@nylorun/studio 0.2.0-rc.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.
- package/LICENSE +192 -0
- package/README.md +22 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +62 -0
- package/dist/host.d.ts +20 -0
- package/dist/host.js +189 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -0
- package/dist/protocol.d.ts +39 -0
- package/dist/protocol.js +1 -0
- package/dist/web/assets/index-B1IsK-Ev.js +64 -0
- package/dist/web/assets/index-B9jULDuO.css +2 -0
- package/dist/web/brand/nylorun-mark.svg +32 -0
- package/dist/web/index.html +14 -0
- package/dist/web/nylo-studio.config.json +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=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,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},ee=Object.prototype.hasOwnProperty;function te(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function ne(e,t){return te(e.type,t,e.props)}function re(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ie(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var ae=/\/+/g;function oe(e,t){return typeof e==`object`&&e&&e.key!=null?ie(``+e.key):t.toString(36)}function se(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function ce(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,ce(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+oe(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(ae,`$&/`)+`/`),ce(o,r,i,``,function(e){return e})):o!=null&&(re(o)&&(o=ne(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(ae,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+oe(a,u),c+=ce(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+oe(a,u++),c+=ce(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return ce(se(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function le(e,t,n){if(e==null)return e;var r=[],i=0;return ce(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ue(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var T=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},de={map:le,forEach:function(e,t,n){le(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return le(e,function(){t++}),t},toArray:function(e){return le(e,function(e){return e})||[]},only:function(e){if(!re(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=de,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!ee.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return te(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)ee.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return te(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=re,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ue}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,T)}catch(e){T(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.8`})),d=o(((e,t)=>{t.exports=u()})),f=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,re());else{var t=n(l);t!==null&&oe(x,t.startTime-e)}}}var S=!1,C=-1,w=5,ee=-1;function te(){return g?!0:!(e.unstable_now()-ee<w)}function ne(){if(g=!1,S){var t=e.unstable_now();ee=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&te());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&oe(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?re():S=!1}}}var re;if(typeof y==`function`)re=function(){y(ne)};else if(typeof MessageChannel<`u`){var ie=new MessageChannel,ae=ie.port2;ie.port1.onmessage=ne,re=function(){ae.postMessage(null)}}else re=function(){_(ne,0)};function oe(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,oe(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,re()))),r},e.unstable_shouldYield=te,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=c(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=c(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=c(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.8`})),h=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function f(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=f(e),t!==null)return t;e=e.sibling}return null}var m=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),ee=Symbol.for(`react.suspense`),te=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),ie=Symbol.for(`react.activity`),ae=Symbol.for(`react.memo_cache_sentinel`),oe=Symbol.iterator;function se(e){return typeof e!=`object`||!e?null:(e=oe&&e[oe]||e[`@@iterator`],typeof e==`function`?e:null)}var ce=Symbol.for(`react.client.reference`);function le(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case ee:return`Suspense`;case te:return`SuspenseList`;case ie:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?le(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return le(e(t))}catch{}}return null}var ue=Array.isArray,T=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,fe={pending:!1,data:null,method:null,action:null},pe=[],me=-1;function he(e){return{current:e}}function ge(e){0>me||(e.current=pe[me],pe[me]=null,me--)}function _e(e,t){me++,pe[me]=e.current,e.current=t}var ve=he(null),ye=he(null),be=he(null),xe=he(null);function Se(e,t){switch(_e(be,t),_e(ye,e),_e(ve,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}ge(ve),_e(ve,e)}function Ce(){ge(ve),ge(ye),ge(be)}function we(e){e.memoizedState!==null&&_e(xe,e);var t=ve.current,n=qd(t,e.type);t!==n&&(_e(ye,e),_e(ve,n))}function Te(e){ye.current===e&&(ge(ve),ge(ye)),xe.current===e&&(ge(xe),np._currentValue=fe)}var Ee,De;function Oe(e){if(Ee===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Ee=t&&t[1]||``,De=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+Ee+e+De}var ke=!1;function Ae(e,t){if(!e||ke)return``;ke=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{ke=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?Oe(n):``}function je(e,t){switch(e.tag){case 26:case 27:case 5:return Oe(e.type);case 16:return Oe(`Lazy`);case 13:return e.child!==t&&t!==null?Oe(`Suspense Fallback`):Oe(`Suspense`);case 19:return Oe(`SuspenseList`);case 0:case 15:return Ae(e.type,!1);case 11:return Ae(e.type.render,!1);case 1:return Ae(e.type,!0);case 31:return Oe(`Activity`);default:return``}}function Me(e){try{var t=``,n=null;do t+=je(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var Ne=Object.prototype.hasOwnProperty,Pe=t.unstable_scheduleCallback,Fe=t.unstable_cancelCallback,Ie=t.unstable_shouldYield,Le=t.unstable_requestPaint,Re=t.unstable_now,ze=t.unstable_getCurrentPriorityLevel,Be=t.unstable_ImmediatePriority,Ve=t.unstable_UserBlockingPriority,He=t.unstable_NormalPriority,Ue=t.unstable_LowPriority,We=t.unstable_IdlePriority,Ge=t.log,Ke=t.unstable_setDisableYieldValue,qe=null,Je=null;function Ye(e){if(typeof Ge==`function`&&Ke(e),Je&&typeof Je.setStrictMode==`function`)try{Je.setStrictMode(qe,e)}catch{}}var Xe=Math.clz32?Math.clz32:$e,Ze=Math.log,Qe=Math.LN2;function $e(e){return e>>>=0,e===0?32:31-(Ze(e)/Qe|0)|0}var et=256,tt=262144,nt=4194304;function rt(e){var t=e&42;if(t!==0)return t;switch(e&-e){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 e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function it(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=rt(n))):i=rt(o):i=rt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=rt(n))):i=rt(o)):i=rt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function at(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function ot(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+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 t+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 st(){var e=nt;return nt<<=1,!(nt&62914560)&&(nt=4194304),e}function ct(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function lt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ut(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Xe(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&dt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function dt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Xe(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ft(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Xe(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function pt(e,t){var n=t&-t;return n=n&42?1:mt(n),(n&(e.suspendedLanes|t))===0?n:0}function mt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=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:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ht(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function gt(){var e=de.p;return e===0?(e=window.event,e===void 0?32:vp(e.type)):e}function _t(e,t){var n=de.p;try{return de.p=e,t()}finally{de.p=n}}var vt=Math.random().toString(36).slice(2),yt=`__reactFiber$`+vt,bt=`__reactProps$`+vt,xt=`__reactContainer$`+vt,St=`__reactEvents$`+vt,Ct=`__reactListeners$`+vt,wt=`__reactHandles$`+vt,Tt=`__reactResources$`+vt,Et=`__reactMarker$`+vt;function Dt(e){delete e[yt],delete e[bt],delete e[St],delete e[Ct],delete e[wt]}function Ot(e){var t=e[yt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[xt]||n[yt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=hf(e);e!==null;){if(n=e[yt])return n;e=hf(e)}return t}e=n,n=e.parentNode}return null}function kt(e){if(e=e[yt]||e[xt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function At(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function jt(e){var t=e[Tt];return t||=e[Tt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Mt(e){e[Et]=!0}var Nt=new Set,Pt={};function Ft(e,t){It(e,t),It(e+`Capture`,t)}function It(e,t){for(Pt[e]=t,e=0;e<t.length;e++)Nt.add(t[e])}var Lt=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]*$`),Rt={},zt={};function Bt(e){return Ne.call(zt,e)?!0:Ne.call(Rt,e)?!1:Lt.test(e)?zt[e]=!0:(Rt[e]=!0,!1)}function Vt(e,t,n){if(Bt(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,``+n)}}}function Ht(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,``+n)}}function Ut(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,``+r)}}function Wt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Gt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Kt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function qt(e){if(!e._valueTracker){var t=Gt(e)?`checked`:`value`;e._valueTracker=Kt(e,t,``+e[t])}}function Jt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Gt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function Yt(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}var Xt=/[\n"\\]/g;function Zt(e){return e.replace(Xt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Qt(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Wt(t)):e.value!==``+Wt(t)&&(e.value=``+Wt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):en(e,o,Wt(n)):en(e,o,Wt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Wt(s):e.removeAttribute(`name`)}function $t(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){qt(e);return}n=n==null?``:``+Wt(n),t=t==null?n:``+Wt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),qt(e)}function en(e,t,n){t===`number`&&Yt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function tn(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Wt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function nn(e,t,n){if(t!=null&&(t=``+Wt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Wt(n)}function rn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(ue(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Wt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),qt(e)}function an(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var on=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 sn(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||on.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function cn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&sn(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&sn(e,o,t[o])}function ln(e){if(e.indexOf(`-`)===-1)return!1;switch(e){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 un=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`],[`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`]]),dn=/^[\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 fn(e){return dn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function pn(){}var mn=null;function hn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var gn=null,_n=null;function vn(e){var t=kt(e);if(t&&(e=t.stateNode)){var n=e[bt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Qt(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+Zt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[bt]||null;if(!a)throw Error(i(90));Qt(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Jt(r)}break a;case`textarea`:nn(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&tn(e,!!n.multiple,t,!1)}}}var yn=!1;function bn(e,t,n){if(yn)return e(t,n);yn=!0;try{return e(t)}finally{if(yn=!1,(gn!==null||_n!==null)&&(ku(),gn&&(t=gn,e=_n,_n=gn=null,vn(t),e)))for(t=0;t<e.length;t++)vn(e[t])}}function xn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[bt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Sn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),Cn=!1;if(Sn)try{var wn={};Object.defineProperty(wn,"passive",{get:function(){Cn=!0}}),window.addEventListener(`test`,wn,wn),window.removeEventListener(`test`,wn,wn)}catch{Cn=!1}var Tn=null,En=null,Dn=null;function On(){if(Dn)return Dn;var e,t=En,n=t.length,r,i=`value`in Tn?Tn.value:Tn.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return Dn=i.slice(e,1<r?1-r:void 0)}function kn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function An(){return!0}function jn(){return!1}function Mn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?An:jn,this.isPropagationStopped=jn,this}return m(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=An)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=An)},persist:function(){},isPersistent:An}),t}var Nn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Pn=Mn(Nn),Fn=m({},Nn,{view:0,detail:0}),In=Mn(Fn),Ln,Rn,zn,Bn=m({},Fn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Zn,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==zn&&(zn&&e.type===`mousemove`?(Ln=e.screenX-zn.screenX,Rn=e.screenY-zn.screenY):Rn=Ln=0,zn=e),Ln)},movementY:function(e){return`movementY`in e?e.movementY:Rn}}),Vn=Mn(Bn),Hn=Mn(m({},Bn,{dataTransfer:0})),Un=Mn(m({},Fn,{relatedTarget:0})),Wn=Mn(m({},Nn,{animationName:0,elapsedTime:0,pseudoElement:0})),Gn=Mn(m({},Nn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Kn=Mn(m({},Nn,{data:0})),qn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Jn={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`},Yn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Xn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Yn[e])?!!t[e]:!1}function Zn(){return Xn}var Qn=Mn(m({},Fn,{key:function(e){if(e.key){var t=qn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=kn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Jn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Zn,charCode:function(e){return e.type===`keypress`?kn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?kn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),$n=Mn(m({},Bn,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),er=Mn(m({},Fn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Zn})),tr=Mn(m({},Nn,{propertyName:0,elapsedTime:0,pseudoElement:0})),nr=Mn(m({},Bn,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),rr=Mn(m({},Nn,{newState:0,oldState:0})),E=[9,13,27,32],ir=Sn&&`CompositionEvent`in window,D=null;Sn&&`documentMode`in document&&(D=document.documentMode);var ar=Sn&&`TextEvent`in window&&!D,or=Sn&&(!ir||D&&8<D&&11>=D),sr=` `,cr=!1;function lr(e,t){switch(e){case`keyup`:return E.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function O(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var ur=!1;function k(e,t){switch(e){case`compositionend`:return O(t);case`keypress`:return t.which===32?(cr=!0,sr):null;case`textInput`:return e=t.data,e===sr&&cr?null:e;default:return null}}function dr(e,t){if(ur)return e===`compositionend`||!ir&&lr(e,t)?(e=On(),Dn=En=Tn=null,ur=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return or&&t.locale!==`ko`?null:t.data;default:return null}}var fr={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 pr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!fr[e.type]:t===`textarea`}function mr(e,t,n,r){gn?_n?_n.push(r):_n=[r]:gn=r,t=Ad(t,`onChange`),0<t.length&&(n=new Pn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var hr=null,gr=null;function A(e){Sd(e,0)}function _r(e){if(Jt(At(e)))return e}function vr(e,t){if(e===`change`)return t}var j=!1;if(Sn){var yr;if(Sn){var br=`oninput`in document;if(!br){var xr=document.createElement(`div`);xr.setAttribute(`oninput`,`return;`),br=typeof xr.oninput==`function`}yr=br}else yr=!1;j=yr&&(!document.documentMode||9<document.documentMode)}function Sr(){hr&&(hr.detachEvent(`onpropertychange`,Cr),gr=hr=null)}function Cr(e){if(e.propertyName===`value`&&_r(gr)){var t=[];mr(t,gr,e,hn(e)),bn(A,t)}}function wr(e,t,n){e===`focusin`?(Sr(),hr=t,gr=n,hr.attachEvent(`onpropertychange`,Cr)):e===`focusout`&&Sr()}function Tr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return _r(gr)}function Er(e,t){if(e===`click`)return _r(t)}function Dr(e,t){if(e===`input`||e===`change`)return _r(t)}function Or(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var kr=typeof Object.is==`function`?Object.is:Or;function Ar(e,t){if(kr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Ne.call(t,i)||!kr(e[i],t[i]))return!1}return!0}function jr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Mr(e,t){var n=jr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=jr(n)}}function Nr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Nr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Pr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Yt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Yt(e.document)}return t}function Fr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ir=Sn&&`documentMode`in document&&11>=document.documentMode,Lr=null,Rr=null,zr=null,Br=!1;function Vr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Br||Lr==null||Lr!==Yt(r)||(r=Lr,`selectionStart`in r&&Fr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),zr&&Ar(zr,r)||(zr=r,r=Ad(Rr,`onSelect`),0<r.length&&(t=new Pn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Lr)))}function Hr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var Ur={animationend:Hr(`Animation`,`AnimationEnd`),animationiteration:Hr(`Animation`,`AnimationIteration`),animationstart:Hr(`Animation`,`AnimationStart`),transitionrun:Hr(`Transition`,`TransitionRun`),transitionstart:Hr(`Transition`,`TransitionStart`),transitioncancel:Hr(`Transition`,`TransitionCancel`),transitionend:Hr(`Transition`,`TransitionEnd`)},Wr={},Gr={};Sn&&(Gr=document.createElement(`div`).style,`AnimationEvent`in window||(delete Ur.animationend.animation,delete Ur.animationiteration.animation,delete Ur.animationstart.animation),`TransitionEvent`in window||delete Ur.transitionend.transition);function Kr(e){if(Wr[e])return Wr[e];if(!Ur[e])return e;var t=Ur[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Gr)return Wr[e]=t[n];return e}var qr=Kr(`animationend`),Jr=Kr(`animationiteration`),Yr=Kr(`animationstart`),Xr=Kr(`transitionrun`),Zr=Kr(`transitionstart`),Qr=Kr(`transitioncancel`),$r=Kr(`transitionend`),ei=new Map,ti=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error 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(` `);ti.push(`scrollEnd`);function ni(e,t){ei.set(e,t),Ft(t,[e])}var ri=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},ii=[],ai=0,oi=0;function si(){for(var e=ai,t=oi=ai=0;t<e;){var n=ii[t];ii[t++]=null;var r=ii[t];ii[t++]=null;var i=ii[t];ii[t++]=null;var a=ii[t];if(ii[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&di(n,i,a)}}function ci(e,t,n,r){ii[ai++]=e,ii[ai++]=t,ii[ai++]=n,ii[ai++]=r,oi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function li(e,t,n,r){return ci(e,t,n,r),fi(e)}function ui(e,t){return ci(e,null,null,t),fi(e)}function di(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Xe(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function fi(e){if(50<bu)throw bu=0,xu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var pi={};function mi(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function hi(e,t,n,r){return new mi(e,t,n,r)}function gi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function _i(e,t){var n=e.alternate;return n===null?(n=hi(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&65011712,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function vi(e,t){e.flags&=65011714;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function yi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)gi(e)&&(s=1);else if(typeof e==`string`)s=qf(e,n,ve.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case ie:return e=hi(31,n,t,a),e.elementType=ie,e.lanes=o,e;case y:return bi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=hi(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case ee:return e=hi(13,n,t,a),e.elementType=ee,e.lanes=o,e;case te:return e=hi(19,n,t,a),e.elementType=te,e.lanes=o,e;default:if(typeof e==`object`&&e)switch(e.$$typeof){case C:s=10;break a;case S:s=9;break a;case w:s=11;break a;case ne:s=14;break a;case re:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=hi(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function bi(e,t,n,r){return e=hi(7,e,r,t),e.lanes=n,e}function xi(e,t,n){return e=hi(6,e,null,t),e.lanes=n,e}function Si(e){var t=hi(18,null,null,0);return t.stateNode=e,t}function Ci(e,t,n){return t=hi(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var wi=new WeakMap;function Ti(e,t){if(typeof e==`object`&&e){var n=wi.get(e);return n===void 0?(t={value:e,source:t,stack:Me(t)},wi.set(e,t),t):n}return{value:e,source:t,stack:Me(t)}}var Ei=[],Di=0,Oi=null,ki=0,Ai=[],M=0,N=null,ji=1,P=``;function Mi(e,t){Ei[Di++]=ki,Ei[Di++]=Oi,Oi=e,ki=t}function Ni(e,t,n){Ai[M++]=ji,Ai[M++]=P,Ai[M++]=N,N=e;var r=ji;e=P;var i=32-Xe(r)-1;r&=~(1<<i),n+=1;var a=32-Xe(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ji=1<<32-Xe(t)+i|n<<i|r,P=a+e}else ji=1<<a|n<<i|r,P=e}function Pi(e){e.return!==null&&(Mi(e,1),Ni(e,1,0))}function Fi(e){for(;e===Oi;)Oi=Ei[--Di],Ei[Di]=null,ki=Ei[--Di],Ei[Di]=null;for(;e===N;)N=Ai[--M],Ai[M]=null,P=Ai[--M],Ai[M]=null,ji=Ai[--M],Ai[M]=null}function Ii(e,t){Ai[M++]=ji,Ai[M++]=P,Ai[M++]=N,ji=t.id,P=t.overflow,N=e}var Li=null,Ri=null,F=!1,zi=null,Bi=!1,Vi=Error(i(519));function Hi(e){throw Ji(Ti(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),Vi}function Ui(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[yt]=e,t[bt]=r,n){case`dialog`:Cd(`cancel`,t),Cd(`close`,t);break;case`iframe`:case`object`:case`embed`:Cd(`load`,t);break;case`video`:case`audio`:for(n=0;n<bd.length;n++)Cd(bd[n],t);break;case`source`:Cd(`error`,t);break;case`img`:case`image`:case`link`:Cd(`error`,t),Cd(`load`,t);break;case`details`:Cd(`toggle`,t);break;case`input`:Cd(`invalid`,t),$t(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Cd(`invalid`,t);break;case`textarea`:Cd(`invalid`,t),rn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||Id(t.textContent,n)?(r.popover!=null&&(Cd(`beforetoggle`,t),Cd(`toggle`,t)),r.onScroll!=null&&Cd(`scroll`,t),r.onScrollEnd!=null&&Cd(`scrollend`,t),r.onClick!=null&&(t.onclick=pn),t=!0):t=!1,t||Hi(e,!0)}function Wi(e){for(Li=e.return;Li;)switch(Li.tag){case 5:case 31:case 13:Bi=!1;return;case 27:case 3:Bi=!0;return;default:Li=Li.return}}function Gi(e){if(e!==Li)return!1;if(!F)return Wi(e),F=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||Jd(e.type,e.memoizedProps)),n=!n),n&&Ri&&Hi(e),Wi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ri=Y(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Ri=Y(e)}else t===27?(t=Ri,nf(e.type)?(e=mf,mf=null,Ri=e):Ri=t):Ri=Li?pf(e.stateNode.nextSibling):null;return!0}function Ki(){Ri=Li=null,F=!1}function qi(){var e=zi;return e!==null&&(ou===null?ou=e:ou.push.apply(ou,e),zi=null),e}function Ji(e){zi===null?zi=[e]:zi.push(e)}var Yi=he(null),Xi=null,Zi=null;function Qi(e,t,n){_e(Yi,t._currentValue),t._currentValue=n}function $i(e){e._currentValue=Yi.current,ge(Yi)}function ea(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function ta(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ea(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ea(s,n,e),s=null}else s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function na(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;kr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===xe.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[np]:e.push(np))}a=a.return}e!==null&&ta(t,e,n,r),t.flags|=262144}function ra(e){for(e=e.firstContext;e!==null;){if(!kr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function ia(e){Xi=e,Zi=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function aa(e){return sa(Xi,e)}function oa(e,t){return Xi===null&&ia(e),sa(e,t)}function sa(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},Zi===null){if(e===null)throw Error(i(308));Zi=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else Zi=Zi.next=t;return n}var ca=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},la=t.unstable_scheduleCallback,ua=t.unstable_NormalPriority,da={$$typeof:C,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function fa(){return{controller:new ca,data:new Map,refCount:0}}function pa(e){e.refCount--,e.refCount===0&&la(ua,function(){e.controller.abort()})}var ma=null,ha=0,ga=0,_a=null;function va(e,t){if(ma===null){var n=ma=[];ha=0,ga=md(),_a={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return ha++,t.then(ya,ya),t}function ya(){if(--ha===0&&ma!==null){_a!==null&&(_a.status=`fulfilled`);var e=ma;ma=null,ga=0,_a=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function ba(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var xa=T.S;T.S=function(e,t){lu=Re(),typeof t==`object`&&t&&typeof t.then==`function`&&va(e,t),xa!==null&&xa(e,t)};var Sa=he(null);function I(){var e=Sa.current;return e===null?Gl.pooledCache:e}function Ca(e,t){t===null?_e(Sa,Sa.current):_e(Sa,t.pool)}function wa(){var e=I();return e===null?null:{parent:da._currentValue,pool:e}}var Ta=Error(i(460)),Ea=Error(i(474)),Da=Error(i(542)),Oa={then:function(){}};function ka(e){return e=e.status,e===`fulfilled`||e===`rejected`}function Aa(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(pn,pn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Pa(e),e;default:if(typeof t.status==`string`)t.then(pn,pn);else{if(e=Gl,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Pa(e),e}throw Ma=t,Ta}}function ja(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Ma=e,Ta):e}}var Ma=null;function Na(){if(Ma===null)throw Error(i(459));var e=Ma;return Ma=null,e}function Pa(e){if(e===Ta||e===Da)throw Error(i(483))}var Fa=null,Ia=0;function La(e){var t=Ia;return Ia+=1,Fa===null&&(Fa=[]),Aa(Fa,e,t)}function Ra(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function za(e,t){throw t.$$typeof===g?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function Ba(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=_i(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=67108866,n):(r=r.index,r<n?(t.flags|=67108866,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=67108866),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=xi(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===y?d(e,t,n.props.children,r,n.key):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===re&&ja(i)===t.type)?(t=a(t,n.props),Ra(t,n),t.return=e,t):(t=yi(n.type,n.key,n.props,null,e.mode,r),Ra(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Ci(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=bi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=xi(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=yi(t.type,t.key,t.props,null,e.mode,n),Ra(n,t),n.return=e,n;case v:return t=Ci(t,e.mode,n),t.return=e,t;case re:return t=ja(t),f(e,t,n)}if(ue(t)||se(t))return t=bi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,La(t),n);if(t.$$typeof===C)return f(e,oa(e,t),n);za(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case _:return n.key===i?l(e,t,n,r):null;case v:return n.key===i?u(e,t,n,r):null;case re:return n=ja(n),p(e,t,n,r)}if(ue(n)||se(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,La(n),r);if(n.$$typeof===C)return p(e,t,oa(e,n),r);za(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case _:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case v:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case re:return r=ja(r),m(e,t,n,r,i)}if(ue(r)||se(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,La(r),i);if(r.$$typeof===C)return m(e,t,n,oa(t,r),i);za(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),F&&Mi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return F&&Mi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&g.alternate!==null&&d.delete(g.key===null?h:g.key),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),F&&Mi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),F&&Mi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return F&&Mi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),F&&Mi(a,g),u}function b(e,r,o,c){if(typeof o==`object`&&o&&o.type===y&&o.key===null&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case _:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===y){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&ja(l)===r.type){n(e,r.sibling),c=a(r,o.props),Ra(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===y?(c=bi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=yi(o.type,o.key,o.props,null,e.mode,c),Ra(c,o),c.return=e,e=c)}return s(e);case v:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ci(o,e.mode,c),c.return=e,e=c}return s(e);case re:return o=ja(o),b(e,r,o,c)}if(ue(o))return h(e,r,o,c);if(se(o)){if(l=se(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return b(e,r,La(o),c);if(o.$$typeof===C)return b(e,r,oa(e,o),c);za(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=xi(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Ia=0;var i=b(e,t,n,r);return Fa=null,i}catch(t){if(t===Ta||t===Da)throw t;var a=hi(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Va=Ba(!0),Ha=Ba(!1),Ua=!1;function Wa(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ga(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ka(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function qa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Wl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=fi(e),di(e,null,n),t}return ci(e,r,t,n),fi(e)}function Ja(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}function Ya(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var Xa=!1;function Za(){if(Xa){var e=_a;if(e!==null)throw e}}function Qa(e,t,n,r){Xa=!1;var i=e.updateQueue;Ua=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(ql&f)===f:(r&f)===f){f!==0&&f===ga&&(Xa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Ua=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),eu|=o,e.lanes=o,e.memoizedState=d}}function $a(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function eo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)$a(n[e],t)}var to=he(null),no=he(0);function ro(e,t){e=Ql,_e(no,e),_e(to,t),Ql=e|t.baseLanes}function io(){_e(no,Ql),_e(to,to.current)}function ao(){Ql=no.current,ge(to),ge(no)}var oo=he(null),so=null;function co(e){var t=e.alternate;_e(mo,mo.current&1),_e(oo,e),so===null&&(t===null||to.current!==null||t.memoizedState!==null)&&(so=e)}function lo(e){_e(mo,mo.current),_e(oo,e),so===null&&(so=e)}function uo(e){e.tag===22?(_e(mo,mo.current),_e(oo,e),so===null&&(so=e)):fo(e)}function fo(){_e(mo,mo.current),_e(oo,oo.current)}function po(e){ge(oo),so===e&&(so=null),ge(mo)}var mo=he(0);function ho(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||uf(n)||df(n)))return t}else if(t.tag===19&&(t.memoizedProps.revealOrder===`forwards`||t.memoizedProps.revealOrder===`backwards`||t.memoizedProps.revealOrder===`unstable_legacy-backwards`||t.memoizedProps.revealOrder===`together`)){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var go=0,L=null,_o=null,vo=null,yo=!1,bo=!1,xo=!1,So=0,Co=0,wo=null,To=0;function Eo(){throw Error(i(321))}function Do(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!kr(e[n],t[n]))return!1;return!0}function Oo(e,t,n,r,i,a){return go=a,L=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,T.H=e===null||e.memoizedState===null?Gs:Ks,xo=!1,a=n(r,i),xo=!1,bo&&(a=Ao(t,n,r,i)),ko(e),a}function ko(e){T.H=Ws;var t=_o!==null&&_o.next!==null;if(go=0,vo=_o=L=null,yo=!1,Co=0,wo=null,t)throw Error(i(300));e===null||lc||(e=e.dependencies,e!==null&&ra(e)&&(lc=!0))}function Ao(e,t,n,r){L=e;var a=0;do{if(bo&&(wo=null),Co=0,bo=!1,25<=a)throw Error(i(301));if(a+=1,vo=_o=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}T.H=qs,o=t(n,r)}while(bo);return o}function jo(){var e=T.H,t=e.useState()[0];return t=typeof t.then==`function`?Ro(t):t,e=e.useState()[0],(_o===null?null:_o.memoizedState)!==e&&(L.flags|=1024),t}function Mo(){var e=So!==0;return So=0,e}function No(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Po(e){if(yo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}yo=!1}go=0,vo=_o=L=null,bo=!1,Co=So=0,wo=null}function Fo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vo===null?L.memoizedState=vo=e:vo=vo.next=e,vo}function Io(){if(_o===null){var e=L.alternate;e=e===null?null:e.memoizedState}else e=_o.next;var t=vo===null?L.memoizedState:vo.next;if(t!==null)vo=t,_o=e;else{if(e===null)throw L.alternate===null?Error(i(467)):Error(i(310));_o=e,e={memoizedState:_o.memoizedState,baseState:_o.baseState,baseQueue:_o.baseQueue,queue:_o.queue,next:null},vo===null?L.memoizedState=vo=e:vo=vo.next=e}return vo}function Lo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Ro(e){var t=Co;return Co+=1,wo===null&&(wo=[]),e=Aa(wo,e,t),t=L,(vo===null?t.memoizedState:vo.next)===null&&(t=t.alternate,T.H=t===null||t.memoizedState===null?Gs:Ks),e}function zo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Ro(e);if(e.$$typeof===C)return aa(e)}throw Error(i(438,String(e)))}function Bo(e){var t=null,n=L.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=L.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=Lo(),L.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=ae;return t.index++,n}function Vo(e,t){return typeof t==`function`?t(e):t}function Ho(e){return Uo(Io(),_o,e)}function Uo(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(go&f)===f:(ql&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===ga&&(d=!0);else if((go&p)===p){u=u.next,p===ga&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,L.lanes|=p,eu|=p;f=u.action,xo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,L.lanes|=f,eu|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!kr(o,e.memoizedState)&&(lc=!0,d&&(n=_a,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function Wo(e){var t=Io(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);kr(o,t.memoizedState)||(lc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function Go(e,t,n){var r=L,a=Io(),o=F;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!kr((_o||a).memoizedState,n);if(s&&(a.memoizedState=n,lc=!0),a=a.queue,gs(Jo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||vo!==null&&vo.memoizedState.tag&1){if(r.flags|=2048,ds(9,{destroy:void 0},qo.bind(null,r,a,n,t),null),Gl===null)throw Error(i(349));o||go&127||Ko(r,t,n)}return n}function Ko(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=L.updateQueue,t===null?(t=Lo(),L.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function qo(e,t,n,r){t.value=n,t.getSnapshot=r,Yo(t)&&Xo(e)}function Jo(e,t,n){return n(function(){Yo(t)&&Xo(e)})}function Yo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!kr(e,n)}catch{return!0}}function Xo(e){var t=ui(e,2);t!==null&&wu(t,e,2)}function Zo(e){var t=Fo();if(typeof e==`function`){var n=e;if(e=n(),xo){Ye(!0);try{n()}finally{Ye(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vo,lastRenderedState:e},t}function Qo(e,t,n,r){return e.baseState=n,Uo(e,_o,typeof r==`function`?r:Vo)}function $o(e,t,n,r,a){if(Vs(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};T.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,es(t,o)):(o.next=n.next,t.pending=n.next=o)}}function es(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=T.T,o={};T.T=o;try{var s=n(i,r),c=T.S;c!==null&&c(o,s),ts(e,t,s)}catch(n){rs(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),T.T=a}}else try{a=n(i,r),ts(e,t,a)}catch(n){rs(e,t,n)}}function ts(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){ns(e,t,n)},function(n){return rs(e,t,n)}):ns(e,t,n)}function ns(e,t,n){t.status=`fulfilled`,t.value=n,is(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,es(e,n)))}function rs(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,is(t),t=t.next;while(t!==r)}e.action=null}function is(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function as(e,t){return t}function os(e,t){if(F){var n=Gl.formState;if(n!==null){a:{var r=L;if(F){if(Ri){b:{for(var i=Ri,a=Bi;i.nodeType!==8;){if(!a){i=null;break b}if(i=pf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Ri=pf(i.nextSibling),r=i.data===`F!`;break a}}Hi(r)}r=!1}r&&(t=n[0])}}return n=Fo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:as,lastRenderedState:t},n.queue=r,n=Rs.bind(null,L,r),r.dispatch=n,r=Zo(!1),a=Bs.bind(null,L,!1,r.queue),r=Fo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=$o.bind(null,L,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ss(e){return cs(Io(),_o,e)}function cs(e,t,n){if(t=Uo(e,t,as)[0],e=Ho(Vo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Ro(t)}catch(e){throw e===Ta?Da:e}else r=t;t=Io();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(L.flags|=2048,ds(9,{destroy:void 0},ls.bind(null,i,n),null)),[r,a,e]}function ls(e,t){e.action=t}function us(e){var t=Io(),n=_o;if(n!==null)return cs(t,n,e);Io(),t=t.memoizedState,n=Io();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ds(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=L.updateQueue,t===null&&(t=Lo(),L.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function fs(){return Io().memoizedState}function ps(e,t,n,r){var i=Fo();L.flags|=e,i.memoizedState=ds(1|t,{destroy:void 0},n,r===void 0?null:r)}function ms(e,t,n,r){var i=Io();r=r===void 0?null:r;var a=i.memoizedState.inst;_o!==null&&r!==null&&Do(r,_o.memoizedState.deps)?i.memoizedState=ds(t,a,n,r):(L.flags|=e,i.memoizedState=ds(1|t,a,n,r))}function hs(e,t){ps(8390656,8,e,t)}function gs(e,t){ms(2048,8,e,t)}function _s(e){L.flags|=4;var t=L.updateQueue;if(t===null)t=Lo(),L.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function vs(e){var t=Io().memoizedState;return _s({ref:t,nextImpl:e}),function(){if(Wl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function ys(e,t){return ms(4,2,e,t)}function bs(e,t){return ms(4,4,e,t)}function xs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Ss(e,t,n){n=n==null?null:n.concat([e]),ms(4,4,xs.bind(null,t,e),n)}function Cs(){}function ws(e,t){var n=Io();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&Do(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ts(e,t){var n=Io();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&Do(t,r[1]))return r[0];if(r=e(),xo){Ye(!0);try{e()}finally{Ye(!1)}}return n.memoizedState=[r,t],r}function Es(e,t,n){return n===void 0||go&1073741824&&!(ql&261930)?e.memoizedState=t:(e.memoizedState=n,e=Cu(),L.lanes|=e,eu|=e,n)}function Ds(e,t,n,r){return kr(n,t)?n:to.current===null?!(go&42)||go&1073741824&&!(ql&261930)?(lc=!0,e.memoizedState=n):(e=Cu(),L.lanes|=e,eu|=e,t):(e=Es(e,n,r),kr(e,t)||(lc=!0),e)}function Os(e,t,n,r,i){var a=de.p;de.p=a!==0&&8>a?a:8;var o=T.T,s={};T.T=s,Bs(e,!1,t,n);try{var c=i(),l=T.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?zs(e,t,ba(c,r),Su(e)):zs(e,t,r,Su(e))}catch(n){zs(e,t,{then:function(){},status:`rejected`,reason:n},Su())}finally{de.p=a,o!==null&&s.types!==null&&(o.types=s.types),T.T=o}}function ks(){}function As(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=js(e).queue;Os(e,a,t,fe,n===null?ks:function(){return Ms(e),n(r)})}function js(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:fe,baseState:fe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vo,lastRenderedState:fe},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Vo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ms(e){var t=js(e);t.next===null&&(t=e.alternate.memoizedState),zs(e,t.next.queue,{},Su())}function Ns(){return aa(np)}function Ps(){return Io().memoizedState}function Fs(){return Io().memoizedState}function Is(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Su();e=Ka(n);var r=qa(t,e,n);r!==null&&(wu(r,t,n),Ja(r,t,n)),t={cache:fa()},e.payload=t;return}t=t.return}}function Ls(e,t,n){var r=Su();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Vs(e)?Hs(t,n):(n=li(e,t,n,r),n!==null&&(wu(n,e,r),Us(n,t,r)))}function Rs(e,t,n){zs(e,t,n,Su())}function zs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vs(e))Hs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,kr(s,o))return ci(e,t,i,0),Gl===null&&si(),!1}catch{}if(n=li(e,t,i,r),n!==null)return wu(n,e,r),Us(n,t,r),!0}return!1}function Bs(e,t,n,r){if(r={lane:2,revertLane:md(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Vs(e)){if(t)throw Error(i(479))}else t=li(e,n,r,2),t!==null&&wu(t,e,2)}function Vs(e){var t=e.alternate;return e===L||t!==null&&t===L}function Hs(e,t){bo=yo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Us(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}var Ws={readContext:aa,use:zo,useCallback:Eo,useContext:Eo,useEffect:Eo,useImperativeHandle:Eo,useLayoutEffect:Eo,useInsertionEffect:Eo,useMemo:Eo,useReducer:Eo,useRef:Eo,useState:Eo,useDebugValue:Eo,useDeferredValue:Eo,useTransition:Eo,useSyncExternalStore:Eo,useId:Eo,useHostTransitionStatus:Eo,useFormState:Eo,useActionState:Eo,useOptimistic:Eo,useMemoCache:Eo,useCacheRefresh:Eo};Ws.useEffectEvent=Eo;var Gs={readContext:aa,use:zo,useCallback:function(e,t){return Fo().memoizedState=[e,t===void 0?null:t],e},useContext:aa,useEffect:hs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ps(4194308,4,xs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ps(4194308,4,e,t)},useInsertionEffect:function(e,t){ps(4,2,e,t)},useMemo:function(e,t){var n=Fo();t=t===void 0?null:t;var r=e();if(xo){Ye(!0);try{e()}finally{Ye(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Fo();if(n!==void 0){var i=n(t);if(xo){Ye(!0);try{n(t)}finally{Ye(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ls.bind(null,L,e),[r.memoizedState,e]},useRef:function(e){var t=Fo();return e={current:e},t.memoizedState=e},useState:function(e){e=Zo(e);var t=e.queue,n=Rs.bind(null,L,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Cs,useDeferredValue:function(e,t){return Es(Fo(),e,t)},useTransition:function(){var e=Zo(!1);return e=Os.bind(null,L,e.queue,!0,!1),Fo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=L,a=Fo();if(F){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Gl===null)throw Error(i(349));ql&127||Ko(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,hs(Jo.bind(null,r,o,e),[e]),r.flags|=2048,ds(9,{destroy:void 0},qo.bind(null,r,o,n,t),null),n},useId:function(){var e=Fo(),t=Gl.identifierPrefix;if(F){var n=P,r=ji;n=(r&~(1<<32-Xe(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=So++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=To++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Ns,useFormState:os,useActionState:os,useOptimistic:function(e){var t=Fo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Bs.bind(null,L,!0,n),n.dispatch=t,[e,t]},useMemoCache:Bo,useCacheRefresh:function(){return Fo().memoizedState=Is.bind(null,L)},useEffectEvent:function(e){var t=Fo(),n={impl:e};return t.memoizedState=n,function(){if(Wl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Ks={readContext:aa,use:zo,useCallback:ws,useContext:aa,useEffect:gs,useImperativeHandle:Ss,useInsertionEffect:ys,useLayoutEffect:bs,useMemo:Ts,useReducer:Ho,useRef:fs,useState:function(){return Ho(Vo)},useDebugValue:Cs,useDeferredValue:function(e,t){return Ds(Io(),_o.memoizedState,e,t)},useTransition:function(){var e=Ho(Vo)[0],t=Io().memoizedState;return[typeof e==`boolean`?e:Ro(e),t]},useSyncExternalStore:Go,useId:Ps,useHostTransitionStatus:Ns,useFormState:ss,useActionState:ss,useOptimistic:function(e,t){return Qo(Io(),_o,e,t)},useMemoCache:Bo,useCacheRefresh:Fs};Ks.useEffectEvent=vs;var qs={readContext:aa,use:zo,useCallback:ws,useContext:aa,useEffect:gs,useImperativeHandle:Ss,useInsertionEffect:ys,useLayoutEffect:bs,useMemo:Ts,useReducer:Wo,useRef:fs,useState:function(){return Wo(Vo)},useDebugValue:Cs,useDeferredValue:function(e,t){var n=Io();return _o===null?Es(n,e,t):Ds(n,_o.memoizedState,e,t)},useTransition:function(){var e=Wo(Vo)[0],t=Io().memoizedState;return[typeof e==`boolean`?e:Ro(e),t]},useSyncExternalStore:Go,useId:Ps,useHostTransitionStatus:Ns,useFormState:us,useActionState:us,useOptimistic:function(e,t){var n=Io();return _o===null?(n.baseState=e,[e,n.queue.dispatch]):Qo(n,_o,e,t)},useMemoCache:Bo,useCacheRefresh:Fs};qs.useEffectEvent=vs;function Js(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:m({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ys={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Su(),i=Ka(r);i.payload=t,n!=null&&(i.callback=n),t=qa(e,i,r),t!==null&&(wu(t,e,r),Ja(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Su(),i=Ka(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=qa(e,i,r),t!==null&&(wu(t,e,r),Ja(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Su(),r=Ka(n);r.tag=2,t!=null&&(r.callback=t),t=qa(e,r,n),t!==null&&(wu(t,e,n),Ja(t,e,n))}};function Xs(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Ar(n,r)||!Ar(i,a):!0}function Zs(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Ys.enqueueReplaceState(t,t.state,null)}function Qs(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=m({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function $s(e){ri(e)}function ec(e){console.error(e)}function tc(e){ri(e)}function nc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function rc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function ic(e,t,n){return n=Ka(n),n.tag=3,n.payload={element:null},n.callback=function(){nc(e,t)},n}function ac(e){return e=Ka(e),e.tag=3,e}function oc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){rc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){rc(t,n,r),typeof i!=`function`&&(fu===null?fu=new Set([this]):fu.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function sc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&na(t,n,a,!0),n=oo.current,n!==null){switch(n.tag){case 31:case 13:return so===null?Iu():n.alternate===null&&$l===0&&($l=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Oa?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Xu(e,r,a)),!1;case 22:return n.flags|=65536,r===Oa?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Xu(e,r,a)),!1}throw Error(i(435,n.tag))}return Xu(e,r,a),Iu(),!1}if(F)return t=oo.current,t===null?(r!==Vi&&(t=Error(i(423),{cause:r}),Ji(Ti(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Ti(r,n),a=ic(e.stateNode,r,a),Ya(e,a),$l!==4&&($l=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Vi&&(e=Error(i(422),{cause:r}),Ji(Ti(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Ti(o,n),au===null?au=[o]:au.push(o),$l!==4&&($l=2),t===null)return!0;r=Ti(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=ic(n.stateNode,r,e),Ya(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(fu===null||!fu.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=ac(a),oc(a,e,n,r),Ya(n,a),!1}n=n.return}while(n!==null);return!1}var cc=Error(i(461)),lc=!1;function uc(e,t,n,r){t.child=e===null?Ha(t,null,n,r):Va(t,e.child,n,r)}function dc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return ia(t),r=Oo(e,t,n,o,a,i),s=Mo(),e!==null&&!lc?(No(e,t,i),Fc(e,t,i)):(F&&s&&Pi(t),t.flags|=1,uc(e,t,r,i),t.child)}function fc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!gi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,pc(e,t,a,r,i)):(e=yi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Ic(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Ar:n,n(o,r)&&e.ref===t.ref)return Fc(e,t,i)}return t.flags|=1,e=_i(a,r),e.ref=t.ref,e.return=t,t.child=e}function pc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Ar(a,r)&&e.ref===t.ref){if(lc=!1,t.pendingProps=r=a,Ic(e,i))e.flags&131072&&(lc=!0);else return t.lanes=e.lanes,Fc(e,t,i)}}return xc(e,t,n,r,i)}function mc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return gc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ca(t,a===null?null:a.cachePool),a===null?io():ro(t,a),uo(t);else return r=t.lanes=536870912,gc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ca(t,null),io(),fo(t)):(Ca(t,a.cachePool),ro(t,a),fo(t),t.memoizedState=null);return uc(e,t,i,n),t.child}function hc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function gc(e,t,n,r,i){var a=I();return a=a===null?null:{parent:da._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ca(t,null),io(),uo(t),e!==null&&na(e,t,r,!0),t.childLanes=i,null}function _c(e,t){return t=Ac({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function vc(e,t,n){return Va(t,e.child,null,n),e=_c(t,t.pendingProps),e.flags|=2,po(t),t.memoizedState=null,e}function yc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(F){if(r.mode===`hidden`)return e=_c(t,r),t.lanes=536870912,hc(null,e);if(lo(t),(e=Ri)?(e=lf(e,Bi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:N===null?null:{id:ji,overflow:P},retryLane:536870912,hydrationErrors:null},n=Si(e),n.return=t,t.child=n,Li=t,Ri=null)):e=null,e===null)throw Hi(t);return t.lanes=536870912,null}return _c(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(lo(t),a){if(t.flags&256)t.flags&=-257,t=vc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(lc||na(e,t,n,!1),a=(n&e.childLanes)!==0,lc||a){if(r=Gl,r!==null&&(s=pt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,ui(e,s),wu(r,e,s),cc;Iu(),t=vc(e,t,n)}else e=o.treeContext,Ri=pf(s.nextSibling),Li=t,F=!0,zi=null,Bi=!1,e!==null&&Ii(t,e),t=_c(t,r),t.flags|=4096;return t}return e=_i(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function bc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function xc(e,t,n,r,i){return ia(t),n=Oo(e,t,n,r,void 0,i),r=Mo(),e!==null&&!lc?(No(e,t,i),Fc(e,t,i)):(F&&r&&Pi(t),t.flags|=1,uc(e,t,n,i),t.child)}function Sc(e,t,n,r,i,a){return ia(t),t.updateQueue=null,n=Ao(t,r,n,i),ko(e),r=Mo(),e!==null&&!lc?(No(e,t,a),Fc(e,t,a)):(F&&r&&Pi(t),t.flags|=1,uc(e,t,n,a),t.child)}function Cc(e,t,n,r,i){if(ia(t),t.stateNode===null){var a=pi,o=n.contextType;typeof o==`object`&&o&&(a=aa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=Ys,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Wa(t),o=n.contextType,a.context=typeof o==`object`&&o?aa(o):pi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Js(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&Ys.enqueueReplaceState(a,a.state,null),Qa(t,r,a,i),Za(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=Qs(n,s);a.props=c;var l=a.context,u=n.contextType;o=pi,typeof u==`object`&&u&&(o=aa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Zs(t,a,r,o),Ua=!1;var f=t.memoizedState;a.state=f,Qa(t,r,a,i),Za(),l=t.memoizedState,s||f!==l||Ua?(typeof d==`function`&&(Js(t,n,d,r),l=t.memoizedState),(c=Ua||Xs(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,Ga(e,t),o=t.memoizedProps,u=Qs(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=pi,typeof l==`object`&&l&&(c=aa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Zs(t,a,r,c),Ua=!1,f=t.memoizedState,a.state=f,Qa(t,r,a,i),Za();var p=t.memoizedState;o!==d||f!==p||Ua||e!==null&&e.dependencies!==null&&ra(e.dependencies)?(typeof s==`function`&&(Js(t,n,s,r),p=t.memoizedState),(u=Ua||Xs(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&ra(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,bc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=Va(t,e.child,null,i),t.child=Va(t,null,n,i)):uc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Fc(e,t,i),e}function wc(e,t,n,r){return Ki(),t.flags|=256,uc(e,t,n,r),t.child}var Tc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ec(e){return{baseLanes:e,cachePool:wa()}}function Dc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=ru),e}function Oc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(mo.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(F){if(a?co(t):fo(t),(e=Ri)?(e=lf(e,Bi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:N===null?null:{id:ji,overflow:P},retryLane:536870912,hydrationErrors:null},n=Si(e),n.return=t,t.child=n,Li=t,Ri=null)):e=null,e===null)throw Hi(t);return df(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(fo(t),a=t.mode,c=Ac({mode:`hidden`,children:c},a),r=bi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Ec(n),r.childLanes=Dc(e,s,n),t.memoizedState=Tc,hc(null,r)):(co(t),kc(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(co(t),t.flags&=-257,t=jc(e,t,n)):t.memoizedState===null?(fo(t),c=r.fallback,a=t.mode,r=Ac({mode:`visible`,children:r.children},a),c=bi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Va(t,e.child,null,n),r=t.child,r.memoizedState=Ec(n),r.childLanes=Dc(e,s,n),t.memoizedState=Tc,t=hc(null,r)):(fo(t),t.child=e.child,t.flags|=128,t=null);else if(co(t),df(c)){if(s=c.nextSibling&&c.nextSibling.dataset,s)var u=s.dgst;s=u,r=Error(i(419)),r.stack=``,r.digest=s,Ji({value:r,source:null,stack:null}),t=jc(e,t,n)}else if(lc||na(e,t,n,!1),s=(n&e.childLanes)!==0,lc||s){if(s=Gl,s!==null&&(r=pt(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,ui(e,r),wu(s,e,r),cc;uf(c)||Iu(),t=jc(e,t,n)}else uf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Ri=pf(c.nextSibling),Li=t,F=!0,zi=null,Bi=!1,e!==null&&Ii(t,e),t=kc(t,r.children),t.flags|=4096);return t}return a?(fo(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=_i(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=bi(c,a,n,null),c.flags|=2):c=_i(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,hc(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Ec(n):(a=c.cachePool,a===null?a=wa():(l=da._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=Dc(e,s,n),t.memoizedState=Tc,hc(e.child,r)):(co(t),n=e.child,e=n.sibling,n=_i(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(s=t.deletions,s===null?(t.deletions=[e],t.flags|=16):s.push(e)),t.child=n,t.memoizedState=null,n)}function kc(e,t){return t=Ac({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function Ac(e,t){return e=hi(22,e,null,t),e.lanes=0,e}function jc(e,t,n){return Va(t,e.child,null,n),e=kc(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Mc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ea(e.return,t,n)}function Nc(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function Pc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=mo.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,_e(mo,o),uc(e,t,r,n),r=F?ki:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Mc(e,n,t);else if(e.tag===19)Mc(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`forwards`:for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ho(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Nc(t,!1,i,n,a,r);break;case`backwards`:case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ho(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Nc(t,!0,n,null,a,r);break;case`together`:Nc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Fc(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),eu|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(na(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=_i(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=_i(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Ic(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ra(e)))}function Lc(e,t,n){switch(t.tag){case 3:Se(t,t.stateNode.containerInfo),Qi(t,da,e.memoizedState.cache),Ki();break;case 27:case 5:we(t);break;case 4:Se(t,t.stateNode.containerInfo);break;case 10:Qi(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,lo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(co(t),e=Fc(e,t,n),e===null?null:e.sibling):Oc(e,t,n):(co(t),t.flags|=128,null);co(t);break;case 19:var i=!!(e.flags&128);if(r=(n&t.childLanes)!==0,r||=(na(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return Pc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),_e(mo,mo.current),r)break;return null;case 22:return t.lanes=0,mc(e,t,n,t.pendingProps);case 24:Qi(t,da,e.memoizedState.cache)}return Fc(e,t,n)}function Rc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)lc=!0;else{if(!Ic(e,n)&&!(t.flags&128))return lc=!1,Lc(e,t,n);lc=!!(e.flags&131072)}}else lc=!1,F&&t.flags&1048576&&Ni(t,ki,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=ja(t.elementType),t.type=e,typeof e==`function`)gi(e)?(r=Qs(e,r),t.tag=1,t=Cc(null,t,e,r,n)):(t.tag=0,t=xc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=dc(null,t,e,r,n);break a}if(a===ne){t.tag=14,t=fc(null,t,e,r,n);break a}}throw t=le(e)||e,Error(i(306,t,``))}}return t;case 0:return xc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=Qs(r,t.pendingProps),Cc(e,t,r,a,n);case 3:a:{if(Se(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ga(e,t),Qa(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Qi(t,da,r),r!==o.cache&&ta(t,[da],n,!0),Za(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=wc(e,t,r,n);break a}if(r!==a){a=Ti(Error(i(424)),t),Ji(a),t=wc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(Ri=pf(e.firstChild),Li=t,F=!0,zi=null,Bi=!0,n=Ha(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ki(),r===a){t=Fc(e,t,n);break a}uc(e,t,r,n)}t=t.child}return t;case 26:return bc(e,t),e===null?(n=Nf(t.type,null,t.pendingProps,null))?t.memoizedState=n:F||(n=t.type,e=t.pendingProps,r=Gd(be.current).createElement(n),r[yt]=t,r[bt]=e,zd(r,n,e),Mt(r),t.stateNode=r):t.memoizedState=Nf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return we(t),e===null&&F&&(r=t.stateNode=gf(t.type,t.pendingProps,be.current),Li=t,Bi=!0,a=Ri,nf(t.type)?(mf=a,Ri=pf(r.firstChild)):Ri=a),uc(e,t,t.pendingProps.children,n),bc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&F&&((a=r=Ri)&&(r=sf(r,t.type,t.pendingProps,Bi),r===null?a=!1:(t.stateNode=r,Li=t,Ri=pf(r.firstChild),Bi=!1,a=!0)),a||Hi(t)),we(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,Jd(a,o)?r=null:s!==null&&Jd(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Oo(e,t,jo,null,null,n),np._currentValue=a),bc(e,t),uc(e,t,r,n),t.child;case 6:return e===null&&F&&((e=n=Ri)&&(n=cf(n,t.pendingProps,Bi),n===null?e=!1:(t.stateNode=n,Li=t,Ri=null,e=!0)),e||Hi(t)),null;case 13:return Oc(e,t,n);case 4:return Se(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Va(t,null,r,n):uc(e,t,r,n),t.child;case 11:return dc(e,t,t.type,t.pendingProps,n);case 7:return uc(e,t,t.pendingProps,n),t.child;case 8:return uc(e,t,t.pendingProps.children,n),t.child;case 12:return uc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Qi(t,t.type,r.value),uc(e,t,r.children,n),t.child;case 9:return a=t.type._context,r=t.pendingProps.children,ia(t),a=aa(a),r=r(a),t.flags|=1,uc(e,t,r,n),t.child;case 14:return fc(e,t,t.type,t.pendingProps,n);case 15:return pc(e,t,t.type,t.pendingProps,n);case 19:return Pc(e,t,n);case 31:return yc(e,t,n);case 22:return mc(e,t,n,t.pendingProps);case 24:return ia(t),r=aa(da),e===null?(a=I(),a===null&&(a=Gl,o=fa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Wa(t),Qi(t,da,a)):((e.lanes&n)!==0&&(Ga(e,t),Qa(t,null,null,n),Za()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,Qi(t,da,r),r!==a.cache&&ta(t,[da],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),Qi(t,da,r))),uc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function zc(e){e.flags|=4}function Bc(e,t,n,r,i){if((t=!!(e.mode&32))&&(t=!1),t){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Nu())e.flags|=8192;else throw Ma=Oa,Ea}}else e.flags&=-16777217}function Vc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!Jf(t)){if(Nu())e.flags|=8192;else throw Ma=Oa,Ea}}function Hc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:st(),e.lanes|=t,iu|=t)}function Uc(e,t){if(!F)switch(e.tailMode){case`hidden`:t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case`collapsed`:n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Wc(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&65011712,r|=i.flags&65011712,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function Gc(e,t,n){var r=t.pendingProps;switch(Fi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Wc(t),null;case 1:return Wc(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),$i(da),Ce(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Gi(t)?zc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,qi())),Wc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(zc(t),o===null?(Wc(t),Bc(t,a,null,r,n)):(Wc(t),Vc(t,o))):o?o===e.memoizedState?(Wc(t),t.flags&=-16777217):(zc(t),Wc(t),Vc(t,o)):(e=e.memoizedProps,e!==r&&zc(t),Wc(t),Bc(t,a,e,r,n)),null;case 27:if(Te(t),n=be.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Wc(t),null}e=ve.current,Gi(t)?Ui(t,e):(e=gf(a,r,n),t.stateNode=e,zc(t))}return Wc(t),null;case 5:if(Te(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Wc(t),null}if(o=ve.current,Gi(t))Ui(t,o);else{var s=Gd(be.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[yt]=t,o[bt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(zd(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&zc(t)}}return Wc(t),Bc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&zc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=be.current,Gi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Li,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[yt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Id(e.nodeValue,n)),e||Hi(t,!0)}else e=Gd(e).createTextNode(r),e[yt]=t,t.stateNode=e}return Wc(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Gi(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[yt]=t}else Ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Wc(t),e=!1}else n=qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(po(t),t):(po(t),null);if(t.flags&128)throw Error(i(558))}return Wc(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=Gi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[yt]=t}else Ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Wc(t),a=!1}else a=qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(po(t),t):(po(t),null)}return po(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Hc(t,t.updateQueue),Wc(t),null);case 4:return Ce(),e===null&&Ed(t.stateNode.containerInfo),Wc(t),null;case 10:return $i(t.type),Wc(t),null;case 19:if(ge(mo),r=t.memoizedState,r===null)return Wc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Uc(r,!1);else{if($l!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=ho(e),o!==null){for(t.flags|=128,Uc(r,!1),e=o.updateQueue,t.updateQueue=e,Hc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)vi(n,e),n=n.sibling;return _e(mo,mo.current&1|2),F&&Mi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Re()>uu&&(t.flags|=128,a=!0,Uc(r,!1),t.lanes=4194304)}}else{if(!a){if(e=ho(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Hc(t,e),Uc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!F)return Wc(t),null}else 2*Re()-r.renderingStartTime>uu&&n!==536870912&&(t.flags|=128,a=!0,Uc(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}return r.tail===null?(Wc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Re(),e.sibling=null,n=mo.current,_e(mo,a?n&1|2:n&1),F&&Mi(t,r.treeForkCount),e);case 22:case 23:return po(t),ao(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Wc(t),t.subtreeFlags&6&&(t.flags|=8192)):Wc(t),n=t.updateQueue,n!==null&&Hc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&ge(Sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$i(da),Wc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function Kc(e,t){switch(Fi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $i(da),Ce(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return Te(t),null;case 31:if(t.memoizedState!==null){if(po(t),t.alternate===null)throw Error(i(340));Ki()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(po(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));Ki()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return ge(mo),null;case 4:return Ce(),null;case 10:return $i(t.type),null;case 22:case 23:return po(t),ao(),e!==null&&ge(Sa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return $i(da),null;case 25:return null;default:return null}}function qc(e,t){switch(Fi(t),t.tag){case 3:$i(da),Ce();break;case 26:case 27:case 5:Te(t);break;case 4:Ce();break;case 31:t.memoizedState!==null&&po(t);break;case 13:po(t);break;case 19:ge(mo);break;case 10:$i(t.type);break;case 22:case 23:po(t),ao(),e!==null&&ge(Sa);break;case 24:$i(da)}}function Jc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){K(t,t.return,e)}}function Yc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){K(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){K(t,t.return,e)}}function Xc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{eo(t,n)}catch(t){K(e,e.return,t)}}}function Zc(e,t,n){n.props=Qs(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){K(e,t,n)}}function Qc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){K(e,t,n)}}function $c(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){K(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){K(e,t,n)}else n.current=null}}function el(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){K(e,e.return,t)}}function R(e,t,n){try{var r=e.stateNode;Bd(r,e.type,n,t),r[bt]=t}catch(t){K(e,e.return,t)}}function tl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&nf(e.type)||e.tag===4}function nl(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||tl(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&nf(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function rl(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=pn));else if(r!==4&&(r===27&&nf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(rl(e,t,n),e=e.sibling;e!==null;)rl(e,t,n),e=e.sibling}function il(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&nf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(il(e,t,n),e=e.sibling;e!==null;)il(e,t,n),e=e.sibling}function al(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);zd(t,r,n),t[yt]=e,t[bt]=n}catch(t){K(e,e.return,t)}}var ol=!1,z=!1,sl=!1,cl=typeof WeakSet==`function`?WeakSet:Set,ll=null;function ul(e,t){if(e=e.containerInfo,Ud=dp,e=Pr(e),Fr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var a=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||a!==0&&f.nodeType!==3||(c=s+a),f!==o||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===a&&(c=s),p===o&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(Wd={focusedElem:e,selectionRange:n},dp=!1,ll=t;ll!==null;)if(t=ll,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,ll=e;else for(;ll!==null;){switch(t=ll,o=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n<e.length;n++)a=e[n],a.ref.impl=a.nextImpl;break;case 11:case 15:break;case 1:if(e&1024&&o!==null){e=void 0,n=t,a=o.memoizedProps,o=o.memoizedState,r=n.stateNode;try{var h=Qs(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){K(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)of(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:of(e);break;default:e.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if(e&1024)throw Error(i(163))}if(e=t.sibling,e!==null){e.return=t.return,ll=e;break}ll=t.return}}function dl(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Tl(e,n),r&4&&Jc(5,n);break;case 1:if(Tl(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){K(n,n.return,e)}else{var i=Qs(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){K(n,n.return,e)}}}r&64&&Xc(n),r&512&&Qc(n,n.return);break;case 3:if(Tl(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{eo(e,t)}catch(e){K(n,n.return,e)}}break;case 27:t===null&&r&4&&al(n);case 26:case 5:Tl(e,n),t===null&&r&4&&el(n),r&512&&Qc(n,n.return);break;case 12:Tl(e,n);break;case 31:Tl(e,n),r&4&&gl(e,n);break;case 13:Tl(e,n),r&4&&_l(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=$u.bind(null,n),ff(e,n))));break;case 22:if(r=n.memoizedState!==null||ol,!r){t=t!==null&&t.memoizedState!==null||z,i=ol;var a=z;ol=r,(z=t)&&!a?Dl(e,n,!!(n.subtreeFlags&8772)):Tl(e,n),ol=i,z=a}break;case 30:break;default:Tl(e,n)}}function fl(e){var t=e.alternate;t!==null&&(e.alternate=null,fl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Dt(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var pl=null,ml=!1;function hl(e,t,n){for(n=n.child;n!==null;)B(e,t,n),n=n.sibling}function B(e,t,n){if(Je&&typeof Je.onCommitFiberUnmount==`function`)try{Je.onCommitFiberUnmount(qe,n)}catch{}switch(n.tag){case 26:z||$c(n,t),hl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:z||$c(n,t);var r=pl,i=ml;nf(n.type)&&(pl=n.stateNode,ml=!1),hl(e,t,n),_f(n.stateNode),pl=r,ml=i;break;case 5:z||$c(n,t);case 6:if(r=pl,i=ml,pl=null,hl(e,t,n),pl=r,ml=i,pl!==null){if(ml)try{(pl.nodeType===9?pl.body:pl.nodeName===`HTML`?pl.ownerDocument.body:pl).removeChild(n.stateNode)}catch(e){K(n,t,e)}else try{pl.removeChild(n.stateNode)}catch(e){K(n,t,e)}}break;case 18:pl!==null&&(ml?(e=pl,rf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Lp(e)):rf(pl,n.stateNode));break;case 4:r=pl,i=ml,pl=n.stateNode.containerInfo,ml=!0,hl(e,t,n),pl=r,ml=i;break;case 0:case 11:case 14:case 15:Yc(2,n,t),z||Yc(4,n,t),hl(e,t,n);break;case 1:z||($c(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Zc(n,t,r)),hl(e,t,n);break;case 21:hl(e,t,n);break;case 22:z=(r=z)||n.memoizedState!==null,hl(e,t,n),z=r;break;default:hl(e,t,n)}}function gl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Lp(e)}catch(e){K(t,t.return,e)}}}function _l(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Lp(e)}catch(e){K(t,t.return,e)}}function vl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new cl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new cl),t;default:throw Error(i(435,e.tag))}}function yl(e,t){var n=vl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=q.bind(null,e,t);t.then(r,r)}})}function bl(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var a=n[r],o=e,s=t,c=s;a:for(;c!==null;){switch(c.tag){case 27:if(nf(c.type)){pl=c.stateNode,ml=!1;break a}break;case 5:pl=c.stateNode,ml=!1;break a;case 3:case 4:pl=c.stateNode.containerInfo,ml=!0;break a}c=c.return}if(pl===null)throw Error(i(160));B(o,s,a),pl=null,ml=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Sl(t,e),t=t.sibling}var xl=null;function Sl(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:bl(t,e),Cl(e),r&4&&(Yc(3,e,e.return),Jc(3,e),Yc(5,e,e.return));break;case 1:bl(t,e),Cl(e),r&512&&(z||n===null||$c(n,n.return)),r&64&&ol&&(e=e.updateQueue,e!==null&&(r=e.callbacks,r!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?r:n.concat(r))));break;case 26:var a=xl;if(bl(t,e),Cl(e),r&512&&(z||n===null||$c(n,n.return)),r&4){var o=n===null?null:n.memoizedState;if(r=e.memoizedState,n===null){if(r===null){if(e.stateNode===null){a:{r=e.type,n=e.memoizedProps,a=a.ownerDocument||a;b:switch(r){case`title`:o=a.getElementsByTagName(`title`)[0],(!o||o[Et]||o[yt]||o.namespaceURI===`http://www.w3.org/2000/svg`||o.hasAttribute(`itemprop`))&&(o=a.createElement(r),a.head.insertBefore(o,a.querySelector(`head > title`))),zd(o,r,n),o[yt]=e,Mt(o),r=o;break a;case`link`:var s=Gf(`link`,`href`,a).get(r+(n.href||``));if(s){for(var c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&o.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&o.getAttribute(`title`)===(n.title==null?null:n.title)&&o.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){s.splice(c,1);break b}}o=a.createElement(r),zd(o,r,n),a.head.appendChild(o);break;case`meta`:if(s=Gf(`meta`,`content`,a).get(r+(n.content||``))){for(c=0;c<s.length;c++)if(o=s[c],o.getAttribute(`content`)===(n.content==null?null:``+n.content)&&o.getAttribute(`name`)===(n.name==null?null:n.name)&&o.getAttribute(`property`)===(n.property==null?null:n.property)&&o.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&o.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){s.splice(c,1);break b}}o=a.createElement(r),zd(o,r,n),a.head.appendChild(o);break;default:throw Error(i(468,r))}o[yt]=e,Mt(o),r=o}e.stateNode=r}else Kf(a,e.type,e.stateNode)}else e.stateNode=Bf(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&R(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?Kf(a,e.type,e.stateNode):Bf(a,r,e.memoizedProps))}break;case 27:bl(t,e),Cl(e),r&512&&(z||n===null||$c(n,n.return)),n!==null&&r&4&&R(e,e.memoizedProps,n.memoizedProps);break;case 5:if(bl(t,e),Cl(e),r&512&&(z||n===null||$c(n,n.return)),e.flags&32){a=e.stateNode;try{an(a,``)}catch(t){K(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,R(e,a,n===null?a:n.memoizedProps)),r&1024&&(sl=!0);break;case 6:if(bl(t,e),Cl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){K(e,e.return,t)}}break;case 3:if(Wf=null,a=xl,xl=bf(t.containerInfo),bl(t,e),xl=a,Cl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Lp(t.containerInfo)}catch(t){K(e,e.return,t)}sl&&(sl=!1,wl(e));break;case 4:r=xl,xl=bf(e.stateNode.containerInfo),bl(t,e),Cl(e),xl=r;break;case 12:bl(t,e),Cl(e);break;case 31:bl(t,e),Cl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 13:bl(t,e),Cl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(cu=Re()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=ol,d=z;if(ol=u||a,z=d||l,bl(t,e),z=d,ol=u,Cl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||ol||z||El(e)),n=null,t=e;;){if(t.tag===5||t.tag===26){if(n===null){l=n=t;try{if(o=l.stateNode,a)s=o.style,typeof s.setProperty==`function`?s.setProperty(`display`,`none`,`important`):s.display=`none`;else{c=l.stateNode;var f=l.memoizedProps.style,p=f!=null&&f.hasOwnProperty(`display`)?f.display:null;c.style.display=p==null||typeof p==`boolean`?``:(``+p).trim()}}catch(e){K(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){K(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?af(m,!0):af(l.stateNode,!1)}catch(e){K(l,l.return,e)}}}else if((t.tag!==22&&t.tag!==23||t.memoizedState===null||t===e)&&t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break a;for(;t.sibling===null;){if(t.return===null||t.return===e)break a;n===t&&(n=null),t=t.return}n===t&&(n=null),t.sibling.return=t.return,t=t.sibling}r&4&&(r=e.updateQueue,r!==null&&(n=r.retryQueue,n!==null&&(r.retryQueue=null,yl(e,n))));break;case 19:bl(t,e),Cl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,yl(e,r)));break;case 30:break;case 21:break;default:bl(t,e),Cl(e)}}function Cl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(tl(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;il(e,nl(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(an(o,``),n.flags&=-33),il(e,nl(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;rl(e,nl(e),s);break;default:throw Error(i(161))}}catch(t){K(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function wl(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;wl(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function Tl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)dl(e,t.alternate,t),t=t.sibling}function El(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Yc(4,t,t.return),El(t);break;case 1:$c(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Zc(t,t.return,n),El(t);break;case 27:_f(t.stateNode);case 26:case 5:$c(t,t.return),El(t);break;case 22:t.memoizedState===null&&El(t);break;case 30:El(t);break;default:El(t)}e=e.sibling}}function Dl(e,t,n){for(n&&=!!(t.subtreeFlags&8772),t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags;switch(a.tag){case 0:case 11:case 15:Dl(i,a,n),Jc(4,a);break;case 1:if(Dl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){K(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var s=r.stateNode;try{var c=i.shared.hiddenCallbacks;if(c!==null)for(i.shared.hiddenCallbacks=null,i=0;i<c.length;i++)$a(c[i],s)}catch(e){K(r,r.return,e)}}n&&o&64&&Xc(a),Qc(a,a.return);break;case 27:al(a);case 26:case 5:Dl(i,a,n),n&&r===null&&o&4&&el(a),Qc(a,a.return);break;case 12:Dl(i,a,n);break;case 31:Dl(i,a,n),n&&o&4&&gl(i,a);break;case 13:Dl(i,a,n),n&&o&4&&_l(i,a);break;case 22:a.memoizedState===null&&Dl(i,a,n),Qc(a,a.return);break;case 30:break;default:Dl(i,a,n)}t=t.sibling}}function Ol(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&pa(n))}function kl(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&pa(e))}function Al(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)jl(e,t,n,r),t=t.sibling}function jl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Al(e,t,n,r),i&2048&&Jc(9,t);break;case 1:Al(e,t,n,r);break;case 3:Al(e,t,n,r),i&2048&&(e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&pa(e)));break;case 12:if(i&2048){Al(e,t,n,r),e=t.stateNode;try{var a=t.memoizedProps,o=a.id,s=a.onPostCommit;typeof s==`function`&&s(o,t.alternate===null?`mount`:`update`,e.passiveEffectDuration,-0)}catch(e){K(t,t.return,e)}}else Al(e,t,n,r);break;case 31:Al(e,t,n,r);break;case 13:Al(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Al(e,t,n,r):(a._visibility|=2,Ml(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?Al(e,t,n,r):Nl(e,t),i&2048&&Ol(o,t);break;case 24:Al(e,t,n,r),i&2048&&kl(t.alternate,t);break;default:Al(e,t,n,r)}}function Ml(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Ml(a,o,s,c,i),Jc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Ml(a,o,s,c,i)):u._visibility&2?Ml(a,o,s,c,i):Nl(a,o),i&&l&2048&&Ol(o.alternate,o);break;case 24:Ml(a,o,s,c,i),i&&l&2048&&kl(o.alternate,o);break;default:Ml(a,o,s,c,i)}t=t.sibling}}function Nl(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Nl(n,r),i&2048&&Ol(r.alternate,r);break;case 24:Nl(n,r),i&2048&&kl(r.alternate,r);break;default:Nl(n,r)}t=t.sibling}}var Pl=8192;function Fl(e,t,n){if(e.subtreeFlags&Pl)for(e=e.child;e!==null;)Il(e,t,n),e=e.sibling}function Il(e,t,n){switch(e.tag){case 26:Fl(e,t,n),e.flags&Pl&&e.memoizedState!==null&&Yf(n,xl,e.memoizedState,e.memoizedProps);break;case 5:Fl(e,t,n);break;case 3:case 4:var r=xl;xl=bf(e.stateNode.containerInfo),Fl(e,t,n),xl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Pl,Pl=16777216,Fl(e,t,n),Pl=r):Fl(e,t,n));break;default:Fl(e,t,n)}}function Ll(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Rl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ll=r,Vl(r,e)}Ll(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)zl(e),e=e.sibling}function zl(e){switch(e.tag){case 0:case 11:case 15:Rl(e),e.flags&2048&&Yc(9,e,e.return);break;case 3:Rl(e);break;case 12:Rl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Bl(e)):Rl(e);break;default:Rl(e)}}function Bl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];ll=r,Vl(r,e)}Ll(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Yc(8,t,t.return),Bl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Bl(t));break;default:Bl(t)}e=e.sibling}}function Vl(e,t){for(;ll!==null;){var n=ll;switch(n.tag){case 0:case 11:case 15:Yc(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:pa(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,ll=r;else a:for(n=e;ll!==null;){r=ll;var i=r.sibling,a=r.return;if(fl(r),r===n){ll=null;break a}if(i!==null){i.return=a,ll=i;break a}ll=a}}}var Hl={getCacheForType:function(e){var t=aa(da),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return aa(da).controller.signal}},Ul=typeof WeakMap==`function`?WeakMap:Map,Wl=0,Gl=null,Kl=null,ql=0,Jl=0,V=null,Yl=!1,Xl=!1,Zl=!1,Ql=0,$l=0,eu=0,tu=0,nu=0,ru=0,iu=0,au=null,ou=null,su=!1,cu=0,lu=0,uu=1/0,du=null,fu=null,pu=0,mu=null,hu=null,gu=0,_u=0,vu=null,yu=null,bu=0,xu=null;function Su(){return Wl&2&&ql!==0?ql&-ql:T.T===null?gt():md()}function Cu(){if(ru===0){if(!(ql&536870912)||F){var e=tt;tt<<=1,!(tt&3932160)&&(tt=262144),ru=e}else ru=536870912}return e=oo.current,e!==null&&(e.flags|=32),ru}function wu(e,t,n){(e===Gl&&(Jl===2||Jl===9)||e.cancelPendingCommit!==null)&&(ju(e,0),Ou(e,ql,ru,!1)),lt(e,n),(!(Wl&2)||e!==Gl)&&(e===Gl&&(!(Wl&2)&&(tu|=n),$l===4&&Ou(e,ql,ru,!1)),od(e))}function Tu(e,t,n){if(Wl&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||at(e,t),a=r?zu(e,t):Lu(e,t,!0),o=r;do{if(a===0){Xl&&!r&&Ou(e,t,0,!1);break}if(n=e.current.alternate,o&&!Du(n)){a=Lu(e,t,!1),o=!1;continue}if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=au;var l=c.current.memoizedState.isDehydrated;if(l&&(ju(c,s).flags|=256),s=Lu(c,s,!1),s!==2){if(Zl&&!l){c.errorRecoveryDisabledLanes|=o,tu|=o,a=4;break a}o=ou,ou=a,o!==null&&(ou===null?ou=o:ou.push.apply(ou,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){ju(e,0),Ou(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t)break;case 6:Ou(r,t,ru,!Yl);break a;case 2:ou=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=cu+300-Re(),10<a)){if(Ou(r,t,ru,!Yl),it(r,0,!0)!==0)break a;gu=t,r.timeoutHandle=Zd(Eu.bind(null,r,n,ou,du,su,t,ru,tu,iu,Yl,o,`Throttled`,-0,0),a);break a}Eu(r,n,ou,du,su,t,ru,tu,iu,Yl,o,null,-0,0)}break}while(1);od(e)}function Eu(e,t,n,r,i,a,o,s,c,l,u,d,f,p){if(e.timeoutHandle=-1,d=t.subtreeFlags,d&8192||(d&16785408)==16785408){d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:pn},Il(t,a,d);var m=(a&62914560)===a?cu-Re():(a&4194048)===a?lu-Re():0;if(m=Zf(d,m),m!==null){gu=a,e.cancelPendingCommit=m(Wu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Ou(e,a,o,!l);return}}Wu(e,t,a,n,r,i,o,s,c)}function Du(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!kr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Ou(e,t,n,r){t&=~nu,t&=~tu,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Xe(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&dt(e,n,t)}function ku(){return Wl&6?!0:(sd(0,!1),!1)}function Au(){if(Kl!==null){if(Jl===0)var e=Kl.return;else e=Kl,Zi=Xi=null,Po(e),Fa=null,Ia=0,e=Kl;for(;e!==null;)qc(e.alternate,e),e=e.return;Kl=null}}function ju(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,Qd(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),gu=0,Au(),Gl=e,Kl=n=_i(e.current,null),ql=t,Jl=0,V=null,Yl=!1,Xl=at(e,t),Zl=!1,iu=ru=nu=tu=eu=$l=0,ou=au=null,su=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Xe(r),a=1<<i;t|=e[i],r&=~a}return Ql=t,si(),n}function Mu(e,t){L=null,T.H=Ws,t===Ta||t===Da?(t=Na(),Jl=3):t===Ea?(t=Na(),Jl=4):Jl=t===cc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,V=t,Kl===null&&($l=1,nc(e,Ti(t,e.current)))}function Nu(){var e=oo.current;return e===null?!0:(ql&4194048)===ql?so===null:(ql&62914560)===ql||ql&536870912?e===so:!1}function Pu(){var e=T.H;return T.H=Ws,e===null?Ws:e}function Fu(){var e=T.A;return T.A=Hl,e}function Iu(){$l=4,Yl||(ql&4194048)!==ql&&oo.current!==null||(Xl=!0),!(eu&134217727)&&!(tu&134217727)||Gl===null||Ou(Gl,ql,ru,!1)}function Lu(e,t,n){var r=Wl;Wl|=2;var i=Pu(),a=Fu();(Gl!==e||ql!==t)&&(du=null,ju(e,t)),t=!1;var o=$l;a:do try{if(Jl!==0&&Kl!==null){var s=Kl,c=V;switch(Jl){case 8:Au(),o=6;break a;case 3:case 2:case 9:case 6:oo.current===null&&(t=!0);var l=Jl;if(Jl=0,V=null,Hu(e,s,c,l),n&&Xl){o=0;break a}break;default:l=Jl,Jl=0,V=null,Hu(e,s,c,l)}}Ru(),o=$l;break}catch(t){Mu(e,t)}while(1);return t&&e.shellSuspendCounter++,Zi=Xi=null,Wl=r,T.H=i,T.A=a,Kl===null&&(Gl=null,ql=0,si()),o}function Ru(){for(;Kl!==null;)Vu(Kl)}function zu(e,t){var n=Wl;Wl|=2;var r=Pu(),a=Fu();Gl!==e||ql!==t?(du=null,uu=Re()+500,ju(e,t)):Xl=at(e,t);a:do try{if(Jl!==0&&Kl!==null){t=Kl;var o=V;b:switch(Jl){case 1:Jl=0,V=null,Hu(e,t,o,1);break;case 2:case 9:if(ka(o)){Jl=0,V=null,H(t);break}t=function(){Jl!==2&&Jl!==9||Gl!==e||(Jl=7),od(e)},o.then(t,t);break a;case 3:Jl=7;break a;case 4:Jl=5;break a;case 7:ka(o)?(Jl=0,V=null,H(t)):(Jl=0,V=null,Hu(e,t,o,7));break;case 5:var s=null;switch(Kl.tag){case 26:s=Kl.memoizedState;case 5:case 27:var c=Kl;if(s?Jf(s):c.stateNode.complete){Jl=0,V=null;var l=c.sibling;if(l!==null)Kl=l;else{var u=c.return;u===null?Kl=null:(Kl=u,U(u))}break b}}Jl=0,V=null,Hu(e,t,o,5);break;case 6:Jl=0,V=null,Hu(e,t,o,6);break;case 8:Au(),$l=6;break a;default:throw Error(i(462))}}Bu();break}catch(t){Mu(e,t)}while(1);return Zi=Xi=null,T.H=r,T.A=a,Wl=n,Kl===null?(Gl=null,ql=0,si(),$l):0}function Bu(){for(;Kl!==null&&!Ie();)Vu(Kl)}function Vu(e){var t=Rc(e.alternate,e,Ql);e.memoizedProps=e.pendingProps,t===null?U(e):Kl=t}function H(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=Sc(n,t,t.pendingProps,t.type,void 0,ql);break;case 11:t=Sc(n,t,t.pendingProps,t.type.render,t.ref,ql);break;case 5:Po(t);default:qc(n,t),t=Kl=vi(t,Ql),t=Rc(n,t,Ql)}e.memoizedProps=e.pendingProps,t===null?U(e):Kl=t}function Hu(e,t,n,r){Zi=Xi=null,Po(t),Fa=null,Ia=0;var i=t.return;try{if(sc(e,i,t,n,ql)){$l=1,nc(e,Ti(n,e.current)),Kl=null;return}}catch(t){if(i!==null)throw Kl=i,t;$l=1,nc(e,Ti(n,e.current)),Kl=null;return}t.flags&32768?(F||r===1?e=!0:Xl||ql&536870912?e=!1:(Yl=e=!0,(r===2||r===9||r===3||r===6)&&(r=oo.current,r!==null&&r.tag===13&&(r.flags|=16384))),Uu(t,e)):U(t)}function U(e){var t=e;do{if(t.flags&32768){Uu(t,Yl);return}e=t.return;var n=Gc(t.alternate,t,Ql);if(n!==null){Kl=n;return}if(t=t.sibling,t!==null){Kl=t;return}Kl=t=e}while(t!==null);$l===0&&($l=5)}function Uu(e,t){do{var n=Kc(e.alternate,e);if(n!==null){n.flags&=32767,Kl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Kl=e;return}Kl=e=n}while(e!==null);$l=6,Kl=null}function Wu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do Ju();while(pu!==0);if(Wl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=oi,ut(e,n,o,s,c,l),e===Gl&&(Kl=Gl=null,ql=0),hu=t,mu=e,gu=n,_u=o,vu=a,yu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,ed(He,function(){return G(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=T.T,T.T=null,a=de.p,de.p=2,s=Wl,Wl|=4;try{ul(e,t,n)}finally{Wl=s,de.p=a,T.T=r}}pu=1,Gu(),Ku(),qu()}}function Gu(){if(pu===1){pu=0;var e=mu,t=hu,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=T.T,T.T=null;var r=de.p;de.p=2;var i=Wl;Wl|=4;try{Sl(t,e);var a=Wd,o=Pr(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&Nr(s.ownerDocument.documentElement,s)){if(c!==null&&Fr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Mr(s,h),v=Mr(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}dp=!!Ud,Wd=Ud=null}finally{Wl=i,de.p=r,T.T=n}}e.current=t,pu=2}}function Ku(){if(pu===2){pu=0;var e=mu,t=hu,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=T.T,T.T=null;var r=de.p;de.p=2;var i=Wl;Wl|=4;try{dl(e,t.alternate,t)}finally{Wl=i,de.p=r,T.T=n}}pu=3}}function qu(){if(pu===4||pu===3){pu=0,Le();var e=mu,t=hu,n=gu,r=yu;t.subtreeFlags&10256||t.flags&10256?pu=5:(pu=0,hu=mu=null,W(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(fu=null),ht(n),t=t.stateNode,Je&&typeof Je.onCommitFiberRoot==`function`)try{Je.onCommitFiberRoot(qe,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=T.T,i=de.p,de.p=2,T.T=null;try{for(var a=e.onRecoverableError,o=0;o<r.length;o++){var s=r[o];a(s.value,{componentStack:s.stack})}}finally{T.T=t,de.p=i}}gu&3&&Ju(),od(e),i=e.pendingLanes,n&261930&&i&42?e===xu?bu++:(bu=0,xu=e):bu=0,sd(0,!1)}}function W(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,pa(t)))}function Ju(){return Gu(),Ku(),qu(),G()}function G(){if(pu!==5)return!1;var e=mu,t=_u;_u=0;var n=ht(gu),r=T.T,a=de.p;try{de.p=32>n?32:n,T.T=null,n=vu,vu=null;var o=mu,s=gu;if(pu=0,hu=mu=null,gu=0,Wl&6)throw Error(i(331));var c=Wl;if(Wl|=4,zl(o.current),jl(o,o.current,s,n),Wl=c,sd(0,!1),Je&&typeof Je.onPostCommitFiberRoot==`function`)try{Je.onPostCommitFiberRoot(qe,o)}catch{}return!0}finally{de.p=a,T.T=r,W(e,t)}}function Yu(e,t,n){t=Ti(n,t),t=ic(e.stateNode,t,2),e=qa(e,t,2),e!==null&&(lt(e,2),od(e))}function K(e,t,n){if(e.tag===3)Yu(e,e,n);else for(;t!==null;){if(t.tag===3){Yu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(fu===null||!fu.has(r))){e=Ti(n,e),n=ac(2),r=qa(t,n,2),r!==null&&(oc(n,r,t,e),lt(r,2),od(r));break}}t=t.return}}function Xu(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Ul;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Zl=!0,i.add(n),e=Zu.bind(null,e,t,n),t.then(e,e))}function Zu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Gl===e&&(ql&n)===n&&($l===4||$l===3&&(ql&62914560)===ql&&300>Re()-cu?!(Wl&2)&&ju(e,0):nu|=n,iu===ql&&(iu=0)),od(e)}function Qu(e,t){t===0&&(t=st()),e=ui(e,t),e!==null&&(lt(e,t),od(e))}function $u(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Qu(e,n)}function q(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Qu(e,n)}function ed(e,t){return Pe(e,t)}var td=null,J=null,nd=!1,rd=!1,id=!1,ad=0;function od(e){e!==J&&e.next===null&&(J===null?td=J=e:J=J.next=e),rd=!0,nd||(nd=!0,pd())}function sd(e,t){if(!id&&rd){id=!0;do for(var n=!1,r=td;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Xe(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,fd(r,a))}else a=ql,a=it(r,r===Gl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||at(r,a)||(n=!0,fd(r,a))}r=r.next}while(n);id=!1}}function cd(){ld()}function ld(){rd=nd=!1;var e=0;ad!==0&&Xd()&&(e=ad);for(var t=Re(),n=null,r=td;r!==null;){var i=r.next,a=ud(r,t);a===0?(r.next=null,n===null?td=i:n.next=i,i===null&&(J=n)):(n=r,(e!==0||a&3)&&(rd=!0)),r=i}pu!==0&&pu!==5||sd(e,!1),ad!==0&&(ad=0)}function ud(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Xe(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ot(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Gl,n=ql,n=it(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Jl===2||Jl===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Fe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||at(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Fe(r),ht(n)){case 2:case 8:n=Ve;break;case 32:n=He;break;case 268435456:n=We;break;default:n=He}return r=dd.bind(null,e),n=Pe(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Fe(r),e.callbackPriority=2,e.callbackNode=null,2}function dd(e,t){if(pu!==0&&pu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(Ju()&&e.callbackNode!==n)return null;var r=ql;return r=it(e,e===Gl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Tu(e,r,t),ud(e,Re()),e.callbackNode!=null&&e.callbackNode===n?dd.bind(null,e):null)}function fd(e,t){if(Ju())return null;Tu(e,t,!0)}function pd(){ef(function(){Wl&6?Pe(Be,cd):ld()})}function md(){if(ad===0){var e=ga;e===0&&(e=et,et<<=1,!(et&261888)&&(et=256)),ad=e}return ad}function hd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:fn(``+e)}function gd(e,t){var n=t.ownerDocument.createElement(`input`);return n.name=t.name,n.value=t.value,e.id&&n.setAttribute(`form`,e.id),t.parentNode.insertBefore(n,t),e=new FormData(e),n.parentNode.removeChild(n),e}function _d(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=hd((i[bt]||null).action),o=r.submitter;o&&(t=(t=o[bt]||null)?hd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Pn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(ad!==0){var e=o?gd(i,o):new FormData(i);As(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?gd(i,o):new FormData(i),As(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var vd=0;vd<ti.length;vd++){var yd=ti[vd];ni(yd.toLowerCase(),`on`+(yd[0].toUpperCase()+yd.slice(1)))}ni(qr,`onAnimationEnd`),ni(Jr,`onAnimationIteration`),ni(Yr,`onAnimationStart`),ni(`dblclick`,`onDoubleClick`),ni(`focusin`,`onFocus`),ni(`focusout`,`onBlur`),ni(Xr,`onTransitionRun`),ni(Zr,`onTransitionStart`),ni(Qr,`onTransitionCancel`),ni($r,`onTransitionEnd`),It(`onMouseEnter`,[`mouseout`,`mouseover`]),It(`onMouseLeave`,[`mouseout`,`mouseover`]),It(`onPointerEnter`,[`pointerout`,`pointerover`]),It(`onPointerLeave`,[`pointerout`,`pointerover`]),Ft(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Ft(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Ft(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Ft(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Ft(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Ft(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var bd=`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(` `),xd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(bd));function Sd(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ri(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){ri(e)}i.currentTarget=null,a=c}}}}function Cd(e,t){var n=t[St];n===void 0&&(n=t[St]=new Set);var r=e+`__bubble`;n.has(r)||(Dd(t,e,2,!1),n.add(r))}function wd(e,t,n){var r=0;t&&(r|=4),Dd(n,e,r,t)}var Td=`_reactListening`+Math.random().toString(36).slice(2);function Ed(e){if(!e[Td]){e[Td]=!0,Nt.forEach(function(t){t!==`selectionchange`&&(xd.has(t)||wd(t,!1,e),wd(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Td]||(t[Td]=!0,wd(`selectionchange`,!1,t))}}function Dd(e,t,n,r){switch(vp(t)){case 2:var i=fp;break;case 8:i=pp;break;default:i=mp}n=i.bind(null,t,n,e),i=void 0,!Cn||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function Od(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=Ot(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}bn(function(){var r=a,i=hn(n),s=[];a:{var c=ei.get(e);if(c!==void 0){var l=Pn,u=e;switch(e){case`keypress`:if(kn(n)===0)break a;case`keydown`:case`keyup`:l=Qn;break;case`focusin`:u=`focus`,l=Un;break;case`focusout`:u=`blur`,l=Un;break;case`beforeblur`:case`afterblur`:l=Un;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Vn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Hn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=er;break;case qr:case Jr:case Yr:l=Wn;break;case $r:l=tr;break;case`scroll`:case`scrollend`:l=In;break;case`wheel`:l=nr;break;case`copy`:case`cut`:case`paste`:l=Gn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=$n;break;case`toggle`:case`beforetoggle`:l=rr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=xn(m,p),g!=null&&d.push(kd(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(c=e===`mouseover`||e===`pointerover`,l=e===`mouseout`||e===`pointerout`,c&&n!==mn&&(u=n.relatedTarget||n.fromElement)&&(Ot(u)||u[xt]))break a;if((l||c)&&(c=i.window===i?i:(c=i.ownerDocument)?c.defaultView||c.parentWindow:window,l?(u=n.relatedTarget||n.toElement,l=r,u=u?Ot(u):null,u!==null&&(f=o(u),d=u.tag,u!==f||d!==5&&d!==27&&d!==6)&&(u=null)):(l=null,u=r),l!==u)){if(d=Vn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=$n,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:At(l),h=u==null?c:At(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,Ot(i)===r&&(d=new d(p,m+`enter`,u,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,l&&u)b:{for(d=jd,p=l,m=u,h=0,g=p;g;g=d(g))h++;g=0;for(var _=m;_;_=d(_))g++;for(;0<h-g;)p=d(p),h--;for(;0<g-h;)m=d(m),g--;for(;h--;){if(p===m||m!==null&&p===m.alternate){d=p;break b}p=d(p),m=d(m)}d=null}else d=null;l!==null&&Md(s,c,l,d,!1),u!==null&&f!==null&&Md(s,f,u,d,!0)}}a:{if(c=r?At(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=vr;else if(pr(c)){if(j)v=Dr;else{v=Tr;var y=wr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&ln(r.elementType)&&(v=vr):v=Er;if(v&&=v(e,r)){mr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&en(c,`number`,c.value)}switch(y=r?At(r):window,e){case`focusin`:(pr(y)||y.contentEditable===`true`)&&(Lr=y,Rr=r,zr=null);break;case`focusout`:zr=Rr=Lr=null;break;case`mousedown`:Br=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Br=!1,Vr(s,n,i);break;case`selectionchange`:if(Ir)break;case`keydown`:case`keyup`:Vr(s,n,i)}var b;if(ir)b:{switch(e){case`compositionstart`:var x=`onCompositionStart`;break b;case`compositionend`:x=`onCompositionEnd`;break b;case`compositionupdate`:x=`onCompositionUpdate`;break b}x=void 0}else ur?lr(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(or&&n.locale!==`ko`&&(ur||x!==`onCompositionStart`?x===`onCompositionEnd`&&ur&&(b=On()):(Tn=i,En=`value`in Tn?Tn.value:Tn.textContent,ur=!0)),y=Ad(r,x),0<y.length&&(x=new Kn(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=O(n),b!==null&&(x.data=b)))),(b=ar?k(e,n):dr(e,n))&&(x=Ad(r,`onBeforeInput`),0<x.length&&(y=new Kn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),_d(s,e,r,n,i)}Sd(s,t)})}function kd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Ad(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=xn(e,n),i!=null&&r.unshift(kd(e,i,a)),i=xn(e,t),i!=null&&r.push(kd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function jd(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Md(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=xn(n,a),l!=null&&o.unshift(kd(n,l,c))):i||(l=xn(n,a),l!=null&&o.push(kd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Nd=/\r\n?/g,Pd=/\u0000|\uFFFD/g;function Fd(e){return(typeof e==`string`?e:``+e).replace(Nd,`
|
|
9
|
+
`).replace(Pd,``)}function Id(e,t){return t=Fd(t),Fd(e)===t}function Ld(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||an(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&an(e,``+r);break;case`className`:Ht(e,`class`,r);break;case`tabIndex`:Ht(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Ht(e,n,r);break;case`style`:cn(e,r,o);break;case`data`:if(t!==`object`){Ht(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)){e.removeAttribute(n);break}if(r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=fn(``+r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`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}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&Ld(e,t,`name`,a.name,a,null),Ld(e,t,`formEncType`,a.formEncType,a,null),Ld(e,t,`formMethod`,a.formMethod,a,null),Ld(e,t,`formTarget`,a.formTarget,a,null)):(Ld(e,t,`encType`,a.encType,a,null),Ld(e,t,`method`,a.method,a,null),Ld(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=fn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=pn);break;case`onScroll`:r!=null&&Cd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Cd(`scrollend`,e);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=fn(``+r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``+r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`: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`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Cd(`beforetoggle`,e),Cd(`toggle`,e),Vt(e,`popover`,r);break;case`xlinkActuate`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Ut(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Ut(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Ut(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Ut(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Vt(e,`is`,r);break;case`innerText`:case`textContent`:break;default:(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)&&(n=un.get(n)||n,Vt(e,n,r))}}function Rd(e,t,n,r,a,o){switch(n){case`style`:cn(e,r,o);break;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));e.innerHTML=n}}break;case`children`:typeof r==`string`?an(e,r):(typeof r==`number`||typeof r==`bigint`)&&an(e,``+r);break;case`onScroll`:r!=null&&Cd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Cd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=pn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!Pt.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),t=n.slice(2,a?n.length-7:void 0),o=e[bt]||null,o=o==null?null:o[n],typeof o==`function`&&e.removeEventListener(t,o,a),typeof r==`function`)){typeof o!=`function`&&o!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(t,r,a);break a}n in e?e[n]=r:!0===r?e.setAttribute(n,``):Vt(e,n,r)}}}function zd(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Cd(`error`,e),Cd(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ld(e,t,o,s,n,null)}}a&&Ld(e,t,`srcSet`,n.srcSet,n,null),r&&Ld(e,t,`src`,n.src,n,null);return;case`input`:Cd(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:Ld(e,t,r,d,n,null)}}$t(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Cd(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:Ld(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&tn(e,!!r,n,!0):tn(e,!!r,t,!1);return;case`textarea`:for(s in Cd(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:Ld(e,t,s,c,n,null)}rn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:Ld(e,t,l,r,n,null)}return;case`dialog`:Cd(`beforetoggle`,e),Cd(`toggle`,e),Cd(`cancel`,e),Cd(`close`,e);break;case`iframe`:case`object`:Cd(`load`,e);break;case`video`:case`audio`:for(r=0;r<bd.length;r++)Cd(bd[r],e);break;case`image`:Cd(`error`,e),Cd(`load`,e);break;case`details`:Cd(`toggle`,e);break;case`embed`:case`source`:case`link`:Cd(`error`,e),Cd(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:Ld(e,t,u,r,n,null)}return;default:if(ln(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Rd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Ld(e,t,c,r,n,null))}function Bd(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||Ld(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:o=m;break;case`name`:a=m;break;case`checked`:u=m;break;case`defaultChecked`:d=m;break;case`value`:s=m;break;case`defaultValue`:c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&Ld(e,t,p,m,r,f)}}Qt(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||Ld(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:p=o;break;case`defaultValue`:c=o;break;case`multiple`:s=o;default:o!==l&&Ld(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?tn(e,!!n,n?[]:``,!1):tn(e,!!n,t,!0)):tn(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:Ld(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:p=a;break;case`defaultValue`:m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&Ld(e,t,s,a,r,o)}nn(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:Ld(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:Ld(e,t,l,p,r,m)}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 g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&Ld(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:Ld(e,t,u,p,r,m)}return;default:if(ln(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Rd(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||Rd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Ld(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||Ld(e,t,f,p,r,m)}function Vd(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function Hd(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&Vd(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&Vd(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var Ud=null,Wd=null;function Gd(e){return e.nodeType===9?e:e.ownerDocument}function Kd(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function qd(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Jd(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Yd=null;function Xd(){var e=window.event;return e&&e.type===`popstate`?e!==Yd&&(Yd=e,!0):(Yd=null,!1)}var Zd=typeof setTimeout==`function`?setTimeout:void 0,Qd=typeof clearTimeout==`function`?clearTimeout:void 0,$d=typeof Promise==`function`?Promise:void 0,ef=typeof queueMicrotask==`function`?queueMicrotask:$d===void 0?Zd:function(e){return $d.resolve(null).then(e).catch(tf)};function tf(e){setTimeout(function(){throw e})}function nf(e){return e===`head`}function rf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Lp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)_f(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,_f(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Et]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&_f(e.ownerDocument.body)}n=i}while(n);Lp(t)}function af(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function of(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:of(n),Dt(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function sf(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Et])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=pf(e.nextSibling),e===null)break}return null}function cf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=pf(e.nextSibling),e===null))return null;return e}function lf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=pf(e.nextSibling),e===null))return null;return e}function uf(e){return e.data===`$?`||e.data===`$~`}function df(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function ff(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function pf(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var mf=null;function Y(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return pf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function hf(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function gf(e,t,n){switch(t=Gd(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function _f(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Dt(e)}var vf=new Map,yf=new Set;function bf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var xf=de.d;de.d={f:Sf,r:Cf,D:Ef,C:Df,L:Of,m:kf,X:jf,S:Af,M:Mf};function Sf(){var e=xf.f(),t=ku();return e||t}function Cf(e){var t=kt(e);t!==null&&t.tag===5&&t.type===`form`?Ms(t):xf.r(e)}var wf=typeof document>`u`?null:document;function Tf(e,t,n){var r=wf;if(r&&typeof t==`string`&&t){var i=Zt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),yf.has(i)||(yf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),zd(t,`link`,e),Mt(t),r.head.appendChild(t)))}}function Ef(e){xf.D(e),Tf(`dns-prefetch`,e,null)}function Df(e,t){xf.C(e,t),Tf(`preconnect`,e,t)}function Of(e,t,n){xf.L(e,t,n);var r=wf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Zt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Zt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Zt(n.imageSizes)+`"]`)):i+=`[href="`+Zt(e)+`"]`;var a=i;switch(t){case`style`:a=Pf(e);break;case`script`:a=Rf(e)}vf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),vf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Ff(a))||t===`script`&&r.querySelector(zf(a))||(t=r.createElement(`link`),zd(t,`link`,e),Mt(t),r.head.appendChild(t)))}}function kf(e,t){xf.m(e,t);var n=wf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Zt(r)+`"][href="`+Zt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Rf(e)}if(!vf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),vf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(zf(a)))return}r=n.createElement(`link`),zd(r,`link`,e),Mt(r),n.head.appendChild(r)}}}function Af(e,t,n){xf.S(e,t,n);var r=wf;if(r&&e){var i=jt(r).hoistableStyles,a=Pf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Ff(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=vf.get(a))&&Hf(e,n);var c=o=r.createElement(`link`);Mt(c),zd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Vf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function jf(e,t){xf.X(e,t);var n=wf;if(n&&e){var r=jt(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),Mt(a),zd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Mf(e,t){xf.M(e,t);var n=wf;if(n&&e){var r=jt(n).hoistableScripts,i=Rf(e),a=r.get(i);a||(a=n.querySelector(zf(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=vf.get(i))&&Uf(e,t),a=n.createElement(`script`),Mt(a),zd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Nf(e,t,n,r){var a=(a=be.current)?bf(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Pf(n.href),n=jt(a).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Pf(n.href);var o=jt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Ff(e)))&&!o._p&&(s.instance=o,s.state.loading=5),vf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},vf.set(e,n),o||Lf(a,e,n,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Rf(n),n=jt(a).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Pf(e){return`href="`+Zt(e)+`"`}function Ff(e){return`link[rel="stylesheet"][`+e+`]`}function If(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Lf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),zd(t,`link`,n),Mt(t),e.head.appendChild(t))}function Rf(e){return`[src="`+Zt(e)+`"]`}function zf(e){return`script[async]`+e}function Bf(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Zt(n.href)+`"]`);if(r)return t.instance=r,Mt(r),r;var a=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Mt(r),zd(r,`style`,a),Vf(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Pf(n.href);var o=e.querySelector(Ff(a));if(o)return t.state.loading|=4,t.instance=o,Mt(o),o;r=If(n),(a=vf.get(a))&&Hf(r,a),o=(e.ownerDocument||e).createElement(`link`),Mt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),zd(o,`link`,r),t.state.loading|=4,Vf(o,n.precedence,e),t.instance=o;case`script`:return o=Rf(n.src),(a=e.querySelector(zf(o)))?(t.instance=a,Mt(a),a):(r=n,(a=vf.get(o))&&(r=m({},n),Uf(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Mt(a),zd(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Vf(r,n.precedence,e));return t.instance}function Vf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Hf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function Uf(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var Wf=null;function Gf(e,t,n){if(Wf===null){var r=new Map,i=Wf=new Map;i.set(n,r)}else i=Wf,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Et]||a[yt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function Kf(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function qf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Jf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Yf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Pf(r.href),a=t.querySelector(Ff(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Qf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Mt(a);return}a=t.ownerDocument||t,r=If(r),(i=vf.get(i))&&Hf(r,i),a=a.createElement(`link`),Mt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),zd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Qf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Xf=0;function Zf(e,t){return e.stylesheets&&e.count===0&&ep(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&Xf===0&&(Xf=62500*Hd());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&ep(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>Xf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Qf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ep(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var $f=null;function ep(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,$f=new Map,t.forEach(tp,e),$f=null,Qf.call(e))}function tp(e,t){if(!(t.state.loading&4)){var n=$f.get(e);if(n)var r=n.get(null);else{n=new Map,$f.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=Qf.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var np={$$typeof:C,Provider:null,Consumer:null,_currentValue:fe,_currentValue2:fe,_threadCount:0};function rp(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,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=ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ct(0),this.hiddenUpdates=ct(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.incompleteTransitions=new Map}function ip(e,t,n,r,i,a,o,s,c,l,u,d){return e=new rp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=hi(3,null,null,t),e.current=a,a.stateNode=e,t=fa(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},Wa(a),e}function ap(e){return e?(e=pi,e):pi}function op(e,t,n,r,i,a){i=ap(i),r.context===null?r.context=i:r.pendingContext=i,r=Ka(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=qa(e,r,t),n!==null&&(wu(n,e,t),Ja(n,e,t))}function sp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function cp(e,t){sp(e,t),(e=e.alternate)&&sp(e,t)}function lp(e){if(e.tag===13||e.tag===31){var t=ui(e,67108864);t!==null&&wu(t,e,67108864),cp(e,67108864)}}function up(e){if(e.tag===13||e.tag===31){var t=Su();t=mt(t);var n=ui(e,t);n!==null&&wu(n,e,t),cp(e,t)}}var dp=!0;function fp(e,t,n,r){var i=T.T;T.T=null;var a=de.p;try{de.p=2,mp(e,t,n,r)}finally{de.p=a,T.T=i}}function pp(e,t,n,r){var i=T.T;T.T=null;var a=de.p;try{de.p=8,mp(e,t,n,r)}finally{de.p=a,T.T=i}}function mp(e,t,n,r){if(dp){var i=hp(r);if(i===null)Od(e,t,r,gp,n),Dp(e,r);else if(kp(i,e,t,n,r))r.stopPropagation();else if(Dp(e,r),t&4&&-1<Ep.indexOf(e)){for(;i!==null;){var a=kt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=rt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Xe(o);s.entanglements[1]|=c,o&=~c}od(a),!(Wl&6)&&(uu=Re()+500,sd(0,!1))}}break;case 31:case 13:s=ui(a,2),s!==null&&wu(s,a,2),ku(),cp(a,2)}if(a=hp(r),a===null&&Od(e,t,r,gp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Od(e,t,r,null,n)}}function hp(e){return e=hn(e),_p(e)}var gp=null;function _p(e){if(gp=null,e=Ot(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return gp=e,null}function vp(e){switch(e){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`resize`: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`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`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(ze()){case Be:return 2;case Ve:return 8;case He:case Ue:return 32;case We:return 268435456;default:return 32}default:return 32}}var yp=!1,bp=null,xp=null,Sp=null,Cp=new Map,wp=new Map,Tp=[],Ep=`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 Dp(e,t){switch(e){case`focusin`:case`focusout`:bp=null;break;case`dragenter`:case`dragleave`:xp=null;break;case`mouseover`:case`mouseout`:Sp=null;break;case`pointerover`:case`pointerout`:Cp.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:wp.delete(t.pointerId)}}function Op(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=kt(t),t!==null&&lp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function kp(e,t,n,r,i){switch(t){case`focusin`:return bp=Op(bp,e,t,n,r,i),!0;case`dragenter`:return xp=Op(xp,e,t,n,r,i),!0;case`mouseover`:return Sp=Op(Sp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Cp.set(a,Op(Cp.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,wp.set(a,Op(wp.get(a)||null,e,t,n,r,i)),!0}return!1}function Ap(e){var t=Ot(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,_t(e.priority,function(){up(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,_t(e.priority,function(){up(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function jp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=hp(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);mn=r,n.target.dispatchEvent(r),mn=null}else return t=kt(n),t!==null&&lp(t),e.blockedOn=n,!1;t.shift()}return!0}function Mp(e,t,n){jp(e)&&n.delete(t)}function Np(){yp=!1,bp!==null&&jp(bp)&&(bp=null),xp!==null&&jp(xp)&&(xp=null),Sp!==null&&jp(Sp)&&(Sp=null),Cp.forEach(Mp),wp.forEach(Mp)}function Pp(e,n){e.blockedOn===n&&(e.blockedOn=null,yp||(yp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Np)))}var Fp=null;function Ip(e){Fp!==e&&(Fp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Fp===e&&(Fp=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(_p(r||n)===null)continue;break}var a=kt(n);a!==null&&(e.splice(t,3),t-=3,As(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Lp(e){function t(t){return Pp(t,e)}bp!==null&&Pp(bp,e),xp!==null&&Pp(xp,e),Sp!==null&&Pp(Sp,e),Cp.forEach(t),wp.forEach(t);for(var n=0;n<Tp.length;n++){var r=Tp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Tp.length&&(n=Tp[0],n.blockedOn===null);)Ap(n),n.blockedOn===null&&Tp.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[bt]||null;if(typeof a==`function`)o||Ip(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[bt]||null)s=o.formAction;else if(_p(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Ip(n)}}}function Rp(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function zp(e){this._internalRoot=e}Bp.prototype.render=zp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;op(n,Su(),e,t,null,null)},Bp.prototype.unmount=zp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;op(e.current,2,null,e,null,null),ku(),t[xt]=null}};function Bp(e){this._internalRoot=e}Bp.prototype.unstable_scheduleHydration=function(e){if(e){var t=gt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Tp.length&&t!==0&&t<Tp[n].priority;n++);Tp.splice(n,0,e),n===0&&Ap(e)}};var Vp=n.version;if(Vp!==`19.2.8`)throw Error(i(527,Vp,`19.2.8`));de.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:f(e),e=e===null?null:e.stateNode,e};var Hp={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:T,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var Up=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Up.isDisabled&&Up.supportsFiber)try{qe=Up.inject(Hp),Je=Up}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=$s,s=ec,c=tc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=ip(e,1,!1,null,null,n,r,null,o,s,c,Rp),e[xt]=t.current,Ed(e),new zp(t)}})),_=o(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=g()})),v=`modulepreload`,y=function(e){return`/`+e},b={},x=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=y(t,n),t=s(t),t in b)return;b[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:v,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},S=l(d(),1),C=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,w=/^[\\/]{2}/;function ee(e,t){return t+e.replace(/\\/g,`/`)}var te=`popstate`;function ne(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function re(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return ce(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:le(t)}return T(t,n,null,e)}function ie(e,t){if(e===!1||e==null)throw Error(t)}function ae(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function oe(){return Math.random().toString(36).substring(2,10)}function se(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function ce(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?ue(t):t,state:n,key:t&&t.key||r||oe(),mask:i}}function le({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function ue(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function T(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=ne(e)?e:ce(h.location,e,t);n&&n(r,e),l=u()+1;let d=se(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=ne(e)?e:ce(h.location,e,t);n&&n(r,e),l=u();let i=se(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return de(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(te,d),c=e,()=>{i.removeEventListener(te,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function de(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),ie(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:le(t);return i=i.replace(/ $/,`%20`),!n&&w.test(i)&&(i=r+i),new URL(i,r)}function fe(e,t,n=`/`){return pe(e,t,n,!1)}function pe(e,t,n,r,i){let a=Me((typeof t==`string`?ue(t):t).pathname||`/`,n);if(a==null)return null;let o=i??me(e),s=null,c=je(a);for(let e=0;s==null&&e<o.length;++e)s=De(o[e],c,r);return s}function me(e){let t=he(e);return _e(t),t}function he(e,t=[],n=[],r=``,i=!1){let a=(e,a,o=i,s)=>{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;ie(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Be([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(ie(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),he(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:Te(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=Ae(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of ge(e.path))a(e,t,!0,n)}),t}function ge(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=ge(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function _e(e){e.sort((e,t)=>e.score===t.score?Ee(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var ve=/^:[\w-]+$/,ye=3,be=2,xe=1,Se=10,Ce=-2,we=e=>e===`*`;function Te(e,t){let n=e.split(`/`),r=n.length;return n.some(we)&&(r+=Ce),t&&(r+=be),n.filter(e=>!we(e)).reduce((e,t)=>e+(ve.test(t)?ye:t===``?xe:Se),r)}function Ee(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function De(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e<r.length;++e){let s=r[e],c=e===r.length-1,l=a===`/`?t:t.slice(a.length)||`/`,u={path:s.relativePath,caseSensitive:s.caseSensitive,end:c},d=s.matcher&&s.compiledParams?ke(u,l,s.matcher,s.compiledParams):Oe(u,l),f=s.route;if(!d&&c&&n&&!r[r.length-1].route.index&&(d=Oe({path:s.relativePath,caseSensitive:s.caseSensitive,end:!1},l)),!d)return null;Object.assign(i,d.params),o.push({params:i,pathname:Be([a,d.pathname]),pathnameBase:He(Be([a,d.pathnameBase])),route:f}),d.pathnameBase!==`/`&&(a=Be([a,d.pathnameBase]))}return o}function Oe(e,t){typeof e==`string`&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=Ae(e.path,e.caseSensitive,e.end);return ke(e,t,n,r)}function ke(e,t,n,r){let i=t.match(n);if(!i)return null;let a=i[0],o=Ve(a,1),s=i.slice(1);return{params:r.reduce((e,{paramName:t,isOptional:n},r)=>{if(t===`*`){let e=s[r]||``;o=Ve(a.slice(0,a.length-e.length),1)}let i=s[r];return e[t]=n&&!i?void 0:(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function Ae(e,t=!1,n=!0){ae(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function je(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return ae(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Me(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function Ne(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?ue(e):e,a;return n?(n=ze(n),a=n.startsWith(`/`)||n.startsWith(`\\`)?Pe(n.substring(1),`/`):Pe(n,t)):a=t,{pathname:a,search:Ue(r),hash:We(i)}}function Pe(e,t){let n=Ve(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function Fe(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function Ie(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Le(e){let t=Ie(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Re(e,t,n,r=!1){let i;typeof e==`string`?i=ue(e):(i={...e},ie(!i.pathname||!i.pathname.includes(`?`),Fe(`?`,`pathname`,`search`,i)),ie(!i.pathname||!i.pathname.includes(`#`),Fe(`#`,`pathname`,`hash`,i)),ie(!i.search||!i.search.includes(`#`),Fe(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=Ne(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var ze=e=>e.replace(/[\\/]{2,}/g,`/`),Be=e=>ze(e.join(`/`));function Ve(e,t=0){let n=e.length;for(;n>t&&e.charCodeAt(n-1)===47;)n--;return n===e.length?e:e.slice(0,n)}var He=e=>Ve(e).replace(/^\/*/,`/`),Ue=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,We=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,Ge=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Ke(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function qe(e){return Be(e.map(e=>e.route.path).filter(Boolean))||`/`}var Je=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Ye(e,t){let n=e;if(typeof n!=`string`||!C.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Je)try{let e=new URL(window.location.href),r=w.test(n)?new URL(ee(n,e.protocol)):new URL(n),a=Me(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{ae(!1,`<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Xe=new URL(`http://localhost`);function Ze(e){if(e.createURL)return e.createURL(`/`);try{return new URL(e.createHref(`/`),Xe)}catch{return Xe}}function Qe(e,t){return e.origin===t.origin&&(e.origin!==`null`||e.protocol===t.protocol&&e.host===t.host)}function $e(e,t){if(e.startsWith(`//`))return!0;let n=t.protocol.toLowerCase();return e.toLowerCase().startsWith(n)?t.host===``||e.slice(n.length).startsWith(`//`):!1}function et(e,t,n,r){let i=null;try{i=e==null?null:new URL(e,n)}catch{}let a=new URL(t,n),o=i!=null&&!Qe(i,n),s=!Qe(a,n);if(r===`reject`){if(o||s)throw Error(`External navigation is not allowed`)}else if(s&&(i==null||!$e(e,i)||!Qe(i,a)))throw Error(`External navigation is not allowed`)}var tt=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(tt);var nt=[`GET`,...tt];new Set(nt);var rt=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function it(e){try{return rt.includes(new URL(e).protocol)}catch{return!1}}var at=S.createContext(null);at.displayName=`DataRouter`;var ot=S.createContext(null);ot.displayName=`DataRouterState`;var st=S.createContext(!1);function ct(){return S.useContext(st)}var lt=S.createContext({isTransitioning:!1});lt.displayName=`ViewTransition`;var ut=S.createContext(new Map);ut.displayName=`Fetchers`;var dt=S.createContext(null);dt.displayName=`Await`;var ft=S.createContext(null);ft.displayName=`Navigation`;var pt=S.createContext(null);pt.displayName=`Location`;var mt=S.createContext({outlet:null,matches:[],isDataRoute:!1});mt.displayName=`Route`;var ht=S.createContext(null);ht.displayName=`RouteError`;var gt=`REACT_ROUTER_ERROR`,_t=`REDIRECT`,vt=`ROUTE_ERROR_RESPONSE`;function yt(e){if(e.startsWith(`${gt}:${_t}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function bt(e){if(e.startsWith(`${gt}:${vt}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new Ge(t.status,t.statusText,t.data)}catch{}}function xt(e,{relative:t}={}){ie(St(),`useHref() may be used only in the context of a <Router> component.`);let{basename:n,navigator:r}=S.useContext(ft),{hash:i,pathname:a,search:o}=kt(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Be([n,a])),r.createHref({pathname:s,search:o,hash:i})}function St(){return S.useContext(pt)!=null}function Ct(){return ie(St(),`useLocation() may be used only in the context of a <Router> component.`),S.useContext(pt).location}var wt=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function Tt(e){S.useContext(ft).static||S.useLayoutEffect(e)}function Et(){let{isDataRoute:e}=S.useContext(mt);return e?Kt():Dt()}function Dt(){ie(St(),`useNavigate() may be used only in the context of a <Router> component.`);let e=S.useContext(at),{basename:t,navigator:n}=S.useContext(ft),{matches:r}=S.useContext(mt),{pathname:i}=Ct(),a=JSON.stringify(Le(r)),o=S.useRef(!1);return Tt(()=>{o.current=!0}),S.useCallback((r,s={})=>{if(ae(o.current,wt),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Re(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Be([t,c.pathname])),et(typeof r==`string`?r:le(r),n.createHref(c),Ze(n),`reject`),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}S.createContext(null);function Ot(){let{matches:e}=S.useContext(mt);return e[e.length-1]?.params??{}}function kt(e,{relative:t}={}){let{matches:n}=S.useContext(mt),{pathname:r}=Ct(),i=JSON.stringify(Le(n));return S.useMemo(()=>Re(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function At(e,t){return jt(e,t)}function jt(e,t,n){ie(St(),`useRoutes() may be used only in the context of a <Router> component.`);let{navigator:r}=S.useContext(ft),{matches:i}=S.useContext(mt),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;Jt(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${s}" (under <Route path="${e}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
10
|
+
|
|
11
|
+
Please change the parent <Route path="${e}"> to <Route path="${e===`/`?`*`:`${e}/*`}">.`)}let u=Ct(),d;if(t){let e=typeof t==`string`?ue(t):t;ie(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):fe(e,{pathname:p});ae(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),ae(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let h=Rt(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:Be([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:Be([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?S.createElement(pt.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function Mt(){let e=Gt(),t=Ke(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=S.createElement(S.Fragment,null,S.createElement(`p`,null,`💿 Hey developer 👋`),S.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,S.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,S.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),S.createElement(S.Fragment,null,S.createElement(`h2`,null,`Unexpected Application Error!`),S.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?S.createElement(`pre`,{style:i},n):null,o)}var Nt=S.createElement(Mt,null),Pt=class extends S.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=bt(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:S.createElement(mt.Provider,{value:this.props.routeContext},S.createElement(ht.Provider,{value:e,children:this.props.component}));return this.context?S.createElement(It,{error:e},t):t}};Pt.contextType=st;var Ft=new WeakMap;function It({children:e,error:t}){let{basename:n,navigator:r}=S.useContext(ft);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=yt(t.digest);if(e){let i=Ft.get(t);if(i)throw i;let a=Ye(e.location,n),o=a.absoluteURL||a.to;if(et(e.location,o,Ze(r),`allow-explicit`),it(o))throw Error(`Invalid redirect location`);if(Je&&!Ft.get(t)){if(a.isExternal||e.reloadDocument)window.location.href=o;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(a.to,{replace:e.replace}));throw Ft.set(t,n),n}}return S.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${o}`})}}return e}function Lt({routeContext:e,match:t,children:n}){let r=S.useContext(at);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),S.createElement(mt.Provider,{value:e},n)}function Rt(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);ie(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e<i.length;e++){let t=i[e];if((t.route.HydrateFallback||t.route.hydrateFallbackElement)&&(s=e),t.route.id){let{loaderData:e,errors:a}=r,c=t.route.loader&&!e.hasOwnProperty(t.route.id)&&(!a||a[t.route.id]===void 0);if(t.route.lazy||c){n.isStatic&&(o=!0),i=s>=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:qe(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||Nt,o&&(s<0&&c===0?(Jt(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?S.createElement(n.route.Component,null):n.route.element?n.route.element:e,S.createElement(Lt,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?S.createElement(Pt,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function zt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Bt(e){let t=S.useContext(at);return ie(t,zt(e)),t}function Vt(e){let t=S.useContext(ot);return ie(t,zt(e)),t}function Ht(e){let t=S.useContext(mt);return ie(t,zt(e)),t}function Ut(e){let t=Ht(e),n=t.matches[t.matches.length-1];return ie(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Wt(){return Ut(`useRouteId`)}function Gt(){let e=S.useContext(ht),t=Vt(`useRouteError`),n=Ut(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Kt(){let{router:e}=Bt(`useNavigate`),t=Ut(`useNavigate`),n=S.useRef(!1);return Tt(()=>{n.current=!0}),S.useCallback(async(r,i={})=>{ae(n.current,wt),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var qt={};function Jt(e,t,n){!t&&!qt[e]&&(qt[e]=!0,ae(!1,n))}S.memo(Yt);function Yt({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return jt(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function Xt(e){ie(!1,`A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.`)}function Zt({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){ie(!St(),`You cannot render a <Router> inside another <Router>. You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=S.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=ue(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=S.useMemo(()=>{let e=Me(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return ae(h!=null,`<Router basename="${s}"> is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the <Router> won't render anything.`),h==null?null:S.createElement(ft.Provider,{value:c},S.createElement(pt.Provider,{children:t,value:h}))}function Qt({children:e,location:t}){return At($t(e),t)}S.Component;function $t(e,t=[]){let n=[];return S.Children.forEach(e,(e,r)=>{if(!S.isValidElement(e))return;let i=[...t,r];if(e.type===S.Fragment){n.push.apply(n,$t(e.props.children,i));return}ie(e.type===Xt,`[${typeof e.type==`string`?e.type:e.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),ie(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=$t(e.props.children,i)),n.push(a)}),n}var en=`get`,tn=`application/x-www-form-urlencoded`;function nn(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function rn(e){return nn(e)&&e.tagName.toLowerCase()===`button`}function an(e){return nn(e)&&e.tagName.toLowerCase()===`form`}function on(e){return nn(e)&&e.tagName.toLowerCase()===`input`}function sn(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function cn(e,t){return e.button===0&&(!t||t===`_self`)&&!sn(e)}var ln=null;function un(){if(ln===null)try{new FormData(document.createElement(`form`),0),ln=!1}catch{ln=!0}return ln}var dn=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function fn(e){return e!=null&&!dn.has(e)?(ae(!1,`"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${tn}"`),null):e}function pn(e,t){let n,r,i,a,o;if(an(e)){let o=e.getAttribute(`action`);r=o?Me(o,t):null,n=e.getAttribute(`method`)||en,i=fn(e.getAttribute(`enctype`))||tn,a=new FormData(e)}else if(rn(e)||on(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a <button> or <input type="submit"> without a <form>`);let s=e.getAttribute(`formaction`)||o.getAttribute(`action`);if(r=s?Me(s,t):null,n=e.getAttribute(`formmethod`)||o.getAttribute(`method`)||en,i=fn(e.getAttribute(`formenctype`))||fn(o.getAttribute(`enctype`))||tn,a=new FormData(o,e),!un()){let{name:t,type:n,value:r}=e;if(n===`image`){let e=t?`${t}.`:``;a.append(`${e}x`,`0`),a.append(`${e}y`,`0`)}else t&&a.append(t,r)}}else if(nn(e))throw Error(`Cannot submit element that is not <form>, <button>, or <input type="submit|image">`);else n=en,r=null,i=tn,o=e;return a&&i===`text/plain`&&(o=a,a=void 0),{action:r,method:n.toLowerCase(),encType:i,formData:a,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function mn(e,t){if(e===!1||e==null)throw Error(t)}function hn(e,t,n,r){let i=typeof e==`string`?new URL(e,typeof window>`u`?`server://singlefetch/`:window.location.origin):e;return i.pathname=n?i.pathname.endsWith(`/`)?`${i.pathname}_.${r}`:`${i.pathname}.${r}`:i.pathname===`/`?`_root.${r}`:t&&Me(i.pathname,t)===`/`?`${Ve(t)}/_root.${r}`:`${Ve(i.pathname)}.${r}`,i}async function gn(e,t){if(e.id in t)return t[e.id];try{let n=await x(()=>import(e.module),[]);return t[e.id]=n,n}catch(t){return console.error(`Error loading route module \`${e.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function _n(e){return e!=null&&typeof e.page==`string`}function vn(e){return e==null?!1:e.href==null?e.rel===`preload`&&typeof e.imageSrcSet==`string`&&typeof e.imageSizes==`string`:typeof e.rel==`string`&&typeof e.href==`string`}async function yn(e,t,n){return wn((await Promise.all(e.map(async e=>{let r=t.routes[e.route.id];if(r){let e=await gn(r,n);return e.links?e.links():[]}return[]}))).flat(1).filter(vn).filter(e=>e.rel===`stylesheet`||e.rel===`preload`).map(e=>e.rel===`stylesheet`?{...e,rel:`prefetch`,as:`style`}:{...e,rel:`prefetch`}))}function bn(e,t,n,r,i,a){let o=(e,t)=>!n[t]||e.route.id!==n[t].route.id,s=(e,t)=>n[t].pathname!==e.pathname||n[t].route.path?.endsWith(`*`)&&n[t].params[`*`]!==e.params[`*`];return a===`assets`?t.filter((e,t)=>o(e,t)||s(e,t)):a===`data`?t.filter((t,a)=>{let c=r.routes[t.route.id];if(!c||!c.hasLoader)return!1;if(o(t,a)||s(t,a))return!0;if(t.route.shouldRevalidate){let r=t.route.shouldRevalidate({currentUrl:new URL(i.pathname+i.search+i.hash,window.origin),currentParams:n[0]?.params||{},nextUrl:new URL(e,window.origin),nextParams:t.params,defaultShouldRevalidate:!0});if(typeof r==`boolean`)return r}return!0}):[]}function xn(e,t,{includeHydrateFallback:n}={}){return Sn(e.map(e=>{let r=t.routes[e.route.id];if(!r)return[];let i=[r.module];return r.clientActionModule&&(i=i.concat(r.clientActionModule)),r.clientLoaderModule&&(i=i.concat(r.clientLoaderModule)),n&&r.hydrateFallbackModule&&(i=i.concat(r.hydrateFallbackModule)),r.imports&&(i=i.concat(r.imports)),i}).flat(1))}function Sn(e){return[...new Set(e)]}function Cn(e){let t={},n=Object.keys(e).sort();for(let r of n)t[r]=e[r];return t}function wn(e,t){let n=new Set,r=new Set(t);return e.reduce((e,i)=>{if(t&&!_n(i)&&i.as===`script`&&i.href&&r.has(i.href))return e;let a=JSON.stringify(Cn(i));return n.has(a)||(n.add(a),e.push({key:a,link:i})),e},[])}function Tn(){let e=S.useContext(at);return mn(e,`You must render this element inside a <DataRouterContext.Provider> element`),e}function En(){let e=S.useContext(ot);return mn(e,`You must render this element inside a <DataRouterStateContext.Provider> element`),e}var Dn=S.createContext(void 0);Dn.displayName=`FrameworkContext`;function On(){let e=S.useContext(Dn);return mn(e,`You must render this element inside a <HydratedRouter> element`),e}function kn(e,t){let n=S.useContext(Dn),[r,i]=S.useState(!1),[a,o]=S.useState(!1),{onFocus:s,onBlur:c,onMouseEnter:l,onMouseLeave:u,onTouchStart:d}=t,f=S.useRef(null);S.useEffect(()=>{if(e===`render`&&o(!0),e===`viewport`){let e=new IntersectionObserver(e=>{e.forEach(e=>{o(e.isIntersecting)})},{threshold:.5});return f.current&&e.observe(f.current),()=>{e.disconnect()}}},[e]),S.useEffect(()=>{if(r){let e=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(e)}}},[r]);let p=()=>{i(!0)},m=()=>{i(!1),o(!1)};return n?e===`intent`?[a,f,{onFocus:An(s,p),onBlur:An(c,m),onMouseEnter:An(l,p),onMouseLeave:An(u,m),onTouchStart:An(d,p)}]:[a,f,{}]:[!1,f,{}]}function An(e,t){return n=>{e&&e(n),n.defaultPrevented||t(n)}}function jn({page:e,...t}){let n=ct(),{nonce:r}=On(),{router:i}=Tn(),a=S.useMemo(()=>fe(i.routes,e,i.basename),[i.routes,e,i.basename]);return a?(t.nonce==null&&r&&(t={...t,nonce:r}),n?S.createElement(Nn,{page:e,matches:a,...t}):S.createElement(Pn,{page:e,matches:a,...t})):null}function Mn(e){let{manifest:t,routeModules:n}=On(),[r,i]=S.useState([]);return S.useEffect(()=>{let r=!1;return yn(e,t,n).then(e=>{r||i(e)}),()=>{r=!0}},[e,t,n]),r}function Nn({page:e,matches:t,...n}){let r=Ct(),{future:i}=On(),{basename:a}=Tn(),o=S.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=hn(e,a,i.v8_trailingSlashAwareDataRequests,`rsc`),o=!1,s=[];for(let e of t)typeof e.route.shouldRevalidate==`function`?o=!0:s.push(e.route.id);return o&&s.length>0&&n.searchParams.set(`_routes`,s.join(`,`)),[n.pathname+n.search]},[a,i.v8_trailingSlashAwareDataRequests,e,r,t]);return S.createElement(S.Fragment,null,o.map(e=>S.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})))}function Pn({page:e,matches:t,...n}){let r=Ct(),{future:i,manifest:a,routeModules:o}=On(),{basename:s}=Tn(),{loaderData:c,matches:l}=En(),u=S.useMemo(()=>bn(e,t,l,a,r,`data`),[e,t,l,a,r]),d=S.useMemo(()=>bn(e,t,l,a,r,`assets`),[e,t,l,a,r]),f=S.useMemo(()=>{if(e===r.pathname+r.search+r.hash)return[];let n=new Set,l=!1;if(t.forEach(e=>{let t=a.routes[e.route.id];!t||!t.hasLoader||(!u.some(t=>t.route.id===e.route.id)&&e.route.id in c&&o[e.route.id]?.shouldRevalidate||t.hasClientLoader?l=!0:n.add(e.route.id))}),n.size===0)return[];let d=hn(e,s,i.v8_trailingSlashAwareDataRequests,`data`);return l&&n.size>0&&d.searchParams.set(`_routes`,t.filter(e=>n.has(e.route.id)).map(e=>e.route.id).join(`,`)),[d.pathname+d.search]},[s,i.v8_trailingSlashAwareDataRequests,c,r,a,u,t,e,o]),p=S.useMemo(()=>xn(d,a),[d,a]),m=Mn(d);return S.createElement(S.Fragment,null,f.map(e=>S.createElement(`link`,{key:e,rel:`prefetch`,as:`fetch`,href:e,...n})),p.map(e=>S.createElement(`link`,{key:e,rel:`modulepreload`,href:e,...n})),m.map(({key:e,link:t})=>S.createElement(`link`,{key:e,nonce:n.nonce,...t,crossOrigin:t.crossOrigin??n.crossOrigin})))}function Fn(...e){return t=>{e.forEach(e=>{typeof e==`function`?e(t):e!=null&&(e.current=t)})}}S.Component;var In=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;try{In&&(window.__reactRouterVersion=`7.18.3`)}catch{}function Ln({basename:e,children:t,useTransitions:n,window:r}){let i=S.useRef();i.current??=re({window:r,v5Compat:!0});let a=i.current,[o,s]=S.useState({action:a.action,location:a.location}),c=S.useCallback(e=>{n===!1?s(e):S.startTransition(()=>s(e))},[n]);return S.useLayoutEffect(()=>a.listen(c),[a,c]),S.createElement(Zt,{basename:e,children:t,location:o.location,navigationType:o.action,navigator:a,useTransitions:n})}var Rn=S.forwardRef(function({onClick:e,discover:t=`render`,prefetch:n=`none`,relative:r,reloadDocument:i,replace:a,mask:o,state:s,target:c,to:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m){let{basename:h,navigator:g,useTransitions:_}=S.useContext(ft),v=typeof l==`string`&&C.test(l),y=Ye(l,h);l=y.to;let b=xt(l,{relative:r}),x=Ct(),w=null;if(o){let e=Re(o,[],x.mask?x.mask.pathname:`/`,!0);h!==`/`&&(e.pathname=e.pathname===`/`?h:Be([h,e.pathname])),w=g.createHref(e)}let[ee,te,ne]=kn(n,p),re=Un(l,{replace:a,mask:o,state:s,target:c,preventScrollReset:u,relative:r,viewTransition:d,defaultShouldRevalidate:f,useTransitions:_});function ie(t){e&&e(t),t.defaultPrevented||re(t)}let ae=!(y.isExternal||i),oe=S.createElement(`a`,{...p,...ne,href:(ae?w:void 0)||y.absoluteURL||b,onClick:ae?ie:e,ref:Fn(m,te),target:c,"data-discover":!v&&t===`render`?`true`:void 0});return ee&&!v?S.createElement(S.Fragment,null,oe,S.createElement(jn,{page:b})):oe});Rn.displayName=`Link`;var zn=S.forwardRef(function({"aria-current":e=`page`,caseSensitive:t=!1,className:n=``,end:r=!1,style:i,to:a,viewTransition:o,children:s,...c},l){let u=kt(a,{relative:c.relative}),d=Ct(),f=S.useContext(ot),{navigator:p,basename:m}=S.useContext(ft),h=f!=null&&Jn(u)&&o===!0,g=p.encodeLocation?p.encodeLocation(u).pathname:u.pathname,_=d.pathname,v=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(_=_.toLowerCase(),v=v?v.toLowerCase():null,g=g.toLowerCase()),v&&m&&(v=Me(v,m)||v);let y=g!==`/`&&g.endsWith(`/`)?g.length-1:g.length,b=_===g||!r&&_.startsWith(g)&&_.charAt(y)===`/`,x=v!=null&&(v===g||!r&&v.startsWith(g)&&v.charAt(g.length)===`/`),C={isActive:b,isPending:x,isTransitioning:h},w=b?e:void 0,ee;ee=typeof n==`function`?n(C):[n,b?`active`:null,x?`pending`:null,h?`transitioning`:null].filter(Boolean).join(` `);let te=typeof i==`function`?i(C):i;return S.createElement(Rn,{...c,"aria-current":w,className:ee,ref:l,style:te,to:a,viewTransition:o},typeof s==`function`?s(C):s)});zn.displayName=`NavLink`;var Bn=S.forwardRef(({discover:e=`render`,fetcherKey:t,navigate:n,reloadDocument:r,replace:i,state:a,method:o=en,action:s,onSubmit:c,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f,...p},m)=>{let{useTransitions:h}=S.useContext(ft),g=Kn(),_=qn(s,{relative:l}),v=o.toLowerCase()===`get`?`get`:`post`,y=typeof s==`string`&&C.test(s);return S.createElement(`form`,{ref:m,method:v,action:_,onSubmit:r?c:e=>{if(c&&c(e),e.defaultPrevented)return;e.preventDefault();let r=e.nativeEvent.submitter,s=r?.getAttribute(`formmethod`)||o,p=()=>g(r||e.currentTarget,{fetcherKey:t,method:s,navigate:n,replace:i,state:a,relative:l,preventScrollReset:u,viewTransition:d,defaultShouldRevalidate:f});h&&n!==!1?S.startTransition(()=>p()):p()},...p,"data-discover":!y&&e===`render`?`true`:void 0})});Bn.displayName=`Form`;function Vn(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Hn(e){let t=S.useContext(at);return ie(t,Vn(e)),t}function Un(e,{target:t,replace:n,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c,useTransitions:l}={}){let u=Et(),d=Ct(),f=kt(e,{relative:o});return S.useCallback(p=>{if(cn(p,t)){p.preventDefault();let t=n===void 0?le(d)===le(f):n,m=()=>u(e,{replace:t,mask:r,state:i,preventScrollReset:a,relative:o,viewTransition:s,defaultShouldRevalidate:c});l?S.startTransition(()=>m()):m()}},[d,u,f,n,r,i,t,e,a,o,s,c,l])}var Wn=0,Gn=()=>`__${String(++Wn)}__`;function Kn(){let{router:e}=Hn(`useSubmit`),{basename:t}=S.useContext(ft),n=Wt(),r=e.fetch,i=e.navigate;return S.useCallback(async(e,a={})=>{let{action:o,method:s,encType:c,formData:l,body:u}=pn(e,t);if(a.navigate===!1){let e=a.fetcherKey||Gn();await r(e,n,a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,flushSync:a.flushSync})}else await i(a.action||o,{defaultShouldRevalidate:a.defaultShouldRevalidate,preventScrollReset:a.preventScrollReset,formData:l,body:u,formMethod:a.method||s,formEncType:a.encType||c,replace:a.replace,state:a.state,fromRouteId:n,flushSync:a.flushSync,viewTransition:a.viewTransition})},[r,i,t,n])}function qn(e,{relative:t}={}){let{basename:n}=S.useContext(ft),r=S.useContext(mt);ie(r,`useFormAction must be used inside a RouteContext`);let[i]=r.matches.slice(-1),a={...kt(e||`.`,{relative:t})},o=Ct();if(e==null){a.search=o.search;let e=new URLSearchParams(a.search),t=e.getAll(`index`);if(t.some(e=>e===``)){e.delete(`index`),t.filter(e=>e).forEach(t=>e.append(`index`,t));let n=e.toString();a.search=n?`?${n}`:``}}return(!e||e===`.`)&&i.route.index&&(a.search=a.search?a.search.replace(/^\?/,`?index&`):`?index`),n!==`/`&&(a.pathname=a.pathname===`/`?n:Be([n,a.pathname])),le(a)}function Jn(e,{relative:t}={}){let n=S.useContext(lt);ie(n!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:r}=Hn(`useViewTransitionState`),i=kt(e,{relative:t});if(!n.isTransitioning)return!1;let a=Me(n.currentLocation.pathname,r)||n.currentLocation.pathname,o=Me(n.nextLocation.pathname,r)||n.nextLocation.pathname;return Oe(i.pathname,o)!=null||Oe(i.pathname,a)!=null}var Yn=[];for(let e=0;e<256;++e)Yn.push((e+256).toString(16).slice(1));function Xn(e,t=0){return(Yn[e[t+0]]+Yn[e[t+1]]+Yn[e[t+2]]+Yn[e[t+3]]+`-`+Yn[e[t+4]]+Yn[e[t+5]]+`-`+Yn[e[t+6]]+Yn[e[t+7]]+`-`+Yn[e[t+8]]+Yn[e[t+9]]+`-`+Yn[e[t+10]]+Yn[e[t+11]]+Yn[e[t+12]]+Yn[e[t+13]]+Yn[e[t+14]]+Yn[e[t+15]]).toLowerCase()}var Zn,Qn=new Uint8Array(16);function $n(){if(!Zn){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);Zn=crypto.getRandomValues.bind(crypto)}return Zn(Qn)}var er={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function tr(e,t,n){if(er.randomUUID&&!t&&!e)return er.randomUUID();e||={};let r=e.random??e.rng?.()??$n();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Xn(r)}var nr;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(nr||={});var rr;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(rr||={});var E=nr.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),ir=e=>{switch(typeof e){case`undefined`:return E.undefined;case`string`:return E.string;case`number`:return Number.isNaN(e)?E.nan:E.number;case`boolean`:return E.boolean;case`function`:return E.function;case`bigint`:return E.bigint;case`symbol`:return E.symbol;case`object`:return Array.isArray(e)?E.array:e===null?E.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?E.promise:typeof Map<`u`&&e instanceof Map?E.map:typeof Set<`u`&&e instanceof Set?E.set:typeof Date<`u`&&e instanceof Date?E.date:E.object;default:return E.unknown}},D=nr.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),ar=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,nr.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};ar.create=e=>new ar(e);var or=(e,t)=>{let n;switch(e.code){case D.invalid_type:n=e.received===E.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case D.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,nr.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:n=`Unrecognized key(s) in object: ${nr.joinValues(e.keys,`, `)}`;break;case D.invalid_union:n=`Invalid input`;break;case D.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${nr.joinValues(e.options)}`;break;case D.invalid_enum_value:n=`Invalid enum value. Expected ${nr.joinValues(e.options)}, received '${e.received}'`;break;case D.invalid_arguments:n=`Invalid function arguments`;break;case D.invalid_return_type:n=`Invalid function return type`;break;case D.invalid_date:n=`Invalid date`;break;case D.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:nr.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case D.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case D.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case D.custom:n=`Invalid input`;break;case D.invalid_intersection_types:n=`Intersection results could not be merged`;break;case D.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case D.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,nr.assertNever(e)}return{message:n}},sr=or;function cr(){return sr}var lr=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function O(e,t){let n=cr(),r=lr({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===or?void 0:or].filter(e=>!!e)});e.common.issues.push(r)}var ur=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return k;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return k;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},k=Object.freeze({status:`aborted`}),dr=e=>({status:`dirty`,value:e}),fr=e=>({status:`valid`,value:e}),pr=e=>e.status===`aborted`,mr=e=>e.status===`dirty`,hr=e=>e.status===`valid`,gr=e=>typeof Promise<`u`&&e instanceof Promise,A;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(A||={});var _r=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},vr=(e,t)=>{if(hr(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new ar(e.common.issues);return this._error=t,this._error}}};function j(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var yr=class{get description(){return this._def.description}_getType(e){return ir(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:ir(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ur,ctx:{common:e.parent.common,data:e.data,parsedType:ir(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(gr(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)};return vr(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return hr(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>hr(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ir(e)},r=this._parse({data:e,path:n.path,parent:n});return vr(n,await(gr(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:D.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new Si({schema:this,typeName:M.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return Ci.create(this,this._def)}nullable(){return wi.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ri.create(this)}promise(){return xi.create(this,this._def)}or(e){return oi.create([this,e],this._def)}and(e){return ui.create(this,e,this._def)}transform(e){return new Si({...j(this._def),schema:this,typeName:M.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new Ti({...j(this._def),innerType:this,defaultValue:t,typeName:M.ZodDefault})}brand(){return new Oi({typeName:M.ZodBranded,type:this,...j(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new Ei({...j(this._def),innerType:this,catchValue:t,typeName:M.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ki.create(this,e)}readonly(){return Ai.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},br=/^c[^\s-]{8,}$/i,xr=/^[0-9a-z]+$/,Sr=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Cr=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,wr=/^[a-z0-9_-]{21}$/i,Tr=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Er=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Dr=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Or=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,kr,Ar=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,jr=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Mr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Nr=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Pr=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Fr=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ir=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,Lr=RegExp(`^${Ir}$`);function Rr(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function zr(e){return RegExp(`^${Rr(e)}$`)}function Br(e){let t=`${Ir}T${Rr(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function Vr(e,t){return!!((t===`v4`||!t)&&Ar.test(e)||(t===`v6`||!t)&&Mr.test(e))}function Hr(e,t){if(!Tr.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Ur(e,t){return!!((t===`v4`||!t)&&jr.test(e)||(t===`v6`||!t)&&Nr.test(e))}var Wr=class e extends yr{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==E.string){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.string,received:t.parsedType}),k}let t=new ur,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:D.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:D.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?O(n,{code:D.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&O(n,{code:D.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Dr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`email`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)kr||=new RegExp(Or,`u`),kr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`emoji`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Cr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`uuid`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)wr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`nanoid`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)br.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`cuid`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)xr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`cuid2`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Sr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`ulid`,code:D.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),O(n,{validation:`url`,code:D.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`regex`,code:D.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Br(r).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Lr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?zr(r).test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{code:D.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Er.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`duration`,code:D.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?Vr(e.data,r.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`ip`,code:D.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Hr(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`jwt`,code:D.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Ur(e.data,r.version)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`cidr`,code:D.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Pr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`base64`,code:D.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Fr.test(e.data)||(n=this._getOrReturnCtx(e,n),O(n,{validation:`base64url`,code:D.invalid_string,message:r.message}),t.dirty()):nr.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:D.invalid_string,...A.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...A.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...A.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...A.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...A.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...A.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...A.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...A.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...A.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...A.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...A.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...A.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...A.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...A.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...A.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...A.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...A.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Wr.create=e=>new Wr({checks:[],typeName:M.ZodString,coerce:e?.coerce??!1,...j(e)});function Gr(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var Kr=class e extends yr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==E.number){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.number,received:t.parsedType}),k}let t,n=new ur;for(let r of this._def.checks)r.kind===`int`?nr.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),O(t,{code:D.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Gr(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),O(t,{code:D.not_finite,message:r.message}),n.dirty()):nr.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,A.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,A.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,A.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,A.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:A.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:A.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:A.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:A.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:A.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&nr.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};Kr.create=e=>new Kr({checks:[],typeName:M.ZodNumber,coerce:e?.coerce||!1,...j(e)});var qr=class e extends yr{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==E.bigint)return this._getInvalidInput(e);let t,n=new ur;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),O(t,{code:D.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):nr.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.bigint,received:t.parsedType}),k}gte(e,t){return this.setLimit(`min`,e,!0,A.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,A.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,A.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,A.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:A.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:A.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};qr.create=e=>new qr({checks:[],typeName:M.ZodBigInt,coerce:e?.coerce??!1,...j(e)});var Jr=class extends yr{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==E.boolean){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.boolean,received:t.parsedType}),k}return fr(e.data)}};Jr.create=e=>new Jr({typeName:M.ZodBoolean,coerce:e?.coerce||!1,...j(e)});var Yr=class e extends yr{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==E.date){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.date,received:t.parsedType}),k}if(Number.isNaN(e.data.getTime()))return O(this._getOrReturnCtx(e),{code:D.invalid_date}),k;let t=new ur,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:D.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),O(n,{code:D.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):nr.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Yr.create=e=>new Yr({checks:[],coerce:e?.coerce||!1,typeName:M.ZodDate,...j(e)});var Xr=class extends yr{_parse(e){if(this._getType(e)!==E.symbol){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.symbol,received:t.parsedType}),k}return fr(e.data)}};Xr.create=e=>new Xr({typeName:M.ZodSymbol,...j(e)});var Zr=class extends yr{_parse(e){if(this._getType(e)!==E.undefined){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.undefined,received:t.parsedType}),k}return fr(e.data)}};Zr.create=e=>new Zr({typeName:M.ZodUndefined,...j(e)});var Qr=class extends yr{_parse(e){if(this._getType(e)!==E.null){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.null,received:t.parsedType}),k}return fr(e.data)}};Qr.create=e=>new Qr({typeName:M.ZodNull,...j(e)});var $r=class extends yr{constructor(){super(...arguments),this._any=!0}_parse(e){return fr(e.data)}};$r.create=e=>new $r({typeName:M.ZodAny,...j(e)});var ei=class extends yr{constructor(){super(...arguments),this._unknown=!0}_parse(e){return fr(e.data)}};ei.create=e=>new ei({typeName:M.ZodUnknown,...j(e)});var ti=class extends yr{_parse(e){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.never,received:t.parsedType}),k}};ti.create=e=>new ti({typeName:M.ZodNever,...j(e)});var ni=class extends yr{_parse(e){if(this._getType(e)!==E.undefined){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.void,received:t.parsedType}),k}return fr(e.data)}};ni.create=e=>new ni({typeName:M.ZodVoid,...j(e)});var ri=class e extends yr{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==E.array)return O(t,{code:D.invalid_type,expected:E.array,received:t.parsedType}),k;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(O(t,{code:e?D.too_big:D.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(O(t,{code:D.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(O(t,{code:D.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new _r(t,e,t.path,n)))).then(e=>ur.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new _r(t,e,t.path,n)));return ur.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:A.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:A.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:A.toString(n)}})}nonempty(e){return this.min(1,e)}};ri.create=(e,t)=>new ri({type:e,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...j(t)});function ii(e){if(e instanceof ai){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=Ci.create(ii(r))}return new ai({...e._def,shape:()=>t})}return e instanceof ri?new ri({...e._def,type:ii(e.element)}):e instanceof Ci?Ci.create(ii(e.unwrap())):e instanceof wi?wi.create(ii(e.unwrap())):e instanceof di?di.create(e.items.map(e=>ii(e))):e}var ai=class e extends yr{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=nr.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==E.object){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.object,received:t.parsedType}),k}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof ti&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new _r(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof ti){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(O(n,{code:D.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new _r(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>ur.mergeObjectSync(t,e)):ur.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return A.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:A.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:M.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of nr.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of nr.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return ii(this)}partial(t){let n={};for(let e of nr.objectKeys(this.shape)){let r=this.shape[e];n[e]=t&&!t[e]?r:r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of nr.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof Ci;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return vi(nr.objectKeys(this.shape))}};ai.create=(e,t)=>new ai({shape:()=>e,unknownKeys:`strip`,catchall:ti.create(),typeName:M.ZodObject,...j(t)}),ai.strictCreate=(e,t)=>new ai({shape:()=>e,unknownKeys:`strict`,catchall:ti.create(),typeName:M.ZodObject,...j(t)}),ai.lazycreate=(e,t)=>new ai({shape:e,unknownKeys:`strip`,catchall:ti.create(),typeName:M.ZodObject,...j(t)});var oi=class extends yr{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new ar(e.ctx.common.issues));return O(t,{code:D.invalid_union,unionErrors:n}),k}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new ar(e));return O(t,{code:D.invalid_union,unionErrors:i}),k}}get options(){return this._def.options}};oi.create=(e,t)=>new oi({options:e,typeName:M.ZodUnion,...j(t)});var si=e=>e instanceof gi?si(e.schema):e instanceof Si?si(e.innerType()):e instanceof _i?[e.value]:e instanceof yi?e.options:e instanceof bi?nr.objectValues(e.enum):e instanceof Ti?si(e._def.innerType):e instanceof Zr?[void 0]:e instanceof Qr?[null]:e instanceof Ci?[void 0,...si(e.unwrap())]:e instanceof wi?[null,...si(e.unwrap())]:e instanceof Oi||e instanceof Ai?si(e.unwrap()):e instanceof Ei?si(e._def.innerType):[],ci=class e extends yr{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==E.object)return O(t,{code:D.invalid_type,expected:E.object,received:t.parsedType}),k;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(O(t,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=si(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:M.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...j(r)})}};function li(e,t){let n=ir(e),r=ir(t);if(e===t)return{valid:!0,data:e};if(n===E.object&&r===E.object){let n=nr.objectKeys(t),r=nr.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=li(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===E.array&&r===E.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=li(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===E.date&&r===E.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var ui=class extends yr{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(pr(e)||pr(r))return k;let i=li(e.value,r.value);return i.valid?((mr(e)||mr(r))&&t.dirty(),{status:t.value,value:i.data}):(O(n,{code:D.invalid_intersection_types}),k)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ui.create=(e,t,n)=>new ui({left:e,right:t,typeName:M.ZodIntersection,...j(n)});var di=class e extends yr{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==E.array)return O(n,{code:D.invalid_type,expected:E.array,received:n.parsedType}),k;if(n.data.length<this._def.items.length)return O(n,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),k;!this._def.rest&&n.data.length>this._def.items.length&&(O(n,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new _r(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>ur.mergeArray(t,e)):ur.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};di.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new di({items:e,typeName:M.ZodTuple,rest:null,...j(t)})};var fi=class e extends yr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==E.object)return O(n,{code:D.invalid_type,expected:E.object,received:n.parsedType}),k;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new _r(n,e,n.path,e)),value:a._parse(new _r(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?ur.mergeObjectAsync(t,r):ur.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof yr?new e({keyType:t,valueType:n,typeName:M.ZodRecord,...j(r)}):new e({keyType:Wr.create(),valueType:t,typeName:M.ZodRecord,...j(n)})}},pi=class extends yr{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==E.map)return O(n,{code:D.invalid_type,expected:E.map,received:n.parsedType}),k;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new _r(n,e,n.path,[a,`key`])),value:i._parse(new _r(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return k;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return k;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};pi.create=(e,t,n)=>new pi({valueType:t,keyType:e,typeName:M.ZodMap,...j(n)});var mi=class e extends yr{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==E.set)return O(n,{code:D.invalid_type,expected:E.set,received:n.parsedType}),k;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(O(n,{code:D.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(O(n,{code:D.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return k;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new _r(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:A.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:A.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};mi.create=(e,t)=>new mi({valueType:e,minSize:null,maxSize:null,typeName:M.ZodSet,...j(t)});var hi=class e extends yr{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==E.function)return O(t,{code:D.invalid_type,expected:E.function,received:t.parsedType}),k;function n(e,n){return lr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cr(),or].filter(e=>!!e),issueData:{code:D.invalid_arguments,argumentsError:n}})}function r(e,n){return lr({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cr(),or].filter(e=>!!e),issueData:{code:D.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof xi){let e=this;return fr(async function(...t){let o=new ar([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return fr(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new ar([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new ar([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:di.create(t).rest(ei.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||di.create([]).rest(ei.create()),returns:n||ei.create(),typeName:M.ZodFunction,...j(r)})}},gi=class extends yr{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};gi.create=(e,t)=>new gi({getter:e,typeName:M.ZodLazy,...j(t)});var _i=class extends yr{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return O(t,{received:t.data,code:D.invalid_literal,expected:this._def.value}),k}return{status:`valid`,value:e.data}}get value(){return this._def.value}};_i.create=(e,t)=>new _i({value:e,typeName:M.ZodLiteral,...j(t)});function vi(e,t){return new yi({values:e,typeName:M.ZodEnum,...j(t)})}var yi=class e extends yr{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return O(t,{expected:nr.joinValues(n),received:t.parsedType,code:D.invalid_type}),k}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return O(t,{received:t.data,code:D.invalid_enum_value,options:n}),k}return fr(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};yi.create=vi;var bi=class extends yr{_parse(e){let t=nr.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==E.string&&n.parsedType!==E.number){let e=nr.objectValues(t);return O(n,{expected:nr.joinValues(e),received:n.parsedType,code:D.invalid_type}),k}if(this._cache||=new Set(nr.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=nr.objectValues(t);return O(n,{received:n.data,code:D.invalid_enum_value,options:e}),k}return fr(e.data)}get enum(){return this._def.values}};bi.create=(e,t)=>new bi({values:e,typeName:M.ZodNativeEnum,...j(t)});var xi=class extends yr{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==E.promise&&t.common.async===!1?(O(t,{code:D.invalid_type,expected:E.promise,received:t.parsedType}),k):fr((t.parsedType===E.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};xi.create=(e,t)=>new xi({type:e,typeName:M.ZodPromise,...j(t)});var Si=class extends yr{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{O(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return k;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?k:r.status===`dirty`||t.value===`dirty`?dr(r.value):r});{if(t.value===`aborted`)return k;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?k:r.status===`dirty`||t.value===`dirty`?dr(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?k:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?k:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!hr(e))return k;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>hr(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):k)}nr.assertNever(r)}};Si.create=(e,t,n)=>new Si({schema:e,typeName:M.ZodEffects,effect:t,...j(n)}),Si.createWithPreprocess=(e,t,n)=>new Si({schema:t,effect:{type:`preprocess`,transform:e},typeName:M.ZodEffects,...j(n)});var Ci=class extends yr{_parse(e){return this._getType(e)===E.undefined?fr(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Ci.create=(e,t)=>new Ci({innerType:e,typeName:M.ZodOptional,...j(t)});var wi=class extends yr{_parse(e){return this._getType(e)===E.null?fr(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};wi.create=(e,t)=>new wi({innerType:e,typeName:M.ZodNullable,...j(t)});var Ti=class extends yr{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===E.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ti.create=(e,t)=>new Ti({innerType:e,typeName:M.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...j(t)});var Ei=class extends yr{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return gr(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new ar(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new ar(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Ei.create=(e,t)=>new Ei({innerType:e,typeName:M.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...j(t)});var Di=class extends yr{_parse(e){if(this._getType(e)!==E.nan){let t=this._getOrReturnCtx(e);return O(t,{code:D.invalid_type,expected:E.nan,received:t.parsedType}),k}return{status:`valid`,value:e.data}}};Di.create=e=>new Di({typeName:M.ZodNaN,...j(e)});var Oi=class extends yr{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},ki=class e extends yr{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?k:e.status===`dirty`?(t.dirty(),dr(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?k:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:M.ZodPipeline})}},Ai=class extends yr{_parse(e){let t=this._def.innerType._parse(e),n=e=>(hr(e)&&(e.value=Object.freeze(e.value)),e);return gr(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};Ai.create=(e,t)=>new Ai({innerType:e,typeName:M.ZodReadonly,...j(t)}),ai.lazycreate;var M;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(M||={});var N=Wr.create,ji=Kr.create;Di.create,qr.create;var P=Jr.create;Yr.create,Xr.create,Zr.create,Qr.create;var Mi=$r.create,Ni=ei.create;ti.create,ni.create;var Pi=ri.create,Fi=ai.create;ai.strictCreate;var Ii=oi.create,Li=ci.create;ui.create,di.create;var Ri=fi.create;pi.create,mi.create,hi.create,gi.create;var F=_i.create,zi=yi.create,Bi=bi.create;xi.create,Si.create,Ci.create,wi.create,Si.createWithPreprocess,ki.create;var Vi=_(),Hi=Fi({name:N(),arguments:N()}),Ui=Fi({id:N(),type:F(`function`),function:Hi,encryptedValue:N().optional()}),Wi=Fi({id:N(),role:N(),content:N().optional(),name:N().optional(),encryptedValue:N().optional()}),Gi=Fi({type:F(`text`),text:N()}),Ki=Li(`type`,[Fi({type:F(`data`),value:N(),mimeType:N()}),Fi({type:F(`url`),value:N(),mimeType:N().optional()})]),qi=Fi({type:F(`image`),source:Ki,metadata:Ni().optional()}),Ji=Fi({type:F(`audio`),source:Ki,metadata:Ni().optional()}),Yi=Fi({type:F(`video`),source:Ki,metadata:Ni().optional()}),Xi=Fi({type:F(`document`),source:Ki,metadata:Ni().optional()}),Zi=Fi({type:F(`binary`),mimeType:N(),id:N().optional(),url:N().optional(),data:N().optional(),filename:N().optional()}),Qi=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:D.custom,message:`BinaryInputContent requires at least one of id, url, or data.`,path:[`id`]})};Zi.superRefine((e,t)=>{Qi(e,t)});var $i=Li(`type`,[Gi,qi,Ji,Yi,Xi,Zi]).superRefine((e,t)=>{e.type===`binary`&&Qi(e,t)}),ea=Li(`role`,[Wi.extend({role:F(`developer`),content:N()}),Wi.extend({role:F(`system`),content:N()}),Wi.extend({role:F(`assistant`),content:N().optional(),toolCalls:Pi(Ui).optional()}),Wi.extend({role:F(`user`),content:Ii([N(),Pi($i)])}),Fi({id:N(),content:N(),role:F(`tool`),toolCallId:N(),error:N().optional(),encryptedValue:N().optional()}),Fi({id:N(),role:F(`activity`),activityType:N(),content:Ri(Mi())}),Fi({id:N(),role:F(`reasoning`),content:N(),encryptedValue:N().optional()})]);Ii([F(`developer`),F(`system`),F(`assistant`),F(`user`),F(`tool`),F(`activity`),F(`reasoning`)]);var ta=Fi({description:N(),value:N()}),na=Fi({name:N(),description:N(),parameters:Mi(),metadata:Ri(Mi()).optional()}),ra=Fi({id:N(),reason:N(),message:N().optional(),toolCallId:N().optional(),responseSchema:Ri(Mi()).optional(),expiresAt:N().optional(),metadata:Ri(Mi()).optional()}),ia=Fi({interruptId:N(),status:zi([`resolved`,`cancelled`]),payload:Mi().optional()}),aa=Fi({threadId:N(),runId:N(),parentRunId:N().optional(),state:Mi(),messages:Pi(ea),tools:Pi(na),context:Pi(ta),forwardedProps:Mi(),resume:Pi(ia).optional()}),oa=Mi(),sa=class extends Error{constructor(e){super(e)}},ca=class extends sa{constructor(){super(`Connect not implemented. This method is not supported by the current agent.`)}},la=Fi({name:N(),description:N().optional()}),ua=Fi({name:N().optional(),type:N().optional(),description:N().optional(),version:N().optional(),provider:N().optional(),documentationUrl:N().optional(),metadata:Ri(Ni()).optional()}),da=Fi({streaming:P().optional(),websocket:P().optional(),httpBinary:P().optional(),pushNotifications:P().optional(),resumable:P().optional()}),fa=Fi({supported:P().optional(),items:Pi(na).optional(),parallelCalls:P().optional(),clientProvided:P().optional()}),pa=Fi({structuredOutput:P().optional(),supportedMimeTypes:Pi(N()).optional()}),ma=Fi({snapshots:P().optional(),deltas:P().optional(),memory:P().optional(),persistentState:P().optional()}),ha=Fi({supported:P().optional(),delegation:P().optional(),handoffs:P().optional(),subAgents:Pi(la).optional()}),ga=Fi({supported:P().optional(),streaming:P().optional(),encrypted:P().optional()}),_a=Fi({image:P().optional(),audio:P().optional(),video:P().optional(),pdf:P().optional(),file:P().optional()}),va=Fi({image:P().optional(),audio:P().optional()}),ya=Fi({input:_a.optional(),output:va.optional()}),ba=Fi({codeExecution:P().optional(),sandboxed:P().optional(),maxIterations:ji().optional(),maxExecutionTime:ji().optional()}),xa=Fi({supported:P().optional(),approvals:P().optional(),interventions:P().optional(),feedback:P().optional(),interrupts:P().optional(),approveWithEdits:P().optional()});Fi({identity:ua.optional(),transport:da.optional(),tools:fa.optional(),output:pa.optional(),state:ma.optional(),multiAgent:ha.optional(),reasoning:ga.optional(),multimodal:ya.optional(),execution:ba.optional(),humanInTheLoop:xa.optional(),custom:Ri(Ni()).optional()});var Sa=Ii([F(`developer`),F(`system`),F(`assistant`),F(`user`)]),I=function(e){return e.TEXT_MESSAGE_START=`TEXT_MESSAGE_START`,e.TEXT_MESSAGE_CONTENT=`TEXT_MESSAGE_CONTENT`,e.TEXT_MESSAGE_END=`TEXT_MESSAGE_END`,e.TEXT_MESSAGE_CHUNK=`TEXT_MESSAGE_CHUNK`,e.TOOL_CALL_START=`TOOL_CALL_START`,e.TOOL_CALL_ARGS=`TOOL_CALL_ARGS`,e.TOOL_CALL_END=`TOOL_CALL_END`,e.TOOL_CALL_CHUNK=`TOOL_CALL_CHUNK`,e.TOOL_CALL_RESULT=`TOOL_CALL_RESULT`,e.THINKING_START=`THINKING_START`,e.THINKING_END=`THINKING_END`,e.THINKING_TEXT_MESSAGE_START=`THINKING_TEXT_MESSAGE_START`,e.THINKING_TEXT_MESSAGE_CONTENT=`THINKING_TEXT_MESSAGE_CONTENT`,e.THINKING_TEXT_MESSAGE_END=`THINKING_TEXT_MESSAGE_END`,e.STATE_SNAPSHOT=`STATE_SNAPSHOT`,e.STATE_DELTA=`STATE_DELTA`,e.MESSAGES_SNAPSHOT=`MESSAGES_SNAPSHOT`,e.ACTIVITY_SNAPSHOT=`ACTIVITY_SNAPSHOT`,e.ACTIVITY_DELTA=`ACTIVITY_DELTA`,e.RAW=`RAW`,e.CUSTOM=`CUSTOM`,e.RUN_STARTED=`RUN_STARTED`,e.RUN_FINISHED=`RUN_FINISHED`,e.RUN_ERROR=`RUN_ERROR`,e.STEP_STARTED=`STEP_STARTED`,e.STEP_FINISHED=`STEP_FINISHED`,e.REASONING_START=`REASONING_START`,e.REASONING_MESSAGE_START=`REASONING_MESSAGE_START`,e.REASONING_MESSAGE_CONTENT=`REASONING_MESSAGE_CONTENT`,e.REASONING_MESSAGE_END=`REASONING_MESSAGE_END`,e.REASONING_MESSAGE_CHUNK=`REASONING_MESSAGE_CHUNK`,e.REASONING_END=`REASONING_END`,e.REASONING_ENCRYPTED_VALUE=`REASONING_ENCRYPTED_VALUE`,e}({}),Ca=Fi({type:Bi(I),timestamp:ji().optional(),rawEvent:Mi().optional()}).passthrough(),wa=Ca.extend({type:F(I.TEXT_MESSAGE_START),messageId:N(),role:Sa.default(`assistant`),name:N().optional()}),Ta=Ca.extend({type:F(I.TEXT_MESSAGE_CONTENT),messageId:N(),delta:N()}),Ea=Ca.extend({type:F(I.TEXT_MESSAGE_END),messageId:N()}),Da=Ca.extend({type:F(I.TEXT_MESSAGE_CHUNK),messageId:N().optional(),role:Sa.optional(),delta:N().optional(),name:N().optional()}),Oa=Ca.extend({type:F(I.THINKING_TEXT_MESSAGE_START)}),ka=Ta.omit({messageId:!0,type:!0}).extend({type:F(I.THINKING_TEXT_MESSAGE_CONTENT)}),Aa=Ca.extend({type:F(I.THINKING_TEXT_MESSAGE_END)}),ja=Ca.extend({type:F(I.TOOL_CALL_START),toolCallId:N(),toolCallName:N(),parentMessageId:N().nullable().optional().transform(e=>e??void 0)}),Ma=Ca.extend({type:F(I.TOOL_CALL_ARGS),toolCallId:N(),delta:N()}),Na=Ca.extend({type:F(I.TOOL_CALL_END),toolCallId:N()}),Pa=Ca.extend({messageId:N(),type:F(I.TOOL_CALL_RESULT),toolCallId:N(),content:N(),role:F(`tool`).optional()}),Fa=Ca.extend({type:F(I.TOOL_CALL_CHUNK),toolCallId:N().optional(),toolCallName:N().optional(),parentMessageId:N().nullable().optional().transform(e=>e??void 0),delta:N().optional()}),Ia=Ca.extend({type:F(I.THINKING_START),title:N().optional()}),La=Ca.extend({type:F(I.THINKING_END)}),Ra=Ca.extend({type:F(I.STATE_SNAPSHOT),snapshot:oa}),za=Ca.extend({type:F(I.STATE_DELTA),delta:Pi(Mi())}),Ba=Ca.extend({type:F(I.MESSAGES_SNAPSHOT),messages:Pi(ea)}),Va=Ca.extend({type:F(I.ACTIVITY_SNAPSHOT),messageId:N(),activityType:N(),content:Ri(Mi()),replace:P().optional().default(!0)}),Ha=Ca.extend({type:F(I.ACTIVITY_DELTA),messageId:N(),activityType:N(),patch:Pi(Mi())}),Ua=Ca.extend({type:F(I.RAW),event:Mi(),source:N().optional()}),Wa=Ca.extend({type:F(I.CUSTOM),name:N(),value:Mi()}),Ga=Ca.extend({type:F(I.RUN_STARTED),threadId:N(),runId:N(),parentRunId:N().optional(),input:aa.optional()}),Ka=Li(`type`,[Fi({type:F(`success`)}).strict(),Fi({type:F(`interrupt`),interrupts:Pi(ra).min(1)}).strict()]),qa=Fi({provider:N().optional(),model:N().optional(),inputTokens:ji().int().nonnegative().optional(),outputTokens:ji().int().nonnegative().optional(),totalTokens:ji().int().nonnegative().optional(),reasoningTokens:ji().int().nonnegative().optional(),cachedInputTokens:ji().int().nonnegative().optional()}),Ja=Ca.extend({type:F(I.RUN_FINISHED),threadId:N(),runId:N(),result:Mi().optional(),outcome:Ka.nullable().optional().transform(e=>e??void 0),usage:Pi(qa).optional()}),Ya=Ca.extend({type:F(I.RUN_ERROR),message:N(),code:N().optional(),usage:Pi(qa).optional()}),Xa=Ca.extend({type:F(I.STEP_STARTED),stepName:N()}),Za=Ca.extend({type:F(I.STEP_FINISHED),stepName:N()}),Qa=Ii([F(`tool-call`),F(`message`)]),$a=Li(`type`,[wa,Ta,Ea,Da,Ia,La,Oa,ka,Aa,ja,Ma,Na,Fa,Pa,Ra,za,Ba,Va,Ha,Ua,Wa,Ga,Ja,Ya,Xa,Za,Ca.extend({type:F(I.REASONING_START),messageId:N()}),Ca.extend({type:F(I.REASONING_MESSAGE_START),messageId:N(),role:F(`reasoning`)}),Ca.extend({type:F(I.REASONING_MESSAGE_CONTENT),messageId:N(),delta:N()}),Ca.extend({type:F(I.REASONING_MESSAGE_END),messageId:N()}),Ca.extend({type:F(I.REASONING_MESSAGE_CHUNK),messageId:N().optional(),delta:N().optional()}),Ca.extend({type:F(I.REASONING_END),messageId:N()}),Ca.extend({type:F(I.REASONING_ENCRYPTED_VALUE),subtype:Qa,entityId:N(),encryptedValue:N()})]),eo=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),to=Object.prototype.hasOwnProperty;function no(e,t){return to.call(e,t)}function ro(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)no(e,i)&&r.push(i);return r}function io(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function ao(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function oo(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function so(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function co(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(co(e[t]))return!0}else if(typeof e==`object`){for(var r=ro(e),i=r.length,a=0;a<i;a++)if(co(e[r[a]]))return!0}}return!1}function lo(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
|
|
12
|
+
`)}var uo=function(e){eo(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,lo(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=lo(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),fo=s({JsonPatchError:()=>po,_areEquals:()=>So,applyOperation:()=>_o,applyPatch:()=>vo,applyReducer:()=>yo,deepClone:()=>mo,getValueByPointer:()=>L,validate:()=>xo,validator:()=>bo}),po=uo,mo=io,ho={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=L(n,this.path);r&&=io(r);var i=_o(n,{op:`remove`,path:this.from}).removed;return _o(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=L(n,this.from);return _o(n,{op:`add`,path:this.path,value:io(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:So(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},go={add:function(e,t,n){return ao(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:ho.move,copy:ho.copy,test:ho.test,_get:ho._get};function L(e,t){if(t==``)return e;var n={op:`_get`,path:t};return _o(e,n),n.value}function _o(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):bo(t,0)),t.path===``){var o={newDocument:e};if(t.op===`add`)return o.newDocument=t.value,o;if(t.op===`replace`)return o.newDocument=t.value,o.removed=e,o;if(t.op===`move`||t.op===`copy`)return o.newDocument=L(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=So(e,t.value),o.test===!1)throw new po(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o.newDocument=e,o}if(t.op===`remove`)return o.removed=e,o.newDocument=null,o;if(t.op===`_get`)return t.value=e,o;if(n)throw new po("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);return o}r||(e=io(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:bo;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=so(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!ao(f))throw new po(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else ao(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new po(`The specified index MUST NOT be greater than the number of elements in the array`,`OPERATION_VALUE_OUT_OF_BOUNDS`,a,t,e);var o=go[t.op].call(t,c,f,e);if(o.test===!1)throw new po(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=ho[t.op].call(t,c,f,e);if(o.test===!1)throw new po(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new po(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}function vo(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new po(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=io(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=_o(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function yo(e,t,n){var r=_o(e,t);if(r.test===!1)throw new po(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function bo(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new po(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(!ho[e.op])throw new po("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n);if(typeof e.path!=`string`)throw new po("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new po('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new po("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new po("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&co(e.value))throw new po("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new po("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new po(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=xo([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new po(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}function xo(e,t,n){try{if(!Array.isArray(e))throw new po(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)vo(io(t),io(e),n||!0);else{n||=bo;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof po)return e;throw e}}function So(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!So(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!So(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var Co=s({compare:()=>Po,generate:()=>Mo,observe:()=>jo,unobserve:()=>Ao}),wo=new WeakMap,To=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),Eo=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function Do(e){return wo.get(e)}function Oo(e,t){return e.observers.get(t)}function ko(e,t){e.observers.delete(t.callback)}function Ao(e,t){t.unobserve()}function jo(e,t){var n=[],r,i=Do(e);if(!i)i=new To(e),wo.set(e,i);else{var a=Oo(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=io(e),t){r.callback=t,r.next=null;var o=function(){Mo(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){Mo(r),clearTimeout(r.next),ko(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new Eo(t,r)),r}function Mo(e,t){t===void 0&&(t=!1);var n=wo.get(e.object);No(n.value,e.object,e.patches,``,t),e.patches.length&&vo(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function No(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=ro(t),o=ro(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(no(t,l)&&(t[l]!==void 0||u===void 0||Array.isArray(t)!==!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?No(u,d,n,r+`/`+oo(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+oo(l),value:io(u)}),n.push({op:`replace`,path:r+`/`+oo(l),value:io(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+oo(l),value:io(u)}),n.push({op:`remove`,path:r+`/`+oo(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!no(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+oo(l),value:io(t[l])})}}}function Po(e,t,n){n===void 0&&(n=!1);var r=[];return No(e,t,r,``,n),r}var Fo=Object.assign({},fo,Co,{JsonPatchError:uo,deepClone:io,escapePathComponent:oo,unescapePathComponent:so}),Io=function(e,t){return Io=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Io(e,t)};function Lo(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Io(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}var Ro=function(){return Ro=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Ro.apply(this,arguments)};function zo(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function Bo(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Vo(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if(a=n.trys,!(a=a.length>0&&a[a.length-1])&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Ho(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Uo(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-->0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Wo(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function Go(e){return this instanceof Go?(this.v=e,this):new Go(e)}function Ko(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof Go?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function qo(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Ho==`function`?Ho(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}function Jo(e){return typeof e==`function`}function Yo(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var Xo=Yo(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
|
|
13
|
+
`+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
|
|
14
|
+
`):``,this.name=`UnsubscriptionError`,this.errors=t}});function Zo(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var Qo=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a){if(this._parentage=null,Array.isArray(a))try{for(var o=Ho(a),s=o.next();!s.done;s=o.next())s.value.remove(this)}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this)}var c=this.initialTeardown;if(Jo(c))try{c()}catch(e){i=e instanceof Xo?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Ho(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{ts(f)}catch(e){i??=[],e instanceof Xo?i=Wo(Wo([],Uo(i)),Uo(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new Xo(i)}},e.prototype.add=function(t){if(t&&t!==this){if(this.closed)ts(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=this._finalizers??[]).push(t)}}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&Zo(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&Zo(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),$o=Qo.EMPTY;function es(e){return e instanceof Qo||e&&`closed`in e&&Jo(e.remove)&&Jo(e.add)&&Jo(e.unsubscribe)}function ts(e){Jo(e)?e():e.unsubscribe()}var ns={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},rs={setTimeout:function(e,t){var n=[...arguments].slice(2),r=rs.delegate;return r?.setTimeout?r.setTimeout.apply(r,Wo([e,t],Uo(n))):setTimeout.apply(void 0,Wo([e,t],Uo(n)))},clearTimeout:function(e){return(rs.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function is(e){rs.setTimeout(function(){var t=ns.onUnhandledError;if(t)t(e);else throw e})}function as(){}var os=(function(){return ls(`C`,void 0,void 0)})();function ss(e){return ls(`E`,void 0,e)}function cs(e){return ls(`N`,e,void 0)}function ls(e,t,n){return{kind:e,value:t,error:n}}var us=null;function ds(e){if(ns.useDeprecatedSynchronousErrorHandling){var t=!us;if(t&&(us={errorThrown:!1,error:null}),e(),t){var n=us,r=n.errorThrown,i=n.error;if(us=null,r)throw i}}else e()}function fs(e){ns.useDeprecatedSynchronousErrorHandling&&us&&(us.errorThrown=!0,us.error=e)}var ps=function(e){Lo(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,es(t)&&t.add(n)):n.destination=xs,n}return t.create=function(e,t,n){return new _s(e,t,n)},t.prototype.next=function(e){this.isStopped?bs(cs(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?bs(ss(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?bs(os,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Qo),ms=Function.prototype.bind;function hs(e,t){return ms.call(e,t)}var gs=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){vs(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){vs(e)}else vs(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){vs(e)}},e}(),_s=function(e){Lo(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(Jo(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&ns.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&hs(t.next,o),error:t.error&&hs(t.error,o),complete:t.complete&&hs(t.complete,o)}):a=t}return i.destination=new gs(a),i}return t}(ps);function vs(e){ns.useDeprecatedSynchronousErrorHandling?fs(e):is(e)}function ys(e){throw e}function bs(e,t){var n=ns.onStoppedNotification;n&&rs.setTimeout(function(){return n(e,t)})}var xs={closed:!0,next:as,error:ys,complete:as},Ss=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function Cs(e){return e}function ws(){return Ts([...arguments])}function Ts(e){return e.length===0?Cs:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var Es=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,i=ks(e)?e:new _s(e,t,n);return ds(function(){var e=r,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return t=Ds(t),new t(function(t,r){var i=new _s({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)})},e.prototype._subscribe=function(e){return this.source?.subscribe(e)},e.prototype[Ss]=function(){return this},e.prototype.pipe=function(){return Ts([...arguments])(this)},e.prototype.toPromise=function(e){var t=this;return e=Ds(e),new e(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function Ds(e){return e??ns.Promise??Promise}function Os(e){return e&&Jo(e.next)&&Jo(e.error)&&Jo(e.complete)}function ks(e){return e&&e instanceof ps||Os(e)&&es(e)}function As(e){return Jo(e?.lift)}function js(e){return function(t){if(As(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError(`Unable to lift unknown Observable type`)}}function Ms(e,t,n,r,i){return new Ns(e,t,n,r,i)}var Ns=function(e){Lo(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)==null||t.call(this))}},t}(ps),Ps=Yo(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),Fs=function(e){Lo(t,e);function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t.prototype.lift=function(e){var t=new Is(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ps},t.prototype.next=function(e){var t=this;ds(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=Ho(t.currentObservers),a=i.next();!a.done;a=i.next())a.value.next(e)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;ds(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;ds(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){return this.observers?.length>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,a=n.observers;return r||i?$o:(this.currentObservers=null,a.push(e),new Qo(function(){t.currentObservers=null,Zo(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new Es;return e.source=this,e},t.create=function(e,t){return new Is(e,t)},t}(Es),Is=function(e){Lo(t,e);function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t.prototype.next=function(e){var t,n;(n=(t=this.destination)?.next)==null||n.call(t,e)},t.prototype.error=function(e){var t,n;(n=(t=this.destination)?.error)==null||n.call(t,e)},t.prototype.complete=function(){var e,t;(t=(e=this.destination)?.complete)==null||t.call(e)},t.prototype._subscribe=function(e){return this.source?.subscribe(e)??$o},t}(Fs),Ls={now:function(){return(Ls.delegate||Date).now()},delegate:void 0},Rs=function(e){Lo(t,e);function t(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=Ls);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,o=n._timestampProvider,s=n._windowTime;r||(i.push(t),!a&&i.push(o.now()+s)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this,r=n._infiniteTimeWindow,i=n._buffer.slice(),a=0;a<i.length&&!e.closed;a+=r?1:2)e.next(i[a]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,i=e._infiniteTimeWindow,a=(i?1:2)*t;if(t<1/0&&a<r.length&&r.splice(0,r.length-a),!i){for(var o=n.now(),s=0,c=1;c<r.length&&r[c]<=o;c+=2)s=c;s&&r.splice(0,s+1)}},t}(Fs),zs=new Es(function(e){return e.complete()});function Bs(e){return e&&Jo(e.schedule)}function Vs(e){return e[e.length-1]}function Hs(e){return Bs(Vs(e))?e.pop():void 0}var Us=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function Ws(e){return Jo(e?.then)}function Gs(e){return Jo(e[Ss])}function Ks(e){return Symbol.asyncIterator&&Jo(e?.[Symbol.asyncIterator])}function qs(e){return TypeError(`You provided `+(typeof e==`object`&&e?`an invalid object`:`'`+e+`'`)+` where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function Js(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var Ys=Js();function Xs(e){return Jo(e?.[Ys])}function Zs(e){return Ko(this,arguments,function(){var t,n,r,i;return Vo(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,Go(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,Go(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,Go(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Qs(e){return Jo(e?.getReader)}function $s(e){if(e instanceof Es)return e;if(e!=null){if(Gs(e))return ec(e);if(Us(e))return tc(e);if(Ws(e))return nc(e);if(Ks(e))return ic(e);if(Xs(e))return rc(e);if(Qs(e))return ac(e)}throw qs(e)}function ec(e){return new Es(function(t){var n=e[Ss]();if(Jo(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function tc(e){return new Es(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function nc(e){return new Es(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,is)})}function rc(e){return new Es(function(t){var n,r;try{for(var i=Ho(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function ic(e){return new Es(function(t){oc(e,t).catch(function(e){return t.error(e)})})}function ac(e){return ic(Zs(e))}function oc(e,t){var n,r,i,a;return Bo(this,void 0,void 0,function(){var o,s;return Vo(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=qo(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function sc(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(a),!i)return a}function cc(e,t){return t===void 0&&(t=0),js(function(n,r){n.subscribe(Ms(r,function(n){return sc(r,e,function(){return r.next(n)},t)},function(){return sc(r,e,function(){return r.complete()},t)},function(n){return sc(r,e,function(){return r.error(n)},t)}))})}function lc(e,t){return t===void 0&&(t=0),js(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function uc(e,t){return $s(e).pipe(lc(t),cc(t))}function dc(e,t){return $s(e).pipe(lc(t),cc(t))}function fc(e,t){return new Es(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function pc(e,t){return new Es(function(n){var r;return sc(n,t,function(){r=e[Ys](),sc(n,t,function(){var e,t,i;try{e=r.next(),t=e.value,i=e.done}catch(e){n.error(e);return}i?n.complete():n.next(t)},0,!0)}),function(){return Jo(r?.return)&&r.return()}})}function mc(e,t){if(!e)throw Error(`Iterable cannot be null`);return new Es(function(n){sc(n,t,function(){var r=e[Symbol.asyncIterator]();sc(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function hc(e,t){return mc(Zs(e),t)}function gc(e,t){if(e!=null){if(Gs(e))return uc(e,t);if(Us(e))return fc(e,t);if(Ws(e))return dc(e,t);if(Ks(e))return mc(e,t);if(Xs(e))return pc(e,t);if(Qs(e))return hc(e,t)}throw qs(e)}function _c(e,t){return t?gc(e,t):$s(e)}function vc(){var e=[...arguments];return _c(e,Hs(e))}function yc(e,t){var n=Jo(e)?e:function(){return e},r=function(e){return e.error(n())};return new Es(t?function(e){return t.schedule(r,0,e)}:r)}var bc=Yo(function(e){return function(){e(this),this.name=`EmptyError`,this.message=`no elements in sequence`}});function xc(e,t){var n=typeof t==`object`;return new Promise(function(r,i){var a=!1,o;e.subscribe({next:function(e){o=e,a=!0},error:i,complete:function(){a?r(o):n?r(t.defaultValue):i(new bc)}})})}function Sc(e,t){return js(function(n,r){var i=0;n.subscribe(Ms(r,function(n){r.next(e.call(t,n,i++))}))})}function Cc(e,t,n,r,i,a,o,s){var c=[],l=0,u=0,d=!1,f=function(){d&&!c.length&&!l&&t.complete()},p=function(e){return l<r?m(e):c.push(e)},m=function(e){a&&t.next(e),l++;var s=!1;$s(n(e,u++)).subscribe(Ms(t,function(e){i?.(e),a?p(e):t.next(e)},function(){s=!0},void 0,function(){if(s)try{l--;for(var e=function(){var e=c.shift();o?sc(t,o,function(){return m(e)}):m(e)};c.length&&l<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(Ms(t,p,function(){d=!0,f()})),function(){s?.()}}function wc(e,t,n){return n===void 0&&(n=1/0),Jo(t)?wc(function(n,r){return Sc(function(e,i){return t(n,e,r,i)})($s(e(n,r)))},n):(typeof t==`number`&&(n=t),js(function(t,r){return Cc(t,r,e,n)}))}function Tc(e){return e===void 0&&(e=1/0),wc(Cs,e)}function Ec(e){return new Es(function(t){$s(e()).subscribe(t)})}function Dc(e){return js(function(t,n){var r=null,i=!1,a;r=t.subscribe(Ms(n,void 0,void 0,function(o){a=$s(e(o,Dc(e)(t))),r?(r.unsubscribe(),r=null,a.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,a.subscribe(n))})}function Oc(e,t){return Jo(t)?wc(e,t,1):wc(e,1)}function kc(e){return js(function(t,n){var r=!1;t.subscribe(Ms(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}function Ac(e){return js(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}function jc(e,t){return js(function(n,r){var i=null,a=0,o=!1,s=function(){return o&&!i&&r.complete()};n.subscribe(Ms(r,function(n){i?.unsubscribe();var o=0,c=a++;$s(e(n,c)).subscribe(i=Ms(r,function(e){return r.next(t?t(n,e,c,o++):e)},function(){i=null,s()}))},function(){o=!0,s()}))})}function Mc(e){return js(function(t,n){$s(e).subscribe(Ms(n,function(){return n.complete()},as)),!n.closed&&t.subscribe(n)})}function Nc(e,t,n){var r=Jo(e)||t||n?{next:e,error:t,complete:n}:e;return r?js(function(e,t){var n;(n=r.subscribe)==null||n.call(r);var i=!0;e.subscribe(Ms(t,function(e){var n;(n=r.next)==null||n.call(r,e),t.next(e)},function(){var e;i=!1,(e=r.complete)==null||e.call(r),t.complete()},function(e){var n;i=!1,(n=r.error)==null||n.call(r,e),t.error(e)},function(){var e,t;i&&((e=r.unsubscribe)==null||e.call(r)),(t=r.finalize)==null||t.call(r)}))}):Cs}function Pc(e){return` \r
|
|
15
|
+
`.indexOf(e)>=0}function Fc(e){for(var t=[`topLevel`],n=0,r,i,a,o=function(e){return t.push(e)},s=function(e){return t[t.length-1]=e},c=function(e){r??(r=n,i=t.length,a=e)},l=function(e){e===a&&(r=void 0,i=void 0,a=void 0)},u=function(){return t.pop()},d=function(){return n--},f=function(e){if(`0`<=e&&e<=`9`){o(`number`);return}switch(e){case`"`:o(`string`);return;case`-`:o(`numberNeedsDigit`);return;case`t`:o(`true`);return;case`f`:o(`false`);return;case`n`:o(`null`);return;case`[`:o(`arrayNeedsValue`);return;case`{`:o(`objectNeedsKey`);return}},p=e.length;n<p;n++){var m=e[n];switch(t[t.length-1]){case`topLevel`:f(m);break;case`string`:switch(m){case`"`:u();break;case`\\`:c(`stringEscape`),o(`stringEscaped`)}break;case`stringEscaped`:m===`u`?o(`stringUnicode`):(l(`stringEscape`),u());break;case`stringUnicode`:n-e.lastIndexOf(`u`,n)===4&&(l(`stringEscape`),u());break;case`number`:m===`.`?s(`numberNeedsDigit`):m===`e`||m===`E`?s(`numberNeedsExponent`):(m<`0`||m>`9`)&&(d(),u());break;case`numberNeedsDigit`:s(`number`);break;case`numberNeedsExponent`:s(m===`+`||m===`-`?`numberNeedsDigit`:`number`);break;case`true`:case`false`:case`null`:(m<`a`||m>`z`)&&(d(),u());break;case`arrayNeedsValue`:m===`]`?u():Pc(m)||(l(`collectionItem`),s(`arrayNeedsComma`),f(m));break;case`arrayNeedsComma`:m===`]`?u():m===`,`&&(c(`collectionItem`),s(`arrayNeedsValue`));break;case`objectNeedsKey`:m===`}`?u():m===`"`&&(c(`collectionItem`),s(`objectNeedsColon`),o(`string`));break;case`objectNeedsColon`:m===`:`&&s(`objectNeedsValue`);break;case`objectNeedsValue`:Pc(m)||(l(`collectionItem`),s(`objectNeedsComma`),f(m));break;case`objectNeedsComma`:m===`}`?u():m===`,`&&(c(`collectionItem`),s(`objectNeedsKey`))}}i!=null&&(t.length=i);for(var h=[r==null?e:e.slice(0,r)],g=function(t){return h.push(t.slice(e.length-e.lastIndexOf(t[0])))},_=t.length-1;_>=0;_--)switch(t[_]){case`string`:h.push(`"`);break;case`numberNeedsDigit`:case`numberNeedsExponent`:h.push(`0`);break;case`true`:g(`true`);break;case`false`:g(`false`);break;case`null`:g(`null`);break;case`arrayNeedsValue`:case`arrayNeedsComma`:h.push(`]`);break;case`objectNeedsKey`:case`objectNeedsColon`:case`objectNeedsValue`:case`objectNeedsComma`:h.push(`}`)}return h.join(``)}function Ic(){let e=this.buf,t=this.pos,n=0,r=0;for(let i=0;i<28;i+=7){let a=e[t++];if(n|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}let i=e[t++];if(n|=(i&15)<<28,r=(i&112)>>4,!(i&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(r|=(a&127)<<i,!(a&128)){this.pos=t,this.assertBounds(),this.varint64Lo=n,this.varint64Hi=r;return}}throw Error(`invalid varint`)}var Lc=4294967296;function Rc(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Lc&&(i+=r/Lc|0,r%=Lc)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Uc(r,i):Hc(r,i)}function zc(e,t){let n=Hc(e,t),r=n.hi&2147483648;r&&(n=Uc(n.lo,n.hi));let i=Bc(n.lo,n.hi);return r?`-`+i:i}function Bc(e,t){if({lo:e,hi:t}=Vc(e,t),t<=2097151)return String(Lc*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Wc(o)+Wc(a)}function Vc(e,t){return{lo:e>>>0,hi:t>>>0}}function Hc(e,t){return{lo:e|0,hi:t|0}}function Uc(e,t){return t=~t,e?e=~e+1:t+=1,Hc(e,t)}var Wc=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Gc(){let e=this.buf[this.pos++];if(!(e&128))return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}var Kc=qc();function qc(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||globalThis.Bun||typeof process!=`object`||{}.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),Jc(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),Yc(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),Jc(e),Rc(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),Yc(e),Rc(e)},dec(e,t){return zc(e,t)},uDec(e,t){return Bc(e,t)}}}function Jc(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function Yc(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}var Xc=Symbol.for(`@bufbuild/protobuf/text-encoding`);function Zc(e){globalThis[Xc]=Object.assign(Object.assign({},e),{encodeUtf8Into:e.encodeUtf8Into??$c(e.encodeUtf8.bind(e))})}function Qc(){let e=globalThis;if(!e[Xc]){let t=new e.TextEncoder,n=new e.TextDecoder,r,i={encodeUtf8(e){return t.encode(e)},decodeUtf8(t,i){return i?(r||=new e.TextDecoder(`utf-8`,{fatal:!0}),r.decode(t)):n.decode(t)},checkUtf8(e){try{return!0}catch{return!1}}};t.encodeInto&&(i.encodeUtf8Into=t.encodeInto.bind(t));let a=String.prototype.isWellFormed;a&&(i.checkUtf8=e=>a.call(e)),Zc(i)}return e[Xc]}function $c(e){return(t,n)=>{let r=e(t);return n.set(r),{written:r.byteLength}}}var el;(function(e){e[e.Varint=0]=`Varint`,e[e.Bit64=1]=`Bit64`,e[e.LengthDelimited=2]=`LengthDelimited`,e[e.StartGroup=3]=`StartGroup`,e[e.EndGroup=4]=`EndGroup`,e[e.Bit32=5]=`Bit32`})(el||={});var R=class{constructor(e){this.stackPos=[],this.encodeUtf8Into=e?$c(e):Qc().encodeUtf8Into,this.buffer=rl,this.viewCache=il,this.pos=0}ensureCapacity(e){let t=this.pos+e;if(t>this.buffer.length){let e=this.buffer.length||tl;for(;e<t;)e*=2;let n=new Uint8Array(e);this.pos>0&&n.set(this.buffer),this.buffer=n}}view(){let e=this.buffer,t=this.viewCache;if(t.byteLength===e.byteLength)return t;let n=new DataView(e.buffer);return this.viewCache=n,n}finish(){let e=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],e}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(nl),this.buffer[this.pos++]=0,this}join(){let e=this.stackPos.pop();if(e===void 0)throw Error(`invalid state, fork stack empty`);let t=this.pos-e-nl,n=ol(t);return n>nl&&(this.ensureCapacity(n-nl),this.buffer.copyWithin(e+n,e+nl,this.pos)),this.pos=e,this.uint32(t),this.pos+=t,this}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.ensureCapacity(e.length),this.buffer.set(e,this.pos),this.pos+=e.length,this}uint32(e){if(cl(e),this.ensureCapacity(5),e<128)return this.buffer[this.pos++]=e,this;for(;e>127;)this.buffer[this.pos++]=e&127|128,e>>>=7;return this.buffer[this.pos++]=e,this}int32(e){if(sl(e),e>=0)return this.uint32(e);this.ensureCapacity(10);for(let t=0;t<9;t++)this.buffer[this.pos++]=e&127|128,e>>=7;return this.buffer[this.pos++]=1,this}bool(e){return this.ensureCapacity(1),this.buffer[this.pos++]=+!!e,this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){typeof e!=`string`&&(e=String(e));let t=e.length;if(t<=al){this.ensureCapacity(t+1);let n=this.buffer,r=this.pos;n[r++]=t;let i=0;for(;i<t;i++){let t=e.charCodeAt(i);if(t>127)break;n[r++]=t}if(i==t)return this.pos=r,this}this.ensureCapacity(t*3+5);let n=ol(t),r=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(e,r.subarray(i+n)),o=ol(a);return o!=n&&r.copyWithin(i+o,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(e){return ll(e),this.ensureCapacity(4),this.view().setFloat32(this.pos,e,!0),this.pos+=4,this}double(e){return this.ensureCapacity(8),this.view().setFloat64(this.pos,e,!0),this.pos+=8,this}fixed32(e){return cl(e),this.ensureCapacity(4),this.view().setUint32(this.pos,e,!0),this.pos+=4,this}sfixed32(e){return sl(e),this.ensureCapacity(4),this.view().setInt32(this.pos,e,!0),this.pos+=4,this}sint32(e){return sl(e),this.uint32((e<<1^e>>31)>>>0)}sfixed64(e){let t=Kc.enc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}fixed64(e){let t=Kc.uEnc(e);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,t.lo,!0),n.setInt32(this.pos+4,t.hi,!0),this.pos+=8,this}int64(e){let t=Kc.enc(e);return this.writeVarint64(t.lo,t.hi)}sint64(e){let t=Kc.enc(e),n=t.hi>>31,r=t.lo<<1^n,i=(t.hi<<1|t.lo>>>31)^n;return this.writeVarint64(r,i)}uint64(e){let t=Kc.uEnc(e);return this.writeVarint64(t.lo,t.hi)}writeVarint64(e,t){this.ensureCapacity(10);let n=this.buffer,r=this.pos;for(let i=0;i<28;i+=7){let a=e>>>i,o=!(!(a>>>7)&&t==0);if(n[r++]=(o?a|128:a)&255,!o)return this.pos=r,this}let i=e>>>28&15|(t&7)<<4,a=!!(t>>3);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this;for(let e=3;e<31;e+=7){let i=t>>>e,a=!!(i>>>7);if(n[r++]=(a?i|128:i)&255,!a)return this.pos=r,this}return n[r++]=t>>>31&1,this.pos=r,this}},tl=128,nl=1,rl=new Uint8Array,il=new DataView(rl.buffer),al=32;function ol(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var z=class{constructor(e,t=Qc().decodeUtf8){this.decodeUtf8=t,this.varint64Lo=0,this.varint64Hi=0,this.varint64=Ic,this.uint32=Gc,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.pos,t=this.uint32(),n=this.pos-e;if(n>5||n==5&&this.buf[this.pos-1]>15)throw Error(`illegal tag: varint overflows uint32`);let r=t>>>3,i=t&7;if(r<=0||i>5)throw Error(`illegal tag: field no `+r+` wire type `+i);return[r,i]}skip(e,t,n=100){let r=this.pos;switch(e){case el.Varint:for(;this.buf[this.pos++]&128;);break;case el.Bit64:this.pos+=4;case el.Bit32:this.pos+=4;break;case el.LengthDelimited:let r=this.uint32();this.pos+=r;break;case el.StartGroup:if(n<=0)throw Error(`maximum recursion depth reached`);for(;;){let[e,r]=this.tag();if(r===el.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(r,e,n-1)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(r,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return this.varint64(),Kc.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),Kc.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let e=this.varint64Lo,t=this.varint64Hi,n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Kc.dec(e,t)}bool(){let e=this.buf[this.pos];return e<128?(this.pos++,e!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Kc.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Kc.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(e){let t=this.bytes(),n=t.length;if(n<=al){let r=Array(n);for(let i=0;i<n;i++){let n=t[i];if(n>127)return this.decodeUtf8(t,e);r[i]=n}return String.fromCharCode.apply(String,r)}return this.decodeUtf8(t,e)}};function sl(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function cl(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function ll(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float32: `+e)}var ul=function(e){return e[e.NULL_VALUE=0]=`NULL_VALUE`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function dl(){return{fields:{}}}var fl={encode(e,t=new R){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&ml.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=dl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:{if(e!==10)break;let t=ml.decode(n,n.uint32());t.value!==void 0&&(i.fields[t.key]=t.value);continue}}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return fl.fromPartial(e??{})},fromPartial(e){let t=dl();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=dl();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function pl(){return{key:``,value:void 0}}var ml={encode(e,t=new R){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&B.encode(B.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=pl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.key=n.string();continue;case 2:if(e!==18)break;i.value=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ml.fromPartial(e??{})},fromPartial(e){let t=pl();return t.key=e.key??``,t.value=e.value??void 0,t}};function hl(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var B={encode(e,t=new R){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&fl.encode(fl.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&_l.encode(_l.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=hl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.nullValue=n.int32();continue;case 2:if(e!==17)break;i.numberValue=n.double();continue;case 3:if(e!==26)break;i.stringValue=n.string();continue;case 4:if(e!==32)break;i.boolValue=n.bool();continue;case 5:if(e!==42)break;i.structValue=fl.unwrap(fl.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=_l.unwrap(_l.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return B.fromPartial(e??{})},fromPartial(e){let t=hl();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=hl();if(e===null)t.nullValue=ul.NULL_VALUE;else if(typeof e==`boolean`)t.boolValue=e;else if(typeof e==`number`)t.numberValue=e;else if(typeof e==`string`)t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e==`object`)t.structValue=e;else if(e!==void 0)throw new globalThis.Error(`Unsupported any value type: `+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function gl(){return{values:[]}}var _l={encode(e,t=new R){for(let n of e.values)B.encode(B.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=gl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.values.push(B.unwrap(B.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return _l.fromPartial(e??{})},fromPartial(e){let t=gl();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=gl();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},vl=function(e){return e[e.ADD=0]=`ADD`,e[e.REMOVE=1]=`REMOVE`,e[e.REPLACE=2]=`REPLACE`,e[e.MOVE=3]=`MOVE`,e[e.COPY=4]=`COPY`,e[e.TEST=5]=`TEST`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function yl(){return{op:0,path:``,from:void 0,value:void 0}}var bl={encode(e,t=new R){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==``&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&B.encode(B.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=yl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.op=n.int32();continue;case 2:if(e!==18)break;i.path=n.string();continue;case 3:if(e!==26)break;i.from=n.string();continue;case 4:if(e!==34)break;i.value=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return bl.fromPartial(e??{})},fromPartial(e){let t=yl();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function xl(){return{id:``,type:``,function:void 0}}var Sl={encode(e,t=new R){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&wl.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=xl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.type=n.string();continue;case 3:if(e!==26)break;i.function=wl.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Sl.fromPartial(e??{})},fromPartial(e){let t=xl();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?wl.fromPartial(e.function):void 0,t}};function Cl(){return{name:``,arguments:``}}var wl={encode(e,t=new R){return e.name!==``&&t.uint32(10).string(e.name),e.arguments!==``&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Cl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.arguments=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return wl.fromPartial(e??{})},fromPartial(e){let t=Cl();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function Tl(){return{value:``,mimeType:``}}var El={encode(e,t=new R){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==``&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Tl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return El.fromPartial(e??{})},fromPartial(e){let t=Tl();return t.value=e.value??``,t.mimeType=e.mimeType??``,t}};function Dl(){return{value:``,mimeType:void 0}}var Ol={encode(e,t=new R){return e.value!==``&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Dl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.value=n.string();continue;case 2:if(e!==18)break;i.mimeType=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ol.fromPartial(e??{})},fromPartial(e){let t=Dl();return t.value=e.value??``,t.mimeType=e.mimeType??void 0,t}};function kl(){return{data:void 0,url:void 0}}var Al={encode(e,t=new R){return e.data!==void 0&&El.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&Ol.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=kl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.data=El.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.url=Ol.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Al.fromPartial(e??{})},fromPartial(e){let t=kl();return t.data=e.data!==void 0&&e.data!==null?El.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?Ol.fromPartial(e.url):void 0,t}};function jl(){return{text:``}}var Ml={encode(e,t=new R){return e.text!==``&&t.uint32(10).string(e.text),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=jl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ml.fromPartial(e??{})},fromPartial(e){let t=jl();return t.text=e.text??``,t}};function Nl(){return{source:void 0,metadata:void 0}}var Pl={encode(e,t=new R){return e.source!==void 0&&Al.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&B.encode(B.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Nl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Al.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Pl.fromPartial(e??{})},fromPartial(e){let t=Nl();return t.source=e.source!==void 0&&e.source!==null?Al.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Fl(){return{source:void 0,metadata:void 0}}var Il={encode(e,t=new R){return e.source!==void 0&&Al.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&B.encode(B.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Fl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Al.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Il.fromPartial(e??{})},fromPartial(e){let t=Fl();return t.source=e.source!==void 0&&e.source!==null?Al.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Ll(){return{source:void 0,metadata:void 0}}var Rl={encode(e,t=new R){return e.source!==void 0&&Al.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&B.encode(B.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Ll();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Al.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Rl.fromPartial(e??{})},fromPartial(e){let t=Ll();return t.source=e.source!==void 0&&e.source!==null?Al.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function zl(){return{source:void 0,metadata:void 0}}var Bl={encode(e,t=new R){return e.source!==void 0&&Al.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&B.encode(B.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=zl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.source=Al.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.metadata=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Bl.fromPartial(e??{})},fromPartial(e){let t=zl();return t.source=e.source!==void 0&&e.source!==null?Al.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function Vl(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var Hl={encode(e,t=new R){return e.text!==void 0&&Ml.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&Pl.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&Il.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&Rl.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&Bl.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Vl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.text=Ml.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.image=Pl.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.audio=Il.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.video=Rl.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.document=Bl.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Hl.fromPartial(e??{})},fromPartial(e){let t=Vl();return t.text=e.text!==void 0&&e.text!==null?Ml.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?Pl.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?Il.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?Rl.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?Bl.fromPartial(e.document):void 0,t}};function Ul(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var Wl={encode(e,t=new R){e.id!==``&&t.uint32(10).string(e.id),e.role!==``&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)Sl.encode(n,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let n of e.contentParts)Hl.encode(n,t.uint32(66).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Ul();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.role=n.string();continue;case 3:if(e!==26)break;i.content=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.toolCalls.push(Sl.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.toolCallId=n.string();continue;case 7:if(e!==58)break;i.error=n.string();continue;case 8:if(e!==66)break;i.contentParts.push(Hl.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Wl.fromPartial(e??{})},fromPartial(e){let t=Ul();return t.id=e.id??``,t.role=e.role??``,t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(e=>Sl.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(e=>Hl.fromPartial(e))||[],t}};function Gl(){return{id:``,reason:``,message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var Kl={encode(e,t=new R){return e.id!==``&&t.uint32(10).string(e.id),e.reason!==``&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&B.encode(B.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&B.encode(B.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Gl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.reason=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.toolCallId=n.string();continue;case 5:if(e!==42)break;i.responseSchema=B.unwrap(B.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.expiresAt=n.string();continue;case 7:if(e!==58)break;i.metadata=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Kl.fromPartial(e??{})},fromPartial(e){let t=Gl();return t.id=e.id??``,t.reason=e.reason??``,t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},ql=function(e){return e[e.TEXT_MESSAGE_START=0]=`TEXT_MESSAGE_START`,e[e.TEXT_MESSAGE_CONTENT=1]=`TEXT_MESSAGE_CONTENT`,e[e.TEXT_MESSAGE_END=2]=`TEXT_MESSAGE_END`,e[e.TOOL_CALL_START=3]=`TOOL_CALL_START`,e[e.TOOL_CALL_ARGS=4]=`TOOL_CALL_ARGS`,e[e.TOOL_CALL_END=5]=`TOOL_CALL_END`,e[e.STATE_SNAPSHOT=6]=`STATE_SNAPSHOT`,e[e.STATE_DELTA=7]=`STATE_DELTA`,e[e.MESSAGES_SNAPSHOT=8]=`MESSAGES_SNAPSHOT`,e[e.RAW=9]=`RAW`,e[e.CUSTOM=10]=`CUSTOM`,e[e.RUN_STARTED=11]=`RUN_STARTED`,e[e.RUN_FINISHED=12]=`RUN_FINISHED`,e[e.RUN_ERROR=13]=`RUN_ERROR`,e[e.STEP_STARTED=14]=`STEP_STARTED`,e[e.STEP_FINISHED=15]=`STEP_FINISHED`,e[e.UNRECOGNIZED=-1]=`UNRECOGNIZED`,e}({});function Jl(){return{type:0,timestamp:void 0,rawEvent:void 0}}var V={encode(e,t=new R){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&B.encode(B.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Jl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.type=n.int32();continue;case 2:if(e!==16)break;i.timestamp=Fu(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return V.fromPartial(e??{})},fromPartial(e){let t=Jl();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function Yl(){return{baseEvent:void 0,messageId:``,role:void 0,name:void 0}}var Xl={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Yl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Xl.fromPartial(e??{})},fromPartial(e){let t=Yl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t.name=e.name??void 0,t}};function Zl(){return{baseEvent:void 0,messageId:``,delta:``}}var Ql={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Zl();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ql.fromPartial(e??{})},fromPartial(e){let t=Zl();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function $l(){return{baseEvent:void 0,messageId:``}}var eu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=$l();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return eu.fromPartial(e??{})},fromPartial(e){let t=$l();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t}};function tu(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0}}var nu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.toolCallName!==``&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=tu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return nu.fromPartial(e??{})},fromPartial(e){let t=tu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t}};function ru(){return{baseEvent:void 0,toolCallId:``,delta:``}}var iu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=ru();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return iu.fromPartial(e??{})},fromPartial(e){let t=ru();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t}};function au(){return{baseEvent:void 0,toolCallId:``}}var ou={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=au();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ou.fromPartial(e??{})},fromPartial(e){let t=au();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t}};function su(){return{baseEvent:void 0,snapshot:void 0}}var cu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&B.encode(B.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=su();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return cu.fromPartial(e??{})},fromPartial(e){let t=su();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function lu(){return{baseEvent:void 0,delta:[]}}var uu={encode(e,t=new R){e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)bl.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=lu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push(bl.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return uu.fromPartial(e??{})},fromPartial(e){let t=lu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>bl.fromPartial(e))||[],t}};function du(){return{baseEvent:void 0,messages:[]}}var fu={encode(e,t=new R){e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)Wl.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=du();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(Wl.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return fu.fromPartial(e??{})},fromPartial(e){let t=du();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>Wl.fromPartial(e))||[],t}};function pu(){return{baseEvent:void 0,event:void 0,source:void 0}}var mu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&B.encode(B.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=pu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=B.unwrap(B.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.source=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return mu.fromPartial(e??{})},fromPartial(e){let t=pu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function hu(){return{baseEvent:void 0,name:``,value:void 0}}var gu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&B.encode(B.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=hu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=B.unwrap(B.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return gu.fromPartial(e??{})},fromPartial(e){let t=hu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t}};function _u(){return{baseEvent:void 0,threadId:``,runId:``}}var vu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=_u();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return vu.fromPartial(e??{})},fromPartial(e){let t=_u();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t}};function yu(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0}}var bu={encode(e,t=new R){return e.provider!==void 0&&t.uint32(10).string(e.provider),e.model!==void 0&&t.uint32(18).string(e.model),e.inputTokens!==void 0&&t.uint32(24).int64(e.inputTokens),e.outputTokens!==void 0&&t.uint32(32).int64(e.outputTokens),e.totalTokens!==void 0&&t.uint32(40).int64(e.totalTokens),e.reasoningTokens!==void 0&&t.uint32(48).int64(e.reasoningTokens),e.cachedInputTokens!==void 0&&t.uint32(56).int64(e.cachedInputTokens),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=yu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.provider=n.string();continue;case 2:if(e!==18)break;i.model=n.string();continue;case 3:if(e!==24)break;i.inputTokens=Fu(n.int64());continue;case 4:if(e!==32)break;i.outputTokens=Fu(n.int64());continue;case 5:if(e!==40)break;i.totalTokens=Fu(n.int64());continue;case 6:if(e!==48)break;i.reasoningTokens=Fu(n.int64());continue;case 7:if(e!==56)break;i.cachedInputTokens=Fu(n.int64());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return bu.fromPartial(e??{})},fromPartial(e){let t=yu();return t.provider=e.provider??void 0,t.model=e.model??void 0,t.inputTokens=e.inputTokens??void 0,t.outputTokens=e.outputTokens??void 0,t.totalTokens=e.totalTokens??void 0,t.reasoningTokens=e.reasoningTokens??void 0,t.cachedInputTokens=e.cachedInputTokens??void 0,t}};function xu(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0,outcome:``,interrupts:[],usage:[]}}var Su={encode(e,t=new R){e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),e.result!==void 0&&B.encode(B.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==``&&t.uint32(42).string(e.outcome);for(let n of e.interrupts)Kl.encode(n,t.uint32(50).fork()).join();for(let n of e.usage)bu.encode(n,t.uint32(58).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=xu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.result=B.unwrap(B.decode(n,n.uint32()));continue;case 5:if(e!==42)break;i.outcome=n.string();continue;case 6:if(e!==50)break;i.interrupts.push(Kl.decode(n,n.uint32()));continue;case 7:if(e!==58)break;i.usage.push(bu.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Su.fromPartial(e??{})},fromPartial(e){let t=xu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.result=e.result??void 0,t.outcome=e.outcome??``,t.interrupts=e.interrupts?.map(e=>Kl.fromPartial(e))||[],t.usage=e.usage?.map(e=>bu.fromPartial(e))||[],t}};function Cu(){return{baseEvent:void 0,code:void 0,message:``,usage:[]}}var wu={encode(e,t=new R){e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==``&&t.uint32(26).string(e.message);for(let n of e.usage)bu.encode(n,t.uint32(34).fork()).join();return t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Cu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.code=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue;case 4:if(e!==34)break;i.usage.push(bu.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return wu.fromPartial(e??{})},fromPartial(e){let t=Cu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t.usage=e.usage?.map(e=>bu.fromPartial(e))||[],t}};function Tu(){return{baseEvent:void 0,stepName:``}}var Eu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Tu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Eu.fromPartial(e??{})},fromPartial(e){let t=Tu();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function Du(){return{baseEvent:void 0,stepName:``}}var Ou={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Du();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ou.fromPartial(e??{})},fromPartial(e){let t=Du();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function ku(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Au={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=ku();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue;case 5:if(e!==42)break;i.name=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Au.fromPartial(e??{})},fromPartial(e){let t=ku();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function ju(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Mu={encode(e,t=new R){return e.baseEvent!==void 0&&V.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=ju();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=V.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Mu.fromPartial(e??{})},fromPartial(e){let t=ju();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?V.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function Nu(){return{textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var Pu={encode(e,t=new R){return e.textMessageStart!==void 0&&Xl.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&Ql.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&eu.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&nu.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&iu.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&ou.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&cu.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&uu.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&fu.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&mu.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&gu.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&vu.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Su.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&wu.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Eu.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Ou.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Au.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Mu.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof z?e:new z(e),r=t===void 0?n.len:n.pos+t,i=Nu();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.textMessageStart=Xl.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=Ql.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=eu.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=nu.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=iu.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=ou.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=cu.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=uu.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=fu.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=mu.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=gu.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=vu.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=Su.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=wu.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=Eu.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=Ou.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=Au.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=Mu.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Pu.fromPartial(e??{})},fromPartial(e){let t=Nu();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Xl.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?Ql.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?eu.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?nu.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?iu.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?ou.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?cu.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?uu.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?fu.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?mu.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?gu.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?vu.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Su.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?wu.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Eu.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Ou.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Au.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Mu.fromPartial(e.toolCallChunk):void 0,t}};function Fu(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error(`Value is larger than Number.MAX_SAFE_INTEGER`);if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error(`Value is smaller than Number.MIN_SAFE_INTEGER`);return t}var Iu=e=>e&&typeof e==`object`?e:void 0,Lu=e=>{let t=Iu(e);if(t){if(t.data){let e=t.data;return{type:`data`,value:e.value,mimeType:e.mimeType}}if(t.url){let e=t.url;return{type:`url`,value:e.value,mimeType:e.mimeType}}}},Ru=e=>{let t=Iu(e);if(t){if(t.text)return{type:`text`,text:t.text.text};if(t.image){let e=t.image;return{type:`image`,source:Lu(e.source),metadata:e.metadata}}if(t.audio){let e=t.audio;return{type:`audio`,source:Lu(e.source),metadata:e.metadata}}if(t.video){let e=t.video;return{type:`video`,source:Lu(e.source),metadata:e.metadata}}if(t.document){let e=t.document;return{type:`document`,source:Lu(e.source),metadata:e.metadata}}}};function zu(e){let t=Pu.decode(e),n=Object.values(t).find(e=>e!==void 0);if(!n)throw Error(`Invalid event`);if(n.type=ql[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,delete n.baseEvent,n.type===I.MESSAGES_SNAPSHOT)for(let e of n.messages){let t=e;if(t.role===`user`&&Array.isArray(t.contentParts)){let e=t.contentParts.map(e=>Ru(e)).filter(e=>e!==void 0);e.length>0&&(t.content=e)}Array.isArray(t.contentParts)&&t.contentParts.length===0&&(t.contentParts=void 0),t.toolCalls?.length===0&&(t.toolCalls=void 0)}if(n.type===I.RUN_FINISHED){let e=n,t=typeof e.outcome==`string`&&e.outcome!==``?e.outcome:void 0,r=Array.isArray(e.interrupts)?e.interrupts:[];delete e.interrupts,t===`interrupt`?e.outcome={type:`interrupt`,interrupts:r}:t===`success`?e.outcome={type:`success`}:delete e.outcome}if((n.type===I.RUN_FINISHED||n.type===I.RUN_ERROR)&&Array.isArray(n.usage)&&n.usage.length===0&&delete n.usage,n.type===I.STATE_DELTA)for(let e of n.delta)e.op=vl[e.op].toLowerCase(),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]});return Object.keys(n).forEach(e=>{n[e]===void 0&&delete n[e]}),$a.parse(n)}var Bu;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(Bu||={});var Vu;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Vu||={});var H=Bu.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Hu=e=>{switch(typeof e){case`undefined`:return H.undefined;case`string`:return H.string;case`number`:return Number.isNaN(e)?H.nan:H.number;case`boolean`:return H.boolean;case`function`:return H.function;case`bigint`:return H.bigint;case`symbol`:return H.symbol;case`object`:return Array.isArray(e)?H.array:e===null?H.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?H.promise:typeof Map<`u`&&e instanceof Map?H.map:typeof Set<`u`&&e instanceof Set?H.set:typeof Date<`u`&&e instanceof Date?H.date:H.object;default:return H.unknown}},U=Bu.arrayToEnum([`invalid_type`,`invalid_literal`,`custom`,`invalid_union`,`invalid_union_discriminator`,`invalid_enum_value`,`unrecognized_keys`,`invalid_arguments`,`invalid_return_type`,`invalid_date`,`invalid_string`,`too_small`,`too_big`,`invalid_intersection_types`,`not_multiple_of`,`not_finite`]),Uu=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Bu.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Uu.create=e=>new Uu(e);var Wu=(e,t)=>{let n;switch(e.code){case U.invalid_type:n=e.received===H.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case U.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Bu.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:n=`Unrecognized key(s) in object: ${Bu.joinValues(e.keys,`, `)}`;break;case U.invalid_union:n=`Invalid input`;break;case U.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Bu.joinValues(e.options)}`;break;case U.invalid_enum_value:n=`Invalid enum value. Expected ${Bu.joinValues(e.options)}, received '${e.received}'`;break;case U.invalid_arguments:n=`Invalid function arguments`;break;case U.invalid_return_type:n=`Invalid function return type`;break;case U.invalid_date:n=`Invalid date`;break;case U.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:Bu.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case U.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case U.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case U.custom:n=`Invalid input`;break;case U.invalid_intersection_types:n=`Intersection results could not be merged`;break;case U.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case U.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,Bu.assertNever(e)}return{message:n}},Gu=Wu;function Ku(){return Gu}var qu=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function W(e,t){let n=Ku(),r=qu({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Wu?void 0:Wu].filter(e=>!!e)});e.common.issues.push(r)}var Ju=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return G;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return G;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}},G=Object.freeze({status:`aborted`}),Yu=e=>({status:`dirty`,value:e}),K=e=>({status:`valid`,value:e}),Xu=e=>e.status===`aborted`,Zu=e=>e.status===`dirty`,Qu=e=>e.status===`valid`,$u=e=>typeof Promise<`u`&&e instanceof Promise,q;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(q||={});var ed=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},td=(e,t)=>{if(Qu(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){if(this._error)return this._error;let t=new Uu(e.common.issues);return this._error=t,this._error}}};function J(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var nd=class{get description(){return this._def.description}_getType(e){return Hu(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Hu(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ju,ctx:{common:e.parent.common,data:e.data,parsedType:Hu(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if($u(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Hu(e)};return td(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Hu(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return Qu(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>Qu(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Hu(e)},r=this._parse({data:e,path:n.path,parent:n});return td(n,await($u(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:U.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new of({schema:this,typeName:Y.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return sf.create(this,this._def)}nullable(){return cf.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Bd.create(this)}promise(){return af.create(this,this._def)}or(e){return Ud.create([this,e],this._def)}and(e){return qd.create(this,e,this._def)}transform(e){return new of({...J(this._def),schema:this,typeName:Y.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new lf({...J(this._def),innerType:this,defaultValue:t,typeName:Y.ZodDefault})}brand(){return new ff({typeName:Y.ZodBranded,type:this,...J(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new uf({...J(this._def),innerType:this,catchValue:t,typeName:Y.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return pf.create(this,e)}readonly(){return mf.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},rd=/^c[^\s-]{8,}$/i,id=/^[0-9a-z]+$/,ad=/^[0-9A-HJKMNP-TV-Z]{26}$/i,od=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,sd=/^[a-z0-9_-]{21}$/i,cd=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ld=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ud=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,dd=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,fd,pd=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,md=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,hd=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,gd=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_d=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,vd=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yd=`((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`,bd=RegExp(`^${yd}$`);function xd(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function Sd(e){return RegExp(`^${xd(e)}$`)}function Cd(e){let t=`${yd}T${xd(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function wd(e,t){return!!((t===`v4`||!t)&&pd.test(e)||(t===`v6`||!t)&&hd.test(e))}function Td(e,t){if(!cd.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function Ed(e,t){return!!((t===`v4`||!t)&&md.test(e)||(t===`v6`||!t)&&gd.test(e))}var Dd=class e extends nd{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==H.string){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.string,received:t.parsedType}),G}let t=new Ju,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?W(n,{code:U.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&W(n,{code:U.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)ud.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`email`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)fd||=new RegExp(dd,`u`),fd.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`emoji`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)od.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`uuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)sd.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`nanoid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)rd.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cuid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)id.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cuid2`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)ad.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`ulid`,code:U.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),W(n,{validation:`url`,code:U.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`regex`,code:U.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Cd(r).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?bd.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Sd(r).test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{code:U.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?ld.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`duration`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?wd(e.data,r.version)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`ip`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?Td(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`jwt`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?Ed(e.data,r.version)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`cidr`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?_d.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`base64`,code:U.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?vd.test(e.data)||(n=this._getOrReturnCtx(e,n),W(n,{validation:`base64url`,code:U.invalid_string,message:r.message}),t.dirty()):Bu.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:U.invalid_string,...q.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...q.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...q.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...q.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...q.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...q.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...q.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...q.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...q.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...q.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...q.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...q.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...q.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...q.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...q.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...q.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...q.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...q.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...q.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...q.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...q.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...q.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...q.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...q.errToObj(t)})}nonempty(e){return this.min(1,q.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Dd.create=e=>new Dd({checks:[],typeName:Y.ZodString,coerce:e?.coerce??!1,...J(e)});function Od(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var kd=class e extends nd{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==H.number){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.number,received:t.parsedType}),G}let t,n=new Ju;for(let r of this._def.checks)r.kind===`int`?Bu.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:U.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Od(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_finite,message:r.message}),n.dirty()):Bu.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,q.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,q.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,q.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,q.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:q.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:q.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:q.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:q.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:q.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:q.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:q.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&Bu.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};kd.create=e=>new kd({checks:[],typeName:Y.ZodNumber,coerce:e?.coerce||!1,...J(e)});var Ad=class e extends nd{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==H.bigint)return this._getInvalidInput(e);let t,n=new Ju;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),W(t,{code:U.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Bu.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.bigint,received:t.parsedType}),G}gte(e,t){return this.setLimit(`min`,e,!0,q.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,q.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,q.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,q.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:q.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:q.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:q.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:q.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:q.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:q.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Ad.create=e=>new Ad({checks:[],typeName:Y.ZodBigInt,coerce:e?.coerce??!1,...J(e)});var jd=class extends nd{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==H.boolean){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.boolean,received:t.parsedType}),G}return K(e.data)}};jd.create=e=>new jd({typeName:Y.ZodBoolean,coerce:e?.coerce||!1,...J(e)});var Md=class e extends nd{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==H.date){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.date,received:t.parsedType}),G}if(Number.isNaN(e.data.getTime()))return W(this._getOrReturnCtx(e),{code:U.invalid_date}),G;let t=new Ju,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),W(n,{code:U.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):Bu.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:q.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:q.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Md.create=e=>new Md({checks:[],coerce:e?.coerce||!1,typeName:Y.ZodDate,...J(e)});var Nd=class extends nd{_parse(e){if(this._getType(e)!==H.symbol){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.symbol,received:t.parsedType}),G}return K(e.data)}};Nd.create=e=>new Nd({typeName:Y.ZodSymbol,...J(e)});var Pd=class extends nd{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.undefined,received:t.parsedType}),G}return K(e.data)}};Pd.create=e=>new Pd({typeName:Y.ZodUndefined,...J(e)});var Fd=class extends nd{_parse(e){if(this._getType(e)!==H.null){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.null,received:t.parsedType}),G}return K(e.data)}};Fd.create=e=>new Fd({typeName:Y.ZodNull,...J(e)});var Id=class extends nd{constructor(){super(...arguments),this._any=!0}_parse(e){return K(e.data)}};Id.create=e=>new Id({typeName:Y.ZodAny,...J(e)});var Ld=class extends nd{constructor(){super(...arguments),this._unknown=!0}_parse(e){return K(e.data)}};Ld.create=e=>new Ld({typeName:Y.ZodUnknown,...J(e)});var Rd=class extends nd{_parse(e){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.never,received:t.parsedType}),G}};Rd.create=e=>new Rd({typeName:Y.ZodNever,...J(e)});var zd=class extends nd{_parse(e){if(this._getType(e)!==H.undefined){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.void,received:t.parsedType}),G}return K(e.data)}};zd.create=e=>new zd({typeName:Y.ZodVoid,...J(e)});var Bd=class e extends nd{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==H.array)return W(t,{code:U.invalid_type,expected:H.array,received:t.parsedType}),G;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(W(t,{code:e?U.too_big:U.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(W(t,{code:U.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(W(t,{code:U.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new ed(t,e,t.path,n)))).then(e=>Ju.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new ed(t,e,t.path,n)));return Ju.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:q.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:q.toString(n)}})}nonempty(e){return this.min(1,e)}};Bd.create=(e,t)=>new Bd({type:e,minLength:null,maxLength:null,exactLength:null,typeName:Y.ZodArray,...J(t)});function Vd(e){if(e instanceof Hd){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=sf.create(Vd(r))}return new Hd({...e._def,shape:()=>t})}return e instanceof Bd?new Bd({...e._def,type:Vd(e.element)}):e instanceof sf?sf.create(Vd(e.unwrap())):e instanceof cf?cf.create(Vd(e.unwrap())):e instanceof Jd?Jd.create(e.items.map(e=>Vd(e))):e}var Hd=class e extends nd{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=Bu.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==H.object){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),G}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Rd&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new ed(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Rd){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(W(n,{code:U.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new ed(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Ju.mergeObjectSync(t,e)):Ju.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return q.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:q.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:Y.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of Bu.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of Bu.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return Vd(this)}partial(t){let n={};for(let e of Bu.objectKeys(this.shape)){let r=this.shape[e];n[e]=t&&!t[e]?r:r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of Bu.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof sf;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return tf(Bu.objectKeys(this.shape))}};Hd.create=(e,t)=>new Hd({shape:()=>e,unknownKeys:`strip`,catchall:Rd.create(),typeName:Y.ZodObject,...J(t)}),Hd.strictCreate=(e,t)=>new Hd({shape:()=>e,unknownKeys:`strict`,catchall:Rd.create(),typeName:Y.ZodObject,...J(t)}),Hd.lazycreate=(e,t)=>new Hd({shape:e,unknownKeys:`strip`,catchall:Rd.create(),typeName:Y.ZodObject,...J(t)});var Ud=class extends nd{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Uu(e.ctx.common.issues));return W(t,{code:U.invalid_union,unionErrors:n}),G}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Uu(e));return W(t,{code:U.invalid_union,unionErrors:i}),G}}get options(){return this._def.options}};Ud.create=(e,t)=>new Ud({options:e,typeName:Y.ZodUnion,...J(t)});var Wd=e=>e instanceof $d?Wd(e.schema):e instanceof of?Wd(e.innerType()):e instanceof ef?[e.value]:e instanceof nf?e.options:e instanceof rf?Bu.objectValues(e.enum):e instanceof lf?Wd(e._def.innerType):e instanceof Pd?[void 0]:e instanceof Fd?[null]:e instanceof sf?[void 0,...Wd(e.unwrap())]:e instanceof cf?[null,...Wd(e.unwrap())]:e instanceof ff||e instanceof mf?Wd(e.unwrap()):e instanceof uf?Wd(e._def.innerType):[],Gd=class e extends nd{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.object)return W(t,{code:U.invalid_type,expected:H.object,received:t.parsedType}),G;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(W(t,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),G)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=Wd(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:Y.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...J(r)})}};function Kd(e,t){let n=Hu(e),r=Hu(t);if(e===t)return{valid:!0,data:e};if(n===H.object&&r===H.object){let n=Bu.objectKeys(t),r=Bu.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Kd(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===H.array&&r===H.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Kd(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===H.date&&r===H.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var qd=class extends nd{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Xu(e)||Xu(r))return G;let i=Kd(e.value,r.value);return i.valid?((Zu(e)||Zu(r))&&t.dirty(),{status:t.value,value:i.data}):(W(n,{code:U.invalid_intersection_types}),G)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};qd.create=(e,t,n)=>new qd({left:e,right:t,typeName:Y.ZodIntersection,...J(n)});var Jd=class e extends nd{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.array)return W(n,{code:U.invalid_type,expected:H.array,received:n.parsedType}),G;if(n.data.length<this._def.items.length)return W(n,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),G;!this._def.rest&&n.data.length>this._def.items.length&&(W(n,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new ed(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Ju.mergeArray(t,e)):Ju.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Jd.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Jd({items:e,typeName:Y.ZodTuple,rest:null,...J(t)})};var Yd=class e extends nd{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.object)return W(n,{code:U.invalid_type,expected:H.object,received:n.parsedType}),G;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new ed(n,e,n.path,e)),value:a._parse(new ed(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Ju.mergeObjectAsync(t,r):Ju.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof nd?new e({keyType:t,valueType:n,typeName:Y.ZodRecord,...J(r)}):new e({keyType:Dd.create(),valueType:t,typeName:Y.ZodRecord,...J(n)})}},Xd=class extends nd{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.map)return W(n,{code:U.invalid_type,expected:H.map,received:n.parsedType}),G;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new ed(n,e,n.path,[a,`key`])),value:i._parse(new ed(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return G;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return G;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Xd.create=(e,t,n)=>new Xd({valueType:t,keyType:e,typeName:Y.ZodMap,...J(n)});var Zd=class e extends nd{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==H.set)return W(n,{code:U.invalid_type,expected:H.set,received:n.parsedType}),G;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(W(n,{code:U.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(W(n,{code:U.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return G;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new ed(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:q.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:q.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Zd.create=(e,t)=>new Zd({valueType:e,minSize:null,maxSize:null,typeName:Y.ZodSet,...J(t)});var Qd=class e extends nd{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==H.function)return W(t,{code:U.invalid_type,expected:H.function,received:t.parsedType}),G;function n(e,n){return qu({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ku(),Wu].filter(e=>!!e),issueData:{code:U.invalid_arguments,argumentsError:n}})}function r(e,n){return qu({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ku(),Wu].filter(e=>!!e),issueData:{code:U.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof af){let e=this;return K(async function(...t){let o=new Uu([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}{let e=this;return K(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Uu([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Uu([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Jd.create(t).rest(Ld.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Jd.create([]).rest(Ld.create()),returns:n||Ld.create(),typeName:Y.ZodFunction,...J(r)})}},$d=class extends nd{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};$d.create=(e,t)=>new $d({getter:e,typeName:Y.ZodLazy,...J(t)});var ef=class extends nd{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return W(t,{received:t.data,code:U.invalid_literal,expected:this._def.value}),G}return{status:`valid`,value:e.data}}get value(){return this._def.value}};ef.create=(e,t)=>new ef({value:e,typeName:Y.ZodLiteral,...J(t)});function tf(e,t){return new nf({values:e,typeName:Y.ZodEnum,...J(t)})}var nf=class e extends nd{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{expected:Bu.joinValues(n),received:t.parsedType,code:U.invalid_type}),G}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return W(t,{received:t.data,code:U.invalid_enum_value,options:n}),G}return K(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};nf.create=tf;var rf=class extends nd{_parse(e){let t=Bu.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==H.string&&n.parsedType!==H.number){let e=Bu.objectValues(t);return W(n,{expected:Bu.joinValues(e),received:n.parsedType,code:U.invalid_type}),G}if(this._cache||=new Set(Bu.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=Bu.objectValues(t);return W(n,{received:n.data,code:U.invalid_enum_value,options:e}),G}return K(e.data)}get enum(){return this._def.values}};rf.create=(e,t)=>new rf({values:e,typeName:Y.ZodNativeEnum,...J(t)});var af=class extends nd{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==H.promise&&t.common.async===!1?(W(t,{code:U.invalid_type,expected:H.promise,received:t.parsedType}),G):K((t.parsedType===H.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};af.create=(e,t)=>new af({type:e,typeName:Y.ZodPromise,...J(t)});var of=class extends nd{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Y.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{W(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return G;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?G:r.status===`dirty`||t.value===`dirty`?Yu(r.value):r});{if(t.value===`aborted`)return G;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?G:r.status===`dirty`||t.value===`dirty`?Yu(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?G:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?G:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`){if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Qu(e))return G;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>Qu(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):G)}Bu.assertNever(r)}};of.create=(e,t,n)=>new of({schema:e,typeName:Y.ZodEffects,effect:t,...J(n)}),of.createWithPreprocess=(e,t,n)=>new of({schema:t,effect:{type:`preprocess`,transform:e},typeName:Y.ZodEffects,...J(n)});var sf=class extends nd{_parse(e){return this._getType(e)===H.undefined?K(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};sf.create=(e,t)=>new sf({innerType:e,typeName:Y.ZodOptional,...J(t)});var cf=class extends nd{_parse(e){return this._getType(e)===H.null?K(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};cf.create=(e,t)=>new cf({innerType:e,typeName:Y.ZodNullable,...J(t)});var lf=class extends nd{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===H.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};lf.create=(e,t)=>new lf({innerType:e,typeName:Y.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...J(t)});var uf=class extends nd{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $u(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Uu(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Uu(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};uf.create=(e,t)=>new uf({innerType:e,typeName:Y.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...J(t)});var df=class extends nd{_parse(e){if(this._getType(e)!==H.nan){let t=this._getOrReturnCtx(e);return W(t,{code:U.invalid_type,expected:H.nan,received:t.parsedType}),G}return{status:`valid`,value:e.data}}};df.create=e=>new df({typeName:Y.ZodNaN,...J(e)});var ff=class extends nd{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},pf=class e extends nd{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?G:e.status===`dirty`?(t.dirty(),Yu(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?G:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:Y.ZodPipeline})}},mf=class extends nd{_parse(e){let t=this._def.innerType._parse(e),n=e=>(Qu(e)&&(e.value=Object.freeze(e.value)),e);return $u(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};mf.create=(e,t)=>new mf({innerType:e,typeName:Y.ZodReadonly,...J(t)}),Hd.lazycreate;var Y;(function(e){e.ZodString=`ZodString`,e.ZodNumber=`ZodNumber`,e.ZodNaN=`ZodNaN`,e.ZodBigInt=`ZodBigInt`,e.ZodBoolean=`ZodBoolean`,e.ZodDate=`ZodDate`,e.ZodSymbol=`ZodSymbol`,e.ZodUndefined=`ZodUndefined`,e.ZodNull=`ZodNull`,e.ZodAny=`ZodAny`,e.ZodUnknown=`ZodUnknown`,e.ZodNever=`ZodNever`,e.ZodVoid=`ZodVoid`,e.ZodArray=`ZodArray`,e.ZodObject=`ZodObject`,e.ZodUnion=`ZodUnion`,e.ZodDiscriminatedUnion=`ZodDiscriminatedUnion`,e.ZodIntersection=`ZodIntersection`,e.ZodTuple=`ZodTuple`,e.ZodRecord=`ZodRecord`,e.ZodMap=`ZodMap`,e.ZodSet=`ZodSet`,e.ZodFunction=`ZodFunction`,e.ZodLazy=`ZodLazy`,e.ZodLiteral=`ZodLiteral`,e.ZodEnum=`ZodEnum`,e.ZodEffects=`ZodEffects`,e.ZodNativeEnum=`ZodNativeEnum`,e.ZodOptional=`ZodOptional`,e.ZodNullable=`ZodNullable`,e.ZodDefault=`ZodDefault`,e.ZodCatch=`ZodCatch`,e.ZodPromise=`ZodPromise`,e.ZodBranded=`ZodBranded`,e.ZodPipeline=`ZodPipeline`,e.ZodReadonly=`ZodReadonly`})(Y||={});var hf=Dd.create;kd.create,df.create,Ad.create;var gf=jd.create;Md.create,Nd.create,Pd.create,Fd.create;var _f=Id.create;Ld.create,Rd.create,zd.create,Bd.create;var vf=Hd.create;Hd.strictCreate,Ud.create;var yf=Gd.create;qd.create,Jd.create,Yd.create,Xd.create,Zd.create,Qd.create,$d.create;var bf=ef.create,xf=nf.create;rf.create,af.create,of.create,sf.create,cf.create,of.createWithPreprocess,pf.create;var Sf=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Cf=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(Sf);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},wf=e=>e===`*`||e===`x`||e===`X`,Tf=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},Ef=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],Df=(e,t)=>{if(wf(e)||wf(t))return 0;let[n,r]=Ef(Tf(e),Tf(t));return n>r?1:n<r?-1:0},Of=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=Df(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},kf=(e,t)=>{let n=Cf(e),r=Cf(t),i=n.pop(),a=r.pop(),o=Of(n,r);return o===0?i&&a?Of(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o},Af=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function jf(){return tr()}function Mf(e){if(Object.freeze(e),typeof e==`object`&&e)for(let t of Object.values(e))typeof t==`object`&&t&&!Object.isFrozen(t)&&Mf(t);return e}var Nf=524288;function Pf(e,t,n){let r=0,i=[e,t],a=new WeakSet;for(;i.length>0;){let e=i.pop();if(typeof e==`string`){if(r+=e.length,r>n)return!0}else if(typeof e==`object`&&e){if(a.has(e))continue;if(a.add(e),Array.isArray(e))for(let t=0;t<e.length;t++)i.push(e[t]);else{let t=Object.keys(e);for(let a=0;a<t.length;a++){let o=t[a];if(r+=o.length,r>n)return!0;i.push(e[o])}}}}return!1}async function Ff(e,t,n,r){let i=typeof process<`u`&&!0,a=i&&!!{}.VITEST_WORKER_ID,o=i&&!!{}.VITEST_WORKER_ID,s=o&&!Pf(t,n,Nf),c=s?Af(t):t,l=s?Af(n):n,u=!1,d=!1,f;for(let t of e)try{s&&(Mf(c),Mf(l));let e=await r(t,c,l);if(e===void 0)continue;let n=!1;if(e.messages!==void 0&&e.messages!==c&&(c=Af(e.messages),u=!0,n=!0),e.state!==void 0&&e.state!==l&&(l=Af(e.state),d=!0,n=!0),s&&n&&Pf(c,l,Nf)&&(s=!1),f=e.stopPropagation,f===!0)break}catch(e){if(o&&e instanceof TypeError){if(a)throw e;console.error(`AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.`,e)}else a||console.error(`Subscriber error:`,e);continue}return{...u?{messages:Object.isFrozen(c)?Af(c):c}:{},...d?{state:Object.isFrozen(l)?Af(l):l}:{},...f===void 0?{}:{stopPropagation:f}}}function If(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,n=e.lifecycle??!0,r=e.verbose??!1;return{enabled:t||n,events:t,lifecycle:n,verbose:r}}function Lf(e){if(e instanceof Rf)return e;if(e===!0)return new Rf(If(!0))}var Rf=class{constructor(e){this.config=e}event(e,t,n,r){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof n==`string`?n:JSON.stringify(n)):console.debug(`[${e}] ${t}`,r??n))}lifecycle(e,t,n){this.config.lifecycle&&(n?console.debug(`[${e}] ${t}`,n):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function zf(e){return e.enabled?new Rf(e):void 0}function Bf(e,t,n){if(t){let r=e.find(e=>e.id===t);if(r?.role===`assistant`)return r;r&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${r.role}' message, not assistant — falling back to toolCallId`);let i={id:r?n:t,role:`assistant`,toolCalls:[]};return e.push(i),i}let r={id:n,role:`assistant`,toolCalls:[]};return e.push(r),r}var Vf=(e,t,n,r,i)=>{let a=Lf(i),o=Af(n.messages),s=Af(e.state),c={},l=e=>{e.messages!==void 0&&(o=e.messages,c.messages=e.messages),e.state!==void 0&&(s=e.state,c.state=e.state)},u=()=>{let e=Af(c);return c={},e.messages!==void 0||e.state!==void 0?vc(e):zs};return t.pipe(Oc(async t=>{let i=await Ff(r,o,s,(r,i,a)=>r.onEvent?.({event:t,agent:n,input:e,messages:i,state:a}));if(l(i),i.stopPropagation===!0?a?.event(`APPLY`,`Event dropped:`,t,{type:t.type,reason:`stopPropagation by subscriber`}):a?.event(`APPLY`,`Event applied:`,t,{type:t.type,subscribers:r.length}),i.stopPropagation===!0)return u();switch(t.type){case I.TEXT_MESSAGE_START:{let i=await Ff(r,o,s,(r,i,a)=>r.onTextMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e,role:n=`assistant`,name:r}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:n,content:``,...r!==void 0&&{name:r}};o.push(t),l({messages:o})}}return u()}case I.TEXT_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await Ff(r,o,s,(r,i,a)=>r.onTextMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case I.TEXT_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await Ff(r,o,s,(r,i,o)=>r.onTextMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,textMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${i}'`),u())}case I.TOOL_CALL_START:{let i=await Ff(r,o,s,(r,i,a)=>r.onToolCallStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r}=t,i=o.find(t=>t.toolCalls?.some(t=>t.id===e))?.toolCalls?.find(t=>t.id===e);if(i)return i.function.name!==n&&(console.warn(`TOOL_CALL_START: tool call '${e}' already exists with name '${i.function.name}' — updating it to '${n}'`),i.function.name=n,l({messages:o})),u();let a=Bf(o,r,e);a.toolCalls??=[],a.toolCalls.push({id:e,type:`function`,function:{name:n,arguments:``}}),l({messages:o})}return u()}case I.TOOL_CALL_ARGS:{let{toolCallId:i,delta:a}=t,c=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!c)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${i}'`),u();let d=c.toolCalls?.find(e=>e.id===i);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${i}'`),u();let f=await Ff(r,o,s,(r,i,a)=>{let o=d.function.arguments,s=d.function.name,c={};try{c=Fc(o)}catch{}return r.onToolCallArgsEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallBuffer:o,toolCallName:s,partialToolCallArgs:c})});return l(f),f.stopPropagation!==!0&&(d.function.arguments+=a,l({messages:o})),u()}case I.TOOL_CALL_END:{let{toolCallId:i}=t,a=o.find(e=>e.toolCalls?.some(e=>e.id===i));if(!a)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${i}'`),u();let c=a.toolCalls?.find(e=>e.id===i);return c?(l(await Ff(r,o,s,(r,i,a)=>{let o=c.function.arguments,s=c.function.name,l={};try{l=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.({event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:l})})),await Promise.all(r.map(t=>{t.onNewToolCall?.({toolCall:c,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${i}'`),u())}case I.TOOL_CALL_RESULT:{let i=await Ff(r,o,s,(r,i,a)=>r.onToolCallResultEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:i,toolCallId:a,content:c,role:u}=t,d={id:i,toolCallId:a,role:u||`tool`,content:c},f=o.findIndex(e=>e.role===`assistant`&&e.toolCalls?.some(e=>e.id===a));if(f===-1)o.push(d);else{let e=f+1;for(;e<o.length&&o[e].role===`tool`;)e++;o.splice(e,0,d)}await Promise.all(r.map(t=>{t.onNewMessage?.({message:d,messages:o,state:s,agent:n,input:e})})),l({messages:o})}return u()}case I.STATE_SNAPSHOT:{let i=await Ff(r,o,s,(r,i,a)=>r.onStateSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{snapshot:e}=t;s=e,l({state:s})}return u()}case I.STATE_DELTA:{let i=await Ff(r,o,s,(r,i,a)=>r.onStateDeltaEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{delta:e}=t;try{s=Fo.applyPatch(s,e,!0,!1).newDocument,l({state:s})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:\nCurrent state: ${JSON.stringify(s,null,2)}\nPatch operations: ${JSON.stringify(e,null,2)}\nError: ${n}`)}}return u()}case I.MESSAGES_SNAPSHOT:{let i=await Ff(r,o,s,(r,i,a)=>r.onMessagesSnapshotEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messages:e}=t,n=new Map(e.map(e=>[e.id,e])),r=e.some(e=>e.role===`activity`),i=e.some(e=>e.role===`reasoning`),a=e=>e.role===`activity`&&!r||e.role===`reasoning`&&!i;o=o.filter(e=>a(e)||n.has(e.id)).map(e=>a(e)?e:n.get(e.id));let s=new Set(o.map(e=>e.id));for(let t of e)s.has(t.id)||o.push(t);l({messages:o})}return u()}case I.ACTIVITY_SNAPSHOT:{let i=t,a=o.findIndex(e=>e.id===i.messageId),c=a>=0?o[a]:void 0,d=c?.role===`activity`?c:void 0,f=i.replace??!0,p=await Ff(r,o,s,(t,r,a)=>t.onActivitySnapshotEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d,existingMessage:c}));if(l(p),p.stopPropagation!==!0){let t={id:i.messageId,role:`activity`,activityType:i.activityType,content:Af(i.content)},c;a===-1?(o.push(t),c=t):d?f&&(o[a]={...d,activityType:i.activityType,content:Af(i.content)}):f&&(o[a]=t,c=t),l({messages:o}),c&&await Promise.all(r.map(t=>t.onNewMessage?.({message:c,messages:o,state:s,agent:n,input:e})))}return u()}case I.ACTIVITY_DELTA:{let i=t,a=o.findIndex(e=>e.id===i.messageId);if(a===-1)return u();let c=o[a];if(c.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${i.messageId}' is not an activity message`),u();let d=c,f=await Ff(r,o,s,(t,r,a)=>t.onActivityDeltaEvent?.({event:i,messages:r,state:a,agent:n,input:e,activityMessage:d}));if(l(f),f.stopPropagation!==!0)try{let e=Af(d.content??{}),t=Fo.applyPatch(e,i.patch??[],!0,!1).newDocument;o[a]={...d,content:Af(t),activityType:i.activityType},l({messages:o})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${i.messageId}': ${t}`)}return u()}case I.RAW:return l(await Ff(r,o,s,(r,i,a)=>r.onRawEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.CUSTOM:return l(await Ff(r,o,s,(r,i,a)=>r.onCustomEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.RUN_STARTED:{let i=await Ff(r,o,s,(r,i,a)=>r.onRunStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let e=t;if(e.input?.messages){for(let t of e.input.messages)o.find(e=>e.id===t.id)||o.push(t);l({messages:o})}}return u()}case I.RUN_FINISHED:{let i=t,a=i.outcome?.type===`interrupt`?{event:i,outcome:`interrupt`,interrupts:i.outcome.interrupts}:{event:i,outcome:`success`,result:i.result},c=await Ff(r,o,s,(t,r,i)=>t.onRunFinishedEvent?.({...a,messages:r,state:i,agent:n,input:e}));return l(c),c.stopPropagation!==!0&&(n.pendingInterrupts=a.outcome===`interrupt`?[...a.interrupts]:[]),u()}case I.RUN_ERROR:return l(await Ff(r,o,s,(r,i,a)=>r.onRunErrorEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.STEP_STARTED:return l(await Ff(r,o,s,(r,i,a)=>r.onStepStartedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.STEP_FINISHED:return l(await Ff(r,o,s,(r,i,a)=>r.onStepFinishedEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be tranformed before being applied`);case I.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be tranformed before being applied`);case I.THINKING_START:return u();case I.THINKING_END:return u();case I.THINKING_TEXT_MESSAGE_START:return u();case I.THINKING_TEXT_MESSAGE_CONTENT:return u();case I.THINKING_TEXT_MESSAGE_END:return u();case I.REASONING_START:return l(await Ff(r,o,s,(r,i,a)=>r.onReasoningStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.REASONING_MESSAGE_START:{let i=await Ff(r,o,s,(r,i,a)=>r.onReasoningMessageStartEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(i),i.stopPropagation!==!0){let{messageId:e}=t;if(!o.find(t=>t.id===e)){let t={id:e,role:`reasoning`,content:``};o.push(t),l({messages:o})}}return u()}case I.REASONING_MESSAGE_CONTENT:{let{messageId:i,delta:a}=t,c=o.find(e=>e.id===i);if(!c)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${i}'`),u();let d=await Ff(r,o,s,(r,i,a)=>r.onReasoningMessageContentEvent?.({event:t,messages:i,state:a,agent:n,input:e,reasoningMessageBuffer:typeof c.content==`string`?c.content:``}));return l(d),d.stopPropagation!==!0&&(c.content=`${typeof c.content==`string`?c.content:``}${a}`,l({messages:o})),u()}case I.REASONING_MESSAGE_END:{let{messageId:i}=t,a=o.find(e=>e.id===i);return a?(l(await Ff(r,o,s,(r,i,o)=>r.onReasoningMessageEndEvent?.({event:t,messages:i,state:o,agent:n,input:e,reasoningMessageBuffer:typeof a.content==`string`?a.content:``}))),await Promise.all(r.map(t=>{t.onNewMessage?.({message:a,messages:o,state:s,agent:n,input:e})})),u()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${i}'`),u())}case I.REASONING_MESSAGE_CHUNK:throw Error(`REASONING_MESSAGE_CHUNK must be transformed before being applied`);case I.REASONING_END:return l(await Ff(r,o,s,(r,i,a)=>r.onReasoningEndEvent?.({event:t,messages:i,state:a,agent:n,input:e}))),u();case I.REASONING_ENCRYPTED_VALUE:{let{subtype:i,entityId:a,encryptedValue:d}=t,f=await Ff(r,o,s,(r,i,a)=>r.onReasoningEncryptedValueEvent?.({event:t,messages:i,state:a,agent:n,input:e}));if(l(f),f.stopPropagation!==!0){let e=!1;if(i===`tool-call`){for(let t of o)if(t.role===`assistant`&&t.toolCalls){let n=t.toolCalls.find(e=>e.id===a);if(n){n.encryptedValue=d,e=!0;break}}}else{let t=o.find(e=>e.id===a);t?.role!==`activity`&&t&&(t.encryptedValue=d,e=!0)}e&&(c.messages=o)}return u()}}return t.type,u()}),Tc(),r.length>0?kc({}):e=>e)},Hf=e=>t=>{let n=Lf(e),r=new Map,i=new Map,a=!1,o=!1,s=!1,c=new Map,l=!1,u=!1,d=!1,f=()=>{r.clear(),i.clear(),c.clear(),l=!1,u=!1,a=!1,o=!1,d=!0};return t.pipe(wc(e=>{let t=e.type;if(n?.event(`VERIFY`,`Event:`,e,{type:e.type}),o)return yc(()=>new sa(`Cannot send event type '${t}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(a&&t!==I.RUN_ERROR&&t!==I.RUN_STARTED)return yc(()=>new sa(`Cannot send event type '${t}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(!s){if(s=!0,t!==I.RUN_STARTED&&t!==I.RUN_ERROR)return yc(()=>new sa(`First event must be 'RUN_STARTED'`))}else if(t===I.RUN_STARTED){if(d&&!a)return yc(()=>new sa(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));a&&f()}switch(t){case I.TEXT_MESSAGE_START:{let t=e.messageId;return r.has(t)?yc(()=>new sa(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${t}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(r.set(t,!0),vc(e))}case I.TEXT_MESSAGE_CONTENT:{let t=e.messageId;return r.has(t)?vc(e):yc(()=>new sa(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${t}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case I.TEXT_MESSAGE_END:{let t=e.messageId;return r.has(t)?(r.delete(t),vc(e)):yc(()=>new sa(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${t}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case I.TOOL_CALL_START:{let t=e.toolCallId;return i.has(t)?yc(()=>new sa(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${t}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(i.set(t,!0),vc(e))}case I.TOOL_CALL_ARGS:{let t=e.toolCallId;return i.has(t)?vc(e):yc(()=>new sa(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${t}'. Start a tool call with 'TOOL_CALL_START' first.`))}case I.TOOL_CALL_END:{let t=e.toolCallId;return i.has(t)?(i.delete(t),vc(e)):yc(()=>new sa(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${t}'. A 'TOOL_CALL_START' event must be sent first.`))}case I.STEP_STARTED:{let t=e.stepName;return c.has(t)?yc(()=>new sa(`Step "${t}" is already active for 'STEP_STARTED'`)):(c.set(t,!0),vc(e))}case I.STEP_FINISHED:{let t=e.stepName;return c.has(t)?(c.delete(t),vc(e)):yc(()=>new sa(`Cannot send 'STEP_FINISHED' for step "${t}" that was not started`))}case I.RUN_STARTED:return d=!0,vc(e);case I.RUN_FINISHED:if(c.size>0){let e=Array.from(c.keys()).join(`, `);return yc(()=>new sa(`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return yc(()=>new sa(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(i.size>0){let e=Array.from(i.keys()).join(`, `);return yc(()=>new sa(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}return a=!0,vc(e);case I.RUN_ERROR:return o=!0,vc(e);case I.CUSTOM:return vc(e);case I.THINKING_TEXT_MESSAGE_START:return l?u?yc(()=>new sa(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.`)):(u=!0,vc(e)):yc(()=>new sa(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.`));case I.THINKING_TEXT_MESSAGE_CONTENT:return u?vc(e):yc(()=>new sa(`Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.`));case I.THINKING_TEXT_MESSAGE_END:return u?(u=!1,vc(e)):yc(()=>new sa(`Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.`));case I.THINKING_START:return l?yc(()=>new sa(`Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.`)):(l=!0,vc(e));case I.THINKING_END:return l?(l=!1,vc(e)):yc(()=>new sa(`Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.`));default:return vc(e)}}))},Uf=function(e){return e.HEADERS=`headers`,e.DATA=`data`,e}({}),Wf=e=>Ec(()=>_c(e())).pipe(jc(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return _c(e.text()).pipe(wc(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,yc(()=>i)}))}let t={type:Uf.HEADERS,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new Es(e=>(e.next(t),(async()=>{try{for(;;){let{done:t,value:r}=await n.read();if(t)break;let i={type:Uf.DATA,data:r};e.next(i)}e.complete()}catch(t){e.error(t)}})(),()=>{n.cancel().catch(e=>{if(e?.name!==`AbortError`)throw e})})):yc(()=>Error(`Failed to getReader() from response`))})),Gf=(e,t)=>{let n=Lf(t),r=new Fs,i=new TextDecoder(`utf-8`,{fatal:!1}),a=``;e.subscribe({next:e=>{if(e.type!==Uf.HEADERS&&e.type===Uf.DATA&&e.data){let t=i.decode(e.data,{stream:!0});a+=t;let n=a.split(/\n\n/);a=n.pop()||``;for(let e of n)o(e)}},error:e=>r.error(e),complete:()=>{a&&(a+=i.decode(),o(a)),r.complete()}});function o(e){let t=e.split(`
|
|
16
|
+
`),i=[];for(let e of t)e.startsWith(`data:`)&&i.push(e.slice(5).replace(/^ /,``));if(i.length>0)try{let e=i.join(`
|
|
17
|
+
`),t=JSON.parse(e);n?.event(`SSE`,`Event received:`,t,{type:t.type}),r.next(t)}catch(e){r.error(e)}}return r.asObservable()},Kf=e=>{let t=new Fs,n=new Uint8Array;e.subscribe({next:e=>{if(e.type!==Uf.HEADERS&&e.type===Uf.DATA&&e.data){let t=new Uint8Array(n.length+e.data.length);t.set(n,0),t.set(e.data,n.length),n=t,r()}},error:e=>t.error(e),complete:()=>{if(n.length>0)try{r()}catch{console.warn(`Incomplete or invalid protocol buffer data at stream end`)}t.complete()}});function r(){for(;n.length>=4;){let e=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<e)break;try{let r=zu(n.slice(4,e));t.next(r),n=n.slice(e)}catch(e){let n=e instanceof Error?e.message:String(e);t.error(Error(`Failed to decode protocol buffer message: ${n}`));return}}}return t.asObservable()},qf=(e,t)=>{let n=Lf(t),r=new Fs,i=new Rs,a=!1;return e.subscribe({next:e=>{if(i.next(e),e.type===Uf.HEADERS&&!a){a=!0;let t=e.headers.get(`content-type`);n?.lifecycle(`HTTP`,`Stream format detected:`,{contentType:t,parser:t===`application/vnd.ag-ui.event+proto`?`protobuf`:`sse`}),t===`application/vnd.ag-ui.event+proto`?Kf(i).subscribe({next:e=>r.next(e),error:e=>r.error(e),complete:()=>r.complete()}):Gf(i,n).subscribe({next:e=>{try{let t=$a.parse(e);n?.event(`HTTP`,`Event validated:`,t,{type:t.type,valid:!0}),r.next(t)}catch(t){n?.event(`HTTP`,`Event invalid:`,{json:e,error:String(t)}),r.error(t)}},error:e=>{if(e?.name===`AbortError`){r.next({type:I.RUN_ERROR,message:e.message||`Request aborted`,code:`abort`,rawEvent:e}),r.complete();return}return r.error(e)},complete:()=>r.complete()})}else a||r.error(Error(`No headers event received before data events`))},error:e=>{i.error(e),r.error(e)},complete:()=>{i.complete()}}),r.asObservable()},Jf=xf([`TextMessageStart`,`TextMessageContent`,`TextMessageEnd`,`ActionExecutionStart`,`ActionExecutionArgs`,`ActionExecutionEnd`,`ActionExecutionResult`,`AgentStateMessage`,`MetaEvent`,`RunStarted`,`RunFinished`,`RunError`,`NodeStarted`,`NodeFinished`]),Yf=xf([`LangGraphInterruptEvent`,`PredictState`,`Exit`]);yf(`type`,[vf({type:bf(Jf.enum.TextMessageStart),messageId:hf(),parentMessageId:hf().optional(),role:hf().optional()}),vf({type:bf(Jf.enum.TextMessageContent),messageId:hf(),content:hf()}),vf({type:bf(Jf.enum.TextMessageEnd),messageId:hf()}),vf({type:bf(Jf.enum.ActionExecutionStart),actionExecutionId:hf(),actionName:hf(),parentMessageId:hf().optional()}),vf({type:bf(Jf.enum.ActionExecutionArgs),actionExecutionId:hf(),args:hf()}),vf({type:bf(Jf.enum.ActionExecutionEnd),actionExecutionId:hf()}),vf({type:bf(Jf.enum.ActionExecutionResult),actionName:hf(),actionExecutionId:hf(),result:hf()}),vf({type:bf(Jf.enum.AgentStateMessage),threadId:hf(),agentName:hf(),nodeName:hf(),runId:hf(),active:gf(),role:hf(),state:hf(),running:gf()}),vf({type:bf(Jf.enum.MetaEvent),name:Yf,value:_f()}),vf({type:bf(Jf.enum.RunError),message:hf(),code:hf().optional()})]),vf({id:hf(),role:hf(),content:hf(),parentMessageId:hf().optional()}),vf({id:hf(),name:hf(),arguments:_f(),parentMessageId:hf().optional()}),vf({id:hf(),result:_f(),actionExecutionId:hf(),actionName:hf()});var Xf=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(`
|
|
18
|
+
`)},Zf=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(wc(r=>{switch(r.type){case I.TEXT_MESSAGE_START:{let e=r;return[{type:Jf.enum.TextMessageStart,messageId:e.messageId,role:e.role}]}case I.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:Jf.enum.TextMessageContent,messageId:e.messageId,content:e.delta}]}case I.TEXT_MESSAGE_END:{let e=r;return[{type:Jf.enum.TextMessageEnd,messageId:e.messageId}]}case I.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:Jf.enum.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case I.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let p=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(Fc(d.function.arguments));e.tool_argument&&e.tool_argument in t?(f({...i,[e.state_key]:t[e.tool_argument]}),p=!0):e.tool_argument||(f({...i,[e.state_key]:t}),p=!0)}catch{}}return[{type:Jf.enum.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...p?[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case I.TOOL_CALL_END:{let e=r;return[{type:Jf.enum.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case I.TOOL_CALL_RESULT:{let e=r;return[{type:Jf.enum.ActionExecutionResult,actionExecutionId:e.toolCallId,result:e.content,actionName:d[e.toolCallId]||`unknown`}]}case I.RAW:return[];case I.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value}return[{type:Jf.enum.MetaEvent,name:e.name,value:e.value}]}case I.STATE_SNAPSHOT:return f(r.snapshot),[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case I.STATE_DELTA:{let c=r,l=Fo.applyPatch(i,c.delta,!0,!1);return l?(f(l.newDocument),[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]):[]}case I.MESSAGES_SNAPSHOT:return c=r.messages,[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:c}:{}}),active:!0}];case I.RUN_STARTED:return[];case I.RUN_FINISHED:return c&&(i.messages=c),Object.keys(i).length===0?[]:[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify({...i,...c?{messages:Qf(c)}:{}}),active:!1}];case I.RUN_ERROR:{let e=r;return[{type:Jf.enum.RunError,message:e.message,code:e.code}]}case I.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case I.STEP_FINISHED:return u=[],l=null,[{type:Jf.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function Qf(e){let t=[];for(let n of e)if(n.role===`assistant`||n.role===`user`||n.role===`system`){let e=Xf(n.content);if(e){let r={id:n.id,role:n.role,content:e};t.push(r)}if(n.role===`assistant`&&n.toolCalls&&n.toolCalls.length>0)for(let e of n.toolCalls){let r={id:e.id,name:e.function.name,arguments:JSON.parse(e.function.arguments),parentMessageId:n.id};t.push(r)}}else if(n.role===`tool`){let r=`unknown`;for(let t of e)if(t.role===`assistant`&&t.toolCalls?.length){for(let e of t.toolCalls)if(e.id===n.toolCallId){r=e.function.name;break}}let i={id:n.id,result:n.content,actionExecutionId:n.toolCallId,actionName:r};t.push(i)}return t}var $f=e=>t=>{let n=Lf(e),r,i,a,o,s=()=>{if(!r||o!==`text`)throw Error(`No text message to close`);let e={type:I.TEXT_MESSAGE_END,messageId:r.messageId};return o=void 0,r=void 0,n?.event(`TRANSFORM`,`TEXT_MESSAGE_END`,e,{messageId:e.messageId}),e},c=()=>{if(!i||o!==`tool`)throw Error(`No tool call to close`);let e={type:I.TOOL_CALL_END,toolCallId:i.toolCallId};return o=void 0,i=void 0,n?.event(`TRANSFORM`,`TOOL_CALL_END`,e,{toolCallId:e.toolCallId}),e},l=()=>{if(!a||o!==`reasoning`)throw Error(`No reasoning message to close`);let e={type:I.REASONING_MESSAGE_END,messageId:a.messageId};return o=void 0,a=void 0,n?.event(`TRANSFORM`,`REASONING_MESSAGE_END`,e,{messageId:e.messageId}),e},u=()=>o===`text`?[s()]:o===`tool`?[c()]:o===`reasoning`?[l()]:[];return t.pipe(wc(e=>{switch(e.type){case I.TEXT_MESSAGE_START:case I.TEXT_MESSAGE_CONTENT:case I.TEXT_MESSAGE_END:case I.TOOL_CALL_START:case I.TOOL_CALL_ARGS:case I.TOOL_CALL_END:case I.TOOL_CALL_RESULT:case I.STATE_SNAPSHOT:case I.STATE_DELTA:case I.MESSAGES_SNAPSHOT:case I.CUSTOM:case I.RUN_STARTED:case I.RUN_FINISHED:case I.RUN_ERROR:case I.STEP_STARTED:case I.STEP_FINISHED:case I.THINKING_START:case I.THINKING_END:case I.THINKING_TEXT_MESSAGE_START:case I.THINKING_TEXT_MESSAGE_CONTENT:case I.THINKING_TEXT_MESSAGE_END:case I.REASONING_START:case I.REASONING_MESSAGE_START:case I.REASONING_MESSAGE_CONTENT:case I.REASONING_MESSAGE_END:case I.REASONING_END:return[...u(),e];case I.RAW:case I.ACTIVITY_SNAPSHOT:case I.ACTIVITY_DELTA:case I.REASONING_ENCRYPTED_VALUE:return[e];case I.TEXT_MESSAGE_CHUNK:{let t=e,i=[];if((o!==`text`||t.messageId!==void 0&&t.messageId!==r?.messageId)&&i.push(...u()),o!==`text`){if(t.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);r={messageId:t.messageId,name:t.name},o=`text`;let e={type:I.TEXT_MESSAGE_START,messageId:t.messageId,role:t.role||`assistant`,...t.name!==void 0&&{name:t.name}};i.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0){let e={type:I.TEXT_MESSAGE_CONTENT,messageId:r.messageId,delta:t.delta};i.push(e),n?.event(`TRANSFORM`,`TEXT_MESSAGE_CONTENT`,e,{messageId:r.messageId})}return i}case I.TOOL_CALL_CHUNK:{let t=e,r=[];if((o!==`tool`||t.toolCallId!==void 0&&t.toolCallId!==i?.toolCallId)&&r.push(...u()),o!==`tool`){if(t.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(t.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);i={toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId},o=`tool`;let e={type:I.TOOL_CALL_START,toolCallId:t.toolCallId,toolCallName:t.toolCallName,parentMessageId:t.parentMessageId};r.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_START`,e,{toolCallId:t.toolCallId,toolCallName:t.toolCallName})}if(t.delta!==void 0){let e={type:I.TOOL_CALL_ARGS,toolCallId:i.toolCallId,delta:t.delta};r.push(e),n?.event(`TRANSFORM`,`TOOL_CALL_ARGS`,e,{toolCallId:i.toolCallId})}return r}case I.REASONING_MESSAGE_CHUNK:{let t=e,r=[];if((o!==`reasoning`||t.messageId&&t.messageId!==a?.messageId)&&r.push(...u()),o!==`reasoning`){if(t.messageId===void 0)throw Error(`First REASONING_MESSAGE_CHUNK must have a messageId`);a={messageId:t.messageId},o=`reasoning`;let e={type:I.REASONING_MESSAGE_START,messageId:t.messageId};r.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_START`,e,{messageId:t.messageId})}if(t.delta!==void 0){let e={type:I.REASONING_MESSAGE_CONTENT,messageId:a.messageId,delta:t.delta};r.push(e),n?.event(`TRANSFORM`,`REASONING_MESSAGE_CONTENT`,e,{messageId:a.messageId})}return r}}return e.type,[]}),Ac(()=>{u()}))};function ep(e,t=new Date){return e.expiresAt!==void 0&&new Date(e.expiresAt)<=t}function tp(e,t){let n=new Set(e.map(e=>e.id)),r=new Set(Object.keys(t)),i=[...n].filter(e=>!r.has(e));if(i.length>0)throw Error(`buildResumeArray: missing responses for open interrupts: ${i.join(`, `)}`);let a=[...r].filter(e=>!n.has(e));if(a.length>0)throw Error(`buildResumeArray: responses reference unknown interrupt ids: ${a.join(`, `)}`);return e.map(e=>{let n=t[e.id];if(n.status===`resolved`){let t={interruptId:e.id,status:`resolved`};return n.payload!==void 0&&(t.payload=n.payload),t}return{interruptId:e.id,status:`cancelled`}})}var np=class{runNext(e,t){return t.run(e).pipe($f(!1))}runNextWithState(e,t){let n=Af(e.messages||[]),r=Af(e.state||{}),i=new Rs;return Vf(e,i,t,[]).subscribe(e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)}),this.runNext(e,t).pipe(Oc(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:Af(n),state:Af(r)})))}},rp=class extends np{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function ip(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``);return{...e,content:n}}return typeof t==`string`?e:{...e,content:``}}var ap=class extends np{run(e,t){let{parentRunId:n,...r}=e,i={...r,messages:r.messages.map(ip)};return this.runNext(i,t)}},op=`THINKING_START`,sp=`THINKING_END`,cp=`THINKING_TEXT_MESSAGE_START`,lp=`THINKING_TEXT_MESSAGE_CONTENT`,up=`THINKING_TEXT_MESSAGE_END`,dp=class extends np{constructor(...e){super(...e),this.currentReasoningId=null,this.currentMessageId=null}warnAboutTransformation(e,t){typeof process<`u`&&{}.SUPPRESS_TRANSFORMATION_WARNINGS||console.warn(`AG-UI is converting ${e} to ${t}. To remove this warning, upgrade your AG-UI integration package (e.g. @ag-ui/langgraph). To surpress it, set SUPPRESS_TRANSFORMATION_WARNINGS=true in your .env file.`)}run(e,t){return this.currentReasoningId=null,this.currentMessageId=null,this.runNext(e,t).pipe(Sc(e=>this.transformEvent(e)))}transformEvent(e){switch(e.type){case op:{this.currentReasoningId=jf();let{title:t,...n}=e;return this.warnAboutTransformation(op,I.REASONING_START),{...n,type:I.REASONING_START,messageId:this.currentReasoningId}}case cp:return this.currentMessageId=jf(),this.warnAboutTransformation(cp,I.REASONING_MESSAGE_START),{...e,type:I.REASONING_MESSAGE_START,messageId:this.currentMessageId,role:`assistant`};case lp:{let{delta:t,...n}=e;return this.warnAboutTransformation(lp,I.REASONING_MESSAGE_CONTENT),{...n,type:I.REASONING_MESSAGE_CONTENT,messageId:this.currentMessageId??jf(),delta:t}}case up:{let t=this.currentMessageId??jf();return this.warnAboutTransformation(up,I.REASONING_MESSAGE_END),{...e,type:I.REASONING_MESSAGE_END,messageId:t}}case sp:{let t=this.currentReasoningId??jf();return this.warnAboutTransformation(sp,I.REASONING_END),{...e,type:I.REASONING_END,messageId:t}}default:return e}}};function fp(e){return e.startsWith(`image/`)?`image`:e.startsWith(`audio/`)?`audio`:e.startsWith(`video/`)?`video`:`document`}function pp(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`binary`&&`mimeType`in e&&typeof e.mimeType==`string`}function mp(e){let t=fp(e.mimeType);return e.data?{type:t,source:{type:`data`,value:e.data,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e.url?{type:t,source:{type:`url`,value:e.url,mimeType:e.mimeType},...e.filename?{metadata:{filename:e.filename}}:{}}:e}function hp(e){let t=e.content;if(!Array.isArray(t))return e;let n=t.map(e=>pp(e)?mp(e):e);return{...e,content:n}}var gp=class extends np{run(e,t){let n={...e,messages:e.messages.map(hp)};return this.runNext(n,t)}},_p=`0.0.58`,vp=class{get maxVersion(){return _p}get debug(){return this._debug}set debug(e){this._debug=If(e),this._debugLogger=zf(this._debug)}get debugLogger(){return this._debugLogger}set debugLogger(e){this._debugLogger=typeof e==`boolean`?e?zf(If(!0)):void 0:e}constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.subscribers=[],this.isRunning=!1,this.pendingInterrupts=[],this.middlewares=[],this.agentId=e,this.description=t??``,this.threadId=n??tr(),this.messages=Af(r??[]),this.state=Af(i??{}),this._debug=If(a),this._debugLogger=zf(this._debug),kf(this.maxVersion,`0.0.39`)<=0&&this.middlewares.unshift(new ap),kf(this.maxVersion,`0.0.45`)<=0&&this.middlewares.unshift(new dp),kf(this.maxVersion,`0.0.47`)<=0&&this.middlewares.unshift(new gp)}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new rp(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??tr();let n=this.prepareRunAgentInput(e);this.debugLogger?.lifecycle(`LIFECYCLE`,`Run started:`,{agentId:this.agentId,threadId:this.threadId});let r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fs;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await xc(ws(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(n),$f(this.debugLogger),Hf(this.debugLogger),e=>e.pipe(Mc(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),Dc(e=>(this.debugLogger?.lifecycle(`LIFECYCLE`,`Run errored:`,{agentId:this.agentId,error:e instanceof Error?e.message:String(e)}),this.isRunning=!1,this.onError(n,e,a))),Ac(()=>{this.debugLogger?.lifecycle(`LIFECYCLE`,`Run finished:`,{agentId:this.agentId,threadId:this.threadId}),this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(vc(null)));let s=Af(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new ca}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??tr();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{e.outcome===`success`&&(r=e.result)}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new Fs;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await xc(ws(()=>Ec(()=>this.connect(n)),$f(this.debugLogger),Hf(this.debugLogger),e=>e.pipe(Mc(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),Dc(e=>(this.isRunning=!1,e instanceof ca?zs:this.onError(n,e,a))),Ac(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(vc(null)),{defaultValue:void 0});let s=Af(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){if(!this.activeRunDetach$)return;let e=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),this.activeRunDetach$?.complete(),await e}apply(e,t,n){return Vf(e,t,this,n,this.debugLogger)}processApplyEvents(e,t,n){return t.pipe(Nc(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),t.state&&(this.state=t.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=Af(this.messages).filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||tr(),tools:Af(e?.tools??[]),context:Af(e?.context??[]),forwardedProps:Af(e?.forwardedProps??{}),state:Af(this.state),messages:t,...e?.resume===void 0?{}:{resume:Af(e.resume)}}}async onInitialize(e,t){if(this.pendingInterrupts.length>0){let t=new Set((e.resume??[]).map(e=>e.interruptId)),n=this.pendingInterrupts.map(e=>e.id).filter(e=>!t.has(e));if(n.length>0)throw new sa(`Thread has ${n.length} pending interrupt(s) not addressed by resume: ${n.join(`, `)}`);for(let e of this.pendingInterrupts)if(ep(e))throw new sa(`Interrupt ${e.id} expired at ${e.expiresAt}`)}let n=await Ff(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return _c(Ff(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.({error:t,messages:r,state:i,agent:this,input:e}))).pipe(Sc(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0){let e=String(t);if(t.name!==`AbortError`&&t.message!==`Fetch is aborted`&&t.message!==`signal is aborted without reason`&&t.message!==`component unmounted`&&e!==`component unmounted`)throw console.error(`Agent execution failed:`,t),t}return{}}))}async onFinalize(e,t){let n=await Ff(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.({messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{t.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{t.onStateChanged?.({state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=Af(this.messages),e.state=Af(this.state),e._debug=this._debug,e._debugLogger=this._debugLogger,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e.pendingInterrupts=Af(this.pendingInterrupts),e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.({message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.({toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.({message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.({toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=Af(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.({messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=Af(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.({messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??tr();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e),get messages(){return e.messages},get state(){return e.state}}),this).run(t)).pipe($f(this.debugLogger),Hf(this.debugLogger),Zf(this.threadId,t.runId,this.agentId),e=>e.pipe(Sc(e=>(this.debugLogger?.event(`LEGACY`,`Event:`,e,{type:e.type}),e))))}},yp=class extends vp{requestInit(e){return{method:`POST`,headers:{...this.headers,"Content-Type":`application/json`,Accept:`text/event-stream`},body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=Af(e.headers??{}),this.fetch=e.fetch??((e,t)=>fetch(e,t))}run(e){return qf(Wf(()=>this.fetch(this.url,this.requestInit(e))),this.debugLogger)}clone(){let e=super.clone();e.url=this.url,e.headers=Af(this.headers??{}),e.fetch=this.fetch;let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},bp=null;function xp(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=bp;bp=e;try{if(t(),e.isFirstRender=!1,e.cells.length!==e.currentIndex)throw Error(`Rendered ${e.currentIndex} hooks but expected ${e.cells.length}. Hooks must be called in the exact same order in every render.`)}finally{bp=n}}function Sp(){if(!bp)throw Error(`No resource fiber available`);return bp}function Cp(){return bp}var wp=typeof process<`u`&&!1,Tp=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),Ep=e=>{e.committedVersion=e.version;for(let t of e.changelog)t.logged=!1,t.settled||(t.settled=!0,e.unsettledCount--),e.committedLog.push(t);e.changelog.length=0,e.unsettledCount===0&&(e.committedLog.length=0),e.rollbackCallbacks.length=0},Dp=(e,t)=>{let n=e.version>t;if(e.version=t,n){for(let t=0;t<e.rollbackCallbacks.length;t++)e.rollbackCallbacks[t]();if(e.rollbackCallbacks.length=0,t<=e.committedVersion){let n=[];for(;e.committedVersion-n.length>t;){let t=e.committedLog.pop();if(t===void 0){if(wp)throw Error(`tap: committed history is shorter than the replay base.`);break}jp(t.fiber,t.cell),t.cell.workInProgress=t.prevState,n.push({record:t,prevState:t.prevState,eagerState:t.eagerState,hasEagerState:t.hasEagerState})}if(n.length>0){let t=e.committedVersion;Ap(e,()=>{for(let t=n.length-1;t>=0;t--){let r=n[t];r.record.prevState=r.prevState,r.record.eagerState=r.eagerState,r.record.hasEagerState=r.hasEagerState,e.committedLog.push(r.record)}e.committedVersion=t})}e.committedVersion=t;for(let t of e.changelog)t.logged=!1;e.changelog.length=0}else{for(;e.committedVersion+e.changelog.length>t;)e.changelog.pop().logged=!1;for(let t=0;t<e.changelog.length;t++)Op(e.changelog[t]);Ep(e)}}},Op=e=>{jp(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},kp=(e,t)=>{e.wipCommitCallbacks.push(t)},Ap=(e,t)=>{e.rollbackCallbacks.push(t)},jp=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),Ap(e.root,()=>{if(t.queue!==null){for(let e of t.queue)e.queued=!1;t.queue=null}t.workInProgress=t.current,t.isDirty=!1}))},Mp=Symbol.for(`react.memo_cache_sentinel`),Np=e=>Array(e).fill(Mp),Pp=(e,t)=>{let n=e.memoCache,r=n.workInProgress;if(r===null){let t=n.current;r=t===null?[]:t.map(e=>e.slice()),n.workInProgress=r,Ap(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=Np(t),r[i]=a):wp&&a.length!==t&&console.error(`Expected a constant size argument for each invocation of c(). The previous cache was allocated with size ${a.length} but size ${t} was requested.`),a},Fp=e=>Pp(Sp(),e),Ip=S.default.__COMPILER_RUNTIME?.c??(e=>(0,S.useMemo)(()=>{let t=Np(e);return t[Mp]=!0,t},[])),Lp=()=>Cp()!==null,Rp=e=>Lp()?Fp(e):Ip(e),zp=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},Bp=()=>{throw Error(`Hook order changed between renders`)},Vp=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Hp(e,t){let n=Sp(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?Vp():i.type===`effect`?i:Bp();if(i===void 0&&(n.isFirstRender||zp(),n.cells[r]=a,n.effectCells.push(a)),a.deps!==null&&!!t!=!!a.deps)throw Error(`useEffect called with and without dependencies across re-renders`);kp(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Up=(e,t)=>{wp&&e.length!==t.length&&console.error(`The final argument passed to a hook changed size between renders. The order and size of this array must remain constant.
|
|
19
|
+
|
|
20
|
+
Previous: [${e.join(`, `)}]\nIncoming: [${t.join(`, `)}]`);for(let n=0;n<e.length&&n<t.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0},Wp=(e,t)=>{kp(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},Gp=(e,t)=>{let n=Sp(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||zp();let a=e();return wp&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&Bp();let a=i;if(Up(a.wipDeps,t))return a.isDirty&&Wp(n,a),a.wip;let o=e();return wp&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,Ap(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),Wp(n,a),o};function Kp(e){return Gp(()=>({current:e}),[])}var qp=Symbol(`tap.Context.defaultValue`),Jp=e=>e,Yp=new Map,Xp=new Set,Zp=()=>new Map(Yp),Qp=(e,t)=>{let n=Yp;Yp=e;try{return t()}finally{Yp=n}},$p=(e,t)=>{e[qp]=t},em=e=>typeof e==`object`&&!!e&&qp in e,tm=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),nm=e=>em(e)||tm(e),rm=e=>{if(!em(e)){if(tm(e)){$p(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},im=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);rm(e);let r=e,i=Sp(),a=Kp(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Hp(()=>{a.current={value:t}},[t]);let s=Yp.get(r),c=s!==void 0||Yp.has(r);Yp.set(r,{value:t,source:i});try{return am(r,o,n)}finally{c?Yp.set(r,s):Yp.delete(r)}},am=(e,t,n)=>{let r=Xp.has(e);t?Xp.add(e):Xp.delete(e);try{return n()}finally{r?Xp.add(e):Xp.delete(e)}},om=e=>{rm(e);let t=e,n=sm(t,e),r=Sp();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},sm=(e,t)=>Yp.get(e)??{value:Jp(t)[qp],source:null},cm=(e,t,n,r)=>{if(!r)return n;let i=n;for(let[n,a]of r)a!==t&&a!==e&&(i??=new Map).set(n,a);return i},lm=(e,t=e.wipContextDeps)=>{let n=Cp();!n||!t||(n.wipContextDeps=cm(n,e,n.wipContextDeps,t))},um=()=>Xp.size>0,dm=e=>{if(!e.contextDeps||!um())return!1;for(let t of Xp.keys())if(e.contextDeps.has(t))return!0;return!1},fm=(e,t,n)=>{if(e.isNeverMounted)throw Error(`Resource updated before mount`);let r=!1,i=!0;e.root.unsettledCount++,e.root.dispatchUpdate(()=>r?i:(r=!0,n&&e.root.changelog.length===0&&!t.cell.isDirty&&!t.hasEagerState&&(t.prevState=t.cell.workInProgress,t.eagerState=n(t.cell.workInProgress,t.action),t.hasEagerState=!0,i=!Object.is(t.cell.current,t.eagerState),!i&&!t.settled&&(t.settled=!0,e.root.unsettledCount--)),i),()=>(r=!0,i=!0,Op(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},pm=(e,t,n,r,i)=>{let a=r?r(n):n;wp&&e.devStrictMode&&r&&r(n);let o={type:`reducer`,workInProgress:a,current:a,isDirty:!1,queue:null,renderQueue:null,reducer:t,dispatch:n=>{let r=Cp();if(r!==null){if(r!==e)throw Error(`Cannot update a resource while rendering a different resource.`);(e.renderPendingCells??=new Set).add(o),(o.renderQueue??=[]).push(n)}else fm(e,{fiber:e,cell:o,action:n,hasEagerState:!1,eagerState:void 0,prevState:o.current,settled:!1,queued:!1,logged:!1},i?t:void 0)}};return o};function mm(e,t,n,r){let i=Sp(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:Bp();i.isFirstRender||zp();let s=pm(i,e,t,n,r);return i.cells[a]=s,s})(),c=s.queue;if(c!==null){let t=e===s.reducer;for(let n=0;n<c.length;n++){let r=c[n];!r.hasEagerState||!t||!Object.is(r.prevState,s.workInProgress)?(r.prevState=s.workInProgress,r.eagerState=e(s.workInProgress,r.action),r.hasEagerState=!0,wp&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):wp&&i.devStrictMode&&e(s.workInProgress,r.action),r.queued=!1,s.workInProgress=r.eagerState}s.queue=null}if(s.reducer=e,s.renderQueue!==null){let t=s.workInProgress;for(let n of s.renderQueue)t=e(t,n);s.renderQueue=null,i.renderPendingCells?.delete(s),Object.is(t,s.workInProgress)||(jp(i,s),s.workInProgress=t)}return s.isDirty&&kp(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function hm(e,t,n){return mm(e,t,n,!1)}var gm=(e,t)=>typeof t==`function`?t(e):t,_m=e=>e===void 0?void 0:typeof e==`function`?e():e;function vm(e){return mm(gm,e,_m,!0)}var ym=(e,t)=>Gp(()=>e,t);function bm(e){let t=Sp(),n=Kp(e);return n.current!==e&&kp(t,()=>{n.current=e}),ym(((...e)=>{if(wp&&Cp())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var xm=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,Sm=()=>{},Cm=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(Sm,Sm):(t.status=`pending`,e.then(e=>{t.status===`pending`&&(t.status=`fulfilled`,t.value=e)},e=>{t.status===`pending`&&(t.status=`rejected`,t.reason=e)})),t.status){case`fulfilled`:return t.value;case`rejected`:throw t.reason;default:throw e}},wm=e=>xm(e)?Cm(e):om(e),Tm=!1,Em=(e,t,n=t)=>{let r=Sp().isNeverMounted,i=r?n():t();wp&&!Tm&&(!r||n===t)&&(Object.is(i,t())||(Tm=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=hm(e=>e+1,0),o=Kp(0),s=bm(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Hp(()=>e(()=>{s()&&a()}),[e]),Hp(()=>{if(s()){if(++o.current>50)throw o.current=0,Error(`Maximum update depth exceeded. The result of getSnapshot should be cached to avoid an infinite loop.`);a()}},[e,i,t]),i},Dm=(e,t)=>{},Om=0,km=()=>{let e=Kp(null);return e.current??=`:tap${Om++}:`,e.current},Am=(e,t,n)=>{let r=()=>{if(!e)return;let n=t();if(typeof e==`function`){let t=e(n);return typeof t==`function`?t:()=>e(null)}return e.current=n,()=>{e.current=null}};n==null?Hp(r):Hp(r,[...n,e])},jm=S.default;function Mm(e){let t=(0,S.useRef)(e);return(0,S.useInsertionEffect)(()=>{t.current=e}),(0,S.useCallback)(((...e)=>t.current(...e)),[])}var Nm=jm.useEffectEvent??Mm,Pm=()=>Cp()!==null,Fm=S.default,Im=e=>Pm()?vm(e):Fm.useState(e),Lm=(e,t,n)=>Pm()?hm(e,t,n):Fm.useReducer(e,t,n),Rm=e=>Pm()?Kp(e):Fm.useRef(e),zm=(e,t)=>Pm()?Gp(e,t):Fm.useMemo(e,t),Bm=(e,t)=>Pm()?ym(e,t):Fm.useCallback(e,t),Vm=(e,t)=>Pm()?Hp(e,t):Fm.useEffect(e,t),Hm=e=>Pm()?bm(e):Nm(e),Um=(e,t,n)=>Pm()?Em(e,t,n):Fm.useSyncExternalStore(e,t,n),Wm=(e,t)=>Pm()?void 0:Fm.useDebugValue(e,t),Gm=(e,t)=>Pm()?Hp(e,t):Fm.useInsertionEffect(e,t),Km=(e,t,n)=>Pm()?Am(e,t,n):Fm.useImperativeHandle(e,t,n),qm=e=>Fm.forwardRef(e),Jm=(e,t)=>Fm.memo(e,t);Fm.Fragment,Fm.Children,Fm.Suspense;var Ym=e=>{let t=Fm.createContext(e);return $p(t,e),t},Xm=e=>Pm()&&nm(e)?wm(e):Fm.use(e),Zm=e=>Pm()&&nm(e)?wm(e):Fm.useContext(e);function Qm(e){return(...t)=>({hook:e,args:t})}function $m(e,t,n){return typeof t==`function`?(...n)=>$m(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var eh=(e,t)=>{if(e.length!==0){if(e.length===1)throw e[0];for(let t of e)console.error(t);throw AggregateError(e,t)}},th=50,nh={schedulers:new Set,isScheduled:!1},rh=null,ih=[],ah=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(rh&&(rh.get(this)??0)>=th)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,nh.schedulers.add(this),ch()}runTask(){rh?.set(this,(rh.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},oh=[];new ah(()=>{let e=oh.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}eh(t,`Errors occurred while running scheduled tasks`)});var sh=e=>{if(rh!==null){ih.push(e);return}e()},ch=()=>{nh.isScheduled||(nh.isScheduled=!0,uh())},lh=()=>{let e=rh;rh=new Map;let t=[];try{for(let e of nh.schedulers)if(nh.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(rh=e,nh.schedulers.clear(),nh.isScheduled=!1,rh===null)for(;ih.length>0;)try{ih.shift()()}catch(e){t.push(e)}}eh(t,`Errors occurred during flushSync`)},uh=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),lh()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(lh,0)})(),dh=e=>{if(rh!==null)return wp&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=nh;nh={schedulers:new Set,isScheduled:!0};try{let t=e();return lh(),t}finally{let e=nh.schedulers;if(nh=t,e.size>0){for(let t of e)nh.schedulers.add(t);ch()}}};function fh(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}eh(t,`Errors during commit`)}function ph(e){let t=e.setup,n=e.setupDeps,r=e.generation,i;try{let e=t();if(e!==void 0&&typeof e!=`function`)throw Error(`An effect function must either return a cleanup function or nothing. Received: ${typeof e}`);i=e}finally{e.generation===r?(e.cleanup=i,e.deps=n):i?.()}}var mh=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Up(e.deps,e.setupDeps);function hh(e){let t=[],n=[];for(let t of e.effectCells)mh(t)&&n.push(t);for(let e of n)if(e.deps=null,e.cleanup!==void 0)try{e.cleanup()}catch(e){t.push(e)}finally{e.cleanup=void 0}for(let e of n)try{ph(e)}catch(e){t.push(e)}eh(t,`Errors during commit`)}function gh(e){let t=[];for(let n of e.effectCells)if(n.deps=null,n.cleanup)try{n.cleanup?.()}catch(e){t.push(e)}finally{n.cleanup=void 0}eh(t,`Errors during cleanup`)}var _h={useState:vm,useReducer:hm,useRef:Kp,useMemo:Gp,useCallback:ym,useEffect:Hp,useLayoutEffect:Hp,useInsertionEffect:Hp,useEffectEvent:bm,useContext:om,use:wm,useSyncExternalStore:Em,useDebugValue:Dm,useId:km,useImperativeHandle:Am,useMemoCache:Fp},vh=S.default,yh=vh.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??vh.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,bh=yh==null?null:`H`in yh?{get current(){return yh.H},set current(e){yh.H=e}}:`ReactCurrentDispatcher`in yh?{get current(){return yh.ReactCurrentDispatcher.current},set current(e){yh.ReactCurrentDispatcher.current=e}}:null;function xh(e){if(!bh)return e();let t=bh.current;bh.current=_h;try{return e()}finally{bh.current=t}}function Sh(e,t,n=void 0,r){return{hook:e,root:t,markDirty:n,devStrictMode:r,cells:[],effectCells:[],contextDeps:null,wipContextDeps:null,wipCommitCallbacks:null,memoCache:{current:null,workInProgress:null,index:0},renderPendingCells:null,currentIndex:0,isFirstRender:!0,isMounted:!1,isNeverMounted:!0}}function Ch(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function wh(e){e.isMounted&&(e.isMounted=!1,gh(e))}function Th(e,t){if(e.renderPendingCells!==null){for(let t of e.renderPendingCells)t.renderQueue=null;e.renderPendingCells.clear()}let n=0,r;try{do{if(++n>25)throw Error(`Too many re-renders. tap limits the number of renders to prevent an infinite loop.`);e.memoCache.index=0,xp(e,()=>{r=xh(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw Ch(e),t}return lm(e),r}function Eh(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=wp&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,Ep(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),fh(t)),n&&(hh(e),gh(e)),hh(e)}var Dh=()=>{let e=Sp();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},Oh=()=>`child`,kh=()=>null,Ah=()=>{if(!wp)return kh;let e=Rm(0);return Im(()=>e.current++),e.current===2?Oh:kh},jh=()=>Cp()?Dh:Ah(),Mh=e=>e(),Nh=(e,t,n)=>{let r=new ah(()=>s.handleUpdate()),i=[],a=Tp((e,t)=>{i.length===0&&!e()||(i.push(t),r.markDirty())}),o=Sh(Mh,a,void 0,t),s={scheduler:r,queue:i,fiber:o,subscribers:new Set,pendingHostRender:!1,isMounted:!1,hasRendered:!1,committedRender:e,context:new Map,value:void 0,applyQueue:()=>{Dp(a,a.committedVersion);for(let e of i)wp&&o.devStrictMode&&e(),e();return Dp(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,sh(()=>s.subscribers.forEach(e=>e())))},finishFlush:(e,t,n)=>{Ep(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&Eh(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{wp&&o.devStrictMode&&Qp(s.context,()=>Th(o,[s.committedRender])),t=Qp(s.context,()=>Th(o,[s.committedRender]))}catch(e){if(Dp(a,a.committedVersion),xm(e)){let t=()=>{s.isMounted&&r.markDirty()};e.then(t,t);return}if(s.isMounted){s.pendingHostRender=!0,n(e=>e+1);return}throw e}if(r.isDirty)throw Error(`Scheduler is dirty, this should never happen`);s.finishFlush(t,a.version,e)}};return s},Ph=e=>{let[,t]=Im(0),n=jh(),r=Rm(null),i=r.current??=Nh(e,n(),t),a=Zp(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=Qp(a,()=>Th(i.fiber,[e])),c={render:e,context:a,value:s,drained:o,wip:i.fiber.wipCommitCallbacks,version:i.fiber.root.version,processed:!1};return i.hasRendered||(i.hasRendered=!0,i.committedRender=e,i.context=a,i.value=s),Vm(()=>(i.isMounted=!0,()=>{i.isMounted=!1,wh(i.fiber)}),[i]),Vm(()=>{if(c.processed){i.fiber.isMounted||(Eh(i.fiber),i.queue.length&&!i.scheduler.isDirty&&i.scheduler.markDirty());return}if(c.processed=!0,i.committedRender=c.render,i.context=c.context,i.fiber.wipCommitCallbacks!==c.wip){i.scheduler.isDirty||i.handleUpdate();return}if(c.drained>0&&i.fiber.root.version===c.version){i.finishFlush(c.value,c.version,c.drained);return}Eh(i.fiber),i.publish(c.value,c.version)}),zm(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},Fh=()=>{let e=Rm(0),t=e.current,n=Sp();return{version:t,markDirty:zm(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},Ih=()=>{let[e]=Im(()=>Tp((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=Lm((t,n)=>(Dp(e,t),t+ +!!n()),0),[,r]=Im(0);return Dp(e,t),{root:e,version:t,markDirty:void 0}},Lh=()=>{let e=jh(),{root:t,version:n,markDirty:r}=Cp()?Fh():Ih();return{version:n,createFiber:Bm((n,i,a)=>Sh(n,t,a?()=>{a(),r?.()}:r,e()),[])}},Rh=(e,t,n)=>{let r=Rm(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,Vm(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Up(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function zh(e){let{version:t,createFiber:n}=Lh(),r=zm(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=Rh(()=>({value:Th(r,e.args)}),[r,t,e.args],dm(r));return Vm(()=>()=>wh(r),[r]),Vm(()=>{Eh(r)},[r,i]),i.value}var Bh=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Vh=(e,t)=>!e.isDirty&&!dm(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Up(e.committedDeps,t),Hh=e=>{if(!um())return!1;for(let{fiber:t}of e.values())if(dm(t))return!0;return!1};function Uh(e){let[t]=Im(()=>new Map),{version:n,createFiber:r}=Lh(),i=Hh(t),a=Rh(()=>{let n=new Set,i=[],a=0;for(let o=0;o<e.length;o++){let s=e[o],c=s.key;if(c===void 0)throw Error(`useResources did not provide a key for array at index ${o}`);if(n.has(c))throw Error(`Duplicate key ${c} in useResources`);n.add(c);let l=t.get(c);if(!l){let e=r(s.hook,s.key,()=>Bh(t,c));l={fiber:e,next:{value:Th(e,s.args),deps:s.deps},isDirty:!1,committedDeps:void 0,committedValue:void 0},a++,t.set(c,l)}else if(l.fiber.hook!==s.hook){let e=r(s.hook,s.key,()=>Bh(t,c)),n=Th(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(Vh(l,s.deps))typeof l.next==`object`&&Ch(l.fiber),l.fiber.contextDeps&&lm(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=Th(l.fiber,s.args);l.next={value:e,deps:s.deps}}i.push(typeof l.next==`object`?l.next.value:l.committedValue)}if(t.size>i.length-a)for(let e of t.keys())n.has(e)||(t.get(e).next=`delete`);return i},[e,t,r,n],i);return Vm(()=>()=>{for(let e of t.keys())wh(t.get(e).fiber)},[t]),Vm(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(wh(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&Eh(n.fiber):(r.remount&&(wh(n.fiber),n.fiber=r.remount),Eh(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var Wh=e=>e(),Gh=e=>{let{createFiber:t}=Lh(),n=zm(()=>t(Wh,void 0),[t]),r=Th(n,[e]);Vm(()=>()=>{wh(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,Eh(n))};return Vm(a),{value:r,effects:a}},Kh=Qm(()=>{let e=Rp(4),[t,n]=Im(qh),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(e,t)=>(n(n=>({...n,renderers:{...n.renderers,[e]:[...n.renderers[e]??[],t]}})),()=>{n(n=>({...n,renderers:{...n.renderers,[e]:n.renderers[e]?.filter(e=>e!==t)??[]}}))}),e[0]=r):r=e[0];let i=r,a;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n(t=>({...t,fallbacks:[...t.fallbacks,e]})),()=>{n(t=>({...t,fallbacks:t.fallbacks.filter(t=>t!==e)}))}),e[1]=a):a=e[1];let o=a,s;return e[2]===t?s=e[3]:(s={getState:()=>t,setDataUI:i,setFallbackDataUI:o},e[2]=t,e[3]=s),s});function qh(){return{renderers:{},fallbacks:[]}}var Jh=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},Yh=e=>{let t=Array.from(e).map(e=>e.getModelContext()).sort((e,t)=>(t.priority??0)-(e.priority??0)),n={};return t.reduce((e,t)=>{let r=t.priority??0;if(t.system&&(e.system?e.system+=`\n\n${t.system}`:e.system=t.system),t.tools)for(let[i,a]of Object.entries(t.tools)){let t=e.tools?.[i];if(t&&t!==a){let o=n[i];if(o===r){if(!a.overwrite)throw Error(`You tried to define a tool with the name ${i}, but it already exists.`);e.tools[i]=Jh(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=Jh({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||={},e.tools[i]=Jh(a),n[i]??=r}return t.config&&(e.config={...e.config,...t.config}),t.callSettings&&(e.callSettings={...e.callSettings,...t.callSettings}),t.unstable_composerMetadata&&(e.unstable_composerMetadata={...e.unstable_composerMetadata,...t.unstable_composerMetadata}),e},{})},Xh=(e,t,n)=>{let r=e=>{console.error(`[assistant-ui] ${n} listener threw an error`,e)};for(let n of e)try{let e=n(typeof t==`function`?t():t);e!==null&&(typeof e==`object`||typeof e==`function`)&&`then`in e&&typeof e.then==`function`&&Promise.resolve(e).catch(r)}catch(e){r(e)}},Zh=Symbol(`skip-update`),Qh=(e,...t)=>{let n=[];for(let r of e)try{r(...t)}catch(e){n.push(e)}if(n.length===1)throw n[0];if(n.length>1){for(let e of n)console.error(e);throw AggregateError(n)}};function $h(e,t){if(e===void 0&&t===void 0)return!0;if(e===void 0||t===void 0)return!1;let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n){let n=e[r],i=t[r];if(!Object.is(n,i))return!1}return!0}var eg=class{_subscribers=new Set;subscribe(e){return this._subscribers.add(e),()=>this._subscribers.delete(e)}waitForUpdate(){return new Promise(e=>{let t=this.subscribe(()=>{t(),e()})})}_notifySubscribers(){Qh(this._subscribers)}},tg=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){Xh(this._subscriptions,e,t);return}Qh(this._subscriptions,e)}_updateConnection(){if(this._subscriptions.size>0){if(this._connection)return;this._connection=this._connect()}else this._connection?.(),this._connection=void 0}subscribe(e){return this._subscriptions.add(e),this._updateConnection(),()=>{this._subscriptions.delete(e),this._updateConnection()}}},ng=class extends tg{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===Zh)throw Error(`Entry not available in the store`);this._previousState=t}_previousState;getState=()=>(this.isConnected||this._syncState(),this._previousState);_syncState(){let e=this.binding.getState();return e===Zh||$h(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},rg=class extends tg{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}_previousStateDirty=!0;_previousState;getState=()=>{if(!this.isConnected||this._previousStateDirty){let e=this.binding.getState();e!==Zh&&(this._previousState===void 0||!$h(e,this._previousState))&&(this._previousState=e),this._previousStateDirty=!1}if(this._previousState===void 0)throw Error(`Entry not available in the store`);return this._previousState};_connect(){let e=this.binding.subscribe(()=>{this._previousStateDirty=!0,this.notifySubscribers()});return this._previousStateDirty=!0,e}},ig=class extends tg{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e}getState(){return this.binding.getState()}outerSubscribe(e){return this.binding.subscribe(e)}_connect(){let e=()=>{this.notifySubscribers()},t=this.binding.getState(),n=t?.subscribe(e),r=this.outerSubscribe(()=>{let r=this.binding.getState();r!==t&&(t=r,n?.(),n=r?.subscribe(e),e())});return()=>{r?.(),n?.()}}},ag=class extends tg{config;constructor(e){super(),this.config=e}getState(){return this.config.binding.getState()}outerSubscribe(e){return this.config.binding.subscribe(e)}_connect(){let e=`Runtime event "${this.config.event}"`,t=t=>{this.notifySubscribers(t,e)},n=this.config.binding.getState(),r=n?.unstable_on(this.config.event,t),i=this.outerSubscribe(()=>{let e=this.config.binding.getState();e!==n&&(n=e,r?.(),r=e?.unstable_on(this.config.event,t))});return()=>{i?.(),r?.()}}},og=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return Yh(new Set(this._providers.values()))}registerModelContextProvider(e){let t=Symbol();this._providers.set(t,e);let n;try{n=e.subscribe?.(()=>{this.notifySubscribers()})}catch(e){this._providers.delete(t);try{this.notifySubscribers()}catch(e){console.error(e)}throw e}return this._providerUnsubscribes.set(t,n),this.notifySubscribers(),()=>{this._providers.delete(t),this._providerUnsubscribes.get(t)?.(),this._providerUnsubscribes.delete(t),this.notifySubscribers()}}_subscribers=new Set;notifySubscribers(){Qh(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},sg=[],cg={modelName:void 0,toolNames:sg},lg=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),ug=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():sg,a=i.length?i:sg;return r===t.modelName&&lg(a,t.toolNames)?t:{modelName:r,toolNames:a}},dg=Qm(()=>{let e=Rp(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new og,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>ug(n,cg),e[1]=r):r=e[1];let[i,a]=Im(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>ug(n,e)),n.subscribe(()=>{a(e=>ug(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),Vm(o,s);let c;e[4]===i?c=e[5]:(c=()=>ug(n,i),e[4]=i,e[5]=c);let l,u,d;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>n.getModelContext(),u=e=>n.subscribe(e),d=e=>n.registerModelContextProvider(e),e[6]=l,e[7]=u,e[8]=d):(l=e[6],u=e[7],d=e[8]);let f;return e[9]===c?f=e[10]:(f={getState:c,getModelContext:l,subscribe:u,register:d},e[9]=c,e[10]=f),f}),fg=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,pg=(e,t)=>{if(t.status?.type!==`running`&&t.status?.type!==`requires-action`){let n=e.complete;return typeof n==`function`?n({args:t.args,result:t.result}):n??null}let n=e.running;return typeof n==`function`?n({args:t.args}):n??null},mg=e=>function(t){return pg(e,t)},hg=e=>e,gg=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),_g=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!gg.has(e))return!1}},vg=class{getOwnPropertyDescriptor(e,t){let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!0,configurable:!0}}set(){return!1}setPrototypeOf(){return!1}defineProperty(){return!1}deleteProperty(){return!1}preventExtensions(){return!1}},yg=Symbol(`assistant-ui.store.clientId`),bg=Symbol(`assistant-ui.store.instanceTag`),xg=(e,t)=>{let n=new Proxy((()=>{}),{apply:()=>(t(),n),get:(n,r)=>r===`source`?e.source:r===`query`?e.query:r===`name`?e.name:r===yg?Tg(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===yg||n in t(),ownKeys:()=>Reflect.ownKeys(t()),getOwnPropertyDescriptor:(e,n)=>{if(!(typeof n==`symbol`||!(n in t())))return{value:t()[n],writable:!1,enumerable:!0,configurable:!0}}});return n},Sg=(e,t)=>{let n=()=>{throw Error(e)};return new Proxy((()=>{}),{apply:n,get:(e,r)=>{if(r===`source`||r===`query`)return null;if(r===`name`)return t;if(r===yg)return n();let i=_g(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},Cg=e=>e?.source!=null,wg=e=>e?.source===null,Tg=e=>e[yg]??e,Eg=e=>e[bg]??Tg(e),Dg=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,Og=e=>{let t=[];for(let n in e)Dg(n)||t.push(n);return t},kg=class extends vg{#e;constructor(e){super(),this.#e=e}get(e,t){let n=_g(t,`OptionalAssistantClient`);if(n!==!1)return n;if(Dg(t))return;let r=this.#e[t];return Cg(r)?r:void 0}ownKeys(){return Og(this.#e)}has(e,t){return!Dg(t)&&t in this.#e}},Ag=e=>new Proxy({},new kg(e)),jg=()=>()=>{},Mg=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,Ng=class extends vg{#e;#t;#n;#r;constructor(e,t,n){super(),this.#e=e,this.#t=t,this.#n=n}get(e,t){if(t===`subscribe`||t===`on`)return jg;if(t===`optional`)return this.#r??=Ag(this.#n());let n=_g(t,this.#e);return n===!1?Sg(this.#t(String(t)),String(t)):n}ownKeys(){return[`subscribe`,`on`,`optional`]}getOwnPropertyDescriptor(e,t){if(t!==`optional`)return super.getOwnPropertyDescriptor(e,t);let n=this.get(e,t);if(n!==void 0)return{value:n,writable:!1,enumerable:!1,configurable:!0}}has(e,t){return t===`subscribe`||t===`on`||t===`optional`}},Pg=((e,t)=>{let n=new Proxy({},new Ng(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>Mg),Fg=()=>new Proxy({},{get(e,t){let n=_g(t,`AssistantClient`);return n===!1?Sg(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),Ig=Ym(Pg),Lg=()=>{},Rg=new WeakMap,zg=e=>Rg.get(e)??Lg,Bg=(e,t)=>{Rg.set(e,t)},Vg=()=>Zm(Ig),Hg=(e,t)=>im(Ig,e,t),Ug=Symbol(`assistant-ui.transform-scopes`);function Wg(e,t){let n=e;if(n[Ug])throw Error(`transformScopes is already attached to this resource`);n[Ug]=t}function Gg(e){return e[Ug]}var Kg=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},qg=()=>{let e=new Map,t=new Set,n=new Set;return{on(n,r){let i=r;if(n===`*`)return t.add(i),()=>t.delete(i);let a=e.get(n);return a||(a=new Set,e.set(n,a)),a.add(i),()=>{a.delete(i),a.size===0&&e.delete(n)}},emit(n,r,i){!e.has(n)&&t.size===0||queueMicrotask(()=>{let a=[],o=e.get(n);if(o)for(let e of o)try{e(r,i)}catch(e){a.push(e)}if(t.size>0){let e={event:n,payload:r};for(let n of t)try{n(e,i)}catch(e){a.push(e)}}if(a.length>0){if(a.length===1)throw a[0];for(let e of a)console.error(e);throw AggregateError(a,`Errors occurred during event emission`)}})},subscribe(e){return n.add(e),()=>n.delete(e)},notifySubscribers(){for(let e of n)try{e()}catch(e){console.error(`NotificationManager: subscriber callback error`,e)}}}},Jg=()=>Im(qg)[0],Yg=Symbol(`assistant-ui.store.clientIndex`),Xg=e=>e[Yg],Zg=Ym([]),Qg=()=>Xm(Zg),$g=(e,t)=>{let n=Rp(3),r=Qg(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],im(Zg,i,t)},e_=Ym(null),t_=Symbol(`aui.scope-effect-unapplied`),n_=(e,t)=>im(e_,e,t),r_=()=>{let e=Xm(e_);if(!e)throw Error(`AssistantTapContext is not available`);return e},i_=()=>r_().clientRef,a_=(e,t,n)=>{let r=Rp(8),{clientRef:i}=r_(),a;r[0]!==i||r[1]!==t||r[2]!==e?(a=()=>{let n=i.current;if(n===null)throw Error(`useAssistantScopeEffect ran before the client was committed. This is likely an internal bug in assistant-ui.`);let r=()=>{let t=i.current?.[e];return t!==void 0&&Cg(t)?Eg(t):void 0},a=t_,o,s=e=>{if(o?.(),o=void 0,a=t_,e!==void 0){let e=t();o=typeof e==`function`?e:void 0}a=e};s(r());let c=n.subscribe(()=>{let e=r();e!==a&&s(e)});return()=>{c(),o?.()}},r[0]=i,r[1]=t,r[2]=e,r[3]=a):a=r[3];let o;r[4]!==i||r[5]!==n||r[6]!==e?(o=[i,e,...n],r[4]=i,r[5]=n,r[6]=e,r[7]=o):o=r[7],Vm(a,o)},o_=()=>{let e=Rp(3),{emit:t}=r_(),n=Qg(),r;return e[0]!==n||e[1]!==t?(r=(e,r)=>{t(e,r,n)},e[0]=n,e[1]=t,e[2]=r):r=e[2],Hm(r)},s_=Symbol(`assistant-ui.store.getValue`),c_=e=>{let t=e[s_];if(!t)throw Error(`Client scope contains a non-client resource. Ensure your Derived get() returns a client created with useClientResource(), not a plain resource.`);return t.getState?.()},l_=new Map;function u_(e){let t=l_.get(e);return t||(t=function(...t){if(!this||typeof this!=`object`)throw Error(`Method "${String(e)}" called without proper context. This may indicate the function was called incorrectly.`);let n=this[s_];if(!n)throw Error(`Method "${String(e)}" called on invalid client proxy. Ensure you are calling this method on a valid client instance.`);let r=n[e];if(!r)throw Error(`Method "${String(e)}" is not implemented.`);if(typeof r!=`function`)throw Error(`"${String(e)}" is not a function.`);return r(...t)},l_.set(e,t)),t}var d_=class extends vg{boundFns;cachedReceiver;outputRef;tagRef;index;constructor(e,t,n){super(),this.outputRef=e,this.tagRef=t,this.index=n}get(e,t,n){if(t===s_)return this.outputRef.current;if(t===Yg)return this.index;if(t===bg)return this.tagRef.current;let r=_g(t,`ClientProxy`);if(r!==!1)return r;let i=this.outputRef.current[t];if(typeof i==`function`){if(n===void 0)return i;(!this.boundFns||this.cachedReceiver!==n)&&(this.boundFns=new Map,this.cachedReceiver=n);let e=this.boundFns.get(t);return e||(e=u_(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===s_||t===Yg||t===bg||t in this.outputRef.current}},f_=e=>{let t=Rm(null),n=Rm(null),r=zm(()=>({}),[e.hook,e.key]),i=Qg().length,a=zm(()=>new Proxy({},new d_(t,n,i)),[i]),o=$g(a,function(){return zh(e)});return t.current||(t.current=o,n.current=r),Vm(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},p_=Qm(f_),m_=(e,t)=>{if(Array.isArray(e)!==Array.isArray(t))return!1;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((e,n)=>Object.is(e,t[n]));let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.hasOwn(t,n)&&Object.is(e[n],t[n]))},h_=e=>{let t=zm(()=>({}),[]);return t.v!==void 0&&m_(t.v,e)?t.v:(t.v=e,e)},g_=typeof process<`u`&&!1,__=(e,t)=>{let n={...e},r=new Set,i=!0;for(;i;){i=!1;for(let e of Object.values(n)){if(r.has(e.hook))continue;r.add(e.hook);let a=Gg(e.hook);if(a){a(n,t),i=!0;break}}}return n},v_=e=>e.hook===U_,y_=e=>{if(!v_(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},b_=Symbol.for(`aui.event-receiver-ref`),x_=(e,t)=>{let n=e===Pg?Fg():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=Ag(r),enumerable:!1}),r},S_=({notifications:e,clientRef:t})=>zm(()=>({subscribe:e.subscribe,on:function(n,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=Kg(n),o=n[b_];if(i!==`*`&&!o&&wg(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);let s=e.on(a,(e,n)=>{if(i===`*`){r(e);return}let a=((o??t).current??this)[i];if(!Cg(a))return;let s=Tg(a);s===n[Xg(s)]&&r(e)});if(i!==`*`){if(o){if(t.parent===Pg)return s}else if(wg(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),C_=e=>{let t=Rp(5),n;t[0]===e?n=t[1]:(n=y_(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=h_(i),o;return t[2]!==r||t[3]!==a?(o={source:r,query:a},t[2]=r,t[3]=a,t[4]=o):o=t[4],h_(o)},w_=(e,t)=>{let n=Rp(3),r;return n[0]!==t||n[1]!==e?(r=t?e:p_(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],zh(r)},T_=Qm((e,t)=>{let n=Vg(),r=v_(t),i=w_(t,r),a=r?i:i.methods,o=C_(t),s=zm(()=>xg({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),E_=e=>{let t=Rp(2),n;return t[0]===e?n=t[1]:(n=e.map(L_),t[0]=e,t[1]=n),Uh(n)},D_=(e,t)=>{let n=h_(t),r=zm(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},O_=({parent:e,entries:t,clientRef:n,notifications:r,destroySignal:i})=>{let a=x_(e,S_({notifications:r,clientRef:n}));return{client:D_(a,[e,...n_({clientRef:n,emit:r.emit,destroySignal:i},function(){return Hg(a,function(){return E_(t)})})])}},k_=({parent:e,entries:t})=>{let n=Rm({parent:e,current:null}).current,{value:r,effects:i}=Gh(function(){let r=Jg(),{client:i}=O_({parent:e,entries:t,clientRef:n,notifications:r});return Vm(()=>e.subscribe(r.notifySubscribers),[e,r]),Vm(()=>r.notifySubscribers()),i});return Gm(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},A_=({parent:e,entries:t})=>{let n=Rm({parent:e,current:null}).current,{value:r,effects:i}=Gh(function(){let r=Jg(),i=Ph(function(){return O_({parent:e,entries:t,clientRef:n,notifications:r})}),a=Um(i.subscribe,()=>i.getValue().client,()=>i.getValue().client);return Vm(()=>{let t=()=>dh(()=>{n.current=i.getValue().client,r.notifySubscribers()}),a=i.subscribe(t),o=e.subscribe(t);return()=>{a(),o()}},[i,e,r]),a});return Gm(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},j_=(e,t,n,r)=>{let{get:i}=r.args[0],a=Um(e.subscribe,()=>i(e),()=>i(e)),o=C_(r),s=zm(()=>xg({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},M_=(e,t)=>{if(g_){let[e]=Im(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!v_(e));if(n)throw Error(`Scope "${n[0]}" is a root scope but this useAui mounted derived-only; remount with a new key to change scope kinds.`);let r=t.map(([e])=>e).join(`,`);if(r!==e)throw Error(`A derived-only config mounted scopes [${e}] but now has [${r}]; remount with a new key to change the scope set.`)}let n=Rm({parent:e,current:null}).current,r=x_(e,{subscribe:e.subscribe,on:function(t,r){if(!this)throw Error(`const { on } = useAui() is not supported. Use aui.on() instead.`);let{scope:i,event:a}=Kg(t);if(i===`*`)return e.on(t,r);let o=t[b_];if(!o&&wg(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[b_]:o??n},r)}}),i=D_(r,[e,...t.map(([t,n])=>j_(e,r,t,n))]);return Gm(()=>{n.parent=e,n.current=i},[i,e,n]),i},N_=(e,t)=>{let n=Rp(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(__(t,e)),n[0]=t,n[1]=e,n[2]=r):r=n[2];let i=r,a;n[3]===i?a=n[4]:(a=()=>i.length===0||i.some(R_),n[3]=i,n[4]=a);let[o]=Im(a),s;return n[5]!==i||n[6]!==o?(s={entries:i,rooted:o},n[5]=i,n[6]=o,n[7]=s):s=n[7],s},P_=(e,t,n)=>{let{entries:r,rooted:i}=N_(e,t);return i?n({parent:e,entries:r}):{client:M_(e,r)}},F_=(e,t)=>P_(e,t,k_);function I_(e){let t=Vg();if(e){let{client:n,effects:r}=P_(t,e,A_);return r&&Bg(n,r),n}return t}function L_(e){let[t,n]=e;return $m(t,T_(t,n))}function R_(e){let[,t]=e;return!v_(t)}var z_=e=>{let t;class n extends vg{get(t,n){let r=_g(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!Dg(i)&&Cg(e[i]))return c_(e[i]())}ownKeys(){return Og(e)}has(t,n){return!Dg(n)&&n in e}}class r extends vg{get(r,i){let a=_g(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!Dg(o))return c_(e[o]())}ownKeys(){return[...Og(e),`optional`]}has(t,n){return n===`optional`||!Dg(n)&&n in e}}return new Proxy({},new r)},B_=new WeakMap,V_=e=>{let t=B_.get(e);return t||(t=z_(e),B_.set(e,t)),t},H_=e=>{let t=Rp(6),n=I_(),r;t[0]===n?r=t[1]:(r=V_(n),t[0]=n,t[1]=r);let i=r,a,o;t[2]!==i||t[3]!==e?(a=()=>e(i),o=()=>e(i),t[2]=i,t[3]=e,t[4]=a,t[5]=o):(a=t[4],o=t[5]);let s=Um(n.subscribe,a,o);if(typeof s==`object`&&s&&(s===i||s===i.optional))throw Error(`You tried to return the entire AssistantState. This is not supported due to technical limitations.`);return Wm(s),s},U_=e=>{let t=Rp(3),{get:n}=e,r=I_(),i;return t[0]!==r||t[1]!==n?(i=()=>n(r),t[0]=r,t[1]=n,t[2]=i):i=t[2],H_(i)},W_=Qm(U_),G_=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function K_(e){let t=Rp(12),n;t[0]===e?n=t[1]:(n=e.map(Y_),t[0]=e,t[1]=n);let r=Uh(n),i;t[2]===e?i=t[3]:(i=e.reduce(J_,{}),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(q_),t[4]=r,t[5]=o);let s=o,c;t[6]!==a||t[7]!==r?(c=e=>{if(`index`in e){if(e.index<0||e.index>=r.length)throw Error(`useClientLookup: index ${e.index} out of bounds (length: ${r.length}) (ignore if recovered)`);return r[e.index].methods}let t=a[e.key];if(t===void 0)throw Error(`useClientLookup: key "${e.key}" not found (ignore if recovered)`);return r[t].methods},t[6]=a,t[7]=r,t[8]=c):c=t[8];let l;return t[9]!==s||t[10]!==c?(l={state:s,get:c},t[9]=s,t[10]=c,t[11]=l):l=t[11],l}function q_(e){return e.state}function J_(e,t,n){return e[G_(t)]=n,e}function Y_(e){return $m(G_(e),p_(e),e.deps)}var X_=e=>{let t=Rp(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[$m(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=Uh(i)[0],[o,s]=Im(Q_),c;t[2]!==a||t[3]!==o?(c={toolUIs:o,mcpApp:a},t[2]=a,t[3]=o,t[4]=c):c=t[4];let l=c,u=i_(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,standalone:n?.standalone??!1};return s(t=>({...t,[e]:[...t[e]??[],r]})),()=>{s(t=>{let n=t[e]?.filter(e=>e!==r)??[];if(n.length>0)return{...t,[e]:n};let i={...t};return delete i[e],i})}},t[5]=d):d=t[5];let f=d,p,m;t[6]===n?(p=t[7],m=t[8]):(p=()=>{if(!n)return;let e=[];for(let[t,r]of Object.entries(n)){let n=`render`in r?r.render:void 0,i=`renderText`in r?r.renderText:void 0,a=n??(i?mg(i):void 0);a&&e.push(f(t,a,{standalone:fg(r)}))}return()=>{e.forEach($_)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),Vm(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(ev,{});return u.current.modelContext().register({getModelContext:()=>({tools:e})})},t[9]=u,t[10]=n,t[11]=h):h=t[11];let g;t[12]===n?g=t[13]:(g=[n],t[12]=n,t[13]=g),a_(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},Z_=Qm(X_);Wg(X_,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=dg())});function Q_(){return{}}function $_(e){return e()}function ev(e,t){let[n,r]=t;if(r.type===`mcp`)return e;let{display:i,render:a,renderText:o,...s}=r;return e[n]=s,e}var tv=e=>Um(e.subscribe,e.getState),nv=Symbol.for(`assistant-ui.silent-runtime-action`),rv=e=>typeof e==`object`&&!!e&&nv in e,iv=(e,t)=>{let n=t();return n.catch(t=>{rv(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},av=Qm(e=>{let t=Rp(9),{runtime:n}=e,r=tv(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o;t[2]===n?(a=t[3],o=t[4]):(a=()=>iv(`attachment remove`,n.remove),o=()=>n,t[2]=n,t[3]=a,t[4]=o);let s;return t[5]!==i||t[6]!==a||t[7]!==o?(s={getState:i,remove:a,__internal_getRuntime:o},t[5]=i,t[6]=a,t[7]=o,t[8]=s):s=t[8],s}),ov=Qm(e=>{let t=Rp(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=av({runtime:a}),t[3]=a,t[4]=o),zh(o)}),sv=Qm(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),cv=Qm(e=>{let t=Rp(55),{threadIdRef:n,messageIdRef:r,runtime:i}=e,a=tv(i),o=o_(),s,c;t[0]!==o||t[1]!==r||t[2]!==i||t[3]!==n?(s=()=>{let e=[];for(let t of[`send`,`attachmentAdd`]){let a=i.unstable_on(t,()=>{o(`composer.${t}`,{threadId:n.current,...r&&{messageId:r.current}})});e.push(a)}return e.push(i.unstable_on(`attachmentAddError`,e=>{o(`composer.attachmentAddError`,{threadId:n.current,...r&&{messageId:r.current},...e.attachmentId&&{attachmentId:e.attachmentId},reason:e.reason,message:e.message})})),()=>{for(let t of e)t()}},c=[i,o,n,r],t[0]=o,t[1]=r,t[2]=i,t[3]=n,t[4]=s,t[5]=c):(s=t[4],c=t[5]),Vm(s,c);let l;if(t[6]!==i||t[7]!==a.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>$m(e.id,ov({runtime:i,index:t}),[i,t]),t[9]=i,t[10]=e),l=a.attachments.map(e),t[6]=i,t[7]=a.attachments,t[8]=l}else l=t[8];let u=K_(l),d=a.queue,f;if(t[11]!==d||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>$m(e.id,sv({item:e,onMove:t=>i.moveQueueItem(e.id,t),onRemove:()=>i.removeQueueItem(e.id)})),t[14]=i,t[15]=e),f=d.map(e),t[11]=d,t[12]=i,t[13]=f}else f=t[13];let p=K_(f),m=a.type??`thread`,h;t[16]!==u.state||t[17]!==d||t[18]!==a.attachmentAccept||t[19]!==a.canCancel||t[20]!==a.canSend||t[21]!==a.dictation||t[22]!==a.isEditing||t[23]!==a.isEmpty||t[24]!==a.quote||t[25]!==a.role||t[26]!==a.runConfig||t[27]!==a.text||t[28]!==m?(h={text:a.text,role:a.role,attachments:u.state,runConfig:a.runConfig,isEditing:a.isEditing,canCancel:a.canCancel,canSend:a.canSend,attachmentAccept:a.attachmentAccept,isEmpty:a.isEmpty,type:m,dictation:a.dictation,quote:a.quote,queue:d},t[16]=u.state,t[17]=d,t[18]=a.attachmentAccept,t[19]=a.canCancel,t[20]=a.canSend,t[21]=a.dictation,t[22]=a.isEditing,t[23]=a.isEmpty,t[24]=a.quote,t[25]=a.role,t[26]=a.runConfig,t[27]=a.text,t[28]=m,t[29]=h):h=t[29];let g=h,_;t[30]===g?_=t[31]:(_=()=>g,t[30]=g,t[31]=_);let v=i.beginEdit??lv,y;t[32]===u?y=t[33]:(y=e=>`id`in e?u.get({key:e.id}):u.get(e),t[32]=u,t[33]=y);let b;t[34]===p?b=t[35]:(b=e=>`id`in e?p.get({key:e.id}):p.get(e),t[34]=p,t[35]=b);let x;t[36]===i?x=t[37]:(x=()=>i,t[36]=i,t[37]=x);let S;return t[38]!==i.addAttachment||t[39]!==i.cancel||t[40]!==i.clearAttachments||t[41]!==i.reset||t[42]!==i.send||t[43]!==i.setQuote||t[44]!==i.setRole||t[45]!==i.setRunConfig||t[46]!==i.setText||t[47]!==i.startDictation||t[48]!==i.stopDictation||t[49]!==b||t[50]!==x||t[51]!==_||t[52]!==v||t[53]!==y?(S={getState:_,setText:i.setText,setRole:i.setRole,setRunConfig:i.setRunConfig,addAttachment:i.addAttachment,reset:i.reset,clearAttachments:i.clearAttachments,send:i.send,cancel:i.cancel,beginEdit:v,startDictation:i.startDictation,stopDictation:i.stopDictation,setQuote:i.setQuote,attachment:y,queueItem:b,__internal_getRuntime:x},t[38]=i.addAttachment,t[39]=i.cancel,t[40]=i.clearAttachments,t[41]=i.reset,t[42]=i.send,t[43]=i.setQuote,t[44]=i.setRole,t[45]=i.setRunConfig,t[46]=i.setText,t[47]=i.startDictation,t[48]=i.stopDictation,t[49]=b,t[50]=x,t[51]=_,t[52]=v,t[53]=y,t[54]=S):S=t[54],S});function lv(){throw Error(`beginEdit is not supported in this runtime`)}var uv=e=>({get current(){return e()}}),dv=Qm(e=>{let t=Rp(13),{runtime:n}=e,r=tv(n),i;t[0]===r?i=t[1]:(i=()=>r,t[0]=r,t[1]=i);let a,o,s,c;t[2]===n?(a=t[3],o=t[4],s=t[5],c=t[6]):(a=e=>n.addToolResult(e),o=e=>n.resumeToolCall(e),s=e=>n.respondToToolApproval(e),c=()=>n,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c);let l;return t[7]!==i||t[8]!==a||t[9]!==o||t[10]!==s||t[11]!==c?(l={getState:i,addToolResult:a,resumeToolCall:o,respondToToolApproval:s,__internal_getRuntime:c},t[7]=i,t[8]=a,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}),fv=Qm(e=>{let t=Rp(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getAttachmentByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=av({runtime:a}),t[3]=a,t[4]=o),zh(o)}),pv=Qm(e=>{let t=Rp(5),{runtime:n,index:r}=e,i;t[0]!==r||t[1]!==n?(i=n.getMessagePartByIndex(r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o;return t[3]===a?o=t[4]:(o=dv({runtime:a}),t[3]=a,t[4]=o),zh(o)}),mv=Qm(e=>{let t=Rp(55),{runtime:n,threadIdRef:r}=e,i=tv(n),[a,o]=Im(!1),[s,c]=Im(!1),l;t[0]===n?l=t[1]:(l=uv(()=>n.getState().id),t[0]=n,t[1]=l);let u=l,d;t[2]!==u||t[3]!==n.composer||t[4]!==r?(d=cv({runtime:n.composer,threadIdRef:r,messageIdRef:u}),t[2]=u,t[3]=n.composer,t[4]=r,t[5]=d):d=t[5];let f=f_(d),p;if(t[6]!==n||t[7]!==i.content){let e;t[9]===n?e=t[10]:(e=(e,t)=>$m(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,pv({runtime:n,index:t}),[n,t]),t[9]=n,t[10]=e),p=i.content.map(e),t[6]=n,t[7]=i.content,t[8]=p}else p=t[8];let m=K_(p),h;t[11]===i.attachments?h=t[12]:(h=i.attachments??[],t[11]=i.attachments,t[12]=h);let g;if(t[13]!==n||t[14]!==h){let e;t[16]===n?e=t[17]:(e=(e,t)=>$m(e.id,fv({runtime:n,index:t}),[n,t]),t[16]=n,t[17]=e),g=h.map(e),t[13]=n,t[14]=h,t[15]=g}else g=t[15];let _=K_(g),v=i,y;t[18]!==f.state||t[19]!==a||t[20]!==s||t[21]!==m.state||t[22]!==v?(y={...v,parts:m.state,composer:f.state,isCopied:a,isHovering:s},t[18]=f.state,t[19]=a,t[20]=s,t[21]=m.state,t[22]=v,t[23]=y):y=t[23];let b=y,x;t[24]===b?x=t[25]:(x=()=>b,t[24]=b,t[25]=x);let S;t[26]===f.methods?S=t[27]:(S=()=>f.methods,t[26]=f.methods,t[27]=S);let C,w,ee,te,ne,re,ie;t[28]===n?(C=t[29],w=t[30],ee=t[31],te=t[32],ne=t[33],re=t[34],ie=t[35]):(C=()=>n.delete(),w=e=>n.reload(e),ee=()=>n.speak(),te=()=>n.stopSpeaking(),ne=e=>n.submitFeedback(e),re=e=>n.switchToBranch(e),ie=()=>n.unstable_getCopyText(),t[28]=n,t[29]=C,t[30]=w,t[31]=ee,t[32]=te,t[33]=ne,t[34]=re,t[35]=ie);let ae;t[36]===m?ae=t[37]:(ae=e=>`index`in e?m.get({index:e.index}):m.get({key:`toolCallId-${e.toolCallId}`}),t[36]=m,t[37]=ae);let oe;t[38]===_?oe=t[39]:(oe=e=>`id`in e?_.get({key:e.id}):_.get(e),t[38]=_,t[39]=oe);let se;t[40]===n?se=t[41]:(se=()=>n,t[40]=n,t[41]=se);let ce;return t[42]!==C||t[43]!==w||t[44]!==ee||t[45]!==te||t[46]!==ne||t[47]!==re||t[48]!==ie||t[49]!==ae||t[50]!==oe||t[51]!==se||t[52]!==x||t[53]!==S?(ce={getState:x,composer:S,delete:C,reload:w,speak:ee,stopSpeaking:te,submitFeedback:ne,switchToBranch:re,getCopyText:ie,part:ae,attachment:oe,setIsCopied:o,setIsHovering:c,__internal_getRuntime:se},t[42]=C,t[43]=w,t[44]=ee,t[45]=te,t[46]=ne,t[47]=re,t[48]=ie,t[49]=ae,t[50]=oe,t[51]=se,t[52]=x,t[53]=S,t[54]=ce):ce=t[54],ce}),hv=Qm(e=>({getState:()=>e})),gv=e=>{let t=Rp(9),n;t[0]===e.suggestions?n=t[1]:(n=e.suggestions.map(vv),t[0]=e.suggestions,t[1]=n);let r=K_(n),i;t[2]===e?i=t[3]:(i=()=>e,t[2]=e,t[3]=i);let a;t[4]===r?a=t[5]:(a=e=>{let{index:t}=e;return r.get({index:t})},t[4]=r,t[5]=a);let o;return t[6]!==i||t[7]!==a?(o={getState:i,suggestion:a},t[6]=i,t[7]=a,t[8]=o):o=t[8],o},_v=Qm(e=>{let t=Rp(4),n;t[0]===e?n=t[1]:(n=e.map(yv),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),gv(r)});function vv(e,t){return $m(t,hv(e),[e])}function yv(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var bv=Qm(e=>{let t=Rp(6),{runtime:n,id:r,threadIdRef:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getMessageById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==o||t[4]!==i?(s=mv({runtime:o,threadIdRef:i}),t[3]=o,t[4]=i,t[5]=s):s=t[5],zh(s)}),xv=Qm(e=>{let t=Rp(64),{runtime:n}=e,r=tv(n),i=o_(),a,o;t[0]!==i||t[1]!==n?(a=()=>{let e=[];for(let t of[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`]){let r=n.unstable_on(t,()=>{let e=n.getState()?.threadId||`unknown`;i(`thread.${t}`,{threadId:e})});e.push(r)}return()=>{for(let t of e)t()}},o=[n,i],t[0]=i,t[1]=n,t[2]=a,t[3]=o):(a=t[2],o=t[3]),Vm(a,o);let s;t[4]===n?s=t[5]:(s=uv(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==n.composer||t[7]!==c?(l=cv({runtime:n.composer,threadIdRef:c}),t[6]=n.composer,t[7]=c,t[8]=l):l=t[8];let u=f_(l),d;t[9]===r.suggestions?d=t[10]:(d=_v(r.suggestions),t[9]=r.suggestions,t[10]=d);let f=f_(d),p;if(t[11]!==n||t[12]!==r.messages||t[13]!==c){let e;t[15]!==n||t[16]!==c?(e=e=>$m(e.id,bv({runtime:n,id:e.id,threadIdRef:c}),[n,e.id,c]),t[15]=n,t[16]=c,t[17]=e):e=t[17],p=r.messages.map(e),t[11]=n,t[12]=r.messages,t[13]=c,t[14]=p}else p=t[14];let m=K_(p),h=m.state.length===0&&!r.isLoading,g;t[18]!==u.state||t[19]!==m.state||t[20]!==r.capabilities||t[21]!==r.extras||t[22]!==r.isDisabled||t[23]!==r.isLoading||t[24]!==r.isRunning||t[25]!==r.speech||t[26]!==r.state||t[27]!==r.suggestions||t[28]!==r.voice||t[29]!==h?(g={isEmpty:h,isDisabled:r.isDisabled,isLoading:r.isLoading,isRunning:r.isRunning,capabilities:r.capabilities,state:r.state,suggestions:r.suggestions,extras:r.extras,speech:r.speech,voice:r.voice,composer:u.state,messages:m.state},t[18]=u.state,t[19]=m.state,t[20]=r.capabilities,t[21]=r.extras,t[22]=r.isDisabled,t[23]=r.isLoading,t[24]=r.isRunning,t[25]=r.speech,t[26]=r.state,t[27]=r.suggestions,t[28]=r.voice,t[29]=h,t[30]=g):g=t[30];let _=g,v;t[31]===_?v=t[32]:(v=()=>_,t[31]=_,t[32]=v);let y;t[33]===u.methods?y=t[34]:(y=()=>u.methods,t[33]=u.methods,t[34]=y);let b;t[35]===f?b=t[36]:(b=()=>f.methods,t[35]=f,t[36]=b);let x;t[37]===m?x=t[38]:(x=e=>`id`in e?m.get({key:e.id}):m.get(e),t[37]=m,t[38]=x);let S;t[39]===n?S=t[40]:(S=()=>n,t[39]=n,t[40]=S);let C;return t[41]!==n.append||t[42]!==n.cancelRun||t[43]!==n.connectVoice||t[44]!==n.deleteMessage||t[45]!==n.disconnectVoice||t[46]!==n.export||t[47]!==n.getModelContext||t[48]!==n.getVoiceVolume||t[49]!==n.import||t[50]!==n.importExternalState||t[51]!==n.muteVoice||t[52]!==n.reset||t[53]!==n.resumeRun||t[54]!==n.startRun||t[55]!==n.stopSpeaking||t[56]!==n.subscribeVoiceVolume||t[57]!==n.unmuteVoice||t[58]!==y||t[59]!==b||t[60]!==x||t[61]!==S||t[62]!==v?(C={getState:v,composer:y,suggestions:b,append:n.append,deleteMessage:n.deleteMessage,startRun:n.startRun,resumeRun:n.resumeRun,importExternalState:n.importExternalState,cancelRun:n.cancelRun,getModelContext:n.getModelContext,export:n.export,import:n.import,reset:n.reset,stopSpeaking:n.stopSpeaking,connectVoice:n.connectVoice,disconnectVoice:n.disconnectVoice,getVoiceVolume:n.getVoiceVolume,subscribeVoiceVolume:n.subscribeVoiceVolume,muteVoice:n.muteVoice,unmuteVoice:n.unmuteVoice,message:x,__internal_getRuntime:S},t[41]=n.append,t[42]=n.cancelRun,t[43]=n.connectVoice,t[44]=n.deleteMessage,t[45]=n.disconnectVoice,t[46]=n.export,t[47]=n.getModelContext,t[48]=n.getVoiceVolume,t[49]=n.import,t[50]=n.importExternalState,t[51]=n.muteVoice,t[52]=n.reset,t[53]=n.resumeRun,t[54]=n.startRun,t[55]=n.stopSpeaking,t[56]=n.subscribeVoiceVolume,t[57]=n.unmuteVoice,t[58]=y,t[59]=b,t[60]=x,t[61]=S,t[62]=v,t[63]=C):C=t[63],C}),Sv=(e,t)=>iv(`thread list ${e}`,t),Cv=Qm(e=>{let t=Rp(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=tv(n),o;bb0:{let e=a.isRunning||a.isMain&&i;if(e===a.isRunning){o=a;break bb0}let n;t[0]!==e||t[1]!==a?(n={...a,isRunning:e},t[0]=e,t[1]=a,t[2]=n):n=t[2],o=n}let s=o,c=o_(),{isMain:l,id:u}=a,d;t[3]!==l||t[4]!==u?(d={isMain:l,threadId:u},t[3]=l,t[4]=u,t[5]=d):d=t[5];let f=Rm(d),p,m;t[6]!==c||t[7]!==l||t[8]!==u?(p=()=>{let e=f.current;(e.isMain!==l||e.threadId!==u)&&(f.current={isMain:l,threadId:u},c(l?`threadListItem.switchedTo`:`threadListItem.switchedAway`,{threadId:u}))},m=[l,u,c],t[6]=c,t[7]=l,t[8]=u,t[9]=p,t[10]=m):(p=t[9],m=t[10]),Vm(p,m);let h;t[11]===s?h=t[12]:(h=()=>s,t[11]=s,t[12]=h);let g,_,v,y,b,x,S;t[13]===n?(g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],x=t[19],S=t[20]):(b=e=>Sv(`switch`,()=>n.switchTo(e)),x=e=>Sv(`rename`,()=>n.rename(e)),S=e=>Sv(`update custom metadata`,()=>n.updateCustom(e)),g=()=>Sv(`archive`,()=>n.archive()),_=()=>Sv(`unarchive`,()=>n.unarchive()),v=()=>Sv(`delete`,()=>n.delete()),y=()=>Sv(`generate title`,()=>n.generateTitle()),t[13]=n,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=x,t[20]=S);let C;t[21]===n?C=t[22]:(C=()=>n,t[21]=n,t[22]=C);let w;return t[23]!==n.detach||t[24]!==n.initialize||t[25]!==g||t[26]!==_||t[27]!==v||t[28]!==y||t[29]!==C||t[30]!==h||t[31]!==b||t[32]!==x||t[33]!==S?(w={getState:h,switchTo:b,rename:x,updateCustom:S,archive:g,unarchive:_,delete:v,generateTitle:y,initialize:n.initialize,detach:n.detach,__internal_getRuntime:C},t[23]=n.detach,t[24]=n.initialize,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=C,t[30]=h,t[31]=b,t[32]=x,t[33]=S,t[34]=w):w=t[34],w}),wv=e=>{let t=Rp(4),n=o_(),r=Rm(e),i,a;t[0]!==n||t[1]!==e?(i=()=>{let t=r.current;t!==e&&(r.current=e,n(`threads.selectionChanged`,{threadId:e,previousThreadId:t}))},a=[e,n],t[0]=n,t[1]=e,t[2]=i,t[3]=a):(i=t[2],a=t[3]),Vm(i,a)},Tv=Qm(e=>{let t=Rp(6),{runtime:n,id:r,mainThreadIsRunning:i}=e,a;t[0]!==r||t[1]!==n?(a=n.getItemById(r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s;return t[3]!==i||t[4]!==o?(s=Cv({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],zh(s)}),Ev=Qm(e=>{let t=Rp(43),{runtime:n,__internal_assistantRuntime:r}=e,i=tv(n);wv(i.mainThreadId);let a;t[0]===n.main?a=t[1]:(a=xv({runtime:n.main}),t[0]=n.main,t[1]=a);let o=f_(a),s;t[2]!==o.state||t[3]!==n||t[4]!==i.threadItems?(s=Object.keys(i.threadItems).map(e=>$m(e,Tv({runtime:n,id:e,mainThreadIsRunning:o.state.isRunning}),[n,e,o.state.isRunning])),t[2]=o.state,t[3]=n,t[4]=i.threadItems,t[5]=s):s=t[5];let c=K_(s),l=i.newThreadId??null,u;t[6]!==o.state||t[7]!==i.archivedThreadIds||t[8]!==i.hasMore||t[9]!==i.isLoading||t[10]!==i.isLoadingMore||t[11]!==i.mainThreadId||t[12]!==i.threadIds||t[13]!==l||t[14]!==c.state?(u={mainThreadId:i.mainThreadId,newThreadId:l,isLoading:i.isLoading,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:c.state,main:o.state},t[6]=o.state,t[7]=i.archivedThreadIds,t[8]=i.hasMore,t[9]=i.isLoading,t[10]=i.isLoadingMore,t[11]=i.mainThreadId,t[12]=i.threadIds,t[13]=l,t[14]=c.state,t[15]=u):u=t[15];let d=u,f;t[16]===d?f=t[17]:(f=()=>d,t[16]=d,t[17]=f);let p;t[18]===o.methods?p=t[19]:(p=()=>o.methods,t[18]=o.methods,t[19]=p);let m;t[20]!==d||t[21]!==c?(m=e=>{if(e===`main`)return c.get({key:d.mainThreadId});if(`id`in e)return c.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?d.archivedThreadIds[t]:d.threadIds[t];return c.get({key:r})},t[20]=d,t[21]=c,t[22]=m):m=t[22];let h,g,_,v,y,b;t[23]===n?(h=t[24],g=t[25],_=t[26],v=t[27],y=t[28],b=t[29]):(y=(e,t)=>Sv(`switch`,()=>n.switchToThread(e,t)),b=()=>Sv(`create`,()=>n.switchToNewThread()),h=()=>n.getLoadThreadsPromise(),g=()=>n.reload(),_=()=>n.reloadMainThread(),v=()=>n.loadMore(),t[23]=n,t[24]=h,t[25]=g,t[26]=_,t[27]=v,t[28]=y,t[29]=b);let x;t[30]===r?x=t[31]:(x=()=>r,t[30]=r,t[31]=x);let S;return t[32]!==h||t[33]!==g||t[34]!==_||t[35]!==v||t[36]!==x||t[37]!==f||t[38]!==p||t[39]!==m||t[40]!==y||t[41]!==b?(S={getState:f,thread:p,item:m,switchToThread:y,switchToNewThread:b,getLoadThreadsPromise:h,reload:g,reloadMainThread:_,loadMore:v,__internal_getAssistantRuntime:x},t[32]=h,t[33]=g,t[34]=_,t[35]=v,t[36]=x,t[37]=f,t[38]=p,t[39]=m,t[40]=y,t[41]=b,t[42]=S):S=t[42],S}),Dv=(e,t)=>{e.thread??=W_({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=W_({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=W_({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=dg()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=W_({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},Ov=e=>{let t=Rp(7),n=i_(),r;t[0]!==n||t[1]!==e?(r=()=>e.registerModelContextProvider(n.current.modelContext()),t[0]=n,t[1]=e,t[2]=r):r=t[2];let i;t[3]===e?i=t[4]:(i=[e],t[3]=e,t[4]=i),a_(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=Ev({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),zh(a)},kv=Qm(Ov);Wg(Ov,(e,t)=>{Dv(e,t),!e.tools&&t.tools.source===null&&(e.tools=Z_({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=Kh())});var Av=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),X=o(((e,t)=>{t.exports=Av()}))(),jv=typeof process<`u`&&!1,Mv=hg({}),Nv=({effects:e})=>{"use no memo";return Vm(e),null},Pv=qm(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=Vg();if(jv){if(i&&a)throw Error("AuiProvider: pass either `extends` or `value`, not both.");if(i&&e.extends===void 0)throw Error("AuiProvider: `extends` must be a client or null, not undefined.");if(i&&!n)throw Error("AuiProvider: `extends` requires a `config`.");if(a&&n)throw Error("AuiProvider: pass either `value` or `config`, not both.");if(!a&&!n)throw Error("AuiProvider: a `config` is required.");if(!i&&!a&&o!==Pg)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??Pg:a?e.value??Pg:o,{client:c,effects:l}=F_(s,n??Mv);return Km(t,()=>c,[c]),(0,X.jsxs)(Ig.Provider,{value:c,children:[(0,X.jsx)(Nv,{effects:zg(s)}),l&&(0,X.jsx)(Nv,{effects:l}),r]})}),Fv=e=>e._core?.RenderComponent,Iv=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=Fv(e),a=hg({...n,threads:kv(e)});return(0,X.jsxs)(Pv,{extends:t,config:a,children:[i&&(0,X.jsx)(i,{}),r]})},Lv=Jm(e=>{let t=Rp(5),{runtime:n,aui:r,config:i,children:a}=e,o=r===void 0?null:r,s;return t[0]!==o||t[1]!==a||t[2]!==i||t[3]!==n?(s=(0,X.jsx)(Iv,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s}),Rv=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e))},o=t=e(r,i,a);return a},zv=(e=>e?Rv(e):Rv),Bv=e=>e;function Vv(e,t=Bv){let n=S.useSyncExternalStore(e.subscribe,S.useCallback(()=>t(e.getState()),[e,t]),S.useCallback(()=>t(e.getInitialState()),[e,t]));return S.useDebugValue(n),n}var Hv=e=>{let t=zv(e),n=e=>Vv(t,e);return Object.assign(n,t),n},Uv=(e=>e?Hv(e):Hv);function Wv(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Gv(e,t=0){return t>100?!1:e===null||typeof e==`string`||typeof e==`boolean`?!0:typeof e==`number`?!Number.isNaN(e)&&Number.isFinite(e):Array.isArray(e)?e.every(e=>Gv(e,t+1)):Wv(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&Gv(n,t+1)):!1}var Kv=100,qv=(e,t,n)=>{if(e===t)return!0;if(n>Kv||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>qv(e,t[r],n+1));if(Array.isArray(t)||!Wv(e)||!Wv(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&qv(e[r],t[r],n+1))},Jv=(e,t)=>!Gv(e)||!Gv(t)?!1:qv(e,t,0);function Yv(e){let t=e.metadata;if(!t||typeof t!=`object`)return;let n=t.custom;if(!n||typeof n!=`object`)return;let r=n.interactables;return Array.isArray(r)?r:void 0}function Xv(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var Zv=e=>{if(!Wv(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function Qv(e,t,n){let r=Array.isArray(t.set)?[...t.set]:[...e];if(t.clear===!0&&(r=[]),Array.isArray(t.remove)&&t.remove.length>0){let e=new Set(t.remove);r=r.filter(t=>{let n=Zv(t);return n===void 0?!e.has(t):!e.has(n)})}let i=t.update;if(Array.isArray(i)&&i.length>0&&(r=r.map(e=>{let t=Zv(e);if(t===void 0||!Wv(e))return e;let n=i.find(e=>Wv(e)&&e.id===t);return n?{...e,...n}:e})),Array.isArray(t.add)&&t.add.length>0){let e=n?t.add.map(e=>{if(!Wv(e)||e.id!==void 0)return e;let t=n();return t===void 0?e:{...e,id:t}}):t.add;r=[...r,...e]}return r}function $v(e,t,n){if(!Wv(e)||!Wv(t))return t;let r=Wv(n?.arrayBaseline)?n.arrayBaseline:e,i={...e};for(let[e,a]of Object.entries(t)){let t=r[e];i[e]=Array.isArray(t)&&Wv(a)?Qv(t,a,n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0):a}return i}function ey(e,t){if(!Wv(e)||!Wv(t))return;for(let n of Object.keys(e))if(!(n in t))return;let n={};for(let[r,i]of Object.entries(t))(!(r in e)||!Jv(e[r],i))&&(n[r]=i);let r=Object.keys(n).length;if(r!==0&&r!==Object.keys(t).length)return n}var ty=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},ny=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=Wv(e.result)?e.result:void 0;if(n?.success===!1)return!1;if(typeof n?.id==`string`)return n.id===t;let r=e.args.id;return r===t||r===void 0},ry=e=>{let t=Wv(e)?e.addedItemIds:void 0;if(!Wv(t))return;let n=new Map;for(let[e,r]of Object.entries(t)){if(!Array.isArray(r))continue;let t=r.filter(e=>typeof e==`string`);t.length>0&&n.set(e,t)}if(n.size!==0)return e=>n.get(e)?.shift()},iy=new WeakMap;function ay(e,t,n){let r=iy.get(e);r||(r=new Map,iy.set(e,r));let i=r.get(n);i||(i=new Map,r.set(n,i));let a=i.get(t);if(a)return a;let o=Xv(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=Yv(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:$v(t.state,e.state),origin:`user-edit`})}else s.push({state:e.state,origin:`user-edit`});continue}if(r.role===`assistant`)for(let e of r.content??[]){let r=ty(e);if(r){if(r.toolCallId===t&&r.toolName===n)r.args&&typeof r.args==`object`&&s.push({state:r.args,origin:`create`,toolCallId:t});else if(r.toolName===o&&ny(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=ry(r.result);s.push({state:i?$v(e.state,n,{idFactory:i}):$v(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function oy(e,t,n){let r=ay(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function sy(e,t){if(!e)return;let{interactables:n,...r}=e,i={...r};if(Array.isArray(n)){let e=[];for(let r of n){let n=oy(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(Jv(r.state,n.state))continue;let i=ey(n.state,r.state);e.push(i?{id:r.id,name:r.name,state:i,partial:!0}:{id:r.id,name:r.name,state:r.state})}e.length&&(i.interactables=e)}return Object.keys(i).length?i:void 0}var cy=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});if(!e||!t)throw Error(`Failed to create promise`);return{promise:n,resolve:e,reject:t}},ly=()=>{let e=[],t=!1,n=!1,r=!1,i,a,o,s=()=>(o??=Promise.all(e.splice(0).map(async e=>{try{await e.reader.cancel().catch(()=>void 0),await e.pipeTask}finally{e.reader.releaseLock()}})).then(()=>void 0),o),c=o=>{o.promise||=o.reader.read().then(({done:s,value:c})=>{o.promise=void 0,!(n||r)&&(s?(e.splice(e.indexOf(o),1),o.reader.releaseLock(),t&&e.length===0&&i.close()):i.enqueue(c),a?.resolve(),a=void 0)}).catch(e=>{n||r||(r=!0,console.error(e),s(),i.error(e),a?.reject(e),a=void 0)})};return{readable:new ReadableStream({start(e){i=e},pull(){return a=cy(),e.forEach(e=>{c(e)}),a.promise},async cancel(){n=!0;let e=s();a?.resolve(),a=void 0,await e}}),isSealed(){return t},isCancelled(){return n},isErrored(){return r},seal(){t||n||r||(t=!0,e.length===0&&i.close())},addStream(i,a){let o=a?.catch(()=>void 0);if(n||r){i.cancel().catch(()=>void 0);return}if(t)throw i.cancel().catch(()=>void 0),Error(`Cannot add streams after the run callback has settled.`);let s={reader:i.getReader(),pipeTask:o};e.push(s),c(s)},enqueue(e){this.addStream(new ReadableStream({start(t){t.enqueue(e),t.close()}}))}}},uy=e=>e instanceof TypeError,dy=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!uy(e))throw e;n?.(e)}},fy=e=>{try{e.close()}catch(e){if(!uy(e))throw e}},py=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),my=(e,t)=>{let n;return[py({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},hy=class{_controller;_strict;_isClosed=!1;_warnedDropped=!1;constructor(e,t={}){this._controller=e,this._strict=t.strict??!0}append(e){let t={type:`text-delta`,path:[],textDelta:e};return this._strict?(this._controller.enqueue(t),this):(dy(this._controller,t,e=>{this._warnedDropped||(this._warnedDropped=!0,console.error(`Dropped text delta for closed stream: ${String(e)}`))}),this)}close(){this._isClosed||(this._isClosed=!0,dy(this._controller,{type:`part-finish`,path:[]}),fy(this._controller))}},gy=(e,t={})=>py(e,e=>new hy(e,t)),_y=(e={})=>my(t=>new hy(t,e)),vy=Symbol.for(`aui.tool-response`),yy=`<no result>`,by=class e{get[vy](){return!0}artifact;result;isError;modelContent;messages;constructor(e){e.artifact!==void 0&&(this.artifact=e.artifact);let t=e.result;this.result=t===void 0?yy:t,this.isError=e.isError??!1,e.modelContent!==void 0&&(this.modelContent=e.modelContent),e.messages!==void 0&&(this.messages=e.messages)}static[Symbol.hasInstance](e){return typeof e==`object`&&!!e&&vy in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?yy:t})}},xy=class{_isClosed=!1;_mergeTask;_controller;constructor(e){this._controller=e;let t=gy({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,dy(this._controller,e);break;case`part-finish`:n||dy(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),dy(this._controller,{type:`tool-call-args-text-finish`,path:[]});break;default:throw Error(`Unexpected chunk type: ${e.type}`)}}}))}get argsText(){return this._argsTextController}_argsTextController;async setResponse(e){if(this._isClosed)return;let t=e.result;dy(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?yy:t,isError:e.isError??!1,...e.modelContent===void 0?{}:{modelContent:e.modelContent},...e.messages===void 0?{}:{messages:e.messages}}),await this.close()}async close(){this._isClosed||(this._isClosed=!0,this._argsTextController.close(),await this._mergeTask,dy(this._controller,{type:`part-finish`,path:[]}),fy(this._controller))}},Sy=()=>my(e=>new xy(e)),Cy=class{value=-1;up(){return++this.value}},wy=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var Ty=class extends TransformStream{constructor(e){let t=new Cy,n=new Map;super({transform(r,i){r.type===`part-start`&&r.path.length===0&&n.set(t.up(),e.up());let[a,...o]=r.path;if(a===void 0){i.enqueue(r);return}let s=n.get(a);if(s===void 0)throw Error(`Path not found`);i.enqueue({...r,path:[s,...o]})}})}},Ey=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},Dy=o(((e,t)=>{var n=typeof Buffer<`u`,r=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,i=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function a(e,t,a){a==null&&typeof t==`object`&&t&&(a=t,t=void 0),n&&Buffer.isBuffer(e)&&(e=e.toString()),e&&e.charCodeAt(0)===65279&&(e=e.slice(1));let s=JSON.parse(e,t);if(typeof s!=`object`||!s)return s;let c=a&&a.protoAction||`error`,l=a&&a.constructorAction||`error`;if(c===`ignore`&&l===`ignore`)return s;if(c!==`ignore`&&l!==`ignore`){if(r.test(e)===!1&&i.test(e)===!1)return s}else if(c!==`ignore`&&l===`ignore`){if(r.test(e)===!1)return s}else if(i.test(e)===!1)return s;return o(s,{protoAction:c,constructorAction:l,safe:a&&a.safe})}function o(e,{protoAction:t=`error`,constructorAction:n=`error`,safe:r}={}){let i=[e];for(;i.length;){let e=i;i=[];for(let a of e){if(t!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`__proto__`)){if(r===!0)return null;if(t===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.__proto__}if(n!==`ignore`&&Object.prototype.hasOwnProperty.call(a,`constructor`)&&a.constructor!==null&&typeof a.constructor==`object`&&Object.prototype.hasOwnProperty.call(a.constructor,`prototype`)){if(r===!0)return null;if(n===`error`)throw SyntaxError(`Object contains forbidden prototype property`);delete a.constructor}for(let e in a){let t=a[e];t&&typeof t==`object`&&i.push(t)}}}return e}function s(e,t,n){let{stackTraceLimit:r}=Error;Error.stackTraceLimit=0;try{return a(e,t,n)}finally{Error.stackTraceLimit=r}}function c(e,t){let{stackTraceLimit:n}=Error;Error.stackTraceLimit=0;try{return a(e,t,{safe:!0})}catch{return}finally{Error.stackTraceLimit=n}}t.exports=s,t.exports.default=s,t.exports.parse=s,t.exports.safeParse=c,t.exports.scan=o})),Oy=class extends TransformStream{constructor(){let e=[];super({transform(t,n){if(t.type===`part-start`){if(t.path.length!==0){n.error(Error(`Nested parts are not supported`));return}e.push(t.part),n.enqueue(t);return}if(t.type===`text-delta`||t.type===`result`||t.type===`part-finish`||t.type===`tool-call-args-text-finish`){if(t.path.length!==1){n.error(Error(`${t.type} chunks must have a path of length 1`));return}let r=t.path[0];if(r<0||r>=e.length){n.error(Error(`Invalid path index: ${r}`));return}let i=e[r];n.enqueue({...t,meta:i});return}n.enqueue(t)}})}},ky=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},Ay=ky(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),jy=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:ly(),contentCounter:new Cy}}get __internal_isClosed(){return this._state.merger.isSealed()||this._state.merger.isCancelled()||this._state.merger.isErrored()}get __internal_isCancelled(){return this._state.merger.isCancelled()}__internal_getReadable(){return this._state.merger.readable}__internal_subscribeToClose(e){this._state.closeSubscriber=e}_addTransformedStream(e,t){if(e.locked)throw TypeError(`Cannot merge a stream that is already locked to a reader.`);let n=e.pipeTo(t.writable).catch(async e=>{throw await t.writable.abort(e).catch(()=>void 0),e});this._state.merger.addStream(t.readable,n)}_addPart(e,t){this._state.append&&(this._state.append.controller.close(),this._state.append=void 0),this.enqueue({type:`part-start`,part:e,path:[]}),this._addTransformedStream(t,new wy(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new Ty(this._state.contentCounter))}appendText(e){(this._state.append?.kind!==`text`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`text`,parentId:this._parentId,controller:this.addTextPart()}),this._state.append.controller.append(e)}appendReasoning(e,t){(t!==void 0||this._state.append?.kind!==`reasoning`||this._state.append.parentId!==this._parentId)&&(this._state.append={kind:`reasoning`,parentId:this._parentId,controller:this.addReasoningPart(t)}),(t===void 0||e.length!==0)&&this._state.append.controller.append(e)}addTextPart(){let[e,t]=_y({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=_y({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`reasoning`,...e}),t),n}addToolCallPart(e){let t=typeof e==`string`?{toolName:e}:e,n=t.toolName,r=t.toolCallId??Ay(),[i,a]=Sy();return this._addPart({type:`tool-call`,toolName:n,toolCallId:r,...this._parentId&&{parentId:this._parentId}},i),t.argsText!==void 0&&(a.argsText.append(t.argsText),a.argsText.close()),t.args!==void 0&&(a.argsText.append(JSON.stringify(t.args)),a.argsText.close()),t.response!==void 0&&a.setResponse(t.response),a}_finishedPartStream(){return new ReadableStream({start(e){e.enqueue({type:`part-finish`,path:[]}),e.close()}})}_withParentIdOption(e){return this._parentId?{...e,parentId:this._parentId}:e}appendSource(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendFile(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}appendData(e){this._addPart(this._withParentIdOption(e),this._finishedPartStream())}enqueue(e){this._state.merger.enqueue(e),e.type===`part-start`&&e.path.length===0&&this._state.contentCounter.up()}withParentId(t){let n=new e(this._state);return n._parentId=t,n}close(){this._state.append?.controller?.close(),this._state.merger.seal(),this._state.closeSubscriber?.()}};function My(e,t={}){let n=new jy(void 0,t);return(async()=>{try{await e(n)}catch(e){n.__internal_isClosed?n.__internal_isCancelled||console.error(e):n.enqueue({type:`error`,path:[],error:String(e)})}finally{n.__internal_isClosed||n.close()}})(),n.__internal_getReadable()}function Ny(e={}){let{resolve:t,promise:n}=cy(),r;return[My(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var Py=/[0-9a-fA-F]/;function Fy(e){let t=[`ROOT`],n=-1,r=null,i=0,a=[],o;function s(){o!==void 0&&(a.push(JSON.parse(`"${o}"`)),o=void 0)}function c(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`),s();break;case`f`:case`t`:case`n`:n=i,r=i,t.pop(),t.push(a),t.push(`INSIDE_LITERAL`);break;case`-`:t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=i,t.pop(),t.push(a),t.push(`INSIDE_NUMBER`),s();break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`),s();break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`),s()}}function l(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop(),o=a.pop()}}function u(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=r,t.pop(),o=a.pop()}}for(let s=0;s<e.length;s++){let d=e[s];switch(t[t.length-1]){case`ROOT`:c(d,s,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``;break;case`}`:n=s,t.pop(),o=a.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:d===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`),o=``);break;case`INSIDE_OBJECT_KEY`:switch(d){case`"`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`);break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`),o+=d;break;default:o+=d}break;case`INSIDE_OBJECT_AFTER_KEY`:d===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:c(d,s,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:l(d,s);break;case`INSIDE_STRING`:switch(d){case`"`:t.pop(),n=s,o=a.pop();break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=s}break;case`INSIDE_ARRAY_START`:switch(d){case`]`:n=s,t.pop(),o=a.pop();break;default:o=`0`,c(d,s,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(d){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`),o=(Number(o)+1).toString();break;case`]`:n=s,t.pop(),o=a.pop();break;default:n=s}break;case`INSIDE_ARRAY_AFTER_COMMA`:c(d,s,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:{t.pop();let e=t[t.length-1];d===`u`?(t.push(`INSIDE_STRING_UNICODE_ESCAPE`),i=0):e===`INSIDE_STRING`&&(n=s),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_STRING_UNICODE_ESCAPE`:{let e=t[t.length-2];if(!Py.test(d)){t.pop(),s--;break}i++,i===4&&(t.pop(),e===`INSIDE_STRING`&&(n=s)),e===`INSIDE_OBJECT_KEY`&&(o+=d);break}case`INSIDE_NUMBER`:switch(d){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=s;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`}`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&l(d,s);break;case`]`:t.pop(),o=a.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s);break;default:t.pop(),o=a.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,s+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?l(d,s):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&u(d,s)):n=s;break}}}let d=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:d+=`"`;break;case`INSIDE_OBJECT_KEY`:case`INSIDE_OBJECT_AFTER_KEY`:case`INSIDE_OBJECT_AFTER_COMMA`:case`INSIDE_OBJECT_START`:case`INSIDE_OBJECT_BEFORE_VALUE`:case`INSIDE_OBJECT_AFTER_VALUE`:d+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:d+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?d+=`true`.slice(t.length):`false`.startsWith(t)?d+=`false`.slice(t.length):`null`.startsWith(t)&&(d+=`null`.slice(t.length))}}return[d,a]}var Iy=l(Dy(),1),Ly=Symbol(`aui.parse-partial-json-object.meta`),Ry=e=>e?.[Ly],zy=e=>{if(e.length===0)return{[Ly]:{state:`partial`,partialPath:[]}};try{let t=Iy.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[Ly]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=Fy(e),r=Iy.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[Ly]={state:`partial`,partialPath:n},r}catch{return}}},By=(e,t,n)=>{if(typeof e!=`object`||!e)return t.state;if(t.state===`complete`)return`complete`;if(n.length===0)return t.state;let[r,...i]=n;if(!Object.hasOwn(e,r))return`partial`;let[a,...o]=t.partialPath;if(r!==a)return`complete`;let s=e[r];return By(s,{state:`partial`,partialPath:o},i)},Vy=(e,t)=>{let n=Ry(e);if(!n)throw Error(`unable to determine object state`);return By(e,n,t.map(String))};async function*Hy(){let e=this.getReader(),t=!0;try{for(;;){let n;try{n=await e.read()}catch(e){throw t=!1,e}if(n.done){t=!1;break}let{value:r}=n;yield r}}finally{try{t&&await e.cancel()}finally{e.releaseLock()}}}function Uy(e){return e[Symbol.asyncIterator]??=Hy,e}var Wy=Ym(null),Gy=()=>Zm(Wy),Ky=Symbol(`innerMessage`),qy=Symbol(`innerMessages`),Jy=[],Yy=(e,t)=>{Ky in e||(e[Ky]=t)},Xy=e=>{let t=`messages`in e?e.messages:e,n=t[qy]||t[Ky];return n?Array.isArray(n)?n:(t[qy]=[n],t[qy]):Jy},Zy=`__external_store_fallback_`,Qy=class{cache=new WeakMap;convertMessages(e,t){return e.map((e,n)=>{let r=t(this.cache.get(e),e,n);return this.cache.set(e,r),r})}},$y=ky(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),eb=/^https?:\/\//i;function tb(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var nb=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},rb=(e,t,n)=>{let{role:r,id:i,createdAt:a,attachments:o,status:s,metadata:c}=e,l={id:i??t,createdAt:a??new Date},u=typeof e.content==`string`?[{type:`text`,text:e.content}]:e.content,d=({image:e,...t})=>typeof e==`string`?tb(e)?.mimeType.startsWith(`image/`)||/^(https:\/\/|blob:)/i.test(e)?{...t,image:e}:(console.warn(`Invalid image data format detected`),null):null;if(r!==`user`&&o?.length)throw Error(`attachments are only supported for user messages`);if(r!==`assistant`&&s)throw Error(`status is only supported for assistant messages`);if(r!==`assistant`&&c?.steps)throw Error(`metadata.steps is only supported for assistant messages`);switch(r){case`assistant`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:return e.text?.trim()?e:null;case`reasoning`:return!e.text?.trim()&&!e.unstable_summary?.trim()?null:e;case`file`:case`source`:return e;case`image`:return d(e);case`data`:return e;case`generative-ui`:return e;case`tool-call`:{let{parentId:t,messages:n,...r}=e,i={...r,toolCallId:e.toolCallId??`tool-${$y()}`,...t!==void 0&&{parentId:t},...n!==void 0&&{messages:n}};return e.args?{...i,args:e.args,argsText:e.argsText??JSON.stringify(e.args)}:{...i,args:zy(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=nb(t,e.data);if(n)return n;throw Error(`Unsupported assistant message part type: ${t}`)}}}).filter(e=>!!e),status:s??n,metadata:{unstable_state:c?.unstable_state??null,unstable_annotations:c?.unstable_annotations??[],unstable_data:c?.unstable_data??[],custom:c?.custom??{},steps:c?.steps??[],...c?.timing&&{timing:c.timing},...c?.submittedFeedback&&{submittedFeedback:c.submittedFeedback},...c?.isOptimistic&&{isOptimistic:!0}}};case`user`:return{...l,role:r,content:u.map(e=>{let t=e.type;switch(t){case`text`:case`image`:case`audio`:case`file`:case`data`:return e;default:{let n=nb(t,e.data);if(n)return n;throw Error(`Unsupported user message part type: ${t}`)}}}),attachments:(o??[]).map(e=>({...e,content:e.content.map(e=>nb(e.type,e.data)??e)})),metadata:{custom:c?.custom??{},...c?.isOptimistic&&{isOptimistic:!0}}};case`system`:if(u.length!==1||u[0].type!==`text`)throw Error(`System messages must have exactly one text message part.`);return{...l,role:r,content:u,metadata:{custom:c?.custom??{}}};default:throw Error(`Unknown message role: ${r}`)}},ib=e=>e.type===`tool-call`&&e.result===void 0,ab=e=>e.type!==`tool-call`||e.result!==void 0?!1:e.interrupt!=null||e.approval!=null&&e.approval.approved===void 0&&e.approval.resolution===void 0,ob=Symbol(`autoStatus`),sb=Object.freeze(Object.assign({type:`running`},{[ob]:!0})),cb=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[ob]:!0})),lb=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[ob]:!0})),ub=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[ob]:!0})),db=e=>e[ob]===!0,fb=(e,t,n,r,i)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[ob]:!0}):e&&t?sb:n?ub:r?lb:cb,pb=(e,t,n)=>fb(t,n,typeof e!=`string`&&e.some(ab),typeof e!=`string`&&e.some(ib));function mb(e,t,n){try{let r=e();if(typeof r==`object`&&r&&`then`in r)return r.then(t,n);t(r)}catch(e){n(e)}}function hb(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var gb=class{resolve;reject;disposed=!1;fieldPath;constructor(e,t,n){this.resolve=e,this.reject=t,this.fieldPath=n}update(e){if(!this.disposed)try{if(Vy(e,this.fieldPath)===`complete`){let t=hb(e,this.fieldPath);t!==void 0&&(this.resolve(t),this.dispose())}}catch(e){this.reject(e),this.dispose()}}end(e){if(!this.disposed)try{let t=hb(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},_b=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=hb(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),Vy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},vb=class{controller;disposed=!1;fieldPath;lastValue=void 0;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=hb(e,this.fieldPath);if(t!==void 0&&typeof t==`string`){let e=t.substring(this.lastValue?.length||0);this.lastValue=t,this.controller.enqueue(e)}Vy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},yb=class{controller;disposed=!1;fieldPath;processedIndexes=new Set;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=hb(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||Vy(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));Vy(e,this.fieldPath)===`complete`&&(this.controller.close(),this.dispose())}catch(e){this.controller.error(e),this.dispose()}}end(){this.disposed||(this.controller.close(),this.dispose())}dispose(){this.disposed=!0}},bb=class{argTextDeltas;handles=new Set;args=zy(``);finished=!1;constructor(e){this.argTextDeltas=e,this.processStream()}async processStream(){try{let e=``,t=this.argTextDeltas.getReader();for(;;){let{value:n,done:r}=await t.read();if(r)break;e+=n;let i=zy(e);if(i!==void 0){this.args=i;for(let e of this.handles)e.update(i)}}}catch(e){console.error(`Error processing argument stream:`,e)}finally{this.finished=!0;for(let e of this.handles)e.end(this.args);this.handles.clear()}}get(...e){return new Promise((t,n)=>{let r=new gb(t,n,e);if(this.args&&Vy(this.args,e)===`complete`){let n=hb(this.args,e);if(n!==void 0){t(n);return}}if(this.finished){r.end(this.args);return}this.handles.add(r),r.update(this.args)})}streamValues(...e){let t=e,n;return Uy(new ReadableStream({start:e=>{n=new _b(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}streamText(...e){let t=e,n;return Uy(new ReadableStream({start:e=>{n=new vb(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}forEach(...e){let t=e,n;return Uy(new ReadableStream({start:e=>{n=new yb(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},xb=class{promise;constructor(e){this.promise=e}get(){return this.promise}},Sb=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new bb(e.readable);let{promise:t,resolve:n}=cy();this.resolve=n,this.response=new xb(t)}async appendArgsTextDelta(e){let t=this.writable.getWriter();try{await t.write(e)}catch(e){console.warn(e)}finally{t.releaseLock()}this.argsText+=e}async finishArgsText(){let e=this.writable.getWriter();try{await e.close()}catch(e){console.warn(e)}finally{e.releaseLock()}}setResponse(e){this.resolve(e)}result={get:async()=>(await this.response.get()).result}},Cb=Symbol.for(`assistant-stream.tool-execution-id`),wb=(e,t,n,r,i)=>{try{let a=t?.(n,r,i);Promise.resolve(a).catch(t=>{console.error(`[assistant-stream] ${e} callback threw an error`,t)})}catch(t){console.error(`[assistant-stream] ${e} callback threw an error`,t)}},Tb=e=>e.join(`,`),Eb=(e,t)=>{let n={...e};return Object.defineProperty(n,Cb,{value:t,enumerable:!0}),n},Db=class extends Ey{constructor(e){let t=e,n=new Map,r=new Map,i=new Set,a=new Map,o=0;super(e=>{let s=new TransformStream({async transform(e,s){let c=a.get(Tb(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?Eb(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new Sb,o=Symbol();a.set(String(n),o),r.set(o,i),t.streamCall({reader:i,toolCallId:e.part.toolCallId,toolName:e.part.toolName,executionId:o})}break}case`text-delta`:if(e.meta.type===`tool-call`){let t=a.get(Tb(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);await n.appendArgsTextDelta(e.textDelta)}break;case`result`:{if(e.meta.type!==`tool-call`)break;let t=a.get(Tb(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new by({result:e.result,artifact:e.artifact,isError:e.isError,modelContent:e.modelContent})),i.add(t);break}case`tool-call-args-text-finish`:{if(e.meta.type!==`tool-call`)break;let{toolCallId:o,toolName:c}=e.meta,l=a.get(Tb(e.path)),u=l?r.get(l):void 0;if(!u)throw Error(`No controller found for tool call`);if(await u.finishArgsText(),i.has(l))break;let d=!1,f=mb(()=>{let e;try{e=Iy.default.parse(u.argsText)}catch(e){throw Error(`Function parameter parsing failed. ${JSON.stringify(e.message)}`)}let n=t.execute({toolCallId:o,toolName:c,args:e,executionId:l});return n!==void 0&&(d=!0,wb(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&wb(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new by({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),dy(s,Eb({type:`result`,path:e.path,...r},l))},n=>{d&&wb(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new by({result:String(n),isError:!0});u.setResponse(r),dy(s,Eb({type:`result`,path:e.path,...r},l))});f&&n.set(l,f);break}case`part-finish`:{if(e.meta.type!==`tool-call`)break;let t=a.get(Tb(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(Tb(e.path)))};o?o.then(()=>{c(),dy(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new Oy).pipeThrough(s)})}},Ob=Symbol.for(`assistant-stream.tool-execution-id`),kb=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1;function Ab(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new by({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(kb(i.parameters)){let e=i.parameters[`~standard`].validate(n.args);e instanceof Promise&&(e=await e),e.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(e.issues)}`)}))}let o,s=new Promise(e=>{o=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new by({result:`Tool execution was cancelled.`,isError:!0}))})})},t.aborted?o():t.addEventListener(`abort`,o,{once:!0})}),c=(async()=>{let e={toolCallId:n.toolCallId,abortSignal:t,human:e=>r(n.toolCallId,e,n.executionId),[Ob]:n.executionId},o=await a(n.args,e),s=by.toResponse(o);if(i.toModelOutput&&!s.isError&&s.modelContent===void 0)try{let e=await i.toModelOutput({toolCallId:n.toolCallId,input:n.args,output:s.result});return new by({result:s.result,artifact:s.artifact,isError:s.isError,messages:s.messages,modelContent:e})}catch(e){console.warn(`[assistant-stream] tool "${n.toolName}" toModelOutput threw; falling back to default projection.`,e)}return s})();try{return await Promise.race([c,s])}finally{t.removeEventListener(`abort`,o)}})(i.execute):void 0}function jb(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Ob]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function Mb(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new Db({execute:e=>Ab(i(),a(),e,s),streamCall:({reader:e,...t})=>jb(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}function Nb(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function Pb(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function Fb(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function Ib(e){if(Nb(e)){let t=e[`~standard`].toJSONSchema;if(typeof t==`function`)return t();let n=e[`~standard`].jsonSchema;if(typeof n==`object`&&n&&typeof n.input==`function`)return n.input()}if(Pb(e))return e.toJSONSchema();if(Fb(e))return e.toJSON();if(Nb(e))throw Error(`Could not convert schema to JSON Schema. The schema implements Standard Schema but does not support JSON Schema conversion. If you are using Zod, please upgrade to Zod v4 (npm install zod@latest). Alternatively, pass a plain JSON Schema object instead.`);return e}function Lb(e,t){return!t.disabled&&t.type!==`backend`&&(t.type!==`frontend`||t.execute!==void 0)}function Rb(e){return e.parameters!==void 0&&!e.unstable_backendDefault?.parameters}function zb(e,t={}){if(!e)return{};let n=t.filter??Lb;return Object.fromEntries(Object.entries(e).filter(([e,t])=>n(e,t)).filter(e=>Rb(e[1])).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,{...t.description&&{description:t.description},parameters:Ib(t.parameters),...t.providerOptions&&{providerOptions:t.providerOptions}}]))}var Bb=Object.freeze({type:`complete`}),Vb=Object.freeze({type:`running`}),Hb=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`})}),Ub=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return Vb;if(n===`complete`)return Bb;if(n!==`incomplete`)return;let{reason:r}=t;return Hb[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},Wb=(e,t,n)=>{if(e.role!==`assistant`)return Bb;if(n.type===`tool-call`)return n.result===void 0?e.status:Bb;if(e.status.type===`running`){let e=Ub(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?Bb:r?e.status:Bb},Gb=Symbol.for(`assistant-ui.message-not-sent`),Kb=e=>typeof e==`object`&&!!e&&Gb in e,qb=class{get path(){return this._core.path}_core;constructor(e){this._core=e,this.__internal_bindMethods()}__internal_bindMethods(){this.getState=this.getState.bind(this),this.remove=this.remove.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this._core.getState()}subscribe(e){return this._core.subscribe(e)}},Jb=class extends qb{_composerApi;constructor(e,t){super(e),this._composerApi=t}remove(){let e=this._composerApi.getState();if(!e)throw Error(`Composer is not available`);return e.removeAttachment(this.getState().id)}},Yb=class extends Jb{get source(){return`thread-composer`}},Xb=class extends Jb{get source(){return`edit-composer`}},Zb=class extends qb{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},Qb=Object.freeze([]),$b=Object.freeze({}),ex=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??Qb,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??$b,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??Qb,value:e?.text??``}),tx=e=>Object.freeze({type:`edit`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,text:e?.text??``,role:e?.role??`user`,attachments:e?.attachments??Qb,runConfig:e?.runConfig??$b,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??Qb,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),nx=class{get path(){return this._core.path}_core;constructor(e){this._core=e}__internal_bindMethods(){this.setText=this.setText.bind(this),this.setRunConfig=this.setRunConfig.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.addAttachment=this.addAttachment.bind(this),this.reset=this.reset.bind(this),this.clearAttachments=this.clearAttachments.bind(this),this.send=this.send.bind(this),this.cancel=this.cancel.bind(this),this.steerQueueItem=this.steerQueueItem.bind(this),this.moveQueueItem=this.moveQueueItem.bind(this),this.removeQueueItem=this.removeQueueItem.bind(this),this.setRole=this.setRole.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.startDictation=this.startDictation.bind(this),this.stopDictation=this.stopDictation.bind(this),this.setQuote=this.setQuote.bind(this),this.unstable_on=this.unstable_on.bind(this)}setText(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setText(e)}setRunConfig(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRunConfig(e)}addAttachment(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);return t.addAttachment(e)}reset(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.reset()}clearAttachments(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);return e.clearAttachments()}send(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.send(e)}cancel(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.cancel()}steerQueueItem(e){this.moveQueueItem(e,{lane:`steer`,insertAfter:null})}moveQueueItem(e,t){let n=this._core.getState();if(!n)throw Error(`Composer is not available`);n.moveQueueItem(e,t)}removeQueueItem(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.removeQueueItem(e)}setRole(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setRole(e)}startDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.startDictation()}stopDictation(){let e=this._core.getState();if(!e)throw Error(`Composer is not available`);e.stopDictation()}setQuote(e){let t=this._core.getState();if(!t)throw Error(`Composer is not available`);t.setQuote(e)}subscribe(e){return this._core.subscribe(e)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new ag({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},rx=class extends nx{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new rg({path:e.path,getState:()=>ex(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>t.subscribe(e)}),this._getState=t.getState.bind(t),this.__internal_bindMethods()}getState(){return this._getState()}getAttachmentByIndex(e){return new Yb(new ng({path:{...this.path,attachmentSource:`thread-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`thread-composer`}:Zh},subscribe:e=>this._core.subscribe(e)}),this._core)}},ix=class extends nx{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new rg({path:e.path,getState:()=>tx(e.getState()),subscribe:t=>e.subscribe(t)});super({path:e.path,getState:()=>e.getState(),subscribe:e=>n.subscribe(e)}),this._beginEdit=t,this._getState=n.getState.bind(n),this.__internal_bindMethods()}__internal_bindMethods(){super.__internal_bindMethods(),this.beginEdit=this.beginEdit.bind(this)}getState(){return this._getState()}beginEdit(){this._beginEdit()}getAttachmentByIndex(e){return new Xb(new ng({path:{...this.path,attachmentSource:`edit-composer`,attachmentSelector:{type:`index`,index:e},ref:`${this.path.ref}.attachments[${e}]`},getState:()=>{let t=this.getState().attachments[e];return t?{...t,source:`edit-composer`}:Zh},subscribe:e=>this._core.subscribe(e)}),this._core)}},ax=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
21
|
+
|
|
22
|
+
`),ox={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},sx=(e,t)=>{let n,r;if(`optionId`in t){let i=e.options?.find(e=>e.id===t.optionId);if(!i)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)n=t.approved;else{if(!Object.hasOwn(ox,i.kind))throw Error(`Tool approval option "${i.id}" has a custom kind "${i.kind}"; respond with an explicit approved value instead`);n=ox[i.kind]}r=i.id}else n=t.approved;return{approvalId:e.id,approved:n,...r!==void 0&&{optionId:r},...t.reason!=null&&{reason:t.reason}}},cx=class{get path(){return this.contentBinding.path}contentBinding;messageApi;threadApi;constructor(e,t,n){this.contentBinding=e,this.messageApi=t,this.threadApi=n,this.__internal_bindMethods()}__internal_bindMethods(){this.addToolResult=this.addToolResult.bind(this),this.resumeToolCall=this.resumeToolCall.bind(this),this.respondToToolApproval=this.respondToToolApproval.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this)}getState(){return this.contentBinding.getState()}addToolResult(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to add tool result to non-tool message part`);if(!this.messageApi)throw Error(`Message API is not available. This is likely a bug in assistant-ui.`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=this.messageApi.getState();if(!n)throw Error(`Message is not available`);let r=t.toolName,i=t.toolCallId,a=by.toResponse(e);this.threadApi.getState().addToolResult({messageId:n.id,toolName:r,toolCallId:i,result:a.result,artifact:a.artifact,isError:a.isError})}resumeToolCall(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to resume tool call on non-tool message part`);if(!this.threadApi)throw Error(`Thread API is not available`);let n=t.toolCallId;this.threadApi.getState().resumeToolCall({toolCallId:n,payload:e})}respondToToolApproval(e){let t=this.contentBinding.getState();if(!t)throw Error(`Message part is not available`);if(t.type!==`tool-call`)throw Error(`Tried to respond to tool approval on non-tool message part`);if(!t.approval||t.approval.approved!==void 0||t.approval.resolution!==void 0)throw Error(`Tool call has no pending approval`);if(!this.threadApi)throw Error(`Thread API is not available`);this.threadApi.getState().respondToToolApproval(sx(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},lx=(e,t)=>{let n=e.content[t];if(!n)return Zh;let r=Wb(e,t,n);return Object.freeze({...n,[Ky]:n[Ky],status:r})},ux=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new ix(new ig({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`edit`},getState:this._getEditComposerRuntimeCore,subscribe:e=>this._threadBinding.subscribe(e)}),()=>this._threadBinding.getState().beginEdit(this._core.getState().id)),this.__internal_bindMethods()}__internal_bindMethods(){this.reload=this.reload.bind(this),this.delete=this.delete.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getMessagePartByIndex=this.getMessagePartByIndex.bind(this),this.getMessagePartByToolCallId=this.getMessagePartByToolCallId.bind(this),this.getAttachmentByIndex=this.getAttachmentByIndex.bind(this),this.unstable_getCopyText=this.unstable_getCopyText.bind(this),this.speak=this.speak.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.submitFeedback=this.submitFeedback.bind(this),this.switchToBranch=this.switchToBranch.bind(this)}composer;_getEditComposerRuntimeCore=()=>this._threadBinding.getState().getEditComposer(this._core.getState().id);getState(){return this._core.getState()}delete(){let e=this._core.getState();return this._threadBinding.getState().deleteMessage(e.id)}reload(e={}){let t=this._getEditComposerRuntimeCore(),n=t??this._threadBinding.getState().composer,r=t??n,{runConfig:i=r.runConfig}=e,a=this._core.getState();if(a.role!==`assistant`)throw Error(`Can only reload assistant messages`);this._threadBinding.getState().startRun({parentId:a.parentId,sourceId:a.id,runConfig:i})}speak(){let e=this._core.getState();return this._threadBinding.getState().speak(e.id)}stopSpeaking(){let e=this._core.getState();if(this._threadBinding.getState().speech?.messageId===e.id)this._threadBinding.getState().stopSpeaking();else throw Error(`Message is not being spoken`)}submitFeedback({type:e}){let t=this._core.getState();this._threadBinding.getState().submitFeedback({messageId:t.id,type:e})}switchToBranch({position:e,branchId:t}){let n=this._core.getState();if(t&&e)throw Error(`May not specify both branchId and position`);if(!t&&!e)throw Error(`Must specify either branchId or position`);let r=this._threadBinding.getState().getBranches(n.id),i=t;if(e===`previous`?i=r[n.branchNumber-2]:e===`next`&&(i=r[n.branchNumber]),!i)throw Error(`Branch not found`);this._threadBinding.getState().switchToBranch(i)}unstable_getCopyText(){return ax(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new cx(new ng({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>lx(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new cx(new ng({path:{...this.path,ref:`${this.path.ref}.content[toolCallId=${JSON.stringify(e)}]`,messagePartSelector:{type:`toolCallId`,toolCallId:e}},getState:()=>{let t=this._core.getState(),n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e);return n===-1?Zh:lx(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new Zb(new ng({path:{...this.path,ref:`${this.path.ref}.attachments[${e}]`,attachmentSource:`message`,attachmentSelector:{type:`index`,index:e}},getState:()=>{let t=this.getState().attachments?.[e];return t?{...t,source:`message`}:Zh},subscribe:e=>this._core.subscribe(e)}))}},dx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),fx=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),px=(e,t)=>typeof t==`string`?{createdAt:new Date,parentId:e.at(-1)?.id??null,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:t}],attachments:[],metadata:{custom:{}}}:{createdAt:t.createdAt??new Date,parentId:t.parentId??e.at(-1)?.id??null,sourceId:t.sourceId??null,role:t.role??`user`,content:t.content,attachments:t.attachments??[],metadata:t.metadata??{custom:{}},runConfig:t.runConfig??{},startRun:t.startRun},mx=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},hx=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:mx(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),gx=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new ng({path:e.path,getState:()=>hx(e.getState(),t.getState()),subscribe:n=>{let r=e.subscribe(n),i=t.subscribe(n);return()=>{r(),i()}}});this._stateBinding=n,this._threadBinding={path:e.path,getState:()=>e.getState(),getStateState:()=>n.getState(),outerSubscribe:t=>e.outerSubscribe(t),subscribe:t=>e.subscribe(t)},this.composer=new rx(new ig({path:{...this.path,ref:`${this.path.ref}.composer`,composerSource:`thread`},getState:()=>this._threadBinding.getState().composer,subscribe:e=>this._threadBinding.subscribe(e)})),this.__internal_bindMethods()}__internal_bindMethods(){this.append=this.append.bind(this),this.deleteMessage=this.deleteMessage.bind(this),this.resumeRun=this.resumeRun.bind(this),this.importExternalState=this.importExternalState.bind(this),this.exportExternalState=this.exportExternalState.bind(this),this.startRun=this.startRun.bind(this),this.cancelRun=this.cancelRun.bind(this),this.unstable_notifySessionReset=this.unstable_notifySessionReset.bind(this),this.stopSpeaking=this.stopSpeaking.bind(this),this.connectVoice=this.connectVoice.bind(this),this.disconnectVoice=this.disconnectVoice.bind(this),this.muteVoice=this.muteVoice.bind(this),this.unmuteVoice=this.unmuteVoice.bind(this),this.getVoiceVolume=this.getVoiceVolume.bind(this),this.subscribeVoiceVolume=this.subscribeVoiceVolume.bind(this),this.export=this.export.bind(this),this.import=this.import.bind(this),this.reset=this.reset.bind(this),this.getMessageByIndex=this.getMessageByIndex.bind(this),this.getMessageById=this.getMessageById.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getModelContext=this.getModelContext.bind(this),this.getState=this.getState.bind(this)}composer;getState(){return this._threadBinding.getStateState()}append(e){let t=this._threadBinding.getState().append(px(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!Kb(e))throw e})}deleteMessage(e){return this._threadBinding.getState().deleteMessage(e)}subscribe(e){return this._stateBinding.subscribe(e)}getModelContext(){return this._threadBinding.getState().getModelContext()}startRun(e){return this._threadBinding.getState().startRun(fx(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(dx(e))}exportExternalState(){return this._threadBinding.getState().exportExternalState()}importExternalState(e){this._threadBinding.getState().importExternalState(e)}cancelRun(){this._threadBinding.getState().cancelRun()}unstable_notifySessionReset(){this._threadBinding.getState().unstable_notifySessionReset()}stopSpeaking(){return this._threadBinding.getState().stopSpeaking()}connectVoice(){this._threadBinding.getState().connectVoice()}disconnectVoice(){this._threadBinding.getState().disconnectVoice()}getVoiceVolume(){return this._threadBinding.getState().getVoiceVolume()}subscribeVoiceVolume(e){return this._threadBinding.getState().subscribeVoiceVolume(e)}muteVoice(){this._threadBinding.getState().muteVoice()}unmuteVoice(){this._threadBinding.getState().unmuteVoice()}export(){return this._threadBinding.getState().export()}import(e){this._threadBinding.getState().import(e)}reset(e){this._threadBinding.getState().reset(e)}getMessageByIndex(e){if(e<0)throw Error(`Message index must be >= 0`);return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[${e}]`,messageSelector:{type:`index`,index:e}},()=>{let t=this._threadBinding.getState().messages,n=t[e];if(n)return{message:n,parentId:t[e-1]?.id??null,index:e}})}getMessageById(e){return this._getMessageRuntime({...this.path,ref:`${this.path.ref}.messages[messageId=${JSON.stringify(e)}]`,messageSelector:{type:`messageId`,messageId:e}},()=>this._threadBinding.getState().getMessageById(e))}_getMessageRuntime(e,t){return new ux(new ng({path:e,getState:()=>{let{message:e,parentId:n,index:r}=t()??{},{messages:i,speech:a}=this._threadBinding.getState();if(!e||n===void 0||r===void 0)return Zh;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[Ky]:e[Ky],index:r,isLast:i.at(-1)?.id===e.id,parentId:n,branchNumber:o.indexOf(e.id)+1,branchCount:o.length,speech:a?.messageId===e.id?a:void 0}},subscribe:e=>this._threadBinding.subscribe(e)}),this._threadBinding)}_eventSubscriptionSubjects=new Map;unstable_on(e,t){let n=this._eventSubscriptionSubjects.get(e);return n||(n=new ag({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},_x=class{get path(){return this._core.path}_core;_threadListBinding;constructor(e,t){this._core=e,this._threadListBinding=t,this.__internal_bindMethods()}__internal_bindMethods(){this.switchTo=this.switchTo.bind(this),this.rename=this.rename.bind(this),this.updateCustom=this.updateCustom.bind(this),this.archive=this.archive.bind(this),this.unarchive=this.unarchive.bind(this),this.delete=this.delete.bind(this),this.initialize=this.initialize.bind(this),this.generateTitle=this.generateTitle.bind(this),this.subscribe=this.subscribe.bind(this),this.unstable_on=this.unstable_on.bind(this),this.getState=this.getState.bind(this),this.detach=this.detach.bind(this)}getState(){return this._core.getState()}switchTo(e){let t=this._core.getState();return this._threadListBinding.switchToThread(t.id,e)}rename(e){let t=this._core.getState();return this._threadListBinding.rename(t.id,e)}updateCustom(e){let t=this._core.getState();if(!this._threadListBinding.updateCustom)throw Error(`Thread list runtime does not support updating custom metadata`);return this._threadListBinding.updateCustom(t.id,e)}archive(){let e=this._core.getState();return this._threadListBinding.archive(e.id)}unarchive(){let e=this._core.getState();return this._threadListBinding.unarchive(e.id)}delete(){let e=this._core.getState();return this._threadListBinding.delete(e.id)}initialize(){let e=this._core.getState();return this._threadListBinding.initialize(e.id)}generateTitle(){let e=this._core.getState();return this._threadListBinding.generateTitle(e.id)}unstable_on(e,t){let n=this._core.getState().isMain,r=this._core.getState().id;return this.subscribe(()=>{let i=this._core.getState(),a=i.isMain,o=i.id;(n!==a||r!==o)&&(n=a,r=o,!(e===`switchedTo`&&!a)&&(e===`switchedAway`&&a||Xh([t],{},`Thread list item "${e}"`)))})}subscribe(e){return this._core.subscribe(e)}detach(){let e=this._core.getState();this._threadListBinding.detach(e.id)}__internal_getRuntime(){return this}},vx=Promise.resolve(),yx=e=>({mainThreadId:e.mainThreadId,newThreadId:e.newThreadId,threadIds:e.threadIds,archivedThreadIds:e.archivedThreadIds,isLoading:e.isLoading,isLoadingMore:e.isLoadingMore??!1,hasMore:e.hasMore??!1,threadItems:e.threadItems}),bx=(e,t)=>{if(t===void 0)return Zh;let n=e.getItemById(t);return n?{id:n.id,remoteId:n.remoteId,externalId:n.externalId,title:n.title,status:n.status,lastMessageAt:n.lastMessageAt,custom:n.custom,isMain:n.id===e.mainThreadId,isRunning:e.unstable_isThreadRunning?.(n.id)??!1}:Zh},xx=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=gx){this._core=e,this._runtimeFactory=t;let n=new rg({path:{},getState:()=>yx(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new _x(new ng({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>bx(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new ig({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??vx}reloadMainThread(){return this._core.reloadMainThread?.()??vx}loadMore(){return this._core.loadMore?.()??vx}getState(){return this._getState()}subscribe(e){return this._stateBinding.subscribe(e)}_mainThreadListItemRuntime;main;get mainItem(){return this._mainThreadListItemRuntime}getById(e){return new this._runtimeFactory(new ig({path:{ref:`threads[threadId=${JSON.stringify(e)}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>this._core.getThreadRuntimeCore(e),subscribe:e=>this._core.subscribe(e)}),this.mainItem)}getItemByIndex(e){return new _x(new ng({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>bx(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new _x(new ng({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>bx(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new _x(new ng({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>bx(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},Sx=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new xx(e.threads),this._thread=this.threads.main,this.__internal_bindMethods()}__internal_bindMethods(){this.registerModelContextProvider=this.registerModelContextProvider.bind(this)}get thread(){return this._thread}registerModelContextProvider(e){return this._core.registerModelContextProvider(e)}},Cx=new WeakMap,wx=e=>Cx.get(e)??0,Tx=(e,t)=>wx(e)===t,Ex=e=>{Cx.set(e,wx(e)+1)},Dx=class{_contextProvider=new og;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},Ox=Object.freeze([]),kx=`DEFAULT_THREAD_ID`,Ax=Object.freeze([kx]),jx=Object.freeze({id:kx,remoteId:void 0,externalId:void 0,status:`regular`}),Mx=Promise.resolve(),Nx=Object.freeze({[kx]:jx}),Px=class extends eg{_mainThreadId=kx;_threads=Ax;_archivedThreads=Ox;_threadData=Nx;adapter={};get isLoading(){return this.adapter.isLoading??!1}get newThreadId(){}get threadIds(){return this._threads}get archivedThreadIds(){return this._archivedThreads}get threadItems(){return this._threadData}getLoadThreadsPromise(){return Mx}_mainThread;get mainThreadId(){return this._mainThreadId}threadFactory;constructor(e={},t){super(),this.threadFactory=t,this.__internal_setAdapter(e,!0)}getMainThreadRuntimeCore(){return this._mainThread}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getItemById(e){return this._threadData[e]}__internal_setAdapter(e,t=!1){let n=this.adapter;this.adapter=e;let r=e.threadId??kx,i=e.threads??Ox,a=e.archivedThreads??Ox,o=n.threadId??kx,s=n.threads??Ox,c=n.archivedThreads??Ox;!t&&o===r&&s===i&&c===a||((s!==i||c!==a||o!==r)&&(this._threadData={...Nx,...Object.fromEntries(e.threads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`regular`}])??[]),...Object.fromEntries(e.archivedThreads?.map(e=>[e.id,{...e,remoteId:e.remoteId,externalId:e.externalId,status:`archived`}])??[])}),s!==i&&(this._threads=this.adapter.threads?.map(e=>e.id)??Ox),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??Ox),(t||o!==r)&&(t||Ex(this._mainThread),this._mainThreadId=r,this._mainThread=this.threadFactory()),this._threadData[this._mainThreadId]||(this._threadData={...this._threadData,[this._mainThreadId]:{id:this._mainThreadId,remoteId:void 0,externalId:void 0,status:`regular`}}),this._notifySubscribers())}async reloadMainThread(){this._mainThread.unstable_refetchThread&&await this._mainThread.unstable_refetchThread()}async switchToThread(e,t){if(this._mainThreadId===e)return;let n=this.adapter.onSwitchToThread;if(!n)throw Error(`External store adapter does not support switching to thread`);await n(e)}async switchToNewThread(){let e=this.adapter.onSwitchToNewThread;if(!e)throw Error(`External store adapter does not support switching to new thread`);await e()}async rename(e,t){let n=this.adapter.onRename;if(!n)throw Error(`External store adapter does not support renaming`);await n(e,t)}async updateCustom(e,t){let n=this.adapter.onUpdateCustom;if(!n)throw Error(`External store adapter does not support updating custom metadata`);await n(e,t)}async detach(){}async archive(e){let t=this.adapter.onArchive;if(!t)throw Error(`External store adapter does not support archiving`);await t(e)}async unarchive(e){let t=this.adapter.onUnarchive;if(!t)throw Error(`External store adapter does not support unarchiving`);await t(e)}async delete(e){let t=this.adapter.onDelete;if(!t)throw Error(`External store adapter does not support deleting`);await t(e)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},Fx={fromArray:e=>{let t=e.map(e=>rb(e,$y(),pb(e.content,!1,!1)));return{messages:t.map((e,n)=>({parentId:n>0?t[n-1].id:null,message:e}))}},fromBranchableArray:(e,t)=>({...t?.headId===void 0?void 0:{headId:t.headId},messages:e.map(({message:e,parentId:t})=>{if(!e.id)throw Error(`ExportedMessageRepository.fromBranchableArray: Each message must have an 'id' field set.`);return{parentId:t,message:rb(e,e.id,pb(e.content,!1,!1))}})})},Ix=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},Lx=class{_value=null;func;constructor(e){this.func=e}get value(){return this._value===null&&(this._value=this.func()),this._value}dirty(){this._value=null}},Rx=class{messages=new Map;head=null;root={children:[],next:null};updateLevels(e,t){let n=[{message:e,level:t}];for(;n.length>0;){let e=n.pop();e.message.level=e.level;for(let t of e.message.children){let r=this.messages.get(t);r&&n.push({message:r,level:e.level+1})}}}performOp(e,t,n){let r=t.prev??this.root,i=e??this.root;if(n!==`relink`||r!==i){if(n===`relink`){for(let n=e;n;n=n.prev)if(n.current.id===t.current.id)throw Error(`MessageRepository(performOp/relink): A message with the same id already exists in the parent tree. This error occurs if the same message id is found multiple times. This is likely an internal bug in assistant-ui.`)}if(n!==`link`&&(r.children=r.children.filter(e=>e!==t.current.id),r.next===t)){let e=r.children.at(-1),t=e?this.messages.get(e):null;if(t===void 0)throw Error(`MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.`);r.next=t}if(n!==`cut`){i.children=[...i.children,t.current.id],(Ix(t)===this.head||i.next===null)&&(i.next=t),t.prev=e;let n=e?e.level+1:0;this.updateLevels(t,n)}}}_messages=new Lx(()=>{let e=Array((this.head?.level??-1)+1);for(let t=this.head;t;t=t.prev)e[t.level]=t.current;return e});get headId(){return this.head?.current.id??null}get canonicalHeadId(){let e=this.head;for(;e?.current.metadata?.isOptimistic;)e=e.prev;return e?.current.id??null}getMessages(e){if(e===void 0||e===this.head?.current.id)return this._messages.value;let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getMessages): Head message not found. This is likely an internal bug in assistant-ui.`);let n=Array(t.level+1);for(let e=t;e;e=e.prev)n[e.level]=e.current;return n}addOrUpdateMessage(e,t){let n=this.messages.get(t.id),r=e?this.messages.get(e):null;if(r===void 0)throw Error(`MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.`);if(n){n.current=t,this.performOp(r,n,`relink`),this._messages.dirty();return}let i={prev:r,current:t,next:null,children:[],level:r?r.level+1:0};this.messages.set(t.id,i),this.performOp(r,i,`link`),this.head===r&&(this.head=i),this._messages.dirty()}getMessage(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui.`);return{parentId:t.prev?.current.id??null,message:t.current,index:t.level}}deleteMessage(e,t){let n=this.messages.get(e);if(!n)throw Error(`MessageRepository(deleteMessage): Message not found. This is likely an internal bug in assistant-ui.`);let r=t===void 0?n.prev:t===null?null:this.messages.get(t);if(r===void 0)throw Error(`MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.`);for(let e of n.children){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.`);this.performOp(r,t,`relink`)}this.performOp(null,n,`cut`),this.messages.delete(e),this.head===n&&(this.head=Ix(r??this.root)),this._messages.dirty()}getBranches(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.`);let{children:n}=t.prev??this.root;return n}evictOffBranchOptimisticMessages(e,t){if(!e)return;let n=new Set;for(let e=t;e;e=e.prev)n.add(e.current.id);let r=[];for(let t=e;t&&!n.has(t.current.id);t=t.prev)t.current.metadata?.isOptimistic&&r.push(t.current.id);for(let e of r)this.messages.has(e)&&this.deleteMessage(e)}switchToBranch(e){let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head,r=t.prev??this.root;r.next=t,this.head=Ix(t),this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}resetHead(e){if(e===null){this.clear();return}let t=this.messages.get(e);if(!t)throw Error(`MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.`);let n=this.head;if(t.children.length>0){let e=[...t.children];for(;e.length>0;){let t=e.pop(),n=this.messages.get(t);if(n){for(let t of n.children)e.push(t);this.messages.delete(t)}}t.children=[],t.next=null}this.head=t;for(let e=t;e;e=e.prev)e.prev?e.prev.next=e:this.root.next=e;this.evictOffBranchOptimisticMessages(n,this.head),this._messages.dirty()}clear(){this.messages.clear(),this.head=null,this.root={children:[],next:null},this._messages.dirty()}export(){let e=[];for(let[,t]of this.messages){if(t.current.metadata?.isOptimistic)continue;let n=t.prev;for(;n&&n.current.metadata?.isOptimistic;)n=n.prev;e.push({message:t.current,parentId:n?.current.id??null})}return{headId:this.canonicalHeadId,messages:e}}import({headId:e,messages:t}){for(let{message:e,parentId:n}of t)this.addOrUpdateMessage(n,e);this.resetHead(e??t.at(-1)?.message.id??null)}},zx=Object.freeze([]);function Bx(e,t){if(t===`*`)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase()),r=`.${e.name.split(`.`).pop().toLowerCase()}`,i=e.type.split(`;`,1)[0].trim().toLowerCase();for(let e of n){if(e.startsWith(`.`)&&e===r||e.includes(`/`)&&e===i)return!0;if(e.endsWith(`/*`)){let t=e.split(`/`)[0];if(i.startsWith(`${t}/`))return!0}}return!1}function Vx(e){let t=$y();return e.type===`image`?{id:t,type:`image`,name:e.filename??`image`,content:[e],status:{type:`complete`}}:e.type===`file`?{id:t,type:`document`,name:e.filename??`document`,contentType:e.mimeType,content:[e],status:{type:`complete`}}:e.type===`audio`?{id:t,type:`audio`,name:`audio.${e.audio.format}`,contentType:`audio/${e.audio.format}`,content:[e],status:{type:`complete`}}:{id:t,type:`data`,name:e.name,content:[e],status:{type:`complete`}}}function Hx(e){let t=[];for(let n of e)n.type!==`text`&&t.push(Vx(n));return t}var Ux=e=>`content`in e&&!(`lastModified`in e),Wx=class{operations=new Set;start(){let e={cancelled:!1,attachmentIds:new Set};return this.operations.add(e),e}accept(e,t){return!e.cancelled&&(e.attachmentIds.add(t),!0)}finish(e){this.operations.delete(e)}isCancelled(e){return e.cancelled}cancel(e){for(let t of[...this.operations])t.attachmentIds.has(e)&&(t.cancelled=!0,this.operations.delete(t))}cancelAll(){for(let e of this.operations)e.cancelled=!0;this.operations.clear()}},Gx=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},Kx=e=>e.status.type===`complete`,qx=class extends eg{isEditing=!0;enrichWithComposerMetadata(e,t){return t?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...t}}}:e}get attachmentAccept(){return this.getAttachmentAdapter()?.accept??`*`}_attachments=[];get attachments(){return this._attachments}setAttachments(e){this._attachments=e,this._notifySubscribers()}get isEmpty(){return!this.text.trim()&&!this.attachments.length}_text=``;get text(){return this._text}_role=`user`;get role(){return this._role}_runConfig={};get runConfig(){return this._runConfig}_quote=void 0;get quote(){return this._quote}setQuote(e){this._quote!==e&&(this._quote=e,this._notifySubscribers())}setText(e){this._text!==e&&(this._text=e,this._rebaseDictation(e),this._notifySubscribers())}_rebaseDictation(e){if(!this._dictation)return;this._dictationBaseText=e,this._currentInterimText=``;let{status:t,inputDisabled:n}=this._dictation;this._dictation=n?{status:t,inputDisabled:n}:{status:t}}setRole(e){this._role!==e&&(this._role=e,this._notifySubscribers())}setRunConfig(e){this._runConfig!==e&&(this._runConfig=e,this._notifySubscribers())}_isSending=!1;_removedDuringSend=new Set;_sendGeneration=0;_attachmentAddOperations=new Wx;_cancelAttachmentAdd(e){this._attachmentAddOperations.cancel(e)}_cancelAllAttachmentAdds(){this._attachmentAddOperations.cancelAll()}_emptyTextAndAttachments(){this._attachments=[],this._text=``,this._notifySubscribers()}async _onClearAttachments(){let e=this.getAttachmentAdapter();if(e){let t=this._attachments.filter(e=>!Kx(e));await Promise.all(t.map(t=>e.remove(t)))}}async reset(){if(this._cancelAllAttachmentAdds(),this._sendGeneration++,this._isSending=!1,this._removedDuringSend.clear(),this._attachments.length===0&&this._text===``&&this._role===`user`&&Object.keys(this._runConfig).length===0&&this._quote===void 0)return;this._role=`user`,this._runConfig={},this._quote=void 0;let e=this._onClearAttachments();this._emptyTextAndAttachments(),await e}async clearAttachments(){this._cancelAllAttachmentAdds();let e=this._onClearAttachments();this.setAttachments([]),await e}async send(e){if(!this.canSend||this._isSending)return;this._dictationSession&&(this._dictationSession.cancel(),this._cleanupDictation());let t=this.getAttachmentAdapter(),n=this.attachments.map(async e=>{if(Kx(e))return e;if(!t)throw Error(`Attachments are not supported`);return await t.send(e)}),r=this.attachments,i=this.text,a=this._quote,o=this.role,s=this.runConfig;this._quote=void 0,this._text=``,this._isSending=!0;let c=++this._sendGeneration;this._notifySubscribers();let l;try{l=await Promise.all(n)}catch(e){throw c===this._sendGeneration&&(!this.text.trim()&&this._quote===void 0&&(this._text=i,this._rebaseDictation(i),this._quote=a,this._notifySubscribers()),Promise.allSettled(n).then(()=>{c===this._sendGeneration&&(this._removedDuringSend.clear(),this._isSending=!1,this._notifySubscribers())})),e}if(c!==this._sendGeneration)return;let u=new Set(r.map(e=>e.id));this._attachments=this._attachments.filter(e=>!u.has(e.id)),this._isSending=!1,this._notifySubscribers();let d=l.filter(e=>!this._removedDuringSend.has(e.id));this._removedDuringSend.clear();let f={createdAt:new Date,role:o,content:i?[{type:`text`,text:i}]:[],attachments:d,runConfig:s,metadata:{custom:{...a?{quote:a}:{}}}},p={text:i,quote:a,attachments:d},m;try{m=this.handleSend(f,e)}catch(e){throw this._restoreUnsentDraft(e,c,p),e}m&&m.catch(e=>{this._restoreUnsentDraft(e,c,p)}),this._notifyEventSubscribers(`send`,{})}restoreDraft(e){return this._text.trim()||this._quote!==void 0||this._attachments.length>0?!1:(this._text=e.text,this._rebaseDictation(e.text),this._quote=e.quote,this._attachments=e.attachments??[],this._notifySubscribers(),!0)}retractDraft(e){let t=e.attachments===void 0?this._attachments.length===0:this._attachments===e.attachments;this._text!==e.text||this._quote!==e.quote||!t||(this._text=``,this._rebaseDictation(``),this._quote=void 0,this._attachments=[],this._notifySubscribers())}_restoreUnsentDraft(e,t,n){Kb(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return zx}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(Ux(e)){let t=this.getAttachmentAdapter();if(t&&!Bx({name:e.name,type:e.contentType??``},t.accept)){let n=`File type ${e.contentType||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n={id:e.id??$y(),type:e.type??`document`,name:e.name,contentType:e.contentType,content:e.content,status:{type:`complete`}};this._attachments=[...this._attachments,n],this._notifySubscribers(),this._notifyEventSubscribers(`attachmentAdd`,{});return}let t=this.getAttachmentAdapter();if(!t){let e=`Attachments are not supported`,t=Error(e);throw this._safeEmitAttachmentAddError(`no-adapter`,e,void 0,t),t}if(!Bx({name:e.name,type:e.type},t.accept)){let n=`File type ${e.type||`unknown`} is not accepted. Accepted types: ${t.accept}`,r=Error(n);throw this._safeEmitAttachmentAddError(`not-accepted`,n,void 0,r),r}let n=this._attachmentAddOperations.start(),r=e=>{if(!this._attachmentAddOperations.accept(n,e.id))return!1;let t=this._attachments.findIndex(t=>t.id===e.id);return this._attachments=t===-1?[...this._attachments,e]:[...this._attachments.slice(0,t),e,...this._attachments.slice(t+1)],this._notifySubscribers(),!0},i;try{await Gx(t.add({file:e}),e=>(i=e,r(e)))}catch(e){if(this._attachmentAddOperations.isCancelled(n))return;throw i&&r({...i,status:{type:`incomplete`,reason:`error`,message:e instanceof Error?e.message:String(e)}}),this._safeEmitAttachmentAddError(`adapter-error`,e instanceof Error?e.message:String(e),i?.id,e instanceof Error?e:void 0),e}finally{this._attachmentAddOperations.finish(n)}this._attachmentAddOperations.isCancelled(n)||(i?.status.type===`incomplete`&&i.status.reason===`error`?this._safeEmitAttachmentAddError(`adapter-error`,i.status.message??`Attachment upload did not complete successfully.`,i.id):this._notifyEventSubscribers(`attachmentAdd`,{}))}_safeEmitAttachmentAddError(e,t,n,r){try{this._notifyEventSubscribers(`attachmentAddError`,{reason:e,message:t,...n!==void 0&&{attachmentId:n},...r!==void 0&&{error:r}})}catch(e){console.error(`[assistant-ui] attachmentAddError subscriber threw:`,e)}}async removeAttachment(e){let t=this._attachments.findIndex(t=>t.id===e);if(t===-1)throw Error(`Attachment not found`);let n=this._attachments[t];if(this._cancelAttachmentAdd(e),this._isSending&&this._removedDuringSend.add(e),!Kx(n)){let t=this.getAttachmentAdapter();if(!t)throw Error(`Attachments are not supported`);try{await t.remove(n)}catch(t){let n=t instanceof Error?t.message:String(t);throw this._attachments=this._attachments.map(t=>t.id===e&&!Kx(t)?{...t,status:{type:`incomplete`,reason:`error`,message:n}}:t),this._notifySubscribers(),t}}this._attachments=this._attachments.filter(t=>t.id!==e),this._notifySubscribers()}_dictation;_dictationSession;_dictationUnsubscribes=[];_dictationBaseText=``;_currentInterimText=``;_dictationSessionIdCounter=0;_activeDictationSessionId;_isCleaningDictation=!1;get dictation(){return this._dictation}_isActiveSession(e,t){return this._activeDictationSessionId===e&&this._dictationSession===t}startDictation(){let e=this.getDictationAdapter();if(!e)throw Error(`Dictation adapter not configured`);if(this._dictationSession){for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession.stop().catch(()=>{}),this._dictationSession=void 0}let t=e.disableInputDuringDictation??!1;this._dictationBaseText=this._text,this._currentInterimText=``;let n=e.listen();this._dictationSession=n;let r=++this._dictationSessionIdCounter;this._activeDictationSessionId=r,this._dictation={status:n.status,inputDisabled:t},this._notifySubscribers();let i=n.onSpeech(e=>{if(!this._isActiveSession(r,n))return;let t=e.isFinal!==!1,i=this._dictationBaseText&&!this._dictationBaseText.endsWith(` `)&&e.transcript?` `:``;if(t){if(this._dictationBaseText=this._dictationBaseText+i+e.transcript,this._currentInterimText=``,this._text=this._dictationBaseText,this._dictation){let{transcript:e,...t}=this._dictation;this._dictation=t}this._notifySubscribers()}else this._currentInterimText=i+e.transcript,this._text=this._dictationBaseText+this._currentInterimText,this._dictation&&={...this._dictation,transcript:e.transcript},this._notifySubscribers()});this._dictationUnsubscribes.push(i);let a=n.onSpeechStart(()=>{this._isActiveSession(r,n)&&(this._dictation={status:{type:`running`},inputDisabled:t,...this._dictation?.transcript&&{transcript:this._dictation.transcript}},this._notifySubscribers())});this._dictationUnsubscribes.push(a);let o=n.onSpeechEnd(()=>{this._cleanupDictation({sessionId:r})});this._dictationUnsubscribes.push(o);let s=setInterval(()=>{this._isActiveSession(r,n)&&n.status.type===`ended`&&this._cleanupDictation({sessionId:r})},100);this._dictationUnsubscribes.push(()=>clearInterval(s))}stopDictation(){if(!this._dictationSession)return;let e=this._dictationSession,t=this._activeDictationSessionId,n=()=>this._cleanupDictation({sessionId:t});e.stop().then(n,n)}_cleanupDictation(e){if(!(e?.sessionId!==void 0&&e.sessionId!==this._activeDictationSessionId||this._isCleaningDictation)){this._isCleaningDictation=!0;try{for(let e of this._dictationUnsubscribes)e();this._dictationUnsubscribes=[],this._dictationSession=void 0,this._activeDictationSessionId=void 0,this._dictation=void 0,this._dictationBaseText=``,this._currentInterimText=``,this._notifySubscribers()}finally{this._isCleaningDictation=!1}}}_eventSubscribers=new Map;_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&Xh(n,t,`Composer runtime "${e}"`)}unstable_on(e,t){let n=t,r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Jx=e=>e.capabilities?.cancel?mx(e):!1,Yx=class extends qx{get canCancel(){return Jx(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??zx,t=this.runtime.getQueueItems?.()??zx,n=this._queueCache;if(n&&n.steer===e&&n.queue===t)return n.flat;let r=e.length===0?t:t.length===0?e:[...e,...t];return this._queueCache={steer:e,queue:t,flat:r},r}moveQueueItem(e,t){this.runtime.moveQueueItem?.(e,t)}removeQueueItem(e){this.runtime.removeQueueItem?.(e)}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}runtime;constructor(e){super(),this.runtime=e,this.connect()}connect(){let e=!1,t=this.runtime.isSendDisabled,n=this.queue;return this.runtime.subscribe(()=>{let r=!1,i=this.canCancel;e!==i&&(e=i,r=!0),t!==this.runtime.isSendDisabled&&(t=this.runtime.isSendDisabled,r=!0),n!==this.queue&&(n=this.queue,r=!0),r&&this._notifySubscribers()})}async handleSend(e,t){return this.runtime.append({...e,parentId:this.runtime.messages.at(-1)?.id??null,sourceId:null,startRun:t?.startRun,steer:t?.steer})}async handleCancel(){this.runtime.cancelRun()}},Xx=class extends qx{get canCancel(){return!0}get canSend(){return!this.isEmpty&&!this._isSending}getAttachmentAdapter(){return this.runtime.adapters?.attachments}getDictationAdapter(){return this.runtime.adapters?.dictation}_nonTextPassthrough;_parentId;_sourceId;runtime;endEditCallback;constructor(e,t,{parentId:n,message:r}){super(),this.runtime=e,this.endEditCallback=t,this._parentId=n,this._sourceId=r.id,this.setText(ax(r)),this.setRole(r.role);let i;r.role===`user`?(i=[...r.attachments??[],...Hx(r.content)],this._nonTextPassthrough=[]):(i=r.attachments??[],this._nonTextPassthrough=r.content.filter(e=>e.type!==`text`)),this.setAttachments(i),this.setRunConfig({...e.composer.runConfig})}get parentId(){return this._parentId}get sourceId(){return this._sourceId}async handleSend(e,t){let n=this._nonTextPassthrough.length>0?[...e.content,...this._nonTextPassthrough]:e.content,r=this.runtime.append({...e,content:n,parentId:this._parentId,sourceId:this._sourceId,startRun:t?.startRun});return this.handleCancel(),r}handleCancel(){this.endEditCallback(),this._notifySubscribers()}},Zx=class extends eg{_isInitialized=!1;repository=new Rx;_voiceMessages=[];_voiceGeneration=0;_cachedMergedMessages=null;_cachedVoiceGeneration=-1;_cachedMergedBase=null;_markVoiceMessagesDirty(){this._voiceGeneration++,this._cachedMergedMessages=null}_getBaseMessages(){return this.repository.getMessages()}get messages(){if(this._voiceMessages.length===0)return this._getBaseMessages();let e=this._getBaseMessages();return(this._cachedVoiceGeneration!==this._voiceGeneration||this._cachedMergedBase!==e)&&(this._cachedMergedMessages=[...e,...this._voiceMessages],this._cachedVoiceGeneration=this._voiceGeneration,this._cachedMergedBase=e),this._cachedMergedMessages}get state(){let e;for(let t of this.messages)t.role===`assistant`&&(e=t);return e?.metadata.unstable_state??null}composer=new Yx(this);_contextProvider;constructor(e){super(),this._contextProvider=e}getModelContext(){return this._contextProvider.getModelContext()}enrichAppendMetadata(e,t=e.parentId){if(e.role!==`user`)return e;let n=this.messages,r=t===null?-1:n.findIndex(e=>e.id===t),i=sy(this.getModelContext().unstable_composerMetadata,n.slice(0,r+1));return i?{...e,metadata:{...e.metadata,custom:{...e.metadata?.custom,...i}}}:e}_editComposers=new Map;getEditComposer(e){return this._editComposers.get(e)}beginEdit(e){if(this._editComposers.has(e))throw Error(`Edit already in progress`);this._editComposers.set(e,new Xx(this,()=>this._editComposers.delete(e),this.repository.getMessage(e))),this._notifySubscribers()}getMessageById(e){try{return this.repository.getMessage(e)}catch{let t=this.repository.getMessages(),n=this._voiceMessages.findIndex(t=>t.id===e);return n===-1?void 0:{parentId:n>0?this._voiceMessages[n-1].id:t.at(-1)?.id??null,message:this._voiceMessages[n],index:t.length+n}}}getBranches(e){return this._voiceMessages.some(t=>t.id===e)?[]:this.repository.getBranches(e)}switchToBranch(e){this.repository.switchToBranch(e),this._notifySubscribers()}_notifyEventSubscribers(e,t){let n=this._eventSubscribers.get(e);n&&Xh(n,t,`Thread runtime "${e}"`)}submitFeedback({messageId:e,type:t}){let n=this.adapters?.feedback;if(!n)throw Error(`Feedback adapter not configured`);let{message:r,parentId:i}=this.repository.getMessage(e);if(n.submit({message:r,type:t}),r.role===`assistant`){let e={...r,metadata:{...r.metadata,submittedFeedback:{type:t}}};this.repository.addOrUpdateMessage(i,e)}this._notifySubscribers()}_stopSpeaking;speech;speak(e){let t=this.adapters?.speech;if(!t)throw Error(`Speech adapter not configured`);let{message:n}=this.repository.getMessage(e);this._stopSpeaking?.();let r=t.speak(ax(n)),i=r.subscribe(()=>{r.status.type===`ended`?(this._stopSpeaking=void 0,this.speech=void 0):this.speech={messageId:e,status:r.status},this._notifySubscribers()});this.speech={messageId:e,status:r.status},this._notifySubscribers(),this._stopSpeaking=()=>{r.cancel(),i(),this.speech=void 0,this._stopSpeaking=void 0}}stopSpeaking(){if(!this._stopSpeaking)throw Error(`No message is being spoken`);this._stopSpeaking(),this._notifySubscribers()}_voiceSession;_voiceUnsubs=[];voice;_voiceVolume=0;_voiceVolumeSubscribers=new Set;getVoiceVolume=()=>this._voiceVolume;subscribeVoiceVolume=e=>(this._voiceVolumeSubscribers.add(e),()=>this._voiceVolumeSubscribers.delete(e));connectVoice(){let e=this.adapters?.voice;if(!e)throw Error(`Voice adapter not configured`);this.disconnectVoice();let t=e.connect({});this._voiceSession=t;let n=[],r=`listening`;this.voice={status:t.status,isMuted:t.isMuted,mode:r},this._voiceVolume=0,this._notifySubscribers(),n.push(t.onStatusChange(e=>{e.type===`ended`?(this._finishVoiceAssistantMessage(),this._voiceSession=void 0,this.voice=void 0):this.voice={status:e,isMuted:t.isMuted,mode:r},this._notifySubscribers()})),n.push(t.onModeChange(e=>{r=e,this.voice&&(this.voice={...this.voice,mode:e},this._notifySubscribers())})),n.push(t.onVolumeChange(e=>{this._voiceVolume=e,Xh(this._voiceVolumeSubscribers,void 0,`Voice volume`)})),n.push(t.onTranscript(e=>{this._handleVoiceTranscript(e)})),this._voiceUnsubs=n}_currentAssistantMsg=null;_handleVoiceTranscript(e){if(this.ensureInitialized(),e.role===`user`)this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null,e.isFinal&&(this._voiceMessages.push({id:$y(),role:`user`,content:[{type:`text`,text:e.text}],metadata:{custom:{}},createdAt:new Date,status:{type:`complete`,reason:`unknown`},attachments:[]}),this._markVoiceMessagesDirty(),this._notifySubscribers());else{if(!this._currentAssistantMsg)this._currentAssistantMsg={id:$y(),role:`assistant`,content:[{type:`text`,text:e.text}],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},status:{type:`running`},createdAt:new Date},this._voiceMessages.push(this._currentAssistantMsg);else{let t=this._voiceMessages.indexOf(this._currentAssistantMsg);if(t===-1)return;let n={...this._currentAssistantMsg,content:[{type:`text`,text:e.text}],...e.isFinal?{status:{type:`complete`,reason:`stop`}}:{}};this._voiceMessages[t]=n,this._currentAssistantMsg=n}e.isFinal&&(this._currentAssistantMsg=null),this._markVoiceMessagesDirty(),this._notifySubscribers()}}_finishVoiceAssistantMessage(){let e=this._voiceMessages.at(-1);if(e?.role===`assistant`&&e.status.type===`running`){let t=this._voiceMessages.length-1;this._voiceMessages[t]={...e,status:{type:`complete`,reason:`stop`}},this._markVoiceMessagesDirty(),this._notifySubscribers()}}disconnectVoice(){this._finishVoiceAssistantMessage(),this._currentAssistantMsg=null;for(let e of this._voiceUnsubs)e();this._voiceUnsubs=[],this._voiceSession?.disconnect(),this._voiceSession=void 0,this.voice=void 0,this._voiceVolume=0,Xh(this._voiceVolumeSubscribers,void 0,`Voice volume`),this._voiceMessages=[],this._markVoiceMessagesDirty(),this._notifySubscribers()}muteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.mute(),this.voice={...this.voice,isMuted:!0},this._notifySubscribers()}unmuteVoice(){if(!this._voiceSession)throw Error(`No active voice session`);this._voiceSession.unmute(),this.voice={...this.voice,isMuted:!1},this._notifySubscribers()}ensureInitialized(){this._isInitialized||(this._isInitialized=!0,this._notifyEventSubscribers(`initialize`,{}))}export(){return this.repository.export()}import(e){this.ensureInitialized(),this.repository.clear(),this.repository.import(e),this._notifySubscribers()}reset(e){this.import(Fx.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>n({}))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&n({})}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},Qx=Symbol.for(`assistant-stream.tool-execution-id`),$x=e=>{try{return JSON.parse(e),!0}catch{return!1}},eS=e=>{try{return JSON.parse(e)}catch{return}},tS=(e,t)=>{let n=eS(e),r=eS(t);return n===void 0||r===void 0?!1:Jv(n,r)},nS=e=>e[Qx],rS=class{_getTools;_callbacks;_entries=new Map;_humanInput=new Map;_executing=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t){this._getTools=e,this._callbacks=t,this._initPipeline()}_initPipeline(){let[e,t]=Ny();this._controller=t;let n=Mb(()=>this._getWrappedTools(),()=>this._ac.signal,(e,t,n)=>this._onHumanInput(e,t,n),{onExecutionStart:(e,t,n)=>this._onExecutionStart(e,n),onExecutionEnd:(e,t,n)=>this._onExecutionEnd(e,n)});e.pipeThrough(n).pipeThrough(new Oy).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let e=new Set(this._executing);return new Promise(t=>{this._settledResolvers.push({executionIds:e,resolve:t})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=nS(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=nS(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=nS(e),r=this._entries.get(t);!r||r.executionId!==n||r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}})}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_hasExecutableTool(e){let t=this._getTools()?.[e];return t?.execute!==void 0||t?.streamCall!==void 0}_shouldCloseArgsStream({toolName:e,argsText:t,hasResult:n}){return n?!0:(this._hasExecutableTool(e)||!this._isRunning)&&$x(t)}_startActiveEntry(e,t,n){let r={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1};return this._entries.set(e,r),r}_demoteEntriesToRestored(){for(let[e,t]of this._entries)t.controller&&this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)tS(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if($x(e.argsText)&&$x(t.argsText)&&tS(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({toolName:t.toolName,argsText:t.argsText,hasResult:n});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({toolName:t.toolName,argsText:e.argsText,hasResult:n})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let n of e)if(!(!n||!Array.isArray(n.content)))for(let e of n.content){if(!e||e.type!==`tool-call`)continue;let n=this._entries.get(e.toolCallId);if(t){n?.controller||this._entries.set(e.toolCallId,{toolName:e.toolName,argsText:e.argsText,hasResult:e.result!==void 0}),e.messages&&this._processMessages(e.messages);continue}let r=n;if(r&&!r.controller){if(e.argsText===r.argsText&&e.result!==void 0===r.hasResult){e.messages&&this._processMessages(e.messages);continue}this._entries.delete(e.toolCallId),r=void 0}if(r||=this._startActiveEntry(e.toolCallId,e.toolName,e.result!==void 0),e.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,e),e.result!==void 0&&!r.hasResult){let{controller:t}=r;if(!t)continue;r.hasResult=!0,r.argsComplete=!0,t.setResponse(new by({result:e.result,artifact:e.artifact,isError:e.isError,...e.modelContent===void 0?{}:{modelContent:e.modelContent}})),t.close()}e.messages&&this._processMessages(e.messages)}}},iS=Object.freeze([]),aS=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},oS=(e,t)=>{let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0},sS=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,cS=class extends Zx{_capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};get capabilities(){return this._capabilities}_messages;isDisabled;isSendDisabled;get isLoading(){return this._store.isLoading??!1}get isRunning(){return this._hasExecutingTools(this._store)?!0:this._store.isRunning}_getBaseMessages(){return this._messages}get state(){return this._store.state??super.state}get adapters(){return this._store.adapters}get unstable_refetchThread(){if(this._store.onRefetchThread)return()=>this._store.onRefetchThread()}suggestions=[];extras=void 0;_converter=new Qy;_pendingDeleteEvictions=new Set;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e);n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let i=e.suggestions??iS;oS(this.suggestions,i)||(this.suggestions=i);let a={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};oS(this._capabilities,a)||(this._capabilities=a);let o;if(e.messageRepository){if(n&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,a=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&n.messageRepository===e.messageRepository)this.repository.resetHead(a),o=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(a),o=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new Qy;else if(n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}o=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${Zy}${i}`;if(t&&(t.role!==`assistant`||!db(t.status)||t.status===pb(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return Yy(e,n),e}return t}let s=e.convertMessage(n,i),c=rb(s,o,pb(s.content,a,r));return Yy(c,n),c}):e.messages;let i=new Set,a=[];for(let e=o.length-1;e>=0;e--){let t=o[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),a.push(t)}a.length!==o.length&&(o=a.reverse());for(let e=0;e<o.length;e++){let t=o[e],n=o[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(o.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);o.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let s=null;sS(r,o)&&(s=$y(),this.repository.addOrUpdateMessage(o.at(-1)?.id??null,rb({role:`assistant`,content:[],metadata:{isOptimistic:!0}},s,{type:`running`}))),this.repository.resetHead(s??o.at(-1)?.id??null),this._messages=this.repository.getMessages(),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new rS(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;aS(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}}),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();let e=t=>{for(let n of t)if(Array.isArray(n.content))for(let t of n.content)!t||t.type!==`tool-call`||(this._toolCallToMessageId.set(t.toolCallId,n.id),t.messages&&e(t.messages))};e(this._messages),this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t=e.sourceId!=null||e.parentId!==(this.messages.at(-1)?.id??null),n=!t&&this._store.queue&&this._store.queue===this._transformedQueue?e:this.enrichAppendMetadata(e),r=wx(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!t&&this._store.queue){if(i&&await i,!Tx(this,r))return;n.steer??this._getEffectiveIsRunning(this._store)?this._store.queue.steer(n):this._store.queue.enqueue(n);return}if(i?.catch(()=>{}),(n.startRun??n.role===`user`)&&await this._toolInvocations?.abort(),Tx(this,r)){if(t){if(!this._store.onEdit)throw Error(`Runtime does not support editing messages.`);this._pendingDeleteEvictions.clear(),await this._store.onEdit(n)}else await this._store.onNew(n)}}async deleteMessage(e){if(this._store.onDelete){this.repository.getMessages().some(t=>t.id===e)&&this._pendingDeleteEvictions.add(e);try{await this._store.onDelete(e)}catch(t){throw this._pendingDeleteEvictions.delete(e),t}return}if(!this._store.setMessages)throw Error(`Runtime does not support deleting messages.`);this._getEffectiveIsRunning(this._store)&&await this._toolInvocations?.abort();let t=this.repository.getMessages();if(t.findIndex(t=>t.id===e)===-1)throw Error(`Message not found.`);this._pendingDeleteEvictions.clear(),this.updateMessages(t.filter(t=>t.id!==e)),this._evictDeletedMessage(e)}_evictDeletedMessage(e){if(!e.startsWith(`__external_store_fallback_`)){try{this.repository.getMessage(e)}catch{return}this.repository.deleteMessage(e),this._messages=this.repository.getMessages(),this._notifySubscribers()}}getQueueItems(){return this._store?.queue?.items??zx}getSteerQueueItems(){return this._store?.queue?.steerItems??zx}moveQueueItem(e,t){this._store?.queue?.move(e,t)}removeQueueItem(e){this._store?.queue?.remove(e)}async startRun(e){if(!this._store.onReload)throw Error(`Runtime does not support reloading messages.`);this._pendingDeleteEvictions.clear(),await this._toolInvocations?.abort(),await this._store.onReload(e.parentId,e)}async resumeRun(e){if(!this._store.onResume)throw Error(`Runtime does not support resuming runs.`);await this._store.onResume(e)}exportExternalState(){if(!this._store.onExportExternalState)throw Error(`Runtime does not support exporting external states.`);return this._store.onExportExternalState()}importExternalState(e){if(!this._store.onLoadExternalState)throw Error(`Runtime does not support importing external states.`);this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.onLoadExternalState(e)}unstable_notifySessionReset(){this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._store.queue?.__internal_notifyCancelled?.()}cancelRun(){if(!this._store.onCancel)throw Error(`Runtime does not support cancelling runs.`);let e=wx(this);this._toolInvocations?.abort(),this._store.queue?.__internal_notifyCancelled?.(),aS(`onCancel`,this._store.onCancel()),this.dropEmptyOptimisticHead();let t=this.repository.getMessages(),n=t[t.length-1],r=this._store.setMessages!==void 0&&n?.role===`user`&&n.id===t.at(-1)?.id&&n.content.every(e=>e.type===`text`)?n:void 0,i;if(r){let e={text:ax(r),attachments:r.attachments,quote:r.metadata.custom.quote};this.composer.restoreDraft(e)&&(this.repository.deleteMessage(r.id),i={id:r.id,draft:e})}i||this._notifySubscribers(),setTimeout(()=>{if(Tx(this,e)){if(this.dropEmptyOptimisticHead(),i){let e=this.repository.getMessages();e.at(-1)?.id===i.id?this.repository.deleteMessage(i.id):e.some(e=>e.id===i.id)&&this.composer.retractDraft(i.draft)}this.updateMessages(this.repository.getMessages())}},0)}dropEmptyOptimisticHead(){let e=this.repository.getMessages().at(-1);e&&e.metadata.isOptimistic&&e.content.length===0&&this.repository.deleteMessage(e.id)}addToolResult(e){if(!this._store.onAddToolResult)throw Error(`Runtime does not support tool results.`);aS(`onAddToolResult`,this._store.onAddToolResult(e))}resumeToolCall(e){if(!(this._toolInvocations?.resume(e.toolCallId,e.payload)??!1)){if(this._store.onResumeToolCall){this._store.onResumeToolCall(e);return}throw Error(`Tool call ${e.toolCallId} is not waiting for resume.`)}}respondToToolApproval(e){if(!this._store.onRespondToToolApproval)throw Error(`Runtime does not support tool approvals.`);aS(`onRespondToToolApproval`,this._store.onRespondToToolApproval(e))}reset(e){let t=new Rx;t.import(Fx.fromArray(e??[])),this.updateMessages(t.getMessages())}import(e){super.import(e),this._store.onImport&&this._store.onImport(this.repository.getMessages())}updateMessages=e=>{this._store.convertMessage===void 0?this._store.setMessages?.(e):this._store.setMessages?.(e.flatMap(Xy))}},lS=e=>e.adapters?.threadList??{},uS=class extends Dx{threads;constructor(e){super(),this.threads=new Px(lS(e),()=>new cS(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(lS(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},dS=e=>{let t=Rp(15),n;t[0]===e?n=t[1]:(n=()=>new uS(e),t[0]=e,t[1]=n);let[r]=Im(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>{Ex(r.threads.getMainThreadRuntimeCore())},t[2]=r.threads,t[3]=i);let a;t[4]===r?a=t[5]:(a=[r],t[4]=r,t[5]=a),Vm(i,a);let o;t[6]!==r||t[7]!==e?(o=()=>{r.setAdapter(e)},t[6]=r,t[7]=e,t[8]=o):o=t[8],Vm(o);let{modelContext:s}=Gy()??{},c,l;t[9]!==s||t[10]!==r?(c=()=>{if(s)return r.registerModelContextProvider(s)},l=[s,r],t[9]=s,t[10]=r,t[11]=c,t[12]=l):(c=t[11],l=t[12]),Vm(c,l);let u;return t[13]===r?u=t[14]:(u=new Sx(r),t[13]=r,t[14]=u),u},fS=e=>{let t=Rp(5),{isDisabled:n,isSendDisabled:r,unstable_capabilities:i,suggestions:a}=e,o;return t[0]!==n||t[1]!==r||t[2]!==a||t[3]!==i?(o={isDisabled:n,isSendDisabled:r,unstable_capabilities:i,suggestions:a},t[0]=n,t[1]=r,t[2]=a,t[3]=i,t[4]=o):o=t[4],o},pS=e=>{let t=Symbol(`${e} extras`),n=e=>typeof e==`object`&&!!e&&t in e;return{provide:e=>(Object.defineProperty(e,t,{value:!0,enumerable:!1,configurable:!0}),e),is:n,tryGet:e=>n(e)?e:void 0,assert:t=>{if(!n(t))throw Error(`The current thread is not backed by the ${e} runtime.`);return t}}},mS=e=>{let{provide:t,is:n,tryGet:r,assert:i}=e,a=e=>i(e.thread.getState().extras);function o(e,...t){let r=t.length>0,a=t[0];return H_(t=>{let o=t.thread.extras;return n(o)?e?e(o):o:r?a:i(o)})}return{provide:t,is:n,tryGet:r,get:a,use:o}},hS=e=>mS(pS(e)),gS=`ui://`,_S=e=>!!e?.startsWith(gS),vS=e=>{let t=[...e.content,...(e.attachments??[]).flatMap(e=>(e.content??[]).filter(e=>e.type!==`text`))],n=[];for(let e of t)e.type===`file`||e.type===`text`?n.push(e):e.type===`image`&&n.push({type:`file`,data:e.image,mimeType:`image/*`,...e.filename!==void 0&&{filename:e.filename}});return n},yS=e=>{let t={queue:zx,steer:zx},n=new Map,r=new Set,i=!1,a=!1,o=e=>e,s=0,c=0,l=!1,u=()=>{Xh(r,void 0,`Message queue`)},d=e=>{t=e,C.items=e.queue,C.steerItems=e.steer,u()},f=(e,t)=>({id:e,prompt:ax(t),parts:vS(t)}),p=e=>{if(t.steer.some(t=>t.id===e))return`steer`;if(t.queue.some(t=>t.id===e))return`queue`},m=()=>{if(i||a)return;let r=t.steer.length>0?`steer`:`queue`,s=t[r][0];if(!s)return;let c=n.get(s.id);n.delete(s.id),d({...t,[r]:t[r].slice(1)}),c&&(i=!0,e.run(o(c),{steer:!1}))},h=t=>{a=!1,s+=Math.max(c,1),c=0,l=!0;try{e.cancel()}finally{l=!1}i=!0,e.run(o(t),{steer:!0})},g=(e,r)=>{a=!1;let i=$y();n.set(i,r),d({...t,[e]:[...t[e],f(i,r)]}),m()},_=e=>{g(`queue`,e)},v=t=>{if(i&&e.cancel){h(t);return}g(`steer`,t)},y=(r,a)=>{let o=p(r);if(!o)throw Error(`Unknown queue item "${r}".`);let s=a.lane??o,c=t[o].find(e=>e.id===r),l=(s===o?t[o]:t[s]).filter(e=>e.id!==r),u=e=>{if(e===r)throw Error(`Queue item "${r}" cannot anchor itself.`);let t=l.findIndex(t=>t.id===e);if(t===-1)throw Error(`Unknown anchor "${e}" in lane "${s}".`);return t},{insertAfter:f,insertBefore:g}=a,_;if(f===void 0&&g===void 0)_=s===o?t[o].findIndex(e=>e.id===r):l.length;else if(f!==void 0&&g!==void 0){let e=f===null?-1:u(f);if((g===null?l.length:u(g))!==e+1)throw Error(`insertAfter "${f}" and insertBefore "${g}" are not adjacent in lane "${s}".`);_=e+1}else _=f===void 0?g===null?l.length:u(g):f===null?0:u(f)+1;if(f===void 0&&g===void 0&&s===`steer`&&o!==`steer`&&i&&e.cancel){let e=n.get(r);n.delete(r),d({queue:t.queue.filter(e=>e.id!==r),steer:t.steer}),h(e);return}let v=[...l.slice(0,_),c,...l.slice(_)],y={...t,[s]:v};s!==o&&(y[o]=t[o].filter(e=>e.id!==r)),d(y),m()},b=(e,r)=>{let i=p(e);if(!i)throw Error(`Unknown queue item "${e}".`);n.set(e,r),d({...t,[i]:t[i].map(t=>t.id===e?f(e,r):t)})},x=e=>{n.delete(e)&&d({queue:t.queue.filter(t=>t.id!==e),steer:t.steer.filter(t=>t.id!==e)})},S=()=>{l||i&&c===0&&(a=!0,c=1)},C={items:t.queue,steerItems:t.steer,enqueue:_,steer:v,move:y,edit:b,remove:x,__internal_setDispatchTransform:e=>{o=e},__internal_notifyCancelled:S};return{adapter:C,notifyBusy:()=>{a=!1,s+=c,c=0,i=!0},notifyIdle:()=>{if(s>0){s--;return}c>0&&c--,i=!1,m()},notifyCancelled:S,clear:()=>{n.clear(),d({queue:zx,steer:zx})},subscribe:e=>(r.add(e),()=>{r.delete(e)})}};function bS(e,t){function n(n){let r=Zm(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function xS(e,t){function n(n){let r=e(n);return r?r[t]:null}function r(e){let t=!1,r;typeof e==`function`?r=e:e&&typeof e==`object`&&(t=!!e.optional,r=e.selector);let i=n({optional:t});return i?r?i(r):i():null}return{[t]:r,[`${t}Store`]:n}}var SS=Ym(null),{useThreadViewport:CS,useThreadViewportStore:wS}=xS(bS(SS,`ThreadPrimitive.Viewport`),`useThreadViewport`),TS=e=>{let t=new Map,n=()=>{let n=0;for(let e of t.values())n+=e;e(n)};return{register:()=>{let e=Symbol();return t.set(e,0),{setHeight:r=>{t.get(e)!==r&&(t.set(e,r),n())},unregister:()=>{t.delete(e),n()}}}}},ES=(e={})=>{let t=new Set,n=TS(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=TS(e=>{a.setState({height:{...a.getState().height,inset:e}})}),i=(e,t)=>(a.setState({element:{...a.getState().element,[e]:t}}),()=>{a.getState().element[e]===t&&a.setState({element:{...a.getState().element,[e]:null}})}),a=Uv(()=>({isAtBottom:!0,scrollToBottom:({behavior:e=`auto`}={})=>{for(let n of t)n({behavior:e})},onScrollToBottom:e=>(t.add(e),()=>{t.delete(e)}),turnAnchor:e.turnAnchor??`bottom`,topAnchorMessageClamp:{tallerThan:e.topAnchorMessageClamp?.tallerThan??`10em`,visibleHeight:e.topAnchorMessageClamp?.visibleHeight??`6em`},height:{viewport:0,inset:0},element:{viewport:null,anchor:null,target:null},targetConfig:null,topAnchorTurn:null,registerViewport:n.register,registerContentInset:r.register,registerViewportElement:e=>i(`viewport`,e),registerAnchorElement:e=>i(`anchor`,e),registerAnchorTargetElement:(e,t)=>(a.setState({element:{...a.getState().element,target:e},targetConfig:e&&t?t:null}),()=>{a.getState().element.target===e&&a.setState({element:{...a.getState().element,target:null},targetConfig:null})}),setTopAnchorTurn:e=>{a.setState({topAnchorTurn:e})}}));return a},DS=e=>e,OS=e=>{let t=Rp(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=wS(n),i;t[1]===e?i=t[2]:(i=()=>ES(e),t[1]=e,t[2]=i);let[a]=Im(i),o,s;t[3]!==r||t[4]!==a?(o=()=>r?.getState().onScrollToBottom(()=>{a.getState().scrollToBottom()}),s=[r,a],t[3]=r,t[4]=a,t[5]=o,t[6]=s):(o=t[5],s=t[6]),Vm(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&DS(r).setState({isAtBottom:e.isAtBottom})})},l=[a,r],t[7]=r,t[8]=a,t[9]=c,t[10]=l):(c=t[9],l=t[10]),Vm(c,l),a},kS=e=>{let t=Rp(7),{children:n,options:r}=e,i;t[0]===r?i=t[1]:(i=r===void 0?{}:r,t[0]=r,t[1]=i);let a=OS(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=Im(o),c;return t[4]!==n||t[5]!==s?(c=(0,X.jsx)(SS.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},AS=()=>{let e=Rp(3),t=I_(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),Vm(n,r),null},jS=Jm(e=>{let t=Rp(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(AS,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,X.jsx)(kS,{children:n}),t[1]=n,t[2]=c);let l;return t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==c?(l=(0,X.jsxs)(Lv,{runtime:a,aui:o,config:i,children:[s,c]}),t[3]=i,t[4]=a,t[5]=o,t[6]=c,t[7]=l):l=t[7],l}),MS=Object.defineProperty,NS=(e,t)=>MS(e,`name`,{value:t,configurable:!0});function PS(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}NS(PS,`setRef`);function FS(...e){return t=>{let n=!1,r=e.map(e=>{let r=PS(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():PS(e[t],null)}}}}NS(FS,`composeRefs`);function IS(...e){return S.useCallback(FS(...e),e)}NS(IS,`useComposedRefs`);var LS=Object.defineProperty,RS=(e,t)=>LS(e,`name`,{value:t,configurable:!0});function zS(e){let t=S.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];JS(r)&&typeof QS==`function`&&(r=QS(r._payload)),S.Children.forEach(r,e=>{if(KS(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;JS(n)&&typeof QS==`function`&&(n=QS(n._payload)),a=US(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=S.cloneElement(a,void 0,s):!o&&S.Children.count(r)===1&&S.isValidElement(r)&&(a=r);let c=a?GS(a):void 0,l=IS(n,c);if(!a){if(r||r===0)throw Error(o?ZS(e):XS(e));return r}let u=WS(i,a.props??{});return a.type!==S.Fragment&&(u.ref=n?l:c),S.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}RS(zS,`createSlot`);var BS=zS(`Slot`),VS=Symbol.for(`radix.slottable`);function HS(e){let t=RS(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=VS,t}RS(HS,`createSlottable`);var US=RS((e,t)=>{if(`child`in e.props){let t=e.props.child;return S.isValidElement(t)?S.cloneElement(t,void 0,e.props.children(t.props.children)):null}return S.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function WS(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}RS(WS,`mergeProps`);function GS(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}RS(GS,`getElementRef`);function KS(e){return S.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===VS}RS(KS,`isSlottable`);var qS=Symbol.for(`react.lazy`);function JS(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===qS&&`_payload`in e&&YS(e._payload)}RS(JS,`isLazyComponent`);function YS(e){return typeof e==`object`&&!!e&&`then`in e}RS(YS,`isPromiseLike`);var XS=RS(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),ZS=RS(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),QS=S.use,$S=l(h(),1),eC=Object.defineProperty,tC=(e,t)=>eC(e,`name`,{value:t,configurable:!0}),nC=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=zS(`Primitive.${t}`),r=S.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,X.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function rC(e,t){e&&$S.flushSync(()=>e.dispatchEvent(t))}tC(rC,`dispatchDiscreteCustomEvent`);var iC=Object.defineProperty,aC=(e,t)=>iC(e,`name`,{value:t,configurable:!0});function oC(e,t){let n=S.createContext(t);n.displayName=e+`Context`;let r=aC(e=>{let{children:t,...r}=e,i=S.useMemo(()=>r,Object.values(r));return(0,X.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=S.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return aC(i,`useContext`),[r,i]}aC(oC,`createContext`);function sC(e,t=[]){let n=[];function r(t,r){let i=S.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=aC(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=S.useMemo(()=>o,Object.values(o));return(0,X.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=S.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return aC(s,`useContext`),[o,s]}aC(r,`createContext`);let i=aC(()=>{let t=n.map(e=>S.createContext(e));return aC(function(n){let r=n?.[e]||t;return S.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,cC(i,...t)]}aC(sC,`createContextScope`);function cC(...e){let t=e[0];if(e.length===1)return t;let n=aC(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return aC(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return S.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}aC(cC,`composeContextScopes`);var lC=Object.defineProperty,uC=(e,t)=>lC(e,`name`,{value:t,configurable:!0});function dC(e){let t=e+`CollectionProvider`,[n,r]=sC(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=uC(e=>{let{scope:t,children:n}=e,r=S.useRef(null),a=S.useRef(new Map).current;return(0,X.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=zS(s),l=S.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=IS(t,a(s,n).collectionRef);return(0,X.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=zS(u),p=S.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=S.useRef(null),s=IS(t,o),c=a(u,n);return S.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,X.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return S.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return uC(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}uC(dC,`createCollection`);var fC=new WeakMap,pC=class e extends Map{static{uC(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],fC.set(this,!0)}set(e,t){return fC.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=gC(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t!==void 0&&this.delete(t)}at(e){let t=mC(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=mC(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return mC(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function mC(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=hC(e,t);return n===-1?void 0:e[n]}uC(mC,`at`);function hC(e,t){let n=e.length,r=gC(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}uC(hC,`toSafeIndex`);function gC(e){return e!==e||e===0?0:Math.trunc(e)}uC(gC,`toSafeInteger`);function _C(e){let t=e+`CollectionProvider`,[n,r]=sC(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new pC,setItemMap:uC(()=>void 0,`setItemMap`)}),o=uC(({state:e,...t})=>e?(0,X.jsx)(c,{...t,state:e}):(0,X.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=uC(e=>{let t=h();return(0,X.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=uC(e=>{let{scope:t,children:n,state:r}=e,a=S.useRef(null),[o,s]=S.useState(null),c=IS(a,s),[l,u]=r;return S.useEffect(()=>{if(!o)return;let e=xC(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,X.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=zS(l),d=S.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=IS(t,a(l,n).collectionRef);return(0,X.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=zS(f),m=S.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=S.useRef(null),[s,c]=S.useState(null),l=IS(t,o,c),{setItemMap:u}=a(f,n),d=S.useRef(i);vC(d.current,i)||(d.current=i);let m=d.current;return S.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(bC):(t.set(s,{...e,element:s}),t.toSorted(bC)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new pC(e)))}},[s,m,u]),(0,X.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return S.useState(new pC)}uC(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return uC(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}uC(_C,`createCollection`);function vC(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}uC(vC,`shallowEqual`);function yC(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}uC(yC,`isElementPreceding`);function bC(e,t){return!e[1].element||!t[1].element?0:yC(e[1].element,t[1].element)?-1:1}uC(bC,`sortByDocumentPosition`);function xC(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}uC(xC,`getChildListObserver`);var SC=Object.defineProperty,CC=(e,t)=>SC(e,`name`,{value:t,configurable:!0}),wC=!!(typeof window<`u`&&window.document&&window.document.createElement);function TC(e,t,{checkForDefaultPrevented:n=!0}={}){return CC(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}CC(TC,`composeEventHandlers`);function EC(e){if(!wC)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}CC(EC,`getOwnerWindow`);function DC(e){if(!wC)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}CC(DC,`getOwnerDocument`);function OC(e,t=!1){let{activeElement:n}=DC(e);if(!n?.nodeName)return null;if(kC(n)&&n.contentDocument)return OC(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=DC(n).getElementById(e);if(t)return t}}return n}CC(OC,`getActiveElement`);function kC(e){return e.tagName===`IFRAME`}CC(kC,`isFrame`);var AC=Object.defineProperty,jC=(e,t)=>AC(e,`name`,{value:t,configurable:!0});function MC(e){let t=S.useRef(e);return S.useEffect(()=>{t.current=e}),S.useMemo(()=>((...e)=>t.current?.(...e)),[])}jC(MC,`useCallbackRef`);var NC=Object.defineProperty,PC=(e,t)=>NC(e,`name`,{value:t,configurable:!0}),FC=`dismissableLayer.update`,IC=`dismissableLayer.pointerDownOutside`,LC=`dismissableLayer.focusOutside`,RC,zC=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),BC=S.forwardRef(PC(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=S.useContext(zC),[d,f]=S.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=S.useState({}),h=IS(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,C=S.useRef(!1),w=UC(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:C,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:S.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),ee=WC(e=>{if(r&&C.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),te=d?y===g.length-1:!1,ne=MC(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return S.useEffect(()=>{if(te)return p.addEventListener(`keydown`,ne,{capture:!0}),()=>p.removeEventListener(`keydown`,ne,{capture:!0})},[p,te,ne]),S.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(RC=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),GC(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=RC))}},[d,p,n,u]),S.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),GC())},[d,u]),S.useEffect(()=>{let e=PC(()=>m({}),`handleUpdate`);return document.addEventListener(FC,e),()=>document.removeEventListener(FC,e)},[]),(0,X.jsx)(nC.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:TC(e.onFocusCapture,ee.onFocusCapture),onBlurCapture:TC(e.onBlurCapture,ee.onBlurCapture),onPointerDownCapture:TC(e.onPointerDownCapture,w.onPointerDownCapture)})},`DismissableLayer`));function VC(){let e=S.useContext(zC),[t,n]=S.useState(null);return S.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}PC(VC,`useDismissableLayerSurface`);var HC=PC(()=>!0,`IS_TRUE`);function UC(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=HC}=t,s=MC(e),c=S.useRef(!1),l=S.useRef(!1),u=S.useRef(new Map),d=S.useRef(()=>{});return S.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}PC(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}PC(t,`isOutsideInteractionIntercepted`);function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}PC(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}PC(p,`handleInteractionBubble`);let m=PC(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||KC(IC,s,p,{discrete:!0})};if(PC(f,`handleAndDispatchPointerDownOutsideEvent`),!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},`handlePointerDown`),h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:PC(()=>c.current=!0,`onPointerDownCapture`)}}PC(UC,`usePointerDownOutside`);function WC(e,t=globalThis?.document){let n=MC(e),r=S.useRef(!1);return S.useEffect(()=>{let e=PC(e=>{e.target&&!r.current&&KC(LC,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:PC(()=>r.current=!0,`onFocusCapture`),onBlurCapture:PC(()=>r.current=!1,`onBlurCapture`)}}PC(WC,`useFocusOutside`);function GC(){let e=new CustomEvent(FC);document.dispatchEvent(e)}PC(GC,`dispatchUpdate`);function KC(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?rC(i,a):i.dispatchEvent(a)}PC(KC,`handleAndDispatchCustomEvent`);var qC=Object.defineProperty,JC=(e,t)=>qC(e,`name`,{value:t,configurable:!0}),YC=0,XC=null;function ZC(e){return QC(),e.children}JC(ZC,`FocusGuards`);function QC(){S.useEffect(()=>{XC||={start:$C(),end:$C()};let{start:e,end:t}=XC;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),YC++,()=>{YC===1&&(XC?.start.remove(),XC?.end.remove(),XC=null),YC=Math.max(0,YC-1)}},[])}JC(QC,`useFocusGuards`);function $C(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}JC($C,`createFocusGuard`);var ew=Object.defineProperty,tw=(e,t)=>ew(e,`name`,{value:t,configurable:!0}),nw=`focusScope.autoFocusOnMount`,rw=`focusScope.autoFocusOnUnmount`,iw={bubbles:!1,cancelable:!0},aw=S.forwardRef(tw(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=S.useState(null),l=MC(i),u=MC(a),d=S.useRef(null),f=IS(t,c),p=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:fw(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||fw(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&fw(s)};tw(e,`handleFocusIn`),tw(t,`handleFocusOut`),tw(n,`handleMutations`),document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),S.useEffect(()=>{if(s){pw.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(nw,iw);s.addEventListener(nw,l),s.dispatchEvent(t),t.defaultPrevented||(ow(gw(cw(s)),{select:!0}),document.activeElement===e&&fw(s))}return()=>{s.removeEventListener(nw,l),setTimeout(()=>{let t=new CustomEvent(rw,iw);s.addEventListener(rw,u),s.dispatchEvent(t),t.defaultPrevented||fw(e??document.body,{select:!0}),s.removeEventListener(rw,u),pw.remove(p)},0)}}},[s,l,u,p]);let m=S.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=sw(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&fw(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&fw(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,X.jsx)(nC.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function ow(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(fw(r,{select:t}),document.activeElement!==n)return}tw(ow,`focusFirst`);function sw(e){let t=cw(e);return[lw(t,e),lw(t.reverse(),e)]}tw(sw,`getTabbableEdges`);function cw(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:tw(e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}tw(cw,`getTabbableCandidates`);function lw(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):uw(r,{upTo:t})))return r}tw(lw,`findVisible`);function uw(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}tw(uw,`isHidden`);function dw(e){return e instanceof HTMLInputElement&&`select`in e}tw(dw,`isSelectableInput`);function fw(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&dw(e)&&t&&e.select()}}tw(fw,`focus`);var pw=mw();function mw(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=hw(e,t),e.unshift(t)},remove(t){e=hw(e,t),e[0]?.resume()}}}tw(mw,`createFocusScopesStack`);function hw(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}tw(hw,`arrayRemove`);function gw(e){return e.filter(e=>e.tagName!==`A`)}tw(gw,`removeLinks`);var _w=Object.defineProperty,vw=(e,t)=>_w(e,`name`,{value:t,configurable:!0}),yw=S.createContext(void 0);function bw(e){let t=S.useContext(yw);return e||t||`ltr`}vw(bw,`useDirection`);var xw=globalThis?.document?S.useLayoutEffect:()=>{},Sw=Object.defineProperty,Cw=(e,t)=>Sw(e,`name`,{value:t,configurable:!0}),ww=S.useId||(()=>void 0),Tw=0;function Ew(e){let[t,n]=S.useState(ww());return xw(()=>{e||n(e=>e??String(Tw++))},[e]),e||(t?`radix-${t}`:``)}Cw(Ew,`useId`);var Dw=Object.defineProperty,Ow=S.forwardRef(((e,t)=>Dw(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=S.useState(!1);xw(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?$S.createPortal((0,X.jsx)(nC.div,{...r,ref:t}),o):null},`Portal`)),kw=Object.defineProperty,Aw=(e,t)=>kw(e,`name`,{value:t,configurable:!0});function jw(e,t){return S.useReducer((e,n)=>t[e][n]??e,e)}Aw(jw,`useStateMachine`);var Mw=Aw(e=>{let{present:t,children:n}=e,r=Nw(t),i=typeof n==`function`?n({present:r.isPresent}):S.Children.only(n),a=Fw(r.ref,Lw(i));return typeof n==`function`||r.isPresent?S.cloneElement(i,{ref:a}):null},`Presence`);function Nw(e){let[t,n]=S.useState(),r=S.useRef(null),i=S.useRef(e),a=S.useRef(`none`),o=S.useRef(void 0),[s,c]=jw(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return S.useEffect(()=>{s===`mounted`?(a.current=o.current??Iw(r.current),o.current=void 0):a.current=`none`},[s]),xw(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=Iw(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),xw(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=Aw(a=>{let o=Iw(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},`handleAnimationEnd`),s=Aw(e=>{e.target===t&&(a.current=Iw(r.current))},`handleAnimationStart`);return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:S.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=Iw(t)}else r.current=null;n(e)},[])}}Aw(Nw,`usePresence`);function Pw(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Aw(Pw,`setRef`);function Fw(...e){let t=S.useRef(e);return t.current=e,S.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=Pw(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():Pw(n[e],null)}}},[])}Aw(Fw,`useStableComposedRefs`);function Iw(e){return e?.animationName||`none`}Aw(Iw,`getAnimationName`);function Lw(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}Aw(Lw,`getElementRef`);var Rw=Object.defineProperty,zw=(e,t)=>Rw(e,`name`,{value:t,configurable:!0}),Bw=S.useEffectEvent,Vw=S.useInsertionEffect;function Hw(e){if(typeof Bw==`function`)return Bw(e);let t=S.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof Vw==`function`?Vw(()=>{t.current=e}):xw(()=>{t.current=e}),S.useMemo(()=>((...e)=>t.current?.(...e)),[])}zw(Hw,`useEffectEvent`);var Uw=Object.defineProperty,Ww=(e,t)=>Uw(e,`name`,{value:t,configurable:!0}),Gw=S.useInsertionEffect||xw;function Kw({prop:e,defaultProp:t,onChange:n=Ww(()=>{},`onChange`),caller:r}){let[i,a,o]=qw({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,S.useCallback(t=>{if(s){let n=Jw(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}Ww(Kw,`useControllableState`);function qw({defaultProp:e,onChange:t}){let[n,r]=S.useState(e),i=S.useRef(n),a=S.useRef(t);return Gw(()=>{a.current=t},[t]),S.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}Ww(qw,`useUncontrolledState`);function Jw(e){return typeof e==`function`}Ww(Jw,`isFunction`);var Yw=Symbol(`RADIX:SYNC_STATE`);function Xw(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=Hw(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=S.useReducer((t,n)=>{if(n.type===Yw)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=S.useRef(p);S.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=S.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return S.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:Yw,state:i})},[i,d.state,c]),[h,f]}Ww(Xw,`useControllableStateReducer`);var Zw=Object.defineProperty,Qw=(e,t)=>Zw(e,`name`,{value:t,configurable:!0}),$w=!1;function eT(){let[e,t]=S.useState($w);return S.useEffect(()=>{$w||($w=!0,t(!0))},[]),e}Qw(eT,`useIsHydrated`);var tT=S.useSyncExternalStore;function nT(){return()=>{}}Qw(nT,`subscribe`);function rT(){return tT(nT,()=>!0,()=>!1)}Qw(rT,`useIsHydratedModern`);var iT=typeof tT==`function`?rT:eT,aT=Object.defineProperty,oT=(e,t)=>aT(e,`name`,{value:t,configurable:!0}),sT=`rovingFocusGroup.onEntryFocus`,cT={bubbles:!1,cancelable:!0},lT=`RovingFocusGroup`,[uT,dT,fT]=dC(lT),[pT,mT]=sC(lT,[fT]),[hT,gT]=pT(lT),_T=S.forwardRef(oT(function(e,t){return(0,X.jsx)(uT.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(uT.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,X.jsx)(vT,{...e,ref:t})})})},`RovingFocusGroup`)),vT=S.forwardRef(oT(function(e,t){let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=S.useRef(null),p=IS(t,f),m=bw(a),[h,g]=Kw({prop:o,defaultProp:s??null,onChange:c,caller:lT}),[_,v]=S.useState(!1),y=MC(l),b=dT(n),x=S.useRef(!1),[C,w]=S.useState(0);return S.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(sT,y),()=>e.removeEventListener(sT,y)},[y]),(0,X.jsx)(hT,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:S.useCallback(e=>g(e),[g]),onItemShiftTab:S.useCallback(()=>v(!0),[]),onFocusableItemAdd:S.useCallback(()=>w(e=>e+1),[]),onFocusableItemRemove:S.useCallback(()=>w(e=>e-1),[]),children:(0,X.jsx)(nC.div,{tabIndex:_||C===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:TC(e.onMouseDown,()=>{x.current=!0}),onFocus:TC(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(sT,cT);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);wT([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:TC(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),yT=`RovingFocusGroupItem`,bT=S.forwardRef(oT(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=Ew(),l=a||c,u=gT(yT,n),d=u.currentTabStopId===l,f=dT(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=iT();return xw(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),S.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,X.jsx)(uT.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,X.jsx)(nC.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:TC(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:TC(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:TC(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=CT(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?TT(n,r+1):n.slice(r+1)}setTimeout(()=>wT(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),xT={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ST(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}oT(ST,`getDirectionAwareKey`);function CT(e,t,n){let r=ST(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return xT[r]}oT(CT,`getFocusIntent`);function wT(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}oT(wT,`focusFirst`);function TT(e,t){return e.map((n,r)=>e[(t+r)%e.length])}oT(TT,`wrapArray`);var ET=_T,DT=bT,OT=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},kT=new WeakMap,AT=new WeakMap,jT={},MT=0,NT=function(e){return e&&(e.host||NT(e.parentNode))},PT=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=NT(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},FT=function(e,t,n,r){var i=PT(t,Array.isArray(e)?e:[e]);jT[n]||(jT[n]=new WeakMap);var a=jT[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(kT.get(e)||0)+1,l=(a.get(e)||0)+1;kT.set(e,c),a.set(e,l),o.push(e),c===1&&i&&AT.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),MT++,function(){o.forEach(function(e){var t=kT.get(e)-1,i=a.get(e)-1;kT.set(e,t),a.set(e,i),t||(AT.has(e)||e.removeAttribute(r),AT.delete(e)),i||e.removeAttribute(n)}),MT--,MT||(kT=new WeakMap,kT=new WeakMap,AT=new WeakMap,jT={})}},IT=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||OT(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),FT(r,i,n,`aria-hidden`)):function(){return null}},LT=`right-scroll-bar-position`,RT=`width-before-scroll-bar`,zT=`with-scroll-bars-hidden`,BT=`--removed-body-scroll-bar-size`;function VT(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function HT(e,t){var n=(0,S.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var UT=typeof window<`u`?S.useLayoutEffect:S.useEffect,WT=new WeakMap;function GT(e,t){var n=HT(t||null,function(t){return e.forEach(function(e){return VT(e,t)})});return UT(function(){var t=WT.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||VT(e,null)}),i.forEach(function(e){r.has(e)||VT(e,a)})}WT.set(n,e)},[e]),n}function KT(e){return e}function qT(e,t){t===void 0&&(t=KT);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function JT(e){e===void 0&&(e={});var t=qT(null);return t.options=Ro({async:!0,ssr:!1},e),t}var YT=function(e){var t=e.sideCar,n=zo(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return S.createElement(r,Ro({},n))};YT.isSideCarExport=!0;function XT(e,t){return e.useMedium(t),YT}var ZT=JT(),QT=function(){},$T=S.forwardRef(function(e,t){var n=S.useRef(null),r=S.useState({onScrollCapture:QT,onWheelCapture:QT,onTouchMoveCapture:QT}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=zo(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,C=GT([n,t]),w=Ro(Ro({},b),i);return S.createElement(S.Fragment,null,u&&S.createElement(x,{sideCar:ZT,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?S.cloneElement(S.Children.only(s),Ro(Ro({},w),{ref:C})):S.createElement(v,Ro({},w,{className:c,ref:C}),s))});$T.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},$T.classNames={fullWidth:RT,zeroRight:LT};var eE=function(){if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function tE(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=eE();return t&&e.setAttribute(`nonce`,t),e}function nE(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function rE(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var iE=function(){var e=0,t=null;return{add:function(n){e==0&&(t=tE())&&(nE(t,n),rE(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},aE=function(){var e=iE();return function(t,n){S.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},oE=function(){var e=aE();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},sE={left:0,top:0,right:0,gap:0},cE=function(e){return parseInt(e||``,10)||0},lE=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[cE(n),cE(r),cE(i)]},uE=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return sE;var t=lE(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},dE=oE(),fE=`data-scroll-locked`,pE=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
|
|
23
|
+
.${zT} {
|
|
24
|
+
overflow: hidden ${r};
|
|
25
|
+
padding-right: ${s}px ${r};
|
|
26
|
+
}
|
|
27
|
+
body[${fE}] {
|
|
28
|
+
overflow: hidden ${r};
|
|
29
|
+
overscroll-behavior: contain;
|
|
30
|
+
${[t&&`position: relative ${r};`,n===`margin`&&`
|
|
31
|
+
padding-left: ${i}px;
|
|
32
|
+
padding-top: ${a}px;
|
|
33
|
+
padding-right: ${o}px;
|
|
34
|
+
margin-left:0;
|
|
35
|
+
margin-top:0;
|
|
36
|
+
margin-right: ${s}px ${r};
|
|
37
|
+
`,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.${LT} {
|
|
41
|
+
right: ${s}px ${r};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.${RT} {
|
|
45
|
+
margin-right: ${s}px ${r};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.${LT} .${LT} {
|
|
49
|
+
right: 0 ${r};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.${RT} .${RT} {
|
|
53
|
+
margin-right: 0 ${r};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
body[${fE}] {
|
|
57
|
+
${BT}: ${s}px;
|
|
58
|
+
}
|
|
59
|
+
`},mE=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},hE=function(){S.useEffect(function(){return document.body.setAttribute(fE,(mE()+1).toString()),function(){var e=mE()-1;e<=0?document.body.removeAttribute(fE):document.body.setAttribute(fE,e.toString())}},[])},gE=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;hE();var a=S.useMemo(function(){return uE(i)},[i]);return S.createElement(dE,{styles:pE(a,!t,i,n?``:`!important`)})},_E=!1;if(typeof window<`u`)try{var vE=Object.defineProperty({},"passive",{get:function(){return _E=!0,!0}});window.addEventListener(`test`,vE,vE),window.removeEventListener(`test`,vE,vE)}catch{_E=!1}var yE=_E?{passive:!1}:!1,bE=function(e){return e.tagName===`TEXTAREA`},xE=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!bE(e)&&n[t]===`visible`)},SE=function(e){return xE(e,`overflowY`)},CE=function(e){return xE(e,`overflowX`)},wE=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),DE(e,r)){var i=OE(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},TE=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},EE=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},DE=function(e,t){return e===`v`?SE(t):CE(t)},OE=function(e,t){return e===`v`?TE(t):EE(t)},kE=function(e,t){return e===`h`&&t===`rtl`?-1:1},AE=function(e,t,n,r,i){var a=kE(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=OE(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&DE(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},jE=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},ME=function(e){return[e.deltaX,e.deltaY]},NE=function(e){return e&&`current`in e?e.current:e},PE=function(e,t){return e[0]===t[0]&&e[1]===t[1]},FE=function(e){return`
|
|
60
|
+
.block-interactivity-${e} {pointer-events: none;}
|
|
61
|
+
.allow-interactivity-${e} {pointer-events: all;}
|
|
62
|
+
`},IE=0,LE=[];function RE(e){var t=S.useRef([]),n=S.useRef([0,0]),r=S.useRef(),i=S.useState(IE++)[0],a=S.useState(oE)[0],o=S.useRef(e);S.useEffect(function(){o.current=e},[e]),S.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=Wo([e.lockRef.current],(e.shards||[]).map(NE),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=S.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=jE(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=wE(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=wE(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return AE(h,t,e,h===`h`?s:c,!0)},[]),c=S.useCallback(function(e){var n=e;if(!(!LE.length||LE[LE.length-1]!==a)){var r=`deltaY`in n?ME(n):jE(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&PE(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(NE).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=S.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:zE(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=S.useCallback(function(e){n.current=jE(e),r.current=void 0},[]),d=S.useCallback(function(t){l(t.type,ME(t),t.target,s(t,e.lockRef.current))},[]),f=S.useCallback(function(t){l(t.type,jE(t),t.target,s(t,e.lockRef.current))},[]);S.useEffect(function(){return LE.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,yE),document.addEventListener(`touchmove`,c,yE),document.addEventListener(`touchstart`,u,yE),function(){LE=LE.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,yE),document.removeEventListener(`touchmove`,c,yE),document.removeEventListener(`touchstart`,u,yE)}},[]);var p=e.removeScrollBar,m=e.inert;return S.createElement(S.Fragment,null,m?S.createElement(a,{styles:FE(i)}):null,p?S.createElement(gE,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function zE(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var BE=XT(ZT,RE),VE=S.forwardRef(function(e,t){return S.createElement($T,Ro({},e,{ref:t,sideCar:BE}))});VE.classNames=$T.classNames;var HE=Object.defineProperty,UE=(e,t)=>HE(e,`name`,{value:t,configurable:!0}),WE=`Dialog`,[GE,KE]=sC(WE),[qE,JE]=GE(WE),YE=UE(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=S.useRef(null),c=S.useRef(null),[l,u]=Kw({prop:r,defaultProp:i??!1,onChange:a,caller:WE}),[d,f]=S.useState(0),[p,m]=S.useState(0);return(0,X.jsx)(qE,{scope:t,triggerRef:s,contentRef:c,contentId:Ew(),titleId:Ew(),descriptionId:Ew(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:S.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),XE=`DialogPortal`,[ZE,QE]=GE(XE,{forceMount:void 0}),$E=UE(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=JE(XE,t);return(0,X.jsx)(ZE,{scope:t,forceMount:n,children:S.Children.map(r,e=>(0,X.jsx)(Mw,{present:n||a.open,children:(0,X.jsx)(Ow,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),eD=`DialogOverlay`,tD=S.forwardRef(UE(function(e,t){let n=QE(eD,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=JE(eD,e.__scopeDialog);return a.modal?(0,X.jsx)(Mw,{present:r||a.open,children:(0,X.jsx)(rD,{...i,ref:t})}):null},`DialogOverlay`)),nD=zS(`DialogOverlay.RemoveScroll`),rD=S.forwardRef(UE(function(e,t){let{__scopeDialog:n,...r}=e,i=JE(eD,n),a=IS(t,VC());return(0,X.jsx)(VE,{as:nD,allowPinchZoom:!0,shards:[i.contentRef],children:(0,X.jsx)(nC.div,{"data-state":hD(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),iD=`DialogContent`,aD=S.forwardRef(UE(function(e,t){let n=QE(iD,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=JE(iD,e.__scopeDialog);return(0,X.jsx)(Mw,{present:r||a.open,children:a.modal?(0,X.jsx)(oD,{...i,ref:t}):(0,X.jsx)(sD,{...i,ref:t})})},`DialogContent`)),oD=S.forwardRef(UE(function(e,t){let n=JE(iD,e.__scopeDialog),r=S.useRef(null),i=IS(t,n.contentRef,r);return S.useEffect(()=>{let e=r.current;if(e)return IT(e)},[]),(0,X.jsx)(cD,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:TC(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:TC(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:TC(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),sD=S.forwardRef(UE(function(e,t){let n=JE(iD,e.__scopeDialog),r=S.useRef(!1),i=S.useRef(!1);return(0,X.jsx)(cD,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`DialogContentNonModal`)),cD=S.forwardRef(UE(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=JE(iD,n);return QC(),(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(aw,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,X.jsx)(BC,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":hD(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),lD=`DialogTitle`,uD=S.forwardRef(UE(function(e,t){let{__scopeDialog:n,...r}=e,i=JE(lD,n),{setTitleCount:a}=i;return xw(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,X.jsx)(nC.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),dD=`DialogDescription`,fD=S.forwardRef(UE(function(e,t){let{__scopeDialog:n,...r}=e,i=JE(dD,n),{setDescriptionCount:a}=i;return xw(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,X.jsx)(nC.p,{id:i.descriptionId,...r,ref:t})},`DialogDescription`)),pD=`DialogClose`,mD=S.forwardRef(UE(function(e,t){let{__scopeDialog:n,...r}=e,i=JE(pD,n);return(0,X.jsx)(nC.button,{type:`button`,...r,ref:t,onClick:TC(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function hD(e){return e?`open`:`closed`}UE(hD,`getState`);var gD=Object.defineProperty,_D=(e,t)=>gD(e,`name`,{value:t,configurable:!0});function vD(e,[t,n]){return Math.min(n,Math.max(t,e))}_D(vD,`clamp`);var yD=Object.defineProperty,bD=(e,t)=>yD(e,`name`,{value:t,configurable:!0});function xD(e,t){return S.useReducer((e,n)=>t[e][n]??e,e)}bD(xD,`useStateMachine`);var SD=`ScrollArea`,[CD,wD]=sC(SD),[TD,ED]=CD(SD),DD=S.forwardRef(bD(function(e,t){let{__scopeScrollArea:n,type:r=`hover`,dir:i,scrollHideDelay:a=600,...o}=e,[s,c]=S.useState(null),[l,u]=S.useState(null),[d,f]=S.useState(null),[p,m]=S.useState(null),[h,g]=S.useState(null),[_,v]=S.useState(0),[y,b]=S.useState(0),[x,C]=S.useState(!1),[w,ee]=S.useState(!1),te=IS(t,c),ne=bw(i);return(0,X.jsx)(TD,{scope:n,type:r,dir:ne,scrollHideDelay:a,scrollArea:s,viewport:l,onViewportChange:u,content:d,onContentChange:f,scrollbarX:p,onScrollbarXChange:m,scrollbarXEnabled:x,onScrollbarXEnabledChange:C,scrollbarY:h,onScrollbarYChange:g,scrollbarYEnabled:w,onScrollbarYEnabledChange:ee,onCornerWidthChange:v,onCornerHeightChange:b,children:(0,X.jsx)(nC.div,{dir:ne,...o,ref:te,style:{position:`relative`,"--radix-scroll-area-corner-width":_+`px`,"--radix-scroll-area-corner-height":y+`px`,...e.style}})})},`ScrollArea`)),OD=`ScrollAreaViewport`,kD=S.forwardRef(bD(function(e,t){let{__scopeScrollArea:n,children:r,nonce:i,...a}=e,o=ED(OD,n),s=IS(t,S.useRef(null),o.onViewportChange);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(AD,{nonce:i}),(0,X.jsx)(nC.div,{"data-radix-scroll-area-viewport":``,...a,ref:s,style:{overflowX:o.scrollbarXEnabled?`scroll`:`hidden`,overflowY:o.scrollbarYEnabled?`scroll`:`hidden`,...e.style},children:(0,X.jsx)(`div`,{ref:o.onContentChange,style:{minWidth:`100%`,display:`table`},children:r})})]})},`ScrollAreaViewport`)),AD=S.memo(bD(function({nonce:e}){return(0,X.jsx)(`style`,{dangerouslySetInnerHTML:{__html:`[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}`},nonce:e})},`ScrollAreaViewportStyle`),(e,t)=>e.nonce===t.nonce),jD=`ScrollAreaScrollbar`,MD=S.forwardRef(bD(function(e,t){let{forceMount:n,...r}=e,i=ED(jD,e.__scopeScrollArea),{onScrollbarXEnabledChange:a,onScrollbarYEnabledChange:o}=i,s=e.orientation===`horizontal`;return S.useEffect(()=>(s?a(!0):o(!0),()=>{s?a(!1):o(!1)}),[s,a,o]),i.type===`hover`?(0,X.jsx)(ND,{...r,ref:t,forceMount:n}):i.type===`scroll`?(0,X.jsx)(PD,{...r,ref:t,forceMount:n}):i.type===`auto`?(0,X.jsx)(FD,{...r,ref:t,forceMount:n}):i.type===`always`?(0,X.jsx)(ID,{...r,ref:t,"data-state":`visible`}):null},`ScrollAreaScrollbar`)),ND=S.forwardRef(bD(function(e,t){let{forceMount:n,...r}=e,i=ED(jD,e.__scopeScrollArea),[a,o]=S.useState(!1);return S.useEffect(()=>{let e=i.scrollArea,t=0;if(e){let n=bD(()=>{window.clearTimeout(t),o(!0)},`handlePointerEnter`),r=bD(()=>{t=window.setTimeout(()=>o(!1),i.scrollHideDelay)},`handlePointerLeave`);return e.addEventListener(`pointerenter`,n),e.addEventListener(`pointerleave`,r),()=>{window.clearTimeout(t),e.removeEventListener(`pointerenter`,n),e.removeEventListener(`pointerleave`,r)}}},[i.scrollArea,i.scrollHideDelay]),(0,X.jsx)(Mw,{present:n||a,children:(0,X.jsx)(FD,{"data-state":a?`visible`:`hidden`,...r,ref:t})})},`ScrollAreaScrollbarHover`)),PD=S.forwardRef(bD(function(e,t){let{forceMount:n,...r}=e,i=ED(jD,e.__scopeScrollArea),a=e.orientation===`horizontal`,o=nO(()=>c(`SCROLL_END`),100),[s,c]=xD(`hidden`,{hidden:{SCROLL:`scrolling`},scrolling:{SCROLL_END:`idle`,POINTER_ENTER:`interacting`},interacting:{SCROLL:`interacting`,POINTER_LEAVE:`idle`},idle:{HIDE:`hidden`,SCROLL:`scrolling`,POINTER_ENTER:`interacting`}});return S.useEffect(()=>{if(s===`idle`){let e=window.setTimeout(()=>c(`HIDE`),i.scrollHideDelay);return()=>window.clearTimeout(e)}},[s,i.scrollHideDelay,c]),S.useEffect(()=>{let e=i.viewport,t=a?`scrollLeft`:`scrollTop`;if(e){let n=e[t],r=bD(()=>{let r=e[t];n!==r&&(c(`SCROLL`),o()),n=r},`handleScroll`);return e.addEventListener(`scroll`,r),()=>e.removeEventListener(`scroll`,r)}},[i.viewport,a,c,o]),(0,X.jsx)(Mw,{present:n||s!==`hidden`,children:(0,X.jsx)(ID,{"data-state":s===`hidden`?`hidden`:`visible`,...r,ref:t,onPointerEnter:TC(e.onPointerEnter,()=>c(`POINTER_ENTER`)),onPointerLeave:TC(e.onPointerLeave,()=>c(`POINTER_LEAVE`))})})},`ScrollAreaScrollbarScroll`)),FD=S.forwardRef(bD(function(e,t){let n=ED(jD,e.__scopeScrollArea),{forceMount:r,...i}=e,[a,o]=S.useState(!1),s=e.orientation===`horizontal`,c=nO(()=>{if(n.viewport){let e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;o(s?e:t)}},10);return rO(n.viewport,c),rO(n.content,c),(0,X.jsx)(Mw,{present:r||a,children:(0,X.jsx)(ID,{"data-state":a?`visible`:`hidden`,...i,ref:t})})},`ScrollAreaScrollbarAuto`)),ID=S.forwardRef(bD(function(e,t){let{orientation:n=`vertical`,...r}=e,i=ED(jD,e.__scopeScrollArea),a=S.useRef(null),o=S.useRef(0),[s,c]=S.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),l=YD(s.viewport,s.content),u={...r,sizes:s,onSizesChange:c,hasThumb:l>0&&l<1,onThumbChange:bD(e=>a.current=e,`onThumbChange`),onThumbPointerUp:bD(()=>o.current=0,`onThumbPointerUp`),onThumbPointerDown:bD(e=>o.current=e,`onThumbPointerDown`)};function d(e,t){return ZD(e,o.current,s,t)}return bD(d,`getScrollPosition`),n===`horizontal`?(0,X.jsx)(LD,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollLeft,t=QD(e,s,i.dir);a.current.style.transform=`translate3d(${t}px, 0, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollLeft=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollLeft=d(e,i.dir))}}):n===`vertical`?(0,X.jsx)(RD,{...u,ref:t,onThumbPositionChange:()=>{if(i.viewport&&a.current){let e=i.viewport.scrollTop,t=QD(e,s);a.current.style.transform=`translate3d(0, ${t}px, 0)`}},onWheelScroll:e=>{i.viewport&&(i.viewport.scrollTop=e)},onDragScroll:e=>{i.viewport&&(i.viewport.scrollTop=d(e))}}):null},`ScrollAreaScrollbarVisible`)),LD=S.forwardRef(bD(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=ED(jD,e.__scopeScrollArea),[o,s]=S.useState(),c=S.useRef(null),l=IS(t,c,a.onScrollbarXChange);return S.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,X.jsx)(VD,{"data-orientation":`horizontal`,...i,ref:l,sizes:n,style:{bottom:0,left:a.dir===`rtl`?`var(--radix-scroll-area-corner-width)`:0,right:a.dir===`ltr`?`var(--radix-scroll-area-corner-width)`:0,"--radix-scroll-area-thumb-width":XD(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),eO(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollWidth,viewport:a.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:JD(o.paddingLeft),paddingEnd:JD(o.paddingRight)}})}})},`ScrollAreaScrollbarX`)),RD=S.forwardRef(bD(function(e,t){let{sizes:n,onSizesChange:r,...i}=e,a=ED(jD,e.__scopeScrollArea),[o,s]=S.useState(),c=S.useRef(null),l=IS(t,c,a.onScrollbarYChange);return S.useEffect(()=>{c.current&&s(getComputedStyle(c.current))},[c]),(0,X.jsx)(VD,{"data-orientation":`vertical`,...i,ref:l,sizes:n,style:{top:0,right:a.dir===`ltr`?0:void 0,left:a.dir===`rtl`?0:void 0,bottom:`var(--radix-scroll-area-corner-height)`,"--radix-scroll-area-thumb-height":XD(n)+`px`,...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(a.viewport){let r=a.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),eO(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&a.viewport&&o&&r({content:a.viewport.scrollHeight,viewport:a.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:JD(o.paddingTop),paddingEnd:JD(o.paddingBottom)}})}})},`ScrollAreaScrollbarY`)),[zD,BD]=CD(jD),VD=S.forwardRef(bD(function(e,t){let{__scopeScrollArea:n,sizes:r,hasThumb:i,onThumbChange:a,onThumbPointerUp:o,onThumbPointerDown:s,onThumbPositionChange:c,onDragScroll:l,onWheelScroll:u,onResize:d,...f}=e,p=ED(jD,n),[m,h]=S.useState(null),g=IS(t,h),_=S.useRef(null),v=S.useRef(``),y=p.viewport,b=r.content-r.viewport,x=MC(u),C=MC(c),w=nO(d,10);function ee(e){if(_.current){let t=e.clientX-_.current.left,n=e.clientY-_.current.top;l({x:t,y:n})}}return bD(ee,`handleDragScroll`),S.useEffect(()=>{let e=bD(e=>{let t=e.target;m?.contains(t)&&x(e,b)},`handleWheel`);return document.addEventListener(`wheel`,e,{passive:!1}),()=>document.removeEventListener(`wheel`,e,{passive:!1})},[y,m,b,x]),S.useEffect(C,[r,C]),rO(m,w),rO(p.content,w),(0,X.jsx)(zD,{scope:n,scrollbar:m,hasThumb:i,onThumbChange:MC(a),onThumbPointerUp:MC(o),onThumbPositionChange:C,onThumbPointerDown:MC(s),children:(0,X.jsx)(nC.div,{...f,ref:g,style:{position:`absolute`,...f.style},onPointerDown:TC(e.onPointerDown,e=>{e.button===0&&(e.target.setPointerCapture(e.pointerId),_.current=m.getBoundingClientRect(),v.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect=`none`,p.viewport&&(p.viewport.style.scrollBehavior=`auto`),ee(e))}),onPointerMove:TC(e.onPointerMove,ee),onPointerUp:TC(e.onPointerUp,e=>{let t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=v.current,p.viewport&&(p.viewport.style.scrollBehavior=``),_.current=null})})})},`ScrollAreaScrollbarImpl`)),HD=`ScrollAreaThumb`,UD=S.forwardRef(bD(function(e,t){let{forceMount:n,...r}=e,i=BD(HD,e.__scopeScrollArea);return(0,X.jsx)(Mw,{present:n||i.hasThumb,children:(0,X.jsx)(WD,{ref:t,...r})})},`ScrollAreaThumb`)),WD=S.forwardRef(bD(function(e,t){let{__scopeScrollArea:n,style:r,...i}=e,a=ED(HD,n),o=BD(HD,n),{onThumbPositionChange:s}=o,c=IS(t,o.onThumbChange),l=S.useRef(void 0),u=nO(()=>{l.current&&=(l.current(),void 0)},100);return S.useEffect(()=>{let e=a.viewport;if(e){let t=bD(()=>{if(u(),!l.current){let t=tO(e,s);l.current=t,s()}},`handleScroll`);return s(),e.addEventListener(`scroll`,t),()=>e.removeEventListener(`scroll`,t)}},[a.viewport,u,s]),(0,X.jsx)(nC.div,{"data-state":o.hasThumb?`visible`:`hidden`,...i,ref:c,style:{width:`var(--radix-scroll-area-thumb-width)`,height:`var(--radix-scroll-area-thumb-height)`,...r},onPointerDownCapture:TC(e.onPointerDownCapture,e=>{let t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;o.onThumbPointerDown({x:n,y:r})}),onPointerUp:TC(e.onPointerUp,o.onThumbPointerUp)})},`ScrollAreaThumbImpl`)),GD=`ScrollAreaCorner`,KD=S.forwardRef(bD(function(e,t){let n=ED(GD,e.__scopeScrollArea),r=!!(n.scrollbarX&&n.scrollbarY);return n.type!==`scroll`&&r?(0,X.jsx)(qD,{...e,ref:t}):null},`ScrollAreaCorner`)),qD=S.forwardRef(bD(function(e,t){let{__scopeScrollArea:n,...r}=e,i=ED(GD,n),[a,o]=S.useState(0),[s,c]=S.useState(0),l=!!(a&&s),{onCornerWidthChange:u,onCornerHeightChange:d}=i;return rO(i.scrollbarX,()=>{let e=i.scrollbarX?.offsetHeight||0;i.onCornerHeightChange(e),c(e)}),rO(i.scrollbarY,()=>{let e=i.scrollbarY?.offsetWidth||0;i.onCornerWidthChange(e),o(e)}),S.useEffect(()=>()=>{u(0),d(0)},[u,d]),l?(0,X.jsx)(nC.div,{...r,ref:t,style:{width:a,height:s,position:`absolute`,right:i.dir===`ltr`?0:void 0,left:i.dir===`rtl`?0:void 0,bottom:0,...e.style}}):null},`ScrollAreaCornerImpl`));function JD(e){return e?parseInt(e,10):0}bD(JD,`toInt`);function YD(e,t){let n=e/t;return isNaN(n)?0:n}bD(YD,`getThumbRatio`);function XD(e){let t=YD(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}bD(XD,`getThumbSize`);function ZD(e,t,n,r=`ltr`){let i=XD(n),a=i/2,o=t||a,s=i-o,c=n.scrollbar.paddingStart+o,l=n.scrollbar.size-n.scrollbar.paddingEnd-s,u=n.content-n.viewport,d=r===`ltr`?[0,u]:[u*-1,0];return $D([c,l],d)(e)}bD(ZD,`getScrollPositionFromPointer`);function QD(e,t,n=`ltr`){let r=XD(t),i=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-i,o=t.content-t.viewport,s=a-r,c=vD(e,n===`ltr`?[0,o]:[o*-1,0]);return $D([0,o],[0,s])(c)}bD(QD,`getThumbOffsetFromScroll`);function $D(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];let r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}bD($D,`linearScale`);function eO(e,t){return e>0&&e<t}bD(eO,`isScrollingWithinScrollbarBounds`);var tO=bD((e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return bD((function i(){let a={left:e.scrollLeft,top:e.scrollTop},o=n.left!==a.left,s=n.top!==a.top;(o||s)&&t(),n=a,r=window.requestAnimationFrame(i)}),`loop`)(),()=>window.cancelAnimationFrame(r)},`addUnlinkedScrollListener`);function nO(e,t){let n=MC(e),r=S.useRef(0);return S.useEffect(()=>()=>window.clearTimeout(r.current),[]),S.useCallback(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)},[n,t])}bD(nO,`useDebounceCallback`);function rO(e,t){let n=MC(t);xw(()=>{let t=0;if(e){let r=new ResizeObserver(()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)});return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}},[e,n])}bD(rO,`useResizeObserver`);var iO=DD,aO=kD,oO=KD,sO=Object.defineProperty,cO=(e,t)=>sO(e,`name`,{value:t,configurable:!0}),lO=`Tabs`,[uO,dO]=sC(lO,[mT]),fO=mT(),[pO,mO]=uO(lO),hO=S.forwardRef(cO(function(e,t){let{__scopeTabs:n,value:r,onValueChange:i,defaultValue:a,orientation:o=`horizontal`,dir:s,activationMode:c=`automatic`,...l}=e,u=bw(s),[d,f]=Kw({prop:r,onChange:i,defaultProp:a??``,caller:lO});return(0,X.jsx)(pO,{scope:n,baseId:Ew(),value:d,onValueChange:f,orientation:o,dir:u,activationMode:c,children:(0,X.jsx)(nC.div,{dir:u,"data-orientation":o,...l,ref:t})})},`Tabs`)),gO=`TabsList`,_O=S.forwardRef(cO(function(e,t){let{__scopeTabs:n,loop:r=!0,...i}=e,a=mO(gO,n),o=fO(n);return(0,X.jsx)(ET,{asChild:!0,...o,orientation:a.orientation,dir:a.dir,loop:r,children:(0,X.jsx)(nC.div,{role:`tablist`,"aria-orientation":a.orientation,...i,ref:t})})},`TabsList`)),vO=`TabsTrigger`,yO=S.forwardRef(cO(function(e,t){let{__scopeTabs:n,value:r,disabled:i=!1,...a}=e,o=mO(vO,n),s=fO(n),c=SO(o.baseId,r),l=CO(o.baseId,r),u=r===o.value;return(0,X.jsx)(DT,{asChild:!0,...s,focusable:!i,active:u,children:(0,X.jsx)(nC.button,{type:`button`,role:`tab`,"aria-selected":u,"aria-controls":l,"data-state":u?`active`:`inactive`,"data-disabled":i?``:void 0,disabled:i,id:c,...a,ref:t,onMouseDown:TC(e.onMouseDown,e=>{!i&&e.button===0&&e.ctrlKey===!1?o.onValueChange(r):e.preventDefault()}),onKeyDown:TC(e.onKeyDown,e=>{i||e.target!==e.currentTarget||[` `,`Enter`].includes(e.key)&&o.onValueChange(r)}),onFocus:TC(e.onFocus,()=>{let e=o.activationMode!==`manual`;!u&&!i&&e&&o.onValueChange(r)})})})},`TabsTrigger`)),bO=`TabsContent`,xO=S.forwardRef(cO(function(e,t){let{__scopeTabs:n,value:r,forceMount:i,children:a,...o}=e,s=mO(bO,n),c=SO(s.baseId,r),l=CO(s.baseId,r),u=r===s.value,d=S.useRef(u);return S.useEffect(()=>{let e=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(e)},[]),(0,X.jsx)(Mw,{present:i||u,children:({present:n})=>(0,X.jsx)(nC.div,{"data-state":u?`active`:`inactive`,"data-orientation":s.orientation,role:`tabpanel`,"aria-labelledby":c,hidden:!n,id:l,tabIndex:0,...o,ref:t,style:{...e.style,animationDuration:d.current?`0s`:void 0},children:n&&a})})},`TabsContent`));function SO(e,t){return`${e}-trigger-${t}`}cO(SO,`makeTriggerId`);function CO(e,t){return`${e}-content-${t}`}cO(CO,`makeContentId`);var wO=hO,TO=_O,EO=yO,DO=xO,OO=hS(`useAgUiRuntime`),kO=(e,t)=>{let n=Wv(e.structuredContent)?e.structuredContent:void 0,r=Wv(e._meta)?e._meta:void 0;if(!(!n&&!r))return{content:t?[{type:`text`,text:t}]:[],...n?{structuredContent:n}:{},...r?{_meta:r}:{},...typeof e.isError==`boolean`?{isError:e.isError}:{}}},AO=e=>{if(!Wv(e))return;let t=e.ui,n=Wv(t)?t.resourceUri:void 0;if(typeof n==`string`&&_S(n))return n;let r=e[`ui/resourceUri`];return typeof r==`string`&&_S(r)?r:void 0},jO=`__aui_agui_responseSchemaRaw`,MO=(e,t)=>({...e,[jO]:t}),NO=e=>e[jO],PO=e=>{let{[jO]:t,...n}=e;return n},FO=new Map,IO=e=>typeof e==`object`&&!!e&&!Array.isArray(e),LO=e=>typeof e==`string`,RO=new Set([`null`,`boolean`,`object`,`array`,`number`,`integer`,`string`]),zO=e=>Array.isArray(e)&&e.every(LO)&&new Set(e).size===e.length,BO=e=>LO(e)&&RO.has(e)||Array.isArray(e)&&e.length>0&&zO(e)&&e.every(e=>RO.has(e)),VO=(e,t)=>e===t||Array.isArray(e)&&BO(e)&&e.includes(t),HO=e=>VO(e,`object`),UO=new Set([`$schema`,`$id`,`title`,`description`]),WO=(e,t)=>IO(e)&&Object.entries(e).every(([e,n])=>e===`type`?VO(n,t):UO.has(e)&&LO(n)),GO=new Map([[`type`,BO],[`required`,zO],...[...UO].map(e=>[e,LO]),[`properties`,e=>IO(e)&&Object.values(e).every(e=>KO(e))],[`items`,e=>KO(e)]]),KO=e=>typeof e==`boolean`||IO(e)&&Object.entries(e).every(([e,t])=>{let n=GO.get(e);return n===void 0||n(t)}),qO=new Map([[`$schema`,LO],[`$id`,LO],[`title`,LO],[`description`,LO],[`type`,HO],[`required`,e=>Array.isArray(e)&&e.every(e=>e===`approved`)&&new Set(e).size===e.length],[`properties`,e=>IO(e)&&Object.entries(e).every(([e,t])=>e===`approved`?WO(t,`boolean`):e===`reason`?WO(t,`string`):KO(t))]]),JO=e=>e===void 0?!0:IO(e)?Object.entries(e).every(([e,t])=>{let n=qO.get(e);return n!==void 0&&n(t)}):!1,YO=e=>e.reason===`tool_call`&&!!e.id&&!!e.toolCallId&&NO(e)===void 0&&JO(e.responseSchema),XO=e=>!!e&&e.approved===void 0&&!e.resolution,ZO=(e,t)=>{if(!e?.length||!e.every(YO)||t&&!e.every(e=>t.has(e.toolCallId)))return FO;let n=e.map(e=>e.toolCallId);return new Set(n).size===n.length?new Map(e.map(e=>[e.toolCallId,{id:e.id}])):FO},QO=(e,{approvalId:t,approved:n,reason:r})=>{let i=!1,a=e.map(e=>{if(e.type!==`tool-call`)return e;let a=e.approval;return a?.id!==t||!XO(a)?e:(i=!0,{...e,approval:{...a,approved:n,...r!==void 0&&{reason:r}}})});return i?a:e},$O=(e,t)=>{let n=new Set(t.map(e=>e.id)),r=new Map;for(let t of e){if(t.type!==`tool-call`)continue;let e=t.approval;!e||e.approved===void 0||n.has(e.id)&&r.set(e.id,{status:`resolved`,payload:{approved:e.approved,...e.reason!==void 0&&{reason:e.reason}}})}return t.some(e=>!r.has(e.id))?null:tp(t.map(e=>{let{responseSchema:t,...n}=PO(e);return n}),Object.fromEntries(r))},ek=(e,t)=>{let{approved:n,reason:r,resolution:i,...a}=e;if(t.status===`cancelled`)return{...a,resolution:`cancelled`};let o=t.payload;if(typeof o!=`object`||!o||typeof o.approved!=`boolean`)return{...a,resolution:`cancelled`};let{approved:s,reason:c}=o;return{...a,approved:s,...typeof c==`string`&&{reason:c}}},tk=(e,t)=>{if(t.length===0)return e;let n=new Map(t.map(e=>[e.interruptId,e])),r=!1,i=e.map(e=>{if(e.type!==`tool-call`)return e;let t=e.approval;if(!t)return e;let i=n.get(t.id);if(!i)return e;let a=ek(t,i);return a?(r=!0,{...e,approval:a}):e});return r?i:e},nk=Symbol(`a2uiSurfaceId`),rk=new Set([`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`]),ik=e=>typeof e==`object`&&!!e&&!Array.isArray(e),ak=e=>e===`v0.9`||e===`v1.0`,ok=e=>{let t=e.surfaceId;return typeof t==`string`&&t.length>0?t:void 0},sk=(e,t)=>(Object.defineProperty(e,nk,{value:t,enumerable:!1}),e),ck=e=>e[nk],lk=(e,t)=>sk({components:new Map(e.components),dataModel:e.dataModel},ck(e)??t),uk=(e,t,n,r)=>{if(!Array.isArray(t)){n.push(`Operation at index ${r} has malformed components.`);return}for(let i=0;i<t.length;i++){let a=t[i];if(!ik(a)||typeof a.id!=`string`||a.id.length===0||typeof a.component!=`string`||a.component.length===0){n.push(`Component at index ${i} in operation ${r} is malformed.`);continue}e.components.set(a.id,{...a})}},dk=e=>{if(e===``||e===`/`)return[];if(e.startsWith(`/`))return e.slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`))},fk=e=>e===`0`||/^[1-9]\d*$/.test(e),pk=(e,t,n)=>{let r=dk(t);if(!r)return{ok:!1,value:e};if(r.length===0)return{ok:!0,value:n};let i=(e,t)=>{let a=r[t],o=t===r.length-1;if(Array.isArray(e)){if(a!==`-`&&!fk(a))return e;let r=e.slice(),s=a===`-`?r.length:Number(a);return r[s]=o?n:i(r[s],t+1),r}let s=ik(e)?{...e}:{},c=s[a];return s[a]=o?n:i(c??(fk(r[t+1]??``)||r[t+1]===`-`?[]:{}),t+1),s};return{ok:!0,value:i(e,0)}},mk=e=>{for(let t of[`contents`,`value`,`data`])if(e[t]!==void 0)return{found:!0,value:e[t]};return{found:!1,value:void 0}};function hk(e,t){let n=new Map(e),r=[];if(!Array.isArray(t))return{state:n,warnings:[`A2UI operations must be an array.`]};for(let e=0;e<t.length;e++)try{let i=t[e];if(!ik(i)){r.push(`Operation at index ${e} is malformed.`);continue}let a=i.version;if(!ak(a)){r.push(`Operation at index ${e} has an unsupported version.`);continue}let o=Object.keys(i).filter(e=>e!==`version`);if(o.length!==1){r.push(`Operation at index ${e} must contain exactly one operation key.`);continue}let s=o[0];if(!rk.has(s)){r.push(`Unknown A2UI operation "${s}" at index ${e}.`);continue}let c=i[s];if(!ik(c)){r.push(`Operation at index ${e} has a malformed payload.`);continue}let l=ok(c);if(!l){r.push(`Operation at index ${e} has no valid surfaceId.`);continue}if(s===`createSurface`){let t=sk({components:new Map,dataModel:a===`v1.0`&&c.dataModel!==void 0?c.dataModel:void 0},l);a===`v1.0`&&c.components!==void 0&&uk(t,c.components,r,e),n.set(l,t);continue}if(s===`deleteSurface`){n.delete(l);continue}let u=n.get(l);if(!u){r.push(`Operation at index ${e} references missing surface "${l}".`);continue}let d=lk(u,l);if(s===`updateComponents`){uk(d,c.components,r,e),n.set(l,d);continue}let f=mk(c);if(!f.found){r.push(`Operation at index ${e} has no data model value.`);continue}let p=c.path??`/`;if(typeof p!=`string`){r.push(`Operation at index ${e} has a malformed data model path.`);continue}let m=pk(d.dataModel,p,f.value);if(!m.ok){r.push(`Operation at index ${e} has an invalid JSON Pointer path.`);continue}d.dataModel=m.value,n.set(l,d)}catch{r.push(`Operation at index ${e} is malformed.`)}return{state:n,warnings:r}}var gk=32,_k=100,vk=5e3,yk=new Set([`Text`,`Image`,`Row`,`Column`,`Card`,`Divider`,`Button`,`TextField`,`CheckBox`]),bk=e=>typeof e==`object`&&!!e&&!Array.isArray(e),xk=e=>{if(!bk(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null},Sk=e=>xk(e)&&Object.keys(e).length===1&&typeof e.path==`string`,Ck=e=>xk(e)&&Object.keys(e).length===1&&xk(e.template)&&Object.keys(e.template).length===2&&typeof e.template.componentId==`string`&&typeof e.template.path==`string`,wk=e=>{if(e===``||e===`/`)return[];if(e.startsWith(`/`))return e.slice(1).split(`/`).map(e=>e.replaceAll(`~1`,`/`).replaceAll(`~0`,`~`))},Tk=(e,t)=>{let n=wk(t);if(!n)return;let r=e;for(let e of n){if(Array.isArray(r)){if(!/^(0|[1-9]\d*)$/.test(e))return;r=r[Number(e)];continue}if(!bk(r)||!Object.hasOwn(r,e))return;r=r[e]}return r},Ek=e=>Sk(e)?e.path:void 0,Dk=e=>{if(e)return wk(e)?.at(-1)},Ok=(e,t)=>{if(Sk(e))return Tk(t,e.path);if(Array.isArray(e))return e.map(e=>Ok(e,t)).filter(e=>e!==void 0);if(!xk(e))return e;let n={};for(let[r,i]of Object.entries(e)){let e=Ok(i,t);e!==void 0&&(n[r]=e)}return n},kk=(e,t)=>{for(let n of t)if(e[n]!==void 0)return e[n]},Ak=(e,t)=>{let n=kk(e,t);return typeof n==`string`?n:void 0},jk=e=>e[nk]??``,Mk=e=>e.emittedNodes>=vk?(e.budgetWarned||=(e.warnings.push(`A2UI node budget of ${vk} was reached.`),!0),!1):(e.emittedNodes++,!0),Nk=(e,t,n,r,i)=>{let a=e.children;if(!Array.isArray(a))return[];let o=[];for(let s of a){if(typeof s!=`string`){n.warnings.push(`Component "${String(e.id??``)}" has a malformed child reference.`);continue}let a=Lk(s,t,n,r+1,i);a&&o.push(a)}return o},Pk=(e,t,n,r)=>{let i=t.action,a=typeof i==`string`?i:bk(i)&&typeof i.name==`string`?i.name:void 0;if(!a)return;let o=bk(i)?i.context:void 0,s=o===void 0?void 0:Ok(o,n);return{type:`a2ui:action`,name:a,surfaceId:r.surfaceId,sourceComponentId:typeof e.id==`string`?e.id:``,...s===void 0?{}:{context:s}}},Fk=(e,t,n,r)=>{let i=e.component;if(i===`Text`){let e=Ak(t,[`text`,`value`]),n=t.variant;return typeof n==`string`&&/^h[1-6]$/.test(n)?{$type:`Header`,...e===void 0?{}:{text:e}}:n===`caption`?{$type:`Caption`,...e===void 0?{}:{value:e}}:{$type:`Markdown`,...e===void 0?{}:{value:e}}}if(i===`Image`){let e=Ak(t,[`src`,`url`]),n=Ak(t,[`alt`,`altText`]),r=t.size,i=t.round;return{$type:`Image`,...e===void 0?{}:{src:e},...n===void 0?{}:{alt:n},...typeof r==`string`||typeof r==`number`?{size:r}:{},...typeof i==`boolean`?{round:i}:{}}}if(i===`Row`){let e=t.gap,n=kk(t,[`align`,`alignment`]),r=kk(t,[`justify`,`distribution`]);return{$type:`Row`,...typeof e==`number`?{gap:e}:{},...typeof n==`string`?{align:n}:{},...typeof r==`string`?{justify:r}:{}}}if(i===`Column`){let e=t.gap,n=kk(t,[`align`,`alignment`]);return{$type:`Col`,...typeof e==`number`?{gap:e}:{},...typeof n==`string`?{align:n}:{}}}if(i===`Card`){let e=t.title,n=t.padding,r=t.background;return{$type:`Card`,...typeof e==`string`?{title:e}:{},...typeof n==`number`?{padding:n}:{},...typeof r==`string`?{background:r}:{}}}if(i===`Divider`)return{$type:`Divider`,...typeof t.flush==`boolean`?{flush:t.flush}:{}};if(i===`Button`){let i=Ak(t,[`label`,`text`]),a=t.buttonStyle,o=t.block,s=t.submit,c=Pk(e,t,n,r);return{$type:`Button`,...i===void 0?{}:{label:i},...typeof a==`string`?{buttonStyle:a}:{},...typeof o==`boolean`?{block:o}:{},...typeof s==`boolean`?{submit:s}:{},...c?{$action:c}:{}}}let a=Dk(Ek(kk(e,[`text`,`value`,`binding`]))),o=Ak(t,[`label`]);if(i===`TextField`){let e=Ak(t,[`placeholder`]),n=typeof t.multiline==`boolean`?t.multiline:t.textFieldType===`longText`||void 0;return{$type:`Input`,...e===void 0?{}:{placeholder:e},...n===void 0?{}:{multiline:n},...o===void 0?{}:{label:o},...a===void 0?{}:{name:a}}}if(i===`CheckBox`){let e=kk(t,[`defaultChecked`,`value`]);return{$type:`Checkbox`,...o===void 0?{}:{label:o},...a===void 0?{}:{name:a},...typeof e==`boolean`?{defaultChecked:e}:{}}}},Ik=(e,t,n,r,i,a)=>{if(!Mk(r))return null;let o=Tk(n,t.template.path);if(!Array.isArray(o))return r.warnings.push(`Template on component "${String(e.id??``)}" did not resolve to a list.`),{$type:`ListView`,children:[]};let s=Math.min(o.length,_k);o.length>_k&&!r.templateCapWarned&&(r.warnings.push(`A2UI template expansion was capped at ${_k} items.`),r.templateCapWarned=!0);let c=[];for(let e=0;e<s&&Mk(r);e++){let n=Lk(t.template.componentId,o[e],r,i+1,a);c.push({$type:`ListViewItem`,...n?{children:n}:{}})}return{$type:`ListView`,children:c}};function Lk(e,t,n,r,i){if(r>=gk)return n.depthWarned||=(n.warnings.push(`A2UI depth cap of ${gk} was reached.`),!0),null;if(i.has(e))return n.warnings.push(`A2UI component cycle detected at "${e}".`),null;let a=n.surface.components.get(e);if(!a)return n.warnings.push(`A2UI component "${e}" was not found.`),null;let o=a.component;i.add(e);try{let e=a.children;if(Ck(e))return Ik(a,e,t,n,r,i);if(typeof o!=`string`||!yk.has(o))return n.warnings.push(`Unknown A2UI component "${String(o??``)}" was skipped.`),null;if(!Mk(n))return null;let s={};for(let[e,n]of Object.entries(a)){if(e===`id`||e===`component`||e===`children`)continue;let r=Ok(n,t);r!==void 0&&(s[e]=r)}let c=Fk(a,s,t,n);if(!c)return null;let l=Nk(a,t,n,r,i);return{...c,...l.length>0?{children:l}:{}}}finally{i.delete(e)}}function Rk(e){let t=[];if(!e.components.has(`root`))return{spec:null,warnings:[`A2UI root component "root" was not found.`]};let n={surface:e,surfaceId:jk(e),warnings:t,emittedNodes:0,depthWarned:!1,budgetWarned:!1,templateCapWarned:!1};try{return{spec:Lk(`root`,e.dataModel,n,0,new Set),warnings:t}}catch{return t.push(`A2UI surface conversion encountered malformed input.`),{spec:null,warnings:t}}}var zk=`agui`,Bk=e=>!!e&&typeof e==`object`&&!Array.isArray(e),Vk=class{emitUpdate;showThinking;logger;onServerMessageId;status;interrupts;textParts=new Map;activeTextMessageId;reasoningParts=new Map;reasoningSignatures=new Map;reasoningMessageIds=new Map;anonymousReasoningKeys=new Set;activeReasoningKey;reasoningPartCounter=0;toolCalls=new Map;a2uiBuckets=new Map;a2uiToolCallIds=new Set;lastResolvedToolCallId;partOrder=[];textPartCounter=0;serverMessageIdReported=!1;streamStartTime;firstTokenTime;totalChunks=0;constructor(e){this.emitUpdate=e.emit,this.showThinking=e.showThinking,this.logger=e.logger,this.onServerMessageId=e.onServerMessageId}hasToolCall(e){return this.toolCalls.has(e)}handle(e){switch(e.type){case`RUN_STARTED`:this.clearTextParts(),this.reasoningParts.clear(),this.reasoningSignatures.clear(),this.reasoningMessageIds.clear(),this.anonymousReasoningKeys.clear(),this.activeReasoningKey=void 0,this.reasoningPartCounter=0,this.toolCalls.clear(),this.a2uiBuckets.clear(),this.a2uiToolCallIds.clear(),this.lastResolvedToolCallId=void 0,this.partOrder.length=0,this.textPartCounter=0,this.activeTextMessageId=void 0,this.interrupts=void 0,this.serverMessageIdReported=!1,this.streamStartTime=Date.now(),this.firstTokenTime=void 0,this.totalChunks=0,this.status={type:`running`},this.emit();break;case`RUN_FINISHED`:{if(e.outcome?.type===`interrupt`){this.interrupts=e.outcome.interrupts,this.status={type:`requires-action`,reason:`interrupt`},this.emit();break}this.interrupts=void 0;let t=Array.from(this.toolCalls.values()).some(e=>e.result===void 0);this.status=e.outcome?.type===`success`||!t?{type:`complete`,reason:`unknown`}:{type:`requires-action`,reason:`tool-calls`},this.emit();break}case`RUN_ERROR`:this.status={type:`incomplete`,reason:`error`,...e.message===void 0?{}:{error:e.message}},this.emit();break;case`RUN_CANCELLED`:this.status={type:`incomplete`,reason:`cancelled`},this.emit();break;case`TEXT_MESSAGE_START`:{this.reportServerMessageId(e.messageId);let t=this.startTextMessage(e.messageId);t&&this.markTextPartTouched(t),this.emit();break}case`TEXT_MESSAGE_CONTENT`:case`TEXT_MESSAGE_CHUNK`:{let t=`messageId`in e?e.messageId:void 0;if(this.reportServerMessageId(t),!e.delta)break;this.recordFirstToken();let n=this.resolveTextMessageId(t);this.appendText(n,e.delta),this.totalChunks++,this.emit();break}case`TEXT_MESSAGE_END`:this.reportServerMessageId(e.messageId),e.messageId&&this.activeTextMessageId===e.messageId&&(this.activeTextMessageId=void 0),this.emit();break;case`CUSTOM`:this.activeTextMessageId=void 0,this.partOrder.push({kind:`data`,name:e.name,value:e.value}),this.emit();break;case`THINKING_START`:case`THINKING_TEXT_MESSAGE_START`:case`REASONING_START`:case`REASONING_MESSAGE_START`:this.handleReasoningStart(`messageId`in e?e.messageId:void 0,e.type===`REASONING_MESSAGE_START`);break;case`REASONING_ENCRYPTED_VALUE`:if(e.subtype===`message`){let t=this.activeReasoningKey,n=this.reasoningParts.has(e.entityId)?e.entityId:t!==void 0&&this.anonymousReasoningKeys.has(t)?t:void 0;n!==void 0&&(this.reasoningSignatures.set(n,e.encryptedValue),this.emit())}break;case`THINKING_TEXT_MESSAGE_CONTENT`:this.handleReasoningContent(e.delta),this.totalChunks++,this.recordFirstToken();break;case`REASONING_MESSAGE_CONTENT`:this.handleReasoningContent(e.delta,`messageId`in e?e.messageId:void 0,!0),this.totalChunks++,this.recordFirstToken();break;case`THINKING_TEXT_MESSAGE_END`:case`THINKING_END`:case`REASONING_MESSAGE_END`:case`REASONING_END`:this.handleReasoningEnd();break;case`TOOL_CALL_START`:this.reportServerMessageId(e.parentMessageId),this.startToolCall(e.toolCallId,e.toolCallName,e.parentMessageId),this.emit();break;case`TOOL_CALL_ARGS`:case`TOOL_CALL_CHUNK`:if(e.type===`TOOL_CALL_CHUNK`&&this.reportServerMessageId(e.parentMessageId),!e.delta)break;this.appendToolArgs(e.toolCallId,e.delta),this.emit();break;case`TOOL_CALL_END`:this.emit();break;case`TOOL_CALL_RESULT`:this.finishToolCall(e.toolCallId,e.content??``,typeof e.mcpResult?.isError==`boolean`?e.mcpResult.isError:e.role!==`tool`&&void 0,e.messageId,e.mcpResult),this.emit();break;case`ACTIVITY_SNAPSHOT`:{if(e.activityType===`a2ui-surface`){this.handleA2uiActivitySnapshot(e);break}if(e.activityType!==`mcp-apps`)break;let t=e.content.toolCallId,n=typeof t==`string`?this.toolCalls.get(t):this.lastResolvedToolCallId?this.toolCalls.get(this.lastResolvedToolCallId):void 0,r=e.content.resourceUri;if(n&&typeof r==`string`&&_S(r)){n.mcpAppResourceUri=r;let t=e.content.serverId,i=e.content.serverHash;typeof t==`string`&&t.length>0?n.mcpAppServerId=t:typeof i==`string`&&i.length>0&&(n.mcpAppServerId=i);let a=e.content.result;Bk(a)&&(n.result!==void 0&&n.modelContent===void 0&&(n.modelContent=[{type:`text`,text:typeof n.result==`string`?n.result:JSON.stringify(n.result)}]),n.result=a,n.snapshotResultApplied=!0,typeof a.isError==`boolean`&&(n.isError=a.isError)),this.emit()}break}default:this.logger.debug?.(`[agui] aggregator ignored event`,e)}}handleA2uiActivitySnapshot(e){let t=e.content.a2ui_operations;if(!Array.isArray(t))return;let n=e.messageId??`a2ui:anonymous`;if(e.replace===!1&&this.a2uiBuckets.has(n))return;let{state:r,warnings:i}=hk(new Map,t);for(let e of i)this.logger.debug(`[agui] a2ui operation warning`,e);this.a2uiBuckets.delete(n),this.a2uiBuckets.set(n,r),this.synthesizeA2uiToolCalls(),this.emit()}synthesizeA2uiToolCalls(){let e=new Map;for(let t of this.a2uiBuckets.values())for(let[n,r]of t)e.set(n,r);let t=new Set;for(let[n,r]of e){let e=`a2ui:${n}`,{spec:i,warnings:a}=Rk(r);for(let e of a)this.logger.debug(`[agui] a2ui surface conversion warning`,e);if(!i)continue;t.add(e);let o={toolCallId:e,toolCallName:`present`,argsText:JSON.stringify(i),parsedArgs:i,result:{},isError:void 0,snapshotResultApplied:!1};this.toolCalls.has(e)||this.partOrder.push({kind:`tool-call`,toolCallId:e}),this.toolCalls.set(e,o),this.a2uiToolCallIds.add(e)}for(let e of this.a2uiToolCallIds){if(t.has(e))continue;this.toolCalls.delete(e);let n=this.partOrder.findIndex(t=>t.kind===`tool-call`&&t.toolCallId===e);n!==-1&&this.partOrder.splice(n,1),this.a2uiToolCallIds.delete(e)}}reportServerMessageId(e){this.serverMessageIdReported||!e||(this.serverMessageIdReported=!0,this.onServerMessageId?.(e))}clearTextParts(){this.textParts.clear()}generateTextKey(){return this.textPartCounter+=1,`text-${this.textPartCounter}`}startTextMessage(e){let t=e??this.generateTextKey();return this.ensureTextPart(t),this.activeTextMessageId=t,t}resolveTextMessageId(e){if(e)return this.ensureTextPart(e),this.activeTextMessageId=e,e;if(this.activeTextMessageId)return this.activeTextMessageId;let t=this.generateTextKey();return this.ensureTextPart(t),this.activeTextMessageId=t,t}ensureTextPart(e){this.textParts.has(e)||(this.textParts.set(e,{buffer:``,touched:!1}),this.partOrder.some(t=>t.kind===`text`&&t.key===e)||this.partOrder.push({kind:`text`,key:e}))}markTextPartTouched(e){let t=this.textParts.get(e);t&&(t.touched=!0)}appendText(e,t){this.ensureTextPart(e);let n=this.textParts.get(e);n&&(n.buffer+=t,n.touched=!0)}startToolCall(e,t,n){if(!e)return;this.activeTextMessageId=void 0,this.partOrder.some(t=>t.kind===`tool-call`&&t.toolCallId===e)||this.insertToolPart(e,n);let r={toolCallId:e,toolCallName:t??`tool`,argsText:``,parsedArgs:void 0,result:void 0,isError:void 0,snapshotResultApplied:!1};n&&(r.parentMessageId=n),this.toolCalls.set(e,r)}insertToolPart(e,t){let n={kind:`tool-call`,toolCallId:e};if(t){let e=this.partOrder.findIndex(e=>e.kind===`text`&&e.key===t);if(e!==-1){let r=e+1;for(;r<this.partOrder.length;){let e=this.partOrder[r];if(e?.kind===`tool-call`&&this.toolCalls.get(e.toolCallId)?.parentMessageId===t){r+=1;continue}break}this.partOrder.splice(r,0,n);return}}this.partOrder.push(n)}appendToolArgs(e,t){let n=e?this.toolCalls.get(e):void 0;if(n){n.argsText+=t;try{let e=JSON.parse(n.argsText);n.parsedArgs=e&&typeof e==`object`?e:void 0}catch{n.parsedArgs=void 0}}}finishToolCall(e,t,n,r,i){if(!e)return;let a=this.toolCalls.get(e);if(a||(a={toolCallId:e,toolCallName:`tool`,argsText:``,parsedArgs:void 0,result:void 0,isError:void 0,snapshotResultApplied:!1},this.toolCalls.set(e,a)),this.partOrder.some(t=>t.kind===`tool-call`&&t.toolCallId===e)||this.partOrder.push({kind:`tool-call`,toolCallId:e}),i!==void 0&&!a.snapshotResultApplied){if(a.result=i,a.modelContent=[{type:`text`,text:t}],a.snapshotResultApplied=!0,a.isError=n,a.mcpAppResourceUri===void 0){let e=AO(i._meta);e!==void 0&&(a.mcpAppResourceUri=e)}}else a.snapshotResultApplied?(a.modelContent===void 0&&(a.modelContent=[{type:`text`,text:t}]),a.isError===void 0&&(a.isError=n)):(a.result=Hk(t),a.isError=n);r&&(a.toolMessageId=r),this.lastResolvedToolCallId=e}emit(){let e=[],t=ZO(this.status?.type===`requires-action`?this.interrupts:void 0,new Set(this.toolCalls.keys()));for(let n of this.partOrder){if(n.kind===`reasoning`){if(this.showThinking){let t=this.reasoningParts.get(n.key)??``;if(t.length>0||this.activeReasoningKey===n.key){let r=this.reasoningSignatures.get(n.key),i=this.reasoningMessageIds.get(n.key),a={...i===void 0?{}:{reasoningId:i},...r===void 0?{}:{encryptedValue:r}};e.push({type:`reasoning`,text:t,...Object.keys(a).length>0?{providerMetadata:{[zk]:a}}:{}})}}continue}if(n.kind===`text`){let t=this.textParts.get(n.key);t?.touched&&e.push({type:`text`,text:t.buffer});continue}if(n.kind===`data`){e.push({type:`data`,name:n.name,data:n.value});continue}let r=this.toolCalls.get(n.toolCallId);if(!r)continue;let i=t.get(r.toolCallId),a={type:`tool-call`,toolCallId:r.toolCallId,toolName:r.toolCallName,args:r.parsedArgs??{},argsText:r.argsText,...i?{approval:i}:{},...r.result===void 0?{}:{result:r.result},...r.modelContent===void 0?{}:{modelContent:r.modelContent},...r.isError===void 0?{}:{isError:r.isError},...r.mcpAppResourceUri?{mcp:{app:{resourceUri:r.mcpAppResourceUri,...r.mcpAppServerId?{serverId:r.mcpAppServerId}:{}}}}:{},...r.parentMessageId?{parentId:r.parentMessageId}:{},...r.toolMessageId?{unstable_toolMessageId:r.toolMessageId}:{}};e.push(a)}let n=this.getTiming(),r={...n?{timing:n}:{},...this.interrupts?{custom:{[zk]:{interrupts:this.interrupts}}}:{}},i={content:e,...this.status?{status:this.status}:void 0,...Object.keys(r).length>0?{metadata:r}:void 0};this.emitUpdate(i)}recordFirstToken(){this.firstTokenTime===void 0&&this.streamStartTime!==void 0&&(this.firstTokenTime=Date.now()-this.streamStartTime)}getTiming(){if(this.streamStartTime===void 0)return;let e=Date.now()-this.streamStartTime,t=this.totalChunks>0?Math.ceil(Array.from(this.textParts.values()).reduce((e,t)=>e+t.buffer.length,0)/4):void 0,n=t&&e>0?t/e*1e3:void 0;return{streamStartTime:this.streamStartTime,...this.firstTokenTime===void 0?{}:{firstTokenTime:this.firstTokenTime},totalStreamTime:e,...t===void 0?{}:{tokenCount:t},...n===void 0?{}:{tokensPerSecond:n},totalChunks:this.totalChunks,toolCallCount:this.toolCalls.size}}handleReasoningStart(e,t=!1){if(!this.showThinking)return;this.activeTextMessageId=void 0;let n=e??`__auto-reasoning-${++this.reasoningPartCounter}`;e===void 0?this.anonymousReasoningKeys.add(n):t&&this.reasoningMessageIds.set(n,e),this.reasoningParts.has(n)||(this.reasoningParts.set(n,``),this.partOrder.push({kind:`reasoning`,key:n})),this.activeReasoningKey=n,this.emit()}handleReasoningContent(e,t,n=!1){if(!this.showThinking||!e)return;this.activeReasoningKey||this.handleReasoningStart(t,n);let r=this.activeReasoningKey;r&&(this.reasoningParts.set(r,(this.reasoningParts.get(r)??``)+e),this.emit())}handleReasoningEnd(){this.showThinking&&(this.activeReasoningKey=void 0,this.emit())}};function Hk(e){if(!e)return e;try{return JSON.parse(e)}catch{return e}}var Uk=e=>typeof e==`object`&&!!e,Z=(e,t)=>{let n=e[t];return typeof n==`string`?n:void 0},Wk=e=>Z(e,`toolCallId`)??Z(e,`tool_call_id`),Gk=e=>{if(!Uk(e))return;let t=e[zk];return Uk(t)?t:void 0},Kk=e=>{let t=Gk(e);return t?{encryptedValue:Z(t,`encryptedValue`),reasoningId:Z(t,`reasoningId`)}:{}},qk=(e,t)=>{let n={...Gk(e.providerMetadata),...t!==void 0&&{filename:t}};return Object.keys(n).length>0?n:void 0},Jk=e=>{if(!Uk(e))return{};let{filename:t,...n}=e;return{filename:Z(e,`filename`),...Object.keys(n).length>0&&{providerMetadata:{agui:n}}}};function Yk(e){if(!e)return e;try{return JSON.parse(e)}catch{return e}}function Xk(){return globalThis.crypto?.randomUUID?.()??Math.random().toString(36).slice(2)}function Zk(e){let t=e.toolCallId??Xk(),n=typeof e.argsText==`string`?e.argsText:JSON.stringify(e.args??{});return{id:t,call:{id:t,type:`function`,function:{name:e.toolName??`tool`,arguments:n}}}}function Qk(e){return typeof e==`string`?e:Array.isArray(e)?e.filter(e=>e?.type===`text`&&typeof e?.text==`string`).map(e=>e.text).join(`
|
|
63
|
+
`):``}function $k(e){return e?.startsWith(`image/`)?`image`:e?.startsWith(`audio/`)?`audio`:e?.startsWith(`video/`)?`video`:`document`}function eA(e,t,n){if(n===`url`||eb.test(e))return t===void 0?{type:`url`,value:e}:{type:`url`,value:e,mimeType:t};let r=tb(e);return{type:`data`,value:r?.data??e,mimeType:r?.mimeType??t??`application/octet-stream`}}function tA(e,t){if(!Uk(e))return null;let n=Z(e,`type`);if(n===`text`){let t=Z(e,`text`);return t===void 0?null:{type:`text`,text:t}}if(n===`image`){let n=Z(e,`image`);if(n===void 0)return null;let r=qk(e,Z(e,`filename`));return{type:`image`,source:eA(n,t),...r&&{metadata:r}}}if(n===`file`){let n=Z(e,`data`);if(n===void 0)return null;let r=Z(e,`mimeType`)||t,i=Z(e,`filename`),a=eA(n,r,Z(e,`sourceType`)),o=qk(e,i);switch($k(a.mimeType)){case`image`:return{type:`image`,source:a,...o&&{metadata:o}};case`audio`:return{type:`audio`,source:a,...o&&{metadata:o}};case`video`:return{type:`video`,source:a,...o&&{metadata:o}};default:return{type:`document`,source:a,...o&&{metadata:o}}}}if(n===`audio`){let t=e.audio;if(!Uk(t))return null;let n=Z(t,`data`),r=Z(t,`format`);return n===void 0||r===void 0?null:{type:`audio`,source:eA(tb(n)?.data??n,`audio/${r}`)}}return null}var nA=new Set([`image`,`audio`,`video`,`document`]);function rA(e){if(!Uk(e))return null;let t=Z(e,`value`);if(t===void 0)return null;let n=Z(e,`mimeType`),r=Z(e,`type`);if(r===`url`)return{value:t,isUrl:!0,...n!==void 0&&{mimeType:n}};if(r===`data`){let e=n??`application/octet-stream`;return{value:`data:${e};base64,${t}`,mimeType:e}}return null}function iA(e){let t=Z(e,`mimeType`);if(t===void 0)return null;let n=Z(e,`data`),r=Z(e,`url`),i=n?{type:`data`,value:n,mimeType:t}:r?{type:`url`,value:r,mimeType:t}:null;if(!i)return null;let a=Z(e,`filename`);return{type:$k(t),source:i,...a&&{metadata:{filename:a}}}}function aA(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!Uk(n))continue;let e=Z(n,`type`)===`binary`?iA(n):n;if(!e)continue;let r=Z(e,`type`);if(r===void 0||!nA.has(r))continue;let i=rA(e.source);if(!i)continue;let{filename:a,providerMetadata:o}=Jk(e.metadata),s=t.length.toString();if(r===`image`){t.push({id:s,type:`image`,name:a??`image`,...i.mimeType!==void 0&&{contentType:i.mimeType},status:{type:`complete`},content:[{type:`image`,image:i.value,...a!==void 0&&{filename:a},...o&&{providerMetadata:o}}]});continue}let c=i.mimeType??`application/octet-stream`;t.push({id:s,type:r===`document`?`document`:`file`,name:a??`file`,contentType:c,status:{type:`complete`},content:[{type:`file`,data:i.value,mimeType:c,...i.isUrl&&{sourceType:`url`},...a!==void 0&&{filename:a},...o&&{providerMetadata:o}}]})}return t}function oA(e){let t=Array.isArray(e.content)?e.content:[],n=e.attachments??[],r=[];typeof e.content==`string`&&e.content.length>0&&r.push({type:`text`,text:e.content});for(let e of t){let t=tA(e,void 0);t&&r.push(t)}for(let e of n){if(!Uk(e))continue;let t=e.content;if(!Array.isArray(t))continue;let n=Z(e,`contentType`);for(let e of t){let t=tA(e,n);t&&r.push(t)}}return r.some(e=>e.type!==`text`)?r:r.length===0?Qk(e.content):r.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
64
|
+
`)}function sA(e){if(!Uk(e))return null;let t=Uk(e.function)?e.function:null,n=Z(e,`toolCallId`)??Z(e,`id`),r=Z(e,`toolName`)??Z(e,`name`)??(t?Z(t,`name`):void 0)??`tool`,i=Z(e,`argsText`)??Z(e,`arguments`)??(t?Z(t,`arguments`):void 0),a=typeof i==`string`?Yk(i):void 0,o=Uk(a)&&!Array.isArray(a)?a:Uk(e.args)&&!Array.isArray(e.args)?e.args:void 0,s={type:`tool-call`,...n===void 0?{}:{toolCallId:n},toolName:r,argsText:i??JSON.stringify(o??{}),...o===void 0?{}:{args:o}};if(e.type===`tool-call`){let t=e.result,n=e.isError;t!==void 0&&(s.result=t),typeof n==`boolean`&&(s.isError=n)}return s}function cA(e){let t=[],n=new Set,r=e=>{if(!e)return;let r=e.toolCallId??Xk();n.has(r)||(n.add(r),t.push({...e,toolCallId:r}))},i=e.content;if(Array.isArray(i))for(let e of i)Uk(e)&&e.type===`tool-call`&&r(sA(e));let a=Array.isArray(e.toolCalls)?e.toolCalls:Array.isArray(e.tool_calls)?e.tool_calls:[];for(let e of a)r(sA(e));return t}function lA(e){if(!Array.isArray(e))return;let t=e.filter(e=>Uk(e)&&typeof e.id==`string`&&typeof e.reason==`string`);return t.length>0?t:void 0}function uA(e){if(!Uk(e))return;let t=e.custom;if(!Uk(t))return;let n=t[zk];if(Uk(n))return lA(n.interrupts)}function dA(e){if(!Uk(e))return[];let t=e.custom;if(!Uk(t))return[];let n=t[zk];if(!Uk(n))return[];let r=n.opaqueReasoning;return Array.isArray(r)?r.flatMap(e=>{if(!Uk(e))return[];let t=Z(e,`id`),n=Z(e,`encryptedValue`);return!t?.trim()||!n?.trim()?[]:[{id:t,encryptedValue:n,...e.after===!0?{after:!0}:{}}]}):[]}function fA(e,t){let n=Uk(e.metadata)?e.metadata:{},r=Uk(n.custom)?n.custom:{},i=Uk(r.agui)?r[zk]:{};return{...e,metadata:{...n,custom:{...r,[zk]:{...i,opaqueReasoning:t}}}}}function pA(e){let t=Qk(e.content),n=uA(e.metadata),r=cA(e),i=ZO(n,new Set(r.map(e=>e.toolCallId).filter(e=>!!e))),a=r.map(e=>{let t=e.toolCallId?i.get(e.toolCallId):void 0;return t?{...e,approval:t}:e}),o=[...t.length>0?[{type:`text`,text:t}]:[],...a],s=Z(e,`name`);return{id:Z(e,`id`)??Xk(),role:`assistant`,content:o.length>0?o:``,...s===void 0?{}:{name:s},...n?{metadata:{custom:{[zk]:{interrupts:n}}}}:{}}}function mA(e,t){let n=Z(t,`name`),r=e===`user`?aA(t.content):[];return{id:Z(t,`id`)??Xk(),role:e,content:Qk(t.content),...n===void 0?{}:{name:n},...r.length>0?{attachments:r}:{}}}function hA(e,t){let n=[];for(let[e,r]of t){let{spec:t}=Rk(r);t&&n.push({type:`tool-call`,toolCallId:`a2ui:${e}`,toolName:`present`,args:t,argsText:JSON.stringify(t),result:{}})}let r=(Array.isArray(e.content)?e.content:[]).filter(e=>!(Uk(e)&&e.type===`tool-call`&&typeof e.toolCallId==`string`&&e.toolCallId.startsWith(`a2ui:`)));return{...e,content:[...r,...n]}}function gA(e,t){let n=t?.showThinking??!0,r=[],i=new Map,a=new Map,o=[];for(let t of e){if(!Uk(t))continue;let e=Z(t,`role`);if(e){if(e===`tool`){let e=Wk(t)??`tool-${Xk()}`,n=Z(t,`id`),i=Qk(t.content),a=kO(t,i),o=a?[{type:`text`,text:i}]:void 0,s=a??(t.result===void 0?typeof t.content==`string`?Yk(t.content):t.content:t.result),c=typeof t.error==`string`||t.isError===!0||t.status===`error`||t.isError!==!1&&void 0,l=AO(a?._meta),u=l===void 0?void 0:{resourceUri:l},d=!1;for(let t=r.length-1;t>=0&&!d;t--){let i=r[t];if(!(!i||i.role!==`assistant`||!Array.isArray(i.content)))for(let a=i.content.length-1;a>=0;a--){let l=i.content[a];if(!Uk(l)||l.type!==`tool-call`||Z(l,`toolCallId`)!==e)continue;let f={...l,result:s,...o?{modelContent:o}:{},...c===void 0?{}:{isError:c},...n===void 0?{}:{unstable_toolMessageId:n},...u?{mcp:{app:u}}:{}},p=i.content.map((e,t)=>t===a?f:e);r[t]={...i,content:p},d=!0;break}}if(d)continue;let f=n??e,p=Z(t,`name`)??Z(t,`toolName`)??`tool`;r.push({id:`${f}:assistant`,role:`assistant`,content:[{type:`tool-call`,toolCallId:e,toolName:p,args:{},argsText:`{}`,result:s,...o?{modelContent:o}:{},...c===void 0?{}:{isError:c},...n===void 0?{}:{unstable_toolMessageId:n},...u?{mcp:{app:u}}:{}}]});continue}if(e===`activity`){if(Z(t,`activityType`)!==`a2ui-surface`)continue;let e=(Uk(t.content)?t.content:null)?.a2ui_operations;if(!Array.isArray(e))continue;let n=-1;for(let e=r.length-1;e>=0;e--){let t=r[e];if(t&&t.role===`assistant`){n=e;break}}if(n===-1)continue;let o=r[n],s=Z(t,`id`)??`a2ui:anonymous`,{state:c}=hk(new Map,e);i.delete(s),a.delete(s),i.set(s,c),a.set(s,n);let l=new Map;for(let[e,t]of i)if(a.get(e)===n)for(let[e,n]of t)l.set(e,n);r[n]=hA(o,l);continue}if(e===`assistant`){r.push(pA(t));continue}if(e===`reasoning`){let e=Qk(t.content),i=Z(t,`encryptedValue`);if(e.trim().length===0){let e=Z(t,`id`);e?.trim()&&i?.trim()&&o.push({id:e,encryptedValue:i,anchor:r.length});continue}if(!n){let e=Z(t,`id`);e?.trim()&&i?.trim()&&o.push({id:e,encryptedValue:i,anchor:r.length});continue}r.push({id:Z(t,`id`)??Xk(),role:`assistant`,content:[{type:`reasoning`,text:e,...i===void 0?{}:{providerMetadata:{[zk]:{encryptedValue:i}}}}]});continue}(e===`user`||e===`system`)&&r.push(mA(e,t))}}for(let{anchor:e,...t}of o){let n=e>=r.length,i=n?r.length-1:e,a=r[i];a&&(r[i]=fA(a,[...dA(a.metadata),...n?[{...t,after:!0}]:[t]]))}for(let e=0;e<r.length;e++){let t=r[e];if(t.role!==`assistant`)continue;let n=uA(t.metadata)!==void 0,i=Array.isArray(t.content)&&t.content.some(e=>Uk(e)&&e.type===`tool-call`&&e.result===void 0);(n||i)&&(r[e]={...t,status:fb(!1,!1,n,i,void 0)})}return r}function _A(e,t){let n=Qk(e.content),r=Array.isArray(e.content)?e.content:[],i=r.filter(e=>e?.type===`tool-call`&&!(typeof e.toolCallId==`string`&&e.toolCallId.startsWith(`a2ui:`))).map(e=>({...Zk(e),part:e})),a=n.length===0&&i.length===0,o=0;for(let n of r){if(!Uk(n)||n.type!==`reasoning`)continue;let r=Z(n,`text`)??``;if(r.trim().length===0)continue;let{encryptedValue:i,reasoningId:s}=Kk(n.providerMetadata);t.push({id:s?.trim()?s:a&&o===0?e.id:`${e.id}:reasoning-${o}`,role:`reasoning`,content:r,...i===void 0?{}:{encryptedValue:i}}),o++}if(!a){t.push({id:e.id,role:`assistant`,content:n,...e.name?{name:e.name}:{},...i.length>0?{toolCalls:i.map(e=>e.call)}:{}});for(let{id:e,part:n}of i){if(n.result===void 0)continue;let r=n.modelContent===void 0?typeof n.result==`string`?n.result:JSON.stringify(n.result):Qk(n.modelContent);t.push({id:n.unstable_toolMessageId??`${e}:tool`,role:`tool`,content:r,toolCallId:e,...n.isError?{error:r}:{}})}}}function vA(e,t){let n=Qk(e.content),r=e.toolCallId??Xk();t.push({id:e.id,role:`tool`,content:n,toolCallId:r,...typeof e.error==`string`?{error:e.error}:{}})}function yA(e){let t=[];for(let n of e){let e={...n,id:n.id??Xk()},r=dA(e.metadata),i=e=>({id:e.id,role:`reasoning`,content:``,encryptedValue:e.encryptedValue});for(let e of r)e.after!==!0&&t.push(i(e));let a=()=>{for(let e of r)e.after===!0&&t.push(i(e))};if(e.role===`assistant`){_A(e,t),a();continue}if(e.role===`tool`){vA(e,t),a();continue}if(e.role===`user`){t.push({id:e.id,role:`user`,content:oA(e),...e.name?{name:e.name}:{}}),a();continue}if(e.role===`system`||e.role===`developer`){t.push({id:e.id,role:e.role,content:Qk(e.content),...e.name?{name:e.name}:{}}),a();continue}if(e.role===`reasoning`){t.push({id:e.id,role:`reasoning`,content:Qk(e.content)}),a();continue}a()}return t}function bA(e){if(!e)return[];let t=zb(e);return Object.entries(t).map(([e,t])=>({name:e,description:t.description??``,parameters:t.parameters}))}var xA=e=>({debug:(...t)=>e?.debug?.(...t),error:(...t)=>e?.error?.(...t)}),SA=e=>typeof e==`string`,CA=e=>SA(e)&&e.length>0,wA=(e,t)=>{let n=Object.entries(t).filter(([,e])=>e!==void 0);return n.length===0?e:{...e,...Object.fromEntries(n)}},TA=e=>!!e&&typeof e==`object`&&!Array.isArray(e),EA=e=>{if(!TA(e))return null;let t=e.id,n=e.reason;if(typeof t!=`string`||typeof n!=`string`)return null;let r={id:t,reason:n};return typeof e.message==`string`&&(r.message=e.message),typeof e.toolCallId==`string`&&(r.toolCallId=e.toolCallId),typeof e.expiresAt==`string`&&(r.expiresAt=e.expiresAt),TA(e.responseSchema)&&(r.responseSchema=e.responseSchema),TA(e.metadata)&&(r.metadata=e.metadata),e.responseSchema==null||TA(e.responseSchema)?r:MO(r,e.responseSchema)},DA=(e,t)=>{if(TA(e)){if(e.type===`success`)return{type:`success`};if(e.type===`interrupt`){if(!Array.isArray(e.interrupts)){t?.debug?.(`[agui] RUN_FINISHED interrupt outcome missing interrupts array`,e);return}let n=e.interrupts.map(e=>EA(e)).filter(e=>e!==null);if(n.length===0){t?.debug?.(`[agui] RUN_FINISHED interrupt outcome has no valid interrupts`,e.interrupts);return}return{type:`interrupt`,interrupts:n}}}},OA=(e,t)=>{if(!e||typeof e!=`object`)return null;let n=e,r=n.type;if(!SA(r))return null;let i=e=>SA(n[e])?n[e]:void 0;switch(r){case`RUN_STARTED`:{let e=i(`runId`);return e?{type:`RUN_STARTED`,runId:e}:null}case`RUN_FINISHED`:{let e=i(`runId`);return e?wA({type:`RUN_FINISHED`,runId:e},{outcome:DA(n.outcome,t?.logger)}):null}case`RUN_CANCELLED`:return wA({type:`RUN_CANCELLED`},{runId:i(`runId`)});case`RUN_ERROR`:return wA({type:`RUN_ERROR`},{message:i(`message`),code:i(`code`)});case`TEXT_MESSAGE_START`:return wA({type:`TEXT_MESSAGE_START`},{messageId:i(`messageId`)});case`TEXT_MESSAGE_CONTENT`:{let e=i(`delta`);return CA(e)?wA({type:`TEXT_MESSAGE_CONTENT`,delta:e},{messageId:i(`messageId`)}):null}case`TEXT_MESSAGE_END`:return wA({type:`TEXT_MESSAGE_END`},{messageId:i(`messageId`)});case`TEXT_MESSAGE_CHUNK`:return wA({type:`TEXT_MESSAGE_CHUNK`,delta:i(`delta`)??``},{messageId:i(`messageId`)});case`THINKING_START`:return wA({type:`THINKING_START`},{title:i(`title`)});case`THINKING_TEXT_MESSAGE_START`:return{type:`THINKING_TEXT_MESSAGE_START`};case`THINKING_TEXT_MESSAGE_CONTENT`:return{type:`THINKING_TEXT_MESSAGE_CONTENT`,delta:i(`delta`)??``};case`THINKING_TEXT_MESSAGE_END`:return{type:`THINKING_TEXT_MESSAGE_END`};case`THINKING_END`:return{type:`THINKING_END`};case`REASONING_START`:return wA({type:`REASONING_START`},{messageId:i(`messageId`)});case`REASONING_MESSAGE_START`:return wA({type:`REASONING_MESSAGE_START`},{messageId:i(`messageId`)});case`REASONING_MESSAGE_CONTENT`:return wA({type:`REASONING_MESSAGE_CONTENT`,delta:i(`delta`)??``},{messageId:i(`messageId`)});case`REASONING_MESSAGE_END`:return wA({type:`REASONING_MESSAGE_END`},{messageId:i(`messageId`)});case`REASONING_ENCRYPTED_VALUE`:{let e=i(`entityId`),t=i(`encryptedValue`),n=i(`subtype`);return!e||!t||n!==`message`&&n!==`tool-call`?null:{type:`REASONING_ENCRYPTED_VALUE`,subtype:n,entityId:e,encryptedValue:t}}case`REASONING_END`:return wA({type:`REASONING_END`},{messageId:i(`messageId`)});case`TOOL_CALL_START`:{let e=i(`toolCallId`);return e?wA({type:`TOOL_CALL_START`,toolCallId:e},{toolCallName:i(`toolCallName`),parentMessageId:i(`parentMessageId`)}):null}case`TOOL_CALL_ARGS`:{let e=i(`toolCallId`);return e?{type:`TOOL_CALL_ARGS`,toolCallId:e,delta:i(`delta`)??``}:null}case`TOOL_CALL_END`:{let e=i(`toolCallId`);return e?{type:`TOOL_CALL_END`,toolCallId:e}:null}case`TOOL_CALL_CHUNK`:return wA({type:`TOOL_CALL_CHUNK`},{toolCallId:i(`toolCallId`),toolCallName:i(`toolCallName`),parentMessageId:i(`parentMessageId`),delta:i(`delta`)});case`TOOL_CALL_RESULT`:{let e=i(`toolCallId`);if(!e)return null;let t=i(`content`)??``;return wA({type:`TOOL_CALL_RESULT`,toolCallId:e,content:t},{messageId:i(`messageId`),role:n.role===`tool`?`tool`:void 0,mcpResult:kO(n,t)})}case`STATE_SNAPSHOT`:return{type:`STATE_SNAPSHOT`,snapshot:n.snapshot};case`STATE_DELTA`:return{type:`STATE_DELTA`,delta:Array.isArray(n.delta)?n.delta:[]};case`MESSAGES_SNAPSHOT`:return{type:`MESSAGES_SNAPSHOT`,messages:Array.isArray(n.messages)?n.messages:[]};case`ACTIVITY_SNAPSHOT`:{let e=i(`activityType`);return!e||!TA(n.content)?null:wA({type:`ACTIVITY_SNAPSHOT`,activityType:e,content:n.content},{messageId:i(`messageId`),replace:typeof n.replace==`boolean`?n.replace:void 0})}case`RAW`:return wA({type:`RAW`,event:n.event},{source:i(`source`)});case`CUSTOM`:{let e=i(`name`);return e?{type:`CUSTOM`,name:e,value:n.value}:null}default:return wA({type:`RAW`,event:n},{source:SA(n.type)?n.type:void 0})}},kA=e=>{if(e.name===`AbortError`)return!0;let t=typeof e.message==`string`?e.message:``;return t===`Fetch is aborted`||t===`signal is aborted without reason`||t===`component unmounted`},AA=(e,t,n)=>{let r=n?{logger:n}:void 0,i;if(e&&typeof e==`object`){let n=e;i=typeof n.type==`string`?OA(n,r):OA({type:t,...n},r)}else i=OA({type:t},r);return i&&i.type===t?i:null},jA=e=>{let{dispatch:t,runId:n,logger:r,onRunFailed:i}=e,a=!1,o=(e,n)=>{let i=AA(e,n,r);i&&t(i)};return{onEvent:({event:e})=>{if(typeof(e&&typeof e==`object`?e.type:void 0)==`string`)return;let n=OA(e);n&&t(n)},onTextMessageStartEvent:({event:e})=>o(e,`TEXT_MESSAGE_START`),onTextMessageContentEvent:({event:e})=>o(e,`TEXT_MESSAGE_CONTENT`),onTextMessageEndEvent:({event:e})=>o(e,`TEXT_MESSAGE_END`),onTextMessageChunkEvent:({event:e})=>o(e,`TEXT_MESSAGE_CHUNK`),onThinkingStartEvent:({event:e})=>o(e,`THINKING_START`),onThinkingEndEvent:({event:e})=>o(e,`THINKING_END`),onThinkingTextMessageStartEvent:({event:e})=>o(e,`THINKING_TEXT_MESSAGE_START`),onThinkingTextMessageContentEvent:({event:e})=>o(e,`THINKING_TEXT_MESSAGE_CONTENT`),onThinkingTextMessageEndEvent:({event:e})=>o(e,`THINKING_TEXT_MESSAGE_END`),onReasoningStartEvent:({event:e})=>o(e,`REASONING_START`),onReasoningEndEvent:({event:e})=>o(e,`REASONING_END`),onReasoningMessageStartEvent:({event:e})=>o(e,`REASONING_MESSAGE_START`),onReasoningMessageContentEvent:({event:e})=>o(e,`REASONING_MESSAGE_CONTENT`),onReasoningMessageEndEvent:({event:e})=>o(e,`REASONING_MESSAGE_END`),onReasoningEncryptedValueEvent:({event:e})=>o(e,`REASONING_ENCRYPTED_VALUE`),onToolCallStartEvent:({event:e})=>o(e,`TOOL_CALL_START`),onToolCallArgsEvent:({event:e})=>o(e,`TOOL_CALL_ARGS`),onToolCallEndEvent:({event:e})=>o(e,`TOOL_CALL_END`),onToolCallChunkEvent:({event:e})=>o(e,`TOOL_CALL_CHUNK`),onToolCallResultEvent:({event:e})=>o(e,`TOOL_CALL_RESULT`),onActivitySnapshotEvent:({event:e})=>o(e,`ACTIVITY_SNAPSHOT`),onStateSnapshotEvent:({event:e})=>o(e,`STATE_SNAPSHOT`),onStateDeltaEvent:({event:e})=>o(e,`STATE_DELTA`),onMessagesSnapshotEvent:({event:e})=>o(e,`MESSAGES_SNAPSHOT`),onCustomEvent:({event:e})=>o(e,`CUSTOM`),onRawEvent:({event:e})=>o(e,`RAW`),onRunFinishedEvent:({event:e})=>{if(a)return;let n=AA(e,`RUN_FINISHED`,r);n&&(a=!0,t(n))},onRunErrorEvent:({event:e})=>{let n=AA(e,`RUN_ERROR`,r);if(!n||n.type!==`RUN_ERROR`)return;a=!0,t(n);let o=Object.assign(Error(n.message??`Run failed`),n.code===void 0?{}:{code:n.code});i?.(o)},onRunFinalized:()=>{a||t({type:`RUN_FINISHED`,runId:n})},onRunFailed:({error:e})=>{if(a=!0,i?.(e),kA(e)){t({type:`RUN_CANCELLED`});return}let n=typeof e.message==`string`?e.message:`Run failed`,r=typeof e?.code==`string`?e.code:void 0;t({type:`RUN_ERROR`,...n===void 0?{}:{message:n},...r===void 0?{}:{code:r}})}}},MA=`__optimistic__`,NA=()=>`${MA}${$y()}`,PA=e=>e.startsWith(MA),FA=e=>e.type===`tool-call`&&`result`in e&&e.result!==void 0,IA=Symbol(`agui-resume-shim`),LA={type:`complete`,reason:`unknown`},RA=(e,t)=>{console.error(`[react-ag-ui] ${e} callback threw an error`,t)},zA=(e,t,...n)=>{if(t)try{let r=t(...n);r!==null&&(typeof r==`object`||typeof r==`function`)&&`then`in r&&typeof r.then==`function`&&Promise.resolve(r).catch(t=>{RA(e,t)})}catch(t){RA(e,t)}},BA=(e,t)=>{let n={...e,...t},r=e?.[zk],i=t[zk];return typeof r==`object`&&r&&typeof i==`object`&&i&&(n[zk]={...r,...i}),n},VA=class{agent;logger;showThinking;autoCancelPendingToolCalls;onError;onCancel;notifyUpdate;reportedErrors=new WeakSet;runtime;repository=new Rx;exportedRepository;isRunningFlag=!1;abortController=null;activeRunAgent=null;stateSnapshot;pendingError=null;history;lastRunConfig;assistantHistoryParents=new Map;snapshotHistoryIds=new Set;persistedHistoryIds=new Set;historyWrites=new Map;_isLoading=!1;_loadPromise;pendingResumeMessageId=null;pendingA2uiResume=!1;pendingA2uiAction;constructor(e){this.agent=e.agent,this.logger=e.logger,this.showThinking=e.showThinking,this.autoCancelPendingToolCalls=e.autoCancelPendingToolCalls,this.onError=e.onError,this.onCancel=e.onCancel,this.history=e.history,this.notifyUpdate=e.notifyUpdate,this.installResumeShim()}updateOptions(e){this.agent=e.agent,this.logger=e.logger,this.showThinking=e.showThinking,this.autoCancelPendingToolCalls=e.autoCancelPendingToolCalls,this.onError=e.onError,this.onCancel=e.onCancel,this.history=e.history,this.installResumeShim()}attachRuntime(e){this.runtime=e}detachRuntime(){this.runtime=void 0,this.cancel().catch(e=>{this.logger.error(`[agui] failed to cancel run during teardown`,e)})}getMessages(){return this.repository.getMessages()}getMessageRepository(){if(this.exportedRepository)return this.exportedRepository;let e=this.repository.export(),t=null;for(let n of this.repository.getMessages())n.metadata.isOptimistic&&e.messages.push({parentId:t,message:n}),t=n.id;return this.exportedRepository={...e,headId:this.repository.headId},this.exportedRepository}tryGetMessage(e){try{return this.repository.getMessage(e)}catch{return}}tryGetMessages(e){try{return this.repository.getMessages(e)}catch{return}}hasMessage(e){return this.tryGetMessage(e)!==void 0}addOrUpdateMessage(e,t){this.repository.addOrUpdateMessage(e,t),this.exportedRepository=void 0}deleteMessage(e,t){this.repository.deleteMessage(e,t),this.exportedRepository=void 0}tryDeleteMessage(e){return this.hasMessage(e)?(this.deleteMessage(e),!0):!1}switchToBranch(e){this.repository.switchToBranch(e),this.exportedRepository=void 0}resetRepositoryHead(e){this.repository.resetHead(e),this.exportedRepository=void 0}clearRepository(){this.repository.clear(),this.exportedRepository=void 0}updateMessage(e,t){let n=this.tryGetMessage(e);if(!n)return!1;let r=t(n.message);return r!==n.message&&(this.addOrUpdateMessage(n.parentId,r),!0)}getState(){return this.stateSnapshot}isRunning(){return this.isRunningFlag}get isLoading(){return this._isLoading}__internal_load(){if(this._loadPromise)return this._loadPromise;let e=this.history?.load()??Promise.resolve(null);return this._isLoading=!0,this._loadPromise=e.then(async e=>{if(e&&(this.applyExternalMessageRepository(e),e.state!==void 0&&this.loadExternalState(e.state),e.unstable_resume)){let t=e.headId??this.repository.headId,n=this.history?.resume?.bind(this.history);await this.startRun(t,this.lastRunConfig,void 0,n)}}).catch(e=>{this.logger.error?.(`[agui] failed to load history`,e),zA(`onError`,this.onError,e instanceof Error?e:Error(String(e)))}).finally(()=>{this._isLoading=!1,this.notifyUpdate()}),this.notifyUpdate(),this._loadPromise}async append(e){let t=e.startRun??e.role===`user`;t&&(this.assertNoPendingInterrupts(),this.maybeAutoCancelPendingToolCalls());let n=this.appendEntry(e);t&&await this.startRun(n,e.runConfig)}maybeAutoCancelPendingToolCalls(){if(this.autoCancelPendingToolCalls===!1)return;let e=this.getPendingToolCalls();e&&(this.cancelUnresolvedToolCalls(e.messageId),this.maybeCompleteAfterToolResults(e.messageId))}appendEntry(e){e.sourceId&&this.tryDeleteMessage(e.sourceId);let t=this.toThreadMessage(e),n=e.parentId===null?null:e.parentId&&this.hasMessage(e.parentId)?e.parentId:this.repository.headId;return this.addOrUpdateMessage(n,t),this.switchToBranch(t.id),this.notifyUpdate(),this.recordHistoryEntry(n,t),t.id}async edit(e){await this.append(e)}async reload(e,t={}){this.assertNoPendingInterrupts(),this.maybeAutoCancelPendingToolCalls(),await this.startRun(e,t.runConfig)}async cancel(){if(this.abortController)try{(this.activeRunAgent??this.agent).abortRun()}finally{this.abortController.abort()}}async resume(e){this.assertNoPendingInterrupts(),await this.startRun(e.parentId,e.runConfig??this.lastRunConfig,void 0,e.stream)}async resumeInFlightRun(e){let t=this.history?.resume?.bind(this.history);if(!t){let e=Error(`[agui] unstable_resume requires a ThreadHistoryAdapter with a resume() method; skipping resume after thread switch`);this.logger.error?.(e.message),zA(`onError`,this.onError,e);return}let n=e.at(-1)?.id??null;try{await this.startRun(n,this.lastRunConfig,void 0,t)}catch{}}assertNoPendingInterrupts(){if(this.getPendingInterrupts())throw Error(`[agui] cannot start a new run while interrupts are pending; resolve them with submitInterruptResponses()`)}findRequiresActionAssistant(e){let t=this.getMessages().findLast(e=>e.role===`assistant`);return!t||t.status?.type!==`requires-action`||t.status.reason!==e?null:t}getPendingInterrupts(){let e=this.findRequiresActionAssistant(`interrupt`);if(!e)return null;let t=e.metadata.custom[zk]?.interrupts;return t?.length?{messageId:e.id,interrupts:t}:null}getPendingToolCalls(){let e=this.findRequiresActionAssistant(`tool-calls`);if(!e)return null;let t=[];for(let n of e.content)n.type===`tool-call`&&(FA(n)||t.push(n.toolCallId));return t.length===0?null:{messageId:e.id,toolCallIds:t}}async submitInterruptResponses(e){let t=this.getPendingInterrupts();if(!t)throw Error(`[agui] submitInterruptResponses: no pending interrupts on this thread`);let n=this.collectInterruptResponses(`submitInterruptResponses`,t.interrupts,e),r=t.interrupts.map(e=>e.id),i=r.filter(e=>!n.has(e));if(i.length>0)throw Error(`[agui] submitInterruptResponses: missing responses for open interrupts: ${i.join(`, `)}`);this.assertInterruptsAnswerable(`submitInterruptResponses`,t.interrupts),await this.resumeWithResponses(t.messageId,r.map(e=>n.get(e)))}async resumeWithResponses(e,t){this.clearPendingInterrupts(e,t),await this.startRun(e,this.lastRunConfig,t)}reportError(e){if(this.reportedErrors.has(e)){this.reportedErrors.delete(e);return}zA(`onError`,this.onError,e instanceof Error?e:Error(String(e)))}assertInterruptsAnswerable(e,t){let n=Date.now();for(let r of t){if(!r.expiresAt)continue;let t=new Date(r.expiresAt).getTime();if(Number.isNaN(t))throw Error(`[agui] ${e}: interrupt ${r.id} has malformed expiresAt "${r.expiresAt}"`);if(t<=n)throw Error(`[agui] ${e}: interrupt ${r.id} expired at ${r.expiresAt}`)}if(this.isRunningFlag)throw Error(`[agui] ${e}: a run is already in progress`)}async respondToToolApproval(e){let t=this.getPendingInterrupts();if(!t)throw Error(`[agui] respondToToolApproval: no pending interrupts on this thread`);let n=this.tryGetMessage(t.messageId)?.message;if(![...ZO(t.interrupts,new Set((n?.content??[]).filter(e=>e.type===`tool-call`).map(e=>e.toolCallId))).values()].some(t=>t.id===e.approvalId))throw Error(`[agui] respondToToolApproval: no pending tool-call interrupt for approval id "${e.approvalId}"`);if(this.assertInterruptsAnswerable(`respondToToolApproval`,t.interrupts),!this.updateMessage(t.messageId,t=>{if(t.role!==`assistant`)return t;let n=t,r=QO(n.content,e);return r===n.content?n:{...n,content:r}}))throw Error(`[agui] respondToToolApproval: approval "${e.approvalId}" is already decided`);this.notifyUpdate();let r=this.tryGetMessage(t.messageId)?.message;if(!r)return;let i=$O(r.content,t.interrupts);i&&await this.resumeWithResponses(t.messageId,i)}async steerAway(e,t){let n=this.getPendingInterrupts();if(!n){let n=this.getPendingToolCalls();if(n){if(t?.length)throw Error(`[agui] steerAway: responses are only valid for pending interrupts`);if(this.isRunningFlag)throw Error(`[agui] steerAway: a run is already in progress`);this.cancelUnresolvedToolCalls(n.messageId),this.maybeCompleteAfterToolResults(n.messageId);let r=this.toAppendMessage(e),i=this.appendEntry(r);await this.startRun(i,r.runConfig);return}if(t?.length)throw Error(`[agui] steerAway: no pending interrupts on this thread`);await this.append(this.toAppendMessage(e));return}let r=this.resolveSteerAwayResume(n.interrupts,t);if(this.isRunningFlag)throw Error(`[agui] steerAway: a run is already in progress`);let i=this.toAppendMessage(e);this.clearPendingInterrupts(n.messageId,r);let a=this.appendEntry(i);await this.startRun(a,i.runConfig,r)}resolveSteerAwayResume(e,t){let n=this.collectInterruptResponses(`steerAway`,e,t??[]);return e.map(e=>n.get(e.id)??{interruptId:e.id,status:`cancelled`})}collectInterruptResponses(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Map;for(let t of n){if(!t||typeof t.interruptId!=`string`)throw Error(`[agui] ${e}: every entry must have an interruptId`);if(t.status!==`resolved`&&t.status!==`cancelled`)throw Error(`[agui] ${e}: invalid status "${t.status}" for interrupt ${t.interruptId}`);if(!r.has(t.interruptId))throw Error(`[agui] ${e}: unknown interrupt id ${t.interruptId}`);if(i.has(t.interruptId))throw Error(`[agui] ${e}: duplicate response for interrupt ${t.interruptId}`);i.set(t.interruptId,t)}return i}toAppendMessage(e){return typeof e==`string`?{createdAt:new Date,parentId:this.repository.headId,sourceId:null,runConfig:{},role:`user`,content:[{type:`text`,text:e}],attachments:[],metadata:{custom:{}}}:{createdAt:e.createdAt??new Date,parentId:e.parentId??this.repository.headId,sourceId:e.sourceId??null,role:e.role??`user`,content:e.content,attachments:e.attachments??[],metadata:e.metadata??{custom:{}},runConfig:e.runConfig??{},startRun:e.startRun}}clearPendingInterrupts(e,t){this.updateMessage(e,e=>{if(e.role!==`assistant`)return e;let n=e;if(n.status?.type!==`requires-action`||n.status.reason!==`interrupt`)return n;let{interrupts:r,...i}=n.metadata.custom.agui??{},a={...n.metadata.custom};return Object.keys(i).length>0?a.agui=i:delete a.agui,{...n,content:tk(n.content,t),status:{type:`complete`,reason:`unknown`},metadata:{...n.metadata,custom:a}}})&&this.notifyUpdate()}findMessageIdForToolCall(e){let t,n=this.getMessages();for(let r=n.length-1;r>=0;r--){let i=n[r];if(!(!i||i.role!==`assistant`)){for(let n of i.content)if(n.type===`tool-call`&&n.toolCallId===e){if(!FA(n))return i.id;t??=i.id}}}return t}cancelUnresolvedToolCalls(e){this.updateMessage(e,e=>{if(e.role!==`assistant`)return e;let t=e,n=t.content.map(e=>e.type!==`tool-call`||FA(e)?e:{...e,result:{error:`Tool call cancelled by user`},isError:!0});return{...t,content:n}})&&this.notifyUpdate()}addToolResult(e){this.updateMessage(e.messageId,t=>{if(t.role!==`assistant`)return t;let n=t,r=!1,i=n.content.map(t=>t.type!==`tool-call`||t.toolCallId!==e.toolCallId?t:(r=!0,{...t,result:e.result,artifact:e.artifact,isError:e.isError}));return r?{...n,content:i}:t})&&(this.notifyUpdate(),this.maybeResumeAfterToolResults(e.messageId))}sendA2uiAction(e){this.assertNoPendingInterrupts(),this.maybeAutoCancelPendingToolCalls();let t=this.repository.headId;if(t===null){this.logger.debug(`[agui] sendA2uiAction: no messages to resume, dropping action`);return}let n={...e};if(delete n.type,`timestamp`in n||(n.timestamp=new Date().toISOString()),this.pendingA2uiAction=n,this.isRunningFlag){this.pendingA2uiResume=!0;return}this.startResumeRun(t)}maybeResumeAfterToolResults(e){if(this.maybeCompleteAfterToolResults(e)){if(this.isRunningFlag){this.pendingResumeMessageId=e;return}this.startResumeRun(e)}}maybeCompleteAfterToolResults(e){let t=this.tryGetMessage(e)?.message;if(!t||t.role!==`assistant`)return!1;let n=t;return n.status?.type!==`requires-action`||n.status.reason!==`tool-calls`||!n.content.every(e=>e.type!==`tool-call`||FA(e))||!this.updateMessage(e,e=>e.role===`assistant`?{...e,status:{type:`complete`,reason:`unknown`}}:e)?!1:(this.notifyUpdate(),this.persistAssistantHistory(e),!0)}startResumeRun(e){this.startRun(e,this.lastRunConfig).catch(e=>{zA(`onError`,this.onError,e instanceof Error?e:Error(String(e)))})}applyExternalMessages(e){if(this.pendingA2uiResume=!1,this.pendingA2uiAction=void 0,this.assistantHistoryParents.clear(),e.length===0)this.clearRepository();else{let t=null,n=null,r=!1,i=new Set;for(let a of e){if(i.has(a.id))continue;i.add(a.id);let e=this.tryGetMessage(a.id);if(e&&e.parentId!==t){r=!0;break}this.addOrUpdateMessage(t,a),t=a.id,n=a.id}if(r){this.clearRepository(),t=null,n=null,i.clear();for(let r of e)i.has(r.id)||(i.add(r.id),this.addOrUpdateMessage(t,r),t=r.id,n=r.id)}this.resetRepositoryHead(n)}this.snapshotHistoryIds.clear();for(let{message:e}of this.getMessageRepository().messages)this.snapshotHistoryIds.add(e.id);this.notifyUpdate()}applyExternalMessageRepository(e){let t=e.headId??e.messages.at(-1)?.message.id??null,n=new Set,r=!1;for(let{message:t}of e.messages){if(n.has(t.id)){r=!0;break}n.add(t.id)}if(t!==null&&!n.has(t)&&(r=!0),!r){this.clearRepository();let t=[...e.messages],n=new Set;for(;t.length>0;){let e=[],i=!1;for(let r of t){if(r.parentId!==null&&!n.has(r.parentId)){e.push(r);continue}this.addOrUpdateMessage(r.parentId,r.message),n.add(r.message.id),i=!0}if(!i){r=!0;break}t=e}}if(r){this.clearRepository();let t=null;for(let{message:n}of e.messages){let e=this.tryGetMessage(n.id);this.addOrUpdateMessage(e?e.parentId:t,n),t=n.id}this.resetRepositoryHead(t)}else this.resetRepositoryHead(t);this.assistantHistoryParents.clear(),this.snapshotHistoryIds.clear(),this.persistedHistoryIds.clear();for(let{message:t}of e.messages)this.persistedHistoryIds.add(t.id);this.notifyUpdate()}loadExternalState(e){this.stateSnapshot=e,this.notifyUpdate()}setState(e){this.stateSnapshot=typeof e==`function`?e(this.stateSnapshot):e,this.notifyUpdate()}resetState(){this.stateSnapshot=void 0,this.notifyUpdate()}async startRun(e,t,n,r){let i=t??{};this.lastRunConfig=i;let a=e===null?void 0:this.tryGetMessage(e),o=e!==null&&a!==void 0&&e!==this.repository.headId,s=[...o?this.tryGetMessages(e)??this.repository.getMessages():this.repository.getMessages()],c=new Set(this.getMessageRepository().messages.map(({message:e})=>e.id));this.pendingError=null;let l=a?e:this.repository.headId,u,d=!1,f=(e=!1)=>{let t=u;if(t!==void 0&&this.tryGetMessage(t)||t!==void 0&&(d||!e))return t;let n=this.repository.headId,r=(t===void 0||o&&(n===null||c.has(n)))&&l&&this.hasMessage(l)?l:n,i=this.insertAssistantPlaceholder(r,t);return u=i,this.markPendingAssistantHistory(i,r),i};o&&f();let p=e=>{let t=Array.isArray(e.content)&&e.content.some(e=>e.type!==`data`),n=this.updateAssistantMessage(f(t),e);n!==u&&(u=n)},m=new Vk({showThinking:this.showThinking,logger:this.logger,emit:p,onServerMessageId:e=>{let t=f(!0);if(t===e)return;let n=this.reassignAssistantId(t,e),r=!n&&!c.has(e)&&this.repository.headId===e;if(n||r){if(u=e,r){let t=this.tryGetMessage(e)?.parentId??null;this.markPendingAssistantHistory(e,t)}}else d=!0}}),h=e=>this.handleEvent(m,e,u),g=new AbortController,_=g.signal;this.abortController=g;let v=this.agent;this.activeRunAgent=v;let y=()=>h({type:`RUN_CANCELLED`});_.addEventListener(`abort`,()=>{y(),this.finishRun(g),zA(`onCancel`,this.onCancel)},{once:!0}),this.setRunning(!0);try{if(r)y=()=>p({status:{type:`incomplete`,reason:`cancelled`}}),await this.consumeResumeStream(r,{runConfig:i,threadId:this.agent.threadId||`main`,parentId:l,historicalMessages:s,abortSignal:_,ensureAssistant:f,applyUpdate:p,getAssistantMessageId:()=>u});else{let e=$y();m.handle({type:`RUN_STARTED`,runId:e});let t=this.buildRunInput(e,i,s,n),r=jA({dispatch:h,runId:e,logger:this.logger,onRunFailed:e=>{_.aborted||(this.pendingError=e,zA(`onError`,this.onError,e))}});try{v.messages=t.messages,v.threadId=t.threadId,v.state=t.state??null}catch{}await v.runAgent.bind(v)(t,r,{signal:_})}}catch(e){if(!_.aborted){let t=e instanceof Error?e:Error(String(e));h({type:`RUN_ERROR`,message:t.message}),zA(`onError`,this.onError,t),this.pendingError=this.pendingError??t}}finally{this.finishRun(g)}if(this.pendingError){let e=this.pendingError;throw this.reportedErrors.add(e),this.pendingError=null,this.pendingResumeMessageId=null,this.pendingA2uiResume=!1,this.pendingA2uiAction=void 0,e}if(this.pendingResumeMessageId!==null){let e=this.pendingResumeMessageId;this.pendingResumeMessageId=null,_.aborted?this.pendingA2uiAction=void 0:this.startResumeRun(e)}if(this.pendingA2uiResume){if(this.pendingA2uiResume=!1,!_.aborted&&this.pendingA2uiAction!==void 0){if(this.getPendingInterrupts()){this.pendingA2uiAction=void 0,this.logger.debug(`[agui] sendA2uiAction: pending interrupts, dropping action`);return}this.maybeAutoCancelPendingToolCalls();let e=this.repository.headId;e===null?(this.pendingA2uiAction=void 0,this.logger.debug(`[agui] sendA2uiAction: no messages to resume, dropping action`)):this.startResumeRun(e)}else this.pendingA2uiAction=void 0}}async consumeResumeStream(e,t){this.pendingA2uiAction=void 0,this.pendingA2uiResume=!1;let n=t.ensureAssistant(),r=()=>t.getAssistantMessageId()??n,i={messages:t.historicalMessages,runConfig:t.runConfig,abortSignal:t.abortSignal,context:this.runtime?.thread.getModelContext()??{},unstable_assistantMessageId:n,unstable_threadId:t.threadId,unstable_parentId:t.parentId,unstable_getMessage:()=>{let e=this.tryGetMessage(r())?.message;if(!e)throw Error(`[agui] resume stream requested the assistant message before it existed`);return e}};try{for await(let n of e(i)){if(t.abortSignal.aborted)return;t.applyUpdate(n)}}catch(e){if(t.abortSignal.aborted)return;let n=e instanceof Error?e:Error(String(e));t.applyUpdate({status:{type:`incomplete`,reason:`error`,error:n.message}}),zA(`onError`,this.onError,n),this.pendingError=this.pendingError??n;return}if(t.abortSignal.aborted)return;let a=this.tryGetMessage(r())?.message;(!a||a.status?.type===`running`)&&t.applyUpdate({status:{type:`complete`,reason:`unknown`}})}buildRunInput(e,t,n,r){let i=this.agent.threadId||`main`,a=yA(n??this.repository.getMessages()),o=this.runtime?.thread.getModelContext(),s={threadId:i,runId:e,state:this.stateSnapshot??null,messages:a,tools:bA(o?.tools),context:o?.system?[{description:`system`,value:o.system}]:[],forwardedProps:{...o?.callSettings??{},...o?.config??{},...t?.custom?{runConfig:t.custom}:{},...this.pendingA2uiAction?{a2uiAction:{userAction:this.pendingA2uiAction}}:{}},...r===void 0?{}:{resume:r}};return this.pendingA2uiAction=void 0,s}installResumeShim(){let e=this.agent;if(e[IA])return;e[IA]=!0;let t=Object.hasOwn(e,`prepareRunAgentInput`)?e.prepareRunAgentInput:Object.getPrototypeOf(e)?.prepareRunAgentInput;typeof t==`function`&&(e.prepareRunAgentInput=function(e){let n=t.call(this,e);return e?.resume!==void 0&&n&&typeof n==`object`?{...n,resume:e.resume}:n})}setRunning(e){this.isRunningFlag=e,this.notifyUpdate()}finishRun(e){this.abortController===e&&(this.abortController=null,this.activeRunAgent=null),this.setRunning(!1)}insertAssistantPlaceholder(e,t=NA()){let n={id:t,role:`assistant`,createdAt:new Date,status:{type:`running`},content:[],metadata:{unstable_state:this.stateSnapshot??null,unstable_annotations:[],unstable_data:[],steps:[],isOptimistic:PA(t),custom:{}}};return this.addOrUpdateMessage(e??this.repository.headId,n),this.switchToBranch(t),this.notifyUpdate(),t}reassignAssistantId(e,t){if(e===t)return!0;let n=this.tryGetMessage(e);if(!n)return!1;let r=this.hasMessage(t);if(r)this.logger.debug?.(`[agui] reassignAssistantId: server id already present in messages or repository, dropping placeholder`,{oldId:e,newId:t}),this.deleteMessage(e,n.parentId??null);else{let{isOptimistic:r,...i}=n.message.metadata;this.addOrUpdateMessage(n.parentId,{...n.message,id:t,metadata:i}),this.switchToBranch(t),this.tryDeleteMessage(e)}let i=this.assistantHistoryParents.get(e);i!==void 0&&(this.assistantHistoryParents.delete(e),!r&&!this.assistantHistoryParents.has(t)&&this.assistantHistoryParents.set(t,i));for(let n of[this.snapshotHistoryIds,this.persistedHistoryIds])n.has(e)&&(n.delete(e),r||n.add(t));let a=this.historyWrites.get(e);if(a&&(this.historyWrites.delete(e),!r)){this.historyWrites.set(t,a);let n=()=>{this.historyWrites.get(t)===a&&this.historyWrites.delete(t)};a.then(()=>{this.persistedHistoryIds.delete(e),this.persistedHistoryIds.add(t),n()},n)}return this.notifyUpdate(),!r}updateAssistantMessage(e,t){let n;if(!this.updateMessage(e,e=>{if(e.role!==`assistant`)return e;let r=e,i=t.metadata?this.mergeAssistantMetadata(r.metadata,t.metadata):r.metadata;n=t.status??r.status;let a=t.content===void 0?r.content:this.preserveToolResults(r.content,t.content);return{...r,content:a,status:n,metadata:i}}))return e;let r=e;if(n!==void 0&&n.type!==`running`&&PA(e)){let t=$y();this.reassignAssistantId(e,t),r=t}else this.notifyUpdate();return this.isPersistableStatus(n)&&this.persistAssistantHistory(r),this.maybeResumeAfterToolResults(r),r}preserveToolResults(e,t){let n=new Map;for(let t of e)t.type===`tool-call`&&FA(t)&&n.set(t.toolCallId,t);if(n.size===0)return t;let r=!1,i=t.map(e=>{if(e.type!==`tool-call`||FA(e))return e;let t=n.get(e.toolCallId);return t?(r=!0,{...e,result:t.result,...t.artifact===void 0?{}:{artifact:t.artifact},...t.isError===void 0?{}:{isError:t.isError}}):e});return r?i:t}mergeAssistantMetadata(e,t){let n=t.unstable_annotations?[...e.unstable_annotations,...t.unstable_annotations]:e.unstable_annotations,r=t.unstable_data?[...e.unstable_data,...t.unstable_data]:e.unstable_data,i=t.steps?[...e.steps,...t.steps]:e.steps;return{unstable_state:t.unstable_state===void 0?e.unstable_state:t.unstable_state,unstable_annotations:n,unstable_data:r,steps:i,...e.isOptimistic?{isOptimistic:!0}:{},...t.timing?{timing:t.timing}:{},custom:t.custom?BA(e.custom,t.custom):e.custom}}handleEvent(e,t,n){switch(t.type){case`STATE_SNAPSHOT`:this.stateSnapshot=t.snapshot,this.notifyUpdate();return;case`STATE_DELTA`:if(t.delta.length===0)return;try{let e=this.stateSnapshot??{},n=Fo.applyPatch(e,t.delta,!0,!1);this.stateSnapshot=n.newDocument,this.notifyUpdate()}catch(e){this.logger.error?.(`[agui] failed to apply state delta`,e)}return;case`MESSAGES_SNAPSHOT`:this.importMessagesSnapshot(t.messages,n);return;case`TOOL_CALL_RESULT`:if(!e.hasToolCall(t.toolCallId)){let e=this.findMessageIdForToolCall(t.toolCallId);if(e!==void 0){this.applyCrossRunToolResult(e,t);return}}e.handle(t);return;case`ACTIVITY_SNAPSHOT`:{let n=t.content.toolCallId;if(t.activityType===`mcp-apps`&&typeof n==`string`&&!e.hasToolCall(n)){let e=this.findMessageIdForToolCall(n);if(e!==void 0){this.applyCrossRunActivitySnapshot(e,n,t);return}}e.handle(t);return}default:e.handle(t)}}applyCrossRunToolResult(e,t){this.updateMessage(e,e=>{if(e.role!==`assistant`)return e;let n=e,r=AO(t.mcpResult?._meta),i=!1,a=n.content.map(e=>e.type!==`tool-call`||e.toolCallId!==t.toolCallId?e:(i=!0,e.mcp?.app!==void 0&&Bk(e.result)&&Array.isArray(e.result.content)?{...e,...e.modelContent===void 0&&t.content?{modelContent:[{type:`text`,text:t.content}]}:{},...e.isError===void 0?typeof t.mcpResult?.isError==`boolean`?{isError:t.mcpResult.isError}:t.role===`tool`?{isError:!1}:{}:{},...t.messageId?{unstable_toolMessageId:t.messageId}:{}}:{...e,result:t.mcpResult??Hk(t.content??``),...t.mcpResult===void 0?{}:{modelContent:[{type:`text`,text:t.content}]},...typeof t.mcpResult?.isError==`boolean`?{isError:t.mcpResult.isError}:t.role===`tool`?{isError:!1}:{},...e.mcp===void 0&&r!==void 0?{mcp:{app:{resourceUri:r}}}:{},...t.messageId?{unstable_toolMessageId:t.messageId}:{}}));return i?{...n,content:a}:e})&&(this.notifyUpdate(),this.maybeCompleteAfterToolResults(e))}applyCrossRunActivitySnapshot(e,t,n){let r=n.content.resourceUri;if(typeof r!=`string`||!_S(r))return;let i=n.content.serverId,a=n.content.serverHash,o=typeof i==`string`&&i.length>0?i:typeof a==`string`&&a.length>0?a:void 0,s=n.content.result;this.updateMessage(e,e=>{if(e.role!==`assistant`)return e;let n=e,i=!1,a=n.content.map(e=>e.type!==`tool-call`||e.toolCallId!==t?e:(i=!0,{...e,mcp:{app:{resourceUri:r,...o?{serverId:o}:{}}},...Bk(s)?{...e.result!==void 0&&e.modelContent===void 0?{modelContent:[{type:`text`,text:typeof e.result==`string`?e.result:JSON.stringify(e.result)}]}:{},result:s,isError:s.isError===!0}:{}}));return i?{...n,content:a}:e})&&(this.notifyUpdate(),this.maybeCompleteAfterToolResults(e))}importMessagesSnapshot(e,t){try{let n=t?this.tryGetMessage(t)?.message:void 0,r=n?.role===`assistant`?n:void 0,i=gA(e,{showThinking:this.showThinking}),a=[];for(let e of i)try{a.push(rb(e,$y(),LA))}catch(e){this.logger.error?.(`[agui] failed to import message from snapshot`,e)}let o=a.some(e=>e.id===r?.id),s=r!==void 0&&!o&&(r.metadata.isOptimistic!==!0||a.at(-1)?.role!==`assistant`);if(s&&a.push(r),this.applyExternalMessages(a),r!==void 0){let e=this.tryGetMessage(r.id);e&&(s&&this.snapshotHistoryIds.delete(r.id),this.markPendingAssistantHistory(r.id,e.parentId))}}catch(e){this.logger.error?.(`[agui] failed to import messages snapshot`,e)}}toThreadMessage(e){return rb(e,$y(),LA)}isTerminalStatus(e){return e?.type===`complete`||e?.type===`incomplete`}isPersistableStatus(e){return this.isTerminalStatus(e)?!0:e?.type===`requires-action`&&e.reason===`interrupt`}recordHistoryEntry(e,t){this.appendHistoryItem(e,t)?.catch(e=>{this.logger.error?.(`[agui] failed to append history entry`,e)})}markPendingAssistantHistory(e,t){this.history&&this.assistantHistoryParents.set(e,t)}persistAssistantHistory(e){let t=this.history;if(!t)return;let n=this.assistantHistoryParents.get(e);if(n===void 0)return;let r=this.tryGetMessage(e)?.message;if(!r||r.role!==`assistant`||!this.isPersistableStatus(r.status))return;let i=this.persistedHistoryIds.has(e),a=t.update;if(a!==void 0&&(i||this.snapshotHistoryIds.has(e))){let i=this.chainHistoryWrite(e,()=>a.call(t,{parentId:n,message:r}));this.assistantHistoryParents.delete(e),i.then(()=>{this.persistedHistoryIds.add(e)},t=>{let r=this.historyWrites.get(e);(r===void 0||r===i)&&this.assistantHistoryParents.set(e,n),this.logger.error?.(`[agui] failed to update history entry`,t)});return}if(i){this.assistantHistoryParents.delete(e);return}let o=this.appendHistoryItem(n,r);o&&(this.assistantHistoryParents.delete(e),o.then(()=>{},t=>{let r=this.historyWrites.get(e);(r===void 0||r===o)&&this.assistantHistoryParents.set(e,n),this.logger.error?.(`[agui] failed to append history entry`,t)}))}appendHistoryItem(e,t){if(!this.history||this.persistedHistoryIds.has(t.id))return;let n=this.historyWrites.get(t.id);if(n)return n;let r=this.history.append.bind(this.history),i=this.chainHistoryWrite(t.id,()=>r({parentId:e,message:t}));return i.then(()=>{this.persistedHistoryIds.add(t.id)},()=>{}),i}chainHistoryWrite(e,t){let n=this.historyWrites.get(e),r;if(n)r=n.then(t,t);else try{r=Promise.resolve(t())}catch(e){r=Promise.reject(e)}return this.historyWrites.set(e,r),r.then(()=>{this.historyWrites.get(e)===r&&this.historyWrites.delete(e)},()=>{this.historyWrites.get(e)===r&&this.historyWrites.delete(e)}),r}},HA=[],UA=Object.freeze([]),WA=()=>()=>{};function GA(e){let t=(0,S.useMemo)(()=>xA(e.logger),[e.logger]),[n,r]=(0,S.useState)(0),i=(0,S.useCallback)(()=>r(e=>e+1),[]),a=(0,S.useRef)(null),o=Gy(),s=e.adapters?.history??o?.history,c=e.adapters?.threadList;a.current||=new VA({agent:e.agent,logger:t,showThinking:e.showThinking??!0,autoCancelPendingToolCalls:e.autoCancelPendingToolCalls,...e.onError&&{onError:e.onError},...e.onCancel&&{onCancel:e.onCancel},...s&&{history:s},notifyUpdate:i});let l=a.current;l.updateOptions({agent:e.agent,logger:t,showThinking:e.showThinking??!0,autoCancelPendingToolCalls:e.autoCancelPendingToolCalls,...e.onError&&{onError:e.onError},...e.onCancel&&{onCancel:e.onCancel},...s&&{history:s}});let[u,d]=(0,S.useState)({}),f=Object.values(u).some(e=>e?.type===`executing`),p=l.isRunning()||f,m=(0,S.useRef)(null),h=(0,S.useRef)(0);e.unstable_enableMessageQueue&&!m.current?m.current=yS({run:e=>{let n=m.current,r=h.current,i=()=>{m.current===n&&h.current===r&&l.getPendingInterrupts()===null&&n?.notifyIdle()};l.append(e).then(i,e=>{i(),t.error?.(`[agui] queued message failed to send`,e)})}}):!e.unstable_enableMessageQueue&&m.current&&(m.current.clear(),m.current=null);let g=e.unstable_enableMessageQueue?m.current:null,_=(0,S.useSyncExternalStore)(g?.subscribe??WA,()=>g?.adapter.items??UA,()=>UA),v=(0,S.useSyncExternalStore)(g?.subscribe??WA,()=>g?.adapter.steerItems??UA,()=>UA),y=p||l.getPendingInterrupts()!==null;(0,S.useEffect)(()=>{y?(h.current++,g?.notifyBusy()):g?.notifyIdle()},[y,g]);let b=(0,S.useMemo)(()=>{if(!c)return;let{onSwitchToNewThread:e,onSwitchToThread:t,...n}=c;return{...n,onSwitchToNewThread:e?async()=>{await e(),l.applyExternalMessages([]),l.resetState()}:void 0,onSwitchToThread:t?async e=>{l.applyExternalMessages([]);let n=await t(e);l.applyExternalMessages(n.messages),n.state===void 0?l.resetState():l.loadExternalState(n.state),n.unstable_resume&&l.resumeInFlightRun(n.messages)}:void 0}},[c,l]),x=e.adapters,C=(0,S.useMemo)(()=>({attachments:x?.attachments??o?.attachments,speech:x?.speech,dictation:x?.dictation,voice:x?.voice,feedback:x?.feedback,threadList:b}),[x,o,b]),w=fS(e),ee=dS((0,S.useMemo)(()=>({...w,isLoading:l.isLoading,messageRepository:l.getMessageRepository(),state:l.getState(),isRunning:p,extras:OO.provide({interrupts:l.getPendingInterrupts()?.interrupts??HA,sendA2uiAction:e=>l.sendA2uiAction(e),submitInterruptResponses:e=>l.submitInterruptResponses(e),steerAway:(e,t)=>l.steerAway(e,t),state:l.getState(),setState:e=>l.setState(e)}),unstable_enableToolInvocations:!0,setToolStatuses:d,onNew:e=>l.append(e),onEdit:e=>(g?.clear(),l.edit(e)),onReload:(e,t)=>(g?.clear(),l.reload(e,t)),onCancel:async()=>{g?.notifyCancelled(),l.cancel()},onAddToolResult:e=>l.addToolResult(e),onRespondToToolApproval:e=>l.respondToToolApproval(e).catch(e=>{l.reportError(e)}),onResume:e=>l.resume(e),setMessages:e=>l.applyExternalMessages(e),onImport:e=>l.applyExternalMessages(e),onLoadExternalState:e=>l.loadExternalState(e),adapters:C,...g&&{queue:g.adapter}}),[C,l,n,p,g,_,v,w])),te=(0,S.useMemo)(()=>{let e=Object.create(ee);return e.unstable_getPendingInterrupts=()=>l.getPendingInterrupts()?.interrupts??[],e.unstable_submitInterruptResponses=e=>l.submitInterruptResponses(e),e},[ee,l]);return(0,S.useEffect)(()=>(l.attachRuntime(te),()=>{l.detachRuntime()}),[l,te]),(0,S.useEffect)(()=>{l.__internal_load()},[l]),te}var KA=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),qA=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),JA=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),YA=e=>{let t=JA(e);return t.charAt(0).toUpperCase()+t.slice(1)},XA={xmlns:`http://www.w3.org/2000/svg`,width:24,height:24,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`},ZA=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},QA=(0,S.createContext)({}),$A=()=>(0,S.useContext)(QA),ej=(0,S.forwardRef)(({color:e,size:t,strokeWidth:n,absoluteStrokeWidth:r,className:i=``,children:a,iconNode:o,...s},c)=>{let{size:l=24,strokeWidth:u=2,absoluteStrokeWidth:d=!1,color:f=`currentColor`,className:p=``}=$A()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,S.createElement)(`svg`,{ref:c,...XA,width:t??l??XA.width,height:t??l??XA.height,stroke:e??f,strokeWidth:m,className:KA(`lucide`,p,i),...!a&&!ZA(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,S.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),tj=(e,t)=>{let n=(0,S.forwardRef)(({className:n,...r},i)=>(0,S.createElement)(ej,{ref:i,iconNode:t,className:KA(`lucide-${qA(YA(e))}`,`lucide-${e}`,n),...r}));return n.displayName=YA(e),n},nj=tj(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),rj=tj(`circle-plus`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}],[`path`,{d:`M12 8v8`,key:`napkw2`}]]),ij=tj(`loader-circle`,[[`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`,key:`13zald`}]]),aj=tj(`send-horizontal`,[[`path`,{d:`M3.714 3.048a.498.498 0 0 0-.683.627l2.843 7.627a2 2 0 0 1 0 1.396l-2.842 7.627a.498.498 0 0 0 .682.627l18-8.5a.5.5 0 0 0 0-.904z`,key:`117uat`}],[`path`,{d:`M6 12h16`,key:`s4cdu5`}]]),oj=tj(`server-off`,[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),sj=tj(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);function cj(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=cj(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function lj(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=cj(e))&&(r&&(r+=` `),r+=t);return r}var uj=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,dj=lj,fj=(e,t)=>n=>{if(t?.variants==null)return dj(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=uj(t)||uj(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return dj(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},pj=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},mj=(e,t)=>({classGroupId:e,validator:t}),hj=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),gj=`-`,_j=[],vj=`arbitrary..`,yj=e=>{let t=Sj(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return xj(e);let n=e.split(gj);return bj(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?pj(i,t):t:i||_j}return n[e]||_j}}},bj=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=bj(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(gj):e.slice(t).join(gj),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},xj=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?vj+r:void 0})(),Sj=e=>{let{theme:t,classGroups:n}=e;return Cj(n,t)},Cj=(e,t)=>{let n=hj();for(let r in e){let i=e[r];wj(i,n,r,t)}return n},wj=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Tj(i,t,n,r)}},Tj=(e,t,n,r)=>{if(typeof e==`string`){Ej(e,t,n);return}if(typeof e==`function`){Dj(e,t,n,r);return}Oj(e,t,n,r)},Ej=(e,t,n)=>{let r=e===``?t:kj(t,e);r.classGroupId=n},Dj=(e,t,n,r)=>{if(Aj(e)){wj(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(mj(n,e))},Oj=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];wj(o,kj(t,a),n,r)}},kj=(e,t)=>{let n=e,r=t.split(gj),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=hj(),n.nextPart.set(t,i)),n=i}return n},Aj=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,jj=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Mj=`!`,Nj=`:`,Pj=[],Fj=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),Ij=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===Nj){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Mj)?(c=s.slice(0,-1),l=!0):s.startsWith(Mj)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return Fj(t,l,c,u)};if(t){let e=t+Nj,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):Fj(Pj,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},Lj=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},Rj=e=>({cache:jj(e.cacheSize),parseClassName:Ij(e),sortModifiers:Lj(e),postfixLookupClassGroupIds:zj(e),...yj(e)}),zj=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},Bj=/\s+/,Vj=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(Bj),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Mj:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},Hj=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=Uj(n))&&(i&&(i+=` `),i+=r);return i},Uj=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=Uj(e[r]))&&(n&&(n+=` `),n+=t);return n},Wj=(e,...t)=>{let n,r,i,a,o=o=>(n=Rj(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=Vj(e,n);return i(e,a),a};return a=o,(...e)=>a(Hj(...e))},Gj=[],Kj=e=>{let t=t=>t[e]||Gj;return t.isThemeGetter=!0,t},qj=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Jj=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Yj=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Xj=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,Zj=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,Qj=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,$j=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,eM=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,tM=e=>Yj.test(e),nM=e=>!!e&&!Number.isNaN(Number(e)),rM=e=>!!e&&Number.isInteger(Number(e)),iM=e=>e.endsWith(`%`)&&nM(e.slice(0,-1)),aM=e=>Xj.test(e),oM=()=>!0,sM=e=>Zj.test(e)&&!Qj.test(e),cM=()=>!1,lM=e=>$j.test(e),uM=e=>eM.test(e),dM=e=>!Q(e)&&!$(e),fM=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),pM=e=>OM(e,MM,cM),Q=e=>qj.test(e),mM=e=>OM(e,NM,sM),hM=e=>OM(e,PM,nM),gM=e=>OM(e,IM,oM),_M=e=>OM(e,FM,cM),vM=e=>OM(e,AM,cM),yM=e=>OM(e,jM,uM),bM=e=>OM(e,LM,lM),$=e=>Jj.test(e),xM=e=>kM(e,NM),SM=e=>kM(e,FM),CM=e=>kM(e,AM),wM=e=>kM(e,MM),TM=e=>kM(e,jM),EM=e=>kM(e,LM,!0),DM=e=>kM(e,IM,!0),OM=(e,t,n)=>{let r=qj.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},kM=(e,t,n=!1)=>{let r=Jj.exec(e);return r?r[1]?t(r[1]):n:!1},AM=e=>e===`position`||e===`percentage`,jM=e=>e===`image`||e===`url`,MM=e=>e===`length`||e===`size`||e===`bg-size`,NM=e=>e===`length`,PM=e=>e===`number`,FM=e=>e===`family-name`,IM=e=>e===`number`||e===`weight`,LM=e=>e===`shadow`,RM=Wj(()=>{let e=Kj(`color`),t=Kj(`font`),n=Kj(`text`),r=Kj(`font-weight`),i=Kj(`tracking`),a=Kj(`leading`),o=Kj(`breakpoint`),s=Kj(`container`),c=Kj(`spacing`),l=Kj(`radius`),u=Kj(`shadow`),d=Kj(`inset-shadow`),f=Kj(`text-shadow`),p=Kj(`drop-shadow`),m=Kj(`blur`),h=Kj(`perspective`),g=Kj(`aspect`),_=Kj(`ease`),v=Kj(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),$,Q],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[$,Q,c],ee=()=>[tM,`full`,`auto`,...w()],te=()=>[rM,`none`,`subgrid`,$,Q],ne=()=>[`auto`,{span:[`full`,rM,$,Q]},rM,$,Q],re=()=>[rM,`auto`,$,Q],ie=()=>[`auto`,`min`,`max`,`fr`,$,Q],ae=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],oe=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],se=()=>[`auto`,...w()],ce=()=>[tM,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],le=()=>[tM,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],ue=()=>[tM,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],T=()=>[e,$,Q],de=()=>[...b(),CM,vM,{position:[$,Q]}],fe=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],pe=()=>[`auto`,`cover`,`contain`,wM,pM,{size:[$,Q]}],me=()=>[iM,xM,mM],he=()=>[``,`none`,`full`,l,$,Q],ge=()=>[``,nM,xM,mM],_e=()=>[`solid`,`dashed`,`dotted`,`double`],ve=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ye=()=>[nM,iM,CM,vM],be=()=>[``,`none`,m,$,Q],xe=()=>[`none`,nM,$,Q],Se=()=>[`none`,nM,$,Q],Ce=()=>[nM,$,Q],we=()=>[tM,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[aM],breakpoint:[aM],color:[oM],container:[aM],"drop-shadow":[aM],ease:[`in`,`out`,`in-out`],font:[dM],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[aM],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[aM],shadow:[aM],spacing:[`px`,nM],text:[aM],"text-shadow":[aM],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,tM,Q,$,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,$,Q]}],"container-named":[fM],columns:[{columns:[nM,Q,$,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:ee()}],"inset-x":[{"inset-x":ee()}],"inset-y":[{"inset-y":ee()}],start:[{"inset-s":ee(),start:ee()}],end:[{"inset-e":ee(),end:ee()}],"inset-bs":[{"inset-bs":ee()}],"inset-be":[{"inset-be":ee()}],top:[{top:ee()}],right:[{right:ee()}],bottom:[{bottom:ee()}],left:[{left:ee()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[rM,`auto`,$,Q]}],basis:[{basis:[tM,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[nM,tM,`auto`,`initial`,`none`,Q]}],grow:[{grow:[``,nM,$,Q]}],shrink:[{shrink:[``,nM,$,Q]}],order:[{order:[rM,`first`,`last`,`none`,$,Q]}],"grid-cols":[{"grid-cols":te()}],"col-start-end":[{col:ne()}],"col-start":[{"col-start":re()}],"col-end":[{"col-end":re()}],"grid-rows":[{"grid-rows":te()}],"row-start-end":[{row:ne()}],"row-start":[{"row-start":re()}],"row-end":[{"row-end":re()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":ie()}],"auto-rows":[{"auto-rows":ie()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...ae(),`normal`]}],"justify-items":[{"justify-items":[...oe(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...oe()]}],"align-content":[{content:[`normal`,...ae()]}],"align-items":[{items:[...oe(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...oe(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":ae()}],"place-items":[{"place-items":[...oe(),`baseline`]}],"place-self":[{"place-self":[`auto`,...oe()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:se()}],mx:[{mx:se()}],my:[{my:se()}],ms:[{ms:se()}],me:[{me:se()}],mbs:[{mbs:se()}],mbe:[{mbe:se()}],mt:[{mt:se()}],mr:[{mr:se()}],mb:[{mb:se()}],ml:[{ml:se()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:ce()}],"inline-size":[{inline:[`auto`,...le()]}],"min-inline-size":[{"min-inline":[`auto`,...le()]}],"max-inline-size":[{"max-inline":[`none`,...le()]}],"block-size":[{block:[`auto`,...ue()]}],"min-block-size":[{"min-block":[`auto`,...ue()]}],"max-block-size":[{"max-block":[`none`,...ue()]}],w:[{w:[s,`screen`,...ce()]}],"min-w":[{"min-w":[s,`screen`,`none`,...ce()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...ce()]}],h:[{h:[`screen`,`lh`,...ce()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...ce()]}],"max-h":[{"max-h":[`screen`,`lh`,...ce()]}],"font-size":[{text:[`base`,n,xM,mM]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,DM,gM]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,iM,Q]}],"font-family":[{font:[SM,_M,t]}],"font-features":[{"font-features":[Q]}],"fvn-normal":[`normal-nums`],"fvn-ordinal":[`ordinal`],"fvn-slashed-zero":[`slashed-zero`],"fvn-figure":[`lining-nums`,`oldstyle-nums`],"fvn-spacing":[`proportional-nums`,`tabular-nums`],"fvn-fraction":[`diagonal-fractions`,`stacked-fractions`],tracking:[{tracking:[i,$,Q]}],"line-clamp":[{"line-clamp":[nM,`none`,$,hM]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,$,Q]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,$,Q]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:T()}],"text-color":[{text:T()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[..._e(),`wavy`]}],"text-decoration-thickness":[{decoration:[nM,`from-font`,`auto`,$,mM]}],"text-decoration-color":[{decoration:T()}],"underline-offset":[{"underline-offset":[nM,`auto`,$,Q]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[rM,$,Q]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,$,Q]}],whitespace:[{whitespace:[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`,`break-spaces`]}],break:[{break:[`normal`,`words`,`all`,`keep`]}],wrap:[{wrap:[`break-word`,`anywhere`,`normal`]}],hyphens:[{hyphens:[`none`,`manual`,`auto`]}],content:[{content:[`none`,$,Q]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:de()}],"bg-repeat":[{bg:fe()}],"bg-size":[{bg:pe()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},rM,$,Q],radial:[``,$,Q],conic:[rM,$,Q]},TM,yM]}],"bg-color":[{bg:T()}],"gradient-from-pos":[{from:me()}],"gradient-via-pos":[{via:me()}],"gradient-to-pos":[{to:me()}],"gradient-from":[{from:T()}],"gradient-via":[{via:T()}],"gradient-to":[{to:T()}],rounded:[{rounded:he()}],"rounded-s":[{"rounded-s":he()}],"rounded-e":[{"rounded-e":he()}],"rounded-t":[{"rounded-t":he()}],"rounded-r":[{"rounded-r":he()}],"rounded-b":[{"rounded-b":he()}],"rounded-l":[{"rounded-l":he()}],"rounded-ss":[{"rounded-ss":he()}],"rounded-se":[{"rounded-se":he()}],"rounded-ee":[{"rounded-ee":he()}],"rounded-es":[{"rounded-es":he()}],"rounded-tl":[{"rounded-tl":he()}],"rounded-tr":[{"rounded-tr":he()}],"rounded-br":[{"rounded-br":he()}],"rounded-bl":[{"rounded-bl":he()}],"border-w":[{border:ge()}],"border-w-x":[{"border-x":ge()}],"border-w-y":[{"border-y":ge()}],"border-w-s":[{"border-s":ge()}],"border-w-e":[{"border-e":ge()}],"border-w-bs":[{"border-bs":ge()}],"border-w-be":[{"border-be":ge()}],"border-w-t":[{"border-t":ge()}],"border-w-r":[{"border-r":ge()}],"border-w-b":[{"border-b":ge()}],"border-w-l":[{"border-l":ge()}],"divide-x":[{"divide-x":ge()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":ge()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[..._e(),`hidden`,`none`]}],"divide-style":[{divide:[..._e(),`hidden`,`none`]}],"border-color":[{border:T()}],"border-color-x":[{"border-x":T()}],"border-color-y":[{"border-y":T()}],"border-color-s":[{"border-s":T()}],"border-color-e":[{"border-e":T()}],"border-color-bs":[{"border-bs":T()}],"border-color-be":[{"border-be":T()}],"border-color-t":[{"border-t":T()}],"border-color-r":[{"border-r":T()}],"border-color-b":[{"border-b":T()}],"border-color-l":[{"border-l":T()}],"divide-color":[{divide:T()}],"outline-style":[{outline:[..._e(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[nM,$,Q]}],"outline-w":[{outline:[``,nM,xM,mM]}],"outline-color":[{outline:T()}],shadow:[{shadow:[``,`none`,u,EM,bM]}],"shadow-color":[{shadow:T()}],"inset-shadow":[{"inset-shadow":[`none`,d,EM,bM]}],"inset-shadow-color":[{"inset-shadow":T()}],"ring-w":[{ring:ge()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:T()}],"ring-offset-w":[{"ring-offset":[nM,mM]}],"ring-offset-color":[{"ring-offset":T()}],"inset-ring-w":[{"inset-ring":ge()}],"inset-ring-color":[{"inset-ring":T()}],"text-shadow":[{"text-shadow":[`none`,f,EM,bM]}],"text-shadow-color":[{"text-shadow":T()}],opacity:[{opacity:[nM,$,Q]}],"mix-blend":[{"mix-blend":[...ve(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ve()}],"mask-clip":[{"mask-clip":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]},`mask-no-clip`],"mask-composite":[{mask:[`add`,`subtract`,`intersect`,`exclude`]}],"mask-image-linear-pos":[{"mask-linear":[nM]}],"mask-image-linear-from-pos":[{"mask-linear-from":ye()}],"mask-image-linear-to-pos":[{"mask-linear-to":ye()}],"mask-image-linear-from-color":[{"mask-linear-from":T()}],"mask-image-linear-to-color":[{"mask-linear-to":T()}],"mask-image-t-from-pos":[{"mask-t-from":ye()}],"mask-image-t-to-pos":[{"mask-t-to":ye()}],"mask-image-t-from-color":[{"mask-t-from":T()}],"mask-image-t-to-color":[{"mask-t-to":T()}],"mask-image-r-from-pos":[{"mask-r-from":ye()}],"mask-image-r-to-pos":[{"mask-r-to":ye()}],"mask-image-r-from-color":[{"mask-r-from":T()}],"mask-image-r-to-color":[{"mask-r-to":T()}],"mask-image-b-from-pos":[{"mask-b-from":ye()}],"mask-image-b-to-pos":[{"mask-b-to":ye()}],"mask-image-b-from-color":[{"mask-b-from":T()}],"mask-image-b-to-color":[{"mask-b-to":T()}],"mask-image-l-from-pos":[{"mask-l-from":ye()}],"mask-image-l-to-pos":[{"mask-l-to":ye()}],"mask-image-l-from-color":[{"mask-l-from":T()}],"mask-image-l-to-color":[{"mask-l-to":T()}],"mask-image-x-from-pos":[{"mask-x-from":ye()}],"mask-image-x-to-pos":[{"mask-x-to":ye()}],"mask-image-x-from-color":[{"mask-x-from":T()}],"mask-image-x-to-color":[{"mask-x-to":T()}],"mask-image-y-from-pos":[{"mask-y-from":ye()}],"mask-image-y-to-pos":[{"mask-y-to":ye()}],"mask-image-y-from-color":[{"mask-y-from":T()}],"mask-image-y-to-color":[{"mask-y-to":T()}],"mask-image-radial":[{"mask-radial":[$,Q]}],"mask-image-radial-from-pos":[{"mask-radial-from":ye()}],"mask-image-radial-to-pos":[{"mask-radial-to":ye()}],"mask-image-radial-from-color":[{"mask-radial-from":T()}],"mask-image-radial-to-color":[{"mask-radial-to":T()}],"mask-image-radial-shape":[{"mask-radial":[`circle`,`ellipse`]}],"mask-image-radial-size":[{"mask-radial":[{closest:[`side`,`corner`],farthest:[`side`,`corner`]}]}],"mask-image-radial-pos":[{"mask-radial-at":b()}],"mask-image-conic-pos":[{"mask-conic":[nM]}],"mask-image-conic-from-pos":[{"mask-conic-from":ye()}],"mask-image-conic-to-pos":[{"mask-conic-to":ye()}],"mask-image-conic-from-color":[{"mask-conic-from":T()}],"mask-image-conic-to-color":[{"mask-conic-to":T()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:de()}],"mask-repeat":[{mask:fe()}],"mask-size":[{mask:pe()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,$,Q]}],filter:[{filter:[``,`none`,$,Q]}],blur:[{blur:be()}],brightness:[{brightness:[nM,$,Q]}],contrast:[{contrast:[nM,$,Q]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,EM,bM]}],"drop-shadow-color":[{"drop-shadow":T()}],grayscale:[{grayscale:[``,nM,$,Q]}],"hue-rotate":[{"hue-rotate":[nM,$,Q]}],invert:[{invert:[``,nM,$,Q]}],saturate:[{saturate:[nM,$,Q]}],sepia:[{sepia:[``,nM,$,Q]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,$,Q]}],"backdrop-blur":[{"backdrop-blur":be()}],"backdrop-brightness":[{"backdrop-brightness":[nM,$,Q]}],"backdrop-contrast":[{"backdrop-contrast":[nM,$,Q]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,nM,$,Q]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[nM,$,Q]}],"backdrop-invert":[{"backdrop-invert":[``,nM,$,Q]}],"backdrop-opacity":[{"backdrop-opacity":[nM,$,Q]}],"backdrop-saturate":[{"backdrop-saturate":[nM,$,Q]}],"backdrop-sepia":[{"backdrop-sepia":[``,nM,$,Q]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,$,Q]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[nM,`initial`,$,Q]}],ease:[{ease:[`linear`,`initial`,_,$,Q]}],delay:[{delay:[nM,$,Q]}],animate:[{animate:[`none`,v,$,Q]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,$,Q]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:xe()}],"rotate-x":[{"rotate-x":xe()}],"rotate-y":[{"rotate-y":xe()}],"rotate-z":[{"rotate-z":xe()}],scale:[{scale:Se()}],"scale-x":[{"scale-x":Se()}],"scale-y":[{"scale-y":Se()}],"scale-z":[{"scale-z":Se()}],"scale-3d":[`scale-3d`],skew:[{skew:Ce()}],"skew-x":[{"skew-x":Ce()}],"skew-y":[{"skew-y":Ce()}],transform:[{transform:[$,Q,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:we()}],"translate-x":[{"translate-x":we()}],"translate-y":[{"translate-y":we()}],"translate-z":[{"translate-z":we()}],"translate-none":[`translate-none`],zoom:[{zoom:[rM,$,Q]}],accent:[{accent:T()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:T()}],"color-scheme":[{scheme:[`normal`,`dark`,`light`,`light-dark`,`only-dark`,`only-light`]}],cursor:[{cursor:[`auto`,`default`,`pointer`,`wait`,`text`,`move`,`help`,`not-allowed`,`none`,`context-menu`,`progress`,`cell`,`crosshair`,`vertical-text`,`alias`,`copy`,`no-drop`,`grab`,`grabbing`,`all-scroll`,`col-resize`,`row-resize`,`n-resize`,`e-resize`,`s-resize`,`w-resize`,`ne-resize`,`nw-resize`,`se-resize`,`sw-resize`,`ew-resize`,`ns-resize`,`nesw-resize`,`nwse-resize`,`zoom-in`,`zoom-out`,$,Q]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":T()}],"scrollbar-track-color":[{"scrollbar-track":T()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"snap-align":[{snap:[`start`,`end`,`center`,`align-none`]}],"snap-stop":[{snap:[`normal`,`always`]}],"snap-type":[{snap:[`none`,`x`,`y`,`both`]}],"snap-strictness":[{snap:[`mandatory`,`proximity`]}],touch:[{touch:[`auto`,`none`,`manipulation`]}],"touch-x":[{"touch-pan":[`x`,`left`,`right`]}],"touch-y":[{"touch-pan":[`y`,`up`,`down`]}],"touch-pz":[`touch-pinch-zoom`],select:[{select:[`none`,`text`,`all`,`auto`]}],"will-change":[{"will-change":[`auto`,`scroll`,`contents`,`transform`,$,Q]}],fill:[{fill:[`none`,...T()]}],"stroke-w":[{stroke:[nM,xM,mM,hM]}],stroke:[{stroke:[`none`,...T()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],overflow:[`overflow-x`,`overflow-y`],overscroll:[`overscroll-x`,`overscroll-y`],inset:[`inset-x`,`inset-y`,`inset-bs`,`inset-be`,`start`,`end`,`top`,`right`,`bottom`,`left`],"inset-x":[`right`,`left`],"inset-y":[`top`,`bottom`],flex:[`basis`,`grow`,`shrink`],gap:[`gap-x`,`gap-y`],p:[`px`,`py`,`ps`,`pe`,`pbs`,`pbe`,`pt`,`pr`,`pb`,`pl`],px:[`pr`,`pl`],py:[`pt`,`pb`],m:[`mx`,`my`,`ms`,`me`,`mbs`,`mbe`,`mt`,`mr`,`mb`,`ml`],mx:[`mr`,`ml`],my:[`mt`,`mb`],size:[`w`,`h`],"font-size":[`leading`],"fvn-normal":[`fvn-ordinal`,`fvn-slashed-zero`,`fvn-figure`,`fvn-spacing`,`fvn-fraction`],"fvn-ordinal":[`fvn-normal`],"fvn-slashed-zero":[`fvn-normal`],"fvn-figure":[`fvn-normal`],"fvn-spacing":[`fvn-normal`],"fvn-fraction":[`fvn-normal`],"line-clamp":[`display`,`overflow`],rounded:[`rounded-s`,`rounded-e`,`rounded-t`,`rounded-r`,`rounded-b`,`rounded-l`,`rounded-ss`,`rounded-se`,`rounded-ee`,`rounded-es`,`rounded-tl`,`rounded-tr`,`rounded-br`,`rounded-bl`],"rounded-s":[`rounded-ss`,`rounded-es`],"rounded-e":[`rounded-se`,`rounded-ee`],"rounded-t":[`rounded-tl`,`rounded-tr`],"rounded-r":[`rounded-tr`,`rounded-br`],"rounded-b":[`rounded-br`,`rounded-bl`],"rounded-l":[`rounded-tl`,`rounded-bl`],"border-spacing":[`border-spacing-x`,`border-spacing-y`],"border-w":[`border-w-x`,`border-w-y`,`border-w-s`,`border-w-e`,`border-w-bs`,`border-w-be`,`border-w-t`,`border-w-r`,`border-w-b`,`border-w-l`],"border-w-x":[`border-w-r`,`border-w-l`],"border-w-y":[`border-w-t`,`border-w-b`],"border-color":[`border-color-x`,`border-color-y`,`border-color-s`,`border-color-e`,`border-color-bs`,`border-color-be`,`border-color-t`,`border-color-r`,`border-color-b`,`border-color-l`],"border-color-x":[`border-color-r`,`border-color-l`],"border-color-y":[`border-color-t`,`border-color-b`],translate:[`translate-x`,`translate-y`,`translate-none`],"translate-none":[`translate`,`translate-x`,`translate-y`,`translate-z`],"scroll-m":[`scroll-mx`,`scroll-my`,`scroll-ms`,`scroll-me`,`scroll-mbs`,`scroll-mbe`,`scroll-mt`,`scroll-mr`,`scroll-mb`,`scroll-ml`],"scroll-mx":[`scroll-mr`,`scroll-ml`],"scroll-my":[`scroll-mt`,`scroll-mb`],"scroll-p":[`scroll-px`,`scroll-py`,`scroll-ps`,`scroll-pe`,`scroll-pbs`,`scroll-pbe`,`scroll-pt`,`scroll-pr`,`scroll-pb`,`scroll-pl`],"scroll-px":[`scroll-pr`,`scroll-pl`],"scroll-py":[`scroll-pt`,`scroll-pb`],touch:[`touch-x`,`touch-y`,`touch-pz`],"touch-x":[`touch`],"touch-y":[`touch`],"touch-pz":[`touch`]},conflictingClassGroupModifiers:{"font-size":[`leading`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function zM(...e){return RM(lj(e))}var BM=fj(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-primary text-primary-foreground [a&]:hover:bg-primary/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-white focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-primary underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function VM({className:e,variant:t=`default`,asChild:n=!1,...r}){let i=n?BS:`span`;return(0,X.jsx)(i,{"data-slot":`badge`,"data-variant":t,className:zM(BM({variant:t}),e),...r})}var HM=fj(`inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground hover:bg-primary/90`,destructive:`bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40`,outline:`border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80`,ghost:`hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-9 px-4 py-2 has-[>svg]:px-3`,xs:`h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5`,lg:`h-10 rounded-md px-6 has-[>svg]:px-4`,icon:`size-9`,"icon-xs":`size-6 rounded-md [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-8`,"icon-lg":`size-10`}},defaultVariants:{variant:`default`,size:`default`}});function UM({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?BS:`button`;return(0,X.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:zM(HM({variant:t,size:n,className:e})),...i})}function WM({className:e,type:t,...n}){return(0,X.jsx)(`input`,{type:t,"data-slot":`input`,className:zM(`h-9 w-full min-w-0 rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none selection:bg-primary selection:text-primary-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:bg-input/30`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40`,e),...n})}function GM({className:e,children:t,...n}){return(0,X.jsxs)(iO,{"data-slot":`scroll-area`,className:zM(`relative`,e),...n,children:[(0,X.jsx)(aO,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,X.jsx)(KM,{}),(0,X.jsx)(oO,{})]})}function KM({className:e,orientation:t=`vertical`,...n}){return(0,X.jsx)(MD,{"data-slot":`scroll-area-scrollbar`,orientation:t,className:zM(`flex touch-none p-px transition-colors select-none`,t===`vertical`&&`h-full w-2.5 border-l border-l-transparent`,t===`horizontal`&&`h-2.5 flex-col border-t border-t-transparent`,e),...n,children:(0,X.jsx)(UD,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}function qM({...e}){return(0,X.jsx)(YE,{"data-slot":`sheet`,...e})}function JM({...e}){return(0,X.jsx)($E,{"data-slot":`sheet-portal`,...e})}function YM({className:e,...t}){return(0,X.jsx)(tD,{"data-slot":`sheet-overlay`,className:zM(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function XM({className:e,children:t,side:n=`right`,showCloseButton:r=!0,showOverlay:i=!0,...a}){return(0,X.jsxs)(JM,{children:[i?(0,X.jsx)(YM,{}):null,(0,X.jsxs)(aD,{"data-slot":`sheet-content`,className:zM(`fixed z-50 flex flex-col gap-4 bg-background shadow-lg transition ease-in-out data-[state=closed]:animate-out data-[state=closed]:duration-300 data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 top-0 h-auto border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 bottom-0 h-auto border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom`,e),...a,children:[t,r&&(0,X.jsxs)(mD,{className:`absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,X.jsx)(sj,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function ZM({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`sheet-header`,className:zM(`flex flex-col gap-1.5 p-4`,e),...t})}function QM({className:e,...t}){return(0,X.jsx)(uD,{"data-slot":`sheet-title`,className:zM(`font-semibold text-foreground`,e),...t})}function $M({className:e,...t}){return(0,X.jsx)(fD,{"data-slot":`sheet-description`,className:zM(`text-sm text-muted-foreground`,e),...t})}function eN({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,X.jsx)(`table`,{"data-slot":`table`,className:zM(`w-full caption-bottom text-sm`,e),...t})})}function tN({className:e,...t}){return(0,X.jsx)(`thead`,{"data-slot":`table-header`,className:zM(`[&_tr]:border-b`,e),...t})}function nN({className:e,...t}){return(0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:zM(`[&_tr:last-child]:border-0`,e),...t})}function rN({className:e,...t}){return(0,X.jsx)(`tr`,{"data-slot":`table-row`,className:zM(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function iN({className:e,...t}){return(0,X.jsx)(`th`,{"data-slot":`table-head`,className:zM(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function aN({className:e,...t}){return(0,X.jsx)(`td`,{"data-slot":`table-cell`,className:zM(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]`,e),...t})}function oN(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`nylo-studio.config.json must contain an object.`);let n=e.agentServerUrl;if(n===void 0)return Object.freeze({});if(typeof n!=`string`)throw Error(`agentServerUrl must be a string.`);let r;try{r=new URL(n)}catch{throw Error(`agentServerUrl must be an absolute http(s) URL.`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw Error(`agentServerUrl must use http or https.`);if(r.username!==``||r.password!==``||r.search!==``||r.hash!==``)throw Error(`agentServerUrl must not contain credentials, a query string, or a fragment.`);if(t===`https:`&&r.protocol===`http:`)throw Error(`An HTTPS Studio cannot connect to an HTTP Agent Server. Serve the Agent Server over HTTPS.`);return Object.freeze({agentServerUrl:r.href.replace(/\/$/u,``)})}async function sN(e=fetch,t=document.baseURI){let n=new URL(t),r=await e(new URL(`/nylo-studio.config.json`,n.origin));if(!r.ok)throw Error(`Could not load nylo-studio.config.json (${r.status}).`);return oN(await r.json(),new URL(t).protocol)}function cN(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function lN(e,t){return typeof e==`string`&&e!==``?e:t}function uN(e){if(typeof e==`string`)return e.length>140?`${e.slice(0,137)}…`:e;try{let t=JSON.stringify(e);return t.length>140?`${t.slice(0,137)}…`:t}catch{return`Result is not serializable.`}}function dN(e){switch(e.type){case`model.requested`:return`Model requested`;case`model.completed`:return`Model completed`;case`model.deferred`:return`Model deferred`;case`model.call`:return`Model response`;case`tool.started`:return`Tool started`;case`tool.completed`:return`Tool completed`;case`tool.deferred`:return`Tool deferred`;case`interaction.required`:return`Approval required`;case`session.run.started`:return`Session input received`;case`final`:return`Final answer`;case`error`:return`Run failed`;default:return e.type.replaceAll(`.`,` `)}}function fN(e){let t=e.payload;if(e.type.startsWith(`tool.`)){let n=lN(t.toolName,`tool`);if(e.type===`tool.completed`){let e=cN(t.attributes);return e.kind===`failed`?`${n}: ${lN(e.message,lN(t.code,`failed`))}`:`${n}: ${uN(e.output??e.kind??t.outcome)}`}return n}return e.type===`interaction.required`?lN(cN(t.interaction).prompt,`A response is required before this work can continue.`):e.type===`final`?uN(t.output):e.type===`error`?lN(t.message,`The run failed.`):e.type===`model.requested`?lN(t.requestedModelId,`Preparing a model request.`):e.type===`model.completed`?`Candidate received.`:e.type===`session.run.started`&&t.input_kind===`approve`?t.approved===!0?`Approval granted.`:`Approval denied.`:`Canonical agent event.`}function pN(e){return e.flatMap(e=>{let t=(t,n)=>[{id:`${e.seq}-${e.type}`,title:t,detail:fN(e),state:n}];switch(e.type){case`model.requested`:return t(`Calling model`,`running`);case`model.completed`:return t(`Model response received`,`completed`);case`tool.started`:return t(`Running ${lN(e.payload.toolName,`tool`)}`,`running`);case`tool.completed`:return t(`${lN(e.payload.toolName,`Tool`)} ${lN(e.payload.outcome,`completed`)}`,e.payload.outcome===`failed`?`failed`:`completed`);case`interaction.required`:return t(`Waiting for approval`,`waiting`);case`session.run.started`:return e.payload.input_kind===`approve`?t(e.payload.approved===!0?`Approval granted`:`Approval denied`,e.payload.approved===!0?`approved`:`denied`):[];case`error`:return t(`Run failed`,`failed`);case`final`:return t(`Final answer ready`,`completed`);default:return[]}}).slice(-8)}function mN(e,t){return new URL(t,`${e}/`).toString()}function hN(e){return e.length>12?`${e.slice(0,8)}…${e.slice(-4)}`:e}function gN(e){return e===void 0?`—`:new Date(e).toLocaleString()}function _N(e){try{return JSON.stringify(e,null,2)}catch{return`Unserializable value`}}function vN(){let[e,t]=(0,S.useState)({status:`Connecting`,agents:[]});return(0,S.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await sN();if(n.agentServerUrl===void 0)throw Error(`No Agent Server URL configured.`);let r=await fetch(mN(n.agentServerUrl,`/v1/agents`),{cache:`no-store`});if(!r.ok)throw Error(`Agent Server returned ${r.status}.`);let i=await r.json();if(i.protocolVersion!==1||!Array.isArray(i.agents))throw Error(`Unsupported Studio discovery document.`);let a=await Promise.all(i.agents.map(async e=>{let t=await fetch(mN(n.agentServerUrl,e.manifestUrl),{cache:`no-store`});if(!t.ok)throw Error(`Manifest for ${e.id} returned ${t.status}.`);let r=await t.json();return{...r,endpoints:{agUi:mN(n.agentServerUrl,r.endpoints.agUi),sessions:mN(n.agentServerUrl,r.endpoints.sessions)}}}));e||t({status:`Running`,url:n.agentServerUrl,agents:a})}catch{e||t(e=>({status:`Offline`,url:e.url,agents:e.agents}))}};n();let r=window.setInterval(()=>void n(),2e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}function yN({title:e,detail:t}){return(0,X.jsx)(`div`,{className:`grid min-h-52 place-items-center rounded-lg border border-dashed p-8 text-center`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-medium`,children:e}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:t})]})})}function bN({title:e,children:t}){return(0,X.jsxs)(`section`,{className:`rounded-xl border bg-card p-5 shadow-sm`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold`,children:e}),(0,X.jsx)(`div`,{className:`mt-4`,children:t})]})}function xN({values:e}){return e.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`None declared`}):(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>(0,X.jsx)(VM,{variant:`secondary`,children:e},e))})}function SN({connection:e}){let t=Ct(),n=Et(),r=t.pathname.match(/^\/agents\/([^/]+)/u)?.[1],i=e.status===`Running`,a=i?`bg-emerald-500`:e.status===`Connecting`?`bg-amber-500`:`bg-muted-foreground`;return(0,X.jsxs)(`header`,{className:`fixed inset-x-0 top-0 z-40 flex h-16 items-center border-b bg-background/95 px-5 backdrop-blur`,children:[(0,X.jsxs)(Rn,{to:`/`,className:`mr-6 flex items-center gap-2 font-semibold tracking-tight`,children:[(0,X.jsx)(`img`,{src:`/brand/nylorun-mark.svg`,alt:``,className:`size-7`}),`Nylorun Studio`]}),(0,X.jsx)(`p`,{className:`hidden text-sm text-muted-foreground sm:block`,children:r===void 0?`Agent server`:`Agent: ${r}`}),(0,X.jsxs)(`div`,{className:`ml-auto flex items-center gap-3`,children:[(0,X.jsxs)(UM,{variant:`outline`,size:`icon`,disabled:!i||r===void 0,onClick:()=>n(`/agents/${r}/sessions/${crypto.randomUUID()}`),children:[(0,X.jsx)(rj,{className:`size-4`}),(0,X.jsx)(`span`,{className:`sr-only`,children:`New session`})]}),(0,X.jsx)(`span`,{className:`size-2 rounded-full ${a}`}),e.status===`Connecting`?(0,X.jsx)(ij,{className:`size-3 animate-spin`}):i?(0,X.jsx)(nj,{className:`size-3`}):(0,X.jsx)(oj,{className:`size-3`}),(0,X.jsx)(`span`,{className:`text-sm`,children:e.status})]})]})}function CN({connection:e}){return(0,X.jsxs)(`main`,{className:`mx-auto max-w-6xl p-6`,children:[(0,X.jsxs)(`div`,{className:`mb-7`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Agents`}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Studio reads the manifests exposed by your local agent server.`})]}),e.status===`Running`?(0,X.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:e.agents.map(e=>(0,X.jsxs)(Rn,{to:`/agents/${encodeURIComponent(e.id)}`,className:`rounded-xl border bg-card p-5 shadow-sm transition-colors hover:bg-muted/50`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-semibold`,children:e.name}),(0,X.jsx)(`p`,{className:`mt-1 font-mono text-xs text-muted-foreground`,children:e.id})]}),(0,X.jsx)(VM,{variant:`outline`,children:e.model.provider})]}),(0,X.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:e.description}),(0,X.jsx)(`div`,{className:`mt-4`,children:(0,X.jsx)(xN,{values:e.capabilities})})]},e.id))}):(0,X.jsx)(yN,{title:`Agent server is offline`,detail:`Start your Hono host, then Studio will discover its agent manifests.`})]})}function wN({connection:e}){let{agentId:t=``}=Ot(),n=Et(),r=e.agents.find(e=>e.id===t),[i,a]=(0,S.useState)([]);if((0,S.useEffect)(()=>{if(e.url===void 0||r===void 0)return;let t=!1,n=async()=>{let n=await fetch(mN(e.url,r.endpoints.sessions),{cache:`no-store`});n.ok&&!t&&a((await n.json()).sessions)};n();let i=window.setInterval(()=>void n(),2e3);return()=>{t=!0,window.clearInterval(i)}},[e.url,r]),r===void 0)return(0,X.jsx)(`main`,{className:`p-6`,children:(0,X.jsx)(yN,{title:`Agent not found`,detail:`Return to the agent list and select an available manifest.`})});let o=r.harness.manifest.middleware??[];return(0,X.jsxs)(`main`,{className:`mx-auto max-w-6xl p-6`,children:[(0,X.jsx)(Rn,{to:`/`,className:`text-sm text-muted-foreground hover:text-foreground`,children:`← All agents`}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-col justify-between gap-4 md:flex-row md:items-end`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:r.name}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:r.description})]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(VM,{children:r.model.provider}),(0,X.jsx)(VM,{variant:`outline`,children:r.model.id})]})]}),(0,X.jsxs)(wO,{defaultValue:`manifest`,className:`mt-7`,children:[(0,X.jsxs)(TO,{className:`flex h-10 items-end gap-6 border-b`,children:[(0,X.jsx)(EO,{value:`manifest`,className:`border-b-2 border-transparent px-0 pb-3 text-sm data-[state=active]:border-primary`,children:`Manifest`}),(0,X.jsx)(EO,{value:`sessions`,className:`border-b-2 border-transparent px-0 pb-3 text-sm data-[state=active]:border-primary`,children:`Sessions`})]}),(0,X.jsxs)(DO,{value:`manifest`,className:`mt-5 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,X.jsx)(bN,{title:`Capabilities`,children:(0,X.jsx)(xN,{values:r.capabilities})}),(0,X.jsx)(bN,{title:`Harness`,children:(0,X.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Package`}),(0,X.jsxs)(`dd`,{children:[r.harness.name,` `,r.harness.version]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`text-muted-foreground`,children:`Middleware`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(xN,{values:o.map(e=>e.id)})})]})]})})]}),(0,X.jsxs)(bN,{title:`Requirements`,children:[(0,X.jsx)(xN,{values:Object.entries(r.requirements??{}).filter(([,e])=>e).map(([e])=>e)}),(0,X.jsxs)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:[`Records: `,r.records?.path??`not reported`]})]})]}),(0,X.jsx)(DO,{value:`sessions`,className:`mt-5`,children:(0,X.jsx)(`div`,{className:`rounded-lg border`,children:(0,X.jsxs)(eN,{children:[(0,X.jsx)(tN,{children:(0,X.jsxs)(rN,{children:[(0,X.jsx)(iN,{children:`ID`}),(0,X.jsx)(iN,{children:`Status`}),(0,X.jsx)(iN,{children:`Started`}),(0,X.jsx)(iN,{children:`Events`})]})}),(0,X.jsx)(nN,{children:i.length===0?(0,X.jsx)(rN,{children:(0,X.jsx)(aN,{colSpan:4,className:`h-24 text-center text-muted-foreground`,children:`No sessions yet.`})}):i.map(e=>(0,X.jsxs)(rN,{className:`cursor-pointer`,onClick:()=>n(`/agents/${r.id}/sessions/${e.session}`),children:[(0,X.jsx)(aN,{className:`font-mono text-xs`,children:hN(e.session)}),(0,X.jsx)(aN,{children:(0,X.jsx)(VM,{variant:`secondary`,children:e.status})}),(0,X.jsx)(aN,{children:gN(e.startedAt)}),(0,X.jsx)(aN,{children:e.events})]},e.session))})]})})})]})]})}function TN({events:e}){let t=pN(e);return(0,X.jsxs)(`section`,{className:`mb-4 rounded-lg border bg-card p-3`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex justify-between`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Run activity`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Canonical events`})]}),t.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Activity will appear when the agent runs.`}):(0,X.jsx)(`ol`,{className:`space-y-2`,children:t.map(e=>(0,X.jsxs)(`li`,{className:`rounded-md border px-3 py-2 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex justify-between gap-3`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`text-xs capitalize text-muted-foreground`,children:e.state})]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.detail})]},e.id))})]})}function EN({url:e,children:t}){let n=GA({agent:(0,S.useMemo)(()=>new yp({url:e}),[e])});return(0,X.jsx)(jS,{runtime:n,children:t})}function DN({agent:e,sessionId:t,events:n}){let[r,i]=(0,S.useState)([]),[a,o]=(0,S.useState)(``),[s,c]=(0,S.useState)(),[l,u]=(0,S.useState)(!1),[d,f]=(0,S.useState)();(0,S.useEffect)(()=>{let n=!1,r=async()=>{let r=await fetch(`${e.endpoints.agUi.replace(/\/$/u,``)}/sessions/${encodeURIComponent(t)}`,{cache:`no-store`});r.ok&&!n&&i((await r.json()).messages);let a=await fetch(`${e.endpoints.sessions.replace(/\/$/u,``)}/${encodeURIComponent(t)}`,{cache:`no-store`});a.ok&&!n&&c((await a.json()).pending_interaction)};r();let a=window.setInterval(()=>void r(),1e3);return()=>{n=!0,window.clearInterval(a)}},[e,t]);let p=async n=>{if(n.preventDefault(),!a.trim()||l)return;let r=a.trim();o(``),u(!0),f(void 0),i(e=>[...e,{id:crypto.randomUUID(),role:`user`,content:r}]);try{let n=new yp({url:e.endpoints.agUi,threadId:t});n.addMessage({id:crypto.randomUUID(),role:`user`,content:r}),await n.runAgent({runId:crypto.randomUUID()},{onNewMessage:({message:e})=>{let t=e;i(e=>[...e,{id:t.id??crypto.randomUUID(),role:t.role??`assistant`,content:typeof t.content==`string`?t.content:_N(t.content)}])}})}catch(e){f(e instanceof Error?e.message:`Agent request failed.`)}finally{u(!1)}},m=async n=>{if(s!==void 0){u(!0);try{let r=await fetch(`${e.endpoints.sessions.replace(/\/$/u,``)}/${encodeURIComponent(t)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({interaction:{id:s.id,kind:`approval`,approved:n}})});if(!r.ok)throw Error(`Approval returned ${r.status}.`);c(void 0)}catch(e){f(e instanceof Error?e.message:`Approval failed.`)}finally{u(!1)}}};return(0,X.jsxs)(`div`,{className:`flex h-[calc(100vh-11rem)] min-h-96 flex-col border`,children:[(0,X.jsxs)(GM,{className:`min-h-0 flex-1 p-5`,children:[(0,X.jsx)(TN,{events:n}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[r.map(e=>(0,X.jsxs)(`article`,{className:`max-w-3xl rounded-lg px-4 py-3 text-sm ${e.role===`user`?`ml-auto bg-primary text-primary-foreground`:`bg-muted`}`,children:[(0,X.jsx)(`p`,{className:`mb-1 text-xs opacity-70`,children:e.role}),(0,X.jsx)(`p`,{className:`whitespace-pre-wrap`,children:e.content})]},e.id)),s!==void 0&&(0,X.jsxs)(`section`,{className:`rounded-lg border border-amber-400/50 bg-amber-50 p-4 text-sm`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`Approval required`}),(0,X.jsx)(`p`,{className:`mt-1`,children:s.prompt}),(0,X.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,X.jsx)(UM,{size:`sm`,onClick:()=>void m(!0),children:`Approve`}),(0,X.jsx)(UM,{size:`sm`,variant:`outline`,onClick:()=>void m(!1),children:`Deny`})]})]}),d!==void 0&&(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:d})]})]}),(0,X.jsxs)(`form`,{onSubmit:p,className:`flex gap-2 border-t p-3`,children:[(0,X.jsx)(WM,{value:a,onChange:e=>o(e.target.value),disabled:l||s!==void 0,placeholder:`Message the agent…`}),(0,X.jsx)(UM,{type:`submit`,size:`icon`,disabled:l||s!==void 0||!a.trim(),children:(0,X.jsx)(aj,{className:`size-4`})})]})]})}function ON({connection:e}){let{agentId:t=``,sessionId:n=``}=Ot(),r=e.agents.find(e=>e.id===t),[i,a]=(0,S.useState)([]),[o,s]=(0,S.useState)();return(0,S.useEffect)(()=>{if(r===void 0)return;let e=!1,t=async()=>{let t=await fetch(`${r.endpoints.sessions.replace(/\/$/u,``)}/${encodeURIComponent(n)}/events?after=0&limit=1000`,{cache:`no-store`});t.ok&&!e&&a((await t.json()).events)};t();let i=window.setInterval(()=>void t(),1e3);return()=>{e=!0,window.clearInterval(i)}},[r,n]),r===void 0?(0,X.jsx)(`main`,{className:`p-6`,children:(0,X.jsx)(yN,{title:`Agent not found`,detail:`Return to the agent list and select an available manifest.`})}):(0,X.jsxs)(EN,{url:r.endpoints.agUi,children:[(0,X.jsxs)(`main`,{className:`mx-auto max-w-6xl p-6`,children:[(0,X.jsxs)(Rn,{to:`/agents/${r.id}`,className:`text-sm text-muted-foreground hover:text-foreground`,children:[`← `,r.name]}),(0,X.jsxs)(`h1`,{className:`mt-3 text-xl font-semibold`,children:[`Session `,hN(n)]}),(0,X.jsxs)(wO,{defaultValue:`chat`,className:`mt-5`,children:[(0,X.jsxs)(TO,{className:`flex h-10 items-end gap-6 border-b`,children:[(0,X.jsx)(EO,{value:`chat`,className:`border-b-2 border-transparent px-0 pb-3 text-sm data-[state=active]:border-primary`,children:`Chat`}),(0,X.jsx)(EO,{value:`events`,className:`border-b-2 border-transparent px-0 pb-3 text-sm data-[state=active]:border-primary`,children:`Events`})]}),(0,X.jsx)(DO,{value:`chat`,className:`mt-4`,children:(0,X.jsx)(DN,{agent:r,sessionId:n,events:i})}),(0,X.jsx)(DO,{value:`events`,className:`mt-4`,children:(0,X.jsx)(`div`,{className:`rounded-lg border`,children:(0,X.jsxs)(eN,{children:[(0,X.jsx)(tN,{children:(0,X.jsxs)(rN,{children:[(0,X.jsx)(iN,{children:`Event`}),(0,X.jsx)(iN,{children:`Summary`})]})}),(0,X.jsx)(nN,{children:i.map(e=>(0,X.jsxs)(rN,{className:`cursor-pointer`,onClick:()=>s(e),children:[(0,X.jsx)(aN,{children:(0,X.jsx)(VM,{variant:`secondary`,children:dN(e)})}),(0,X.jsx)(aN,{className:`max-w-2xl truncate text-xs text-muted-foreground`,children:fN(e)})]},e.seq))})]})})})]})]}),(0,X.jsx)(qM,{modal:!1,open:o!==void 0,onOpenChange:e=>!e&&s(void 0),children:(0,X.jsxs)(XM,{showOverlay:!1,children:[(0,X.jsxs)(ZM,{children:[(0,X.jsx)(QM,{children:o===void 0?`Event`:dN(o)}),(0,X.jsx)($M,{children:`Canonical event details`})]}),o!==void 0&&(0,X.jsx)(GM,{className:`min-h-0 flex-1 px-4 pb-6`,children:(0,X.jsx)(`pre`,{className:`overflow-auto rounded bg-muted p-3 text-xs`,children:_N(o)})})]})})]})}function kN(){let e=vN();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(SN,{connection:e}),(0,X.jsx)(`div`,{className:`pt-16`,children:(0,X.jsxs)(Qt,{children:[(0,X.jsx)(Xt,{path:`/`,element:(0,X.jsx)(CN,{connection:e})}),(0,X.jsx)(Xt,{path:`/agents/:agentId`,element:(0,X.jsx)(wN,{connection:e})}),(0,X.jsx)(Xt,{path:`/agents/:agentId/sessions/:sessionId`,element:(0,X.jsx)(ON,{connection:e})})]})})]})}function AN(){return(0,X.jsx)(Ln,{children:(0,X.jsx)(kN,{})})}(0,Vi.createRoot)(document.getElementById(`root`)).render((0,X.jsx)(S.StrictMode,{children:(0,X.jsx)(AN,{})}));
|