@whitenight_5/web-assistant 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,192 +0,0 @@
|
|
|
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,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},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(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 l=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},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function ee(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 te(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,te(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),te(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+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+j(a,u),c+=te(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+j(a,u++),c+=te(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return te(ee(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 ne(e,t,n){if(e==null)return e;var r=[],i=0;return te(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function re(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 M=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)},N={map:ne,forEach:function(e,t,n){ne(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return ne(e,function(){t++}),t},toArray:function(e){return ne(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=N,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)!T.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 E(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)T.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 E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:re}},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,M)}catch(e){M(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`})),u=o(((e,t)=>{t.exports=l()})),d=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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=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&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=u();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`})),m=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=p()})),h=o((e=>{var t=f(),n=u(),r=m();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 d(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 p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(e),t!==null)return t;e=e.sibling}return null}var h=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`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function ee(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var te=Symbol.for(`react.client.reference`);function ne(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===te?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 T:return`Suspense`;case E:return`SuspenseList`;case k: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 D:return t=e.displayName||null,t===null?ne(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return ne(e(t))}catch{}}return null}var re=Array.isArray,M=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ie={pending:!1,data:null,method:null,action:null},ae=[],oe=-1;function se(e){return{current:e}}function P(e){0>oe||(e.current=ae[oe],ae[oe]=null,oe--)}function ce(e,t){oe++,ae[oe]=e.current,e.current=t}var le=se(null),ue=se(null),de=se(null),fe=se(null);function pe(e,t){switch(ce(de,t),ce(ue,e),ce(le,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?af(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=af(t),e=of(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}P(le),ce(le,e)}function me(){P(le),P(ue),P(de)}function he(e){e.memoizedState!==null&&ce(fe,e);var t=le.current,n=of(t,e.type);t!==n&&(ce(ue,e),ce(le,n))}function ge(e){ue.current===e&&(P(le),P(ue)),fe.current===e&&(P(fe),hp._currentValue=ie)}var _e,ve;function ye(e){if(_e===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);_e=t&&t[1]||``,ve=-1<e.stack.indexOf(`
|
|
2
|
-
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
-
`+_e+e+ve}var be=!1;function xe(e,t){if(!e||be)return``;be=!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{be=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?ye(n):``}function Se(e,t){switch(e.tag){case 26:case 27:case 5:return ye(e.type);case 16:return ye(`Lazy`);case 13:return e.child!==t&&t!==null?ye(`Suspense Fallback`):ye(`Suspense`);case 19:return ye(`SuspenseList`);case 0:case 15:return xe(e.type,!1);case 11:return xe(e.type.render,!1);case 1:return xe(e.type,!0);case 31:return ye(`Activity`);default:return``}}function Ce(e){try{var t=``,n=null;do t+=Se(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
-
Error generating stack: `+e.message+`
|
|
8
|
-
`+e.stack}}var we=Object.prototype.hasOwnProperty,Te=t.unstable_scheduleCallback,Ee=t.unstable_cancelCallback,De=t.unstable_shouldYield,Oe=t.unstable_requestPaint,ke=t.unstable_now,Ae=t.unstable_getCurrentPriorityLevel,je=t.unstable_ImmediatePriority,Me=t.unstable_UserBlockingPriority,Ne=t.unstable_NormalPriority,Pe=t.unstable_LowPriority,Fe=t.unstable_IdlePriority,Ie=t.log,Le=t.unstable_setDisableYieldValue,Re=null,ze=null;function Be(e){if(typeof Ie==`function`&&Le(e),ze&&typeof ze.setStrictMode==`function`)try{ze.setStrictMode(Re,e)}catch{}}var Ve=Math.clz32?Math.clz32:We,He=Math.log,Ue=Math.LN2;function We(e){return e>>>=0,e===0?32:31-(He(e)/Ue|0)|0}var Ge=256,Ke=262144,qe=4194304;function Je(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 Ye(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=Je(n))):i=Je(o):i=Je(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Je(n))):i=Je(o)):i=Je(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 Xe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ze(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 Qe(){var e=qe;return qe<<=1,!(qe&62914560)&&(qe=4194304),e}function $e(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function et(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function tt(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-Ve(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&&nt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function nt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ve(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function rt(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ve(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function it(e,t){var n=t&-t;return n=n&42?1:at(n),(n&(e.suspendedLanes|t))===0?n:0}function at(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 ot(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function st(){var e=N.p;return e===0?(e=window.event,e===void 0?32:jp(e.type)):e}function ct(e,t){var n=N.p;try{return N.p=e,t()}finally{N.p=n}}var F=Math.random().toString(36).slice(2),lt=`__reactFiber$`+F,ut=`__reactProps$`+F,dt=`__reactContainer$`+F,ft=`__reactEvents$`+F,pt=`__reactListeners$`+F,mt=`__reactHandles$`+F,ht=`__reactResources$`+F,gt=`__reactMarker$`+F;function _t(e){delete e[lt],delete e[ut],delete e[ft],delete e[pt],delete e[mt]}function vt(e){var t=e[lt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[dt]||n[lt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Of(e);e!==null;){if(n=e[lt])return n;e=Of(e)}return t}e=n,n=e.parentNode}return null}function yt(e){if(e=e[lt]||e[dt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function bt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function xt(e){var t=e[ht];return t||=e[ht]={hoistableStyles:new Map,hoistableScripts:new Map},t}function St(e){e[gt]=!0}var Ct=new Set,wt={};function Tt(e,t){Et(e,t),Et(e+`Capture`,t)}function Et(e,t){for(wt[e]=t,e=0;e<t.length;e++)Ct.add(t[e])}var Dt=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]*$`),Ot={},kt={};function At(e){return we.call(kt,e)?!0:we.call(Ot,e)?!1:Dt.test(e)?kt[e]=!0:(Ot[e]=!0,!1)}function jt(e,t,n){if(At(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 Mt(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 Nt(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 Pt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Ft(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function It(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 Lt(e){if(!e._valueTracker){var t=Ft(e)?`checked`:`value`;e._valueTracker=It(e,t,``+e[t])}}function Rt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Ft(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}function zt(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 Bt=/[\n"\\]/g;function Vt(e){return e.replace(Bt,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function Ht(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=``+Pt(t)):e.value!==``+Pt(t)&&(e.value=``+Pt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):Wt(e,o,Pt(n)):Wt(e,o,Pt(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=``+Pt(s):e.removeAttribute(`name`)}function Ut(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)){Lt(e);return}n=n==null?``:``+Pt(n),t=t==null?n:``+Pt(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),Lt(e)}function Wt(e,t,n){t===`number`&&zt(e.ownerDocument)===e||e.defaultValue===``+n||(e.defaultValue=``+n)}function Gt(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=``+Pt(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 Kt(e,t,n){if(t!=null&&(t=``+Pt(t),t!==e.value&&(e.value=t),n==null)){e.defaultValue!==t&&(e.defaultValue=t);return}e.defaultValue=n==null?``:``+Pt(n)}function qt(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(re(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Pt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Lt(e)}function Jt(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Yt=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 Xt(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||Yt.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function Zt(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&&Xt(e,a,r)}else for(var o in t)t.hasOwnProperty(o)&&Xt(e,o,t[o])}function Qt(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 $t=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`]]),en=/^[\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 tn(e){return en.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function nn(){}var rn=null;function an(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var on=null,sn=null;function cn(e){var t=yt(e);if(t&&(e=t.stateNode)){var n=e[ut]||null;a:switch(e=t.stateNode,t.type){case`input`:if(Ht(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="`+Vt(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[ut]||null;if(!a)throw Error(i(90));Ht(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&&Rt(r)}break a;case`textarea`:Kt(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&Gt(e,!!n.multiple,t,!1)}}}var ln=!1;function un(e,t,n){if(ln)return e(t,n);ln=!0;try{return e(t)}finally{if(ln=!1,(on!==null||sn!==null)&&(Pu(),on&&(t=on,e=sn,sn=on=null,cn(t),e)))for(t=0;t<e.length;t++)cn(e[t])}}function dn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[ut]||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 fn=!(typeof window>`u`||window.document===void 0||window.document.createElement===void 0),pn=!1;if(fn)try{var mn={};Object.defineProperty(mn,"passive",{get:function(){pn=!0}}),window.addEventListener(`test`,mn,mn),window.removeEventListener(`test`,mn,mn)}catch{pn=!1}var hn=null,gn=null,_n=null;function vn(){if(_n)return _n;var e,t=gn,n=t.length,r,i=`value`in hn?hn.value:hn.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 _n=i.slice(e,1<r?1-r:void 0)}function yn(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 bn(){return!0}function xn(){return!1}function Sn(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)?bn:xn,this.isPropagationStopped=xn,this}return h(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=bn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=bn)},persist:function(){},isPersistent:bn}),t}var Cn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},wn=Sn(Cn),Tn=h({},Cn,{view:0,detail:0}),En=Sn(Tn),Dn,On,kn,An=h({},Tn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Vn,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!==kn&&(kn&&e.type===`mousemove`?(Dn=e.screenX-kn.screenX,On=e.screenY-kn.screenY):On=Dn=0,kn=e),Dn)},movementY:function(e){return`movementY`in e?e.movementY:On}}),jn=Sn(An),Mn=Sn(h({},An,{dataTransfer:0})),Nn=Sn(h({},Tn,{relatedTarget:0})),Pn=Sn(h({},Cn,{animationName:0,elapsedTime:0,pseudoElement:0})),Fn=Sn(h({},Cn,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),In=Sn(h({},Cn,{data:0})),Ln={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Rn={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`},zn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function Bn(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=zn[e])?!!t[e]:!1}function Vn(){return Bn}var Hn=Sn(h({},Tn,{key:function(e){if(e.key){var t=Ln[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=yn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Rn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Vn,charCode:function(e){return e.type===`keypress`?yn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?yn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),Un=Sn(h({},An,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),Wn=Sn(h({},Tn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Vn})),Gn=Sn(h({},Cn,{propertyName:0,elapsedTime:0,pseudoElement:0})),Kn=Sn(h({},An,{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})),qn=Sn(h({},Cn,{newState:0,oldState:0})),Jn=[9,13,27,32],Yn=fn&&`CompositionEvent`in window,Xn=null;fn&&`documentMode`in document&&(Xn=document.documentMode);var Zn=fn&&`TextEvent`in window&&!Xn,Qn=fn&&(!Yn||Xn&&8<Xn&&11>=Xn),$n=` `,er=!1;function tr(e,t){switch(e){case`keyup`:return Jn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function nr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var rr=!1;function ir(e,t){switch(e){case`compositionend`:return nr(t);case`keypress`:return t.which===32?(er=!0,$n):null;case`textInput`:return e=t.data,e===$n&&er?null:e;default:return null}}function ar(e,t){if(rr)return e===`compositionend`||!Yn&&tr(e,t)?(e=vn(),_n=gn=hn=null,rr=!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 Qn&&t.locale!==`ko`?null:t.data;default:return null}}var or={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 sr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!or[e.type]:t===`textarea`}function cr(e,t,n,r){on?sn?sn.push(r):sn=[r]:on=r,t=Hd(t,`onChange`),0<t.length&&(n=new wn(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var lr=null,ur=null;function dr(e){Pd(e,0)}function fr(e){if(Rt(bt(e)))return e}function pr(e,t){if(e===`change`)return t}var mr=!1;if(fn){var hr;if(fn){var gr=`oninput`in document;if(!gr){var _r=document.createElement(`div`);_r.setAttribute(`oninput`,`return;`),gr=typeof _r.oninput==`function`}hr=gr}else hr=!1;mr=hr&&(!document.documentMode||9<document.documentMode)}function vr(){lr&&(lr.detachEvent(`onpropertychange`,yr),ur=lr=null)}function yr(e){if(e.propertyName===`value`&&fr(ur)){var t=[];cr(t,ur,e,an(e)),un(dr,t)}}function br(e,t,n){e===`focusin`?(vr(),lr=t,ur=n,lr.attachEvent(`onpropertychange`,yr)):e===`focusout`&&vr()}function xr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return fr(ur)}function Sr(e,t){if(e===`click`)return fr(t)}function Cr(e,t){if(e===`input`||e===`change`)return fr(t)}function wr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var Tr=typeof Object.is==`function`?Object.is:wr;function Er(e,t){if(Tr(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(!we.call(t,i)||!Tr(e[i],t[i]))return!1}return!0}function Dr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Or(e,t){var n=Dr(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=Dr(n)}}function kr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?kr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Ar(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=zt(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=zt(e.document)}return t}function jr(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 Mr=fn&&`documentMode`in document&&11>=document.documentMode,Nr=null,Pr=null,Fr=null,Ir=!1;function Lr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Ir||Nr==null||Nr!==zt(r)||(r=Nr,`selectionStart`in r&&jr(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}),Fr&&Er(Fr,r)||(Fr=r,r=Hd(Pr,`onSelect`),0<r.length&&(t=new wn(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Nr)))}function Rr(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var zr={animationend:Rr(`Animation`,`AnimationEnd`),animationiteration:Rr(`Animation`,`AnimationIteration`),animationstart:Rr(`Animation`,`AnimationStart`),transitionrun:Rr(`Transition`,`TransitionRun`),transitionstart:Rr(`Transition`,`TransitionStart`),transitioncancel:Rr(`Transition`,`TransitionCancel`),transitionend:Rr(`Transition`,`TransitionEnd`)},Br={},Vr={};fn&&(Vr=document.createElement(`div`).style,`AnimationEvent`in window||(delete zr.animationend.animation,delete zr.animationiteration.animation,delete zr.animationstart.animation),`TransitionEvent`in window||delete zr.transitionend.transition);function Hr(e){if(Br[e])return Br[e];if(!zr[e])return e;var t=zr[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in Vr)return Br[e]=t[n];return e}var Ur=Hr(`animationend`),Wr=Hr(`animationiteration`),Gr=Hr(`animationstart`),Kr=Hr(`transitionrun`),qr=Hr(`transitionstart`),Jr=Hr(`transitioncancel`),Yr=Hr(`transitionend`),Xr=new Map,Zr=`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(` `);Zr.push(`scrollEnd`);function Qr(e,t){Xr.set(e,t),Tt(t,[e])}var $r=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)},ei=[],ti=0,ni=0;function ri(){for(var e=ti,t=ni=ti=0;t<e;){var n=ei[t];ei[t++]=null;var r=ei[t];ei[t++]=null;var i=ei[t];ei[t++]=null;var a=ei[t];if(ei[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&&si(n,i,a)}}function ii(e,t,n,r){ei[ti++]=e,ei[ti++]=t,ei[ti++]=n,ei[ti++]=r,ni|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function ai(e,t,n,r){return ii(e,t,n,r),ci(e)}function oi(e,t){return ii(e,null,null,t),ci(e)}function si(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-Ve(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function ci(e){if(50<Tu)throw Tu=0,Eu=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var li={};function ui(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 di(e,t,n,r){return new ui(e,t,n,r)}function fi(e){return e=e.prototype,!(!e||!e.isReactComponent)}function pi(e,t){var n=e.alternate;return n===null?(n=di(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 mi(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 hi(e,t,n,r,a,o){var s=0;if(r=e,typeof e==`function`)fi(e)&&(s=1);else if(typeof e==`string`)s=op(e,n,le.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(e){case k:return e=di(31,n,t,a),e.elementType=k,e.lanes=o,e;case y:return gi(n.children,a,o,t);case b:s=8,a|=24;break;case x:return e=di(12,n,t,a|2),e.elementType=x,e.lanes=o,e;case T:return e=di(13,n,t,a),e.elementType=T,e.lanes=o,e;case E:return e=di(19,n,t,a),e.elementType=E,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 D:s=14;break a;case O:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=di(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function gi(e,t,n,r){return e=di(7,e,r,t),e.lanes=n,e}function _i(e,t,n){return e=di(6,e,null,t),e.lanes=n,e}function vi(e){var t=di(18,null,null,0);return t.stateNode=e,t}function yi(e,t,n){return t=di(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var bi=new WeakMap;function xi(e,t){if(typeof e==`object`&&e){var n=bi.get(e);return n===void 0?(t={value:e,source:t,stack:Ce(t)},bi.set(e,t),t):n}return{value:e,source:t,stack:Ce(t)}}var Si=[],Ci=0,wi=null,Ti=0,Ei=[],Di=0,Oi=null,ki=1,Ai=``;function ji(e,t){Si[Ci++]=Ti,Si[Ci++]=wi,wi=e,Ti=t}function Mi(e,t,n){Ei[Di++]=ki,Ei[Di++]=Ai,Ei[Di++]=Oi,Oi=e;var r=ki;e=Ai;var i=32-Ve(r)-1;r&=~(1<<i),n+=1;var a=32-Ve(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,ki=1<<32-Ve(t)+i|n<<i|r,Ai=a+e}else ki=1<<a|n<<i|r,Ai=e}function Ni(e){e.return!==null&&(ji(e,1),Mi(e,1,0))}function Pi(e){for(;e===wi;)wi=Si[--Ci],Si[Ci]=null,Ti=Si[--Ci],Si[Ci]=null;for(;e===Oi;)Oi=Ei[--Di],Ei[Di]=null,Ai=Ei[--Di],Ei[Di]=null,ki=Ei[--Di],Ei[Di]=null}function Fi(e,t){Ei[Di++]=ki,Ei[Di++]=Ai,Ei[Di++]=Oi,ki=t.id,Ai=t.overflow,Oi=e}var Ii=null,Li=null,Ri=!1,zi=null,Bi=!1,Vi=Error(i(519));function Hi(e){throw Ji(xi(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[lt]=e,t[ut]=r,n){case`dialog`:Fd(`cancel`,t),Fd(`close`,t);break;case`iframe`:case`object`:case`embed`:Fd(`load`,t);break;case`video`:case`audio`:for(n=0;n<Md.length;n++)Fd(Md[n],t);break;case`source`:Fd(`error`,t);break;case`img`:case`image`:case`link`:Fd(`error`,t),Fd(`load`,t);break;case`details`:Fd(`toggle`,t);break;case`input`:Fd(`invalid`,t),Ut(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Fd(`invalid`,t);break;case`textarea`:Fd(`invalid`,t),qt(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||Jd(t.textContent,n)?(r.popover!=null&&(Fd(`beforetoggle`,t),Fd(`toggle`,t)),r.onScroll!=null&&Fd(`scroll`,t),r.onScrollEnd!=null&&Fd(`scrollend`,t),r.onClick!=null&&(t.onclick=nn),t=!0):t=!1,t||Hi(e,!0)}function Wi(e){for(Ii=e.return;Ii;)switch(Ii.tag){case 5:case 31:case 13:Bi=!1;return;case 27:case 3:Bi=!0;return;default:Ii=Ii.return}}function Gi(e){if(e!==Ii)return!1;if(!Ri)return Wi(e),Ri=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||sf(e.type,e.memoizedProps)),n=!n),n&&Li&&Hi(e),Wi(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Li=Df(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));Li=Df(e)}else t===27?(t=Li,hf(e.type)?(e=Ef,Ef=null,Li=e):Li=t):Li=Ii?Tf(e.stateNode.nextSibling):null;return!0}function Ki(){Li=Ii=null,Ri=!1}function qi(){var e=zi;return e!==null&&(du===null?du=e:du.push.apply(du,e),zi=null),e}function Ji(e){zi===null?zi=[e]:zi.push(e)}var Yi=se(null),Xi=null,Zi=null;function Qi(e,t,n){ce(Yi,t._currentValue),t._currentValue=n}function $i(e){e._currentValue=Yi.current,P(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;Tr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===fe.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[hp]:e.push(hp))}a=a.return}e!==null&&ta(t,e,n,r),t.flags|=262144}function ra(e){for(e=e.firstContext;e!==null;){if(!Tr(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=Ed(),_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=M.S;M.S=function(e,t){mu=ke(),typeof t==`object`&&t&&typeof t.then==`function`&&va(e,t),xa!==null&&xa(e,t)};var Sa=se(null);function Ca(){var e=Sa.current;return e===null?Yl.pooledCache:e}function wa(e,t){t===null?ce(Sa,Sa.current):ce(Sa,t.pool)}function Ta(){var e=Ca();return e===null?null:{parent:da._currentValue,pool:e}}var Ea=Error(i(460)),Da=Error(i(474)),Oa=Error(i(542)),ka={then:function(){}};function Aa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function ja(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(nn,nn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,Fa(e),e;default:if(typeof t.status==`string`)t.then(nn,nn);else{if(e=Yl,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,Fa(e),e}throw Na=t,Ea}}function Ma(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(Na=e,Ea):e}}var Na=null;function Pa(){if(Na===null)throw Error(i(459));var e=Na;return Na=null,e}function Fa(e){if(e===Ea||e===Oa)throw Error(i(483))}var Ia=null,La=0;function Ra(e){var t=La;return La+=1,Ia===null&&(Ia=[]),ja(Ia,e,t)}function za(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function Ba(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 Va(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=pi(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=_i(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===O&&Ma(i)===t.type)?(t=a(t,n.props),za(t,n),t.return=e,t):(t=hi(n.type,n.key,n.props,null,e.mode,r),za(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=yi(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=gi(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=_i(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case _:return n=hi(t.type,t.key,t.props,null,e.mode,n),za(n,t),n.return=e,n;case v:return t=yi(t,e.mode,n),t.return=e,t;case O:return t=Ma(t),f(e,t,n)}if(re(t)||ee(t))return t=gi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,Ra(t),n);if(t.$$typeof===C)return f(e,oa(e,t),n);Ba(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 O:return n=Ma(n),p(e,t,n,r)}if(re(n)||ee(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,Ra(n),r);if(n.$$typeof===C)return p(e,t,oa(e,n),r);Ba(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 O:return r=Ma(r),m(e,t,n,r,i)}if(re(r)||ee(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,Ra(r),i);if(r.$$typeof===C)return m(e,t,n,oa(t,r),i);Ba(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),Ri&&ji(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 Ri&&ji(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)}),Ri&&ji(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),Ri&&ji(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 Ri&&ji(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)}),Ri&&ji(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===O&&Ma(l)===r.type){n(e,r.sibling),c=a(r,o.props),za(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===y?(c=gi(o.props.children,e.mode,c,o.key),c.return=e,e=c):(c=hi(o.type,o.key,o.props,null,e.mode,c),za(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=yi(o,e.mode,c),c.return=e,e=c}return s(e);case O:return o=Ma(o),b(e,r,o,c)}if(re(o))return h(e,r,o,c);if(ee(o)){if(l=ee(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,Ra(o),c);if(o.$$typeof===C)return b(e,r,oa(e,o),c);Ba(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=_i(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{La=0;var i=b(e,t,n,r);return Ia=null,i}catch(t){if(t===Ea||t===Oa)throw t;var a=di(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ha=Va(!0),Ua=Va(!1),Wa=!1;function Ga(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ka(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 qa(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Ja(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Jl&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=ci(e),si(e,null,n),t}return ii(e,r,t,n),ci(e)}function Ya(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,rt(e,n)}}function Xa(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 Za=!1;function Qa(){if(Za){var e=_a;if(e!==null)throw e}}function $a(e,t,n,r){Za=!1;var i=e.updateQueue;Wa=!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?(Zl&f)===f:(r&f)===f){f!==0&&f===ga&&(Za=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(m=g.payload,typeof m==`function`){d=m.call(_,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=g.payload,f=typeof m==`function`?m.call(_,d,f):m,f==null)break a;d=h({},d,f);break a;case 2:Wa=!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),au|=o,e.lanes=o,e.memoizedState=d}}function eo(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function to(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)eo(n[e],t)}var no=se(null),ro=se(0);function io(e,t){e=ru,ce(ro,e),ce(no,t),ru=e|t.baseLanes}function ao(){ce(ro,ru),ce(no,no.current)}function oo(){ru=ro.current,P(no),P(ro)}var so=se(null),co=null;function lo(e){var t=e.alternate;ce(ho,ho.current&1),ce(so,e),co===null&&(t===null||no.current!==null||t.memoizedState!==null)&&(co=e)}function uo(e){ce(ho,ho.current),ce(so,e),co===null&&(co=e)}function fo(e){e.tag===22?(ce(ho,ho.current),ce(so,e),co===null&&(co=e)):po(e)}function po(){ce(ho,ho.current),ce(so,so.current)}function mo(e){P(so),co===e&&(co=null),P(ho)}var ho=se(0);function go(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||Sf(n)||Cf(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 _o=0,vo=null,yo=null,bo=null,xo=!1,So=!1,Co=!1,wo=0,To=0,Eo=null,Do=0;function Oo(){throw Error(i(321))}function ko(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Tr(e[n],t[n]))return!1;return!0}function Ao(e,t,n,r,i,a){return _o=a,vo=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,M.H=e===null||e.memoizedState===null?qs:Js,Co=!1,a=n(r,i),Co=!1,So&&(a=Mo(t,n,r,i)),jo(e),a}function jo(e){M.H=Ks;var t=yo!==null&&yo.next!==null;if(_o=0,bo=yo=vo=null,xo=!1,To=0,Eo=null,t)throw Error(i(300));e===null||dc||(e=e.dependencies,e!==null&&ra(e)&&(dc=!0))}function Mo(e,t,n,r){vo=e;var a=0;do{if(So&&(Eo=null),To=0,So=!1,25<=a)throw Error(i(301));if(a+=1,bo=yo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}M.H=Ys,o=t(n,r)}while(So);return o}function No(){var e=M.H,t=e.useState()[0];return t=typeof t.then==`function`?Bo(t):t,e=e.useState()[0],(yo===null?null:yo.memoizedState)!==e&&(vo.flags|=1024),t}function Po(){var e=wo!==0;return wo=0,e}function Fo(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function Io(e){if(xo){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}xo=!1}_o=0,bo=yo=vo=null,So=!1,To=wo=0,Eo=null}function Lo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return bo===null?vo.memoizedState=bo=e:bo=bo.next=e,bo}function Ro(){if(yo===null){var e=vo.alternate;e=e===null?null:e.memoizedState}else e=yo.next;var t=bo===null?vo.memoizedState:bo.next;if(t!==null)bo=t,yo=e;else{if(e===null)throw vo.alternate===null?Error(i(467)):Error(i(310));yo=e,e={memoizedState:yo.memoizedState,baseState:yo.baseState,baseQueue:yo.baseQueue,queue:yo.queue,next:null},bo===null?vo.memoizedState=bo=e:bo=bo.next=e}return bo}function zo(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Bo(e){var t=To;return To+=1,Eo===null&&(Eo=[]),e=ja(Eo,e,t),t=vo,(bo===null?t.memoizedState:bo.next)===null&&(t=t.alternate,M.H=t===null||t.memoizedState===null?qs:Js),e}function Vo(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return Bo(e);if(e.$$typeof===C)return aa(e)}throw Error(i(438,String(e)))}function Ho(e){var t=null,n=vo.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=vo.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=zo(),vo.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]=A;return t.index++,n}function Uo(e,t){return typeof t==`function`?t(e):t}function Wo(e){return Go(Ro(),yo,e)}function Go(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?(_o&f)===f:(Zl&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((_o&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,vo.lanes|=p,au|=p;f=u.action,Co&&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,vo.lanes|=f,au|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!Tr(o,e.memoizedState)&&(dc=!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 Ko(e){var t=Ro(),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);Tr(o,t.memoizedState)||(dc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function qo(e,t,n){var r=vo,a=Ro(),o=Ri;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!Tr((yo||a).memoizedState,n);if(s&&(a.memoizedState=n,dc=!0),a=a.queue,vs(Xo.bind(null,r,a,e),[e]),a.getSnapshot!==t||s||bo!==null&&bo.memoizedState.tag&1){if(r.flags|=2048,ps(9,{destroy:void 0},Yo.bind(null,r,a,n,t),null),Yl===null)throw Error(i(349));o||_o&127||Jo(r,t,n)}return n}function Jo(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=vo.updateQueue,t===null?(t=zo(),vo.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function Yo(e,t,n,r){t.value=n,t.getSnapshot=r,Zo(t)&&Qo(e)}function Xo(e,t,n){return n(function(){Zo(t)&&Qo(e)})}function Zo(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Tr(e,n)}catch{return!0}}function Qo(e){var t=oi(e,2);t!==null&&ku(t,e,2)}function $o(e){var t=Lo();if(typeof e==`function`){var n=e;if(e=n(),Co){Be(!0);try{n()}finally{Be(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:e},t}function es(e,t,n,r){return e.baseState=n,Go(e,yo,typeof r==`function`?r:Uo)}function ts(e,t,n,r,a){if(Us(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)}};M.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,ns(t,o)):(o.next=n.next,t.pending=n.next=o)}}function ns(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=M.T,o={};M.T=o;try{var s=n(i,r),c=M.S;c!==null&&c(o,s),rs(e,t,s)}catch(n){as(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),M.T=a}}else try{a=n(i,r),rs(e,t,a)}catch(n){as(e,t,n)}}function rs(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){is(e,t,n)},function(n){return as(e,t,n)}):is(e,t,n)}function is(e,t,n){t.status=`fulfilled`,t.value=n,os(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,ns(e,n)))}function as(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,os(t),t=t.next;while(t!==r)}e.action=null}function os(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function ss(e,t){return t}function cs(e,t){if(Ri){var n=Yl.formState;if(n!==null){a:{var r=vo;if(Ri){if(Li){b:{for(var i=Li,a=Bi;i.nodeType!==8;){if(!a){i=null;break b}if(i=Tf(i.nextSibling),i===null){i=null;break b}}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){Li=Tf(i.nextSibling),r=i.data===`F!`;break a}}Hi(r)}r=!1}r&&(t=n[0])}}return n=Lo(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ss,lastRenderedState:t},n.queue=r,n=Bs.bind(null,vo,r),r.dispatch=n,r=$o(!1),a=Hs.bind(null,vo,!1,r.queue),r=Lo(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=ts.bind(null,vo,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function ls(e){return us(Ro(),yo,e)}function us(e,t,n){if(t=Go(e,t,ss)[0],e=Wo(Uo)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=Bo(t)}catch(e){throw e===Ea?Oa:e}else r=t;t=Ro();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(vo.flags|=2048,ps(9,{destroy:void 0},ds.bind(null,i,n),null)),[r,a,e]}function ds(e,t){e.action=t}function fs(e){var t=Ro(),n=yo;if(n!==null)return us(t,n,e);Ro(),t=t.memoizedState,n=Ro();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function ps(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=vo.updateQueue,t===null&&(t=zo(),vo.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 ms(){return Ro().memoizedState}function hs(e,t,n,r){var i=Lo();vo.flags|=e,i.memoizedState=ps(1|t,{destroy:void 0},n,r===void 0?null:r)}function gs(e,t,n,r){var i=Ro();r=r===void 0?null:r;var a=i.memoizedState.inst;yo!==null&&r!==null&&ko(r,yo.memoizedState.deps)?i.memoizedState=ps(t,a,n,r):(vo.flags|=e,i.memoizedState=ps(1|t,a,n,r))}function _s(e,t){hs(8390656,8,e,t)}function vs(e,t){gs(2048,8,e,t)}function ys(e){vo.flags|=4;var t=vo.updateQueue;if(t===null)t=zo(),vo.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function bs(e){var t=Ro().memoizedState;return ys({ref:t,nextImpl:e}),function(){if(Jl&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function xs(e,t){return gs(4,2,e,t)}function Ss(e,t){return gs(4,4,e,t)}function Cs(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 ws(e,t,n){n=n==null?null:n.concat([e]),gs(4,4,Cs.bind(null,t,e),n)}function Ts(){}function Es(e,t){var n=Ro();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&ko(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Ds(e,t){var n=Ro();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&ko(t,r[1]))return r[0];if(r=e(),Co){Be(!0);try{e()}finally{Be(!1)}}return n.memoizedState=[r,t],r}function Os(e,t,n){return n===void 0||_o&1073741824&&!(Zl&261930)?e.memoizedState=t:(e.memoizedState=n,e=Ou(),vo.lanes|=e,au|=e,n)}function ks(e,t,n,r){return Tr(n,t)?n:no.current===null?!(_o&42)||_o&1073741824&&!(Zl&261930)?(dc=!0,e.memoizedState=n):(e=Ou(),vo.lanes|=e,au|=e,t):(e=Os(e,n,r),Tr(e,t)||(dc=!0),e)}function As(e,t,n,r,i){var a=N.p;N.p=a!==0&&8>a?a:8;var o=M.T,s={};M.T=s,Hs(e,!1,t,n);try{var c=i(),l=M.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Vs(e,t,ba(c,r),Du(e)):Vs(e,t,r,Du(e))}catch(n){Vs(e,t,{then:function(){},status:`rejected`,reason:n},Du())}finally{N.p=a,o!==null&&s.types!==null&&(o.types=s.types),M.T=o}}function js(){}function Ms(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=Ns(e).queue;As(e,a,t,ie,n===null?js:function(){return Ps(e),n(r)})}function Ns(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:ie,baseState:ie,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:ie},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Uo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Ps(e){var t=Ns(e);t.next===null&&(t=e.alternate.memoizedState),Vs(e,t.next.queue,{},Du())}function Fs(){return aa(hp)}function Is(){return Ro().memoizedState}function Ls(){return Ro().memoizedState}function Rs(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=Du();e=qa(n);var r=Ja(t,e,n);r!==null&&(ku(r,t,n),Ya(r,t,n)),t={cache:fa()},e.payload=t;return}t=t.return}}function zs(e,t,n){var r=Du();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Us(e)?Ws(t,n):(n=ai(e,t,n,r),n!==null&&(ku(n,e,r),Gs(n,t,r)))}function Bs(e,t,n){Vs(e,t,n,Du())}function Vs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Us(e))Ws(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,Tr(s,o))return ii(e,t,i,0),Yl===null&&ri(),!1}catch{}if(n=ai(e,t,i,r),n!==null)return ku(n,e,r),Gs(n,t,r),!0}return!1}function Hs(e,t,n,r){if(r={lane:2,revertLane:Ed(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Us(e)){if(t)throw Error(i(479))}else t=ai(e,n,r,2),t!==null&&ku(t,e,2)}function Us(e){var t=e.alternate;return e===vo||t!==null&&t===vo}function Ws(e,t){So=xo=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function Gs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rt(e,n)}}var Ks={readContext:aa,use:Vo,useCallback:Oo,useContext:Oo,useEffect:Oo,useImperativeHandle:Oo,useLayoutEffect:Oo,useInsertionEffect:Oo,useMemo:Oo,useReducer:Oo,useRef:Oo,useState:Oo,useDebugValue:Oo,useDeferredValue:Oo,useTransition:Oo,useSyncExternalStore:Oo,useId:Oo,useHostTransitionStatus:Oo,useFormState:Oo,useActionState:Oo,useOptimistic:Oo,useMemoCache:Oo,useCacheRefresh:Oo};Ks.useEffectEvent=Oo;var qs={readContext:aa,use:Vo,useCallback:function(e,t){return Lo().memoizedState=[e,t===void 0?null:t],e},useContext:aa,useEffect:_s,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),hs(4194308,4,Cs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return hs(4194308,4,e,t)},useInsertionEffect:function(e,t){hs(4,2,e,t)},useMemo:function(e,t){var n=Lo();t=t===void 0?null:t;var r=e();if(Co){Be(!0);try{e()}finally{Be(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=Lo();if(n!==void 0){var i=n(t);if(Co){Be(!0);try{n(t)}finally{Be(!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=zs.bind(null,vo,e),[r.memoizedState,e]},useRef:function(e){var t=Lo();return e={current:e},t.memoizedState=e},useState:function(e){e=$o(e);var t=e.queue,n=Bs.bind(null,vo,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ts,useDeferredValue:function(e,t){return Os(Lo(),e,t)},useTransition:function(){var e=$o(!1);return e=As.bind(null,vo,e.queue,!0,!1),Lo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=vo,a=Lo();if(Ri){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),Yl===null)throw Error(i(349));Zl&127||Jo(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,_s(Xo.bind(null,r,o,e),[e]),r.flags|=2048,ps(9,{destroy:void 0},Yo.bind(null,r,o,n,t),null),n},useId:function(){var e=Lo(),t=Yl.identifierPrefix;if(Ri){var n=Ai,r=ki;n=(r&~(1<<32-Ve(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=wo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Do++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:Fs,useFormState:cs,useActionState:cs,useOptimistic:function(e){var t=Lo();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=Hs.bind(null,vo,!0,n),n.dispatch=t,[e,t]},useMemoCache:Ho,useCacheRefresh:function(){return Lo().memoizedState=Rs.bind(null,vo)},useEffectEvent:function(e){var t=Lo(),n={impl:e};return t.memoizedState=n,function(){if(Jl&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},Js={readContext:aa,use:Vo,useCallback:Es,useContext:aa,useEffect:vs,useImperativeHandle:ws,useInsertionEffect:xs,useLayoutEffect:Ss,useMemo:Ds,useReducer:Wo,useRef:ms,useState:function(){return Wo(Uo)},useDebugValue:Ts,useDeferredValue:function(e,t){return ks(Ro(),yo.memoizedState,e,t)},useTransition:function(){var e=Wo(Uo)[0],t=Ro().memoizedState;return[typeof e==`boolean`?e:Bo(e),t]},useSyncExternalStore:qo,useId:Is,useHostTransitionStatus:Fs,useFormState:ls,useActionState:ls,useOptimistic:function(e,t){return es(Ro(),yo,e,t)},useMemoCache:Ho,useCacheRefresh:Ls};Js.useEffectEvent=bs;var Ys={readContext:aa,use:Vo,useCallback:Es,useContext:aa,useEffect:vs,useImperativeHandle:ws,useInsertionEffect:xs,useLayoutEffect:Ss,useMemo:Ds,useReducer:Ko,useRef:ms,useState:function(){return Ko(Uo)},useDebugValue:Ts,useDeferredValue:function(e,t){var n=Ro();return yo===null?Os(n,e,t):ks(n,yo.memoizedState,e,t)},useTransition:function(){var e=Ko(Uo)[0],t=Ro().memoizedState;return[typeof e==`boolean`?e:Bo(e),t]},useSyncExternalStore:qo,useId:Is,useHostTransitionStatus:Fs,useFormState:fs,useActionState:fs,useOptimistic:function(e,t){var n=Ro();return yo===null?(n.baseState=e,[e,n.queue.dispatch]):es(n,yo,e,t)},useMemoCache:Ho,useCacheRefresh:Ls};Ys.useEffectEvent=bs;function Xs(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:h({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Zs={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Du(),i=qa(r);i.payload=t,n!=null&&(i.callback=n),t=Ja(e,i,r),t!==null&&(ku(t,e,r),Ya(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Du(),i=qa(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ja(e,i,r),t!==null&&(ku(t,e,r),Ya(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Du(),r=qa(n);r.tag=2,t!=null&&(r.callback=t),t=Ja(e,r,n),t!==null&&(ku(t,e,n),Ya(t,e,n))}};function Qs(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?!Er(n,r)||!Er(i,a):!0}function $s(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&&Zs.enqueueReplaceState(t,t.state,null)}function ec(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=h({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function tc(e){$r(e)}function nc(e){console.error(e)}function rc(e){$r(e)}function ic(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function ac(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 oc(e,t,n){return n=qa(n),n.tag=3,n.payload={element:null},n.callback=function(){ic(e,t)},n}function sc(e){return e=qa(e),e.tag=3,e}function cc(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(){ac(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){ac(t,n,r),typeof i!=`function`&&(_u===null?_u=new Set([this]):_u.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function lc(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=so.current,n!==null){switch(n.tag){case 31:case 13:return co===null?Vu():n.alternate===null&&iu===0&&(iu=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===ka?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),od(e,r,a)),!1;case 22:return n.flags|=65536,r===ka?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)),od(e,r,a)),!1}throw Error(i(435,n.tag))}return od(e,r,a),Vu(),!1}if(Ri)return t=so.current,t===null?(r!==Vi&&(t=Error(i(423),{cause:r}),Ji(xi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=xi(r,n),a=oc(e.stateNode,r,a),Xa(e,a),iu!==4&&(iu=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==Vi&&(e=Error(i(422),{cause:r}),Ji(xi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=xi(o,n),uu===null?uu=[o]:uu.push(o),iu!==4&&(iu=2),t===null)return!0;r=xi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=oc(n.stateNode,r,e),Xa(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`&&(_u===null||!_u.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=sc(a),cc(a,e,n,r),Xa(n,a),!1}n=n.return}while(n!==null);return!1}var uc=Error(i(461)),dc=!1;function fc(e,t,n,r){t.child=e===null?Ua(t,null,n,r):Ha(t,e.child,n,r)}function pc(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=Ao(e,t,n,o,a,i),s=Po(),e!==null&&!dc?(Fo(e,t,i),Ic(e,t,i)):(Ri&&s&&Ni(t),t.flags|=1,fc(e,t,r,i),t.child)}function mc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!fi(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,hc(e,t,a,r,i)):(e=hi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!Lc(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Er:n,n(o,r)&&e.ref===t.ref)return Ic(e,t,i)}return t.flags|=1,e=pi(a,r),e.ref=t.ref,e.return=t,t.child=e}function hc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Er(a,r)&&e.ref===t.ref){if(dc=!1,t.pendingProps=r=a,Lc(e,i))e.flags&131072&&(dc=!0);else return t.lanes=e.lanes,Ic(e,t,i)}}return Cc(e,t,n,r,i)}function gc(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 vc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&wa(t,a===null?null:a.cachePool),a===null?ao():io(t,a),fo(t);else return r=t.lanes=536870912,vc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&wa(t,null),ao(),po(t)):(wa(t,a.cachePool),io(t,a),po(t),t.memoizedState=null);return fc(e,t,i,n),t.child}function _c(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function vc(e,t,n,r,i){var a=Ca();return a=a===null?null:{parent:da._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&wa(t,null),ao(),fo(t),e!==null&&na(e,t,r,!0),t.childLanes=i,null}function yc(e,t){return t=jc({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function bc(e,t,n){return Ha(t,e.child,null,n),e=yc(t,t.pendingProps),e.flags|=2,mo(t),t.memoizedState=null,e}function xc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(Ri){if(r.mode===`hidden`)return e=yc(t,r),t.lanes=536870912,_c(null,e);if(uo(t),(e=Li)?(e=xf(e,Bi),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Oi===null?null:{id:ki,overflow:Ai},retryLane:536870912,hydrationErrors:null},n=vi(e),n.return=t,t.child=n,Ii=t,Li=null)):e=null,e===null)throw Hi(t);return t.lanes=536870912,null}return yc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(uo(t),a){if(t.flags&256)t.flags&=-257,t=bc(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(dc||na(e,t,n,!1),a=(n&e.childLanes)!==0,dc||a){if(r=Yl,r!==null&&(s=it(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,oi(e,s),ku(r,e,s),uc;Vu(),t=bc(e,t,n)}else e=o.treeContext,Li=Tf(s.nextSibling),Ii=t,Ri=!0,zi=null,Bi=!1,e!==null&&Fi(t,e),t=yc(t,r),t.flags|=4096;return t}return e=pi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Sc(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 Cc(e,t,n,r,i){return ia(t),n=Ao(e,t,n,r,void 0,i),r=Po(),e!==null&&!dc?(Fo(e,t,i),Ic(e,t,i)):(Ri&&r&&Ni(t),t.flags|=1,fc(e,t,n,i),t.child)}function wc(e,t,n,r,i,a){return ia(t),t.updateQueue=null,n=Mo(t,r,n,i),jo(e),r=Po(),e!==null&&!dc?(Fo(e,t,a),Ic(e,t,a)):(Ri&&r&&Ni(t),t.flags|=1,fc(e,t,n,a),t.child)}function Tc(e,t,n,r,i){if(ia(t),t.stateNode===null){var a=li,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=Zs,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},Ga(t),o=n.contextType,a.context=typeof o==`object`&&o?aa(o):li,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(Xs(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&&Zs.enqueueReplaceState(a,a.state,null),$a(t,r,a,i),Qa(),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=ec(n,s);a.props=c;var l=a.context,u=n.contextType;o=li,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)&&$s(t,a,r,o),Wa=!1;var f=t.memoizedState;a.state=f,$a(t,r,a,i),Qa(),l=t.memoizedState,s||f!==l||Wa?(typeof d==`function`&&(Xs(t,n,d,r),l=t.memoizedState),(c=Wa||Qs(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,Ka(e,t),o=t.memoizedProps,u=ec(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=li,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)&&$s(t,a,r,c),Wa=!1,f=t.memoizedState,a.state=f,$a(t,r,a,i),Qa();var p=t.memoizedState;o!==d||f!==p||Wa||e!==null&&e.dependencies!==null&&ra(e.dependencies)?(typeof s==`function`&&(Xs(t,n,s,r),p=t.memoizedState),(u=Wa||Qs(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,Sc(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=Ha(t,e.child,null,i),t.child=Ha(t,null,n,i)):fc(e,t,n,i),t.memoizedState=a.state,e=t.child):e=Ic(e,t,i),e}function Ec(e,t,n,r){return Ki(),t.flags|=256,fc(e,t,n,r),t.child}var Dc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Oc(e){return{baseLanes:e,cachePool:Ta()}}function I(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=cu),e}function kc(e,t,n){var r=t.pendingProps,a=!1,o=!!(t.flags&128),s;if((s=o)||(s=e!==null&&e.memoizedState===null?!1:!!(ho.current&2)),s&&(a=!0,t.flags&=-129),s=!!(t.flags&32),t.flags&=-33,e===null){if(Ri){if(a?lo(t):po(t),(e=Li)?(e=xf(e,Bi),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:Oi===null?null:{id:ki,overflow:Ai},retryLane:536870912,hydrationErrors:null},n=vi(e),n.return=t,t.child=n,Ii=t,Li=null)):e=null,e===null)throw Hi(t);return Cf(e)?t.lanes=32:t.lanes=536870912,null}var c=r.children;return r=r.fallback,a?(po(t),a=t.mode,c=jc({mode:`hidden`,children:c},a),r=gi(r,a,n,null),c.return=t,r.return=t,c.sibling=r,t.child=c,r=t.child,r.memoizedState=Oc(n),r.childLanes=I(e,s,n),t.memoizedState=Dc,_c(null,r)):(lo(t),Ac(t,c))}var l=e.memoizedState;if(l!==null&&(c=l.dehydrated,c!==null)){if(o)t.flags&256?(lo(t),t.flags&=-257,t=Mc(e,t,n)):t.memoizedState===null?(po(t),c=r.fallback,a=t.mode,r=jc({mode:`visible`,children:r.children},a),c=gi(c,a,n,null),c.flags|=2,r.return=t,c.return=t,r.sibling=c,t.child=r,Ha(t,e.child,null,n),r=t.child,r.memoizedState=Oc(n),r.childLanes=I(e,s,n),t.memoizedState=Dc,t=_c(null,r)):(po(t),t.child=e.child,t.flags|=128,t=null);else if(lo(t),Cf(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=Mc(e,t,n)}else if(dc||na(e,t,n,!1),s=(n&e.childLanes)!==0,dc||s){if(s=Yl,s!==null&&(r=it(s,n),r!==0&&r!==l.retryLane))throw l.retryLane=r,oi(e,r),ku(s,e,r),uc;Sf(c)||Vu(),t=Mc(e,t,n)}else Sf(c)?(t.flags|=192,t.child=e.child,t=null):(e=l.treeContext,Li=Tf(c.nextSibling),Ii=t,Ri=!0,zi=null,Bi=!1,e!==null&&Fi(t,e),t=Ac(t,r.children),t.flags|=4096);return t}return a?(po(t),c=r.fallback,a=t.mode,l=e.child,u=l.sibling,r=pi(l,{mode:`hidden`,children:r.children}),r.subtreeFlags=l.subtreeFlags&65011712,u===null?(c=gi(c,a,n,null),c.flags|=2):c=pi(u,c),c.return=t,r.return=t,r.sibling=c,t.child=r,_c(null,r),r=t.child,c=e.child.memoizedState,c===null?c=Oc(n):(a=c.cachePool,a===null?a=Ta():(l=da._currentValue,a=a.parent===l?a:{parent:l,pool:l}),c={baseLanes:c.baseLanes|n,cachePool:a}),r.memoizedState=c,r.childLanes=I(e,s,n),t.memoizedState=Dc,_c(e.child,r)):(lo(t),n=e.child,e=n.sibling,n=pi(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 Ac(e,t){return t=jc({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function jc(e,t){return e=di(22,e,null,t),e.lanes=0,e}function Mc(e,t,n){return Ha(t,e.child,null,n),e=Ac(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function Nc(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ea(e.return,t,n)}function Pc(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 Fc(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=ho.current,s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,ce(ho,o),fc(e,t,r,n),r=Ri?Ti:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Nc(e,n,t);else if(e.tag===19)Nc(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&&go(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),Pc(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&&go(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}Pc(t,!0,n,null,a,r);break;case`together`:Pc(t,!1,null,null,void 0,r);break;default:t.memoizedState=null}return t.child}function Ic(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),au|=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=pi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=pi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function Lc(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&ra(e)))}function Rc(e,t,n){switch(t.tag){case 3:pe(t,t.stateNode.containerInfo),Qi(t,da,e.memoizedState.cache),Ki();break;case 27:case 5:he(t);break;case 4:pe(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,uo(t),null;break;case 13:var r=t.memoizedState;if(r!==null)return r.dehydrated===null?(n&t.child.childLanes)===0?(lo(t),e=Ic(e,t,n),e===null?null:e.sibling):kc(e,t,n):(lo(t),t.flags|=128,null);lo(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 Fc(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),ce(ho,ho.current),r)break;return null;case 22:return t.lanes=0,gc(e,t,n,t.pendingProps);case 24:Qi(t,da,e.memoizedState.cache)}return Ic(e,t,n)}function zc(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)dc=!0;else{if(!Lc(e,n)&&!(t.flags&128))return dc=!1,Rc(e,t,n);dc=!!(e.flags&131072)}}else dc=!1,Ri&&t.flags&1048576&&Mi(t,Ti,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=Ma(t.elementType),t.type=e,typeof e==`function`)fi(e)?(r=ec(e,r),t.tag=1,t=Tc(null,t,e,r,n)):(t.tag=0,t=Cc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===w){t.tag=11,t=pc(null,t,e,r,n);break a}if(a===D){t.tag=14,t=mc(null,t,e,r,n);break a}}throw t=ne(e)||e,Error(i(306,t,``))}}return t;case 0:return Cc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=ec(r,t.pendingProps),Tc(e,t,r,a,n);case 3:a:{if(pe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,Ka(e,t),$a(t,r,null,n);var s=t.memoizedState;if(r=s.cache,Qi(t,da,r),r!==o.cache&&ta(t,[da],n,!0),Qa(),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=Ec(e,t,r,n);break a}if(r!==a){a=xi(Error(i(424)),t),Ji(a),t=Ec(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(Li=Tf(e.firstChild),Ii=t,Ri=!0,zi=null,Bi=!0,n=Ua(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling}else{if(Ki(),r===a){t=Ic(e,t,n);break a}fc(e,t,r,n)}t=t.child}return t;case 26:return Sc(e,t),e===null?(n=Kf(t.type,null,t.pendingProps,null))?t.memoizedState=n:Ri||(n=t.type,e=t.pendingProps,r=rf(de.current).createElement(n),r[lt]=t,r[ut]=e,Zd(r,n,e),St(r),t.stateNode=r):t.memoizedState=Kf(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return he(t),e===null&&Ri&&(r=t.stateNode=kf(t.type,t.pendingProps,de.current),Ii=t,Bi=!0,a=Li,hf(t.type)?(Ef=a,Li=Tf(r.firstChild)):Li=a),fc(e,t,t.pendingProps.children,n),Sc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&Ri&&((a=r=Li)&&(r=yf(r,t.type,t.pendingProps,Bi),r===null?a=!1:(t.stateNode=r,Ii=t,Li=Tf(r.firstChild),Bi=!1,a=!0)),a||Hi(t)),he(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,sf(a,o)?r=null:s!==null&&sf(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=Ao(e,t,No,null,null,n),hp._currentValue=a),Sc(e,t),fc(e,t,r,n),t.child;case 6:return e===null&&Ri&&((e=n=Li)&&(n=bf(n,t.pendingProps,Bi),n===null?e=!1:(t.stateNode=n,Ii=t,Li=null,e=!0)),e||Hi(t)),null;case 13:return kc(e,t,n);case 4:return pe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Ha(t,null,r,n):fc(e,t,r,n),t.child;case 11:return pc(e,t,t.type,t.pendingProps,n);case 7:return fc(e,t,t.pendingProps,n),t.child;case 8:return fc(e,t,t.pendingProps.children,n),t.child;case 12:return fc(e,t,t.pendingProps.children,n),t.child;case 10:return r=t.pendingProps,Qi(t,t.type,r.value),fc(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,fc(e,t,r,n),t.child;case 14:return mc(e,t,t.type,t.pendingProps,n);case 15:return hc(e,t,t.type,t.pendingProps,n);case 19:return Fc(e,t,n);case 31:return xc(e,t,n);case 22:return gc(e,t,n,t.pendingProps);case 24:return ia(t),r=aa(da),e===null?(a=Ca(),a===null&&(a=Yl,o=fa(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},Ga(t),Qi(t,da,a)):((e.lanes&n)!==0&&(Ka(e,t),$a(t,null,null,n),Qa()),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))),fc(e,t,t.pendingProps.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function Bc(e){e.flags|=4}function Vc(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(Ru())e.flags|=8192;else throw Na=ka,Da}}else e.flags&=-16777217}function Hc(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!sp(t)){if(Ru())e.flags|=8192;else throw Na=ka,Da}}function Uc(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:Qe(),e.lanes|=t,lu|=t)}function Wc(e,t){if(!Ri)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 Gc(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 Kc(e,t,n){var r=t.pendingProps;switch(Pi(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gc(t),null;case 1:return Gc(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),me(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(Gi(t)?Bc(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,qi())),Gc(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(Bc(t),o===null?(Gc(t),Vc(t,a,null,r,n)):(Gc(t),Hc(t,o))):o?o===e.memoizedState?(Gc(t),t.flags&=-16777217):(Bc(t),Gc(t),Hc(t,o)):(e=e.memoizedProps,e!==r&&Bc(t),Gc(t),Vc(t,a,e,r,n)),null;case 27:if(ge(t),n=de.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Bc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Gc(t),null}e=le.current,Gi(t)?Ui(t,e):(e=kf(a,r,n),t.stateNode=e,Bc(t))}return Gc(t),null;case 5:if(ge(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&Bc(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return Gc(t),null}if(o=le.current,Gi(t))Ui(t,o);else{var s=rf(de.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[lt]=t,o[ut]=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&&Bc(t)}}return Gc(t),Vc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Bc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=de.current,Gi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=Ii,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[lt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Jd(e.nodeValue,n)),e||Hi(t,!0)}else e=rf(e).createTextNode(r),e[lt]=t,t.stateNode=e}return Gc(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[lt]=t}else Ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Gc(t),e=!1}else n=qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(mo(t),t):(mo(t),null);if(t.flags&128)throw Error(i(558))}return Gc(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[lt]=t}else Ki(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Gc(t),a=!1}else a=qi(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(mo(t),t):(mo(t),null)}return mo(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),Uc(t,t.updateQueue),Gc(t),null);case 4:return me(),e===null&&Rd(t.stateNode.containerInfo),Gc(t),null;case 10:return $i(t.type),Gc(t),null;case 19:if(P(ho),r=t.memoizedState,r===null)return Gc(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)Wc(r,!1);else{if(iu!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=go(e),o!==null){for(t.flags|=128,Wc(r,!1),e=o.updateQueue,t.updateQueue=e,Uc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)mi(n,e),n=n.sibling;return ce(ho,ho.current&1|2),Ri&&ji(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ke()>hu&&(t.flags|=128,a=!0,Wc(r,!1),t.lanes=4194304)}}else{if(!a){if(e=go(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,Uc(t,e),Wc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!o.alternate&&!Ri)return Gc(t),null}else 2*ke()-r.renderingStartTime>hu&&n!==536870912&&(t.flags|=128,a=!0,Wc(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?(Gc(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ke(),e.sibling=null,n=ho.current,ce(ho,a?n&1|2:n&1),Ri&&ji(t,r.treeForkCount),e);case 22:case 23:return mo(t),oo(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(Gc(t),t.subtreeFlags&6&&(t.flags|=8192)):Gc(t),n=t.updateQueue,n!==null&&Uc(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&&P(Sa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),$i(da),Gc(t),null;case 25:return null;case 30:return null}throw Error(i(156,t.tag))}function qc(e,t){switch(Pi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return $i(da),me(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ge(t),null;case 31:if(t.memoizedState!==null){if(mo(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(mo(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 P(ho),null;case 4:return me(),null;case 10:return $i(t.type),null;case 22:case 23:return mo(t),oo(),e!==null&&P(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 Jc(e,t){switch(Pi(t),t.tag){case 3:$i(da),me();break;case 26:case 27:case 5:ge(t);break;case 4:me();break;case 31:t.memoizedState!==null&&mo(t);break;case 13:mo(t);break;case 19:P(ho);break;case 10:$i(t.type);break;case 22:case 23:mo(t),oo(),e!==null&&P(Sa);break;case 24:$i(da)}}function Yc(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){ad(t,t.return,e)}}function Xc(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){ad(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){ad(t,t.return,e)}}function Zc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{to(t,n)}catch(t){ad(e,e.return,t)}}}function Qc(e,t,n){n.props=ec(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){ad(e,t,n)}}function $c(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){ad(e,t,n)}}function el(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){ad(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){ad(e,t,n)}else n.current=null}}function tl(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){ad(e,e.return,t)}}function nl(e,t,n){try{var r=e.stateNode;Qd(r,e.type,n,t),r[ut]=t}catch(t){ad(e,e.return,t)}}function rl(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&hf(e.type)||e.tag===4}function il(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||rl(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&&hf(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 al(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=nn));else if(r!==4&&(r===27&&hf(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for(al(e,t,n),e=e.sibling;e!==null;)al(e,t,n),e=e.sibling}function ol(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&&hf(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(ol(e,t,n),e=e.sibling;e!==null;)ol(e,t,n),e=e.sibling}function sl(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[lt]=e,t[ut]=n}catch(t){ad(e,e.return,t)}}var cl=!1,ll=!1,ul=!1,dl=typeof WeakSet==`function`?WeakSet:Set,fl=null;function pl(e,t){if(e=e.containerInfo,tf=wp,e=Ar(e),jr(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(nf={focusedElem:e,selectionRange:n},wp=!1,fl=t;fl!==null;)if(t=fl,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,fl=e;else for(;fl!==null;){switch(t=fl,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=ec(n.type,a);e=r.getSnapshotBeforeUpdate(h,o),r.__reactInternalSnapshotBeforeUpdate=e}catch(e){ad(n,n.return,e)}}break;case 3:if(e&1024){if(e=t.stateNode.containerInfo,n=e.nodeType,n===9)vf(e);else if(n===1)switch(e.nodeName){case`HEAD`:case`HTML`:case`BODY`:vf(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,fl=e;break}fl=t.return}}function ml(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:kl(e,n),r&4&&Yc(5,n);break;case 1:if(kl(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){ad(n,n.return,e)}else{var i=ec(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){ad(n,n.return,e)}}}r&64&&Zc(n),r&512&&$c(n,n.return);break;case 3:if(kl(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{to(e,t)}catch(e){ad(n,n.return,e)}}break;case 27:t===null&&r&4&&sl(n);case 26:case 5:kl(e,n),t===null&&r&4&&tl(n),r&512&&$c(n,n.return);break;case 12:kl(e,n);break;case 31:kl(e,n),r&4&&bl(e,n);break;case 13:kl(e,n),r&4&&xl(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=ld.bind(null,n),wf(e,n))));break;case 22:if(r=n.memoizedState!==null||cl,!r){t=t!==null&&t.memoizedState!==null||ll,i=cl;var a=ll;cl=r,(ll=t)&&!a?jl(e,n,!!(n.subtreeFlags&8772)):kl(e,n),cl=i,ll=a}break;case 30:break;default:kl(e,n)}}function hl(e){var t=e.alternate;t!==null&&(e.alternate=null,hl(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&_t(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 gl=null,_l=!1;function vl(e,t,n){for(n=n.child;n!==null;)yl(e,t,n),n=n.sibling}function yl(e,t,n){if(ze&&typeof ze.onCommitFiberUnmount==`function`)try{ze.onCommitFiberUnmount(Re,n)}catch{}switch(n.tag){case 26:ll||el(n,t),vl(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:ll||el(n,t);var r=gl,i=_l;hf(n.type)&&(gl=n.stateNode,_l=!1),vl(e,t,n),Af(n.stateNode),gl=r,_l=i;break;case 5:ll||el(n,t);case 6:if(r=gl,i=_l,gl=null,vl(e,t,n),gl=r,_l=i,gl!==null){if(_l)try{(gl.nodeType===9?gl.body:gl.nodeName===`HTML`?gl.ownerDocument.body:gl).removeChild(n.stateNode)}catch(e){ad(n,t,e)}else try{gl.removeChild(n.stateNode)}catch(e){ad(n,t,e)}}break;case 18:gl!==null&&(_l?(e=gl,gf(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Xp(e)):gf(gl,n.stateNode));break;case 4:r=gl,i=_l,gl=n.stateNode.containerInfo,_l=!0,vl(e,t,n),gl=r,_l=i;break;case 0:case 11:case 14:case 15:Xc(2,n,t),ll||Xc(4,n,t),vl(e,t,n);break;case 1:ll||(el(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&Qc(n,t,r)),vl(e,t,n);break;case 21:vl(e,t,n);break;case 22:ll=(r=ll)||n.memoizedState!==null,vl(e,t,n),ll=r;break;default:vl(e,t,n)}}function bl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Xp(e)}catch(e){ad(t,t.return,e)}}}function xl(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Xp(e)}catch(e){ad(t,t.return,e)}}function Sl(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new dl),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new dl),t;default:throw Error(i(435,e.tag))}}function Cl(e,t){var n=Sl(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=ud.bind(null,e,t);t.then(r,r)}})}function wl(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(hf(c.type)){gl=c.stateNode,_l=!1;break a}break;case 5:gl=c.stateNode,_l=!1;break a;case 3:case 4:gl=c.stateNode.containerInfo,_l=!0;break a}c=c.return}if(gl===null)throw Error(i(160));yl(o,s,a),gl=null,_l=!1,o=a.alternate,o!==null&&(o.return=null),a.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)El(t,e),t=t.sibling}var Tl=null;function El(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:wl(t,e),Dl(e),r&4&&(Xc(3,e,e.return),Yc(3,e),Xc(5,e,e.return));break;case 1:wl(t,e),Dl(e),r&512&&(ll||n===null||el(n,n.return)),r&64&&cl&&(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=Tl;if(wl(t,e),Dl(e),r&512&&(ll||n===null||el(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[gt]||o[lt]||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[lt]=e,St(o),r=o;break a;case`link`:var s=ip(`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=ip(`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[lt]=e,St(o),r=o}e.stateNode=r}else ap(a,e.type,e.stateNode)}else e.stateNode=$f(a,r,e.memoizedProps)}else o===r?r===null&&e.stateNode!==null&&nl(e,e.memoizedProps,n.memoizedProps):(o===null?n.stateNode!==null&&(n=n.stateNode,n.parentNode.removeChild(n)):o.count--,r===null?ap(a,e.type,e.stateNode):$f(a,r,e.memoizedProps))}break;case 27:wl(t,e),Dl(e),r&512&&(ll||n===null||el(n,n.return)),n!==null&&r&4&&nl(e,e.memoizedProps,n.memoizedProps);break;case 5:if(wl(t,e),Dl(e),r&512&&(ll||n===null||el(n,n.return)),e.flags&32){a=e.stateNode;try{Jt(a,``)}catch(t){ad(e,e.return,t)}}r&4&&e.stateNode!=null&&(a=e.memoizedProps,nl(e,a,n===null?a:n.memoizedProps)),r&1024&&(ul=!0);break;case 6:if(wl(t,e),Dl(e),r&4){if(e.stateNode===null)throw Error(i(162));r=e.memoizedProps,n=e.stateNode;try{n.nodeValue=r}catch(t){ad(e,e.return,t)}}break;case 3:if(rp=null,a=Tl,Tl=Nf(t.containerInfo),wl(t,e),Tl=a,Dl(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Xp(t.containerInfo)}catch(t){ad(e,e.return,t)}ul&&(ul=!1,Ol(e));break;case 4:r=Tl,Tl=Nf(e.stateNode.containerInfo),wl(t,e),Dl(e),Tl=r;break;case 12:wl(t,e),Dl(e);break;case 31:wl(t,e),Dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Cl(e,r)));break;case 13:wl(t,e),Dl(e),e.child.flags&8192&&e.memoizedState!==null!=(n!==null&&n.memoizedState!==null)&&(pu=ke()),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Cl(e,r)));break;case 22:a=e.memoizedState!==null;var l=n!==null&&n.memoizedState!==null,u=cl,d=ll;if(cl=u||a,ll=d||l,wl(t,e),ll=d,cl=u,Dl(e),r&8192)a:for(t=e.stateNode,t._visibility=a?t._visibility&-2:t._visibility|1,a&&(n===null||l||cl||ll||Al(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){ad(l,l.return,e)}}}else if(t.tag===6){if(n===null){l=t;try{l.stateNode.nodeValue=a?``:l.memoizedProps}catch(e){ad(l,l.return,e)}}}else if(t.tag===18){if(n===null){l=t;try{var m=l.stateNode;a?_f(m,!0):_f(l.stateNode,!1)}catch(e){ad(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,Cl(e,n))));break;case 19:wl(t,e),Dl(e),r&4&&(r=e.updateQueue,r!==null&&(e.updateQueue=null,Cl(e,r)));break;case 30:break;case 21:break;default:wl(t,e),Dl(e)}}function Dl(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(rl(r)){n=r;break}r=r.return}if(n==null)throw Error(i(160));switch(n.tag){case 27:var a=n.stateNode;ol(e,il(e),a);break;case 5:var o=n.stateNode;n.flags&32&&(Jt(o,``),n.flags&=-33),ol(e,il(e),o);break;case 3:case 4:var s=n.stateNode.containerInfo;al(e,il(e),s);break;default:throw Error(i(161))}}catch(t){ad(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Ol(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Ol(t),t.tag===5&&t.flags&1024&&t.stateNode.reset(),e=e.sibling}}function kl(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)ml(e,t.alternate,t),t=t.sibling}function Al(e){for(e=e.child;e!==null;){var t=e;switch(t.tag){case 0:case 11:case 14:case 15:Xc(4,t,t.return),Al(t);break;case 1:el(t,t.return);var n=t.stateNode;typeof n.componentWillUnmount==`function`&&Qc(t,t.return,n),Al(t);break;case 27:Af(t.stateNode);case 26:case 5:el(t,t.return),Al(t);break;case 22:t.memoizedState===null&&Al(t);break;case 30:Al(t);break;default:Al(t)}e=e.sibling}}function jl(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:jl(i,a,n),Yc(4,a);break;case 1:if(jl(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){ad(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++)eo(c[i],s)}catch(e){ad(r,r.return,e)}}n&&o&64&&Zc(a),$c(a,a.return);break;case 27:sl(a);case 26:case 5:jl(i,a,n),n&&r===null&&o&4&&tl(a),$c(a,a.return);break;case 12:jl(i,a,n);break;case 31:jl(i,a,n),n&&o&4&&bl(i,a);break;case 13:jl(i,a,n),n&&o&4&&xl(i,a);break;case 22:a.memoizedState===null&&jl(i,a,n),$c(a,a.return);break;case 30:break;default:jl(i,a,n)}t=t.sibling}}function Ml(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 Nl(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 Pl(e,t,n,r){if(t.subtreeFlags&10256)for(t=t.child;t!==null;)Fl(e,t,n,r),t=t.sibling}function Fl(e,t,n,r){var i=t.flags;switch(t.tag){case 0:case 11:case 15:Pl(e,t,n,r),i&2048&&Yc(9,t);break;case 1:Pl(e,t,n,r);break;case 3:Pl(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){Pl(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){ad(t,t.return,e)}}else Pl(e,t,n,r);break;case 31:Pl(e,t,n,r);break;case 13:Pl(e,t,n,r);break;case 23:break;case 22:a=t.stateNode,o=t.alternate,t.memoizedState===null?a._visibility&2?Pl(e,t,n,r):(a._visibility|=2,Il(e,t,n,r,!!(t.subtreeFlags&10256)||!1)):a._visibility&2?Pl(e,t,n,r):Ll(e,t),i&2048&&Ml(o,t);break;case 24:Pl(e,t,n,r),i&2048&&Nl(t.alternate,t);break;default:Pl(e,t,n,r)}}function Il(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:Il(a,o,s,c,i),Yc(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Il(a,o,s,c,i)):u._visibility&2?Il(a,o,s,c,i):Ll(a,o),i&&l&2048&&Ml(o.alternate,o);break;case 24:Il(a,o,s,c,i),i&&l&2048&&Nl(o.alternate,o);break;default:Il(a,o,s,c,i)}t=t.sibling}}function Ll(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:Ll(n,r),i&2048&&Ml(r.alternate,r);break;case 24:Ll(n,r),i&2048&&Nl(r.alternate,r);break;default:Ll(n,r)}t=t.sibling}}var Rl=8192;function zl(e,t,n){if(e.subtreeFlags&Rl)for(e=e.child;e!==null;)Bl(e,t,n),e=e.sibling}function Bl(e,t,n){switch(e.tag){case 26:zl(e,t,n),e.flags&Rl&&e.memoizedState!==null&&cp(n,Tl,e.memoizedState,e.memoizedProps);break;case 5:zl(e,t,n);break;case 3:case 4:var r=Tl;Tl=Nf(e.stateNode.containerInfo),zl(e,t,n),Tl=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=Rl,Rl=16777216,zl(e,t,n),Rl=r):zl(e,t,n));break;default:zl(e,t,n)}}function Vl(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 Hl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];fl=r,Gl(r,e)}Vl(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Ul(e),e=e.sibling}function Ul(e){switch(e.tag){case 0:case 11:case 15:Hl(e),e.flags&2048&&Xc(9,e,e.return);break;case 3:Hl(e);break;case 12:Hl(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,Wl(e)):Hl(e);break;default:Hl(e)}}function Wl(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];fl=r,Gl(r,e)}Vl(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:Xc(8,t,t.return),Wl(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,Wl(t));break;default:Wl(t)}e=e.sibling}}function Gl(e,t){for(;fl!==null;){var n=fl;switch(n.tag){case 0:case 11:case 15:Xc(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,fl=r;else a:for(n=e;fl!==null;){r=fl;var i=r.sibling,a=r.return;if(hl(r),r===n){fl=null;break a}if(i!==null){i.return=a,fl=i;break a}fl=a}}}var Kl={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}},ql=typeof WeakMap==`function`?WeakMap:Map,Jl=0,Yl=null,Xl=null,Zl=0,Ql=0,$l=null,eu=!1,tu=!1,nu=!1,ru=0,iu=0,au=0,ou=0,su=0,cu=0,lu=0,uu=null,du=null,fu=!1,pu=0,mu=0,hu=1/0,gu=null,_u=null,vu=0,yu=null,bu=null,xu=0,Su=0,Cu=null,wu=null,Tu=0,Eu=null;function Du(){return Jl&2&&Zl!==0?Zl&-Zl:M.T===null?st():Ed()}function Ou(){if(cu===0){if(!(Zl&536870912)||Ri){var e=Ke;Ke<<=1,!(Ke&3932160)&&(Ke=262144),cu=e}else cu=536870912}return e=so.current,e!==null&&(e.flags|=32),cu}function ku(e,t,n){(e===Yl&&(Ql===2||Ql===9)||e.cancelPendingCommit!==null)&&(Iu(e,0),Nu(e,Zl,cu,!1)),et(e,n),(!(Jl&2)||e!==Yl)&&(e===Yl&&(!(Jl&2)&&(ou|=n),iu===4&&Nu(e,Zl,cu,!1)),vd(e))}function Au(e,t,n){if(Jl&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||Xe(e,t),a=r?Wu(e,t):Hu(e,t,!0),o=r;do{if(a===0){tu&&!r&&Nu(e,t,0,!1);break}if(n=e.current.alternate,o&&!Mu(n)){a=Hu(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=uu;var l=c.current.memoizedState.isDehydrated;if(l&&(Iu(c,s).flags|=256),s=Hu(c,s,!1),s!==2){if(nu&&!l){c.errorRecoveryDisabledLanes|=o,ou|=o,a=4;break a}o=du,du=a,o!==null&&(du===null?du=o:du.push.apply(du,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Iu(e,0),Nu(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:Nu(r,t,cu,!eu);break a;case 2:du=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=pu+300-ke(),10<a)){if(Nu(r,t,cu,!eu),Ye(r,0,!0)!==0)break a;xu=t,r.timeoutHandle=uf(ju.bind(null,r,n,du,gu,fu,t,cu,ou,lu,eu,o,`Throttled`,-0,0),a);break a}ju(r,n,du,gu,fu,t,cu,ou,lu,eu,o,null,-0,0)}break}while(1);vd(e)}function ju(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:nn},Bl(t,a,d);var m=(a&62914560)===a?pu-ke():(a&4194048)===a?mu-ke():0;if(m=up(d,m),m!==null){xu=a,e.cancelPendingCommit=m(Zu.bind(null,e,t,a,n,r,i,o,s,c,u,d,null,f,p)),Nu(e,a,o,!l);return}}Zu(e,t,a,n,r,i,o,s,c)}function Mu(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(!Tr(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 Nu(e,t,n,r){t&=~su,t&=~ou,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ve(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&nt(e,n,t)}function Pu(){return Jl&6?!0:(yd(0,!1),!1)}function Fu(){if(Xl!==null){if(Ql===0)var e=Xl.return;else e=Xl,Zi=Xi=null,Io(e),Ia=null,La=0,e=Xl;for(;e!==null;)Jc(e.alternate,e),e=e.return;Xl=null}}function Iu(e,t){var n=e.timeoutHandle;n!==-1&&(e.timeoutHandle=-1,df(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),xu=0,Fu(),Yl=e,Xl=n=pi(e.current,null),Zl=t,Ql=0,$l=null,eu=!1,tu=Xe(e,t),nu=!1,lu=cu=su=ou=au=iu=0,du=uu=null,fu=!1,t&8&&(t|=t&32);var r=e.entangledLanes;if(r!==0)for(e=e.entanglements,r&=t;0<r;){var i=31-Ve(r),a=1<<i;t|=e[i],r&=~a}return ru=t,ri(),n}function Lu(e,t){vo=null,M.H=Ks,t===Ea||t===Oa?(t=Pa(),Ql=3):t===Da?(t=Pa(),Ql=4):Ql=t===uc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,$l=t,Xl===null&&(iu=1,ic(e,xi(t,e.current)))}function Ru(){var e=so.current;return e===null?!0:(Zl&4194048)===Zl?co===null:(Zl&62914560)===Zl||Zl&536870912?e===co:!1}function zu(){var e=M.H;return M.H=Ks,e===null?Ks:e}function Bu(){var e=M.A;return M.A=Kl,e}function Vu(){iu=4,eu||(Zl&4194048)!==Zl&&so.current!==null||(tu=!0),!(au&134217727)&&!(ou&134217727)||Yl===null||Nu(Yl,Zl,cu,!1)}function Hu(e,t,n){var r=Jl;Jl|=2;var i=zu(),a=Bu();(Yl!==e||Zl!==t)&&(gu=null,Iu(e,t)),t=!1;var o=iu;a:do try{if(Ql!==0&&Xl!==null){var s=Xl,c=$l;switch(Ql){case 8:Fu(),o=6;break a;case 3:case 2:case 9:case 6:so.current===null&&(t=!0);var l=Ql;if(Ql=0,$l=null,Ju(e,s,c,l),n&&tu){o=0;break a}break;default:l=Ql,Ql=0,$l=null,Ju(e,s,c,l)}}Uu(),o=iu;break}catch(t){Lu(e,t)}while(1);return t&&e.shellSuspendCounter++,Zi=Xi=null,Jl=r,M.H=i,M.A=a,Xl===null&&(Yl=null,Zl=0,ri()),o}function Uu(){for(;Xl!==null;)Ku(Xl)}function Wu(e,t){var n=Jl;Jl|=2;var r=zu(),a=Bu();Yl!==e||Zl!==t?(gu=null,hu=ke()+500,Iu(e,t)):tu=Xe(e,t);a:do try{if(Ql!==0&&Xl!==null){t=Xl;var o=$l;b:switch(Ql){case 1:Ql=0,$l=null,Ju(e,t,o,1);break;case 2:case 9:if(Aa(o)){Ql=0,$l=null,qu(t);break}t=function(){Ql!==2&&Ql!==9||Yl!==e||(Ql=7),vd(e)},o.then(t,t);break a;case 3:Ql=7;break a;case 4:Ql=5;break a;case 7:Aa(o)?(Ql=0,$l=null,qu(t)):(Ql=0,$l=null,Ju(e,t,o,7));break;case 5:var s=null;switch(Xl.tag){case 26:s=Xl.memoizedState;case 5:case 27:var c=Xl;if(s?sp(s):c.stateNode.complete){Ql=0,$l=null;var l=c.sibling;if(l!==null)Xl=l;else{var u=c.return;u===null?Xl=null:(Xl=u,Yu(u))}break b}}Ql=0,$l=null,Ju(e,t,o,5);break;case 6:Ql=0,$l=null,Ju(e,t,o,6);break;case 8:Fu(),iu=6;break a;default:throw Error(i(462))}}Gu();break}catch(t){Lu(e,t)}while(1);return Zi=Xi=null,M.H=r,M.A=a,Jl=n,Xl===null?(Yl=null,Zl=0,ri(),iu):0}function Gu(){for(;Xl!==null&&!De();)Ku(Xl)}function Ku(e){var t=zc(e.alternate,e,ru);e.memoizedProps=e.pendingProps,t===null?Yu(e):Xl=t}function qu(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=wc(n,t,t.pendingProps,t.type,void 0,Zl);break;case 11:t=wc(n,t,t.pendingProps,t.type.render,t.ref,Zl);break;case 5:Io(t);default:Jc(n,t),t=Xl=mi(t,ru),t=zc(n,t,ru)}e.memoizedProps=e.pendingProps,t===null?Yu(e):Xl=t}function Ju(e,t,n,r){Zi=Xi=null,Io(t),Ia=null,La=0;var i=t.return;try{if(lc(e,i,t,n,Zl)){iu=1,ic(e,xi(n,e.current)),Xl=null;return}}catch(t){if(i!==null)throw Xl=i,t;iu=1,ic(e,xi(n,e.current)),Xl=null;return}t.flags&32768?(Ri||r===1?e=!0:tu||Zl&536870912?e=!1:(eu=e=!0,(r===2||r===9||r===3||r===6)&&(r=so.current,r!==null&&r.tag===13&&(r.flags|=16384))),Xu(t,e)):Yu(t)}function Yu(e){var t=e;do{if(t.flags&32768){Xu(t,eu);return}e=t.return;var n=Kc(t.alternate,t,ru);if(n!==null){Xl=n;return}if(t=t.sibling,t!==null){Xl=t;return}Xl=t=e}while(t!==null);iu===0&&(iu=5)}function Xu(e,t){do{var n=qc(e.alternate,e);if(n!==null){n.flags&=32767,Xl=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){Xl=e;return}Xl=e=n}while(e!==null);iu=6,Xl=null}function Zu(e,t,n,r,a,o,s,c,l){e.cancelPendingCommit=null;do nd();while(vu!==0);if(Jl&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));if(o=t.lanes|t.childLanes,o|=ni,tt(e,n,o,s,c,l),e===Yl&&(Xl=Yl=null,Zl=0),bu=t,yu=e,xu=n,Su=o,Cu=a,wu=r,t.subtreeFlags&10256||t.flags&10256?(e.callbackNode=null,e.callbackPriority=0,dd(Ne,function(){return rd(),null})):(e.callbackNode=null,e.callbackPriority=0),r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=M.T,M.T=null,a=N.p,N.p=2,s=Jl,Jl|=4;try{pl(e,t,n)}finally{Jl=s,N.p=a,M.T=r}}vu=1,Qu(),$u(),ed()}}function Qu(){if(vu===1){vu=0;var e=yu,t=bu,n=!!(t.flags&13878);if(t.subtreeFlags&13878||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=Jl;Jl|=4;try{El(t,e);var a=nf,o=Ar(e.containerInfo),s=a.focusedElem,c=a.selectionRange;if(o!==s&&s&&s.ownerDocument&&kr(s.ownerDocument.documentElement,s)){if(c!==null&&jr(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 _=Or(s,h),v=Or(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}}wp=!!tf,nf=tf=null}finally{Jl=i,N.p=r,M.T=n}}e.current=t,vu=2}}function $u(){if(vu===2){vu=0;var e=yu,t=bu,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=M.T,M.T=null;var r=N.p;N.p=2;var i=Jl;Jl|=4;try{ml(e,t.alternate,t)}finally{Jl=i,N.p=r,M.T=n}}vu=3}}function ed(){if(vu===4||vu===3){vu=0,Oe();var e=yu,t=bu,n=xu,r=wu;t.subtreeFlags&10256||t.flags&10256?vu=5:(vu=0,bu=yu=null,td(e,e.pendingLanes));var i=e.pendingLanes;if(i===0&&(_u=null),ot(n),t=t.stateNode,ze&&typeof ze.onCommitFiberRoot==`function`)try{ze.onCommitFiberRoot(Re,t,void 0,(t.current.flags&128)==128)}catch{}if(r!==null){t=M.T,i=N.p,N.p=2,M.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{M.T=t,N.p=i}}xu&3&&nd(),vd(e),i=e.pendingLanes,n&261930&&i&42?e===Eu?Tu++:(Tu=0,Eu=e):Tu=0,yd(0,!1)}}function td(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,pa(t)))}function nd(){return Qu(),$u(),ed(),rd()}function rd(){if(vu!==5)return!1;var e=yu,t=Su;Su=0;var n=ot(xu),r=M.T,a=N.p;try{N.p=32>n?32:n,M.T=null,n=Cu,Cu=null;var o=yu,s=xu;if(vu=0,bu=yu=null,xu=0,Jl&6)throw Error(i(331));var c=Jl;if(Jl|=4,Ul(o.current),Fl(o,o.current,s,n),Jl=c,yd(0,!1),ze&&typeof ze.onPostCommitFiberRoot==`function`)try{ze.onPostCommitFiberRoot(Re,o)}catch{}return!0}finally{N.p=a,M.T=r,td(e,t)}}function id(e,t,n){t=xi(n,t),t=oc(e.stateNode,t,2),e=Ja(e,t,2),e!==null&&(et(e,2),vd(e))}function ad(e,t,n){if(e.tag===3)id(e,e,n);else for(;t!==null;){if(t.tag===3){id(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(_u===null||!_u.has(r))){e=xi(n,e),n=sc(2),r=Ja(t,n,2),r!==null&&(cc(n,r,t,e),et(r,2),vd(r));break}}t=t.return}}function od(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new ql;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)||(nu=!0,i.add(n),e=sd.bind(null,e,t,n),t.then(e,e))}function sd(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,Yl===e&&(Zl&n)===n&&(iu===4||iu===3&&(Zl&62914560)===Zl&&300>ke()-pu?!(Jl&2)&&Iu(e,0):su|=n,lu===Zl&&(lu=0)),vd(e)}function cd(e,t){t===0&&(t=Qe()),e=oi(e,t),e!==null&&(et(e,t),vd(e))}function ld(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),cd(e,n)}function ud(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),cd(e,n)}function dd(e,t){return Te(e,t)}var fd=null,pd=null,md=!1,hd=!1,gd=!1,_d=0;function vd(e){e!==pd&&e.next===null&&(pd===null?fd=pd=e:pd=pd.next=e),hd=!0,md||(md=!0,Td())}function yd(e,t){if(!gd&&hd){gd=!0;do for(var n=!1,r=fd;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-Ve(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,wd(r,a))}else a=Zl,a=Ye(r,r===Yl?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Xe(r,a)||(n=!0,wd(r,a))}r=r.next}while(n);gd=!1}}function bd(){xd()}function xd(){hd=md=!1;var e=0;_d!==0&&lf()&&(e=_d);for(var t=ke(),n=null,r=fd;r!==null;){var i=r.next,a=Sd(r,t);a===0?(r.next=null,n===null?fd=i:n.next=i,i===null&&(pd=n)):(n=r,(e!==0||a&3)&&(hd=!0)),r=i}vu!==0&&vu!==5||yd(e,!1),_d!==0&&(_d=0)}function Sd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ve(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=Ze(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=Yl,n=Zl,n=Ye(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(Ql===2||Ql===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Ee(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||Xe(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Ee(r),ot(n)){case 2:case 8:n=Me;break;case 32:n=Ne;break;case 268435456:n=Fe;break;default:n=Ne}return r=Cd.bind(null,e),n=Te(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Ee(r),e.callbackPriority=2,e.callbackNode=null,2}function Cd(e,t){if(vu!==0&&vu!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(nd()&&e.callbackNode!==n)return null;var r=Zl;return r=Ye(e,e===Yl?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Au(e,r,t),Sd(e,ke()),e.callbackNode!=null&&e.callbackNode===n?Cd.bind(null,e):null)}function wd(e,t){if(nd())return null;Au(e,t,!0)}function Td(){pf(function(){Jl&6?Te(je,bd):xd()})}function Ed(){if(_d===0){var e=ga;e===0&&(e=Ge,Ge<<=1,!(Ge&261888)&&(Ge=256)),_d=e}return _d}function Dd(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:tn(``+e)}function Od(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 kd(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Dd((i[ut]||null).action),o=r.submitter;o&&(t=(t=o[ut]||null)?Dd(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new wn(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(_d!==0){var e=o?Od(i,o):new FormData(i);Ms(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=o?Od(i,o):new FormData(i),Ms(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Ad=0;Ad<Zr.length;Ad++){var jd=Zr[Ad];Qr(jd.toLowerCase(),`on`+(jd[0].toUpperCase()+jd.slice(1)))}Qr(Ur,`onAnimationEnd`),Qr(Wr,`onAnimationIteration`),Qr(Gr,`onAnimationStart`),Qr(`dblclick`,`onDoubleClick`),Qr(`focusin`,`onFocus`),Qr(`focusout`,`onBlur`),Qr(Kr,`onTransitionRun`),Qr(qr,`onTransitionStart`),Qr(Jr,`onTransitionCancel`),Qr(Yr,`onTransitionEnd`),Et(`onMouseEnter`,[`mouseout`,`mouseover`]),Et(`onMouseLeave`,[`mouseout`,`mouseover`]),Et(`onPointerEnter`,[`pointerout`,`pointerover`]),Et(`onPointerLeave`,[`pointerout`,`pointerover`]),Tt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Tt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Tt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Tt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Tt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Md=`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(` `),Nd=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Md));function Pd(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){$r(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){$r(e)}i.currentTarget=null,a=c}}}}function Fd(e,t){var n=t[ft];n===void 0&&(n=t[ft]=new Set);var r=e+`__bubble`;n.has(r)||(zd(t,e,2,!1),n.add(r))}function Id(e,t,n){var r=0;t&&(r|=4),zd(n,e,r,t)}var Ld=`_reactListening`+Math.random().toString(36).slice(2);function Rd(e){if(!e[Ld]){e[Ld]=!0,Ct.forEach(function(t){t!==`selectionchange`&&(Nd.has(t)||Id(t,!1,e),Id(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Ld]||(t[Ld]=!0,Id(`selectionchange`,!1,t))}}function zd(e,t,n,r){switch(jp(t)){case 2:var i=Tp;break;case 8:i=Ep;break;default:i=Dp}n=i.bind(null,t,n,e),i=void 0,!pn||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 Bd(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=vt(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}un(function(){var r=a,i=an(n),s=[];a:{var c=Xr.get(e);if(c!==void 0){var l=wn,u=e;switch(e){case`keypress`:if(yn(n)===0)break a;case`keydown`:case`keyup`:l=Hn;break;case`focusin`:u=`focus`,l=Nn;break;case`focusout`:u=`blur`,l=Nn;break;case`beforeblur`:case`afterblur`:l=Nn;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=jn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Mn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=Wn;break;case Ur:case Wr:case Gr:l=Pn;break;case Yr:l=Gn;break;case`scroll`:case`scrollend`:l=En;break;case`wheel`:l=Kn;break;case`copy`:case`cut`:case`paste`:l=Fn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=Un;break;case`toggle`:case`beforetoggle`:l=qn}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=dn(m,p),g!=null&&d.push(Vd(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!==rn&&(u=n.relatedTarget||n.fromElement)&&(vt(u)||u[dt]))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?vt(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=jn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=Un,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=l==null?c:bt(l),h=u==null?c:bt(u),c=new d(g,m+`leave`,l,n,i),c.target=f,c.relatedTarget=h,g=null,vt(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=Ud,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&&Wd(s,c,l,d,!1),u!==null&&f!==null&&Wd(s,f,u,d,!0)}}a:{if(c=r?bt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var v=pr;else if(sr(c)){if(mr)v=Cr;else{v=xr;var y=br}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&Qt(r.elementType)&&(v=pr):v=Sr;if(v&&=v(e,r)){cr(s,v,n,i);break a}y&&y(e,c,r),e===`focusout`&&r&&c.type===`number`&&r.memoizedProps.value!=null&&Wt(c,`number`,c.value)}switch(y=r?bt(r):window,e){case`focusin`:(sr(y)||y.contentEditable===`true`)&&(Nr=y,Pr=r,Fr=null);break;case`focusout`:Fr=Pr=Nr=null;break;case`mousedown`:Ir=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Ir=!1,Lr(s,n,i);break;case`selectionchange`:if(Mr)break;case`keydown`:case`keyup`:Lr(s,n,i)}var b;if(Yn)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 rr?tr(e,n)&&(x=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(x=`onCompositionStart`);x&&(Qn&&n.locale!==`ko`&&(rr||x!==`onCompositionStart`?x===`onCompositionEnd`&&rr&&(b=vn()):(hn=i,gn=`value`in hn?hn.value:hn.textContent,rr=!0)),y=Hd(r,x),0<y.length&&(x=new In(x,e,null,n,i),s.push({event:x,listeners:y}),b?x.data=b:(b=nr(n),b!==null&&(x.data=b)))),(b=Zn?ir(e,n):ar(e,n))&&(x=Hd(r,`onBeforeInput`),0<x.length&&(y=new In(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:y,listeners:x}),y.data=b)),kd(s,e,r,n,i)}Pd(s,t)})}function Vd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Hd(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=dn(e,n),i!=null&&r.unshift(Vd(e,i,a)),i=dn(e,t),i!=null&&r.push(Vd(e,i,a))),e.tag===3)return r;e=e.return}return[]}function Ud(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function Wd(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=dn(n,a),l!=null&&o.unshift(Vd(n,l,c))):i||(l=dn(n,a),l!=null&&o.push(Vd(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var Gd=/\r\n?/g,Kd=/\u0000|\uFFFD/g;function qd(e){return(typeof e==`string`?e:``+e).replace(Gd,`
|
|
9
|
-
`).replace(Kd,``)}function Jd(e,t){return t=qd(t),qd(e)===t}function Yd(e,t,n,r,a,o){switch(n){case`children`:typeof r==`string`?t===`body`||t===`textarea`&&r===``||Jt(e,r):(typeof r==`number`||typeof r==`bigint`)&&t!==`body`&&Jt(e,``+r);break;case`className`:Mt(e,`class`,r);break;case`tabIndex`:Mt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Mt(e,n,r);break;case`style`:Zt(e,r,o);break;case`data`:if(t!==`object`){Mt(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=tn(``+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`&&Yd(e,t,`name`,a.name,a,null),Yd(e,t,`formEncType`,a.formEncType,a,null),Yd(e,t,`formMethod`,a.formMethod,a,null),Yd(e,t,`formTarget`,a.formTarget,a,null)):(Yd(e,t,`encType`,a.encType,a,null),Yd(e,t,`method`,a.method,a,null),Yd(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=tn(``+r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=nn);break;case`onScroll`:r!=null&&Fd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Fd(`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=tn(``+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`:Fd(`beforetoggle`,e),Fd(`toggle`,e),jt(e,`popover`,r);break;case`xlinkActuate`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:Nt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:Nt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:jt(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=$t.get(n)||n,jt(e,n,r))}}function Xd(e,t,n,r,a,o){switch(n){case`style`:Zt(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`?Jt(e,r):(typeof r==`number`||typeof r==`bigint`)&&Jt(e,``+r);break;case`onScroll`:r!=null&&Fd(`scroll`,e);break;case`onScrollEnd`:r!=null&&Fd(`scrollend`,e);break;case`onClick`:r!=null&&(e.onclick=nn);break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:break;case`innerText`:case`textContent`:break;default:if(!wt.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[ut]||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,``):jt(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`:Fd(`error`,e),Fd(`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:Yd(e,t,o,s,n,null)}}a&&Yd(e,t,`srcSet`,n.srcSet,n,null),r&&Yd(e,t,`src`,n.src,n,null);return;case`input`:Fd(`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:Yd(e,t,r,d,n,null)}}Ut(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Fd(`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:Yd(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&Gt(e,!!r,n,!0):Gt(e,!!r,t,!1);return;case`textarea`:for(s in Fd(`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:Yd(e,t,s,c,n,null)}qt(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:Yd(e,t,l,r,n,null)}return;case`dialog`:Fd(`beforetoggle`,e),Fd(`toggle`,e),Fd(`cancel`,e),Fd(`close`,e);break;case`iframe`:case`object`:Fd(`load`,e);break;case`video`:case`audio`:for(r=0;r<Md.length;r++)Fd(Md[r],e);break;case`image`:Fd(`error`,e),Fd(`load`,e);break;case`details`:Fd(`toggle`,e);break;case`embed`:case`source`:case`link`:Fd(`error`,e),Fd(`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:Yd(e,t,u,r,n,null)}return;default:if(Qt(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&Xd(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&Yd(e,t,c,r,n,null))}function Qd(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)||Yd(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&&Yd(e,t,p,m,r,f)}}Ht(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)||Yd(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&&Yd(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?Gt(e,!!n,n?[]:``,!1):Gt(e,!!n,t,!0)):Gt(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:Yd(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&&Yd(e,t,s,a,r,o)}Kt(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:Yd(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:Yd(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)&&Yd(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:Yd(e,t,u,p,r,m)}return;default:if(Qt(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&Xd(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||Xd(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&Yd(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||Yd(e,t,f,p,r,m)}function $d(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function ef(){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&&$d(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&&$d(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 tf=null,nf=null;function rf(e){return e.nodeType===9?e:e.ownerDocument}function af(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 of(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 sf(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 cf=null;function lf(){var e=window.event;return e&&e.type===`popstate`?e!==cf&&(cf=e,!0):(cf=null,!1)}var uf=typeof setTimeout==`function`?setTimeout:void 0,df=typeof clearTimeout==`function`?clearTimeout:void 0,ff=typeof Promise==`function`?Promise:void 0,pf=typeof queueMicrotask==`function`?queueMicrotask:ff===void 0?uf:function(e){return ff.resolve(null).then(e).catch(mf)};function mf(e){setTimeout(function(){throw e})}function hf(e){return e===`head`}function gf(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),Xp(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Af(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Af(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[gt]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Af(e.ownerDocument.body)}n=i}while(n);Xp(t)}function _f(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 vf(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`:vf(n),_t(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function yf(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[gt])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=Tf(e.nextSibling),e===null)break}return null}function bf(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=Tf(e.nextSibling),e===null))return null;return e}function xf(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=Tf(e.nextSibling),e===null))return null;return e}function Sf(e){return e.data===`$?`||e.data===`$~`}function Cf(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function wf(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 Tf(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 Ef=null;function Df(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return Tf(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Of(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 kf(e,t,n){switch(t=rf(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 Af(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);_t(e)}var jf=new Map,Mf=new Set;function Nf(e){return typeof e.getRootNode==`function`?e.getRootNode():e.nodeType===9?e:e.ownerDocument}var Pf=N.d;N.d={f:Ff,r:If,D:zf,C:Bf,L:Vf,m:Hf,X:Wf,S:Uf,M:Gf};function Ff(){var e=Pf.f(),t=Pu();return e||t}function If(e){var t=yt(e);t!==null&&t.tag===5&&t.type===`form`?Ps(t):Pf.r(e)}var Lf=typeof document>`u`?null:document;function Rf(e,t,n){var r=Lf;if(r&&typeof t==`string`&&t){var i=Vt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Mf.has(i)||(Mf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Zd(t,`link`,e),St(t),r.head.appendChild(t)))}}function zf(e){Pf.D(e),Rf(`dns-prefetch`,e,null)}function Bf(e,t){Pf.C(e,t),Rf(`preconnect`,e,t)}function Vf(e,t,n){Pf.L(e,t,n);var r=Lf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Vt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Vt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Vt(n.imageSizes)+`"]`)):i+=`[href="`+Vt(e)+`"]`;var a=i;switch(t){case`style`:a=qf(e);break;case`script`:a=Zf(e)}jf.has(a)||(e=h({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),jf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Jf(a))||t===`script`&&r.querySelector(Qf(a))||(t=r.createElement(`link`),Zd(t,`link`,e),St(t),r.head.appendChild(t)))}}function Hf(e,t){Pf.m(e,t);var n=Lf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Vt(r)+`"][href="`+Vt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Zf(e)}if(!jf.has(a)&&(e=h({rel:`modulepreload`,href:e},t),jf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Qf(a)))return}r=n.createElement(`link`),Zd(r,`link`,e),St(r),n.head.appendChild(r)}}}function Uf(e,t,n){Pf.S(e,t,n);var r=Lf;if(r&&e){var i=xt(r).hoistableStyles,a=qf(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Jf(a)))s.loading=5;else{e=h({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=jf.get(a))&&tp(e,n);var c=o=r.createElement(`link`);St(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,ep(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Wf(e,t){Pf.X(e,t);var n=Lf;if(n&&e){var r=xt(n).hoistableScripts,i=Zf(e),a=r.get(i);a||(a=n.querySelector(Qf(i)),a||(e=h({src:e,async:!0},t),(t=jf.get(i))&&np(e,t),a=n.createElement(`script`),St(a),Zd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Gf(e,t){Pf.M(e,t);var n=Lf;if(n&&e){var r=xt(n).hoistableScripts,i=Zf(e),a=r.get(i);a||(a=n.querySelector(Qf(i)),a||(e=h({src:e,async:!0,type:`module`},t),(t=jf.get(i))&&np(e,t),a=n.createElement(`script`),St(a),Zd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Kf(e,t,n,r){var a=(a=de.current)?Nf(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=qf(n.href),n=xt(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=qf(n.href);var o=xt(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(Jf(e)))&&!o._p&&(s.instance=o,s.state.loading=5),jf.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},jf.set(e,n),o||Xf(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=Zf(n),n=xt(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 qf(e){return`href="`+Vt(e)+`"`}function Jf(e){return`link[rel="stylesheet"][`+e+`]`}function Yf(e){return h({},e,{"data-precedence":e.precedence,precedence:null})}function Xf(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),St(t),e.head.appendChild(t))}function Zf(e){return`[src="`+Vt(e)+`"]`}function Qf(e){return`script[async]`+e}function $f(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Vt(n.href)+`"]`);if(r)return t.instance=r,St(r),r;var a=h({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),St(r),Zd(r,`style`,a),ep(r,n.precedence,e),t.instance=r;case`stylesheet`:a=qf(n.href);var o=e.querySelector(Jf(a));if(o)return t.state.loading|=4,t.instance=o,St(o),o;r=Yf(n),(a=jf.get(a))&&tp(r,a),o=(e.ownerDocument||e).createElement(`link`),St(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,ep(o,n.precedence,e),t.instance=o;case`script`:return o=Zf(n.src),(a=e.querySelector(Qf(o)))?(t.instance=a,St(a),a):(r=n,(a=jf.get(o))&&(r=h({},n),np(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),St(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,ep(r,n.precedence,e));return t.instance}function ep(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 tp(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function np(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var rp=null;function ip(e,t,n){if(rp===null){var r=new Map,i=rp=new Map;i.set(n,r)}else i=rp,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[gt]||a[lt]||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 ap(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function op(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 sp(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function cp(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=qf(r.href),a=t.querySelector(Jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=dp.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,St(a);return}a=t.ownerDocument||t,r=Yf(r),(i=jf.get(i))&&tp(r,i),a=a.createElement(`link`),St(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=dp.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var lp=0;function up(e,t){return e.stylesheets&&e.count===0&&pp(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&pp(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&lp===0&&(lp=62500*ef());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&pp(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>lp?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function dp(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)pp(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fp=null;function pp(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fp=new Map,t.forEach(mp,e),fp=null,dp.call(e))}function mp(e,t){if(!(t.state.loading&4)){var n=fp.get(e);if(n)var r=n.get(null);else{n=new Map,fp.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=dp.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 hp={$$typeof:C,Provider:null,Consumer:null,_currentValue:ie,_currentValue2:ie,_threadCount:0};function gp(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=$e(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$e(0),this.hiddenUpdates=$e(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 _p(e,t,n,r,i,a,o,s,c,l,u,d){return e=new gp(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=di(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},Ga(a),e}function vp(e){return e?(e=li,e):li}function yp(e,t,n,r,i,a){i=vp(i),r.context===null?r.context=i:r.pendingContext=i,r=qa(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=Ja(e,r,t),n!==null&&(ku(n,e,t),Ya(n,e,t))}function bp(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function xp(e,t){bp(e,t),(e=e.alternate)&&bp(e,t)}function Sp(e){if(e.tag===13||e.tag===31){var t=oi(e,67108864);t!==null&&ku(t,e,67108864),xp(e,67108864)}}function Cp(e){if(e.tag===13||e.tag===31){var t=Du();t=at(t);var n=oi(e,t);n!==null&&ku(n,e,t),xp(e,t)}}var wp=!0;function Tp(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=2,Dp(e,t,n,r)}finally{N.p=a,M.T=i}}function Ep(e,t,n,r){var i=M.T;M.T=null;var a=N.p;try{N.p=8,Dp(e,t,n,r)}finally{N.p=a,M.T=i}}function Dp(e,t,n,r){if(wp){var i=Op(r);if(i===null)Bd(e,t,r,kp,n),Bp(e,r);else if(Hp(i,e,t,n,r))r.stopPropagation();else if(Bp(e,r),t&4&&-1<zp.indexOf(e)){for(;i!==null;){var a=yt(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=Je(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ve(o);s.entanglements[1]|=c,o&=~c}vd(a),!(Jl&6)&&(hu=ke()+500,yd(0,!1))}}break;case 31:case 13:s=oi(a,2),s!==null&&ku(s,a,2),Pu(),xp(a,2)}if(a=Op(r),a===null&&Bd(e,t,r,kp,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else Bd(e,t,r,null,n)}}function Op(e){return e=an(e),Ap(e)}var kp=null;function Ap(e){if(kp=null,e=vt(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 kp=e,null}function jp(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(Ae()){case je:return 2;case Me:return 8;case Ne:case Pe:return 32;case Fe:return 268435456;default:return 32}default:return 32}}var Mp=!1,Np=null,Pp=null,Fp=null,Ip=new Map,Lp=new Map,Rp=[],zp=`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 Bp(e,t){switch(e){case`focusin`:case`focusout`:Np=null;break;case`dragenter`:case`dragleave`:Pp=null;break;case`mouseover`:case`mouseout`:Fp=null;break;case`pointerover`:case`pointerout`:Ip.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:Lp.delete(t.pointerId)}}function Vp(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=yt(t),t!==null&&Sp(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Hp(e,t,n,r,i){switch(t){case`focusin`:return Np=Vp(Np,e,t,n,r,i),!0;case`dragenter`:return Pp=Vp(Pp,e,t,n,r,i),!0;case`mouseover`:return Fp=Vp(Fp,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Ip.set(a,Vp(Ip.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,Lp.set(a,Vp(Lp.get(a)||null,e,t,n,r,i)),!0}return!1}function Up(e){var t=vt(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,ct(e.priority,function(){Cp(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,ct(e.priority,function(){Cp(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 Wp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Op(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);rn=r,n.target.dispatchEvent(r),rn=null}else return t=yt(n),t!==null&&Sp(t),e.blockedOn=n,!1;t.shift()}return!0}function Gp(e,t,n){Wp(e)&&n.delete(t)}function Kp(){Mp=!1,Np!==null&&Wp(Np)&&(Np=null),Pp!==null&&Wp(Pp)&&(Pp=null),Fp!==null&&Wp(Fp)&&(Fp=null),Ip.forEach(Gp),Lp.forEach(Gp)}function qp(e,n){e.blockedOn===n&&(e.blockedOn=null,Mp||(Mp=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Kp)))}var Jp=null;function Yp(e){Jp!==e&&(Jp=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Jp===e&&(Jp=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(Ap(r||n)===null)continue;break}var a=yt(n);a!==null&&(e.splice(t,3),t-=3,Ms(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Xp(e){function t(t){return qp(t,e)}Np!==null&&qp(Np,e),Pp!==null&&qp(Pp,e),Fp!==null&&qp(Fp,e),Ip.forEach(t),Lp.forEach(t);for(var n=0;n<Rp.length;n++){var r=Rp[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Rp.length&&(n=Rp[0],n.blockedOn===null);)Up(n),n.blockedOn===null&&Rp.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[ut]||null;if(typeof a==`function`)o||Yp(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[ut]||null)s=o.formAction;else if(Ap(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Yp(n)}}}function Zp(){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 Qp(e){this._internalRoot=e}$p.prototype.render=Qp.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;yp(n,Du(),e,t,null,null)},$p.prototype.unmount=Qp.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;yp(e.current,2,null,e,null,null),Pu(),t[dt]=null}};function $p(e){this._internalRoot=e}$p.prototype.unstable_scheduleHydration=function(e){if(e){var t=st();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Rp.length&&t!==0&&t<Rp[n].priority;n++);Rp.splice(n,0,e),n===0&&Up(e)}};var em=n.version;if(em!==`19.2.8`)throw Error(i(527,em,`19.2.8`));N.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=d(t),e=e===null?null:p(e),e=e===null?null:e.stateNode,e};var tm={bundleType:0,version:`19.2.8`,rendererPackageName:`react-dom`,currentDispatcherRef:M,reconcilerVersion:`19.2.8`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var nm=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!nm.isDisabled&&nm.supportsFiber)try{Re=nm.inject(tm),ze=nm}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=tc,s=nc,c=rc;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=_p(e,1,!1,null,null,n,r,null,o,s,c,Zp),e[dt]=t.current,Rd(e),new Qp(t)}})),g=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=h()})),_=c(u(),1),v=g(),y=!1;function b(){return y}var x=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})),S=o(((e,t)=>{t.exports=x()})),C=(0,_.createContext)({});function w(e){let t=(0,_.useRef)(null);return t.current===null&&(t.current=e()),t.current}var T=typeof window<`u`?_.useLayoutEffect:_.useEffect,E=(0,_.createContext)(null);function D(e,t){e.indexOf(t)===-1&&e.push(t)}function O(e,t){let n=e.indexOf(t);n>-1&&e.splice(n,1)}var k=(e,t,n)=>n>t?t:n<e?e:n,A={},j=e=>/^-?(?:\d+(?:\.\d+)?|\.\d+)$/u.test(e),ee=e=>typeof e==`object`&&!!e,te=e=>/^0[^.\s]+$/u.test(e);function ne(e){let t;return()=>(t===void 0&&(t=e()),t)}var re=e=>e,M=(...e)=>e.reduce((e,t)=>n=>t(e(n))),N=(e,t,n)=>{let r=t-e;return r?(n-e)/r:1},ie=class{constructor(){this.subscriptions=[]}add(e){return D(this.subscriptions,e),()=>O(this.subscriptions,e)}notify(e,t,n){let r=this.subscriptions.length;if(r){if(r===1)this.subscriptions[0](e,t,n);else for(let i=0;i<r;i++){let r=this.subscriptions[i];r&&r(e,t,n)}}}getSize(){return this.subscriptions.length}clear(){this.subscriptions.length=0}},ae=e=>e*1e3,oe=e=>e/1e3,se=(e,t)=>t?1e3/t*e:0,P=(e,t,n)=>(((1-3*n+3*t)*e+(3*n-6*t))*e+3*t)*e,ce=1e-7,le=12;function ue(e,t,n,r,i){let a,o,s=0;do o=t+(n-t)/2,a=P(o,r,i)-e,a>0?n=o:t=o;while(Math.abs(a)>ce&&++s<le);return o}function de(e,t,n,r){if(e===t&&n===r)return re;let i=t=>ue(t,0,1,e,n);return e=>e===0||e===1?e:P(i(e),t,r)}var fe=e=>t=>t<=.5?e(2*t)/2:(2-e(2*(1-t)))/2,pe=e=>t=>1-e(1-t),me=de(.33,1.53,.69,.99),he=pe(me),ge=fe(he),_e=e=>e>=1?1:(e*=2)<1?.5*he(e):.5*(2-2**(-10*(e-1))),ve=e=>1-Math.sin(Math.acos(e)),ye=pe(ve),be=fe(ve),xe=de(.42,0,1,1),Se=de(0,0,.58,1),Ce=de(.42,0,.58,1),we=e=>Array.isArray(e)&&typeof e[0]!=`number`,Te=e=>Array.isArray(e)&&typeof e[0]==`number`,Ee={linear:re,easeIn:xe,easeInOut:Ce,easeOut:Se,circIn:ve,circInOut:be,circOut:ye,backIn:he,backInOut:ge,backOut:me,anticipate:_e},De=e=>typeof e==`string`,Oe=e=>{if(Te(e)){e.length;let[t,n,r,i]=e;return de(t,n,r,i)}return De(e)?(Ee[e],`${e}`,Ee[e]):e},ke=[`setup`,`read`,`resolveKeyframes`,`preUpdate`,`update`,`preRender`,`render`,`postRender`];function Ae(e){let t=new Set,n=new Set,r=!1,i=!1,a=new WeakSet,o={delta:0,timestamp:0,isProcessing:!1};function s(t){a.has(t)&&(c.schedule(t),e()),t(o)}let c={schedule:(e,i=!1,o=!1)=>{let s=o&&r?t:n;return i&&a.add(e),s.add(e),e},cancel:e=>{n.delete(e),a.delete(e)},process:e=>{if(o=e,r){i=!0;return}r=!0;let a=t;t=n,n=a,t.forEach(s),t.clear(),r=!1,i&&(i=!1,c.process(e))}};return c}var je=40;function Me(e,t){let n=!1,r=!0,i={delta:0,timestamp:0,isProcessing:!1},a=()=>n=!0,o=ke.reduce((e,t)=>(e[t]=Ae(a),e),{}),{setup:s,read:c,resolveKeyframes:l,preUpdate:u,update:d,preRender:f,render:p,postRender:m}=o,h=()=>{let a=A.useManualTiming,o=a?i.timestamp:performance.now();n=!1,a||(i.delta=r?1e3/60:Math.max(Math.min(o-i.timestamp,je),1)),i.timestamp=o,i.isProcessing=!0,s.process(i),c.process(i),l.process(i),u.process(i),d.process(i),f.process(i),p.process(i),m.process(i),i.isProcessing=!1,n&&t&&(r=!1,e(h))},g=()=>{n=!0,r=!0,i.isProcessing||e(h)};return{schedule:ke.reduce((e,t)=>{let r=o[t];return e[t]=(e,t=!1,i=!1)=>(n||g(),r.schedule(e,t,i)),e},{}),cancel:e=>{for(let t=0;t<ke.length;t++)o[ke[t]].cancel(e)},state:i,steps:o}}var{schedule:Ne,cancel:Pe,state:Fe,steps:Ie}=Me(typeof requestAnimationFrame<`u`?requestAnimationFrame:re,!0),Le;function Re(){Le=void 0}var ze={now:()=>(Le===void 0&&ze.set(Fe.isProcessing||A.useManualTiming?Fe.timestamp:performance.now()),Le),set:e=>{Le=e,queueMicrotask(Re)}},Be=e=>t=>typeof t==`string`&&t.startsWith(e),Ve=Be(`--`),He=Be(`var(--`),Ue=e=>He(e)?We.test(e.split(`/*`)[0].trim()):!1,We=/var\(--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)$/iu;function Ge(e){return typeof e==`string`&&e.split(`/*`)[0].includes(`var(--`)}var Ke={test:e=>typeof e==`number`,parse:parseFloat,transform:e=>e},qe={...Ke,transform:e=>k(0,1,e)},Je={...Ke,default:1},Ye=e=>Math.round(e*1e5)/1e5,Xe=/-?(?:\d+(?:\.\d+)?|\.\d+)/gu;function Ze(e){return e==null}var Qe=/^(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))$/iu,$e=(e,t)=>n=>!!(typeof n==`string`&&Qe.test(n)&&n.startsWith(e)||t&&!Ze(n)&&Object.prototype.hasOwnProperty.call(n,t)),et=(e,t,n)=>r=>{if(typeof r!=`string`)return r;let[i,a,o,s]=r.match(Xe);return{[e]:parseFloat(i),[t]:parseFloat(a),[n]:parseFloat(o),alpha:s===void 0?1:parseFloat(s)}},tt=e=>k(0,255,e),nt={...Ke,transform:e=>Math.round(tt(e))},rt={test:$e(`rgb`,`red`),parse:et(`red`,`green`,`blue`),transform:({red:e,green:t,blue:n,alpha:r=1})=>`rgba(`+nt.transform(e)+`, `+nt.transform(t)+`, `+nt.transform(n)+`, `+Ye(qe.transform(r))+`)`};function it(e){let t=``,n=``,r=``,i=``;return e.length>5?(t=e.substring(1,3),n=e.substring(3,5),r=e.substring(5,7),i=e.substring(7,9)):(t=e.substring(1,2),n=e.substring(2,3),r=e.substring(3,4),i=e.substring(4,5),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}var at={test:$e(`#`),parse:it,transform:rt.transform},ot=e=>({test:t=>typeof t==`string`&&t.endsWith(e)&&t.split(` `).length===1,parse:parseFloat,transform:t=>`${t}${e}`}),st=ot(`deg`),ct=ot(`%`),F=ot(`px`),lt=ot(`vh`),ut=ot(`vw`),dt={...ct,parse:e=>ct.parse(e)/100,transform:e=>ct.transform(e*100)},ft={test:$e(`hsl`,`hue`),parse:et(`hue`,`saturation`,`lightness`),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>`hsla(`+Math.round(e)+`, `+ct.transform(Ye(t))+`, `+ct.transform(Ye(n))+`, `+Ye(qe.transform(r))+`)`},pt={test:e=>rt.test(e)||at.test(e)||ft.test(e),parse:e=>rt.test(e)?rt.parse(e):ft.test(e)?ft.parse(e):at.parse(e),transform:e=>typeof e==`string`?e:e.hasOwnProperty(`red`)?rt.transform(e):ft.transform(e),getAnimatableNone:e=>{let t=pt.parse(e);return t.alpha=0,pt.transform(t)}},mt=/(?:#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\))/giu;function ht(e){return isNaN(e)&&typeof e==`string`&&(e.match(Xe)?.length||0)+(e.match(mt)?.length||0)>0}var gt=`number`,_t=`color`,vt=`var`,yt=`var(`,bt="${}",xt=/var\s*\(\s*--(?:[\w-]+\s*|[\w-]+\s*,(?:\s*[^)(\s]|\s*\((?:[^)(]|\([^)(]*\))*\))+\s*)\)|#[\da-f]{3,8}|(?:rgb|hsl)a?\((?:-?[\d.]+%?[,\s]+){2}-?[\d.]+%?\s*(?:[,/]\s*)?(?:\b\d+(?:\.\d+)?|\.\d+)?%?\)|-?(?:\d+(?:\.\d+)?|\.\d+)/giu;function St(e){let t=e.toString(),n=[],r={color:[],number:[],var:[]},i=[],a=0;return{values:n,split:t.replace(xt,e=>(pt.test(e)?(r.color.push(a),i.push(_t),n.push(pt.parse(e))):e.startsWith(yt)?(r.var.push(a),i.push(vt),n.push(e)):(r.number.push(a),i.push(gt),n.push(parseFloat(e))),++a,bt)).split(bt),indexes:r,types:i}}function Ct(e){return St(e).values}function wt({split:e,types:t}){let n=e.length;return r=>{let i=``;for(let a=0;a<n;a++)if(i+=e[a],r[a]!==void 0){let e=t[a];i+=e===gt?Ye(r[a]):e===_t?pt.transform(r[a]):r[a]}return i}}function Tt(e){return wt(St(e))}var Et=e=>typeof e==`number`?0:pt.test(e)?pt.getAnimatableNone(e):e,Dt=(e,t)=>typeof e==`number`?t?.trim().endsWith(`/`)?e:0:Et(e);function Ot(e){let t=St(e);return wt(t)(t.values.map((e,n)=>Dt(e,t.split[n])))}var kt={test:ht,parse:Ct,createTransformer:Tt,getAnimatableNone:Ot};function At(e,t,n){return n<0&&(n+=1),n>1&&--n,n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function jt({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,a=0,o=0;if(!t)i=a=o=n;else{let r=n<.5?n*(1+t):n+t-n*t,s=2*n-r;i=At(s,r,e+1/3),a=At(s,r,e),o=At(s,r,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:r}}function Mt(e,t){return n=>n>0?t:e}var Nt=(e,t,n)=>e+(t-e)*n,Pt=(e,t,n)=>{let r=e*e,i=n*(t*t-r)+r;return i<0?0:Math.sqrt(i)},Ft=[at,rt,ft],It=e=>Ft.find(t=>t.test(e));function Lt(e){let t=It(e);if(`${e}`,!t)return!1;let n=t.parse(e);return t===ft&&(n=jt(n)),n}var Rt=(e,t)=>{let n=Lt(e),r=Lt(t);if(!n||!r)return Mt(e,t);let i={...n};return e=>(i.red=Pt(n.red,r.red,e),i.green=Pt(n.green,r.green,e),i.blue=Pt(n.blue,r.blue,e),i.alpha=Nt(n.alpha,r.alpha,e),rt.transform(i))},zt=new Set([`none`,`hidden`]);function Bt(e,t){return zt.has(e)?n=>n<=0?e:t:n=>n>=1?t:e}function Vt(e,t){return n=>Nt(e,t,n)}function Ht(e){return typeof e==`number`?Vt:typeof e==`string`?Ue(e)?Mt:pt.test(e)?Rt:Kt:Array.isArray(e)?Ut:typeof e==`object`?pt.test(e)?Rt:Wt:Mt}function Ut(e,t){let n=[...e],r=n.length,i=e.map((e,n)=>Ht(e)(e,t[n]));return e=>{for(let t=0;t<r;t++)n[t]=i[t](e);return n}}function Wt(e,t){let n={...e,...t},r={};for(let i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Ht(e[i])(e[i],t[i]));return e=>{for(let t in r)n[t]=r[t](e);return n}}function Gt(e,t){let n=[],r={color:0,var:0,number:0};for(let i=0;i<t.values.length;i++){let a=t.types[i],o=e.indexes[a][r[a]],s=e.values[o]??0;n[i]=s,r[a]++}return n}var Kt=(e,t)=>{let n=kt.createTransformer(t),r=St(e),i=St(t);return r.indexes.var.length===i.indexes.var.length&&r.indexes.color.length===i.indexes.color.length&&r.indexes.number.length>=i.indexes.number.length?zt.has(e)&&!i.values.length||zt.has(t)&&!r.values.length?Bt(e,t):M(Ut(Gt(r,i),i.values),n):(`${e}${t}`,Mt(e,t))};function qt(e,t,n){return typeof e==`number`&&typeof t==`number`&&typeof n==`number`?Nt(e,t,n):Ht(e)(e,t)}var Jt=e=>{let t=({timestamp:t})=>e(t);return{start:(e=!0)=>Ne.update(t,e),stop:()=>Pe(t),now:()=>Fe.isProcessing?Fe.timestamp:ze.now()}},Yt=(e,t,n=10)=>{let r=``,i=Math.max(Math.round(t/n),2);for(let t=0;t<i;t++)r+=Math.round(e(t/(i-1))*1e4)/1e4+`, `;return`linear(${r.substring(0,r.length-2)})`},Xt=2e4;function Zt(e,t=50,n=Xt,r){let i=0,a=e.next(i);for(r?.push(a.value);!a.done&&i<n;)i+=t,a=e.next(i),r?.push(a.value);return i>=n?1/0:i}function Qt(e,t=100,n){let r=n({...e,keyframes:[0,t]}),i=Math.min(Zt(r),Xt);return{type:`keyframes`,ease:e=>r.next(i*e).value/t,duration:oe(i)}}var $t={stiffness:100,damping:10,mass:1,velocity:0,duration:800,bounce:.3,visualDuration:.3,restSpeed:{granular:.01,default:2},restDelta:{granular:.005,default:.5},minDuration:.01,maxDuration:10,minDamping:.05,maxDamping:1};function en(e,t){return e*Math.sqrt(1-t*t)}var tn=12;function nn(e,t,n){let r=n;for(let n=1;n<tn;n++)r-=e(r)/t(r);return r}var rn=.001;function an({duration:e=$t.duration,bounce:t=$t.bounce,velocity:n=$t.velocity,mass:r=$t.mass}){let i,a;$t.maxDuration;let o=1-t;o=k($t.minDamping,$t.maxDamping,o),e=k($t.minDuration,$t.maxDuration,oe(e)),o<1?(i=t=>{let r=t*o,i=r*e,a=r-n,s=en(t,o),c=Math.exp(-i);return rn-a/s*c},a=t=>{let r=t*o*e,a=r*n+n,s=o*o*t*t*e,c=Math.exp(-r),l=en(t*t,o);return(-i(t)+rn>0?-1:1)*((a-s)*c)/l}):(i=t=>-.001+Math.exp(-t*e)*((t-n)*e+1),a=t=>Math.exp(-t*e)*((n-t)*(e*e)));let s=5/e,c=nn(i,a,s);if(e=ae(e),isNaN(c))return{stiffness:$t.stiffness,damping:$t.damping,duration:e};{let t=c*c*r;return{stiffness:t,damping:o*2*Math.sqrt(r*t),duration:e}}}var on=[`duration`,`bounce`],sn=[`stiffness`,`damping`,`mass`];function cn(e,t){return t.some(t=>e[t]!==void 0)}function ln(e){let t={velocity:$t.velocity,stiffness:$t.stiffness,damping:$t.damping,mass:$t.mass,isResolvedFromDuration:!1,...e};if(!cn(e,sn)&&cn(e,on)){if(t.velocity=0,e.visualDuration){let n=e.visualDuration,r=2*Math.PI/(n*1.2),i=r*r,a=2*k(.05,1,1-(e.bounce||0))*Math.sqrt(i);t={...t,mass:$t.mass,stiffness:i,damping:a}}else{let n=an({...e,velocity:0});t={...t,...n,mass:$t.mass},t.isResolvedFromDuration=!0}}return t}function un(e=$t.visualDuration,t=$t.bounce){let n=typeof e==`object`?e:{visualDuration:e,keyframes:[0,1],bounce:t},{restSpeed:r,restDelta:i}=n,a=n.keyframes[0],o=n.keyframes[n.keyframes.length-1],s={done:!1,value:a},{stiffness:c,damping:l,mass:u,duration:d,velocity:f,isResolvedFromDuration:p}=ln({...n,velocity:-oe(n.velocity||0)}),m=f||0,h=l/(2*Math.sqrt(c*u)),g=o-a,_=oe(Math.sqrt(c/u)),v=h*_,y=Math.abs(g)<5;r||=y?$t.restSpeed.granular:$t.restSpeed.default,i||=y?$t.restDelta.granular:$t.restDelta.default;let b,x;if(h<1){let e=en(_,h),t=(m+v*g)/e,n=v*t+g*e,r=v*g-t*e,i=-1,a=0,s=0,c=c=>{if(c!==i){i=c;let l=Math.exp(-v*c),u=Math.sin(e*c),d=Math.cos(e*c);a=o-l*(t*u+g*d),s=l*(n*u+r*d)}};b=e=>(c(e),a),x=e=>(c(e),s)}else if(h===1){b=e=>o-Math.exp(-_*e)*(g+(m+_*g)*e);let e=m+_*g;x=t=>Math.exp(-_*t)*(_*e*t-m)}else{let e=_*Math.sqrt(h*h-1);b=t=>{let n=Math.exp(-v*t),r=Math.min(e*t,300);return o-n*((m+v*g)*Math.sinh(r)+e*g*Math.cosh(r))/e};let t=(m+v*g)/e,n=v*t-g*e,r=v*g-t*e;x=t=>{let i=Math.exp(-v*t),a=Math.min(e*t,300);return i*(n*Math.sinh(a)+r*Math.cosh(a))}}let S={calculatedDuration:p&&d||null,velocity:e=>ae(x(e)),next:e=>{let t=b(e);if(p)s.done=e>=d;else{let n=ae(x(e));s.done=Math.abs(n)<=r&&Math.abs(o-t)<=i}return s.value=s.done?o:t,s},toString:()=>{let e=Math.min(Zt(S),Xt),t=Yt(t=>S.next(e*t).value,e,30);return e+`ms `+t},toTransition:()=>{}};return S}un.applyToOptions=e=>{let t=Qt(e,100,un);return e.ease=t.ease,e.duration=ae(t.duration),e.type=`keyframes`,e};function dn({keyframes:e,velocity:t=0,power:n=.8,timeConstant:r=325,bounceDamping:i=10,bounceStiffness:a=500,modifyTarget:o,min:s,max:c,restDelta:l=.5,restSpeed:u}){let d=e[0],f={done:!1,value:d},p=e=>e<s||e>c,m=e=>s===void 0?c:c===void 0||Math.abs(s-e)<Math.abs(c-e)?s:c,h=n*t,g=d+h,_=o===void 0?g:o(g);_!==g&&(h=_-d);let v=e=>-h*Math.exp(-e/r),y=e=>{let t=v(e);f.done=Math.abs(t)<=l,f.value=f.done?_:_+t},b,x,S=e=>{p(f.value)&&(b=e,x=un({keyframes:[f.value,m(f.value)],velocity:-v(e)/r*1e3,damping:i,stiffness:a,restDelta:l,restSpeed:u}))};return S(0),{calculatedDuration:null,next:e=>{let t=!1;return!x&&b===void 0&&(t=!0,y(e),S(e)),b!==void 0&&e>=b?x.next(e-b):(!t&&y(e),f)}}}function fn(e,t,n){let r=[],i=n||A.mix||qt,a=e.length-1;for(let n=0;n<a;n++){let a=i(e[n],e[n+1]);t&&(a=M(Array.isArray(t)?t[n]||re:t,a)),r.push(a)}return r}function pn(e,t,{clamp:n=!0,ease:r,mixer:i}={}){let a=e.length;if(t.length,a===1)return()=>t[0];if(a===2&&t[0]===t[1])return()=>t[1];let o=e[0]===e[1];e[0]>e[a-1]&&(e=[...e].reverse(),t=[...t].reverse());let s=fn(t,r,i),c=s.length,l=n=>{if(o&&n<e[0])return t[0];let r=0;if(c>1)for(;r<e.length-2&&!(n<e[r+1]);r++);let i=N(e[r],e[r+1],n);return s[r](i)};return n?t=>l(k(e[0],e[a-1],t)):l}function mn(e,t){let n=e[e.length-1];for(let r=1;r<=t;r++){let i=N(0,t,r);e.push(Nt(n,1,i))}}function hn(e){let t=[0];return mn(t,e.length-1),t}function gn(e,t){return e.map(e=>e*t)}function _n(e,t){return e.map(()=>t||Ce).splice(0,e.length-1)}function vn({duration:e=300,keyframes:t,times:n,ease:r=`easeInOut`}){let i=we(r)?r.map(Oe):Oe(r),a={done:!1,value:t[0]},o=pn(gn(n&&n.length===t.length?n:hn(t),e),t,{ease:Array.isArray(i)?i:_n(t,i)});return{calculatedDuration:e,next:t=>(a.value=o(t),a.done=t>=e,a)}}var yn=5;function bn(e,t,n){let r=Math.max(t-yn,0);return se(n-e(r),t-r)}var xn=e=>e!==null;function Sn(e,{repeat:t,repeatType:n=`loop`},r,i=1){let a=e.filter(xn),o=i<0||t&&n!==`loop`&&t%2==1?0:a.length-1;return!o||r===void 0?a[o]:r}var Cn={decay:dn,inertia:dn,tween:vn,keyframes:vn,spring:un};function wn(e){typeof e.type==`string`&&(e.type=Cn[e.type])}var Tn=class{constructor(){this.updateFinished()}get finished(){return this._finished}updateFinished(){this._finished=new Promise(e=>{this.resolve=e})}notifyFinished(){this.resolve()}then(e,t){return this.finished.then(e,t)}},En=e=>e/100,Dn=class extends Tn{constructor(e){super(),this.state=`idle`,this.startTime=null,this.isStopped=!1,this.currentTime=0,this.holdTime=null,this.playbackSpeed=1,this.delayState={done:!1,value:void 0},this.stop=()=>{let{motionValue:e}=this.options;e&&e.updatedAt!==ze.now()&&this.tick(ze.now()),this.isStopped=!0,this.state!==`idle`&&(this.teardown(),this.options.onStop?.())},this.options=e,this.initAnimation(),this.play(),e.autoplay===!1&&this.pause()}initAnimation(){let{options:e}=this;wn(e);let{type:t=vn,repeat:n=0,repeatDelay:r=0,repeatType:i,velocity:a=0}=e,{keyframes:o}=e,s=t||vn;s!==vn&&typeof o[0]!=`number`&&(this.mixKeyframes=M(En,qt(o[0],o[1])),o=[0,100]);let c=s({...e,keyframes:o});i===`mirror`&&(this.mirroredGenerator=s({...e,keyframes:[...o].reverse(),velocity:-a})),c.calculatedDuration===null&&(c.calculatedDuration=Zt(c));let{calculatedDuration:l}=c;this.calculatedDuration=l,this.resolvedDuration=l+r,this.totalDuration=this.resolvedDuration*(n+1)-r,this.generator=c}updateTime(e){let t=Math.round(e-this.startTime)*this.playbackSpeed;this.currentTime=this.holdTime===null?t:this.holdTime}tick(e,t=!1){let{generator:n,totalDuration:r,mixKeyframes:i,mirroredGenerator:a,resolvedDuration:o,calculatedDuration:s}=this;if(this.startTime===null)return n.next(0);let{delay:c=0,keyframes:l,repeat:u,repeatType:d,repeatDelay:f,type:p,onUpdate:m,finalKeyframe:h}=this.options;this.speed>0?this.startTime=Math.min(this.startTime,e):this.speed<0&&(this.startTime=Math.min(e-r/this.speed,this.startTime)),t?this.currentTime=e:this.updateTime(e);let g=this.currentTime-c*(this.playbackSpeed>=0?1:-1),_=this.playbackSpeed>=0?g<0:g>r;this.currentTime=Math.max(g,0),this.state===`finished`&&this.holdTime===null&&(this.currentTime=r);let v=this.currentTime,y=n;if(u){let e=Math.min(this.currentTime,r)/o,t=Math.floor(e),n=e%1;!n&&e>=1&&(n=1),n===1&&t--,t=Math.min(t,u+1),t%2&&(d===`reverse`?(n=1-n,f&&(n-=f/o)):d===`mirror`&&(y=a)),v=k(0,1,n)*o}let b;_?(this.delayState.value=l[0],b=this.delayState):b=y.next(v),i&&!_&&(b.value=i(b.value));let{done:x}=b;!_&&s!==null&&(x=this.playbackSpeed>=0?this.currentTime>=r:this.currentTime<=0);let S=this.holdTime===null&&(this.state===`finished`||this.state===`running`&&x);return S&&p!==dn&&(b.value=Sn(l,this.options,h,this.speed)),m&&m(b.value),S&&this.finish(),b}then(e,t){return this.finished.then(e,t)}get duration(){return oe(this.calculatedDuration)}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+oe(e)}get time(){return oe(this.currentTime)}set time(e){e=ae(e),this.currentTime=e,this.startTime===null||this.holdTime!==null||this.playbackSpeed===0?this.holdTime=e:this.driver&&(this.startTime=this.driver.now()-e/this.playbackSpeed),this.driver?this.driver.start(!1):(this.startTime=0,this.state=`paused`,this.holdTime=e,this.tick(e))}getGeneratorVelocity(){let e=this.currentTime;if(e<=0)return this.options.velocity||0;if(this.generator.velocity)return this.generator.velocity(e);let t=this.generator.next(e).value;return bn(e=>this.generator.next(e).value,e,t)}get speed(){return this.playbackSpeed}set speed(e){let t=this.playbackSpeed!==e;t&&this.driver&&this.updateTime(ze.now()),this.playbackSpeed=e,t&&this.driver&&(this.time=oe(this.currentTime))}play(){if(this.isStopped)return;let{driver:e=Jt,startTime:t}=this.options;this.driver||=e(e=>this.tick(e)),this.options.onPlay?.();let n=this.driver.now();this.state===`finished`?(this.updateFinished(),this.startTime=n):this.holdTime===null?this.startTime||=t??n:this.startTime=n-this.holdTime,this.state===`finished`&&this.speed<0&&(this.startTime+=this.calculatedDuration),this.holdTime=null,this.state=`running`,this.driver.start()}pause(){this.state=`paused`,this.updateTime(ze.now()),this.holdTime=this.currentTime}complete(){this.state!==`running`&&this.play(),this.state=`finished`,this.holdTime=null}finish(){this.notifyFinished(),this.teardown(),this.state=`finished`,this.options.onComplete?.()}cancel(){this.holdTime=null,this.startTime=0,this.tick(0),this.teardown(),this.options.onCancel?.()}teardown(){this.state=`idle`,this.stopDriver(),this.startTime=this.holdTime=null}stopDriver(){this.driver&&=(this.driver.stop(),void 0)}sample(e){return this.startTime=0,this.tick(e,!0)}attachTimeline(e){return this.options.allowFlatten&&(this.options.type=`keyframes`,this.options.ease=`linear`,this.initAnimation()),this.driver?.stop(),e.observe(this)}};function On(e){for(let t=1;t<e.length;t++)e[t]??(e[t]=e[t-1])}var kn=e=>e*180/Math.PI,An=e=>Mn(kn(Math.atan2(e[1],e[0]))),jn={x:4,y:5,translateX:4,translateY:5,scaleX:0,scaleY:3,scale:e=>(Math.abs(e[0])+Math.abs(e[3]))/2,rotate:An,rotateZ:An,skewX:e=>kn(Math.atan(e[1])),skewY:e=>kn(Math.atan(e[2])),skew:e=>(Math.abs(e[1])+Math.abs(e[2]))/2},Mn=e=>(e%=360,e<0&&(e+=360),e),Nn=An,Pn=e=>Math.sqrt(e[0]*e[0]+e[1]*e[1]),Fn=e=>Math.sqrt(e[4]*e[4]+e[5]*e[5]),In={x:12,y:13,z:14,translateX:12,translateY:13,translateZ:14,scaleX:Pn,scaleY:Fn,scale:e=>(Pn(e)+Fn(e))/2,rotateX:e=>Mn(kn(Math.atan2(e[6],e[5]))),rotateY:e=>Mn(kn(Math.atan2(-e[2],e[0]))),rotateZ:Nn,rotate:Nn,skewX:e=>kn(Math.atan(e[4])),skewY:e=>kn(Math.atan(e[1])),skew:e=>(Math.abs(e[1])+Math.abs(e[4]))/2};function Ln(e){return+!!e.includes(`scale`)}function Rn(e,t){if(!e||e===`none`)return Ln(t);let n=e.match(/^matrix3d\(([-\d.e\s,]+)\)$/u),r,i;if(n)r=In,i=n;else{let t=e.match(/^matrix\(([-\d.e\s,]+)\)$/u);r=jn,i=t}if(!i)return Ln(t);let a=r[t],o=i[1].split(`,`).map(Bn);return typeof a==`function`?a(o):o[a]}var zn=(e,t)=>{let{transform:n=`none`}=getComputedStyle(e);return Rn(n,t)};function Bn(e){return parseFloat(e.trim())}var Vn=[`transformPerspective`,`x`,`y`,`z`,`translateX`,`translateY`,`translateZ`,`scale`,`scaleX`,`scaleY`,`rotate`,`rotateX`,`rotateY`,`rotateZ`,`skew`,`skewX`,`skewY`],Hn=new Set([...Vn,`pathRotation`]),Un=e=>e===Ke||e===F,Wn=new Set([`x`,`y`,`z`]),Gn=Vn.filter(e=>!Wn.has(e));function Kn(e){let t=[];return Gn.forEach(n=>{let r=e.getValue(n);r!==void 0&&(t.push([n,r.get()]),r.set(+!!n.startsWith(`scale`)))}),t}var qn={width:({x:e},{paddingLeft:t=`0`,paddingRight:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},height:({y:e},{paddingTop:t=`0`,paddingBottom:n=`0`,boxSizing:r})=>{let i=e.max-e.min;return r===`border-box`?i:i-parseFloat(t)-parseFloat(n)},top:(e,{top:t})=>parseFloat(t),left:(e,{left:t})=>parseFloat(t),bottom:({y:e},{top:t})=>parseFloat(t)+(e.max-e.min),right:({x:e},{left:t})=>parseFloat(t)+(e.max-e.min),x:(e,{transform:t})=>Rn(t,`x`),y:(e,{transform:t})=>Rn(t,`y`)};qn.translateX=qn.x,qn.translateY=qn.y;var Jn=new Set,Yn=!1,Xn=!1,Zn=!1;function Qn(){if(Xn){let e=Array.from(Jn).filter(e=>e.needsMeasurement),t=new Set(e.map(e=>e.element)),n=new Map;t.forEach(e=>{let t=Kn(e);t.length&&(n.set(e,t),e.render())}),e.forEach(e=>e.measureInitialState()),t.forEach(e=>{e.render();let t=n.get(e);t&&t.forEach(([t,n])=>{e.getValue(t)?.set(n)})}),e.forEach(e=>e.measureEndState()),e.forEach(e=>{e.suspendedScrollY!==void 0&&window.scrollTo(0,e.suspendedScrollY)})}Xn=!1,Yn=!1,Jn.forEach(e=>e.complete(Zn)),Jn.clear()}function $n(){Jn.forEach(e=>{e.readKeyframes(),e.needsMeasurement&&(Xn=!0)})}function er(){Zn=!0,$n(),Qn(),Zn=!1}var tr=class{constructor(e,t,n,r,i,a=!1){this.state=`pending`,this.isAsync=!1,this.needsMeasurement=!1,this.unresolvedKeyframes=[...e],this.onComplete=t,this.name=n,this.motionValue=r,this.element=i,this.isAsync=a}scheduleResolve(){this.state=`scheduled`,this.isAsync?(Jn.add(this),Yn||(Yn=!0,Ne.read($n),Ne.resolveKeyframes(Qn))):(this.readKeyframes(),this.complete())}readKeyframes(){let{unresolvedKeyframes:e,name:t,element:n,motionValue:r}=this;if(e[0]===null){let i=r?.get(),a=e[e.length-1];if(i!==void 0)e[0]=i;else if(n&&t){let r=n.readValue(t,a);r!=null&&(e[0]=r)}e[0]===void 0&&(e[0]=a),r&&i===void 0&&r.set(e[0])}On(e)}setFinalKeyframe(){}measureInitialState(){}renderEndStyles(){}measureEndState(){}complete(e=!1){this.state=`complete`,this.onComplete(this.unresolvedKeyframes,this.finalKeyframe,e),Jn.delete(this)}cancel(){this.state===`scheduled`&&(Jn.delete(this),this.state=`pending`)}resume(){this.state===`pending`&&this.scheduleResolve()}},nr=e=>e.startsWith(`--`);function rr(e,t,n){nr(t)?e.style.setProperty(t,n):e.style[t]=n}var ir={};function ar(e,t){let n=ne(e);return()=>ir[t]??n()}var or=ar(()=>window.ScrollTimeline!==void 0,`scrollTimeline`),sr=ar(()=>{try{document.createElement(`div`).animate({opacity:0},{easing:`linear(0, 1)`})}catch{return!1}return!0},`linearEasing`),cr=([e,t,n,r])=>`cubic-bezier(${e}, ${t}, ${n}, ${r})`,lr={linear:`linear`,ease:`ease`,easeIn:`ease-in`,easeOut:`ease-out`,easeInOut:`ease-in-out`,circIn:cr([0,.65,.55,1]),circOut:cr([.55,0,1,.45]),backIn:cr([.31,.01,.66,-.59]),backOut:cr([.33,1.53,.69,.99])};function ur(e,t){if(e)return typeof e==`function`?sr()?Yt(e,t):`ease-out`:Te(e)?cr(e):Array.isArray(e)?e.map(e=>ur(e,t)||lr.easeOut):lr[e]}function dr(e,t,n,{delay:r=0,duration:i=300,repeat:a=0,repeatType:o=`loop`,ease:s=`easeOut`,times:c}={},l=void 0){let u={[t]:n};c&&(u.offset=c);let d=ur(s,i);Array.isArray(d)&&(u.easing=d);let f={delay:r,duration:i,easing:Array.isArray(d)?`linear`:d,fill:`both`,iterations:a+1,direction:o===`reverse`?`alternate`:`normal`};return l&&(f.pseudoElement=l),e.animate(u,f)}function fr(e){return typeof e==`function`&&`applyToOptions`in e}function pr({type:e,...t}){return fr(e)&&sr()?e.applyToOptions(t):(t.duration??=300,t.ease??=`easeOut`,t)}var mr=class extends Tn{constructor(e){if(super(),this.finishedTime=null,this.isStopped=!1,this.manualStartTime=null,!e)return;let{element:t,name:n,keyframes:r,pseudoElement:i,allowFlatten:a=!1,finalKeyframe:o,onComplete:s}=e;this.isPseudoElement=!!i,this.allowFlatten=a,this.options=e,e.type;let c=pr(e);this.animation=dr(t,n,r,c,i),c.autoplay===!1&&this.animation.pause(),this.animation.onfinish=()=>{if(this.finishedTime=this.time,!i){let e=Sn(r,this.options,o,this.speed);this.updateMotionValue&&this.updateMotionValue(e),rr(t,n,e),this.animation.cancel()}s?.(),this.notifyFinished()}}play(){this.isStopped||(this.manualStartTime=null,this.animation.play(),this.state===`finished`&&this.updateFinished())}pause(){this.animation.pause()}complete(){this.animation.finish?.()}cancel(){try{this.animation.cancel()}catch{}}stop(){if(this.isStopped)return;this.isStopped=!0;let{state:e}=this;e!==`idle`&&e!==`finished`&&(this.updateMotionValue?this.updateMotionValue():this.commitStyles(),this.isPseudoElement||this.cancel())}commitStyles(){let e=this.options?.element;!this.isPseudoElement&&e?.isConnected&&this.animation.commitStyles?.()}get duration(){let e=this.animation.effect?.getComputedTiming?.().duration||0;return oe(Number(e))}get iterationDuration(){let{delay:e=0}=this.options||{};return this.duration+oe(e)}get time(){return oe(Number(this.animation.currentTime)||0)}set time(e){let t=this.finishedTime!==null;this.manualStartTime=null,this.finishedTime=null,this.animation.currentTime=ae(e),t&&this.animation.pause()}get speed(){return this.animation.playbackRate}set speed(e){e<0&&(this.finishedTime=null),this.animation.playbackRate=e}get state(){return this.finishedTime===null?this.animation.playState:`finished`}get startTime(){return this.manualStartTime??Number(this.animation.startTime)}set startTime(e){this.manualStartTime=this.animation.startTime=e}attachTimeline({timeline:e,rangeStart:t,rangeEnd:n,observe:r}){return this.allowFlatten&&this.animation.effect?.updateTiming({easing:`linear`}),this.animation.onfinish=null,e&&or()?(this.animation.timeline=e,t&&(this.animation.rangeStart=t),n&&(this.animation.rangeEnd=n),re):r(this)}},hr={anticipate:_e,backInOut:ge,circInOut:be};function gr(e){return e in hr}function _r(e){typeof e.ease==`string`&&gr(e.ease)&&(e.ease=hr[e.ease])}var vr=10,yr=class extends mr{constructor(e){_r(e),wn(e),super(e),e.startTime!==void 0&&e.autoplay!==!1&&(this.startTime=e.startTime),this.options=e}updateMotionValue(e){let{motionValue:t,onUpdate:n,onComplete:r,element:i,...a}=this.options;if(!t)return;if(e!==void 0){t.set(e);return}let o=new Dn({...a,autoplay:!1}),s=Math.max(vr,ze.now()-this.startTime),c=k(0,vr,s-vr),l=o.sample(s).value,{name:u}=this.options;i&&u&&rr(i,u,l),t.setWithVelocity(o.sample(Math.max(0,s-c)).value,l,c),o.stop()}},br=(e,t)=>t!==`zIndex`&&!!(typeof e==`number`||Array.isArray(e)||typeof e==`string`&&(kt.test(e)||e===`0`)&&!e.startsWith(`url(`));function xr(e){let t=e[0];if(e.length===1)return!0;for(let n=0;n<e.length;n++)if(e[n]!==t)return!0}function Sr(e,t,n,r){let i=e[0];if(i===null)return!1;if(t===`display`||t===`visibility`)return!0;let a=e[e.length-1],o=br(i,t),s=br(a,t);return`${t}${i}${a}${o?a:i}`,!o||!s?!1:xr(e)||(n===`spring`||fr(n))&&r}function Cr(e){e.duration=0,e.type=`keyframes`}var wr=new Set([`opacity`,`clipPath`,`filter`,`transform`,`backgroundColor`]),Tr=/^(?:oklch|oklab|lab|lch|color|color-mix|light-dark)\(/;function Er(e){for(let t=0;t<e.length;t++)if(typeof e[t]==`string`&&Tr.test(e[t]))return!0;return!1}var Dr=new Set([`color`,`backgroundColor`,`outlineColor`,`fill`,`stroke`,`borderColor`,`borderTopColor`,`borderRightColor`,`borderBottomColor`,`borderLeftColor`]),Or=ne(()=>Object.hasOwnProperty.call(Element.prototype,`animate`));function kr(e){let{motionValue:t,name:n,repeatDelay:r,repeatType:i,damping:a,type:o,keyframes:s}=e,c=t?.owner?.current;if(!(c instanceof HTMLElement)&&!(c instanceof SVGElement))return!1;let{onUpdate:l,transformTemplate:u}=t.owner.getProps();return Or()&&n&&(wr.has(n)||Dr.has(n)&&Er(s))&&(n!==`transform`||!u)&&!l&&!r&&i!==`mirror`&&a!==0&&o!==`inertia`}var Ar=40,jr=class extends Tn{constructor({autoplay:e=!0,delay:t=0,type:n=`keyframes`,repeat:r=0,repeatDelay:i=0,repeatType:a=`loop`,keyframes:o,name:s,motionValue:c,element:l,...u}){super(),this.stop=()=>{this._animation&&(this._animation.stop(),this.stopTimeline?.()),this.keyframeResolver?.cancel()},this.createdAt=ze.now();let d={autoplay:e,delay:t,type:n,repeat:r,repeatDelay:i,repeatType:a,name:s,motionValue:c,element:l,...u},f=l?.KeyframeResolver||tr;this.keyframeResolver=new f(o,(e,t,n)=>this.onKeyframesResolved(e,t,d,!n),s,c,l),this.keyframeResolver?.scheduleResolve()}onKeyframesResolved(e,t,n,r){this.keyframeResolver=void 0;let{name:i,type:a,velocity:o,delay:s,isHandoff:c,onUpdate:l}=n;this.resolvedAt=ze.now();let u=!0;Sr(e,i,a,o)||(u=!1,(A.instantAnimations||!s)&&l?.(Sn(e,n,t)),e[0]=e[e.length-1],Cr(n),n.repeat=0);let d={startTime:r?this.resolvedAt&&this.resolvedAt-this.createdAt>Ar?this.resolvedAt:this.createdAt:void 0,finalKeyframe:t,...n,keyframes:e},f=u&&!c&&kr(d),p=d.motionValue?.owner?.current,m;if(f)try{m=new yr({...d,element:p})}catch{m=new Dn(d)}else m=new Dn(d);m.finished.then(()=>{this.notifyFinished()}).catch(re),this.pendingTimeline&&=(this.stopTimeline=m.attachTimeline(this.pendingTimeline),void 0),this._animation=m}get finished(){return this._animation?this.animation.finished:this._finished}then(e,t){return this.finished.finally(e).then(()=>{})}get animation(){return this._animation||(this.keyframeResolver?.resume(),er()),this._animation}get duration(){return this.animation.duration}get iterationDuration(){return this.animation.iterationDuration}get time(){return this.animation.time}set time(e){this.animation.time=e}get speed(){return this.animation.speed}get state(){return this.animation.state}set speed(e){this.animation.speed=e}get startTime(){return this.animation.startTime}attachTimeline(e){return this._animation?this.stopTimeline=this.animation.attachTimeline(e):this.pendingTimeline=e,()=>this.stop()}play(){this.animation.play()}pause(){this.animation.pause()}complete(){this.animation.complete()}cancel(){this._animation&&this.animation.cancel(),this.keyframeResolver?.cancel()}};function Mr(e,t,n,r=0,i=1){let a=Array.from(e).sort((e,t)=>e.sortNodePosition(t)).indexOf(t),o=e.size,s=(o-1)*r;return typeof n==`function`?n(a,o):i===1?a*r:s-a*r}var Nr=30,Pr=e=>!isNaN(parseFloat(e)),Fr={current:void 0},Ir=class{constructor(e,t={}){this.canTrackVelocity=null,this.events={},this.updateAndNotify=e=>{let t=ze.now();if(this.updatedAt!==t&&this.setPrevFrameValue(),this.prev=this.current,this.setCurrent(e),this.current!==this.prev&&(this.events.change?.notify(this.current),this.dependents))for(let e of this.dependents)e.dirty()},this.hasAnimated=!1,this.setCurrent(e),this.owner=t.owner}setCurrent(e){this.current=e,this.updatedAt=ze.now(),this.canTrackVelocity===null&&e!==void 0&&(this.canTrackVelocity=Pr(this.current))}setPrevFrameValue(e=this.current){this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt}onChange(e){return this.on(`change`,e)}on(e,t){this.events[e]||(this.events[e]=new ie);let n=this.events[e].add(t);return e===`change`?()=>{n(),Ne.read(()=>{this.events.change.getSize()||this.stop()})}:n}clearListeners(){for(let e in this.events)this.events[e].clear()}attach(e,t){this.passiveEffect=e,this.stopPassiveEffect=t}set(e){this.passiveEffect?this.passiveEffect(e,this.updateAndNotify):this.updateAndNotify(e)}setWithVelocity(e,t,n){this.set(t),this.prev=void 0,this.prevFrameValue=e,this.prevUpdatedAt=this.updatedAt-n}jump(e,t=!0){this.updateAndNotify(e),this.prev=e,this.prevUpdatedAt=this.prevFrameValue=void 0,t&&this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}dirty(){this.events.change?.notify(this.current)}addDependent(e){this.dependents||=new Set,this.dependents.add(e)}removeDependent(e){this.dependents&&this.dependents.delete(e)}get(){return Fr.current&&Fr.current.push(this),this.current}getPrevious(){return this.prev}getVelocity(){let e=ze.now();if(!this.canTrackVelocity||this.prevFrameValue===void 0||e-this.updatedAt>Nr)return 0;let t=Math.min(this.updatedAt-this.prevUpdatedAt,Nr);return se(parseFloat(this.current)-parseFloat(this.prevFrameValue),t)}start(e){return this.stop(),new Promise(t=>{this.hasAnimated=!0,this.animation=e(t),this.events.animationStart&&this.events.animationStart.notify()}).then(()=>{this.events.animationComplete&&this.events.animationComplete.notify(),this.clearAnimation()})}stop(){this.animation&&(this.animation.stop(),this.events.animationCancel&&this.events.animationCancel.notify()),this.clearAnimation()}isAnimating(){return!!this.animation}clearAnimation(){delete this.animation}destroy(){this.dependents?.clear(),this.events.destroy?.notify(),this.clearListeners(),this.stop(),this.stopPassiveEffect&&this.stopPassiveEffect()}};function Lr(e,t){return new Ir(e,t)}function Rr(e,t){if(e?.inherit&&t){let{inherit:n,...r}=e;return{...t,...r}}return e}function zr(e,t){let n=e?.[t]??e?.default??e;return n===e?n:Rr(n,e)}var Br={type:`spring`,stiffness:500,damping:25,restSpeed:10},Vr=e=>({type:`spring`,stiffness:550,damping:e===0?2*Math.sqrt(550):30,restSpeed:10}),Hr={type:`keyframes`,duration:.8},Ur={type:`keyframes`,ease:[.25,.1,.35,1],duration:.3},Wr=(e,{keyframes:t})=>t.length>2?Hr:Hn.has(e)?e.startsWith(`scale`)?Vr(t[1]):Br:Ur,Gr=new Set([`when`,`delay`,`delayChildren`,`staggerChildren`,`staggerDirection`,`repeat`,`repeatType`,`repeatDelay`,`from`,`elapsed`]);function Kr(e){for(let t in e)if(!Gr.has(t))return!0;return!1}var qr=(e,t,n,r={},i,a)=>o=>{let s=zr(r,e)||{},c=s.delay||r.delay||0,{elapsed:l=0}=r;l-=ae(c);let u={keyframes:Array.isArray(n)?n:[null,n],ease:`easeOut`,velocity:t.getVelocity(),...s,delay:-l,onUpdate:e=>{t.set(e),s.onUpdate&&s.onUpdate(e)},onComplete:()=>{o(),s.onComplete&&s.onComplete()},name:e,motionValue:t,element:a?void 0:i};Kr(s)||Object.assign(u,Wr(e,u)),u.duration&&=ae(u.duration),u.repeatDelay&&=ae(u.repeatDelay),u.from!==void 0&&(u.keyframes[0]=u.from);let d=!1;if((u.type===!1||u.duration===0&&!u.repeatDelay)&&(Cr(u),u.delay===0&&(d=!0)),(A.instantAnimations||A.skipAnimations||i?.shouldSkipAnimations||s.skipAnimations)&&(d=!0,Cr(u),u.delay=0),u.allowFlatten=!s.type&&!s.ease,d&&!a&&t.get()!==void 0){let e=Sn(u.keyframes,s);if(e!==void 0){Ne.update(()=>{u.onUpdate(e),u.onComplete()});return}}return s.isSync?new Dn(u):new jr(u)},Jr=/^var\(--(?:([\w-]+)|([\w-]+), ?([a-zA-Z\d ()%#.,-]+))\)/u;function Yr(e){let t=Jr.exec(e);if(!t)return[,];let[,n,r,i]=t;return[`--${n??r}`,i]}function Xr(e,t,n=1){`${e}`;let[r,i]=Yr(e);if(!r)return;let a=window.getComputedStyle(t).getPropertyValue(r);if(a){let e=a.trim();return j(e)?parseFloat(e):e}return Ue(i)?Xr(i,t,n+1):i}function Zr(e){let t=[{},{}];return e?.values.forEach((e,n)=>{t[0][n]=e.get(),t[1][n]=e.getVelocity()}),t}function Qr(e,t,n,r){if(typeof t==`function`){let[i,a]=Zr(r);t=t(n===void 0?e.custom:n,i,a)}if(typeof t==`string`&&(t=e.variants&&e.variants[t]),typeof t==`function`){let[i,a]=Zr(r);t=t(n===void 0?e.custom:n,i,a)}return t}function $r(e,t,n){let r=e.getProps();return Qr(r,t,n===void 0?r.custom:n,e)}var ei=new Set([`width`,`height`,`top`,`left`,`right`,`bottom`,...Vn]),ti=e=>Array.isArray(e);function ni(e,t,n){e.hasValue(t)?e.getValue(t).set(n):e.addValue(t,Lr(n))}function ri(e){return ti(e)?e[e.length-1]||0:e}function ii(e,t){let{transitionEnd:n={},transition:r={},...i}=$r(e,t)||{};i={...i,...n};for(let t in i)ni(e,t,ri(i[t]))}var ai=e=>!!(e&&e.getVelocity);function oi(e){return!!(ai(e)&&e.add)}function si(e,t){let n=e.getValue(`willChange`);if(oi(n))return n.add(t);if(!n&&A.WillChange){let n=new A.WillChange(`auto`);e.addValue(`willChange`,n),n.add(t)}}function ci(e){return e.replace(/([A-Z])/g,e=>`-${e.toLowerCase()}`)}var li=`data-`+ci(`framerAppearId`);function ui(e){return e.props[li]}var di=typeof window<`u`;function fi({protectedKeys:e,needsAnimating:t},n){let r=e.hasOwnProperty(n)&&t[n]!==!0;return t[n]=!1,r}function pi(e,t,{delay:n=0,transitionOverride:r,type:i}={}){let{transition:a,transitionEnd:o,...s}=t,c=e.getDefaultTransition();a=a?Rr(a,c):c;let l=a?.reduceMotion,u=a?.skipAnimations;r&&(a=r);let d=[],f=i&&e.animationState&&e.animationState.getState()[i],p=a?.path;p&&p.animateVisualElement(e,s,a,n,d);for(let t in s){let r=e.getValue(t,e.latestValues[t]??null),i=s[t];if(i===void 0||f&&fi(f,t))continue;let o={delay:n,...zr(a||{},t)};u&&(o.skipAnimations=!0);let c=r.get();if(c!==void 0&&!r.isAnimating()&&!Array.isArray(i)&&i===c&&!o.velocity){Ne.update(()=>r.set(i));continue}let p=!1;if(di&&window.MotionHandoffAnimation){let n=ui(e);if(n){let e=window.MotionHandoffAnimation(n,t,Ne);e!==null&&(o.startTime=e,p=!0)}}si(e,t);let m=l??e.shouldReduceMotion;r.start(qr(t,r,i,m&&ei.has(t)?{type:!1}:o,e,p));let h=r.animation;h&&d.push(h)}if(o){let t=()=>Ne.update(()=>{o&&ii(e,o)});d.length?Promise.all(d).then(t):t()}return d}function mi(e,t,n={}){let r=$r(e,t,n.type===`exit`?e.presenceContext?.custom:void 0),{transition:i=e.getDefaultTransition()||{}}=r||{};n.transitionOverride&&(i=n.transitionOverride);let a=r?()=>Promise.all(pi(e,r,n)):()=>Promise.resolve(),o=e.variantChildren&&e.variantChildren.size?(r=0)=>{let{delayChildren:a=0,staggerChildren:o,staggerDirection:s}=i;return hi(e,t,r,a,o,s,n)}:()=>Promise.resolve(),{when:s}=i;if(s){let[e,t]=s===`beforeChildren`?[a,o]:[o,a];return e().then(()=>t())}return Promise.all([a(),o(n.delay)])}function hi(e,t,n=0,r=0,i=0,a=1,o){let s=[];for(let c of e.variantChildren)c.notify(`AnimationStart`,t),s.push(mi(c,t,{...o,delay:n+(typeof r==`function`?0:r)+Mr(e.variantChildren,c,r,i,a)}).then(()=>c.notify(`AnimationComplete`,t)));return Promise.all(s)}function gi(e,t,n={}){e.notify(`AnimationStart`,t);let r;if(Array.isArray(t)){let i=t.map(t=>mi(e,t,n));r=Promise.all(i)}else if(typeof t==`string`)r=mi(e,t,n);else{let i=typeof t==`function`?$r(e,t,n.custom):t;r=Promise.all(pi(e,i,n))}return r.then(()=>{e.notify(`AnimationComplete`,t)})}var _i={test:e=>e===`auto`,parse:e=>e},vi=e=>t=>t.test(e),yi=[Ke,F,ct,st,ut,lt,_i],bi=e=>yi.find(vi(e));function xi(e){return typeof e==`number`?e===0:e===null||e===`none`||e===`0`||te(e)}var Si=new Set([`brightness`,`contrast`,`saturate`,`opacity`]);function Ci(e){let[t,n]=e.slice(0,-1).split(`(`);if(t===`drop-shadow`)return e;let[r]=n.match(Xe)||[];if(!r)return e;let i=n.replace(r,``),a=+!!Si.has(t);return r!==n&&(a*=100),t+`(`+a+i+`)`}var wi=/\b([a-z-]*)\(.*?\)/gu,Ti={...kt,getAnimatableNone:e=>{let t=e.match(wi);return t?t.map(Ci).join(` `):e}},Ei={...kt,getAnimatableNone:e=>{let t=kt.parse(e);return kt.createTransformer(e)(t.map(e=>typeof e==`number`?0:typeof e==`object`?{...e,alpha:1}:e))}},Di={...Ke,transform:Math.round},Oi={borderWidth:F,borderTopWidth:F,borderRightWidth:F,borderBottomWidth:F,borderLeftWidth:F,borderRadius:F,borderTopLeftRadius:F,borderTopRightRadius:F,borderBottomRightRadius:F,borderBottomLeftRadius:F,width:F,maxWidth:F,height:F,maxHeight:F,top:F,right:F,bottom:F,left:F,inset:F,insetBlock:F,insetBlockStart:F,insetBlockEnd:F,insetInline:F,insetInlineStart:F,insetInlineEnd:F,padding:F,paddingTop:F,paddingRight:F,paddingBottom:F,paddingLeft:F,paddingBlock:F,paddingBlockStart:F,paddingBlockEnd:F,paddingInline:F,paddingInlineStart:F,paddingInlineEnd:F,margin:F,marginTop:F,marginRight:F,marginBottom:F,marginLeft:F,marginBlock:F,marginBlockStart:F,marginBlockEnd:F,marginInline:F,marginInlineStart:F,marginInlineEnd:F,fontSize:F,backgroundPositionX:F,backgroundPositionY:F,rotate:st,pathRotation:st,rotateX:st,rotateY:st,rotateZ:st,scale:Je,scaleX:Je,scaleY:Je,scaleZ:Je,skew:st,skewX:st,skewY:st,distance:F,translateX:F,translateY:F,translateZ:F,x:F,y:F,z:F,perspective:F,transformPerspective:F,opacity:qe,originX:dt,originY:dt,originZ:F,zIndex:Di,fillOpacity:qe,strokeOpacity:qe,numOctaves:Di},ki={...Oi,color:pt,backgroundColor:pt,outlineColor:pt,fill:pt,stroke:pt,borderColor:pt,borderTopColor:pt,borderRightColor:pt,borderBottomColor:pt,borderLeftColor:pt,filter:Ti,WebkitFilter:Ti,mask:Ei,WebkitMask:Ei},Ai=e=>ki[e],ji=new Set([Ti,Ei]);function Mi(e,t){let n=Ai(e);return ji.has(n)||(n=kt),n.getAnimatableNone?n.getAnimatableNone(t):void 0}var Ni=new Set([`auto`,`none`,`0`]);function Pi(e,t,n){let r=0,i;for(;r<e.length&&!i;){let t=e[r];typeof t==`string`&&!Ni.has(t)&&St(t).values.length&&(i=e[r]),r++}if(i&&n)for(let r of t)e[r]=Mi(n,i)}var Fi=class extends tr{constructor(e,t,n,r,i){super(e,t,n,r,i,!0)}readKeyframes(){let{unresolvedKeyframes:e,element:t,name:n}=this;if(!t||!t.current)return;super.readKeyframes();for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`&&(r=r.trim(),Ue(r))){let i=Xr(r,t.current);i!==void 0&&(e[n]=i),n===e.length-1&&(this.finalKeyframe=r)}}if(this.resolveNoneKeyframes(),!ei.has(n)||e.length!==2)return;let[r,i]=e,a=bi(r),o=bi(i);if(Ge(r)!==Ge(i)&&qn[n]){this.needsMeasurement=!0;return}if(a!==o){if(Un(a)&&Un(o))for(let t=0;t<e.length;t++){let n=e[t];typeof n==`string`&&(e[t]=parseFloat(n))}else qn[n]&&(this.needsMeasurement=!0)}}resolveNoneKeyframes(){let{unresolvedKeyframes:e,name:t}=this,n=[];for(let t=0;t<e.length;t++)(e[t]===null||xi(e[t]))&&n.push(t);n.length&&Pi(e,n,t)}measureInitialState(){let{element:e,unresolvedKeyframes:t,name:n}=this;if(!e||!e.current)return;n===`height`&&(this.suspendedScrollY=window.pageYOffset),this.measuredOrigin=qn[n](e.measureViewportBox(),window.getComputedStyle(e.current)),t[0]=this.measuredOrigin;let r=t[t.length-1];r!==void 0&&e.getValue(n,r).jump(r,!1)}measureEndState(){let{element:e,name:t,unresolvedKeyframes:n}=this;if(!e||!e.current)return;let r=e.getValue(t);r&&r.jump(this.measuredOrigin,!1);let i=n.length-1,a=n[i];n[i]=qn[t](e.measureViewportBox(),window.getComputedStyle(e.current)),a!==null&&this.finalKeyframe===void 0&&(this.finalKeyframe=a),this.removedTransforms?.length&&this.removedTransforms.forEach(([t,n])=>{e.getValue(t).set(n)}),this.resolveNoneKeyframes()}},Ii=[`borderTopLeftRadius`,`borderTopRightRadius`,`borderBottomRightRadius`,`borderBottomLeftRadius`];function Li(e,t,n){if(e==null)return[];if(e instanceof EventTarget)return[e];if(typeof e==`string`){let r=document;t&&(r=t.current);let i=n?.[e]??r.querySelectorAll(e);return i?Array.from(i):[]}return Array.from(e).filter(e=>e!=null)}var Ri=(e,t)=>t&&typeof e==`number`?t.transform(e):e;function zi(e){return ee(e)&&`offsetHeight`in e&&!(`ownerSVGElement`in e)}var{schedule:Bi,cancel:Vi}=Me(queueMicrotask,!1),Hi={x:!1,y:!1};function Ui(){return Hi.x||Hi.y}function Wi(e){return e===`x`||e===`y`?Hi[e]?null:(Hi[e]=!0,()=>{Hi[e]=!1}):Hi.x||Hi.y?null:(Hi.x=Hi.y=!0,()=>{Hi.x=Hi.y=!1})}function Gi(e,t){let n=Li(e),r=new AbortController;return[n,{passive:!0,...t,signal:r.signal},()=>r.abort()]}function Ki(e){return!(e.pointerType===`touch`||Ui())}function qi(e,t,n={}){let[r,i,a]=Gi(e,n);return r.forEach(e=>{let n=!1,r=!1,a,o=()=>{e.removeEventListener(`pointerleave`,u)},s=e=>{a&&=(a(e),void 0),o()},c=e=>{n=!1,window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),r&&(r=!1,s(e))},l=()=>{n=!0,window.addEventListener(`pointerup`,c,i),window.addEventListener(`pointercancel`,c,i)},u=e=>{if(e.pointerType!==`touch`){if(n){r=!0;return}s(e)}};e.addEventListener(`pointerenter`,n=>{if(!Ki(n))return;r=!1;let o=t(e,n);typeof o==`function`&&(a=o,e.addEventListener(`pointerleave`,u,i))},i),e.addEventListener(`pointerdown`,l,i)}),a}var Ji=(e,t)=>t?e===t||Ji(e,t.parentElement):!1,Yi=e=>e.pointerType===`mouse`?typeof e.button!=`number`||e.button<=0:e.isPrimary!==!1,Xi=new Set([`BUTTON`,`INPUT`,`SELECT`,`TEXTAREA`,`A`]);function Zi(e){return Xi.has(e.tagName)||e.isContentEditable===!0}var Qi=new Set([`INPUT`,`SELECT`,`TEXTAREA`]);function $i(e){return Qi.has(e.tagName)||e.isContentEditable===!0}var ea=new WeakSet;function ta(e){return t=>{t.key===`Enter`&&e(t)}}function na(e,t){e.dispatchEvent(new PointerEvent(`pointer`+t,{isPrimary:!0,bubbles:!0}))}var ra=(e,t)=>{let n=e.currentTarget;if(!n)return;let r=ta(()=>{if(ea.has(n))return;na(n,`down`);let e=ta(()=>{na(n,`up`)});n.addEventListener(`keyup`,e,t),n.addEventListener(`blur`,()=>na(n,`cancel`),t)});n.addEventListener(`keydown`,r,t),n.addEventListener(`blur`,()=>n.removeEventListener(`keydown`,r),t)};function ia(e){return Yi(e)&&!Ui()}var aa=new WeakSet;function oa(e,t,n={}){let[r,i,a]=Gi(e,n),o=e=>{let r=e.currentTarget;if(!ia(e)||aa.has(e))return;ea.add(r),n.stopPropagation&&aa.add(e);let a=t(r,e),o={...i,capture:!0},s=(e,t)=>{window.removeEventListener(`pointerup`,c,o),window.removeEventListener(`pointercancel`,l,o),ea.has(r)&&ea.delete(r),ia(e)&&typeof a==`function`&&a(e,{success:t})},c=e=>{s(e,r===window||r===document||n.useGlobalTarget||Ji(r,e.target))},l=e=>{s(e,!1)};window.addEventListener(`pointerup`,c,o),window.addEventListener(`pointercancel`,l,o)};return r.forEach(e=>{(n.useGlobalTarget?window:e).addEventListener(`pointerdown`,o,i),zi(e)&&(e.addEventListener(`focus`,e=>ra(e,i)),!Zi(e)&&!e.hasAttribute(`tabindex`)&&(e.tabIndex=0))}),a}function sa(e){return ee(e)&&`ownerSVGElement`in e}var ca=new WeakMap,la,ua=(e,t,n)=>(r,i)=>i&&i[0]?i[0][e+`Size`]:sa(r)&&`getBBox`in r?r.getBBox()[t]:r[n],da=ua(`inline`,`width`,`offsetWidth`),fa=ua(`block`,`height`,`offsetHeight`);function pa({target:e,borderBoxSize:t}){ca.get(e)?.forEach(n=>{n(e,{get width(){return da(e,t)},get height(){return fa(e,t)}})})}function ma(e){e.forEach(pa)}function ha(){typeof ResizeObserver>`u`||(la=new ResizeObserver(ma))}function ga(e,t){la||ha();let n=Li(e);return n.forEach(e=>{let n=ca.get(e);n||(n=new Set,ca.set(e,n)),n.add(t),la?.observe(e)}),()=>{n.forEach(e=>{let n=ca.get(e);n?.delete(t),n?.size||la?.unobserve(e)})}}var _a=new Set,va;function ya(){va=()=>{let e={get width(){return window.innerWidth},get height(){return window.innerHeight}};_a.forEach(t=>t(e))},window.addEventListener(`resize`,va)}function ba(e){return _a.add(e),va||ya(),()=>{_a.delete(e),!_a.size&&typeof va==`function`&&(window.removeEventListener(`resize`,va),va=void 0)}}function xa(e,t){return typeof e==`function`?ba(e):ga(e,t)}var Sa={value:null,addProjectionMetrics:null};function Ca(e){return sa(e)&&e.tagName===`svg`}var wa=[...yi,pt,kt],Ta=e=>wa.find(vi(e)),Ea=()=>({translate:0,scale:1,origin:0,originPoint:0}),Da=()=>({x:Ea(),y:Ea()}),Oa=()=>({min:0,max:0}),ka=()=>({x:Oa(),y:Oa()}),Aa=new WeakMap;function ja(e){return typeof e==`object`&&!!e&&typeof e.start==`function`}function Ma(e){return typeof e==`string`||Array.isArray(e)}var Na=[`animate`,`whileInView`,`whileFocus`,`whileHover`,`whileTap`,`whileDrag`,`exit`],Pa=[`initial`,...Na];function Fa(e){return ja(e.animate)||Pa.some(t=>Ma(e[t]))}function Ia(e){return!!(Fa(e)||e.variants)}function La(e,t,n){for(let r in t){let i=t[r],a=n[r];if(ai(i))e.addValue(r,i);else if(ai(a))e.addValue(r,Lr(i,{owner:e}));else if(a!==i){if(e.hasValue(r)){let t=e.getValue(r);t.liveStyle===!0?t.jump(i):t.hasAnimated||t.set(i)}else{let t=e.getStaticValue(r);e.addValue(r,Lr(t===void 0?i:t,{owner:e}))}}}for(let r in n)t[r]===void 0&&e.removeValue(r);return t}var Ra={current:null},za={current:!1},Ba=typeof window<`u`;function Va(){if(za.current=!0,Ba){if(window.matchMedia){let e=window.matchMedia(`(prefers-reduced-motion)`),t=()=>Ra.current=e.matches;e.addEventListener(`change`,t),t()}else Ra.current=!1}}var Ha=[`AnimationStart`,`AnimationComplete`,`Update`,`BeforeLayoutMeasure`,`LayoutMeasure`,`LayoutAnimationStart`,`LayoutAnimationComplete`],Ua={};function Wa(e){Ua=e}function Ga(){return Ua}var Ka=class{scrapeMotionValuesFromProps(e,t,n){return{}}constructor({parent:e,props:t,presenceContext:n,reducedMotionConfig:r,skipAnimations:i,blockInitialAnimation:a,visualState:o},s={}){this.current=null,this.children=new Set,this.isVariantNode=!1,this.isControllingVariants=!1,this.shouldReduceMotion=null,this.shouldSkipAnimations=!1,this.values=new Map,this.KeyframeResolver=tr,this.features={},this.valueSubscriptions=new Map,this.prevMotionValues={},this.hasBeenMounted=!1,this.events={},this.propEventSubscriptions={},this.notifyUpdate=()=>this.notify(`Update`,this.latestValues),this.render=()=>{this.current&&(this.triggerBuild(),this.renderInstance(this.current,this.renderState,this.props.style,this.projection))},this.renderScheduledAt=0,this.scheduleRender=()=>{let e=ze.now();this.renderScheduledAt<e&&(this.renderScheduledAt=e,Ne.render(this.render,!1,!0))};let{latestValues:c,renderState:l}=o;this.latestValues=c,this.baseTarget={...c},this.initialValues=t.initial?{...c}:{},this.renderState=l,this.parent=e,this.props=t,this.presenceContext=n,this.depth=e?e.depth+1:0,this.reducedMotionConfig=r,this.skipAnimationsConfig=i,this.options=s,this.blockInitialAnimation=!!a,this.isControllingVariants=Fa(t),this.isVariantNode=Ia(t),this.isVariantNode&&(this.variantChildren=new Set),this.manuallyAnimateOnMount=!!(e&&e.current);let{willChange:u,...d}=this.scrapeMotionValuesFromProps(t,{},this);for(let e in d){let t=d[e];c[e]!==void 0&&ai(t)&&t.set(c[e])}}mount(e){if(this.hasBeenMounted)for(let e in this.initialValues)this.values.get(e)?.jump(this.initialValues[e]),this.latestValues[e]=this.initialValues[e];this.current=e,Aa.set(e,this),this.projection&&!this.projection.instance&&this.projection.mount(e),this.parent&&this.isVariantNode&&!this.isControllingVariants&&(this.removeFromVariantTree=this.parent.addVariantChild(this)),this.values.forEach((e,t)=>this.bindToMotionValue(t,e)),this.reducedMotionConfig===`never`?this.shouldReduceMotion=!1:this.reducedMotionConfig===`always`?this.shouldReduceMotion=!0:(za.current||Va(),this.shouldReduceMotion=Ra.current),this.shouldSkipAnimations=this.skipAnimationsConfig??!1,this.parent?.addChild(this),this.update(this.props,this.presenceContext),this.hasBeenMounted=!0}unmount(){this.projection&&this.projection.unmount(),Pe(this.notifyUpdate),Pe(this.render),this.valueSubscriptions.forEach(e=>e()),this.valueSubscriptions.clear(),this.removeFromVariantTree&&this.removeFromVariantTree(),this.parent?.removeChild(this);for(let e in this.events)this.events[e].clear();for(let e in this.features){let t=this.features[e];t&&(t.unmount(),t.isMounted=!1)}this.current=null}addChild(e){this.children.add(e),this.enteringChildren??=new Set,this.enteringChildren.add(e)}removeChild(e){this.children.delete(e),this.enteringChildren&&this.enteringChildren.delete(e)}bindToMotionValue(e,t){if(this.valueSubscriptions.has(e)&&this.valueSubscriptions.get(e)(),t.accelerate&&wr.has(e)&&this.current instanceof HTMLElement){let{factory:n,keyframes:r,times:i,ease:a,duration:o}=t.accelerate,s=new mr({element:this.current,name:e,keyframes:r,times:i,ease:a,duration:ae(o)}),c=n(s);this.valueSubscriptions.set(e,()=>{c(),s.cancel()});return}let n=Hn.has(e);n&&this.onBindTransform&&this.onBindTransform();let r=t.on(`change`,t=>{this.latestValues[e]=t,this.props.onUpdate&&Ne.preRender(this.notifyUpdate),n&&this.projection&&(this.projection.isTransformDirty=!0),this.scheduleRender()}),i;typeof window<`u`&&window.MotionCheckAppearSync&&(i=window.MotionCheckAppearSync(this,e,t)),this.valueSubscriptions.set(e,()=>{r(),i&&i()})}sortNodePosition(e){return!this.current||!this.sortInstanceNodePosition||this.type!==e.type?0:this.sortInstanceNodePosition(this.current,e.current)}updateFeatures(){let e=`animation`;for(e in Ua){let t=Ua[e];if(!t)continue;let{isEnabled:n,Feature:r}=t;if(!this.features[e]&&r&&n(this.props)&&(this.features[e]=new r(this)),this.features[e]){let t=this.features[e];t.isMounted?t.update():(t.mount(),t.isMounted=!0)}}}triggerBuild(){this.build(this.renderState,this.latestValues,this.props)}measureViewportBox(){return this.current?this.measureInstanceViewportBox(this.current,this.props):ka()}getStaticValue(e){return this.latestValues[e]}setStaticValue(e,t){this.latestValues[e]=t}update(e,t){(e.transformTemplate||this.props.transformTemplate)&&this.scheduleRender(),this.prevProps=this.props,this.props=e,this.prevPresenceContext=this.presenceContext,this.presenceContext=t;for(let t=0;t<Ha.length;t++){let n=Ha[t];this.propEventSubscriptions[n]&&(this.propEventSubscriptions[n](),delete this.propEventSubscriptions[n]);let r=e[`on`+n];r&&(this.propEventSubscriptions[n]=this.on(n,r))}this.prevMotionValues=La(this,this.scrapeMotionValuesFromProps(e,this.prevProps||{},this),this.prevMotionValues),this.handleChildMotionValue&&this.handleChildMotionValue()}getProps(){return this.props}getVariant(e){return this.props.variants?this.props.variants[e]:void 0}getDefaultTransition(){return this.props.transition}getTransformPagePoint(){return this.props.transformPagePoint}getClosestVariantNode(){return this.isVariantNode?this:this.parent?this.parent.getClosestVariantNode():void 0}addVariantChild(e){let t=this.getClosestVariantNode();if(t)return t.variantChildren&&t.variantChildren.add(e),()=>t.variantChildren.delete(e)}addValue(e,t){let n=this.values.get(e);t!==n&&(n&&this.removeValue(e),this.bindToMotionValue(e,t),this.values.set(e,t),this.latestValues[e]=t.get())}removeValue(e){this.values.delete(e);let t=this.valueSubscriptions.get(e);t&&(t(),this.valueSubscriptions.delete(e)),delete this.latestValues[e],this.removeValueFromRenderState(e,this.renderState)}hasValue(e){return this.values.has(e)}getValue(e,t){if(this.props.values&&this.props.values[e])return this.props.values[e];let n=this.values.get(e);return n===void 0&&t!==void 0&&(n=Lr(t===null?void 0:t,{owner:this}),this.addValue(e,n)),n}readValue(e,t){let n=this.latestValues[e]!==void 0||!this.current?this.latestValues[e]:this.getBaseTargetFromProps(this.props,e)??this.readValueFromInstance(this.current,e,this.options);return n!=null&&(typeof n==`string`&&(j(n)||te(n))?n=parseFloat(n):!Ta(n)&&kt.test(t)&&(n=Mi(e,t)),this.setBaseTarget(e,ai(n)?n.get():n)),ai(n)?n.get():n}setBaseTarget(e,t){this.baseTarget[e]=t}getBaseTarget(e){let{initial:t}=this.props,n;if(typeof t==`string`||typeof t==`object`){let r=Qr(this.props,t,this.presenceContext?.custom);r&&(n=r[e])}if(t&&n!==void 0)return n;let r=this.getBaseTargetFromProps(this.props,e);return r!==void 0&&!ai(r)?r:this.initialValues[e]!==void 0&&n===void 0?void 0:this.baseTarget[e]}on(e,t){return this.events[e]||(this.events[e]=new ie),this.events[e].add(t)}notify(e,...t){this.events[e]&&this.events[e].notify(...t)}scheduleRenderMicrotask(){Bi.render(this.render)}},qa=class extends Ka{constructor(){super(...arguments),this.KeyframeResolver=Fi}sortInstanceNodePosition(e,t){return e.compareDocumentPosition(t)&2?1:-1}getBaseTargetFromProps(e,t){let n=e.style;return n?n[t]:void 0}removeValueFromRenderState(e,{vars:t,style:n}){delete t[e],delete n[e]}handleChildMotionValue(){this.childSubscription&&(this.childSubscription(),delete this.childSubscription);let{children:e}=this.props;ai(e)&&(this.childSubscription=e.on(`change`,e=>{this.current&&(this.current.textContent=`${e}`)}))}},Ja=class{constructor(e){this.isMounted=!1,this.node=e}update(){}};function Ya({top:e,left:t,right:n,bottom:r}){return{x:{min:t,max:n},y:{min:e,max:r}}}function Xa({x:e,y:t}){return{top:t.min,right:e.max,bottom:t.max,left:e.min}}function Za(e,t){if(!t)return e;let n=t({x:e.left,y:e.top}),r=t({x:e.right,y:e.bottom});return{top:n.y,left:n.x,bottom:r.y,right:r.x}}function Qa(e){return e===void 0||e===1}function $a({scale:e,scaleX:t,scaleY:n}){return!Qa(e)||!Qa(t)||!Qa(n)}function eo(e){return $a(e)||to(e)||e.z||e.rotate||e.rotateX||e.rotateY||e.skewX||e.skewY}function to(e){return no(e.x)||no(e.y)}function no(e){return e&&e!==`0%`}function ro(e,t,n){return n+t*(e-n)}function io(e,t,n,r,i){return i!==void 0&&(e=ro(e,i,r)),ro(e,n,r)+t}function ao(e,t=0,n=1,r,i){e.min=io(e.min,t,n,r,i),e.max=io(e.max,t,n,r,i)}function oo(e,{x:t,y:n}){ao(e.x,t.translate,t.scale,t.originPoint),ao(e.y,n.translate,n.scale,n.originPoint)}var so=.999999999999,co=1.0000000000001;function lo(e,t,n,r=!1){let i=n.length;if(!i)return;t.x=t.y=1;let a,o;for(let s=0;s<i;s++){a=n[s],o=a.projectionDelta;let{visualElement:i}=a.options;i&&i.props.style&&i.props.style.display===`contents`||(r&&a.options.layoutScroll&&a.scroll&&a!==a.root&&(uo(e.x,-a.scroll.offset.x),uo(e.y,-a.scroll.offset.y)),o&&(t.x*=o.x.scale,t.y*=o.y.scale,oo(e,o)),r&&eo(a.latestValues)&&mo(e,a.latestValues,a.layout?.layoutBox))}t.x<co&&t.x>so&&(t.x=1),t.y<co&&t.y>so&&(t.y=1)}function uo(e,t){e.min+=t,e.max+=t}function fo(e,t,n,r,i=.5){ao(e,t,n,Nt(e.min,e.max,i),r)}function po(e,t){return typeof e==`string`?parseFloat(e)/100*(t.max-t.min):e}function mo(e,t,n){let r=n??e;fo(e.x,po(t.x,r.x),t.scaleX,t.scale,t.originX),fo(e.y,po(t.y,r.y),t.scaleY,t.scale,t.originY)}function ho(e,t){return Ya(Za(e.getBoundingClientRect(),t))}function go(e,t,n){let r=ho(e,n),{scroll:i}=t;return i&&(uo(r.x,i.offset.x),uo(r.y,i.offset.y)),r}var _o={x:`translateX`,y:`translateY`,z:`translateZ`,transformPerspective:`perspective`},vo=Vn.length;function yo(e,t,n){let r=``,i=!0;for(let a=0;a<vo;a++){let o=Vn[a],s=e[o];if(s===void 0)continue;let c=!0;if(typeof s==`number`)c=s===+!!o.startsWith(`scale`);else{let e=parseFloat(s);c=o.startsWith(`scale`)?e===1:e===0}if(!c||n){let e=Ri(s,Oi[o]);if(!c){i=!1;let t=_o[o]||o;r+=`${t}(${e}) `}n&&(t[o]=e)}}let a=e.pathRotation;return a&&(i=!1,r+=`rotate(${Ri(a,Oi.pathRotation)}) `),r=r.trim(),n?r=n(t,i?``:r):i&&(r=`none`),r}function bo(e,t,n){let{style:r,vars:i,transformOrigin:a}=e,o=!1,s=!1;for(let e in t){let n=t[e];if(Hn.has(e)){o=!0;continue}if(Ve(e)){i[e]=n;continue}{let t=Ri(n,Oi[e]);e.startsWith(`origin`)?(s=!0,a[e]=t):r[e]=t}}if(t.transform||(o||n?r.transform=yo(t,e.transform,n):r.transform&&=`none`),s){let{originX:e=`50%`,originY:t=`50%`,originZ:n=0}=a;r.transformOrigin=`${e} ${t} ${n}`}}function xo(e,{style:t,vars:n},r,i){let a=e.style,o;for(o in t)a[o]=t[o];for(o in i?.applyProjectionStyles(a,r),n)a.setProperty(o,n[o])}function So(e,t){return t.max===t.min?0:e/(t.max-t.min)*100}var Co={correct:(e,t)=>{if(!t.target)return e;if(typeof e==`string`){if(F.test(e))e=parseFloat(e);else return e}return`${So(e,t.target.x)}% ${So(e,t.target.y)}%`}},wo={correct:(e,{treeScale:t,projectionDelta:n})=>{let r=e,i=kt.parse(e);if(i.length>5)return r;let a=kt.createTransformer(e),o=typeof i[0]==`number`?0:1,s=n.x.scale*t.x,c=n.y.scale*t.y;i[0+o]/=s,i[1+o]/=c;let l=Nt(s,c,.5);return typeof i[2+o]==`number`&&(i[2+o]/=l),typeof i[3+o]==`number`&&(i[3+o]/=l),a(i)}},To={borderRadius:{...Co,applyTo:[...Ii]},borderTopLeftRadius:Co,borderTopRightRadius:Co,borderBottomLeftRadius:Co,borderBottomRightRadius:Co,boxShadow:wo};function Eo(e,{layout:t,layoutId:n}){return Hn.has(e)||e.startsWith(`origin`)||(t||n!==void 0)&&(!!To[e]||e===`opacity`)}function Do(e,t,n){let r=e.style,i=t?.style,a={};if(!r)return a;for(let t in r)(ai(r[t])||i&&ai(i[t])||Eo(t,e)||n?.getValue(t)?.liveStyle!==void 0)&&(a[t]=r[t]);return a}function Oo(e){return window.getComputedStyle(e)}var ko=class extends qa{constructor(){super(...arguments),this.type=`html`,this.renderInstance=xo}mount(e){e.style,super.mount(e)}readValueFromInstance(e,t){if(Hn.has(t))return this.projection?.isProjecting?Ln(t):zn(e,t);{let n=Oo(e),r=(Ve(t)?n.getPropertyValue(t):n[t])||0;return typeof r==`string`?r.trim():r}}measureInstanceViewportBox(e,{transformPagePoint:t}){return ho(e,t)}build(e,t,n){bo(e,t,n.transformTemplate)}scrapeMotionValuesFromProps(e,t,n){return Do(e,t,n)}},Ao={offset:`stroke-dashoffset`,array:`stroke-dasharray`},jo={offset:`strokeDashoffset`,array:`strokeDasharray`};function Mo(e,t,n=1,r=0,i=!0){e.pathLength=1;let a=i?Ao:jo;e[a.offset]=`${-r}`,e[a.array]=`${t} ${n}`}var No=[`transform`,`opacity`,`offsetDistance`,`offsetPath`,`offsetRotate`,`offsetAnchor`];function Po(e,{attrX:t,attrY:n,attrScale:r,pathLength:i,pathSpacing:a=1,pathOffset:o=0,...s},c,l,u){if(bo(e,s,l),c){e.style.viewBox&&(e.attrs.viewBox=e.style.viewBox);return}e.attrs=e.style,e.style={};let{attrs:d,style:f}=e;for(let e of No)d[e]!==void 0&&(f[e]=d[e],delete d[e]);(f.transform||d.transformOrigin)&&(f.transformOrigin=d.transformOrigin??`50% 50%`,delete d.transformOrigin),f.transform&&(f.transformBox=u?.transformBox??`fill-box`,delete d.transformBox),t!==void 0&&(d.x=t),n!==void 0&&(d.y=n),r!==void 0&&(d.scale=r),i!==void 0&&Mo(d,i,a,o,!1)}var Fo=new Set([`baseFrequency`,`diffuseConstant`,`kernelMatrix`,`kernelUnitLength`,`keySplines`,`keyTimes`,`limitingConeAngle`,`markerHeight`,`markerWidth`,`numOctaves`,`targetX`,`targetY`,`surfaceScale`,`specularConstant`,`specularExponent`,`stdDeviation`,`tableValues`,`viewBox`,`gradientTransform`,`pathLength`,`startOffset`,`textLength`,`lengthAdjust`]),Io=e=>typeof e==`string`&&e.toLowerCase()===`svg`;function Lo(e,t,n,r){xo(e,t,void 0,r);for(let n in t.attrs)e.setAttribute(Fo.has(n)?n:ci(n),t.attrs[n])}function Ro(e,t,n){let r=Do(e,t,n);for(let n in e)if(ai(e[n])||ai(t[n])){let t=Vn.indexOf(n)===-1?n:`attr`+n.charAt(0).toUpperCase()+n.substring(1);r[t]=e[n]}return r}var zo=class extends qa{constructor(){super(...arguments),this.type=`svg`,this.isSVGTag=!1,this.measureInstanceViewportBox=ka}getBaseTargetFromProps(e,t){return e[t]}readValueFromInstance(e,t){if(Hn.has(t)){let e=Ai(t);return e&&e.default||0}if(No.includes(t)){let n=getComputedStyle(e)[t];if(typeof n==`string`&&n)return n.trim()}return t=Fo.has(t)?t:ci(t),e.getAttribute(t)}scrapeMotionValuesFromProps(e,t,n){return Ro(e,t,n)}build(e,t,n){Po(e,t,this.isSVGTag,n.transformTemplate,n.style)}renderInstance(e,t,n,r){Lo(e,t,n,r)}mount(e){this.isSVGTag=Io(e.tagName),super.mount(e)}},Bo=Pa.length;function Vo(e){if(!e)return;if(!e.isControllingVariants){let t=e.parent&&Vo(e.parent)||{};return e.props.initial!==void 0&&(t.initial=e.props.initial),t}let t={};for(let n=0;n<Bo;n++){let r=Pa[n],i=e.props[r];(Ma(i)||i===!1)&&(t[r]=i)}return t}function Ho(e,t){if(!Array.isArray(t))return!1;let n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}var Uo=[...Na].reverse(),Wo=Na.length;function Go(e){return t=>Promise.all(t.map(({animation:t,options:n})=>gi(e,t,n)))}function Ko(e){let t=Go(e),n=Yo(),r=!0,i=!1,a=t=>(n,r)=>{let i=$r(e,r,t===`exit`?e.presenceContext?.custom:void 0);if(i){let{transition:e,transitionEnd:t,...r}=i;n={...n,...r,...t}}return n};function o(n){t=n(e)}function s(o){let{props:s}=e,c=Vo(e.parent)||{},l=[],u=new Set,d={},f=1/0;for(let t=0;t<Wo;t++){let p=Uo[t],m=n[p],h=s[p]===void 0?c[p]:s[p],g=Ma(h),_=p===o?m.isActive:null;_===!1&&(f=t);let v=h===c[p]&&h!==s[p]&&g;if(v&&(r||i)&&e.manuallyAnimateOnMount&&(v=!1),m.protectedKeys={...d},!m.isActive&&_===null||!h&&!m.prevProp||ja(h)||typeof h==`boolean`)continue;if(p===`exit`&&m.isActive&&_!==!0){m.prevResolvedValues&&(d={...d,...m.prevResolvedValues});continue}let y=qo(m.prevProp,h),b=y||p===o&&m.isActive&&!v&&g||t>f&&g,x=!1,S=Array.isArray(h)?h:[h],C=S.reduce(a(p),{});_===!1&&(C={});let{prevResolvedValues:w={}}=m,T={...w,...C},E=t=>{b=!0,u.has(t)&&(x=!0,u.delete(t)),m.needsAnimating[t]=!0;let n=e.getValue(t);n&&(n.liveStyle=!1)};for(let e in T){let t=C[e],n=w[e];if(d.hasOwnProperty(e))continue;let r=!1;r=ti(t)&&ti(n)?!Ho(t,n)||y:t!==n,r?t==null?u.add(e):E(e):t!==void 0&&u.has(e)?E(e):m.protectedKeys[e]=!0}m.prevProp=h,m.prevResolvedValues=C,m.isActive&&(d={...d,...C}),(r||i)&&e.blockInitialAnimation&&(b=!1);let D=v&&y;b&&(!D||x)&&l.push(...S.map(t=>{let n={type:p};if(typeof t==`string`&&(r||i)&&!D&&e.manuallyAnimateOnMount&&e.parent){let{parent:r}=e,i=$r(r,t);if(r.enteringChildren&&i){let{delayChildren:t}=i.transition||{};n.delay=Mr(r.enteringChildren,e,t)}}return{animation:t,options:n}}))}if(u.size){let t={};if(typeof s.initial!=`boolean`){let n=$r(e,Array.isArray(s.initial)?s.initial[0]:s.initial);n&&n.transition&&(t.transition=n.transition)}u.forEach(n=>{let r=e.getBaseTarget(n),i=e.getValue(n);i&&(i.liveStyle=!0),t[n]=r??null}),l.push({animation:t})}let p=!!l.length;return r&&(s.initial===!1||s.initial===s.animate)&&!e.manuallyAnimateOnMount&&(p=!1),r=!1,i=!1,p?t(l):Promise.resolve()}function c(t,r){if(n[t].isActive===r)return Promise.resolve();e.variantChildren?.forEach(e=>e.animationState?.setActive(t,r)),n[t].isActive=r;let i=s(t);for(let e in n)n[e].protectedKeys={};return i}return{animateChanges:s,setActive:c,setAnimateFunction:o,getState:()=>n,reset:()=>{n=Yo(),i=!0}}}function qo(e,t){return typeof t==`string`?t!==e:Array.isArray(t)?!Ho(t,e):!1}function Jo(e=!1){return{isActive:e,protectedKeys:{},needsAnimating:{},prevResolvedValues:{}}}function Yo(){return{animate:Jo(!0),whileInView:Jo(),whileHover:Jo(),whileTap:Jo(),whileDrag:Jo(),whileFocus:Jo(),exit:Jo()}}function Xo(e,t){e.min=t.min,e.max=t.max}function Zo(e,t){Xo(e.x,t.x),Xo(e.y,t.y)}function Qo(e,t){e.translate=t.translate,e.scale=t.scale,e.originPoint=t.originPoint,e.origin=t.origin}var $o=.9999,es=1.0001,ts=-.01,ns=.01;function rs(e){return e.max-e.min}function is(e,t,n){return Math.abs(e-t)<=n}function as(e,t,n,r=.5){e.origin=r,e.originPoint=Nt(t.min,t.max,e.origin),e.scale=rs(n)/rs(t),e.translate=Nt(n.min,n.max,e.origin)-e.originPoint,(e.scale>=$o&&e.scale<=es||isNaN(e.scale))&&(e.scale=1),(e.translate>=ts&&e.translate<=ns||isNaN(e.translate))&&(e.translate=0)}function os(e,t,n,r){as(e.x,t.x,n.x,r?r.originX:void 0),as(e.y,t.y,n.y,r?r.originY:void 0)}function ss(e,t,n,r=0){e.min=(r?Nt(n.min,n.max,r):n.min)+t.min,e.max=e.min+rs(t)}function cs(e,t,n,r){ss(e.x,t.x,n.x,r?.x),ss(e.y,t.y,n.y,r?.y)}function ls(e,t,n,r=0){let i=r?Nt(n.min,n.max,r):n.min;e.min=t.min-i,e.max=e.min+rs(t)}function us(e,t,n,r){ls(e.x,t.x,n.x,r?.x),ls(e.y,t.y,n.y,r?.y)}function ds(e,t,n,r,i){return e-=t,e=ro(e,1/n,r),i!==void 0&&(e=ro(e,1/i,r)),e}function fs(e,t=0,n=1,r=.5,i,a=e,o=e){if(ct.test(t)&&(t=parseFloat(t),t=Nt(o.min,o.max,t/100)-o.min),typeof t!=`number`)return;let s=Nt(a.min,a.max,r);e===a&&(s-=t),e.min=ds(e.min,t,n,s,i),e.max=ds(e.max,t,n,s,i)}function ps(e,t,[n,r,i],a,o){fs(e,t[n],t[r],t[i],t.scale,a,o)}var ms=[`x`,`scaleX`,`originX`],hs=[`y`,`scaleY`,`originY`];function gs(e,t,n,r){ps(e.x,t,ms,n?n.x:void 0,r?r.x:void 0),ps(e.y,t,hs,n?n.y:void 0,r?r.y:void 0)}function _s(e){return e.translate===0&&e.scale===1}function vs(e){return _s(e.x)&&_s(e.y)}function ys(e,t){return e.min===t.min&&e.max===t.max}function bs(e,t){return ys(e.x,t.x)&&ys(e.y,t.y)}function xs(e,t){return Math.round(e.min)===Math.round(t.min)&&Math.round(e.max)===Math.round(t.max)}function Ss(e,t){return xs(e.x,t.x)&&xs(e.y,t.y)}function Cs(e){return rs(e.x)/rs(e.y)}function ws(e,t){return e.translate===t.translate&&e.scale===t.scale&&e.originPoint===t.originPoint}function Ts(e){return[e(`x`),e(`y`)]}function Es(e,t,n){let r=``,i=e.x.translate/t.x,a=e.y.translate/t.y,o=n?.z||0;if((i||a||o)&&(r=`translate3d(${i}px, ${a}px, ${o}px) `),(t.x!==1||t.y!==1)&&(r+=`scale(${1/t.x}, ${1/t.y}) `),n){let{transformPerspective:e,rotate:t,pathRotation:i,rotateX:a,rotateY:o,skewX:s,skewY:c}=n;e&&(r=`perspective(${e}px) ${r}`),t&&(r+=`rotate(${t}deg) `),i&&(r+=`rotate(${i}deg) `),a&&(r+=`rotateX(${a}deg) `),o&&(r+=`rotateY(${o}deg) `),s&&(r+=`skewX(${s}deg) `),c&&(r+=`skewY(${c}deg) `)}let s=e.x.scale*t.x,c=e.y.scale*t.y;return(s!==1||c!==1)&&(r+=`scale(${s}, ${c})`),r||`none`}var Ds=Ii.length,Os=e=>typeof e==`string`?parseFloat(e):e,ks=e=>typeof e==`number`||F.test(e);function As(e,t,n,r,i,a){i?(e.opacity=Nt(0,n.opacity??1,Ms(r)),e.opacityExit=Nt(t.opacity??1,0,Ns(r))):a&&(e.opacity=Nt(t.opacity??1,n.opacity??1,r));for(let i=0;i<Ds;i++){let a=Ii[i],o=js(t,a),s=js(n,a);(o!==void 0||s!==void 0)&&(o||=0,s||=0,o===0||s===0||ks(o)===ks(s)?(e[a]=Math.max(Nt(Os(o),Os(s),r),0),(ct.test(s)||ct.test(o))&&(e[a]+=`%`)):e[a]=s)}(t.rotate||n.rotate)&&(e.rotate=Nt(t.rotate||0,n.rotate||0,r))}function js(e,t){return e[t]===void 0?e.borderRadius:e[t]}var Ms=Ps(0,.5,ye),Ns=Ps(.5,.95,re);function Ps(e,t,n){return r=>r<e?0:r>t?1:n(N(e,t,r))}function Fs(e,t,n){let r=ai(e)?e:Lr(e);return r.start(qr(``,r,t,n)),r.animation}function Is(e,t,n,r={passive:!0}){return e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)}var Ls=(e,t)=>e.depth-t.depth,Rs=class{constructor(){this.children=[],this.isDirty=!1}add(e){D(this.children,e),this.isDirty=!0}remove(e){O(this.children,e),this.isDirty=!0}forEach(e){this.isDirty&&this.children.sort(Ls),this.isDirty=!1,this.children.forEach(e)}};function zs(e,t){let n=ze.now(),r=({timestamp:i})=>{let a=i-n;a>=t&&(Pe(r),e(a-t))};return Ne.setup(r,!0),()=>Pe(r)}function Bs(e){return ai(e)?e.get():e}var Vs=class{constructor(){this.members=[]}add(e){D(this.members,e);for(let t=this.members.length-1;t>=0;t--){let n=this.members[t];if(n===e||n===this.lead||n===this.prevLead)continue;let r=n.instance;(!r||r.isConnected===!1)&&!n.snapshot&&(O(this.members,n),n.unmount())}e.scheduleRender()}remove(e){if(O(this.members,e),e===this.prevLead&&(this.prevLead=void 0),e===this.lead){let e=this.members[this.members.length-1];e&&this.promote(e)}}relegate(e){for(let t=this.members.indexOf(e)-1;t>=0;t--){let e=this.members[t];if(e.isPresent!==!1&&e.instance?.isConnected!==!1)return this.promote(e),!0}return!1}promote(e,t){let n=this.lead;if(e!==n&&(this.prevLead=n,this.lead=e,e.show(),n)){n.updateSnapshot(),e.scheduleRender();let{layoutDependency:r}=n.options,{layoutDependency:i}=e.options;(r===void 0||r!==i)&&(e.resumeFrom=n,t&&(n.preserveOpacity=!0),n.snapshot&&(e.snapshot=n.snapshot,e.snapshot.latestValues=n.animationValues||n.latestValues),e.root?.isUpdating&&(e.isLayoutDirty=!0)),e.options.crossfade===!1&&n.hide()}}exitAnimationComplete(){this.members.forEach(e=>{e.options.onExitComplete?.(),e.resumingFrom?.options.onExitComplete?.()})}scheduleRender(){this.members.forEach(e=>e.instance&&e.scheduleRender(!1))}removeLeadSnapshot(){this.lead?.snapshot&&(this.lead.snapshot=void 0)}},Hs={hasAnimatedSinceResize:!0,hasEverUpdated:!1},Us={nodes:0,calculatedTargetDeltas:0,calculatedProjections:0},Ws=[``,`X`,`Y`,`Z`],Gs=1e3,Ks=0;function qs(e,t,n,r){let{latestValues:i}=t;i[e]&&(n[e]=i[e],t.setStaticValue(e,0),r&&(r[e]=0))}function Js(e){if(e.hasCheckedOptimisedAppear=!0,e.root===e)return;let{visualElement:t}=e.options;if(!t)return;let n=ui(t);if(window.MotionHasOptimisedAnimation(n,`transform`)){let{layout:t,layoutId:r}=e.options;window.MotionCancelOptimisedAnimation(n,`transform`,Ne,!(t||r))}let{parent:r}=e;r&&!r.hasCheckedOptimisedAppear&&Js(r)}function Ys({attachResizeListener:e,defaultParent:t,measureScroll:n,checkIsScrollRoot:r,resetTransform:i}){return class{constructor(e={},n=t?.()){this.id=Ks++,this.animationId=0,this.animationCommitId=0,this.children=new Set,this.options={},this.isTreeAnimating=!1,this.isAnimationBlocked=!1,this.isLayoutDirty=!1,this.isProjectionDirty=!1,this.isSharedProjectionDirty=!1,this.isTransformDirty=!1,this.updateManuallyBlocked=!1,this.updateBlockedByResize=!1,this.isUpdating=!1,this.isSVG=!1,this.needsReset=!1,this.shouldResetTransform=!1,this.hasCheckedOptimisedAppear=!1,this.treeScale={x:1,y:1},this.eventHandlers=new Map,this.hasTreeAnimated=!1,this.layoutVersion=0,this.updateScheduled=!1,this.scheduleUpdate=()=>this.update(),this.projectionUpdateScheduled=!1,this.checkUpdateFailed=()=>{this.isUpdating&&(this.isUpdating=!1,this.clearAllSnapshots())},this.updateProjection=()=>{this.projectionUpdateScheduled=!1,Sa.value&&(Us.nodes=Us.calculatedTargetDeltas=Us.calculatedProjections=0),this.nodes.forEach(Qs),this.nodes.forEach(sc),this.nodes.forEach(cc),this.nodes.forEach($s),Sa.addProjectionMetrics&&Sa.addProjectionMetrics(Us)},this.resolvedRelativeTargetAt=0,this.linkedParentVersion=0,this.hasProjected=!1,this.isVisible=!0,this.animationProgress=0,this.sharedNodes=new Map,this.latestValues=e,this.root=n?n.root||n:this,this.path=n?[...n.path,n]:[],this.parent=n,this.depth=n?n.depth+1:0;for(let e=0;e<this.path.length;e++)this.path[e].shouldResetTransform=!0;this.root===this&&(this.nodes=new Rs)}addEventListener(e,t){return this.eventHandlers.has(e)||this.eventHandlers.set(e,new ie),this.eventHandlers.get(e).add(t)}notifyListeners(e,...t){let n=this.eventHandlers.get(e);n&&n.notify(...t)}hasListeners(e){return this.eventHandlers.has(e)}mount(t){if(this.instance)return;this.isSVG=sa(t)&&!Ca(t),this.instance=t;let{layoutId:n,layout:r,visualElement:i}=this.options;if(i&&!i.current&&i.mount(t),this.root.nodes.add(this),this.parent&&this.parent.children.add(this),this.root.hasTreeAnimated&&(r||n)&&(this.isLayoutDirty=!0),e){let n,r=0,i=()=>this.root.updateBlockedByResize=!1;Ne.read(()=>{r=window.innerWidth}),e(t,()=>{let e=window.innerWidth;e!==r&&(r=e,this.root.updateBlockedByResize=!0,n&&n(),n=zs(i,250),Hs.hasAnimatedSinceResize&&(Hs.hasAnimatedSinceResize=!1,this.nodes.forEach(oc)))})}n&&this.root.registerSharedNode(n,this),this.options.animate!==!1&&i&&(n||r)&&this.addEventListener(`didUpdate`,({delta:e,hasLayoutChanged:t,hasRelativeLayoutChanged:n,layout:r})=>{if(this.isTreeAnimationBlocked()){this.target=void 0,this.relativeTarget=void 0;return}let a=this.options.transition||i.getDefaultTransition()||hc,{onLayoutAnimationStart:o,onLayoutAnimationComplete:s}=i.getProps(),c=!this.targetLayout||!Ss(this.targetLayout,r),l=!t&&n;if(this.options.layoutRoot||this.resumeFrom||l||t&&(c||!this.currentAnimation)){this.resumeFrom&&(this.resumingFrom=this.resumeFrom,this.resumingFrom.resumingFrom=void 0);let t={...zr(a,`layout`),onPlay:o,onComplete:s};(i.shouldReduceMotion||this.options.layoutRoot)&&(t.delay=0,t.type=!1),this.startAnimation(t),this.setAnimationOrigin(e,l,t.path)}else t||oc(this),this.isLead()&&this.options.onExitComplete&&this.options.onExitComplete();this.targetLayout=r})}unmount(){this.options.layoutId&&this.willUpdate(),this.root.nodes.remove(this);let e=this.getStack();e&&e.remove(this),this.parent&&this.parent.children.delete(this),this.instance=void 0,this.eventHandlers.clear(),Pe(this.updateProjection)}blockUpdate(){this.updateManuallyBlocked=!0}unblockUpdate(){this.updateManuallyBlocked=!1}isUpdateBlocked(){return this.updateManuallyBlocked||this.updateBlockedByResize}isTreeAnimationBlocked(){return this.isAnimationBlocked||this.parent&&this.parent.isTreeAnimationBlocked()||!1}startUpdate(){this.isUpdateBlocked()||(this.isUpdating=!0,this.nodes&&this.nodes.forEach(lc),this.animationId++)}getTransformTemplate(){let{visualElement:e}=this.options;return e&&e.getProps().transformTemplate}willUpdate(e=!0){if(this.root.hasTreeAnimated=!0,this.root.isUpdateBlocked()){this.options.onExitComplete&&this.options.onExitComplete();return}if(window.MotionCancelOptimisedAnimation&&!this.hasCheckedOptimisedAppear&&Js(this),!this.root.isUpdating&&this.root.startUpdate(),this.isLayoutDirty)return;this.isLayoutDirty=!0;for(let e=0;e<this.path.length;e++){let t=this.path[e];t.shouldResetTransform=!0,(typeof t.latestValues.x==`string`||typeof t.latestValues.y==`string`)&&(t.isLayoutDirty=!0),t.updateScroll(`snapshot`),t.options.layoutRoot&&t.willUpdate(!1)}let{layoutId:t,layout:n}=this.options;if(t===void 0&&!n)return;let r=this.getTransformTemplate();this.prevTransformTemplateValue=r?r(this.latestValues,``):void 0,this.updateSnapshot(),e&&this.notifyListeners(`willUpdate`)}update(){if(this.updateScheduled=!1,this.isUpdateBlocked()){let e=this.updateBlockedByResize;this.unblockUpdate(),this.updateBlockedByResize=!1,this.clearAllSnapshots(),e&&this.nodes.forEach(nc),this.nodes.forEach(tc);return}if(this.animationId<=this.animationCommitId){this.nodes.forEach(rc);return}this.animationCommitId=this.animationId,this.isUpdating?(this.isUpdating=!1,this.nodes.forEach(ic),this.nodes.forEach(ac),this.nodes.forEach(Xs),this.nodes.forEach(Zs)):this.nodes.forEach(rc),this.clearAllSnapshots();let e=ze.now();Fe.delta=k(0,1e3/60,e-Fe.timestamp),Fe.timestamp=e,Fe.isProcessing=!0,Ie.update.process(Fe),Ie.preRender.process(Fe),Ie.render.process(Fe),Fe.isProcessing=!1}didUpdate(){this.updateScheduled||(this.updateScheduled=!0,Bi.read(this.scheduleUpdate))}clearAllSnapshots(){this.nodes.forEach(ec),this.sharedNodes.forEach(uc)}scheduleUpdateProjection(){this.projectionUpdateScheduled||(this.projectionUpdateScheduled=!0,Ne.preRender(this.updateProjection,!1,!0))}scheduleCheckAfterUnmount(){Ne.postRender(()=>{this.isLayoutDirty?this.root.didUpdate():this.root.checkUpdateFailed()})}updateSnapshot(){!this.snapshot&&this.instance&&(this.snapshot=this.measure(),this.snapshot&&!rs(this.snapshot.measuredBox.x)&&!rs(this.snapshot.measuredBox.y)&&(this.snapshot=void 0))}updateLayout(){if(!this.instance||(this.updateScroll(),!(this.options.alwaysMeasureLayout&&this.isLead())&&!this.isLayoutDirty))return;if(this.resumeFrom&&!this.resumeFrom.instance)for(let e=0;e<this.path.length;e++)this.path[e].updateScroll();let e=this.layout;this.layout=this.measure(!1),this.layoutVersion++,this.layoutCorrected||=ka(),this.isLayoutDirty=!1,this.projectionDelta=void 0,this.notifyListeners(`measure`,this.layout.layoutBox);let{visualElement:t}=this.options;t&&t.notify(`LayoutMeasure`,this.layout.layoutBox,e?e.layoutBox:void 0)}updateScroll(e=`measure`){let t=!!(this.options.layoutScroll&&this.instance);if(this.scroll&&this.scroll.animationId===this.root.animationId&&this.scroll.phase===e&&(t=!1),t&&this.instance){let t=r(this.instance);this.scroll={animationId:this.root.animationId,phase:e,isRoot:t,offset:n(this.instance),wasRoot:this.scroll?this.scroll.isRoot:t}}}resetTransform(){if(!i)return;let e=this.isLayoutDirty||this.shouldResetTransform||this.options.alwaysMeasureLayout,t=this.projectionDelta&&!vs(this.projectionDelta),n=this.getTransformTemplate(),r=n?n(this.latestValues,``):void 0,a=r!==this.prevTransformTemplateValue;e&&this.instance&&(t||eo(this.latestValues)||a)&&(i(this.instance,r),this.shouldResetTransform=!1,this.scheduleRender())}measure(e=!0){let t=this.measurePageBox(),n=this.removeElementScroll(t);return e&&(n=this.removeTransform(n)),yc(n),{animationId:this.root.animationId,measuredBox:t,layoutBox:n,latestValues:{},source:this.id}}measurePageBox(){let{visualElement:e}=this.options;if(!e)return ka();let t=e.measureViewportBox();if(!(this.scroll?.wasRoot||this.path.some(xc))){let{scroll:e}=this.root;e&&(uo(t.x,e.offset.x),uo(t.y,e.offset.y))}return t}removeElementScroll(e){let t=ka();if(Zo(t,e),this.scroll?.wasRoot)return t;for(let n=0;n<this.path.length;n++){let r=this.path[n],{scroll:i,options:a}=r;r!==this.root&&i&&a.layoutScroll&&(i.wasRoot&&Zo(t,e),uo(t.x,i.offset.x),uo(t.y,i.offset.y))}return t}applyTransform(e,t=!1,n){let r=n||ka();Zo(r,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];!t&&n.options.layoutScroll&&n.scroll&&n!==n.root&&(uo(r.x,-n.scroll.offset.x),uo(r.y,-n.scroll.offset.y)),eo(n.latestValues)&&mo(r,n.latestValues,n.layout?.layoutBox)}return eo(this.latestValues)&&mo(r,this.latestValues,this.layout?.layoutBox),r}removeTransform(e){let t=ka();Zo(t,e);for(let e=0;e<this.path.length;e++){let n=this.path[e];if(!eo(n.latestValues))continue;let r;n.instance&&($a(n.latestValues)&&n.updateSnapshot(),r=ka(),Zo(r,n.measurePageBox())),gs(t,n.latestValues,n.snapshot?.layoutBox,r)}return eo(this.latestValues)&&gs(t,this.latestValues),t}setTargetDelta(e){this.targetDelta=e,this.root.scheduleUpdateProjection(),this.isProjectionDirty=!0}setOptions(e){this.options={...this.options,...e,crossfade:e.crossfade===void 0||e.crossfade}}clearMeasurements(){this.scroll=void 0,this.layout=void 0,this.snapshot=void 0,this.prevTransformTemplateValue=void 0,this.targetDelta=void 0,this.target=void 0,this.isLayoutDirty=!1}forceRelativeParentToResolveTarget(){this.relativeParent&&this.relativeParent.resolvedRelativeTargetAt!==Fe.timestamp&&this.relativeParent.resolveTargetDelta(!0)}resolveTargetDelta(e=!1){let t=this.getLead();this.isProjectionDirty||=t.isProjectionDirty,this.isTransformDirty||=t.isTransformDirty,this.isSharedProjectionDirty||=t.isSharedProjectionDirty;let n=!!this.resumingFrom||this!==t;if(!(e||n&&this.isSharedProjectionDirty||this.isProjectionDirty||this.parent?.isProjectionDirty||this.attemptToResolveRelativeTarget||this.root.updateBlockedByResize))return;let{layout:r,layoutId:i}=this.options;if(!this.layout||!(r||i))return;this.resolvedRelativeTargetAt=Fe.timestamp;let a=this.getClosestProjectingParent();a&&this.linkedParentVersion!==a.layoutVersion&&!a.options.layoutRoot&&this.removeRelativeTarget(),!this.targetDelta&&!this.relativeTarget&&(this.options.layoutAnchor!==!1&&a&&a.layout?this.createRelativeTarget(a,this.layout.layoutBox,a.layout.layoutBox):this.removeRelativeTarget()),(this.relativeTarget||this.targetDelta)&&(this.target||(this.target=ka(),this.targetWithTransforms=ka()),this.relativeTarget&&this.relativeTargetOrigin&&this.relativeParent&&this.relativeParent.target?(this.forceRelativeParentToResolveTarget(),cs(this.target,this.relativeTarget,this.relativeParent.target,this.options.layoutAnchor||void 0)):this.targetDelta?(this.resumingFrom?this.applyTransform(this.layout.layoutBox,!1,this.target):Zo(this.target,this.layout.layoutBox),oo(this.target,this.targetDelta)):Zo(this.target,this.layout.layoutBox),this.attemptToResolveRelativeTarget&&(this.attemptToResolveRelativeTarget=!1,this.options.layoutAnchor!==!1&&a&&!!a.resumingFrom==!!this.resumingFrom&&!a.options.layoutScroll&&a.target&&this.animationProgress!==1?this.createRelativeTarget(a,this.target,a.target):this.relativeParent=this.relativeTarget=void 0),Sa.value&&Us.calculatedTargetDeltas++)}getClosestProjectingParent(){if(!(!this.parent||$a(this.parent.latestValues)||to(this.parent.latestValues)))return this.parent.isProjecting()?this.parent:this.parent.getClosestProjectingParent()}isProjecting(){return!!((this.relativeTarget||this.targetDelta||this.options.layoutRoot)&&this.layout)}createRelativeTarget(e,t,n){this.relativeParent=e,this.linkedParentVersion=e.layoutVersion,this.forceRelativeParentToResolveTarget(),this.relativeTarget=ka(),this.relativeTargetOrigin=ka(),us(this.relativeTargetOrigin,t,n,this.options.layoutAnchor||void 0),Zo(this.relativeTarget,this.relativeTargetOrigin)}removeRelativeTarget(){this.relativeParent=this.relativeTarget=void 0}calcProjection(){let e=this.getLead(),t=!!this.resumingFrom||this!==e,n=!0;if((this.isProjectionDirty||this.parent?.isProjectionDirty)&&(n=!1),t&&(this.isSharedProjectionDirty||this.isTransformDirty)&&(n=!1),this.resolvedRelativeTargetAt===Fe.timestamp&&(n=!1),n)return;let{layout:r,layoutId:i}=this.options;if(this.isTreeAnimating=!!(this.parent&&this.parent.isTreeAnimating||this.currentAnimation||this.pendingAnimation),this.isTreeAnimating||(this.targetDelta=this.relativeTarget=void 0),!this.layout||!(r||i))return;Zo(this.layoutCorrected,this.layout.layoutBox);let a=this.treeScale.x,o=this.treeScale.y;lo(this.layoutCorrected,this.treeScale,this.path,t),e.layout&&!e.target&&(this.treeScale.x!==1||this.treeScale.y!==1)&&(e.target=e.layout.layoutBox,e.targetWithTransforms=ka());let{target:s}=e;if(!s){this.prevProjectionDelta&&(this.createProjectionDeltas(),this.scheduleRender());return}!this.projectionDelta||!this.prevProjectionDelta?this.createProjectionDeltas():(Qo(this.prevProjectionDelta.x,this.projectionDelta.x),Qo(this.prevProjectionDelta.y,this.projectionDelta.y)),os(this.projectionDelta,this.layoutCorrected,s,this.latestValues),(this.treeScale.x!==a||this.treeScale.y!==o||!ws(this.projectionDelta.x,this.prevProjectionDelta.x)||!ws(this.projectionDelta.y,this.prevProjectionDelta.y))&&(this.hasProjected=!0,this.scheduleRender(),this.notifyListeners(`projectionUpdate`,s)),Sa.value&&Us.calculatedProjections++}hide(){this.isVisible=!1}show(){this.isVisible=!0}scheduleRender(e=!0){if(this.options.visualElement?.scheduleRender(),e){let e=this.getStack();e&&e.scheduleRender()}this.resumingFrom&&!this.resumingFrom.instance&&(this.resumingFrom=void 0)}createProjectionDeltas(){this.prevProjectionDelta=Da(),this.projectionDelta=Da(),this.projectionDeltaWithTransform=Da()}setAnimationOrigin(e,t=!1,n){let r=this.snapshot,i=r?r.latestValues:{},a={...this.latestValues},o=Da();(!this.relativeParent||!this.relativeParent.options.layoutRoot)&&(this.relativeTarget=this.relativeTargetOrigin=void 0),this.attemptToResolveRelativeTarget=!t;let s=ka(),c=(r?r.source:void 0)!==(this.layout?this.layout.source:void 0),l=this.getStack(),u=!l||l.members.length<=1,d=!(!c||u||this.options.crossfade!==!0||this.path.some(mc));this.animationProgress=0;let f,p=n?.interpolateProjection(e);this.mixTargetDelta=t=>{let n=t/1e3,r=p?.(n);r?(o.x.translate=r.x,o.x.scale=Nt(e.x.scale,1,n),o.x.origin=e.x.origin,o.x.originPoint=e.x.originPoint,o.y.translate=r.y,o.y.scale=Nt(e.y.scale,1,n),o.y.origin=e.y.origin,o.y.originPoint=e.y.originPoint):(dc(o.x,e.x,n),dc(o.y,e.y,n)),this.setTargetDelta(o),this.relativeTarget&&this.relativeTargetOrigin&&this.layout&&this.relativeParent&&this.relativeParent.layout&&(us(s,this.layout.layoutBox,this.relativeParent.layout.layoutBox,this.options.layoutAnchor||void 0),pc(this.relativeTarget,this.relativeTargetOrigin,s,n),f&&bs(this.relativeTarget,f)&&(this.isProjectionDirty=!1),f||=ka(),Zo(f,this.relativeTarget)),c&&(this.animationValues=a,As(a,i,this.latestValues,n,d,u)),r&&r.rotate!==void 0&&(this.animationValues||=a,this.animationValues.pathRotation=r.rotate),this.root.scheduleUpdateProjection(),this.scheduleRender(),this.animationProgress=n},this.mixTargetDelta(this.options.layoutRoot?1e3:0)}startAnimation(e){this.notifyListeners(`animationStart`),this.currentAnimation?.stop(),this.resumingFrom?.currentAnimation?.stop(),this.pendingAnimation&&=(Pe(this.pendingAnimation),void 0),this.pendingAnimation=Ne.update(()=>{Hs.hasAnimatedSinceResize=!0,this.motionValue||=Lr(0),this.motionValue.jump(0,!1),this.currentAnimation=Fs(this.motionValue,[0,1e3],{...e,velocity:0,isSync:!0,onUpdate:t=>{this.mixTargetDelta(t),e.onUpdate&&e.onUpdate(t)},onComplete:()=>{e.onComplete&&e.onComplete(),this.completeAnimation()}}),this.resumingFrom&&(this.resumingFrom.currentAnimation=this.currentAnimation),this.pendingAnimation=void 0})}completeAnimation(){this.resumingFrom&&(this.resumingFrom.currentAnimation=void 0,this.resumingFrom.preserveOpacity=void 0);let e=this.getStack();e&&e.exitAnimationComplete(),this.resumingFrom=this.currentAnimation=this.animationValues=void 0,this.notifyListeners(`animationComplete`)}finishAnimation(){this.currentAnimation&&(this.mixTargetDelta&&this.mixTargetDelta(Gs),this.currentAnimation.stop()),this.completeAnimation()}applyTransformsToTarget(){let e=this.getLead(),{targetWithTransforms:t,target:n,layout:r,latestValues:i}=e;if(t&&n&&r){if(this!==e&&this.layout&&r&&bc(this.options.animationType,this.layout.layoutBox,r.layoutBox)){n=this.target||ka();let t=rs(this.layout.layoutBox.x);n.x.min=e.target.x.min,n.x.max=n.x.min+t;let r=rs(this.layout.layoutBox.y);n.y.min=e.target.y.min,n.y.max=n.y.min+r}Zo(t,n),mo(t,i),os(this.projectionDeltaWithTransform,this.layoutCorrected,t,i)}}registerSharedNode(e,t){this.sharedNodes.has(e)||this.sharedNodes.set(e,new Vs),this.sharedNodes.get(e).add(t);let n=t.options.initialPromotionConfig;t.promote({transition:n?n.transition:void 0,preserveFollowOpacity:n&&n.shouldPreserveFollowOpacity?n.shouldPreserveFollowOpacity(t):void 0})}isLead(){let e=this.getStack();return!e||e.lead===this}getLead(){let{layoutId:e}=this.options;return e&&this.getStack()?.lead||this}getPrevLead(){let{layoutId:e}=this.options;return e?this.getStack()?.prevLead:void 0}getStack(){let{layoutId:e}=this.options;if(e)return this.root.sharedNodes.get(e)}promote({needsReset:e,transition:t,preserveFollowOpacity:n}={}){let r=this.getStack();r&&r.promote(this,n),e&&(this.projectionDelta=void 0,this.needsReset=!0),t&&this.setOptions({transition:t})}relegate(){let e=this.getStack();return e?e.relegate(this):!1}resetSkewAndRotation(){let{visualElement:e}=this.options;if(!e)return;let t=!1,{latestValues:n}=e;if((n.z||n.rotate||n.rotateX||n.rotateY||n.rotateZ||n.skewX||n.skewY)&&(t=!0),!t)return;let r={};n.z&&qs(`z`,e,r,this.animationValues);for(let t=0;t<Ws.length;t++)qs(`rotate${Ws[t]}`,e,r,this.animationValues),qs(`skew${Ws[t]}`,e,r,this.animationValues);e.render();for(let t in r)e.setStaticValue(t,r[t]),this.animationValues&&(this.animationValues[t]=r[t]);e.scheduleRender()}applyProjectionStyles(e,t){if(!this.instance||this.isSVG)return;if(!this.isVisible){e.visibility=`hidden`;return}let n=this.getTransformTemplate();if(this.needsReset){this.needsReset=!1,e.visibility=``,e.opacity=``,e.pointerEvents=Bs(t?.pointerEvents)||``,e.transform=n?n(this.latestValues,``):`none`;return}let r=this.getLead();if(!this.projectionDelta||!this.layout||!r.target){this.options.layoutId&&(e.opacity=this.latestValues.opacity===void 0?1:this.latestValues.opacity,e.pointerEvents=Bs(t?.pointerEvents)||``),this.hasProjected&&!eo(this.latestValues)&&(e.transform=n?n({},``):`none`,this.hasProjected=!1);return}e.visibility=``;let i=r.animationValues||r.latestValues;this.applyTransformsToTarget();let a=Es(this.projectionDeltaWithTransform,this.treeScale,i);n&&(a=n(i,a)),e.transform=a;let{x:o,y:s}=this.projectionDelta;e.transformOrigin=`${o.origin*100}% ${s.origin*100}% 0`,e.opacity=r.animationValues?r===this?i.opacity??this.latestValues.opacity??1:this.preserveOpacity?this.latestValues.opacity:i.opacityExit:r===this?i.opacity===void 0?``:i.opacity:i.opacityExit===void 0?0:i.opacityExit;for(let t in To){if(i[t]===void 0)continue;let{correct:n,applyTo:o,isCSSVariable:s}=To[t],c=a===`none`?i[t]:n(i[t],r);if(o){let t=o.length;for(let n=0;n<t;n++)e[o[n]]=c}else s?this.options.visualElement.renderState.vars[t]=c:e[t]=c}this.options.layoutId&&(e.pointerEvents=r===this?Bs(t?.pointerEvents)||``:`none`)}clearSnapshot(){this.resumeFrom=this.snapshot=void 0}resetTree(){this.root.nodes.forEach(e=>e.currentAnimation?.stop()),this.root.nodes.forEach(tc),this.root.sharedNodes.clear()}}}function Xs(e){e.updateLayout()}function Zs(e){let t=e.resumeFrom?.snapshot||e.snapshot;if(e.isLead()&&e.layout&&t&&e.hasListeners(`didUpdate`)){let{layoutBox:n,measuredBox:r}=e.layout,{animationType:i}=e.options,a=t.source!==e.layout.source;if(i===`size`)Ts(e=>{let r=a?t.measuredBox[e]:t.layoutBox[e],i=rs(r);r.min=n[e].min,r.max=r.min+i});else if(i===`x`||i===`y`){let e=i===`x`?`y`:`x`;Xo(a?t.measuredBox[e]:t.layoutBox[e],n[e])}else bc(i,t.layoutBox,n)&&Ts(r=>{let i=a?t.measuredBox[r]:t.layoutBox[r],o=rs(n[r]);i.max=i.min+o,e.relativeTarget&&!e.currentAnimation&&(e.isProjectionDirty=!0,e.relativeTarget[r].max=e.relativeTarget[r].min+o)});let o=Da();os(o,n,t.layoutBox);let s=Da();a?os(s,e.applyTransform(r,!0),t.measuredBox):os(s,n,t.layoutBox);let c=!vs(o),l=!1;if(!e.resumeFrom){let r=e.getClosestProjectingParent();if(r&&!r.resumeFrom){let{snapshot:i,layout:a}=r;if(i&&a){let o=e.options.layoutAnchor||void 0,s=ka();us(s,t.layoutBox,i.layoutBox,o);let c=ka();us(c,n,a.layoutBox,o),Ss(s,c)||(l=!0),r.options.layoutRoot&&(e.relativeTarget=c,e.relativeTargetOrigin=s,e.relativeParent=r)}}}e.notifyListeners(`didUpdate`,{layout:n,snapshot:t,delta:s,layoutDelta:o,hasLayoutChanged:c,hasRelativeLayoutChanged:l})}else if(e.isLead()){let{onExitComplete:t}=e.options;t&&t()}e.options.transition=void 0}function Qs(e){Sa.value&&Us.nodes++,e.parent&&(e.isProjecting()||(e.isProjectionDirty=e.parent.isProjectionDirty),e.isSharedProjectionDirty||=!!(e.isProjectionDirty||e.parent.isProjectionDirty||e.parent.isSharedProjectionDirty),e.isTransformDirty||=e.parent.isTransformDirty)}function $s(e){e.isProjectionDirty=e.isSharedProjectionDirty=e.isTransformDirty=!1}function ec(e){e.clearSnapshot()}function tc(e){e.clearMeasurements()}function nc(e){e.isLayoutDirty=!0,e.updateLayout()}function rc(e){e.isLayoutDirty=!1}function ic(e){e.isAnimationBlocked&&e.layout&&!e.isLayoutDirty&&(e.snapshot=e.layout,e.isLayoutDirty=!0)}function ac(e){let{visualElement:t}=e.options;t&&t.getProps().onBeforeLayoutMeasure&&t.notify(`BeforeLayoutMeasure`),e.resetTransform()}function oc(e){e.finishAnimation(),e.targetDelta=e.relativeTarget=e.target=void 0,e.isProjectionDirty=!0}function sc(e){e.resolveTargetDelta()}function cc(e){e.calcProjection()}function lc(e){e.resetSkewAndRotation()}function uc(e){e.removeLeadSnapshot()}function dc(e,t,n){e.translate=Nt(t.translate,0,n),e.scale=Nt(t.scale,1,n),e.origin=t.origin,e.originPoint=t.originPoint}function fc(e,t,n,r){e.min=Nt(t.min,n.min,r),e.max=Nt(t.max,n.max,r)}function pc(e,t,n,r){fc(e.x,t.x,n.x,r),fc(e.y,t.y,n.y,r)}function mc(e){return e.animationValues&&e.animationValues.opacityExit!==void 0}var hc={duration:.45,ease:[.4,0,.1,1]},gc=e=>typeof navigator<`u`&&navigator.userAgent&&navigator.userAgent.toLowerCase().includes(e),_c=gc(`applewebkit/`)&&!gc(`chrome/`)?Math.round:re;function vc(e){e.min=_c(e.min),e.max=_c(e.max)}function yc(e){vc(e.x),vc(e.y)}function bc(e,t,n){return e===`position`||e===`preserve-aspect`&&!is(Cs(t),Cs(n),.2)}function xc(e){return e!==e.root&&e.scroll?.wasRoot}var Sc=Ys({attachResizeListener:(e,t)=>Is(e,`resize`,t),measureScroll:()=>({x:document.documentElement.scrollLeft||document.body?.scrollLeft||0,y:document.documentElement.scrollTop||document.body?.scrollTop||0}),checkIsScrollRoot:()=>!0}),Cc={current:void 0},wc=Ys({measureScroll:e=>({x:e.scrollLeft,y:e.scrollTop}),defaultParent:()=>{if(!Cc.current){let e=new Sc({});e.mount(window),e.setOptions({layoutScroll:!0}),Cc.current=e}return Cc.current},resetTransform:(e,t)=>{e.style.transform=t===void 0?`none`:t},checkIsScrollRoot:e=>window.getComputedStyle(e).position===`fixed`}),Tc=(0,_.createContext)({transformPagePoint:e=>e,isStatic:!1,reducedMotion:`never`});function Ec(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Dc(...e){return t=>{let n=!1,r=e.map(e=>{let r=Ec(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():Ec(e[t],null)}}}}function Oc(...e){return _.useCallback(Dc(...e),e)}var I=S(),kc=class extends _.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(zi(t)&&e.isPresent&&!this.props.isPresent&&this.props.pop!==!1){let e=t.offsetParent,n=zi(e)&&e.offsetWidth||0,r=zi(e)&&e.offsetHeight||0,i=getComputedStyle(t),a=this.props.sizeRef.current;a.height=parseFloat(i.height),a.width=parseFloat(i.width),a.top=t.offsetTop,a.left=t.offsetLeft,a.right=n-a.width-a.left,a.bottom=r-a.height-a.top,a.direction=i.direction}return null}componentDidUpdate(){}render(){return this.props.children}};function Ac({children:e,isPresent:t,anchorX:n,anchorY:r,root:i,pop:a}){let o=(0,_.useId)(),s=(0,_.useRef)(null),c=(0,_.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0,direction:`ltr`}),{nonce:l}=(0,_.useContext)(Tc),u=Oc(s,a===!1?void 0:e.props?.ref??e?.ref);return(0,_.useInsertionEffect)(()=>{let{width:e,height:u,top:d,left:f,right:p,bottom:m,direction:h}=c.current;if(t||a===!1||!s.current||!e||!u)return;let g=h===`rtl`,_=n===`left`?g?`right: ${p}`:`left: ${f}`:g?`left: ${f}`:`right: ${p}`,v=r===`bottom`?`bottom: ${m}`:`top: ${d}`;s.current.dataset.motionPopId=o;let y=document.createElement(`style`);l&&(y.nonce=l);let b=i??document.head;return b.appendChild(y),y.sheet&&y.sheet.insertRule(`
|
|
10
|
-
[data-motion-pop-id="${o}"] {
|
|
11
|
-
position: absolute !important;
|
|
12
|
-
width: ${e}px !important;
|
|
13
|
-
height: ${u}px !important;
|
|
14
|
-
${_}px !important;
|
|
15
|
-
${v}px !important;
|
|
16
|
-
}
|
|
17
|
-
`),()=>{s.current?.removeAttribute(`data-motion-pop-id`),b.contains(y)&&b.removeChild(y)}},[t]),(0,I.jsx)(kc,{isPresent:t,childRef:s,sizeRef:c,pop:a,children:a===!1?e:_.cloneElement(e,{ref:u})})}var jc=({children:e,initial:t,isPresent:n,onExitComplete:r,custom:i,presenceAffectsLayout:a,mode:o,anchorX:s,anchorY:c,root:l})=>{let u=w(Mc),d=(0,_.useId)(),f=(0,_.useRef)(n),p=(0,_.useRef)(r);T(()=>{f.current=n,p.current=r});let m=!0,h=(0,_.useMemo)(()=>(m=!1,{id:d,initial:t,isPresent:n,custom:i,onExitComplete:e=>{u.set(e,!0);for(let e of u.values())if(!e)return;r&&r()},register:e=>(u.set(e,!1),()=>{u.delete(e),!f.current&&!u.size&&p.current?.()})}),[n,u,r]);return a&&m&&(h={...h}),(0,_.useMemo)(()=>{u.forEach((e,t)=>u.set(t,!1))},[n]),_.useEffect(()=>{!n&&!u.size&&r&&r()},[n]),e=(0,I.jsx)(Ac,{pop:o===`popLayout`,isPresent:n,anchorX:s,anchorY:c,root:l,children:e}),(0,I.jsx)(E.Provider,{value:h,children:e})};function Mc(){return new Map}function Nc(e=!0){let t=(0,_.useContext)(E);if(t===null)return[!0,null];let{isPresent:n,onExitComplete:r,register:i}=t,a=(0,_.useId)();(0,_.useEffect)(()=>{if(e)return i(a)},[e]);let o=(0,_.useCallback)(()=>e&&r&&r(a),[a,r,e]);return!n&&r?[!1,o]:[!0]}var Pc=e=>e.key||``;function Fc(e){let t=[];return _.Children.forEach(e,e=>{(0,_.isValidElement)(e)&&t.push(e)}),t}var Ic=({children:e,custom:t,initial:n=!0,onExitComplete:r,presenceAffectsLayout:i=!0,mode:a=`sync`,propagate:o=!1,anchorX:s=`left`,anchorY:c=`top`,root:l})=>{let[u,d]=Nc(o),f=(0,_.useMemo)(()=>Fc(e),[e]),p=o&&!u?[]:f.map(Pc),m=(0,_.useRef)(!0),h=(0,_.useRef)(f),g=w(()=>new Map),v=(0,_.useRef)(new Set),[y,b]=(0,_.useState)(f),[x,S]=(0,_.useState)(f);T(()=>{o&&!u&&!x.length&&d?.()},[u,o,x.length,d]),T(()=>{m.current=!1,h.current=f;for(let e=0;e<x.length;e++){let t=Pc(x[e]);p.includes(t)?(g.delete(t),v.current.delete(t)):g.get(t)!==!0&&g.set(t,!1)}},[x,p.length,p.join(`-`)]);let E=[];if(f!==y){let e=[...f];for(let t=0;t<x.length;t++){let n=x[t],r=Pc(n);p.includes(r)||(e.splice(t,0,n),E.push(n))}return a===`wait`&&E.length&&(e=E),S(Fc(e)),b(f),null}let{forceRender:D}=(0,_.useContext)(C);return(0,I.jsx)(I.Fragment,{children:x.map(e=>{let _=Pc(e),y=o&&!u?!1:f===x||p.includes(_);return(0,I.jsx)(jc,{isPresent:y,initial:!m.current||n?void 0:!1,custom:t,presenceAffectsLayout:i,mode:a,root:l,onExitComplete:y?void 0:()=>{if(v.current.has(_))return;if(g.has(_))v.current.add(_),g.set(_,!0);else return;let e=!0;g.forEach(t=>{t||(e=!1)}),e&&(D?.(),S(h.current),o&&d?.(),r&&r())},anchorX:s,anchorY:c,children:e},_)})})},Lc=(0,_.createContext)({strict:!1}),Rc={animation:[`animate`,`variants`,`whileHover`,`whileTap`,`exit`,`whileInView`,`whileFocus`,`whileDrag`],exit:[`exit`],drag:[`drag`,`dragControls`],focus:[`whileFocus`],hover:[`whileHover`,`onHoverStart`,`onHoverEnd`],tap:[`whileTap`,`onTap`,`onTapStart`,`onTapCancel`],pan:[`onPan`,`onPanStart`,`onPanSessionStart`,`onPanEnd`],inView:[`whileInView`,`onViewportEnter`,`onViewportLeave`],layout:[`layout`,`layoutId`]},zc=!1;function Bc(){if(zc)return;let e={};for(let t in Rc)e[t]={isEnabled:e=>Rc[t].some(t=>!!e[t])};Wa(e),zc=!0}function Vc(){return Bc(),Ga()}function Hc(e){let t=Vc();for(let n in e)t[n]={...t[n],...e[n]};Wa(t)}var Uc=(0,_.createContext)({});function Wc(e,t){if(Fa(e)){let{initial:t,animate:n}=e;return{initial:t===!1||Ma(t)?t:void 0,animate:Ma(n)?n:void 0}}return e.inherit===!1?{}:t}function Gc(e){let{initial:t,animate:n}=Wc(e,(0,_.useContext)(Uc));return(0,_.useMemo)(()=>({initial:t,animate:n}),[Kc(t),Kc(n)])}function Kc(e){return Array.isArray(e)?e.join(` `):e}var qc=()=>({style:{},transform:{},transformOrigin:{},vars:{}});function Jc(e,t,n){for(let r in t)!ai(t[r])&&!Eo(r,n)&&(e[r]=t[r])}function Yc({transformTemplate:e},t){return(0,_.useMemo)(()=>{let n=qc();return bo(n,t,e),Object.assign({},n.vars,n.style)},[t])}function Xc(e,t){let n=e.style||{},r={};return Jc(r,n,e),Object.assign(r,Yc(e,t)),r}function Zc(e,t){let n={},r=Xc(e,t);return e.drag&&e.dragListener!==!1&&(n.draggable=!1,r.userSelect=r.WebkitUserSelect=r.WebkitTouchCallout=`none`,r.touchAction=e.drag===!0?`none`:`pan-${e.drag===`x`?`y`:`x`}`),e.tabIndex===void 0&&(e.onTap||e.onTapStart||e.whileTap)&&(n.tabIndex=0),n.style=r,n}var Qc=()=>({...qc(),attrs:{}});function $c(e,t,n,r){let i=(0,_.useMemo)(()=>{let n=Qc();return Po(n,t,Io(r),e.transformTemplate,e.style),{...n.attrs,style:{...n.style}}},[t]);if(e.style){let t={};Jc(t,e.style,e),i.style={...t,...i.style}}return i}var el=new Set(`animate.exit.variants.initial.style.values.variants.transition.transformTemplate.custom.inherit.onBeforeLayoutMeasure.onAnimationStart.onAnimationComplete.onUpdate.onDragStart.onDrag.onDragEnd.onMeasureDragConstraints.onDirectionLock.onDragTransitionEnd._dragX._dragY.onHoverStart.onHoverEnd.onViewportEnter.onViewportLeave.globalTapTarget.propagate.ignoreStrict.viewport`.split(`.`));function tl(e){return e.startsWith(`while`)||e.startsWith(`drag`)&&e!==`draggable`||e.startsWith(`layout`)||e.startsWith(`onTap`)||e.startsWith(`onPan`)||e.startsWith(`onLayout`)||el.has(e)}function nl(e,t){return e.startsWith(`on`)?!tl(e):t?.(e)??!tl(e)}function rl(e,t,n,r){let i={};for(let a in e)(a!==`values`||typeof e.values!=`object`)&&(ai(e[a])||(nl(a,r)||n===!0&&tl(a)||!t&&!tl(a)||e.draggable&&a.startsWith(`onDrag`))&&(i[a]=e[a]));return i}var il=[`animate`,`circle`,`defs`,`desc`,`ellipse`,`g`,`image`,`line`,`filter`,`marker`,`mask`,`metadata`,`path`,`pattern`,`polygon`,`polyline`,`rect`,`stop`,`switch`,`symbol`,`svg`,`text`,`tspan`,`use`,`view`];function al(e){return typeof e!=`string`||e.includes(`-`)?!1:!!(il.indexOf(e)>-1||/[A-Z]/u.test(e))}function ol(e,t,n,{latestValues:r},i,a=!1,o,s){let c=(o??al(e)?$c:Zc)(t,r,i,e),l=rl(t,typeof e==`string`,a,s),u=e===_.Fragment?{}:{...l,...c,ref:n},{children:d}=t,f=(0,_.useMemo)(()=>ai(d)?d.get():d,[d]);return(0,_.createElement)(e,{...u,children:f})}function sl({scrapeMotionValuesFromProps:e,createRenderState:t},n,r,i){return{latestValues:cl(n,r,i,e),renderState:t()}}function cl(e,t,n,r){let i={},a=r(e,{});for(let e in a)i[e]=Bs(a[e]);let{initial:o,animate:s}=e,c=Fa(e),l=Ia(e);t&&l&&!c&&e.inherit!==!1&&(o===void 0&&(o=t.initial),s===void 0&&(s=t.animate));let u=n?n.initial===!1:!1;u||=o===!1;let d=u?s:o;if(d&&typeof d!=`boolean`&&!ja(d)){let t=Array.isArray(d)?d:[d];for(let n=0;n<t.length;n++){let r=Qr(e,t[n]);if(r){let{transitionEnd:e,transition:t,...n}=r;for(let e in n){let t=n[e];if(Array.isArray(t)){let e=u?t.length-1:0;t=t[e]}t!==null&&(i[e]=t)}for(let t in e)i[t]=e[t]}}}return i}var ll=e=>(t,n)=>{let r=(0,_.useContext)(Uc),i=(0,_.useContext)(E),a=()=>sl(e,t,r,i);return n?a():w(a)},ul=ll({scrapeMotionValuesFromProps:Do,createRenderState:qc}),dl=ll({scrapeMotionValuesFromProps:Ro,createRenderState:Qc}),fl=Symbol.for(`motionComponentSymbol`);function pl(e,t,n){let r=(0,_.useRef)(n);(0,_.useInsertionEffect)(()=>{r.current=n});let i=(0,_.useRef)(null);return(0,_.useCallback)(n=>{n&&e.onMount?.(n),t&&(n?t.mount(n):t.unmount());let a=r.current;if(typeof a==`function`){if(n){let e=a(n);typeof e==`function`&&(i.current=e)}else i.current?(i.current(),i.current=null):a(n)}else a&&(a.current=n)},[t])}var ml=(0,_.createContext)({});function hl(e){return e&&typeof e==`object`&&Object.prototype.hasOwnProperty.call(e,`current`)}function gl(e,t,n,r,i,a){let{visualElement:o}=(0,_.useContext)(Uc),s=(0,_.useContext)(Lc),c=(0,_.useContext)(E),l=(0,_.useContext)(Tc),u=l.reducedMotion,d=l.skipAnimations,f=(0,_.useRef)(null),p=(0,_.useRef)(!1);r||=s.renderer,!f.current&&r&&(f.current=r(e,{visualState:t,parent:o,props:n,presenceContext:c,blockInitialAnimation:c?c.initial===!1:!1,reducedMotionConfig:u,skipAnimations:d,isSVG:a}),p.current&&f.current&&(f.current.manuallyAnimateOnMount=!0));let m=f.current,h=(0,_.useContext)(ml);m&&!m.projection&&i&&(m.type===`html`||m.type===`svg`)&&_l(f.current,n,i,h);let g=(0,_.useRef)(!1);(0,_.useInsertionEffect)(()=>{m&&g.current&&m.update(n,c)});let v=n[li],y=(0,_.useRef)(!!v&&typeof window<`u`&&!window.MotionHandoffIsComplete?.(v)&&window.MotionHasOptimisedAnimation?.(v));return T(()=>{p.current=!0,m&&(g.current=!0,window.MotionIsMounted=!0,m.updateFeatures(),m.scheduleRenderMicrotask(),y.current&&m.animationState&&m.animationState.animateChanges())}),(0,_.useEffect)(()=>{m&&(!y.current&&m.animationState&&m.animationState.animateChanges(),y.current&&=(queueMicrotask(()=>{window.MotionHandoffMarkAsComplete?.(v)}),!1),m.enteringChildren=void 0)}),m}function _l(e,t,n,r){let{layoutId:i,layout:a,drag:o,dragConstraints:s,layoutScroll:c,layoutRoot:l,layoutAnchor:u,layoutCrossfade:d}=t;e.projection=new n(e.latestValues,t[`data-framer-portal-id`]?void 0:vl(e.parent)),e.projection.setOptions({layoutId:i,layout:a,alwaysMeasureLayout:!!o||s&&hl(s),visualElement:e,animationType:typeof a==`string`?a:`both`,initialPromotionConfig:r,crossfade:d,layoutScroll:c,layoutRoot:l,layoutAnchor:u})}function vl(e){if(e)return e.options.allowProjection===!1?vl(e.parent):e.projection}function yl(e,{forwardMotionProps:t=!1,type:n}={},r,i){r&&Hc(r);let a=n?n===`svg`:al(e),o=a?dl:ul;function s(n,s){let c,l={...(0,_.useContext)(Tc),...n,layoutId:bl(n)},{isStatic:u,isValidProp:d}=l,f=Gc(n),p=o(n,u);if(!u&&typeof window<`u`){xl(l,r);let t=Sl(l);c=t.MeasureLayout,f.visualElement=gl(e,p,l,i,t.ProjectionNode,a)}return(0,I.jsxs)(Uc.Provider,{value:f,children:[c&&f.visualElement?(0,I.jsx)(c,{visualElement:f.visualElement,...l}):null,ol(e,n,pl(p,f.visualElement,s),p,u,t,a,d)]})}s.displayName=`motion.${typeof e==`string`?e:`create(${e.displayName??e.name??``})`}`;let c=(0,_.forwardRef)(s);return c[fl]=e,c}function bl({layoutId:e}){let t=(0,_.useContext)(C).id;return t&&e!==void 0?t+`-`+e:e}function xl(e,t){(0,_.useContext)(Lc).strict}function Sl(e){let{drag:t,layout:n}=Vc();if(!t&&!n)return{};let r={...t,...n};return{MeasureLayout:t?.isEnabled(e)||n?.isEnabled(e)?r.MeasureLayout:void 0,ProjectionNode:r.ProjectionNode}}function Cl(e,t){if(typeof Proxy>`u`)return yl;let n=new Map,r=(n,r)=>yl(n,r,e,t);return new Proxy((e,t)=>r(e,t),{get:(i,a)=>a===`create`?r:(n.has(a)||n.set(a,yl(a,void 0,e,t)),n.get(a))})}var wl=(e,t)=>t.isSVG??al(e)?new zo(t):new ko(t,{allowProjection:e!==_.Fragment}),Tl=class extends Ja{constructor(e){super(e),e.animationState||=Ko(e)}updateAnimationControlsSubscription(){let{animate:e}=this.node.getProps();ja(e)&&(this.unmountControls=e.subscribe(this.node))}mount(){this.updateAnimationControlsSubscription()}update(){let{animate:e}=this.node.getProps(),{animate:t}=this.node.prevProps||{};e!==t&&this.updateAnimationControlsSubscription()}unmount(){this.node.animationState.reset(),this.unmountControls?.()}},El=0,Dl={animation:{Feature:Tl},exit:{Feature:class extends Ja{constructor(){super(...arguments),this.id=El++,this.isExitComplete=!1}update(){if(!this.node.presenceContext)return;let{isPresent:e,onExitComplete:t}=this.node.presenceContext,{isPresent:n}=this.node.prevPresenceContext||{};if(!this.node.animationState||e===n)return;if(e&&n===!1){if(this.isExitComplete){let{initial:e,custom:t}=this.node.getProps();if(typeof e==`string`||typeof e==`object`&&e&&!Array.isArray(e)){let n=$r(this.node,e,t);if(n){let{transition:e,transitionEnd:t,...r}=n;for(let e in r)this.node.getValue(e)?.jump(r[e])}}this.node.animationState.reset(),this.node.animationState.animateChanges()}else this.node.animationState.setActive(`exit`,!1);this.isExitComplete=!1;return}let r=this.node.animationState.setActive(`exit`,!e);t&&!e&&r.then(()=>{this.isExitComplete=!0,t(this.id)})}mount(){let{register:e,onExitComplete:t}=this.node.presenceContext||{};t&&t(this.id),e&&(this.unmount=e(this.id))}unmount(){}}}};function Ol(e){return{point:{x:e.pageX,y:e.pageY}}}var kl=e=>t=>Yi(t)&&e(t,Ol(t));function Al(e,t,n,r){return Is(e,t,kl(n),r)}var jl=({current:e})=>e?e.ownerDocument.defaultView:null,Ml=(e,t)=>Math.abs(e-t);function Nl(e,t){let n=Ml(e.x,t.x),r=Ml(e.y,t.y);return Math.sqrt(n**2+r**2)}var Pl=new Set([`auto`,`scroll`]),Fl=class{constructor(e,t,{transformPagePoint:n,contextWindow:r=window,dragSnapToOrigin:i=!1,distanceThreshold:a=3,element:o}={}){if(this.startEvent=null,this.lastMoveEvent=null,this.lastMoveEventInfo=null,this.lastRawMoveEventInfo=null,this.handlers={},this.contextWindow=window,this.scrollPositions=new Map,this.removeScrollListeners=null,this.onElementScroll=e=>{this.handleScroll(e.target)},this.onWindowScroll=()=>{this.handleScroll(window)},this.updatePoint=()=>{if(!(this.lastMoveEvent&&this.lastMoveEventInfo))return;this.lastRawMoveEventInfo&&(this.lastMoveEventInfo=Il(this.lastRawMoveEventInfo,this.transformPagePoint));let e=Rl(this.lastMoveEventInfo,this.history),t=this.startEvent!==null,n=Nl(e.offset,{x:0,y:0})>=this.distanceThreshold;if(!t&&!n)return;let{point:r}=e,{timestamp:i}=Fe;this.history.push({...r,timestamp:i});let{onStart:a,onMove:o}=this.handlers;t||(a&&a(this.lastMoveEvent,e),this.startEvent=this.lastMoveEvent),o&&o(this.lastMoveEvent,e)},this.handlePointerMove=(e,t)=>{this.lastMoveEvent=e,this.lastRawMoveEventInfo=t,this.lastMoveEventInfo=Il(t,this.transformPagePoint),Ne.update(this.updatePoint,!0)},this.handlePointerUp=(e,t)=>{this.end();let{onEnd:n,onSessionEnd:r,resumeAnimation:i}=this.handlers;if((this.dragSnapToOrigin||!this.startEvent)&&i&&i(),!(this.lastMoveEvent&&this.lastMoveEventInfo))return;let a=Rl(e.type===`pointercancel`?this.lastMoveEventInfo:Il(t,this.transformPagePoint),this.history);this.startEvent&&n&&n(e,a),r&&r(e,a)},!Yi(e))return;this.dragSnapToOrigin=i,this.handlers=t,this.transformPagePoint=n,this.distanceThreshold=a,this.contextWindow=r||window;let s=Il(Ol(e),this.transformPagePoint),{point:c}=s,{timestamp:l}=Fe;this.history=[{...c,timestamp:l}];let{onSessionStart:u}=t;u&&u(e,Rl(s,this.history));let d={passive:!0,capture:!0};this.removeListeners=M(Al(this.contextWindow,`pointermove`,this.handlePointerMove,d),Al(this.contextWindow,`pointerup`,this.handlePointerUp,d),Al(this.contextWindow,`pointercancel`,this.handlePointerUp,d)),o&&this.startScrollTracking(o)}startScrollTracking(e){let t=e.parentElement;for(;t;){let e=getComputedStyle(t);(Pl.has(e.overflowX)||Pl.has(e.overflowY))&&this.scrollPositions.set(t,{x:t.scrollLeft,y:t.scrollTop}),t=t.parentElement}this.scrollPositions.set(window,{x:window.scrollX,y:window.scrollY}),window.addEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.addEventListener(`scroll`,this.onWindowScroll),this.removeScrollListeners=()=>{window.removeEventListener(`scroll`,this.onElementScroll,{capture:!0}),window.removeEventListener(`scroll`,this.onWindowScroll)}}handleScroll(e){let t=this.scrollPositions.get(e);if(!t)return;let n=e===window,r=n?{x:window.scrollX,y:window.scrollY}:{x:e.scrollLeft,y:e.scrollTop},i={x:r.x-t.x,y:r.y-t.y};(i.x!==0||i.y!==0)&&(n?this.lastMoveEventInfo&&(this.lastMoveEventInfo.point.x+=i.x,this.lastMoveEventInfo.point.y+=i.y):this.history.length>0&&(this.history[0].x-=i.x,this.history[0].y-=i.y),this.scrollPositions.set(e,r),Ne.update(this.updatePoint,!0))}updateHandlers(e){this.handlers=e}end(){this.removeListeners&&this.removeListeners(),this.removeScrollListeners&&this.removeScrollListeners(),this.scrollPositions.clear(),Pe(this.updatePoint)}};function Il(e,t){return t?{point:t(e.point)}:e}function Ll(e,t){return{x:e.x-t.x,y:e.y-t.y}}function Rl({point:e},t){return{point:e,delta:Ll(e,Bl(t)),offset:Ll(e,zl(t)),velocity:Vl(t,.1)}}function zl(e){return e[0]}function Bl(e){return e[e.length-1]}function Vl(e,t){if(e.length<2)return{x:0,y:0};let n=e.length-1,r=null,i=Bl(e);for(;n>=0&&(r=e[n],!(i.timestamp-r.timestamp>ae(t)));)n--;if(!r)return{x:0,y:0};r===e[0]&&e.length>2&&i.timestamp-r.timestamp>ae(t)*2&&(r=e[1]);let a=oe(i.timestamp-r.timestamp);if(a===0)return{x:0,y:0};let o={x:(i.x-r.x)/a,y:(i.y-r.y)/a};return o.x===1/0&&(o.x=0),o.y===1/0&&(o.y=0),o}function Hl(e,{min:t,max:n},r){return t!==void 0&&e<t?e=r?Nt(t,e,r.min):Math.max(e,t):n!==void 0&&e>n&&(e=r?Nt(n,e,r.max):Math.min(e,n)),e}function Ul(e,t,n){return{min:t===void 0?void 0:e.min+t,max:n===void 0?void 0:e.max+n-(e.max-e.min)}}function Wl(e,{top:t,left:n,bottom:r,right:i}){return{x:Ul(e.x,n,i),y:Ul(e.y,t,r)}}function Gl(e,t){let n=t.min-e.min,r=t.max-e.max;return t.max-t.min<e.max-e.min&&([n,r]=[r,n]),{min:n,max:r}}function Kl(e,t){return{x:Gl(e.x,t.x),y:Gl(e.y,t.y)}}function ql(e,t){let n=.5,r=rs(e),i=rs(t);return i>r?n=N(t.min,t.max-r,e.min):r>i&&(n=N(e.min,e.max-i,t.min)),k(0,1,n)}function Jl(e,t){let n={};return t.min!==void 0&&(n.min=t.min-e.min),t.max!==void 0&&(n.max=t.max-e.min),n}var Yl=.35;function Xl(e=Yl){return e===!1?e=0:e===!0&&(e=Yl),{x:Zl(e,`left`,`right`),y:Zl(e,`top`,`bottom`)}}function Zl(e,t,n){return{min:Ql(e,t),max:Ql(e,n)}}function Ql(e,t){return typeof e==`number`?e:e[t]||0}var $l=new WeakMap,eu=class{constructor(e){this.openDragLock=null,this.isDragging=!1,this.currentDirection=null,this.originPoint={x:0,y:0},this.constraints=!1,this.hasMutatedConstraints=!1,this.elastic=ka(),this.latestPointerEvent=null,this.latestPanInfo=null,this.visualElement=e}start(e,{snapToCursor:t=!1,distanceThreshold:n}={}){let{presenceContext:r}=this.visualElement;if(r&&r.isPresent===!1)return;let i=e=>{t&&this.snapToCursor(Ol(e).point),this.stopAnimation()},a=(e,t)=>{let{drag:n,dragPropagation:r,onDragStart:i}=this.getProps();if(n&&!r&&(this.openDragLock&&this.openDragLock(),this.openDragLock=Wi(n),!this.openDragLock))return;this.latestPointerEvent=e,this.latestPanInfo=t,this.isDragging=!0,this.currentDirection=null,this.resolveConstraints(),this.visualElement.projection&&(this.visualElement.projection.isAnimationBlocked=!0,this.visualElement.projection.target=void 0),Ts(e=>{let t=this.getAxisMotionValue(e).get()||0;if(ct.test(t)){let{projection:n}=this.visualElement;if(n&&n.layout){let r=n.layout.layoutBox[e];r&&(t=rs(r)*(parseFloat(t)/100))}}this.originPoint[e]=t}),i&&Ne.update(()=>i(e,t),!1,!0),si(this.visualElement,`transform`);let{animationState:a}=this.visualElement;a&&a.setActive(`whileDrag`,!0)},o=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t;let{dragPropagation:n,dragDirectionLock:r,onDirectionLock:i,onDrag:a}=this.getProps();if(!n&&!this.openDragLock)return;let{offset:o}=t;if(r&&this.currentDirection===null){this.currentDirection=iu(o),this.currentDirection!==null&&i&&i(this.currentDirection);return}this.updateAxis(`x`,t.point,o),this.updateAxis(`y`,t.point,o),this.visualElement.render(),a&&Ne.update(()=>a(e,t),!1,!0)},s=(e,t)=>{this.latestPointerEvent=e,this.latestPanInfo=t,this.stop(e,t),this.latestPointerEvent=null,this.latestPanInfo=null},c=()=>{let{dragSnapToOrigin:e}=this.getProps();(e||this.constraints)&&this.startAnimation({x:0,y:0})},{dragSnapToOrigin:l}=this.getProps();this.panSession=new Fl(e,{onSessionStart:i,onStart:a,onMove:o,onSessionEnd:s,resumeAnimation:c},{transformPagePoint:this.visualElement.getTransformPagePoint(),dragSnapToOrigin:l,distanceThreshold:n,contextWindow:jl(this.visualElement),element:this.visualElement.current})}stop(e,t){let n=e||this.latestPointerEvent,r=t||this.latestPanInfo,i=this.isDragging;if(this.cancel(),!i||!r||!n)return;let{velocity:a}=r;this.startAnimation(a);let{onDragEnd:o}=this.getProps();o&&Ne.postRender(()=>o(n,r))}cancel(){this.isDragging=!1;let{projection:e,animationState:t}=this.visualElement;e&&(e.isAnimationBlocked=!1),this.endPanSession();let{dragPropagation:n}=this.getProps();!n&&this.openDragLock&&(this.openDragLock(),this.openDragLock=null),t&&t.setActive(`whileDrag`,!1)}endPanSession(){this.panSession&&this.panSession.end(),this.panSession=void 0}updateAxis(e,t,n){let{drag:r}=this.getProps();if(!n||!ru(e,r,this.currentDirection))return;let i=this.getAxisMotionValue(e),a=this.originPoint[e]+n[e];this.constraints&&this.constraints[e]&&(a=Hl(a,this.constraints[e],this.elastic[e])),i.set(a)}resolveConstraints(){let{dragConstraints:e,dragElastic:t}=this.getProps(),n=this.visualElement.projection&&!this.visualElement.projection.layout?this.visualElement.projection.measure(!1):this.visualElement.projection?.layout,r=this.constraints;e&&hl(e)?this.constraints||=this.resolveRefConstraints():this.constraints=e&&n?Wl(n.layoutBox,e):!1,this.elastic=Xl(t),r!==this.constraints&&!hl(e)&&n&&this.constraints&&!this.hasMutatedConstraints&&Ts(e=>{this.constraints!==!1&&this.getAxisMotionValue(e)&&(this.constraints[e]=Jl(n.layoutBox[e],this.constraints[e]))})}resolveRefConstraints(){let{dragConstraints:e,onMeasureDragConstraints:t}=this.getProps();if(!e||!hl(e))return!1;let n=e.current,{projection:r}=this.visualElement;if(!r||!r.layout)return!1;r.root&&(r.root.scroll=void 0,r.root.updateScroll());let i=go(n,r.root,this.visualElement.getTransformPagePoint()),a=Kl(r.layout.layoutBox,i);if(t){let e=t(Xa(a));this.hasMutatedConstraints=!!e,e&&(a=Ya(e))}return a}startAnimation(e){let{drag:t,dragMomentum:n,dragElastic:r,dragTransition:i,dragSnapToOrigin:a,onDragTransitionEnd:o}=this.getProps(),s=this.constraints||{},c=Ts(o=>{if(!ru(o,t,this.currentDirection))return;let c=s&&s[o]||{};(a===!0||a===o)&&(c={min:0,max:0});let l=r?200:1e6,u=r?40:1e7,d={type:`inertia`,velocity:n?e[o]:0,bounceStiffness:l,bounceDamping:u,timeConstant:750,restDelta:1,restSpeed:10,...i,...c};return this.startAxisValueAnimation(o,d)});return Promise.all(c).then(o)}startAxisValueAnimation(e,t){let n=this.getAxisMotionValue(e);return si(this.visualElement,e),n.start(qr(e,n,0,t,this.visualElement,!1))}stopAnimation(){Ts(e=>this.getAxisMotionValue(e).stop())}getAxisMotionValue(e){let t=`_drag${e.toUpperCase()}`;return this.visualElement.getProps()[t]||this.visualElement.getValue(e,this.visualElement.latestValues[e]??0)}snapToCursor(e){Ts(t=>{let{drag:n}=this.getProps();if(!ru(t,n,this.currentDirection))return;let{projection:r}=this.visualElement,i=this.getAxisMotionValue(t);if(r&&r.layout){let{min:n,max:a}=r.layout.layoutBox[t],o=i.get()||0;i.set(e[t]-Nt(n,a,.5)+o)}})}scalePositionWithinConstraints(){if(!this.visualElement.current)return;let{drag:e,dragConstraints:t}=this.getProps(),{projection:n}=this.visualElement;if(!hl(t)||!n||!this.constraints)return;this.stopAnimation();let r={x:0,y:0};Ts(e=>{let t=this.getAxisMotionValue(e);if(t&&this.constraints!==!1){let n=t.get();r[e]=ql({min:n,max:n},this.constraints[e])}});let{transformTemplate:i}=this.visualElement.getProps();this.visualElement.current.style.transform=i?i({},``):`none`,n.root&&n.root.updateScroll(),n.updateLayout(),this.constraints=!1,this.resolveConstraints(),Ts(t=>{if(!ru(t,e,null))return;let n=this.getAxisMotionValue(t),{min:i,max:a}=this.constraints[t];n.set(Nt(i,a,r[t]))}),this.visualElement.render()}addListeners(){if(!this.visualElement.current)return;$l.set(this.visualElement,this);let e=this.visualElement.current,t=Al(e,`pointerdown`,t=>{let{drag:n,dragListener:r=!0}=this.getProps(),i=t.target,a=i!==e&&$i(i);n&&r&&!a&&this.start(t)}),n,r=()=>{let{dragConstraints:t}=this.getProps();hl(t)&&t.current&&(this.constraints=this.resolveRefConstraints(),n||=nu(e,t.current,()=>this.scalePositionWithinConstraints()))},{projection:i}=this.visualElement,a=i.addEventListener(`measure`,r);i&&!i.layout&&(i.root&&i.root.updateScroll(),i.updateLayout()),Ne.read(r);let o=Is(window,`resize`,()=>this.scalePositionWithinConstraints()),s=i.addEventListener(`didUpdate`,(({delta:e,hasLayoutChanged:t})=>{this.isDragging&&t&&(Ts(t=>{let n=this.getAxisMotionValue(t);n&&(this.originPoint[t]+=e[t].translate,n.set(n.get()+e[t].translate))}),this.visualElement.render())}));return()=>{o(),t(),a(),s&&s(),n&&n()}}getProps(){let e=this.visualElement.getProps(),{drag:t=!1,dragDirectionLock:n=!1,dragPropagation:r=!1,dragConstraints:i=!1,dragElastic:a=Yl,dragMomentum:o=!0}=e;return{...e,drag:t,dragDirectionLock:n,dragPropagation:r,dragConstraints:i,dragElastic:a,dragMomentum:o}}};function tu(e){let t=!0;return()=>{if(t){t=!1;return}e()}}function nu(e,t,n){let r=xa(e,tu(n)),i=xa(t,tu(n));return()=>{r(),i()}}function ru(e,t,n){return(t===!0||t===e)&&(n===null||n===e)}function iu(e,t=10){let n=null;return Math.abs(e.y)>t?n=`y`:Math.abs(e.x)>t&&(n=`x`),n}var au=class extends Ja{constructor(e){super(e),this.removeGroupControls=re,this.removeListeners=re,this.controls=new eu(e)}mount(){let{dragControls:e}=this.node.getProps();e&&(this.removeGroupControls=e.subscribe(this.controls)),this.removeListeners=this.controls.addListeners()||re}update(){let{dragControls:e}=this.node.getProps(),{dragControls:t}=this.node.prevProps||{};e!==t&&(this.removeGroupControls(),e&&(this.removeGroupControls=e.subscribe(this.controls)))}unmount(){this.removeGroupControls(),this.removeListeners(),this.controls.isDragging||this.controls.endPanSession()}},ou=e=>(t,n)=>{e&&Ne.update(()=>e(t,n),!1,!0)},su=class extends Ja{constructor(){super(...arguments),this.removePointerDownListener=re}onPointerDown(e){this.session=new Fl(e,this.createPanHandlers(),{transformPagePoint:this.node.getTransformPagePoint(),contextWindow:jl(this.node)})}createPanHandlers(){let{onPanSessionStart:e,onPanStart:t,onPan:n,onPanEnd:r}=this.node.getProps();return{onSessionStart:ou(e),onStart:ou(t),onMove:ou(n),onEnd:(e,t)=>{delete this.session,r&&Ne.postRender(()=>r(e,t))}}}mount(){this.removePointerDownListener=Al(this.node.current,`pointerdown`,e=>this.onPointerDown(e))}update(){this.session&&this.session.updateHandlers(this.createPanHandlers())}unmount(){this.removePointerDownListener(),this.session&&this.session.end()}},cu=!1,lu=class extends _.Component{componentDidMount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n,layoutId:r}=this.props,{projection:i}=e;i&&(t.group&&t.group.add(i),n&&n.register&&r&&n.register(i),cu&&i.root.didUpdate(),i.addEventListener(`animationComplete`,()=>{this.safeToRemove()}),i.setOptions({...i.options,layoutDependency:this.props.layoutDependency,onExitComplete:()=>this.safeToRemove()})),Hs.hasEverUpdated=!0}getSnapshotBeforeUpdate(e){let{layoutDependency:t,visualElement:n,drag:r,isPresent:i}=this.props,{projection:a}=n;return a?(a.isPresent=i,e.layoutDependency!==t&&a.setOptions({...a.options,layoutDependency:t}),cu=!0,r||e.layoutDependency!==t||t===void 0||e.isPresent!==i?a.willUpdate():this.safeToRemove(),e.isPresent!==i&&(i?a.promote():a.relegate()||Ne.postRender(()=>{let e=a.getStack();(!e||!e.members.length)&&this.safeToRemove()})),null):null}componentDidUpdate(){let{visualElement:e,layoutAnchor:t}=this.props,{projection:n}=e;n&&(n.options.layoutAnchor=t,n.root.didUpdate(),Bi.postRender(()=>{!n.currentAnimation&&n.isLead()&&this.safeToRemove()}))}componentWillUnmount(){let{visualElement:e,layoutGroup:t,switchLayoutGroup:n}=this.props,{projection:r}=e;cu=!0,r&&(r.scheduleCheckAfterUnmount(),t&&t.group&&t.group.remove(r),n&&n.deregister&&n.deregister(r))}safeToRemove(){let{safeToRemove:e}=this.props;e&&e()}render(){return null}};function uu(e){let[t,n]=Nc(),r=(0,_.useContext)(C);return(0,I.jsx)(lu,{...e,layoutGroup:r,switchLayoutGroup:(0,_.useContext)(ml),isPresent:t,safeToRemove:n})}var du={pan:{Feature:su},drag:{Feature:au,ProjectionNode:wc,MeasureLayout:uu}};function fu(e,t,n){let{props:r}=e;e.animationState&&r.whileHover&&e.animationState.setActive(`whileHover`,n===`Start`);let i=r[`onHover`+n];i&&Ne.postRender(()=>i(t,Ol(t)))}var pu=class extends Ja{mount(){let{current:e}=this.node;e&&(this.unmount=qi(e,(e,t)=>(fu(this.node,t,`Start`),e=>fu(this.node,e,`End`))))}unmount(){}},mu=class extends Ja{constructor(){super(...arguments),this.isActive=!1}onFocus(){let e=!1;try{e=this.node.current.matches(`:focus-visible`)}catch{e=!0}e&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!0),this.isActive=!0)}onBlur(){this.isActive&&this.node.animationState&&(this.node.animationState.setActive(`whileFocus`,!1),this.isActive=!1)}mount(){this.unmount=M(Is(this.node.current,`focus`,()=>this.onFocus()),Is(this.node.current,`blur`,()=>this.onBlur()))}unmount(){}};function hu(e,t,n){let{props:r}=e;if(e.current instanceof HTMLButtonElement&&e.current.disabled)return;e.animationState&&r.whileTap&&e.animationState.setActive(`whileTap`,n===`Start`);let i=r[`onTap`+(n===`End`?``:n)];i&&Ne.postRender(()=>i(t,Ol(t)))}var gu=class extends Ja{mount(){let{current:e}=this.node;if(!e)return;let{globalTapTarget:t,propagate:n}=this.node.props;this.unmount=oa(e,(e,t)=>(hu(this.node,t,`Start`),(e,{success:t})=>hu(this.node,e,t?`End`:`Cancel`)),{useGlobalTarget:t,stopPropagation:n?.tap===!1})}unmount(){}},_u=new WeakMap,vu=new WeakMap,yu=e=>{let t=_u.get(e.target);t&&t(e)},bu=e=>{e.forEach(yu)};function xu({root:e,...t}){let n=e||document;vu.has(n)||vu.set(n,{});let r=vu.get(n),i=JSON.stringify(t);return r[i]||(r[i]=new IntersectionObserver(bu,{root:e,...t})),r[i]}function Su(e,t,n){let r=xu(t);return _u.set(e,n),r.observe(e),()=>{_u.delete(e),r.unobserve(e)}}var Cu={some:0,all:1},wu=class extends Ja{constructor(){super(...arguments),this.hasEnteredView=!1,this.isInView=!1}startObserver(){this.stopObserver?.();let{viewport:e={}}=this.node.getProps(),{root:t,margin:n,amount:r=`some`,once:i}=e,a={root:t?t.current:void 0,rootMargin:n,threshold:typeof r==`number`?r:Cu[r]},o=e=>{let{isIntersecting:t}=e;if(this.isInView===t||(this.isInView=t,i&&!t&&this.hasEnteredView))return;t&&(this.hasEnteredView=!0),this.node.animationState&&this.node.animationState.setActive(`whileInView`,t);let{onViewportEnter:n,onViewportLeave:r}=this.node.getProps(),a=t?n:r;a&&a(e)};this.stopObserver=Su(this.node.current,a,o)}mount(){this.startObserver()}update(){if(typeof IntersectionObserver>`u`)return;let{props:e,prevProps:t}=this.node;[`amount`,`margin`,`root`].some(Tu(e,t))&&this.startObserver()}unmount(){this.stopObserver?.(),this.hasEnteredView=!1,this.isInView=!1}};function Tu({viewport:e={}},{viewport:t={}}={}){return n=>e[n]!==t[n]}var Eu={inView:{Feature:wu},tap:{Feature:gu},focus:{Feature:mu},hover:{Feature:pu}},Du={layout:{ProjectionNode:wc,MeasureLayout:uu}},Ou=Cl({...Dl,...Eu,...du,...Du},wl);function ku(e){if(typeof window>`u`||window.navigator==null)return!1;let t=window.navigator.userAgentData?.brands;return Array.isArray(t)&&t.some(t=>e.test(t.brand))||e.test(window.navigator.userAgent)}function Au(e){return typeof window<`u`&&window.navigator!=null&&e.test(window.navigator.userAgentData?.platform||window.navigator.platform)}function ju(e){let t=null;return()=>(t??=e(),t)}var Mu=ju(function(){return Au(/^Mac/i)}),Nu=ju(function(){return Au(/^iPhone/i)}),Pu=ju(function(){return Au(/^iPad/i)||Mu()&&navigator.maxTouchPoints>1}),Fu=ju(function(){return Nu()||Pu()}),Iu=ju(function(){return ku(/AppleWebKit/i)&&(Fu()||!Lu())}),Lu=ju(function(){return ku(/Chrome|CriOS|CrMo/i)}),Ru=ju(function(){return ku(/Android/i)}),zu=ju(function(){return ku(/(Firefox|FxiOS)/i)});function Bu(e){if(Hu())e.focus({preventScroll:!0});else{let t=Uu(e);e.focus(),Wu(t)}}var Vu=null;function Hu(){if(Vu==null){Vu=!1;try{document.createElement(`div`).focus({get preventScroll(){return Vu=!0,!0}})}catch{}}return Vu}function Uu(e){let t=e.parentNode,n=[],r=document.scrollingElement||document.documentElement;for(;t instanceof HTMLElement&&t!==r;)(t.offsetHeight<t.scrollHeight||t.offsetWidth<t.scrollWidth)&&n.push({element:t,scrollTop:t.scrollTop,scrollLeft:t.scrollLeft}),t=t.parentNode;return r instanceof HTMLElement&&n.push({element:r,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft}),n}function Wu(e){for(let{element:t,scrollTop:n,scrollLeft:r}of e)t.scrollTop=n,t.scrollLeft=r}function Gu(e,t,n=!0){let{metaKey:r,ctrlKey:i,altKey:a,shiftKey:o}=t;!Iu()&&zu()&&window.event?.type?.startsWith(`key`)&&e.target===`_blank`&&(Mu()?r=!0:i=!0);let s=Iu()&&Mu()&&!Pu()?new KeyboardEvent(`keydown`,{keyIdentifier:`Enter`,metaKey:r,ctrlKey:i,altKey:a,shiftKey:o}):new MouseEvent(`click`,{metaKey:r,ctrlKey:i,altKey:a,shiftKey:o,detail:1,bubbles:!0,cancelable:!0});Gu.isOpening=n,Bu(e),e.dispatchEvent(s),Gu.isOpening=!1}Gu.isOpening=!1;var Ku=typeof document<`u`?_.useLayoutEffect:()=>{},qu={prefix:String(Math.round(Math.random()*1e10)),current:0},Ju=_.createContext(qu),Yu=_.createContext(!1);typeof window<`u`&&window.document&&window.document.createElement;var Xu=new WeakMap;function Zu(e=!1){let t=(0,_.useContext)(Ju),n=(0,_.useRef)(null);if(n.current===null&&!e){let e=_.default.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED?.ReactCurrentOwner?.current;if(e){let n=Xu.get(e);n==null?Xu.set(e,{id:t.current,state:e.memoizedState}):e.memoizedState!==n.state&&(t.current=n.id,Xu.delete(e))}n.current=++t.current}return n.current}function Qu(e){let t=(0,_.useContext)(Ju),n=Zu(!!e),r=`react-aria${t.prefix}`;return e||`${r}-${n}`}function $u(e){let t=_.useId(),[n]=(0,_.useState)(id()),r=n?`react-aria`:`react-aria${qu.prefix}`;return e||`${r}-${t}`}var ed=typeof _.useId==`function`?$u:Qu;function td(){return!1}function nd(){return!0}function rd(e){return()=>{}}function id(){return typeof _.useSyncExternalStore==`function`?_.useSyncExternalStore(rd,td,nd):(0,_.useContext)(Yu)}var ad=!!(typeof window<`u`&&window.document&&window.document.createElement),od=new Map,sd;typeof FinalizationRegistry<`u`&&(sd=new FinalizationRegistry(e=>{od.delete(e)}));var cd=new WeakMap;function ld(e){let[t,n]=(0,_.useState)(e),r=(0,_.useRef)(null),i=ed(t),a=(0,_.useRef)(null),o=cd.get(a);if(sd&&o!==i&&(o!=null&&sd.unregister(a),sd.register(a,i,a),cd.set(a,i)),ad){let e=od.get(i);e&&!e.includes(r)?e.push(r):od.set(i,[r])}return Ku(()=>{let e=i;return()=>{sd&&(sd.unregister(a),cd.delete(a)),od.delete(e)}},[i]),(0,_.useEffect)(()=>{let e=r.current;return e&&n(e),()=>{e&&(r.current=null)}}),i}function ud(e,t){if(e===t)return e;let n=od.get(e);if(n)return n.forEach(e=>e.current=t),t;let r=od.get(t);return r?(r.forEach(t=>t.current=e),e):t}function dd(...e){return(...t)=>{for(let n of e)typeof n==`function`&&n(...t)}}var fd=e=>hd(e)?e.document:gd(e)?e:e?.ownerDocument??(typeof document<`u`?document:void 0),pd=e=>fd(e)?.defaultView??(typeof window<`u`?window:void 0);function md(e){return typeof e==`object`&&!!e&&`nodeType`in e&&typeof e.nodeType==`number`}function hd(e){return typeof e==`object`&&!!e&&`window`in e&&e.window===e}function gd(e){return md(e)&&e.nodeType===9}function _d(e){return md(e)&&e.nodeType===11&&`host`in e}function vd(e,t){if(!b())return t&&e?e.contains(t):!1;if(!e||!t)return!1;let n=t;for(;n!==null;){if(n===e)return!0;n=typeof n.assignedElements!=`function`&&n.assignedSlot?.parentNode?n.assignedSlot.parentNode:_d(n)?n.host:n.parentNode}return!1}var yd=(e=document)=>{if(!b())return e.activeElement;let t=e.activeElement;for(;t&&`shadowRoot`in t&&t.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t};function bd(e){if(b()&&e.target instanceof Element&&e.target.shadowRoot){if(`composedPath`in e)return e.composedPath()[0]??null;if(`composedPath`in e.nativeEvent)return e.nativeEvent.composedPath()[0]??null}return e.target}function xd(...e){return e.length===1&&e[0]?e[0]:t=>{let n=!1,r=e.map(e=>{let r=Sd(e,t);return n||=typeof r==`function`,r});if(n)return()=>{r.forEach((t,n)=>{typeof t==`function`?t():Sd(e[n],null)})}}}function Sd(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}var Cd=c(m(),1);function wd(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=wd(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Td(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=wd(e))&&(r&&(r+=` `),r+=t);return r}function Ed(...e){let t={...e[0]};for(let n=1;n<e.length;n++){let r=e[n];for(let e in r){let n=t[e],i=r[e];typeof n==`function`&&typeof i==`function`&&e[0]===`o`&&e[1]===`n`&&e.charCodeAt(2)>=65&&e.charCodeAt(2)<=90?t[e]=dd(n,i):(e===`className`||e===`UNSAFE_className`)&&typeof n==`string`&&typeof i==`string`?t[e]=Td(n,i):e===`id`&&n&&i?t.id=ud(n,i):e===`ref`&&n&&i?t.ref=xd(n,i):t[e]=i===void 0?n:i}}return t}var Dd=new Set([`id`]),Od=new Set([`aria-label`,`aria-labelledby`,`aria-describedby`,`aria-details`]),kd=new Set([`href`,`hrefLang`,`target`,`rel`,`download`,`ping`,`referrerPolicy`]),Ad=new Set([`dir`,`lang`,`hidden`,`inert`,`translate`]),jd=new Set(`onClick.onAuxClick.onContextMenu.onDoubleClick.onMouseDown.onMouseEnter.onMouseLeave.onMouseMove.onMouseOut.onMouseOver.onMouseUp.onTouchCancel.onTouchEnd.onTouchMove.onTouchStart.onPointerDown.onPointerMove.onPointerUp.onPointerCancel.onPointerEnter.onPointerLeave.onPointerOver.onPointerOut.onGotPointerCapture.onLostPointerCapture.onScroll.onWheel.onAnimationStart.onAnimationEnd.onAnimationIteration.onTransitionCancel.onTransitionEnd.onTransitionRun.onTransitionStart`.split(`.`)),Md=/^(data-.*)$/;function Nd(e,t={}){let{labelable:n,isLink:r,global:i,events:a=i,propNames:o}=t,s={};for(let t in e)Object.prototype.hasOwnProperty.call(e,t)&&(Dd.has(t)||n&&Od.has(t)||r&&kd.has(t)||i&&Ad.has(t)||a&&(jd.has(t)||t.endsWith(`Capture`)&&jd.has(t.slice(0,-7)))||o?.has(t)||Md.test(t))&&(s[t]=e[t]);return s}var Pd=new Map,Fd=new Set;function Id(){if(typeof window>`u`)return;function e(e){return`propertyName`in e}let t=t=>{let r=bd(t);if(!e(t)||!r)return;let i=Pd.get(r);i||(i=new Set,Pd.set(r,i),r.addEventListener(`transitioncancel`,n,{once:!0})),i.add(t.propertyName)},n=t=>{let r=bd(t);if(!e(t)||!r)return;let i=Pd.get(r);if(i&&(i.delete(t.propertyName),i.size===0&&(r.removeEventListener(`transitioncancel`,n),Pd.delete(r)),Pd.size===0)){for(let e of Fd)e();Fd.clear()}};document.body.addEventListener(`transitionrun`,t),document.body.addEventListener(`transitionend`,n)}typeof document<`u`&&(document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,Id):Id());function Ld(){for(let[e]of Pd)`isConnected`in e&&!e.isConnected&&Pd.delete(e)}function Rd(e){requestAnimationFrame(()=>{Ld(),Pd.size===0?e():Fd.add(e)})}function zd(){let e=(0,_.useRef)(new Map),t=(0,_.useCallback)((t,n,r,i)=>{let a=i?.once?(...t)=>{e.current.delete(r),r(...t)}:r;e.current.set(r,{type:n,eventTarget:t,fn:a,options:i}),t.addEventListener(n,a,i)},[]),n=(0,_.useCallback)((t,n,r,i)=>{let a=e.current.get(r)?.fn||r;t.removeEventListener(n,a,i),e.current.delete(r)},[]),r=(0,_.useCallback)(()=>{e.current.forEach((e,t)=>{n(e.eventTarget,e.type,t,e.options)})},[n]);return(0,_.useEffect)(()=>r,[r]),{addGlobalListener:t,removeGlobalListener:n,removeAllGlobalListeners:r}}function Bd(e){let t=(0,_.useRef)(null),n=(0,_.useRef)(void 0),r=(0,_.useCallback)(t=>{if(typeof e==`function`){let n=e,r=n(t);return()=>{typeof r==`function`?r():n(null)}}if(e)return e.current=t,()=>{e.current=null}},[e]);return(0,_.useMemo)(()=>({get current(){return t.current},set current(e){t.current=e,n.current&&=(n.current(),void 0),e!=null&&(n.current=r(e))}}),[r])}var Vd=_.useInsertionEffect??Ku;function Hd(e){let t=(0,_.useRef)(null);return Vd(()=>{t.current=e},[e]),(0,_.useCallback)((...e)=>{let n=t.current;return n?.(...e)},[])}function Ud(e,t){Ku(()=>{if(e&&e.ref&&t)return e.ref.current=t.current,()=>{e.ref&&(e.ref.current=null)}})}function Wd(e){return e.pointerType===``&&e.isTrusted?!0:Ru()&&e.pointerType?e.type===`click`&&e.buttons===1:e.detail===0&&!e.pointerType}function Gd(e){return!Ru()&&e.width===0&&e.height===0||Ru()&&e.width===1&&e.height===1&&e.pressure===0&&e.detail===0&&e.pointerType===`mouse`}var Kd=typeof Element<`u`&&`checkVisibility`in Element.prototype;function qd(e){let t=pd(e);if(!(e instanceof t.HTMLElement)&&!(e instanceof t.SVGElement))return!1;let{display:n,visibility:r}=e.style,i=n!==`none`&&r!==`hidden`&&r!==`collapse`;if(i){let{getComputedStyle:t}=pd(e),{display:n,visibility:r}=t(e);i=n!==`none`&&r!==`hidden`&&r!==`collapse`}return i}function Jd(e,t){return!e.hasAttribute(`hidden`)&&!e.hasAttribute(`data-react-aria-prevent-focus`)&&(e.nodeName===`DETAILS`&&t&&t.nodeName!==`SUMMARY`?e.hasAttribute(`open`):!0)}function Yd(e,t){return Kd?e.checkVisibility({visibilityProperty:!0})&&!e.closest(`[data-react-aria-prevent-focus]`):e.nodeName!==`#comment`&&qd(e)&&Jd(e,t)&&(!e.parentElement||Yd(e.parentElement,e))}var Xd=[`input:not([disabled]):not([type=hidden])`,`select:not([disabled])`,`textarea:not([disabled])`,`button:not([disabled])`,`a[href]`,`area[href]`,`summary`,`iframe`,`object`,`embed`,`audio[controls]`,`video[controls]`,`[contenteditable]:not([contenteditable^="false"])`,`permission`],Zd=Xd.join(`:not([hidden]),`)+`,[tabindex]:not([disabled]):not([hidden])`;Xd.push(`[tabindex]:not([tabindex="-1"]):not([disabled])`),Xd.join(`:not([hidden]):not([tabindex="-1"]),`);function Qd(e,t){return e.matches(Zd)&&!$d(e)&&(t?.skipVisibilityCheck||Yd(e))}function $d(e){let t=e;for(;t!=null;){if(t instanceof pd(t).HTMLElement&&t.inert)return!0;t=t.parentElement}return!1}function ef(e,t){let n=pd(t),r=fd(t);if(r==null||n==null)return;let i,a=`meta[name="${CSS.escape(e)}"], meta[property="${CSS.escape(e)}"]`,o=r.querySelector(a);return o&&o instanceof n.HTMLMetaElement&&(e===`csp-nonce`&&o.nonce&&(i??=o.nonce||void 0),o.content&&(i??=o.content||void 0)),e===`csp-nonce`&&(i??=n.__webpack_nonce__||globalThis.__webpack_nonce__||void 0),i}var tf=new WeakMap;function nf(e){let t=fd(e),n=tf.get(t);return n??=ef(`csp-nonce`,t),n!==void 0&&tf.set(t,n),n}function rf(e,t){let{ref:n,render:r,...i}=t,a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>xd(n,a),[n,a]);Ku(()=>{},[e,r]);let s={...i,ref:o};return r?r(s,void 0):(0,I.jsx)(e,{...s})}var af={},of=new Proxy({},{get(e,t){if(typeof t!=`string`)return;let n=af[t];return n||(n=rf.bind(null,t),af[t]=n),n}}),sf=Array.isArray,cf=e=>{if(!e&&e!==0&&e!==0n)return``;if(typeof e==`string`)return e;if(typeof e==`number`)return e===e?``+e:``;if(typeof e==`bigint`)return``+e;let t=``;if(sf(e)){let n=e.length;for(let r=0;r<n;r++){let n=e[r];if(!n&&n!==0&&n!==0n)continue;let i=typeof n==`string`?n:cf(n);i&&(t&&(t+=` `),t+=i)}return t}if(typeof e==`object`)for(let n in e)e[n]&&(t&&(t+=` `),t+=n);return t},lf=/\s+/g,uf=Array.isArray,df=e=>typeof e!=`string`||!e?e:e.replace(lf,` `).trim(),ff=e=>{let t=e.length;if(t===0)return!1;let n=e.charCodeAt(0),r=e.charCodeAt(t-1);if(n===32||r===32||n>=9&&n<=13||n===160||r>=9&&r<=13||r===160)return!0;for(let n=0;n<t;n++){let r=e.charCodeAt(n);if(r>=9&&r<=13||r===160||r===32&&n+1<t&&e.charCodeAt(n+1)===32)return!0}return!1},pf=(...e)=>{let t=cf(e);if(t)return ff(t)?df(t):t},mf=e=>e===!1?`false`:e===!0?`true`:e===0?`0`:e,hf=e=>{if(!e||typeof e!=`object`)return!0;for(let t in e)return!1;return!0},gf=(e,t)=>{if(e===t)return!0;if(!e||!t)return!1;let n=e,r=t,i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e=0;e<i.length;e++){let t=i[e];if(!a.includes(t)||n[t]!==r[t])return!1}return!0},_f=(e,t)=>{let n=e;for(let e in t)if(Object.hasOwn(t,e)){let r=t[e];n[e]=e in n?pf(n[e],r):r}return e},vf=(e,t)=>{for(let n=0;n<e.length;n++){let r=e[n];uf(r)?vf(r,t):r&&t.push(r)}},yf=(...e)=>{let t=[];vf(e,t);let n=[];for(let e=0;e<t.length;e++)t[e]&&n.push(t[e]);return n},bf=(e,t)=>{let n=e,r=t,i={};for(let e in n){let t=n[e];if(e in r){let n=r[e];i[e]=uf(t)||uf(n)?yf(n,t):typeof t==`object`&&typeof n==`object`&&t&&n?bf(t,n):n+` `+t}else i[e]=t}for(let e in r)e in n||(i[e]=r[e]);return i},xf={twMerge:!0,twMergeConfig:{}},Sf=256,Cf=128,wf=Symbol(`tv-cache-miss`),Tf=e=>e?.class!=null&&e.class!==``||e?.className!=null&&e.className!==``,Ef=e=>{if(e===void 0)return``;if(e===null)return`null`;if(typeof e==`string`)return e;if(typeof e==`boolean`)return e?`true`:`false`;if(typeof e==`number`)return e===0?`0`:String(e);if(typeof e==`bigint`)return String(e);let t=mf(e),n=typeof t;if(n===`string`||n===`number`||n===`boolean`||n===`bigint`)return String(t);if(n===`object`)try{return JSON.stringify(t)}catch{return null}return null},Df=(e,t)=>{if(t===void 0)return e;if(t===null)return e+`null`;let n=typeof t;if(n===`string`||n===`number`||n===`boolean`||n===`bigint`)return e+String(t);if(Array.isArray(t))return e+t.join(`\0`);try{return e+JSON.stringify(t)}catch{return e+`?`}},Of=(e,t,n,r)=>{let i=``,a=Object.create(null);for(let r=0;r<e.length;r++){let o=e[r];a[o]=1;let s=t[o];n&&n[o]!==void 0&&(s=n[o]);let c=Ef(s);if(c===null)return null;i+=o+`:`+c+`;`}let o=[];for(let e in t)e===`class`||e===`className`||a[e]||(a[e]=1,o.push(e));if(n)for(let e in n)e===`class`||e===`className`||a[e]||n[e]===void 0||(a[e]=1,o.push(e));o.length>1&&o.sort();for(let e=0;e<o.length;e++){let r=o[e],a=t[r];n&&n[r]!==void 0&&(a=n[r]);let s=Ef(a);if(s===null)return null;i+=r+`:`+s+`;`}return i},kf=(e,t)=>{let n=``;for(let t=0;t<e.length;t++){let{conditionKeys:r,source:i}=e[t];for(let e=0;e<r.length;e++){let t=r[e];n+=t+`=`,n=Df(n,i[t]),n+=`,`}n+=`c=`,n=Df(n,i.class),n+=`|cn=`,n=Df(n,i.className),n+=`;`}for(let e=0;e<t.length;e++){let{conditionKeys:r,source:i}=t[e];for(let e=0;e<r.length;e++){let t=r[e];n+=t+`=`,n=Df(n,i[t]),n+=`,`}Array.isArray(i.slots)&&(n+=`slots=`+i.slots.join(`,`)+`,`),n+=`c=`,n=Df(n,i.class),n+=`|cn=`,n=Df(n,i.className),n+=`;`}return n},Af=(e=Sf)=>{let t=new Map,n=null;return{get(e){if(t.has(e))return t.get(e);if(n?.has(e)){let r=n.get(e);return t.set(e,r),r}return wf},set(r,i){t.size>=e&&(n=t,t=new Map),t.set(r,i)}}},jf=(e=Sf)=>{let t=Af(e);return{get(e){return t.get(e)},set(e,n){t.set(e,n)}}},Mf=(e=Cf)=>{let t=new Map,n=null,r=0;return{get(e,i){let a=t.get(e);if(a){let e=a.get(i);if(e!==void 0||a.has(i))return e}if(n){let a=n.get(e);if(a){let n=a.get(i);if(n!==void 0||a.has(i)){let a=t.get(e);return a||(a=new Map,t.set(e,a)),a.has(i)||r++,a.set(i,n),n}}}return wf},set(i,a,o){r>=e&&(n=t,t=new Map,r=0);let s=t.get(i);s||(s=new Map,t.set(i,s)),s.has(a)||r++,s.set(a,o)}}},Nf=(e,t)=>{let n=null;return(r,i)=>{if(!Tf(i))return r;let a=i.class,o=i.className;if(a!=null&&a!==``&&typeof a!=`string`||o!=null&&o!==``&&typeof o!=`string`)return e(t,r,a,o);n??=Mf();let s=r??``,c=(typeof a==`string`?a:``)+`\0`+(typeof o==`string`?o:``),l=n.get(s,c);if(l!==wf)return l;let u=e(t,r,a,o);return n.set(s,c,u),u}};function Pf(){let e=null,t={},n=!1;return{get cachedTwMerge(){return e},set cachedTwMerge(t){e=t},get cachedTwMergeConfig(){return t},set cachedTwMergeConfig(e){t=e},get didTwMergeConfigChange(){return n},set didTwMergeConfigChange(e){n=e},reset(){e=null,t={},n=!1}}}var Ff=Pf(),If=e=>{!hf(e.twMergeConfig)&&!gf(e.twMergeConfig,Ff.cachedTwMergeConfig)&&(Ff.didTwMergeConfigChange=!0,Ff.cachedTwMergeConfig=e.twMergeConfig)},Lf=(e,t)=>{let n=[];for(let r=0;r<t.length;r++){let i=t[r],a=e[i];n.push({key:i,values:a,isEmpty:hf(a)})}return n},Rf=e=>{if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e in r)e!==`class`&&e!==`className`&&i.push(e);t.push({conditionKeys:i,source:r})}return t},zf=e=>{if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let n=0;n<e.length;n++){let r=e[n],i=[];for(let e in r)e!==`slots`&&e!==`class`&&e!==`className`&&i.push(e);t.push({conditionKeys:i,source:r})}return t},Bf=e=>{let t={};for(let n=0;n<e.length;n++){let r=e[n],i=r.source.slots;if(Array.isArray(i))for(let e=0;e<i.length;e++){let n=i[e];t[n]||(t[n]=[]),t[n].push(r)}}return t},Vf=(e,t)=>{let{extend:n=null,slots:r={},variants:i={},compoundVariants:a=[],compoundSlots:o=[],defaultVariants:s={}}=e,c={...xf,...t},l=e.slots!==void 0,u=n?.base?pf(n.base,e?.base):e?.base,d=n?.variants&&!hf(n.variants)?bf(i,n.variants):i,f=n?.defaultVariants&&!hf(n.defaultVariants)?{...n.defaultVariants,...s}:s;If(c);let p=!n?.slots||hf(n.slots),m=l?p&&n?.base?pf(e?.base,n.base):typeof e?.base==`string`||e?.base==null?e.base:pf(e.base):void 0,h=l?{base:m,...r}:{},g=p?h:_f({...n?.slots},hf(h)?{base:e?.base}:h),_=!n?.compoundVariants||hf(n.compoundVariants)?a:yf(n?.compoundVariants,a),v=!n?.compoundSlots||hf(n.compoundSlots)?o:yf(n?.compoundSlots,o),y=Object.keys(d);return{config:c,extend:n,base:u,variants:d,defaultVariants:f,slots:g,compoundVariants:_,compoundSlots:v,compiledVariants:null,compiledCompoundVariants:null,compiledCompoundSlots:null,compiledCompoundSlotsBySlot:null,deferredError:_&&!Array.isArray(_)?TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof _}`):v&&!Array.isArray(v)?TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof v}`):null,mode:l||!p?`slots`:y.length===0?`plain`:`variants`,slotKeys:null,variantKeys:y}},Hf=e=>e.compiledVariants===null?(e.compiledVariants=Lf(e.variants,e.variantKeys),e.compiledCompoundVariants=Rf(e.compoundVariants),e.compiledCompoundSlots=zf(e.compoundSlots),e.compiledCompoundSlotsBySlot=Bf(e.compiledCompoundSlots),e.slotKeys=e.slots&&typeof e.slots==`object`?Object.keys(e.slots):[],e):e,Uf=[],Wf=[],Gf=[],Kf=[],qf=[],Jf=(e,t,n)=>{let r={};for(let t in e)r[t]=e[t];if(t)for(let e in t)t[e]!==void 0&&(r[e]=t[e]);if(n)for(let e in n)n[e]!==void 0&&(r[e]=n[e]);return r},Yf=e=>e==null||e===!1,Xf=(e,t)=>{if(!Array.isArray(e))return e===t||Yf(e)&&Yf(t);for(let n=0;n<e.length;n++){let r=e[n];if(r===t||Yf(r)&&Yf(t))return!0}return!1},Zf=(e,t,n,r)=>{if(e.isEmpty)return null;let i=r?.[e.key]??n?.[e.key];if(i===null)return null;let a=mf(i);if(typeof a==`object`)return null;let o=t?.[e.key],s=a??mf(o);return e.values[s||`false`]},Qf=(e,t)=>{let{conditionKeys:n,source:r}=e;for(let e=0;e<n.length;e++){let i=n[e];if(!Xf(r[i],t[i]))return!1}return!0},$f=(e,t,n)=>{typeof n==`string`?t===`base`&&e.push(n):n&&typeof n==`object`&&n[t]&&e.push(n[t])},ep=(e,t,n)=>{let r=Wf;r.length=0;for(let i=0;i<e.length;i++){let a=Zf(e[i],t,n);a&&r.push(a)}return r},tp=(e,t,n,r,i)=>{let a=Wf;a.length=0;for(let o=0;o<t.length;o++){let s=Zf(t[o],n,r,i),c=e===`base`&&typeof s==`string`?s:s&&s[e];c&&a.push(c)}return a},np=(e,t)=>{let n=Gf;n.length=0;for(let r=0;r<e.length;r++){let i=e[r];Qf(i,t)&&(i.source.class&&n.push(i.source.class),i.source.className&&n.push(i.source.className))}return n},rp=(e,t,n)=>{let r=Kf;r.length=0;for(let i=0;i<t.length;i++){let a=t[i];Qf(a,n)&&($f(r,e,a.source.class),$f(r,e,a.source.className))}return r},ip=(e,t)=>{let n=qf;n.length=0;for(let r=0;r<e.length;r++){let i=e[r];Qf(i,t)&&(i.source.class&&n.push(i.source.class),i.source.className&&n.push(i.source.className))}return n},ap=(e,t)=>{let{base:n,config:r}=e,i=wf,a=Nf(t,r);return(e=>(i===wf&&(i=t(r,n)),a(i,e)))},op=(e,t)=>{let{base:n,config:r,defaultVariants:i,deferredError:a,variantKeys:o}=e,s=e.compiledCompoundVariants,c=e.compiledVariants,l=Uf,u=null,d=Nf(t,r),f=1,p=e=>{let a=s.length>0?np(s,Jf(i,e)):void 0;return t(r,n,ep(c,i,e),a)};return(t=>{if(a)throw a;(c===null||s===null)&&(Hf(e),c=e.compiledVariants,s=e.compiledCompoundVariants,l=e.compiledCompoundSlots??Uf);let n;if(f>0)f--,n=p(t);else{u??=jf();let e=Of(o,i,t);if(e!==null){let r=s.length>0||l.length>0?kf(s,l):``,i=e+`#`+r,a=u.get(i);a===wf?(n=p(t),u.set(i,n)):n=a}else n=p(t)}return d(n,t)})},sp=(e,t)=>{let{config:n,defaultVariants:r,deferredError:i,slots:a,variantKeys:o}=e,s=null,c=null,l=null,u=null,d=!1,f=null,p=null,m=1,h=()=>{if(l!==null)return;(e.compiledVariants===null||e.compiledCompoundVariants===null||e.compiledCompoundSlots===null||e.compiledCompoundSlotsBySlot===null||e.slotKeys===null)&&Hf(e);let i=e.compiledVariants;s=e.compiledCompoundVariants,c=e.compiledCompoundSlots;let o=e.compiledCompoundSlotsBySlot;l=e.slotKeys,d=s.length>0||c.length>0,f=Nf(t,n);let p=Array(l.length);for(let e=0;e<l.length;e++){let c=l[e],u=o[c]??Uf;p[e]=(e,o)=>{let l=d?Jf(r,e,o):void 0,f=l?rp(c,s,l):void 0,p=l?ip(u,l):void 0;return t(n,a[c],tp(c,i,r,e,o),f,p)}}u=p},g=e=>{let t=l,n=u,r=f,i={};for(let a=0;a<t.length;a++){let o=n[a],s=o(e);i[t[a]]=t=>{if(t==null)return s;let n=!1;for(let e in t)if(e!==`class`&&e!==`className`&&t[e]!==void 0){n=!0;break}return r(n?o(e,t):s,t)}}return i};return(e=>{if(i)throw i;if(h(),m>0)return m--,g(e);let t=Of(o,r,e);if(t===null)return g(e);let n=d?kf(s,c):``,a=t+`#`+n;p??=Af();let l=p.get(a);if(l!==wf)return l;let u=g(e);return p.set(a,u),u})},cp=(e,t)=>{if(e.mode===`plain`)return ap(e,t);let n;return(r=>(n??=e.mode===`slots`?sp(e,t):op(e,t),n(r)))},lp=(e,t)=>{e.variantKeys=t.variantKeys,e.extend=t.extend,e.base=t.base,e.slots=t.slots,e.variants=t.variants,e.defaultVariants=t.defaultVariants,e.compoundSlots=t.compoundSlots,e.compoundVariants=t.compoundVariants},up=e=>{let t=(t,n)=>{let r=Vf(t,n),i=cp(r,e);return lp(i,r),i};return{tv:t,createTV:e=>(n,r)=>t(n,r?bf(e,r):e)}},dp=(e,t)=>{let n=e.length,r=t.length,i=Array(n+r);for(let t=0;t<n;t++)i[t]=e[t];for(let e=0;e<r;e++)i[n+e]=t[e];return i},fp=(e,t)=>({classGroupId:e,validator:t}),pp=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),mp=`-`,hp=[],gp=`arbitrary..`,_p=e=>{let t=bp(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e[0]===`[`&&e[e.length-1]===`]`)return yp(e);let n=e.split(mp);return vp(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?dp(i,t):t:i||hp}return n[e]||hp}}},vp=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=vp(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(mp):e.slice(t).join(mp),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},yp=e=>{let t=e.slice(1,-1),n=t.indexOf(`:`);if(n===-1)return;let r=t.slice(0,n);return r?gp+r:void 0},bp=e=>{let{theme:t,classGroups:n}=e;return xp(n,t)},xp=(e,t)=>{let n=pp();for(let r in e){let i=e[r];Sp(i,n,r,t)}return n},Sp=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Cp(i,t,n,r)}},Cp=(e,t,n,r)=>{if(typeof e==`string`){wp(e,t,n);return}if(typeof e==`function`){Tp(e,t,n,r);return}Ep(e,t,n,r)},wp=(e,t,n)=>{let r=e===``?t:Dp(t,e);r.classGroupId=n},Tp=(e,t,n,r)=>{if(Op(e)){Sp(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(fp(n,e))},Ep=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Sp(o,Dp(t,a),n,r)}},Dp=(e,t)=>{let n=e,r=t.split(mp),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=pp(),n.nextPart.set(t,i)),n=i}return n},Op=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,kp=`!`,Ap=58,jp=47,Mp=91,Np=93,Pp=40,Fp=41,Ip=33,Lp=(e,t,n,r)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:void 0}),Rp=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e.charCodeAt(s);if(n===0&&r===0){if(o===Ap){t.push(e.slice(i,s)),i=s+1;continue}if(o===jp){a=s;continue}}o===Mp?n++:o===Np?n--:o===Pp?r++:o===Fp&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1,u=s.length-1;s.charCodeAt(u)===Ip?(c=s.slice(0,-1),l=!0):s.charCodeAt(0)===Ip&&(c=s.slice(1),l=!0);let d=a&&a>i?a-i:void 0;return Lp(t,l,c,d)},zp=e=>{let t=new Set(e.orderSensitiveModifiers);return e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);if(o||s){if(r.length>0){r.sort();for(let e=0;e<r.length;e++)n.push(r[e]);r=[]}n.push(a)}else r.push(a)}if(r.length>0){r.sort();for(let e=0;e<r.length;e++)n.push(r[e])}return n}},Bp={isExternal:!0,classId:-1,conflictIds:[]},Vp=4096,Hp=16384,Up=e=>{let t=zp(e),n=Wp(e),{getClassGroupId:r,getConflictingClassGroupIds:i}=_p(e),a=Object.create(null),o=Object.create(null),s=0,c=new Int32Array(256),l=0,u=new Uint8Array(64),d=!1,f=e=>{let t=[],n=e.length,r=-1;d=!1;for(let i=0;i<n;i++){let n=e.charCodeAt(i);n===32?r!==-1&&(t.push(e.slice(r,i)),r=-1):n>=9&&n<=13?(d=!0,r!==-1&&(t.push(e.slice(r,i)),r=-1)):r===-1&&(r=i)}return r!==-1&&t.push(e.slice(r)),t},p=new Map,m=0,h=e=>{let t=p.get(e);if(t===void 0&&(t=m++,p.set(e,t),t>=c.length)){let e=new Int32Array(c.length*2);e.set(c),c=e}return t},g=e=>{let{isExternal:a,modifiers:o,hasImportantModifier:s,baseClassName:c,maybePostfixModifierPosition:l}=Rp(e);if(a)return Bp;let u=!!l,d;if(u){let e=c.substring(0,l);d=r(e);let t=d&&n[d]?r(c):void 0;t&&t!==d&&(d=t,u=!1)}else d=r(c);if(!d){if(!u||(d=r(c),!d))return Bp;u=!1}let f=o.length===0?``:o.length===1?o[0]:t(o).join(`:`),p=s?f+kp:f,m=i(d,u),g=[];for(let e=0;e<m.length;e++)g.push(h(p+m[e]));return{isExternal:!1,classId:h(p+d),conflictIds:g}},_=e=>{let t=a[e];return t===void 0?(t=o[e],t===void 0&&(t=g(e)),a[e]=t,++s>Vp&&(s=0,o=a,a=Object.create(null)),t):t};return{parseClassName:Rp,sortModifiers:t,postfixLookupClassGroupIds:n,getClassGroupId:r,getConflictingClassGroupIds:i,getClassDescriptor:_,mergeClassList:e=>{let t=f(e),n=t.length;if(n===1)return t[0];m>Hp&&(p.clear(),m=0,a=Object.create(null),o=Object.create(null),s=0),l=l+1|0,l===0&&(l=1);let r=l;if(n>u.length){let e=u.length;for(;e<n;)e*=2;u=new Uint8Array(e)}let i=!1,h=0;for(let e=n-1;e>=0;--e){let n=t[e];h+=n.length;let a=_(n);if(a.isExternal){u[e]=1;continue}let o=a.classId;if(c[o]===r){u[e]=0,i=!0;continue}c[o]=r;let s=a.conflictIds;for(let e=0;e<s.length;e++)c[s[e]]=r;u[e]=1}if(!i&&!d&&e.length===h+n-1)return e;let g=``;for(let e=0;e<n;e++)u[e]===1&&(g&&(g+=` `),g+=t[e]);return g}}},Wp=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},Gp=500,Kp=e=>{let t,n,r=Object.create(null),i=Object.create(null),a=0,o=r=>(t=Up(e()),n=t.mergeClassList,c.mergeString=s,s(r)),s=e=>{let t=r[e];return t===void 0?(t=i[e],t===void 0&&(t=n(e)),r[e]=t,++a>Gp&&(a=0,i=r,r=Object.create(null)),t):t},c=(...e)=>c.mergeString(cf(e));return c.mergeString=o,c},qp=[],Jp=e=>{let t=t=>t[e]||qp;return t.isThemeGetter=!0,t},Yp=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,Xp=/^\((?:(\w[\w-]*):)?(.+)\)$/i,Zp=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,Qp=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,$p=/\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$/,em=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,tm=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,nm=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,rm=Number,im=Number.isNaN,am=Number.isInteger,om=e=>Zp.test(e),sm=e=>!!e&&!im(rm(e)),cm=e=>!!e&&am(rm(e)),lm=e=>e.endsWith(`%`)&&sm(e.slice(0,-1)),um=e=>Qp.test(e),dm=()=>!0,fm=e=>$p.test(e)&&!em.test(e),pm=()=>!1,mm=e=>tm.test(e),hm=e=>nm.test(e),gm=e=>!L(e)&&!R(e),_m=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)),vm=e=>Om(e,Mm,pm),L=e=>Yp.test(e),ym=e=>Om(e,Nm,fm),bm=e=>Om(e,Pm,sm),xm=e=>Om(e,Im,dm),Sm=e=>Om(e,Fm,pm),Cm=e=>Om(e,Am,pm),eee=e=>Om(e,jm,hm),wm=e=>Om(e,Lm,mm),R=e=>Xp.test(e),Tm=e=>km(e,Nm),tee=e=>km(e,Fm),Em=e=>km(e,Am),nee=e=>km(e,Mm),ree=e=>km(e,jm),Dm=e=>km(e,Lm,!0),iee=e=>km(e,Im,!0),Om=(e,t,n)=>{let r=Yp.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},km=(e,t,n=!1)=>{let r=Xp.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=()=>{let e=Jp(`color`),t=Jp(`font`),n=Jp(`text`),r=Jp(`font-weight`),i=Jp(`tracking`),a=Jp(`leading`),o=Jp(`breakpoint`),s=Jp(`container`),c=Jp(`spacing`),l=Jp(`radius`),u=Jp(`shadow`),d=Jp(`inset-shadow`),f=Jp(`text-shadow`),p=Jp(`drop-shadow`),m=Jp(`blur`),h=Jp(`perspective`),g=Jp(`aspect`),_=Jp(`ease`),v=Jp(`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(),R,L],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[R,L,c],T=()=>[om,`full`,`auto`,...w()],E=()=>[cm,`none`,`subgrid`,R,L],D=()=>[`auto`,{span:[`full`,cm,R,L]},cm,R,L],O=()=>[cm,`auto`,R,L],k=()=>[`auto`,`min`,`max`,`fr`,R,L],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],ee=()=>[`auto`,...w()],te=()=>[om,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],ne=()=>[om,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],re=()=>[om,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],M=()=>[e,R,L],N=()=>[...b(),Em,Cm,{position:[R,L]}],ie=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],ae=()=>[`auto`,`cover`,`contain`,nee,vm,{size:[R,L]}],oe=()=>[lm,Tm,ym],se=()=>[``,`none`,`full`,l,R,L],P=()=>[``,sm,Tm,ym],ce=()=>[`solid`,`dashed`,`dotted`,`double`],le=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],ue=()=>[sm,lm,Em,Cm],de=()=>[``,`none`,m,R,L],fe=()=>[`none`,sm,R,L],pe=()=>[`none`,sm,R,L],me=()=>[sm,R,L],he=()=>[om,`full`,...w()];return{theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[um],breakpoint:[um],color:[dm],container:[um],"drop-shadow":[um],ease:[`in`,`out`,`in-out`],font:[gm],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[um],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[um],shadow:[um],spacing:[`px`,sm],text:[um],"text-shadow":[um],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,om,L,R,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,R,L]}],"container-named":[_m],columns:[{columns:[sm,L,R,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:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[cm,`auto`,R,L]}],basis:[{basis:[om,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[sm,om,`auto`,`initial`,`none`,L]}],grow:[{grow:[``,sm,R,L]}],shrink:[{shrink:[``,sm,R,L]}],order:[{order:[cm,`first`,`last`,`none`,R,L]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"row-start":[{"row-start":O()}],"row-end":[{"row-end":O()}],"grid-flow":[{"grid-flow":[`row`,`col`,`dense`,`row-dense`,`col-dense`]}],"auto-cols":[{"auto-cols":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],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:ee()}],mx:[{mx:ee()}],my:[{my:ee()}],ms:[{ms:ee()}],me:[{me:ee()}],mbs:[{mbs:ee()}],mbe:[{mbe:ee()}],mt:[{mt:ee()}],mr:[{mr:ee()}],mb:[{mb:ee()}],ml:[{ml:ee()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:te()}],"inline-size":[{inline:[`auto`,...ne()]}],"min-inline-size":[{"min-inline":[`auto`,...ne()]}],"max-inline-size":[{"max-inline":[`none`,...ne()]}],"block-size":[{block:[`auto`,...re()]}],"min-block-size":[{"min-block":[`auto`,...re()]}],"max-block-size":[{"max-block":[`none`,...re()]}],w:[{w:[s,`screen`,...te()]}],"min-w":[{"min-w":[s,`screen`,`none`,...te()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...te()]}],h:[{h:[`screen`,`lh`,...te()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...te()]}],"max-h":[{"max-h":[`screen`,`lh`,...te()]}],"font-size":[{text:[`base`,n,Tm,ym]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,iee,xm]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,lm,L]}],"font-family":[{font:[tee,Sm,t]}],"font-features":[{"font-features":[L]}],"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,R,L]}],"line-clamp":[{"line-clamp":[sm,`none`,R,bm]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,R,L]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,R,L]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:M()}],"text-color":[{text:M()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...ce(),`wavy`]}],"text-decoration-thickness":[{decoration:[sm,`from-font`,`auto`,R,ym]}],"text-decoration-color":[{decoration:M()}],"underline-offset":[{"underline-offset":[sm,`auto`,R,L]}],"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:[cm,R,L]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,R,L]}],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`,R,L]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:N()}],"bg-repeat":[{bg:ie()}],"bg-size":[{bg:ae()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},cm,R,L],radial:[``,R,L],conic:[cm,R,L]},ree,eee]}],"bg-color":[{bg:M()}],"gradient-from-pos":[{from:oe()}],"gradient-via-pos":[{via:oe()}],"gradient-to-pos":[{to:oe()}],"gradient-from":[{from:M()}],"gradient-via":[{via:M()}],"gradient-to":[{to:M()}],rounded:[{rounded:se()}],"rounded-s":[{"rounded-s":se()}],"rounded-e":[{"rounded-e":se()}],"rounded-t":[{"rounded-t":se()}],"rounded-r":[{"rounded-r":se()}],"rounded-b":[{"rounded-b":se()}],"rounded-l":[{"rounded-l":se()}],"rounded-ss":[{"rounded-ss":se()}],"rounded-se":[{"rounded-se":se()}],"rounded-ee":[{"rounded-ee":se()}],"rounded-es":[{"rounded-es":se()}],"rounded-tl":[{"rounded-tl":se()}],"rounded-tr":[{"rounded-tr":se()}],"rounded-br":[{"rounded-br":se()}],"rounded-bl":[{"rounded-bl":se()}],"border-w":[{border:P()}],"border-w-x":[{"border-x":P()}],"border-w-y":[{"border-y":P()}],"border-w-s":[{"border-s":P()}],"border-w-e":[{"border-e":P()}],"border-w-bs":[{"border-bs":P()}],"border-w-be":[{"border-be":P()}],"border-w-t":[{"border-t":P()}],"border-w-r":[{"border-r":P()}],"border-w-b":[{"border-b":P()}],"border-w-l":[{"border-l":P()}],"divide-x":[{"divide-x":P()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":P()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...ce(),`hidden`,`none`]}],"divide-style":[{divide:[...ce(),`hidden`,`none`]}],"border-color":[{border:M()}],"border-color-x":[{"border-x":M()}],"border-color-y":[{"border-y":M()}],"border-color-s":[{"border-s":M()}],"border-color-e":[{"border-e":M()}],"border-color-bs":[{"border-bs":M()}],"border-color-be":[{"border-be":M()}],"border-color-t":[{"border-t":M()}],"border-color-r":[{"border-r":M()}],"border-color-b":[{"border-b":M()}],"border-color-l":[{"border-l":M()}],"divide-color":[{divide:M()}],"outline-style":[{outline:[...ce(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[sm,R,L]}],"outline-w":[{outline:[``,sm,Tm,ym]}],"outline-color":[{outline:M()}],shadow:[{shadow:[``,`none`,u,Dm,wm]}],"shadow-color":[{shadow:M()}],"inset-shadow":[{"inset-shadow":[`none`,d,Dm,wm]}],"inset-shadow-color":[{"inset-shadow":M()}],"ring-w":[{ring:P()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:M()}],"ring-offset-w":[{"ring-offset":[sm,ym]}],"ring-offset-color":[{"ring-offset":M()}],"inset-ring-w":[{"inset-ring":P()}],"inset-ring-color":[{"inset-ring":M()}],"text-shadow":[{"text-shadow":[`none`,f,Dm,wm]}],"text-shadow-color":[{"text-shadow":M()}],opacity:[{opacity:[sm,R,L]}],"mix-blend":[{"mix-blend":[...le(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":le()}],"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":[sm]}],"mask-image-linear-from-pos":[{"mask-linear-from":ue()}],"mask-image-linear-to-pos":[{"mask-linear-to":ue()}],"mask-image-linear-from-color":[{"mask-linear-from":M()}],"mask-image-linear-to-color":[{"mask-linear-to":M()}],"mask-image-t-from-pos":[{"mask-t-from":ue()}],"mask-image-t-to-pos":[{"mask-t-to":ue()}],"mask-image-t-from-color":[{"mask-t-from":M()}],"mask-image-t-to-color":[{"mask-t-to":M()}],"mask-image-r-from-pos":[{"mask-r-from":ue()}],"mask-image-r-to-pos":[{"mask-r-to":ue()}],"mask-image-r-from-color":[{"mask-r-from":M()}],"mask-image-r-to-color":[{"mask-r-to":M()}],"mask-image-b-from-pos":[{"mask-b-from":ue()}],"mask-image-b-to-pos":[{"mask-b-to":ue()}],"mask-image-b-from-color":[{"mask-b-from":M()}],"mask-image-b-to-color":[{"mask-b-to":M()}],"mask-image-l-from-pos":[{"mask-l-from":ue()}],"mask-image-l-to-pos":[{"mask-l-to":ue()}],"mask-image-l-from-color":[{"mask-l-from":M()}],"mask-image-l-to-color":[{"mask-l-to":M()}],"mask-image-x-from-pos":[{"mask-x-from":ue()}],"mask-image-x-to-pos":[{"mask-x-to":ue()}],"mask-image-x-from-color":[{"mask-x-from":M()}],"mask-image-x-to-color":[{"mask-x-to":M()}],"mask-image-y-from-pos":[{"mask-y-from":ue()}],"mask-image-y-to-pos":[{"mask-y-to":ue()}],"mask-image-y-from-color":[{"mask-y-from":M()}],"mask-image-y-to-color":[{"mask-y-to":M()}],"mask-image-radial":[{"mask-radial":[R,L]}],"mask-image-radial-from-pos":[{"mask-radial-from":ue()}],"mask-image-radial-to-pos":[{"mask-radial-to":ue()}],"mask-image-radial-from-color":[{"mask-radial-from":M()}],"mask-image-radial-to-color":[{"mask-radial-to":M()}],"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":[sm]}],"mask-image-conic-from-pos":[{"mask-conic-from":ue()}],"mask-image-conic-to-pos":[{"mask-conic-to":ue()}],"mask-image-conic-from-color":[{"mask-conic-from":M()}],"mask-image-conic-to-color":[{"mask-conic-to":M()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:N()}],"mask-repeat":[{mask:ie()}],"mask-size":[{mask:ae()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,R,L]}],filter:[{filter:[``,`none`,R,L]}],blur:[{blur:de()}],brightness:[{brightness:[sm,R,L]}],contrast:[{contrast:[sm,R,L]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Dm,wm]}],"drop-shadow-color":[{"drop-shadow":M()}],grayscale:[{grayscale:[``,sm,R,L]}],"hue-rotate":[{"hue-rotate":[sm,R,L]}],invert:[{invert:[``,sm,R,L]}],saturate:[{saturate:[sm,R,L]}],sepia:[{sepia:[``,sm,R,L]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,R,L]}],"backdrop-blur":[{"backdrop-blur":de()}],"backdrop-brightness":[{"backdrop-brightness":[sm,R,L]}],"backdrop-contrast":[{"backdrop-contrast":[sm,R,L]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,sm,R,L]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[sm,R,L]}],"backdrop-invert":[{"backdrop-invert":[``,sm,R,L]}],"backdrop-opacity":[{"backdrop-opacity":[sm,R,L]}],"backdrop-saturate":[{"backdrop-saturate":[sm,R,L]}],"backdrop-sepia":[{"backdrop-sepia":[``,sm,R,L]}],"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`,R,L]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[sm,`initial`,R,L]}],ease:[{ease:[`linear`,`initial`,_,R,L]}],delay:[{delay:[sm,R,L]}],animate:[{animate:[`none`,v,R,L]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,R,L]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:fe()}],"rotate-x":[{"rotate-x":fe()}],"rotate-y":[{"rotate-y":fe()}],"rotate-z":[{"rotate-z":fe()}],scale:[{scale:pe()}],"scale-x":[{"scale-x":pe()}],"scale-y":[{"scale-y":pe()}],"scale-z":[{"scale-z":pe()}],"scale-3d":[`scale-3d`],skew:[{skew:me()}],"skew-x":[{"skew-x":me()}],"skew-y":[{"skew-y":me()}],transform:[{transform:[R,L,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:he()}],"translate-x":[{"translate-x":he()}],"translate-y":[{"translate-y":he()}],"translate-z":[{"translate-z":he()}],"translate-none":[`translate-none`],zoom:[{zoom:[cm,R,L]}],accent:[{accent:M()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:M()}],"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`,R,L]}],"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":M()}],"scrollbar-track-color":[{"scrollbar-track":M()}],"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`,R,L]}],fill:[{fill:[`none`,...M()]}],"stroke-w":[{stroke:[sm,Tm,ym,bm]}],stroke:[{stroke:[`none`,...M()]}],"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`]}},zm=(e,{extend:t={},override:n={}})=>(Vm(e.theme,n.theme),Vm(e.classGroups,n.classGroups),Vm(e.conflictingClassGroups,n.conflictingClassGroups),Vm(e.conflictingClassGroupModifiers,n.conflictingClassGroupModifiers),Bm(e,`postfixLookupClassGroups`,n.postfixLookupClassGroups),Bm(e,`orderSensitiveModifiers`,n.orderSensitiveModifiers),Hm(e.theme,t.theme),Hm(e.classGroups,t.classGroups),Hm(e.conflictingClassGroups,t.conflictingClassGroups),Hm(e.conflictingClassGroupModifiers,t.conflictingClassGroupModifiers),Um(e,t,`postfixLookupClassGroups`),Um(e,t,`orderSensitiveModifiers`),e),Bm=(e,t,n)=>{n!==void 0&&(e[t]=n)},Vm=(e,t)=>{if(t)for(let n in t)Bm(e,n,t[n])},Hm=(e,t)=>{if(t)for(let n in t)Um(e,t,n)},Um=(e,t,n)=>{let r=t[n];r!==void 0&&(e[n]=e[n]?e[n].concat(r):r)},Wm=e=>Kp(e?typeof e==`function`?()=>e(Rm()):()=>zm(Rm(),e):Rm),Gm=e=>{if(hf(e))return;let t=e,n={...t.extend??{}};for(let e of[`theme`,`classGroups`,`conflictingClassGroups`,`conflictingClassGroupModifiers`,`postfixLookupClassGroups`,`orderSensitiveModifiers`,`cacheSize`,`prefix`,`separator`,`experimentalParseClassName`])t[e]!==void 0&&n[e]===void 0&&(n[e]=t[e]);let r={};if(Object.keys(n).length>0&&(r.extend=n),t.override!=null&&!hf(t.override)&&(r.override=t.override),r.extend||r.override)return r},Km=e=>{let t=Wm(Gm(e));return e=>t.mergeString(e)},qm,Jm=()=>(qm||=Wm(),qm),Ym=()=>((!Ff.cachedTwMerge||Ff.didTwMergeConfigChange)&&(Ff.didTwMergeConfigChange=!1,Ff.cachedTwMerge=Km(Ff.cachedTwMergeConfig)),Ff.cachedTwMerge),Xm=e=>{let t=e?.twMergeConfig;t&&!hf(t)&&(gf(t,Ff.cachedTwMergeConfig)||(Ff.cachedTwMergeConfig=t,Ff.didTwMergeConfigChange=!0))},Zm=e=>cf(e);(()=>{let e=Error();return!(`line`in e)&&!(`lineNumber`in e)})();var Qm=Ff.reset.bind(Ff);Ff.reset=()=>{qm=void 0,Qm()};var $m=(e,t)=>{let n=Zm(e);return!n||!(t?.twMerge??!0)?n||void 0:n.indexOf(` `)===-1?n:(Xm(t),(t?.twMergeConfig&&!hf(t.twMergeConfig)?Ym():Jm().mergeString)(n)||void 0)},eh=up((e,...t)=>$m(t,e)),th=eh.tv;eh.createTV;var nh=pf,rh=th({defaultVariants:{status:`default`},slots:{base:`alert`,content:`alert__content`,description:`alert__description`,indicator:`alert__indicator`,title:`alert__title`},variants:{status:{accent:{base:`alert--accent`},danger:{base:`alert--danger`},default:{base:`alert--default`},success:{base:`alert--success`},warning:{base:`alert--warning`}}}}),ih=th({base:`button`,defaultVariants:{fullWidth:!1,isIconOnly:!1,size:`md`,variant:`primary`},variants:{fullWidth:{false:``,true:`button--full-width`},isIconOnly:{true:`button--icon-only`},size:{lg:`button--lg`,md:`button--md`,sm:`button--sm`},variant:{danger:`button--danger`,"danger-soft":`button--danger-soft`,ghost:`button--ghost`,outline:`button--outline`,primary:`button--primary`,secondary:`button--secondary`,tertiary:`button--tertiary`}}}),ah=th({defaultVariants:{variant:`default`},slots:{base:`card`,content:`card__content`,description:`card__description`,footer:`card__footer`,header:`card__header`,title:`card__title`},variants:{variant:{default:{base:`card--default`},secondary:{base:`card--secondary`},tertiary:{base:`card--tertiary`},transparent:{base:`card--transparent`}}}}),oh=Symbol(`default`);function sh(e){let{className:t,style:n,children:r,defaultClassName:i,defaultChildren:a,defaultStyle:o,values:s,render:c}=e;return(0,_.useMemo)(()=>{let e,l,u;return e=typeof t==`function`?t({...s,defaultClassName:i}):t,l=typeof n==`function`?n({...s,defaultStyle:o||{}}):n,u=typeof r==`function`?r({...s,defaultChildren:a}):r??a,{className:e??i,style:l||o?{...o,...l}:void 0,children:u??a,"data-rac":``,render:c?e=>c(e,s):void 0}},[t,n,r,i,a,o,s,c])}function ch(e,t){return n=>t(typeof e==`function`?e(n):e,n)}function lh(e,t){let n=(0,_.useContext)(e);if(t===null)return null;if(n&&typeof n==`object`&&`slots`in n&&n.slots){let e=t||oh;if(!n.slots[e]){let e=new Intl.ListFormat().format(Object.keys(n.slots).map(e=>`"${e}"`)),r=t?`Invalid slot "${t}".`:`A slot prop is required.`;throw Error(`${r} Valid slot names are ${e}.`)}return n.slots[e]}return n}function uh(e,t,n){let{ref:r,...i}=lh(n,e.slot)||{},a=Bd((0,_.useMemo)(()=>xd(t,r),[t,r])),o=Ed(i,e);return`style`in i&&i.style&&`style`in e&&e.style&&(o.style=typeof i.style==`function`||typeof e.style==`function`?t=>{let n=typeof i.style==`function`?i.style(t):i.style,r={...t.defaultStyle,...n},a=typeof e.style==`function`?e.style({...t,defaultStyle:r}):e.style;return{...r,...a}}:{...i.style,...e.style}),[o,a]}function dh(e,t,n){let{render:r,...i}=t,a=(0,_.useRef)(null),o=(0,_.useMemo)(()=>xd(n,a),[n,a]);Ku(()=>{},[e,r]);let s={...i,ref:o};return r?r(s,void 0):_.createElement(e,s)}var fh={},ph=new Proxy({},{get(e,t){if(typeof t!=`string`)return;let n=fh[t];return n||(n=(0,_.forwardRef)(dh.bind(null,t)),fh[t]=n),n}});typeof HTMLTemplateElement<`u`&&(Object.defineProperty(HTMLTemplateElement.prototype,"firstChild",{configurable:!0,enumerable:!0,get:function(){return this.content.firstChild}}),Object.defineProperty(HTMLTemplateElement.prototype,"appendChild",{configurable:!0,enumerable:!0,value:function(e){return this.content.appendChild(e)}}),Object.defineProperty(HTMLTemplateElement.prototype,"removeChild",{configurable:!0,enumerable:!0,value:function(e){return this.content.removeChild(e)}}),Object.defineProperty(HTMLTemplateElement.prototype,"insertBefore",{configurable:!0,enumerable:!0,value:function(e,t){return this.content.insertBefore(e,t)}}));var mh=(0,_.createContext)(!1);function hh(e){let t=(t,n)=>(0,_.useContext)(mh)?null:e(t,n);return t.displayName=e.displayName||e.name,(0,_.forwardRef)(t)}var gh=(0,_.createContext)(null),_h=7e3,vh=null;function yh(e,t=`assertive`,n=_h){vh?vh.announce(e,t,n):(vh=new bh,(typeof IS_REACT_ACT_ENVIRONMENT==`boolean`?IS_REACT_ACT_ENVIRONMENT:typeof jest<`u`)?vh.announce(e,t,n):setTimeout(()=>{vh?.isAttached()&&vh?.announce(e,t,n)},100))}var bh=class{constructor(){this.node=null,this.assertiveLog=null,this.politeLog=null,typeof document<`u`&&(this.node=document.createElement(`div`),this.node.dataset.liveAnnouncer=`true`,Object.assign(this.node.style,{border:0,clip:`rect(0 0 0 0)`,clipPath:`inset(50%)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`}),this.assertiveLog=this.createLog(`assertive`),this.node.appendChild(this.assertiveLog),this.politeLog=this.createLog(`polite`),this.node.appendChild(this.politeLog),document.body.prepend(this.node))}isAttached(){return this.node?.isConnected}createLog(e){let t=document.createElement(`div`);return t.setAttribute(`role`,`log`),t.setAttribute(`aria-live`,e),t.setAttribute(`aria-relevant`,`additions`),t}destroy(){this.node&&=(document.body.removeChild(this.node),null)}announce(e,t=`assertive`,n=_h){if(!this.node)return;let r=document.createElement(`div`);typeof e==`object`?(r.setAttribute(`role`,`img`),r.setAttribute(`aria-labelledby`,e[`aria-labelledby`])):r.textContent=e,t===`assertive`?this.assertiveLog?.appendChild(r):this.politeLog?.appendChild(r),e!==``&&setTimeout(()=>{r.remove()},n)}clear(e){this.node&&((!e||e===`assertive`)&&this.assertiveLog&&(this.assertiveLog.innerHTML=``),(!e||e===`polite`)&&this.politeLog&&(this.politeLog.innerHTML=``))}};function xh(e){let t=e;return t.nativeEvent=e,t.isDefaultPrevented=()=>t.defaultPrevented,t.isPropagationStopped=()=>t.cancelBubble,t.persist=()=>{},t}function Sh(e,t){Object.defineProperty(e,"target",{value:t}),Object.defineProperty(e,"currentTarget",{value:t})}function Ch(e){let t=(0,_.useRef)({isFocused:!1,observer:null});return Ku(()=>{let e=t.current;return()=>{e.observer&&=(e.observer.disconnect(),null)}},[]),(0,_.useCallback)(n=>{let r=bd(n);if(r instanceof HTMLButtonElement||r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement||r instanceof HTMLSelectElement){t.current.isFocused=!0;let n=r;n.addEventListener(`focusout`,r=>{if(t.current.isFocused=!1,n.disabled){let t=xh(r);e?.(t)}t.current.observer&&(t.current.observer.disconnect(),t.current.observer=null)},{once:!0}),t.current.observer=new MutationObserver(()=>{if(t.current.isFocused&&n.disabled){t.current.observer?.disconnect();let e=n===yd()?null:yd();n.dispatchEvent(new FocusEvent(`blur`,{relatedTarget:e})),n.dispatchEvent(new FocusEvent(`focusout`,{bubbles:!0,relatedTarget:e}))}}),t.current.observer.observe(n,{attributes:!0,attributeFilter:[`disabled`]})}},[e])}var wh=!1;function Th(e){for(;e&&!Qd(e,{skipVisibilityCheck:!0});)e=e.parentElement;let t=yd(pd(e).document);if(!t||t===e)return;let n=e?.getRootNode(),r=n!=null&&_d(n)?n:pd(e),i=t=>t===e||t!=null&&vd(e,t),a=e=>e===t||t!=null&&e!=null&&vd(t,e);wh=!0;let o=!1,s=e=>{(a(bd(e))||o)&&e.stopImmediatePropagation()},c=n=>{(a(bd(n))||o)&&(n.stopImmediatePropagation(),!e&&!o&&(o=!0,Bu(t),d()))},l=e=>{(i(bd(e))||o)&&e.stopImmediatePropagation()},u=e=>{(i(bd(e))||o)&&(e.stopImmediatePropagation(),o||(o=!0,Bu(t),d()))};r.addEventListener(`blur`,s,!0),r.addEventListener(`focusout`,c,!0),r.addEventListener(`focusin`,u,!0),r.addEventListener(`focus`,l,!0);let d=()=>{cancelAnimationFrame(f),r.removeEventListener(`blur`,s,!0),r.removeEventListener(`focusout`,c,!0),r.removeEventListener(`focusin`,u,!0),r.removeEventListener(`focus`,l,!0),wh=!1,o=!1},f=requestAnimationFrame(d);return d}var Eh=null,Dh=new Set,Oh=new Map,kh=!1,Ah=!1,jh={Tab:!0,Escape:!0};function Mh(e,t){for(let n of Dh)n(e,t)}function Nh(e){return!(e.metaKey||!Mu()&&e.altKey||e.ctrlKey||e.key===`Control`||e.key===`Shift`||e.key===`Meta`)}function Ph(e){kh=!0,!Gu.isOpening&&Nh(e)&&(Eh=`keyboard`,Mh(`keyboard`,e))}function Fh(e){Eh=`pointer`,`pointerType`in e&&e.pointerType,(e.type===`mousedown`||e.type===`pointerdown`)&&(kh=!0,Mh(`pointer`,e))}function Ih(e){!Gu.isOpening&&Wd(e)&&(kh=!0,Eh=`virtual`)}function Lh(e){if(wh)return;let t=bd(e),n=pd(t),r=fd(t);if(t===n){Ah=!0;return}t!==r&&e.isTrusted&&(!kh&&!Ah&&(Eh=`virtual`,Mh(`virtual`,e)),kh=!1,Ah=!1)}function Rh(){wh||(kh=!1,Ah=!0)}function zh(e){if(typeof window>`u`||typeof document>`u`)return;let t=pd(e),n=fd(e);if(Oh.get(t))return;let r=t.HTMLElement.prototype.focus;Reflect.defineProperty(t.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:function(){kh=!0,r.apply(this,arguments)}}),n.addEventListener(`keydown`,Ph,!0),n.addEventListener(`keyup`,Ph,!0),n.addEventListener(`click`,Ih,!0),t.addEventListener(`focus`,Lh,!0),t.addEventListener(`blur`,Rh,!1),typeof PointerEvent<`u`&&(n.addEventListener(`pointerdown`,Fh,!0),n.addEventListener(`pointermove`,Fh,!0),n.addEventListener(`pointerup`,Fh,!0)),t.addEventListener(`beforeunload`,()=>{Bh(e)},{once:!0}),Oh.set(t,{focus:r})}var Bh=(e,t)=>{let n=pd(e),r=fd(e);t&&r.removeEventListener(`DOMContentLoaded`,t),Oh.has(n)&&(Reflect.defineProperty(n.HTMLElement.prototype,"focus",{configurable:!0,writable:!0,value:Oh.get(n).focus}),r.removeEventListener(`keydown`,Ph,!0),r.removeEventListener(`keyup`,Ph,!0),r.removeEventListener(`click`,Ih,!0),n.removeEventListener(`focus`,Lh,!0),n.removeEventListener(`blur`,Rh,!1),typeof PointerEvent<`u`&&(r.removeEventListener(`pointerdown`,Fh,!0),r.removeEventListener(`pointermove`,Fh,!0),r.removeEventListener(`pointerup`,Fh,!0)),Oh.delete(n))};function Vh(e){let t=fd(e),n;return t.readyState===`loading`?(n=()=>{zh(e)},t.addEventListener(`DOMContentLoaded`,n)):zh(e),()=>Bh(e,n)}typeof document<`u`&&Vh();function Hh(){return Eh!==`pointer`}function Uh(){return Eh}var Wh=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function Gh(e,t,n){let r=n?bd(n):void 0,i=fd(r),a=pd(r),o=a===void 0?HTMLInputElement:a.HTMLInputElement,s=a===void 0?HTMLTextAreaElement:a.HTMLTextAreaElement,c=a===void 0?HTMLElement:a.HTMLElement,l=a===void 0?KeyboardEvent:a.KeyboardEvent,u=yd(i);return e=e||u instanceof o&&!Wh.has(u.type)||u instanceof s||u instanceof c&&u.isContentEditable,!(e&&t===`keyboard`&&n instanceof l&&!jh[n.key])}function Kh(e,t,n){zh(),(0,_.useEffect)(()=>{if(n?.enabled===!1)return;let t=(t,r)=>{Gh(!!n?.isTextInput,t,r)&&e(Hh())};return Dh.add(t),()=>{Dh.delete(t)}},t)}function qh(e){if(!e.isConnected)return;let t=fd(e);if(Uh()===`virtual`){let n=yd(t);Rd(()=>{let r=yd(t);(r===n||r===t.body)&&e.isConnected&&Bu(e)})}else Bu(e)}function Jh(e){let{isDisabled:t,onFocus:n,onBlur:r,onFocusChange:i}=e,a=(0,_.useCallback)(e=>{if(bd(e)===e.currentTarget)return r&&r(e),i&&i(!1),!0},[r,i]),o=Ch(a),s=(0,_.useCallback)(e=>{let t=bd(e),r=fd(t),a=r?yd(r):yd();t===e.currentTarget&&t===a&&(n&&n(e),i&&i(!0),o(e))},[i,n,o]);return{focusProps:{onFocus:!t&&(n||i||r)?s:void 0,onBlur:!t&&(r||i)?a:void 0}}}function Yh(e){if(e)return t=>{let n=!0;e({...t,preventDefault(){t.preventDefault()},isDefaultPrevented(){return t.isDefaultPrevented()},stopPropagation(){n=!0},continuePropagation(){n=!1,typeof t.continuePropagation==`function`&&t.continuePropagation()},isPropagationStopped(){return n}}),n&&!(typeof t.isPropagationStopped==`function`&&t.isPropagationStopped())&&t.stopPropagation()}}var Xh=new Set([`shift`,`alt`,`control`,`meta`,`mod`]),aee=[`Alt`,`Control`,`Meta`,`Shift`];function oee(e){let t=new Set;return e.alt&&t.add(`Alt`),e.shift&&t.add(`Shift`),e.ctrl&&t.add(`Control`),e.meta&&t.add(`Meta`),e.mod&&t.add(Mu()?`Meta`:`Control`),t}function see(e){let t=new Set;return e.altKey&&t.add(`Alt`),e.ctrlKey&&t.add(`Control`),e.metaKey&&t.add(`Meta`),e.shiftKey&&t.add(`Shift`),t}function Zh(e){return aee.filter(t=>e.has(t))}function cee(e){let t=e.split(`+`).reduce((e,t)=>{let n=t.toLowerCase();return Xh.has(n)?n===`shift`?e.shift=!0:n===`alt`?e.alt=!0:n===`control`?e.ctrl=!0:n===`meta`?e.meta=!0:n===`mod`&&(e.mod=!0):e.key=t,e},{shift:!1,alt:!1,ctrl:!1,meta:!1,mod:!1,key:``});if(t.key===``)throw Error(`Invalid keyboard shortcut: "${e}". Must include exactly one non-modifier key (e.g. "a", "Enter", "ArrowDown"). Combine any of Shift, Alt, Ctrl, Meta, and Mod.`);return t}function Qh(e){return e.toLowerCase()}var lee={space:` `,esc:`escape`,del:`delete`,ins:`insert`,left:`arrowleft`,right:`arrowright`,up:`arrowup`,down:`arrowdown`,pageup:`pageup`,pagedown:`pagedown`};function uee(e){let t=Qh(e);return lee[t]??t}function dee(e){let t=Zh(oee(e)),n=uee(e.key);return t.length>0?`${t.join(`+`)}+${n}`:n}function fee(e){let t=Zh(see(e)),n=Qh(e.key);return(t.length>0?`${t.join(`+`)}+`:``)+n}function pee(e){let t=new Map;for(let[n,r]of Object.entries(e)){let e=cee(n);t.set(dee(e),r)}return e=>{let n=fee(e),r=t.get(n),i=r?.(e);i===void 0&&r!==void 0?i={shouldContinuePropagation:!1,shouldPreventDefault:!0}:typeof i==`boolean`&&(i={shouldContinuePropagation:!i,shouldPreventDefault:i}),i?.shouldPreventDefault&&e.preventDefault(),(!r||i?.shouldContinuePropagation)&&e.continuePropagation()}}function mee(e){let{shortcuts:t,allowRepeats:n=!1,allowComposing:r=!1}=e,i,a;if(t){let o=pee(t),s=Yh(e=>{if(!vd(e.currentTarget,bd(e))){e.continuePropagation();return}if(e.nativeEvent?.repeat&&!n||e.nativeEvent?.isComposing&&!r){e.continuePropagation();return}o(e)}),c=Yh(e=>{if(!vd(e.currentTarget,bd(e))){e.continuePropagation();return}if(e.nativeEvent?.repeat&&!n||e.nativeEvent?.isComposing&&!r){e.continuePropagation();return}e.continuePropagation()});i=e.onKeyDown?dd(e.onKeyDown,s):s,a=e.onKeyUp?dd(e.onKeyUp,c):c}else i=Yh(e.onKeyDown),a=Yh(e.onKeyUp);return{keyboardProps:e.isDisabled?{}:{onKeyDown:i,onKeyUp:a}}}var hee=_.createContext(null);function gee(e){let t=(0,_.useContext)(hee)||{};Ud(t,e);let{ref:n,...r}=t;return r}function _ee(e,t){let{focusProps:n}=Jh(e),{keyboardProps:r}=mee(e),i=Ed(n,r),a=gee(t),o=e.isDisabled?{}:a,s=(0,_.useRef)(e.autoFocus);(0,_.useEffect)(()=>{s.current&&t.current&&qh(t.current),s.current=!1},[t]);let c=e.excludeFromTabOrder?-1:0;return e.isDisabled&&(c=void 0),{focusableProps:Ed({...i,tabIndex:c},o)}}var $h=`default`,eg=``,tg=new WeakMap;function vee(e){if(Fu()&&Iu()){if($h==="default"){let t=fd(e);eg=t.documentElement.style.webkitUserSelect,t.documentElement.style.webkitUserSelect=`none`}$h=`disabled`}else if(e instanceof HTMLElement||e instanceof SVGElement){let t=`userSelect`in e.style?`userSelect`:`webkitUserSelect`;tg.set(e,e.style[t]),e.style[t]=`none`}}function ng(e){if(Fu()&&Iu()){if($h!==`disabled`)return;$h=`restoring`,setTimeout(()=>{Rd(()=>{if($h===`restoring`){let t=fd(e);t.documentElement.style.webkitUserSelect===`none`&&(t.documentElement.style.webkitUserSelect=eg||``),eg=``,$h=`default`}})},300)}else if((e instanceof HTMLElement||e instanceof SVGElement)&&e&&tg.has(e)){let t=tg.get(e),n=`userSelect`in e.style?`userSelect`:`webkitUserSelect`;e.style[n]===`none`&&(e.style[n]=t),e.getAttribute(`style`)===``&&e.removeAttribute(`style`),tg.delete(e)}}var rg=_.createContext({register:()=>{}});rg.displayName=`PressResponderContext`;function yee(e){let t=(0,_.useContext)(rg);if(t){let{register:n,ref:r,...i}=t;e=Ed(i,e),n()}return Ud(t,e.ref),e}var ig=class{#e;constructor(e,t,n,r){this.#e=!0;let i=(r?.target??n.currentTarget)?.getBoundingClientRect(),a,o=0,s,c=null;n.clientX!=null&&n.clientY!=null&&(s=n.clientX,c=n.clientY),i&&(s!=null&&c!=null?(a=s-i.left,o=c-i.top):(a=i.width/2,o=i.height/2)),this.type=e,this.pointerType=t,this.target=n.currentTarget,this.shiftKey=n.shiftKey,this.metaKey=n.metaKey,this.ctrlKey=n.ctrlKey,this.altKey=n.altKey,this.x=a,this.y=o,this.key=n.key}continuePropagation(){this.#e=!1}get shouldStopPropagation(){return this.#e}},ag=Symbol(`linkClicked`),og=`react-aria-pressable-style`,sg=`data-react-aria-pressable`;function bee(e){let{onPress:t,onPressChange:n,onPressStart:r,onPressEnd:i,onPressUp:a,onClick:o,isDisabled:s,isPressed:c,preventFocusOnPress:l,shouldCancelOnPointerExit:u,allowTextSelectionOnPress:d,ref:f,...p}=yee(e),[m,h]=(0,_.useState)(!1),g=(0,_.useRef)({isPressed:!1,ignoreEmulatedMouseEvents:!1,didFirePressStart:!1,isTriggeringEvent:!1,activePointerId:null,target:null,isOverTarget:!1,pointerType:null,disposables:[]}),{addGlobalListener:v,removeAllGlobalListeners:y}=zd(),b=(0,_.useCallback)((e,t)=>{let i=g.current;if(s||i.didFirePressStart)return!1;let a=!0;if(i.isTriggeringEvent=!0,r){let n=new ig(`pressstart`,t,e);r(n),a=n.shouldStopPropagation}return n&&n(!0),i.isTriggeringEvent=!1,i.didFirePressStart=!0,h(!0),a},[s,r,n]),x=(0,_.useCallback)((e,r,a=!0)=>{let o=g.current;if(!o.didFirePressStart)return!1;o.didFirePressStart=!1,o.isTriggeringEvent=!0;let c=!0;if(i){let t=new ig(`pressend`,r,e);i(t),c=t.shouldStopPropagation}if(n&&n(!1),h(!1),t&&a&&!s){let n=new ig(`press`,r,e);t(n),c&&=n.shouldStopPropagation}return o.isTriggeringEvent=!1,c},[s,i,n,t]),S=Hd(x),C=Hd((0,_.useCallback)((e,t)=>{let n=g.current;if(s)return!1;if(a){n.isTriggeringEvent=!0;let r=new ig(`pressup`,t,e);return a(r),n.isTriggeringEvent=!1,r.shouldStopPropagation}return!0},[s,a])),w=(0,_.useCallback)(e=>{let t=g.current;if(t.isPressed&&t.target){t.didFirePressStart&&t.pointerType!=null&&x(ug(t.target,e),t.pointerType,!1),t.isPressed=!1,t.isOverTarget=!1,t.activePointerId=null,t.pointerType=null,y(),d||ng(t.target);for(let e of t.disposables)e();t.disposables=[]}},[d,y,x]),T=Hd(w);(0,_.useEffect)(()=>{s&&g.current.isPressed&&T({currentTarget:g.current.target,shiftKey:!1,ctrlKey:!1,metaKey:!1,altKey:!1})},[s]);let E=(0,_.useCallback)(e=>{u&&w(e)},[u,w]),D=(0,_.useCallback)(e=>{s||o?.(e)},[s,o]),O=(0,_.useCallback)((e,t)=>{if(!s&&o){let n=new MouseEvent(`click`,e);Sh(n,t),o(xh(n))}},[s,o]),k=(0,_.useMemo)(()=>{let e=g.current,t={onKeyDown(t){if(lg(t.nativeEvent,t.currentTarget)&&vd(t.currentTarget,bd(t))){dg(bd(t),t.key)&&t.preventDefault();let r=!0;!e.isPressed&&!t.repeat&&(e.target=t.currentTarget,e.isPressed=!0,e.pointerType=`keyboard`,r=b(t,`keyboard`));let i=t.currentTarget;v(fd(t.currentTarget),`keyup`,dd(t=>{lg(t,i)&&!t.repeat&&vd(i,bd(t))&&e.target&&C(ug(e.target,t),`keyboard`)},n),!0),r&&t.stopPropagation(),t.metaKey&&Mu()&&e.metaKeyEvents?.set(t.key,t.nativeEvent)}else t.key===`Meta`&&(e.metaKeyEvents=new Map)},onClick(t){if((!t||vd(t.currentTarget,bd(t)))&&t&&t.button===0&&!e.isTriggeringEvent&&!Gu.isOpening){let n=!0;if(s&&t.preventDefault(),!e.ignoreEmulatedMouseEvents&&!e.isPressed&&(e.pointerType===`virtual`||Wd(t.nativeEvent))){let e=b(t,`virtual`),r=C(t,`virtual`),i=S(t,`virtual`);D(t),n=e&&r&&i}else if(e.isPressed&&e.pointerType!==`keyboard`){let r=e.pointerType||t.nativeEvent.pointerType||`virtual`,i=C(ug(t.currentTarget,t),r),a=S(ug(t.currentTarget,t),r,!0);n=i&&a,e.isOverTarget=!1,D(t),T(t)}e.ignoreEmulatedMouseEvents=!1,n&&t.stopPropagation()}}},n=t=>{if(e.isPressed&&e.target&&lg(t,e.target)){dg(bd(t),t.key)&&t.preventDefault();let n=bd(t),r=vd(e.target,n);S(ug(e.target,t),`keyboard`,r),r&&O(t,e.target),y(),t.key!==`Enter`&&cg(e.target)&&vd(e.target,n)&&!t[ag]&&(t[ag]=!0,Gu(e.target,t,!1)),e.isPressed=!1,e.metaKeyEvents?.delete(t.key)}else if(t.key===`Meta`&&e.metaKeyEvents?.size){let t=e.metaKeyEvents;e.metaKeyEvents=void 0;for(let n of t.values())e.target?.dispatchEvent(new KeyboardEvent(`keyup`,n))}};if(typeof PointerEvent<`u`){t.onPointerDown=t=>{if(t.button!==0||!vd(t.currentTarget,bd(t)))return;if(Gd(t.nativeEvent)){e.pointerType=`virtual`;return}e.pointerType=t.pointerType;let i=!0;if(!e.isPressed){e.isPressed=!0,e.isOverTarget=!0,e.activePointerId=t.pointerId,e.target=t.currentTarget,d||vee(e.target),i=b(t,e.pointerType);let a=bd(t);`releasePointerCapture`in a&&(`hasPointerCapture`in a?a.hasPointerCapture(t.pointerId)&&a.releasePointerCapture(t.pointerId):a.releasePointerCapture(t.pointerId)),v(fd(t.currentTarget),`pointerup`,n,!1),v(fd(t.currentTarget),`pointercancel`,r,!1)}i&&t.stopPropagation()},t.onMouseDown=t=>{if(vd(t.currentTarget,bd(t))&&t.button===0){if(l){let n=Th(t.target);n&&e.disposables.push(n)}t.stopPropagation()}},t.onPointerUp=t=>{vd(t.currentTarget,bd(t))&&e.pointerType!==`virtual`&&t.button===0&&!e.isPressed&&C(t,e.pointerType||t.pointerType)},t.onPointerEnter=t=>{t.pointerId===e.activePointerId&&e.target&&!e.isOverTarget&&e.pointerType!=null&&(e.isOverTarget=!0,b(ug(e.target,t),e.pointerType))},t.onPointerLeave=t=>{t.pointerId===e.activePointerId&&e.target&&e.isOverTarget&&e.pointerType!=null&&(e.isOverTarget=!1,S(ug(e.target,t),e.pointerType,!1),E(t))};let n=t=>{if(t.pointerId===e.activePointerId&&e.isPressed&&t.button===0&&e.target){if(vd(e.target,bd(t))&&e.pointerType!=null){let n=!1,r=setTimeout(()=>{e.isPressed&&e.target instanceof HTMLElement&&(n?T(t):(Bu(e.target),e.target.click()))},80);v(t.currentTarget,`click`,()=>n=!0,!0),e.disposables.push(()=>clearTimeout(r))}else T(t);e.isOverTarget=!1}},r=e=>{T(e)};t.onDragStart=e=>{vd(e.currentTarget,bd(e))&&T(e)}}return t},[v,s,l,y,d,E,b,D,O]);return(0,_.useEffect)(()=>{if(!f)return;let e=fd(f.current);if(!e||!e.head||e.getElementById(og))return;let t=e.createElement(`style`);t.id=og;let n=nf(e);n&&(t.nonce=n),t.textContent=`
|
|
18
|
-
@layer {
|
|
19
|
-
[${sg}] {
|
|
20
|
-
touch-action: pan-x pan-y pinch-zoom;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
`.trim(),e.head.prepend(t)},[f]),(0,_.useEffect)(()=>{let e=g.current;return()=>{d||ng(e.target??void 0);for(let t of e.disposables)t();e.disposables=[]}},[d]),{isPressed:c||m,pressProps:Ed(p,k,{[sg]:!0})}}function cg(e){return e.tagName===`A`&&e.hasAttribute(`href`)}function lg(e,t){let{key:n,code:r}=e,i=t,a=i.getAttribute(`role`);return(n===`Enter`||n===` `||n===`Spacebar`||r===`Space`)&&!(i instanceof pd(i).HTMLInputElement&&!pg(i,n)||i instanceof pd(i).HTMLTextAreaElement||i.isContentEditable)&&!((a===`link`||!a&&cg(i))&&n!==`Enter`)}function ug(e,t){let n=t.clientX,r=t.clientY;return{currentTarget:e,shiftKey:t.shiftKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,altKey:t.altKey,clientX:n,clientY:r,key:t.key}}function xee(e){return e instanceof HTMLInputElement?!1:e instanceof HTMLButtonElement?e.type!==`submit`&&e.type!==`reset`:!cg(e)}function dg(e,t){return Mu()&&t===`Enter`?!1:e instanceof HTMLInputElement?t===`Enter`&&(e.type===`checkbox`||e.type===`radio`)?!1:!pg(e,t):xee(e)}var fg=new Set([`checkbox`,`radio`,`range`,`color`,`file`,`image`,`button`,`submit`,`reset`]);function pg(e,t){return e.type===`checkbox`||e.type===`radio`?t===` `:fg.has(e.type)}function mg(e,t){let{elementType:n=`button`,isDisabled:r,onPress:i,onPressStart:a,onPressEnd:o,onPressUp:s,onPressChange:c,preventFocusOnPress:l,allowFocusWhenDisabled:u,onClick:d,href:f,target:p,rel:m,type:h=`button`}=e,g;g=n===`button`?{type:h,disabled:r,form:e.form,formAction:e.formAction,formEncType:e.formEncType,formMethod:e.formMethod,formNoValidate:e.formNoValidate,formTarget:e.formTarget,name:e.name,value:e.value}:{role:`button`,href:n===`a`&&!r?f:void 0,target:n===`a`?p:void 0,type:n===`input`?h:void 0,disabled:n===`input`?r:void 0,"aria-disabled":!r||n===`input`?void 0:r,rel:n===`a`?m:void 0};let{pressProps:_,isPressed:v}=bee({onPressStart:a,onPressEnd:o,onPressChange:c,onPress:i,onPressUp:s,onClick:d,isDisabled:r,preventFocusOnPress:l,ref:t}),{focusableProps:y}=_ee(e,t);u&&(y.tabIndex=r?-1:y.tabIndex);let b=Ed(y,_,Nd(e,{labelable:!0}));return{isPressed:v,buttonProps:Ed(g,b,{"aria-haspopup":e[`aria-haspopup`],"aria-expanded":e[`aria-expanded`],"aria-controls":e[`aria-controls`],"aria-pressed":e[`aria-pressed`],"aria-current":e[`aria-current`],"aria-disabled":e[`aria-disabled`]})}}function hg(e){let{isDisabled:t,onBlurWithin:n,onFocusWithin:r,onFocusWithinChange:i}=e,a=(0,_.useRef)({isFocusWithin:!1}),{addGlobalListener:o,removeAllGlobalListeners:s}=zd(),c=(0,_.useCallback)(e=>{vd(e.currentTarget,bd(e))&&a.current.isFocusWithin&&!vd(e.currentTarget,e.relatedTarget)&&(a.current.isFocusWithin=!1,s(),n&&n(e),i&&i(!1))},[n,i,a,s]),l=Ch(c),u=(0,_.useCallback)(e=>{if(!vd(e.currentTarget,bd(e)))return;let t=bd(e),n=fd(t),s=yd(n);if(!a.current.isFocusWithin&&s===t){r&&r(e),i&&i(!0),a.current.isFocusWithin=!0,l(e);let t=e.currentTarget;o(n,`focus`,e=>{let r=bd(e);if(a.current.isFocusWithin&&!vd(t,r)){let e=new n.defaultView.FocusEvent(`blur`,{relatedTarget:r});Sh(e,t);let i=xh(e);c(i)}},{capture:!0})}},[r,i,l,o,c]);return t?{focusWithinProps:{onFocus:void 0,onBlur:void 0}}:{focusWithinProps:{onFocus:u,onBlur:c}}}function gg(e={}){let{autoFocus:t=!1,isTextInput:n,within:r}=e,i=(0,_.useRef)({isFocused:!1,isFocusVisible:t||Hh()}),[a,o]=(0,_.useState)(!1),[s,c]=(0,_.useState)(()=>i.current.isFocused&&i.current.isFocusVisible),l=(0,_.useCallback)(()=>c(i.current.isFocused&&i.current.isFocusVisible),[]),u=(0,_.useCallback)(e=>{i.current.isFocused=e,i.current.isFocusVisible=Hh(),o(e),l()},[l]);Kh(e=>{i.current.isFocusVisible=e,l()},[n,a],{enabled:a,isTextInput:n});let{focusProps:d}=Jh({isDisabled:r,onFocusChange:u}),{focusWithinProps:f}=hg({isDisabled:!r,onFocusWithinChange:u});return{isFocused:a,isFocusVisible:s,focusProps:r?f:d}}var _g=!1,vg=0;function yg(){_g=!0,setTimeout(()=>{_g=!1},500)}function bg(e){e.pointerType===`touch`&&yg()}function xg(){let e=fd(null);if(e!==void 0)return vg===0&&typeof PointerEvent<`u`&&e.addEventListener(`pointerup`,bg),vg++,()=>{vg--,!(vg>0)&&typeof PointerEvent<`u`&&e.removeEventListener(`pointerup`,bg)}}function Sg(e){let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,isDisabled:i}=e,[a,o]=(0,_.useState)(!1),s=(0,_.useRef)({isHovered:!1,ignoreEmulatedMouseEvents:!1,pointerType:``,target:null}).current;(0,_.useEffect)(xg,[]);let{addGlobalListener:c,removeAllGlobalListeners:l}=zd(),{hoverProps:u,triggerHoverEnd:d}=(0,_.useMemo)(()=>{let e=(e,r)=>{if(s.pointerType=r,i||r===`touch`||s.isHovered||!vd(e.currentTarget,bd(e)))return;s.isHovered=!0;let l=e.currentTarget;s.target=l,c(fd(bd(e)),`pointerover`,e=>{s.isHovered&&s.target&&!vd(s.target,bd(e))&&a(e,e.pointerType)},{capture:!0}),t&&t({type:`hoverstart`,target:l,pointerType:r}),n&&n(!0),o(!0)},a=(e,t)=>{let i=s.target;s.pointerType=``,s.target=null,t!==`touch`&&s.isHovered&&i&&(s.isHovered=!1,l(),r&&r({type:`hoverend`,target:i,pointerType:t}),n&&n(!1),o(!1))},u={};return typeof PointerEvent<`u`&&(u.onPointerEnter=t=>{_g&&t.pointerType===`mouse`||e(t,t.pointerType)},u.onPointerLeave=e=>{!i&&vd(e.currentTarget,bd(e))&&a(e,e.pointerType)}),{hoverProps:u,triggerHoverEnd:a}},[t,n,r,i,s,c,l]);return(0,_.useEffect)(()=>{i&&d({currentTarget:s.target},s.pointerType)},[i]),{hoverProps:u,isHovered:a}}var Cg=(0,_.createContext)({}),wg=hh(function(e,t){[e,t]=uh(e,t,Cg);let n=e,{isPending:r}=n,{buttonProps:i,isPressed:a}=mg(e,t);i=Eg(i,r);let{focusProps:o,isFocused:s,isFocusVisible:c}=gg(e),{hoverProps:l,isHovered:u}=Sg({...e,isDisabled:e.isDisabled||r}),d={isHovered:u,isPressed:(n.isPressed||a)&&!r,isFocused:s,isFocusVisible:c,isDisabled:e.isDisabled||!1,isPending:r??!1},f=sh({...e,values:d,defaultClassName:`react-aria-Button`}),p=ld(i.id),m=ld(),h=i[`aria-labelledby`];r&&(h?h=`${h} ${m}`:i[`aria-label`]&&(h=`${p} ${m}`));let g=(0,_.useRef)(r);(0,_.useEffect)(()=>{let e={"aria-labelledby":h||p};(!g.current&&s&&r||g.current&&s&&!r)&&yh(e,`assertive`),g.current=r},[r,s,h,p]);let v=Nd(e,{global:!0});return delete v.onClick,_.createElement(ph.button,{...Ed(v,f,i,o,l),type:i.type===`submit`&&r?`button`:i.type,id:p,ref:t,"aria-labelledby":h,slot:e.slot||void 0,"aria-disabled":r?`true`:i[`aria-disabled`],"data-disabled":e.isDisabled||void 0,"data-pressed":d.isPressed||void 0,"data-hovered":u||void 0,"data-focused":s||void 0,"data-pending":r||void 0,"data-focus-visible":c||void 0},_.createElement(gh.Provider,{value:{id:m}},f.children))}),Tg=/Focus|Blur|Hover|Pointer(Enter|Leave|Over|Out)|Mouse(Enter|Leave|Over|Out)/;function Eg(e,t){if(t){for(let t in e)t.startsWith(`on`)&&!Tg.test(t)&&(e[t]=void 0);e.href=void 0,e.target=void 0}return e}function Dg(e,t){return ch(e,(e,n)=>nh(typeof t==`function`?t(n)??``:t??``,e??``)??``)}var Og=(e,t,n)=>typeof e==`function`?e({...n??{},className:t}):t,kg=e=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,I.jsx)(`path`,{clipRule:`evenodd`,d:`M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-9.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0m-.25 3a.75.75 0 0 0-1.5 0V11a.75.75 0 0 0 1.5 0z`,fill:`currentColor`,fillRule:`evenodd`})}),Ag=e=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,I.jsx)(`path`,{clipRule:`evenodd`,d:`M7.134 2.994L2.217 11.5a1 1 0 0 0 .866 1.5h9.834a1 1 0 0 0 .866-1.5L8.866 2.993a1 1 0 0 0-1.732 0m3.03-.75c-.962-1.665-3.366-1.665-4.329 0L.918 10.749c-.963 1.666.24 3.751 2.165 3.751h9.834c1.925 0 3.128-2.085 2.164-3.751zM8 5a.75.75 0 0 1 .75.75v2a.75.75 0 0 1-1.5 0v-2A.75.75 0 0 1 8 5m1 5.75a1 1 0 1 1-2 0a1 1 0 0 1 2 0`,fill:`currentColor`,fillRule:`evenodd`})}),jg=e=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,I.jsx)(`path`,{clipRule:`evenodd`,d:`M8 13.5a5.5 5.5 0 1 0 0-11a5.5 5.5 0 0 0 0 11M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14m1-4.5a1 1 0 1 1-2 0a1 1 0 0 1 2 0M8.75 5a.75.75 0 0 0-1.5 0v2.5a.75.75 0 0 0 1.5 0z`,fill:`currentColor`,fillRule:`evenodd`})}),Mg=e=>(0,I.jsx)(`svg`,{"aria-hidden":`true`,fill:`none`,height:16,role:`presentation`,viewBox:`0 0 16 16`,width:16,xmlns:`http://www.w3.org/2000/svg`,...e,children:(0,I.jsx)(`path`,{clipRule:`evenodd`,d:`M13.5 8a5.5 5.5 0 1 1-11 0a5.5 5.5 0 0 1 11 0M15 8A7 7 0 1 1 1 8a7 7 0 0 1 14 0m-3.9-1.55a.75.75 0 1 0-1.2-.9L7.419 8.858L6.03 7.47a.75.75 0 0 0-1.06 1.06l2 2a.75.75 0 0 0 1.13-.08z`,fill:`currentColor`,fillRule:`evenodd`})}),Ng=(0,_.createContext)({}),Pg=(0,_.createContext)({}),Fg=`__button_group_child`,Ig=({children:e,className:t,fullWidth:n,isDisabled:r,isIconOnly:i,size:a,slot:o,style:s,variant:c,[Fg]:l,...u})=>{let d=(0,_.use)(Pg),f=l===!0,p=a??(f?d?.size:void 0),m=c??(f?d?.variant:void 0),h=r??(f?d?.isDisabled:void 0),g=ih({fullWidth:n??(f?d?.fullWidth:void 0),isIconOnly:i,size:p,variant:m});return(0,I.jsx)(wg,{className:Dg(t,g),"data-slot":`button`,isDisabled:h,slot:o,style:s,...u,children:t=>typeof e==`function`?e(t):e})},Lg=Object.assign(Ig,{Root:Ig}),Rg=(0,_.createContext)({}),zg=({children:e,className:t,variant:n=`default`,...r})=>{let i=_.useMemo(()=>ah({variant:n}),[n]),a=(0,I.jsx)(of.div,{className:i.base({className:t}),"data-slot":`card`,...r,children:e});return(0,I.jsx)(Rg,{value:{slots:i},children:n===`transparent`?a:(0,I.jsx)(Ng,{value:{variant:n},children:a})})},Bg=Object.assign(zg,{Root:zg,Header:({className:e,...t})=>{let{slots:n}=(0,_.use)(Rg);return(0,I.jsx)(of.div,{className:Og(n?.header,e),"data-slot":`card-header`,...t})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(Rg);return(0,I.jsx)(of.h3,{className:Og(r?.title,t),"data-slot":`card-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(Rg);return(0,I.jsx)(of.p,{className:Og(r?.description,t),"data-slot":`card-description`,...n,children:e})},Content:({className:e,...t})=>{let{slots:n}=(0,_.use)(Rg);return(0,I.jsx)(of.div,{className:Og(n?.content,e),"data-slot":`card-content`,...t})},Footer:({className:e,...t})=>{let{slots:n}=(0,_.use)(Rg);return(0,I.jsx)(of.div,{className:Og(n?.footer,e),"data-slot":`card-footer`,...t})}}),Vg=(0,_.createContext)({}),Hg=({children:e,className:t,status:n,...r})=>{let i=_.useMemo(()=>rh({status:n}),[n]);return(0,I.jsx)(Vg,{value:{slots:i,status:n},children:(0,I.jsx)(Ng,{value:{variant:`default`},children:(0,I.jsx)(of.div,{className:i?.base({className:t}),"data-slot":`alert-root`,...r,children:e})})})},Ug=Object.assign(Hg,{Root:Hg,Indicator:({children:e,className:t,...n})=>{let{slots:r,status:i}=(0,_.use)(Vg),a=()=>{switch(i){case`accent`:return(0,I.jsx)(kg,{"data-slot":`alert-default-icon`});case`success`:return(0,I.jsx)(Mg,{"data-slot":`alert-default-icon`});case`warning`:return(0,I.jsx)(Ag,{"data-slot":`alert-default-icon`});case`danger`:return(0,I.jsx)(jg,{"data-slot":`alert-default-icon`});default:return(0,I.jsx)(kg,{"data-slot":`alert-default-icon`})}};return(0,I.jsx)(of.div,{className:Og(r?.indicator,t),"data-slot":`alert-indicator`,...n,children:e??a()})},Content:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(Vg);return(0,I.jsx)(of.div,{className:Og(r?.content,t),"data-slot":`alert-content`,...n,children:e})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(Vg);return(0,I.jsx)(of.p,{className:Og(r?.title,t),"data-slot":`alert-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,_.use)(Vg);return(0,I.jsx)(of.span,{className:Og(r?.description,t),"data-slot":`alert-description`,...n,children:e})}}),Wg=.2,Gg=12,Kg=75,qg=.35,Jg={INACTIVE:0,TOUCH_DELAY:1,HOLDING:2,WAITING_FOR_CLICK:3},Yg=({hoverOpacity:e,pressedOpacity:t,disabled:n=!1,className:r=``,style:i,easing:a,duration:o=150,minimumPressDuration:s=225,touchDelay:c=150})=>{let[l,u]=(0,_.useState)(!1),[d,f]=(0,_.useState)(!1),p=(0,_.useRef)(null),m=(0,_.useRef)(null),h=(0,_.useRef)(``),g=(0,_.useRef)(``),v=(0,_.useRef)(0),y=(0,_.useRef)(void 0),b=(0,_.useRef)(Jg.INACTIVE),x=(0,_.useRef)(void 0),S=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(!m.current)return;let n=m.current.style;e!==void 0&&n.setProperty(`--ripple-hover-opacity`,e+``),t!==void 0&&n.setProperty(`--ripple-pressed-opacity`,t+``),o!==void 0&&o!==150&&n.setProperty(`--ripple-duration`,o+`ms`)},[e,t,o]),(0,_.useEffect)(()=>{let e=p.current?.parentElement;if(!e)return;let t=(t,n)=>e.addEventListener(t,n,!0);return t(`click`,re),t(`contextmenu`,N),t(`pointercancel`,M),t(`pointerdown`,ne),t(`pointerenter`,E),t(`pointerleave`,ee),t(`pointerup`,te),()=>{let t=(t,n)=>e.removeEventListener(t,n,!0);t(`click`,re),t(`contextmenu`,N),t(`pointercancel`,M),t(`pointerdown`,ne),t(`pointerenter`,E),t(`pointerleave`,ee),t(`pointerup`,te)}},[n,a,o,s,c]);let C=(0,_.useCallback)(({pointerType:e})=>e===`touch`,[]),w=(0,_.useCallback)(e=>{var t;if(n||(t=p.current?.parentElement)!=null&&t.disabled||!e.isPrimary||x.current&&x.current.pointerId!==e.pointerId)return!1;if(e.type===`pointerenter`||e.type===`pointerleave`)return!C(e);let r=e.buttons===1;return C(e)||r},[n,C]),T=(0,_.useCallback)(({x:e,y:t})=>{let n=p.current;if(!n)return!1;let r=n.getBoundingClientRect();return e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},[p]),E=(0,_.useCallback)(e=>{w(e)&&u(!0)},[w]),D=(0,_.useCallback)(()=>{let e=p.current;if(!e)return;let{height:t,width:n}=e.getBoundingClientRect(),r=Math.max(t,n),i=Math.max(qg*r,Kg),a=Math.floor(r*Wg),o=Math.sqrt(n**2+t**2)+Gg;v.current=a,g.current=(o+i)/a+``,h.current=a+`px`},[p]),O=(0,_.useCallback)(e=>{let t=p.current;if(!t)return{x:0,y:0};let n=t.getBoundingClientRect(),r=window.scrollX+n.left,i=window.scrollY+n.top;return{x:e.pageX-r,y:e.pageY-i}},[p]),k=(0,_.useCallback)(e=>{let t=p.current?.parentElement;if(!t)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};let n=t.getBoundingClientRect(),r={x:(n.width-v.current)/2,y:(n.height-v.current)/2};return{startPoint:e?O(e):r,endPoint:r}},[p,O]),A=(0,_.useCallback)(e=>{var t;let n=m.current;if(!n)return;f(!0),(t=y.current)==null||t.cancel(),D();let{startPoint:r,endPoint:i}=k(e),s=`${r.x}px,${r.y}px`,c=`${i.x}px,${i.y}px`;y.current=n.animate({height:[h.current,h.current],width:[h.current,h.current],transform:[`translate(${s}) scale(1)`,`translate(${c}) scale(${g.current})`]},{pseudoElement:`::after`,duration:o,easing:a,fill:`forwards`})},[D,o,a,k]),j=(0,_.useCallback)(()=>{x.current=void 0,b.current=Jg.INACTIVE;let e=y.current,t=1/0;if(typeof e?.currentTime==`number`?t=e.currentTime:e!=null&&e.currentTime&&(t=e.currentTime.to(`ms`).value),t>=s)return void f(!1);setTimeout(()=>{y.current===e&&f(!1)},s-t)},[s]),ee=(0,_.useCallback)(e=>{w(e)&&(u(!1),b.current!==Jg.INACTIVE&&j())},[j,w]),te=(0,_.useCallback)(e=>{if(w(e)){if(b.current===Jg.HOLDING){b.current=Jg.WAITING_FOR_CLICK;return}if(b.current===Jg.TOUCH_DELAY){b.current=Jg.WAITING_FOR_CLICK,A(x.current);return}}},[w,A]),ne=(0,_.useCallback)(e=>{if(w(e)){if(x.current=e,!C(e)){b.current=Jg.WAITING_FOR_CLICK,A(e);return}S.current&&!T(e)||(S.current=!1,b.current=Jg.TOUCH_DELAY,setTimeout(()=>{b.current===Jg.TOUCH_DELAY&&(b.current=Jg.HOLDING,A(e))},c))}},[w,C,T,A,c]),re=(0,_.useCallback)(e=>{if(!n){if(b.current===Jg.WAITING_FOR_CLICK){j();return}b.current===Jg.INACTIVE&&(A(e),j())}},[n,j,A]),M=(0,_.useCallback)(e=>{w(e)&&j()},[j,w]),N=(0,_.useCallback)(()=>{n||(S.current=!0,j())},[n,j]);return(0,I.jsx)(`div`,{ref:p,className:`salty-ripple${r?` ${r}`:``}`,style:i,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{ref:m,className:`salty-ripple-surface${l?` --hover`:``}${d?` --press`:``}`})})},Xg={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Zg=_.createContext&&_.createContext(Xg),Qg=[`attr`,`size`,`title`];function $g(e,t){if(e==null)return{};var n,r,i=e_(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function e_(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function t_(){return t_=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},t_.apply(null,arguments)}function n_(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function r_(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?n_(Object(n),!0).forEach(function(t){i_(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):n_(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function i_(e,t,n){return(t=a_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a_(e){var t=o_(e,`string`);return typeof t==`symbol`?t:t+``}function o_(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s_(e){return e&&e.map((e,t)=>_.createElement(e.tag,r_({key:t},e.attr),s_(e.child)))}function c_(e){return t=>_.createElement(See,t_({attr:r_({},e.attr)},t),s_(e.child))}function See(e){var t=t=>{var n=e.attr,r=e.size,i=e.title,a=$g(e,Qg),o=r||t.size||`1em`,s;return t.className&&(s=t.className),e.className&&(s=(s?s+` `:``)+e.className),_.createElement(`svg`,t_({stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`},t.attr,n,a,{className:s,style:r_(r_({color:e.color||t.color},t.style),e.style),height:o,width:o,xmlns:`http://www.w3.org/2000/svg`}),i&&_.createElement(`title`,null,i),e.children)};return Zg===void 0?t(Xg):_.createElement(Zg.Consumer,null,e=>t(e))}function Cee(e){return c_({tag:`svg`,attr:{viewBox:`0 0 384 512`},child:[{tag:`path`,attr:{d:`M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z`},child:[]}]})(e)}function wee(e){return c_({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M234.7 42.7L197 56.8c-3 1.1-5 4-5 7.2s2 6.1 5 7.2l37.7 14.1L248.8 123c1.1 3 4 5 7.2 5s6.1-2 7.2-5l14.1-37.7L315 71.2c3-1.1 5-4 5-7.2s-2-6.1-5-7.2L277.3 42.7 263.2 5c-1.1-3-4-5-7.2-5s-6.1 2-7.2 5L234.7 42.7zM46.1 395.4c-18.7 18.7-18.7 49.1 0 67.9l34.6 34.6c18.7 18.7 49.1 18.7 67.9 0L529.9 116.5c18.7-18.7 18.7-49.1 0-67.9L495.3 14.1c-18.7-18.7-49.1-18.7-67.9 0L46.1 395.4zM484.6 82.6l-105 105-23.3-23.3 105-105 23.3 23.3zM7.5 117.2C3 118.9 0 123.2 0 128s3 9.1 7.5 10.8L64 160l21.2 56.5c1.7 4.5 6 7.5 10.8 7.5s9.1-3 10.8-7.5L128 160l56.5-21.2c4.5-1.7 7.5-6 7.5-10.8s-3-9.1-7.5-10.8L128 96 106.8 39.5C105.1 35 100.8 32 96 32s-9.1 3-10.8 7.5L64 96 7.5 117.2zm352 256c-4.5 1.7-7.5 6-7.5 10.8s3 9.1 7.5 10.8L416 416l21.2 56.5c1.7 4.5 6 7.5 10.8 7.5s9.1-3 10.8-7.5L480 416l56.5-21.2c4.5-1.7 7.5-6 7.5-10.8s-3-9.1-7.5-10.8L480 352l-21.2-56.5c-1.7-4.5-6-7.5-10.8-7.5s-9.1 3-10.8 7.5L416 352l-56.5 21.2z`},child:[]}]})(e)}function Tee(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M224 256A128 128 0 1 0 224 0a128 128 0 1 0 0 256zm-45.7 48C79.8 304 0 383.8 0 482.3C0 498.7 13.3 512 29.7 512l388.6 0c16.4 0 29.7-13.3 29.7-29.7C448 383.8 368.2 304 269.7 304l-91.4 0z`},child:[]}]})(e)}function Eee(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M135.2 17.7C140.6 6.8 151.7 0 163.8 0L284.2 0c12.1 0 23.2 6.8 28.6 17.7L320 32l96 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64S14.3 32 32 32l96 0 7.2-14.3zM32 128l384 0 0 320c0 35.3-28.7 64-64 64L96 512c-35.3 0-64-28.7-64-64l0-320zm96 64c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16zm96 0c-8.8 0-16 7.2-16 16l0 224c0 8.8 7.2 16 16 16s16-7.2 16-16l0-224c0-8.8-7.2-16-16-16z`},child:[]}]})(e)}function l_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M0 80L0 229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7L48 32C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z`},child:[]}]})(e)}function u_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M316.9 18C311.6 7 300.4 0 288.1 0s-23.4 7-28.8 18L195 150.3 51.4 171.5c-12 1.8-22 10.2-25.7 21.7s-.7 24.2 7.9 32.7L137.8 329 113.2 474.7c-2 12 3 24.2 12.9 31.3s23 8 33.8 2.3l128.3-68.5 128.3 68.5c10.8 5.7 23.9 4.9 33.8-2.3s14.9-19.3 12.9-31.3L438.5 329 542.7 225.9c8.6-8.5 11.7-21.2 7.9-32.7s-13.7-19.9-25.7-21.7L381.2 150.3 316.9 18z`},child:[]}]})(e)}function d_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 640 512`},child:[{tag:`path`,attr:{d:`M320 0c17.7 0 32 14.3 32 32l0 64 120 0c39.8 0 72 32.2 72 72l0 272c0 39.8-32.2 72-72 72l-304 0c-39.8 0-72-32.2-72-72l0-272c0-39.8 32.2-72 72-72l120 0 0-64c0-17.7 14.3-32 32-32zM208 384c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zm96 0c-8.8 0-16 7.2-16 16s7.2 16 16 16l32 0c8.8 0 16-7.2 16-16s-7.2-16-16-16l-32 0zM264 256a40 40 0 1 0 -80 0 40 40 0 1 0 80 0zm152 40a40 40 0 1 0 0-80 40 40 0 1 0 0 80zM48 224l16 0 0 192-16 0c-26.5 0-48-21.5-48-48l0-96c0-26.5 21.5-48 48-48zm544 0c26.5 0 48 21.5 48 48l0 96c0 26.5-21.5 48-48 48l-16 0 0-192 16 0z`},child:[]}]})(e)}function f_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M256 80c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 144L48 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l144 0 0 144c0 17.7 14.3 32 32 32s32-14.3 32-32l0-144 144 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-144 0 0-144z`},child:[]}]})(e)}function p_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480l0-83.6c0-4 1.5-7.8 4.2-10.8L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z`},child:[]}]})(e)}function m_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M432 256c0 17.7-14.3 32-32 32L48 288c-17.7 0-32-14.3-32-32s14.3-32 32-32l352 0c17.7 0 32 14.3 32 32z`},child:[]}]})(e)}function h_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z`},child:[]}]})(e)}function g_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z`},child:[]}]})(e)}function __(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M47.6 300.4L228.3 469.1c7.5 7 17.4 10.9 27.7 10.9s20.2-3.9 27.7-10.9L464.4 300.4c30.4-28.3 47.6-68 47.6-109.5v-5.8c0-69.9-50.5-129.5-119.4-141C347 36.5 300.6 51.4 268 84L256 96 244 84c-32.6-32.6-79-47.5-124.6-39.9C50.5 55.6 0 115.2 0 185.1v5.8c0 41.5 17.2 81.2 47.6 109.5z`},child:[]}]})(e)}function v_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M495.9 166.6c3.2 8.7 .5 18.4-6.4 24.6l-43.3 39.4c1.1 8.3 1.7 16.8 1.7 25.4s-.6 17.1-1.7 25.4l43.3 39.4c6.9 6.2 9.6 15.9 6.4 24.6c-4.4 11.9-9.7 23.3-15.8 34.3l-4.7 8.1c-6.6 11-14 21.4-22.1 31.2c-5.9 7.2-15.7 9.6-24.5 6.8l-55.7-17.7c-13.4 10.3-28.2 18.9-44 25.4l-12.5 57.1c-2 9.1-9 16.3-18.2 17.8c-13.8 2.3-28 3.5-42.5 3.5s-28.7-1.2-42.5-3.5c-9.2-1.5-16.2-8.7-18.2-17.8l-12.5-57.1c-15.8-6.5-30.6-15.1-44-25.4L83.1 425.9c-8.8 2.8-18.6 .3-24.5-6.8c-8.1-9.8-15.5-20.2-22.1-31.2l-4.7-8.1c-6.1-11-11.4-22.4-15.8-34.3c-3.2-8.7-.5-18.4 6.4-24.6l43.3-39.4C64.6 273.1 64 264.6 64 256s.6-17.1 1.7-25.4L22.4 191.2c-6.9-6.2-9.6-15.9-6.4-24.6c4.4-11.9 9.7-23.3 15.8-34.3l4.7-8.1c6.6-11 14-21.4 22.1-31.2c5.9-7.2 15.7-9.6 24.5-6.8l55.7 17.7c13.4-10.3 28.2-18.9 44-25.4l12.5-57.1c2-9.1 9-16.3 18.2-17.8C227.3 1.2 241.5 0 256 0s28.7 1.2 42.5 3.5c9.2 1.5 16.2 8.7 18.2 17.8l12.5 57.1c15.8 6.5 30.6 15.1 44 25.4l55.7-17.7c8.8-2.8 18.6-.3 24.5 6.8c8.1 9.8 15.5 20.2 22.1 31.2l4.7 8.1c6.1 11 11.4 22.4 15.8 34.3zM256 336a80 80 0 1 0 0-160 80 80 0 1 0 0 160z`},child:[]}]})(e)}function y_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M222.7 32.1c5 16.9-4.6 34.8-21.5 39.8C121.8 95.6 64 169.1 64 256c0 106 86 192 192 192s192-86 192-192c0-86.9-57.8-160.4-137.1-184.1c-16.9-5-26.6-22.9-21.5-39.8s22.9-26.6 39.8-21.5C434.9 42.1 512 140 512 256c0 141.4-114.6 256-256 256S0 397.4 0 256C0 140 77.1 42.1 182.9 10.6c16.9-5 34.8 4.6 39.8 21.5z`},child:[]}]})(e)}function b_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z`},child:[]}]})(e)}function x_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z`},child:[]}]})(e)}function S_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z`},child:[]}]})(e)}function C_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 576 512`},child:[{tag:`path`,attr:{d:`M0 24C0 10.7 10.7 0 24 0L69.5 0c22 0 41.5 12.8 50.6 32l411 0c26.3 0 45.5 25 38.6 50.4l-41 152.3c-8.5 31.4-37 53.3-69.5 53.3l-288.5 0 5.4 28.5c2.2 11.3 12.1 19.5 23.6 19.5L488 336c13.3 0 24 10.7 24 24s-10.7 24-24 24l-288.3 0c-34.6 0-64.3-24.6-70.7-58.5L77.4 54.5c-.7-3.8-4-6.5-7.9-6.5L24 48C10.7 48 0 37.3 0 24zM128 464a48 48 0 1 1 96 0 48 48 0 1 1 -96 0zm336-48a48 48 0 1 1 0 96 48 48 0 1 1 0-96zM252 160c0 11 9 20 20 20l44 0 0 44c0 11 9 20 20 20s20-9 20-20l0-44 44 0c11 0 20-9 20-20s-9-20-20-20l-44 0 0-44c0-11-9-20-20-20s-20 9-20 20l0 44-44 0c-11 0-20 9-20 20z`},child:[]}]})(e)}function w_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M0 96C0 78.3 14.3 64 32 64l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 128C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 288c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32L32 448c-17.7 0-32-14.3-32-32s14.3-32 32-32l384 0c17.7 0 32 14.3 32 32z`},child:[]}]})(e)}function T_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M438.6 278.6c12.5-12.5 12.5-32.8 0-45.3l-160-160c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L338.8 224 32 224c-17.7 0-32 14.3-32 32s14.3 32 32 32l306.7 0L233.4 393.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0l160-160z`},child:[]}]})(e)}function E_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 512 512`},child:[{tag:`path`,attr:{d:`M160 368c26.5 0 48 21.5 48 48l0 16 72.5-54.4c8.3-6.2 18.4-9.6 28.8-9.6L448 368c8.8 0 16-7.2 16-16l0-288c0-8.8-7.2-16-16-16L64 48c-8.8 0-16 7.2-16 16l0 288c0 8.8 7.2 16 16 16l96 0zm48 124l-.2 .2-5.1 3.8-17.1 12.8c-4.8 3.6-11.3 4.2-16.8 1.5s-8.8-8.2-8.8-14.3l0-21.3 0-6.4 0-.3 0-4 0-48-48 0-48 0c-35.3 0-64-28.7-64-64L0 64C0 28.7 28.7 0 64 0L448 0c35.3 0 64 28.7 64 64l0 288c0 35.3-28.7 64-64 64l-138.7 0L208 492z`},child:[]}]})(e)}function D_(e){return c_({tag:`svg`,attr:{viewBox:`0 0 448 512`},child:[{tag:`path`,attr:{d:`M384 336l-192 0c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l140.1 0L400 115.9 400 320c0 8.8-7.2 16-16 16zM192 384l192 0c35.3 0 64-28.7 64-64l0-204.1c0-12.7-5.1-24.9-14.1-33.9L366.1 14.1c-9-9-21.2-14.1-33.9-14.1L192 0c-35.3 0-64 28.7-64 64l0 256c0 35.3 28.7 64 64 64zM64 128c-35.3 0-64 28.7-64 64L0 448c0 35.3 28.7 64 64 64l192 0c35.3 0 64-28.7 64-64l0-32-48 0 0 32c0 8.8-7.2 16-16 16L64 464c-8.8 0-16-7.2-16-16l0-256c0-8.8 7.2-16 16-16l32 0 0-48-32 0z`},child:[]}]})(e)}var O_={robot:d_,wandMagic:wee,paperPlane:p_,message:E_,copy:D_,close:Cee,menu:w_,chevronDown:S_,settings:v_,loading:y_,success:x_,error:b_,home:g_,cartPlus:C_,search:h_,arrowRight:T_,trash:Eee,user:Tee,heart:__,tag:l_,star:u_,plus:f_,minus:m_},k_=({isOpen:e,onToggle:t})=>(0,I.jsxs)(Lg,{isIconOnly:!0,variant:`primary`,onPress:t,"aria-label":e?`Close AI Assistant`:`Open AI Assistant`,className:`fixed bottom-6 right-6 z-[2147483647] h-14 w-14 rounded-full bg-[#FF641E] text-white shadow-lg shadow-[#FF641E]/30 transition-transform hover:scale-105 hover:bg-[#FF641E]/90`,children:[e?(0,I.jsx)(O_.close,{size:24}):(0,I.jsx)(O_.wandMagic,{size:24}),(0,I.jsx)(Yg,{})]}),A_=null;function j_(e,t){e.currentIndex=0,e.wipContextDeps=null,e.wipCommitCallbacks=[];let n=A_;A_=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{A_=n}}function M_(){if(!A_)throw Error(`No resource fiber available`);return A_}function N_(){return A_}var P_=typeof process<`u`&&!1,F_=e=>({version:0,committedVersion:0,dispatchUpdate:e,changelog:[],committedLog:[],unsettledCount:0,rollbackCallbacks:[]}),I_=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},L_=(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(P_)throw Error(`tap: committed history is shorter than the replay base.`);break}V_(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;B_(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++)R_(e.changelog[t]);I_(e)}}},R_=e=>{V_(e.fiber,e.cell),e.queued||(e.queued=!0,(e.cell.queue??=[]).push(e))},z_=(e,t)=>{e.wipCommitCallbacks.push(t)},B_=(e,t)=>{e.rollbackCallbacks.push(t)},V_=(e,t)=>{t.isDirty||(t.isDirty=!0,e.markDirty?.(),B_(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}))},H_=Symbol.for(`react.memo_cache_sentinel`),U_=e=>Array(e).fill(H_),W_=(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,B_(e.root,()=>{n.workInProgress=null})}let i=n.index++,a=r[i];return a===void 0?(a=U_(t),r[i]=a):P_&&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},G_=e=>W_(M_(),e),K_=_.default.__COMPILER_RUNTIME?.c??(e=>(0,_.useMemo)(()=>{let t=U_(e);return t[H_]=!0,t},[])),q_=()=>N_()!==null,z=e=>q_()?G_(e):K_(e),J_=()=>{throw Error(`Rendered more hooks than during the previous render. Hooks must be called in the exact same order in every render.`)},Y_=()=>{throw Error(`Hook order changed between renders`)},X_=()=>({type:`effect`,setup:void 0,setupDeps:void 0,cleanup:void 0,deps:null,generation:0});function Z_(e,t){let n=M_(),r=n.currentIndex++,i=n.cells[r],a=i===void 0?X_():i.type===`effect`?i:Y_();if(i===void 0&&(n.isFirstRender||J_(),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`);z_(n,()=>{a.setup=e,a.setupDeps=t,a.generation++})}var Q_=(e,t)=>{P_&&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.
|
|
24
|
-
|
|
25
|
-
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},$_=(e,t)=>{z_(e,()=>{t.current=t.wip,t.currentDeps=t.wipDeps,t.isDirty=!1})},ev=(e,t)=>{let n=M_(),r=n.currentIndex++,i=n.cells[r];if(i===void 0){n.isFirstRender||J_();let a=e();return P_&&n.devStrictMode&&e(),i={type:`memo`,current:a,currentDeps:t,wip:a,wipDeps:t,isDirty:!1},n.cells[r]=i,a}i.type!==`memo`&&Y_();let a=i;if(Q_(a.wipDeps,t))return a.isDirty&&$_(n,a),a.wip;let o=e();return P_&&n.devStrictMode&&e(),a.wip=o,a.wipDeps=t,a.isDirty||(a.isDirty=!0,B_(n.root,()=>{a.wip=a.current,a.wipDeps=a.currentDeps,a.isDirty=!1})),$_(n,a),o};function tv(e){return ev(()=>({current:e}),[])}var nv=Symbol(`tap.Context.defaultValue`),rv=e=>e,iv=new Map,av=new Set,ov=()=>new Map(iv),sv=(e,t)=>{let n=iv;iv=e;try{return t()}finally{iv=n}},cv=(e,t)=>{e[nv]=t},lv=e=>typeof e==`object`&&!!e&&nv in e,uv=e=>typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Symbol.for(`react.context`),dv=e=>lv(e)||uv(e),fv=e=>{if(!lv(e)){if(uv(e)){cv(e,e._currentValue??e._currentValue2);return}throw Error("A tap resource's `use()` only accepts a tap context.")}},pv=(e,t,n)=>{if(typeof e!=`object`||!e)throw Error(`useContextProvider only accepts a React context.`);fv(e);let r=e,i=M_(),a=tv(void 0),o=a.current===void 0||!Object.is(a.current.value,t);Z_(()=>{a.current={value:t}},[t]);let s=iv.get(r),c=s!==void 0||iv.has(r);iv.set(r,{value:t,source:i});try{return mv(r,o,n)}finally{c?iv.set(r,s):iv.delete(r)}},mv=(e,t,n)=>{let r=av.has(e);t?av.add(e):av.delete(e);try{return n()}finally{r?av.add(e):av.delete(e)}},hv=e=>{fv(e);let t=e,n=gv(t,e),r=M_();return(r.wipContextDeps??=new Map).set(t,n.source),n.value},gv=(e,t)=>iv.get(e)??{value:rv(t)[nv],source:null},Dee=(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},_v=(e,t=e.wipContextDeps)=>{let n=N_();n&&t&&(n.wipContextDeps=Dee(n,e,n.wipContextDeps,t))},vv=()=>av.size>0,yv=e=>{if(!e.contextDeps||!vv())return!1;for(let t of av.keys())if(e.contextDeps.has(t))return!0;return!1},Oee=(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,R_(t),t.logged||(t.logged=!0,e.root.changelog.push(t)),!0))},kee=(e,t,n,r,i)=>{let a=r?r(n):n;P_&&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=N_();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 Oee(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 bv(e,t,n,r){let i=M_(),a=i.currentIndex++,o=i.cells[a],s=(()=>{if(o!==void 0)return o.type===`reducer`?o:Y_();i.isFirstRender||J_();let s=kee(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,P_&&i.devStrictMode&&(r.eagerState=e(s.workInProgress,r.action))):P_&&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)||(V_(i,s),s.workInProgress=t)}return s.isDirty&&z_(i,()=>{s.current=s.workInProgress,s.isDirty=!1}),[s.workInProgress,s.dispatch]}function xv(e,t,n){return bv(e,t,n,!1)}var Aee=(e,t)=>typeof t==`function`?t(e):t,jee=e=>e===void 0?void 0:typeof e==`function`?e():e;function Sv(e){return bv(Aee,e,jee,!0)}var Cv=(e,t)=>ev(()=>e,t);function wv(e){let t=M_(),n=tv(e);return n.current!==e&&z_(t,()=>{n.current=e}),Cv(((...e)=>{if(P_&&N_())throw Error(`useEffectEvent cannot be called during render`);return n.current(...e)}),[])}var Tv=e=>typeof e==`object`&&!!e&&typeof e.then==`function`,Ev=()=>{},Mee=e=>{let t=e;switch(typeof t.status==`string`?t.status!==`fulfilled`&&t.status!==`rejected`&&e.then(Ev,Ev):(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}},Dv=e=>Tv(e)?Mee(e):hv(e),Ov=!1,kv=(e,t,n=t)=>{let r=M_().isNeverMounted,i=r?n():t();P_&&!Ov&&(!r||n===t)&&(Object.is(i,t())||(Ov=!0,console.error(`The result of getSnapshot should be cached to avoid an infinite loop`)));let[,a]=xv(e=>e+1,0),o=tv(0),s=wv(()=>{try{if(Object.is(i,t()))return o.current=0,!1}catch{}return!0});return Z_(()=>e(()=>{s()&&a()}),[e]),Z_(()=>{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},Nee=(e,t)=>{},Pee=0,Av=()=>{let e=tv(null);return e.current??=`:tap${Pee++}:`,e.current},jv=(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?Z_(r):Z_(r,[...n,e])},Fee=_.default;function Iee(e){let t=(0,_.useRef)(e);return(0,_.useInsertionEffect)(()=>{t.current=e}),(0,_.useCallback)(((...e)=>t.current(...e)),[])}var Lee=Fee.useEffectEvent??Iee,Mv=()=>N_()!==null,Nv=_.default,Pv=e=>Mv()?Sv(e):Nv.useState(e),Ree=(e,t,n)=>Mv()?xv(e,t,n):Nv.useReducer(e,t,n),B=e=>Mv()?tv(e):Nv.useRef(e),Fv=(e,t)=>Mv()?ev(e,t):Nv.useMemo(e,t),Iv=(e,t)=>Mv()?Cv(e,t):Nv.useCallback(e,t),V=(e,t)=>Mv()?Z_(e,t):Nv.useEffect(e,t),Lv=(e,t)=>Mv()?Z_(e,t):Nv.useLayoutEffect(e,t),Rv=e=>Mv()?wv(e):Lee(e),zv=(e,t,n)=>Mv()?kv(e,t,n):Nv.useSyncExternalStore(e,t,n),Bv=(e,t)=>Mv()?void 0:Nv.useDebugValue(e,t),Vv=(e,t)=>Mv()?Z_(e,t):Nv.useInsertionEffect(e,t),Hv=()=>Mv()?Av():Nv.useId(),Uv=(e,t,n)=>Mv()?jv(e,t,n):Nv.useImperativeHandle(e,t,n),Wv=e=>Nv.forwardRef(e),Gv=(e,t)=>Nv.memo(e,t),Kv=Nv.Fragment,qv=(...e)=>Nv.createElement(...e),Jv=(...e)=>Nv.cloneElement(...e),Yv=e=>Nv.isValidElement(e);Nv.Children,Nv.Suspense;var Xv=e=>{let t=Nv.createContext(e);return cv(t,e),t},Zv=e=>Mv()&&dv(e)?Dv(e):Nv.use(e),Qv=e=>Mv()&&dv(e)?Dv(e):Nv.useContext(e);function $v(e){return(...t)=>({hook:e,args:t})}function ey(e,t,n){return typeof t==`function`?(...n)=>ey(e,t(...n)):n?{...t,key:e,deps:n}:{...t,key:e}}var ty=(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)}},ny=50,ry={schedulers:new Set,isScheduled:!1},iy=null,ay=[],oy=class{_isDirty=!1;_task;constructor(e){this._task=e}get isDirty(){return this._isDirty}markDirty(){if(iy&&(iy.get(this)??0)>=ny)throw Error(`Maximum update depth exceeded. This can happen when a resource repeatedly calls setState inside useEffect.`);this._isDirty=!0,ry.schedulers.add(this),ly()}runTask(){iy?.set(this,(iy.get(this)??0)+1),this._isDirty=!1,this._task()}settle(){this._isDirty=!1}},sy=[];new oy(()=>{let e=sy.splice(0),t=[];for(let n of e)try{n()}catch(e){t.push(e)}ty(t,`Errors occurred while running scheduled tasks`)});var cy=e=>{if(iy!==null){ay.push(e);return}e()},ly=()=>{ry.isScheduled||(ry.isScheduled=!0,dy())},uy=()=>{let e=iy;iy=new Map;let t=[];try{for(let e of ry.schedulers)if(ry.schedulers.delete(e),e.isDirty)try{e.runTask()}catch(e){t.push(e)}}finally{if(iy=e,ry.schedulers.clear(),ry.isScheduled=!1,iy===null)for(;ay.length>0;)try{ay.shift()()}catch(e){t.push(e)}}ty(t,`Errors occurred during flushSync`)},dy=(()=>{if(typeof MessageChannel<`u`){let e=null,t;return()=>{if(!e){let n=new MessageChannel;n.port1.onmessage=()=>{e?.unref?.(),uy()},e=n.port1,t=n.port2}e.ref?.(),t.postMessage(null)}}return()=>setTimeout(uy,0)})(),fy=e=>{if(iy!==null)return P_&&console.warn(`flushTapSync was called from inside a render or commit. The flush is deferred until the current pass completes.`),e();let t=ry;ry={schedulers:new Set,isScheduled:!0};try{let t=e();return uy(),t}finally{let e=ry.schedulers;if(ry=t,e.size>0){for(let t of e)ry.schedulers.add(t);ly()}}};function py(e){let t=[];for(let n=0;n<e.length;n++)try{e[n]()}catch(e){t.push(e)}ty(t,`Errors during commit`)}function my(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 hy=e=>e.setup===void 0?!1:e.deps===null||e.setupDeps===void 0||!Q_(e.deps,e.setupDeps);function gy(e){let t=[],n=[];for(let t of e.effectCells)hy(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{my(e)}catch(e){t.push(e)}ty(t,`Errors during commit`)}function _y(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}ty(t,`Errors during cleanup`)}var vy={useState:Sv,useReducer:xv,useRef:tv,useMemo:ev,useCallback:Cv,useEffect:Z_,useLayoutEffect:Z_,useInsertionEffect:Z_,useEffectEvent:wv,useContext:hv,use:Dv,useSyncExternalStore:kv,useDebugValue:Nee,useId:Av,useImperativeHandle:jv,useMemoCache:G_},yy=_.default,by=yy.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE??yy.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,xy=by==null?null:`H`in by?{get current(){return by.H},set current(e){by.H=e}}:`ReactCurrentDispatcher`in by?{get current(){return by.ReactCurrentDispatcher.current},set current(e){by.ReactCurrentDispatcher.current=e}}:null;function Sy(e){if(!xy)return e();let t=xy.current;xy.current=vy;try{return e()}finally{xy.current=t}}function Cy(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 wy(e){e.wipCommitCallbacks=null,e.wipContextDeps=null,e.memoCache.workInProgress=null}function Ty(e){e.isMounted&&(e.isMounted=!1,_y(e))}function Ey(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,j_(e,()=>{r=Sy(()=>e.hook(...t))})}while((e.renderPendingCells?.size??0)>0)}catch(t){throw wy(e),t}return _v(e),r}function Dy(e){let t=e.wipCommitCallbacks;e.wipCommitCallbacks=null;let n=P_&&!e.isMounted&&e.devStrictMode===`root`;e.isMounted=!0,e.isNeverMounted=!1,t!==null&&(e.contextDeps=e.wipContextDeps,I_(e.root),e.memoCache.workInProgress!==null&&(e.memoCache.current=e.memoCache.workInProgress,e.memoCache.workInProgress=null),py(t)),n&&(gy(e),_y(e)),gy(e)}var Oy=()=>{let e=M_();return e.devStrictMode?e.isFirstRender?`child`:`root`:null},ky=()=>`child`,Ay=()=>null,jy=()=>{if(!P_)return Ay;let e=B(0);return Pv(()=>e.current++),e.current===2?ky:Ay},My=()=>N_()?Oy:jy(),Ny=e=>e(),Py=(e,t,n)=>{let r=new oy(()=>s.handleUpdate()),i=[],a=F_((e,t)=>{(i.length!==0||e())&&(i.push(t),r.markDirty())}),o=Cy(Ny,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:()=>{L_(a,a.committedVersion);for(let e of i)P_&&o.devStrictMode&&e(),e();return L_(a,a.committedVersion+a.changelog.length),i.length},publish:(e,t)=>{r.isDirty||a.committedVersion!==t||s.value===e||(s.value=e,cy(()=>s.subscribers.forEach(e=>e())))},finishFlush:(e,t,n)=>{I_(a),i.splice(0,n),s.pendingHostRender=!1,i.length===0&&r.settle(),s.isMounted&&Dy(o),s.publish(e,t)},handleUpdate:()=>{let e=s.applyQueue(),t;try{P_&&o.devStrictMode&&sv(s.context,()=>Ey(o,[s.committedRender])),t=sv(s.context,()=>Ey(o,[s.committedRender]))}catch(e){if(L_(a,a.committedVersion),Tv(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},Fy=e=>{let[,t]=Pv(0),n=My(),r=B(null),i=r.current??=Py(e,n(),t),a=ov(),o=i.scheduler.isDirty||i.pendingHostRender?i.applyQueue():0,s=sv(a,()=>Ey(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),V(()=>(i.isMounted=!0,()=>{i.isMounted=!1,Ty(i.fiber)}),[i]),V(()=>{if(c.processed){i.fiber.isMounted||(Dy(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}Dy(i.fiber),i.publish(c.value,c.version)}),Fv(()=>({getValue:()=>i.value,subscribe:e=>(i.subscribers.add(e),()=>i.subscribers.delete(e))}),[i])},Iy=()=>{let e=B(0),t=e.current,n=M_();return{version:t,markDirty:Fv(()=>()=>{e.current++,n.markDirty?.()},[n]),root:n.root}},Ly=()=>{let[e]=Pv(()=>F_((e,t)=>{let i=!1;r(t=>(i=!e(),i?t:t+1)),i||n(t)})),[t,n]=Ree((t,n)=>(L_(e,t),t+ +!!n()),0),[,r]=Pv(0);return L_(e,t),{root:e,version:t,markDirty:void 0}},Ry=()=>{let e=My(),{root:t,version:n,markDirty:r}=N_()?Iy():Ly();return{version:n,createFiber:Iv((n,i,a)=>Cy(n,t,a?()=>{a(),r?.()}:r,e()),[])}},zy=(e,t,n)=>{let r=B(null),i=r.current??={wipDeps:null,wip:null,currentDeps:null,current:null};return i.wipDeps=i.currentDeps,i.wip=i.current,V(()=>{i.currentDeps=i.wipDeps,i.current=i.wip}),!n&&i.currentDeps&&Q_(i.currentDeps,t)?i.current:(i.wipDeps=t,i.wip=e(),i.wip)};function By(e){let{version:t,createFiber:n}=Ry(),r=Fv(()=>n(e.hook,e.key),[e.hook,e.key,n]),i=zy(()=>({value:Ey(r,e.args)}),[r,t,e.args],yv(r));return V(()=>()=>Ty(r),[r]),V(()=>{Dy(r)},[r,i]),i.value}var Vy=(e,t)=>{let n=e.get(t);n&&(n.isDirty=!0)},Hy=(e,t)=>!e.isDirty&&!yv(e.fiber)&&t!==void 0&&e.committedDeps!==void 0&&Q_(e.committedDeps,t),Uy=e=>{if(!vv())return!1;for(let{fiber:t}of e.values())if(yv(t))return!0;return!1};function Wy(e){let[t]=Pv(()=>new Map),{version:n,createFiber:r}=Ry(),i=Uy(t),a=zy(()=>{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,()=>Vy(t,c));l={fiber:e,next:{value:Ey(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,()=>Vy(t,c)),n=Ey(e,s.args);l.next={value:n,deps:s.deps,remount:e}}else if(Hy(l,s.deps))typeof l.next==`object`&&wy(l.fiber),l.fiber.contextDeps&&_v(l.fiber,l.fiber.contextDeps),l.next=`skip`;else{let e=Ey(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 V(()=>()=>{for(let e of t.keys())Ty(t.get(e).fiber)},[t]),V(()=>{for(let[e,n]of t.entries()){let r=n.next;r===`delete`?(Ty(n.fiber),t.delete(e)):r===`skip`?!n.fiber.isNeverMounted&&!n.fiber.isMounted&&Dy(n.fiber):(r.remount&&(Ty(n.fiber),n.fiber=r.remount),Dy(n.fiber),n.committedDeps=r.deps,n.committedValue=r.value,n.isDirty=!1,n.next=`skip`)}},[a,t]),a}var Gy=e=>e(),Ky=e=>{let{createFiber:t}=Ry(),n=Fv(()=>t(Gy,void 0),[t]),r=Ey(n,[e]);V(()=>()=>{Ty(n)},[n]);let i=!1,a=()=>{i&&n.isMounted||(i=!0,Dy(n))};return V(a),{value:r,effects:a}},qy=$v(()=>{let e=z(4),[t,n]=Pv(Jy),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 Jy(){return{renderers:{},fallbacks:[]}}var Yy=e=>{if(!e.overwrite)return e;let{overwrite:t,...n}=e;return n},Xy=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]=Yy(a);continue}let s=o>r?t:a,c=o>r?a:t;e.tools[i]=Yy({...c,...s}),n[i]=Math.max(o,r);continue}e.tools||={},e.tools[i]=Yy(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},{})},Zy=(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)}},Qy=e=>e,$y=new Set([`$$typeof`,`nodeType`,`then`,`__v_raw`,`__v_isRef`,`__v_isReactive`,`__v_isReadonly`,`__v_isShallow`,`__v_skip`]),eb=(e,t)=>{if(e===Symbol.toStringTag)return t;if(typeof e!=`symbol`){if(e===`toJSON`)return()=>t;if(!$y.has(e))return!1}},tb=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}},nb=Symbol(`assistant-ui.store.clientId`),rb=Symbol(`assistant-ui.store.instanceTag`),ib=(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===nb?cb(t()):t()[r],has:(e,n)=>n===`source`||n===`query`||n===`name`||n===nb||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},ab=(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===nb)return n();let i=eb(r,`AssistantClientAccessor`);return i===!1?n():i},has:(e,t)=>t===`source`||t===`query`||t===`name`,ownKeys:()=>[],getOwnPropertyDescriptor:()=>void 0})},ob=e=>e?.source!=null,sb=e=>e?.source===null,cb=e=>e[nb]??e,lb=e=>e[rb]??cb(e),ub=e=>e===`optional`||e===`subscribe`||e===`on`||e===`__proto__`||typeof e==`symbol`,db=e=>{let t=[];for(let n in e)ub(n)||t.push(n);return t},fb=class extends tb{#e;constructor(e){super(),this.#e=e}get(e,t){let n=eb(t,`OptionalAssistantClient`);if(n!==!1)return n;if(ub(t))return;let r=this.#e[t];return ob(r)?r:void 0}ownKeys(){return db(this.#e)}has(e,t){return!ub(t)&&t in this.#e}},pb=e=>new Proxy({},new fb(e)),mb=()=>()=>{},hb=`You are using a component or hook that requires an AuiProvider. Wrap your component in an <AuiProvider> component.`,gb=class extends tb{#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 mb;if(t===`optional`)return this.#r??=pb(this.#n());let n=eb(t,this.#e);return n===!1?ab(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`}},_b=((e,t)=>{let n=new Proxy({},new gb(e,t,()=>n));return n})(`DefaultAssistantClient`,()=>hb),vb=()=>new Proxy({},{get(e,t){let n=eb(t,`AssistantClient`);return n===!1?ab(`The current scope does not have a "${String(t)}" property.`,String(t)):n}}),yb=Xv(_b),bb=()=>{},xb=new WeakMap,Sb=e=>xb.get(e)??bb,Cb=(e,t)=>{xb.set(e,t)},wb=()=>Qv(yb),Tb=(e,t)=>pv(yb,e,t),Eb=Symbol(`assistant-ui.transform-scopes`);function Db(e,t){let n=e;if(n[Eb])throw Error(`transformScopes is already attached to this resource`);n[Eb]=t}function Ob(e){return e[Eb]}var kb=e=>typeof e==`string`?{scope:e.split(`.`)[0],event:e}:{scope:e.scope,event:e.event},Ab=()=>{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)}}}},jb=()=>Pv(Ab)[0],Mb=Symbol(`assistant-ui.store.clientIndex`),Nb=e=>e[Mb],Pb=Xv([]),Fb=()=>Zv(Pb),Ib=(e,t)=>{let n=z(3),r=Fb(),i;return n[0]!==e||n[1]!==r?(i=[...r,e],n[0]=e,n[1]=r,n[2]=i):i=n[2],pv(Pb,i,t)},Lb=Xv(null),Rb=Symbol(`aui.scope-effect-unapplied`),zb=(e,t)=>pv(Lb,e,t),Bb=()=>{let e=Zv(Lb);if(!e)throw Error(`AssistantTapContext is not available`);return e},Vb=()=>Bb().clientRef,Hb=()=>Zv(Lb)?.destroySignal,Ub=(e,t,n)=>{let r=z(8),{clientRef:i}=Bb(),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&&ob(t)?lb(t):void 0},a=Rb,o,s=e=>{if(o?.(),o=void 0,a=Rb,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],V(a,o)},Wb=()=>{let e=z(3),{emit:t}=Bb(),n=Fb(),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],Rv(r)},Gb=Symbol(`assistant-ui.store.getValue`),Kb=e=>{let t=e[Gb];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?.()},qb=new Map;function Jb(e){let t=qb.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[Gb];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)},qb.set(e,t)),t}var Yb=class extends tb{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===Gb)return this.outputRef.current;if(t===Mb)return this.index;if(t===rb)return this.tagRef.current;let r=eb(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=Jb(t).bind(n),this.boundFns.set(t,e)),e}return i}ownKeys(){return Object.keys(this.outputRef.current)}has(e,t){return t===Gb||t===Mb||t===rb||t in this.outputRef.current}},Xb=e=>{let t=B(null),n=B(null),r=Fv(()=>({}),[e.hook,e.key]),i=Fb().length,a=Fv(()=>new Proxy({},new Yb(t,n,i)),[i]),o=Ib(a,function(){return By(e)});return t.current||(t.current=o,n.current=r),V(()=>{t.current=o,n.current=r}),{methods:a,state:o.getState?.(),key:e.key}},Zb=$v(Xb),Qb=(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]))},$b=e=>{let t=Fv(()=>({}),[]);return t.v!==void 0&&Qb(t.v,e)?t.v:(t.v=e,e)},ex=e=>{let t=z(2),n=B(void 0),r;return t[0]===e?r=t[1]:(r=t=>{let r=e(t);return n.current!==void 0&&Qb(n.current,r)?n.current:(n.current=r,r)},t[0]=e,t[1]=r),r},tx=(()=>{try{return!1}catch{return!1}})(),nx=(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=Ob(e.hook);if(a){a(n,t),i=!0;break}}}return n},rx=e=>e.hook===Dx,ix=e=>{if(!rx(e))return{source:`root`,query:{}};let t=e.args[0];return{source:t.source,query:t.query??{}}},ax=Symbol.for(`aui.event-receiver-ref`),ox=(e,t)=>{let n=e===_b?vb():e,r=Object.create(n);Object.assign(r,t);let i;return Object.defineProperty(r,"optional",{get:()=>i??=pb(r),enumerable:!1}),r},sx=({notifications:e,clientRef:t})=>Fv(()=>({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}=kb(n),o=n[ax];if(i!==`*`&&!o&&sb(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(!ob(a))return;let s=cb(a);s===n[Nb(s)]&&r(e)});if(i!==`*`){if(o){if(t.parent===_b)return s}else if(sb(t.parent[i]))return s}let c=t.parent.on(n,r);return()=>{s(),c()}}}),[e,t]),cx=e=>{let t=z(5),n;t[0]===e?n=t[1]:(n=ix(e),t[0]=e,t[1]=n);let{source:r,query:i}=n,a=$b(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],$b(o)},lx=(e,t)=>{let n=z(3),r;return n[0]!==t||n[1]!==e?(r=t?e:Zb(e),n[0]=t,n[1]=e,n[2]=r):r=n[2],By(r)},ux=$v((e,t)=>{let n=wb(),r=rx(t),i=lx(t,r),a=r?i:i.methods,o=cx(t),s=Fv(()=>ib({name:e,...o},()=>a),[e,o,a]);return n[e]=s,s}),dx=e=>{let t=z(2),n;return t[0]===e?n=t[1]:(n=e.map(Sx),t[0]=e,t[1]=n),Wy(n)},fx=(e,t)=>{let n=$b(t),r=Fv(()=>({}),[]);return r.deps!==n&&(r.deps=n,r.client=e),r.client},px=({parent:e,entries:t,clientRef:n,notifications:r,destroySignal:i})=>{let a=ox(e,sx({notifications:r,clientRef:n}));return{client:fx(a,[e,...zb({clientRef:n,emit:r.emit,destroySignal:i},function(){return Tb(a,function(){return dx(t)})})])}},mx=({parent:e,entries:t})=>{let n=B({parent:e,current:null}).current,{value:r,effects:i}=Ky(function(){let r=jb(),{client:i}=px({parent:e,entries:t,clientRef:n,notifications:r});return V(()=>e.subscribe(r.notifySubscribers),[e,r]),V(()=>r.notifySubscribers()),i});return Vv(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},hx=({parent:e,entries:t})=>{let n=B({parent:e,current:null}).current,{value:r,effects:i}=Ky(function(){let r=jb(),i=Fy(function(){return px({parent:e,entries:t,clientRef:n,notifications:r})}),a=zv(i.subscribe,()=>i.getValue().client,()=>i.getValue().client);return V(()=>{let t=()=>fy(()=>{n.current=i.getValue().client,r.notifySubscribers()}),a=i.subscribe(t),o=e.subscribe(t);return()=>{a(),o()}},[i,e,r]),a});return Vv(()=>{n.parent=e,n.current=r},[r,e,n]),{client:r,effects:i}},gx=(e,t,n,r)=>{let{get:i}=r.args[0],a=zv(e.subscribe,()=>i(e),()=>i(e)),o=cx(r),s=Fv(()=>ib({name:n,...o},()=>a),[n,o,a]);return t[n]=s,s},_x=(e,t)=>{if(tx){let[e]=Pv(()=>t.map(([e])=>e).join(`,`)),n=t.find(([,e])=>!rx(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=B({parent:e,current:null}).current,r=ox(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}=kb(t);if(i===`*`)return e.on(t,r);let o=t[ax];if(!o&&sb(this[i]))throw Error(`Scope "${i}" is not available. Use { scope: "*", event: "${a}" } to listen globally.`);return e.on({scope:i,event:a,[ax]:o??n},r)}}),i=fx(r,[e,...t.map(([t,n])=>gx(e,r,t,n))]);return Vv(()=>{n.parent=e,n.current=i},[i,e,n]),i},vx=(e,t)=>{let n=z(8),r;n[0]!==t||n[1]!==e?(r=Object.entries(nx(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(Cx),n[3]=i,n[4]=a);let[o]=Pv(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},yx=(e,t,n)=>{let{entries:r,rooted:i}=vx(e,t);return i?n({parent:e,entries:r}):{client:_x(e,r)}},bx=(e,t)=>yx(e,t,mx);function xx(e){let t=wb();if(e){let{client:n,effects:r}=yx(t,e,hx);return r&&Cb(n,r),n}return t}function Sx(e){let[t,n]=e;return ey(t,ux(t,n))}function Cx(e){let[,t]=e;return!rx(t)}var wx=e=>{let t;class n extends tb{get(t,n){let r=eb(n,`OptionalAssistantState`);if(r!==!1)return r;let i=n;if(!ub(i)&&ob(e[i]))return Kb(e[i]())}ownKeys(){return db(e)}has(t,n){return!ub(n)&&n in e}}class r extends tb{get(r,i){let a=eb(i,`AssistantState`);if(a!==!1)return a;if(i===`optional`)return t??=new Proxy({},new n);let o=i;if(!ub(o))return Kb(e[o]())}ownKeys(){return[...db(e),`optional`]}has(t,n){return n===`optional`||!ub(n)&&n in e}}return new Proxy({},new r)},Tx=new WeakMap,Ex=e=>{let t=Tx.get(e);return t||(t=wx(e),Tx.set(e,t)),t},H=e=>{let t=z(6),n=xx(),r;t[0]===n?r=t[1]:(r=Ex(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=zv(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 Bv(s),s},Dx=e=>{let t=z(3),{get:n}=e,r=xx(),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)},Ox=$v(Dx),kx=e=>{if(e.key===void 0)throw Error(`useClientLookup: Element has no key`);return e.key};function Ax(e){let t=z(12),n;t[0]===e?n=t[1]:(n=e.map(Nx),t[0]=e,t[1]=n);let r=Wy(n),i;t[2]===e?i=t[3]:(i=e.reduce(Mx,{}),t[2]=e,t[3]=i);let a=i,o;t[4]===r?o=t[5]:(o=r.map(jx),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 jx(e){return e.state}function Mx(e,t,n){return e[kx(t)]=n,e}function Nx(e){return ey(kx(e),Zb(e),e.deps)}var Px=(e,t=0)=>t===0?Math.abs(e.scrollHeight-e.scrollTop-e.clientHeight)<=1||e.scrollHeight<=e.clientHeight:e.scrollHeight-t-e.scrollTop-e.clientHeight<=1||e.scrollHeight-t<=e.clientHeight,Fx=(e,t=0)=>t===0?e.scrollHeight>e.clientHeight+1:e.scrollHeight-t>e.clientHeight+1,Ix=(e,t)=>e.scrollTop>t.scrollTop&&e.scrollHeight===t.scrollHeight,Lx=Symbol(`skip-update`),Rx=(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)}},zx=(e,t)=>e===void 0||t===void 0?e===t:Qb(e,t),Bx=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(){Rx(this._subscribers)}},Vx=class extends Bx{_state;constructor(e){super(),this._state=e,this.subscribe=this.subscribe.bind(this),this.getState=this.getState.bind(this),this.getServerSnapshot=()=>e}getState(){return this._state}getServerSnapshot;setState(e){Object.is(e,this._state)||(this._state=e,this._notifySubscribers())}},Hx=class{_subscriptions=new Set;_connection;get isConnected(){return!!this._connection}notifySubscribers(e,t){if(t){Zy(this._subscriptions,e,t);return}Rx(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()}}},Ux=class extends Hx{get path(){return this.binding.path}binding;constructor(e){super(),this.binding=e;let t=e.getState();if(t===Lx)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===Lx||zx(e,this._previousState)?!1:(this._previousState=e,!0)}_connect(){let e=this.binding.subscribe(()=>{this._syncState()&&this.notifySubscribers()});return this._syncState(),e}},Wx=class extends Hx{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!==Lx&&(this._previousState===void 0||!zx(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}},Gx=class extends Hx{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?.()}}},Kx=class extends Hx{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?.()}}},qx=class{_providers=new Map;_providerUnsubscribes=new Map;getModelContext(){return Xy(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(){Rx(this._subscribers)}subscribe(e){return this._subscribers.add(e),()=>{this._subscribers.delete(e)}}},Jx=[],Yx={modelName:void 0,toolNames:Jx},Xx=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>e===t[n]),Zx=(e,t)=>{let n=e.getModelContext(),r=n.config?.modelName,i=n.tools?Object.keys(n.tools).sort():Jx,a=i.length?i:Jx;return r===t.modelName&&Xx(a,t.toolNames)?t:{modelName:r,toolNames:a}},Qx=$v(()=>{let e=z(11),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new qx,e[0]=t):t=e[0];let n=t,r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>Zx(n,Yx),e[1]=r):r=e[1];let[i,a]=Pv(r),o,s;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>(a(e=>Zx(n,e)),n.subscribe(()=>{a(e=>Zx(n,e))})),s=[n],e[2]=o,e[3]=s):(o=e[2],s=e[3]),V(o,s);let c;e[4]===i?c=e[5]:(c=()=>Zx(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}),$x=(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},eS=e=>e.display===void 0?e.type===`human`:e.display===`standalone`,tS=e=>function(t){return $x(e,t)},nS=e=>{let t=z(16),{toolkit:n,mcpApp:r}=e,i;t[0]===r?i=t[1]:(i=r?[ey(`mcpApp`,r)]:[],t[0]=r,t[1]=i);let a=Wy(i)[0],[o,s]=Pv(iS),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=Vb(),d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(e,t,n)=>{let r={render:t,renderText:n?.renderText,standalone:n?.standalone??!1};return s(t=>({...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?tS(i):void 0);a&&e.push(f(t,a,{standalone:eS(r),renderText:i}))}return()=>{e.forEach(aS)}},m=[n,f],t[6]=n,t[7]=p,t[8]=m),V(p,m);let h;t[9]!==u||t[10]!==n?(h=()=>{if(!n)return;let e=Object.entries(n).reduce(oS,{});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),Ub(`modelContext`,h,g);let _;return t[14]===l?_=t[15]:(_={getState:()=>l,setToolUI:f},t[14]=l,t[15]=_),_},rS=$v(nS);Db(nS,(e,t)=>{!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Qx())});function iS(){return{}}function aS(e){return e()}function oS(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 sS=e=>zv(e.subscribe,e.getState,e.getServerSnapshot),cS=Symbol.for(`assistant-ui.silent-runtime-action`),lS=e=>typeof e==`object`&&!!e&&cS in e,uS=(e,t)=>{let n=t();return n.catch(t=>{lS(t)||console.error(`[assistant-ui] ${e} failed:`,t)}),n},dS=$v(e=>{let t=z(9),{runtime:n}=e,r=sS(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=()=>uS(`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}),fS=$v(e=>{let t=z(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=dS({runtime:a}),t[3]=a,t[4]=o),By(o)}),pS=$v(({item:e,onMove:t,onRemove:n})=>({getState:()=>e,steer:()=>t({lane:`steer`,insertAfter:null}),move:t,remove:n})),mS=$v(e=>{let t=z(55),{threadIdRef:n,messageIdRef:r,runtime:i}=e,a=sS(i),o=Wb(),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]),V(s,c);let l;if(t[6]!==i||t[7]!==a.attachments){let e;t[9]===i?e=t[10]:(e=(e,t)=>ey(e.id,fS({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=Ax(l),d=a.queue,f;if(t[11]!==d||t[12]!==i){let e;t[14]===i?e=t[15]:(e=e=>ey(e.id,pS({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=Ax(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??hS,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 hS(){throw Error(`beginEdit is not supported in this runtime`)}var gS=e=>({get current(){return e()}}),_S=$v(e=>{let t=z(13),{runtime:n}=e,r=sS(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}),vS=$v(e=>{let t=z(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=dS({runtime:a}),t[3]=a,t[4]=o),By(o)}),yS=$v(e=>{let t=z(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=_S({runtime:a}),t[3]=a,t[4]=o),By(o)}),bS=$v(e=>{let t=z(55),{runtime:n,threadIdRef:r}=e,i=sS(n),[a,o]=Pv(!1),[s,c]=Pv(!1),l;t[0]===n?l=t[1]:(l=gS(()=>n.getState().id),t[0]=n,t[1]=l);let u=l,d;t[2]!==u||t[3]!==n.composer||t[4]!==r?(d=mS({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=Xb(d),p;if(t[6]!==n||t[7]!==i.content){let e;t[9]===n?e=t[10]:(e=(e,t)=>ey(`toolCallId`in e&&e.toolCallId!=null?`toolCallId-${e.toolCallId}`:`index-${t}`,yS({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=Ax(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)=>ey(e.id,vS({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 _=Ax(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,T,E,D,O,k;t[28]===n?(C=t[29],w=t[30],T=t[31],E=t[32],D=t[33],O=t[34],k=t[35]):(C=()=>n.delete(),w=e=>n.reload(e),T=()=>n.speak(),E=()=>n.stopSpeaking(),D=e=>n.submitFeedback(e),O=e=>n.switchToBranch(e),k=()=>n.unstable_getCopyText(),t[28]=n,t[29]=C,t[30]=w,t[31]=T,t[32]=E,t[33]=D,t[34]=O,t[35]=k);let A;t[36]===m?A=t[37]:(A=e=>`index`in e?m.get({index:e.index}):m.get({key:`toolCallId-${e.toolCallId}`}),t[36]=m,t[37]=A);let j;t[38]===_?j=t[39]:(j=e=>`id`in e?_.get({key:e.id}):_.get(e),t[38]=_,t[39]=j);let ee;t[40]===n?ee=t[41]:(ee=()=>n,t[40]=n,t[41]=ee);let te;return t[42]!==C||t[43]!==w||t[44]!==T||t[45]!==E||t[46]!==D||t[47]!==O||t[48]!==k||t[49]!==A||t[50]!==j||t[51]!==ee||t[52]!==x||t[53]!==S?(te={getState:x,composer:S,delete:C,reload:w,speak:T,stopSpeaking:E,submitFeedback:D,switchToBranch:O,getCopyText:k,part:A,attachment:j,setIsCopied:o,setIsHovering:c,__internal_getRuntime:ee},t[42]=C,t[43]=w,t[44]=T,t[45]=E,t[46]=D,t[47]=O,t[48]=k,t[49]=A,t[50]=j,t[51]=ee,t[52]=x,t[53]=S,t[54]=te):te=t[54],te}),xS=e=>{let t=Fv(()=>({}),[]),n=t.state,r=e.suggestions.map((e,t)=>{let r=n?.suggestions[t];return r&&Qb(r,e)?r:e}),i=n&&n.suggestions.length===r.length&&r.every((e,t)=>e===n.suggestions[t])?n:{suggestions:r};return t.state=i,i},SS=$v(e=>({getState:()=>e})),CS=e=>{let t=z(9),n=xS(e),r;t[0]===n.suggestions?r=t[1]:(r=n.suggestions.map(TS),t[0]=n.suggestions,t[1]=r);let i=Ax(r),a;t[2]===n?a=t[3]:(a=()=>n,t[2]=n,t[3]=a);let o;t[4]===i?o=t[5]:(o=e=>{let{index:t}=e;return i.get({index:t})},t[4]=i,t[5]=o);let s;return t[6]!==a||t[7]!==o?(s={getState:a,suggestion:o},t[6]=a,t[7]=o,t[8]=s):s=t[8],s},wS=$v(e=>{let t=z(4),n;t[0]===e?n=t[1]:(n=e.map(ES),t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r={suggestions:n},t[2]=n,t[3]=r),CS(r)});function TS(e,t){return ey(t,SS(e),[e])}function ES(e){return{title:e.title??e.prompt,label:e.label??``,prompt:e.prompt}}var DS=$v(e=>{let t=z(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=bS({runtime:o,threadIdRef:i}),t[3]=o,t[4]=i,t[5]=s):s=t[5],By(s)}),OS=$v(e=>{let t=z(64),{runtime:n}=e,r=sS(n),i=Wb(),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]),V(a,o);let s;t[4]===n?s=t[5]:(s=gS(()=>n.getState().threadId),t[4]=n,t[5]=s);let c=s,l;t[6]!==n.composer||t[7]!==c?(l=mS({runtime:n.composer,threadIdRef:c}),t[6]=n.composer,t[7]=c,t[8]=l):l=t[8];let u=Xb(l),d;t[9]===r.suggestions?d=t[10]:(d=wS(r.suggestions),t[9]=r.suggestions,t[10]=d);let f=Xb(d),p;if(t[11]!==n||t[12]!==r.messages||t[13]!==c){let e;t[15]!==n||t[16]!==c?(e=e=>ey(e.id,DS({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=Ax(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}),kS=(e,t)=>uS(`thread list ${e}`,t),AS=$v(e=>{let t=z(35),{runtime:n,mainThreadIsRunning:r}=e,i=r!==void 0&&r,a=sS(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=Wb(),{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=B(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]),V(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=>kS(`switch`,()=>n.switchTo(e)),x=e=>kS(`rename`,()=>n.rename(e)),S=e=>kS(`update custom metadata`,()=>n.updateCustom(e)),g=()=>kS(`archive`,()=>n.archive()),_=()=>kS(`unarchive`,()=>n.unarchive()),v=()=>kS(`delete`,()=>n.delete()),y=()=>kS(`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}),jS=e=>{let t=z(4),n=Wb(),r=B(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]),V(i,a)},MS=$v(e=>{let t=z(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=AS({runtime:o,mainThreadIsRunning:i}),t[3]=i,t[4]=o,t[5]=s):s=t[5],By(s)}),NS=$v(e=>{let t=z(47),{runtime:n,__internal_assistantRuntime:r}=e,i=sS(n);jS(i.mainThreadId);let a=Wb(),o,s;t[0]!==a||t[1]!==n?(o=()=>n.unstable_subscribeThreadEvents(e=>{let{threadId:t,type:r}=e;t!==n.getState().mainThreadId&&a(`thread.${r}`,{threadId:t})}),s=[n,a],t[0]=a,t[1]=n,t[2]=o,t[3]=s):(o=t[2],s=t[3]),V(o,s);let c;t[4]===n.main?c=t[5]:(c=OS({runtime:n.main}),t[4]=n.main,t[5]=c);let l=Xb(c),u;t[6]!==l.state||t[7]!==n||t[8]!==i.threadItems?(u=Object.keys(i.threadItems).map(e=>ey(e,MS({runtime:n,id:e,mainThreadIsRunning:l.state.isRunning}),[n,e,l.state.isRunning])),t[6]=l.state,t[7]=n,t[8]=i.threadItems,t[9]=u):u=t[9];let d=Ax(u),f=i.newThreadId??null,p;t[10]!==l.state||t[11]!==i.archivedThreadIds||t[12]!==i.hasMore||t[13]!==i.isLoading||t[14]!==i.isLoadingMore||t[15]!==i.mainThreadId||t[16]!==i.threadIds||t[17]!==f||t[18]!==d.state?(p={mainThreadId:i.mainThreadId,newThreadId:f,isLoading:i.isLoading,isLoadingMore:i.isLoadingMore,hasMore:i.hasMore,threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadItems:d.state,main:l.state},t[10]=l.state,t[11]=i.archivedThreadIds,t[12]=i.hasMore,t[13]=i.isLoading,t[14]=i.isLoadingMore,t[15]=i.mainThreadId,t[16]=i.threadIds,t[17]=f,t[18]=d.state,t[19]=p):p=t[19];let m=p,h;t[20]===m?h=t[21]:(h=()=>m,t[20]=m,t[21]=h);let g;t[22]===l.methods?g=t[23]:(g=()=>l.methods,t[22]=l.methods,t[23]=g);let _;t[24]!==m||t[25]!==d?(_=e=>{if(e===`main`)return d.get({key:m.mainThreadId});if(`id`in e)return d.get({key:e.id});let{index:t,archived:n}=e,r=n!==void 0&&n?m.archivedThreadIds[t]:m.threadIds[t];return d.get({key:r})},t[24]=m,t[25]=d,t[26]=_):_=t[26];let v,y,b,x,S,C;t[27]===n?(v=t[28],y=t[29],b=t[30],x=t[31],S=t[32],C=t[33]):(v=(e,t)=>kS(`switch`,()=>n.switchToThread(e,t)),y=()=>kS(`create`,()=>n.switchToNewThread()),b=()=>n.getLoadThreadsPromise(),x=()=>n.reload(),S=()=>n.reloadMainThread(),C=()=>n.loadMore(),t[27]=n,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=S,t[33]=C);let w;t[34]===r?w=t[35]:(w=()=>r,t[34]=r,t[35]=w);let T;return t[36]!==v||t[37]!==y||t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==C||t[42]!==w||t[43]!==h||t[44]!==g||t[45]!==_?(T={getState:h,thread:g,item:_,switchToThread:v,switchToNewThread:y,getLoadThreadsPromise:b,reload:x,reloadMainThread:S,loadMore:C,__internal_getAssistantRuntime:w},t[36]=v,t[37]=y,t[38]=b,t[39]=x,t[40]=S,t[41]=C,t[42]=w,t[43]=h,t[44]=g,t[45]=_,t[46]=T):T=t[46],T}),PS=(e,t)=>{e.thread??=Ox({source:`threads`,query:{type:`main`},get:e=>e.threads.thread(`main`)}),e.threadListItem??=Ox({source:`threads`,query:{type:`main`},get:e=>e.threads.item(`main`)}),e.composer??=Ox({source:`thread`,query:{},get:e=>e.threads.thread(`main`).composer()}),!e.modelContext&&t.modelContext.source===null&&(e.modelContext=Qx()),!e.suggestions&&t.suggestions.source===null&&(e.suggestions=Ox({source:`thread`,query:{},get:e=>e.thread.suggestions()}))},FS=e=>{let t=z(7),n=Vb(),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),Ub(`modelContext`,r,i);let a;return t[5]===e?a=t[6]:(a=NS({runtime:e.threads,__internal_assistantRuntime:e}),t[5]=e,t[6]=a),By(a)},IS=$v(FS);Db(FS,(e,t)=>{PS(e,t),!e.tools&&t.tools.source===null&&(e.tools=rS({})),!e.dataRenderers&&t.dataRenderers.source===null&&(e.dataRenderers=qy())});var LS=e=>{let{children:t,condition:n}=e;return H(n)?t:null};LS.displayName=`AuiIf`;var RS=Qy({}),zS=({effects:e})=>{"use no memo";return V(e),null},BS=Wv(function(e,t){"use no memo";let{config:n,children:r}=e,i=`extends`in e,a=`value`in e,o=wb();if(tx){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!==_b)throw Error(`A parent AuiProvider exists — pass extends={aui} to inherit it or extends={null} to isolate.`)}let s=i?e.extends??_b:a?e.value??_b:o,{client:c,effects:l}=bx(s,n??RS);return Uv(t,()=>c,[c]),(0,I.jsxs)(yb.Provider,{value:c,children:[(0,I.jsx)(zS,{effects:Sb(s)}),l&&(0,I.jsx)(zS,{effects:l}),r]})}),VS=e=>{let t=xx(),n=B(!1),r=n.current?null:e(t);return H(()=>n.current?e(t):r),()=>(n.current=!0,e(t))},HS=Object.freeze({});function US(e){let t=z(3),{getItemState:n,children:r}=e,i=VS(n),a;return t[0]!==r||t[1]!==i?(a=r(i),t[0]=r,t[1]=i,t[2]=a):a=t[2],WS(a)}var WS=e=>{let t=typeof e==`object`&&e&&`type`in e?e:null,n=t?.type,r=t?.key;return Fv(()=>t,[n,r,typeof t?.props==`object`&&t.props!=null&&Object.entries(t.props).length===0?HS:t?.props])??e},GS=(e,t)=>{let n=z(11),r=xx(),i=Rv(t),a;n[0]===e?a=n[1]:(a=kb(e),n[0]=e,n[1]=a);let{scope:o,event:s}=a,c;n[2]!==r||n[3]!==i||n[4]!==s||n[5]!==o?(c=()=>r.on({scope:o,event:s},i),n[2]=r,n[3]=i,n[4]=s,n[5]=o,n[6]=c):c=n[6];let l;n[7]!==r||n[8]!==s||n[9]!==o?(l=[r,o,s],n[7]=r,n[8]=s,n[9]=o,n[10]=l):l=n[10],V(c,l)},zee=e=>e._core?.RenderComponent,Bee=({runtime:e,aui:t,config:n,children:r})=>{"use no memo";let i=zee(e),a=Qy({...n,threads:IS(e)});return(0,I.jsxs)(BS,{extends:t,config:a,children:[i&&(0,I.jsx)(i,{}),r]})},Vee=Gv(e=>{let t=z(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,I.jsx)(Bee,{runtime:n,aui:o,config:i,children:a}),t[0]=o,t[1]=a,t[2]=i,t[3]=n,t[4]=s):s=t[4],s});function Hee(e){return e}function KS(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qS(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=>qS(e,t+1)):KS(e)?Object.entries(e).every(([e,n])=>typeof e==`string`&&qS(n,t+1)):!1}var Uee=100,JS=(e,t,n)=>{if(e===t)return!0;if(n>Uee||e==null||t==null)return!1;if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:e.every((e,r)=>JS(e,t[r],n+1));if(Array.isArray(t)||!KS(e)||!KS(t))return!1;let r=Object.keys(e),i=Object.keys(t);return r.length===i.length&&r.every(r=>Object.hasOwn(t,r)&&JS(e[r],t[r],n+1))},YS=(e,t)=>!qS(e)||!qS(t)?!1:JS(e,t,0);function Wee(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 Gee(e){return`update_${e.replace(/[^a-zA-Z0-9_-]/g,`_`)}`}var XS=e=>{if(!KS(e))return;let t=e.id;return typeof t==`string`||typeof t==`number`?t:void 0};function Kee(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=XS(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=XS(e);if(t===void 0||!KS(e))return e;let n=i.find(e=>KS(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(!KS(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 ZS(e,t,n){if(!KS(e)||!KS(t))return t;let r=KS(n?.arrayBaseline)?n.arrayBaseline:e,i={...e};for(let[e,a]of Object.entries(t)){let t=r[e];i[e]=Array.isArray(t)&&KS(a)?Kee(t,a,n?.idFactory&&(n.idKeyedFields===void 0||n.idKeyedFields.has(e))?()=>n.idFactory?.(e):void 0):a}return i}function qee(e,t){if(!KS(e)||!KS(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)||!YS(e[r],i))&&(n[r]=i);let r=Object.keys(n).length;if(r!==0&&r!==Object.keys(t).length)return n}var Jee=e=>{if(!e||typeof e!=`object`)return;let t=e;return t.type===`tool-call`?t:void 0},Yee=(e,t)=>{if(!e.args||typeof e.args!=`object`)return!1;let n=KS(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},Xee=e=>{let t=KS(e)?e.addedItemIds:void 0;if(!KS(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()},QS=new WeakMap;function Zee(e,t,n){let r=QS.get(e);r||(r=new Map,QS.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=Gee(n),s=[],c=()=>s[s.length-1];for(let r of e){if(r.role===`user`){let e=Wee(r)?.find(e=>e.id===t);if(!e)continue;if(e.partial){let t=c();t&&s.push({state:ZS(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=Jee(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&&Yee(r,t)){let e=c();if(e){let{id:t,...n}=r.args,i=Xee(r.result);s.push({state:i?ZS(e.state,n,{idFactory:i}):ZS(e.state,n),origin:`update`,toolCallId:r.toolCallId})}}}}}return i.set(t,s),s}function Qee(e,t,n){let r=Zee(e,t,n),i=r[r.length-1];return i?{state:i.state}:void 0}function $ee(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=Qee(t,r.id,r.name);if(!n){e.push({id:r.id,name:r.name,state:r.state});continue}if(YS(r.state,n.state))continue;let i=qee(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 $S={toResponse(e,t){return new Response($S.toByteStream(e,t),{headers:t.headers??{}})},fromResponse(e,t){return $S.fromByteStream(e.body,t)},toByteStream(e,t){return e.pipeThrough(t)},fromByteStream(e,t){return e.pipeThrough(t)}},eC=()=>{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}},ete=()=>{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=eC(),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()}}))}}},tC=e=>e instanceof TypeError,nC=(e,t,n)=>{try{e.enqueue(t)}catch(e){if(!tC(e))throw e;n?.(e)}},rC=e=>{try{e.close()}catch(e){if(!tC(e))throw e}},iC=(e,t)=>new ReadableStream({start(n){return e.start?.(t(n))},pull(n){return e.pull?.(t(n))},cancel(t){return e.cancel?.(t)}}),aC=(e,t)=>{let n;return[iC({start(e){n=e},cancel(e){return t?.(n,e)}},e),n]},oC=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):(nC(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,nC(this._controller,{type:`part-finish`,path:[]}),rC(this._controller))}},tte=(e,t={})=>iC(e,e=>new oC(e,t)),sC=(e={})=>aC(t=>new oC(t,e)),cC=Symbol.for(`aui.tool-response`),lC=`<no result>`,uC=class e{get[cC](){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?lC: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&&cC in e}static toResponse(t){return t instanceof e?t:new e({result:t===void 0?lC:t})}},nte=class{_isClosed=!1;_mergeTask;_controller;constructor(e){this._controller=e;let t=tte({start:e=>{this._argsTextController=e}}),n=!1;this._mergeTask=t.pipeTo(new WritableStream({write:e=>{switch(e.type){case`text-delta`:n=!0,nC(this._controller,e);break;case`part-finish`:n||nC(this._controller,{type:`text-delta`,textDelta:`{}`,path:[]}),nC(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;nC(this._controller,{type:`result`,path:[],...e.artifact===void 0?{}:{artifact:e.artifact},result:t===void 0?lC: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,nC(this._controller,{type:`part-finish`,path:[]}),rC(this._controller))}},rte=()=>aC(e=>new nte(e)),dC=class{value=-1;up(){return++this.value}},ite=class extends TransformStream{constructor(e){super({transform(t,n){n.enqueue({...t,path:[e,...t.path]})}})}};TransformStream;var ate=class extends TransformStream{constructor(e){let t=new dC,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]})}})}},fC=class extends TransformStream{constructor(e){super();let t=e(super.readable);Object.defineProperty(this,"readable",{value:t,writable:!1})}},ote=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})),pC=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)}})}},mC=(e,t=21)=>(n=t)=>{let r=``,i=n|0;for(;i-->0;)r+=e[Math.random()*e.length|0];return r},hC=mC(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),ste=class e{_state;_parentId;constructor(e,t={}){this._state=e||{strict:t.strict??!0,merger:ete(),contentCounter:new dC}}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 ite(this._state.contentCounter.value))}merge(e){this._addTransformedStream(e,new ate(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]=sC({strict:this._state.strict});return this._addPart(this._withParentIdOption({type:`text`}),e),t}addReasoningPart(e){let[t,n]=sC({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??hC(),[i,a]=rte();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 cte(e,t={}){let n=new ste(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 gC(e={}){let{resolve:t,promise:n}=eC(),r;return[cte(e=>(r=e,r.__internal_subscribeToClose(t),n),e),r]}var lte=class extends TransformStream{constructor(e,t,n){let[r,i]=gC({strict:e.strict}),a;super({start(t){return a=r.pipeTo(new WritableStream({write(e){t.enqueue(e)},abort(e){t.error(e)},close(){t.terminate()}})).catch(e=>{t.error(e)}),e.start?.(i)},transform(t){return e.transform?.(t,i)},async flush(){await e.flush?.(i),i.close(),await a}},t,n)}},ute=/[0-9a-fA-F]/;function dte(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(!ute.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 _C=c(ote(),1),vC=Symbol(`aui.parse-partial-json-object.meta`),fte=e=>e?.[vC],yC=e=>{if(e.length===0)return{[vC]:{state:`partial`,partialPath:[]}};try{let t=_C.default.parse(e);if(typeof t!=`object`||!t)throw Error(`argsText is expected to be an object`);return t[vC]={state:`complete`,partialPath:[]},t}catch{try{let[t,n]=dte(e),r=_C.default.parse(t);if(typeof r!=`object`||!r)throw Error(`argsText is expected to be an object`);return r[vC]={state:`partial`,partialPath:n},r}catch{return}}},bC=(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 bC(s,{state:`partial`,partialPath:o},i)},xC=(e,t)=>{let n=fte(e);if(!n)throw Error(`unable to determine object state`);return bC(e,n,t.map(String))};async function*pte(){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 SC(e){return e[Symbol.asyncIterator]??=pte,e}var CC=Xv(null),mte=(e,t)=>pv(CC,e,t),wC=()=>Qv(CC),hte={},gte=e=>{let t=$b(e??hte);return e==null?null:t},TC=Symbol(`innerMessage`),EC=Symbol(`innerMessages`),_te=[],DC=(e,t)=>{TC in e||(e[TC]=t)},OC=e=>{let t=`messages`in e?e.messages:e,n=t[EC]||t[TC];return n?Array.isArray(n)?n:(t[EC]=[n],t[EC]):_te},kC=`__external_store_fallback_`,AC=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})}},jC=mC(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,7),vte=`__error__`,yte=()=>`${vte}${jC()}`,bte=/^https?:\/\//i;function MC(e){let t=e.match(/^data:([^;,]+)(?:;[^;,]+)*;base64,(.*)$/i);return t?{mimeType:t[1].toLowerCase(),data:t[2]}:null}var xte=e=>{if(e.sourceType===`url`||bte.test(e.data))return{kind:`url`,url:e.data};let t=MC(e.data);return{kind:`data`,data:t?.data??e.data,mimeType:t?.mimeType??e.mimeType}};function NC(e){try{return new URL(e),!0}catch{return!1}}function PC(e){return/^data:([^;,]+)(?:[;,])/i.exec(e)?.[1]?.toLowerCase()}var FC=(e,t)=>{if(e.startsWith(`data-`))return{type:`data`,name:e.substring(5),data:t}},IC=(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`?MC(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-${jC()}`,...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:yC(e.argsText??``)??{},argsText:e.argsText??``}}default:{let n=FC(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=FC(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=>FC(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}`)}},LC=e=>e.type===`tool-call`&&e.result===void 0,RC=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,zC=Symbol(`autoStatus`),Ste=Object.freeze(Object.assign({type:`running`},{[zC]:!0})),Cte=Object.freeze(Object.assign({type:`complete`,reason:`unknown`},{[zC]:!0})),wte=Object.freeze(Object.assign({type:`incomplete`,reason:`cancelled`},{[zC]:!0})),Tte=Object.freeze(Object.assign({type:`requires-action`,reason:`tool-calls`},{[zC]:!0})),Ete=Object.freeze(Object.assign({type:`requires-action`,reason:`interrupt`},{[zC]:!0})),BC=e=>e[zC]===!0,VC=(e,t,n,r,i,a)=>e&&i?Object.assign({type:`incomplete`,reason:`error`,error:i},{[zC]:!0}):e&&t?Ste:n?Ete:r?Tte:a?wte:Cte,HC=(e,t,n)=>VC(t,n,typeof e!=`string`&&e.some(RC),typeof e!=`string`&&e.some(LC)),UC=e=>{let t;try{t=e instanceof Error?String(e):JSON.stringify(e)}catch{}return t??=String(e),t.length>200?`${t.slice(0,200)}…`:t},WC=(e,t)=>{let n=Array.isArray(e)?e:[e];for(let e of n)if(typeof e!=`object`||!e||e.role!==`tool`&&(e.role!==`assistant`&&e.role!==`user`&&e.role!==`system`||typeof e.content!=`string`&&!Array.isArray(e.content)))throw Error(`External message converter: the converter callback returned an invalid message (${UC(e)}) for input ${UC(t)}. Return an empty array to skip a message.`);return n.filter(e=>e.role!==`tool`||typeof e.toolCallId==`string`&&e.toolCallId.length>0||(GC.has(e)||(GC.add(e),console.warn(`External message converter: dropping a tool result without a toolCallId (${UC(e)}) for input ${UC(t)}.`)),!1))},GC=new WeakSet,KC=(e,t,n)=>({input:e,outputs:WC(t(e,n),e)}),qC=(e,t)=>({[TC]:[...e[TC]??[],...t[TC]??[]]}),JC=e=>{let t={role:`assistant`,content:[]};for(let n of e)if(n.role===`tool`){let e=t.content.findIndex(e=>e.type===`tool-call`&&e.toolCallId===n.toolCallId);if(e!==-1){let r=t.content[e];if(n.toolName!=null&&r.toolName!==n.toolName)throw Error(`Tool call name ${n.toolCallId} ${n.toolName} does not match existing tool call ${r.toolName}`);t.content[e]={...r,[TC]:[...r[TC]??[],n],result:n.result,artifact:n.artifact,isError:n.isError,messages:n.messages}}}else{let e=n.role,r=(typeof n.content==`string`?[{type:`text`,text:n.content}]:n.content).map(e=>({...e,[TC]:[n]}));switch(e){case`system`:case`user`:return{...n,content:r};case`assistant`:t.content.length===0&&(t.id=n.id,t.createdAt??=n.createdAt,t.status??=n.status,n.attachments&&(t.attachments=[...t.attachments??[],...n.attachments])),n.metadata&&(t.metadata??={},n.metadata.unstable_state!==void 0&&(t.metadata.unstable_state=n.metadata.unstable_state),n.metadata.unstable_annotations&&(t.metadata.unstable_annotations=[...t.metadata.unstable_annotations??[],...n.metadata.unstable_annotations]),n.metadata.unstable_data&&(t.metadata.unstable_data=[...t.metadata.unstable_data??[],...n.metadata.unstable_data]),n.metadata.steps&&(t.metadata.steps=[...t.metadata.steps??[],...n.metadata.steps]),n.metadata.custom&&(t.metadata.custom={...t.metadata.custom??{},...n.metadata.custom}),n.metadata.timing&&(t.metadata.timing=n.metadata.timing),n.metadata.submittedFeedback&&(t.metadata.submittedFeedback=n.metadata.submittedFeedback),n.metadata.isOptimistic&&(t.metadata.isOptimistic=!0));for(let e of r){if(e.type===`tool-call`){let n=t.content.findIndex(t=>t.type===`tool-call`&&t.toolCallId===e.toolCallId);if(n!==-1){let r=t.content[n];t.content[n]={...r,...e,...qC(r,e)};continue}}if(e.type===`reasoning`&&`parentId`in e&&e.parentId){let n=t.content.findIndex(t=>t.type===`reasoning`&&`parentId`in t&&t.parentId===e.parentId);if(n!==-1){let r=t.content[n];t.content[n]={...r,text:`${r.text}\n\n${e.text}`,...qC(r,e)};continue}}t.content.push(e)}break;default:throw Error(`Unknown message role: ${e}`)}}return t},YC=(e,t)=>{let n=[],r=!1,i=!1,a=[],o=[],s=()=>{o.length&&n.push({inputs:a,outputs:o}),a=[],o=[],r=!1,i=!1};for(let n of e)for(let e of n.outputs)(i&&e.role!==`tool`||!r||e.role===`user`||e.role===`system`)&&s(),r=e.role===`assistant`||e.role===`tool`,a.at(-1)!==n.input&&a.push(n.input),o.push(e),e.role===`assistant`&&(e.convertConfig?.joinStrategy===`none`||t===`none`)&&(i=!0);return s(),n},XC=(e,t)=>{if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},ZC=(e,t,n,r,i,a,o)=>{let s=t===n-1,c=JC(e.outputs),l=o!==void 0&&e.outputs.some(e=>e.role!==`tool`&&e.id!=null&&o.has(e.id)),u=VC(s,r,typeof c.content==`object`&&c.content.some(RC),typeof c.content==`object`&&c.content.some(LC),s?i:void 0,l),d=`${kC}${t}`,f=a?.message;if(f&&(f.role!==`assistant`||!BC(f.status)||f.status===u||f.status.type===`incomplete`&&f.status.reason===`error`&&f.status.error!==void 0&&u.type===`incomplete`&&u.reason===`error`&&u.error!==void 0&&(f.status.error===u.error||YS(f.status.error,u.error)))&&XC(OC(f),e.inputs)){if(a.generatedFallbackMessages.has(f)&&f.id!==d){let t={...f,id:d};return a.generatedFallbackMessages.add(t),DC(t,e.inputs),t}return f}let p=IC(c,d,u);return a&&c.id==null&&a.generatedFallbackMessages.add(p),DC(p,e.inputs),p};function QC(e){let t={id:yte(),role:`assistant`,content:[],status:{type:`incomplete`,reason:`error`,error:e},createdAt:new Date,metadata:{unstable_state:null,unstable_annotations:[],unstable_data:[],custom:{},steps:[]}};return DC(t,[]),t}var $C=(e,t)=>{if(t){let n=e.at(-1);(!n||n.role!==`assistant`)&&e.push(QC(t))}return e},ew=(e,t,n,r)=>{let i=YC(e.map(e=>KC(e,t,r)));return $C(i.map((e,t)=>ZC(e,t,i.length,n,r.error,void 0,r.cancelledMessageIds)),r.error)},tw=new WeakSet,nw=ew,rw=e=>{let t=z(17),{callback:n,messages:r,isRunning:i,joinStrategy:a,metadata:o}=e,[s]=Pv(Dte),c;t[0]===o?c=t[1]:(c=o??{},t[0]=o,t[1]=c);let l;t[2]!==s||t[3]!==n||t[4]!==c?(l={metadata:c,callback:n,...s},t[2]=s,t[3]=n,t[4]=c,t[5]=l):l=t[5];let u=l,d;if(t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==u.callback||t[10]!==u.callbackCache||t[11]!==u.chunkCache||t[12]!==u.converterCache||t[13]!==u.metadata){let e=[];for(let t of r){let n=u.callbackCache.get(t);(!n||n.metadata!==u.metadata||n.callback!==u.callback)&&(n={...KC(t,u.callback,u.metadata),metadata:u.metadata,callback:u.callback},u.callbackCache.set(t,n)),e.push(n)}let n;t[15]===u.chunkCache?n=t[16]:(n=e=>{let t=e.outputs[0];if(!t)return e;let n=u.chunkCache.get(t);return n&&XC(n.outputs,e.outputs)?n:(u.chunkCache.set(t,e),e)},t[15]=u.chunkCache,t[16]=n);let o=YC(e,a).map(n),s=u.converterCache.convertMessages(o,(e,t,n)=>ZC(t,n,o.length,i,u.metadata.error,{message:e,generatedFallbackMessages:tw},u.metadata.cancelledMessageIds));DC(s,r),d=$C(s,u.metadata.error),t[6]=i,t[7]=a,t[8]=r,t[9]=u.callback,t[10]=u.callbackCache,t[11]=u.chunkCache,t[12]=u.converterCache,t[13]=u.metadata,t[14]=d}else d=t[14];return d};function Dte(){return{callbackCache:new WeakMap,chunkCache:new WeakMap,converterCache:new AC}}var Ote=e=>Math.ceil(e/4),iw=(e,t,n)=>t<=e.lastContentLength?e:{...e,firstTokenTime:e.firstTokenTime??n()-e.startTime,lastContentLength:t,totalChunks:e.totalChunks+1},kte=(e,t,n,r,i,a=Date.now)=>{let o=r.getAssistantMessageId(t),s=i?.estimateTokens??Ote;if(n&&o!==void 0){let n;return n=e===null||e.messageId!==o?{messageId:o,startTime:a(),lastContentLength:0,totalChunks:0}:e,{state:iw(n,r.getTextLength(t,n.messageId),a),timings:{}}}if(!n&&e!==null){let n=a(),i=iw(e,r.getTextLength(t,e.messageId),()=>n),o=n-i.startTime,c=s(i.lastContentLength),l=r.getToolCallCount(t,i.messageId),u={streamStartTime:i.startTime,totalStreamTime:o,totalChunks:i.totalChunks,toolCallCount:l,...i.firstTokenTime!==void 0&&{firstTokenTime:i.firstTokenTime},...c>0&&{tokenCount:c},...o>0&&c>0&&{tokensPerSecond:c/(o/1e3)}};return{state:null,timings:{[i.messageId]:u}}}return{state:e,timings:{}}},Ate=(e,t,n,r)=>{let[i,a]=Pv({}),o=B(null),s=B(n);s.current=n;let c=B(r);return c.current=r,V(()=>{let n=kte(o.current,e,t,s.current,c.current);o.current=n.state,Object.keys(n.timings).length>0&&a(e=>({...e,...n.timings}))},[e,t]),i},aw=new Set([`__proto__`,`constructor`,`prototype`]);function ow(e){if(aw.has(e))throw Error(`Unsafe gorp path segment: ${e}`)}var sw=class{_state;_strict;_logged=new Set;_warnedClamp=!1;constructor(e=null,t={}){this._state=e,this._strict=t.strict??!0}get state(){return this._state}logOnce(e,t){this._logged.has(e)||this._logged.size>=20||(this._logged.add(e),t())}append(e){this._state=e.reduce((e,t)=>{if(this._strict)return this.apply(e,t);try{return this.apply(e,t)}catch(n){return this.logOnce(`skip:${String(n)}`,()=>console.error(`Skipped unappliable gorp operation: ${String(n)}`,t)),e}},this._state)}apply(e,t){let n=t.type;switch(n){case`set`:return this.updatePath(e,t.path,()=>t.value);case`append-text`:return this.updatePath(e,t.path,e=>{if(typeof e!=`string`)throw Error(`Expected string at path [${t.path.join(`, `)}]`);return e+t.value});default:throw Error(`Invalid operation type: ${n}`)}}updatePath(e,t,n){if(t.length===0)return n(e);if(e??={},typeof e!=`object`)throw Error(`Invalid path: [${t.join(`, `)}]`);let[r,...i]=t;if(ow(r),Array.isArray(e)){let a=Number(r);if(!Number.isInteger(a)||String(a)!==String(r))throw Error(`Expected array index at [${t.join(`, `)}]`);if(a<0)throw Error(`Insert array index out of bounds`);if(a>e.length){if(this._strict)throw Error(`Insert array index out of bounds`);this._warnedClamp||(this._warnedClamp=!0,console.warn(`Clamped out-of-bounds gorp array index ${a} to ${e.length}`)),a=Math.min(a,e.length)}let o=[...e];return o[a]=this.updatePath(Object.hasOwn(o,a)?o[a]:void 0,i,n),o}let a={...e};return a[r]=this.updatePath(Object.hasOwn(a,r)?a[r]:void 0,i,n),a}},cw=class{_streamStartTime;_firstTokenTime;_totalChunks=0;_toolCallIds=new Set;constructor(){this._streamStartTime=Date.now()}recordChunk(){this._totalChunks++}recordFirstToken(){this._firstTokenTime===void 0&&(this._firstTokenTime=Date.now())}recordToolCallStart(e){this._toolCallIds.add(e)}getTiming(e,t){let n=Date.now()-this._streamStartTime,r=e&&e>0?e:t?Math.ceil(t.length/4):void 0,i=r&&n>0?r/n*1e3:void 0;return{streamStartTime:this._streamStartTime,...this._firstTokenTime===void 0?void 0:{firstTokenTime:this._firstTokenTime-this._streamStartTime},totalStreamTime:n,...r===void 0?void 0:{tokenCount:r},...i===void 0?void 0:{tokensPerSecond:i},totalChunks:this._totalChunks,toolCallCount:this._toolCallIds.size}}},lw=(e,t)=>({...e,parts:t,get content(){return this.parts}}),uw=(e,t)=>lw(e,[...e.parts,t]),dw=({unstable_state:e=null}={})=>({role:`assistant`,status:{type:`running`},parts:[],get content(){return this.parts},metadata:{unstable_state:e,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}),fw=16,pw=(e,t,n,r)=>{let i=t.path.length===1?e.parts[t.path[0]]:void 0;if(i===void 0)return n(`no-part:${t.type}`,`Dropped ${t.type} chunk: no part at path [${t.path.join(`, `)}]`),e;let a=t.path[0],o=r(i);return o===i?e:lw(e,[...e.parts.slice(0,a),o,...e.parts.slice(a+1)])},mw=(e,t,n)=>{let r=t.part;if(r.type===`text`||r.type===`reasoning`)return uw(e,{type:r.type,text:``,status:{type:`running`},...r.type===`reasoning`&&r.unstable_summary!==void 0?{unstable_summary:r.unstable_summary}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`tool-call`)return uw(e,{type:`tool-call`,state:`partial-call`,status:{type:`running`,isArgsComplete:!1},toolCallId:r.toolCallId,toolName:r.toolName,argsText:``,args:{},timing:{startedAt:Date.now()},...r.parentId&&{parentId:r.parentId}});if(r.type===`source`)return uw(e,{type:`source`,sourceType:r.sourceType,id:r.id,url:r.url,...r.title?{title:r.title}:void 0,...r.parentId&&{parentId:r.parentId}});if(r.type===`file`)return uw(e,{type:`file`,mimeType:r.mimeType,data:r.data,...r.parentId&&{parentId:r.parentId}});if(r.type===`data`)return uw(e,{type:`data`,name:r.name,data:r.data,...r.parentId&&{parentId:r.parentId}});{let t=String(r.type);return n(`unsupported-part-start:${t}`,`Unsupported part-start type ${t}: inserting an empty reasoning part to preserve part indices`),uw(e,{type:`reasoning`,text:``,status:{type:`running`}})}},hw=(e,t,n)=>pw(e,t,n,e=>e.type===`tool-call`?e.state===`partial-call`?{...e,state:`call`}:{...e}:(n(`wrong-part:tool-call-args-text-finish`,`Dropped tool-call-args-text-finish chunk: part is not a tool-call`),e)),gw=(e,t,n)=>pw(e,t,n,e=>({...e,status:{type:`complete`,reason:`unknown`}})),_w=(e,t,n)=>pw(e,t,n,e=>{if(e.type===`text`||e.type===`reasoning`)return{...e,text:e.text+t.textDelta};if(e.type===`tool-call`){let n=e.argsText+t.textDelta,r=yC(n)??e.args;return{...e,argsText:n,args:r}}return n(`wrong-part:text-delta`,`Dropped text-delta chunk: part is neither text nor tool-call`),e}),vw=(e,t,n)=>pw(e,t,n,e=>e.type===`tool-call`?{...e,state:`result`,...e.timing===void 0?{}:{timing:{...e.timing,completedAt:e.timing.completedAt??Date.now()}},...t.artifact===void 0?{}:{artifact:t.artifact},result:t.result,isError:t.isError??!1,...t.modelContent===void 0?{}:{modelContent:t.modelContent},...t.messages===void 0?{}:{messages:t.messages},status:{type:`complete`,reason:`stop`}}:(n(`wrong-part:result`,`Dropped result chunk: part is not a tool-call`),e)),yw=(e,t)=>{if(e.status?.type===`incomplete`&&e.status?.reason===`error`)return e;let n=bw(t);return{...e,status:n}},bw=e=>e.finishReason===`tool-calls`?{type:`requires-action`,reason:`tool-calls`}:e.finishReason===`stop`||e.finishReason===`unknown`?{type:`complete`,reason:e.finishReason}:{type:`incomplete`,reason:e.finishReason},xw=(e,t)=>({...e,metadata:{...e.metadata,unstable_annotations:[...e.metadata.unstable_annotations,...t.annotations]}}),Sw=(e,t)=>({...e,metadata:{...e.metadata,unstable_data:[...e.metadata.unstable_data,...t.data]}}),Cw=(e,t)=>({...e,metadata:{...e.metadata,steps:[...e.metadata.steps,{state:`started`,messageId:t.messageId}]}}),ww=(e,t)=>{let n=e.metadata.steps.slice(),r=n.length-1;return n.length>0&&n[r]?.state===`started`?n[r]={...n[r],state:`finished`,finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}:n.push({state:`finished`,messageId:hC(),finishReason:t.finishReason,usage:t.usage,isContinued:t.isContinued}),{...e,metadata:{...e.metadata,steps:n}}},Tw=(e,t)=>{let n=t.severity===`critical`||t.severity===`warning`||t.severity===`info`?t.severity:void 0;return{...e,status:{type:`incomplete`,reason:`error`,error:{code:t.code??`unknown`,message:t.error??`unknown error`,...n!==void 0&&{severity:n}}}}},Ew=(e,t,n)=>(n.append(t.operations),{...e,metadata:{...e.metadata,unstable_state:n.state}}),Dw=(e,t)=>{let n=0;for(let e of t.metadata.steps)e.state===`finished`&&e.usage&&(n+=e.usage.outputTokens);let r=``;for(let e of t.parts)(e.type===`text`||e.type===`reasoning`)&&(r+=e.text);return e.getTiming(n>0?n:void 0,r||void 0)},Ow=e=>{let t=!1;return()=>{t||(t=!0,queueMicrotask(()=>{t=!1,e()}))}},kw=class extends TransformStream{constructor({initialMessage:e,throttle:t,onError:n,strict:r=!0}={}){let i=e??dw(),a,o=new cw,s=new Set,c=(e,t)=>{s.has(e)||s.size>=fw||(s.add(e),console.warn(t))},l,u=t?Ow(()=>{l?.enqueue(i)}):()=>{l?.enqueue(i)};super({start(e){l=e},transform(e){o.recordChunk();let t=e.type;switch(t){case`part-start`:i=mw(i,e,c),e.part.type===`tool-call`&&o.recordToolCallStart(e.part.toolCallId);break;case`tool-call-args-text-finish`:i=hw(i,e,c);break;case`part-finish`:i=gw(i,e,c);break;case`text-delta`:{let t=_w(i,e,c);t!==i&&o.recordFirstToken(),i=t;break}case`result`:i=vw(i,e,c);break;case`message-finish`:i=yw(i,e);break;case`annotations`:i=xw(i,e);break;case`data`:i=Sw(i,e);break;case`step-start`:i=Cw(i,e);break;case`step-finish`:i=ww(i,e);break;case`error`:i=Tw(i,e),n?.(e.error);break;case`update-state`:a??=new sw(i.metadata.unstable_state,{strict:r}),i=Ew(i,e,a);break;default:throw Error(`Unsupported chunk type: ${t}`)}i.status.type!==`running`&&(i={...i,metadata:{...i.metadata,timing:Dw(o,i)}}),u()},flush(e){if(i.status?.type===`running`){let t=i.parts?.some(e=>e.type===`tool-call`&&(e.state===`call`||e.state===`partial-call`)&&e.result===void 0)??!1;i=yw(i,{type:`message-finish`,path:[],finishReason:t?`tool-calls`:`unknown`,usage:{inputTokens:0,outputTokens:0}}),i={...i,metadata:{...i.metadata,timing:Dw(o,i)}},e.enqueue(i)}}})}},Aw=class extends fC{constructor(){super(e=>{let t=new lte({transform(e,t){t.appendText(e)}});return e.pipeThrough(new TextDecoderStream).pipeThrough(t)})}},jw=class e{readable;constructor(e){this.readable=e}static fromAssistantStream(t){return new e(t.pipeThrough(new kw))}async unstable_result(){let e;for await(let t of this)e=t;return e||{role:`assistant`,status:{type:`complete`,reason:`unknown`},parts:[],content:[],metadata:{unstable_state:null,unstable_data:[],unstable_annotations:[],steps:[],custom:{}}}}[Symbol.asyncIterator](){return SC(this.readable)[Symbol.asyncIterator]()}tee(){let[t,n]=this.readable.tee();return[new e(t),new e(n)]}};function Mw(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 Nw(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}var Pw=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(xC(e,this.fieldPath)===`complete`){let t=Nw(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=Nw(e,this.fieldPath);this.resolve(t)}catch(e){this.reject(e)}finally{this.dispose()}}dispose(){this.disposed=!0}},Fw=class{controller;disposed=!1;fieldPath;constructor(e,t){this.controller=e,this.fieldPath=t}update(e){if(!this.disposed)try{let t=Nw(e,this.fieldPath);t!==void 0&&this.controller.enqueue(t),xC(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}},Iw=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=Nw(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)}xC(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}},Lw=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=Nw(e,this.fieldPath);if(!Array.isArray(t))return;for(let n=0;n<t.length;n++)this.processedIndexes.has(n)||xC(e,[...this.fieldPath,n])===`complete`&&(this.controller.enqueue(t[n]),this.processedIndexes.add(n));xC(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}},Rw=class{argTextDeltas;handles=new Set;args=yC(``);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=yC(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 Pw(t,n,e);if(this.args&&xC(this.args,e)===`complete`){let n=Nw(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 SC(new ReadableStream({start:e=>{n=new Fw(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 SC(new ReadableStream({start:e=>{n=new Iw(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 SC(new ReadableStream({start:e=>{n=new Lw(e,t),this.finished||this.handles.add(n),n.update(this.args),this.finished&&n.end()},cancel:()=>{n&&(n.dispose(),this.handles.delete(n))}}))}},zw=class{promise;constructor(e){this.promise=e}get(){return this.promise}},Bw=class{args;response;writable;resolve;argsText=``;constructor(){let e=new TransformStream;this.writable=e.writable,this.args=new Rw(e.readable);let{promise:t,resolve:n}=eC();this.resolve=n,this.response=new zw(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}},Vw=Symbol.for(`assistant-stream.tool-execution-id`),Hw=(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)}},Uw=e=>e.join(`,`),Ww=(e,t)=>{let n={...e};return Object.defineProperty(n,Vw,{value:t,enumerable:!0}),n},Gw=class extends fC{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(Uw(e.path));switch((e.type!==`part-finish`||e.meta.type!==`tool-call`)&&s.enqueue(c?Ww(e,c):e),e.type){case`part-start`:{let n=o;if(o+=1,e.part.type===`tool-call`){let i=new Bw,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(Uw(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(Uw(e.path)),n=t?r.get(t):void 0;if(!n)throw Error(`No controller found for tool call`);n.setResponse(new uC({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(Uw(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=Mw(()=>{let e;try{e=_C.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,Hw(`onExecutionStart`,t.onExecutionStart,o,c,l)),n},n=>{if(d&&Hw(`onExecutionEnd`,t.onExecutionEnd,o,c,l),n===void 0)return;let r=new uC({artifact:n.artifact,result:n.result,isError:n.isError,messages:n.messages,modelContent:n.modelContent});u.setResponse(r),nC(s,Ww({type:`result`,path:e.path,...r},l))},n=>{d&&Hw(`onExecutionEnd`,t.onExecutionEnd,o,c,l);let r=new uC({result:String(n),isError:!0});u.setResponse(r),nC(s,Ww({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(Uw(e.path)),o=t?n.get(t):void 0,c=()=>{t&&(n.delete(t),r.delete(t),i.delete(t),a.delete(Uw(e.path)))};o?o.then(()=>{c(),nC(s,e)}):(c(),s.enqueue(e))}}},async flush(){await Promise.all(n.values())}});return e.pipeThrough(new pC).pipeThrough(s)})}},Kw=Symbol.for(`assistant-stream.tool-execution-id`),qw=e=>typeof e==`object`&&!!e&&`~standard`in e&&e[`~standard`].version===1,Jw=e=>typeof e?.then==`function`;function Yw(e,t,n,r){let i=e?.[n.toolName];return i?.execute?(async e=>{if(t.aborted)return new uC({result:`Tool execution was cancelled.`,isError:!0});let a=e;if(qw(i.parameters)){let e=i.parameters[`~standard`].validate(n.args),t=Jw(e)?await e:e;t.issues&&(a=i.experimental_onSchemaValidationError??(()=>{throw Error(`Function parameter validation failed. ${JSON.stringify(t.issues)}`)}))}let o,s=new Promise(e=>{o=()=>{queueMicrotask(()=>{queueMicrotask(()=>{e(new uC({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),[Kw]:n.executionId},o=await a(n.args,e),s=uC.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 uC({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 Xw(e,t,n,r,i){let a={toolCallId:r.toolCallId,abortSignal:t,human:e=>i(r.toolCallId,e,r.executionId),[Kw]:r.executionId};e?.[r.toolName]?.streamCall?.(n,a)}function Zw(e,t,n,r){let i=typeof e==`function`?e:()=>e,a=typeof t==`function`?t:()=>t,o=r,s=n;return new Gw({execute:e=>Yw(i(),a(),e,s),streamCall:({reader:e,...t})=>Xw(i(),a(),e,t,s),onExecutionStart:o?.onExecutionStart,onExecutionEnd:o?.onExecutionEnd})}function Qw(e){return typeof e==`object`&&!!e&&`~standard`in e&&typeof e[`~standard`]==`object`}function $w(e){return typeof e==`object`&&!!e&&`toJSONSchema`in e&&typeof e.toJSONSchema==`function`}function eT(e){return typeof e==`object`&&!!e&&`toJSON`in e&&typeof e.toJSON==`function`}function jte(e){if(Qw(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($w(e))return e.toJSONSchema();if(eT(e))return e.toJSON();if(Qw(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 Mte(e,t){return!t.disabled&&t.type!==`backend`&&(t.type!==`frontend`||t.execute!==void 0)}function Nte(e){return e.parameters!==void 0&&!e.unstable_backendDefault?.parameters}function Pte(e,t={}){if(!e)return{};let n=t.filter??Mte;return Object.fromEntries(Object.entries(e).filter(([e,t])=>n(e,t)).filter(e=>Nte(e[1])).sort(([e],[t])=>e<t?-1:+(e>t)).map(([e,t])=>[e,{...t.description&&{description:t.description},parameters:jte(t.parameters),...t.providerOptions&&{providerOptions:t.providerOptions}}]))}var tT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({attachment:Ox({source:`message`,query:{type:`index`,index:n},get:e=>e.message.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},nT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({attachment:Ox({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.attachment({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Fte=e=>{let t=z(6),{runtime:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({threadListItem:AS({runtime:n})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},rT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({message:Ox({source:`thread`,query:{type:`index`,index:n},get:e=>e.thread.message({index:n})}),composer:Ox({source:`message`,query:{},get:e=>e.thread.message({index:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},iT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({part:Ox({source:`message`,query:{type:`index`,index:n},get:e=>e.message.part({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},Ite=$v(e=>{let t=z(7),{text:n,isRunning:r}=e,i;t[0]===r?i=t[1]:(i=r?{type:`running`}:{type:`complete`},t[0]=r,t[1]=i);let a;t[2]!==i||t[3]!==n?(a={type:`text`,text:n,status:i},t[2]=i,t[3]=n,t[4]=a):a=t[4];let o=a,s;return t[5]===o?s=t[6]:(s={getState:()=>o,addToolResult:oT,resumeToolCall:sT,respondToToolApproval:cT},t[5]=o,t[6]=s),s}),aT=e=>{let t=z(7),{text:n,isRunning:r,children:i}=e,a=r!==void 0&&r,o=xx(),s;t[0]!==a||t[1]!==n?(s=Qy({part:Ite({text:n,isRunning:a})}),t[0]=a,t[1]=n,t[2]=s):s=t[2];let c=s,l;return t[3]!==o||t[4]!==i||t[5]!==c?(l=(0,I.jsx)(BS,{extends:o,config:c,children:i}),t[3]=o,t[4]=i,t[5]=c,t[6]=l):l=t[6],l};function oT(){throw Error(`Not supported`)}function sT(){throw Error(`Not supported`)}function cT(){throw Error(`Not supported`)}var lT=Object.freeze({type:`complete`}),uT=Object.freeze({type:`running`}),dT=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`})}),fT=e=>{let t=e.status;if(!t||typeof t!=`object`)return;let{type:n}=t;if(n===`running`)return uT;if(n===`complete`)return lT;if(n!==`incomplete`)return;let{reason:r}=t;return dT[r===`cancelled`||r===`length`||r===`content-filter`||r===`other`||r===`error`?r:`other`]},pT=(e,t,n)=>{if(e.role!==`assistant`)return lT;if(n.type===`tool-call`)return n.result===void 0?e.status:lT;if(e.status.type===`running`){let e=fT(n);if(e)return e}let r=t===Math.max(0,e.content.length-1);return e.status.type===`requires-action`?lT:r?e.status:lT},mT=(e,t)=>{if(t){for(let n of t)if(e[n]?.status.type===`running`)return uT;let n=t.at(-1);return n===void 0?lT:e[n]?.status??lT}for(let t of e)if(t?.status.type===`running`)return uT;return e.at(-1)?.status??lT},hT=$v(e=>{let t=z(11),{parts:n,getMessagePart:r}=e,[i,a]=Pv(!0),o;t[0]===n?o=t[1]:(o=mT(n),t[0]=n,t[1]=o);let s=o,c;t[2]!==i||t[3]!==n||t[4]!==s?(c={parts:n,collapsed:i,status:s},t[2]=i,t[3]=n,t[4]=s,t[5]=c):c=t[5];let l=c,u;t[6]===l?u=t[7]:(u=()=>l,t[6]=l,t[7]=u);let d;return t[8]!==r||t[9]!==u?(d={getState:u,setCollapsed:a,part:r},t[8]=r,t[9]=u,t[10]=d):d=t[10],d}),gT=e=>{let t=z(4),{startIndex:n,endIndex:r,children:i}=e,a=H(_T).slice(n,r+1),o=xx(),s=Qy({chainOfThought:hT({parts:a,getMessagePart:e=>{let{index:t}=e;if(t<0||t>=a.length)throw Error(`ChainOfThought part index ${t} is out of bounds (0..${a.length-1})`);return o.message.part({index:n+t})}})}),c;return t[0]!==i||t[1]!==s||t[2]!==o?(c=(0,I.jsx)(BS,{extends:o,config:s,children:i}),t[0]=i,t[1]=s,t[2]=o,t[3]=c):c=t[3],c};function _T(e){return e.message.parts}var vT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({suggestion:Ox({source:`suggestions`,query:{index:n},get:e=>e.suggestions.suggestion({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},yT=e=>{let t=z(6),{index:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({queueItem:Ox({source:`composer`,query:{type:`index`,index:n},get:e=>e.composer.queueItem({index:n})})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},bT=[`critical`,`warning`,`info`],xT=[`inline`,`toast`,`silent`,`dev-only`],ST=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!(typeof t.code!=`string`||typeof t.message!=`string`||`severity`in t&&t.severity!==void 0&&(typeof t.severity!=`string`||!bT.includes(t.severity))||`display`in t&&t.display!==void 0&&(typeof t.display!=`string`||!xT.includes(t.display)))},CT=Symbol.for(`assistant-ui.message-not-sent`),wT=class extends Error{[CT]=!0;constructor(e=`The message was not sent.`){super(e),this.name=`MessageNotSentError`}},TT=e=>typeof e==`object`&&!!e&&CT in e,ET=e=>{if(ST(e))return e;if(e instanceof Error)return{code:`unknown`,message:e.message};if(typeof e==`string`)return{code:`unknown`,message:e};try{return{code:`unknown`,message:`[${typeof e}] ${String(e)}`}}catch{return{code:`unknown`,message:`[${typeof e}]`}}},DT=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)}},OT=class extends DT{_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)}},kT=class extends OT{get source(){return`thread-composer`}},AT=class extends OT{get source(){return`edit-composer`}},jT=class extends DT{get source(){return`message`}remove(){throw Error(`Message attachments cannot be removed`)}},MT=Object.freeze([]),NT=Object.freeze({}),PT=e=>Object.freeze({type:`thread`,isEditing:e?.isEditing??!1,canCancel:e?.canCancel??!1,canSend:e?.canSend??!1,isEmpty:e?.isEmpty??!0,attachments:e?.attachments??MT,text:e?.text??``,role:e?.role??`user`,runConfig:e?.runConfig??NT,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??MT,value:e?.text??``}),FT=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??MT,runConfig:e?.runConfig??NT,attachmentAccept:e?.attachmentAccept??``,dictation:e?.dictation,quote:e?.quote,queue:e?.queue??MT,parentId:e?.parentId??null,sourceId:e?.sourceId??null,value:e?.text??``}),IT=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 Kx({event:e,binding:this._core}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},LT=class extends IT{get path(){return this._core.path}get type(){return`thread`}_getState;constructor(e){let t=new Wx({path:e.path,getState:()=>PT(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 kT(new Ux({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`}:Lx},subscribe:e=>this._core.subscribe(e)}),this._core)}},RT=class extends IT{get path(){return this._core.path}get type(){return`edit`}_getState;_beginEdit;constructor(e,t){let n=new Wx({path:e.path,getState:()=>FT(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 AT(new Ux({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`}:Lx},subscribe:e=>this._core.subscribe(e)}),this._core)}},zT=e=>e.content.filter(e=>e.type===`text`).map(e=>e.text).join(`
|
|
26
|
-
|
|
27
|
-
`),BT=`ui://`,VT=e=>!!e?.startsWith(BT),HT=e=>e.display===`text`||e.allowFreeform===!0,UT={"allow-once":!0,"allow-always":!0,"reject-once":!1,"reject-always":!1},WT=(e,t)=>{let n=t.text;if(n!==void 0&&!HT(e))throw Error(`Tool approval "${e.id}" does not accept a free-form answer; the request must declare display "text" or allowFreeform`);let r,i;if(`optionId`in t){let n=e.options?.find(e=>e.id===t.optionId);if(!n)throw Error(`Tool approval has no option with id "${t.optionId}"`);if(`approved`in t)r=t.approved;else{if(!Object.hasOwn(UT,n.kind))throw Error(`Tool approval option "${n.id}" has a custom kind "${n.kind}"; respond with an explicit approved value instead`);r=UT[n.kind]}i=n.id}else if(`approved`in t)r=t.approved;else{if(e.display!==`text`&&e.display!==`select`)throw Error(`Tool approval "${e.id}" is a decision, not a question; respond with an explicit approved value, optionally alongside the answer`);r=!0}return{approvalId:e.id,approved:r,...i!==void 0&&{optionId:i},...n!==void 0&&{text:n},...t.reason!=null&&{reason:t.reason}}},GT=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=uC.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`);return this.threadApi.getState().respondToToolApproval(WT(t.approval,e))}subscribe(e){return this.contentBinding.subscribe(e)}},KT=(e,t)=>{let n=e.content[t];if(!n)return Lx;let r=pT(e,t,n);return Object.freeze({...n,[TC]:n[TC],status:r})},qT=class{get path(){return this._core.path}_core;_threadBinding;constructor(e,t){this._core=e,this._threadBinding=t,this.composer=new RT(new Gx({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 zT(this.getState())}subscribe(e){return this._core.subscribe(e)}getMessagePartByIndex(e){if(e<0)throw Error(`Message part index must be >= 0`);return new GT(new Ux({path:{...this.path,ref:`${this.path.ref}.content[${e}]`,messagePartSelector:{type:`index`,index:e}},getState:()=>KT(this.getState(),e),subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getMessagePartByToolCallId(e){return new GT(new Ux({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?Lx:KT(t,n)},subscribe:e=>this._core.subscribe(e)}),this._core,this._threadBinding)}getAttachmentByIndex(e){return new jT(new Ux({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`}:Lx},subscribe:e=>this._core.subscribe(e)}))}},JT=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{},...e.stream?{stream:e.stream}:{}}),YT=e=>({parentId:e.parentId??null,sourceId:e.sourceId??null,runConfig:e.runConfig??{}}),XT=(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},ZT=e=>{if(e.isRunning!==void 0)return e.isRunning;let t=e.messages.at(-1);return t?.role===`assistant`&&t.status.type===`running`},QT=(e,t)=>Object.freeze({threadId:t.id,metadata:t,capabilities:e.capabilities,isDisabled:e.isDisabled,isLoading:e.isLoading,isRunning:ZT(e),messages:e.messages,state:e.state,suggestions:e.suggestions,extras:e.extras,speech:e.speech,voice:e.voice}),$T=class{get path(){return this._threadBinding.path}get __internal_threadBinding(){return this._threadBinding}_threadBinding;_stateBinding;constructor(e,t){let n=new Ux({path:e.path,getState:()=>QT(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 LT(new Gx({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(XT(this._threadBinding.getState().messages,e));Promise.resolve(t).catch(e=>{if(!TT(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(YT(e))}resumeRun(e){return this._threadBinding.getState().resumeRun(JT(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 qT(new Ux({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 Lx;let o=this._threadBinding.getState().getBranches(e.id);return{...e,[TC]:e[TC],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 Kx({event:e,binding:this._threadBinding}),this._eventSubscriptionSubjects.set(e,n)),n.subscribe(t)}},eE=(e,t)=>({attachments:[],attachmentAccept:`*`,async addAttachment(){throw e},async removeAttachment(){throw e},isEditing:t,canCancel:!1,canSend:!1,isEmpty:!0,text:``,setText(){throw e},role:`user`,setRole(){throw e},runConfig:{},setRunConfig(){throw e},async reset(){},async clearAttachments(){},send(){throw e},cancel(){},queue:[],moveQueueItem(){},removeQueueItem(){},dictation:void 0,startDictation(){throw e},stopDictation(){},quote:void 0,setQuote(){throw e},subscribe(){return()=>{}},unstable_on(){return()=>{}}}),tE=class extends Bx{switchToBranch(){throw this.error}append(){throw this.error}deleteMessage(){throw this.error}startRun(){throw this.error}resumeRun(){throw this.error}cancelRun(){throw this.error}unstable_notifySessionReset(){throw this.error}addToolResult(){throw this.error}resumeToolCall(){throw this.error}respondToToolApproval(){throw this.error}speak(){throw this.error}stopSpeaking(){throw this.error}connectVoice(){throw this.error}disconnectVoice(){throw this.error}muteVoice(){throw this.error}unmuteVoice(){throw this.error}submitFeedback(){throw this.error}exportExternalState(){throw this.error}importExternalState(){throw this.error}beginEdit(){throw this.error}import(){throw this.error}reset(){throw this.error}getModelContext(){return{}}getEditComposer(){}getVoiceVolume=()=>0;subscribeVoiceVolume=()=>()=>{};speech=void 0;voice=void 0;capabilities={switchToBranch:!1,switchBranchDuringRun:!1,edit:!1,delete:!1,reload:!1,refetchThread:!1,cancel:!1,unstable_copy:!1,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};isDisabled=!1;isSendDisabled=!1;state=null;suggestions=[];extras=void 0;unstable_on(){return()=>{}}},nE=Error(`This is a readonly thread. You cannot perform mutations on readonly threads.`),rE=class extends tE{get error(){return nE}_messages=[];get messages(){return this._messages}setMessages(e){this._messages!==e&&(this._messages=e,this._notifySubscribers())}getMessageById(e){let t=this._messages.findIndex(t=>t.id===e);if(t!==-1)return{parentId:this._messages[t-1]?.id??null,message:this._messages[t],index:t}}getBranches(e){return this._messages.findIndex(t=>t.id===e)===-1?[]:[e]}export(){return{messages:this._messages.map((e,t)=>({message:e,parentId:this._messages[t-1]?.id??null}))}}composer=eE(nE,!1);isLoading=!1;cancelRun(){}stopSpeaking(){}disconnectVoice(){}},iE=Object.freeze({ref:`readonly-thread`,threadSelector:{type:`main`}}),aE=Object.freeze({id:`readonly`,remoteId:void 0,externalId:void 0,isMain:!0,isRunning:!1,status:`regular`,title:void 0}),oE=Object.freeze({path:iE,getState:()=>aE,subscribe:()=>()=>{}}),sE=e=>{let t=z(14),{messages:n,children:r}=e,i;t[0]===n?i=t[1]:(i=()=>{let e=new rE;return e.setMessages(n),e},t[0]=n,t[1]=i);let[a]=Pv(i),o,s;t[2]!==a||t[3]!==n?(o=()=>{a.setMessages(n)},s=[a,n],t[2]=a,t[3]=n,t[4]=o,t[5]=s):(o=t[4],s=t[5]),V(o,s);let c;t[6]===a?c=t[7]:(c=new $T({path:iE,getState:()=>a,subscribe:e=>a.subscribe(e),outerSubscribe:e=>a.subscribe(e)},oE),t[6]=a,t[7]=c);let l=c,u=xx(),d;t[8]===l?d=t[9]:(d=Qy({thread:OS({runtime:l}),composer:Ox({source:`thread`,query:{},get:cE})}),t[8]=l,t[9]=d);let f=d,p;return t[10]!==u||t[11]!==r||t[12]!==f?(p=(0,I.jsx)(BS,{extends:u,config:f,children:r}),t[10]=u,t[11]=r,t[12]=f,t[13]=p):p=t[13],p};function cE(e){return e.thread.composer()}var lE=e=>{let t=z(6),{adapters:n,children:r}=e,i=Qv(CC),a;t[0]!==n||t[1]!==i?(a={...i,...n},t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a,s;return t[3]!==r||t[4]!==o?(s=(0,I.jsx)(CC.Provider,{value:o,children:r}),t[3]=r,t[4]=o,t[5]=s):s=t[5],s},uE=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||Zy([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}},dE=Promise.resolve(),fE=()=>{},pE=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}),mE=(e,t)=>{if(t===void 0)return Lx;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}:Lx},hE=class{_getState;_stateBinding;_core;_runtimeFactory;constructor(e,t=$T){this._core=e,this._runtimeFactory=t;let n=new Wx({path:{},getState:()=>pE(e),subscribe:t=>e.subscribe(t)});this._getState=n.getState.bind(n),this._stateBinding=n,this._mainThreadListItemRuntime=new uE(new Ux({path:{ref:`threadItems[main]`,threadSelector:{type:`main`}},getState:()=>mE(this._core,this._core.mainThreadId),subscribe:e=>this._core.subscribe(e)}),this._core),this.main=new t(new Gx({path:{ref:`threads.main`,threadSelector:{type:`main`}},getState:()=>e.getMainThreadRuntimeCore(),subscribe:t=>e.subscribe(t)}),this._mainThreadListItemRuntime),this.__internal_bindMethods()}__internal_bindMethods(){this.switchToThread=this.switchToThread.bind(this),this.switchToNewThread=this.switchToNewThread.bind(this),this.unstable_subscribeThreadEvents=this.unstable_subscribeThreadEvents.bind(this),this.getLoadThreadsPromise=this.getLoadThreadsPromise.bind(this),this.reload=this.reload.bind(this),this.reloadMainThread=this.reloadMainThread.bind(this),this.loadMore=this.loadMore.bind(this),this.getState=this.getState.bind(this),this.subscribe=this.subscribe.bind(this),this.getById=this.getById.bind(this),this.getItemById=this.getItemById.bind(this),this.getItemByIndex=this.getItemByIndex.bind(this),this.getArchivedItemByIndex=this.getArchivedItemByIndex.bind(this)}switchToThread(e,t){return this._core.switchToThread(e,t)}switchToNewThread(){return this._core.switchToNewThread()}unstable_subscribeThreadEvents(e){return this._core.unstable_subscribeThreadEvents?.(e)??fE}getLoadThreadsPromise(){return this._core.getLoadThreadsPromise()}reload(){return this._core.reload?.()??dE}reloadMainThread(){return this._core.reloadMainThread?.()??dE}loadMore(){return this._core.loadMore?.()??dE}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 Gx({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 uE(new Ux({path:{ref:`threadItems[${e}]`,threadSelector:{type:`index`,index:e}},getState:()=>mE(this._core,this._core.threadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getArchivedItemByIndex(e){return new uE(new Ux({path:{ref:`archivedThreadItems[${e}]`,threadSelector:{type:`archiveIndex`,index:e}},getState:()=>mE(this._core,this._core.archivedThreadIds[e]),subscribe:e=>this._core.subscribe(e)}),this._core)}getItemById(e){return new uE(new Ux({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>mE(this._core,e),subscribe:e=>this._core.subscribe(e)}),this._core)}},gE=class{threads;_thread;_core;constructor(e){this._core=e,this.threads=new hE(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)}},_E=new WeakMap,vE=e=>_E.get(e)??0,yE=(e,t)=>vE(e)===t,bE=e=>{_E.set(e,vE(e)+1)},xE=class{_contextProvider=new qx;registerModelContextProvider(e){return this._contextProvider.registerModelContextProvider(e)}getModelContextProvider(){return this._contextProvider}},SE=Object.freeze([]),CE=`DEFAULT_THREAD_ID`,wE=Object.freeze([CE]),TE=Object.freeze({id:CE,remoteId:void 0,externalId:void 0,status:`regular`}),EE=Promise.resolve(),DE=Object.freeze({[CE]:TE}),OE=class extends Bx{_mainThreadId=CE;_threads=wE;_archivedThreads=SE;_threadData=DE;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 EE}_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??CE,i=e.threads??SE,a=e.archivedThreads??SE,o=n.threadId??CE,s=n.threads??SE,c=n.archivedThreads??SE;(t||o!==r||s!==i||c!==a)&&((s!==i||c!==a||o!==r)&&(this._threadData={...DE,...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)??SE),c!==a&&(this._archivedThreads=this.adapter.archivedThreads?.map(e=>e.id)??SE),(t||o!==r)&&(t||bE(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.`)}},kE={fromArray:e=>{let t=e.map(e=>IC(e,jC(),HC(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:IC(e,e.id,HC(e.content,!1,!1))}})})},AE=e=>{let t=e;for(;t.next;)t=t.next;return`current`in t?t:null},jE=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}},ME=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],(AE(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 jE(()=>{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=AE(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=AE(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)}},NE=Object.freeze([]);function*PE(e){for(let t of e)if(t?.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e&&e.type===`tool-call`&&(yield{part:e,messageId:t.id},e.messages?.length&&(yield*PE(e.messages)))}var FE=e=>{let t=globalThis.Buffer;if(t)return t.from(e).toString(`base64`);let n=``,r=32768;for(let t=0;t<e.length;t+=r)n+=String.fromCharCode(...e.subarray(t,t+r));return btoa(n)},IE=async e=>{if(typeof FileReader>`u`){let t=await e.arrayBuffer();return`data:${e.type||`application/octet-stream`};base64,${FE(new Uint8Array(t))}`}return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=e=>n(e),r.readAsDataURL(e)})};function LE(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 RE(e){let t=jC();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 zE(e){let t=[];for(let n of e)n.type!==`text`&&t.push(RE(n));return t}var BE=e=>`content`in e&&!(`lastModified`in e),VE=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()}},HE=async(e,t)=>{if(Symbol.asyncIterator in e){for await(let n of e)if(!t(n))break}else t(await e)},UE=e=>e.status.type===`complete`,WE=class extends Bx{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 VE;_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=>!UE(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(UE(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){TT(e)&&t===this._sendGeneration&&this.restoreDraft(n)}cancel(){this.handleCancel()}get queue(){return NE}moveQueueItem(e,t){}removeQueueItem(e){}async addAttachment(e){if(BE(e)){let t=this.getAttachmentAdapter();if(t&&!LE({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??jC(),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(!LE({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 HE(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),!UE(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&&!UE(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&&Zy(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)}}},GE=e=>e.capabilities?.cancel?ZT(e):!1,KE=class extends WE{get canCancel(){return GE(this.runtime)}get canSend(){return!this.isEmpty&&!this.runtime.isSendDisabled&&!this._isSending}_queueCache;get queue(){let e=this.runtime.getSteerQueueItems?.()??NE,t=this.runtime.getQueueItems?.()??NE,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()}},qE=class extends WE{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(zT(r)),this.setRole(r.role);let i;r.role===`user`?(i=[...r.attachments??[],...zE(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()}},JE=class extends Bx{_isInitialized=!1;repository=new ME;_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 KE(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=$ee(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 qE(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&&Zy(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(zT(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,Zy(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:jC(),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:jC(),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,Zy(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(kE.fromArray(e??[]))}_eventSubscribers=new Map;unstable_on(e,t){let n=t;if(e===`modelContextUpdate`)return this._contextProvider.subscribe?.(()=>Zy([n],{},`Thread runtime "${e}"`))??(()=>{});let r=this._eventSubscribers.get(e);return r||(r=new Set,this._eventSubscribers.set(e,r)),r.add(n),e===`initialize`&&this._isInitialized&&queueMicrotask(()=>{r.has(n)&&Zy([n],{},`Thread runtime "${e}"`)}),()=>{this._eventSubscribers.get(e)?.delete(n)}}},YE=Symbol.for(`assistant-stream.tool-execution-id`),XE=e=>{try{return JSON.parse(e),!0}catch{return!1}},ZE=e=>{try{return JSON.parse(e)}catch{return}},QE=(e,t)=>{let n=ZE(e),r=ZE(t);return n===void 0||r===void 0?!1:YS(n,r)},$E=e=>e[YE],eD=class{_getTools;_callbacks;_isClientToolCall;_entries=new Map;_humanInput=new Map;_executing=new Set;_discardedToolCallIds=new Set;_settledResolvers=[];_statuses=new Map;_ac=new AbortController;_pendingRestore=!0;_lastSnapshot=null;_isRunning=!1;_controller;_pipelineDead=!1;_pipelineRestartUsed=!1;constructor(e,t,n){this._getTools=e,this._callbacks=t,this._isClientToolCall=n,this._initPipeline()}_initPipeline(){let[e,t]=gC();this._controller=t;let n=Zw(()=>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 pC).pipeTo(new WritableStream({write:e=>{try{if(e.type!==`result`)return;this._handleResultChunk(e)}catch(e){console.error(`[ToolInvocationTracker] result chunk handling failed`,e)}}})).catch(e=>{console.error(`[ToolInvocationTracker] stream pipeline failed; will attempt single restart on next setState`,e),this._pipelineDead=!0})}setState(e){try{if(this._pipelineDead){if(this._pipelineRestartUsed)return;this._pipelineRestartUsed=!0,this._pipelineDead=!1,this._demoteEntriesToRestored(),this._executing.clear(),this._ac=new AbortController,this._initPipeline()}if(this._lastSnapshot&&this._lastSnapshot.messages===e.messages&&this._lastSnapshot.isRunning===e.isRunning&&this._lastSnapshot.isLoading===e.isLoading)return;e.isLoading===!0&&(this._pendingRestore=!0);let t=this._isRunning;this._isRunning=e.isRunning;try{this._processMessages(e.messages)}catch(e){throw this._isRunning=t,e}this._lastSnapshot=e,this._pendingRestore=!1}catch(e){console.error(`[ToolInvocationTracker] setState failed; snapshot dropped`,e)}}reset(){try{this._pendingRestore=!0,this._entries.clear(),this._discardedToolCallIds.clear(),this._lastSnapshot=null,this.abort(),this._statuses.size>0&&(this._statuses=new Map,this._invokeOnStatusesChange())}catch(e){console.error(`[ToolInvocationTracker] reset failed`,e)}}abort(e){try{if(this._humanInput.forEach(({reject:e})=>{try{e(Error(`Tool execution aborted`))}catch{}}),this._humanInput.clear(),e?.discardPending)for(let[e,t]of this._entries)t.controller&&(t.argsComplete||t.hasResult||(this._discardedToolCallIds.add(e),t.skipExecute=!0));if(this._ac.abort(),this._ac=new AbortController,this._executing.size===0)return Promise.resolve();let t=new Set(this._executing);return new Promise(e=>{this._settledResolvers.push({executionIds:t,resolve:e})})}catch(e){return console.error(`[ToolInvocationTracker] abort failed`,e),Promise.resolve()}}resume(e,t){try{let n=this._humanInput.get(e);return n?(this._humanInput.delete(e),this._setStatus(e,{type:`executing`}),n.resolve(t),!0):!1}catch(e){return console.error(`[ToolInvocationTracker] resume failed`,e),!1}}getStatuses(){return this._statuses}_getWrappedTools(){let e=this._getTools();if(e)return Object.fromEntries(Object.entries(e).map(([e,t])=>{let n=t.execute,r=t.streamCall;return n===void 0&&r===void 0?[e,t]:[e,{...t,...n!==void 0&&{execute:(...[e,t])=>{let r=$E(t),i=this._captureExecution(t.toolCallId,r);return!i||i.skipExecute?new Promise(()=>{}):n(e,t)}},...r!==void 0&&{streamCall:(...[e,t])=>{let n=$E(t);if(this._captureExecution(t.toolCallId,n))return r(e,t)}}}]}))}_captureExecution(e,t){if(t===void 0)return;let n=this._entries.get(e);if(n?.controller)return n.executionId===void 0&&(n.executionId=t),n.executionId===t?n:void 0}_onHumanInput(e,t,n){return new Promise((r,i)=>{let a=this._entries.get(e);if(!a?.controller||a.executionId!==n){i(Error(`Tool execution aborted`));return}let o=this._humanInput.get(e);if(o)try{o.reject(Error(`Human input request was superseded by a new request`))}catch{}this._humanInput.set(e,{executionId:n,resolve:r,reject:i}),this._setStatus(e,{type:`interrupt`,payload:{type:`human`,payload:t}})})}_onExecutionStart(e,t){this._captureExecution(e,t)&&(this._entries.get(e).skipExecute||(this._executing.add(t),this._humanInput.get(e)?.executionId!==t&&this._setStatus(e,{type:`executing`})))}_onExecutionEnd(e,t){if(t===void 0||!this._executing.delete(t))return;this._entries.get(e)?.executionId===t&&this._deleteStatus(e);let n=[];this._settledResolvers.forEach(({executionIds:e,resolve:t})=>{if([...e].some(e=>this._executing.has(e))){n.push({executionIds:e,resolve:t});return}try{t()}catch{}}),this._settledResolvers.length=0,this._settledResolvers.push(...n)}_handleResultChunk(e){let t=e.meta.toolCallId,n=$E(e),r=this._entries.get(t);r&&r.executionId===n&&(r?.hasResult||r.skipExecute||this._invokeOnResult({type:`add-tool-result`,toolCallId:t,toolName:e.meta.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}_invokeOnResult(e){try{this._callbacks.onResult(e)}catch(e){console.error(`[ToolInvocationTracker] onResult callback threw; result dropped`,e)}}_invokeOnStatusesChange(){try{this._callbacks.onStatusesChange(this._statuses)}catch(e){console.error(`[ToolInvocationTracker] onStatusesChange callback threw; status change not propagated`,e)}}_setStatus(e,t){let n=new Map(this._statuses);n.set(e,t),this._statuses=n,this._invokeOnStatusesChange()}_deleteStatus(e){if(!this._statuses.has(e))return;let t=new Map(this._statuses);t.delete(e),this._statuses=t,this._invokeOnStatusesChange()}_warnProviderOwnedSkip(e,t){}_shouldCloseArgsStream({argsText:e,hasResult:t,clientOwned:n}){return t?!0:XE(e)?n||!this._isRunning:!1}_startActiveEntry(e,t,n,r){let i={toolName:t,controller:this._controller.addToolCallPart({toolName:t,toolCallId:e}),argsText:``,hasResult:!1,skipExecute:n,argsComplete:!1,clientOwned:r};return this._entries.set(e,i),i}_demoteEntriesToRestored(){for(let[e,t]of this._entries)if(t.controller){if(!t.argsComplete&&!t.hasResult){this._entries.delete(e);continue}this._entries.set(e,{toolName:t.toolName,argsText:t.argsText,hasResult:t.hasResult})}}_processArgsText(e,t){if(!e.controller)return;let n=t.result!==void 0;if(t.argsText!==e.argsText){let r=!0;if(e.argsComplete)QE(e.argsText,t.argsText)&&(e.argsText=t.argsText),r=!1;else if(!t.argsText.startsWith(e.argsText)){if(XE(e.argsText)&&XE(t.argsText)&&QE(e.argsText,t.argsText)){let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i,r=!1}else r=!1}if(r&&e.controller){let r=t.argsText.slice(e.argsText.length);e.controller.argsText.append(r);let i=this._shouldCloseArgsStream({argsText:t.argsText,hasResult:n,clientOwned:e.clientOwned});i&&e.controller.argsText.close(),e.argsText=t.argsText,e.argsComplete=i}}!e.argsComplete&&e.controller&&this._shouldCloseArgsStream({argsText:e.argsText,hasResult:n,clientOwned:e.clientOwned})&&(e.controller.argsText.close(),e.argsComplete=!0)}_processMessages(e){let t=this._pendingRestore;for(let{part:n}of PE(e)){let e=this._entries.get(n.toolCallId);if(t){e?.controller||this._entries.set(n.toolCallId,{toolName:n.toolName,argsText:n.argsText,hasResult:n.result!==void 0});continue}let r=e;if(n.result!==void 0&&this._discardedToolCallIds.delete(n.toolCallId),r&&!r.controller){if(n.argsText===r.argsText&&n.result!==void 0===r.hasResult)continue;this._entries.delete(n.toolCallId),r=void 0}if(!r){let e=this._isClientToolCall?.(n),t=n.result===void 0&&e===!1;t&&this._warnProviderOwnedSkip(n.toolName,n.toolCallId),r=this._startActiveEntry(n.toolCallId,n.toolName,n.result!==void 0||t||this._discardedToolCallIds.has(n.toolCallId),e===!0)}if(n.approval!==void 0&&(r.skipExecute=!0),this._processArgsText(r,n),n.result!==void 0&&!r.hasResult){let{controller:e}=r;if(!e)continue;r.hasResult=!0,r.argsComplete=!0,e.setResponse(new uC({result:n.result,artifact:n.artifact,isError:n.isError,...n.modelContent===void 0?{}:{modelContent:n.modelContent}})),e.close()}}}},tD=Object.freeze([]),nD=(e,t)=>{Promise.resolve(t).catch(t=>{console.error(`[ExternalStoreThreadRuntimeCore] ${e} callback rejected`,t)})},rD=(e,t)=>e&&t[t.length-1]?.role!==`assistant`,iD=class extends JE{_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 AC;_pendingDeleteEvictions=new Set;_optimistic=null;_store;_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}_transformedQueue;_toolInvocations=null;_toolStatuses=new Map;_effectiveIsRunning=!1;_inTrackerUpdate=!1;_pendingRunningRefresh=!1;_runTrackerUpdate(e){this._inTrackerUpdate=!0;try{e()}finally{this._inTrackerUpdate=!1}this._pendingRunningRefresh&&(this._pendingRunningRefresh=!1,this._refreshEffectiveIsRunning())}_refreshEffectiveIsRunning(){let e=this._getEffectiveIsRunning(this._store);this._effectiveIsRunning!==e&&(this._effectiveIsRunning=e,this._notifyEventSubscribers(e?`runStart`:`runEnd`,{}),this._notifySubscribers())}_hasExecutingTools(e){if(e.unstable_enableToolInvocations!==!0||this._toolInvocations===null)return!1;for(let e of this._toolStatuses.values())if(e.type===`executing`)return!0;return!1}_getEffectiveIsRunning(e){return(e.isRunning??!1)||this._hasExecutingTools(e)}beginEdit(e){if(!this._store.onEdit)throw Error(`Runtime does not support editing.`);super.beginEdit(e)}constructor(e,t){super(e),this.__internal_setAdapter(t)}__internal_setAdapter(e){this._store!==e&&this._updateStoreSnapshot(e)}_updateStoreSnapshot(e){let t=this._effectiveIsRunning;this.isDisabled=e.isDisabled??!1,this.isSendDisabled=e.isSendDisabled??!1;let n=this._store;this._store=e;let r=this._getEffectiveIsRunning(e),i=e.unstable_messageRepositoryInstance,a=i!==void 0&&i!==this.repository;a&&(this.repository=i,this._pendingDeleteEvictions.clear()),n?.queue!==e.queue&&(this._transformedQueue=void 0,e.queue?.__internal_setDispatchTransform?.(e=>{let t=this.messages.at(-1)?.id??null;return this.enrichAppendMetadata({...e,parentId:t},t)}),e.queue?.__internal_setDispatchTransform&&(this._transformedQueue=e.queue)),this.extras!==e.extras&&(this.extras=e.extras);let o=e.suggestions??tD;Qb(this.suggestions,o)||(this.suggestions=o);let s={switchToBranch:this._store.setMessages!==void 0,switchBranchDuringRun:!1,edit:this._store.onEdit!==void 0,delete:this._store.onDelete!==void 0||this._store.setMessages!==void 0,reload:this._store.onReload!==void 0,refetchThread:this._store.onRefetchThread!==void 0,cancel:this._store.onCancel!==void 0,speech:this._store.adapters?.speech!==void 0,dictation:this._store.adapters?.dictation!==void 0,voice:this._store.adapters?.voice!==void 0,unstable_copy:this._store.unstable_capabilities?.copy!==!1,attachments:!!this._store.adapters?.attachments,feedback:!!this._store.adapters?.feedback,queue:this._store.queue!==void 0};Qb(this._capabilities,s)||(this._capabilities=s);let c;if(e.messageRepository){if(n&&!a&&n.isRunning===e.isRunning&&n.messageRepository===e.messageRepository&&t===r){this._notifySubscribers();return}let i=e.messageRepository.messages,o=e.messageRepository.headId??i.at(-1)?.message.id??null;if(n&&!a&&n.messageRepository===e.messageRepository)this.repository.resetHead(o),c=this.repository.getMessages();else{let e=new Set(i.map(({message:e})=>e.id));for(let{message:e,parentId:t}of i)this.repository.addOrUpdateMessage(t,e);for(let{message:t}of this.repository.export().messages)e.has(t.id)||this.repository.deleteMessage(t.id);this._pendingDeleteEvictions.clear(),this.repository.resetHead(o),c=this.repository.getMessages()}}else if(e.messages){if(n){if(n.convertMessage!==e.convertMessage)this._converter=new AC;else if(!a&&n.isRunning===e.isRunning&&n.messages===e.messages&&t===r){this._notifySubscribers();return}}c=e.convertMessage?this._converter.convertMessages(e.messages,(t,n,i)=>{if(!e.convertMessage)return n;let a=i===(e.messages?.length??0)-1,o=`${kC}${i}`;if(t&&(t.role!==`assistant`||!BC(t.status)||t.status===HC(t.content,a,r))){if(t.id.startsWith(`__external_store_fallback_`)&&t.id!==o){let e={...t,id:o};return DC(e,n),e}return t}let s=e.convertMessage(n,i),c=IC(s,o,HC(s.content,a,r));return DC(c,n),c}):e.messages;let i=new Set,o=[];for(let e=c.length-1;e>=0;e--){let t=c[e];if(i.has(t.id)){console.warn(`ExternalStoreThreadRuntimeCore: duplicate message id "${t.id}" in the provided messages array; keeping the last occurrence.`);continue}i.add(t.id),o.push(t)}o.length!==c.length&&(c=o.reverse());for(let e=0;e<c.length;e++){let t=c[e],n=c[e-1];this.repository.addOrUpdateMessage(n?.id??null,t)}if(this._pendingDeleteEvictions.size>0){let e=new Set(c.map(e=>e.id));for(let t of this._pendingDeleteEvictions)if(this._pendingDeleteEvictions.delete(t),!e.has(t)){try{this.repository.getMessage(t)}catch{continue}this.repository.deleteMessage(t)}}}else throw Error(`ExternalStoreAdapter must provide either 'messages' or 'messageRepository'`);c.length>0&&this.ensureInitialized(),this._effectiveIsRunning=r,t!==r&&(r?this._notifyEventSubscribers(`runStart`,{}):this._notifyEventSubscribers(`runEnd`,{}));let l=null;if(rD(r,c)){let e=c.at(-1)?.id??null;this._optimistic?.parentId!==e&&(this._optimistic={id:jC(),parentId:e}),l=this._optimistic.id,this.repository.addOrUpdateMessage(e,IC({role:`assistant`,content:[],metadata:{isOptimistic:!0}},l,{type:`running`}))}l===null&&(this._optimistic=null),this.repository.resetHead(l??c.at(-1)?.id??null);let u=this.repository.getMessages();(!this._messages||!XC(this._messages,u))&&(this._messages=u),a&&this._runTrackerUpdate(()=>this._toolInvocations?.reset()),this._runTrackerUpdate(()=>this._driveToolInvocations()),this._notifySubscribers()}_driveToolInvocations(){if(!this._store.unstable_enableToolInvocations){this._toolInvocations&&(this._toolInvocations.reset(),this._toolInvocations=null,this._toolStatuses=new Map,this._store.setToolStatuses?.({}));return}this._toolInvocations||=new eD(()=>this.getModelContext().tools,{onResult:e=>{try{let t=this._findMessageIdForToolCall(e.toolCallId);if(t===void 0)return;nD(`onAddToolResult`,this._store.onAddToolResult?.({messageId:t,toolCallId:e.toolCallId,toolName:e.toolName,result:e.result,isError:e.isError,...e.artifact!==void 0&&{artifact:e.artifact},...e.modelContent!==void 0&&{modelContent:e.modelContent}}))}catch(e){console.error(`[ExternalStoreThreadRuntimeCore] onAddToolResult dispatch failed`,e)}},onStatusesChange:e=>{let t=this._hasExecutingTools(this._store);this._toolStatuses=e;try{this._store.setToolStatuses?.(Object.fromEntries(e))}finally{t!==this._hasExecutingTools(this._store)&&(this._inTrackerUpdate?this._pendingRunningRefresh=!0:this._updateStoreSnapshot(this._store))}}},e=>this._store.unstable_isClientToolCall?.(e)),this._toolInvocations.setState({messages:this._messages,isRunning:this._getEffectiveIsRunning(this._store),...this._store.isLoading!==void 0&&{isLoading:this._store.isLoading}})}_toolCallToMessageId=new Map;_messagesForToolCallIndex=null;_findMessageIdForToolCall(e){if(this._messagesForToolCallIndex!==this._messages){this._toolCallToMessageId.clear();for(let{part:e,messageId:t}of PE(this._messages))this._toolCallToMessageId.set(e.toolCallId,t);this._messagesForToolCallIndex=this._messages}return this._toolCallToMessageId.get(e)}switchToBranch(e){if(!this._store.setMessages)throw Error(`Runtime does not support switching branches.`);if(this._getEffectiveIsRunning(this._store))return;let t=this._store.unstable_onBranchChange,n=t?this.repository.canonicalHeadId:null;this.repository.switchToBranch(e),this._pendingDeleteEvictions.clear(),this.updateMessages(this.repository.getMessages()),t&&this._notifyBranchChange(n,t)}_notifyBranchChange(e,t){let n=this.repository.canonicalHeadId;n!==e&&t({headId:n,visibleMessageIds:this.repository.getMessages().map(e=>e.id)})}async append(e){let t=e.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=vE(this);this.ensureInitialized();let i=this._getInitializePromise?.();if(!t&&this._store.queue){if(i&&await i,!yE(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({discardPending:!0}),yE(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??NE}getSteerQueueItems(){return this._store?.queue?.steerItems??NE}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({discardPending:!0}),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=vE(this);this._toolInvocations?.abort({discardPending:!0}),this._store.queue?.__internal_notifyCancelled?.(),nD(`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:zT(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(yE(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.`);nD(`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.`);try{return Promise.resolve(this._store.onRespondToToolApproval(e))}catch(e){return Promise.reject(e)}}reset(e){let t=new ME;t.import(kE.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(OC))}},aD=e=>e.adapters?.threadList??{},oD=class extends xE{threads;constructor(e){super(),this.threads=new OE(aD(e),()=>new iD(this._contextProvider,e))}setAdapter(e){this.threads.__internal_setAdapter(aD(e)),this.threads.getMainThreadRuntimeCore().__internal_setAdapter(e)}},sD=e=>{let t=z(15),n;t[0]===e?n=t[1]:(n=()=>new oD(e),t[0]=e,t[1]=n);let[r]=Pv(n),i;t[2]===r.threads?i=t[3]:(i=()=>()=>{bE(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),V(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],V(o);let{modelContext:s}=wC()??{},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]),V(c,l);let u;return t[13]===r?u=t[14]:(u=new gE(r),t[13]=r,t[14]=u),u},cD=e=>{let t={useThreadMessages:({messages:t,isRunning:n,joinStrategy:r,metadata:i})=>rw({callback:e,messages:t,isRunning:n,joinStrategy:r,metadata:i}),toThreadMessages:(t,n=!1,r={})=>nw(t,e,n,r),toOriginalMessages:e=>{let t=OC(e);if(t.length===0)throw Error(`No original messages found`);return t},toOriginalMessage:e=>t.toOriginalMessages(e)[0],useOriginalMessage:()=>t.useOriginalMessages()[0],useOriginalMessages:()=>{let e=xx(),t=H(t=>{if(e.part.source)return OC(t.part)}),n=H(e=>OC(e.message)),r=t??n;if(r.length===0)throw Error(`No original messages found`);return r}};return t},lD=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}}},uD=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}},dD=e=>uD(lD(e)),fD=e=>e.status?.type!==`running`,pD=(e,t)=>{let n=()=>void t.generateTitle().catch(e=>{lS(e)||console.error(`[assistant-ui] Thread title generation failed`,e)}),r=()=>e.getState().messages.some(fD);if(r())return n(),()=>{};let i=e.subscribe(()=>{r()&&(i(),n())});return i},mD=({threadId:e,generation:t,runtimeHook:n,publish:r,itemRuntime:i})=>{let a=n(),o=a?.thread?.__internal_threadBinding,s=Iv(()=>{o&&r(e,o.getState(),t)},[e,t,o,r]),c=B(!1);c.current||s(),V(()=>{if(o)return c.current=!0,s(),o.outerSubscribe(s)},[o,s]);let l=B(void 0),u=B(!1),d=B(void 0),f=B(!1),p=Rv(()=>{if(u.current||i.getState().status!==`new`)return;u.current=!0;let e=i.initialize();l.current=e,e.then(()=>{f.current&&(d.current?.(),d.current=pD(a.thread,i))},()=>{l.current===e&&(l.current=void 0,u.current=!1)})}),m=Rv(()=>(p(),l.current));return V(()=>{if(!o)return;let e=o.getState(),t=e.__internal_setGetInitializePromise;typeof t==`function`&&t.call(e,m)},[o]),V(()=>{if(!a?.threads?.main)return;u.current=!1,f.current=!0;let e=a.threads.main.unstable_on(`initialize`,p);return()=>{f.current=!1,e(),d.current?.(),d.current=void 0}},[a]),a},hD=$v(({threadId:e,generation:t,parentList:n,runtimeHook:r,parentClient:i,adapters:a,publish:o})=>{let s=Fv(()=>new uE(new Ux({path:{ref:`threadItems[threadId=${e}]`,threadSelector:{type:`threadId`,threadId:e}},getState:()=>{let t=n.getItemById(e);return t?{id:t.id,remoteId:t.remoteId,externalId:t.externalId,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom,status:t.status,isMain:t.id===n.mainThreadId,isRunning:n.unstable_isThreadRunning?.(t.id)??!1}:Lx},subscribe:e=>n.subscribe(e)}),n),[n,e]),{client:c}=bx(i,{threadListItem:AS({runtime:s})});return Tb(c,function(){return mte(a,function(){return mD({threadId:e,generation:t,runtimeHook:r,publish:o,itemRuntime:s})})})}),gD=[`runStart`,`runEnd`,`initialize`,`modelContextUpdate`],_D=e=>{let t=z(3),{detectorRef:n}=e,r,i;return t[0]===n?(r=t[1],i=t[2]):(r=()=>{n.current=!0},i=[n],t[0]=n,t[1]=r,t[2]=i),Lv(r,i),null},vD=class extends Bx{runtimeHook;adapterStore=new Vx({defaultAdapters:null,threadAdapters:new Map});hostStore=new Vx({threads:[],hookEpoch:0});pendingThreadAdapters=new Map;instances=new Map;nextGeneration=0;parent;constructor(e,t){super(),this.parent=t,this.runtimeHook=e}_whenRuntimeAttached(e){return new Promise((t,n)=>{let r=()=>{let r=this.instances.get(e);if(!r)i(),n(Error(`Thread was deleted before runtime was started`));else if(!r.runtime||r.publishedGeneration!==r.generation)return;else i(),t(r.runtime)},i=this.subscribe(r);r()})}startThreadRuntime(e){if(!this.instances.has(e)){let t=this.nextGeneration++;this.instances.set(e,{generation:t,isRunning:!1}),this._syncHostThreads()}return this._whenRuntimeAttached(e)}__internal_restartThreadRuntime(e){let t=this.instances.get(e);return t?(t.runtime&&bE(t.runtime),t.generation=this.nextGeneration++,this._syncHostThreads(),this._notifySubscribers(),this._whenRuntimeAttached(e)):this.startThreadRuntime(e)}getThreadRuntimeCore(e){let t=this.instances.get(e);if(t)return t.runtime}__internal_isThreadRunning(e){return this.instances.get(e)?.isRunning??!1}runningSubscribers=new Set;__internal_subscribeRunningChanged(e){return this.runningSubscribers.add(e),()=>this.runningSubscribers.delete(e)}threadEventSubscribers=new Set;__internal_subscribeThreadEvents(e){return this.threadEventSubscribers.add(e),()=>this.threadEventSubscribers.delete(e)}_publish=(e,t,n)=>{this._publishThreadRuntime(e,t,n)};_publishThreadRuntime(e,t,n){let r=this.instances.get(e);if(!r||r.generation!==n)return;let i=r.runtime;if(r.runtime=t,r.publishedGeneration=n,i!==t&&this._trackRunning(e,r),this._notifySubscribers(),i!==void 0&&i!==t)for(let e of this.replacedSubscribers)e()}replacedSubscribers=new Set;__internal_subscribeRuntimeReplaced(e){return this.replacedSubscribers.add(e),()=>this.replacedSubscribers.delete(e)}_trackRunning(e,t){t.unsubscribeRunning?.();let n=t.runtime;if(!n){t.unsubscribeRunning=void 0,this._setRunning(t,!1);return}this._setRunning(t,ZT(n));let r=[n.subscribe(()=>{this._setRunning(t,ZT(n))}),...gD.map(t=>n.unstable_on(t,()=>{Zy(this.threadEventSubscribers,{threadId:e,type:t},`Thread event "${t}"`)}))];t.unsubscribeRunning=()=>{for(let e of r)e()}}_setRunning(e,t){if(e.isRunning!==t){e.isRunning=t;for(let e of this.runningSubscribers)e()}}stopThreadRuntime(e){let t=this.instances.get(e);t?.runtime&&bE(t.runtime),t?.unsubscribeRunning?.(),this.instances.delete(e),this.pendingThreadAdapters.delete(e),this._syncHostThreads(),this._notifySubscribers()}setRuntimeHook(e){if(this.runtimeHook===e)return;this.runtimeHook=e;let t=this.hostStore.getState();this.hostStore.setState({...t,hookEpoch:t.hookEpoch+1})}__internal_setDefaultAdapters(e){let t=this.adapterStore.getState();t.defaultAdapters!==e&&this.adapterStore.setState({...t,defaultAdapters:e})}__internal_setThreadAdapters(e,t){let n=this.adapterStore.getState(),r=new Map(n.threadAdapters);t===null?r.delete(e):r.set(e,t),this.adapterStore.setState({...n,threadAdapters:r})}__internal_dispose(){for(let e of[...this.instances.keys()])this.stopThreadRuntime(e)}_syncHostThreads(){let e=this.hostStore.getState();this.hostStore.setState({...e,threads:Array.from(this.instances.entries()).map(([e,{generation:t}])=>({id:e,generation:t}))})}__internal_useHost(e){let{threads:t,hookEpoch:n}=sS(this.hostStore),r=sS(this.adapterStore),i=this.runtimeHook;return Wy(t.map(({id:t,generation:a})=>{let o=this.pendingThreadAdapters.has(t)?this.pendingThreadAdapters.get(t):r.threadAdapters.get(t)??r.defaultAdapters;return ey(`${t}:${a}:${n}`,hD({threadId:t,generation:a,parentList:this.parent,runtimeHook:i,parentClient:e,adapters:o,publish:this._publish}))}))}__internal_RenderThreadRuntimes=({provider:e})=>(sS(this.hostStore),Array.from(this.instances.entries()).map(([t,{generation:n}])=>(0,I.jsx)(this._OuterActiveThreadProvider,{threadId:t,provider:e},`${t}:${n}`)));__internal_Host=({parentClient:e})=>(this.__internal_useHost(e),null);_OuterActiveThreadProvider=Gv(({threadId:e,provider:t})=>{let n=Fv(()=>new hE(this.parent).getItemById(e),[e]),r=B(!1);return V(()=>{},[t]),(0,I.jsx)(Fte,{runtime:n,children:(0,I.jsx)(t,{children:(0,I.jsx)(this._AdapterSink,{threadId:e,detectorRef:r})})})});_AdapterSink=({threadId:e,detectorRef:t})=>{let n=wC();return this.pendingThreadAdapters.set(e,n),Lv(()=>(this.__internal_setThreadAdapters(e,n),()=>{this.pendingThreadAdapters.get(e)===n&&this.pendingThreadAdapters.delete(e),this.__internal_setThreadAdapters(e,null)}),[e,n]),(0,I.jsx)(_D,{detectorRef:t})}},yD=(e,t,n)=>n.reduce((e,n)=>n?.(e,t)??e,e),bD=class extends Bx{_pendingTransforms=[];_completedOptimistics=[];_nextTransformOrder=0;_epoch=0;_baseValue;_cachedValue;constructor(e){super(),this._baseValue=e,this._cachedValue=e}_updateState(){let e=[...this._pendingTransforms.map(e=>({order:e.order,apply:t=>yD(t,e.task,[e.loading,e.optimistic])})),...this._completedOptimistics.map(({order:e,optimistic:t})=>({order:e,apply:t}))].sort((e,t)=>e.order-t.order);this._cachedValue=e.reduce((e,t)=>t.apply(e),this._baseValue),this._notifySubscribers()}get baseValue(){return this._baseValue}get value(){return this._cachedValue}update(e){this._baseValue=e,this._updateState()}reset(e){this._epoch++,this._pendingTransforms.length=0,this._completedOptimistics.length=0,this._baseValue=e,this._cachedValue=e,this._notifySubscribers()}async optimisticUpdate(e){let t=this._epoch,n=this._nextTransformOrder++,r=e.execute(),i={...e,order:n,task:r};try{this._pendingTransforms.push(i),this._updateState();let n=await r;if(t!==this._epoch)return n;this._baseValue=yD(this._baseValue,n,[e.optimistic,e.then]);for(let t of this._completedOptimistics)(e.then||t.order>i.order)&&(this._baseValue=t.optimistic(this._baseValue));return e.optimistic&&(this._completedOptimistics.push({order:i.order,optimistic:e.optimistic}),this._completedOptimistics.sort((e,t)=>e.order-t.order)),n}finally{let e=this._pendingTransforms.indexOf(i);e>-1&&this._pendingTransforms.splice(e,1),this._pendingTransforms.length===0&&(this._completedOptimistics.length=0),this._updateState()}}},xD=Error("This is the empty thread, a placeholder for the main thread. You cannot perform any actions on this thread instance. This error is probably because you tried to call a thread method in your render function. Call the method inside a `useEffect` hook instead."),SD=new class extends tE{get error(){return xD}messages=[];composer=eE(xD,!0);isLoading=!0;getMessageById(){}getBranches(){return[]}export(){return{messages:[]}}subscribe(){return()=>{}}waitForUpdate(){return Promise.reject(xD)}};function CD(e){return e}var wD=`__LOCALID_`,TD=e=>e||void 0,ED=(e,t)=>{let n=new Set([...t.threadIds,...t.archivedThreadIds]);for(let r of e){switch(r.status){case`regular`:case`archived`:break;default:{let e=r.status;throw Error(`Unsupported state: ${e}`)}}let e=t.threadIdMap[r.remoteId],i=e===void 0?void 0:t.threadData[e],a=i?.id??r.remoteId,o=e??CD(a),s=i!==void 0&&i.status!==`new`?i.initializeTask:void 0;n.has(a)?i!==void 0&&i.status!==r.status&&(r.status===`regular`?(t.archivedThreadIds=t.archivedThreadIds.filter(e=>e!==a),t.threadIds.push(a)):(t.threadIds=t.threadIds.filter(e=>e!==a),t.archivedThreadIds.push(a))):(n.add(a),r.status===`regular`?t.threadIds.push(a):t.archivedThreadIds.push(a)),t.threadIdMap[a]=o,t.threadIdMap[r.remoteId]=o,t.threadData[o]={...i?.localOrigin===!0?{localOrigin:!0}:{},id:a,remoteId:r.remoteId,externalId:r.externalId,status:r.status,title:r.title,lastMessageAt:r.lastMessageAt,custom:r.custom,initializeTask:s??Promise.resolve({remoteId:r.remoteId,externalId:r.externalId})}}return t},DD=()=>({isLoading:!0,isLoadingMore:!1,cursor:void 0,newThreadId:void 0,threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}}),OD=e=>{let t;do t=`${wD}${jC()}`;while(e.threadIdMap[t]);let n=CD(t);return{id:t,state:{...e,newThreadId:t,threadIdMap:{...e.threadIdMap,[t]:n},threadData:{...e.threadData,[n]:{status:`new`,id:t,remoteId:void 0,externalId:void 0,title:void 0,custom:void 0,localOrigin:!0}}}}},kD=(e,t,n)=>{let r=new Set(e.threadIds),i=new Set(e.archivedThreadIds),a=[],o=[],s=(e,t)=>e.has(t.id)||t.remoteId!==void 0&&e.has(t.remoteId);for(let t of Object.values(e.threadData)){let e=n.get(t.id);(e===void 0||e===`new`)&&(e!==void 0||t.localOrigin===!0)&&(t.status===`regular`&&!s(r,t)?(a.push(t),r.add(t.id)):t.status===`archived`&&!s(i,t)&&(o.push(t),i.add(t.id)))}if(a.length===0&&o.length===0)return e;let c=(e,t)=>{let n=e.indexOf(t.id);if(n!==-1)return n;let r=t.remoteId===void 0?-1:e.indexOf(t.remoteId);return r===-1?2**53-1:r};return a.sort((e,n)=>c(t.threadIds,e)-c(t.threadIds,n)),o.sort((e,n)=>c(t.archivedThreadIds,e)-c(t.archivedThreadIds,n)),{...e,threadIds:[...a.map(e=>e.id),...e.threadIds],archivedThreadIds:[...o.map(e=>e.id),...e.archivedThreadIds]}},AD=e=>new Map(Object.values(e.threadData).map(e=>[e.id,e.status])),jD=(e,t)=>{let n=e.threadIdMap[t];if(n!==void 0)return e.threadData[n]},MD=(e,t,n)=>{let r=jD(e,t);if(!r)return e;let{id:i,status:a}=r;if(a===n)return e;let o={...e};switch(a){case`new`:o.newThreadId=void 0;break;case`regular`:o.threadIds=o.threadIds.filter(e=>e!==i);break;case`archived`:o.archivedThreadIds=o.archivedThreadIds.filter(e=>e!==i);break;default:throw Error(`Unsupported state: ${a}`)}switch(n){case`regular`:o.threadIds=[i,...o.threadIds];break;case`archived`:o.archivedThreadIds=[i,...o.archivedThreadIds];break;case`deleted`:{let n=e.threadIdMap[t];o.threadData=Object.fromEntries(Object.entries(o.threadData).filter(([e])=>e!==n)),o.threadIdMap=Object.fromEntries(Object.entries(o.threadIdMap).filter(([,e])=>e!==n));break}default:throw Error(`Unsupported state: ${n}`)}return n!==`deleted`&&(o.threadData={...o.threadData,[i]:{...r,status:n}}),o},ND=class extends Error{[cS]=!0;constructor(){super(`Thread list adapter changed while an operation was pending.`),this.name=`ThreadListAdapterChangedError`}},PD=(e,t)=>Error(`Thread "${e}" not found while ${t}.`),FD=(e,t,n)=>Error(`Thread "${e}" has status "${t}", so it cannot ${n}.`),ID=DD(),LD=class extends Bx{_options;_hookManager;_runtimeAdapters;_loadThreadsPromise;_loadMorePromise;_loadGeneration=0;_adapterGeneration=0;_replaceListOnNextLoad=!1;_staleThreadIdsOnReplace;_switchGeneration=0;_switchTask;_mainThreadId;_state=new bD(ID);_useAdaptersProvider=({children:e})=>{let t=this._options.adapter.unstable_useAdapters;return t===void 0?e:(0,I.jsx)(this._SynthesizedAdapters,{useAdapters:t,children:e})};_SynthesizedAdapters=({useAdapters:e,children:t})=>{let n=gte(e());return n==null?t:(0,I.jsx)(lE,{adapters:n,children:t})};resolveProvider(e){return e.unstable_Provider===void 0?e.unstable_useAdapters===void 0?Kv:this._useAdaptersProvider:e.unstable_Provider}get threadItems(){return this._state.value.threadData}getLoadThreadsPromise(){if(!this._loadThreadsPromise){let e=this._loadGeneration,t=!1,n=AD(this._state.baseValue);this._loadThreadsPromise=this._state.optimisticUpdate({execute:()=>this._options.adapter.list(),loading:t=>e===this._loadGeneration?{...t,isLoading:!0}:t,then:(r,i)=>{if(e!==this._loadGeneration)return r;if(this._replaceListOnNextLoad)return this._replaceListOnNextLoad=!1,t=!0,this._replaceWithThreads(r,i.threads,TD(i.nextCursor));let a=ED(i.threads,{threadIds:[],archivedThreadIds:[],threadIdMap:{...r.threadIdMap},threadData:{...r.threadData}});return kD({...r,isLoading:!1,cursor:TD(i.nextCursor),threadIds:a.threadIds,archivedThreadIds:a.archivedThreadIds,threadIdMap:a.threadIdMap,threadData:a.threadData},r,n)}}).catch(n=>{if(e===this._loadGeneration){if(console.error(`[assistant-ui] thread list load failed:`,n),this._loadThreadsPromise=void 0,!this._replaceListOnNextLoad){this._state.update({...this._state.baseValue,isLoading:!1});return}this._replaceListOnNextLoad=!1,t=!0,this._state.update(this._replaceWithThreads(this._state.baseValue,[],void 0))}}).then(()=>{if(!t)return;let e=this._options.threadId;e!==void 0&&this.getItemById(e)?.id!==this._mainThreadId&&this._switchToThreadFromProp(e).catch(()=>{})})}return this._loadThreadsPromise}loadMore(){if(this._loadMorePromise)return this._loadMorePromise;let e=this._state.value;if(e.cursor===void 0||e.isLoading)return Promise.resolve();let t=this._loadGeneration,n=this._options.adapter,r=e.cursor,i=this._state.optimisticUpdate({execute:()=>n.list({after:r}),loading:e=>t===this._loadGeneration?{...e,isLoadingMore:!0}:e,then:(e,r)=>{if(t!==this._loadGeneration||n!==this._options.adapter)return e;let i=ED(r.threads,{threadIds:[...e.threadIds],archivedThreadIds:[...e.archivedThreadIds],threadIdMap:{...e.threadIdMap},threadData:{...e.threadData}});return{...e,isLoadingMore:!1,cursor:TD(r.nextCursor),threadIds:i.threadIds,archivedThreadIds:i.archivedThreadIds,threadIdMap:i.threadIdMap,threadData:i.threadData}}}).catch(e=>{t===this._loadGeneration&&console.error(`[assistant-ui] thread list loadMore failed:`,e)}).then(()=>{this._loadMorePromise===i&&(this._loadMorePromise=void 0)});return this._loadMorePromise=i,i}constructor(e,t){super(),this._state.subscribe(()=>{this._notifySubscribers(),this._notifyThreadIdChange()}),this._runtimeAdapters={modelContext:t},this._hookManager=new vD(e.runtimeHook,this),this._hookManager.__internal_setDefaultAdapters(this._runtimeAdapters),this._hookManager.__internal_subscribeRunningChanged(()=>this._notifySubscribers()),this._hookManager.__internal_subscribeRuntimeReplaced(()=>{queueMicrotask(()=>this._notifySubscribers())}),this.providerStore=new Vx(this.resolveProvider(e.adapter)),this.__internal_setOptions(e),this.switchToNewThread()}_initialThreadLoaded=!1;providerStore;__internal_setOptions(e){if(this._options===e)return;let t=this._options!==void 0&&this._options.adapter!==e.adapter,n=this._initialThreadLoaded&&this._options!==void 0&&this._options.threadId!==e.threadId;this._options=e,this.providerStore.setState(this.resolveProvider(e.adapter)),this._hookManager.setRuntimeHook(e.runtimeHook),t&&(this._loadGeneration++,this._adapterGeneration++,this._switchGeneration++,this._switchTask=void 0,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._replaceListOnNextLoad=!0,this._staleThreadIdsOnReplace=new Set(Object.values(this._state.baseValue.threadData).filter(e=>e.status!==`new`).map(e=>e.id)),this._state.update({...this._state.baseValue,cursor:void 0})),n&&this._switchToThreadFromProp(e.threadId).catch(()=>{})}_requireAdapterGeneration(e){if(e!==this._adapterGeneration)throw new ND}_requireAdapterSettled(){if(this._replaceListOnNextLoad)throw new ND}_replaceWithThreads(e,t,n){let r=[];if(e.newThreadId){let t=e.threadIdMap[e.newThreadId],n=t?e.threadData[t]:void 0;n?.status===`new`&&r.push(n)}let i=this._staleThreadIdsOnReplace;if(i)for(let t of Object.values(e.threadData))i.has(t.id)||(t.status===`new`||t.remoteId!==void 0)&&r.push(t);this._staleThreadIdsOnReplace=void 0;let a={threadIds:[],archivedThreadIds:[],threadIdMap:{},threadData:{}};for(let e of r){let t=CD(e.id);a.threadData[t]||(a.threadIdMap[e.id]=t,e.remoteId!==void 0&&(a.threadIdMap[e.remoteId]=t),a.threadData[t]=e)}let{threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l}=ED(t,a);for(let e of r){if(e.remoteId===void 0)continue;let t=l[CD(e.id)];t!==void 0&&(t.status===`regular`&&!o.includes(t.id)?o.push(t.id):t.status===`archived`&&!s.includes(t.id)&&s.push(t.id))}let u={...e,isLoading:!1,cursor:n,threadIds:o,archivedThreadIds:s,threadIdMap:c,threadData:l,newThreadId:e.newThreadId!==void 0&&c[e.newThreadId]===void 0?void 0:e.newThreadId};if(jD(u,this._mainThreadId)===void 0){let e=u.newThreadId;if(e!==void 0)this._mainThreadId=e;else{let e=OD(u);this._mainThreadId=e.id,u=e.state}this._options.threadId===void 0?this._notifyThreadIdChange():this._lastNotifiedThreadId=void 0}let d=new Set(Object.values(u.threadData).map(e=>e.id));for(let t of Object.values(e.threadData))d.has(t.id)||this._hookManager.stopThreadRuntime(t.id);return this._hookManager.startThreadRuntime(this._mainThreadId).then(()=>this._notifySubscribers(),()=>void 0),u}__internal_load(){if(this.getLoadThreadsPromise(),this._initialThreadLoaded)return;this._initialThreadLoaded=!0;let e=this._options.threadId??this._options.initialThreadId;e!==void 0&&(this._options.threadId===void 0?this.switchToThread(e):this._switchToThreadFromProp(e)).catch(()=>{})}async reloadMainThread(){let e=this._mainThreadId;if(e===void 0||this.getItemById(e)?.status===`new`)return;let t=this._hookManager.getThreadRuntimeCore(e);try{t?.unstable_refetchThread?await t.unstable_refetchThread():await this._hookManager.__internal_restartThreadRuntime(e)}catch(t){if(e!==this._mainThreadId)return;throw t}e===this._mainThreadId&&this._notifySubscribers()}reload(){return this._loadGeneration++,this._loadThreadsPromise=void 0,this._loadMorePromise=void 0,this._state.update({...this._state.baseValue,cursor:void 0}),this.getLoadThreadsPromise()}get isLoading(){return this._state.value.isLoading}get isLoadingMore(){return this._state.value.isLoadingMore}get hasMore(){return this._state.value.cursor!==void 0}get threadIds(){return this._state.value.threadIds}get archivedThreadIds(){return this._state.value.archivedThreadIds}get newThreadId(){return this._state.value.newThreadId}get mainThreadId(){return this._mainThreadId}get _mainThreadRemoteId(){if(this._mainThreadId!==void 0)return jD(this._state.value,this._mainThreadId)?.remoteId}_lastNotifiedThreadId=void 0;_notifyThreadIdChange(e=!0){let t=this._mainThreadRemoteId;this._lastNotifiedThreadId!==t&&(this._lastNotifiedThreadId=t,e&&this._options.onThreadIdChange?.(t))}getMainThreadRuntimeCore(){return this._hookManager.getThreadRuntimeCore(this._mainThreadId)||SD}getThreadRuntimeCore(e){let t=this.getItemById(e);if(!t)throw PD(e,`getting its runtime`);let n=this._hookManager.getThreadRuntimeCore(t.id);if(!n)throw Error(`Runtime for thread "${e}" not found while getting its runtime.`);return n}unstable_isThreadRunning(e){let t=this.getItemById(e);return t?this._hookManager.__internal_isThreadRunning(t.id):!1}unstable_subscribeThreadEvents(e){return this._hookManager.__internal_subscribeThreadEvents(e)}getItemById(e){return jD(this._state.value,e)}switchToThread(e,t){return this._startSwitchToThread(e,t,!0)}_startSwitchToThread(e,t,n){let r=++this._switchGeneration,i=this._switchToThread(e,t,r,n);return this._switchTask=i,i}async _switchToThread(e,t,n,r){if(this._replaceListOnNextLoad&&e!==this._state.value.newThreadId)throw new ND;let i=this.getItemById(e);if(!i){let t=await this._options.adapter.fetch(e);if(n!==this._switchGeneration)return;let r=this._state.value,a=CD(t.remoteId),o={...r.threadData,[a]:{id:a,initializeTask:Promise.resolve({remoteId:t.remoteId,externalId:t.externalId}),remoteId:t.remoteId,externalId:t.externalId,status:t.status,title:t.title,lastMessageAt:t.lastMessageAt,custom:t.custom}},s={...r.threadIdMap,[t.remoteId]:a},c=t.remoteId,l=t.status===`regular`?r.threadIds.includes(c):r.archivedThreadIds.includes(c),u=r.threadIds.filter(e=>e!==c),d=r.archivedThreadIds.filter(e=>e!==c),f=t.status===`regular`?l?r.threadIds:[...u,c]:u,p=t.status===`archived`?l?r.archivedThreadIds:[...d,c]:d;this._state.update({...r,threadIds:f,archivedThreadIds:p,threadIdMap:s,threadData:o}),i=this.getItemById(e)}if(!i)throw PD(e,`switching to it`);if(this._mainThreadId===i.id)return;let a=this._hookManager.startThreadRuntime(i.id);if(this.mainThreadId===void 0?a.then(()=>this._notifySubscribers(),()=>void 0):await a,n!==this._switchGeneration)return;let o=this.getItemById(i.id);o?.id===i.id&&(o.status===`archived`&&t?.unarchive!==!1&&(await o.initializeTask,n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)||o.status===`archived`&&(await this.unarchive(o.id),n!==this._switchGeneration||(o=this.getItemById(i.id),o?.id!==i.id)))||(this._mainThreadId=o.id,this._notifySubscribers(),this._notifyThreadIdChange(r)))}switchToNewThread(){return this._startSwitchToNewThread(!0)}_switchToThreadFromProp(e){return e===void 0?this._startSwitchToNewThread(!1):this._startSwitchToThread(e,void 0,!1)}_startSwitchToNewThread(e){let t=++this._switchGeneration,n=this._switchToNewThread(t,e);return this._switchTask=n,n}async _switchToNewThread(e,t){for(;this._state.baseValue.newThreadId!==void 0&&this._state.value.newThreadId===void 0;)if(await this._state.waitForUpdate(),e!==this._switchGeneration)return;let n=this._state.baseValue,r=this._state.value.newThreadId;if(r===void 0){let e=OD(n);r=e.id,this._state.update(e.state)}return this._switchToThread(r,void 0,e,t)}initialize=async e=>{let t=this._options.adapter,n=this._adapterGeneration;if(this._state.value.newThreadId!==e){this._requireAdapterSettled();let t=this.getItemById(e);if(!t)throw PD(e,`initializing it`);if(t.status===`new`)throw FD(e,t.status,`be initialized here`);let{remoteId:r,externalId:i}=await t.initializeTask;return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}}let{remoteId:r,externalId:i}=await this._state.optimisticUpdate({execute:()=>(this._requireAdapterGeneration(n),t.initialize(e)),optimistic:t=>MD(t,e,`regular`),loading:(t,n)=>{let r=CD(e);return{...t,threadData:{...t.threadData,[r]:{...t.threadData[r],initializeTask:n}}}},then:(t,{remoteId:r,externalId:i})=>{if(n!==this._adapterGeneration)return t;let a=jD(t,e);if(!a)return t;let o=CD(e),s=t.threadIdMap[r],c=s!==void 0&&s!==o?t.threadData[s]:void 0,l={...t.threadData};c!==void 0&&delete l[s],l[o]={...a,initializeTask:Promise.resolve({remoteId:r,externalId:i}),remoteId:r,externalId:i};let u=e=>c===void 0?e:e.filter(e=>e!==c.id);return{...t,threadIds:u(t.threadIds),archivedThreadIds:u(t.archivedThreadIds),threadIdMap:{...t.threadIdMap,[r]:o},threadData:l}}});return this._requireAdapterGeneration(n),{remoteId:r,externalId:i}};generateTitle=async e=>{this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw PD(e,`generating its title`);if(r.status===`new`)throw FD(e,r.status,`generate a title`);let{remoteId:i}=await r.initializeTask;this._requireAdapterGeneration(n);let a=this._hookManager.getThreadRuntimeCore(r.id);if(!a)return;let o=a.messages.filter(fD),s=await t.generateTitle(i,o),c=jw.fromAssistantStream(s);for await(let e of c){if(n!==this._adapterGeneration)return;let t=e.parts.filter(e=>e.type===`text`)[0]?.text;await this._state.optimisticUpdate({execute:async()=>{},optimistic:e=>{if(n!==this._adapterGeneration)return e;let i=jD(e,r.id);return i?{...e,threadData:{...e.threadData,[i.id]:{...i,title:t}}}:e}})}};async rename(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw PD(e,`renaming it`);if(i.status===`new`)throw FD(e,i.status,`be renamed`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;return this._requireAdapterGeneration(r),n.rename(e,t)},optimistic:n=>{let r=jD(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,title:t}}}:n}})}async updateCustom(e,t){this._requireAdapterSettled();let n=this._options.adapter,r=this._adapterGeneration,i=this.getItemById(e);if(!i)throw PD(e,`updating its custom metadata`);if(i.status===`new`)throw FD(e,i.status,`update custom metadata`);if(!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await i.initializeTask;if(this._requireAdapterGeneration(r),!n.updateCustom)throw Error(`Remote thread list adapter does not support updating custom metadata`);return n.updateCustom(e,t)},optimistic:n=>{let r=jD(n,e);return r?{...n,threadData:{...n.threadData,[r.id]:{...r,custom:t}}}:n}})}async _ensureThreadIsNotMain(e){if(e===this.newThreadId)throw Error(`Cannot ensure new thread is not main`);let t;for(;e===this._mainThreadId;){let e=this._switchTask,n=!e||e===t;n&&(e=this.switchToNewThread()),t=e;try{await e}catch(t){if(n&&this._switchTask===e)throw t}}}async archive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw PD(e,`archiving it`);if(r.status!==`regular`)throw FD(e,r.status,`be archived`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),t.archive(e)},optimistic:e=>MD(e,r.id,`archived`)})}async unarchive(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw PD(e,`unarchiving it`);if(r.status!==`archived`)throw FD(e,r.status,`be unarchived`);return this._state.optimisticUpdate({execute:async()=>{try{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.unarchive(e)}catch(e){throw n===this._adapterGeneration&&await this._ensureThreadIsNotMain(r.id),e}},optimistic:e=>MD(e,r.id,`regular`)})}async delete(e){this._requireAdapterSettled();let t=this._options.adapter,n=this._adapterGeneration,r=this.getItemById(e);if(!r)throw PD(e,`deleting it`);if(r.status!==`regular`&&r.status!==`archived`)throw FD(e,r.status,`be deleted`);return await this._ensureThreadIsNotMain(r.id),this._requireAdapterGeneration(n),this._hookManager.stopThreadRuntime(r.id),this._state.optimisticUpdate({execute:async()=>{let{remoteId:e}=await r.initializeTask;return this._requireAdapterGeneration(n),await t.delete(e)},optimistic:e=>MD(e,r.id,`deleted`)})}__internal_dispose(){this._hookManager.__internal_dispose()}async detach(e){let t=this._adapterGeneration,n=this.getItemById(e);if(!n)throw PD(e,`detaching it`);if(n.status!==`regular`&&n.status!==`archived`)throw FD(e,n.status,`be detached`);await this._ensureThreadIsNotMain(n.id),this._requireAdapterGeneration(t),this._hookManager.stopThreadRuntime(n.id)}boundIdsStore=new Vx([]);__internal_RenderComponent=()=>{let e=Hv();V(()=>(this.boundIdsStore.setState([...this.boundIdsStore.getState(),e]),()=>{this.boundIdsStore.setState(this.boundIdsStore.getState().filter(t=>t!==e))}),[e]);let t=sS(this.boundIdsStore),n=sS(this.providerStore),r=xx();return(t.length===0||t[0]===e)&&(0,I.jsxs)(lE,{adapters:this._runtimeAdapters,children:[(0,I.jsx)(this._hookManager.__internal_RenderThreadRuntimes,{provider:n}),(0,I.jsx)(this._hookManager.__internal_Host,{parentClient:r})]})}},RD=class extends xE{threads;constructor(e){super(),this.threads=new LD(e,this._contextProvider)}get RenderComponent(){return this.threads.__internal_RenderComponent}},zD=e=>{let t=z(10),n;t[0]===e?n=t[1]:(n=()=>new RD(e),t[0]=e,t[1]=n);let[r]=Pv(n),i;t[2]!==e||t[3]!==r.threads?(i=()=>{r.threads.__internal_setOptions(e),r.threads.__internal_load()},t[2]=e,t[3]=r.threads,t[4]=i):i=t[4];let a;t[5]!==e||t[6]!==r?(a=[r,e],t[5]=e,t[6]=r,t[7]=a):a=t[7],V(i,a);let o;return t[8]===r?o=t[9]:(o=new gE(r),t[8]=r,t[9]=o),o},BD=e=>{let[t]=Pv(()=>new Vx(e.runtimeHook));V(()=>{t.setState(e.runtimeHook)},[t,e.runtimeHook]);let n=B(e.initialThreadId),r=Iv(function(){return sS({subscribe:t.subscribe,getState:t.getState,getServerSnapshot:t.getState})()},[t]),i=Rv(t=>{e.onThreadIdChange?.(t)}),a=Fv(()=>({adapter:e.adapter,allowNesting:e.allowNesting,threadId:e.threadId,initialThreadId:n.current,runtimeHook:r,onThreadIdChange:i}),[e.adapter,e.allowNesting,e.threadId,r]);if(xx().threadListItem.source!==null){if(!a.allowNesting)throw Error(`useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. Set allowNesting: true to allow nesting (the inner runtime will become a no-op).`);return e.runtimeHook()}return zD(a)},VD=e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text};case`image`:return{type:`image`,image:e.image,...e.filename==null?void 0:{filename:e.filename}};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename==null?void 0:{filename:e.filename},...e.sourceType==null?void 0:{sourceType:e.sourceType}};case`audio`:return{type:`audio`,audio:{data:e.audio.data,format:e.audio.format}};case`data`:return qS(e.data)||console.warn(`attachment data is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};default:throw Error(`Attachment part type not supported by aui/v0: ${t}`)}},HD=e=>{if(e.role===`user`&&e.attachments.length!==0)return e.attachments.map(({id:e,type:t,name:n,contentType:r,status:i,content:a})=>({id:e,type:t,name:n,status:i,...r==null?void 0:{contentType:r},content:a.map(VD)}))};function UD(e){let t=e.status?.type===`running`?{type:`incomplete`,reason:`cancelled`}:e.status,n=HD(e);return{role:e.role,content:e.content.map(e=>{let t=e.type;switch(t){case`text`:return{type:`text`,text:e.text};case`reasoning`:return{type:`reasoning`,text:e.text,...e.unstable_summary===void 0?void 0:{unstable_summary:e.unstable_summary}};case`source`:return e.sourceType===`url`?{type:`source`,sourceType:`url`,id:e.id,url:e.url,...e.title==null?void 0:{title:e.title},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata}}:{type:`source`,sourceType:`document`,id:e.id,title:e.title,mediaType:e.mediaType,...e.filename==null?void 0:{filename:e.filename},...e.providerMetadata==null?void 0:{providerMetadata:e.providerMetadata}};case`tool-call`:return e.result!==void 0&&!qS(e.result)&&console.warn(`tool-call result is not JSON! ${JSON.stringify(e)}`),{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,...JSON.stringify(e.args)===e.argsText?{args:e.args}:{argsText:e.argsText},...e.result===void 0?void 0:{result:e.result},...e.isError?{isError:!0}:void 0,...e.approval?{approval:e.approval}:void 0};case`image`:return{type:`image`,image:e.image};case`file`:return{type:`file`,data:e.data,mimeType:e.mimeType,...e.filename?{filename:e.filename}:void 0,...e.sourceType?{sourceType:e.sourceType}:void 0};case`data`:return qS(e.data)||console.warn(`data part is not JSON! ${JSON.stringify(e)}`),{type:`data`,name:e.name,data:e.data};default:throw Error(`Message part type not supported by aui/v0: ${t}`)}}),metadata:e.metadata,...t?{status:t}:void 0,...n?{attachments:n}:void 0}}function WD(e){let t=e.content,n=IC({id:e.id,createdAt:e.created_at,...t},e.id,{type:`complete`,reason:`unknown`});return{parentId:e.parent_id,message:n}}var GD=class extends Error{constructor(e){super(e),this.name=`CloudResponseError`}},KD=(e,t)=>new GD(`Invalid Assistant Cloud response for "${e}": expected ${t}`),qD=(e,t)=>{if(typeof e!=`object`||!e||Array.isArray(e))throw KD(t,`an object`);return e},JD=(e,t)=>{if(!Array.isArray(e))throw KD(t,`an array`);return e},YD=(e,t)=>{if(typeof e!=`string`)throw KD(t,`a string`);return e},XD=(e,t)=>e===null?null:YD(e,t),ZD=(e,t)=>{if(typeof e!=`boolean`)throw KD(t,`a boolean`);return e},QD=(e,t)=>{if(!Number.isInteger(e))throw KD(t,`an integer`);return e},$D=(e,t)=>{if(typeof e!=`string`)throw KD(t,`a canonical ISO timestamp`);let n=new Date(e);if(Number.isNaN(n.getTime())||n.toISOString()!==e)throw KD(t,`a canonical ISO timestamp`);return n},eO=(e,t)=>qD(e,t),tO=3e4,nO=async(e,t)=>{let n=new AbortController,r=!1,i=setTimeout(()=>{r=!0,n.abort()},tO);try{return await t(n.signal)}catch(t){throw r?Error(`Assistant Cloud ${e} timed out after ${tO}ms`,{cause:t}):t}finally{clearTimeout(i)}},rO=e=>{try{let t=e.split(`.`)[1];if(!t)throw Error(`Invalid JWT format`);let n=t.replace(/-/g,`+`).replace(/_/g,`/`);for(;n.length%4!=0;)n+=`=`;let r=atob(n),i=JSON.parse(r).exp;if(!i||typeof i!=`number`)throw Error(`JWT does not contain a valid "exp" field`);return i*1e3}catch(e){throw Error(`Unable to determine the token expiry: ${e}`)}},iO=(e,t)=>{let n=YD(e,t);if(n.length===0)throw new GD(`Invalid Assistant Cloud response for "${t}": expected a non-empty string`);return n},aO=(e,t)=>{let n=qD(e,t);return{token:iO(n.token,`${t}.token`),expires_at:iO(n.expires_at,`${t}.expires_at`)}},oO=async(e,t)=>{let n;try{n=await e.json()}catch{throw new GD(`Invalid Assistant Cloud response for "${t}": expected valid JSON`)}let r=qD(n,t);return{data:r,accessToken:iO(r.access_token,`${t}.access_token`)}},sO=class{strategy=`jwt`;cachedToken=null;tokenExpiry=null;tokenRequest=null;#e;constructor(e){this.#e=e}async getAuthHeaders(){let e=Date.now();if(this.cachedToken&&this.tokenExpiry&&this.tokenExpiry-e>3e4)return{Authorization:`Bearer ${this.cachedToken}`};this.tokenRequest||=this.fetchAuthHeaders();let t=this.tokenRequest;try{return await t}finally{this.tokenRequest===t&&(this.tokenRequest=null)}}async fetchAuthHeaders(){let e=await this.#e();return e?(this.cachedToken=e,this.tokenExpiry=rO(e),{Authorization:`Bearer ${e}`}):!1}readAuthHeaders(e){let t=e.get(`Authorization`);if(!t)return;let[n,r]=t.split(` `);if(n!==`Bearer`||!r)throw Error(`Invalid auth header received`);this.cachedToken=r,this.tokenExpiry=rO(r)}},Lte=class{strategy=`api-key`;#e;#t;#n;constructor(e,t,n){this.#e=e,this.#t=t,this.#n=n}async getAuthHeaders(){return{Authorization:`Bearer ${this.#e}`,"Aui-User-Id":this.#t,"Aui-Workspace-Id":this.#n}}readAuthHeaders(){}},cO=`aui:refresh_token`,lO=e=>`${cO}:${e}`,uO=e=>{try{e.removeItem(cO)}catch{}},dO=()=>{if(!(`localStorage`in globalThis))return null;try{return globalThis.localStorage}catch{return null}},Rte=e=>{let t=dO();if(t)try{let n=lO(e),r=t.getItem(n);if(r)return uO(t),JSON.parse(r);let i=t.getItem(cO);if(!i)return;let a;try{a=JSON.parse(i)}catch{uO(t);return}return t.setItem(n,i),uO(t),a}catch{return}},fO=(e,t)=>{let n=dO();if(n)try{n.setItem(lO(e),JSON.stringify(t))}catch{}},zte=e=>{let t=dO();if(t)try{t.removeItem(lO(e))}catch{}},pO=new WeakMap,Bte=()=>`navigator`in globalThis?globalThis.navigator?.locks??null:null,Vte=e=>`assistant-cloud:anonymous-auth:${e}`,Hte=(e,t)=>{let n=dO();if(!n)return t();let r=pO.get(n);r||(r=new Map,pO.set(n,r));let i=r.get(e);if(i)return i;let a=Bte(),o=(a?a.request(Vte(e),t):t()).finally(()=>{r.get(e)===o&&r.delete(e)});return r.set(e,o),o},Ute=class{strategy=`anon`;baseUrl;jwtStrategy;constructor(e){this.baseUrl=e;let t=async()=>{let e=Date.now(),t=Rte(this.baseUrl);if(t){if(new Date(t.expires_at).getTime()-e>3e4){let e=await nO(`refresh token request`,async e=>{let n=await fetch(`${this.baseUrl}/v1/auth/tokens/refresh`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({refresh_token:t.token}),signal:e});if(n.ok){let{data:e,accessToken:t}=await oO(n,`refresh auth token response`);return e.refresh_token!=null&&fO(this.baseUrl,aO(e.refresh_token,`refresh auth token response.refresh_token`)),t}if(n.status===429||n.status>=500)throw Error(`Assistant Cloud token refresh failed with status ${n.status}`);return null});if(e!==null)return e}else zte(this.baseUrl)}return nO(`anonymous token request`,async e=>{let t=await fetch(`${this.baseUrl}/v1/auth/tokens/anonymous`,{method:`POST`,signal:e});if(!t.ok)return null;let{data:n,accessToken:r}=await oO(t,`anonymous auth token response`);return fO(this.baseUrl,aO(n.refresh_token,`anonymous auth token response.refresh_token`)),r})};this.jwtStrategy=new sO(()=>Hte(this.baseUrl,t))}async getAuthHeaders(){return this.jwtStrategy.getAuthHeaders()}readAuthHeaders(e){this.jwtStrategy.readAuthHeaders(e)}},Wte=class extends Error{status;constructor(e,t){super(e),this.status=t,this.name=`CloudAPIError`}},mO=e=>!e||!e.endsWith(`/`)?e:e.slice(0,-1),Gte=class{_auth;_baseUrl;constructor(e){if(`authToken`in e)this._baseUrl=mO(e.baseUrl),this._auth=new sO(e.authToken);else if(`apiKey`in e)this._baseUrl=mO(e.baseUrl??`https://backend.assistant-api.com`),this._auth=new Lte(e.apiKey,e.userId,e.workspaceId);else if(`anonymous`in e)this._baseUrl=mO(e.baseUrl),this._auth=new Ute(this._baseUrl);else throw Error(`Invalid configuration: Must provide authToken, apiKey, or anonymous configuration`)}async initializeAuth(){return!!await this._auth.getAuthHeaders()}async makeRawRequest(e,t={}){let n=await this._auth.getAuthHeaders();if(!n)throw Error(`Authorization failed`);let r={...n,...t.headers,"Content-Type":`application/json`},i=new URLSearchParams;if(t.query)for(let[e,n]of Object.entries(t.query))n!==!1&&(n===!0?i.set(e,`true`):i.set(e,n.toString()));let a=new URL(`${this._baseUrl}/v1${e}`);a.search=i.toString();let o=await fetch(a,{method:t.method??`GET`,headers:r,body:t.body?JSON.stringify(t.body):null});if(this._auth.readAuthHeaders(o.headers),!o.ok){let e=await o.text(),t;try{let n=JSON.parse(e);typeof n?.message==`string`&&n.message.length>0&&(t=n.message)}catch{}throw new Wte(t??`Request failed with status ${o.status}, ${e}`,o.status)}return o}async makeRequest(e,t={}){let n=await this.makeRawRequest(e,t);if(n.status===204||n.headers.get(`content-length`)===`0`)return;let r=await n.text();if(r.trim()!==``)return JSON.parse(r)}},Kte=class{cloud;constructor(e){this.cloud=e}async create(){return{token:YD(qD(await this.cloud.makeRequest(`/auth/tokens`,{method:`POST`}),`auth token response`).token,`token`)}}},hO=(e,t)=>{let n=qD(e,t);return{id:YD(n.id,`${t}.id`),parent_id:XD(n.parent_id,`${t}.parent_id`),height:QD(n.height,`${t}.height`),created_at:$D(n.created_at,`${t}.created_at`),updated_at:$D(n.updated_at,`${t}.updated_at`),format:YD(n.format,`${t}.format`),content:eO(n.content,`${t}.content`)}},qte=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:JD(qD(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{query:t}),`thread message list response`).messages,`messages`).map((e,t)=>hO(e,`messages[${t}]`))}}async create(e,t){return{message_id:YD(qD(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t}),`thread message create response`).message_id,`message_id`)}}async update(e,t,n){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}`,{method:`PUT`,body:n})}},gO=(e,t)=>{let n=qD(e,t);return{title:XD(n.title,`${t}.title`)??``,last_message_at:$D(n.last_message_at,`${t}.last_message_at`),metadata:n.metadata,external_id:XD(n.external_id,`${t}.external_id`),id:YD(n.id,`${t}.id`),project_id:YD(n.project_id,`${t}.project_id`),created_at:$D(n.created_at,`${t}.created_at`),updated_at:$D(n.updated_at,`${t}.updated_at`),workspace_id:YD(n.workspace_id,`${t}.workspace_id`),is_archived:ZD(n.is_archived,`${t}.is_archived`)}},Jte=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new qte(e)}async list(e){let t=e?.is_archived===void 0?e:{...e,is_archived:String(e.is_archived)};return{threads:JD(qD(await this.cloud.makeRequest(`/threads`,{query:t}),`thread list response`).threads,`threads`).map((e,t)=>gO(e,`threads[${t}]`))}}async get(e){return gO(qD(await this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`),`thread response`).thread,`thread`)}async create(e){return{thread_id:YD(qD(await this.cloud.makeRequest(`/threads`,{method:`POST`,body:e}),`thread create response`).thread_id,`thread_id`)}}async update(e,t){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`PUT`,body:t})}async delete(e){return this.cloud.makeRequest(`/threads/${encodeURIComponent(e)}`,{method:`DELETE`})}},Yte=class{cloud;constructor(e){this.cloud=e}async list(e,t){return{messages:JD(qD(await this.cloud.makeRequest(`/projects/threads/${encodeURIComponent(e)}/messages`,{query:t}),`project thread message list response`).messages,`messages`).map((e,t)=>hO(e,`messages[${t}]`))}}},Xte=class{messages;cloud;constructor(e){this.cloud=e,this.messages=new Yte(e)}async list(e){return{threads:JD(qD(await this.cloud.makeRequest(`/projects/threads`,{query:{...e,...e?.is_archived===void 0?{}:{is_archived:String(e.is_archived)}}}),`project thread list response`).threads,`threads`).map((e,t)=>gO(e,`threads[${t}]`))}}},Zte=class{threads;constructor(e){this.threads=new Xte(e)}},Qte=class{cloud;constructor(e){this.cloud=e}__internal_getAssistantOptions(e){return{api:`${this.cloud._baseUrl}/v1/runs/stream`,headers:async()=>{let e=await this.cloud._auth.getAuthHeaders();if(!e)throw Error(`Authorization failed`);return{...e,Accept:`text/plain`}},body:{assistant_id:e,response_format:`vercel-ai-data-stream/v1`,thread_id:`unstable_todo`}}}async stream(e){let t=await this.cloud.makeRawRequest(`/runs/stream`,{method:`POST`,headers:{Accept:`text/plain`},body:e});if(!t.body)throw new GD(`Invalid Assistant Cloud response for "run stream": expected a response body`);let n=t.headers.get(`content-type`);if(n?.split(`;`,1)[0]?.trim().toLowerCase()!==`text/plain`)throw await t.body.cancel().catch(()=>void 0),new GD(`Invalid Assistant Cloud response for "run stream": expected a "text/plain" content type, received ${n?`"${n}"`:`no Content-Type header`}`);return $S.fromResponse(t,new Aw)}async report(e){return{run_id:YD(qD(await this.cloud.makeRequest(`/runs`,{method:`POST`,body:e}),`run report response`).run_id,`run_id`)}}},$te=class{cloud;constructor(e){this.cloud=e}async pdfToImages(e){let t=qD(await this.cloud.makeRequest(`/files/pdf-to-images`,{method:`POST`,body:e}),`PDF conversion response`);return{success:ZD(t.success,`PDF conversion response.success`),urls:JD(t.urls,`PDF conversion response.urls`).map((e,t)=>YD(e,`PDF conversion response.urls[${t}]`)),message:YD(t.message,`PDF conversion response.message`)}}async generatePresignedUploadUrl(e){let t=qD(await this.cloud.makeRequest(`/files/attachments/generate-presigned-upload-url`,{method:`POST`,body:e}),`presigned upload response`);return{success:ZD(t.success,`presigned upload response.success`),signedUrl:YD(t.signedUrl,`presigned upload response.signedUrl`),expiresAt:YD(t.expiresAt,`presigned upload response.expiresAt`),publicUrl:YD(t.publicUrl,`presigned upload response.publicUrl`)}}},_O=class{threads;projects;auth;runs;files;telemetry;constructor(e){let t=new Gte(e);this.threads=new Jte(t),this.projects=new Zte(t),this.auth={tokens:new Kte(t)},this.runs=new Qte(t),this.files=new $te(t);let n=e.telemetry;this.telemetry=n===!1?{enabled:!1}:n===!0||n===void 0?{enabled:!0}:{...n,enabled:n.enabled!==!1}}},vO=class{idMapping={};getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}async append(e,t,n,r,i){let a=this.getCloud(),o=this.idMapping[t];if(o instanceof Promise){await o;return}let s=(async()=>{let t=n?await this.idMapping[n]??n:null,{message_id:o}=await a.threads.messages.create(e,{parent_id:t,format:r,content:i});return o})();this.idMapping[t]=s;try{let e=await s;this.idMapping[t]===s&&(this.idMapping[t]=e)}catch(e){throw this.idMapping[t]===s&&delete this.idMapping[t],e}}async update(e,t,n,r){let i=this.getCloud(),a=await this.getRemoteId(t);if(!a){console.warn(`Skipping update for message ${t}: no remote id is mapped.`);return}await i.threads.messages.update(e,a,{content:r})}isPersisted(e){return e in this.idMapping}async getRemoteId(e){let t=this.idMapping[e];if(t)return t}async load(e,t){let{messages:n}=await this.getCloud().threads.messages.list(e,t?{format:t}:void 0);for(let e of n)this.idMapping[e.id]=e.id;return n}reset(){this.idMapping={}}},yO=(e,t)=>({append:async(n,r)=>{let i=t.getId(r.message),a=t.encode(r);return e.append(n,i,r.parentId,t.format,a)},update:e.update?async(n,r,i)=>{let a=t.encode(r);return e.update(n,i,t.format,a)}:void 0,load:async n=>({messages:(await e.load(n,t.format)).filter(e=>e.format===t.format).map(e=>t.decode({id:e.id,parent_id:e.parent_id,format:e.format,content:e.content})).reverse()}),isPersisted:t=>e.isPersisted(t)}),bO=5e4,xO=/^[A-Za-z0-9+/]{100,}={0,2}$/;function SO(e){return e.length<=bO?e:e.slice(0,bO)}function CO(e){if(e!=null)try{return SO(JSON.stringify(e))}catch{return}}function wO(e){if(e!=null){try{let t=typeof e==`string`?JSON.parse(e):e;if(Array.isArray(t)){let e=t.map(e=>{if(e&&typeof e==`object`&&e.type&&(e.type===`image`||e.type===`audio`)&&typeof e.data==`string`&&xO.test(e.data.slice(0,200))){let t=(e.data.length*3/4/1024).toFixed(1);return{...e,data:`[${e.type}: ${t}KB]`}}return e});return SO(JSON.stringify(e))}}catch{}return CO(e)}}function TO(e){let{toolName:t,toolCallId:n,args:r,argsText:i,result:a,toolSource:o}=e,s={tool_name:t,tool_call_id:n},c=i==null?CO(r):SO(i);c!==void 0&&(s.tool_args=c);let l=o===`mcp`?wO(a):CO(a);return l!==void 0&&(s.tool_result=l),o&&(s.tool_source=o),s}function EO(e){let t=e.inputTokens??e.promptTokens,n=e.outputTokens??e.completionTokens,r=e.reasoningTokens??e.outputTokenDetails?.reasoningTokens,i=e.cachedInputTokens??e.inputTokenDetails?.cacheReadTokens;if(t!=null||n!=null||r!=null||i!=null)return{...t==null?void 0:{inputTokens:t},...n==null?void 0:{outputTokens:n},...r==null?void 0:{reasoningTokens:r},...i==null?void 0:{cachedInputTokens:i}}}var DO=new WeakMap,OO=class{cloudRef;getAui;constructor(e,t){this.cloudRef=e,this.getAui=t}get aui(){return this.getAui()}getPersistence(e=this.aui.threadListItem){let t=cb(e);return DO.has(t)||DO.set(t,new vO(()=>this.cloudRef.current)),DO.get(t)}get _persistence(){return this.getPersistence()}tryGetKeyedThreadListItem(){let e=this.aui.threadListItem;if(!e.source)return;let t=e.getState().id;if(t!==void 0)return this.aui.threads.getState().threadItems.some(e=>e.id===t||e.remoteId===t)?this.aui.threads.item({id:t}):e}withFormat(e){let t=this,n,r=()=>{let e=t.tryGetKeyedThreadListItem();return e&&(n=e),n},i=()=>n??r(),a=n=>yO(t.getPersistence(n),e);return{pin(){r()},async append(e){let t=i();if(!t)throw Error(`Cannot persist cloud history without a thread list item.`);let n=t.getState().remoteId??(await t.initialize()).remoteId;await a(t).append(n,e)},async update(e,t){let n=i(),r=n?.getState().remoteId;r&&n&&await a(n).update?.(r,e,t)},async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)},reportTelemetry(n,r){let a=n.map(t=>e.encode(t));t._reportRunTelemetry(e.format,a,r,i())},async load(){let e=r(),n=t.aui.threadListItem,i=n.source?n.getState().remoteId:void 0;return i?a(e??n).load(i):{messages:[]}}}}async append({parentId:e,message:t}){let{remoteId:n}=await this.aui.threadListItem.initialize(),r=UD(t);await this._persistence.append(n,t.id,e,`aui/v0`,r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,`aui/v0`,r)}async update(e){if(!this._persistence.isPersisted(e.message.id))return this.append(e);let{message:t}=e,n=this.aui.threadListItem.getState().remoteId;if(!n)return;let r=UD(t);await this._persistence.update(n,t.id,`aui/v0`,r),this.cloudRef.current.telemetry.enabled&&this._maybeReportRun(n,`aui/v0`,r)}async delete(){throw Error(`Assistant Cloud does not support deleting thread messages yet.`)}async load(){let e=this.aui.threadListItem.getState().remoteId;return e?{messages:(await this._persistence.load(e,`aui/v0`)).filter(e=>e.format===`aui/v0`).map(WD).reverse()}:{messages:[]}}_reportRunTelemetry(e,t,n,r){if(!this.cloudRef.current.telemetry.enabled)return;let i=(r??this.aui.threadListItem).getState().remoteId;if(!i)return;let a=jO(e,t);a&&this._sendReport(i,a,n?.durationMs,n?.stepTimestamps)}_maybeReportRun(e,t,n){let r=AO(t,n);r&&this._sendReport(e,r)}_sendReport(e,t,n,r){let i=kO(t.steps,r),a={thread_id:e,status:t.status,...t.totalSteps==null?void 0:{total_steps:t.totalSteps},...t.toolCalls?{tool_calls:t.toolCalls}:void 0,...i?{steps:i}:void 0,...t.inputTokens==null?void 0:{input_tokens:t.inputTokens},...t.outputTokens==null?void 0:{output_tokens:t.outputTokens},...t.reasoningTokens==null?void 0:{reasoning_tokens:t.reasoningTokens},...t.cachedInputTokens==null?void 0:{cached_input_tokens:t.cachedInputTokens},...n==null?void 0:{duration_ms:n},...t.outputText==null?void 0:{output_text:t.outputText},...t.metadata?{metadata:t.metadata}:void 0,...t.modelId?{model_id:t.modelId}:void 0},{beforeReport:o}=this.cloudRef.current.telemetry,s=o?o(a):a;s&&this.cloudRef.current.runs.report(s).catch(()=>{})}};function kO(e,t){if(!t)return e;if(!e)return t.map(e=>({...e}));let n=Math.min(e.length,t.length);return e.map((e,r)=>({...e,...r<n?t[r]:void 0}))}function AO(e,t){switch(e){case`aui/v0`:return NO(t);case`ai-sdk/v6`:return VO(t);default:return null}}function jO(e,t){if(e===`ai-sdk/v6`)return HO(t);for(let n=t.length-1;n>=0;n--){let r=AO(e,t[n]);if(r)return r}return null}var MO={error:`error`,incomplete:`incomplete`};function NO(e){let t=e;if(t.role!==`assistant`||t.status?.type===`requires-action`)return null;let n=t.content?.filter(e=>e.type===`tool-call`&&e.toolName&&e.toolCallId).map(e=>TO({toolName:e.toolName,toolCallId:e.toolCallId,args:e.args,result:e.result,argsText:e.argsText})),r=t.content?.filter(e=>e.type===`text`&&e.text),i=r&&r.length>0?SO(r.map(e=>e.text).join(``)):void 0,a=t.metadata?.steps,o,s,c,l;if(a&&a.length>0){let e=0,t=0,n=0,r=0,i=!1,u=!1,d=!1,f=!1;for(let o of a){if(!o.usage)continue;let a=EO(o.usage);a&&(a.inputTokens!=null&&(e+=a.inputTokens,i=!0),a.outputTokens!=null&&(t+=a.outputTokens,u=!0),a.reasoningTokens!=null&&(n+=a.reasoningTokens,d=!0),a.cachedInputTokens!=null&&(r+=a.cachedInputTokens,f=!0))}o=i?e:void 0,s=u?t:void 0,c=d?n:void 0,l=f?r:void 0}let u=t.status?.type,d=u&&MO[u]||`completed`,f=t.metadata?.custom,p=t.metadata?.modelId??(typeof t.metadata?.custom?.modelId==`string`?t.metadata.custom.modelId:void 0),m=a&&a.length>1?a.map(e=>{let t=e.usage?EO(e.usage):void 0;return{...t?.inputTokens==null?void 0:{input_tokens:t.inputTokens},...t?.outputTokens==null?void 0:{output_tokens:t.outputTokens},...t?.reasoningTokens==null?void 0:{reasoning_tokens:t.reasoningTokens},...t?.cachedInputTokens==null?void 0:{cached_input_tokens:t.cachedInputTokens}}}):void 0;return{status:d,...n&&n.length>0?{toolCalls:n}:void 0,...a?.length?{totalSteps:a.length}:void 0,...o==null?void 0:{inputTokens:o},...s==null?void 0:{outputTokens:s},...c==null?void 0:{reasoningTokens:c},...l==null?void 0:{cachedInputTokens:l},...i==null?void 0:{outputText:i},...f?{metadata:f}:void 0,...m?{steps:m}:void 0,...p?{modelId:p}:void 0}}function PO(e){return e.toolCallId?e.type===`tool-call`||e.type===`dynamic-tool`?!!e.toolName:e.type.startsWith(`tool-`)||e.type.startsWith(`dynamic-tool-`):!1}function FO(e){return e.type===`dynamic-tool`||e.type.startsWith(`dynamic-tool-`)}function IO(e){let t=FO(e)?`mcp`:`frontend`;return TO({toolName:e.toolName??e.type.slice(5),toolCallId:e.toolCallId,args:e.args??e.input,result:e.result??e.output,toolSource:t})}function LO(e){let t=[],n=[],r=[],i=null;for(let a of e)if(a.type===`step-start`)i!==null&&r.push({tool_calls:i}),i=[];else if(a.type===`text`&&a.text)t.push(a.text);else if(PO(a)){let e=IO(a);n.push(e),i!==null&&i.push(e)}return i!==null&&r.push({tool_calls:i}),{textParts:t,toolCalls:n,stepsData:r}}function RO(e){if(!e)return;if(typeof e.modelId==`string`)return e.modelId;let t=e.custom;if(typeof t?.modelId==`string`)return t.modelId}function zO(e,t,n,r,i,a){let o=e.length>0,s=o?SO(e.join(``)):void 0,c=RO(r),l=i&&i.length>1?i.map(e=>({...e.tool_calls.length>0?{tool_calls:e.tool_calls}:void 0})):void 0;return{status:o?`completed`:`incomplete`,...t.length>0?{toolCalls:t}:void 0,...n>0?{totalSteps:n}:void 0,...a?.inputTokens==null?void 0:{inputTokens:a.inputTokens},...a?.outputTokens==null?void 0:{outputTokens:a.outputTokens},...a?.reasoningTokens==null?void 0:{reasoningTokens:a.reasoningTokens},...a?.cachedInputTokens==null?void 0:{cachedInputTokens:a.cachedInputTokens},...s==null?void 0:{outputText:s},...r?{metadata:r}:void 0,...l?{steps:l}:void 0,...c?{modelId:c}:void 0}}function BO(e){let t=e?.usage;if(t){let e=EO(t);if(e)return e}let n=e?.steps;if(n&&n.length>0){let e=0,t=0,r=0,i=0,a=!1,o=!1,s=!1,c=!1,l=!1;for(let u of n){if(!u.usage)continue;let n=EO(u.usage);n&&(n.inputTokens!=null&&(e+=n.inputTokens,a=!0),n.outputTokens!=null&&(t+=n.outputTokens,o=!0),n.reasoningTokens!=null&&(r+=n.reasoningTokens,s=!0),n.cachedInputTokens!=null&&(i+=n.cachedInputTokens,c=!0),l=!0)}if(l)return{...a?{inputTokens:e}:void 0,...o?{outputTokens:t}:void 0,...s?{reasoningTokens:r}:void 0,...c?{cachedInputTokens:i}:void 0}}}function VO(e){let t=e;if(t.role!==`assistant`)return null;let{textParts:n,toolCalls:r,stepsData:i}=LO(t.parts??[]);return zO(n,r,i.length,t.metadata,i,BO(t.metadata))}function HO(e){let t=[],n=[],r=[],i=!1,a,o=0,s=0,c=0,l=0,u=!1,d=!1,f=!1,p=!1;for(let m of e){let e=m;if(e.role!==`assistant`)continue;i=!0;let{textParts:h,toolCalls:g,stepsData:_}=LO(e.parts??[]);t.push(...h),n.push(...g),r.push(..._),e.metadata&&(a=e.metadata);let v=BO(e.metadata);v&&(v.inputTokens!=null&&(o+=v.inputTokens,u=!0),v.outputTokens!=null&&(s+=v.outputTokens,d=!0),v.reasoningTokens!=null&&(c+=v.reasoningTokens,f=!0),v.cachedInputTokens!=null&&(l+=v.cachedInputTokens,p=!0))}return i?zO(t,n,r.length,a,r,{...u?{inputTokens:o}:void 0,...d?{outputTokens:s}:void 0,...f?{reasoningTokens:c}:void 0,...p?{cachedInputTokens:l}:void 0}):null}function UO(e){let t=xx(),n=B(t);V(()=>{n.current=t});let[r]=Pv(()=>new OO(e,()=>n.current));return r}var WO=e=>e.startsWith(`image/`)?`image`:e.startsWith(`text/`)?`document`:`file`,GO=class{accept=`*`;getCloud;constructor(e){this.getCloud=typeof e==`function`?e:()=>e}uploadedUrls=new Map;async*add({file:e}){let t=jC(),n={id:t,type:WO(e.type),name:e.name,contentType:e.type,file:e,status:{type:`running`,reason:`uploading`,progress:0}};yield n;try{let{signedUrl:r,publicUrl:i}=await this.getCloud().files.generatePresignedUploadUrl({filename:e.name}),a=await fetch(r,{method:`PUT`,body:e,headers:{"Content-Type":e.type},mode:`cors`});if(!a.ok)throw Error(`Failed to upload file: ${a.status} ${a.statusText}`);this.uploadedUrls.set(t,i),n={...n,status:{type:`requires-action`,reason:`composer-send`}},yield n}catch(e){console.error(`[assistant-ui] Failed to upload attachment:`,e),n={...n,status:{type:`incomplete`,reason:`error`,message:e instanceof Error?e.message:String(e)}},yield n}}async remove(e){this.uploadedUrls.delete(e.id)}async send(e){let t=this.uploadedUrls.get(e.id);if(!t)throw Error(`Attachment not uploaded`);this.uploadedUrls.delete(e.id);let n;return n=e.type===`image`?[{type:`image`,image:t,filename:e.name}]:[{type:`file`,data:t,mimeType:e.contentType??``,filename:e.name}],{...e,status:{type:`complete`},content:n}}},KO=class{list(){return Promise.resolve({threads:[]})}rename(){return Promise.resolve()}updateCustom(){return Promise.resolve()}archive(){return Promise.resolve()}unarchive(){return Promise.resolve()}delete(){return Promise.resolve()}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){return Promise.resolve(new ReadableStream({start(e){e.close()}}))}fetch(e){return Promise.reject(Error(`Thread "${e}" not found in in-memory thread list.`))}},qO=e=>KS(e)?e:void 0,JO=typeof process<`u`&&{}.NEXT_PUBLIC_ASSISTANT_BASE_URL,YO=JO?new _O({baseUrl:JO,anonymous:!0}):void 0,XO=e=>{let t=UO(e),[n]=Pv(()=>new GO(()=>e.current));return Fv(()=>({history:t,attachments:n}),[t,n])},ZO=20,QO=e=>{let t={activeCursor:e,archivedCursor:void 0,activeExhausted:!1,archivedExhausted:!1};if(!e||!e.startsWith(`{`))return t;try{let n=JSON.parse(e);return KS(n)?{activeCursor:typeof n.a==`string`?n.a:void 0,archivedCursor:typeof n.r==`string`?n.r:void 0,activeExhausted:n.ae===!0,archivedExhausted:n.re===!0}:t}catch{return t}},$O=e=>{let t=typeof e==`function`?e:()=>e,n=function(){return XO({get current(){return t().cloud??YO}})},r=t().cloud??YO;if(!r){let e=new KO;return e.initialize=async e=>({remoteId:e,externalId:(await t().create?.())?.externalId}),e}return{list:async({after:e}={})=>{let{activeCursor:t,archivedCursor:n,activeExhausted:i,archivedExhausted:a}=QO(e),[{threads:o},{threads:s}]=await Promise.all([i?Promise.resolve({threads:[]}):r.threads.list({limit:ZO,...t?{after:t}:{}}),a?Promise.resolve({threads:[]}):r.threads.list({is_archived:!0,limit:ZO,...n?{after:n}:{}})]),c=!i&&o.length===ZO?o.at(-1)?.id:void 0,l=!a&&s.length===ZO?s.at(-1)?.id:void 0;return{threads:[...o,...s].map(e=>({status:e.is_archived?`archived`:`regular`,remoteId:e.id,title:e.title,lastMessageAt:e.last_message_at?new Date(e.last_message_at):void 0,externalId:e.external_id??void 0,custom:qO(e.metadata)})),nextCursor:c||l?JSON.stringify({a:c,r:l,...c===void 0?{ae:!0}:{},...l===void 0?{re:!0}:{}}):void 0}},initialize:async()=>{let e=await(t().create?.()??Promise.resolve()),n=e?e.externalId:void 0,{thread_id:i}=await r.threads.create({last_message_at:new Date,external_id:n});return{externalId:n,remoteId:i}},rename:async(e,t)=>r.threads.update(e,{title:t}),updateCustom:async(e,t)=>r.threads.update(e,{metadata:t??null}),archive:async e=>r.threads.update(e,{is_archived:!0}),unarchive:async e=>r.threads.update(e,{is_archived:!1}),delete:async e=>(await t().delete?.(e),r.threads.delete(e)),generateTitle:async(e,t)=>{let n=t.map(e=>({...e,content:e.content.filter(e=>e.type===`text`||e.type===`tool-call`)}));return r.runs.stream({thread_id:e,assistant_id:`system/thread_title`,messages:n})},fetch:async e=>{let t=await r.threads.get(e);return{status:t.is_archived?`archived`:`regular`,remoteId:t.id,title:t.title,lastMessageAt:t.last_message_at?new Date(t.last_message_at):void 0,externalId:t.external_id??void 0,custom:qO(t.metadata)}},unstable_useAdapters:n}},ek=e=>{let t=B(e);Vv(()=>{t.current=e},[e]);let n=e.cloud??YO,r=Fv(()=>$O(()=>({...t.current,cloud:n})),[n]),i=Fv(()=>({get current(){return t.current.cloud??YO}}),[]),a=Iv(function(){return XO(i)},[i]);return Fv(()=>r.unstable_useAdapters===void 0?r:{...r,unstable_useAdapters:a},[r,a])},tk=e=>{let t=z(6),{id:n,children:r}=e,i=xx(),a;t[0]===n?a=t[1]:(a=Qy({message:Ox({source:`thread`,query:{type:`id`,id:n},get:e=>e.thread.message({id:n})}),composer:Ox({source:`message`,query:{},get:e=>e.thread.message({id:n}).composer()})}),t[0]=n,t[1]=a);let o=a,s;return t[2]!==i||t[3]!==r||t[4]!==o?(s=(0,I.jsx)(BS,{extends:i,config:o,children:r}),t[2]=i,t[3]=r,t[4]=o,t[5]=s):s=t[5],s},nk=(e,t)=>e.Message===t.Message&&e.EditComposer===t.EditComposer&&e.UserEditComposer===t.UserEditComposer&&e.AssistantEditComposer===t.AssistantEditComposer&&e.SystemEditComposer===t.SystemEditComposer&&e.UserMessage===t.UserMessage&&e.AssistantMessage===t.AssistantMessage&&e.SystemMessage===t.SystemMessage,rk=()=>null,ik=new WeakMap,ak=(e,t)=>{let n=ik.get(e);return n||(n=new Set(e.map(e=>e.id)),ik.set(e,n)),n.has(t)},ok=(e,t,n)=>{switch(t){case`user`:return n?e.UserEditComposer??e.EditComposer??e.UserMessage??e.Message:e.UserMessage??e.Message;case`assistant`:return n?e.AssistantEditComposer??e.EditComposer??e.AssistantMessage??e.Message:e.AssistantMessage??e.Message;case`system`:return n?e.SystemEditComposer??e.EditComposer??e.SystemMessage??e.Message??rk:e.SystemMessage??e.Message??rk;default:throw Error(`Unknown message role: ${t}`)}},sk=e=>{let t=z(6),{components:n}=e,r=H(pk),i=H(mk),a;t[0]!==n||t[1]!==i||t[2]!==r?(a=ok(n,r,i),t[0]=n,t[1]=i,t[2]=r,t[3]=a):a=t[3];let o=a,s;return t[4]===o?s=t[5]:(s=(0,I.jsx)(o,{}),t[4]=o,t[5]=s),s},ck=Gv(e=>{let t=z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(sk,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(rT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&nk(e.components,t.components));ck.displayName=`ThreadPrimitive.MessageByIndex`;var lk=Gv(e=>{let t=z(7),{messageId:n,components:r}=e,i;if(t[0]===n?i=t[1]:(i=e=>ak(e.thread.messages,n),t[0]=n,t[1]=i),!H(i))return null;let a;t[2]===r?a=t[3]:(a=(0,I.jsx)(sk,{components:r}),t[2]=r,t[3]=a);let o;return t[4]!==n||t[5]!==a?(o=(0,I.jsx)(tk,{id:n,children:a}),t[4]=n,t[5]=a,t[6]=o):o=t[6],o},(e,t)=>e.messageId===t.messageId&&nk(e.components,t.components));lk.displayName=`ThreadPrimitive.Unstable_MessageById`;var uk=({children:e})=>{let t=H(e=>e.thread.messages.length);return Fv(()=>t===0?null:Array.from({length:t},(t,n)=>(0,I.jsx)(rT,{index:n,children:(0,I.jsx)(US,{getItemState:e=>e.thread.message({index:n}).getState(),children:t=>e({get message(){return t()}})})},n)),[t,e])},dk=e=>{let t=z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,I.jsx)(uk,{children:()=>(0,I.jsx)(sk,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,I.jsx)(uk,{children:r}),t[2]=r,t[3]=i),i};dk.displayName=`ThreadPrimitive.Messages`;var fk=Gv(dk,(e,t)=>e.children||t.children?e.children===t.children:nk(e.components,t.components));function pk(e){return e.message.role}function mk(e){return e.message.composer.isEditing}var hk=e=>{let t=e.message.metadata;if(t&&typeof t==`object`)return t.custom?.quote},gk=class extends Error{componentName;constructor(e,t=`Component "${e}" is not in the generative-ui allowlist.`){super(t),this.name=`GenerativeUIRenderError`,this.componentName=e}},_k=e=>typeof e==`object`&&!!e,vk=(e,t,n,r)=>{if(e==null)return null;if(typeof e==`string`)return e;if(!_k(e)||!(`component`in e)||typeof e.component!=`string`)return null;let{component:i,props:a,children:o,key:s}=e,c=t[i];if(!c){if(n)return(0,I.jsx)(n,{component:i,props:a},s??r);throw new gk(i)}let l=o?.length?o.map((e,i)=>vk(e,t,n,`${r}/${i}`)):void 0;return qv(c,{...a??{},key:s??r},...l??[])},yk=e=>{if(!e||e.root===void 0||e.root===null)return[];let t=e.root;return Array.isArray(t)?t:[t]},bk=e=>{let t=z(11),{spec:n,components:r,Fallback:i}=e,a;t[0]===n?a=t[1]:(a=yk(n),t[0]=n,t[1]=a);let o=a,s;if(t[2]!==i||t[3]!==r||t[4]!==o){let e;t[6]!==i||t[7]!==r?(e=(e,t)=>vk(e,r,i,`${t}`),t[6]=i,t[7]=r,t[8]=e):e=t[8],s=o.map(e),t[2]=i,t[3]=r,t[4]=o,t[5]=s}else s=t[5];let c;return t[9]===s?c=t[10]:(c=(0,I.jsx)(I.Fragment,{children:s}),t[9]=s,t[10]=c),c};bk.displayName=`GenerativeUIRender`;var xk=e=>{let t=z(4),{components:n,spec:r,Fallback:i}=e,a=H(Sk),o=r??a;if(!o)return null;let s;return t[0]!==i||t[1]!==n||t[2]!==o?(s=(0,I.jsx)(bk,{spec:o,components:n,Fallback:i}),t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3],s};xk.displayName=`MessagePrimitive.GenerativeUI`;function Sk(e){let t=e.part;return t?.type===`generative-ui`?t.spec:void 0}var Ck=e=>{let t=-1;return{startGroup:e=>{t===-1&&(t=e)},endGroup:(n,r)=>{t!==-1&&(r.push({type:e,startIndex:t,endIndex:n}),t=-1)},finalize:(n,r)=>{t!==-1&&r.push({type:e,startIndex:t,endIndex:n})}}},wk=(e,t,n)=>{let r=[];if(t){let t=Ck(`chainOfThoughtGroup`);for(let n=0;n<e.length;n++){let i=e[n];i===`tool-call`||i===`reasoning`?t.startGroup(n):(t.endGroup(n-1,r),r.push({type:`single`,index:n}))}t.finalize(e.length-1,r)}else{let t=Ck(`toolGroup`),n=Ck(`reasoningGroup`);for(let i=0;i<e.length;i++){let a=e[i];a===`tool-call`?(n.endGroup(i-1,r),t.startGroup(i)):a===`reasoning`?(t.endGroup(i-1,r),n.startGroup(i)):(t.endGroup(i-1,r),n.endGroup(i-1,r),r.push({type:`single`,index:i}))}t.finalize(e.length-1,r),n.finalize(e.length-1,r)}if(n){let e=new Set;for(let t of r){if(t.type===`single`)continue;let r=n[t.startIndex];r!==void 0&&!e.has(r)&&(e.add(r),t.idKey=`id:${r}`)}}return r},Tk=e=>{let t=z(10),n=H(ex(Yk)),r=H(ex(Zk)),i;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0];let n;t[1]===r?n=t[2]:(n={ranges:e,partIds:r},t[1]=r,t[2]=n),i=n;break bb0}let a;t[3]!==n||t[4]!==r||t[5]!==e?(a=wk(n,e,r),t[3]=n,t[4]=r,t[5]=e,t[6]=a):a=t[6];let o;t[7]!==r||t[8]!==a?(o={ranges:a,partIds:r},t[7]=r,t[8]=a,t[9]=o):o=t[9],i=o}return i},Ek=e=>{let t=z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=H(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,I.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},Dk=(e,t,n)=>e.renderers[t]?.[0]||(e.fallbacks[0]??n),Ok=e=>{let t=z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>Dk(e.dataRenderers,r.name,n),t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=H(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,I.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},kk={Text:()=>null,Reasoning:()=>null,Source:()=>null,Image:()=>null,File:()=>null,Unstable_Audio:()=>null,ToolGroup:({children:e})=>e,ReasoningGroup:({children:e})=>e},Ak=e=>{let t=z(41),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d,generativeUI:f}=r,p=i===void 0?kk.Text:i,m=a===void 0?kk.Reasoning:a,h=o===void 0?kk.Image:o,g=s===void 0?kk.Source:s,_=c===void 0?kk.File:c,v=l===void 0?kk.Unstable_Audio:l,y;t[2]===u?y=t[3]:(y=u===void 0?{}:u,t[2]=u,t[3]=y);let b=y,x=xx(),S=H(Qk),C=S.type;if(C===`tool-call`){let e=x.part.addToolResult,n=x.part.resumeToolCall,r=x.part.respondToToolApproval;if(`Override`in b){let i;return t[4]!==e||t[5]!==S||t[6]!==r||t[7]!==n||t[8]!==b.Override?(i=(0,I.jsx)(b.Override,{...S,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=S,t[6]=r,t[7]=n,t[8]=b.Override,t[9]=i):i=t[9],i}let i=b.by_name?.[S.toolName]??b.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==S||t[13]!==r||t[14]!==n?(a=(0,I.jsx)(Ek,{...S,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=S,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(S.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(C){case`text`:{let e;return t[16]!==p||t[17]!==S?(e=(0,I.jsx)(p,{...S}),t[16]=p,t[17]=S,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==m||t[20]!==S?(e=(0,I.jsx)(m,{...S}),t[19]=m,t[20]=S,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==g||t[23]!==S?(e=(0,I.jsx)(g,{...S}),t[22]=g,t[23]=S,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==h||t[26]!==S?(e=(0,I.jsx)(h,{...S}),t[25]=h,t[26]=S,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==_||t[29]!==S?(e=(0,I.jsx)(_,{...S}),t[28]=_,t[29]=S,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==v||t[32]!==S?(e=(0,I.jsx)(v,{...S}),t[31]=v,t[32]=S,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[S.name]??d?.Fallback,n;return t[34]!==e||t[35]!==S?(n=(0,I.jsx)(Ok,{...S,Fallback:e}),t[34]=e,t[35]=S,t[36]=n):n=t[36],n}case`generative-ui`:{if(!f?.components)return null;let e=S,n;return t[37]!==f.Fallback||t[38]!==f.components||t[39]!==e.spec?(n=(0,I.jsx)(bk,{spec:e.spec,components:f.components,Fallback:f.Fallback}),t[37]=f.Fallback,t[38]=f.components,t[39]=e.spec,t[40]=n):n=t[40],n}default:return console.warn(`Unknown message part type: ${C}`),null}},jk=Gv(e=>{let t=z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(Ak,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(iT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.generativeUI===t.components?.generativeUI&&e.components?.ToolGroup===t.components?.ToolGroup&&e.components?.ReasoningGroup===t.components?.ReasoningGroup);jk.displayName=`MessagePrimitive.PartByIndex`;var Mk=e=>{let t=z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,I.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,I.jsx)(aT,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},Nk=Object.freeze({type:`complete`}),Pk=Object.freeze({type:`running`}),Fk=Gv(e=>{let t=z(6),{components:n}=e,r=H($k);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,I.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}if(r.type!==`running`)return null;let i=n?.Text??kk.Text,a;return t[3]!==r||t[4]!==i?(a=(0,I.jsx)(Mk,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Ik=Gv(e=>{let t=z(4),{components:n,enabled:r}=e,i;if(t[0]===r?i=t[1]:(i=e=>{if(!r||e.message.parts.length===0)return!1;let t=e.message.parts[e.message.parts.length-1];return t?.type!==`text`&&t?.type!==`reasoning`},t[0]=r,t[1]=i),!H(i))return null;let a;return t[2]===n?a=t[3]:(a=(0,I.jsx)(Fk,{components:n}),t[2]=n,t[3]=a),a},(e,t)=>e.enabled===t.enabled&&e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),Lk=Gv(e=>{let t=z(4),{Quote:n}=e,r=H(hk);if(!r)return null;let i;return t[0]!==n||t[1]!==r.messageId||t[2]!==r.text?(i=(0,I.jsx)(n,{text:r.text,messageId:r.messageId}),t[0]=n,t[1]=r.messageId,t[2]=r.text,t[3]=i):i=t[3],i});function Rk(e,t){return(e.toolUIs[t.toolName]?.[0]?.render??null)||(VT(t.mcp?.app?.resourceUri)&&e.mcpApp?e.mcpApp.render:null)}var zk=()=>{let e=z(6),t=xx(),n=H(eA),r=H(tA);if(!r||n.type!==`tool-call`)return null;let i;return e[0]!==r||e[1]!==t.part.addToolResult||e[2]!==t.part.respondToToolApproval||e[3]!==t.part.resumeToolCall||e[4]!==n?(i=(0,I.jsx)(r,{...n,addResult:t.part.addToolResult,resume:t.part.resumeToolCall,respondToApproval:t.part.respondToToolApproval}),e[0]=r,e[1]=t.part.addToolResult,e[2]=t.part.respondToToolApproval,e[3]=t.part.resumeToolCall,e[4]=n,e[5]=i):i=e[5],i},Bk=()=>{let e=z(3),t=H(nA),n=H(rA);if(!n||t.type!==`data`)return null;let r=t,i;return e[0]!==n||e[1]!==r?(i=(0,I.jsx)(n,{...r}),e[0]=n,e[1]=r,e[2]=i):i=e[2],i},Vk=()=>{let e=z(2),t=H(iA);if(t===`tool-call`){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(zk,{}),e[0]=t):t=e[0],t}if(t===`data`){let t;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,I.jsx)(Bk,{}),e[1]=t):t=e[1],t}return null},Hk=Object.freeze({type:`text`,text:``,status:Pk}),Uk=({children:e})=>{let t=xx(),n=H(e=>e.dataRenderers);return(0,I.jsx)(US,{getItemState:e=>e.part.getState(),children:r=>e({get part(){let e=r();if(e.type===`tool-call`){let n=Rk(t.tools.getState(),e)!==null,r=t.part;return{...e,toolUI:n?(0,I.jsx)(zk,{}):null,addResult:r.addToolResult,resume:r.resumeToolCall,respondToApproval:r.respondToToolApproval}}if(e.type===`data`){let t=Dk(n,e.name,void 0)!==void 0;return{...e,dataRendererUI:t?(0,I.jsx)(Bk,{}):null}}return e}})})},Wk=e=>{let t=z(5),{index:n,children:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(Uk,{children:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(iT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},Gk=e=>{let t=z(9),{children:n}=e,r=H(aA),i=H(oA),a=r===0&&i;if(r===0){if(!a)return null;let e;t[0]===n?e=t[1]:(e=n({part:Hk}),t[0]=n,t[1]=e);let r;return t[2]===e?r=t[3]:(r=(0,I.jsx)(aT,{text:``,isRunning:!0,children:e}),t[2]=e,t[3]=r),r}let o;if(t[4]!==n||t[5]!==r){let e;t[7]===n?e=t[8]:(e=(e,t)=>(0,I.jsx)(Wk,{index:t,children:e=>n(e)??(0,I.jsx)(Vk,{})},t),t[7]=n,t[8]=e),o=(0,I.jsx)(I.Fragment,{children:Array.from({length:r},e)}),t[4]=n,t[5]=r,t[6]=o}else o=t[6];return o},Kk=e=>{let t=z(5),{components:n,unstable_showEmptyOnNonTextEnd:r,children:i}=e,a=r===void 0||r;if(i){let e;return t[0]===i?e=t[1]:(e=(0,I.jsx)(Gk,{children:i}),t[0]=i,t[1]=e),e}let o;return t[2]!==n||t[3]!==a?(o=(0,I.jsx)(qk,{components:n,unstable_showEmptyOnNonTextEnd:a}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o};Kk.displayName=`MessagePrimitive.Parts`;var qk=e=>{let t=z(15),{components:n,unstable_showEmptyOnNonTextEnd:r}=e,i=H(sA),{ranges:a,partIds:o}=Tk(!!n?.ChainOfThought),s;bb0:{if(i===0){let e;t[0]===n?e=t[1]:(e=(0,I.jsx)(Fk,{components:n}),t[0]=n,t[1]=e),s=e;break bb0}let e;if(t[2]!==n||t[3]!==a||t[4]!==o){let r=new Set,i=e=>{let t=o[e];return t!==void 0&&!r.has(t)?(r.add(t),`part-id:${t}`):`part-${e}`};e=a.map(e=>{if(e.type===`single`)return(0,I.jsx)(jk,{index:e.index,components:n},e.index);if(e.type===`chainOfThoughtGroup`){let t=n?.ChainOfThought;return t?(0,I.jsx)(gT,{startIndex:e.startIndex,endIndex:e.endIndex,children:(0,I.jsx)(t,{})},`chainOfThought-${e.idKey??e.startIndex}`):null}if(e.type===`toolGroup`){let t=n?.ToolGroup??kk.ToolGroup;return(0,I.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let a=e.startIndex+r;return(0,I.jsx)(jk,{index:a,components:n},i(a))})},`tool-${e.idKey??e.startIndex}`)}{let t=n?.ReasoningGroup??kk.ReasoningGroup;return(0,I.jsx)(t,{startIndex:e.startIndex,endIndex:e.endIndex,children:Array.from({length:e.endIndex-e.startIndex+1},(t,r)=>{let i=e.startIndex+r;return(0,I.jsx)(jk,{index:i,components:n},`part-${i}`)})},`reasoning-${e.startIndex}`)}}),t[2]=n,t[3]=a,t[4]=o,t[5]=e}else e=t[5];s=e}let c=s,l;t[6]===n?l=t[7]:(l=n?.Quote&&(0,I.jsx)(Lk,{Quote:n.Quote}),t[6]=n,t[7]=l);let u;t[8]!==n||t[9]!==r?(u=(0,I.jsx)(Ik,{components:n,enabled:r}),t[8]=n,t[9]=r,t[10]=u):u=t[10];let d;return t[11]!==c||t[12]!==l||t[13]!==u?(d=(0,I.jsxs)(I.Fragment,{children:[l,c,u]}),t[11]=c,t[12]=l,t[13]=u,t[14]=d):d=t[14],d};function Jk(e){return e.type}function Yk(e){return e.message.parts.map(Jk)}function Xk(e){return e.type===`tool-call`?e.toolCallId:void 0}function Zk(e){return e.message.parts.map(Xk)}function Qk(e){return e.part}function $k(e){return e.message.status??Nk}function eA(e){return e.part}function tA(e){return e.part.type===`tool-call`?Rk(e.tools,e.part):null}function nA(e){return e.part}function rA(e){return e.part.type===`data`?Dk(e.dataRenderers,e.part.name,void 0)??null:null}function iA(e){return e.part.type}function aA(e){return e.message.parts.length}function oA(e){return(e.message.status?.type??`complete`)===`running`}function sA(e){return e.message.parts.length}var cA=Symbol.for(`@assistant-ui/groupBy.memoKey`),lA=e=>{let t=e.nextChildIdx++;return e.nodeKey===``?String(t):`${e.nodeKey}.${t}`},uA=(e,t)=>{if(!(t===void 0||e.claimed.has(t)))return e.claimed.add(t),`id:${t}`},dA=(e,t)=>{let n={key:``,nodeKey:``,indices:[],children:[],nextChildIdx:0,claimed:new Set},r=[n],i=()=>{let e=r.pop(),n=r[r.length-1];n.children.push({type:`group`,key:e.key,nodeKey:e.nodeKey,idKey:uA(n,t?.[e.indices[0]]),indices:e.indices,children:e.children})};for(let n=0;n<e.length;n++){let a=e[n],o=0;for(;o<r.length-1&&o<a.length&&r[o+1].key===a[o];)o++;for(;r.length-1>o;)i();for(;r.length-1<a.length;){let e=r[r.length-1];r.push({key:a[r.length-1],nodeKey:lA(e),indices:[],children:[],nextChildIdx:0,claimed:new Set})}let s=r[r.length-1];s.children.push({type:`part`,index:n,nodeKey:lA(s),idKey:uA(s,t?.[n])});for(let e=1;e<r.length;e++)r[e].indices.push(n)}for(;r.length>1;)i();return n.children},fA=(e,t,n)=>{if(!n)return!1;switch(e){case`never`:return!1;case`always`:return!0;case`empty`:return t.length===0;case`no-text`:{let e=t[t.length-1];return e===void 0||e.type!==`text`&&e.type!==`reasoning`}}},pA=()=>{throw Error("MessagePrimitive.GroupedParts: rendered `children` under a leaf part. `children` is only meaningful for `group-…` cases — add a matching case for the part type or return `null` to skip it.")},mA=(e,t,n)=>{if(e.type===`part`)return(0,I.jsx)(Wk,{index:e.index,children:({part:e})=>n({part:e,children:(0,I.jsx)(pA,{})})},e.idKey?`part-${e.idKey}`:`part-${e.index}`);let r=mT(t,e.indices),i={type:e.key,status:r,indices:e.indices};return(0,I.jsx)(Kv,{children:n({part:i,children:(0,I.jsx)(I.Fragment,{children:e.children.map(e=>mA(e,t,n))})})},e.idKey??e.nodeKey)},hA=({groupBy:e,indicator:t=`no-text`,children:n})=>{let r=H(ex(e=>e.message.parts)),i=H(e=>e.tools.toolUIs),a=H(e=>t!==`never`&&e.message.status?.type===`running`),o=Fv(()=>{let t={toolUIs:i};return dA(r.map(n=>e(n,t)??[]),r.map(e=>e.type===`tool-call`?e.toolCallId:void 0))},[r,e[cA]??e,i]);return(0,I.jsxs)(I.Fragment,{children:[o.map(e=>mA(e,r,n)),fA(t,r,a)&&n({part:{type:`indicator`},children:(0,I.jsx)(pA,{})})]})};hA.displayName=`MessagePrimitive.GroupedParts`;var gA=Gv(e=>{let t=z(5),{children:n}=e,r=H(hk);if(!r)return null;let i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a;return t[3]===i?a=t[4]:(a=(0,I.jsx)(I.Fragment,{children:i}),t[3]=i,t[4]=a),a});gA.displayName=`MessagePrimitive.Quote`;var _A=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},vA=e=>{let t=z(5),{components:n}=e,r=H(SA);if(!r)return null;let i=r,a;t[0]!==n||t[1]!==i?(a=_A(n,i),t[0]=n,t[1]=i,t[2]=a):a=t[2];let o=a;if(!o)return null;let s;return t[3]===o?s=t[4]:(s=(0,I.jsx)(o,{}),t[3]=o,t[4]=s),s},yA=Gv(e=>{let t=z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(vA,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(tT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);yA.displayName=`MessagePrimitive.AttachmentByIndex`;var bA=({children:e})=>{let t=H(ex(e=>e.message.role===`user`?(e.message.attachments??[]).map(e=>e.id):[]));return Fv(()=>t.map((t,n)=>(0,I.jsx)(tT,{index:n,children:(0,I.jsx)(US,{getItemState:e=>e.message.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},xA=e=>{let t=z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,I.jsx)(bA,{children:e=>{let{attachment:t}=e,r=_A(n,t);return r?(0,I.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,I.jsx)(bA,{children:r}),t[2]=r,t[3]=i),i};xA.displayName=`MessagePrimitive.Attachments`;function SA(e){return e.attachment}var CA=(e,t)=>{switch(t.type){case`image`:return e?.Image??e?.Attachment;case`document`:return e?.Document??e?.Attachment;case`file`:return e?.File??e?.Attachment;default:return e?.Attachment}},wA=e=>{let t=z(5),{components:n}=e,r=H(OA);if(!r)return null;let i;t[0]!==r||t[1]!==n?(i=CA(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i;if(!a)return null;let o;return t[3]===a?o=t[4]:(o=(0,I.jsx)(a,{}),t[3]=a,t[4]=o),o},TA=Gv(e=>{let t=z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(wA,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(nT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components?.Image===t.components?.Image&&e.components?.Document===t.components?.Document&&e.components?.File===t.components?.File&&e.components?.Attachment===t.components?.Attachment);TA.displayName=`ComposerPrimitive.AttachmentByIndex`;var EA=({children:e})=>{let t=H(ex(e=>e.composer.attachments.map(e=>e.id)));return Fv(()=>t.map((t,n)=>(0,I.jsx)(nT,{index:n,children:(0,I.jsx)(US,{getItemState:e=>e.composer.attachment({index:n}).getState(),children:t=>e({get attachment(){return t()}})})},t)),[t,e])},DA=e=>{let t=z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,I.jsx)(EA,{children:e=>{let{attachment:t}=e,r=CA(n,t);return r?(0,I.jsx)(r,{}):null}}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,I.jsx)(EA,{children:r}),t[2]=r,t[3]=i),i};DA.displayName=`ComposerPrimitive.Attachments`;function OA(e){return e.attachment}var kA=Gv(({children:e})=>{let t=H(ex(e=>e.composer.queue.map(e=>e.id)));return Fv(()=>t.map((t,n)=>(0,I.jsx)(yT,{index:n,children:(0,I.jsx)(US,{getItemState:e=>e.composer.queueItem({index:n}).getState(),children:t=>e({get queueItem(){return t()}})})},t)),[t,e])});kA.displayName=`ComposerPrimitive.Queue`;var AA=()=>H(NA),jA=e=>{let t=z(10),{components:n,children:r}=e,i=AA();if(!i?.length)return null;if(n){let e;t[0]===n?e=t[1]:(e=(0,I.jsx)(dk,{components:n}),t[0]=n,t[1]=e);let r;return t[2]!==i||t[3]!==e?(r=(0,I.jsx)(sE,{messages:i,children:e}),t[2]=i,t[3]=e,t[4]=r):r=t[4],r}let a;t[5]===r?a=t[6]:(a=(0,I.jsx)(dk,{children:r}),t[5]=r,t[6]=a);let o;return t[7]!==i||t[8]!==a?(o=(0,I.jsx)(sE,{messages:i,children:a}),t[7]=i,t[8]=a,t[9]=o):o=t[9],o};jA.displayName=`PartPrimitive.Messages`;var MA=Gv(jA);function NA(e){let t=e.part;if(t.type===`tool-call`)return`messages`in t?t.messages:void 0}var PA=e=>{let{children:t}=e;return H(FA)?t:null};PA.displayName=`MessagePartPrimitive.InProgress`;function FA(e){return e.part.status.type===`running`}var IA=e=>{let t=z(2),{components:n}=e,r=n.Suggestion,i;return t[0]===r?i=t[1]:(i=(0,I.jsx)(r,{}),t[0]=r,t[1]=i),i},LA=Gv(e=>{let t=z(5),{index:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(IA,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(vT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.index===t.index&&e.components.Suggestion===t.components.Suggestion);LA.displayName=`ThreadPrimitive.SuggestionByIndex`;var RA=({children:e})=>{let t=H(e=>e.suggestions.suggestions.length);return Fv(()=>t===0?null:Array.from({length:t},(t,n)=>(0,I.jsx)(vT,{index:n,children:(0,I.jsx)(US,{getItemState:e=>e.suggestions.suggestion({index:n}).getState(),children:t=>e({get suggestion(){return t()}})})},n)),[t,e])},zA=e=>{let t=z(4),{components:n,children:r}=e;if(n){let e;return t[0]===n?e=t[1]:(e=(0,I.jsx)(RA,{children:()=>(0,I.jsx)(IA,{components:n})}),t[0]=n,t[1]=e),e}let i;return t[2]===r?i=t[3]:(i=(0,I.jsx)(RA,{children:r}),t[2]=r,t[3]=i),i};zA.displayName=`ThreadPrimitive.Suggestions`;var BA=Gv(zA,(e,t)=>e.children||t.children?e.children===t.children:e.components.Suggestion===t.components.Suggestion),VA=e=>{let t=z(3),n;return t[0]!==e.dictation||t[1]!==e.editing?(n=t=>{if(e.editing===!0&&!t.composer.isEditing||e.editing===!1&&t.composer.isEditing)return!1;let n=t.composer.dictation!=null;return!(e.dictation===!0&&!n||e.dictation===!1&&n)},t[0]=e.dictation,t[1]=e.editing,t[2]=n):n=t[2],H(n)},HA=e=>{let t=z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),VA(r)?n:null};HA.displayName=`ComposerPrimitive.If`;var UA=e=>!e.composer.canSend||e.thread.isRunning&&!e.thread.capabilities.queue,WA=e=>!e.composer.canCancel,GA=e=>e.thread.isRunning||e.thread.isDisabled||e.message.role!==`assistant`,KA=e=>e.message.role===`assistant`&&e.message.status?.type===`running`||!e.message.parts.some(e=>e.type===`text`&&e.text.length>0),qA=(e,t)=>e.thread.isDisabled||t&&e.thread.isRunning&&!e.thread.capabilities.queue,JA=e=>{if(e.message.status?.type!==`incomplete`||e.message.status.reason!==`error`)return;let t=e.message.status.error;return typeof t==`string`?t:typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:t??`An error occurred`},YA=()=>{let e=z(5),t=xx(),n=H(UA),r;e[0]===t?r=e[1]:(r=e=>{t.composer.send(e)},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={send:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},XA=()=>{let e=z(5),t=xx(),n=H(WA),r;e[0]===t?r=e[1]:(r=()=>{t.composer.cancel()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={cancel:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a},ZA=()=>{let e=z(5),t=xx(),n=H(QA),r;e[0]===t?r=e[1]:(r=()=>{t.composer.startDictation()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={startDictation:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a};function QA(e){return e.composer.dictation!=null||!e.thread.capabilities.dictation||!e.composer.isEditing}var $A=()=>{let e=z(5),t=xx(),n=H(ej),r;e[0]===t?r=e[1]:(r=e=>t.composer.addAttachment(e),e[0]=t,e[1]=r);let i=r,a;return e[2]!==i||e[3]!==n?(a={addAttachment:i,disabled:n},e[2]=i,e[3]=n,e[4]=a):a=e[4],a};function ej(e){return!e.composer.isEditing}var tj=e=>{let t=z(15),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{copiedDuration:r,copyToClipboard:i}=n,a=r===void 0?3e3:r,o=xx(),s=H(KA),c=H(nj),l=H(rj),u=H(ij),d=B(void 0),f=B(0),p,m;t[2]===o?(p=t[3],m=t[4]):(p=()=>()=>{f.current+=1,d.current!==void 0&&(clearTimeout(d.current),d.current=void 0,o.message.setIsCopied(!1))},m=[o],t[2]=o,t[3]=p,t[4]=m),V(p,m);let h;t[5]!==o||t[6]!==u||t[7]!==a||t[8]!==i||t[9]!==l?(h=()=>{if(!i)return;let e=l?u:o.message.getCopyText();if(!e)return;let t=f.current,n;try{n=i(e)}catch{return}Promise.resolve(n).then(()=>{t===f.current&&(d.current!==void 0&&clearTimeout(d.current),o.message.setIsCopied(!0),d.current=setTimeout(()=>{d.current=void 0,o.message.setIsCopied(!1)},a))},aj)},t[5]=o,t[6]=u,t[7]=a,t[8]=i,t[9]=l,t[10]=h):h=t[10];let g=h,_=s||!i,v;return t[11]!==g||t[12]!==c||t[13]!==_?(v={copy:g,disabled:_,isCopied:c},t[11]=g,t[12]=c,t[13]=_,t[14]=v):v=t[14],v};function nj(e){return e.message.isCopied}function rj(e){return e.composer.isEditing}function ij(e){return e.composer.text}function aj(){}var oj=()=>{let e=z(5),t=xx(),n=H(GA),r;e[0]===t?r=e[1]:(r=()=>{t.message.reload()},e[0]=t,e[1]=r);let i=r,a;return e[2]!==n||e[3]!==i?(a={reload:i,disabled:n},e[2]=n,e[3]=i,e[4]=a):a=e[4],a},sj=e=>{let t=z(10),{prompt:n,send:r,clearComposer:i}=e,a=i===void 0||i,o=xx(),s=r??!1,c;t[0]===s?c=t[1]:(c=e=>qA(e,s),t[0]=s,t[1]=c);let l=H(c),u;t[2]!==o||t[3]!==a||t[4]!==n||t[5]!==s?(u=()=>{if(s){let{isRunning:e,capabilities:t}=o.thread.getState();if(e&&!t.queue)return;o.thread.append({content:[{type:`text`,text:n}],runConfig:o.composer.getState().runConfig}),a&&!e&&o.composer.setText(``)}else if(a)o.composer.setText(n);else{let e=o.composer.getState().text;o.composer.setText([e,n].filter(cj).join(` `))}},t[2]=o,t[3]=a,t[4]=n,t[5]=s,t[6]=u):u=t[6];let d=u,f;return t[7]!==l||t[8]!==d?(f={trigger:d,disabled:l},t[7]=l,t[8]=d,t[9]=f):f=t[9],f};function cj(e){return e.trim()}var lj=()=>H(JA),uj=async(e,t)=>{let{signal:n,onUpdate:r}=t;if(Symbol.asyncIterator in e)for await(let t of e){if(n.aborted)break;r(t)}else{let t=await e;if(n.aborted)return;r(t)}},dj=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},fj=e=>{let t={queue:NE,steer:NE},n=new Map,r=new Set,i=!1,a=!1,o=e=>e,s=0,c=0,l=!1,u=()=>{Zy(r,void 0,`Message queue`)},d=e=>{t=e,C.items=e.queue,C.steerItems=e.steer,u()},f=(e,t)=>({id:e,prompt:zT(t),parts:dj(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=jC();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:NE,steer:NE})},subscribe:e=>(r.add(e),()=>{r.delete(e)})}},pj=(e,t)=>e.status?.type!==`requires-action`||e.status.reason!==`tool-calls`||e.content.some(e=>e.type===`tool-call`&&e.result===void 0&&e.approval!==void 0&&e.approval.approved===void 0&&e.approval.resolution===void 0)?!1:t===void 0?e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0):e.content.every(e=>e.type!==`tool-call`||e.result!==void 0||e.approval!==void 0||!t.includes(e.toolName)),mj=class extends Error{name=`AbortError`;detach;constructor(e,t){super(t),this.detach=e}},hj=e=>e.role!==`assistant`||e.status.type!==`requires-action`||e.status.reason!==`interrupt`||e.content.some(e=>e.type===`tool-call`&&e.result===void 0&&e.interrupt!=null)?e:{...e,status:VC(!1,!1,!1,e.content.some(e=>e.type===`tool-call`&&e.result===void 0))},gj=e=>({...e,messages:e.messages.map(e=>({...e,message:hj(e.message)}))}),_j=class extends JE{capabilities={switchToBranch:!0,switchBranchDuringRun:!0,edit:!0,delete:!1,reload:!0,refetchThread:!1,cancel:!0,unstable_copy:!0,speech:!1,dictation:!1,voice:!1,attachments:!1,feedback:!1,queue:!1};abortController=null;_queue=null;_queueRunInFlight=!1;_activeRun=null;_runGeneration=0;_historyWrites=new Map;_chainHistoryWrite(e,t){let n=(this._historyWrites.get(e)??Promise.resolve()).then(t,t),r=n.then(()=>{},()=>{});return this._historyWrites.set(e,r),r.then(()=>{this._historyWrites.get(e)===r&&this._historyWrites.delete(e)}),n}_persistPausedMessage(e,t){if(t.status?.type!==`requires-action`)return;let n=this._options.adapters.history;if(!n?.update)return;let r=n.update.bind(n),i={parentId:e,message:t,runConfig:this._lastRunConfig};this._chainHistoryWrite(t.id,()=>r(i)).catch(()=>{})}isDisabled=!1;isSendDisabled=!1;_isLoading=!1;get isLoading(){return this._isLoading}_suggestions=[];_suggestionsController=null;get suggestions(){return this._suggestions}get adapters(){return this._options.adapters}constructor(e,t){super(e),this.__internal_setOptions(t)}_options;_lastRunConfig={};_getThreadId;__internal_setGetThreadId(e){this._getThreadId=e}_getInitializePromise;__internal_setGetInitializePromise(e){this._getInitializePromise=e}get extras(){}__internal_setOptions(e){if(this._options===e)return;let t=this._options?.adapters.history;this._options=e;let n=!1,r=e.adapters?.speech!==void 0;this.capabilities.speech!==r&&(this.capabilities.speech=r,n=!0);let i=e.adapters?.dictation!==void 0;this.capabilities.dictation!==i&&(this.capabilities.dictation=i,n=!0);let a=e.adapters?.voice!==void 0;this.capabilities.voice!==a&&(this.capabilities.voice=a,n=!0);let o=e.adapters?.attachments!==void 0;this.capabilities.attachments!==o&&(this.capabilities.attachments=o,n=!0);let s=e.adapters?.feedback!==void 0;this.capabilities.feedback!==s&&(this.capabilities.feedback=s,n=!0);let c=e.adapters?.history?.delete!==void 0;this.capabilities.delete!==c&&(this.capabilities.delete=c,n=!0);let l=e.unstable_enableMessageQueue===!0;l&&!this._queue?(this._queue=fj({run:e=>{this._queueRunInFlight=!0;let t=this._runGeneration;this._runAppend({...e,parentId:this.messages.at(-1)?.id??null}).finally(()=>{this._queueRunInFlight=!1,this._runGeneration===t&&this._queue?.notifyIdle()}).catch(()=>{})}}),this._queue.subscribe(()=>this._notifySubscribers())):!l&&this._queue&&(this._queue=null),this.capabilities.queue!==l&&(this.capabilities.queue=l,n=!0),n&&this._notifySubscribers(),this._loadRequested&&!this._loadPromise&&!t&&e.adapters.history&&this.messages.length===0&&this.__internal_load().catch(e=>{console.error(`[assistant-ui] local thread history load failed:`,e)})}_loadPromise;_loadRequested=!1;__internal_load(){if(this._loadRequested=!0,this._loadPromise)return this._loadPromise;if(!this.adapters.history)return Promise.resolve();let e=this.adapters.history.load();return this._isLoading=!0,this._notifySubscribers(),this._loadPromise=e.then(e=>{if(!e)return;this.repository.import(gj(e)),e.messages.length>0&&this.ensureInitialized(),this._notifySubscribers();let t=this.adapters.history?.resume?.bind(this.adapters.history);e.unstable_resume&&t&&this.startRun({parentId:this.repository.headId,sourceId:this.repository.headId,runConfig:this._lastRunConfig},t).catch(()=>{})}).finally(()=>{this._isLoading=!1,this._notifySubscribers()}),this._loadPromise}async append(e){let t=e.parentId===(this.messages.at(-1)?.id??null),n=e.startRun??e.role===`user`;if(this._queue&&n&&t){e.steer??this._queueRunInFlight?this._queue.adapter.steer(e):this._queue.adapter.enqueue(e);return}return this._queue&&!t&&(this._options.unstable_queueClearOnRewind??!0)&&this._queue.clear(),this._runAppend(e)}getQueueItems(){return this._queue?.adapter.items??NE}getSteerQueueItems(){return this._queue?.adapter.steerItems??NE}moveQueueItem(e,t){this._queue?.adapter.move(e,t)}removeQueueItem(e){this._queue?.adapter.remove(e)}_rollbackAppend(e){try{this.repository.deleteMessage(e)}catch{return}this._notifySubscribers()}async _runAppend(e){let t=vE(this),n=this.enrichAppendMetadata(e);this.ensureInitialized();let r=IC(n,jC(),{type:`complete`,reason:`unknown`});this.repository.addOrUpdateMessage(n.parentId,r),this._notifySubscribers();try{let e=this._getInitializePromise?.();e&&await e}catch(e){if(this._rollbackAppend(r.id),!yE(this,t))return;let n=new wT;throw n.cause=e,n}if(!yE(this,t)){this._rollbackAppend(r.id);return}let i=this._options.adapters.history?.append({parentId:n.parentId,message:r,...n.runConfig!==void 0&&{runConfig:n.runConfig}});if(i?.catch(()=>{}),n.startRun??n.role===`user`){let[e,t]=await Promise.allSettled([this.startRun({parentId:r.id,sourceId:n.sourceId,runConfig:n.runConfig??{}}),i]);if(e.status===`rejected`)throw e.reason;if(t.status===`rejected`)throw t.reason}else this.repository.resetHead(r.id),this._notifySubscribers(),await i}async deleteMessage(e){let t=this._options.adapters.history;if(!t?.delete)throw Error(`Runtime does not support deleting messages.`);let n=this.repository.getMessages(),r=n.findIndex(t=>t.id===e);if(r===-1)throw Error(`Message not found.`);let i=n[r],a=[{parentId:n[r-1]?.id??null,message:i}];await t.delete(a),this.repository.deleteMessage(e),this._notifySubscribers()}resumeRun({stream:e,...t}){if(!e)throw Error(`You must pass a stream parameter to resume runs.`);return this.startRun(t,e)}exportExternalState(){throw Error(`Runtime does not support exporting external states.`)}import(e){super.import(gj(e))}importExternalState(){throw Error(`Runtime does not support importing external states.`)}unstable_notifySessionReset(){throw Error(`Runtime does not support resetting sessions.`)}async startRun({parentId:e,runConfig:t},n){this.ensureInitialized();let r={id:jC(),role:`assistant`,status:{type:`running`},content:[],metadata:{unstable_state:this.state,unstable_annotations:[],unstable_data:[],steps:[],custom:{}},createdAt:new Date};return this._runLoop(e,r,t,n)}async _runLoop(e,t,n,r){this._notifyEventSubscribers(`runStart`,{});let i=t.status?.type===`requires-action`&&this._options.adapters.history?.update!==void 0,a={cancelled:!1};this._activeRun=a,this._runGeneration++;let o=!1;try{this._queue?.notifyBusy(),this._suggestions=[],this._suggestionsController?.abort(),this._suggestionsController=null,this._notifySubscribers();do if(t=await this.performRoundtrip(e,t,n,i,a,r),r=void 0,this._activeRun!==a)break;while(pj(t,this._options.unstable_humanToolNames))}finally{this._notifyEventSubscribers(`runEnd`,{}),o=this._activeRun===a,o&&(this._activeRun=null),(o||a.cancelled)&&queueMicrotask(()=>this._queue?.notifyIdle())}if(o&&this.adapters.suggestion&&t.status?.type!==`requires-action`){this._suggestionsController=new AbortController;let e=this._suggestionsController.signal,t=this.adapters.suggestion;(async()=>{try{await uj(t.generate({messages:this.messages,signal:e}),{signal:e,onUpdate:e=>{this._suggestions=e,this._notifySubscribers()}})}catch{}})()}}async performRoundtrip(e,t,n,r,i,a){let o=e?this.repository.getMessages(e):[];this.abortController?.abort();let s=new AbortController;this.abortController=s;let c=t.content,l=t.metadata?.unstable_annotations,u=t.metadata?.unstable_data,d=t.metadata?.steps,f=t.metadata?.custom,p=!0;try{this.repository.getMessage(t.id)}catch{p=!1}let m=()=>{if(!p)return this._activeRun===i;try{return this.repository.getMessage(t.id).message===t}catch{return!1}},h=n=>{if(!m())return;let r=n.metadata?.steps,i=r?[...d??[],...r]:void 0,a=n.metadata?.unstable_annotations,o=n.metadata?.unstable_data,s=a?[...l??[],...a]:void 0,h=o?[...u??[],...o]:void 0;t={...t,...n.content?{content:[...c,...n.content??[]]}:void 0,status:n.status??t.status,...n.metadata?{metadata:{...t.metadata,...n.metadata.unstable_state===void 0?void 0:{unstable_state:n.metadata.unstable_state},...s?{unstable_annotations:s}:void 0,...h?{unstable_data:h}:void 0,...i?{steps:i}:void 0,...n.metadata?.timing?{timing:n.metadata.timing}:void 0,...n.metadata?.custom?{custom:{...f??{},...n.metadata.custom}}:void 0}}:void 0},this.repository.addOrUpdateMessage(e,t),p=!0,this._notifySubscribers()},g=this._options.maxSteps??2;try{if((t.metadata?.steps?.length??0)>=g)return h({status:{type:`incomplete`,reason:`tool-calls`}}),t;h({status:{type:`running`}}),this.repository.resetHead(t.id),this._notifySubscribers(),this._lastRunConfig=n??{};let{unstable_composerMetadata:r,...c}=this.getModelContext();a??=this.adapters.chatModel.run.bind(this.adapters.chatModel);let l=s.signal,u=()=>l.aborted&&(t.status.type===`running`||t.status.type===`requires-action`&&(this._activeRun!==i||pj(t,this._options.unstable_humanToolNames))),d=this._getThreadId?.(),f=a({messages:o,runConfig:this._lastRunConfig,abortSignal:l,context:c,unstable_assistantMessageId:t.id,unstable_threadId:d,unstable_parentId:e,unstable_getMessage(){return t}});if(Symbol.asyncIterator in f)for await(let e of f){if(l.aborted){u()&&h({status:{type:`incomplete`,reason:`cancelled`}});break}h(e)}else h(await f);u()?h({status:{type:`incomplete`,reason:`cancelled`}}):t.status.type===`running`&&h({status:{type:`complete`,reason:`unknown`}})}catch(e){if(e instanceof mj)h({status:{type:`incomplete`,reason:`cancelled`}});else if(e instanceof Error&&e.name===`AbortError`)h({status:{type:`incomplete`,reason:`cancelled`}});else throw h({status:{type:`incomplete`,reason:`error`,error:ET(e)}}),e}finally{this.abortController===s&&(this.abortController=null);let n=this._options.adapters.history,i={parentId:e,message:t,runConfig:this._lastRunConfig},a=t.status.type===`complete`||t.status.type===`incomplete`,o=t.status.type===`requires-action`&&!pj(t,this._options.unstable_humanToolNames);if(m()&&(a||o&&n?.update)){let e=r&&n?.update?n.update.bind(n):n?.append.bind(n);e&&await this._chainHistoryWrite(t.id,()=>e(i))}}return t}detach(){bE(this),this._queue=null;let e=new mj(!0);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}cancelRun(){this._queue&&(this._options.unstable_queueClearOnCancel??!0?this._queue.clear():(this._queue.notifyCancelled(),this._activeRun&&(this._activeRun.cancelled=!0)));let e=new mj(!1);this.abortController?.abort(e),this.abortController=null,this._suggestionsController?.abort(),this._suggestionsController=null}addToolResult({messageId:e,toolCallId:t,result:n,isError:r,artifact:i}){let a=this.repository.getMessage(e),{parentId:o}=a,{message:s}=a;if(s.role!==`assistant`)throw Error(`Tried to add tool result to non-assistant message`);let c=!1,l=!1,u=s.content.map(e=>e.type!==`tool-call`||e.toolCallId!==t?e:(l=!0,e.result===void 0&&(c=!0),{...e,result:n,artifact:i,isError:r}));if(!l)throw Error(`Tried to add tool result to non-existing tool call`);s={...s,content:u},this.repository.addOrUpdateMessage(o,s),this._notifySubscribers(),c&&pj(s,this._options.unstable_humanToolNames)?this._runLoop(o,s,this._lastRunConfig).catch(()=>{}):c&&this._persistPausedMessage(o,s)}resumeToolCall(e){throw Error(`Local runtime does not support resuming tool calls. For human-in-the-loop tools, list the tool in unstable_humanToolNames and complete the call with addToolResult.`)}respondToToolApproval({approvalId:e,approved:t,optionId:n,text:r,reason:i}){let a=this.repository.getMessages().findLast(t=>t.role===`assistant`&&t.content.some(t=>t.type===`tool-call`&&t.approval?.id===e));if(!a)throw Error(`Tried to respond to a non-existing tool approval`);if(this.abortController!==null)throw Error(`Tried to respond to a tool approval while a run is in progress`);if(a.status?.type!==`requires-action`)throw Error(`Tried to respond to a tool approval on a message whose status is not requires-action`);let o=a.content.find(t=>t.type===`tool-call`&&t.approval?.id===e);if(o?.type!==`tool-call`||!o.approval)throw Error(`Tried to respond to a non-existing tool approval`);if(o.approval.resolution!==void 0)throw Error(`Tried to respond to a tool approval that was cancelled or expired`);if(o.approval.approved!==void 0)throw Error(`Tried to respond to an already decided tool approval`);let s=o.approval,c=a.content.map(e=>{if(e!==o)return e;let a={...s,approved:t,...n!=null&&{optionId:n},...r!=null&&{text:r},...i!=null&&{reason:i}};return t?{...e,approval:a}:{...e,approval:a,result:{error:i||`Tool approval denied`},isError:!0}});a={...a,content:c};let{parentId:l}=this.repository.getMessage(a.id);return this.repository.addOrUpdateMessage(l,a),this._notifySubscribers(),this.repository.headId===a.id&&pj(a,this._options.unstable_humanToolNames)?this._runLoop(l,a,this._lastRunConfig).catch(()=>{}):this._persistPausedMessage(l,a),Promise.resolve()}},vj=Object.freeze([]),yj=`__DEFAULT_ID__`,bj=Object.freeze({[yj]:{id:yj,remoteId:void 0,externalId:void 0,status:`regular`,title:void 0}}),xj=class extends Bx{_mainThread;constructor(e){super(),this._mainThread=e()}get isLoading(){return!1}getMainThreadRuntimeCore(){return this._mainThread}get newThreadId(){}get threadIds(){return vj}get archivedThreadIds(){return vj}get mainThreadId(){return yj}get threadItems(){return bj}getThreadRuntimeCore(){throw Error(`Method not implemented.`)}getLoadThreadsPromise(){return Promise.resolve()}getItemById(e){if(e===this.mainThreadId)return{status:`regular`,id:this.mainThreadId,remoteId:this.mainThreadId,externalId:void 0,title:void 0,isMain:!0};throw Error(`Method not implemented`)}async switchToThread(){throw Error(`Method not implemented.`)}switchToNewThread(){throw Error(`Method not implemented.`)}rename(){throw Error(`Method not implemented.`)}archive(){throw Error(`Method not implemented.`)}detach(){throw Error(`Method not implemented.`)}unarchive(){throw Error(`Method not implemented.`)}delete(){throw Error(`Method not implemented.`)}initialize(e){return Promise.resolve({remoteId:e,externalId:void 0})}generateTitle(){throw Error(`Method not implemented.`)}},Sj=class extends xE{threads;Provider=void 0;_options;constructor(e,t){super(),this._options=e,this.threads=new xj(()=>new _j(this._contextProvider,this._options)),t&&this.threads.getMainThreadRuntimeCore().import(kE.fromArray(t))}},Cj=(e,{initialMessages:t,...n})=>{let{modelContext:r,...i}=wC()??{},a={...n,adapters:{...i,...n.adapters,chatModel:e}},[o]=Pv(()=>new Sj(a,t)),s=B(void 0),c=B(void 0);return s.current=H(e=>e.threadListItem.remoteId),V(()=>{o.threads.getMainThreadRuntimeCore().__internal_setGetThreadId(()=>s.current)},[o]),V(()=>()=>{o.threads.getMainThreadRuntimeCore().detach()},[o]),V(()=>{o.threads.getMainThreadRuntimeCore().__internal_setOptions(a)}),V(()=>{let e=o.threads.getMainThreadRuntimeCore().__internal_load();c.current!==e&&(c.current=e,e.catch(e=>{console.error(`[assistant-ui] local thread history load failed:`,e)}))},[o]),V(()=>{if(r)return o.registerModelContextProvider(r)},[r,o]),Fv(()=>new gE(o),[o])},wj=(e,{cloud:t,...n}={})=>BD({runtimeHook:function(){return Cj(e,n)},adapter:ek({cloud:t}),allowNesting:!0});function Tj(e,t){function n(n){let r=Qv(e);if(!n?.optional&&!r)throw Error(`This component must be used within ${t}.`);return r}return n}function Ej(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 Dj=Xv(null),{useThreadViewport:Oj,useThreadViewportStore:kj}=Ej(Tj(Dj,`ThreadPrimitive.Viewport`),`useThreadViewport`),Aj=(e,t,n)=>{if(Array.isArray(e))return e.map((e,r)=>Aj(e,`${t}[${r}]`,n));if(e&&typeof e==`object`){let r=e,i=Object.keys(r),a=n.get(t)??[],o=new Set(a),s=[...a.filter(e=>Object.hasOwn(r,e)),...i.filter(e=>!o.has(e))];return n.set(t,s),Object.fromEntries(s.map(e=>[e,Aj(r[e],`${t}.${JSON.stringify(e)}`,n)]))}return e},jj=(e,t)=>{let n=e?.get(t)??new Map;return e?.set(t,n),n},Mj=(e,t,n)=>{let r=Aj(n,`$`,jj(e,t));return JSON.stringify(r)},Nj=[{mediaType:`image/gif`,prefix:[71,73,70]},{mediaType:`image/png`,prefix:[137,80,78,71]},{mediaType:`image/jpeg`,prefix:[255,216]},{mediaType:`image/webp`,prefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,prefix:[66,77]},{mediaType:`image/tiff`,prefix:[73,73,42,0]},{mediaType:`image/tiff`,prefix:[77,77,0,42]},{mediaType:`image/avif`,prefix:[null,null,null,null,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,prefix:[null,null,null,null,102,116,121,112,104,101,105,99]}],Pj=16,Fj=e=>{let t=e.slice(0,Pj),n=t.slice(0,t.length-t.length%4);if(n.length===0)return;let r=globalThis.Buffer;if(r)return new Uint8Array(r.from(n,`base64`));try{let e=atob(n),t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}catch{return}};function Ij(e){let t=Fj(e);if(t)return Nj.find(({prefix:e})=>t.length>=e.length&&e.every((e,n)=>e===null||t[n]===e))?.mediaType}function Lj(e,t){if(t?.startsWith(`image/`))return t;let n=PC(e);if(n?.startsWith(`image/`))return n;let r=MC(e)?.data??(NC(e)?void 0:e);if(r!==void 0){let e=Ij(r);if(e)return e}return`image/png`}function Rj(e,t){return t||PC(e)||`application/octet-stream`}function zj(e,t){let n=MC(e);return n?n.mimeType===t?e:`data:${t};base64,${n.data}`:NC(e)?e:`data:${t};base64,${e}`}var Bj=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},Vj=(e=>e?Bj(e):Bj),Hj=e=>e;function Uj(e,t=Hj){let n=_.useSyncExternalStore(e.subscribe,_.useCallback(()=>t(e.getState()),[e,t]),_.useCallback(()=>t(e.getInitialState()),[e,t]));return _.useDebugValue(n),n}var Wj=e=>{let t=Vj(e),n=e=>Uj(t,e);return Object.assign(n,t),n},Gj=(e=>e?Wj(e):Wj),Kj=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()}}}}},qj=(e={})=>{let t=new Set,n=Kj(e=>{a.setState({height:{...a.getState().height,viewport:e}})}),r=Kj(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=Gj(()=>({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},Jj=e=>e,Yj=e=>{let t=z(11),n;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={optional:!0},t[0]=n):n=t[0];let r=kj(n),i;t[1]===e?i=t[2]:(i=()=>qj(e),t[1]=e,t[2]=i);let[a]=Pv(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]),V(o,s);let c,l;return t[7]!==r||t[8]!==a?(c=()=>{if(r)return a.subscribe(e=>{r.getState().isAtBottom!==e.isAtBottom&&Jj(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]),V(c,l),a},Xj=e=>{let t=z(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=Yj(i),o;t[2]===a?o=t[3]:(o=()=>({useThreadViewport:a}),t[2]=a,t[3]=o);let[s]=Pv(o),c;return t[4]!==n||t[5]!==s?(c=(0,I.jsx)(Dj.Provider,{value:s,children:n}),t[4]=n,t[5]=s,t[6]=c):c=t[6],c},Zj=()=>{let e=z(3),t=xx(),n,r;return e[0]===t?(n=e[1],r=e[2]):(n=()=>{},r=[t],e[0]=t,e[1]=n,e[2]=r),V(n,r),null},Qj=Gv(e=>{let t=z(8),{children:n,aui:r,config:i,runtime:a}=e,o=r??null,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,I.jsx)(Zj,{}),t[0]=s):s=t[0];let c;t[1]===n?c=t[2]:(c=(0,I.jsx)(Xj,{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,I.jsxs)(Vee,{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}),$j=/:([\w-]{1,64})\[([^\]\n]{1,1024})\](?:\{name=([^}\n]{1,1024})\})?/gu,eM={serialize(e){let t=e.id===e.label?``:`{name=${e.id}}`;return`:${e.type}[${e.label}]${t}`},parse(e){let t=[],n=0;for(let r of e.matchAll($j)){r.index>n&&t.push({kind:`text`,text:e.slice(n,r.index)});let i=r[2];t.push({kind:`mention`,type:r[1],label:i,id:r[3]??i}),n=r.index+r[0].length}return n<e.length&&t.push({kind:`text`,text:e.slice(n)}),t}},tM=e=>({isDisabled:e.isDisabled,isSendDisabled:e.isSendDisabled,unstable_capabilities:e.unstable_capabilities,suggestions:e.suggestions}),nM=Object.defineProperty,rM=(e,t)=>nM(e,`name`,{value:t,configurable:!0});function iM(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}rM(iM,`setRef`);function aM(...e){return t=>{let n=!1,r=e.map(e=>{let r=iM(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():iM(e[t],null)}}}}rM(aM,`composeRefs`);function oM(...e){return _.useCallback(aM(...e),e)}rM(oM,`useComposedRefs`);var sM=Object.defineProperty,cM=(e,t)=>sM(e,`name`,{value:t,configurable:!0});function lM(e){let t=_.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];vM(r)&&typeof SM==`function`&&(r=SM(r._payload)),_.Children.forEach(r,e=>{if(gM(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;vM(n)&&typeof SM==`function`&&(n=SM(n._payload)),a=pM(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=_.cloneElement(a,void 0,s):!o&&_.Children.count(r)===1&&_.isValidElement(r)&&(a=r);let c=a?hM(a):void 0,l=oM(n,c);if(!a){if(r||r===0)throw Error(o?xM(e):bM(e));return r}let u=mM(i,a.props??{});return a.type!==_.Fragment&&(u.ref=n?l:c),_.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}cM(lM,`createSlot`);var uM=lM(`Slot`),dM=Symbol.for(`radix.slottable`);function fM(e){let t=cM(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=dM,t}cM(fM,`createSlottable`);var pM=cM((e,t)=>{if(`child`in e.props){let t=e.props.child;return _.isValidElement(t)?_.cloneElement(t,void 0,e.props.children(t.props.children)):null}return _.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function mM(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}}cM(mM,`mergeProps`);function hM(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)}cM(hM,`getElementRef`);function gM(e){return _.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===dM}cM(gM,`isSlottable`);var _M=Symbol.for(`react.lazy`);function vM(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===_M&&`_payload`in e&&yM(e._payload)}cM(vM,`isLazyComponent`);function yM(e){return typeof e==`object`&&!!e&&`then`in e}cM(yM,`isPromiseLike`);var bM=cM(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),xM=cM(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),SM=_.use,CM=Object.defineProperty,wM=(e,t)=>CM(e,`name`,{value:t,configurable:!0}),TM=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=lM(`Primitive.${t}`),r=_.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,I.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function EM(e,t){e&&Cd.flushSync(()=>e.dispatchEvent(t))}wM(EM,`dispatchDiscreteCustomEvent`);var DM=Object.defineProperty,OM=(e,t)=>DM(e,`name`,{value:t,configurable:!0}),kM=!!(typeof window<`u`&&window.document&&window.document.createElement);function AM(e,t,{checkForDefaultPrevented:n=!0}={}){return OM(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}OM(AM,`composeEventHandlers`);function jM(e){if(!kM)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}OM(jM,`getOwnerWindow`);function MM(e){if(!kM)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}OM(MM,`getOwnerDocument`);function NM(e,t=!1){let{activeElement:n}=MM(e);if(!n?.nodeName)return null;if(PM(n)&&n.contentDocument)return NM(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=MM(n).getElementById(e);if(t)return t}}return n}OM(NM,`getActiveElement`);function PM(e){return e.tagName===`IFRAME`}OM(PM,`isFrame`);var FM=Object.defineProperty,IM=(e,t)=>FM(e,`name`,{value:t,configurable:!0});function LM(e){let t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>((...e)=>t.current?.(...e)),[])}IM(LM,`useCallbackRef`);var RM=Object.defineProperty,zM=(e,t)=>RM(e,`name`,{value:t,configurable:!0});function BM(e,t=globalThis?.document){let n=LM(e);_.useEffect(()=>{let e=zM(e=>{e.key===`Escape`&&n(e)},`handleKeyDown`);return t.addEventListener(`keydown`,e,{capture:!0}),()=>t.removeEventListener(`keydown`,e,{capture:!0})},[n,t])}zM(BM,`useEscapeKeydown`);var VM=TM;VM.dispatchDiscreteCustomEvent=EM,VM.Root=TM;var HM=Object.defineProperty,UM=(e,t)=>{let n={};for(var r in e)HM(n,r,{get:e[r],enumerable:!0});return t||HM(n,Symbol.toStringTag,{value:`Module`}),n},WM=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`];function GM(e){let t=Wv((t,n)=>{let r=z(17),i,a,o,s;r[0]===t?(i=r[1],a=r[2],o=r[3],s=r[4]):({render:o,asChild:i,children:a,...s}=t,r[0]=t,r[1]=i,r[2]=a,r[3]=o,r[4]=s);let c=e;if(o&&Yv(o)){let e=a===void 0?o.props.children:a,t=s,i;r[5]!==o||r[6]!==e?(i=Jv(o,void 0,e),r[5]=o,r[6]=e,r[7]=i):i=r[7];let l;return r[8]!==n||r[9]!==t||r[10]!==i?(l=(0,I.jsx)(c,{...t,asChild:!0,ref:n,children:i}),r[8]=n,r[9]=t,r[10]=i,r[11]=l):l=r[11],l}let l=s,u;return r[12]!==i||r[13]!==a||r[14]!==n||r[15]!==l?(u=(0,I.jsx)(c,{...l,asChild:i,ref:n,children:a}),r[12]=i,r[13]=a,r[14]=n,r[15]=l,r[16]=u):u=r[16],u});return t.displayName=typeof e==`string`?e:e.displayName??e.name??`Component`,t}function KM(e){let t=VM[e],n=GM(t);return n.displayName=`Primitive.${e}`,n}var qM=WM.reduce((e,t)=>(e[t]=KM(t),e),{}),JM=(e,t,n=[])=>{let r=Wv((e,r)=>{let i=z(6),a={},o={};Object.keys(e).forEach(t=>{n.includes(t)?a[t]=e[t]:o[t]=e[t]});let s=t(a)??void 0,c=qM,l=o.disabled||!s,u=AM(o.onClick,s),d;return i[0]!==r||i[1]!==o||i[2]!==c.button||i[3]!==l||i[4]!==u?(d=(0,I.jsx)(c.button,{type:`button`,...o,ref:r,disabled:l,onClick:u}),i[0]=r,i[1]=o,i[2]=c.button,i[3]=l,i[4]=u,i[5]=d):d=i[5],d});return r.displayName=e,r},YM=Xv(null),XM=()=>Qv(YM),ZM=e=>{let t=z(8),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=B(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=[],t[1]=a):a=t[1];let o=B(a),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>{let e=Array.from(i.current.entries());e.sort(QM),o.current=e.map($M)},t[2]=s):s=t[2];let c=s,l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=(e,t)=>{let n=t?.priority??0;return i.current.set(e,n),c(),()=>{i.current.delete(e),c()}},t[3]=l):l=t[3];let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>o.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={register:u,getPlugins:f},t[5]=p):p=t[5];let m=p,h;return t[6]===n?h=t[7]:(h=(0,I.jsx)(YM.Provider,{value:m,children:n}),t[6]=n,t[7]=h),h};function QM(e,t){return t[1]-e[1]}function $M(e){let[t]=e;return t}var eN=Xv(null),tN=Xv(null),nN=()=>{let e=Qv(eN);if(!e)throw Error(`useTriggerPopoverRootContext must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},rN=()=>Qv(eN),iN=()=>{let e=Qv(tN);if(!e)throw Error(`useTriggerPopoverAriaPublish must be used within ComposerPrimitive.TriggerPopoverRoot`);return e},aN=()=>{let e=nN();return zv(e.subscribe,e.getTriggers,e.getTriggers)},oN=new Map,sN=()=>()=>{},cN=()=>oN,lN=()=>{let e=rN();return zv(e?e.subscribe:sN,e?e.getTriggers:cN,e?e.getTriggers:cN)},uN=()=>null,dN=()=>{let e=rN();return zv(e?e.subscribeAria:sN,e?e.getActiveAria:uN,e?e.getActiveAria:uN)};function fN(){let e=z(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=new Set,e[0]=t):t=e[0];let n=B(t),r;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(r=()=>{for(let e of n.current)e()},e[1]=r):r=e[1];let i=r,a;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(a=e=>(n.current.add(e),()=>{n.current.delete(e)}),e[2]=a):a=e[2];let o=a,s;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s={notify:i,subscribe:o},e[3]=s):s=e[3],s}var pN=e=>{let t=z(21),{children:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=new Map,t[0]=r):r=t[0];let i=B(r),a;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(a=new Set,t[1]=a):a=t[1];let o=B(a),{notify:s,subscribe:c}=fN(),l;t[2]===s?l=t[3]:(l=e=>{let{char:t}=e;if(i.current.has(t))return hN;let n=new Map(i.current);n.set(t,e),i.current=n,s();for(let t of o.current)t.added(e);return()=>{let e=new Map(i.current);e.delete(t),i.current=e,s();for(let e of o.current)e.removed(t)}},t[2]=s,t[3]=l);let u=l,d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>i.current,t[4]=d):d=t[4];let f=d,p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>(o.current.add(e),()=>{o.current.delete(e)}),t[5]=p):p=t[5];let m=p,h=B(null),g=B(null),{notify:_,subscribe:v}=fN(),y;t[6]===_?y=t[7]:(y=(e,t)=>{if(t===null){if(g.current!==e)return;h.current=null,g.current=null,_();return}let n=h.current;(g.current!==e||n===null||n.popoverId!==t.popoverId||n.highlightedItemId!==t.highlightedItemId)&&(h.current=t,g.current=e,_())},t[6]=_,t[7]=y);let b=y,x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>h.current,t[8]=x):x=t[8];let S=x,C;t[9]!==u||t[10]!==c||t[11]!==v?(C={register:u,getTriggers:f,subscribe:c,subscribeLifecycle:m,getActiveAria:S,subscribeAria:v},t[9]=u,t[10]=c,t[11]=v,t[12]=C):C=t[12];let w=C,T;t[13]===b?T=t[14]:(T={setActiveAria:b},t[13]=b,t[14]=T);let E=T,D;t[15]!==E||t[16]!==n?(D=(0,I.jsx)(tN.Provider,{value:E,children:n}),t[15]=E,t[16]=n,t[17]=D):D=t[17];let O;return t[18]!==D||t[19]!==w?(O=(0,I.jsx)(eN.Provider,{value:w,children:D}),t[18]=D,t[19]=w,t[20]=O):O=t[20],O},mN=e=>{let t=z(4),{children:n}=e;if(XM()){let e;return t[0]===n?e=t[1]:(e=(0,I.jsx)(pN,{children:n}),t[0]=n,t[1]=e),e}let r;return t[2]===n?r=t[3]:(r=(0,I.jsx)(ZM,{children:(0,I.jsx)(pN,{children:n})}),t[2]=n,t[3]=r),r};mN.displayName=`ComposerPrimitive.TriggerPopoverRoot`;function hN(){}var gN=/\s/u;function _N(e,t,n,r){if(r===null)return null;let{query:i,offset:a,endOffset:o}=r;return a<0||a+t.length>n||!e.startsWith(t,a)||o<a+t.length||o>e.length?null:{query:i,offset:a,endOffset:o}}function vN(e,t,n,r){if(r)return _N(e,t,n,r(e,t,n));let i=e.slice(0,n);for(let e=i.length-1;e>=0;e--){let r=i[e];if(gN.test(r))return null;if(i.startsWith(t,e)){if(e>0&&!gN.test(i[e-1]))continue;return{query:i.slice(e+t.length),offset:e,endOffset:n}}}return null}var yN=$v(e=>{let t=z(8),{text:n,triggerChar:r,matcher:i}=e,[a,o]=Pv(n.length),s=Math.min(a,n.length),c;t[0]!==i||t[1]!==s||t[2]!==n||t[3]!==r?(c=vN(n,r,s,i),t[0]=i,t[1]=s,t[2]=n,t[3]=r,t[4]=c):c=t[4];let l=c,u=l?.query??``,d;return t[5]!==u||t[6]!==l?(d={trigger:l,query:u,setCursorPosition:o},t[5]=u,t[6]=l,t[7]=d):d=t[7],d});function bN(e){return`type`in e}var xN=$v(e=>{let t=z(25),{navigableList:n,isSearchMode:r,activeCategoryId:i,query:a,popoverId:o,open:s,selectItem:c,selectCategory:l,goBack:u,close:d}=e,[f,p]=Pv(0),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=()=>{p(0)},t[0]=m):m=t[0];let h;t[1]===n?h=t[2]:(h=[n],t[1]=n,t[2]=h),V(m,h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>{p(0)},t[3]=g):g=t[3];let _;t[4]!==i||t[5]!==r?(_=[r,i],t[4]=i,t[5]=r,t[6]=_):_=t[6],V(g,_);let v;t[7]!==f||t[8]!==n.length?(v=e=>{e<0||e>=n.length||e!==f&&p(e)},t[7]=f,t[8]=n.length,t[9]=v):v=t[9];let y=Rv(v),b;t[10]!==i||t[11]!==d||t[12]!==u||t[13]!==f||t[14]!==n||t[15]!==s||t[16]!==a||t[17]!==l||t[18]!==c?(b=e=>{if(!s)return!1;switch(e.key){case`ArrowDown`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e<t-1?e+1:0}),!0;case`ArrowUp`:return e.preventDefault(),p(e=>{let t=n.length;return t===0?0:e>0?e-1:t-1}),!0;case`Enter`:case`Tab`:{if(e.shiftKey)return!1;e.preventDefault();let t=n[f];return t&&(bN(t)?c(t):l(t.id)),!0}case`Escape`:return e.preventDefault(),d(),!0;case`Backspace`:return i&&a===``?(e.preventDefault(),u(),!0):!1;default:return!1}},t[10]=i,t[11]=d,t[12]=u,t[13]=f,t[14]=n,t[15]=s,t[16]=a,t[17]=l,t[18]=c,t[19]=b):b=t[19];let x=Rv(b),S=n[f],C=s&&S?`${o}-option-${S.id}`:void 0,w;return t[20]!==x||t[21]!==y||t[22]!==f||t[23]!==C?(w={highlightedIndex:f,highlightedItemId:C,highlightIndex:y,handleKeyDown:x},t[20]=x,t[21]=y,t[22]=f,t[23]=C,t[24]=w):w=t[24],w});function SN(e,t){return!t||e.id.toLowerCase().includes(t)||e.label.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1)}var CN=$v(e=>{let t=z(38),{adapter:n,query:r,open:i}=e,[a,o]=Pv(null),s,c;t[0]===i?(s=t[1],c=t[2]):(s=()=>{i||o(null)},c=[i],t[0]=i,t[1]=s,t[2]=c),V(s,c);let l;bb0:{if(!i||!n){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],l=e;break bb0}let e;t[4]===n?e=t[5]:(e=n.categories(),t[4]=n,t[5]=e),l=e}let u=l,d=i?a:null,f;bb1:{if(!d||!n){let e;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[6]=e):e=t[6],f=e;break bb1}let e;t[7]!==n||t[8]!==d?(e=n.categoryItems(d),t[7]=n,t[8]=d,t[9]=e):e=t[9],f=e}let p=f,m;bb2:{if(!i||!n||d){m=null;break bb2}if(!r&&u.length>0){m=null;break bb2}if(n.search){let e;t[10]!==n||t[11]!==r?(e=n.search(r),t[10]=n,t[11]=r,t[12]=e):e=t[12],m=e;break bb2}let e;if(t[13]!==n||t[14]!==u||t[15]!==r){e=[];let i=r.toLowerCase();for(let t of u)for(let r of n.categoryItems(t.id))SN(r,i)&&e.push(r);t[13]=n,t[14]=u,t[15]=r,t[16]=e}else e=t[16];m=e}let h=m,g=h!==null,_;bb3:{if(g){let e;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[17]=e):e=t[17],_=e;break bb3}if(!r){_=u;break bb3}let e;if(t[18]!==u||t[19]!==r){let n=r.toLowerCase();e=u.filter(e=>e.label.toLowerCase().includes(n)),t[18]=u,t[19]=r,t[20]=e}else e=t[20];_=e}let v=_,y;bb4:{if(g){let e;t[21]===h?e=t[22]:(e=h??[],t[21]=h,t[22]=e),y=e;break bb4}if(!r){y=p;break bb4}let e;if(t[23]!==p||t[24]!==r){let n=r.toLowerCase();e=p.filter(e=>SN(e,n)),t[23]=p,t[24]=r,t[25]=e}else e=t[25];y=e}let b=y,x;bb5:{if(g){let e;t[26]===h?e=t[27]:(e=h??[],t[26]=h,t[27]=e),x=e;break bb5}if(d){x=b;break bb5}x=v}let S=x,C;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(C=e=>{o(e)},t[28]=C):C=t[28];let w=Rv(C),T;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(T=()=>{o(null)},t[29]=T):T=t[29];let E=Rv(T),D;return t[30]!==d||t[31]!==v||t[32]!==b||t[33]!==E||t[34]!==g||t[35]!==S||t[36]!==w?(D={categories:v,items:b,isSearchMode:g,activeCategoryId:d,navigableList:S,selectCategory:w,goBack:E},t[30]=d,t[31]=v,t[32]=b,t[33]=E,t[34]=g,t[35]=S,t[36]=w,t[37]=D):D=t[37],D}),wN=$v(e=>{let t=z(15),{behavior:n,trigger:r,aui:i,setCursorPosition:a,onSelected:o}=e,s=B(null),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=e=>(s.current=e,()=>{s.current===e&&(s.current=null)}),t[0]=c):c=t[0];let l=Rv(c),u;t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==r?(u=e=>{if(!r||!n)return;if(s.current?.(e)){o();return}let t=i.composer.getState().text,c=t.slice(0,r.offset),l=t.slice(r.endOffset),u=()=>{let t=n.formatter.serialize(e);i.composer.setText(c+t+(l.startsWith(` `)?l:` ${l}`)),a(c.length+t.length+1)};n.kind===`directive`?(u(),n.onInserted?.(e)):(n.removeOnExecute?(i.composer.setText(c+(l.startsWith(` `)?l.slice(1):l)),a(c.length)):u(),n.onExecute(e)),o()},t[1]=i,t[2]=n,t[3]=o,t[4]=a,t[5]=r,t[6]=u):u=t[6];let d=Rv(u),f;t[7]!==o||t[8]!==a||t[9]!==r?(f=()=>{o(),r&&a(r.offset)},t[7]=o,t[8]=a,t[9]=r,t[10]=f):f=t[10];let p=Rv(f),m;return t[11]!==p||t[12]!==l||t[13]!==d?(m={selectItem:d,close:p,registerSelectItemOverride:l},t[11]=p,t[12]=l,t[13]=d,t[14]=m):m=t[14],m}),TN=$v(e=>{let t=z(47),{adapter:n,text:r,triggerChar:i,matcher:a,behavior:o,aui:s,popoverId:c,isLoading:l}=e,u;t[0]!==a||t[1]!==r||t[2]!==i?(u=yN({text:r,triggerChar:i,matcher:a}),t[0]=a,t[1]=r,t[2]=i,t[3]=u):u=t[3];let d=By(u),f=d.trigger!==null&&n!==void 0&&o!==void 0,p;t[4]!==n||t[5]!==d.query||t[6]!==f?(p=CN({adapter:n,query:d.query,open:f}),t[4]=n,t[5]=d.query,t[6]=f,t[7]=p):p=t[7];let m=By(p),h;t[8]===m?h=t[9]:(h=()=>{m.goBack()},t[8]=m,t[9]=h);let g=Rv(h),_;t[10]!==s||t[11]!==o||t[12]!==d.setCursorPosition||t[13]!==d.trigger||t[14]!==g||t[15]!==i?(_=wN({behavior:o,trigger:d.trigger,aui:s,triggerChar:i,setCursorPosition:d.setCursorPosition,onSelected:g}),t[10]=s,t[11]=o,t[12]=d.setCursorPosition,t[13]=d.trigger,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v=By(_),y;t[17]!==d.query||t[18]!==m.activeCategoryId||t[19]!==m.goBack||t[20]!==m.isSearchMode||t[21]!==m.navigableList||t[22]!==m.selectCategory||t[23]!==f||t[24]!==c||t[25]!==v.close||t[26]!==v.selectItem?(y=xN({navigableList:m.navigableList,isSearchMode:m.isSearchMode,activeCategoryId:m.activeCategoryId,query:d.query,popoverId:c,open:f,selectItem:v.selectItem,selectCategory:m.selectCategory,goBack:m.goBack,close:v.close}),t[17]=d.query,t[18]=m.activeCategoryId,t[19]=m.goBack,t[20]=m.isSearchMode,t[21]=m.navigableList,t[22]=m.selectCategory,t[23]=f,t[24]=c,t[25]=v.close,t[26]=v.selectItem,t[27]=y):y=t[27];let b=By(y),x;return t[28]!==d.query||t[29]!==d.setCursorPosition||t[30]!==l||t[31]!==b.handleKeyDown||t[32]!==b.highlightIndex||t[33]!==b.highlightedIndex||t[34]!==b.highlightedItemId||t[35]!==m.activeCategoryId||t[36]!==m.categories||t[37]!==m.goBack||t[38]!==m.isSearchMode||t[39]!==m.items||t[40]!==m.selectCategory||t[41]!==f||t[42]!==c||t[43]!==v.close||t[44]!==v.registerSelectItemOverride||t[45]!==v.selectItem?(x={open:f,query:d.query,activeCategoryId:m.activeCategoryId,categories:m.categories,items:m.items,highlightedIndex:b.highlightedIndex,isSearchMode:m.isSearchMode,isLoading:l,popoverId:c,highlightedItemId:b.highlightedItemId,selectCategory:m.selectCategory,goBack:m.goBack,selectItem:v.selectItem,close:v.close,highlightIndex:b.highlightIndex,handleKeyDown:b.handleKeyDown,setCursorPosition:d.setCursorPosition,registerSelectItemOverride:v.registerSelectItemOverride},t[28]=d.query,t[29]=d.setCursorPosition,t[30]=l,t[31]=b.handleKeyDown,t[32]=b.highlightIndex,t[33]=b.highlightedIndex,t[34]=b.highlightedItemId,t[35]=m.activeCategoryId,t[36]=m.categories,t[37]=m.goBack,t[38]=m.isSearchMode,t[39]=m.items,t[40]=m.selectCategory,t[41]=f,t[42]=c,t[43]=v.close,t[44]=v.registerSelectItemOverride,t[45]=v.selectItem,t[46]=x):x=t[46],x}),EN=Xv(null),DN=()=>{let e=Qv(EN);if(!e)throw Error(`useTriggerPopoverScopeContext must be used within ComposerPrimitive.TriggerPopover`);return e},ON=()=>Qv(EN),kN=Xv(null),AN=()=>{let e=Qv(kN);if(!e)throw Error(`TriggerPopover.Directive / TriggerPopover.Action must be rendered inside ComposerPrimitive.TriggerPopover`);return e},jN=Wv((e,t)=>{let n=z(69),r,i,a,o,s,c,l;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6],l=n[7]):({char:a,matcher:s,adapter:r,isLoading:l,"aria-label":i,children:o,...c}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c,n[7]=l);let u=l!==void 0&&l,d=xx(),f=H(MN),p=Hv(),m=B(s),h;n[8]===s?h=n[9]:(h=()=>{m.current=s},n[8]=s,n[9]=h),V(h);let g;n[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>(e,t,n)=>m.current(e,t,n),n[10]=g):g=n[10];let[_]=Pv(g),v=s!==void 0,y=B(null),[b,x]=Pv(null),S=B(0),C;n[11]===a?C=n[12]:(C=e=>(S.current+=1,y.current=e,x(e),()=>{S.current=Math.max(0,S.current-1),y.current===e&&(y.current=null,x(null))}),n[11]=a,n[12]=C);let w=C,T;n[13]===w?T=n[14]:(T={register:w},n[13]=w,n[14]=T);let E=T,D=b??void 0,O;n[15]!==r||n[16]!==d||n[17]!==a||n[18]!==u||n[19]!==s||n[20]!==p||n[21]!==D||n[22]!==f?(O=TN({adapter:r,text:f,triggerChar:a,matcher:s,behavior:D,aui:d,popoverId:p,isLoading:u}),n[15]=r,n[16]=d,n[17]=a,n[18]=u,n[19]=s,n[20]=p,n[21]=D,n[22]=f,n[23]=O):O=n[23];let k=By(O),A;n[24]===k?A=n[25]:(A=()=>k,n[24]=k,n[25]=A);let j=Rv(A),ee=nN(),te;n[26]!==b||n[27]!==a||n[28]!==j||n[29]!==v||n[30]!==_||n[31]!==ee?(te=()=>ee.register({char:a,...v?{matcher:_}:{},...b?{behavior:b}:{},resource:j()}),n[26]=b,n[27]=a,n[28]=j,n[29]=v,n[30]=_,n[31]=ee,n[32]=te):te=n[32];let ne;n[33]!==b||n[34]!==a||n[35]!==v||n[36]!==ee?(ne=[ee,a,v,b],n[33]=b,n[34]=a,n[35]=v,n[36]=ee,n[37]=ne):ne=n[37],V(te,ne);let re=XM(),M;n[38]!==j||n[39]!==re?(M=()=>{if(re)return re.register(j())},n[38]=j,n[39]=re,n[40]=M):M=n[40];let N;n[41]===re?N=n[42]:(N=[re],n[41]=re,n[42]=N),V(M,N);let ie=b!==null&&k.open,ae=iN(),oe,se;n[43]!==ae||n[44]!==a||n[45]!==ie?(oe=()=>{if(ie)return()=>{ae.setActiveAria(a,null)}},se=[ae,a,ie],n[43]=ae,n[44]=a,n[45]=ie,n[46]=oe,n[47]=se):(oe=n[46],se=n[47]),V(oe,se);let P,ce;n[48]!==ae||n[49]!==a||n[50]!==ie||n[51]!==p||n[52]!==k.highlightedItemId?(P=()=>{ie&&ae.setActiveAria(a,{popoverId:p,highlightedItemId:k.highlightedItemId})},ce=[ae,a,p,ie,k.highlightedItemId],n[48]=ae,n[49]=a,n[50]=ie,n[51]=p,n[52]=k.highlightedItemId,n[53]=P,n[54]=ce):(P=n[53],ce=n[54]),V(P,ce);let le;n[55]!==i||n[56]!==o||n[57]!==t||n[58]!==ie||n[59]!==p||n[60]!==c||n[61]!==k.highlightedItemId?(le=ie?(0,I.jsx)(qM.div,{role:`listbox`,id:p,"aria-label":i??`Suggestions`,"aria-activedescendant":k.highlightedItemId,"data-state":`open`,...c,ref:t,children:o}):o,n[55]=i,n[56]=o,n[57]=t,n[58]=ie,n[59]=p,n[60]=c,n[61]=k.highlightedItemId,n[62]=le):le=n[62];let ue;n[63]!==k||n[64]!==le?(ue=(0,I.jsx)(EN.Provider,{value:k,children:le}),n[63]=k,n[64]=le,n[65]=ue):ue=n[65];let de;return n[66]!==E||n[67]!==ue?(de=(0,I.jsx)(kN.Provider,{value:E,children:ue}),n[66]=E,n[67]=ue,n[68]=de):de=n[68],de});jN.displayName=`ComposerPrimitive.TriggerPopover`;function MN(e){return e.composer.text}var NN=()=>{let e=z(2),{disabled:t,send:n}=YA(),r;return e[0]===n?r=e[1]:(r=()=>n(),e[0]=n,e[1]=r),t?null:r},PN=JM(`ComposerPrimitive.Send`,NN),FN=Xv(null),IN=()=>Qv(FN),LN=`[contenteditable]:not([contenteditable='false'])`,RN=`textarea:not(:disabled), ${LN}`,zN=[`a`,`audio[controls]`,`button`,`details`,`embed`,`iframe`,`input`,`label`,`select`,`summary`,`textarea`,`video[controls]`,LN,`[tabindex]`].join(`, `),BN=Wv((e,t)=>{let n=z(24),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({onSubmit:a,onMouseDown:i,compact:r,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let s=NN(),[c,l]=Pv(!1),u;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={setMultiline:l},n[5]=u):u=n[5];let d=u,f;n[6]===r?f=n[7]:(f=e=>r?e.composer.attachments.length===0&&e.composer.quote==null&&e.composer.queue.length===0&&e.composer.dictation==null&&!e.composer.text.includes(`
|
|
28
|
-
`):!1,n[6]=r,n[7]=f);let p=H(f)&&!c,m;n[8]===s?m=n[9]:(m=e=>{e.preventDefault(),s&&s()},n[8]=s,n[9]=m);let h=m,g=VN,_=r?d:null,v=p?``:void 0,y;n[10]!==h||n[11]!==a?(y=AM(a,h),n[10]=h,n[11]=a,n[12]=y):y=n[12];let b;n[13]===i?b=n[14]:(b=AM(i,g),n[13]=i,n[14]=b);let x;n[15]!==t||n[16]!==o||n[17]!==v||n[18]!==y||n[19]!==b?(x=(0,I.jsx)(qM.form,{...o,"data-compact":v,ref:t,onSubmit:y,onMouseDown:b}),n[15]=t,n[16]=o,n[17]=v,n[18]=y,n[19]=b,n[20]=x):x=n[20];let S;return n[21]!==_||n[22]!==x?(S=(0,I.jsx)(FN.Provider,{value:_,children:x}),n[21]=_,n[22]=x,n[23]=S):S=n[23],S});BN.displayName=`ComposerPrimitive.Root`;function VN(e){if(e.button!==0)return;let t=e.target;if(!(t instanceof Element)||!e.currentTarget.contains(t))return;let n=t.closest(zN);if(n&&e.currentTarget.contains(n))return;let r=e.currentTarget.querySelector(RN);r&&(e.preventDefault(),r.focus())}var HN=e=>{let t=z(4),n=LM(e),r=Oj(UN),i,a;t[0]!==n||t[1]!==r?(i=()=>r(n),a=[r,n],t[0]=n,t[1]=r,t[2]=i,t[3]=a):(i=t[2],a=t[3]),V(i,a)};function UN(e){return e.onScrollToBottom}var WN=()=>!1,GN=()=>{},KN=e=>{let t=z(4),n;t[0]===e?n=t[1]:(n=t=>{if(typeof window>`u`||e===null||!window.matchMedia)return GN;let n=window.matchMedia(e);return n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t)},t[0]=e,t[1]=n);let r=n,i;return t[2]===e?i=t[3]:(i=()=>typeof window>`u`||e===null||!window.matchMedia?!1:window.matchMedia(e).matches,t[2]=e,t[3]=i),zv(r,i,WN)};function qN(){return H(JN)}function JN(e){return e.composer.isEditing?e.composer.text:``}function YN(e){return!!H(XN)||!!e}function XN(e){return e.thread.isDisabled||e.composer.dictation?.inputDisabled}function ZN(){let e=z(4),t=dN();if(!t){let t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t={},e[0]=t):t=e[0],t}let n;return e[1]!==t.highlightedItemId||e[2]!==t.popoverId?(n={"aria-controls":t.popoverId,"aria-expanded":!0,"aria-haspopup":`listbox`,"aria-activedescendant":t.highlightedItemId},e[1]=t.highlightedItemId,e[2]=t.popoverId,e[3]=n):n=e[3],n}function QN(){return QN=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},QN.apply(null,arguments)}function $N(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var eP=_.useLayoutEffect,tP=function(e){var t=_.useRef(e);return eP(function(){t.current=e}),t},nP=function(e,t){if(typeof e==`function`){e(t);return}e.current=t},rP=function(e,t){var n=_.useRef();return _.useCallback(function(r){e.current=r,n.current&&nP(n.current,null),n.current=t,t&&nP(t,r)},[t])},iP={"min-height":`0`,"max-height":`none`,height:`0`,visibility:`hidden`,overflow:`hidden`,position:`absolute`,"z-index":`-1000`,top:`0`,right:`0`,display:`block`},aP=function(e){Object.keys(iP).forEach(function(t){e.style.setProperty(t,iP[t],`important`)})},oP=null,sP=function(e,t){var n=e.scrollHeight;return t.sizingStyle.boxSizing===`border-box`?n+t.borderSize:n-t.paddingSize};function cP(e,t,n,r){n===void 0&&(n=1),r===void 0&&(r=1/0),oP||(oP=document.createElement(`textarea`),oP.setAttribute(`tabindex`,`-1`),oP.setAttribute(`aria-hidden`,`true`),aP(oP)),oP.parentNode===null&&document.body.appendChild(oP);var i=e.paddingSize,a=e.borderSize,o=e.sizingStyle,s=o.boxSizing;Object.keys(o).forEach(function(e){var t=e;oP.style[t]=o[t]}),aP(oP),oP.value=t;var c=sP(oP,e);oP.value=t,c=sP(oP,e),oP.value=`x`;var l=oP.scrollHeight-i,u=l*n;s===`border-box`&&(u=u+i+a),c=Math.max(u,c);var d=l*r;return s===`border-box`&&(d=d+i+a),c=Math.min(d,c),[c,l]}var lP=function(){},uP=function(e,t){return e.reduce(function(e,n){return e[n]=t[n],e},{})},dP=[`borderBottomWidth`,`borderLeftWidth`,`borderRightWidth`,`borderTopWidth`,`boxSizing`,`fontFamily`,`fontSize`,`fontStyle`,`fontWeight`,`letterSpacing`,`lineHeight`,`paddingBottom`,`paddingLeft`,`paddingRight`,`paddingTop`,`tabSize`,`textIndent`,`textRendering`,`textTransform`,`width`,`wordBreak`,`wordSpacing`,`scrollbarGutter`],fP=!!document.documentElement.currentStyle,pP=function(e){var t=window.getComputedStyle(e);if(t===null)return null;var n=uP(dP,t),r=n.boxSizing;return r===``?null:(fP&&r===`border-box`&&(n.width=parseFloat(n.width)+parseFloat(n.borderRightWidth)+parseFloat(n.borderLeftWidth)+parseFloat(n.paddingRight)+parseFloat(n.paddingLeft)+`px`),{sizingStyle:n,paddingSize:parseFloat(n.paddingBottom)+parseFloat(n.paddingTop),borderSize:parseFloat(n.borderBottomWidth)+parseFloat(n.borderTopWidth)})};function mP(e,t,n){var r=tP(n);_.useLayoutEffect(function(){var n=function(e){return r.current(e)};if(e)return e.addEventListener(t,n),function(){return e.removeEventListener(t,n)}},[])}var hP=function(e,t){mP(document.body,`reset`,function(n){e.current.form===n.target&&t(n)})},gP=function(e){mP(window,`resize`,e)},_P=function(e){mP(document.fonts,`loadingdone`,e)},vP=[`cacheMeasurements`,`maxRows`,`minRows`,`onChange`,`onHeightChange`],yP=_.forwardRef(function(e,t){var n=e.cacheMeasurements,r=e.maxRows,i=e.minRows,a=e.onChange,o=a===void 0?lP:a,s=e.onHeightChange,c=s===void 0?lP:s,l=$N(e,vP),u=l.value!==void 0,d=_.useRef(null),f=rP(d,t),p=_.useRef(0),m=_.useRef(),h=function(){var e=d.current,t=n&&m.current?m.current:pP(e);if(t){m.current=t;var a=cP(t,e.value||e.placeholder||`x`,i,r),o=a[0],s=a[1];p.current!==o&&(p.current=o,e.style.setProperty(`height`,o+`px`,`important`),c(o,{rowHeight:s}))}};return _.useLayoutEffect(h),hP(d,function(){if(!u){var e=d.current.value;requestAnimationFrame(function(){var t=d.current;t&&e!==t.value&&h()})}}),gP(h),_P(h),_.createElement(`textarea`,QN({},l,{onChange:function(e){u||h(),o(e)},ref:f}))}),bP=`(pointer: coarse) and (not (any-pointer: fine))`,xP=Wv(({autoFocus:e=!1,asChild:t,render:n,disabled:r,onChange:i,onKeyDown:a,onPaste:o,onSelect:s,submitOnEnter:c,submitMode:l,cancelOnEscape:u=!0,unstable_focusOnRunStart:d=!0,unstable_focusOnScrollToBottom:f=!0,unstable_focusOnThreadSwitched:p=!0,unstable_insertNewlineOnTouchEnter:m=!1,addAttachmentOnPaste:h=!0,onHeightChange:g,..._},v)=>{let y=xx(),b=XM(),x=IN(),S=l??(c===!1?`none`:`enter`),C=KN(m?bP:null),w=m&&C&&S===`enter`?`none`:S,T=qN(),E=YN(r),D=B(null),O=oM(v,D),k=B(!1);BM(e=>{if(!D.current?.contains(e.target)||e.isComposing)return;if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(!u)return;let t=y.composer;t.getState().canCancel&&(t.cancel(),e.preventDefault())});let A=e=>{if(!E&&!e.nativeEvent.isComposing){if(b){for(let t of b.getPlugins())if(t.handleKeyDown(e))return}if(e.key===`Enter`){let t=y.thread.getState(),n=t.capabilities.queue;if(e.shiftKey&&(e.ctrlKey||e.metaKey)&&n&&S!==`none`&&y.composer.getState().canSend){e.preventDefault(),y.composer.send({steer:!0});return}if(e.shiftKey||t.isRunning&&!n)return;let r=!1;w===`ctrlEnter`?r=e.ctrlKey||e.metaKey:w===`enter`&&(r=!0),r&&(e.preventDefault(),D.current?.closest(`form`)?.requestSubmit())}}},j=async e=>{if(!h)return;let t=y.thread.getState().capabilities,n=Array.from(e.clipboardData?.files||[]);t.attachments&&n.length>0&&(e.preventDefault(),await Promise.all(n.map(async e=>{try{await y.composer.addAttachment(e)}catch{}})))},ee=(e,t)=>{if(g?.(e,t),!x)return;let n=D.current;if(!n||n.value===``)return;let r=getComputedStyle(n),i=r.boxSizing===`border-box`?e-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderTopWidth)-parseFloat(r.borderBottomWidth):e;Math.round(i/t.rowHeight)>1&&x.setMultiline(!0)},te=e&&!E,ne=Iv(()=>{let e=D.current;e&&te&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length))},[te]);V(()=>ne(),[ne]),HN(()=>{y.composer.getState().type===`thread`&&f&&ne()}),V(()=>{if(y.composer.getState().type===`thread`&&d)return y.on(`thread.runStart`,ne)},[d,ne,y]),V(()=>{if(y.composer.getState().type===`thread`&&p)return y.on(`threads.selectionChanged`,ne)},[p,ne,y]),V(()=>{T===``&&x?.setMultiline(!1)},[T,x]);let re=ZN(),M={name:`input`,value:T,..._,...re,ref:O,disabled:E,onChange:AM(i,e=>{if(!y.composer.getState().isEditing)return;let t=e.nativeEvent.isComposing===!0;k.current&&!t&&(k.current=!1);let n=t||k.current;if(fy(()=>{y.composer.setText(e.target.value)}),n)return;let r=e.target.selectionStart??e.target.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(r)}),onKeyDown:AM(a,A),onCompositionStart:AM(_.onCompositionStart,()=>{k.current=!0}),onCompositionEnd:AM(_.onCompositionEnd,e=>{if(k.current=!1,!y.composer.getState().isEditing)return;let t=e.target;fy(()=>{y.composer.setText(t.value)});let n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onSelect:AM(s,e=>{if(k.current)return;let t=e.target,n=t.selectionStart??t.value.length;if(b)for(let e of b.getPlugins())e.setCursorPosition(n)}),onPaste:AM(o,j),...x?{onHeightChange:ee}:g===void 0?{}:{onHeightChange:g}};if(n&&Yv(n)){let e=_.children===void 0?n.props.children:_.children;return(0,I.jsx)(uM,{...M,children:Jv(n,void 0,e)})}let N=t?uM:yP;return(0,I.jsx)(N,{...M})});xP.displayName=`ComposerPrimitive.Input`;var SP=JM(`ComposerPrimitive.Cancel`,()=>{let{disabled:e,cancel:t}=XA();return e?null:t}),CP=JM(`ComposerPrimitive.AddAttachment`,e=>{let t=z(6),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{multiple:r}=n,i=r===void 0||r,{disabled:a,addAttachment:o}=$A(),s=xx(),c;return t[2]!==o||t[3]!==s.composer||t[4]!==i?(c=()=>{let e=document.createElement(`input`);e.type=`file`,e.multiple=i,e.hidden=!0;let t=s.composer.getState().attachmentAccept;t!==`*`&&(e.accept=t),document.body.appendChild(e),e.onchange=async t=>{let n=t.target.files;if(!n)return;let r=Array.from(n,async e=>{try{await o(e)}catch{}});document.body.removeChild(e),await Promise.all(r)},e.oncancel=()=>{(!e.files||e.files.length===0)&&document.body.removeChild(e)},e.click()},t[2]=o,t[3]=s.composer,t[4]=i,t[5]=c):c=t[5],a?null:c},[`multiple`]),wP=Wv((e,t)=>{let n=z(32),{disabled:r,asChild:i,render:a,children:o,...s}=e,c=i!==void 0&&i,[l,u]=Pv(!1),d=xx(),f;n[0]!==d||n[1]!==r?(f=e=>{if(!r&&e.dataTransfer.types.includes(`Files`)){if(e.preventDefault(),!d.thread.getState().capabilities.attachments){e.dataTransfer.dropEffect=`none`;return}u(!0)}},n[0]=d,n[1]=r,n[2]=f):f=n[2];let p=f,m;n[3]!==d||n[4]!==r||n[5]!==l?(m=e=>{if(!r&&e.dataTransfer.types.includes(`Files`)){if(e.preventDefault(),!d.thread.getState().capabilities.attachments){e.dataTransfer.dropEffect=`none`;return}l||u(!0)}},n[3]=d,n[4]=r,n[5]=l,n[6]=m):m=n[6];let h=m,g;n[7]===r?g=n[8]:(g=e=>{if(r)return;e.preventDefault();let t=e.relatedTarget;t&&e.currentTarget.contains(t)||u(!1)},n[7]=r,n[8]=g);let _=g,v;n[9]!==d||n[10]!==r?(v=async e=>{if(r||(u(!1),!e.dataTransfer.types.includes(`Files`)))return;e.preventDefault();let t=Array.from(e.dataTransfer.files);d.thread.getState().capabilities.attachments&&t.length!==0&&await Promise.all(t.map(async e=>{try{await d.composer.addAttachment(e)}catch{}}))},n[9]=d,n[10]=r,n[11]=v):v=n[11];let y=v,b;n[12]===l?b=n[13]:(b=l?{"data-dragging":`true`}:null,n[12]=l,n[13]=b);let x=AM(s.onDragEnterCapture,p),S=AM(s.onDragOverCapture,h),C=AM(s.onDragLeaveCapture,_),w=AM(s.onDropCapture,y),T;n[14]!==t||n[15]!==s||n[16]!==w||n[17]!==b||n[18]!==x||n[19]!==S||n[20]!==C?(T={...b,...s,onDragEnterCapture:x,onDragOverCapture:S,onDragLeaveCapture:C,onDropCapture:w,ref:t},n[14]=t,n[15]=s,n[16]=w,n[17]=b,n[18]=x,n[19]=S,n[20]=C,n[21]=T):T=n[21];let E=T;if(a&&Yv(a)){let e=o===void 0?a.props.children:o,t;n[22]!==a||n[23]!==e?(t=Jv(a,void 0,e),n[22]=a,n[23]=e,n[24]=t):t=n[24];let r;return n[25]!==E||n[26]!==t?(r=(0,I.jsx)(uM,{...E,children:t}),n[25]=E,n[26]=t,n[27]=r):r=n[27],r}let D=c?uM:`div`,O;return n[28]!==D||n[29]!==o||n[30]!==E?(O=(0,I.jsx)(D,{...E,children:o}),n[28]=D,n[29]=o,n[30]=E,n[31]=O):O=n[31],O});wP.displayName=`ComposerPrimitive.AttachmentDropzone`;var TP=JM(`ComposerPrimitive.Dictate`,()=>{let{disabled:e,startDictation:t}=ZA();return e?null:t}),EP=JM(`ComposerPrimitive.StopDictation`,()=>{let e=z(2),t=xx(),n=H(DP),r;return e[0]===t.composer?r=e[1]:(r=()=>{t.composer.stopDictation()},e[0]=t.composer,e[1]=r),n?r:null});function DP(e){return e.composer.dictation!=null}var OP=Wv((e,t)=>{let n=z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=H(kP);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,I.jsx)(qM.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});OP.displayName=`ComposerPrimitive.DictationTranscript`;function kP(e){return e.composer.dictation?.transcript}var AP=Wv((e,t)=>{let n=z(3);if(!H(NP))return null;let r;return n[0]!==t||n[1]!==e?(r=(0,I.jsx)(qM.div,{...e,ref:t}),n[0]=t,n[1]=e,n[2]=r):r=n[2],r});AP.displayName=`ComposerPrimitive.Quote`;var jP=Wv((e,t)=>{let n=z(7),r,i;n[0]===e?(r=n[1],i=n[2]):({children:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=H(PP);if(!a)return null;let o=r??a,s;return n[3]!==t||n[4]!==i||n[5]!==o?(s=(0,I.jsx)(qM.span,{...i,ref:t,children:o}),n[3]=t,n[4]=i,n[5]=o,n[6]=s):s=n[6],s});jP.displayName=`ComposerPrimitive.QuoteText`;var MP=Wv((e,t)=>{let n=z(12),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let a=xx(),o;n[3]===a?o=n[4]:(o=()=>{a.composer.setQuote(void 0)},n[3]=a,n[4]=o);let s=o,c;n[5]!==s||n[6]!==r?(c=AM(r,s),n[5]=s,n[6]=r,n[7]=c):c=n[7];let l;return n[8]!==t||n[9]!==i||n[10]!==c?(l=(0,I.jsx)(qM.button,{type:`button`,...i,ref:t,onClick:c}),n[8]=t,n[9]=i,n[10]=c,n[11]=l):l=n[11],l});MP.displayName=`ComposerPrimitive.QuoteDismiss`;function NP(e){return e.composer.quote}function PP(e){return e.composer.quote?.text}var FP=Wv((e,t)=>{let n=z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{categories:o,activeCategoryId:s,isSearchMode:c,open:l}=DN();if(!l||s||c)return null;let u=r??`Categories`,d;n[4]!==o||n[5]!==i?(d=i(o),n[4]=o,n[5]=i,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,I.jsx)(qM.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});FP.displayName=`ComposerPrimitive.TriggerPopoverCategories`;var IP=Wv((e,t)=>{let n=z(30),r,i,a,o;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4]):({categoryId:r,onClick:i,onMouseMove:a,...o}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o);let{selectCategory:s,highlightIndex:c,categories:l,highlightedIndex:u,activeCategoryId:d,isSearchMode:f,popoverId:p}=DN(),m;n[5]!==r||n[6]!==s?(m=()=>{s(r)},n[5]=r,n[6]=s,n[7]=m):m=n[7];let h=m,g;if(n[8]!==l||n[9]!==r){let e;n[11]===r?e=n[12]:(e=e=>e.id===r,n[11]=r,n[12]=e),g=l.findIndex(e),n[8]=l,n[9]=r,n[10]=g}else g=n[10];let _=g,v=!d&&!f&&_===u,y;n[13]!==_||n[14]!==c?(y=()=>{c(_)},n[13]=_,n[14]=c,n[15]=y):y=n[15];let b=y,x=`${p}-option-${r}`,S=v?``:void 0,C;n[16]!==h||n[17]!==i?(C=AM(i,h),n[16]=h,n[17]=i,n[18]=C):C=n[18];let w;n[19]!==b||n[20]!==a?(w=AM(a,b),n[19]=b,n[20]=a,n[21]=w):w=n[21];let T;return n[22]!==t||n[23]!==v||n[24]!==o||n[25]!==x||n[26]!==S||n[27]!==C||n[28]!==w?(T=(0,I.jsx)(qM.button,{type:`button`,role:`option`,id:x,"aria-selected":v,"data-highlighted":S,...o,ref:t,onClick:C,onMouseMove:w}),n[22]=t,n[23]=v,n[24]=o,n[25]=x,n[26]=S,n[27]=C,n[28]=w,n[29]=T):T=n[29],T});IP.displayName=`ComposerPrimitive.TriggerPopoverCategoryItem`;var LP=Wv((e,t)=>{let n=z(12),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({children:i,"aria-label":r,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let{items:o,activeCategoryId:s,isSearchMode:c,open:l}=DN();if(!l||!s&&!c)return null;let u=r??`Items`,d;n[4]!==i||n[5]!==o?(d=i(o),n[4]=i,n[5]=o,n[6]=d):d=n[6];let f;return n[7]!==t||n[8]!==a||n[9]!==u||n[10]!==d?(f=(0,I.jsx)(qM.div,{role:`group`,"aria-label":u,...a,ref:t,children:d}),n[7]=t,n[8]=a,n[9]=u,n[10]=d,n[11]=f):f=n[11],f});LP.displayName=`ComposerPrimitive.TriggerPopoverItems`;var RP=Wv((e,t)=>{let n=z(30),r,i,a,o,s;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5]):({item:i,index:r,onClick:a,onMouseMove:o,...s}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s);let{selectItem:c,highlightIndex:l,items:u,highlightedIndex:d,activeCategoryId:f,isSearchMode:p,popoverId:m}=DN(),h;n[6]!==i||n[7]!==c?(h=()=>{c(i)},n[6]=i,n[7]=c,n[8]=h):h=n[8];let g=h,_;n[9]!==r||n[10]!==i.id||n[11]!==u?(_=r??u.findIndex(e=>e.id===i.id),n[9]=r,n[10]=i.id,n[11]=u,n[12]=_):_=n[12];let v=_,y=(p||f!==null)&&v===d,b;n[13]!==l||n[14]!==v?(b=()=>{l(v)},n[13]=l,n[14]=v,n[15]=b):b=n[15];let x=b,S=`${m}-option-${i.id}`,C=y?``:void 0,w;n[16]!==g||n[17]!==a?(w=AM(a,g),n[16]=g,n[17]=a,n[18]=w):w=n[18];let T;n[19]!==x||n[20]!==o?(T=AM(o,x),n[19]=x,n[20]=o,n[21]=T):T=n[21];let E;return n[22]!==t||n[23]!==y||n[24]!==s||n[25]!==S||n[26]!==C||n[27]!==w||n[28]!==T?(E=(0,I.jsx)(qM.button,{type:`button`,role:`option`,id:S,"aria-selected":y,"data-highlighted":C,...s,ref:t,onClick:w,onMouseMove:T}),n[22]=t,n[23]=y,n[24]=s,n[25]=S,n[26]=C,n[27]=w,n[28]=T,n[29]=E):E=n[29],E});RP.displayName=`ComposerPrimitive.TriggerPopoverItem`;var zP=Wv((e,t)=>{let n=z(10),r,i;n[0]===e?(r=n[1],i=n[2]):({onClick:r,...i}=e,n[0]=e,n[1]=r,n[2]=i);let{activeCategoryId:a,isSearchMode:o,goBack:s,open:c}=DN();if(!c||!a||o)return null;let l;n[3]!==s||n[4]!==r?(l=AM(r,s),n[3]=s,n[4]=r,n[5]=l):l=n[5];let u;return n[6]!==t||n[7]!==i||n[8]!==l?(u=(0,I.jsx)(qM.button,{type:`button`,...i,ref:t,onClick:l}),n[6]=t,n[7]=i,n[8]=l,n[9]=u):u=n[9],u});zP.displayName=`ComposerPrimitive.TriggerPopoverBack`;var BP=e=>{let t=z(8),{formatter:n,onExecute:r,removeOnExecute:i}=e,{register:a}=AN(),o=B(r),s,c;t[0]===r?(s=t[1],c=t[2]):(s=()=>{o.current=r},c=[r],t[0]=r,t[1]=s,t[2]=c),Vv(s,c);let l,u;return t[3]!==n||t[4]!==a||t[5]!==i?(l=()=>{let e={kind:`action`,formatter:n??eM,onExecute:e=>o.current(e),...i===void 0?{}:{removeOnExecute:i}};return a(e)},u=[a,n,i],t[3]=n,t[4]=a,t[5]=i,t[6]=l,t[7]=u):(l=t[6],u=t[7]),V(l,u),null};BP.displayName=`ComposerPrimitive.TriggerPopoverAction`;var VP=e=>{let t=z(7),{formatter:n,onInserted:r}=e,{register:i}=AN(),a=B(r),o,s;t[0]===r?(o=t[1],s=t[2]):(o=()=>{a.current=r},s=[r],t[0]=r,t[1]=o,t[2]=s),Vv(o,s);let c,l;return t[3]!==n||t[4]!==i?(c=()=>i({kind:`directive`,formatter:n??eM,onInserted:e=>a.current?.(e)}),l=[i,n],t[3]=n,t[4]=i,t[5]=c,t[6]=l):(c=t[5],l=t[6]),V(c,l),null};VP.displayName=`ComposerPrimitive.TriggerPopoverDirective`;var HP=Object.assign(jN,{Directive:VP,Action:BP}),UP=UM({AddAttachment:()=>CP,AttachmentByIndex:()=>TA,AttachmentDropzone:()=>wP,Attachments:()=>DA,Cancel:()=>SP,Dictate:()=>TP,DictationTranscript:()=>OP,If:()=>HA,Input:()=>xP,Queue:()=>kA,Quote:()=>AP,QuoteDismiss:()=>MP,QuoteText:()=>jP,Root:()=>BN,Send:()=>PN,StopDictation:()=>EP,Unstable_TriggerPopover:()=>HP,Unstable_TriggerPopoverBack:()=>zP,Unstable_TriggerPopoverCategories:()=>FP,Unstable_TriggerPopoverCategoryItem:()=>IP,Unstable_TriggerPopoverItem:()=>RP,Unstable_TriggerPopoverItems:()=>LP,Unstable_TriggerPopoverRoot:()=>mN,unstable_useTriggerPopoverRootContext:()=>nN,unstable_useTriggerPopoverRootContextOptional:()=>rN,unstable_useTriggerPopoverScopeContext:()=>DN,unstable_useTriggerPopoverScopeContextOptional:()=>ON,unstable_useTriggerPopoverTriggers:()=>aN,unstable_useTriggerPopoverTriggersOptional:()=>lN}),WP=Object.freeze({type:`complete`}),GP=Object.freeze({type:`text`,text:``,status:WP}),KP=()=>H(qP);function qP(e){return e.part.type!==`text`&&e.part.type!==`reasoning`?GP:e.part}var JP=Xv(null);function YP(e){let t=Qv(JP);if(!e?.optional&&!t)throw Error(`This component must be used within a SmoothContextProvider.`);return t}var{useSmoothStatus:ene,useSmoothStatusStore:XP}=Ej(YP,`useSmoothStatus`),ZP=250,QP=5,$P=class{animationFrameId=null;lastUpdateTime=Date.now();lastCommitTime=0;targetText=``;drainMs=ZP;maxCharIntervalMs=QP;maxCharsPerFrame=1/0;minCommitMs=0;currentText;setText;constructor(e,t){this.currentText=e,this.setText=t}start(){this.animationFrameId===null&&(this.lastUpdateTime=Date.now(),this.animate())}stop(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}animate=()=>{let e=Date.now(),t=e-this.lastUpdateTime,n=this.targetText.length-this.currentText.length,r=Math.min(this.maxCharIntervalMs,this.drainMs/n),i=Math.min(n,this.maxCharsPerFrame),a=0;for(;t>=r&&a<i;)a++,t-=r;a===i&&i===this.maxCharsPerFrame&&(t=0),this.animationFrameId=a===n?null:requestAnimationFrame(this.animate),a!==0&&(this.currentText=this.targetText.slice(0,this.currentText.length+a),this.lastUpdateTime=e-t,(a===n||e-this.lastCommitTime>=this.minCommitMs)&&(this.lastCommitTime=e,this.setText(this.currentText)))}},eF=Object.freeze({type:`running`}),tF=(e,t)=>e!==void 0&&e>0?e:t,nF=(e,t=!1)=>{let{text:n}=e,r=KN(`(prefers-reduced-motion: reduce)`),i=typeof t==`object`&&t?t:void 0,a=t!==!1&&t!==null&&!r,o=tF(i?.drainMs,ZP),s=tF(i?.maxCharIntervalMs,QP),c=tF(i?.maxCharsPerFrame,1/0),l=tF(i?.minCommitMs,0),[u,d]=Pv(e.status.type===`running`?``:n),f=xx(),p=H(()=>f.part),[m,h]=Pv(p);(p!==m||!n.startsWith(u))&&(h(p),d(e.status.type===`running`?``:n));let g=XP({optional:!0}),_=LM(t=>{if(d(t),g){let n=u!==t||e.status.type===`running`?eF:e.status;Jj(g).setState(n,!0)}});V(()=>{if(g){let t=a&&(u!==n||e.status.type===`running`)?eF:e.status;Jj(g).setState(t,!0)}},[g,a,n,u,e.status]);let[v]=Pv(new $P(u,_));V(()=>{v.drainMs=o,v.maxCharIntervalMs=s,v.maxCharsPerFrame=c,v.minCommitMs=l},[v,o,s,c,l]);let y=B(p);return V(()=>{if(!a){v.stop();return}let t=y.current!==p;if(y.current=p,t||!n.startsWith(v.targetText)){e.status.type===`running`?(v.currentText=``,v.targetText=n,v.lastCommitTime=0,v.start()):(v.currentText=n,v.targetText=n,v.stop(),_(n));return}if(v.targetText=n,e.status.type!==`running`){if(v.currentText===``){v.currentText=n,v.stop(),_(n);return}v.start();return}v.start()},[v,a,n,e.status.type,p,_]),V(()=>()=>{v.stop()},[v]),Fv(()=>a?{...e,text:u,status:n===u?e.status:eF}:e,[a,u,e,n])},rF=Object.freeze({type:`complete`}),iF=Object.freeze({type:`image`,image:``,status:rF}),aF=()=>H(oF);function oF(e){return e.part.type===`image`?e.part:iF}var sF=Wv((e,t)=>{let n=z(10),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({smooth:i,component:a,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=i===void 0||i,s=a===void 0?`span`:a,{text:c,status:l}=nF(KP(),o),u;return n[4]!==s||n[5]!==t||n[6]!==r||n[7]!==l.type||n[8]!==c?(u=(0,I.jsx)(s,{"data-status":l.type,...r,ref:t,children:c}),n[4]=s,n[5]=t,n[6]=r,n[7]=l.type,n[8]=c,n[9]=u):u=n[9],u});sF.displayName=`MessagePartPrimitive.Text`;var cF=Wv((e,t)=>{let n=z(4),{image:r}=aF(),i;return n[0]!==t||n[1]!==r||n[2]!==e?(i=(0,I.jsx)(qM.img,{src:r,...e,ref:t}),n[0]=t,n[1]=r,n[2]=e,n[3]=i):i=n[3],i});cF.displayName=`MessagePartPrimitive.Image`;var lF=UM({Image:()=>cF,InProgress:()=>PA,Messages:()=>MA,Text:()=>sF}),uF=e=>{let t=z(2),n=B(void 0),r;return t[0]===e?r=t[1]:(r=t=>{n.current&&=(n.current(),void 0),t&&(n.current=e(t))},t[0]=e,t[1]=r),r},dF=(e,t)=>{let n=e.trim().match(/^(\d+(?:\.\d+)?|\.\d+)(em|px|rem)$/);if(!n)return 1/0;let r=Number(n[1]),i=n[2];return i===`px`?r:i===`em`?r*(parseFloat(getComputedStyle(t).fontSize)||16):i===`rem`?r*(parseFloat(getComputedStyle(document.documentElement).fontSize)||16):1/0},fF=e=>e.dataset.messageId,pF=()=>{let e=document.createElement(`div`);return e.dataset.auiTopAnchorReserve=``,e.style.height=`0px`,e.style.flexShrink=`0`,e.style.pointerEvents=`none`,e.setAttribute(`aria-hidden`,`true`),e},mF=(e,t)=>{let n=`${t}px`;return e.style.height!==n&&(e.style.height=n,!0)},hF=e=>{let t=window.devicePixelRatio||1;return Math.round(e*t)/t},gF=()=>{let e=z(4),t=xx(),n;e[0]===t.message?n=e[1]:(n=()=>t.message,e[0]=t.message,e[1]=n);let r=H(n),i;return e[2]===r?i=e[3]:(i=e=>{let t=()=>{r.setIsHovering(!0)},n=()=>{r.setIsHovering(!1)};return e.addEventListener(`mouseenter`,t),e.addEventListener(`mouseleave`,n),e.matches(`:hover`)&&queueMicrotask(()=>r.setIsHovering(!0)),()=>{e.removeEventListener(`mouseenter`,t),e.removeEventListener(`mouseleave`,n),r.setIsHovering(!1)}},e[2]=r,e[3]=i),uF(i)},_F=()=>{let e=z(2),t=Oj(wF),n;return e[0]===t?n=e[1]:(n=e=>e.message.role===`user`&&e.message.index>0&&e.message.index===e.thread.messages.length-2&&e.thread.messages.at(-1)?.role===`assistant`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),H(n)},vF=()=>{let e=z(2),t=Oj(TF),n;return e[0]===t?n=e[1]:(n=e=>e.message.isLast&&e.message.role===`assistant`&&e.message.index>=1&&e.thread.messages.at(e.message.index-1)?.role===`user`&&(e.message.id===t||e.thread.isRunning),e[0]=t,e[1]=n),H(n)},yF=(e,t)=>{let n=z(3),r;return n[0]!==e||n[1]!==t?(r=n=>{if(e)return t.getState().registerAnchorElement(n)},n[0]=e,n[1]=t,n[2]=r):r=n[2],uF(r)},bF=e=>{let t=z(3),{active:n,threadViewportStore:r}=e,i;return t[0]!==n||t[1]!==r?(i=e=>{if(!n)return;let t=r.getState(),i=t.topAnchorMessageClamp;return t.registerAnchorTargetElement(e,{tallerThan:dF(i.tallerThan,e),visibleHeight:dF(i.visibleHeight,e)})},t[0]=n,t[1]=r,t[2]=i):i=t[2],uF(i)},xF=e=>{let t=z(7),n,r;t[0]===e?(n=t[1],r=t[2]):({forwardedRef:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i=gF(),a=oM(n,i),o=H(EF),s;return t[3]!==o||t[4]!==r||t[5]!==a?(s=(0,I.jsx)(qM.div,{...r,ref:a,"data-message-id":o}),t[3]=o,t[4]=r,t[5]=a,t[6]=s):s=t[6],s},SF=e=>{let t=z(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({forwardedRef:n,threadViewportStore:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=gF(),o=_F(),s=vF(),c=yF(o,i),l;t[4]!==s||t[5]!==i?(l={active:s,threadViewportStore:i},t[4]=s,t[5]=i,t[6]=l):l=t[6];let u=bF(l),d=oM(n,a,c,u),f=H(DF),p=o?``:void 0,m=s?``:void 0,h;return t[7]!==f||t[8]!==r||t[9]!==d||t[10]!==p||t[11]!==m?(h=(0,I.jsx)(qM.div,{...r,ref:d,"data-message-id":f,"data-aui-top-anchor-user":p,"data-aui-top-anchor-target":m}),t[7]=f,t[8]=r,t[9]=d,t[10]=p,t[11]=m,t[12]=h):h=t[12],h},CF=Wv((e,t)=>{let n=z(7),r=kj();if(r.getState().turnAnchor===`top`){let i;return n[0]!==t||n[1]!==e||n[2]!==r?(i=(0,I.jsx)(SF,{...e,forwardedRef:t,threadViewportStore:r}),n[0]=t,n[1]=e,n[2]=r,n[3]=i):i=n[3],i}let i;return n[4]!==t||n[5]!==e?(i=(0,I.jsx)(xF,{...e,forwardedRef:t}),n[4]=t,n[5]=e,n[6]=i):i=n[6],i});CF.displayName=`MessagePrimitive.Root`;function wF(e){return e.topAnchorTurn?.anchorId}function TF(e){return e.topAnchorTurn?.targetId}function EF(e){return e.message.id}function DF(e){return e.message.id}var OF={...kk,Text:()=>(0,I.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,I.jsx)(sF,{}),(0,I.jsx)(PA,{children:(0,I.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Image:()=>(0,I.jsx)(cF,{})},kF=e=>{let t=z(10);if(`children`in e){let n;return t[0]===e.children?n=t[1]:(n=(0,I.jsx)(Kk,{children:e.children}),t[0]=e.children,t[1]=n),n}let n,r;t[2]===e?(n=t[3],r=t[4]):({components:n,...r}=e,t[2]=e,t[3]=n,t[4]=r);let i;t[5]===n?i=t[6]:(i=n?{Text:n.Text??OF.Text,Image:n.Image??OF.Image,Reasoning:n.Reasoning??kk.Reasoning,Source:n.Source??kk.Source,File:n.File??kk.File,Unstable_Audio:n.Unstable_Audio??kk.Unstable_Audio,...`ChainOfThought`in n?{ChainOfThought:n.ChainOfThought}:{tools:n.tools,data:n.data,ToolGroup:n.ToolGroup??kk.ToolGroup,ReasoningGroup:n.ReasoningGroup??kk.ReasoningGroup},Empty:n.Empty,Quote:n.Quote,generativeUI:n.generativeUI}:OF,t[5]=n,t[6]=i);let a=i,o;return t[7]!==r||t[8]!==a?(o=(0,I.jsx)(Kk,{components:a,...r}),t[7]=r,t[8]=a,t[9]=o):o=t[9],o};kF.displayName=`MessagePrimitive.Parts`;var AF=e=>{let t=z(12),n;return t[0]!==e.assistant||t[1]!==e.copied||t[2]!==e.hasAttachments||t[3]!==e.hasBranches||t[4]!==e.hasContent||t[5]!==e.last||t[6]!==e.lastOrHover||t[7]!==e.speaking||t[8]!==e.submittedFeedback||t[9]!==e.system||t[10]!==e.user?(n=t=>{let{role:n,attachments:r,parts:i,branchCount:a,isLast:o,speech:s,isCopied:c,isHovering:l}=t.message;return!(e.hasBranches===!0&&a<2||e.user&&n!==`user`||e.assistant&&n!==`assistant`||e.system&&n!==`system`||e.lastOrHover===!0&&!l&&!o||e.last!==void 0&&e.last!==o||e.copied===!0&&!c||e.copied===!1&&c||e.speaking===!0&&s==null||e.speaking===!1&&s!=null||e.hasAttachments===!0&&(n!==`user`||!r?.length)||e.hasAttachments===!1&&n===`user`&&r?.length||e.hasContent===!0&&i.length===0||e.hasContent===!1&&i.length>0||e.submittedFeedback!==void 0&&(t.message.metadata.submittedFeedback?.type??null)!==e.submittedFeedback)},t[0]=e.assistant,t[1]=e.copied,t[2]=e.hasAttachments,t[3]=e.hasBranches,t[4]=e.hasContent,t[5]=e.last,t[6]=e.lastOrHover,t[7]=e.speaking,t[8]=e.submittedFeedback,t[9]=e.system,t[10]=e.user,t[11]=n):n=t[11],H(n)},jF=e=>{let t=z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),AF(r)?n:null};jF.displayName=`MessagePrimitive.If`;var MF=e=>{let{children:t}=e;return lj()===void 0?null:t};MF.displayName=`MessagePrimitive.Error`;var NF=e=>{let t=new Map;for(let n=0;n<e.length;n++){let r=e[n]?.parentId??`__ungrouped_${n}`,i=t.get(r)??[];i.push(n),t.set(r,i)}let n=[];for(let[e,r]of t){let t=e.startsWith(`__ungrouped_`)?void 0:e;n.push({groupKey:t,indices:r})}return n},PF=e=>{let t=z(4),n=H(GF),r;bb0:{if(n.length===0){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],r=e;break bb0}let i;t[1]!==e||t[2]!==n?(i=e(n),t[1]=e,t[2]=n,t[3]=i):i=t[3],r=i}return r},FF=e=>{let t=z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.toolName?(i=e=>e.tools.toolUIs[r.toolName]?.[0]?.render??n,t[3]=n,t[4]=r.toolName,t[5]=i):i=t[5];let a=H(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,I.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},IF=e=>{let t=z(9),n,r;t[0]===e?(n=t[1],r=t[2]):({Fallback:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]!==n||t[4]!==r.name?(i=e=>{let t=e.dataRenderers.renderers[r.name]??n;return Array.isArray(t)?t[0]??n:t},t[3]=n,t[4]=r.name,t[5]=i):i=t[5];let a=H(i);if(!a)return null;let o;return t[6]!==a||t[7]!==r?(o=(0,I.jsx)(a,{...r}),t[6]=a,t[7]=r,t[8]=o):o=t[8],o},LF={Text:()=>(0,I.jsxs)(`p`,{style:{whiteSpace:`pre-line`},children:[(0,I.jsx)(sF,{}),(0,I.jsx)(PA,{children:(0,I.jsx)(`span`,{style:{fontFamily:`revert`},children:` ●`})})]}),Reasoning:()=>null,Source:()=>null,Image:()=>(0,I.jsx)(cF,{}),File:()=>null,Unstable_Audio:()=>null,Group:({children:e})=>e},RF=e=>{let t=z(37),{components:n}=e,r;t[0]===n?r=t[1]:(r=n===void 0?{}:n,t[0]=n,t[1]=r);let{Text:i,Reasoning:a,Image:o,Source:s,File:c,Unstable_Audio:l,tools:u,data:d}=r,f=i===void 0?LF.Text:i,p=a===void 0?LF.Reasoning:a,m=o===void 0?LF.Image:o,h=s===void 0?LF.Source:s,g=c===void 0?LF.File:c,_=l===void 0?LF.Unstable_Audio:l,v;t[2]===u?v=t[3]:(v=u===void 0?{}:u,t[2]=u,t[3]=v);let y=v,b=xx(),x=H(KF),S=x.type;if(S===`tool-call`){let e=b.part.addToolResult,n=b.part.resumeToolCall,r=b.part.respondToToolApproval;if(`Override`in y){let i;return t[4]!==e||t[5]!==x||t[6]!==r||t[7]!==n||t[8]!==y.Override?(i=(0,I.jsx)(y.Override,{...x,addResult:e,resume:n,respondToApproval:r}),t[4]=e,t[5]=x,t[6]=r,t[7]=n,t[8]=y.Override,t[9]=i):i=t[9],i}let i=y.by_name?.[x.toolName]??y.Fallback,a;return t[10]!==i||t[11]!==e||t[12]!==x||t[13]!==r||t[14]!==n?(a=(0,I.jsx)(FF,{...x,Fallback:i,addResult:e,resume:n,respondToApproval:r}),t[10]=i,t[11]=e,t[12]=x,t[13]=r,t[14]=n,t[15]=a):a=t[15],a}if(x.status?.type===`requires-action`)throw Error(`Encountered unexpected requires-action status`);switch(S){case`text`:{let e;return t[16]!==f||t[17]!==x?(e=(0,I.jsx)(f,{...x}),t[16]=f,t[17]=x,t[18]=e):e=t[18],e}case`reasoning`:{let e;return t[19]!==p||t[20]!==x?(e=(0,I.jsx)(p,{...x}),t[19]=p,t[20]=x,t[21]=e):e=t[21],e}case`source`:{let e;return t[22]!==h||t[23]!==x?(e=(0,I.jsx)(h,{...x}),t[22]=h,t[23]=x,t[24]=e):e=t[24],e}case`image`:{let e;return t[25]!==m||t[26]!==x?(e=(0,I.jsx)(m,{...x}),t[25]=m,t[26]=x,t[27]=e):e=t[27],e}case`file`:{let e;return t[28]!==g||t[29]!==x?(e=(0,I.jsx)(g,{...x}),t[28]=g,t[29]=x,t[30]=e):e=t[30],e}case`audio`:{let e;return t[31]!==_||t[32]!==x?(e=(0,I.jsx)(_,{...x}),t[31]=_,t[32]=x,t[33]=e):e=t[33],e}case`data`:{let e=d?.by_name?.[x.name]??d?.Fallback,n;return t[34]!==e||t[35]!==x?(n=(0,I.jsx)(IF,{...x,Fallback:e}),t[34]=e,t[35]=x,t[36]=n):n=t[36],n}default:return console.warn(`Unknown message part type: ${S}`),null}},zF=Gv(e=>{let t=z(5),{partIndex:n,components:r}=e,i;t[0]===r?i=t[1]:(i=(0,I.jsx)(RF,{components:r}),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,I.jsx)(iT,{index:n,children:i}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a},(e,t)=>e.partIndex===t.partIndex&&e.components?.Text===t.components?.Text&&e.components?.Reasoning===t.components?.Reasoning&&e.components?.Source===t.components?.Source&&e.components?.Image===t.components?.Image&&e.components?.File===t.components?.File&&e.components?.Unstable_Audio===t.components?.Unstable_Audio&&e.components?.tools===t.components?.tools&&e.components?.data===t.components?.data&&e.components?.Group===t.components?.Group),BF=e=>{let t=z(6),{status:n,component:r}=e,i=n.type===`running`,a;t[0]!==r||t[1]!==n?(a=(0,I.jsx)(r,{type:`text`,text:``,status:n}),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o;return t[3]!==i||t[4]!==a?(o=(0,I.jsx)(aT,{text:``,isRunning:i,children:a}),t[3]=i,t[4]=a,t[5]=o):o=t[5],o},VF=Object.freeze({type:`complete`}),HF=Gv(e=>{let t=z(6),{components:n}=e,r=H(qF);if(n?.Empty){let e;return t[0]!==n.Empty||t[1]!==r?(e=(0,I.jsx)(n.Empty,{status:r}),t[0]=n.Empty,t[1]=r,t[2]=e):e=t[2],e}let i=n?.Text??LF.Text,a;return t[3]!==r||t[4]!==i?(a=(0,I.jsx)(BF,{status:r,component:i}),t[3]=r,t[4]=i,t[5]=a):a=t[5],a},(e,t)=>e.components?.Empty===t.components?.Empty&&e.components?.Text===t.components?.Text),UF=e=>{let t=z(9),{groupingFunction:n,components:r}=e,i=H(JF),a=PF(n),o;bb0:{if(i===0){let e;t[0]===r?e=t[1]:(e=(0,I.jsx)(HF,{components:r}),t[0]=r,t[1]=e),o=e;break bb0}let e;if(t[2]!==r||t[3]!==a){let n;t[5]===r?n=t[6]:(n=(e,t)=>{let n=r?.Group??LF.Group;return(0,I.jsx)(n,{groupKey:e.groupKey,indices:e.indices,children:e.indices.map(e=>(0,I.jsx)(zF,{partIndex:e,components:r},e))},`group-${t}-${e.groupKey??`ungrouped`}`)},t[5]=r,t[6]=n),e=a.map(n),t[2]=r,t[3]=a,t[4]=e}else e=t[4];o=e}let s=o,c;return t[7]===s?c=t[8]:(c=(0,I.jsx)(I.Fragment,{children:s}),t[7]=s,t[8]=c),c};UF.displayName=`MessagePrimitive.Unstable_PartsGrouped`;var WF=e=>{let t=z(6),n,r;t[0]===e?(n=t[1],r=t[2]):({components:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;return t[3]!==n||t[4]!==r?(i=(0,I.jsx)(UF,{...r,components:n,groupingFunction:NF}),t[3]=n,t[4]=r,t[5]=i):i=t[5],i};WF.displayName=`MessagePrimitive.Unstable_PartsGroupedByParentId`;function GF(e){return e.message.parts}function KF(e){return e.part}function qF(e){return e.message.status??VF}function JF(e){return e.message.parts.length}var YF=UM({AttachmentByIndex:()=>yA,Attachments:()=>xA,Content:()=>kF,Error:()=>MF,GenerativeUI:()=>xk,GroupedParts:()=>hA,If:()=>jF,PartByIndex:()=>jk,Parts:()=>kF,Quote:()=>gA,Root:()=>CF,Unstable_PartsGrouped:()=>UF,Unstable_PartsGroupedByParentId:()=>WF}),XF=e=>{let t=z(2),n=LM(e),r;return t[0]===n?r=t[1]:(r=e=>{let t=new ResizeObserver(()=>{n()}),r=new MutationObserver(e=>{e.some(ZF)&&n()});return t.observe(e),r.observe(e,{childList:!0,subtree:!0,attributes:!0,characterData:!0}),()=>{t.disconnect(),r.disconnect()}},t[0]=n,t[1]=r),uF(r)};function ZF(e){return e.type!==`attributes`||e.attributeName!==`style`}var QF=({autoScroll:e,scrollToBottomOnRunStart:t=!0,scrollToBottomOnInitialize:n=!0,scrollToBottomOnThreadSwitch:r=!0})=>{let i=B(null),a=H(e=>e.thread.messages.length>0),o=H(e=>e.thread.isRunning),s=B(!1),c=B(null),l=kj();e===void 0&&(e=l.getState().turnAnchor!==`top`);let u=B(0),d=B(0),f=B(0),p=B(0),m=B(null),h=B(e),g=Iv(e=>{let t=i.current;t&&(h.current=!0,m.current=e,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]),_=Iv(()=>{c.current!==null&&(cancelAnimationFrame(c.current),c.current=null)},[]),v=Iv(e=>{m.current=e,_(),c.current=requestAnimationFrame(()=>{c.current=null,g(e)})},[_,g]);Lv(()=>()=>_(),[_]);let y=Iv(()=>{let e=l.getState();return e.turnAnchor===`top`&&e.element.viewport===i.current&&e.element.anchor!==null},[l]),b=()=>{let t=i.current;if(!t)return;let n=l.getState().isAtBottom,r=Px(t);if(!(!r&&u.current<t.scrollTop)){let i=Ix({scrollTop:u.current,scrollHeight:d.current},t);r?(Fx(t)&&(m.current=null),e&&(h.current=!0)):i&&(_(),m.current=null,h.current=!1),(r||m.current===null)&&r!==n&&Jj(l).setState({isAtBottom:r})}u.current=t.scrollTop,d.current=t.scrollHeight},x=XF(()=>{let t=i.current;if(!t)return;let{scrollHeight:n,clientHeight:r}=t;if(n===f.current&&r===p.current)return;f.current=n,p.current=r;let a=m.current;a&&y()?m.current=null:a?g(a):e&&!(o&&y())&&h.current&&g(`instant`),b()}),S=uF(e=>{let t=()=>{m.current=null};return e.addEventListener(`scroll`,b),e.addEventListener(`pointerdown`,t),()=>{e.removeEventListener(`scroll`,b),e.removeEventListener(`pointerdown`,t)}});return Lv(()=>{if(n){if(!a){s.current=!1;return}s.current||(s.current=!0,m.current===null&&v(`instant`))}},[a,v,n]),HN(({behavior:e})=>{g(e)}),GS(`thread.runStart`,()=>{t&&l.getState().turnAnchor!==`top`&&v(`auto`)}),GS(`threads.selectionChanged`,()=>{r&&v(`instant`)}),oM(x,S,i)},$F=Wv((e,t)=>{let n=z(6),r=xx(),i,a;n[0]===r?(i=n[1],a=n[2]):(i=()=>{let e=e=>{if(e.key===`Escape`&&!(e.defaultPrevented||r.thread.source===null)&&r.thread.getState().speech!=null){e.preventDefault();try{r.thread.stopSpeaking()}catch(e){let t=e;if(!(t instanceof Error)||t.message!==`No message is being spoken`)throw t}}};return document.addEventListener(`keydown`,e),()=>{document.removeEventListener(`keydown`,e)}},a=[r],n[0]=r,n[1]=i,n[2]=a),V(i,a);let o;return n[3]!==e||n[4]!==t?(o=(0,I.jsx)(qM.div,{...e,ref:t}),n[3]=e,n[4]=t,n[5]=o):o=n[5],o});$F.displayName=`ThreadPrimitive.Root`;var eI=e=>{let{children:t}=e;return H(tI)?t:null};eI.displayName=`ThreadPrimitive.Empty`;function tI(e){return e.thread.isEmpty}var nI=e=>{let t=z(4),n;return t[0]!==e.disabled||t[1]!==e.empty||t[2]!==e.running?(n=t=>!(e.empty===!0&&!t.thread.isEmpty||e.empty===!1&&t.thread.isEmpty||e.running===!0&&!t.thread.isRunning||e.running===!1&&t.thread.isRunning||e.disabled===!0&&!t.thread.isDisabled||e.disabled===!1&&t.thread.isDisabled),t[0]=e.disabled,t[1]=e.empty,t[2]=e.running,t[3]=n):n=t[3],H(n)},rI=e=>{let t=z(3),n,r;return t[0]===e?(n=t[1],r=t[2]):({children:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),nI(r)?n:null};rI.displayName=`ThreadPrimitive.If`;var iI=(e,t)=>{let n=z(3),r;return n[0]!==t||n[1]!==e?(r=n=>{if(!e)return;let r=e(),i=()=>{let e=t?t(n):n.offsetHeight;r.setHeight(e)},a=new ResizeObserver(i);return a.observe(n),i(),()=>{a.disconnect(),r.unregister()}},n[0]=t,n[1]=e,n[2]=r):r=n[2],uF(r)},aI=e=>{let t=0,n=e;for(;n;)t+=n.offsetTop,n=n.offsetParent;return t},oI=(e,t)=>{let n=0,r=e;for(;r&&r!==t;)n+=r.offsetTop,r=r.offsetParent;return r===t?n:aI(e)-aI(t)},sI=({viewport:e,anchor:t,tallerThan:n,visibleHeight:r})=>{let i=oI(t,e),a=t.offsetHeight;return i+Math.max(0,a-(a<=n?a:r))},cI=({scrollHeight:e,...t})=>{let{viewport:n}=t,r=sI(t)+n.clientHeight;return Math.max(0,r-e)},lI=({viewport:e,reserve:t,...n})=>cI({viewport:e,...n,scrollHeight:e.scrollHeight-t.offsetHeight}),uI=e=>{let t=new ResizeObserver(e),n=new MutationObserver(e),r=null,i=null,a=null,o=()=>{t.disconnect(),n.disconnect(),r=null,i=null,a=null};return{target:(e,s,c)=>{(r!==e||i!==s||a!==c)&&(o(),t.observe(e),t.observe(s),t.observe(c),n.observe(c,{childList:!0,subtree:!0,characterData:!0}),r=e,i=s,a=c)},disconnect:o}},dI=e=>{let t=null;return{schedule:()=>{t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))},cancel:()=>{t!==null&&(cancelAnimationFrame(t),t=null)}}},fI=e=>{let t=null,n;function r(){let r=e.getState(),{viewport:o,anchor:s,target:c}=r.element,l=r.targetConfig;if(r.turnAnchor!==`top`||!o){a.disconnect(),t&&(mF(t,0),t.remove());return}if(!s&&!c&&!l&&r.topAnchorTurn){a.disconnect(),t?.parentElement&&t.parentElement.lastElementChild!==t&&t.parentElement.append(t);return}if(!s||!c||!l){a.disconnect(),t&&(mF(t,0),t.remove());return}if(t??=pF(),(t.parentElement!==c.parentElement||t.previousElementSibling!==c)&&c.after(t),a.target(o,s,c),mF(t,lI({viewport:o,anchor:s,reserve:t,...l}))){i.schedule();return}let u=fF(s);if(u!==void 0&&n===u)return;let d=hF(sI({viewport:o,anchor:s,...l}));Math.abs(o.scrollTop-d)>1&&o.scrollTo({top:d,behavior:`smooth`}),u!==void 0&&(n=u)}let i=dI(r),a=uI(i.schedule);i.schedule();let o=e.subscribe(i.schedule);return()=>{i.cancel(),o(),a.disconnect(),t?.remove()}},pI=e=>{let t=z(4),n=kj(),r,i;t[0]!==e||t[1]!==n?(r=()=>{if(e)return fI(n)},i=[e,n],t[0]=e,t[1]=n,t[2]=r,t[3]=i):(r=t[2],i=t[3]),Lv(r,i)},mI=(e,t)=>{if(!e)return!1;let n=t.findIndex(t=>t.id===e.targetId);return n<1?!1:t[n-1]?.id===e.anchorId&&t.slice(n+1).every(e=>e.role===`user`)},hI=({isRunning:e,messages:t})=>{if(!e)return null;let n=t.at(-1),r=t.at(-2);return r?.role!==`user`||n?.role!==`assistant`?null:{anchorId:r.id,targetId:n.id}},gI=e=>hI(e)?.anchorId,_I=e=>hI(e)?.targetId,vI=()=>iI(Oj(CI),wI),yI=()=>uF(Oj(TI)),bI=e=>{let t=z(19),n=kj(),r;t[0]===e?r=t[1]:(r=t=>{if(e)return gI(t.thread)},t[0]=e,t[1]=r);let i=H(r),a;t[2]===e?a=t[3]:(a=t=>{if(e)return _I(t.thread)},t[2]=e,t[3]=a);let o=H(a),s=Oj(EI),c;bb0:{if(!i||!o){c=null;break bb0}let e;t[4]!==i||t[5]!==o?(e={anchorId:i,targetId:o},t[4]=i,t[5]=o,t[6]=e):e=t[6],c=e}let l=c,u;t[7]!==e||t[8]!==s?(u=t=>e&&!!s&&mI(s,t.thread.messages),t[7]=e,t[8]=s,t[9]=u):u=t[9];let d=H(u),f,p;t[10]!==n||t[11]!==s||t[12]!==d?(f=()=>{s&&!d&&n.getState().setTopAnchorTurn(null)},p=[n,s,d],t[10]=n,t[11]=s,t[12]=d,t[13]=f,t[14]=p):(f=t[13],p=t[14]),Lv(f,p);let m,h;t[15]!==l||t[16]!==n?(m=()=>{if(!l)return;let e=n.getState(),t=e.topAnchorTurn;(t?.anchorId!==l.anchorId||t.targetId!==l.targetId)&&e.setTopAnchorTurn(l)},h=[l,n],t[15]=l,t[16]=n,t[17]=m,t[18]=h):(m=t[17],h=t[18]),Lv(m,h)},xI=Wv((e,t)=>{let n=z(18),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c,children:i,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l;n[7]!==r||n[8]!==o||n[9]!==s||n[10]!==c?(l={autoScroll:r,scrollToBottomOnRunStart:s,scrollToBottomOnInitialize:o,scrollToBottomOnThreadSwitch:c},n[7]=r,n[8]=o,n[9]=s,n[10]=c,n[11]=l):l=n[11];let u=QF(l),d=vI(),f=yI(),p=kj(),m;n[12]===p?m=n[13]:(m=p.getState(),n[12]=p,n[13]=m);let h=m.turnAnchor===`top`;bI(h),pI(h);let g=oM(t,u,d,f),_;return n[14]!==i||n[15]!==g||n[16]!==a?(_=(0,I.jsx)(qM.div,{...a,ref:g,children:i}),n[14]=i,n[15]=g,n[16]=a,n[17]=_):_=n[17],_});xI.displayName=`ThreadPrimitive.ViewportScrollable`;var SI=Wv((e,t)=>{let n=z(13),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({turnAnchor:a,topAnchorMessageClamp:i,...r}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o;n[4]!==i||n[5]!==a?(o={turnAnchor:a,topAnchorMessageClamp:i},n[4]=i,n[5]=a,n[6]=o):o=n[6];let s;n[7]!==r||n[8]!==t?(s=(0,I.jsx)(xI,{...r,ref:t}),n[7]=r,n[8]=t,n[9]=s):s=n[9];let c;return n[10]!==o||n[11]!==s?(c=(0,I.jsx)(Xj,{options:o,children:s}),n[10]=o,n[11]=s,n[12]=c):c=n[12],c});SI.displayName=`ThreadPrimitive.Viewport`;function CI(e){return e.registerViewport}function wI(e){return e.clientHeight}function TI(e){return e.registerViewportElement}function EI(e){return e.topAnchorTurn}var DI=Wv((e,t)=>{let n=z(3),r=oM(t,iI(Oj(OI),kI)),i;return n[0]!==e||n[1]!==r?(i=(0,I.jsx)(qM.div,{...e,ref:r}),n[0]=e,n[1]=r,n[2]=i):i=n[2],i});DI.displayName=`ThreadPrimitive.ViewportFooter`;function OI(e){return e.registerContentInset}function kI(e){let t=parseFloat(getComputedStyle(e).marginTop)||0;return e.offsetHeight+t}var AI=JM(`ThreadPrimitive.ScrollToBottom`,e=>{let t=z(5),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{behavior:r}=n,i=Oj(jI),a=kj(),o;return t[2]!==r||t[3]!==a?(o=()=>{a.getState().scrollToBottom({behavior:r})},t[2]=r,t[3]=a,t[4]=o):o=t[4],i?null:o},[`behavior`]);function jI(e){return e.isAtBottom}var MI=JM(`ThreadPrimitive.Suggestion`,e=>{let t=z(4),{prompt:n,send:r,clearComposer:i,autoSend:a}=e,o=r??a??!1,s;t[0]!==i||t[1]!==n||t[2]!==o?(s={prompt:n,send:o,clearComposer:i},t[0]=i,t[1]=n,t[2]=o,t[3]=s):s=t[3];let{disabled:c,trigger:l}=sj(s);return c?null:l},[`prompt`,`send`,`clearComposer`,`autoSend`,`method`]),NI=UM({Empty:()=>eI,If:()=>rI,MessageByIndex:()=>ck,Messages:()=>fk,Root:()=>$F,ScrollToBottom:()=>AI,Suggestion:()=>MI,SuggestionByIndex:()=>LA,Suggestions:()=>BA,Unstable_MessageById:()=>lk,Viewport:()=>SI,ViewportFooter:()=>DI,ViewportProvider:()=>Xj}),PI=Wv((e,t)=>{let n=z(4),r=H(FI),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,I.jsx)(qM.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});PI.displayName=`SuggestionPrimitive.Title`;function FI(e){return e.suggestion.title}var II=Wv((e,t)=>{let n=z(4),r=H(LI),i=e.children??r,a;return n[0]!==e||n[1]!==t||n[2]!==i?(a=(0,I.jsx)(qM.span,{...e,ref:t,children:i}),n[0]=e,n[1]=t,n[2]=i,n[3]=a):a=n[3],a});II.displayName=`SuggestionPrimitive.Description`;function LI(e){return e.suggestion.label}var RI=JM(`SuggestionPrimitive.Trigger`,e=>{let t=z(4),{send:n,clearComposer:r}=e,i=H(zI),a;t[0]!==r||t[1]!==i||t[2]!==n?(a={prompt:i,send:n,clearComposer:r},t[0]=r,t[1]=i,t[2]=n,t[3]=a):a=t[3];let{trigger:o,disabled:s}=sj(a);return s?null:o},[`send`,`clearComposer`]);function zI(e){return e.suggestion.prompt}var BI=UM({Description:()=>II,Title:()=>PI,Trigger:()=>RI}),VI={mode:`dify-sdk`,localApiUrl:`http://localhost:5688/api/ai/chat/stream`},HI={DIFY_CHAT_MESSAGES:`https://dify.app.hicloudapp.com/v1/chat-messages`,DIFY_CONVERSATIONS:`https://dify.app.hicloudapp.com/v1/conversations`,DIFY_MESSAGES:e=>`https://dify.app.hicloudapp.com/v1/messages?conversation_id=${e}`,DIFY_DELETE_CONVERSATION:e=>`https://dify.app.hicloudapp.com/v1/conversations/${e}`,LOCAL_AGENT_CHAT:`/local/api/ai/chat/demo`},UI={API_KEY:`app-gDlpetMgsv6zqeqd1NjJt9u7`,APP_ID:`test-app-id`,BASE_URL:`https://dify.app.hicloudapp.com/v1`},WI={apiKey:`app-gDlpetMgsv6zqeqd1NjJt9u7`,appId:`test-app-id`,baseUrl:`https://dify.app.hicloudapp.com/v1`},GI=()=>{if(!WI.apiKey)throw Error(`Dify API Key not configured. Set VITE_DIFY_API_KEY in .env.local`);if(!WI.appId)throw Error(`Dify App ID not configured. Set VITE_DIFY_APP_ID in .env.local`);return!0};function KI(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function qI(e,t=`|`){return e.map(e=>oL(e)).join(t)}function JI(e,t){return typeof t==`bigint`?t.toString():t}function YI(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function tne(e){return e==null}function XI(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function nne(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var ZI=Symbol(`evaluating`);function rne(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==ZI)return r===void 0&&(r=ZI,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function QI(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function $I(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function ine(e){return JSON.stringify(e)}function ane(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var eL=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function tL(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var one=YI(()=>{if(EL.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function nL(e){if(tL(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return tL(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function rL(e){return nL(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var sne=new Set([`string`,`number`,`symbol`]);function iL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function aL(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function U(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function oL(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function cne(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var lne={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function une(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return aL(e,$I(e._zod.def,{get shape(){let e={};for(let r of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,r))throw Error(`Unrecognized key: "${String(r)}"`);t[r]&&QI(e,r,n.shape[r])}return QI(this,`shape`,e),e},checks:[]}))}function dne(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return aL(e,$I(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e of Reflect.ownKeys(t)){if(!Object.prototype.hasOwnProperty.call(n.shape,e))throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&delete r[e]}return QI(this,`shape`,r),r},checks:[]}))}function fne(e,t){if(!nL(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return aL(e,$I(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return QI(this,`shape`,n),n}}))}function pne(e,t){if(!nL(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return aL(e,$I(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return QI(this,`shape`,n),n}}))}function mne(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return aL(e,$I(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return QI(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function sL(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);return aL(t,$I(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(r,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t of Reflect.ownKeys(r))i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return QI(this,`shape`,i),i},checks:[]}))}function hne(e,t,n){return aL(t,$I(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t of Reflect.ownKeys(n)){if(!Object.prototype.hasOwnProperty.call(i,t))throw Error(`Unrecognized key: "${String(t)}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t of Reflect.ownKeys(r))i[t]=new e({type:`nonoptional`,innerType:r[t]});return QI(this,`shape`,i),i}}))}function cL(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function gne(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function lL(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function uL(e){return typeof e==`string`?e:e?.message}function dL(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function fL(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:uL(e.inst?._zod.def?.error?.(e))??uL(a?.(e))??uL(t?.error?.(e))??uL(n.customError?.(e))??uL(n.localeError?.(e))??`Invalid input`,{inst:s,schema:c,continue:l,input:u,...d}=e;return d.path??=[],d.message=o,t?.reportInput&&(d.input=u),d}var _ne=/[\uD800-\uDBFF]/;function pL(e){let t=e.length;if(!_ne.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function mL(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function vne(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function hL(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function yne(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):bne(e,n,r.value)}}function gL(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function _L(e,t,n){return gL(e,t,n,!1)}function bne(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:gL(this,t,n.bind(this))},set(e){gL(this,t,e)}})}function xne(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var vL,yL=!1,Sne={configurable:!0,get(){yL=!0}};function bL(e,t,n){let r=Object.getPrototypeOf(e._zod);if(t in r&&vL!==e._zod){vL=void 0;return}vL=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Sne);let e=yL;yL=!1;try{let r=n(this);return yL?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),yL||=e,r}catch(n){throw delete this[t],yL||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}})}function Cne(e,t,n,r){let i=xne(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var wne=`~constantCatch`;function Tne(e){let t=()=>e;return t[wne]=!0,t}var xL,SL={value:void 0,enumerable:!1},CL=`captureStackTrace`in Error?Error:null;function Ene(e){let t=CL;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return CL=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function W(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){SL.value=new a(r);try{Object.defineProperty(n,"_zod",SL)}finally{SL.value=void 0}}if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),yne(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Ene(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var wL=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},TL=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(xL=globalThis).__zod_globalConfig??(xL.__zod_globalConfig={});var EL=globalThis.__zod_globalConfig;function DL(e){return e&&Object.assign(EL,e),EL}function Dne(){let e=this._zod;return e.message??=JSON.stringify(e.def,JI,2),e.message}function One(e){this._zod.message=e}var kne={get:Dne,set:One,enumerable:!0,configurable:!0},OL={value:void 0,enumerable:!1},kL={value:void 0,enumerable:!1},AL=new WeakSet([Object.prototype,Error.prototype]),jL=(e,t)=>{e.name=`$ZodError`,OL.value=e._zod,Object.defineProperty(e,"_zod",OL),kL.value=t,Object.defineProperty(e,"issues",kL),OL.value=void 0,kL.value=void 0,Object.defineProperty(e,"message",kne);let n=Object.getPrototypeOf(e);AL.has(n)||(AL.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))},ML=W(`$ZodError`,jL),NL=W(`$ZodError`,jL,void 0,{Parent:Error});function Ane(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function jne(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Ane(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Mne(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function PL(e,t){return{callee:t?.callee??e,Err:t?.Err}}var FL=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new wL;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>fL(e,o,DL())));throw eL(n,a?.callee??t),n}return s.value};return t},IL=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>fL(e,o,DL())));throw eL(n,a?.callee??t),n}return s.value};return t},LL=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new wL;return a.issues.length?{success:!1,error:new(e??ML)(a.issues.map(e=>fL(e,i,DL())))}:{success:!0,data:a.value}},Nne=LL(NL),RL=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>fL(e,i,DL())))}:{success:!0,data:a.value}},Pne=RL(NL),Fne=e=>{let t=FL(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,PL(n,a))};return n},Ine=e=>{let t=FL(e),n=(e,r,i,a)=>t(e,r,i,PL(n,a));return n},Lne=e=>{let t=IL(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,PL(n,a))};return n},Rne=e=>{let t=IL(e),n=async(e,r,i,a)=>await t(e,r,i,PL(n,a));return n},zne=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return LL(e)(t,n,i)},Bne=e=>(t,n,r)=>LL(e)(t,n,r),Vne=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return RL(e)(t,n,i)},Hne=e=>async(t,n,r)=>RL(e)(t,n,r),Une=/^[cC][0-9a-z]{6,}$/,Wne=/^[0-9a-z]+$/,Gne=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Kne=/^[0-9a-vA-V]{20}$/,qne=/^[A-Za-z0-9]{27}$/,Jne=/^[a-zA-Z0-9_-]{21}$/;function Yne(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Xne=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Zne=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,zL=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Qne=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,$ne=`^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function BL(){return new RegExp($ne,`u`)}var VL=/^(?:(?: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])$/,HL=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,UL=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,WL=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,GL=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,KL=/^[A-Za-z0-9_-]*$/,qL=/^https?$/,JL=/^\+[1-9]\d{6,14}$/,YL=`(?:(?:\\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])))`;function XL(e){return RegExp(`^${e}$`)}var ZL=XL(YL);function QL(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function $L(e){return RegExp(`^${QL(e)}$`)}function eR(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${QL({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${QL({precision:e.precision})}`:n;return RegExp(`^${YL}T(?:${r})$`)}var tR=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},nR=/^-?\d+$/,rR=/^-?\d+(?:\.\d+)?$/,iR=/^(?:true|false)$/i,aR=/^null$/i,oR=/^[^A-Z]*$/,sR=/^[^a-z]*$/,cR=W(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),lR=e=>{let t=e.value;return!tne(t)&&t.length!==void 0},uR={number:`number`,bigint:`bigint`,object:`date`},dR=W(`$ZodCheckLessThan`,(e,t)=>{cR.init(e,t);let n=uR[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:uR[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),fR=W(`$ZodCheckGreaterThan`,(e,t)=>{cR.init(e,t);let n=uR[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:uR[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pR=W(`$ZodCheckMultipleOf`,(e,t)=>{cR.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):nne(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),mR=W(`$ZodCheckNumberFormat`,(e,t)=>{cR.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=lne[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=nR)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),hR=W(`$ZodCheckMaxLength`,(e,t)=>{var n;cR.init(e,t),(n=e._zod.def).when??(n.when=lR),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?pL(r):i)<=t.maximum)return;let a=mL(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gR=W(`$ZodCheckMinLength`,(e,t)=>{var n;cR.init(e,t),(n=e._zod.def).when??(n.when=lR),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?pL(r):i)>=t.minimum)return;let a=mL(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),_R=W(`$ZodCheckLengthEquals`,(e,t)=>{var n;cR.init(e,t),(n=e._zod.def).when??(n.when=lR),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?pL(r):i;if(a===t.length)return;let o=mL(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),vR=W(`$ZodCheckStringFormat`,(e,t)=>{var n,r;cR.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),yR=W(`$ZodCheckRegex`,(e,t)=>{vR.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),bR=W(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=oR,vR.init(e,t)}),xR=W(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=sR,vR.init(e,t)}),SR=W(`$ZodCheckIncludes`,(e,t)=>{cR.init(e,t);let n=iL(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),CR=W(`$ZodCheckStartsWith`,(e,t)=>{cR.init(e,t);let n=RegExp(`^${iL(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),wR=W(`$ZodCheckEndsWith`,(e,t)=>{cR.init(e,t);let n=RegExp(`.*${iL(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),TR=W(`$ZodCheckOverwrite`,(e,t)=>{cR.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),ER=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
29
|
-
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
30
|
-
`)}\n};`)(...Object.values(this.closed))}},DR={major:4,minor:5,patch:4},OR=W(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=DR;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=cL(t),a;for(let o of n){if(o._zod.def.when){if(gne(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new wL;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(dL(t.issues,n,e),i||=cL(t,n))});else{if(t.issues.length===n)continue;dL(t.issues,n,e),i||=cL(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(cL(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new wL;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new wL;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return _L(this,`~standard`,AR(this))},set"~standard"(e){gL(this,`~standard`,e)}}),kR=e=>e.success?{value:e.data}:{issues:e.error?.issues};function AR(e){return{validate:t=>{try{return kR(Nne(e,t))}catch{return Pne(e,t).then(kR)}},vendor:`zod`,version:1}}var jR=W(`$ZodString`,(e,t)=>{OR.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??tR(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),MR=W(`$ZodStringFormat`,(e,t)=>{vR.init(e,t),jR.init(e,t)}),NR=W(`$ZodGUID`,(e,t)=>{t.pattern??=Zne,MR.init(e,t)}),PR=W(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=zL(e)}else t.pattern??=zL();MR.init(e,t)}),FR=W(`$ZodEmail`,(e,t)=>{t.pattern??=Qne,MR.init(e,t)});function IR(e,t){if(!t.normalize&&t.protocol?.source===qL.source&&!/^https?:\/\//i.test(e))return 1;try{return new URL(e)}catch{return 2}}var LR=/[\t\n\r]/g;function RR(e){return e.replace(LR,``)}function zR(e,t){return t.lastIndex=0,t.test(e.hostname)}function BR(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var VR=W(`$ZodURL`,(e,t)=>{MR.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=IR(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}t.hostname&&!zR(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!BR(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:RR(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),HR=W(`$ZodEmoji`,(e,t)=>{t.pattern??=BL(),MR.init(e,t)}),UR=W(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Jne:Yne(t.length),MR.init(e,t)}),WR=W(`$ZodCUID`,(e,t)=>{t.pattern??=Une,MR.init(e,t)}),GR=W(`$ZodCUID2`,(e,t)=>{t.pattern??=Wne,MR.init(e,t)}),KR=W(`$ZodULID`,(e,t)=>{t.pattern??=Gne,MR.init(e,t)}),qR=W(`$ZodXID`,(e,t)=>{t.pattern??=Kne,MR.init(e,t)}),JR=W(`$ZodKSUID`,(e,t)=>{t.pattern??=qne,MR.init(e,t)}),YR=W(`$ZodISODateTime`,(e,t)=>{t.pattern??=eR(t),MR.init(e,t),(t.local||t.precision===-1)&&(e._zod.bag.laxFormat=!0,e._zod.onattach.push(e=>{e._zod.bag.laxFormat=!0}))}),XR=W(`$ZodISODate`,(e,t)=>{t.pattern??=ZL,MR.init(e,t)}),ZR=W(`$ZodISOTime`,(e,t)=>{t.pattern??=$L(t),MR.init(e,t)}),QR=W(`$ZodISODuration`,(e,t)=>{t.pattern??=Xne,MR.init(e,t)}),$R=W(`$ZodIPv4`,(e,t)=>{t.pattern??=VL,MR.init(e,t),e._zod.bag.format=`ipv4`}),ez=/^[0-9a-fA-F:.]+$/;function tz(e){if(!ez.test(e))return!1;try{return new URL(`http://[${e}]`),!0}catch{return!1}}var nz=W(`$ZodIPv6`,(e,t)=>{t.pattern??=HL,MR.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{tz(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),rz=W(`$ZodCIDRv4`,(e,t)=>{t.pattern??=UL,MR.init(e,t)});function iz(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:tz(n)}var az=W(`$ZodCIDRv6`,(e,t)=>{t.pattern??=WL,MR.init(e,t),e._zod.check=n=>{iz(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function oz(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var sz=W(`$ZodBase64`,(e,t)=>{t.pattern??=GL,MR.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{oz(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function cz(e){if(!KL.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return oz(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var lz=W(`$ZodBase64URL`,(e,t)=>{t.pattern??=KL,MR.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{cz(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),uz=W(`$ZodE164`,(e,t)=>{t.pattern??=JL,MR.init(e,t)});function dz(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var fz=W(`$ZodJWT`,(e,t)=>{MR.init(e,t),e._zod.check=n=>{dz(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),pz=W(`$ZodNumber`,(e,t)=>{OR.init(e,t),e._zod.pattern=e._zod.bag.pattern??rR,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),mz=W(`$ZodNumberFormat`,(e,t)=>{mR.init(e,t),pz.init(e,t)}),hz=W(`$ZodBoolean`,(e,t)=>{OR.init(e,t),e._zod.pattern=iR,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),gz=W(`$ZodNull`,(e,t)=>{OR.init(e,t),e._zod.pattern=aR,e._zod.values=new Set([null]),e._zod.parse=(t,n)=>{let r=t.value;return r===null||t.issues.push({expected:`null`,code:`invalid_type`,input:r,inst:e}),t}}),_z=W(`$ZodAny`,(e,t)=>{OR.init(e,t),e._zod.parse=e=>e}),vz=W(`$ZodUnknown`,(e,t)=>{OR.init(e,t),e._zod.parse=e=>e}),yz=W(`$ZodNever`,(e,t)=>{OR.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function bz(e,t,n){e.issues.length&&t.issues.push(...lL(n,e.issues)),t.value[n]=e.value}var xz=W(`$ZodArray`,(e,t)=>{OR.init(e,t);let n=EL.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[];for(let e=0;e<a.length;e++){let n=a[e],s=t.element._zod.run({value:n,issues:[]},i);s instanceof Promise?o.push(s.then(t=>bz(t,r,e))):bz(s,r,e)}return o.length?Promise.all(o).then(()=>r):r}});function Sz(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...lL(n,e.issues))}if(!o&&i===void 0){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}}var Cz=[];function wz(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Cz,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=cne(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Tz(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin,d=c.optout;for(let i in t){if(s.has(i))continue;if(i===`__proto__`){l===`never`&&o.push(i);continue}if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Sz(e,n,i,t,u,d))):Sz(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Ez=new WeakMap,Dz=W(`$ZodObject`,(e,t)=>{if(OR.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Ez.set(t,e),Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),Ez.set(t,n),n}})}let n=YI(()=>wz(t));bL(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||QI(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let r=tL,i=t.catchall,a,o=EL.memoizer;o?.attach(e),e._zod.parse=(t,s)=>{a??=n.value;let c=t.value;if(!r(c))return t.issues.push({expected:`object`,code:`invalid_type`,input:c,inst:e}),t;t.value=o?o.alloc(e,t,{},s):{};let l=[],u=a.shape;for(let e of a.allKeys){if(e===`__proto__`)continue;let n=u[e],r=n._zod.optin,i=n._zod.optout,a=n._zod.run({value:c[e],issues:[]},s);a instanceof Promise?l.push(a.then(n=>Sz(n,t,e,c,r,i))):Sz(a,t,e,c,r,i)}return i?Tz(l,c,t,s,n.value,e):l.length?Promise.all(l).then(()=>t):t}}),Oz=W(`$ZodObjectJIT`,(e,t)=>{Dz.init(e,t);let n=e._zod.parse,r=YI(()=>wz(t)),i=EL.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new ER([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
31
|
-
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
32
|
-
const iss = ${e}.issues[i];
|
|
33
|
-
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
34
|
-
payload.issues.push(iss);
|
|
35
|
-
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:ine(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
36
|
-
const ${n}_present = ${i};
|
|
37
|
-
if (!${n}.issues.length || ${n}_present) {
|
|
38
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (${e}) {
|
|
42
|
-
newResult[${r}] = ${n}.value;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
`)}else f?o.write(`
|
|
47
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (${n}.value === undefined) {
|
|
51
|
-
if (${i}) {
|
|
52
|
-
newResult[${r}] = undefined;
|
|
53
|
-
}
|
|
54
|
-
} else {
|
|
55
|
-
newResult[${r}] = ${n}.value;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
`):o.write(`
|
|
59
|
-
const ${n}_present = ${i};
|
|
60
|
-
if (${n}.issues.length) {${c(n,r)}
|
|
61
|
-
}
|
|
62
|
-
if (!${n}_present && !${n}.issues.length) {
|
|
63
|
-
payload.issues.push({
|
|
64
|
-
code: "invalid_type",
|
|
65
|
-
expected: "nonoptional",
|
|
66
|
-
input: undefined,
|
|
67
|
-
path: [${r}]
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (${n}_present) {
|
|
72
|
-
newResult[${r}] = ${n}.value;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=tL,c=!EL.jitless,l=c&&one.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Tz([],p,i,f,d,e):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function kz(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!cL(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>fL(e,r,DL())))}),t)}var Az=W(`$ZodUnion`,(e,t)=>{OR.init(e,t),bL(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),bL(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),bL(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),bL(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>XI(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>kz(t,r,e,i)):kz(o,r,e,i)}}),jz=W(`$ZodDiscriminatedUnion`,(e,t)=>{t.inclusive=!1,Az.init(e,t);let n=e._zod.parse;bL(e,`propValues`,e=>{let t={};for(let n of e.def.options){let r=n._zod.propValues;if(!r||Object.keys(r).length===0)throw Error(`Invalid discriminated union option at index "${e.def.options.indexOf(n)}"`);for(let[e,n]of Object.entries(r)){Object.prototype.hasOwnProperty.call(t,e)||QI(t,e,new Set);for(let r of n)t[e].add(r)}}return t}),t.options.forEach((e,n)=>{let r=Ez.get(e._zod.def);if(r&&!Object.prototype.hasOwnProperty.call(r,t.discriminator))throw Error(`Invalid discriminated union option at index "${n}"`)});let r=YI(()=>{let e=t.options,n=new Map;for(let r of e){let e=r._zod.propValues?.[t.discriminator];if(!e||e.size===0)throw Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(let t of e){if(n.has(t))throw Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(i,a)=>{let o=i.value;if(!tL(o))return i.issues.push({code:`invalid_type`,expected:`object`,input:o,inst:e}),i;let s=r.value.get(o?.[t.discriminator]);return s?s._zod.run(i,a):t.unionFallback||a.direction===`backward`?n(i,a):(i.issues.push({code:`invalid_union`,errors:[],note:`No matching discriminator`,discriminator:t.discriminator,options:Array.from(r.value.keys()),input:o,path:[t.discriminator],inst:e}),i)}}),Mz=W(`$ZodIntersection`,(e,t)=>{OR.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Pz(e,t,n)):Pz(e,i,a)}});function Nz(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(nL(e)&&nL(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Nz(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Nz(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Pz(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Nz(t.value,n.value);if(!c.valid){if(cL(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Fz=W(`$ZodRecord`,(e,t)=>{OR.init(e,t);let n=EL.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!nL(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>fL(e,i,DL())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(...lL(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(...lL(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&rR.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>fL(e,i,DL())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(...lL(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(...lL(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Iz=W(`$ZodEnum`,(e,t)=>{OR.init(e,t);let n=KI(t.entries),r=new Set(n);e._zod.values=r;let i=n.filter(e=>sne.has(typeof e));e._zod.pattern=RegExp(i.length?`^(${i.map(e=>iL(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Lz=W(`$ZodLiteral`,(e,t)=>{OR.init(e,t);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(t.values.length?`^(${t.values.map(e=>typeof e==`string`?iL(e):e?iL(e.toString()):String(e)).join(`|`)})$`:`^[^\\s\\S]$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}}),Rz=W(`$ZodTransform`,(e,t)=>{OR.init(e,t),e._zod.optin=`optional`,EL.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new TL(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new wL;return n.value=i,n}});function zz(e,t){return e.value=t.issues.length?void 0:t.value,e}var Bz=W(`$ZodOptional`,(e,t)=>{OR.init(e,t),bL(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,bL(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),bL(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${XI(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>zz(e,t)):zz(e,r)}return t.innerType._zod.run(e,n)}}),Vz=W(`$ZodExactOptional`,(e,t)=>{Bz.init(e,t),bL(e,`values`,e=>e.def.innerType._zod.values),bL(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Hz=W(`$ZodNullable`,(e,t)=>{OR.init(e,t),bL(e,`optin`,e=>e.def.innerType._zod.optin),bL(e,`optout`,e=>e.def.innerType._zod.optout),bL(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${XI(t.source)}|null)$`):void 0}),bL(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Uz=W(`$ZodDefault`,(e,t)=>{OR.init(e,t),e._zod.optin=`defaulted`,bL(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Wz(e,t)):Wz(r,t)}});function Wz(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Gz=W(`$ZodPrefault`,(e,t)=>{OR.init(e,t),e._zod.optin=`defaulted`,bL(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Kz=W(`$ZodNonOptional`,(e,t)=>{OR.init(e,t),bL(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>qz(t,e)):qz(i,e)}});function qz(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Jz(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>fL(e,r,DL()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Yz=W(`$ZodCatch`,(e,t)=>{OR.init(e,t),bL(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),bL(e,`optout`,e=>e.def.innerType._zod.optout),bL(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Jz(e,r,t,n)):Jz(e,r,t,n)}}),Xz=W(`$ZodPipe`,(e,t)=>{OR.init(e,t),bL(e,`values`,e=>e.def.in._zod.values),bL(e,`optin`,e=>e.def.in._zod.optin),bL(e,`optout`,e=>e.def.out._zod.optout),bL(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Zz(e,t.in,n)):Zz(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Zz(e,t.out,n)):Zz(r,t.out,n)}});function Zz(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var Qz=W(`$ZodReadonly`,(e,t)=>{OR.init(e,t),bL(e,`propValues`,e=>e.def.innerType._zod.propValues),bL(e,`values`,e=>e.def.innerType._zod.values),bL(e,`optin`,e=>e.def.innerType?._zod?.optin),bL(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then($z):$z(r)}});function $z(e){return e.memo||(e.value=Object.freeze(e.value)),e}var eB=W(`$ZodLazy`,(e,t)=>{OR.init(e,t),rne(e._zod,`innerType`,()=>{let e=t;return e._cachedInner||=t.getter(),e._cachedInner}),bL(e,`pattern`,e=>e.innerType?._zod?.pattern),bL(e,`propValues`,e=>e.innerType?._zod?.propValues),bL(e,`optin`,e=>e.innerType?._zod?.optin??void 0),bL(e,`optout`,e=>e.innerType?._zod?.optout??void 0),e._zod.parse=(t,n)=>e._zod.innerType._zod.run(t,n)}),tB=W(`$ZodCustom`,(e,t)=>{cR.init(e,t),OR.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>nB(t,n,r,e));nB(i,n,r,e)}});function nB(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(hL(e))}}var rB=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},iB=`~memo`,aB=[];function oB(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var sB=new WeakMap;function cB(e,t){let n=sB.get(e);if(n!==void 0)return n;if(t.has(e))return!0;t.add(e);let r=!1,i=e=>{!r&&e?._zod&&cB(e,t)&&(r=!0)},a=e._zod.def;switch(a.type){case`object`:for(let e of Reflect.ownKeys(a.shape))i(a.shape[e]);i(a.catchall);break;case`array`:i(a.element);break;case`tuple`:for(let e of a.items)i(e);i(a.rest);break;case`record`:case`map`:i(a.keyType),i(a.valueType);break;case`set`:i(a.valueType);break;case`union`:for(let e of a.options)i(e);break;case`intersection`:i(a.left),i(a.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:i(a.innerType);break;case`pipe`:i(a.in),i(a.out);break;case`function`:i(a.input),i(a.output);break;case`lazy`:i(e._zod.innerType);break;case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in a){let t=Object.getOwnPropertyDescriptor(a,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)i(n);else if(Array.isArray(n))for(let e of n)i(e)}}}return t.delete(e),sB.set(e,r),r}function lB(e,t){let n=e.buckets.get(t);return n||(n=new Map,e.buckets.set(t,n)),n}var uB,dB=[],fB={alloc(e,t,n){let r=uB;if(!r)return n;uB=void 0;let i={value:n,issues:null};return r.set(t.value,i),dB.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&mB(n,e.value))throw new rB;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,a=(o,s)=>{if(n===void 0&&(n=cB(e,new Set),!n))return e._zod.parse=t,e._zod.run===a&&(e._zod.run=t),t(o,s);let c=o.value;if(typeof c!=`object`||!c)return t(o,s);let l=s[iB];l||(l={buckets:new Map,backEdges:void 0},s[iB]=l);let u;r===s?u=i:(u=lB(l,e),r=s,i=u);let d=u.get(c);if(d)return o.value=d.value,d.issues?d.issues.length&&o.issues.push(...oB(d.issues)):(o.memo=!0,l.backEdges??(l.backEdges=new Set),l.backEdges.add(d.value)),o;uB=u;let f=dB.length,p=t(o,s);uB=void 0;let m=dB.length>f?dB.pop():void 0;return p instanceof Promise?p.then(e=>(m&&(m.issues=e.issues.length?oB(e.issues):aB),e)):(m&&(m.issues=p.issues.length?oB(p.issues):aB),p)};e._zod.parse=a,e._zod.run===t&&(e._zod.run=a)})}};function pB(){return fB}function mB(e,t){let n=e[iB]?.backEdges;return n!==void 0&&typeof t==`object`&&!!t&&n.has(t)}var hB=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,credit_card:`credit card number`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(vne(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${oL(e.values[0])}`:`Invalid option: expected one of ${qI(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${qI(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function gB(){return{localeError:hB()}}var _B,vB=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function yB(){return new vB}(_B=globalThis).__zod_globalRegistry??(_B.__zod_globalRegistry=yB());var bB=globalThis.__zod_globalRegistry;function xB(e,t){return new e({type:`string`,...U(t)})}function SB(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...U(t)})}function CB(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...U(t)})}function wB(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...U(t)})}function TB(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...U(t)})}function EB(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...U(t)})}function DB(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...U(t)})}function OB(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...U(t)})}function kB(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...U(t)})}function AB(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...U(t)})}function jB(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...U(t)})}function MB(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...U(t)})}function NB(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...U(t)})}function PB(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...U(t)})}function FB(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...U(t)})}function IB(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...U(t)})}function LB(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...U(t)})}function RB(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...U(t)})}function zB(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...U(t)})}function BB(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...U(t)})}function VB(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...U(t)})}function HB(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...U(t)})}function UB(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...U(t)})}function WB(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...U(t)})}function GB(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...U(t)})}function KB(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...U(t)})}function qB(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...U(t)})}function JB(e,t){return new e({type:`number`,checks:[],...U(t)})}function YB(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...U(t)})}function XB(e,t){return new e({type:`boolean`,...U(t)})}function ZB(e,t){return new e({type:`null`,...U(t)})}function QB(e){return new e({type:`any`})}function $B(e){return new e({type:`unknown`})}function eV(e,t){return new e({type:`never`,...U(t)})}function tV(e,t){return new dR({check:`less_than`,...U(t),value:e,inclusive:!1})}function nV(e,t){return new dR({check:`less_than`,...U(t),value:e,inclusive:!0})}function rV(e,t){return new fR({check:`greater_than`,...U(t),value:e,inclusive:!1})}function iV(e,t){return new fR({check:`greater_than`,...U(t),value:e,inclusive:!0})}function aV(e,t){return new pR({check:`multiple_of`,...U(t),value:e})}function oV(e,t){return new hR({check:`max_length`,...U(t),maximum:e})}function sV(e,t){return new gR({check:`min_length`,...U(t),minimum:e})}function cV(e,t){return new _R({check:`length_equals`,...U(t),length:e})}function lV(e,t){return new yR({check:`string_format`,format:`regex`,...U(t),pattern:e})}function uV(e){return new bR({check:`string_format`,format:`lowercase`,...U(e)})}function dV(e){return new xR({check:`string_format`,format:`uppercase`,...U(e)})}function fV(e,t){return new SR({check:`string_format`,format:`includes`,...U(t),includes:e})}function pV(e,t){return new CR({check:`string_format`,format:`starts_with`,...U(t),prefix:e})}function mV(e,t){return new wR({check:`string_format`,format:`ends_with`,...U(t),suffix:e})}function hV(e){return new TR({check:`overwrite`,tx:e})}function gV(e){return hV(t=>t.normalize(e))}function _V(){return hV(e=>e.trim())}function vV(){return hV(e=>e.toLowerCase())}function yV(){return hV(e=>e.toUpperCase())}function bV(){return hV(e=>ane(e))}function xV(e,t,n){return new e({type:`array`,element:t,...U(n)})}function SV(e,t,n){let r=U(n);return r.abort??=!0,new e({type:`custom`,check:`custom`,fn:t,...r})}function CV(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...U(n)})}function wV(e,t){let n=TV(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(hL(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(hL(r))}},e(t.value,t)),t);return n}function TV(e,t){let n=new cR({check:`custom`,...U(t)});return n._zod.check=e,n}function EV(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&QI(e,t,n[t]);return e}function DV(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??bB,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function OV(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function kV(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,kV(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&EV(o.schema,c),t.io===`input`&&zV(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function AV(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function jV(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${AV(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+AV(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
76
|
-
|
|
77
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}e.external&&(e.sharedDefsExtractedFor=e.external)}function MV(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;MV(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var NV=new Set([`type`,`properties`,`required`,`additionalProperties`]),PV=[`oneOf`,`anyOf`];function FV(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function IV(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!NV.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??FV(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}QI(n,r,e.length===1?e[0]:IV(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=FV(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function LV(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of NV)if(t in e)return;let n=t.filter(e=>PV.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=IV(t);else{let e=n[0],i=PV.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>IV([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,EV(e,r))}function RV(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):EV(i,s),EV(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())MV(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])LV(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}EV(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,QI(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:VV(t,`input`,e.processors),output:VV(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function zV(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return zV(r.element,n);if(r.type===`set`)return zV(r.valueType,n);if(r.type===`lazy`)return zV(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return zV(r.innerType,n);if(r.type===`intersection`)return zV(r.left,n)||zV(r.right,n);if(r.type===`record`||r.type===`map`)return zV(r.keyType,n)||zV(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:zV(r.in,n)||zV(r.out,n);if(r.type===`object`){for(let e in r.shape)if(zV(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(zV(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(zV(e,n))return!0;return!!(r.rest&&zV(r.rest,n))}return!1}var BV=(e,t={})=>n=>{let r=DV({...n,processors:t});return kV(e,r),jV(r,e),RV(r,e)},VV=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=DV({...i??{},target:a,io:t,processors:n});return kV(e,o),jV(o,e),RV(o,e)},HV={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},UV=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=HV[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},WV=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;i.type=typeof s==`string`&&s.includes(`int`)?`integer`:`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(Number.isFinite(c)&&c!==0?i.multipleOf=Math.abs(c):OV(e,t,i,r,`A multipleOf divisor of ${c} cannot be represented in JSON Schema`))},GV=(e,t,n,r)=>{n.type=`boolean`},KV=(e,t,n,r)=>{OV(e,t,n,r,`BigInt cannot be represented in JSON Schema`)},qV=(e,t,n,r)=>{OV(e,t,n,r,`Symbols cannot be represented in JSON Schema`)},JV=(e,t,n,r)=>{t.target===`openapi-3.0`?(n.type=`string`,n.nullable=!0,n.enum=[null]):n.type=`null`},YV=(e,t,n,r)=>{OV(e,t,n,r,`Undefined cannot be represented in JSON Schema`)},XV=(e,t,n,r)=>{OV(e,t,n,r,`Void cannot be represented in JSON Schema`)},ZV=(e,t,n,r)=>{n.not={}},QV=(e,t,n,r)=>{},$V=(e,t,n,r)=>{},eH=(e,t,n,r)=>{OV(e,t,n,r,`Date cannot be represented in JSON Schema`)},tH=(e,t,n,r)=>{let i=e._zod.def,a=KI(i.entries);if(a.length===0){n.not={};return}a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},nH=(e,t,n,r)=>{let i=e._zod.def;if(i.values.length===0){n.not={};return}let a=[];for(let o of i.values)if(o===void 0){if(OV(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof o==`bigint`){if(OV(e,t,n,r,`BigInt literals cannot be represented in JSON Schema`))return;a.push(Number(o))}else a.push(o);if(a.length!==0){if(a.length===1){let e=a[0];n.type=e===null?`null`:typeof e,t.target===`draft-04`||t.target===`openapi-3.0`?n.enum=[e]:n.const=e}else a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),a.every(e=>typeof e==`boolean`)&&(n.type=`boolean`),a.every(e=>e===null)&&(n.type=`null`),n.enum=a}},rH=(e,t,n,r)=>{OV(e,t,n,r,`NaN cannot be represented in JSON Schema`)},iH=(e,t,n,r)=>{let i=n,a=e._zod.pattern;if(!a)throw Error(`Pattern not found in template literal`);i.type=`string`,i.pattern=a.source},aH=(e,t,n,r)=>{let i=n,a={type:`string`,format:`binary`,contentEncoding:`binary`},{minimum:o,maximum:s,mime:c}=e._zod.bag;o!==void 0&&(a.minLength=o),s!==void 0&&(a.maxLength=s),c?c.length===1?(a.contentMediaType=c[0],Object.assign(i,a)):(Object.assign(i,a),i.anyOf=c.map(e=>({contentMediaType:e}))):Object.assign(i,a)},oH=(e,t,n,r)=>{n.type=`boolean`},sH=(e,t,n,r)=>{OV(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},cH=(e,t,n,r)=>{OV(e,t,n,r,`Function types cannot be represented in JSON Schema`)},lH=(e,t,n,r)=>{OV(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},uH=(e,t,n,r)=>{OV(e,t,n,r,`Map cannot be represented in JSON Schema`)},dH=(e,t,n,r)=>{OV(e,t,n,r,`Set cannot be represented in JSON Schema`)},fH=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=kV(a.element,t,{...r,path:[...r.path,`items`]})};function pH(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?pH(t.out):t.type===`catch`?pH(t.innerType):e._zod.optin}var mH=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&OV(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)QI(i.properties,e,kV(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e];return t.io===`input`?pH(n)===void 0:n._zod.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=kV(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},hH=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>kV(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},gH=(e,t,n,r)=>{let i=e._zod.def,a=kV(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=kV(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},_H=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>kV(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?kV(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?pH(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=e._zod.bag;typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)};function vH(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=vH(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>vH(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i?(p.type=`string`,a||(p.pattern=(r.includes(`number`)?rR:nR).source),p):p}var yH=new WeakMap;function bH(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of yH.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=vH(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var xH=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=kV(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)QI(i.patternProperties,t.source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=kV(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=yH.get(t);n||(n=[],yH.set(t,n),t.deferred.push(()=>bH(t))),n.push(e)}i.additionalProperties=kV(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&pH(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},SH=(e,t,n,r)=>{let i=e._zod.def,a=kV(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},CH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},wH=Symbol();function TH(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(OV(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),wH):JSON.parse(o)}var EH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=TH(i.defaultValue,e,t,n,r);o!==wH&&(n.default=o)},DH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=TH(i.defaultValue,e,t,n,r);o!==wH&&(n._prefault=o)},OH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{OV(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},kH=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;kV(o,t,r);let s=t.seen.get(e);s.ref=o},AH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},jH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},MH=(e,t,n,r)=>{let i=e._zod.def;kV(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},NH=(e,t,n,r)=>{let i=e._zod.innerType;kV(i,t,r);let a=t.seen.get(e);a.ref=i},PH={string:UV,number:WV,boolean:GV,bigint:KV,symbol:qV,null:JV,undefined:YV,void:XV,never:ZV,any:QV,unknown:$V,date:eH,enum:tH,literal:nH,nan:rH,template_literal:iH,file:aH,success:oH,custom:sH,function:cH,transform:lH,map:uH,set:dH,array:fH,object:mH,union:hH,intersection:gH,tuple:_H,record:xH,nullable:SH,nonoptional:CH,default:EH,prefault:DH,catch:OH,pipe:kH,readonly:AH,promise:jH,optional:MH,lazy:NH};function FH(e,t){if(`_idmap`in e){let n=e,r=DV({...t,processors:PH}),i={};for(let e of n._idmap.entries()){let[t,n]=e;kV(n,r)}let a={};r.external={registry:n,uri:t?.uri,defs:i};for(let e of n._idmap.entries()){let[t,n]=e;jV(r,n),QI(a,t,RV(r,n))}return Object.keys(i).length>0&&(a.__shared={[r.target===`draft-2020-12`?`$defs`:`definitions`]:i}),{schemas:a}}let n=DV({...t,processors:PH});return kV(e,n),jV(n,e),RV(n,e)}var IH=new WeakSet([Object.prototype,Error.prototype]);function LH(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var RH=W(`ZodError`,(e,t)=>{ML.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);IH.has(n)||(IH.add(n),LH(n,`format`,e=>t=>Mne(e,t)),LH(n,`flatten`,e=>t=>jne(e,t)),LH(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,JI,2)}),LH(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,JI,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),zH=FL(RH),BH=IL(RH),VH=LL(RH),HH=RL(RH),UH=Fne(RH),WH=Ine(RH),GH=Lne(RH),KH=Rne(RH),qH=zne(RH),JH=Bne(RH),YH=Vne(RH),XH=Hne(RH);function ZH(){EL.localeError||DL(gB())}function QH(){EL.memoizer||DL({memoizer:pB()})}var $H=W(`ZodType`,(e,t)=>(ZH(),OR.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone($I(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return aL(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(DW(e,t))},superRefine(e,t){return this.check(OW(e,t))},overwrite(e){return this.check(hV(e))},optional(){return oW(this)},exactOptional(){return cW(this)},nullable(){return uW(this)},nullish(){return oW(uW(this))},nonoptional(e){return gW(this,e)},array(){return VU(this)},or(e){return KU([this,e])},and(e){return XU(this,e)},transform(e){return bW(this,iW(e))},default(e){return fW(this,e)},prefault(e){return mW(this,e)},catch(e){return vW(this,e)},pipe(e){return bW(this,e)},readonly(){return SW(this)},describe(e){let t=this.clone();return bB.add(t,{description:e}),t},meta(...e){if(e.length===0)return bB.get(this);let t=this.clone();return bB.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return _L(this,`~standard`,{...AR(this),jsonSchema:{input:VV(this,`input`),output:VV(this,`output`)}})},set"~standard"(e){gL(this,`~standard`,e)},parse:function e(t,n){return zH(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await BH(this,t,n,{callee:e})},safeParse(e,t){return VH(this,e,t)},async safeParseAsync(e,t){return HH(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){gL(this,`spa`,e)},encode:function e(t,n){return UH(this,t,n,{callee:e})},decode:function e(t,n){return WH(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await GH(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await KH(this,t,n,{callee:e})},safeEncode(e,t){return qH(this,e,t)},safeDecode(e,t){return JH(this,e,t)},async safeEncodeAsync(e,t){return YH(this,e,t)},async safeDecodeAsync(e,t){return XH(this,e,t)},toJSONSchema(e){return BV(this,{})(e)},get description(){return bB.get(this)?.description},get _def(){return this._zod.def}}),eU=W(`_ZodString`,(e,t)=>{jR.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>UV(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null},{regex(...e){return this.check(lV(...e))},includes(...e){return this.check(fV(...e))},startsWith(...e){return this.check(pV(...e))},endsWith(...e){return this.check(mV(...e))},min(...e){return this.check(sV(...e))},max(...e){return this.check(oV(...e))},length(...e){return this.check(cV(...e))},nonempty(...e){return this.check(sV(1,...e))},lowercase(e){return this.check(uV(e))},uppercase(e){return this.check(dV(e))},trim(){return this.check(_V())},normalize(...e){return this.check(gV(...e))},toLowerCase(){return this.check(vV())},toUpperCase(){return this.check(yV())},slugify(){return this.check(bV())}}),tU=W(`ZodString`,(e,t)=>{jR.init(e,t),eU.init(e,t)},{email(e){return this.check(SB(sU,e))},url(e){return this.check(OB(uU,e))},jwt(e){return this.check(UB(TU,e))},emoji(e){return this.check(kB(dU,e))},guid(e){return this.check(CB(cU,e))},uuid(e){return this.check(wB(lU,e))},uuidv4(e){return this.check(TB(lU,e))},uuidv6(e){return this.check(EB(lU,e))},uuidv7(e){return this.check(DB(lU,e))},nanoid(e){return this.check(AB(fU,e))},cuid(e){return this.check(jB(pU,e))},cuid2(e){return this.check(MB(mU,e))},ulid(e){return this.check(NB(hU,e))},base64(e){return this.check(BB(SU,e))},base64url(e){return this.check(VB(CU,e))},xid(e){return this.check(PB(gU,e))},ksuid(e){return this.check(FB(_U,e))},ipv4(e){return this.check(IB(vU,e))},ipv6(e){return this.check(LB(yU,e))},cidrv4(e){return this.check(RB(bU,e))},cidrv6(e){return this.check(zB(xU,e))},e164(e){return this.check(HB(wU,e))},datetime(e){return this.check(WB(rU,e))},date(e){return this.check(GB(iU,e))},time(e){return this.check(KB(aU,e))},duration(e){return this.check(qB(oU,e))}});function G(e){return xB(tU,e)}var nU=W(`ZodStringFormat`,(e,t)=>{MR.init(e,t),eU.init(e,t)}),rU=W(`ZodISODateTime`,(e,t)=>{YR.init(e,t),nU.init(e,t)}),iU=W(`ZodISODate`,(e,t)=>{XR.init(e,t),nU.init(e,t)}),aU=W(`ZodISOTime`,(e,t)=>{ZR.init(e,t),nU.init(e,t)}),oU=W(`ZodISODuration`,(e,t)=>{QR.init(e,t),nU.init(e,t)}),sU=W(`ZodEmail`,(e,t)=>{FR.init(e,t),nU.init(e,t)}),cU=W(`ZodGUID`,(e,t)=>{NR.init(e,t),nU.init(e,t)}),lU=W(`ZodUUID`,(e,t)=>{PR.init(e,t),nU.init(e,t)}),uU=W(`ZodURL`,(e,t)=>{VR.init(e,t),nU.init(e,t)}),dU=W(`ZodEmoji`,(e,t)=>{HR.init(e,t),nU.init(e,t)}),fU=W(`ZodNanoID`,(e,t)=>{UR.init(e,t),nU.init(e,t)}),pU=W(`ZodCUID`,(e,t)=>{WR.init(e,t),nU.init(e,t)}),mU=W(`ZodCUID2`,(e,t)=>{GR.init(e,t),nU.init(e,t)}),hU=W(`ZodULID`,(e,t)=>{KR.init(e,t),nU.init(e,t)}),gU=W(`ZodXID`,(e,t)=>{qR.init(e,t),nU.init(e,t)}),_U=W(`ZodKSUID`,(e,t)=>{JR.init(e,t),nU.init(e,t)}),vU=W(`ZodIPv4`,(e,t)=>{$R.init(e,t),nU.init(e,t)}),yU=W(`ZodIPv6`,(e,t)=>{nz.init(e,t),nU.init(e,t)}),bU=W(`ZodCIDRv4`,(e,t)=>{rz.init(e,t),nU.init(e,t)}),xU=W(`ZodCIDRv6`,(e,t)=>{az.init(e,t),nU.init(e,t)}),SU=W(`ZodBase64`,(e,t)=>{sz.init(e,t),nU.init(e,t)}),CU=W(`ZodBase64URL`,(e,t)=>{lz.init(e,t),nU.init(e,t)}),wU=W(`ZodE164`,(e,t)=>{uz.init(e,t),nU.init(e,t)}),TU=W(`ZodJWT`,(e,t)=>{fz.init(e,t),nU.init(e,t)}),EU=W(`ZodNumber`,(e,t)=>{pz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>WV(e,t,n,r);let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null},{gt(e,t){return this.check(rV(e,t))},gte(e,t){return this.check(iV(e,t))},min(e,t){return this.check(iV(e,t))},lt(e,t){return this.check(tV(e,t))},lte(e,t){return this.check(nV(e,t))},max(e,t){return this.check(nV(e,t))},int(e){return this.check(kU(e))},safe(e){return this.check(kU(e))},positive(e){return this.check(rV(0,e))},nonnegative(e){return this.check(iV(0,e))},negative(e){return this.check(tV(0,e))},nonpositive(e){return this.check(nV(0,e))},multipleOf(e,t){return this.check(aV(e,t))},step(e,t){return this.check(aV(e,t))},finite(){return this}});function DU(e){return JB(EU,e)}var OU=W(`ZodNumberFormat`,(e,t)=>{mz.init(e,t),EU.init(e,t)});function kU(e){return YB(OU,e)}var AU=W(`ZodBoolean`,(e,t)=>{hz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>GV(e,t,n,r)});function jU(e){return XB(AU,e)}var MU=W(`ZodNull`,(e,t)=>{gz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>JV(e,t,n,r)});function NU(e){return ZB(MU,e)}var PU=W(`ZodAny`,(e,t)=>{_z.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function FU(){return QB(PU)}var IU=W(`ZodUnknown`,(e,t)=>{vz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function LU(){return $B(IU)}var RU=W(`ZodNever`,(e,t)=>{yz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ZV(e,t,n,r)});function zU(e){return eV(RU,e)}var BU=W(`ZodArray`,(e,t)=>{QH(),xz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fH(e,t,n,r),e.element=t.element},{min(e,t){return this.check(sV(e,t))},nonempty(e){return this.check(sV(1,e))},max(e,t){return this.check(oV(e,t))},length(e,t){return this.check(cV(e,t))},unwrap(){return this.element}});function VU(e,t){return xV(BU,e,t)}var HU=W(`ZodObject`,(e,t)=>{QH(),Oz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mH(e,t,n,r),Cne(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return eW(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:LU()})},loose(){return this.clone({...this._zod.def,catchall:LU()})},strict(){return this.clone({...this._zod.def,catchall:zU()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return fne(this,e)},safeExtend(e){return pne(this,e)},merge(e){return mne(this,e)},pick(e){return une(this,e)},omit(e){return dne(this,e)},partial(...e){return sL(aW,this,e[0])},exactPartial(...e){return sL(sW,this,e[0],`exactPartial`)},required(...e){return hne(hW,this,e[0])}});function UU(e,t){return new HU({type:`object`,shape:e??{},...U(t)})}function WU(e,t){return new HU({type:`object`,shape:e,catchall:LU(),...U(t)})}var GU=W(`ZodUnion`,(e,t)=>{Az.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hH(e,t,n,r),e.options=t.options});function KU(e,t){return new GU({type:`union`,options:e,...U(t)})}var qU=W(`ZodDiscriminatedUnion`,(e,t)=>{GU.init(e,t),jz.init(e,t)});function JU(e,t,n){return new qU({type:`union`,options:t,discriminator:e,...U(n)})}var YU=W(`ZodIntersection`,(e,t)=>{Mz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gH(e,t,n,r)});function XU(e,t){return new YU({type:`intersection`,left:e,right:t})}var ZU=W(`ZodRecord`,(e,t)=>{QH(),Fz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xH(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function QU(e,t,n){return!t||!t._zod?new ZU({type:`record`,keyType:G(),valueType:e,...U(t)}):new ZU({type:`record`,keyType:e,valueType:t,...U(n)})}var $U=W(`ZodEnum`,(e,t)=>{Iz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tH(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new $U({...t,checks:[],...U(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new $U({...t,checks:[],...U(r),entries:i})}});function eW(e,t){return new $U({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...U(t)})}var tW=W(`ZodLiteral`,(e,t)=>{Lz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nH(e,t,n,r),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function nW(e,t){return new tW({type:`literal`,values:Array.isArray(e)?e:[e],...U(t)})}var rW=W(`ZodTransform`,(e,t)=>{QH(),Rz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>lH(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new TL(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(hL(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(hL(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function iW(e){return new rW({type:`transform`,transform:e})}var aW=W(`ZodOptional`,(e,t)=>{Bz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>MH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function oW(e){return new aW({type:`optional`,innerType:e})}var sW=W(`ZodExactOptional`,(e,t)=>{Vz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>MH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function cW(e){return new sW({type:`optional`,innerType:e})}var lW=W(`ZodNullable`,(e,t)=>{Hz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>SH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function uW(e){return new lW({type:`nullable`,innerType:e})}var dW=W(`ZodDefault`,(e,t)=>{Uz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>EH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function fW(e,t){return new dW({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():rL(t)}})}var pW=W(`ZodPrefault`,(e,t)=>{Gz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>DH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function mW(e,t){return new pW({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():rL(t)}})}var hW=W(`ZodNonOptional`,(e,t)=>{Kz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>CH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function gW(e,t){return new hW({type:`nonoptional`,innerType:e,...U(t)})}var _W=W(`ZodCatch`,(e,t)=>{Yz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>OH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function vW(e,t){return new _W({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:Tne(t)})}var yW=W(`ZodPipe`,(e,t)=>{Xz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>kH(e,t,n,r),e.in=t.in,e.out=t.out});function bW(e,t){return new yW({type:`pipe`,in:e,out:t})}var xW=W(`ZodReadonly`,(e,t)=>{Qz.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>AH(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function SW(e){return new xW({type:`readonly`,innerType:e})}var CW=W(`ZodLazy`,(e,t)=>{eB.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>NH(e,t,n,r),e.unwrap=()=>e._zod.def.getter()});function wW(e){return new CW({type:`lazy`,getter:e})}var TW=W(`ZodCustom`,(e,t)=>{tB.init(e,t),$H.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sH(e,t,n,r)});function EW(e,t){return SV(TW,e??(()=>!0),t)}function DW(e,t={}){return CV(TW,e,t)}function OW(e,t){return wV(e,t)}function kW(e,t={}){let n=new TW({type:`custom`,check:`custom`,fn:t=>t instanceof e,abort:!0,...U(t)});return n._zod.bag.Class=e,n._zod.check=t=>{t.value instanceof e||t.issues.push({code:`invalid_type`,expected:e.name,input:t.value,inst:n,path:[...n._zod.def.path??[]]})},n}var AW=UU({query:G().min(1).describe(`User message content`),inputs:QU(G(),G()).default({}).describe(`Custom variables`),response_mode:eW([`streaming`,`blocking`]).default(`streaming`),user:G().min(1).describe(`User identifier`),conversation_id:G().optional().describe(`Conversation ID for resuming`)}),jW=KU([UU({event:nW(`message`),message_id:G(),conversation_id:G(),answer:G().describe(`Current reply text fragment (streaming accumulation)`),created_at:DU().optional()}),UU({event:nW(`message_end`),message_id:G(),conversation_id:G(),metadata:QU(G(),LU()).optional()}),UU({event:nW(`agent_thought`),id:G().optional(),thought:G().optional().describe(`Thought content`),observation:G().optional().describe(`Observation result`),tool:G().optional().describe(`Tool name`),tool_input:G().optional().describe(`Tool input`),message_files:VU(LU()).optional()}),UU({event:nW(`error`),code:G().optional(),message:G(),status:DU().optional()}),UU({event:nW(`ping`)}),UU({event:nW(`workflow_started`),conversation_id:G(),message_id:G(),created_at:DU(),task_id:G(),workflow_run_id:G(),data:UU({id:G(),workflow_id:G(),inputs:QU(G(),LU()),created_at:DU(),reason:G().optional()})}),UU({event:nW(`node_started`),conversation_id:G(),message_id:G(),created_at:DU(),task_id:G(),workflow_run_id:G(),data:UU({id:G(),node_id:G(),node_type:G(),title:G(),index:DU(),predecessor_node_id:G().nullable(),inputs:LU().nullable(),inputs_truncated:jU(),created_at:DU(),extras:QU(G(),LU()),iteration_id:G().nullable(),loop_id:G().nullable(),agent_strategy:G().nullable()})}),UU({event:nW(`node_finished`),conversation_id:G(),message_id:G(),created_at:DU(),task_id:G(),workflow_run_id:G(),data:UU({id:G(),node_id:G(),node_type:G(),title:G(),index:DU(),predecessor_node_id:G().nullable(),inputs:QU(G(),LU()),inputs_truncated:jU(),process_data:QU(G(),LU()),process_data_truncated:jU(),outputs:QU(G(),LU()),outputs_truncated:jU(),status:G(),error:G().nullable(),elapsed_time:DU(),execution_metadata:LU().nullable(),created_at:DU(),finished_at:DU(),files:VU(LU()),iteration_id:G().nullable(),loop_id:G().nullable()})}),UU({event:nW(`workflow_finished`),conversation_id:G(),message_id:G(),created_at:DU(),task_id:G(),workflow_run_id:G(),data:UU({id:G(),workflow_id:G(),status:G(),outputs:QU(G(),LU()),error:G().nullable(),elapsed_time:DU(),total_tokens:DU(),total_steps:DU(),created_by:UU({id:G(),user:G()}),created_at:DU(),finished_at:DU(),exceptions_count:DU(),files:VU(LU())})})]),MW=e=>{if(!e.startsWith(`data:`))return null;let t=e.slice(5).trim();if(!t)return null;try{let e=JSON.parse(t),n=jW.safeParse(e);return n.success?n.data:null}catch{return null}},NW=e=>{let t=e.getReader(),n=new TextDecoder,r=``;return{async*[Symbol.asyncIterator](){try{for(;;){let{done:e,value:i}=await t.read();if(e){if(r.trim()){let e=MW(r);e&&(yield e)}return}r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
78
|
-
`);r=a.pop()??``;for(let e of a){let t=e.trim();if(!t)continue;let n=MW(t);n&&(yield n)}}}finally{t.releaseLock()}}}},PW=e=>{let t={query:e.query,inputs:e.inputs??{},response_mode:`streaming`,user:e.user,conversation_id:e.conversationId},n=AW.safeParse(t);if(!n.success)throw Error(`Dify request validation failed: ${n.error.message}`);return n.data},FW=async e=>{GI();let t=PW(e),n=await fetch(HI.DIFY_CHAT_MESSAGES,{method:`POST`,headers:{"Content-Type":`application/json`,Authorization:`Bearer ${WI.apiKey}`},body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>`Unknown error`);throw Error(`Dify API request failed (${n.status}): ${e}`)}if(!n.body)throw Error(`Dify API returned empty response body`);return NW(n.body)},IW=`ai-assist-conversation-id`,LW=`ai-assist-session-id`,RW=`ai-assist-history`,zW=50,BW=()=>{try{return sessionStorage.getItem(IW)}catch{return null}},VW=e=>{try{sessionStorage.setItem(IW,e)}catch{}},HW=()=>{try{let e=sessionStorage.getItem(LW);if(e)return e;let t=`anonymous_${crypto.randomUUID()}`;return sessionStorage.setItem(LW,t),t}catch{return`anonymous_${Date.now()}`}},UW=()=>{try{sessionStorage.removeItem(IW)}catch{}},WW=()=>{try{let e=localStorage.getItem(RW);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},GW=(e,t)=>{try{let n=WW(),r={conversationId:e,lastMessage:t,timestamp:Date.now()},i=n.filter(t=>t.conversationId!==e);i.unshift(r),localStorage.setItem(RW,JSON.stringify(i.slice(0,zW)))}catch{}},KW=`ai-assist-last-action-result`,qW=e=>{try{sessionStorage.setItem(KW,e)}catch{}},JW=()=>{try{return sessionStorage.getItem(KW)!==null}catch{return!1}},YW=()=>{try{let e=sessionStorage.getItem(KW)??``;return sessionStorage.removeItem(KW),e}catch{return``}},XW=e=>({log:(...e)=>void 0,warn:(...e)=>void 0,error:(...e)=>void 0}),ZW=/```action\s*([\s\S]*?)```/g,QW=XW(`[action-parser]`),$W=e=>{QW.log(`Parse start, input text length:`,e.length),QW.log(`Raw text preview:`,e.slice(0,200));let t=[];ZW.lastIndex=0;let n=/```action/.test(e);QW.log("Has ```action marker:",n);let r=(e.match(/```/g)||[]).length;if(QW.log(`Code fence count:`,r,`(should be even for balanced fences)`),!n)return QW.log("Parse failed: no ```action marker found in text"),QW.log(`Parse end, result count:`,0),[];(r<2||r%2!=0)&&QW.warn(`Unbalanced code fences detected`);let i=0,a;for(;(a=ZW.exec(e))!==null;){i++,QW.log(`--- Matched action block #${i} ---`),QW.log(`Match position: index=`,a.index,`~`,a.index+a[0].length);let e=a[1].trim();if(QW.log(`Extracted JSON string:`,e),!e){QW.log(`Skipped: empty JSON content`);continue}try{let n=JSON.parse(e);QW.log(`JSON parsed successfully:`,n),eG(n)?(QW.log(`Validation passed:`,n),t.push(n)):(QW.warn(`Validation failed: missing tool or params field, or wrong type`),QW.warn(`Expected structure: { tool: string, params: object }`),QW.warn(`Actual structure:`,JSON.stringify(n,null,2)))}catch(t){QW.error(`JSON parse failed:`,t instanceof Error?t.message:t),QW.error(`Raw string:`,e)}}return QW.log(`Regex match complete, matched`,i,`action blocks`),QW.log(`Valid action count:`,t.length),t.length===0&&i===0&&(QW.warn("Parse failed: regex did not match a complete ```action ... ``` structure"),QW.warn(`Possible causes:`),QW.warn(" 1. Missing closing ``` marker"),QW.warn(" 2. Extra characters between ``` and action"),QW.warn(" 3. Dify reply node not wrapped in ```action")),QW.log(`Parse end`),t},eG=e=>{if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.tool==`string`&&typeof t.params==`object`&&t.params!==null},tG=e=>e.replace(ZW,``).trim(),nG=[{name:`click_element`,description:`Click on a page element, such as add-to-cart button, navigation link, etc. (requires user confirmation)`,arguments:{data_attributes:`data-* attribute selector (e.g. [data-assistant-action='add-to-cart'])`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column (e.g. .btn-orange.px-3). Fill this first.`,text_match:`Exact visible text of the element (e.g. 'Add to Cart'). Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'nearby product title text from 父链上下文 column', targetSelector: 'simple tag name like button or a' }. Only use when css_selector and text_match are insufficient.`,confirmRequired:`true (always requires user confirmation for click)`}},{name:`fill_input`,description:`Fill content into an input field, such as search box, form field, etc. Auto-presses Enter after filling to trigger search/submit. (auto-execute)`,arguments:{data_attributes:`data-* attribute selector (e.g. [data-assistant-action='search-input'])`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Input placeholder or label text. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'label text', targetSelector: 'input' }`,value:`Content to fill (required)`}},{name:`scroll_to`,description:`Scroll the page to a specified element or position (auto-execute)`,arguments:{data_attributes:`data-* attribute selector for target element`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Text content of the element to scroll to. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'anchor text', targetSelector: 'simple tag name' }`,position:`Scroll position: top or bottom (alternative to element selectors)`}},{name:`navigate_to`,description:`Navigate to a specified URL (requires user confirmation)`,arguments:{url:`Target URL (required)`}},{name:`highlight_element`,description:`Highlight a page element to draw user attention (auto-execute)`,arguments:{data_attributes:`data-* attribute selector`,css_selector:`PRIMARY selector - direct CSS selector from the interactive elements table's '最佳选择器' column`,text_match:`Visible text of the element. Fill from '元素文本' column.`,anchor_context:`FALLBACK only - JSON: { anchorText: 'anchor text', targetSelector: 'simple tag name' }`}}],rG=JSON.stringify(nG);`
|
|
79
|
-
## Available Tools
|
|
80
|
-
|
|
81
|
-
You can use the following tools to help users interact with web pages. When an action needs to be performed, embed an instruction block in the reply using the following format:
|
|
82
|
-
|
|
83
|
-
\`\`\`action
|
|
84
|
-
{
|
|
85
|
-
"tool": "tool_name",
|
|
86
|
-
"params": { ... }
|
|
87
|
-
}
|
|
88
|
-
\`\`\`
|
|
89
|
-
|
|
90
|
-
### Tool List
|
|
91
|
-
|
|
92
|
-
${nG.map(e=>`
|
|
93
|
-
#### ${e.name}
|
|
94
|
-
${e.description}
|
|
95
|
-
Parameters: ${JSON.stringify(e.arguments)}`).join(`
|
|
96
|
-
`)}
|
|
97
|
-
|
|
98
|
-
### Usage Rules
|
|
99
|
-
1. Each reply may contain at most one instruction block
|
|
100
|
-
2. Instruction blocks must be wrapped in \`\`\`action
|
|
101
|
-
3. Parameter values must be strings (except anchor_context which is a JSON object)
|
|
102
|
-
4. Element location priority: css_selector > text_match > data_attributes > anchor_context
|
|
103
|
-
5. Use anchor_context ONLY when css_selector and text_match cannot uniquely identify the element (e.g. product cards with identical buttons)
|
|
104
|
-
6. click_element and navigate_to require user confirmation before execution
|
|
105
|
-
7. fill_input, scroll_to, and highlight_element execute automatically`.trim();var iG=XW(`[action-resolver]`),aG=e=>{let t=window.getComputedStyle(e);if(t.display===`none`||t.visibility===`hidden`||t.opacity===`0`)return!1;let n=e.getBoundingClientRect();return n.width>0&&n.height>0},oG=e=>{try{let t=document.querySelector(e);if(t&&aG(t))return t}catch{iG.log(`[strategy-1] invalid data_attributes selector:`,e)}return null},sG=(e,t)=>{if(!e)return null;let n=e.trim(),r=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:e=>e.textContent?.trim().includes(n)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}).nextNode();if(!r?.parentElement)return null;let i=r.parentElement;if(!aG(i))return null;let a=i.parentElement;for(let e=0;e<6&&a&&a!==document.body;e++){let e=a.querySelector(t);if(e&&aG(e))return e;a=a.parentElement}return null},cG=(e=``)=>{let t=e.trim(),n=Array.from(document.querySelectorAll(`button, a, [role="button"], input[type="submit"], input[type="button"]`));for(let e of n)if((e.textContent||``).trim()===t&&aG(e))return e;for(let e of n)if((e.textContent||``).trim().includes(t)&&aG(e))return e;return null},lG=e=>{try{let t=document.querySelector(e);if(t&&aG(t))return t}catch{iG.log(`[strategy-4] invalid css_selector:`,e)}return null},uG=e=>{if(iG.log(`[resolveElement] params:`,e),e.dataAttributes){let t=oG(e.dataAttributes);if(t)return{element:t,strategy:`data-attribute`}}if(e.anchorContext){let t=sG(e.anchorContext.anchorText,e.anchorContext.targetSelector);if(t)return{element:t,strategy:`anchor-context`}}if(e.textMatch){let t=cG(e.textMatch);if(t)return{element:t,strategy:`text-match`}}if(e.cssSelector){let t=lG(e.cssSelector);if(t)return{element:t,strategy:`css-selector`}}return null},dG=async e=>{let{element:t}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target element not found`};if(t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`)return{success:!1,error:`element_not_interactable`,message:`Element is disabled, cannot click`};let n=t.getBoundingClientRect();if(n.width===0||n.height===0)return{success:!1,error:`element_not_visible`,message:`Element is not visible, cannot click`};try{return t.scrollIntoView({behavior:`smooth`,block:`center`}),await new Promise(e=>setTimeout(e,300)),t.click(),{success:!0,message:`Clicked element: ${t.tagName.toLowerCase()}${t.id?`#${t.id}`:``}`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}}}catch(e){return{success:!1,error:`click_failed`,message:`Click failed: ${e instanceof Error?e.message:`Unknown error`}`}}},fG=async e=>{let{element:t,value:n}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target input element not found`};if(!(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t.getAttribute(`contenteditable`)===`true`))return{success:!1,error:`element_not_input`,message:`Target element is not an input`};if(!n)return{success:!1,error:`value_required`,message:`A value parameter is required for fill`};try{if(t.focus(),t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let e=Object.getOwnPropertyDescriptor(t instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype,`value`)?.set;e?e.call(t,n):t.value=n,t.dispatchEvent(new Event(`input`,{bubbles:!0})),t.dispatchEvent(new Event(`change`,{bubbles:!0}));let r=t.closest(`form`);if(r)r.requestSubmit();else{let e=t.parentElement;for(let n=0;n<2&&e;n++){let n=e.querySelector(`button, input[type="submit"], input[type="button"], a[role="button"], [role="button"]`);if(n&&n!==t){n.click();break}e=e.parentElement}}}return{success:!0,message:`Filled with: "${n}"`,data:{value:n}}}catch(e){return{success:!1,error:`fill_failed`,message:`Fill failed: ${e instanceof Error?e.message:`Unknown error`}`}}},pG=async e=>{let{element:t,position:n}=e;try{if(t)return t.scrollIntoView({behavior:`smooth`,block:`center`}),{success:!0,message:`Scrolled to target element`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}};if(n){let e={behavior:`smooth`};switch(n){case`top`:e.top=0;break;case`bottom`:e.top=document.documentElement.scrollHeight;break;default:return{success:!1,error:`invalid_position`,message:`Unsupported position: ${n} (only top/bottom allowed)`}}return window.scrollTo(e),{success:!0,message:n===`top`?`Scrolled to page top`:`Scrolled to page bottom`}}return{success:!1,error:`missing_target`,message:`element or position parameter is required`}}catch(e){return{success:!1,error:`scroll_failed`,message:`Scroll failed: ${e instanceof Error?e.message:`Unknown error`}`}}},mG=async e=>{let{url:t}=e;if(!t)return{success:!1,error:`url_required`,message:`URL is required for navigation`};try{let e=new URL(t,window.location.href);return window.location.href=e.href,{success:!0,message:`Navigating to: ${e.href}`,data:{url:e.href}}}catch(e){return{success:!1,error:`invalid_url`,message:`Invalid URL: ${e instanceof Error?e.message:`Unknown error`}`}}},hG=`ai-assistant-highlight`,gG=()=>{if(document.getElementById(`ai-assistant-highlight-style`))return;let e=document.createElement(`style`);e.id=`ai-assistant-highlight-style`,e.textContent=`
|
|
106
|
-
.${hG} {
|
|
107
|
-
outline: 3px solid #3b82f6 !important;
|
|
108
|
-
outline-offset: 2px !important;
|
|
109
|
-
box-shadow: 0 0 0 6px rgba(59, 130, 246, 0.3) !important;
|
|
110
|
-
transition: outline 0.3s, box-shadow 0.3s !important;
|
|
111
|
-
}
|
|
112
|
-
`,document.head.appendChild(e)},_G=()=>{document.querySelectorAll(`.${hG}`).forEach(e=>{e.classList.remove(hG)})},vG=async e=>{let{element:t}=e;if(!t)return{success:!1,error:`element_not_found`,message:`Target element not found`};try{return gG(),_G(),t.scrollIntoView({behavior:`smooth`,block:`center`}),await new Promise(e=>setTimeout(e,300)),t.classList.add(hG),setTimeout(()=>{t.classList.remove(hG)},5e3),{success:!0,message:`Element highlighted`,data:{tagName:t.tagName.toLowerCase(),text:(t.textContent||``).trim().slice(0,50)}}}catch(e){return{success:!1,error:`highlight_failed`,message:`Highlight failed: ${e instanceof Error?e.message:`Unknown error`}`}}},yG=class e{static findMainContent(t){return t.querySelector(`main, [role="main"]`)||(t.body?e.detectMainContent(t.body):t.documentElement)}static detectMainContent(t){let n=[];if(e.collectCandidates(t,n,15),n.length===0)return t;n.sort((t,n)=>e.calculateContentScore(n)-e.calculateContentScore(t));let r=n[0];for(let t=1;t<n.length;t++){let i=n[t];!n.some((e,n)=>n!==t&&e.contains(i))&&e.calculateContentScore(i)>e.calculateContentScore(r)&&(r=i)}return r}static collectCandidates(t,n,r){e.calculateContentScore(t)>=r&&n.push(t),Array.from(t.children).forEach(t=>{e.collectCandidates(t,n,r)})}static calculateContentScore(t){let n=0;[`article`,`content`,`main-container`,`main`,`main-content`,`post`,`entry`].forEach(e=>{t.classList.contains(e)&&(n+=10)}),[`content`,`main`,`article`,`post`,`entry`].forEach(e=>{t.id?.toLowerCase().includes(e)&&(n+=10)});let r=t.tagName.toLowerCase();[`article`,`main`,`section`].includes(r)&&(n+=8);let i=t.getElementsByTagName(`p`).length;n+=Math.min(i*2,10);let a=t.querySelectorAll(`h1, h2, h3`).length;n+=Math.min(a*3,9);let o=t.textContent?.trim().length||0;o>300&&(n+=Math.min(Math.floor(o/300)*2,10));let s=e.calculateLinkDensity(t);s<.3?n+=5:s>.5&&(n-=5),(t.hasAttribute(`data-main`)||t.hasAttribute(`data-content`)||t.hasAttribute(`itemprop`))&&(n+=8);let c=t.getAttribute(`role`);return(c===`main`||c===`article`)&&(n+=10),t.matches(`aside, nav, header, footer, .sidebar, .navigation, .menu, .ad, .advertisement`)&&(n-=10),t.getElementsByTagName(`form`).length>2&&(n-=5),Math.max(0,n)}static calculateLinkDensity(e){let t=e.getElementsByTagName(`a`),n=0;for(let e of Array.from(t))n+=e.textContent?.length||0;let r=e.textContent?.length||1;return n/r}static isNavigation(e){if(e.tagName.toLowerCase()===`nav`||e.getAttribute(`role`)===`navigation`)return!0;let t=[/nav/i,/menu/i,/sidebar/i,/toolbar/i],n=`${e.className} ${e.id}`.toLowerCase();return t.some(e=>e.test(n))}static isSupplementary(e){if(e.tagName.toLowerCase()===`aside`||e.getAttribute(`role`)===`complementary`)return!0;let t=[/sidebar/i,/widget/i,/related/i,/advertisement/i,/social/i],n=`${e.className} ${e.id}`.toLowerCase();return t.some(e=>e.test(n))}static detectLandmarks(e){let t={navigation:[],main:[],complementary:[],contentinfo:[],banner:[],search:[],form:[],region:[]};for(let[n,r]of Object.entries({navigation:`nav, [role="navigation"]`,main:`main, [role="main"]`,complementary:`aside, [role="complementary"]`,contentinfo:`footer, [role="contentinfo"]`,banner:`header, [role="banner"]`,search:`[role="search"]`,form:`form[aria-label], form[aria-labelledby], [role="form"]`,region:`section[aria-label], section[aria-labelledby], [role="region"]`})){let i=e.querySelectorAll(r);t[n]=Array.from(i)}return t}};function bG(e,t){let n=(e??``).trim();if(!t||n.length<=t)return n;let r=[`login`,`log in`,`sign in`,`sign up`,`submit`,`search`,`filter`,`add to cart`,`next`,`continue`],i=n.toLowerCase(),a=r.map(e=>({k:e,i:i.indexOf(e)})).find(e=>e.i>-1),o=Math.max(0,Math.floor(t*.66));if(a&&a.i>o){let e=Math.max(12,t-o-5),r=Math.max(0,a.i-Math.floor(e/2)),i=Math.min(n.length,r+e);return`${n.slice(0,o).trimEnd()} … ${n.slice(r,i).trim()}…`}let s=n.slice(0,t),c=s.lastIndexOf(` `);return`${c>32?s.slice(0,c):s}…`}function xG(e){let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return`sec-${(t>>>0).toString(36)}`}function SG(e){switch(e){case`header`:return`🧭`;case`navigation`:return`📑`;case`main`:return`📄`;case`sections`:return`🗂️`;case`sidebar`:return`📚`;case`footer`:return`🔻`;case`modals`:return`💬`;default:return`🔹`}}function CG(e,t){let n=bG(e.text||e.attributes?.ariaLabel,t?.maxTextLength??80),r=e.selector?.css||``,i=e.tag.toLowerCase(),a=e.interaction?.submit?`submit`:e.interaction?.click?`click`:e.interaction?.change?`change`:void 0,o=a?` (${a})`:``;return`- ${i.toUpperCase()}: ${n||`(no text)`} → \`${r}\`${o}`}function wG(e){let t=[];t.push(...e.buttons.map(e=>e.selector?.css||``)),t.push(...e.links.map(e=>e.selector?.css||``)),t.push(...e.inputs.map(e=>e.selector?.css||``)),t.push(...e.clickable.map(e=>e.selector?.css||``));let n=t.length||1,r=t.filter(e=>e.startsWith(`#`)).length,i=t.filter(e=>/\[data-testid=/.test(e)).length,a=t.filter(e=>/:nth-child\(/.test(e)).length,o=r+i;return`Selector quality: ${Math.round(o/n*100)}% stable (ID/data-testid), ${Math.round(a/n*100)}% structural (:nth-child)`}function TG(e,t){let n=[],r=e=>typeof t?.maxElements==`number`?e.slice(0,t.maxElements):e;if(e.buttons.length){n.push(`Buttons:`);for(let i of r(e.buttons))n.push(CG(i,t))}if(e.links.length){n.push(`Links:`);for(let i of r(e.links))n.push(CG(i,t))}if(e.inputs.length){n.push(`Inputs:`);for(let i of r(e.inputs))n.push(CG(i,t))}if(e.clickable.length){n.push(`Other Clickable:`);for(let i of r(e.clickable))n.push(CG(i,t))}if(e.forms.length){n.push(`Forms:`);for(let t of r(e.forms))n.push(`- FORM: action=${t.action??`-`} method=${t.method??`-`} → \`${t.selector}\``)}return n.join(`
|
|
113
|
-
`)}function EG(e){let t=SG(`region`),n=xG(`${e.selector}|${e.label??``}|${e.role??``}`),r=e.label?` ${e.label}`:``,i=[];e.buttonCount&&i.push(`${e.buttonCount} buttons`),e.linkCount&&i.push(`${e.linkCount} links`),e.inputCount&&i.push(`${e.inputCount} inputs`),e.textPreview&&i.push(`“${bG(e.textPreview,80)}”`);let a=i.length?` — ${i.join(`, `)}`:``;return`${t} ${r} → \`${e.selector}\` [${n}]${a}`}function DG(e,t,n=`section`){return`<page ${[t?.title?`title="${OG(t.title)}"`:null,t?.url?`url="${OG(t.url)}"`:null].filter(Boolean).join(` `)}>\n <${n}><![CDATA[\n${e}\n]]></${n}>\n</page>`}function OG(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var kG=class{static structure(e,t={},n){let r=[];r.push(`# Page Outline`),(n?.title||n?.url)&&(r.push(`Title: ${n?.title??``}`.trim()),r.push(`URL: ${n?.url??``}`.trim())),r.push(``);let i=e.regions,a=[[`header`,i.header],[`navigation`,i.navigation],[`main`,i.main],[`sections`,i.sections],[`sidebar`,i.sidebar],[`footer`,i.footer],[`modals`,i.modals]];for(let[e,t]of a){if(!t)continue;let n=SG(e);if(Array.isArray(t)){if(!t.length)continue;r.push(`## ${n} ${AG(e)}`);for(let e of t)r.push(EG(e))}else r.push(`## ${n} ${AG(e)}`),r.push(EG(t));r.push(``)}if(e.suggestions?.length){r.push(`## Suggestions`);for(let t of e.suggestions)r.push(`- ${t}`);r.push(``)}return r.push(`Next: choose a region (by selector or [sectionId]) and call dom_extract_region for actionable details.`),DG(r.join(`
|
|
114
|
-
`),n,`outline`)}static region(e,t={},n){let r=[];r.push(`# Region Details`),(n?.title||n?.url)&&(r.push(`Title: ${n?.title??``}`.trim()),r.push(`URL: ${n?.url??``}`.trim())),r.push(``);let i=e.interactive;if(e.page){let t=[e.page.hasErrors?`errors: yes`:`errors: no`,e.page.isLoading?`loading: yes`:`loading: no`,e.page.hasModals?`modals: yes`:`modals: no`];r.push(`Page state: ${t.join(`, `)}`)}let a=[],o=e=>e?e.length:0;return a.push(`${o(i.buttons)} buttons`),a.push(`${o(i.links)} links`),a.push(`${o(i.inputs)} inputs`),i.forms?.length&&a.push(`${o(i.forms)} forms`),r.push(`Summary: ${a.join(`, `)}`),r.push(wG(i)),r.push(``),r.push(TG(i,t)),r.push(``),r.push(`Next: write a script using the most stable selectors above. If selectors look unstable, rerun dom_extract_region with higher detail or call dom_extract_content for text context.`),DG(r.join(`
|
|
115
|
-
`),n,`section`)}static content(e,t={},n){let r=[];if(r.push(`# Content`),r.push(`Selector: \`${e.selector}\``),r.push(``),e.text.headings?.length){r.push(`Headings:`);for(let n of e.text.headings)r.push(`- H${n.level}: ${bG(n.text,t.maxTextLength??120)}`);r.push(``)}if(e.text.paragraphs?.length){let n=typeof t.maxElements==`number`?t.maxElements:e.text.paragraphs.length;r.push(`Paragraphs:`);for(let i of e.text.paragraphs.slice(0,n))r.push(`- ${bG(i,t.maxTextLength??200)}`);r.push(``)}if(e.text.lists?.length){r.push(`Lists:`);for(let n of e.text.lists){r.push(`- ${n.type.toUpperCase()}:`);let e=typeof t.maxElements==`number`?t.maxElements:n.items.length;for(let i of n.items.slice(0,e))r.push(` - ${bG(i,t.maxTextLength??120)}`)}r.push(``)}if(e.tables?.length){r.push(`Tables:`);for(let n of e.tables){r.push(`- Headers: ${n.headers.join(` | `)}`);let e=typeof t.maxElements==`number`?t.maxElements:n.rows.length;for(let t of n.rows.slice(0,e))r.push(` - ${t.join(` | `)}`)}r.push(``)}if(e.media?.length){r.push(`Media:`);let n=typeof t.maxElements==`number`?t.maxElements:e.media.length;for(let t of e.media.slice(0,n))r.push(`- ${t.type.toUpperCase()}: ${t.alt??``} ${t.src?`→ ${t.src}`:``}`.trim());r.push(``)}return r.push(`Next: if text is insufficient for targeting, call dom_extract_region for interactive selectors.`),DG(r.join(`
|
|
116
|
-
`),n,`content`)}};function AG(e){return e.charAt(0).toUpperCase()+e.slice(1)}var jG=class e{static generateSelectors(t){let n=t.ownerDocument||document,r=[];t.id&&e.isUniqueId(t.id,n)&&r.push({type:`id`,value:`#${CSS.escape(t.id)}`,score:100});let i=e.getDataTestId(t);if(i){let t=`[${i.name}="${CSS.escape(i.value)}"]`;r.push({type:`data-testid`,value:t,score:90+(e.isUniqueSelector(t,n)?5:0)})}let a=t.getAttribute(`role`),o=t.getAttribute(`aria-label`);if(a&&o){let t=`[role="${CSS.escape(a)}"][aria-label="${CSS.escape(o)}"]`;r.push({type:`role-aria`,value:t,score:85+(e.isUniqueSelector(t,n)?5:0)})}let s=t.getAttribute(`name`);if(s){let t=`[name="${CSS.escape(s)}"]`;r.push({type:`name`,value:t,score:78+(e.isUniqueSelector(t,n)?5:0)})}let c=e.generateCSSSelector(t,n),l=(c.match(/:nth-child\(/g)||[]).length*10,u=c.includes(`.`)?8:0,d=Math.max(0,70+u-l);r.push({type:`class-path`,value:c,score:d});let f=e.generateXPath(t,n);r.push({type:`xpath`,value:f,score:40});let p=e.generateTextBasedSelector(t);p&&r.push({type:`text`,value:p,score:30}),r.sort((e,t)=>t.score-e.score);let m={css:r.find(r=>r.type!==`xpath`&&r.type!==`text`&&e.isUniqueSelector(r.value,n,t))?.value||c,xpath:f,candidates:r};return p&&(m.textBased=p),i&&(m.dataTestId=i.value),o&&(m.ariaLabel=o),m}static generateCSSSelector(t,n){if(t.id&&e.isUniqueId(t.id,n))return`#${CSS.escape(t.id)}`;let r=e.getDataTestId(t);if(r){let i=`[${r.name}="${CSS.escape(r.value)}"]`;if(e.isUniqueSelector(i,n,t))return i}let i=[],a=t;for(;a&&a.nodeType===Node.ELEMENT_NODE;){let t=a.nodeName.toLowerCase();if(a.id&&e.isUniqueId(a.id,n)){t=`#${CSS.escape(a.id)}`,i.unshift(t);break}let r=e.getMeaningfulClasses(a);r.length>0&&(t+=`.${r.map(e=>CSS.escape(e)).join(`.`)}`);let o=a.parentElement?.children;if(o&&o.length>1){let n=Array.from(o).indexOf(a);(n>0||!e.isUniqueSelector(t,a.parentElement))&&(t+=`:nth-child(${n+1})`)}i.unshift(t),a=a.parentElement}return e.optimizePath(i,t,n)}static generateXPath(t,n){let r=[],i=t;for(;i&&i.nodeType===Node.ELEMENT_NODE;){let t=i.nodeName.toLowerCase();if(i.id&&!i.id.includes(`"`)&&e.isUniqueId(i.id,n)){r.unshift(`*[@id="${i.id}"]`);break}let a=t,o=i.parentElement?.children;if(o){let e=Array.from(o).filter(e=>e.nodeName.toLowerCase()===t);if(e.length>1){let t=e.indexOf(i)+1;a+=`[${t}]`}}r.unshift(a),i=i.parentElement}return`//${r.join(`/`)}`}static generateTextBasedSelector(e){let t=e.textContent?.trim();if(!t||t.length>50)return;let n=e.nodeName.toLowerCase();if([`button`,`a`,`label`].includes(n))return`${n}:contains("${t.replace(/['"\\]/g,`\\$&`)}")`}static getDataTestId(e){for(let t of[`data-testid`,`data-test-id`,`data-test`,`data-cy`]){let n=e.getAttributeNode(t);if(n?.value)return n}}static isUniqueId(e,t){return t.querySelectorAll(`#${CSS.escape(e)}`).length===1}static isUniqueSelector(e,t,n){try{let r=t.querySelectorAll(e);return r.length===1&&(n===void 0||r[0]===n)}catch{return!1}}static getMeaningfulClasses(e){let t=Array.from(e.classList),n=[/^(p|m|w|h|text|bg|border|flex|grid|col|row)-/,/^(xs|sm|md|lg|xl|2xl):/,/^(hover|focus|active|disabled|checked):/,/^js-/,/^is-/,/^has-/];return t.filter(e=>e.length<3?!1:!n.some(t=>t.test(e))).slice(0,2)}static optimizePath(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e.slice(r).join(` > `);try{let e=n.querySelectorAll(i);if(e.length===1&&e[0]===t)return i}catch{}}return e.join(` > `)}static getContextPath(e){let t=[],n=e,r=0;for(;n&&n!==e.ownerDocument?.body&&r<5;){let e=n.nodeName.toLowerCase(),i=e;if(n.id)i=`${e}#${n.id}`;else if(n.className&&typeof n.className==`string`){let t=n.className.split(` `)[0];t&&(i=`${e}.${t}`)}let a=n.getAttribute(`role`);a&&(i+=`[role="${a}"]`),t.unshift(i),n=n.parentElement,r++}return t}},MG=class e{static isDocument(e){return e.nodeType===Node.DOCUMENT_NODE}static isVisible(e){let t=e.getBoundingClientRect(),n=e.ownerDocument?.defaultView?.getComputedStyle(e);return n?t.width>0&&t.height>0&&n.display!==`none`&&n.visibility!==`hidden`&&n.opacity!==`0`:!1}static isInViewport(e){let t=e.getBoundingClientRect(),n={width:e.ownerDocument?.defaultView?.innerWidth||0,height:e.ownerDocument?.defaultView?.innerHeight||0};return t.top<n.height&&t.bottom>0&&t.left<n.width&&t.right>0}static passesFilter(t,n){if(!n)return!0;if(n.excludeSelectors?.length){for(let e of n.excludeSelectors)if(t.matches(e))return!1}if(n.includeSelectors?.length){let e=!1;for(let r of n.includeSelectors)if(t.matches(r)){e=!0;break}if(!e)return!1}if(n.tags?.length&&!n.tags.includes(t.tagName.toLowerCase()))return!1;let r=t.textContent?.toLowerCase()||``;if(n.textContains?.length){let e=!1;for(let t of n.textContains)if(r.includes(t.toLowerCase())){e=!0;break}if(!e)return!1}if(n.textMatches?.length){let e=!1;for(let t of n.textMatches)if(t.test(r)){e=!0;break}if(!e)return!1}if(n.hasAttributes?.length){for(let e of n.hasAttributes)if(!t.hasAttribute(e))return!1}if(n.attributeValues)for(let[e,r]of Object.entries(n.attributeValues)){let n=t.getAttribute(e);if(!n)return!1;if(typeof r==`string`){if(n!==r)return!1}else if(r instanceof RegExp&&!r.test(n))return!1}if(n.withinSelectors?.length){let e=!1;for(let r of n.withinSelectors)if(t.closest(r)){e=!0;break}if(!e)return!1}if(n.interactionTypes?.length){let r=e.getInteractionInfo(t),i=!1;for(let e of n.interactionTypes)if(r[e]){i=!0;break}if(!i)return!1}if(n.nearText){let e=t.parentElement;if(!e||!e.textContent?.toLowerCase().includes(n.nearText.toLowerCase()))return!1}return!0}static extractElement(t,n,r=0){if(n.maxDepth!==void 0&&r>n.maxDepth||!n.includeHidden&&!e.isVisible(t)||n.viewportOnly&&!e.isInViewport(t)||!e.passesFilter(t,n.filter))return null;let i={tag:t.tagName.toLowerCase(),text:e.getElementText(t,n),selector:jG.generateSelectors(t),attributes:e.getRelevantAttributes(t,n),context:e.getElementContext(t),interaction:e.getInteractionInfo(t)};if(n.mode===`full`&&e.isSemanticContainer(t)){let a=[];if(n.includeShadowDOM&&t.shadowRoot){let i=e.extractChildren(t.shadowRoot,n,r+1);a.push(...i)}let o=e.extractChildren(t,n,r+1);a.push(...o),a.length>0&&(i.children=a)}return i}static extractChildren(t,n,r){let i=[];for(let a of Array.from(t.children)){let t=e.extractElement(a,n,r);t&&i.push(t)}return i}static getRelevantAttributes(e,t){let n=`id.class.name.type.value.placeholder.href.src.alt.title.action.method.aria-label.aria-describedby.aria-controls.role.disabled.readonly.required.checked.min.max.pattern.step.autocomplete.data-testid.data-test.data-cy`.split(`.`),r={},i=t.attributeTruncateLength??100,a=t.dataAttributeTruncateLength??50;for(let t of n){let n=e.getAttribute(t);n&&(r[t]=n.length>i?`${n.substring(0,i)}...`:n)}for(let t of e.attributes)t.name.startsWith(`data-`)&&!n.includes(t.name)&&(r[t.name]=t.value.length>a?`${t.value.substring(0,a)}...`:t.value);return r}static getElementContext(e){let t={parentChain:jG.getContextPath(e)},n=e.closest(`form`);n&&(t.nearestForm=jG.generateSelectors(n).css);let r=e.closest(`section, [role="region"]`);r&&(t.nearestSection=jG.generateSelectors(r).css);let i=e.closest(`main, [role="main"]`);i&&(t.nearestMain=jG.generateSelectors(i).css);let a=e.closest(`nav, [role="navigation"]`);return a&&(t.nearestNav=jG.generateSelectors(a).css),t}static getInteractionInfo(t){let n=t,r={};(n.onclick||t.getAttribute(`onclick`)||t.matches(`button, a[href], [role="button"], [tabindex]:not([tabindex="-1"])`))&&(r.click=!0),(n.onchange||t.getAttribute(`onchange`)||t.matches(`input, select, textarea`))&&(r.change=!0),(n.onsubmit||t.getAttribute(`onsubmit`)||t.matches(`form`))&&(r.submit=!0),t.matches(`a[href], button[type="submit"]`)&&(r.nav=!0),(t.hasAttribute(`disabled`)||t.getAttribute(`aria-disabled`)===`true`)&&(r.disabled=!0),e.isVisible(t)||(r.hidden=!0);let i=t.getAttribute(`role`);if(i&&(r.role=i),t.matches(`input, textarea, select, button`)){let e=t.form||t.closest(`form`);e&&(r.form=jG.generateSelectors(e).css)}return r}static getElementText(e,t){if(e.matches(`input, textarea`)){let t=e;return t.value||t.placeholder||``}if(e.matches(`img`))return e.alt||``;let n=e.textContent?.trim()||``,r=t?.textTruncateLength;return r&&n.length>r?`${n.substring(0,r)}...`:n}static isSemanticContainer(e){return e.matches(`article, section, nav, aside, main, header, footer, form, table, ul, ol, dl, figure, details, dialog, [role="region"], [role="navigation"], [role="main"], [role="complementary"]`)}},NG=class e{options;constructor(e={}){this.options={mode:e.mode||`interactive`,maxDepth:e.maxDepth??5,includeHidden:e.includeHidden||!1,includeShadowDOM:e.includeShadowDOM??!0,includeIframes:e.includeIframes||!1,viewportOnly:e.viewportOnly||!1,mainContentOnly:e.mainContentOnly||!1,customSelectors:e.customSelectors||[],...e.attributeTruncateLength!==void 0&&{attributeTruncateLength:e.attributeTruncateLength},...e.dataAttributeTruncateLength!==void 0&&{dataAttributeTruncateLength:e.dataAttributeTruncateLength},...e.textTruncateLength!==void 0&&{textTruncateLength:e.textTruncateLength},...e.filter!==void 0&&{filter:e.filter}}}extract(e=document,t){let n=Date.now(),r=MG.isDocument(e),i=r?e:e.ownerDocument,a={...this.options,...t},o=r?i:e;a.mainContentOnly&&r&&(o=yG.findMainContent(i));let s=this.extractPageState(i),c=this.extractLandmarks(i),l=this.extractInteractiveElements(o,a),u={mode:a.mode,timestamp:n,page:s,landmarks:c,interactive:l};if(a.mode===`full`){let e=this.extractSemanticElements(o,a),t=this.extractMetadata(i,o,a);return{...u,semantic:e,metadata:t}}return u}extractPageState(e){let t=this.getFocusedElement(e);return{url:e.location?.href||``,title:e.title||``,hasErrors:this.detectErrors(e),isLoading:this.detectLoading(e),hasModals:this.detectModals(e),...t!==void 0&&{hasFocus:t}}}extractLandmarks(e){let t=yG.detectLandmarks(e);return{navigation:this.elementsToSelectors(t.navigation||[]),main:this.elementsToSelectors(t.main||[]),forms:this.elementsToSelectors(t.form||[]),headers:this.elementsToSelectors(t.banner||[]),footers:this.elementsToSelectors(t.contentinfo||[]),articles:this.elementsToSelectors(t.region||[]),sections:this.elementsToSelectors(t.region||[])}}elementsToSelectors(e){return e.map(e=>jG.generateSelectors(e).css)}querySelectorAll(e,t,n){let r=[...e.querySelectorAll(t)];if(!n)return r;`shadowRoot`in e&&e.shadowRoot&&r.push(...this.querySelectorAll(e.shadowRoot,t,!0));for(let n of e.querySelectorAll(`*`))n.shadowRoot&&r.push(...this.querySelectorAll(n.shadowRoot,t,!0));return r}extractAll(e,t,n){let r=[];for(let i of this.querySelectorAll(e,t,n.includeShadowDOM)){let e=MG.extractElement(i,n);e&&r.push(e)}return r}extractInteractiveElements(e,t){let n=[];for(let r of t.customSelectors??[])n.push(...this.extractAll(e,r,t));return{buttons:this.extractAll(e,`button, [role="button"], input[type="button"], input[type="submit"]`,t),links:this.extractAll(e,`a[href]`,t),inputs:this.extractAll(e,`input:not([type="button"]):not([type="submit"]), textarea, select`,t),forms:this.extractForms(e,t),clickable:n}}extractForms(e,t){let n=[];return this.querySelectorAll(e,`form`,t.includeShadowDOM).forEach(e=>{if(!this.shouldIncludeElement(e,t))return;let r=e.getAttribute(`action`),i=e.getAttribute(`method`),a={selector:jG.generateSelectors(e).css,inputs:this.extractAll(e,`input:not([type="button"]):not([type="submit"]), textarea, select`,t),buttons:this.extractAll(e,`button, input[type="button"], input[type="submit"]`,t)};r&&(a.action=r),i&&(a.method=i),n.push(a)}),n}extractSemanticElements(e,t){return{headings:this.extractAll(e,`h1, h2, h3, h4, h5, h6`,t),images:this.extractAll(e,`img`,t),tables:this.extractAll(e,`table`,t),lists:this.extractAll(e,`ul, ol`,t),articles:this.extractAll(e,`article, [role="article"]`,t)}}extractMetadata(e,t,n){let r=this.querySelectorAll(t,`*`,n.includeShadowDOM),i=this.querySelectorAll(t,`button, a, input, textarea, select, h1, h2, h3, h4, h5, h6, img, table, ul, ol, article`,n.includeShadowDOM).length,a={totalElements:r.length,extractedElements:i};n.mainContentOnly&&!MG.isDocument(t)&&(a.mainContent=jG.generateSelectors(t).css);let o=e.documentElement.getAttribute(`lang`);return o&&(a.language=o),a}shouldIncludeElement(e,t){return!(!t.includeHidden&&!MG.isVisible(e)||t.viewportOnly&&!MG.isInViewport(e)||t.filter&&!MG.passesFilter(e,t.filter))}detectErrors(e){return[`.error`,`.alert-danger`,`[role="alert"]`,`.error-message`].some(t=>{let n=e.querySelector(t);return n?MG.isVisible(n):!1})}detectLoading(e){return[`.loading`,`.spinner`,`[aria-busy="true"]`,`.loader`].some(t=>{let n=e.querySelector(t);return n?MG.isVisible(n):!1})}detectModals(e){return[`[role="dialog"]`,`.modal`,`.popup`,`.overlay`].some(t=>{let n=e.querySelector(t);return n?MG.isVisible(n):!1})}getFocusedElement(e){let t=e.activeElement;if(t&&t!==e.body)return jG.generateSelectors(t).css}static extractInteractive(t,n={}){return new e({...n,mode:`interactive`}).extract(t)}static extractFull(t,n={}){return new e({...n,mode:`full`}).extract(t)}static extractFromElement(t,n=`interactive`,r={}){return new e({...r,mode:n}).extract(t)}},PG=XW(`[page-context-extractor]`),FG=()=>({title:document.title||``,url:window.location.href,description:document.querySelector(`meta[name="description"]`)?.getAttribute(`content`)??``}),IG=()=>{try{let e=FG(),t=NG.extractFull(document,{includeHidden:!1,includeShadowDOM:!0,includeIframes:!0,mainContentOnly:!0,textTruncateLength:80,attributeTruncateLength:60});return kG.region(t,{detail:`deep`,maxTextLength:4e3,maxElements:150},{title:e.title,url:e.url}).trim()}catch(e){PG.log(`[extractMainContent] smart-dom-reader failed, fallback to textContent:`,e);let t=document.body.cloneNode(!0);return t.querySelectorAll(`script, style, noscript`).forEach(e=>e.remove()),(t.textContent||``).trim().slice(0,4e3)}},LG=e=>{let t=[],n=e.interactive;if(!n)return t;for(let e of Object.values(n))if(Array.isArray(e))for(let n of e)typeof n==`object`&&n&&t.push(n);return t},RG=(e,t=4)=>{let n=[],r=e.parentElement;for(let e=0;e<t&&r&&r!==document.body;e++){let t=Array.from(r.childNodes).filter(e=>e.nodeType===Node.TEXT_NODE).map(e=>e.textContent?.trim()??``).filter(e=>e.length>0).join(` `)||(r.textContent||``).trim().slice(0,120);t&&n.push(`L${e+1}: ${t.slice(0,120)}`),r=r.parentElement}return n.join(` → `)},zG=e=>e.filter(e=>String(e.text??``).trim().length>0).map(e=>{let t=e.selector,n=t?.candidates?.[0]?.value??``,r=t?.css??n,i=null;if(r)try{i=document.querySelector(r)}catch{}let a=e.attributes,o=a?.[`data-assistant-action`]??i?.getAttribute(`data-assistant-action`)??``,s=a?.[`data-product-id`]??i?.getAttribute(`data-product-id`)??``,c=i?RG(i):``,l=e.interaction;return{tag:String(e.tag??``),text:String(e.text??``).slice(0,50),dataAction:o,dataProductId:s,parentChain:c,bestSelector:r,disabled:l?.disabled??!1}}),BG=e=>e.length===0?``:`| # | 标签 | 元素文本 | data-action | data-product-id | 父链上下文(从近到远) | 最佳选择器 | 状态 |\n| --- | --- | --- | --- | --- | --- | --- | --- |\n${e.map((e,t)=>`| ${t+1} | ${e.tag} | ${e.text} | ${e.dataAction} | ${e.dataProductId} | ${e.parentChain} | ${e.bestSelector} | ${e.disabled?`disabled`:`active`} |`).join(`
|
|
117
|
-
`)}`,VG=()=>{try{return BG(zG(LG(NG.extractInteractive(document,{includeHidden:!1,includeShadowDOM:!0,includeIframes:!0,viewportOnly:!1,mainContentOnly:!1,textTruncateLength:80,attributeTruncateLength:80}))))}catch(e){return PG.log(`[extractInteractiveIndex] smart-dom-reader failed, return empty:`,e),``}},HG=null,UG=``,WG=()=>{HG=null,UG=``},GG=()=>{let e=window.location.href;if(UG===e&&HG)return HG;let t=FG(),n=IG(),r=VG();return HG={pageTitle:t.title,pageUrl:t.url,pageDescription:t.description,pageContent:n,interactiveElements:r},UG=e,HG},KG=XW(`[action-executor]`),qG={click_element:dG,fill_input:fG,scroll_to:pG,navigate_to:mG,highlight_element:vG},JG=e=>e.tool===`navigate_to`?{url:e.params.url}:e.tool===`scroll_to`&&e.params.position?{position:e.params.position}:(KG.log(e.params),{element:uG({dataAttributes:e.params.data_attributes,anchorContext:e.params.anchor_context?{anchorText:e.params.anchor_context.anchorText,targetSelector:e.params.anchor_context.targetSelector}:void 0,textMatch:e.params.text_match,cssSelector:e.params.css_selector})?.element,value:e.params.value,url:e.params.url,position:e.params.position}),YG=async e=>{let t=qG[e.tool];if(!t){let t={success:!1,error:`unknown_tool`,message:`Unknown tool: ${e.tool}`};return qW(JSON.stringify(t)),t}let n=JG(e);KG.log(`[executeAction] tool=${e.tool} params=`,n);let r=await t(n);return KG.log(`[executeAction] result=`,r),WG(),qW(JSON.stringify(r)),r},XG=(0,_.createContext)(null);XG.Provider;var ZG=()=>(0,_.useContext)(XG),QG={click_element:`Click Element`,navigate_to:`Navigate`};function $G(e,t,n,r){let i=ZG(),[a,o]=(0,_.useState)(()=>r===void 0),[s,c]=(0,_.useState)(!1),[l,u]=(0,_.useState)(!1),d=r!==void 0,f=r?.success??!1,p=(0,_.useMemo)(()=>r?r.success?r.message??`Operation completed`:r.message??r.error??`Operation failed`:``,[r]),m=(0,_.useCallback)(e=>{s||(c(!0),o(!1),n(e))},[s,n]);(0,_.useEffect)(()=>{!i&&!s&&!d&&m(new uC({result:{success:!1,error:`portal_missing`,message:`Confirm UI portal target not found`},isError:!0}))},[i,s,m,d]);let h=(0,_.useMemo)(()=>{let e=typeof t.anchor_context==`string`&&t.anchor_context!==``?JSON.parse(t.anchor_context).anchorText:t.anchor_context;return t.url?`Navigate to: ${t.url}`:t.data_attributes?`Execute: ${t.data_attributes}`:e&&typeof e==`object`?`Click: ${e.anchorText}`:t.text_match?`Click: ${t.text_match}`:t.css_selector?`Operate: ${t.css_selector}`:`Perform page action`},[t]),g=(0,_.useCallback)(async()=>{if(!(s||l)){u(!0);try{let n=await YG({tool:e,params:t});m(new uC({result:n,isError:!n.success,...n.data&&{artifact:n.data}}))}catch(e){let t=e instanceof Error?e.message:`Action execution failed`;m(new uC({result:{success:!1,error:`exception`,message:t},isError:!0}))}finally{u(!1)}}},[s,l,e,t,m]),v=(0,_.useCallback)(()=>{m({success:!1,error:`user_cancelled`,message:`User cancelled the operation`})},[m]),y=(0,_.useCallback)(()=>{v()},[v]);return{isOpen:a,hasResult:d,resultSuccess:f,resultMessage:p,description:h,executing:l,portalTarget:i,label:QG[e]??`Confirm Action`,handleConfirm:g,handleCancel:v,handleBackdropClick:y}}var eK=({toolName:e,args:t,addResult:n,result:r})=>{let{isOpen:i,hasResult:a,resultSuccess:o,resultMessage:s,description:c,executing:l,portalTarget:u,label:d,handleConfirm:f,handleCancel:p,handleBackdropClick:m}=$G(e,t,n,r);return a?(0,I.jsx)(`div`,{className:`mt-2 rounded-lg border border-[#3C5F32]/15 bg-[#F5D2AF]/60 px-4 py-3 text-sm`,children:(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[o?(0,I.jsx)(O_.success,{className:`text-[#3C5F32] shrink-0`,size:16}):(0,I.jsx)(O_.error,{className:`text-[#FF641E] shrink-0`,size:16}),(0,I.jsx)(`span`,{className:o?`text-[#3C5F32]`:`text-[#FF641E]`,children:s})]})}):u?i?(0,Cd.createPortal)((0,I.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-center justify-center backdrop-blur-xs pointer-events-auto rounded-xl`,onClick:m,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`confirm-tool-title`,children:(0,I.jsxs)(Bg,{className:`w-[90%] max-w-sm bg-[#F5D2AF]/90 backdrop-blur-sm shadow-2xl`,onClick:e=>e.stopPropagation(),children:[(0,I.jsxs)(`div`,{id:`confirm-tool-title`,className:`flex items-center gap-2 border-b border-[#3C5F32]/10 px-4 py-3 text-base font-semibold text-[#3C5F32]`,children:[(0,I.jsx)(O_.wandMagic,{size:18,className:`text-[#FF641E]`}),d]}),(0,I.jsxs)(`div`,{className:`space-y-1 px-4 py-4`,children:[(0,I.jsx)(`p`,{className:`text-sm text-[#3C5F32]/80`,children:c}),(0,I.jsx)(`p`,{className:`text-xs text-[#3C5F32]/50`,children:`Please confirm this action`})]}),(0,I.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-[#3C5F32]/10 px-4 py-3`,children:[(0,I.jsxs)(Lg,{variant:`ghost`,size:`sm`,onPress:p,isDisabled:l,className:`text-[#3C5F32]`,children:[`Cancel`,(0,I.jsx)(Yg,{})]}),(0,I.jsxs)(Lg,{size:`sm`,onPress:f,isDisabled:l,className:`bg-[#FF641E] text-white hover:bg-[#FF641E]/90`,children:[l?`Executing...`:`Confirm`,(0,I.jsx)(Yg,{})]})]})]})}),u):null:(0,I.jsxs)(Ug,{status:`danger`,className:`mx-3 my-2 max-[300px]`,children:[(0,I.jsx)(Ug.Indicator,{}),(0,I.jsxs)(Ug.Content,{children:[(0,I.jsx)(Ug.Title,{children:`System Error`}),(0,I.jsx)(Ug.Description,{children:`Confirmation UI failed to initialize. Please refresh the page.`})]})]})},tK={fill_input:`Fill Input`,scroll_to:`Scroll Page`,highlight_element:`Highlight Element`},nK=({toolName:e,args:t,result:n,status:r})=>{let i=tK[e]??`Tool`,a=r?.type;if(a===`running`)return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-blue-50 px-3 py-2 text-xs text-blue-600`,children:[(0,I.jsx)(O_.loading,{className:`animate-spin`,size:14}),(0,I.jsxs)(`span`,{children:[`Executing: `,i]}),t.value&&(0,I.jsxs)(`span`,{className:`text-blue-400`,children:[`→ `,t.value]})]});if(a===`complete`||n){let e=n?.success!==!1,t=n?.message??`Completed`;return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg px-3 py-2 text-xs ${e?`bg-green-50 text-green-600`:`bg-red-50 text-red-600`}`,children:[e?(0,I.jsx)(O_.success,{size:14}):(0,I.jsx)(O_.error,{size:14}),(0,I.jsx)(`span`,{children:t})]})}return(0,I.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-gray-50 px-3 py-2 text-xs text-gray-500`,children:[(0,I.jsx)(O_.wandMagic,{size:14}),(0,I.jsx)(`span`,{children:i})]})},rK=KU([UU({anchorText:G(),targetSelector:G()}),G(),nW(``)]),iK=UU({data_attributes:G().optional(),anchor_context:rK.optional(),text_match:G().optional(),css_selector:G().optional()}),aK=Hee({click_element:{type:`human`,description:`Click on a page element, such as add-to-cart button, navigation link, etc.`,parameters:iK,render:eK},navigate_to:{type:`human`,description:`Navigate to the specified URL`,parameters:UU({url:G()}),render:eK},fill_input:{type:`frontend`,description:`Fill content into an input field, such as search box, form field, etc. Auto-presses Enter after filling to trigger search/submit.`,parameters:iK.extend({value:G()}),execute:async e=>YG({tool:`fill_input`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector,value:e.value}}),render:nK},scroll_to:{type:`frontend`,description:`Scroll the page to a specified element or position`,parameters:iK.extend({position:eW([`top`,`bottom`]).optional()}),execute:async e=>YG({tool:`scroll_to`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector,position:e.position}}),render:nK},highlight_element:{type:`frontend`,description:`Highlight a page element to draw user attention`,parameters:iK,execute:async e=>YG({tool:`highlight_element`,params:{data_attributes:e.data_attributes,anchor_context:e.anchor_context,text_match:e.text_match,css_selector:e.css_selector}}),render:nK}}),oK=[`click_element`,`navigate_to`],sK={name:``,price:``,sku:``,availability:``,found:!1},cK=()=>{let e=Array.from(document.querySelectorAll(`script[type="application/ld+json"]`));for(let t of e)try{let e=JSON.parse(t.textContent||``),n=Array.isArray(e)?e:[e];for(let e of n){let t=e,n=t[`@graph`];if(Array.isArray(n))for(let e of n){let t=lK(e);if(t)return t}let r=lK(t);if(r)return r}}catch{}return null},lK=e=>{let t=e[`@type`];if(typeof t!=`string`||!t.includes(`Product`))return null;let n=typeof e.name==`string`?e.name:``,r=e.offers;return{name:n,price:typeof r?.price==`string`?r.price:``,sku:typeof e.sku==`string`?e.sku:``,availability:typeof e.availability==`string`?e.availability.replace(`https://schema.org/`,``):``,found:!0}},uK=()=>{let e=document.querySelector(`meta[property="og:title"]`)?.getAttribute(`content`),t=[`.price`,`.product-price`,`[data-price]`,`[itemprop="price"]`,`.price-current`],n=``;for(let e of t){let t=document.querySelector(e);if(t?.textContent?.trim()){n=t.textContent.trim();break}}let r=e||document.title||``;return r||n?{name:r,price:n,sku:``,availability:``,found:!0}:sK},dK=()=>cK()||uK(),fK=e=>{if(!e.found)return``;let t=[];return e.name&&t.push(`名称: ${e.name}`),e.price&&t.push(`价格: ${e.price}`),e.sku&&t.push(`SKU: ${e.sku}`),e.availability&&t.push(`库存: ${e.availability}`),t.join(` | `)},pK=()=>{let e=GG(),t=dK();return{page_title:e.pageTitle,page_url:e.pageUrl,page_content:e.pageContent,page_description:e.pageDescription,product_info:fK(t),interactive_elements:e.interactiveElements}},mK=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`)return n.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)||``}return``},hK=()=>pK(),gK=XW(`[use-dify-assistant]`),_K=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role!==`assistant`)continue;let r=n.content.find(e=>e.type===`tool-call`&&e.result!==void 0);if(r)return{toolCallId:r.toolCallId,toolName:r.toolName,result:r.result}}return null},vK=()=>({...hK(),tools:rG}),yK=e=>oK.includes(e),bK=()=>({async*run({messages:e,abortSignal:t,unstable_getMessage:n}){let r=_K(e)??(n?_K([n()]):null);if(r){gK.log(`resume detected for tool:`,r.toolName,`callId:`,r.toolCallId.slice(0,8));let e=r.result;yield{content:[{type:`text`,text:e?.success===!0?`✅ ${e.message??`Operation completed`}`:`❌ ${e?.message??e?.error??`Operation failed`}`}]};return}if([...e].reverse().find(e=>e.role===`assistant`)?.content.some(e=>e.type===`tool-call`&&e.result===void 0)){gK.log(`pending tool-call detected, skip resend`);return}let i=mK(e);if(!i)return;let a=HW(),o=BW()??void 0;try{let e=await FW({query:i,inputs:vK(),conversationId:o,user:a}),n=``,r=null;for await(let a of e){if(t.aborted)return;switch(a.event){case`message`:n+=a.answer,r=a.conversation_id,yield{content:[{type:`text`,text:tG(n)||`Processing your request...`}]};break;case`agent_thought`:a.thought&&(yield{content:[{type:`reasoning`,text:a.thought},...n?[{type:`text`,text:tG(n)}]:[]]});break;case`message_end`:{r=a.conversation_id,VW(r),GW(r,tG(n)||i);let e=$W(n);if(e.length===0){yield{content:[{type:`text`,text:tG(n)}]};return}let t=e[0],o=crypto.randomUUID(),s=[{type:`text`,text:tG(n)},{type:`tool-call`,toolCallId:o,toolName:t.tool,args:t.params,argsText:JSON.stringify(t.params)}];gK.log(`emit tool-call:`,t.tool),yK(t.tool)?yield{content:s,status:{type:`requires-action`,reason:`tool-calls`}}:yield{content:s};return}case`error`:yield{content:[{type:`text`,text:`[Error] ${a.message}`}]};return}}}catch(e){yield{content:[{type:`text`,text:`[Request failed] ${e instanceof Error?e.message:`Unknown error`}`}]}}}}),xK=e=>{gK.log(`useDifyAssistant:`,e);let t=wj((0,_.useMemo)(()=>bK(),[]),{unstable_humanToolNames:[...e.humanToolNames]}),n=(0,_.useCallback)(()=>{UW()},[]);return{runtime:t,config:e.config,clearConversation:n}},SK=dD(`useAISDKRuntime`),CK=(e,t)=>{if(t==null)return[];let n=e.findIndex(e=>e.id===t);if(n===-1)throw Error(`sliceMessagesUntil: Message "${t}" not found in AI SDK messages. This is likely an internal bug in assistant-ui.`);for(;e[n+1]?.role===`assistant`;)n++;return e.slice(0,n+1)},wK=e=>{let t=[...e.content,...e.attachments?.flatMap(e=>e.content.map(t=>({...t,filename:e.name,contentType:e.contentType})))??[]].map(e=>{switch(e.type){case`text`:return{type:`text`,text:e.text};case`image`:{let t=Lj(e.image,e.contentType);return{type:`file`,url:zj(e.image,t),...e.filename&&{filename:e.filename},mediaType:t}}case`file`:{let t=Rj(e.data,e.mimeType);return{type:`file`,url:e.sourceType===`id`?e.data:zj(e.data,t),mediaType:t,...e.filename&&{filename:e.filename}}}case`audio`:{let t=`audio/${e.audio.format}`,n=e.audio.data,r=xte({data:n,mimeType:t});return{type:`file`,url:r.kind===`url`?r.url:`data:${t};base64,${r.data}`,mediaType:t,...e.filename&&{filename:e.filename}}}case`data`:return{type:`data-${e.name}`,data:e.data};default:throw Error(`Unsupported part type: ${e.type}`)}});return{role:e.role,parts:t,metadata:e.metadata}},TK=`vercel.ai.error`,EK=Symbol.for(TK),DK,OK,K=class e extends (OK=Error,DK=EK,OK){constructor({name:e,message:t,cause:n}){super(t),this[DK]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,TK)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},kK=`AI_APICallError`,AK=`vercel.ai.error.${kK}`,jK=Symbol.for(AK),MK,NK,PK=class extends (NK=K,MK=jK,NK){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:kK,message:e,cause:o}),this[MK]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return K.hasMarker(e,AK)}},FK=`AI_EmptyResponseBodyError`,IK=`vercel.ai.error.${FK}`,LK=Symbol.for(IK),RK,zK,BK=class extends (zK=K,RK=LK,zK){constructor({message:e=`Empty response body`}={}){super({name:FK,message:e}),this[RK]=!0}static isInstance(e){return K.hasMarker(e,IK)}};function VK(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.toString():JSON.stringify(e)}var HK=`AI_InvalidArgumentError`,UK=`vercel.ai.error.${HK}`,WK=Symbol.for(UK),GK,KK,qK=class extends (KK=K,GK=WK,KK){constructor({message:e,cause:t,argument:n}){super({name:HK,message:e,cause:t}),this[GK]=!0,this.argument=n}static isInstance(e){return K.hasMarker(e,UK)}},JK=`AI_InvalidPromptError`,YK=`vercel.ai.error.${JK}`,XK=Symbol.for(YK),ZK,QK,$K=class extends (QK=K,ZK=XK,QK){constructor({prompt:e,message:t,cause:n}){super({name:JK,message:`Invalid prompt: ${t}`,cause:n}),this[ZK]=!0,this.prompt=e}static isInstance(e){return K.hasMarker(e,YK)}},eq=`AI_JSONParseError`,tq=`vercel.ai.error.${eq}`,nq=Symbol.for(tq),rq,iq,aq=class extends (iq=K,rq=nq,iq){constructor({text:e,cause:t}){super({name:eq,message:`JSON parsing failed: Text: ${e}.
|
|
118
|
-
Error message: ${VK(t)}`,cause:t}),this[rq]=!0,this.text=e}static isInstance(e){return K.hasMarker(e,tq)}},oq=`AI_TypeValidationError`,sq=`vercel.ai.error.${oq}`,cq=Symbol.for(sq),lq,uq,dq=class e extends (uq=K,lq=cq,uq){constructor({value:e,cause:t,context:n}){let r=`Type validation failed`;if(n?.field&&(r+=` for ${n.field}`),n?.entityName||n?.entityId){r+=` (`;let e=[];n.entityName&&e.push(n.entityName),n.entityId&&e.push(`id: "${n.entityId}"`),r+=e.join(`, `),r+=`)`}super({name:oq,message:`${r}: Value: ${JSON.stringify(e)}.
|
|
119
|
-
Error message: ${VK(t)}`,cause:t}),this[lq]=!0,this.value=e,this.context=n}static isInstance(e){return K.hasMarker(e,sq)}static wrap({value:t,cause:n,context:r}){return e.isInstance(n)&&n.value===t&&n.context?.field===r?.field&&n.context?.entityName===r?.entityName&&n.context?.entityId===r?.entityId?n:new e({value:t,cause:n,context:r})}},fq=`AI_UnsupportedFunctionalityError`,pq=`vercel.ai.error.${fq}`,mq=Symbol.for(pq),hq,gq,_q=class extends (gq=K,hq=mq,gq){constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:fq,message:t}),this[hq]=!0,this.functionality=e}static isInstance(e){return K.hasMarker(e,pq)}},vq=class extends Error{constructor(e,t){super(e),this.name=`ParseError`,this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}},yq=10,bq=13,xq=32;function Sq(e){}function Cq(e){if(typeof e==`function`)throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");let{onEvent:t=Sq,onError:n=Sq,onRetry:r=Sq,onComment:i,maxBufferSize:a}=e,o=[],s=0,c=!0,l,u=``,d=0,f,p=!1;function m(e){if(p)throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,e.charCodeAt(0)===239&&e.charCodeAt(1)===187&&e.charCodeAt(2)===191&&(e=e.slice(3))),o.length===0){let t=g(e);t!==``&&(o.push(t),s=t.length),h();return}if(e.indexOf(`
|
|
120
|
-
`)===-1&&e.indexOf(`\r`)===-1){o.push(e),s+=e.length,h();return}o.push(e);let t=o.join(``);o.length=0,s=0;let n=g(t);n!==``&&(o.push(n),s=n.length),h()}function h(){a!==void 0&&(s+u.length<=a||(p=!0,o.length=0,s=0,l=void 0,u=``,d=0,f=void 0,n(new vq(`Buffered data exceeded max buffer size of ${a} characters`,{type:`max-buffer-size-exceeded`}))))}function g(e){let n=0;if(e.indexOf(`\r`)===-1){let r=e.indexOf(`
|
|
121
|
-
`,n);for(;r!==-1;){if(n===r){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0,n=r+1,r=e.indexOf(`
|
|
122
|
-
`,n);continue}let i=e.charCodeAt(n);if(wq(e,n,i)){let i=e.charCodeAt(n+5)===xq?n+6:n+5,a=e.slice(i,r);if(d===0&&e.charCodeAt(r+1)===yq){t({id:l,event:f,data:a}),l=void 0,u=``,f=void 0,n=r+2,r=e.indexOf(`
|
|
123
|
-
`,n);continue}u=d===0?a:`${u}
|
|
124
|
-
${a}`,d++}else Tq(e,n,i)?f=e.slice(e.charCodeAt(n+6)===xq?n+7:n+6,r)||void 0:_(e,n,r);n=r+1,r=e.indexOf(`
|
|
125
|
-
`,n)}return e.slice(n)}for(;n<e.length;){let t=e.indexOf(`\r`,n),r=e.indexOf(`
|
|
126
|
-
`,n),i=-1;if(t!==-1&&r!==-1?i=t<r?t:r:t===-1?r!==-1&&(i=r):i=t===e.length-1?-1:t,i===-1)break;_(e,n,i),n=i+1,e.charCodeAt(n-1)===bq&&e.charCodeAt(n)===yq&&n++}return e.slice(n)}function _(e,t,n){if(t===n){y();return}let r=e.charCodeAt(t);if(wq(e,t,r)){let r=e.charCodeAt(t+5)===xq?t+6:t+5,i=e.slice(r,n);u=d===0?i:`${u}
|
|
127
|
-
${i}`,d++;return}if(Tq(e,t,r)){f=e.slice(e.charCodeAt(t+6)===xq?t+7:t+6,n)||void 0;return}if(r===105&&e.charCodeAt(t+1)===100&&e.charCodeAt(t+2)===58){let r=e.slice(e.charCodeAt(t+3)===xq?t+4:t+3,n);r.includes(`\0`)||(l=r);return}if(r===58){if(i){let r=e.slice(t,n);i(r.slice(e.charCodeAt(t+1)===xq?2:1))}return}let a=e.slice(t,n),o=a.indexOf(`:`);if(o===-1){v(a,``,a);return}let s=a.slice(0,o),c=a.charCodeAt(o+1)===xq?2:1;v(s,a.slice(o+c),a)}function v(e,t,i){switch(e){case`event`:f=t||void 0;break;case`data`:u=d===0?t:`${u}
|
|
128
|
-
${t}`,d++;break;case`id`:t.includes(`\0`)||(l=t);break;case`retry`:/^\d+$/.test(t)?r(parseInt(t,10)):n(new vq(`Invalid \`retry\` value: "${t}"`,{type:`invalid-retry`,value:t,line:i}));break;default:n(new vq(`Unknown field "${e.length>20?`${e.slice(0,20)}\u2026`:e}"`,{type:`unknown-field`,field:e,value:t,line:i}))}}function y(){d>0&&t({id:l,event:f,data:u}),l=void 0,u=``,d=0,f=void 0}function b(e={}){if(e.consume&&o.length>0){let e=o.join(``);_(e,0,e.length)}c=!0,l=void 0,u=``,d=0,f=void 0,o.length=0,s=0,p=!1}return{feed:m,reset:b}}function wq(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function Tq(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}var Eq=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:n,maxBufferSize:r}={}){let i;super({start(a){i=Cq({onEvent:e=>{a.enqueue(e)},onError(t){typeof e==`function`&&e(t),(e===`terminate`||t.type===`max-buffer-size-exceeded`)&&a.error(t)},onRetry:t,onComment:n,maxBufferSize:r})},transform(e){i.feed(e)}})}},Dq=Symbol.for(`workflow-serialize`),Oq=Symbol.for(`workflow-deserialize`);function kq(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function Aq(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function jq(e){return Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null))}async function Mq(e,t){if(e==null)return Promise.resolve();let n=t?.abortSignal;return new Promise((t,r)=>{if(n?.aborted){r(Nq());return}let i=setTimeout(()=>{a(),t()},e),a=()=>{clearTimeout(i),n?.removeEventListener(`abort`,o)},o=()=>{a(),r(Nq())};n?.addEventListener(`abort`,o)})}function Nq(){return new DOMException(`Delay was aborted`,`AbortError`)}function Pq(e){let t=e??globalThis.WebSocket;if(t==null)throw Error(`No WebSocket implementation available.`);return t}var Fq=new TextDecoder;async function Iq(e){return typeof e==`string`?e:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?Fq.decode(e):typeof Blob<`u`&&e instanceof Blob?e.text():String(e)}var Lq=1;async function Rq(e,{highWaterMark:t=1048576,pollIntervalMs:n=20,abortSignal:r}={}){for(;e.readyState===Lq&&(e.bufferedAmount??0)>t;){if(r?.aborted===!0)return;await Mq(n)}}function zq({url:e,protocols:t,headers:n,webSocket:r,abortSignal:i,onOpen:a,onMessageText:o,onProcessingError:s,onSocketError:c,onClose:l,onAbort:u}){let d,f,p=e=>{f!=null&&(i?.removeEventListener(`abort`,f),f=void 0);try{d?.close(e)}catch{}};if(i?.aborted)return u?.(i.reason??Error(`Aborted`)),{socket:void 0,close:p};try{d=new(Pq(r))(e,t,{headers:jq(n??{})})}catch(e){return s(e),{socket:void 0,close:p}}i!=null&&u!=null&&(f=()=>u(i.reason??Error(`Aborted`)),i.addEventListener(`abort`,f,{once:!0}));let m=d;d.onopen=()=>{try{a?.(m)}catch(e){s(e)}};let h=Promise.resolve();return d.onmessage=e=>{h=h.then(()=>Iq(e.data)).then(e=>o(e)).catch(s)},d.onerror=()=>{h=h.then(()=>c?.()).catch(s)},d.onclose=e=>{let t=e,n=typeof t?.code==`number`?t.code:void 0,r=typeof t?.reason==`string`?t.reason:void 0;h=h.then(()=>l?.({code:n,reason:r})).catch(s)},{socket:d,close:p}}function Bq(e){let t=!1;return new ReadableStream({async pull(n){if(!t)try{let{value:t,done:r}=await e.next();r?n.close():n.enqueue(t)}catch(e){n.error(e)}},async cancel(n){if(t=!0,e.return)try{await e.return(n)}catch{}}})}var{btoa:Vq,atob:Hq}=globalThis;function Uq(e){let t=Hq(e.replace(/-/g,`+`).replace(/_/g,`/`));return Uint8Array.from(t,e=>e.codePointAt(0))}function Wq(e){let t=``;for(let n=0;n<e.length;n++)t+=String.fromCodePoint(e[n]);return Vq(t)}var Gq=Symbol.for(`vercel.ai.providerStreamError`);function Kq(e){return typeof e==`object`&&!!e&&e[Gq]===!0}var qq=class{constructor(){this.status={type:`pending`},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise||=new Promise((e,t)=>{this.status.type===`resolved`?e(this.status.value):this.status.type===`rejected`&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise}resolve(e){var t;this.status={type:`resolved`,value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:`rejected`,error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}isResolved(){return this.status.type===`resolved`}isRejected(){return this.status.type===`rejected`}isPending(){return this.status.type===`pending`}};function Jq(e){return Object.fromEntries([...e.headers])}function Yq(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function Xq(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var Zq=[`fetch failed`,`failed to fetch`],Qq=new Set([`ConnectionRefused`,`ConnectionClosed`,`FailedToOpenSocket`,`ECONNRESET`,`ECONNREFUSED`,`ETIMEDOUT`,`EPIPE`,`UND_ERR_SOCKET`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`]);function $q(e){let t=new Set,n=e;for(;n instanceof Error&&!t.has(n);){t.add(n);let e=n;if(typeof e.code==`string`&&Qq.has(e.code))return e;n=n.cause}}function eJ({error:e,url:t,requestBodyValues:n}){if(Xq(e))return e;if(e instanceof TypeError&&Zq.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new PK({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}let r=$q(e);return r==null?e:PK.isInstance(e)?new PK({message:e.message,cause:e.cause,url:e.url,requestBodyValues:e.requestBodyValues,statusCode:e.statusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,data:e.data,isRetryable:!0}):new PK({message:`Cannot connect to API: ${e instanceof Error?e.message:r.message}`,cause:e,url:t,requestBodyValues:n,isRetryable:!0})}var tJ=`5.0.36`;function nJ(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function rJ(e,...t){let n=new Headers(nJ(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var iJ=[{mediaType:`image/gif`,bytesPrefix:[71,73,70]},{mediaType:`image/png`,bytesPrefix:[137,80,78,71]},{mediaType:`image/jpeg`,bytesPrefix:[255,216]},{mediaType:`image/webp`,bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:`image/bmp`,bytesPrefix:[66,77]},{mediaType:`image/tiff`,bytesPrefix:[73,73,42,0]},{mediaType:`image/tiff`,bytesPrefix:[77,77,0,42]},{mediaType:`image/avif`,bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:`image/heic`,bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],aJ=[{mediaType:`application/pdf`,bytesPrefix:[37,80,68,70]}],oJ=[{mediaType:`audio/mpeg`,bytesPrefix:[255,251]},{mediaType:`audio/mpeg`,bytesPrefix:[255,250]},{mediaType:`audio/mpeg`,bytesPrefix:[255,243]},{mediaType:`audio/mpeg`,bytesPrefix:[255,242]},{mediaType:`audio/mpeg`,bytesPrefix:[255,227]},{mediaType:`audio/mpeg`,bytesPrefix:[255,226]},{mediaType:`audio/wav`,bytesPrefix:[82,73,70,70,null,null,null,null,87,65,86,69]},{mediaType:`audio/ogg`,bytesPrefix:[79,103,103,83]},{mediaType:`audio/flac`,bytesPrefix:[102,76,97,67]},{mediaType:`audio/aac`,bytesPrefix:[64,21,0,0]},{mediaType:`audio/webm`,bytesPrefix:[26,69,223,163]}],sJ=[...oJ,{mediaType:`audio/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]}],cJ=[{mediaType:`video/mp4`,bytesPrefix:[0,0,0,null,102,116,121,112]},{mediaType:`video/webm`,bytesPrefix:[26,69,223,163]},{mediaType:`video/quicktime`,bytesPrefix:[0,0,0,20,102,116,121,112,113,116]},{mediaType:`video/x-msvideo`,bytesPrefix:[82,73,70,70]}],lJ=18,uJ=131084;function dJ(e,t){if(typeof e!=`string`)return e.length>t?e.subarray(0,t):e;let n=Math.ceil(t/3)*4,r=Uq(e.substring(0,Math.min(e.length,n)));return r.length>t?r.subarray(0,t):r}function fJ(e){return e.length>10&&e[0]===73&&e[1]===68&&e[2]===51}var pJ=e=>{let t=(e[6]&127)<<21|(e[7]&127)<<14|(e[8]&127)<<7|e[9]&127;return e.subarray(t+10)};function mJ({data:e,signatures:t}){let n=dJ(e,lJ);fJ(n)&&(n=pJ(dJ(e,uJ)));for(let e of t)if(n.length>=e.bytesPrefix.length&&e.bytesPrefix.every((e,t)=>e===null||n[t]===e))return e.mediaType}var hJ={image:iJ,audio:sJ,video:cJ,application:aJ};function gJ({data:e,topLevelType:t}){if(t===void 0)return mJ({data:e,signatures:[...iJ,...aJ,...oJ,...cJ]});let n=hJ[t];if(n!==void 0)return mJ({data:e,signatures:n})}function _J(e){let t=e.indexOf(`/`);if(t===-1)return!1;let n=e.substring(t+1);return n.length>0&&n!==`*`}async function vJ(e){try{await e.body?.cancel()}catch{}}var yJ=`AI_DownloadError`,bJ=`vercel.ai.error.${yJ}`,xJ=Symbol.for(bJ),SJ,CJ,wJ=class extends (CJ=K,SJ=xJ,CJ){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:yJ,message:i,cause:r}),this[SJ]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return K.hasMarker(e,bJ)}};function TJ(e=globalThis){return e.window!=null}function EJ(e,t){try{return new URL(e).origin===new URL(t).origin}catch{return!1}}function DJ(e){let t;try{t=new URL(e)}catch{throw new wJ({url:e,message:`Invalid URL: ${e}`})}if(t.protocol===`data:`)return;if(t.protocol!==`http:`&&t.protocol!==`https:`)throw new wJ({url:e,message:`URL scheme must be http, https, or data, got ${t.protocol}`});let n=t.hostname.toLowerCase().replace(/\.+$/,``);if(!n)throw new wJ({url:e,message:`URL must have a hostname`});if(n===`localhost`||n.endsWith(`.local`)||n.endsWith(`.localhost`))throw new wJ({url:e,message:`URL with hostname ${n} is not allowed`});if(n.startsWith(`[`)&&n.endsWith(`]`)){if(MJ(n.slice(1,-1)))throw new wJ({url:e,message:`URL with IPv6 address ${n} is not allowed`});return}if(kJ(n)){if(AJ(n))throw new wJ({url:e,message:`URL with IP address ${n} is not allowed`});return}}function OJ({address:e,family:t,hostname:n}){if(t===4?!kJ(e)||AJ(e):t!==6||MJ(e))throw new wJ({url:n,message:`Hostname ${n} resolved to disallowed IP address ${e}`})}function kJ(e){let t=e.split(`.`);return t.length===4&&t.every(e=>{let t=Number(e);return Number.isInteger(t)&&t>=0&&t<=255&&String(t)===e})}function AJ(e){let[t,n,r]=e.split(`.`).map(Number);return t===0||t===10||t===100&&n>=64&&n<=127||t===127||t===169&&n===254||t===172&&n>=16&&n<=31||t===192&&n===0&&r===0||t===192&&n===0&&r===2||t===192&&n===168||t===198&&(n===18||n===19)||t===198&&n===51&&r===100||t===203&&n===0&&r===113||t>=224}function jJ(e){let t=e.toLowerCase(),n=t.indexOf(`%`);n!==-1&&(t=t.slice(0,n));let r=t.split(`::`);if(r.length>2)return null;let i=e=>{if(e===``)return[];let t=[],n=e.split(`:`);for(let e=0;e<n.length;e++){let r=n[e];if(r.includes(`.`)){if(e!==n.length-1||!kJ(r))return null;let[i,a,o,s]=r.split(`.`).map(Number);t.push(i<<8|a,o<<8|s);continue}if(!/^[0-9a-f]{1,4}$/.test(r))return null;t.push(parseInt(r,16))}return t},a=i(r[0]);if(a===null)return null;if(r.length===2){let e=i(r[1]);if(e===null)return null;let t=8-a.length-e.length;return t<0?null:[...a,...Array(t).fill(0),...e]}return a.length===8?a:null}function MJ(e){let t=jJ(e);if(t===null)return!0;let n=e=>t.slice(0,e).every(e=>e===0);return n(7)&&(t[7]===0||t[7]===1)||(t[0]&65024)==64512||(t[0]&65472)==65152||(t[0]&65472)==65216||(t[0]&65280)==65280||t[0]===8193&&t[1]===3512||t[0]===16383&&!(t[1]&61440)?!0:n(6)||n(5)&&t[5]===65535||n(4)&&t[4]===65535&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===0&&t[3]===0&&t[4]===0&&t[5]===0||t[0]===100&&t[1]===65435&&t[2]===1?AJ(`${t[6]>>8&255}.${t[6]&255}.${t[7]>>8&255}.${t[7]&255}`):!1}function NJ(e){return((t,n,r)=>{e(t,{...n,all:!0},(e,i)=>{if(e){r(e);return}try{let[e]=i;if(e==null)throw Error(`Hostname ${t} did not resolve to an address`);for(let{address:e,family:n}of i)OJ({address:e,family:n,hostname:t});n.all===!0?r(null,i):r(null,e.address,e.family)}catch(e){r(e instanceof Error?e:Error(String(e)))}})})}var PJ,FJ=globalThis.fetch,IJ=zJ(FJ);function LJ(){let e=globalThis.process;return e?.release?.name===`node`&&e.versions?.bun==null}async function RJ(){return!LJ()||!IJ||globalThis.fetch!==FJ?globalThis.fetch:PJ??=Promise.resolve().then(BJ)}function zJ(e){if(typeof e!=`function`)return!1;let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}function BJ(){let{createRequire:e}=VJ(`node:module`),{lookup:t}=VJ(`node:dns`),{Agent:n,fetch:r}=e(HJ())(`undici`),i=new n({connect:{lookup:NJ(t)}});return((e,t)=>r(e,{...t,dispatcher:i}))}function VJ(e){let t=globalThis.process,n=(t?.getBuiltinModule)?.call(t,e);if(n==null)throw Error(`Node.js built-in module ${e} is unavailable`);return n}function HJ(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error(`Capture current module path`);Error.captureStackTrace(e,HJ);let[t]=e.stack,n=t?.getFileName();if(n==null)throw Error(`Unable to determine the current module path`);return n}finally{Error.prepareStackTrace=e}}var UJ=[`connection`,`keep-alive`,`te`,`trailer`,`transfer-encoding`,`upgrade`,`host`,`forwarded`,`proxy-authorization`,`via`,`x-forwarded-for`,`x-forwarded-host`,`x-forwarded-proto`,`x-real-ip`,`metadata`,`metadata-flavor`,`x-aws-ec2-metadata-token`,`x-metadata-token`,`cookie`,`set-cookie`];function WJ(e){let t=new Headers(e);for(let e of UJ)t.delete(e);return t}var GJ=10,KJ=new Set([301,302,303,307,308]);async function qJ({url:e,headers:t,abortSignal:n,maxRedirects:r=GJ,fetch:i,trustedOrigin:a}){let o=t===void 0?void 0:WJ(t),s=e=>{let t={signal:n,redirect:e};return o!==void 0&&(t.headers=new Headers(o)),t},c=e;for(let t=0;t<=r;t++){let t=a!==void 0&&EJ(c,a);t||DJ(c);let n=i??(t?globalThis.fetch:await RJ()),r=await n(c,s(`manual`));if(r.type===`opaqueredirect`){if(!TJ())throw new wJ({url:e,message:`Redirect from ${c} could not be validated and was blocked`});return await n(c,s(`follow`))}let l=r.headers.get(`location`);if(KJ.has(r.status)&&l){await vJ(r);let e=new URL(l,c).toString();if(o!==void 0&&!EJ(e,c)){let e=o.get(`user-agent`);o=new Headers(e==null?void 0:{"user-agent":e})}c=e;continue}return r}throw new wJ({url:e,message:`Too many redirects (max ${r})`})}var JJ=2147483648;async function YJ({response:e,url:t,maxBytes:n=JJ}){let r=e.headers.get(`content-length`);if(r!=null){let i=parseInt(r,10);if(!isNaN(i)&&i>n)throw await vJ(e),new wJ({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${i}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new wJ({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}catch{}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}function XJ(...e){return e.filter(e=>e!=null)}var ZJ=({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new qK({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`},QJ=ZJ(),$J=()=>globalThis.fetch,eY=async({url:e,headers:t={},successfulResponseHandler:n,failedResponseHandler:r,abortSignal:i,fetch:a,validateUrl:o,credentialedOrigin:s,trustedOrigin:c})=>{try{let l=a??$J(),u=rJ(s!==void 0&&!EJ(e,s)?{}:t,`ai-sdk/provider-utils/${tJ}`,Yq()),d=o?await qJ({url:e,headers:u,abortSignal:i,fetch:a,trustedOrigin:c}):await l(e,{method:`GET`,headers:u,signal:i}),f=Jq(d);if(!d.ok){let t;try{t=await r({response:d,url:e,requestBodyValues:{}})}catch(t){throw Xq(t)||PK.isInstance(t)?t:new PK({message:`Failed to process error response`,cause:t,statusCode:d.status,url:e,responseHeaders:f,requestBodyValues:{}})}throw t.value}try{return await n({response:d,url:e,requestBodyValues:{}})}catch(t){throw t instanceof Error&&(Xq(t)||PK.isInstance(t))?t:new PK({message:`Failed to process successful response`,cause:t,statusCode:d.status,url:e,responseHeaders:f,requestBodyValues:{}})}}catch(t){throw eJ({error:t,url:e,requestBodyValues:{}})}};function tY(e){return globalThis.Buffer?.isBuffer(e)??!1}function nY(e){return e!=null}function rY(e){return typeof e==`object`&&!!e&&!(e instanceof Uint8Array)&&!(e instanceof URL)&&!(e instanceof ArrayBuffer)&&!tY(e)&&!(`type`in e)}function iY(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function aY({mediaType:e,url:t,supportedUrls:n}){t=t.toLowerCase(),e=e.toLowerCase();let r=!e.includes(`/`);return Object.entries(n).map(([e,t])=>{let n=e.toLowerCase();return n===`*`||n===`*/*`?{mediaTypePrefix:``,regexes:t}:{mediaTypePrefix:n.replace(/\*/,``),regexes:t}}).filter(({mediaTypePrefix:t})=>t===``?!0:r?`${e}/`===t:e.startsWith(t)).flatMap(({regexes:e})=>e).some(e=>oY(e,t))}function oY(e,t){if(!e.global&&!e.sticky)return e.test(t);let n=e.lastIndex;e.lastIndex=0;try{return e.test(t)}finally{e.lastIndex=n}}function sY({settingValue:e,environmentVariableName:t}){if(typeof e==`string`||!(e!=null||typeof process>`u`)&&(e={}[t],e!=null&&typeof e==`string`))return e}function cY({total:e,pending:t,completed:n,failed:r}){if(lY(e)&&lY(t)&&lY(n)&&lY(r)&&t+n+r===e)return{total:e,pending:t,completed:n,failed:r}}function lY(e){return e!=null&&Number.isSafeInteger(e)&&e>=0}var uY=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,dY=/"(?: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 fY(e){let t=JSON.parse(e);return typeof t!=`object`||!t||uY.test(e)===!1&&dY.test(e)===!1?t:pY(t)}function pY(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function mY(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return fY(e)}try{return fY(e)}finally{Error.stackTraceLimit=t}}function hY(e){if(e.type===`object`||Array.isArray(e.type)&&e.type.includes(`object`)){let{additionalProperties:t}=e;e.additionalProperties=t!=null&&typeof t!=`boolean`&&gY(t);let{properties:n}=e;if(n!=null)for(let e of Object.keys(n))n[e]=gY(n[e])}e.items!=null&&(e.items=Array.isArray(e.items)?e.items.map(gY):gY(e.items)),e.anyOf!=null&&(e.anyOf=e.anyOf.map(gY)),e.allOf!=null&&(e.allOf=e.allOf.map(gY)),e.oneOf!=null&&(e.oneOf=e.oneOf.map(gY));let{definitions:t}=e;if(t!=null)for(let e of Object.keys(t))t[e]=gY(t[e]);return e}function gY(e){return typeof e==`boolean`?e:hY(e)}var _Y=Symbol(`Let zodToJsonSchema decide on which parser to use`),vY={name:void 0,$refStrategy:`root`,basePath:[`#`],effectStrategy:`input`,pipeStrategy:`all`,dateStrategy:`format:date-time`,mapStrategy:`entries`,removeAdditionalStrategy:`passthrough`,allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:`definitions`,strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:`escape`,applyRegexFlags:!1,emailStrategy:`format:email`,base64Strategy:`contentEncoding:base64`,nameStrategy:`ref`},yY=e=>typeof e==`string`?{...vY,name:e}:{...vY,...e};function bY(){return{}}function xY(e,t){let n={type:`array`};return e.type?._def&&e.type?._def?.typeName!==`ZodAny`&&(n.items=fX(e.type._def,{...t,currentPath:[...t.currentPath,`items`]})),e.minLength&&(n.minItems=e.minLength.value),e.maxLength&&(n.maxItems=e.maxLength.value),e.exactLength&&(n.minItems=e.exactLength.value,n.maxItems=e.exactLength.value),n}function SY(e){let t={type:`integer`,format:`int64`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function CY(){return{type:`boolean`}}function wY(e,t){return fX(e.type._def,t)}var TY=(e,t)=>fX(e.innerType._def,t);function EY(e,t,n){let r=n??t.dateStrategy;if(Array.isArray(r))return{anyOf:r.map(n=>EY(e,t,n))};switch(r){case`string`:case`format:date-time`:return{type:`string`,format:`date-time`};case`format:date`:return{type:`string`,format:`date`};case`integer`:return DY(e)}}var DY=e=>{let t={type:`integer`,format:`unix-time`};for(let n of e.checks)switch(n.kind){case`min`:t.minimum=n.value;break;case`max`:t.maximum=n.value}return t};function OY(e,t){return{...fX(e.innerType._def,t),default:e.defaultValue()}}function kY(e,t){return t.effectStrategy===`input`?fX(e.schema._def,t):bY()}function AY(e){return{type:`string`,enum:Array.from(e.values)}}var jY=e=>`type`in e&&e.type===`string`?!1:`allOf`in e;function MY(e,t){let n=[fX(e.left._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]}),fX(e.right._def,{...t,currentPath:[...t.currentPath,`allOf`,`1`]})].filter(e=>!!e),r=[];return n.forEach(e=>{if(jY(e))r.push(...e.allOf);else{let t=e;if(`additionalProperties`in e&&e.additionalProperties===!1){let{additionalProperties:n,...r}=e;t=r}r.push(t)}}),r.length?{allOf:r}:void 0}function NY(e){let t=typeof e.value;return t!==`bigint`&&t!==`number`&&t!==`boolean`&&t!==`string`?{type:Array.isArray(e.value)?`array`:`object`}:{type:t===`bigint`?`integer`:t,const:e.value}}var PY=void 0,FY={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(PY===void 0&&(PY=RegExp(`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,`u`)),PY),uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function IY(e,t){let n={type:`string`};if(e.checks)for(let r of e.checks)switch(r.kind){case`min`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value;break;case`max`:n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`email`:switch(t.emailStrategy){case`format:email`:BY(n,`email`,r.message,t);break;case`format:idn-email`:BY(n,`idn-email`,r.message,t);break;case`pattern:zod`:VY(n,FY.email,r.message,t)}break;case`url`:BY(n,`uri`,r.message,t);break;case`uuid`:BY(n,`uuid`,r.message,t);break;case`regex`:VY(n,r.regex,r.message,t);break;case`cuid`:VY(n,FY.cuid,r.message,t);break;case`cuid2`:VY(n,FY.cuid2,r.message,t);break;case`startsWith`:VY(n,RegExp(`^${LY(r.value,t)}`),r.message,t);break;case`endsWith`:VY(n,RegExp(`${LY(r.value,t)}$`),r.message,t);break;case`datetime`:BY(n,`date-time`,r.message,t);break;case`date`:BY(n,`date`,r.message,t);break;case`time`:BY(n,`time`,r.message,t);break;case`duration`:BY(n,`duration`,r.message,t);break;case`length`:n.minLength=typeof n.minLength==`number`?Math.max(n.minLength,r.value):r.value,n.maxLength=typeof n.maxLength==`number`?Math.min(n.maxLength,r.value):r.value;break;case`includes`:VY(n,RegExp(LY(r.value,t)),r.message,t);break;case`ip`:r.version!==`v6`&&BY(n,`ipv4`,r.message,t),r.version!==`v4`&&BY(n,`ipv6`,r.message,t);break;case`base64url`:VY(n,FY.base64url,r.message,t);break;case`jwt`:VY(n,FY.jwt,r.message,t);break;case`cidr`:r.version!==`v6`&&VY(n,FY.ipv4Cidr,r.message,t),r.version!==`v4`&&VY(n,FY.ipv6Cidr,r.message,t);break;case`emoji`:VY(n,FY.emoji(),r.message,t);break;case`ulid`:VY(n,FY.ulid,r.message,t);break;case`base64`:switch(t.base64Strategy){case`format:binary`:BY(n,`binary`,r.message,t);break;case`contentEncoding:base64`:n.contentEncoding=`base64`;break;case`pattern:zod`:VY(n,FY.base64,r.message,t)}break;case`nanoid`:VY(n,FY.nanoid,r.message,t)}return n}function LY(e,t){return t.patternStrategy===`escape`?zY(e):e}var RY=new Set(`ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789`);function zY(e){let t=``;for(let n=0;n<e.length;n++)RY.has(e[n])||(t+=`\\`),t+=e[n];return t}function BY(e,t,n,r){e.format||e.anyOf?.some(e=>e.format)?(e.anyOf||=[],e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...n&&r.errorMessages&&{errorMessage:{format:n}}})):e.format=t}function VY(e,t,n,r){e.pattern||e.allOf?.some(e=>e.pattern)?(e.allOf||=[],e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:HY(t,r),...n&&r.errorMessages&&{errorMessage:{pattern:n}}})):e.pattern=HY(t,r)}function HY(e,t){if(!t.applyRegexFlags||!e.flags)return e.source;let n={i:e.flags.includes(`i`),m:e.flags.includes(`m`),s:e.flags.includes(`s`)},r=n.i?e.source.toLowerCase():e.source,i=``,a=!1,o=!1,s=!1;for(let e=0;e<r.length;e++){if(a){i+=r[e],a=!1;continue}if(n.i){if(o){if(r[e].match(/[a-z]/)){s?(i+=r[e],i+=`${r[e-2]}-${r[e]}`.toUpperCase(),s=!1):r[e+1]===`-`&&r[e+2]?.match(/[a-z]/)?(i+=r[e],s=!0):i+=`${r[e]}${r[e].toUpperCase()}`;continue}}else if(r[e].match(/[a-z]/)){i+=`[${r[e]}${r[e].toUpperCase()}]`;continue}}if(n.m){if(r[e]===`^`){i+=`(^|(?<=[\r
|
|
129
|
-
]))`;continue}if(r[e]===`$`){i+=`($|(?=[\r
|
|
130
|
-
]))`;continue}}if(n.s&&r[e]===`.`){i+=o?`${r[e]}\r
|
|
131
|
-
`:`[${r[e]}\r
|
|
132
|
-
]`;continue}i+=r[e],r[e]===`\\`?a=!0:o&&r[e]===`]`?o=!1:!o&&r[e]===`[`&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join(`/`)} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function UY(e,t){let n={type:`object`,additionalProperties:fX(e.valueType._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]})??t.allowedAdditionalProperties};if(e.keyType?._def.typeName===`ZodString`&&e.keyType._def.checks?.length){let{type:r,...i}=IY(e.keyType._def,t);return{...n,propertyNames:i}}if(e.keyType?._def.typeName===`ZodEnum`)return{...n,propertyNames:{enum:e.keyType._def.values}};if(e.keyType?._def.typeName===`ZodBranded`&&e.keyType._def.type._def.typeName===`ZodString`&&e.keyType._def.type._def.checks?.length){let{type:r,...i}=wY(e.keyType._def,t);return{...n,propertyNames:i}}return n}function WY(e,t){return t.mapStrategy===`record`?UY(e,t):{type:`array`,maxItems:125,items:{type:`array`,items:[fX(e.keyType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`0`]})||bY(),fX(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`,`items`,`1`]})||bY()],minItems:2,maxItems:2}}}function GY(e){let t=e.values,n=Object.keys(e.values).filter(e=>typeof t[t[e]]!=`number`).map(e=>t[e]),r=Array.from(new Set(n.map(e=>typeof e)));return{type:r.length===1?r[0]===`string`?`string`:`number`:[`string`,`number`],enum:n}}function KY(){return{not:bY()}}function qY(){return{type:`null`}}var JY={ZodString:`string`,ZodNumber:`number`,ZodBigInt:`integer`,ZodBoolean:`boolean`,ZodNull:`null`};function YY(e,t){let n=e.options instanceof Map?Array.from(e.options.values()):e.options;if(n.every(e=>e._def.typeName in JY&&(!e._def.checks||!e._def.checks.length))){let e=n.reduce((e,t)=>{let n=JY[t._def.typeName];return n&&!e.includes(n)?[...e,n]:e},[]);return{type:e.length>1?e:e[0]}}if(n.every(e=>e._def.typeName===`ZodLiteral`&&!e.description)){let e=n.reduce((e,t)=>{let n=typeof t._def.value;switch(n){case`string`:case`number`:case`boolean`:return[...e,n];case`bigint`:return[...e,`integer`];case`object`:if(t._def.value===null)return[...e,`null`];default:return e}},[]);if(e.length===n.length){let t=e.filter((e,t,n)=>n.indexOf(e)===t);return{type:t.length>1?t:t[0],enum:n.reduce((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value],[])}}}else if(n.every(e=>e._def.typeName===`ZodEnum`))return{type:`string`,enum:n.reduce((e,t)=>[...e,...t._def.values.filter(t=>!e.includes(t))],[])};return XY(e,t)}var XY=(e,t)=>{let n=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((e,n)=>fX(e._def,{...t,currentPath:[...t.currentPath,`anyOf`,`${n}`]})).filter(e=>!!e&&(!t.strictUnions||typeof e==`object`&&Object.keys(e).length>0));return n.length?{anyOf:n}:void 0};function ZY(e,t){if([`ZodString`,`ZodNumber`,`ZodBigInt`,`ZodBoolean`,`ZodNull`].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[JY[e.innerType._def.typeName],`null`]};let n=fX(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`0`]});return n&&{anyOf:[n,{type:`null`}]}}function QY(e){let t={type:`number`};if(!e.checks)return t;for(let n of e.checks)switch(n.kind){case`int`:t.type=`integer`;break;case`min`:n.inclusive?t.minimum=n.value:t.exclusiveMinimum=n.value;break;case`max`:n.inclusive?t.maximum=n.value:t.exclusiveMaximum=n.value;break;case`multipleOf`:t.multipleOf=n.value}return t}function $Y(e,t){let n={type:`object`,properties:{}},r=[],i=e.shape();for(let e in i){let a=i[e];if(a===void 0||a._def===void 0)continue;let o=tX(a),s=fX(a._def,{...t,currentPath:[...t.currentPath,`properties`,e],propertyPath:[...t.currentPath,`properties`,e]});s!==void 0&&(n.properties[e]=s,o||r.push(e))}r.length&&(n.required=r);let a=eX(e,t);return a!==void 0&&(n.additionalProperties=a),n}function eX(e,t){if(e.catchall._def.typeName!==`ZodNever`)return fX(e.catchall._def,{...t,currentPath:[...t.currentPath,`additionalProperties`]});switch(e.unknownKeys){case`passthrough`:return t.allowedAdditionalProperties;case`strict`:return t.rejectedAdditionalProperties;case`strip`:return t.removeAdditionalStrategy===`strict`?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function tX(e){try{return e.isOptional()}catch{return!0}}var nX=(e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return fX(e.innerType._def,t);let n=fX(e.innerType._def,{...t,currentPath:[...t.currentPath,`anyOf`,`1`]});return n?{anyOf:[{not:bY()},n]}:bY()},rX=(e,t)=>{if(t.pipeStrategy===`input`)return fX(e.in._def,t);if(t.pipeStrategy===`output`)return fX(e.out._def,t);let n=fX(e.in._def,{...t,currentPath:[...t.currentPath,`allOf`,`0`]});return{allOf:[n,fX(e.out._def,{...t,currentPath:[...t.currentPath,`allOf`,n?`1`:`0`]})].filter(e=>e!==void 0)}};function iX(e,t){return fX(e.type._def,t)}function aX(e,t){let n={type:`array`,uniqueItems:!0,items:fX(e.valueType._def,{...t,currentPath:[...t.currentPath,`items`]})};return e.minSize&&(n.minItems=e.minSize.value),e.maxSize&&(n.maxItems=e.maxSize.value),n}function oX(e,t){return e.rest?{type:`array`,minItems:e.items.length,items:e.items.map((e,n)=>fX(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[]),additionalItems:fX(e.rest._def,{...t,currentPath:[...t.currentPath,`additionalItems`]})}:{type:`array`,minItems:e.items.length,maxItems:e.items.length,items:e.items.map((e,n)=>fX(e._def,{...t,currentPath:[...t.currentPath,`items`,`${n}`]})).reduce((e,t)=>t===void 0?e:[...e,t],[])}}function sX(){return{not:bY()}}function cX(){return bY()}var lX=(e,t)=>fX(e.innerType._def,t),uX=(e,t,n)=>{switch(t){case`ZodString`:return IY(e,n);case`ZodNumber`:return QY(e);case`ZodObject`:return $Y(e,n);case`ZodBigInt`:return SY(e);case`ZodBoolean`:return CY();case`ZodDate`:return EY(e,n);case`ZodUndefined`:return sX();case`ZodNull`:return qY();case`ZodArray`:return xY(e,n);case`ZodUnion`:case`ZodDiscriminatedUnion`:return YY(e,n);case`ZodIntersection`:return MY(e,n);case`ZodTuple`:return oX(e,n);case`ZodRecord`:return UY(e,n);case`ZodLiteral`:return NY(e);case`ZodEnum`:return AY(e);case`ZodNativeEnum`:return GY(e);case`ZodNullable`:return ZY(e,n);case`ZodOptional`:return nX(e,n);case`ZodMap`:return WY(e,n);case`ZodSet`:return aX(e,n);case`ZodLazy`:return()=>e.getter()._def;case`ZodPromise`:return iX(e,n);case`ZodNaN`:case`ZodNever`:return KY();case`ZodEffects`:return kY(e,n);case`ZodAny`:return bY();case`ZodUnknown`:return cX();case`ZodDefault`:return OY(e,n);case`ZodBranded`:return wY(e,n);case`ZodReadonly`:return lX(e,n);case`ZodCatch`:return TY(e,n);case`ZodPipeline`:return rX(e,n);case`ZodFunction`:case`ZodVoid`:case`ZodSymbol`:return;default:return(e=>void 0)(t)}},dX=(e,t)=>{let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];n++);return[(e.length-n).toString(),...t.slice(n)].join(`/`)};function fX(e,t,n=!1){let r=t.seen.get(e);if(t.override){let i=t.override?.call(t,e,t,r,n);if(i!==_Y)return i}if(r&&!n){let e=pX(r,t);if(e!==void 0)return e}let i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);let a=uX(e,e.typeName,t),o=typeof a==`function`?fX(a(),t):a;if(o&&mX(e,t,o),t.postProcess){let n=t.postProcess(o,e,t);return i.jsonSchema=o,n}return i.jsonSchema=o,o}var pX=(e,t)=>{switch(t.$refStrategy){case`root`:return{$ref:e.path.join(`/`)};case`relative`:return{$ref:dX(t.currentPath,e.path)};case`none`:case`seen`:return e.path.length<t.currentPath.length&&e.path.every((e,n)=>t.currentPath[n]===e)?(console.warn(`Recursive reference detected at ${t.currentPath.join(`/`)}! Defaulting to any`),bY()):t.$refStrategy===`seen`?bY():void 0}},mX=(e,t,n)=>(e.description&&(n.description=e.description),n),hX=e=>{let t=yY(e),n=t.name===void 0?t.basePath:[...t.basePath,t.definitionPath,t.name];return{...t,currentPath:n,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([e,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}]))}},gX=(e,t)=>{let n=hX(t),r=typeof t==`object`&&t.definitions?Object.entries(t.definitions).reduce((e,[t,r])=>({...e,[t]:fX(r._def,{...n,currentPath:[...n.basePath,n.definitionPath,t]},!0)??bY()}),{}):void 0,i=typeof t==`string`?t:t?.nameStrategy===`title`?void 0:t?.name,a=fX(e._def,i===void 0?n:{...n,currentPath:[...n.basePath,n.definitionPath,i]},!1)??bY(),o=typeof t==`object`&&t.name!==void 0&&t.nameStrategy===`title`?t.name:void 0;o!==void 0&&(a.title=o);let s=i===void 0?r?{...a,[n.definitionPath]:r}:a:{$ref:[...n.$refStrategy===`relative`?[]:n.basePath,n.definitionPath,i].join(`/`),[n.definitionPath]:{...r,[i]:a}};return s.$schema=`http://json-schema.org/draft-07/schema#`,s},_X=Symbol.for(`vercel.ai.schema`);function vX(e){let t;return()=>(t??=e(),t)}function yX(e,{validate:t}={}){return{[_X]:!0,_type:void 0,get jsonSchema(){return typeof e==`function`&&(e=e()),e},validate:t}}function bX(e){return typeof e==`object`&&!!e&&_X in e&&e[_X]===!0&&`jsonSchema`in e&&`validate`in e}function xX(e){return e==null?yX({type:`object`,properties:{},additionalProperties:!1}):bX(e)?e:`~standard`in e?e[`~standard`].vendor===`zod`?DX(e):SX(e):e()}function SX(e){return yX(()=>{if(!CX(e))throw Error(`Standard schema vendor '${e[`~standard`].vendor}' does not support JSON Schema conversion.`);return hY(e[`~standard`].jsonSchema.input({target:`draft-07`}))},{validate:async t=>{let n=await e[`~standard`].validate(t);return`value`in n?{success:!0,value:n.value}:{success:!1,error:new dq({value:t,cause:n.issues})}}})}function CX(e){return e[`~standard`].jsonSchema!=null}function wX(e,t){let n=t?.useReferences??!1;return yX(()=>gX(e,{$refStrategy:n?`root`:`none`}),{validate:async t=>{let n=await e.safeParseAsync(t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function TX(e,t){let n=t?.useReferences??!1;return yX(()=>hY(FH(e,{target:`draft-7`,io:`input`,reused:n?`ref`:`inline`})),{validate:async t=>{let n=await HH(e,t);return n.success?{success:!0,value:n.data}:{success:!1,error:n.error}}})}function EX(e){return`_zod`in e}function DX(e,t){return EX(e)?TX(e,t):wX(e,t)}async function OX({value:e,schema:t,context:n}){let r=await kX({value:e,schema:t,context:n});if(!r.success)throw dq.wrap({value:e,cause:r.error,context:n});return r.value}async function kX({value:e,schema:t,context:n}){let r=xX(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};let t=await r.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:dq.wrap({value:e,cause:t.error,context:n}),rawValue:e}}catch(t){return{success:!1,error:dq.wrap({value:e,cause:t,context:n}),rawValue:e}}}async function AX({text:e,schema:t}){try{let n=mY(e);return t==null?n:await OX({value:n,schema:t})}catch(t){throw aq.isInstance(t)||dq.isInstance(t)?t:new aq({text:e,cause:t})}}async function jX({text:e,schema:t}){try{let n=mY(e);return t==null?{success:!0,value:n,rawValue:n}:await kX({value:n,schema:t})}catch(t){return{success:!1,error:aq.isInstance(t)?t:new aq({text:e,cause:t}),rawValue:void 0}}}function MX({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Eq).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await jX({text:e,schema:t}))}}))}var NX=()=>globalThis.fetch,PX=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>await FX({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),FX=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=NX()})=>{try{let s=await o(e,{method:`POST`,headers:rJ(t,`ai-sdk/provider-utils/${tJ}`,Yq()),body:n.content,signal:a}),c=Jq(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw Xq(t)||PK.isInstance(t)?t:new PK({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(Xq(t)||PK.isInstance(t))?t:new PK({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw eJ({error:t,url:e,requestBodyValues:n.values})}};function IX(e){return e}function LX({id:e,inputSchema:t,outputSchema:n,supportsDeferredResults:r}){return({onInputStart:i,onInputDelta:a,onInputAvailable:o,...s})=>IX({type:`provider`,isProviderExecuted:!0,id:e,args:s,inputSchema:t,outputSchema:n,onInputStart:i,onInputDelta:a,onInputAvailable:o,supportsDeferredResults:r})}async function RX(e){return typeof e==`function`&&(e=e()),Promise.resolve(e)}var zX=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r,shouldRetry:i,getDelayInMs:a=({exponentialBackoffDelay:e})=>e,createRetryError:o=({message:e})=>Error(e)})=>async s=>BX(s,{maxRetries:e,delayInMs:t,backoffFactor:n,abortSignal:r,shouldRetry:i,getDelayInMs:a,createRetryError:o});async function BX(e,{maxRetries:t,delayInMs:n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},c=[]){try{return await e()}catch(l){if(Xq(l)||t===0)throw l;let u=VK(l),d=[...c,l],f=d.length;if(f>t)throw s({message:`Failed after ${f} attempts. Last error: ${u}`,reason:`maxRetriesExceeded`,errors:d});if(await a(l)&&f<=t)return await Mq(o({error:l,exponentialBackoffDelay:n}),{abortSignal:i}),BX(e,{maxRetries:t,delayInMs:r*n,backoffFactor:r,abortSignal:i,shouldRetry:a,getDelayInMs:o,createRetryError:s},d);throw f===1?l:s({message:`Failed after ${f} attempts with non-retryable error: '${u}'`,reason:`errorNotRetryable`,errors:d})}}var VX=new TextDecoder;function HX({stream:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i}){let a=e.getReader(),o=!1,s=()=>{o||=(a.releaseLock(),!0)};return new ReadableStream({async pull(e){try{let{done:t,value:n}=await a.read();t?(s(),e.close()):e.enqueue(n)}catch(a){if(s(),Xq(a)){e.error(a);return}e.error(eJ({error:new PK({message:`Failed to process successful response`,cause:a,statusCode:r,url:t,responseHeaders:i,requestBodyValues:n}),url:t,requestBodyValues:n}))}},async cancel(e){try{await a.cancel(e)}finally{s()}}})}async function UX({response:e,url:t}){return VX.decode(await YJ({response:e,url:t}))}var WX=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await UX({response:r,url:i}),s=Jq(r);if(o.trim()===``)return{responseHeaders:s,value:new PK({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await AX({text:o,schema:e});return{responseHeaders:s,value:new PK({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new PK({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},GX=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=Jq(t);if(t.body==null)throw new BK({});return{responseHeaders:i,value:MX({stream:HX({stream:t.body,url:n,requestBodyValues:r,statusCode:t.status,responseHeaders:i}),schema:e})}},KX=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await UX({response:t,url:n}),a=await jX({text:i,schema:e}),o=Jq(t);if(!a.success)throw new PK({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}},qX=e=>async({response:t})=>{let n=Jq(t);if(t.body==null)throw new BK({});return{responseHeaders:n,value:JX({stream:t.body,schema:e})}};async function*JX({stream:e,schema:t}){let n=e.getReader(),r=new TextDecoder,i=``,a=!1;try{for(;;){let{done:e,value:o}=await n.read();if(e){a=!0,i+=r.decode();break}i+=r.decode(o,{stream:!0});let s=i.indexOf(`
|
|
133
|
-
`);for(;s!==-1;){let e=i.slice(0,s).replace(/\r$/,``);i=i.slice(s+1),e.trim().length>0&&(yield await AX({text:e,schema:t})),s=i.indexOf(`
|
|
134
|
-
`)}}let e=i.replace(/\r$/,``);e.trim().length>0&&(yield await AX({text:e,schema:t}))}finally{a||await n.cancel().catch(()=>{}),n.releaseLock()}}function YX(e){if(e==null)return!0;let t=typeof e;return t===`string`||t===`number`||t===`boolean`?!0:t===`function`||t===`symbol`||t===`bigint`?!1:Array.isArray(e)?e.every(YX):Object.getPrototypeOf(e)===Object.prototype&&Object.values(e).every(YX)}var XX=`AI_SerializationError`,ZX=`vercel.ai.error.${XX}`,QX=Symbol.for(ZX),$X,eZ,tZ=class extends (eZ=K,$X=QX,eZ){constructor({message:e=`Failed to serialize value.`,cause:t}={}){super({name:XX,message:e,cause:t}),this[$X]=!0}static isInstance(e){return K.hasMarker(e,ZX)}};function nZ(e){let t={};for(let[n,r]of Object.entries(e.config))if(n===`headers`){let e=rZ(r);YX(e)&&(t[n]=e)}else YX(r)&&(t[n]=r);return{modelId:e.modelId,config:t}}function rZ(e){let t=e;if(typeof e==`function`&&(t=e()),t instanceof Promise)throw new tZ({message:`Cannot serialize asynchronous model options.`});return t}var iZ=`transcription-stream.start`,aZ=`transcription-stream.audio-done`;function oZ(e){let t;try{t=mY(e)}catch{return}if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t;switch(n.type){case`stream-start`:return Array.isArray(n.warnings)&&n.warnings.every(uZ)?n:void 0;case`transcript-delta`:return sZ(n.delta)&&lZ(n.id,sZ)&&lZ(n.providerMetadata,iY)?n:void 0;case`transcript-partial`:return sZ(n.text)&&lZ(n.id,sZ)&&lZ(n.startSecond,cZ)&&lZ(n.durationInSeconds,cZ)&&lZ(n.channelIndex,cZ)&&lZ(n.providerMetadata,iY)?n:void 0;case`transcript-final`:return sZ(n.text)&&lZ(n.id,sZ)&&lZ(n.startSecond,cZ)&&lZ(n.endSecond,cZ)&&lZ(n.channelIndex,cZ)&&lZ(n.providerMetadata,iY)?n:void 0;case`finish`:return sZ(n.text)&&Array.isArray(n.segments)&&n.segments.every(dZ)&&lZ(n.language,sZ)&&lZ(n.durationInSeconds,cZ)&&lZ(n.providerMetadata,iY)?n:void 0;case`response-metadata`:{if(!(lZ(n.modelId,sZ)&&lZ(n.headers,iY)))return;let e=n.timestamp;if(e==null)return{...n,timestamp:void 0};if(typeof e!=`string`)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:{...n,timestamp:t}}case`raw`:return`rawValue`in n?n:void 0;case`error`:return`error`in n?n:void 0;default:return}}function sZ(e){return typeof e==`string`}function cZ(e){return typeof e==`number`}function lZ(e,t){return e===void 0||t(e)}function uZ(e){return iY(e)&&sZ(e.type)}function dZ(e){return iY(e)&&sZ(e.text)&&cZ(e.startSecond)&&cZ(e.endSecond)}function fZ(e){return e?.replace(/\/$/,``)}function pZ(e){return e!=null&&typeof e.execute==`function`}function mZ(e){return e!=null&&typeof e[Symbol.asyncIterator]==`function`}async function*hZ({tool:e,input:t,options:n}){let r=e.execute(t,n);if(mZ(r)){let e;for await(let t of r)e=t,yield{type:`preliminary`,output:t};yield{type:`final`,output:e}}else yield{type:`final`,output:await r}}function gZ(e){return e?.experimental_toolCaller}var _Z=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);var u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}0&&(t.exports={SYMBOL_FOR_REQ_CONTEXT:u,getContext:d})})),vZ=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>u,RefreshAccessTokenFailedError:()=>d}),t.exports=c(l);var u=class extends Error{constructor(){super(`No authentication found. Please log in with the Vercel CLI (vercel login).`),this.name=`AccessTokenMissingError`}},d=class extends Error{constructor(e){super(`Failed to refresh authentication token.`,{cause:e}),this.name=`RefreshAccessTokenFailedError`}};0&&(t.exports={AccessTokenMissingError:u,RefreshAccessTokenFailedError:d})})),yZ=o(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{AccessTokenMissingError:()=>d.AccessTokenMissingError,RefreshAccessTokenFailedError:()=>d.RefreshAccessTokenFailedError,getContext:()=>u.getContext,getVercelOidcToken:()=>f,getVercelOidcTokenSync:()=>p,getVercelToken:()=>m}),t.exports=c(l);var u=_Z(),d=vZ();async function f(){return``}function p(){return``}async function m(){throw Error(`getVercelToken is not supported in browser environments`)}0&&(t.exports={AccessTokenMissingError,RefreshAccessTokenFailedError,getContext,getVercelOidcToken:f,getVercelOidcTokenSync:p,getVercelToken:m})}))(),bZ=`ai-gateway-realtime.v1`,xZ=`ai-gateway-transcription.v1`,SZ=`ai-gateway-auth.`,CZ=`ai-gateway-team.`;function wZ(e,t){return EZ(bZ,e,t)}function TZ(e,t){return EZ(xZ,e,t)}function EZ(e,t,n){let r=[e,`${SZ}${t}`];return n?.teamIdOrSlug&&r.push(`${CZ}${DZ(n.teamIdOrSlug)}`),r}function DZ(e){let t=new TextEncoder().encode(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/u,``)}var q={any:FU,array:VU,boolean:jU,discriminatedUnion:JU,enum:eW,literal:nW,number:DU,object:UU,record:QU,string:G,union:KU,unknown:LU},OZ=Symbol.for(`vercel.ai.gateway.error`),kZ,AZ,jZ=class e extends (AZ=Error,kZ=OZ,AZ){constructor({message:e,statusCode:t=500,cause:n,generationId:r,isRetryable:i=t!=null&&(t===408||t===409||t===429||t>=500)}){super(r?`${e} [${r}]`:e),this[kZ]=!0,this.statusCode=t,this.cause=n,this.generationId=r,this.isRetryable=i}static isInstance(t){return e.hasMarker(t)}static hasMarker(e){return typeof e==`object`&&!!e&&OZ in e&&e[OZ]===!0}},MZ=`GatewayAuthenticationError`,NZ=`vercel.ai.gateway.error.${MZ}`,PZ=Symbol.for(NZ),FZ,IZ,LZ=class e extends (IZ=jZ,FZ=PZ,IZ){constructor({message:e=`Authentication failed`,statusCode:t=401,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[FZ]=!0,this.name=MZ,this.type=`authentication_error`}static isInstance(e){return jZ.hasMarker(e)&&PZ in e}static createContextualError({apiKeyProvided:t,oidcTokenProvided:n,statusCode:r=401,cause:i,generationId:a}){let o;return o=t?`AI Gateway authentication failed: Invalid API key or token.
|
|
135
|
-
|
|
136
|
-
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
137
|
-
|
|
138
|
-
Provide an API key or Vercel access token via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.`:n?`AI Gateway authentication failed: Invalid OIDC token.
|
|
139
|
-
|
|
140
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.
|
|
141
|
-
|
|
142
|
-
Alternatively, use an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
143
|
-
or pass a Vercel access token via the 'apiKey' option.`:`AI Gateway authentication failed: No authentication provided.
|
|
144
|
-
|
|
145
|
-
Option 1 - API key:
|
|
146
|
-
Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
147
|
-
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
148
|
-
|
|
149
|
-
Option 2 - Vercel access token:
|
|
150
|
-
Pass a Vercel personal access token or Vercel app access token via the 'apiKey' option.
|
|
151
|
-
|
|
152
|
-
Option 3 - OIDC token:
|
|
153
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new e({message:o,statusCode:r,cause:i,generationId:a})}},RZ=`GatewayInvalidRequestError`,zZ=`vercel.ai.gateway.error.${RZ}`,BZ=Symbol.for(zZ),VZ,HZ,UZ=class extends (HZ=jZ,VZ=BZ,HZ){constructor({message:e=`Invalid request`,statusCode:t=400,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[VZ]=!0,this.name=RZ,this.type=`invalid_request_error`}static isInstance(e){return jZ.hasMarker(e)&&BZ in e}},WZ=`GatewayRateLimitError`,GZ=`vercel.ai.gateway.error.${WZ}`,KZ=Symbol.for(GZ),qZ,JZ,YZ=class extends (JZ=jZ,qZ=KZ,JZ){constructor({message:e=`Rate limit exceeded`,statusCode:t=429,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[qZ]=!0,this.name=WZ,this.type=`rate_limit_exceeded`}static isInstance(e){return jZ.hasMarker(e)&&KZ in e}},XZ=`GatewayModelNotFoundError`,ZZ=`vercel.ai.gateway.error.${XZ}`,QZ=Symbol.for(ZZ),$Z=vX(()=>DX(q.object({modelId:q.string()}))),eQ,tQ,nQ=class extends (tQ=jZ,eQ=QZ,tQ){constructor({message:e=`Model not found`,statusCode:t=404,modelId:n,cause:r,generationId:i}={}){super({message:e,statusCode:t,cause:r,generationId:i}),this[eQ]=!0,this.name=XZ,this.type=`model_not_found`,this.modelId=n}static isInstance(e){return jZ.hasMarker(e)&&QZ in e}},rQ=`GatewayNotFoundError`,iQ=`vercel.ai.gateway.error.${rQ}`,aQ=Symbol.for(iQ),oQ,sQ,cQ=class extends (sQ=jZ,oQ=aQ,sQ){constructor({message:e=`Resource not found`,statusCode:t=404,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[oQ]=!0,this.name=rQ,this.type=`not_found`}static isInstance(e){return jZ.hasMarker(e)&&aQ in e}},lQ=`GatewayInternalServerError`,uQ=`vercel.ai.gateway.error.${lQ}`,dQ=Symbol.for(uQ),fQ,pQ,mQ=class extends (pQ=jZ,fQ=dQ,pQ){constructor({message:e=`Internal server error`,statusCode:t=500,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[fQ]=!0,this.name=lQ,this.type=`internal_server_error`}static isInstance(e){return jZ.hasMarker(e)&&dQ in e}},hQ=`GatewayFailedDependencyError`,gQ=`vercel.ai.gateway.error.${hQ}`,_Q=Symbol.for(gQ),vQ,yQ,bQ=class extends (yQ=jZ,vQ=_Q,yQ){constructor({message:e=`Failed dependency`,statusCode:t=424,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[vQ]=!0,this.name=hQ,this.type=`failed_dependency`}static isInstance(e){return jZ.hasMarker(e)&&_Q in e}},xQ=`GatewayForbiddenError`,SQ=`vercel.ai.gateway.error.${xQ}`,CQ=Symbol.for(SQ),wQ=vX(()=>DX(q.object({ruleId:q.string()}))),TQ,EQ,DQ=class extends (EQ=jZ,TQ=CQ,EQ){constructor({message:e=`Forbidden`,statusCode:t=403,cause:n,generationId:r,ruleId:i}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[TQ]=!0,this.name=xQ,this.type=`forbidden`,this.ruleId=i}static isInstance(e){return jZ.hasMarker(e)&&CQ in e}},OQ=`GatewayResponseError`,kQ=`vercel.ai.gateway.error.${OQ}`,AQ=Symbol.for(kQ),jQ,MQ,NQ=class extends (MQ=jZ,jQ=AQ,MQ){constructor({message:e=`Invalid response from Gateway`,statusCode:t=502,response:n,validationError:r,cause:i,generationId:a,isRetryable:o}={}){super({message:e,statusCode:t,cause:i,generationId:a,isRetryable:o}),this[jQ]=!0,this.name=OQ,this.type=`response_error`,this.response=n,this.validationError=r}static isInstance(e){return jZ.hasMarker(e)&&AQ in e}};async function PQ({response:e,statusCode:t,defaultMessage:n=`Gateway request failed`,cause:r,authMethod:i,isRetryable:a}){let o=await kX({value:e,schema:FQ});if(!o.success){let i=typeof e==`object`&&e&&`generationId`in e?e.generationId:void 0;return new NQ({message:`Invalid error response format: ${n}`,statusCode:t,response:e,validationError:o.error,cause:r,generationId:i,isRetryable:a})}let s=o.value,c=s.error.type,l=s.error.message,u=s.generationId??void 0;switch(c){case`authentication_error`:return LZ.createContextualError({apiKeyProvided:i===`api-key`,oidcTokenProvided:i===`oidc`,statusCode:t,cause:r,generationId:u});case`invalid_request_error`:return new UZ({message:l,statusCode:t,cause:r,generationId:u});case`rate_limit_exceeded`:return new YZ({message:l,statusCode:t,cause:r,generationId:u});case`model_not_found`:{let e=await kX({value:s.error.param,schema:$Z});return new nQ({message:l,statusCode:t,modelId:e.success?e.value.modelId:void 0,cause:r,generationId:u})}case`not_found`:return new cQ({message:l,statusCode:t,cause:r,generationId:u});case`internal_server_error`:return new mQ({message:l,statusCode:t,cause:r,generationId:u});case`failed_dependency`:return new bQ({message:l,statusCode:t,cause:r,generationId:u});case`forbidden`:{let e=await kX({value:s.error.param,schema:wQ});return new DQ({message:l,statusCode:t,cause:r,generationId:u,ruleId:e.success?e.value.ruleId:void 0})}default:return new mQ({message:l,statusCode:t,cause:r,generationId:u})}}var FQ=vX(()=>DX(q.object({error:q.object({message:q.string(),type:q.string().nullish(),param:q.unknown().nullish(),code:q.union([q.string(),q.number()]).nullish()}),generationId:q.string().nullish()})));function IQ(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return mY(e.responseBody)}catch{return e.responseBody}return{}}var LQ=`GatewayTimeoutError`,RQ=`vercel.ai.gateway.error.${LQ}`,zQ=Symbol.for(RQ),BQ,VQ,HQ=class e extends (VQ=jZ,BQ=zQ,VQ){constructor({message:e=`Request timed out`,statusCode:t=408,cause:n,generationId:r}={}){super({message:e,statusCode:t,cause:n,generationId:r}),this[BQ]=!0,this.name=LQ,this.type=`timeout_error`}static isInstance(e){return jZ.hasMarker(e)&&zQ in e}static createTimeoutError({originalMessage:t,statusCode:n=408,cause:r,generationId:i}){let a=`Gateway request timed out: ${t}
|
|
154
|
-
|
|
155
|
-
This is a client-side timeout. To resolve this, increase your timeout configuration: https://vercel.com/docs/ai-gateway/capabilities/video-generation#extending-timeouts-for-node.js`;return new e({message:a,statusCode:n,cause:r,generationId:i})}};function UQ(e){if(!(e instanceof Error))return!1;let t=e.code;return typeof t==`string`&&[`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`].includes(t)}async function WQ(e,t){return jZ.isInstance(e)?e:UQ(e)?HQ.createTimeoutError({originalMessage:e instanceof Error?e.message:`Unknown error`,cause:e}):PK.isInstance(e)?e.cause&&UQ(e.cause)?HQ.createTimeoutError({originalMessage:e.message,cause:e}):await PQ({response:IQ(e),statusCode:e.statusCode??500,defaultMessage:`Gateway request failed`,cause:e,authMethod:t,isRetryable:e.isRetryable&&(e.statusCode==null||e.statusCode<400)?!0:void 0}):await PQ({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:`Unknown Gateway error`,cause:e,authMethod:t})}var GQ=`ai-gateway-auth-method`,KQ=`x-vercel-ai-gateway-team`;async function qQ(e){let t=await kX({value:e[GQ],schema:JQ});return t.success?t.value:void 0}var JQ=vX(()=>DX(q.union([q.literal(`api-key`),q.literal(`oidc`)]))),YQ=[`embedding`,`image`,`language`,`realtime`,`reranking`,`speech`,`transcription`,`video`],XQ=class{constructor(e){this.config=e}async getAvailableModels(){try{let{value:e}=await eY({url:`${this.config.baseURL}/config`,validateUrl:!1,headers:this.config.headers?await RX(this.config.headers):void 0,successfulResponseHandler:KX(ZQ),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),fetch:this.config.fetch});return e}catch(e){throw await WQ(e)}}async getCredits(){try{let{value:e}=await eY({url:`${new URL(this.config.baseURL).origin}/v1/credits`,validateUrl:!1,headers:this.config.headers?await RX(this.config.headers):void 0,successfulResponseHandler:KX(QQ),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),fetch:this.config.fetch});return e}catch(e){throw await WQ(e)}}},ZQ=vX(()=>DX(q.object({models:q.array(q.object({id:q.string(),name:q.string(),description:q.string().nullish(),pricing:q.object({input:q.string(),output:q.string(),input_cache_read:q.string().nullish(),input_cache_write:q.string().nullish()}).transform(({input:e,output:t,input_cache_read:n,input_cache_write:r})=>({input:e,output:t,...n?{cachedInputTokens:n}:{},...r?{cacheCreationInputTokens:r}:{}})).nullish(),specification:q.object({specificationVersion:q.literal(`v4`),provider:q.string(),modelId:q.string()}),modelType:q.string().nullish()})).transform(e=>e.filter(e=>e.modelType==null||YQ.includes(e.modelType)))}))),QQ=vX(()=>DX(q.object({balance:q.string(),total_used:q.string()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),$Q=class{constructor(e){this.config=e}async getSpendReport(e){try{let t=new URL(this.config.baseURL),n=new URLSearchParams;n.set(`start_date`,e.startDate),n.set(`end_date`,e.endDate),e.groupBy&&n.set(`group_by`,e.groupBy),e.datePart&&n.set(`date_part`,e.datePart),e.userId&&n.set(`user_id`,e.userId),e.model&&n.set(`model`,e.model),e.provider&&n.set(`provider`,e.provider),e.credentialType&&n.set(`credential_type`,e.credentialType),e.tags&&e.tags.length>0&&n.set(`tags`,e.tags.join(`,`));let{value:r}=await eY({url:`${t.origin}/v1/report?${n.toString()}`,validateUrl:!1,headers:this.config.headers?await RX(this.config.headers):void 0,successfulResponseHandler:KX(e$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),fetch:this.config.fetch});return r}catch(e){throw await WQ(e)}}},e$=vX(()=>DX(q.object({results:q.array(q.object({day:q.string().optional(),hour:q.string().optional(),user:q.string().optional(),model:q.string().optional(),tag:q.string().optional(),provider:q.string().optional(),credential_type:q.enum([`byok`,`system`]).optional(),total_cost:q.number(),market_cost:q.number().optional(),input_tokens:q.number().optional(),output_tokens:q.number().optional(),cached_input_tokens:q.number().optional(),cache_creation_input_tokens:q.number().optional(),reasoning_tokens:q.number().optional(),request_count:q.number().optional()}).transform(({credential_type:e,total_cost:t,market_cost:n,input_tokens:r,output_tokens:i,cached_input_tokens:a,cache_creation_input_tokens:o,reasoning_tokens:s,request_count:c,...l})=>({...l,...e===void 0?{}:{credentialType:e},totalCost:t,...n===void 0?{}:{marketCost:n},...r===void 0?{}:{inputTokens:r},...i===void 0?{}:{outputTokens:i},...a===void 0?{}:{cachedInputTokens:a},...o===void 0?{}:{cacheCreationInputTokens:o},...s===void 0?{}:{reasoningTokens:s},...c===void 0?{}:{requestCount:c}})))}))),t$=class{constructor(e){this.config=e}async getGenerationInfo(e){try{let{value:t}=await eY({url:`${new URL(this.config.baseURL).origin}/v1/generation?id=${encodeURIComponent(e.id)}`,validateUrl:!1,headers:this.config.headers?await RX(this.config.headers):void 0,successfulResponseHandler:KX(n$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),fetch:this.config.fetch});return t}catch(e){throw await WQ(e)}}},n$=vX(()=>DX(q.object({data:q.object({id:q.string(),total_cost:q.number(),upstream_inference_cost:q.number(),usage:q.number(),created_at:q.string(),model:q.string(),is_byok:q.boolean(),provider_name:q.string(),streamed:q.boolean(),finish_reason:q.string(),latency:q.number(),generation_time:q.number(),native_tokens_prompt:q.number(),native_tokens_completion:q.number(),native_tokens_reasoning:q.number(),native_tokens_cached:q.number(),native_tokens_cache_creation:q.number(),billable_web_search_calls:q.number()}).transform(({total_cost:e,upstream_inference_cost:t,created_at:n,is_byok:r,provider_name:i,finish_reason:a,generation_time:o,native_tokens_prompt:s,native_tokens_completion:c,native_tokens_reasoning:l,native_tokens_cached:u,native_tokens_cache_creation:d,billable_web_search_calls:f,...p})=>({...p,totalCost:e,upstreamInferenceCost:t,createdAt:n,isByok:r,providerName:i,finishReason:a,generationTime:o,promptTokens:s,completionTokens:c,reasoningTokens:l,cachedTokens:u,cacheCreationTokens:d,billableWebSearchCalls:f}))}).transform(({data:e})=>e))),r$=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.supportedUrls={"*/*":[/.*/]}}static[Dq](e){return nZ({modelId:e.modelId,config:e.config})}static[Oq](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async getArgs(e){let{abortSignal:t,...n}=e;return{args:this.maybeEncodeFileParts(n),warnings:[]}}async doGenerate(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:a,value:o,rawValue:s}=await PX({url:this.getUrl(),headers:Aq(i,e.headers,this.getModelConfigHeaders(this.modelId,!1),await RX(this.config.o11yHeaders)),body:t,successfulResponseHandler:KX(q.any()),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...r&&{abortSignal:r},fetch:this.config.fetch});return{...o,request:{body:t},response:{headers:a,body:s},warnings:n}}catch(e){throw await WQ(e,await qQ(i??{}))}}async doStream(e){let{args:t,warnings:n}=await this.getArgs(e),{abortSignal:r}=e,i=this.config.headers?await RX(this.config.headers):void 0;try{let{value:a,responseHeaders:o}=await PX({url:this.getUrl(),headers:Aq(i,e.headers,this.getModelConfigHeaders(this.modelId,!0),await RX(this.config.o11yHeaders)),body:t,successfulResponseHandler:GX(q.any()),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...r&&{abortSignal:r},fetch:this.config.fetch});return{stream:a.pipeThrough(new TransformStream({start(e){n.length>0&&e.enqueue({type:`stream-start`,warnings:n})},transform(t,n){if(t.success){let r=t.value;if(r.type===`raw`&&!e.includeRawChunks)return;r.type===`response-metadata`&&r.timestamp&&typeof r.timestamp==`string`&&(r.timestamp=new Date(r.timestamp)),n.enqueue(r)}else n.error(t.error)}})),request:{body:t},response:{headers:o}}}catch(e){throw await WQ(e,await qQ(i??{}))}}maybeEncodeFileParts(e){for(let t of e.prompt)if(Array.isArray(t.content)){for(let e of t.content)if(e.type===`file`||e.type===`reasoning-file`)e.data=i$(e.data);else if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&(t.data=i$(t.data))}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":`4`,"ai-language-model-id":e,"ai-language-model-streaming":String(t)}}};function i$(e){if(e.type===`data`){let t=e.data;if(t instanceof Uint8Array)return{...e,data:Buffer.from(t).toString(`base64`)}}return e}var a$=class e extends r${static[Dq](e){return r$[Dq](e)}static[Oq](t){return new e(t.modelId,t.config)}constructor(e,t){super(e,t)}async experimental_doStartBatch({requests:e,providerOptions:t,headers:n,abortSignal:r,webhookUrl:i}){let a=this.config.headers?await RX(this.config.headers):void 0,o=o$(t),s=s$(t);try{let{value:t}=await PX({url:this.getBatchUrl(`start`),headers:Aq(a,n,this.getBatchConfigHeaders(),await RX(this.config.o11yHeaders),o==null?void 0:{"idempotency-key":o}),body:{...i!=null&&{callbackUrl:i},modelId:this.modelId,requests:e.map(e=>({id:e.id,options:this.maybeEncodeFileParts(e.options)})),...s!=null&&{providerOptions:s}},successfulResponseHandler:KX(g$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...r&&{abortSignal:r},fetch:this.config.fetch});return{batchId:t.batchId,...l$(t),warnings:t.warnings??[]}}catch(e){throw c$(e)?e:await WQ(e,await qQ(a??{}))}}async experimental_doGetBatchStatus({batchId:e,headers:t,abortSignal:n}){let r=this.config.headers?await RX(this.config.headers):void 0;try{let{value:i}=await PX({url:this.getBatchUrl(`status`),headers:Aq(r,t,this.getBatchConfigHeaders(),await RX(this.config.o11yHeaders)),body:{batchId:e},successfulResponseHandler:KX(_$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return l$(i)}catch(e){throw c$(e)?e:await WQ(e,await qQ(r??{}))}}async experimental_doGetBatchResults({batchId:e,headers:t,abortSignal:n}){let r=this.config.headers?await RX(this.config.headers):void 0;try{let{value:i}=await PX({url:this.getBatchUrl(`results`),headers:Aq(r,t,this.getBatchConfigHeaders(),await RX(this.config.o11yHeaders)),body:{batchId:e},successfulResponseHandler:qX(d$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return Bq(u$(i))}catch(e){throw c$(e)?e:await WQ(e,await qQ(r??{}))}}getBatchUrl(e){return`${this.config.baseURL}/batch/${e}`}getBatchConfigHeaders(){return{"ai-model-id":this.modelId}}};function o$(e){let t=e?.gateway;if(typeof t!=`object`||!t||Array.isArray(t))return;let n=t.idempotencyKey;return typeof n==`string`&&n.length>0?n:void 0}function s$(e){let t=e?.gateway;if(typeof t!=`object`||!t||Array.isArray(t)||!(`idempotencyKey`in t))return e;let{idempotencyKey:n,...r}=t,i={...e};if(Object.keys(r).length===0?delete i.gateway:i.gateway=r,Object.keys(i).length!==0)return i}function c$(e){return e instanceof Error||e instanceof DOMException?e.name===`AbortError`||e.name===`TimeoutError`:!1}function l$(e){let t=cY({total:e.requestCounts?.total,pending:e.requestCounts?.pending,completed:e.requestCounts?.completed,failed:e.requestCounts?.failed});return{status:e.status,...e.rawStatus!=null&&{rawStatus:e.rawStatus},...t!=null&&{requestCounts:t},...e.error!=null&&{error:{message:e.error.message,...e.error.type!=null&&{type:e.error.type},...e.error.code!=null&&{code:e.error.code},...e.error.statusCode!=null&&{statusCode:e.error.statusCode}}},...e.createdAt!=null&&{createdAt:e.createdAt},...e.expiresAt!=null&&{expiresAt:e.expiresAt},...e.providerMetadata!=null&&{providerMetadata:e.providerMetadata}}}async function*u$(e){for await(let t of e){let e=t;if(e.status===`succeeded`){let t=e.result?.response;t!==void 0&&typeof t.timestamp==`string`&&(t.timestamp=new Date(t.timestamp))}yield e}}var d$=q.object({id:q.string(),status:q.enum([`cancelled`,`expired`,`failed`,`succeeded`])}).catchall(q.unknown()),f$=q.object({message:q.string(),type:q.string().nullish(),code:q.string().nullish(),statusCode:q.number().nullish()}),p$=q.object({total:q.number().nullish(),pending:q.number().nullish(),completed:q.number().nullish(),failed:q.number().nullish()}),m$=q.record(q.string(),q.record(q.string(),q.unknown())),h$=q.object({status:q.enum([`completed`,`failed`,`pending`]),rawStatus:q.string().nullish(),requestCounts:p$.nullish(),error:f$.nullish(),createdAt:q.string().nullish(),expiresAt:q.string().nullish(),providerMetadata:m$.nullish()}),g$=h$.extend({batchId:q.string(),warnings:q.array(q.object({requestId:q.string().nullish(),warning:q.unknown()}).catchall(q.unknown())).nullish()}),_$=h$,v$=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}static[Dq](e){return nZ({modelId:e.modelId,config:e.config})}static[Oq](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:n,providerOptions:r}){let i=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:a,value:o,rawValue:s}=await PX({url:this.getUrl(),headers:Aq(i,t??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{values:e,...r?{providerOptions:r}:{}},successfulResponseHandler:KX(b$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{embeddings:o.embeddings,usage:o.usage??void 0,providerMetadata:o.providerMetadata,response:{headers:a,body:s},warnings:o.warnings??[]}}catch(e){throw await WQ(e,await qQ(i??{}))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":`4`,"ai-model-id":this.modelId}}},y$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),b$=vX(()=>DX(q.object({embeddings:q.array(q.array(q.number())),usage:q.object({tokens:q.number()}).nullish(),warnings:q.array(y$).optional(),providerMetadata:q.record(q.string(),q.record(q.string(),q.unknown())).optional()}))),x$=class e{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxImagesPerCall=2**53-1}static[Dq](e){return nZ({modelId:e.modelId,config:e.config})}static[Oq](t){return new e(t.modelId,t.config)}get provider(){return this.config.provider}async doGenerate({prompt:e,n:t,size:n,aspectRatio:r,seed:i,files:a,mask:o,providerOptions:s,headers:c,abortSignal:l}){let u=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:d,value:f}=await PX({url:this.getUrl(),headers:Aq(u,c??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{prompt:e,n:t,...n&&{size:n},...r&&{aspectRatio:r},...i&&{seed:i},...s&&{providerOptions:s},...a&&{files:a.map(e=>S$(e))},...o&&{mask:S$(o)}},successfulResponseHandler:KX(E$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...l&&{abortSignal:l},fetch:this.config.fetch});return{images:f.images,warnings:f.warnings??[],providerMetadata:f.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:d},...f.usage!=null&&{usage:{inputTokens:f.usage.inputTokens??void 0,outputTokens:f.usage.outputTokens??void 0,totalTokens:f.usage.totalTokens??void 0}}}}catch(e){throw await WQ(e,await qQ(u??{}))}}getUrl(){return`${this.config.baseURL}/image-model`}getModelConfigHeaders(){return{"ai-image-model-specification-version":`4`,"ai-model-id":this.modelId}}};function S$(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:Wq(e.data)}:e}var C$=q.object({images:q.array(q.unknown()).optional()}).catchall(q.unknown()),w$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),T$=q.object({inputTokens:q.number().nullish(),outputTokens:q.number().nullish(),totalTokens:q.number().nullish()}),E$=q.object({images:q.array(q.string()),warnings:q.array(w$).optional(),providerMetadata:q.record(q.string(),C$).optional(),usage:T$.optional()}),D$=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`,this.maxVideosPerCall=2**53-1}get provider(){return this.config.provider}async doGenerate(e){let{headers:t,abortSignal:n}=e,r=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:i,value:a}=await PX({url:this.getUrl(),headers:Aq(r,t??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders),{accept:`text/event-stream`}),body:this.buildRequestBody(e),successfulResponseHandler:async({response:e,url:t,requestBodyValues:n})=>{if(e.body==null)throw new PK({message:`SSE response body is empty`,url:t,requestBodyValues:n,statusCode:e.status});let r=MX({stream:e.body,schema:M$}).getReader(),{done:i,value:a}=await r.read();if(r.releaseLock(),i||!a)throw new PK({message:`SSE stream ended without a data event`,url:t,requestBodyValues:n,statusCode:e.status});if(!a.success)throw new PK({message:`Failed to parse video SSE event`,cause:a.error,url:t,requestBodyValues:n,statusCode:e.status});let o=a.value;if(o.type===`error`)throw new PK({message:o.message,statusCode:o.statusCode,url:t,requestBodyValues:n,responseHeaders:Object.fromEntries([...e.headers]),responseBody:JSON.stringify(o),data:{error:{message:o.message,type:o.errorType,param:o.param}}});return{value:{videos:o.videos,warnings:o.warnings,providerMetadata:o.providerMetadata},responseHeaders:Object.fromEntries([...e.headers])}},failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{videos:a.videos,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:i}}}catch(e){throw await WQ(e,await qQ(r??{}))}}async handleWebhookOption({webhook:e}){let{url:t,received:n}=await e();return{webhookUrl:t,received:n}}async doStart(e){let{headers:t,abortSignal:n,webhookUrl:r}=e,i=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:a,value:o}=await PX({url:this.getStartUrl(),headers:Aq(i,t??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{...this.buildRequestBody(e),...r&&{callbackUrl:r}},successfulResponseHandler:KX(N$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...n&&{abortSignal:n},fetch:this.config.fetch});return{operation:o.operation,warnings:o.warnings??[],providerMetadata:o.providerMetadata??void 0,response:{timestamp:new Date,modelId:this.modelId,headers:a}}}catch(e){throw await WQ(e,await qQ(i??{}))}}async doStatus({operation:e,abortSignal:t,headers:n}){let r=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:i,value:a}=await PX({url:this.getStatusUrl(),headers:Aq(r,n??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{operation:e},successfulResponseHandler:KX(P$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...t&&{abortSignal:t},fetch:this.config.fetch}),o={timestamp:new Date,modelId:this.modelId,headers:i};return a.status===`completed`?{status:`completed`,videos:a.videos,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:o}:a.status===`error`?{status:`error`,error:a.error,providerMetadata:a.providerMetadata??void 0,response:o}:a.status===`cancelled`?{status:`error`,error:`Video generation was cancelled.`,providerMetadata:a.providerMetadata??void 0,response:o}:{status:`pending`,warnings:a.warnings??[],providerMetadata:a.providerMetadata??void 0,response:o}}catch(e){throw await WQ(e,await qQ(r??{}))}}buildRequestBody({prompt:e,n:t,aspectRatio:n,resolution:r,duration:i,fps:a,seed:o,generateAudio:s,image:c,frameImages:l,inputReferences:u,providerOptions:d}){return{prompt:e,n:t,...n&&{aspectRatio:n},...r&&{resolution:r},...i&&{duration:i},...a&&{fps:a},...o&&{seed:o},...s!==void 0&&{generateAudio:s},...d&&{providerOptions:d},...c&&{image:O$(c)},...l&&{frameImages:l.map(e=>({...e,image:O$(e.image)}))},...u&&{inputReferences:u.map(e=>O$(e))}}}getUrl(){return`${this.config.baseURL}/video-model`}getStartUrl(){return`${this.config.baseURL}/video-model/start`}getStatusUrl(){return`${this.config.baseURL}/video-model/status`}getModelConfigHeaders(){return{"ai-video-model-specification-version":`4`,"ai-model-id":this.modelId}}};function O$(e){return e.type===`file`&&e.data instanceof Uint8Array?{...e,data:Wq(e.data)}:e}var k$=q.object({videos:q.array(q.unknown()).optional()}).catchall(q.unknown()),A$=q.union([q.object({type:q.literal(`url`),url:q.string(),mediaType:q.string()}),q.object({type:q.literal(`base64`),data:q.string(),mediaType:q.string()})]),j$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),M$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`result`),videos:q.array(A$),warnings:q.array(j$).optional(),providerMetadata:q.record(q.string(),k$).optional()}),q.object({type:q.literal(`error`),message:q.string(),errorType:q.string(),statusCode:q.number(),param:q.unknown().nullable()})]),N$=q.object({operation:q.unknown(),warnings:q.array(j$).nullish(),providerMetadata:q.record(q.string(),k$).nullish()}),P$=q.discriminatedUnion(`status`,[q.object({status:q.literal(`pending`),warnings:q.array(j$).nullish(),providerMetadata:q.record(q.string(),k$).nullish()}),q.object({status:q.literal(`completed`),videos:q.array(A$),warnings:q.array(j$).nullish(),providerMetadata:q.record(q.string(),k$).nullish()}),q.object({status:q.literal(`error`),error:q.string(),providerMetadata:q.record(q.string(),k$).nullish()}),q.object({status:q.literal(`cancelled`),providerMetadata:q.record(q.string(),k$).nullish()})]),F$=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doRerank({documents:e,query:t,topN:n,headers:r,abortSignal:i,providerOptions:a}){let o=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:s,value:c,rawValue:l}=await PX({url:this.getUrl(),headers:Aq(o,r??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{documents:e,query:t,...n==null?{}:{topN:n},...a?{providerOptions:a}:{}},successfulResponseHandler:KX(L$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...i&&{abortSignal:i},fetch:this.config.fetch});return{ranking:c.ranking,providerMetadata:c.providerMetadata,response:{headers:s,body:l},warnings:c.warnings??[]}}catch(e){throw await WQ(e,await qQ(o??{}))}}getUrl(){return`${this.config.baseURL}/reranking-model`}getModelConfigHeaders(){return{"ai-reranking-model-specification-version":`4`,"ai-model-id":this.modelId}}},I$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),L$=vX(()=>DX(q.object({ranking:q.array(q.object({index:q.number(),relevanceScore:q.number()})),warnings:q.array(I$).optional(),providerMetadata:q.record(q.string(),q.record(q.string(),q.unknown())).optional()}))),R$=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doGenerate({text:e,voice:t,outputFormat:n,instructions:r,speed:i,language:a,providerOptions:o,headers:s,abortSignal:c}){let l=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:u,value:d,rawValue:f}=await PX({url:this.getUrl(),headers:Aq(l,s??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{text:e,...t&&{voice:t},...n&&{outputFormat:n},...r&&{instructions:r},...i!=null&&{speed:i},...a&&{language:a},...o&&{providerOptions:o}},successfulResponseHandler:KX(V$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...c&&{abortSignal:c},fetch:this.config.fetch});return{audio:d.audio,warnings:d.warnings??[],providerMetadata:d.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:u,body:f}}}catch(e){throw await WQ(e,await qQ(l??{}))}}getUrl(){return`${this.config.baseURL}/speech-model`}getModelConfigHeaders(){return{"ai-speech-model-specification-version":`4`,"ai-model-id":this.modelId}}},z$=q.object({}).catchall(q.unknown()),B$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),V$=q.object({audio:q.string(),warnings:q.array(B$).optional(),providerMetadata:q.record(q.string(),z$).optional()}),H$=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion=`v4`}get provider(){return this.config.provider}async doGenerate({audio:e,mediaType:t,providerOptions:n,headers:r,abortSignal:i}){let a=this.config.headers?await RX(this.config.headers):void 0;try{let{responseHeaders:o,value:s,rawValue:c}=await PX({url:this.getUrl(),headers:Aq(a,r??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),body:{audio:e instanceof Uint8Array?Wq(e):e,mediaType:t,...n&&{providerOptions:n}},successfulResponseHandler:KX(Y$),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),...i&&{abortSignal:i},fetch:this.config.fetch});return{text:s.text,segments:s.segments??[],language:s.language??void 0,durationInSeconds:s.durationInSeconds??void 0,warnings:s.warnings??[],providerMetadata:s.providerMetadata,response:{timestamp:new Date,modelId:this.modelId,headers:o,body:c}}}catch(e){throw await WQ(e,await qQ(a??{}))}}async doStream(e){var t;let n=((t=this.config._internal)?.currentDate)?.call(t)??new Date,r=Aq(await RX(this.config.headers??{}),e.headers??{},this.getModelConfigHeaders(),await RX(this.config.o11yHeaders)),i=await qQ(r),a={type:iZ,inputAudioFormat:e.inputAudioFormat,...e.providerOptions!=null&&{providerOptions:e.providerOptions},...e.includeRawChunks!=null&&{includeRawChunks:e.includeRawChunks}};return{stream:K$({webSocket:this.config.webSocket,url:U$(this.config.baseURL,this.modelId),protocols:W$(r),headers:r,startFrame:a,audio:e.audio,abortSignal:e.abortSignal,authMethod:i}),request:{body:a},response:{timestamp:n,modelId:this.modelId}}}getUrl(){return`${this.config.baseURL}/transcription-model`}getModelConfigHeaders(){return{"ai-transcription-model-specification-version":`4`,"ai-model-id":this.modelId}}};function U$(e,t){let n=new URL(`${e.replace(/^http/,`ws`)}/transcription-model`);return n.searchParams.set(`ai-model-id`,t),n.toString()}function W$(e){let t=nJ(e),n=t.authorization,r=n?.startsWith(`Bearer `)?n.slice(7):void 0;return r==null?[xZ]:TZ(r,{teamIdOrSlug:t[KQ]})}var G$=65536;function K$({webSocket:e,url:t,protocols:n,headers:r,startFrame:i,audio:a,abortSignal:o,authMethod:s}){let c=!1,l=()=>{};return new ReadableStream({start:u=>{let d,f=!1,p,m=!1,h;l=e=>{d==null?a.cancel().catch(()=>{}):d.cancel().catch(()=>{}),h?.close(e)};let g=()=>{m=!0,d==null?a.cancel().catch(()=>{}):(d.cancel().catch(()=>{}),d=void 0)},_=e=>{c||(c=!0,l(),X$(u,e,s))},v=async e=>{let t=a.getReader();d=t;try{for(;;){let{done:n,value:r}=await t.read();if(n||c)break;let i=typeof r==`string`?Uq(r):r;for(let t=0;t<i.length&&!c;t+=G$)e.send(i.subarray(t,t+G$)),await Rq(e)}}finally{t.releaseLock(),d===t&&(d=void 0)}!c&&!m&&e.send(JSON.stringify({type:aZ}))};h=zq({url:t,protocols:n,headers:r,webSocket:e,abortSignal:o,onAbort:e=>{c||(c=!0,l(),u.error(e))},onProcessingError:_,onOpen:e=>{e.send(JSON.stringify(i)),v(e).catch(_)},onMessageText:e=>{if(c)return;let t=oZ(e);if(t!=null){if(t.type===`finish`){c=!0,u.enqueue(t),u.close(),l(1e3);return}t.type===`error`&&(f=!0,p=t.error,g()),u.enqueue(t)}},onSocketError:()=>{_(Error(`Connection error on AI Gateway transcription stream`))},onClose:()=>{if(f){if(c)return;$$(p,s).then(_);return}_(Error(`AI Gateway transcription stream closed before a finish part was received`))}})},cancel:()=>{c||(c=!0,l())}})}var q$=q.object({}).catchall(q.unknown()),J$=q.discriminatedUnion(`type`,[q.object({type:q.literal(`unsupported`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`compatibility`),feature:q.string(),details:q.string().optional()}),q.object({type:q.literal(`deprecated`),setting:q.string(),message:q.string()}),q.object({type:q.literal(`other`),message:q.string()})]),Y$=q.object({text:q.string(),segments:q.array(q.object({text:q.string(),startSecond:q.number(),endSecond:q.number()})).optional(),language:q.string().nullish(),durationInSeconds:q.number().nullish(),warnings:q.array(J$).optional(),providerMetadata:q.record(q.string(),q$).optional()});async function X$(e,t,n){e.error(await WQ(t,n))}function Z$(e){return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`?e.message:VK(e)}var Q$={authentication_error:401,failed_dependency:424,forbidden:403,internal_server_error:500,invalid_request_error:400,model_not_found:404,rate_limit_exceeded:429};async function $$(e,t){return typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`&&`type`in e&&typeof e.type==`string`&&e.type in Q$?PQ({response:{error:{message:e.message,type:e.type}},statusCode:Q$[e.type],authMethod:t}):Error(`AI Gateway transcription stream failed: ${Z$(e)}`)}var e1=class{constructor(e,t){this.specificationVersion=`v4`,this.modelId=e,this.provider=t.provider,this.config=t}async doCreateClientSecret(e){let t=await this.config.createClientSecret({modelId:this.modelId,...e?.expiresAfterSeconds!=null&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:t.token,url:t1(this.config.baseURL,this.modelId),...t.expiresAt!=null&&{expiresAt:t.expiresAt}}}getWebSocketConfig(e){return{url:e.url,protocols:wZ(e.token,{teamIdOrSlug:this.config.teamIdOrSlug})}}parseServerEvent(e){return e}serializeClientEvent(e){return e}buildSessionConfig(e){return e}};function t1(e,t){let n=new URL(`${e.replace(/^http/,`ws`)}/realtime-model`);return n.searchParams.set(`ai-model-id`,t),n.toString()}var n1=LX({id:`gateway.exa_search`,inputSchema:vX(()=>DX(q.object({query:q.string().describe(`Natural-language web search query. This is required.`),type:q.enum([`auto`,`fast`,`instant`]).optional().describe(`Search method. Use auto for the default balance of speed and quality.`),num_results:q.number().optional().describe(`Maximum number of results to return (1-100, default: 10).`),category:q.enum([`company`,`people`,`research paper`,`news`,`personal site`,`financial report`]).optional().describe(`Optional content category to focus results.`),user_location:q.string().optional().describe(`Two-letter ISO country code such as 'US'.`),include_domains:q.array(q.string()).optional().describe(`Only return results from these domains.`),exclude_domains:q.array(q.string()).optional().describe(`Exclude results from these domains.`),start_published_date:q.string().optional().describe(`Only return links published after this ISO 8601 date.`),end_published_date:q.string().optional().describe(`Only return links published before this ISO 8601 date.`),contents:q.object({text:q.union([q.boolean(),q.object({max_characters:q.number().optional(),include_html_tags:q.boolean().optional(),verbosity:q.enum([`compact`,`standard`,`full`]).optional(),include_sections:q.array(q.enum([`header`,`navigation`,`banner`,`body`,`sidebar`,`footer`,`metadata`])).optional(),exclude_sections:q.array(q.enum([`header`,`navigation`,`banner`,`body`,`sidebar`,`footer`,`metadata`])).optional()})]).optional(),highlights:q.union([q.boolean(),q.object({query:q.string().optional(),max_characters:q.number().optional()})]).optional(),max_age_hours:q.number().optional(),livecrawl_timeout:q.number().optional(),subpages:q.number().optional(),subpage_target:q.union([q.string(),q.array(q.string())]).optional(),extras:q.object({links:q.number().optional(),image_links:q.number().optional()}).optional()}).optional().describe(`Controls extracted page content and freshness.`)}))),outputSchema:vX(()=>DX(q.union([q.object({requestId:q.string(),searchType:q.string().optional(),resolvedSearchType:q.string().optional(),results:q.array(q.object({title:q.string(),url:q.string(),id:q.string(),publishedDate:q.string().nullable().optional(),author:q.string().nullable().optional(),image:q.string().nullable().optional(),favicon:q.string().nullable().optional(),text:q.string().optional(),highlights:q.array(q.string()).optional(),highlightScores:q.array(q.number()).optional(),summary:q.string().optional(),subpages:q.array(q.any()).optional(),extras:q.object({links:q.array(q.string()).optional(),imageLinks:q.array(q.string()).optional()}).optional()})),costDollars:q.object({total:q.number().optional(),search:q.record(q.string(),q.number()).optional()}).optional()}),q.object({error:q.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`configuration_error`,`execution_error`,`unknown`]),statusCode:q.number().optional(),message:q.string()})])))}),r1=(e={})=>n1(e),i1=LX({id:`gateway.parallel_search`,inputSchema:vX(()=>DX(q.object({objective:q.string().describe(`Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters.`),search_queries:q.array(q.string()).optional().describe(`Optional search queries to supplement the objective. Maximum 200 characters per query.`),mode:q.enum([`one-shot`,`agentic`]).optional().describe(`Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.`),max_results:q.number().optional().describe(`Maximum number of results to return (1-20). Defaults to 10 if not specified.`),source_policy:q.object({include_domains:q.array(q.string()).optional().describe(`Limit results to these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page).`),exclude_domains:q.array(q.string()).optional().describe(`Exclude results from these domains. Use plain domain names only — e.g. example.com or sub.example.gov, or a bare extension like .edu. Do not include a scheme, path, or port (e.g. not https://example.com/page).`),after_date:q.string().optional().describe(`Only include results published after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time.`)}).optional().describe(`Source policy for controlling which domains to include/exclude and freshness.`),excerpts:q.object({max_chars_per_result:q.number().optional().describe(`Maximum characters per result.`),max_chars_total:q.number().optional().describe(`Maximum total characters across all results.`)}).optional().describe(`Excerpt configuration for controlling result length.`),fetch_policy:q.object({max_age_seconds:q.number().optional().describe(`Maximum age in seconds for cached content. Set to 0 to always fetch fresh content.`)}).optional().describe(`Fetch policy for controlling content freshness.`)}))),outputSchema:vX(()=>DX(q.union([q.object({searchId:q.string(),results:q.array(q.object({url:q.string(),title:q.string(),excerpt:q.string(),publishDate:q.string().nullable().optional(),relevanceScore:q.number().optional()}))}),q.object({error:q.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`configuration_error`,`unknown`]),statusCode:q.number().optional(),message:q.string()})])))}),a1=(e={})=>i1(e),o1=LX({id:`gateway.perplexity_search`,inputSchema:vX(()=>DX(q.object({query:q.union([q.string(),q.array(q.string())]).describe(`Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries.`),max_results:q.number().optional().describe(`Maximum number of search results to return (1-20, default: 10)`),max_tokens_per_page:q.number().optional().describe(`Maximum number of tokens to extract per search result page (256-2048, default: 2048)`),max_tokens:q.number().optional().describe(`Maximum total tokens across all search results (default: 25000, max: 1000000)`),country:q.string().optional().describe(`Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')`),search_domain_filter:q.array(q.string()).optional().describe(`List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']`),search_language_filter:q.array(q.string()).optional().describe(`List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']`),search_after_date:q.string().optional().describe(`Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),search_before_date:q.string().optional().describe(`Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),last_updated_after_filter:q.string().optional().describe(`Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter.`),last_updated_before_filter:q.string().optional().describe(`Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter.`),search_recency_filter:q.enum([`day`,`week`,`month`,`year`]).optional().describe(`Filter results by relative time period. Cannot be used with search_after_date or search_before_date.`)}))),outputSchema:vX(()=>DX(q.union([q.object({results:q.array(q.object({title:q.string(),url:q.string(),snippet:q.string(),date:q.string().optional(),lastUpdated:q.string().optional()})),id:q.string()}),q.object({error:q.enum([`api_error`,`rate_limit`,`timeout`,`invalid_input`,`unknown`]),statusCode:q.number().optional(),message:q.string()})])))}),s1=(e={})=>o1(e),c1=q.object({count:q.number().optional().describe(`Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge.`),include_contents:q.boolean().optional().describe(`Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost.`),mode:q.enum([`inline`,`url`]).optional().describe(`Requested data delivery mode. Search card data is always inline.`),content_format:q.enum([`card_json`,`csv`,`json_compact`,`json_records`]).optional().describe(`Serialization for inlined card data.`),max_rows:q.number().optional().describe(`Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost.`),node_ids:q.array(q.string()).optional().describe(`Data Graph node IDs to prioritize. Maximum 20.`),strict:q.boolean().optional().describe(`Only return cards matching node_ids. Requires a non-empty node_ids.`)}),l1=q.object({count:q.number().optional().describe(`Maximum number of web results to return (1-20).`),include_contents:q.boolean().optional().describe(`Inline extracted web page text. This can add a data charge.`),category:q.enum([`finance`,`news`,`sports`]).optional().describe(`Optional web-result category filter.`),include_domains:q.array(q.string()).optional().describe(`Only return results from these bare domains.`),exclude_domains:q.array(q.string()).optional().describe(`Exclude results from these bare domains.`),snippet_max_chars:q.number().optional().describe(`Maximum characters in each web-result snippet.`),highlights:q.boolean().optional().describe(`Include highlighted passages in web results. Defaults to true in AI Gateway.`),article_content_max_chars:q.number().optional().describe(`Maximum extracted characters per web page when including contents.`),published_after:q.string().optional().describe(`Keep results published on or after this ISO date (YYYY-MM-DD).`),published_before:q.string().optional().describe(`Keep results published on or before this ISO date (YYYY-MM-DD).`)}),u1=vX(()=>DX(q.object({query:q.string().describe(`Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.`),effort:q.enum([`deep`,`fast`,`instant`]).optional().describe(`Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency.`),sources:q.object({data:c1.optional(),web:l1.optional()}).optional().describe(`Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched.`),location:q.object({latitude:q.number().describe(`Latitude between -90 and 90.`),longitude:q.number().describe(`Longitude between -180 and 180.`)}).optional().describe(`End-user coordinates for localized results.`),country_code:q.string().optional().describe(`Two-letter ISO 3166-1 country code, such as 'US'.`),locale:q.string().optional().describe(`BCP-47 locale, such as 'en-US'.`),timezone:q.string().optional().describe(`IANA timezone, such as 'America/New_York'.`),output_settings:q.object({image_dark_mode:q.boolean().optional().describe(`Render card preview images in dark mode.`),force_refresh:q.boolean().optional().describe(`Instant-effort only. Request a refreshed instant result.`)}).optional().describe(`Controls card rendering in the search response.`),include_related:q.number().optional().describe(`Maximum related search suggestions to include (1-20).`)}))),d1=q.union([q.boolean(),q.number(),q.string()]).nullable(),f1=q.object({content_format:q.enum([`card_json`,`csv`,`json_compact`,`json_records`]).nullish(),cost:q.number().optional(),data:q.string().nullish(),records:q.array(q.record(q.string(),d1)).nullish(),dataset:q.object({columns:q.array(q.object({name:q.string(),type:q.enum([`boolean`,`date`,`datetime`,`number`,`string`]),unit:q.string().nullish()})),rows:q.array(q.array(d1)),total_rows:q.number(),truncated:q.boolean(),ref:q.string(),sources:q.array(q.object({name:q.string(),index:q.enum([`data`,`web`]).optional()})),provenance:q.enum([`query`,`web_extraction`]).optional()}).nullish(),card_data:q.object({}).passthrough().nullish(),card_data_schema:q.object({}).passthrough().nullish(),url:q.string().nullish(),expires_at:q.string().nullish(),total_rows:q.number().nullish(),truncated:q.boolean().optional(),export_pricing:q.object({baseline_usd:q.number(),free_rows:q.number(),max_rows_ceiling:q.number(),row_cpm_usd:q.number()}).nullish(),manifest:q.array(q.object({dtype:q.enum([`boolean`,`date`,`datetime`,`number`,`string`]).nullish(),entity:q.string().nullish(),metric:q.string().nullish(),name:q.string().nullish(),unit:q.string().nullish()})).nullish()}).passthrough(),p1=q.object({card_id:q.string().nullish(),title:q.string().nullish(),description:q.string().nullish(),semantic_description:q.string().nullish(),webpage_url:q.string().nullish(),image_url:q.string().nullish(),embed_url:q.string().nullish(),sources:q.array(q.object({source_name:q.string().nullish(),source_description:q.string().nullish(),source_index:q.enum([`data`,`web`]),source_text:q.string().nullish(),url:q.string().nullish()})).nullish(),methodologies:q.array(q.object({methodology_name:q.string().nullable(),methodology_description:q.string().nullable()})).nullish(),source_indexes:q.array(q.enum([`data`,`web`])).nullish(),card_type:q.string().nullish(),relevance:q.enum([`High`,`Low`,`Medium`]).nullish(),content:f1.nullish(),exportable:q.boolean().optional(),nodes:q.array(q.object({id:q.string(),type:q.enum([`entity`,`metric`]),name:q.string(),description:q.string().nullish()})).nullish(),metric_definitions:q.array(q.object({name:q.string(),definition:q.string()})).nullish(),data_freshness:q.object({coverage_end:q.string().nullish(),data_as_of:q.string().nullish(),last_updated:q.string().nullish()}).nullish()}).passthrough(),m1=q.object({title:q.string(),url:q.string(),snippet:q.string().nullish(),source_name:q.string().nullish(),publish_date:q.string().nullish(),content:f1.nullish()}).passthrough(),h1=LX({id:`gateway.tako_search`,inputSchema:u1,outputSchema:vX(()=>DX(q.union([q.object({request_id:q.string(),cards:q.array(p1).optional(),web_results:q.array(m1).optional(),usage:q.object({total_cost_usd:q.number(),compute:q.object({cost_usd:q.number()}).nullish(),data:q.object({cost_usd:q.number(),datasets:q.number()}).nullish()}).nullish(),related:q.array(q.object({}).passthrough()).nullish()}).passthrough(),q.object({error:q.enum([`api_error`,`configuration_error`,`execution_error`,`invalid_input`,`rate_limit`,`timeout`,`unknown_tool`]),statusCode:q.number().optional(),message:q.string()})])))}),g1={exaSearch:r1,parallelSearch:a1,perplexitySearch:s1,takoSearch:(e={})=>h1(e)};async function _1(){return(0,yZ.getContext)().headers?.[`x-vercel-id`]}var v1=`4.0.73`,ere=`0.0.1`,y1=q.object({token:q.string(),expiresAt:q.number().nullish()});function b1(e={}){let t=null,n=null,r=e.metadataCacheRefreshMillis??3e5,i=0,a=fZ(e.baseURL)??`https://ai-gateway.vercel.sh/v4/ai`,o=t=>rJ({Authorization:`Bearer ${t.token}`,"ai-gateway-protocol-version":ere,[GQ]:t.authMethod,...e.teamIdOrSlug==null?{}:{[KQ]:e.teamIdOrSlug},...e.headers},`ai-sdk/gateway/${v1}`),s=async()=>{try{return o(await S1(e))}catch(e){throw LZ.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},c=async()=>{try{return await S1(e)}catch(e){throw LZ.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401,cause:e})}},l=async t=>{C1();let n=await c(),r=o(n),i=new URL(`/v1/realtime/client-secrets`,a).toString();try{let{value:n}=await PX({url:i,headers:r,body:{model:t.modelId,...t.routeKind!=null&&{routeKind:t.routeKind},...t.expiresAfterSeconds!=null&&{expiresIn:t.expiresAfterSeconds}},successfulResponseHandler:KX(y1),failedResponseHandler:WX({errorSchema:q.any(),errorToMessage:e=>VK(e)??`unknown error`}),fetch:e.fetch});return{token:n.token,...n.expiresAt!=null&&{expiresAt:n.expiresAt}}}catch(e){throw await WQ(e,await qQ(r))}},u=()=>{let e=sY({settingValue:void 0,environmentVariableName:`VERCEL_DEPLOYMENT_ID`}),t=sY({settingValue:void 0,environmentVariableName:`VERCEL_ENV`}),n=sY({settingValue:void 0,environmentVariableName:`VERCEL_REGION`}),r=sY({settingValue:void 0,environmentVariableName:`VERCEL_PROJECT_ID`});return async()=>{let i=await _1();return{...e&&{"ai-o11y-deployment-id":e},...t&&{"ai-o11y-environment":t},...n&&{"ai-o11y-region":n},...i&&{"ai-o11y-request-id":i},...r&&{"ai-o11y-project-id":r}}}},d=t=>new a$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()}),f=async()=>{var o;let c=((o=e._internal)?.currentDate)?.call(o).getTime()??Date.now();return(!t||c-i>r)&&(i=c,t=new XQ({baseURL:a,headers:s,fetch:e.fetch}).getAvailableModels().then(e=>(n=e,e)).catch(async e=>{throw await WQ(e,await qQ(await s()))})),n?Promise.resolve(n):t},p=async()=>new XQ({baseURL:a,headers:s,fetch:e.fetch}).getCredits().catch(async e=>{throw await WQ(e,await qQ(await s()))}),m=async t=>new $Q({baseURL:a,headers:s,fetch:e.fetch}).getSpendReport(t).catch(async e=>{throw await WQ(e,await qQ(await s()))}),h=async t=>new t$({baseURL:a,headers:s,fetch:e.fetch}).getGenerationInfo(t).catch(async e=>{throw await WQ(e,await qQ(await s()))}),g=function(e){if(new.target)throw Error(`The Gateway Provider model function cannot be called with the new keyword.`);return d(e)};g.specificationVersion=`v4`,g.getAvailableModels=f,g.getCredits=p,g.getSpendReport=m,g.getGenerationInfo=h,g.imageModel=t=>new x$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()}),g.languageModel=d;let _=t=>new v$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.embeddingModel=_,g.textEmbeddingModel=_,g.videoModel=t=>new D$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});let v=t=>new F$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.rerankingModel=v,g.reranking=v;let y=t=>new R$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u()});g.speechModel=y,g.speech=y;let b=t=>new H$(t,{provider:`gateway`,baseURL:a,headers:s,fetch:e.fetch,o11yHeaders:u(),webSocket:e.webSocket});g.transcriptionModel=b,g.transcription=b,g.experimental_transcription=Object.assign(e=>b(e),{getToken:async e=>{let t=await l({modelId:e.model,routeKind:`transcription`,...e.expiresAfterSeconds!=null&&{expiresAfterSeconds:e.expiresAfterSeconds}});return{token:t.token,url:U$(a,e.model),...t.expiresAt!=null&&{expiresAt:t.expiresAt}}}});let x=t=>new e1(t,{provider:`gateway.realtime`,baseURL:a,teamIdOrSlug:e.teamIdOrSlug,createClientSecret:l});return g.experimental_realtime=Object.assign(e=>x(e),{getToken:async e=>{let{model:t,...n}=e,r=await x(t).doCreateClientSecret(n);return{token:r.token,url:r.url,...r.expiresAt!=null&&{expiresAt:r.expiresAt}}}}),g.chat=g.languageModel,g.embedding=g.embeddingModel,g.image=g.imageModel,g.video=g.videoModel,g.tools=g1,g}var x1=b1();async function S1(e){let t=sY({settingValue:e.apiKey,environmentVariableName:`AI_GATEWAY_API_KEY`});return t?{token:t,authMethod:`api-key`}:{token:await(0,yZ.getVercelOidcToken)(),authMethod:`oidc`}}function C1(){if(globalThis.window!==void 0)throw Error(`AI Gateway client secrets must be minted server-side: minting needs your Gateway credential, which must never reach the browser. Call gateway.experimental_realtime.getToken() or gateway.experimental_transcription.getToken() from your server and pass the returned token to the client.`)}var w1=Object.defineProperty,T1=(e,t)=>{for(var n in t)w1(e,n,{get:t[n],enumerable:!0})},E1=`AI_InvalidArgumentError`,D1=`vercel.ai.error.${E1}`,O1=Symbol.for(D1),k1,A1,j1=class extends (A1=K,k1=O1,A1){constructor({parameter:e,value:t,message:n}){super({name:E1,message:`Invalid argument for parameter ${e}: ${n}`}),this[k1]=!0,this.parameter=e,this.value=t}static isInstance(e){return K.hasMarker(e,D1)}},M1=`AI_InvalidToolApprovalError`,N1=`vercel.ai.error.${M1}`,P1=Symbol.for(N1),F1,I1,L1=class extends (I1=K,F1=P1,I1){constructor({approvalId:e}){super({name:M1,message:`Tool approval response references unknown approvalId: "${e}". No matching tool-approval-request found in message history.`}),this[F1]=!0,this.approvalId=e}static isInstance(e){return K.hasMarker(e,N1)}},R1=`AI_InvalidToolApprovalSignatureError`,z1=`vercel.ai.error.${R1}`,B1=Symbol.for(z1),V1,H1,U1=class extends (H1=K,V1=B1,H1){constructor({approvalId:e,toolCallId:t,reason:n}){super({name:R1,message:`Tool approval signature verification failed for approval "${e}" (tool call "${t}"): ${n}`}),this[V1]=!0,this.approvalId=e,this.toolCallId=t}static isInstance(e){return K.hasMarker(e,z1)}},W1=`AI_InvalidToolInputError`,G1=`vercel.ai.error.${W1}`,K1=Symbol.for(G1),q1,J1,Y1=class extends (J1=K,q1=K1,J1){constructor({toolInput:e,toolName:t,cause:n,message:r=`Invalid input for tool ${t}: ${VK(n)}`}){super({name:W1,message:r,cause:n}),this[q1]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return K.hasMarker(e,G1)}},X1=`AI_ToolCallNotFoundForApprovalError`,Z1=`vercel.ai.error.${X1}`,Q1=Symbol.for(Z1),$1,e0,t0=class extends (e0=K,$1=Q1,e0){constructor({toolCallId:e,approvalId:t}){super({name:X1,message:`Tool call "${e}" not found for approval request "${t}".`}),this[$1]=!0,this.toolCallId=e,this.approvalId=t}static isInstance(e){return K.hasMarker(e,Z1)}},n0=`AI_MissingToolResultsError`,r0=`vercel.ai.error.${n0}`,i0=Symbol.for(r0),a0,o0,s0=class extends (o0=K,a0=i0,o0){constructor({toolCallIds:e}){super({name:n0,message:`Tool result${e.length>1?`s are`:` is`} missing for tool call${e.length>1?`s`:``} ${e.join(`, `)}.`}),this[a0]=!0,this.toolCallIds=e}static isInstance(e){return K.hasMarker(e,r0)}},c0=`AI_NoObjectGeneratedError`,l0=`vercel.ai.error.${c0}`,u0=Symbol.for(l0),d0,f0,p0=class extends (f0=K,d0=u0,f0){constructor({message:e=`No object generated.`,cause:t,text:n,response:r,usage:i,finishReason:a}){super({name:c0,message:e,cause:t}),this[d0]=!0,this.text=n,this.response=r,this.usage=i,this.finishReason=a}static isInstance(e){return K.hasMarker(e,l0)}},m0=`AI_NoOutputGeneratedError`,h0=`vercel.ai.error.${m0}`,g0=Symbol.for(h0),_0,v0,y0=class extends (v0=K,_0=g0,v0){constructor({message:e=`No output generated.`,cause:t}={}){super({name:m0,message:e,cause:t}),this[_0]=!0}static isInstance(e){return K.hasMarker(e,h0)}},b0=`AI_NoSuchToolError`,x0=`vercel.ai.error.${b0}`,S0=Symbol.for(x0),C0,w0,T0=class extends (w0=K,C0=S0,w0){constructor({toolName:e,availableTools:t=void 0,message:n=`Model tried to call unavailable tool '${e}'. ${t===void 0?`No tools are available.`:`Available tools: ${t.join(`, `)}.`}`}){super({name:b0,message:n}),this[C0]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return K.hasMarker(e,x0)}},E0=`AI_StreamProviderError`,D0=`vercel.ai.error.${E0}`,O0=Symbol.for(D0),k0,A0,j0=class extends (A0=K,k0=O0,A0){constructor({message:e,type:t,code:n,statusCode:r,isRetryable:i=M0(r),data:a,cause:o}){super({name:E0,message:e,cause:o}),this[k0]=!0,this.type=t,this.code=n,this.statusCode=r,this.isRetryable=i,this.data=a}static isInstance(e){return K.hasMarker(e,D0)}};function M0(e){return e!=null&&(e===408||e===409||e===429||e>=500)}var N0=`AI_ToolCallRepairError`,P0=`vercel.ai.error.${N0}`,F0=Symbol.for(P0),I0,L0,R0=class extends (L0=K,I0=F0,L0){constructor({cause:e,originalError:t,message:n=`Error repairing tool call: ${VK(e)}`}){super({name:N0,message:n,cause:e}),this[I0]=!0,this.originalError=t}static isInstance(e){return K.hasMarker(e,P0)}},z0=class extends K{constructor(e){super({name:`AI_UnsupportedModelVersionError`,message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},B0=`AI_UIMessageStreamError`,V0=`vercel.ai.error.${B0}`,H0=Symbol.for(V0),U0,W0,G0=class extends (W0=K,U0=H0,W0){constructor({chunkType:e,chunkId:t,message:n}){super({name:B0,message:n}),this[U0]=!0,this.chunkType=e,this.chunkId=t}static isInstance(e){return K.hasMarker(e,V0)}},K0=`AI_InvalidDataContentError`,q0=`vercel.ai.error.${K0}`,J0=Symbol.for(q0),Y0,X0,Z0=class extends (X0=K,Y0=J0,X0){constructor({content:e,cause:t,message:n=`Invalid data content. Expected a base64 string, Uint8Array, ArrayBuffer, or Buffer, but got ${typeof e}.`}){super({name:K0,message:n,cause:t}),this[Y0]=!0,this.content=e}static isInstance(e){return K.hasMarker(e,q0)}},Q0=`AI_InvalidMessageRoleError`,$0=`vercel.ai.error.${Q0}`,e2=Symbol.for($0),t2,n2,r2=class extends (n2=K,t2=e2,n2){constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:Q0,message:t}),this[t2]=!0,this.role=e}static isInstance(e){return K.hasMarker(e,$0)}},i2=`AI_MessageConversionError`,a2=`vercel.ai.error.${i2}`,o2=Symbol.for(a2),s2,c2,l2=class extends (c2=K,s2=o2,c2){constructor({originalMessage:e,message:t}){super({name:i2,message:t}),this[s2]=!0,this.originalMessage=e}static isInstance(e){return K.hasMarker(e,a2)}},u2=`AI_RetryError`,d2=`vercel.ai.error.${u2}`,f2=Symbol.for(d2),p2,m2,h2=class extends (m2=K,p2=f2,m2){constructor({message:e,reason:t,errors:n}){super({name:u2,message:e}),this[p2]=!0,this.reason=t,this.errors=n,this.lastError=n[n.length-1]}static isInstance(e){return K.hasMarker(e,d2)}};function g2({warning:e,provider:t,model:n}){let r=`AI SDK Warning${t!=null&&n!=null?` (${t} / ${n})`:``}:`;switch(e.type){case`unsupported`:{let t=`${r} The feature "${e.feature}" is not supported.`;return e.details&&(t+=` ${e.details}`),t}case`compatibility`:{let t=`${r} The feature "${e.feature}" is used in a compatibility mode.`;return e.details&&(t+=` ${e.details}`),t}case`deprecated`:return`${r} Deprecated: "${e.setting}". ${e.message}`;case`other`:return`${r} ${e.message}`;default:return`${r} ${JSON.stringify(e,null,2)}`}}var _2=`AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.`,v2=!1;function y2({message:e,type:t}){typeof process<`u`&&typeof process.emitWarning==`function`?process.emitWarning(e,{type:t}):console.warn(e)}var b2=e=>{if(e.warnings.length===0)return;let t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t==`function`){t(e);return}v2||(v2=!0,y2({message:_2,type:`Warning`}));for(let t of e.warnings)y2({message:g2({warning:t,provider:e.provider,model:e.model}),type:t.type===`deprecated`?`DeprecationWarning`:`Warning`})}};function x2({provider:e,modelId:t}){b2({warnings:[{type:`compatibility`,feature:`specificationVersion`,details:`Using v2 specification compatibility mode. Some features may not be available.`}],provider:e,model:t})}function S2(e){return e.specificationVersion===`v3`?e:(x2({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function C2(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?S2(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function w2(e){return e.specificationVersion===`v3`?e:(x2({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function T2(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?w2(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function E2(e){return e.specificationVersion===`v3`?e:(x2({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){switch(t){case`specificationVersion`:return`v3`;case`doGenerate`:return async(...t)=>{let n=await e.doGenerate(...t);return{...n,finishReason:O2(n.finishReason),usage:k2(n.usage)}};case`doStream`:return async(...t)=>{let n=await e.doStream(...t);return{...n,stream:D2(n.stream)}};default:return e[t]}}}))}function D2(e){return e.pipeThrough(new TransformStream({transform(e,t){switch(e.type){case`finish`:t.enqueue({...e,finishReason:O2(e.finishReason),usage:k2(e.usage)});break;default:t.enqueue(e)}}}))}function O2(e){return{unified:e===`unknown`?`other`:e,raw:void 0}}function k2(e){return{inputTokens:{total:e.inputTokens,noCache:void 0,cacheRead:e.cachedInputTokens,cacheWrite:void 0},outputTokens:{total:e.outputTokens,text:void 0,reasoning:e.reasoningTokens}}}function A2(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?E2(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function j2(e){return e.specificationVersion===`v4`?e:new Proxy(e,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function M2(e){return e.specificationVersion===`v3`?e:(x2({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function N2(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?M2(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function P2(e){return e.specificationVersion===`v3`?e:(x2({provider:e.provider,modelId:e.modelId}),new Proxy(e,{get(e,t){return t===`specificationVersion`?`v3`:e[t]}}))}function F2(e){if(e.specificationVersion===`v4`)return e;let t=e.specificationVersion===`v2`?P2(e):e;return new Proxy(t,{get(e,t){return t===`specificationVersion`?`v4`:e[t]}})}function I2(e){if(`specificationVersion`in e&&e.specificationVersion===`v3`)return e;let t=e;return{specificationVersion:`v3`,languageModel:e=>E2(t.languageModel(e)),embeddingModel:e=>S2(t.textEmbeddingModel(e)),imageModel:e=>w2(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>P2(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>M2(t.speechModel(e)):void 0,rerankingModel:void 0}}function L2(e){if(`specificationVersion`in e&&e.specificationVersion===`v4`)return e;let t=!(`specificationVersion`in e)||e.specificationVersion!==`v3`?I2(e):e;return{specificationVersion:`v4`,languageModel:e=>A2(t.languageModel(e)),embeddingModel:e=>C2(t.embeddingModel(e)),imageModel:e=>T2(t.imageModel(e)),transcriptionModel:t.transcriptionModel?e=>F2(t.transcriptionModel(e)):void 0,speechModel:t.speechModel?e=>N2(t.speechModel(e)):void 0,rerankingModel:t.rerankingModel?e=>j2(t.rerankingModel(e)):void 0}}function R2(e){if(typeof e==`string`)return z2().languageModel(e);if(![`v4`,`v3`,`v2`].includes(e.specificationVersion)){let t=e;throw new z0({version:t.specificationVersion,provider:t.provider,modelId:t.modelId})}return A2(e)}function z2(){return L2(globalThis.AI_SDK_DEFAULT_PROVIDER??x1)}function B2(e){return e.map(e=>V2(e))}function V2(e){return e instanceof URL?new URL(e.href):Array.isArray(e)?e.map(e=>V2(e)):e instanceof Uint8Array?new Uint8Array(e):e instanceof ArrayBuffer?e.slice(0):e instanceof Date?new Date(e):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,V2(t)])):e}var H2=`7.0.91`,U2=async({url:e,maxBytes:t,abortSignal:n})=>{let r=e.toString();try{let e=await qJ({url:r,headers:rJ({},`ai-sdk/${H2}`,Yq()),abortSignal:n});if(!e.ok)throw await vJ(e),new wJ({url:r,statusCode:e.status,statusText:e.statusText});return{data:await YJ({response:e,url:r,maxBytes:t??JJ}),mediaType:e.headers.get(`content-type`)??void 0}}catch(e){throw wJ.isInstance(e)?e:new wJ({url:r,cause:e})}},W2=(e=U2)=>t=>Promise.all(t.map(async t=>t.isUrlSupportedByModel?null:await e(t)));function G2(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;let n={...e};for(let r in t)if(r!==`__proto__`&&r!==`constructor`&&r!==`prototype`&&Object.prototype.hasOwnProperty.call(t,r)){let i=t[r];if(i===void 0)continue;let a=r in e?e[r]:void 0,o=typeof i==`object`&&!!i&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp),s=typeof a==`object`&&!!a&&!Array.isArray(a)&&!(a instanceof Date)&&!(a instanceof RegExp);n[r]=o&&s?G2(a,i):i}return n}function K2(e){try{let[t,n]=e.split(`,`);return{mediaType:t.split(`;`)[0].split(`:`)[1],base64Content:n}}catch{return{mediaType:void 0,base64Content:void 0}}}function q2(e){if(typeof e!=`object`||!e)return!1;let t=e.type;return t===`data`||t===`url`||t===`reference`||t===`text`}function J2(e){if(e.protocol===`data:`){let{mediaType:t,base64Content:n}=K2(e.toString());if(t==null||n==null)throw new Z0({content:e,message:`Invalid data URL format in content ${e.toString()}`});return{data:{type:`data`,data:n},mediaType:t}}return{data:{type:`url`,url:e},mediaType:void 0}}function Y2(e){return e instanceof Uint8Array?{data:{type:`data`,data:e},mediaType:void 0}:e instanceof ArrayBuffer||tY(e)?{data:{type:`data`,data:new Uint8Array(e)},mediaType:void 0}:{data:{type:`data`,data:e},mediaType:void 0}}function X2(e){if(q2(e))switch(e.type){case`data`:if(typeof e.data==`string`&&e.data.startsWith(`data:`))throw new Z0({content:e.data,message:`Data URLs are not valid inline data. Pass them as { type: "url", url } instead.`});return Y2(e.data);case`url`:return J2(e.url);case`reference`:return{data:{type:`reference`,reference:e.reference},mediaType:void 0};case`text`:return{data:{type:`text`,text:e.text},mediaType:void 0}}if(e instanceof URL)return J2(e);if(typeof e==`string`)try{return J2(new URL(e))}catch{return Y2(e)}return rY(e)?{data:{type:`reference`,reference:e},mediaType:void 0}:Y2(e)}async function Z2({prompt:e,supportedUrls:t,download:n=W2(),provider:r}){let i=await e4(e.messages,n,t),a=new Map;for(let t of e.messages)if(t.role===`assistant`&&Array.isArray(t.content))for(let e of t.content)e.type===`tool-approval-request`&&`approvalId`in e&&`toolCallId`in e&&a.set(e.approvalId,e.toolCallId);let o=new Set;for(let t of e.messages)if(t.role===`tool`){for(let e of t.content)if(e.type===`tool-approval-response`){let t=a.get(e.approvalId);t&&o.add(t)}}let s=[...e.instructions==null?[]:typeof e.instructions==`string`?[{role:`system`,content:e.instructions}]:kq(e.instructions).map(e=>({role:`system`,content:e.content,providerOptions:e.providerOptions})),...e.messages.map(e=>Q2({message:e,downloadedAssets:i,provider:r}))],c=[];for(let e of s){if(e.role!==`tool`){c.push(e);continue}let t=c.at(-1);if(t?.role===`tool`){let n=t.content.at(-1);n!=null&&t.providerOptions!=null&&(n.providerOptions=G2(t.providerOptions,n.providerOptions)),t.content.push(...e.content),t.providerOptions=e.providerOptions}else c.push(e)}let l=new Set;for(let e of c)switch(e.role){case`assistant`:for(let t of e.content)t.type===`tool-call`&&!t.providerExecuted&&l.add(t.toolCallId);break;case`tool`:for(let t of e.content)t.type===`tool-result`&&l.delete(t.toolCallId);break;case`user`:case`system`:for(let e of o)l.delete(e);if(l.size>0)throw new s0({toolCallIds:Array.from(l)})}for(let e of o)l.delete(e);if(l.size>0)throw new s0({toolCallIds:Array.from(l)});return c.filter(e=>e.role!==`tool`||e.content.length>0)}function Q2({message:e,downloadedAssets:t,provider:n}){let r=[],i=e.role;switch(i){case`system`:return{role:`system`,content:e.content,providerOptions:e.providerOptions};case`user`:{if(typeof e.content==`string`)return{role:`user`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions};let n={role:`user`,content:e.content.map(e=>(e.type===`image`&&r.push({type:`deprecated`,setting:`"image" content part`,message:`The "image" content part type is deprecated. Use a "file" part with mediaType: 'image' (or a more specific image/* subtype) instead.`}),$2(e))).map(e=>t4(e,t)).filter(e=>e.type!==`text`||e.text!==``),providerOptions:e.providerOptions};return r.length>0&&b2({warnings:r}),n}case`assistant`:{if(typeof e.content==`string`)return{role:`assistant`,content:[{type:`text`,text:e.content}],providerOptions:e.providerOptions};let i={role:`assistant`,content:e.content.filter(e=>e.type!==`text`||e.text!==``||e.providerOptions!=null).filter(e=>e.type!==`tool-approval-request`).map(e=>{let i=e.providerOptions;switch(e.type){case`custom`:return{type:`custom`,kind:e.kind,providerOptions:i};case`file`:{let{data:t,mediaType:n}=X2(e.data);return{type:`file`,data:t,filename:e.filename,mediaType:n??e.mediaType,providerOptions:i}}case`reasoning`:return{type:`reasoning`,text:e.text,providerOptions:i};case`reasoning-file`:{let{data:t,mediaType:n}=X2(e.data);if(t.type!==`data`&&t.type!==`url`)throw Error(`Unsupported reasoning-file data type: ${t.type}`);return{type:`reasoning-file`,data:t,mediaType:n??e.mediaType,providerOptions:i}}case`text`:return{type:`text`,text:e.text,providerOptions:i};case`tool-call`:return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,providerExecuted:e.providerExecuted,providerOptions:i};case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:n4({output:e.output,provider:n,warnings:r,downloadedAssets:t}),providerOptions:i}}}),providerOptions:e.providerOptions};return r.length>0&&b2({warnings:r}),i}case`tool`:{let i={role:`tool`,content:e.content.filter(e=>e.type!==`tool-approval-response`||e.providerExecuted).map(e=>{switch(e.type){case`tool-result`:return{type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:n4({output:e.output,provider:n,warnings:r,downloadedAssets:t}),providerOptions:e.providerOptions};case`tool-approval-response`:return{type:`tool-approval-response`,approvalId:e.approvalId,approved:e.approved,reason:e.reason}}}),providerOptions:e.providerOptions};return r.length>0&&b2({warnings:r}),i}default:throw new r2({role:i})}}function $2(e){return e.type===`image`?{type:`file`,data:e.image,mediaType:e.mediaType??`image`,providerOptions:e.providerOptions}:e}async function e4(e,t,n){let r=[];for(let t of e){if(t.role===`user`&&Array.isArray(t.content))for(let e of t.content){let t=$2(e);t.type===`file`&&r.push(t)}if(t.role===`tool`){for(let e of t.content)if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&r.push(t)}if(t.role===`assistant`&&Array.isArray(t.content)){for(let e of t.content)if(e.type===`tool-result`&&e.output.type===`content`)for(let t of e.output.value)t.type===`file`&&r.push(t)}}let i=r.map(e=>{let t=e.mediaType,{data:n}=X2(e.data);return{mediaType:t,data:n}}).filter(e=>e.data.type===`url`).map(e=>({url:e.data.url,isUrlSupportedByModel:e.mediaType!=null&&aY({url:e.data.url.toString(),mediaType:e.mediaType,supportedUrls:n})})),a=await t(i);return Object.fromEntries(a.map((e,t)=>e==null?null:[i[t].url.toString(),{data:e.data,mediaType:e.mediaType}]).filter(e=>e!=null))}function t4(e,t){if(e.type===`text`)return{type:`text`,text:e.text,providerOptions:e.providerOptions};let{data:n,mediaType:r}=X2(e.data),i=r??e.mediaType,a=n;if(a.type===`url`){let e=t[a.url.toString()];e&&(a={type:`data`,data:e.data},e.mediaType!=null&&(i==null||!_J(i))&&(i=e.mediaType))}if(a.type===`data`&&(a.data instanceof Uint8Array||typeof a.data==`string`)){let e=gJ({data:a.data,topLevelType:`image`});e!=null&&(i=e)}if(i==null)throw Error(`Media type is missing for file part`);return{type:`file`,mediaType:i,filename:e.filename,data:a,providerOptions:e.providerOptions}}function n4({output:e,provider:t,warnings:n=[],downloadedAssets:r}){return e.type===`content`?{type:`content`,value:e.value.map(e=>{switch(e.type){case`file`:{let t=t4(e,r);if(t.type!==`file`)throw Error(`Expected tool result file content to convert to file.`);return t}case`file-data`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-data"`,message:`The "file-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'data', data } instead.`}),{type:`file`,data:{type:`data`,data:e.data},filename:e.filename,mediaType:e.mediaType,providerOptions:e.providerOptions};case`file-url`:{let t=e.mediaType??a4(e.url),r=`The "file-url" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'url', url } instead.`;if(!e.mediaType){let n=t===`application/octet-stream`?`Unable to infer media type from URL. Defaulting to 'application/octet-stream'.`:`Inferred media type '${t}' from URL.`;r=`The "file-url" tool result content part with URL "${e.url}" is missing a "mediaType". ${n} ${r}`}return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-url"`,message:r}),{type:`file`,data:{type:`url`,url:new URL(e.url)},mediaType:t,providerOptions:e.providerOptions}}case`file-id`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-id"`,message:`The "file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:r4({fileId:e.fileId,provider:t})},mediaType:`application`,providerOptions:e.providerOptions};case`file-reference`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "file-reference"`,message:`The "file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:e.providerReference},mediaType:`application`,providerOptions:e.providerOptions};case`image-data`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-data"`,message:`The "image-data" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'data', data } instead.`}),{type:`file`,data:{type:`data`,data:e.data},mediaType:e.mediaType,providerOptions:e.providerOptions};case`image-url`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-url"`,message:`The "image-url" type for tool result content is deprecated. Use the "file" type with mediaType 'image' (or a specific image/* subtype) and { type: 'url', url } instead.`}),{type:`file`,data:{type:`url`,url:new URL(e.url)},mediaType:`image`,providerOptions:e.providerOptions};case`image-file-id`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-file-id"`,message:`The "image-file-id" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:r4({fileId:e.fileId,provider:t})},mediaType:`image`,providerOptions:e.providerOptions};case`image-file-reference`:return n.push({type:`deprecated`,setting:`"tool-result" content of type "image-file-reference"`,message:`The "image-file-reference" type for tool result content is deprecated. Use the "file" type with mediaType and { type: 'reference', reference } instead.`}),{type:`file`,data:{type:`reference`,reference:e.providerReference},mediaType:`image`,providerOptions:e.providerOptions};default:return e}})}:e}function r4({fileId:e,provider:t}){if(typeof e==`object`)return e;if(t==null)throw Error(`Cannot convert string fileId to provider reference without a provider ID. Use a Record<string, string> fileId or switch to the file-reference type.`);return{[t]:e}}var i4={jpg:`image/jpeg`,jpeg:`image/jpeg`,png:`image/png`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,avif:`image/avif`,heic:`image/heic`,bmp:`image/bmp`,tiff:`image/tiff`,tif:`image/tiff`,pdf:`application/pdf`,mp4:`video/mp4`,webm:`video/webm`,mp3:`audio/mpeg`,wav:`audio/wav`,ogg:`audio/ogg`};function a4(e,t=`application/octet-stream`){try{let t=new URL(e).pathname.split(`.`).pop()?.toLowerCase();if(t&&Object.hasOwn(i4,t))return i4[t]}catch{}return t}async function o4({toolCallId:e,input:t,output:n,tool:r,errorMode:i}){return i===`text`?{type:`error-text`,value:VK(n)}:i===`json`?{type:`error-json`,value:s4(n)}:r?.toModelOutput?await r.toModelOutput({toolCallId:e,input:t,output:n}):typeof n==`string`?{type:`text`,value:n}:{type:`json`,value:s4(n)}}function s4(e){return e===void 0?null:e}function c4({maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,seed:o,stopSequences:s,reasoning:c}){if(e!=null){if(!Number.isInteger(e))throw new j1({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be an integer`});if(e<1)throw new j1({parameter:`maxOutputTokens`,value:e,message:`maxOutputTokens must be >= 1`})}if(t!=null&&typeof t!=`number`)throw new j1({parameter:`temperature`,value:t,message:`temperature must be a number`});if(n!=null&&typeof n!=`number`)throw new j1({parameter:`topP`,value:n,message:`topP must be a number`});if(r!=null&&typeof r!=`number`)throw new j1({parameter:`topK`,value:r,message:`topK must be a number`});if(i!=null&&typeof i!=`number`)throw new j1({parameter:`presencePenalty`,value:i,message:`presencePenalty must be a number`});if(a!=null&&typeof a!=`number`)throw new j1({parameter:`frequencyPenalty`,value:a,message:`frequencyPenalty must be a number`});if(o!=null&&!Number.isInteger(o))throw new j1({parameter:`seed`,value:o,message:`seed must be an integer`});return{maxOutputTokens:e,temperature:t,topP:n,topK:r,presencePenalty:i,frequencyPenalty:a,stopSequences:s,seed:o,reasoning:c}}function l4({toolChoice:e}){return e==null?{type:`auto`}:typeof e==`string`?{type:e}:{type:`tool`,toolName:e.toolName}}function u4(e){return e!=null&&Object.keys(e).length>0}async function d4({tools:e,toolOrder:t,toolsContext:n={},experimental_sandbox:r}){if(!u4(e))return;let i=[];for(let[a,o]of f4({tools:e,toolOrder:t})){let e=o.type;switch(e){case void 0:case`dynamic`:case`function`:{let e=p4({tool:o,toolName:a,toolsContext:n,experimental_sandbox:r}),t=o.providerOptions,s=o.inputExamples,c=o.strict;i.push({type:`function`,name:a,inputSchema:await xX(o.inputSchema).jsonSchema,...e==null?{}:{description:e},...s==null?{}:{inputExamples:s},...t==null?{}:{providerOptions:t},...c==null?{}:{strict:c}});break}case`provider`:i.push({type:`provider`,name:a,id:o.id,args:o.args});break;default:throw Error(`Unsupported tool type: ${e}`)}}return i}function f4({tools:e,toolOrder:t}){if(t==null)return Object.entries(e);let n=Object.entries(e),r=n.filter(([e])=>t.includes(e)).sort(([e],[n])=>t.indexOf(e)-t.indexOf(n)),i=n.filter(([e])=>!t.includes(e)).sort(([e],[t])=>e<t?-1:+(e>t));return[...r,...i]}function p4({tool:e,toolName:t,toolsContext:n,experimental_sandbox:r}){return e.description===void 0?void 0:typeof e.description==`string`?e.description:e.description({context:n[t],experimental_sandbox:r})}function m4(e){if(e!=null)return typeof e==`number`?e:e.totalMs}function h4(e){if(e!=null&&typeof e!=`number`)return e.stepMs}function g4(e){if(e!=null&&typeof e!=`number`)return e.firstChunkMs}function _4(e){if(e!=null&&typeof e!=`number`)return e.chunkMs}function v4(e,t){if(e!=null&&typeof e!=`number`)return e.tools?.[`${t}Ms`]??e.toolMs}var J={array:VU,boolean:jU,custom:EW,discriminatedUnion:JU,enum:eW,instanceof:kW,lazy:wW,literal:nW,looseObject:WU,never:zU,null:NU,number:DU,object:UU,record:QU,string:G,union:KU,unknown:LU},y4=J.lazy(()=>J.union([J.null(),J.string(),J.number(),J.boolean(),J.record(J.string(),y4.optional()),J.array(y4)])),b4=J.record(J.string(),J.record(J.string(),y4.optional())),x4=J.union([J.string(),J.instanceof(Uint8Array),J.instanceof(ArrayBuffer),J.custom(tY,{message:`Must be a Buffer`})]),S4=J.record(J.string(),J.string()),C4=J.object({type:J.literal(`text`),text:J.string(),providerOptions:b4.optional()}),w4=J.object({type:J.literal(`image`),image:J.union([x4,J.instanceof(URL),S4]),mediaType:J.string().optional(),providerOptions:b4.optional()}),T4=J.discriminatedUnion(`type`,[J.object({type:J.literal(`data`),data:x4}),J.object({type:J.literal(`url`),url:J.instanceof(URL)}),J.object({type:J.literal(`reference`),reference:S4}),J.object({type:J.literal(`text`),text:J.string()})]),E4=J.discriminatedUnion(`type`,[J.object({type:J.literal(`data`),data:x4}),J.object({type:J.literal(`url`),url:J.instanceof(URL)})]),D4=J.object({type:J.literal(`file`),data:J.union([T4,x4,J.instanceof(URL),S4]),filename:J.string().optional(),mediaType:J.string(),providerOptions:b4.optional()}),O4=J.object({type:J.literal(`reasoning`),text:J.string(),providerOptions:b4.optional()}),k4=J.object({type:J.literal(`custom`),kind:J.string().transform(e=>e),providerOptions:b4.optional()}),A4=J.object({type:J.literal(`reasoning-file`),data:J.union([E4,x4,J.instanceof(URL)]),mediaType:J.string(),providerOptions:b4.optional()}),j4=J.object({type:J.literal(`tool-call`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerOptions:b4.optional(),providerExecuted:J.boolean().optional()}),M4=J.discriminatedUnion(`type`,[J.object({type:J.literal(`text`),value:J.string(),providerOptions:b4.optional()}),J.object({type:J.literal(`json`),value:y4,providerOptions:b4.optional()}),J.object({type:J.literal(`execution-denied`),reason:J.string().optional(),providerOptions:b4.optional()}),J.object({type:J.literal(`error-text`),value:J.string(),providerOptions:b4.optional()}),J.object({type:J.literal(`error-json`),value:y4,providerOptions:b4.optional()}),J.object({type:J.literal(`content`),value:J.array(J.union([J.object({type:J.literal(`text`),text:J.string(),providerOptions:b4.optional()}),J.object({type:J.literal(`file`),data:T4,mediaType:J.string(),filename:J.string().optional(),providerOptions:b4.optional()}),J.object({type:J.literal(`file-data`),data:J.string(),mediaType:J.string(),filename:J.string().optional(),providerOptions:b4.optional()}),J.object({type:J.literal(`file-url`),url:J.string(),mediaType:J.string().optional(),providerOptions:b4.optional()}),J.object({type:J.literal(`file-id`),fileId:J.union([J.string(),J.record(J.string(),J.string())]),providerOptions:b4.optional()}),J.object({type:J.literal(`file-reference`),providerReference:J.record(J.string(),J.string()),providerOptions:b4.optional()}),J.object({type:J.literal(`image-data`),data:J.string(),mediaType:J.string(),providerOptions:b4.optional()}),J.object({type:J.literal(`image-url`),url:J.string(),providerOptions:b4.optional()}),J.object({type:J.literal(`image-file-id`),fileId:J.union([J.string(),J.record(J.string(),J.string())]),providerOptions:b4.optional()}),J.object({type:J.literal(`image-file-reference`),providerReference:J.record(J.string(),J.string()),providerOptions:b4.optional()}),J.object({type:J.literal(`custom`),providerOptions:b4.optional()})]))})]),N4=J.object({type:J.literal(`tool-result`),toolCallId:J.string(),toolName:J.string(),output:M4,providerOptions:b4.optional()}),P4=J.object({type:J.literal(`tool-approval-request`),approvalId:J.string(),toolCallId:J.string(),reason:J.string().optional()}),F4=J.object({type:J.literal(`tool-approval-response`),approvalId:J.string(),approved:J.boolean(),reason:J.string().optional()}),I4=J.object({role:J.literal(`system`),content:J.string(),providerOptions:b4.optional()}),L4=J.object({role:J.literal(`user`),content:J.union([J.string(),J.array(J.union([C4,w4,D4]))]),providerOptions:b4.optional()}),R4=J.object({role:J.literal(`assistant`),content:J.union([J.string(),J.array(J.union([C4,k4,D4,O4,A4,j4,N4,P4]))]),providerOptions:b4.optional()}),z4=J.object({role:J.literal(`tool`),content:J.array(J.union([N4,F4])),providerOptions:b4.optional()}),B4=J.union([I4,L4,R4,z4]);async function V4({allowSystemInMessages:e=!1,system:t,instructions:n=t,prompt:r,messages:i}){if(r==null&&i==null)throw new $K({prompt:r,message:`prompt or messages must be defined`});if(r!=null&&i!=null)throw new $K({prompt:r,message:`prompt and messages cannot be defined at the same time`});if(typeof n!=`string`&&!kq(n).every(e=>e.role===`system`))throw new $K({prompt:r,message:`instructions must be a string, SystemModelMessage, or array of SystemModelMessage`});if(r!=null&&typeof r==`string`)i=[{role:`user`,content:r}];else if(r!=null&&Array.isArray(r))i=r;else if(i==null)throw new $K({prompt:r,message:`prompt or messages must be defined`});if(i.length===0)throw new $K({prompt:r,message:`messages must not be empty`});if(!e&&i.some(e=>e.role===`system`))throw new $K({prompt:r,message:`System messages are not allowed in the prompt or messages fields. Use the instructions option instead.`});let a=await kX({value:i,schema:J.array(B4)});if(!a.success)throw new $K({prompt:r,message:`The messages do not match the ModelMessage[] schema.`,cause:a.error});return{messages:i,instructions:n}}function H4(e){if(!LZ.isInstance(e))return e;let t=(process==null?void 0:`production`)===`production`,n=`https://ai-sdk.dev/unauthenticated-ai-gateway`;return t?new K({name:`GatewayError`,message:`Unauthenticated. Configure AI_GATEWAY_API_KEY or use a provider module. Learn more: ${n}`}):Object.assign(Error(`\x1B[1m\x1B[31mUnauthenticated request to AI Gateway.\x1B[0m
|
|
156
|
-
|
|
157
|
-
To authenticate, set the \x1B[33mAI_GATEWAY_API_KEY\x1B[0m environment variable with your API key.
|
|
158
|
-
|
|
159
|
-
Alternatively, you can use a provider module instead of the AI Gateway.
|
|
160
|
-
|
|
161
|
-
Learn more: \x1B[34m${n}\x1B[0m
|
|
162
|
-
|
|
163
|
-
`),{name:`GatewayAuthenticationError`})}function U4(e){return{inputTokens:e.inputTokens.total,inputTokenDetails:{noCacheTokens:e.inputTokens.noCache,cacheReadTokens:e.inputTokens.cacheRead,cacheWriteTokens:e.inputTokens.cacheWrite},outputTokens:e.outputTokens.total,outputTokenDetails:{textTokens:e.outputTokens.text,reasoningTokens:e.outputTokens.reasoning},totalTokens:K4(e.inputTokens.total,e.outputTokens.total),raw:e.raw}}function W4(){return{inputTokens:void 0,inputTokenDetails:{noCacheTokens:void 0,cacheReadTokens:void 0,cacheWriteTokens:void 0},outputTokens:void 0,outputTokenDetails:{textTokens:void 0,reasoningTokens:void 0},totalTokens:void 0,raw:void 0}}function G4(e,t){return{inputTokens:K4(e.inputTokens,t.inputTokens),inputTokenDetails:{noCacheTokens:K4(e.inputTokenDetails?.noCacheTokens,t.inputTokenDetails?.noCacheTokens),cacheReadTokens:K4(e.inputTokenDetails?.cacheReadTokens,t.inputTokenDetails?.cacheReadTokens),cacheWriteTokens:K4(e.inputTokenDetails?.cacheWriteTokens,t.inputTokenDetails?.cacheWriteTokens)},outputTokens:K4(e.outputTokens,t.outputTokens),outputTokenDetails:{textTokens:K4(e.outputTokenDetails?.textTokens,t.outputTokenDetails?.textTokens),reasoningTokens:K4(e.outputTokenDetails?.reasoningTokens,t.outputTokenDetails?.reasoningTokens)},totalTokens:K4(e.totalTokens,t.totalTokens)}}function K4(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function q4(e,t){return e!=null&&Object.hasOwn(e,t)?e[t]:void 0}function J4(...e){let t=XJ(...e).map(e=>e instanceof AbortSignal?e:AbortSignal.timeout(e));return t.length===0?void 0:t.length===1?t[0]:AbortSignal.any(t)}function Y4(){return(globalThis==null?void 0:globalThis.performance)?.now()??Date.now()}async function X4(e){await Promise.all(kq(e.callbacks).map(async t=>{try{await t?.(e.event)}catch{}}))}function Z4({error:e,exponentialBackoffDelay:t}){let n=PK.isInstance(e)?e.responseHeaders:PK.isInstance(e.cause)?e.cause.responseHeaders:void 0;if(!n)return t;let r,i=n[`retry-after-ms`];if(i){let e=parseFloat(i);Number.isNaN(e)||(r=e)}let a=n[`retry-after`];if(a&&r===void 0){let e=parseFloat(a);r=Number.isNaN(e)?Date.parse(a)-Date.now():e*1e3}return r!=null&&!Number.isNaN(r)&&0<=r&&(r<6e4||r<t)?r:t}var Q4=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:n=2,abortSignal:r}={})=>zX({maxRetries:e,initialDelayInMs:t,backoffFactor:n,abortSignal:r,shouldRetry:e=>e instanceof Error&&(PK.isInstance(e)&&e.isRetryable===!0||jZ.isInstance(e)&&e.isRetryable===!0),getDelayInMs:({error:e,exponentialBackoffDelay:t})=>Z4({error:e,exponentialBackoffDelay:t}),createRetryError:({message:e,reason:t,errors:n})=>new h2({message:e,reason:t,errors:n})});function $4({maxRetries:e,abortSignal:t,parameter:n=`maxRetries`,defaultMaxRetries:r=2}){if(e!=null){if(!Number.isInteger(e))throw new j1({parameter:n,value:e,message:`${n} must be an integer`});if(e<0)throw new j1({parameter:n,value:e,message:`${n} must be >= 0`})}let i=e??r;return{maxRetries:i,retry:Q4({maxRetries:i,abortSignal:t})}}function e3({abortController:e,label:t,timeoutMs:n}){if(e!=null&&n!=null)return setTimeout(()=>e.abort(new DOMException(`${t} timeout of ${n}ms exceeded`,`TimeoutError`)),n)}function t3({tokens:e,durationMs:t}){let n=1e3*(e??0)/(t??0);return Number.isFinite(n)?n:0}function n3({messages:e}){let t=e.at(-1);if(t?.role!=`tool`)return{approvedToolApprovals:[],deniedToolApprovals:[]};let n=Object.create(null);for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-call`&&(n[t.toolCallId]=t)}let r=Object.create(null);for(let t of e)if(t.role===`assistant`&&typeof t.content!=`string`){let e=t.content;for(let t of e)t.type===`tool-approval-request`&&(r[t.approvalId]=t)}let i=Object.create(null);for(let e of t.content)e.type===`tool-result`&&(i[e.toolCallId]=e);let a=[],o=[],s=t.content.filter(e=>e.type===`tool-approval-response`);for(let e of s){let t=r[e.approvalId];if(t==null)throw new L1({approvalId:e.approvalId});let s=i[t.toolCallId];if(s!=null&&(e.approved||s.output.type!==`execution-denied`))continue;let c=n[t.toolCallId];if(c==null)throw new t0({toolCallId:t.toolCallId,approvalId:t.approvalId});let l={approvalRequest:t,approvalResponse:e,toolCall:c,...s==null?{}:{existingToolResult:s}};e.approved?a.push(l):o.push(l)}return{approvedToolApprovals:a,deniedToolApprovals:o}}var r3=class{constructor({data:e,mediaType:t,providerMetadata:n}){let r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t,this.providerMetadata=n}get base64(){return this.base64Data??=Wq(this.uint8ArrayData),this.base64Data}get uint8Array(){return this.uint8ArrayData??=Uq(this.base64Data),this.uint8ArrayData}},i3=class extends r3{constructor(e){super(e),this.type=`file`}};async function a3({toolName:e,context:t,contextSchema:n}){return n==null?t:await OX({value:t,schema:n,context:{field:`tool context`,entityName:e}})}async function o3({toolCall:e,tools:t,toolsContext:n,callId:r,messages:i,abortSignal:a,timeout:o,experimental_sandbox:s,onPreliminaryToolResult:c,onToolExecutionStart:l,onToolExecutionEnd:u,executeToolInTelemetryContext:d=async({execute:e})=>await e(),runInTracingChannelSpan:f=async({execute:e})=>await e()}){let{toolName:p,toolCallId:m,input:h}=e,g=q4(t,p);if(!pZ(g))return;let _=await a3({toolName:p,context:q4(n,p),contextSchema:g.contextSchema}),v={toolCall:e,messages:i,toolContext:_},y={callId:r,...v};return await f({type:`executeTool`,event:y,execute:async()=>{let t;await X4({event:y,callbacks:l});let n=J4(a,v4(o,p)),f=0;try{await d({callId:r,toolCallId:m,...v,execute:async()=>{let r=Y4();try{let r=hZ({tool:g,input:h,options:{toolCallId:m,messages:i,abortSignal:n,context:_,experimental_sandbox:s}});for await(let n of r)n.type===`preliminary`?c?.({...e,type:`tool-result`,output:n.output,preliminary:!0}):t=n.output}finally{f=Y4()-r}}})}catch(t){let n={type:`tool-error`,toolCallId:m,toolName:p,input:h,error:t,dynamic:g.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}};return await X4({event:{...y,toolOutput:n,toolExecutionMs:f},callbacks:u}),{output:n,toolExecutionMs:f}}let b={type:`tool-result`,toolCallId:m,toolName:p,input:h,output:t,dynamic:g.type===`dynamic`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata}};return await X4({event:{...y,toolOutput:b,toolExecutionMs:f},callbacks:u}),{output:b,toolExecutionMs:f}}})}function s3({tools:e,activeTools:t}){return e==null||t==null?e:Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e)))}function c3(e){return e===`stop`||e===`tool-calls`}T1({},{array:()=>p3,choice:()=>m3,json:()=>h3,object:()=>f3,text:()=>d3});function l3(e){let t=[`ROOT`],n=-1,r=null,i=0;function a(e){return e>=`0`&&e<=`9`||e>=`A`&&e<=`F`||e>=`a`&&e<=`f`}function o(e,i,a){switch(e){case`"`:n=i,t.pop(),t.push(a),t.push(`INSIDE_STRING`);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`);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`);break;case`{`:n=i,t.pop(),t.push(a),t.push(`INSIDE_OBJECT_START`);break;case`[`:n=i,t.pop(),t.push(a),t.push(`INSIDE_ARRAY_START`)}}function s(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_OBJECT_AFTER_COMMA`);break;case`}`:n=r,t.pop()}}function c(e,r){switch(e){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=r,t.pop()}}for(let l=0;l<e.length;l++){let u=e[l];switch(t[t.length-1]){case`ROOT`:o(u,l,`FINISH`);break;case`INSIDE_OBJECT_START`:switch(u){case`"`:t.pop(),t.push(`INSIDE_OBJECT_KEY`);break;case`}`:n=l,t.pop()}break;case`INSIDE_OBJECT_AFTER_COMMA`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_KEY`));break;case`INSIDE_OBJECT_KEY`:u===`"`&&(t.pop(),t.push(`INSIDE_OBJECT_AFTER_KEY`));break;case`INSIDE_OBJECT_AFTER_KEY`:u===`:`&&(t.pop(),t.push(`INSIDE_OBJECT_BEFORE_VALUE`));break;case`INSIDE_OBJECT_BEFORE_VALUE`:o(u,l,`INSIDE_OBJECT_AFTER_VALUE`);break;case`INSIDE_OBJECT_AFTER_VALUE`:s(u,l);break;case`INSIDE_STRING`:switch(u){case`"`:t.pop(),n=l;break;case`\\`:t.push(`INSIDE_STRING_ESCAPE`);break;default:n=l}break;case`INSIDE_ARRAY_START`:switch(u){case`]`:n=l,t.pop();break;default:n=l,o(u,l,`INSIDE_ARRAY_AFTER_VALUE`)}break;case`INSIDE_ARRAY_AFTER_VALUE`:switch(u){case`,`:t.pop(),t.push(`INSIDE_ARRAY_AFTER_COMMA`);break;case`]`:n=l,t.pop();break;default:n=l}break;case`INSIDE_ARRAY_AFTER_COMMA`:o(u,l,`INSIDE_ARRAY_AFTER_VALUE`);break;case`INSIDE_STRING_ESCAPE`:t.pop(),u===`u`?(i=0,t.push(`INSIDE_STRING_UNICODE_ESCAPE`)):n=l;break;case`INSIDE_STRING_UNICODE_ESCAPE`:a(u)&&(i++,i===4&&(t.pop(),n=l));break;case`INSIDE_NUMBER`:switch(u){case`0`:case`1`:case`2`:case`3`:case`4`:case`5`:case`6`:case`7`:case`8`:case`9`:n=l;break;case`e`:case`E`:case`-`:case`.`:break;case`,`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`}`:t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`&&s(u,l);break;case`]`:t.pop(),t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l);break;default:t.pop()}break;case`INSIDE_LITERAL`:{let i=e.substring(r,l+1);!`false`.startsWith(i)&&!`true`.startsWith(i)&&!`null`.startsWith(i)?(t.pop(),t[t.length-1]===`INSIDE_OBJECT_AFTER_VALUE`?s(u,l):t[t.length-1]===`INSIDE_ARRAY_AFTER_VALUE`&&c(u,l)):n=l;break}}}let l=e.slice(0,n+1);for(let n=t.length-1;n>=0;n--)switch(t[n]){case`INSIDE_STRING`:l+=`"`;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`:l+=`}`;break;case`INSIDE_ARRAY_START`:case`INSIDE_ARRAY_AFTER_COMMA`:case`INSIDE_ARRAY_AFTER_VALUE`:l+=`]`;break;case`INSIDE_LITERAL`:{let t=e.substring(r,e.length);`true`.startsWith(t)?l+=`true`.slice(t.length):`false`.startsWith(t)?l+=`false`.slice(t.length):`null`.startsWith(t)&&(l+=`null`.slice(t.length))}}return l}async function u3(e){if(e===void 0)return{value:void 0,state:`undefined-input`};let t=await jX({text:e});return t.success?{value:t.value,state:`successful-parse`}:(t=await jX({text:l3(e)}),t.success?{value:t.value,state:`repaired-parse`}:{value:void 0,state:`failed-parse`})}var d3=()=>({name:`text`,responseFormat:Promise.resolve({type:`text`}),async parseCompleteOutput({text:e}){return e},async parsePartialOutput({text:e}){return{partial:e}},createElementStreamTransform(){}}),f3=({schema:e,name:t,description:n})=>{let r=xX(e);return{name:`object`,responseFormat:RX(r.jsonSchema).then(e=>({type:`json`,schema:e,...t!=null&&{name:t},...n!=null&&{description:n}})),async parseCompleteOutput({text:e},t){let n=await jX({text:e});if(!n.success)throw new p0({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=await kX({value:n.value,schema:r});if(!i.success)throw new p0({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return i.value},async parsePartialOutput({text:e}){let t=await u3(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return{partial:t.value}}},createElementStreamTransform(){}}},p3=({element:e,name:t,description:n})=>{let r=xX(e);return{name:`array`,responseFormat:RX(r.jsonSchema).then(e=>{let{$schema:r,definitions:i,$defs:a,...o}=e;return{type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,...i!=null&&{definitions:i},...a!=null&&{$defs:a},type:`object`,properties:{elements:{type:`array`,items:o}},required:[`elements`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}}),async parseCompleteOutput({text:e},t){let n=await jX({text:e});if(!n.success)throw new p0({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let i=n.value;if(typeof i!=`object`||!i||!(`elements`in i)||!Array.isArray(i.elements))throw new p0({message:`No object generated: response did not match schema.`,cause:new dq({value:i,cause:`response must be an object with an elements array`}),text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});let a=[];for(let n of i.elements){let i=await kX({value:n,schema:r});if(!i.success)throw new p0({message:`No object generated: response did not match schema.`,cause:i.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});a.push(i.value)}return a},async parsePartialOutput({text:e}){let t=await u3(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let e=t.value;if(typeof e!=`object`||!e||!(`elements`in e)||!Array.isArray(e.elements))return;let n=t.state===`repaired-parse`&&e.elements.length>0?e.elements.slice(0,-1):e.elements,i=[];for(let e of n){let t=await kX({value:e,schema:r});t.success&&i.push(t.value)}return{partial:i}}}},createElementStreamTransform(){let e=0;return new TransformStream({transform({partialOutput:t},n){if(t!=null)for(;e<t.length;e++)n.enqueue(t[e])}})}}},m3=({options:e,name:t,description:n})=>({name:`choice`,responseFormat:Promise.resolve({type:`json`,schema:{$schema:`http://json-schema.org/draft-07/schema#`,type:`object`,properties:{result:{type:`string`,enum:e}},required:[`result`],additionalProperties:!1},...t!=null&&{name:t},...n!=null&&{description:n}}),async parseCompleteOutput({text:t},n){let r=await jX({text:t});if(!r.success)throw new p0({message:`No object generated: could not parse the response.`,cause:r.error,text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});let i=r.value;if(typeof i!=`object`||!i||!(`result`in i)||typeof i.result!=`string`||!e.includes(i.result))throw new p0({message:`No object generated: response did not match schema.`,cause:new dq({value:i,cause:`response must be an object that contains a choice value.`}),text:t,response:n.response,usage:n.usage,finishReason:n.finishReason});return i.result},async parsePartialOutput({text:t}){let n=await u3(t);switch(n.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:{let t=n.value;if(typeof t!=`object`||!t||!(`result`in t)||typeof t.result!=`string`)return;let r=e.filter(e=>e.startsWith(t.result));return n.state===`successful-parse`?r.includes(t.result)?{partial:t.result}:void 0:r.length===1?{partial:r[0]}:void 0}}},createElementStreamTransform(){}}),h3=({name:e,description:t}={})=>({name:`json`,responseFormat:Promise.resolve({type:`json`,...e!=null&&{name:e},...t!=null&&{description:t}}),async parseCompleteOutput({text:e},t){let n=await jX({text:e});if(!n.success)throw new p0({message:`No object generated: could not parse the response.`,cause:n.error,text:e,response:t.response,usage:t.usage,finishReason:t.finishReason});return n.value},async parsePartialOutput({text:e}){let t=await u3(e);switch(t.state){case`failed-parse`:case`undefined-input`:return;case`repaired-parse`:case`successful-parse`:return t.value===void 0?void 0:{partial:t.value}}},createElementStreamTransform(){}});async function g3({toolCall:e,tools:t,repairToolCall:n,refineToolInput:r,messages:i,instructions:a}){try{if(t==null){if(e.providerExecuted&&e.dynamic)return await _3({toolCall:await v3(e),refineToolInput:r});throw new T0({toolName:e.toolName})}try{return await _3({toolCall:await y3({toolCall:e,tools:t}),refineToolInput:r})}catch(o){if(n==null||!(T0.isInstance(o)||Y1.isInstance(o)))throw o;let s=null;try{s=await n({toolCall:e,tools:t,inputSchema:async({toolName:e})=>{let n=q4(t,e)?.inputSchema;return await xX(n).jsonSchema},instructions:a,system:a,messages:i,error:o})}catch(e){throw new R0({cause:e,originalError:o})}if(s==null)throw o;return await _3({toolCall:await y3({toolCall:s,tools:t}),refineToolInput:r})}}catch(n){let r=await jX({text:e.input}),i=r.success?r.value:e.input,a=q4(t,e.toolName);return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:i,dynamic:!0,invalid:!0,error:n,title:a?.title,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...a?.metadata==null?{}:{toolMetadata:a.metadata}}}}async function _3({toolCall:e,refineToolInput:t}){let n=q4(t,e.toolName);return n==null?e:{...e,input:await n(e.input)}}async function v3(e){let t=e.input.trim()===``?{success:!0,value:{}}:await jX({text:e.input});if(t.success===!1)throw new Y1({toolName:e.toolName,toolInput:e.input,cause:t.error});return{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:t.value,providerExecuted:!0,dynamic:!0,providerMetadata:e.providerMetadata}}async function y3({toolCall:e,tools:t}){let n=e.toolName,r=q4(t,n);if(r==null){if(e.providerExecuted&&e.dynamic)return await v3(e);throw new T0({toolName:e.toolName,availableTools:Object.keys(t)})}let i=xX(r.inputSchema),a=e.input.trim()===``?await kX({value:{},schema:i}):await jX({text:e.input,schema:i});if(a.success===!1)throw new Y1({toolName:n,toolInput:e.input,cause:a.error});return r.type===`dynamic`?{type:`tool-call`,toolCallId:e.toolCallId,toolName:e.toolName,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},dynamic:!0,title:r.title}:{type:`tool-call`,toolCallId:e.toolCallId,toolName:n,input:a.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,...r.metadata==null?{}:{toolMetadata:r.metadata},title:r.title}}function b3({callSettings:e,stepSettings:t}){return c4({maxOutputTokens:t?.maxOutputTokens??e.maxOutputTokens,temperature:t?.temperature??e.temperature,topP:t?.topP??e.topP,topK:t?.topK??e.topK,presencePenalty:t?.presencePenalty??e.presencePenalty,frequencyPenalty:t?.frequencyPenalty??e.frequencyPenalty,stopSequences:t?.stopSequences??e.stopSequences,seed:t?.seed??e.seed,reasoning:t?.reasoning??e.reasoning})}function x3(e){return typeof e==`object`&&e&&`type`in e?e.type===`data`?e.data:e.url:e}function S3(e){return e.map(e=>e.type===`reasoning`?{type:`reasoning`,text:e.text,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}}:{type:`reasoning-file`,data:e.file.base64,mediaType:e.file.mediaType,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}})}function C3(e){return e.map(e=>{if(e.type===`reasoning`)return{type:`reasoning`,text:e.text,...e.providerOptions==null?{}:{providerMetadata:e.providerOptions}};let t=x3(e.data);return{type:`reasoning-file`,file:new r3({data:t instanceof ArrayBuffer?new Uint8Array(t):t instanceof URL?t.toString():t,mediaType:e.mediaType}),...e.providerOptions==null?{}:{providerMetadata:e.providerOptions}}})}async function w3({tools:e,toolCall:t,toolApproval:n,messages:r,toolsContext:i,runtimeContext:a}){if(n!=null&&typeof n==`function`)return T3(await n({toolCall:t,tools:e,toolsContext:i,messages:r,runtimeContext:a}));let o=t.toolName,s=q4(e,o),c=t.input,l=q4(n,o);return l==null?s?.needsApproval==null?{type:`not-applicable`}:(typeof s.needsApproval==`function`?await s.needsApproval(c,{toolCallId:t.toolCallId,messages:r,context:await a3({toolName:o,context:q4(i,o),contextSchema:s?.contextSchema})}):s.needsApproval)?{type:`user-approval`}:{type:`not-applicable`}:T3(typeof l==`function`?await l(c,{toolCallId:t.toolCallId,messages:r,toolContext:await a3({toolName:o,context:q4(i,o),contextSchema:s?.contextSchema}),runtimeContext:a}):l)}function T3(e){return e===void 0?{type:`not-applicable`}:typeof e==`string`?{type:e}:e}function E3(...e){return async t=>{await Promise.allSettled(e.map(async e=>{await e?.(t)}))}}var D3=`ai:telemetry`;function O3(){return typeof process<`u`&&process.release?.name===`node`}var k3;async function A3(){if(O3())return k3??=Promise.resolve(j3(`node:diagnostics_channel`)),k3}function j3(e){let t=globalThis.process;try{return(t?.getBuiltinModule)?.call(t,e)}catch{return}}async function M3(e,t){let n=await A3(),r=(n?.tracingChannel)?.call(n,D3);if(r==null||r.hasSubscribers===!1)return await t();let i,a,o,s=!1,c=!1,l=()=>{try{i=Promise.resolve(t())}catch(e){i=Promise.reject(e)}return i=i.then(e=>(a=e,s=!0,e),e=>{throw o=e,c=!0,e}),i};try{return await r.tracePromise(l,e)}catch{if(c)throw o;return s?a:i==null?await t():await i}}function N3({message:e,completion:t}){if(!O3())return;let n=j3(`node:diagnostics_channel`),r=j3(`node:async_hooks`),i=(n?.tracingChannel)?.call(n,D3);if(i==null||i.hasSubscribers===!1||r==null){Promise.resolve(t).catch(()=>{});return}let a=e,o,s=!1,c=e=>{try{e()}catch{}},l=({result:e,error:t})=>{s||(s=!0,t!==void 0&&(a.error=t,c(()=>i.error.publish(a))),e!==void 0&&(a.result=e),c(()=>i.asyncEnd.publish(a)))};return c(()=>{i.start.runStores(a,()=>{o=new r.AsyncResource(`ai.telemetry`)})}),c(()=>i.end.publish(a)),Promise.resolve(t).then(e=>l({result:e}),e=>l({error:e})),{run:e=>o==null?e():o.runInAsyncScope(e)}}function P3(){return globalThis.AI_SDK_TELEMETRY_INTEGRATIONS??[]}function F3(e,t){return Object.assign(Object.create(Object.getPrototypeOf(e)),e,t)}function I3({telemetry:e}){if(e?.isEnabled===!1)return{};let t=e?.integrations,n=t==null?P3():kq(t),r={recordInputs:e?.recordInputs,recordOutputs:e?.recordOutputs,functionId:e?.functionId},i=e=>{let t=E3(...n.map(t=>t[e]?.bind(t)).filter(Boolean).map(e=>(t=>e(F3(t,r)))));return async e=>{await t(e)}},a=n.map(e=>e.executeLanguageModelCall?.bind(e)).filter(Boolean),o=n.map(e=>e.executeTool?.bind(e)).filter(Boolean);return{runInTracingChannelSpan:async({type:e,event:t,execute:n})=>await M3({type:e,event:F3(t,r)},n),startTracingChannelContext:({type:e,event:t,completion:n})=>N3({message:{type:e,event:F3(t,r)},completion:n}),onStart:i(`onStart`),onStepStart:i(`onStepStart`),onLanguageModelCallStart:i(`onLanguageModelCallStart`),onLanguageModelCallEnd:i(`onLanguageModelCallEnd`),onToolExecutionStart:i(`onToolExecutionStart`),onToolExecutionEnd:i(`onToolExecutionEnd`),onStepEnd:E3(i(`onStepEnd`),i(`onStepFinish`)),onObjectStepStart:i(`onObjectStepStart`),onObjectStepEnd:i(`onObjectStepEnd`),onEmbedStart:i(`onEmbedStart`),onEmbedEnd:i(`onEmbedEnd`),onRerankStart:i(`onRerankStart`),onRerankEnd:i(`onRerankEnd`),onEnd:i(`onEnd`),onAbort:i(`onAbort`),onError:i(`onError`),executeLanguageModelCall:async({execute:e,...t})=>{let n=F3(t,r),i=e;for(let e of a){let t=i;i=()=>e({...n,execute:t})}return await M3({type:`languageModelCall`,event:n},i)},executeTool:async({execute:e,...t})=>{let n=F3(t,r),i=e;for(let e of o){let t=i;i=()=>e({...n,execute:t})}return await i()}}}function L3(e){let t=e.map(e=>`text`in e?e.text:``).join(``);return t.length>0?t:void 0}var R3=class{constructor({callId:e,stepNumber:t,provider:n,modelId:r,runtimeContext:i,toolsContext:a,content:o,finishReason:s,rawFinishReason:c,usage:l,performance:u,warnings:d,request:f,response:p,providerMetadata:m}){this.callId=e,this.stepNumber=t,this.model={provider:n,modelId:r},this.runtimeContext=i,this.toolsContext=a,this.content=o,this.finishReason=s,this.rawFinishReason=c,this.usage=l,this.performance=u,this.warnings=d,this.request=f,this.response=p,this.providerMetadata=m}get text(){return this.content.filter(e=>e.type===`text`).map(e=>e.text).join(``)}get reasoning(){return S3(this.content.filter(e=>e.type===`reasoning`||e.type===`reasoning-file`))}get reasoningText(){return L3(this.reasoning)}get files(){return this.content.filter(e=>e.type===`file`).map(e=>e.file)}get sources(){return this.content.filter(e=>e.type===`source`)}get toolCalls(){return this.content.filter(e=>e.type===`tool-call`)}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type===`tool-result`)}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function z3({context:e,includeContext:t}){return e==null?{}:Object.fromEntries(Object.entries(e).filter(([e])=>t?.[e]===!0))}function B3({step:e,includeRuntimeContext:t,includeToolsContext:n}){return new R3({callId:e.callId,stepNumber:e.stepNumber,provider:e.model.provider,modelId:e.model.modelId,runtimeContext:z3({context:e.runtimeContext,includeContext:t}),toolsContext:V3({toolsContext:e.toolsContext,includeToolsContext:n}),content:e.content,finishReason:e.finishReason,rawFinishReason:e.rawFinishReason,usage:e.usage,performance:e.performance,warnings:e.warnings,request:e.request,response:e.response,providerMetadata:e.providerMetadata})}function V3({toolsContext:e,includeToolsContext:t}){return t==null?{}:Object.fromEntries(Object.entries(e).map(([e,n])=>[e,H3({toolName:e,toolContext:n,includeToolsContext:t})]))}function H3({toolName:e,toolContext:t,includeToolsContext:n}){return z3({context:t,includeContext:n?.[e]})}function U3({telemetry:e,includeRuntimeContext:t,includeToolsContext:n}){let r=I3({telemetry:e});return{...r,onStart:e=>r.onStart?.call(r,{...e,runtimeContext:z3({context:e.runtimeContext,includeContext:t}),toolsContext:V3({toolsContext:e.toolsContext,includeToolsContext:n})}),onStepStart:e=>r.onStepStart?.call(r,{...e,runtimeContext:z3({context:e.runtimeContext,includeContext:t}),steps:e.steps.map(e=>B3({step:e,includeRuntimeContext:t,includeToolsContext:n})),toolsContext:V3({toolsContext:e.toolsContext,includeToolsContext:n})}),onStepEnd:e=>r.onStepEnd?.call(r,B3({step:e,includeRuntimeContext:t,includeToolsContext:n})),onStepFinish:e=>r.onStepEnd?.call(r,B3({step:e,includeRuntimeContext:t,includeToolsContext:n})),onEnd:e=>r.onEnd?.call(r,(r=>({...e,runtimeContext:z3({context:e.runtimeContext,includeContext:t}),steps:r,finalStep:r.at(-1),toolsContext:V3({toolsContext:e.toolsContext,includeToolsContext:n})}))(e.steps.map(e=>B3({step:e,includeRuntimeContext:t,includeToolsContext:n})))),onAbort:e=>r.onAbort?.call(r,{...e,steps:e.steps.map(e=>B3({step:e,includeRuntimeContext:t,includeToolsContext:n}))}),onToolExecutionStart:e=>r.onToolExecutionStart?.call(r,{...e,toolContext:H3({toolName:e.toolCall.toolName,toolContext:e.toolContext,includeToolsContext:n})}),onToolExecutionEnd:e=>r.onToolExecutionEnd?.call(r,{...e,toolContext:H3({toolName:e.toolCall.toolName,toolContext:e.toolContext,includeToolsContext:n})})}}function W3(e){return({steps:t})=>t.length===e}async function G3({stopConditions:e,steps:t}){return(await Promise.all(e.map(e=>e({steps:t})))).some(e=>e)}function K3(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}async function q3({content:e,tools:t}){let n=[],r=new Map,i=[];for(let n of e)if(n.type!==`source`&&(n.type!==`tool-result`&&n.type!==`tool-error`||n.providerExecuted)&&(n.type!==`text`||n.text.length!==0))switch(n.type){case`text`:i.push({type:`text`,text:n.text,providerOptions:n.providerMetadata});break;case`custom`:i.push({type:`custom`,kind:n.kind,providerOptions:n.providerMetadata});break;case`reasoning`:i.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});break;case`file`:i.push({type:`file`,data:n.file.base64,mediaType:n.file.mediaType,providerOptions:n.providerMetadata});break;case`reasoning-file`:i.push({type:`reasoning-file`,data:n.file.base64,mediaType:n.file.mediaType,providerOptions:n.providerMetadata});break;case`tool-call`:r.has(n.toolCallId)||r.set(n.toolCallId,r.size),i.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:n.toolName,input:n.invalid&&typeof n.input!=`object`?{}:n.input,providerExecuted:n.providerExecuted,providerOptions:n.providerMetadata});break;case`tool-result`:{let e=await o4({toolCallId:n.toolCallId,input:n.input,tool:q4(t,n.toolName),output:n.output,errorMode:`none`});i.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-error`:{let e=await o4({toolCallId:n.toolCallId,input:n.input,tool:q4(t,n.toolName),output:n.error,errorMode:`json`});i.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,providerOptions:n.providerMetadata});break}case`tool-approval-request`:i.push({type:`tool-approval-request`,approvalId:n.approvalId,toolCallId:n.toolCall.toolCallId,...n.reason==null?{}:{reason:n.reason},isAutomatic:n.isAutomatic,...n.signature==null?{}:{signature:n.signature}})}i.length>0&&n.push({role:`assistant`,content:i});let a=[];for(let n of e){if(n.type!==`tool-approval-response`&&n.type!==`tool-result`&&n.type!==`tool-error`)continue;if(n.type===`tool-approval-response`){a.push({type:`tool-approval-response`,approvalId:n.approvalId,approved:n.approved,reason:n.reason,providerExecuted:n.providerExecuted}),n.approved===!1&&a.push({type:`tool-result`,toolCallId:n.toolCall.toolCallId,toolName:n.toolCall.toolName,output:{type:`execution-denied`,reason:n.reason}});continue}if(n.providerExecuted)continue;let e=await o4({toolCallId:n.toolCallId,input:n.input,tool:q4(t,n.toolName),output:n.type===`tool-result`?n.output:n.error,errorMode:n.type===`tool-error`?`text`:`none`});a.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:e,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}})}return a.length>0&&n.push({role:`tool`,content:J3({toolResultContent:a,toolCallOrder:r})}),n}function J3({toolResultContent:e,toolCallOrder:t}){let n=e.filter(e=>e.type===`tool-result`).map((e,t)=>({part:e,index:t})).sort((e,n)=>{let r=t.get(e.part.toolCallId),i=t.get(n.part.toolCallId);return r==null&&i==null?e.index-n.index:r==null?1:i==null?-1:r-i||e.index-n.index}).map(({part:e})=>e),r=0;return e.map(e=>e.type===`tool-result`?n[r++]:e)}var Y3=`AI_SDK_DIRECT_TOOL_CALL`;function X3({tools:e,toolCallers:t}){if(e==null||t==null)return;let n={};for(let[r,i]of Object.entries(t)){if(!Object.prototype.hasOwnProperty.call(e,r))throw new j1({parameter:`experimental_toolCallers`,value:t,message:`unknown tool "${r}".`});if(!Array.isArray(i))throw new j1({parameter:`experimental_toolCallers`,value:t,message:`callers for tool "${r}" must be an array.`});n[r]=i.map(n=>{if(n===Y3)return n;if(typeof n!=`string`||!Object.prototype.hasOwnProperty.call(e,n)||gZ(e[n])==null)throw new j1({parameter:`experimental_toolCallers`,value:t,message:`tool "${r}" contains an invalid caller.`});return n})}return n}function Z3({tools:e,toolCallers:t}){if(e==null||t==null)return{executionTools:e,modelTools:e};let n={...e},r={...e},i=new Map;for(let[e,a]of Object.entries(t)){let t=n[e];if(t==null)continue;let o=!1,s=!1,c=t;for(let t of a){if(t===Y3){o=!0;continue}let r=gZ(n[t]);if(r!=null){if(r.type===`provider`)s=!0,c={...c,providerOptions:r.prepareProviderOptions(c.providerOptions)};else{let n=i.get(t)??{};n[e]=c,i.set(t,n)}}}n[e]=c,o||s?r[e]=c:delete r[e]}for(let[e,t]of Object.entries(n)){let a=gZ(t);if(a?.type!==`local`)continue;let o=a.bind(i.get(e)??{});n[e]=o,Object.prototype.hasOwnProperty.call(r,e)&&(r[e]=o)}return{executionTools:n,modelTools:r}}var Q3=new TextEncoder;function $3(e){return typeof e!=`object`||!e?JSON.stringify(e):Array.isArray(e)?`[${e.map(e=>e===void 0?`null`:$3(e)).join(`,`)}]`:`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${$3(e[t])}`).join(`,`)}}`}function e6(e){return Wq(e).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/g,``)}async function t6(e){let t=await crypto.subtle.digest(`SHA-256`,Q3.encode($3(e)));return e6(new Uint8Array(t))}var n6=new TextEncoder;function r6(e){return Uq(e)}async function i6(e){let t=typeof e==`string`?n6.encode(e):e;return crypto.subtle.importKey(`raw`,t,{name:`HMAC`,hash:`SHA-256`},!1,[`sign`,`verify`])}function a6(e,t,n,r){return n6.encode(JSON.stringify([`ai-sdk-tool-approval-v1`,e,t,n,r]))}function o6(e,t,n,r){return n6.encode(`${e}
|
|
164
|
-
${t}
|
|
165
|
-
${n}
|
|
166
|
-
${r}`)}async function s6({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i}){let a=await i6(e),o=a6(t,n,r,await t6(i)),s=await crypto.subtle.sign(`HMAC`,a,o);return e6(new Uint8Array(s))}async function c6({secret:e,signature:t,approvalId:n,toolCallId:r,toolName:i,input:a}){let o=await i6(e),s=await t6(a),c=r6(t),l=a6(n,r,i,s);if(await crypto.subtle.verify(`HMAC`,o,c,l))return!0;if(!n.includes(`
|
|
167
|
-
`)&&!r.includes(`
|
|
168
|
-
`)&&!i.includes(`
|
|
169
|
-
`)){let e=o6(n,r,i,s);return crypto.subtle.verify(`HMAC`,o,c,e)}return!1}async function l6({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i}){if(e!=null)return s6({secret:e,approvalId:t,toolCallId:n,toolName:r,input:i})}async function u6({approvedToolApprovals:e,tools:t,toolApproval:n,messages:r,toolsContext:i,runtimeContext:a,toolApprovalSecret:o}){let s=[],c=[],l=[];for(let u of e){let{toolCall:e,approvalRequest:d}=u,f=q4(t,e.toolName);if(o!=null){if(d.signature==null)throw new U1({approvalId:d.approvalId,toolCallId:e.toolCallId,reason:`missing signature`});if(!await c6({secret:o,signature:d.signature,approvalId:d.approvalId,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input}))throw new U1({approvalId:d.approvalId,toolCallId:e.toolCallId,reason:`invalid signature`})}if(pZ(f)&&f.inputSchema!=null){let t=await kX({value:e.input,schema:xX(f.inputSchema)});if(!t.success){l.push({...u,error:new Y1({toolName:e.toolName,toolInput:JSON.stringify(e.input),cause:t.error})});continue}}let p=await w3({tools:t,toolApproval:n,toolCall:e,messages:r,toolsContext:i,runtimeContext:a});p.type===`denied`?c.push({...u,approvalResponse:{...u.approvalResponse,approved:!1,reason:p.reason??u.approvalResponse.reason}}):s.push(u)}return{approvedToolApprovals:s,deniedToolApprovals:c,invalidToolApprovals:l}}ZJ({prefix:`aitxt`,size:24}),ZJ({prefix:`call`,size:24});function d6(e,t){let n=new Headers(e??{});for(let[e,r]of Object.entries(t))n.has(e)||n.set(e,r);return n}function f6({status:e,statusText:t,headers:n,stream:r}){return new Response(r.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:d6(n,{"content-type":`text/plain; charset=utf-8`})})}function p6({response:e,status:t,statusText:n,headers:r,stream:i}){let a=t??200;n===void 0?e.writeHead(a,r):e.writeHead(a,n,r);let o=i.getReader();return(async()=>{try{for(;;){let{done:t,value:n}=await o.read();if(t)break;let r=e.write(n),i=e.flush;typeof i==`function`&&i.call(e),r||await new Promise(t=>{e.once(`drain`,t)})}}catch(e){throw e}finally{e.end()}})()}function m6({response:e,status:t,statusText:n,headers:r,stream:i}){return p6({response:e,status:t,statusText:n,headers:Object.fromEntries(d6(r,{"content-type":`text/plain; charset=utf-8`}).entries()),stream:i.pipeThrough(new TextEncoderStream)})}function h6({stream:e}){return e.pipeThrough(new TransformStream({transform(e,t){e.type===`text-delta`&&t.enqueue(e.text)}}))}var g6=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
170
|
-
|
|
171
|
-
`)},flush(e){e.enqueue(`data: [DONE]
|
|
172
|
-
|
|
173
|
-
`)}})}},_6={"content-type":`text/event-stream`,"cache-control":`no-cache`,connection:`keep-alive`,"x-vercel-ai-ui-message-stream":`v1`,"x-accel-buffering":`no`};function v6({status:e,statusText:t,headers:n,stream:r,consumeSseStream:i}){let a=r.pipeThrough(new g6);if(i){let[e,t]=a.tee();a=e,i({stream:t})}return new Response(a.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:d6(n,_6)})}function y6({response:e,status:t,statusText:n,headers:r,stream:i,consumeSseStream:a}){let o=i.pipeThrough(new g6);if(a){let[e,t]=o.tee();o=e,a({stream:t})}return p6({response:e,status:t,statusText:n,headers:Object.fromEntries(d6(r,_6).entries()),stream:o.pipeThrough(new TextEncoderStream)})}function b6({originalMessages:e,responseMessageId:t}){if(e==null)return;let n=e[e.length-1];return n?.role===`assistant`?n.id:typeof t==`function`?t():t}var x6=J.record(J.string(),y4.optional()),S6=vX(()=>DX(J.union([J.looseObject({type:J.literal(`text-start`),id:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`text-delta`),id:J.string(),delta:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`text-end`),id:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`error`),errorText:J.string()}),J.looseObject({type:J.literal(`tool-input-start`),toolCallId:J.string(),toolName:J.string(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional(),toolMetadata:x6.optional(),dynamic:J.boolean().optional(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-input-delta`),toolCallId:J.string(),inputTextDelta:J.string()}),J.looseObject({type:J.literal(`tool-input-available`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional(),toolMetadata:x6.optional(),dynamic:J.boolean().optional(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-input-error`),toolCallId:J.string(),toolName:J.string(),input:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional(),toolMetadata:x6.optional(),dynamic:J.boolean().optional(),errorText:J.string(),title:J.string().optional()}),J.looseObject({type:J.literal(`tool-approval-request`),approvalId:J.string(),toolCallId:J.string(),approvalDescriptor:J.unknown().optional(),reason:J.string().optional(),isAutomatic:J.boolean().optional(),signature:J.string().optional()}),J.looseObject({type:J.literal(`tool-approval-response`),approvalId:J.string(),approved:J.boolean(),reason:J.string().optional(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`tool-output-available`),toolCallId:J.string(),output:J.unknown(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional(),toolMetadata:x6.optional(),dynamic:J.boolean().optional(),preliminary:J.boolean().optional()}),J.looseObject({type:J.literal(`tool-output-error`),toolCallId:J.string(),errorText:J.string(),providerExecuted:J.boolean().optional(),providerMetadata:b4.optional(),toolMetadata:x6.optional(),dynamic:J.boolean().optional()}),J.looseObject({type:J.literal(`tool-output-denied`),toolCallId:J.string()}),J.looseObject({type:J.literal(`reasoning-start`),id:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`reasoning-delta`),id:J.string(),delta:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`reasoning-end`),id:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`custom`),kind:J.string().transform(e=>e),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`source-url`),sourceId:J.string(),url:J.string(),title:J.string().optional(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`source-document`),sourceId:J.string(),mediaType:J.string(),title:J.string(),filename:J.string().optional(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`file`),url:J.string(),mediaType:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.literal(`reasoning-file`),url:J.string(),mediaType:J.string(),providerMetadata:b4.optional()}),J.looseObject({type:J.custom(e=>typeof e==`string`&&e.startsWith(`data-`),{message:`Type must start with "data-"`}),id:J.string().optional(),data:J.unknown(),transient:J.boolean().optional()}),J.looseObject({type:J.literal(`start-step`)}),J.looseObject({type:J.literal(`finish-step`)}),J.looseObject({type:J.literal(`reset-step`)}),J.looseObject({type:J.literal(`start`),messageId:J.string().optional(),messageMetadata:J.unknown().optional()}),J.looseObject({type:J.literal(`finish`),finishReason:J.enum([`stop`,`length`,`content-filter`,`tool-calls`,`error`,`other`]).optional(),messageMetadata:J.unknown().optional()}),J.looseObject({type:J.literal(`abort`),reason:J.string().optional()}),J.looseObject({type:J.literal(`message-metadata`),messageMetadata:J.unknown()})])));function C6(e){return e.type.startsWith(`data-`)}function w6(){return Object.create(null)}function T6(e){return e.type.startsWith(`data-`)}function E6(e){return e.type===`text`}function D6(e){return e.type===`custom`}function O6(e){return e.type===`file`}function k6(e){return e.type===`reasoning-file`}function A6(e){return e.type===`reasoning`}function j6(e){return e.type.startsWith(`tool-`)}function M6(e){return e.type===`dynamic-tool`}function N6(e){return j6(e)||M6(e)}function P6(e){return e.type.split(`-`).slice(1).join(`-`)}function F6(e){return M6(e)?e.toolName:P6(e)}function I6({lastMessage:e,messageId:t}){return{message:e?.role===`assistant`?e:{id:t,metadata:void 0,role:`assistant`,parts:[]},activeTextParts:w6(),activeReasoningParts:w6(),partialToolCalls:w6()}}function L6({stream:e,messageMetadataSchema:t,dataPartSchemas:n,runUpdateMessageJob:r,onError:i,onToolCall:a,onData:o}){return e.pipeThrough(new TransformStream({async transform(e,s){await r(async({state:r,write:c})=>{function l(){let e=r.message.parts,t=e.length-1;for(;t>=0&&e[t].type!==`step-start`;)t--;return e.slice(t+1)}function u(){return l().filter(N6)}function d(e){let t=u().find(t=>t.toolCallId===e);if(t==null){let n=r.message.parts;for(let r=n.length-1;r>=0;r--){let i=n[r];if(N6(i)&&i.toolCallId===e){t=i;break}}}if(t==null)throw new G0({chunkType:`tool-invocation`,chunkId:e,message:`No tool invocation found for tool call ID "${e}".`});return t}function f(e){let t=r.message.parts.filter(N6).find(t=>t.approval?.id===e);if(t==null)throw new G0({chunkType:`tool-approval-response`,chunkId:e,message:`No tool invocation found for approval ID "${e}".`});return t}function p(e,t){let n=t??l().find(t=>j6(t)&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`tool-${e.toolName}`,toolCallId:e.toolCallId,state:e.state,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},input:i.input,output:i.output,rawInput:i.rawInput,errorText:i.errorText,providerExecuted:i.providerExecuted,preliminary:i.preliminary,...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}function m(e,t){let n=t??l().find(t=>t.type===`dynamic-tool`&&t.toolCallId===e.toolCallId),i=e,a=n;if(n!=null){n.state=e.state,a.toolName=e.toolName,a.input=i.input,a.output=i.output,a.errorText=i.errorText,a.rawInput=i.rawInput??a.rawInput,a.preliminary=i.preliminary,e.title!==void 0&&(a.title=e.title),e.toolMetadata!==void 0&&(a.toolMetadata=e.toolMetadata),a.providerExecuted=i.providerExecuted??n.providerExecuted;let t=i.providerMetadata;if(t!=null){if(e.state===`output-available`||e.state===`output-error`){let e=n;e.resultProviderMetadata=t}else n.callProviderMetadata=t}}else r.message.parts.push({type:`dynamic-tool`,toolName:e.toolName,toolCallId:e.toolCallId,state:e.state,input:i.input,output:i.output,errorText:i.errorText,preliminary:i.preliminary,providerExecuted:i.providerExecuted,title:e.title,...e.toolMetadata===void 0?{}:{toolMetadata:e.toolMetadata},...i.providerMetadata!=null&&(e.state===`output-available`||e.state===`output-error`)?{resultProviderMetadata:i.providerMetadata}:{},...i.providerMetadata!=null&&e.state!==`output-available`&&e.state!==`output-error`?{callProviderMetadata:i.providerMetadata}:{}})}async function h(e){if(e!=null){let n=r.message.metadata==null?e:G2(r.message.metadata,e);t!=null&&await OX({value:n,schema:t,context:{field:`message.metadata`,entityId:r.message.id}}),r.message.metadata=n}}switch(e.type){case`text-start`:{let t={type:`text`,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeTextParts[e.id]=t,r.message.parts.push(t),c();break}case`text-delta`:{let t=r.activeTextParts[e.id];if(t==null)throw new G0({chunkType:`text-delta`,chunkId:e.id,message:`Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`text-end`:{let t=r.activeTextParts[e.id];if(t==null)throw new G0({chunkType:`text-end`,chunkId:e.id,message:`Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`});t.state=`done`,t.providerMetadata=e.providerMetadata??t.providerMetadata,delete r.activeTextParts[e.id],c();break}case`custom`:{let t={type:`custom`,kind:e.kind,providerMetadata:e.providerMetadata};r.message.parts.push(t),c();break}case`reasoning-start`:{let t={type:`reasoning`,id:e.id,text:``,providerMetadata:e.providerMetadata,state:`streaming`};r.activeReasoningParts[e.id]=t,r.message.parts.push(t),c();break}case`reasoning-delta`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new G0({chunkType:`reasoning-delta`,chunkId:e.id,message:`Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`});t.text+=e.delta,t.providerMetadata=e.providerMetadata??t.providerMetadata,c();break}case`reasoning-end`:{let t=r.activeReasoningParts[e.id];if(t==null)throw new G0({chunkType:`reasoning-end`,chunkId:e.id,message:`Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`});t.providerMetadata=e.providerMetadata??t.providerMetadata,t.state=`done`,delete r.activeReasoningParts[e.id],c();break}case`file`:case`reasoning-file`:r.message.parts.push({type:e.type,mediaType:e.mediaType,url:e.url,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}),c();break;case`source-url`:r.message.parts.push({type:`source-url`,sourceId:e.sourceId,url:e.url,title:e.title,providerMetadata:e.providerMetadata}),c();break;case`source-document`:r.message.parts.push({type:`source-document`,sourceId:e.sourceId,mediaType:e.mediaType,title:e.title,filename:e.filename,providerMetadata:e.providerMetadata}),c();break;case`tool-input-start`:{let t=l().filter(j6);r.partialToolCalls[e.toolCallId]={text:``,toolName:e.toolName,index:t.length,dynamic:e.dynamic,title:e.title,toolMetadata:e.toolMetadata},e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-streaming`,input:void 0,providerExecuted:e.providerExecuted,title:e.title,toolMetadata:e.toolMetadata,providerMetadata:e.providerMetadata}),c();break}case`tool-input-delta`:{let t=r.partialToolCalls[e.toolCallId];if(t==null)throw new G0({chunkType:`tool-input-delta`,chunkId:e.toolCallId,message:`Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`});t.text+=e.inputTextDelta;let{value:n}=await u3(t.text);t.dynamic?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}):p({toolCallId:e.toolCallId,toolName:t.toolName,state:`input-streaming`,input:n,title:t.title,toolMetadata:t.toolMetadata}),c();break}case`tool-input-available`:e.dynamic?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`input-available`,input:e.input,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:e.title,toolMetadata:e.toolMetadata}),c(),a&&!e.providerExecuted&&await a({toolCall:e});break;case`tool-input-error`:{let t=l().filter(N6).find(t=>t.toolCallId===e.toolCallId);(t==null?e.dynamic:t.type===`dynamic-tool`)?m({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}):p({toolCallId:e.toolCallId,toolName:e.toolName,state:`output-error`,input:void 0,rawInput:e.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,toolMetadata:e.toolMetadata}),c();break}case`tool-approval-request`:{let t=d(e.toolCallId);t.state=`approval-requested`,t.approval={id:e.approvalId,...e.approvalDescriptor==null?{}:{descriptor:e.approvalDescriptor},...e.reason==null?{}:{requestReason:e.reason},...e.isAutomatic===!0?{isAutomatic:!0}:{},...e.signature==null?{}:{signature:e.signature}},c();break}case`tool-approval-response`:{let t=f(e.approvalId),n=t.approval==null?{id:e.approvalId}:t.approval;t.state=`approval-responded`,t.approval={...n,id:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason}},e.providerExecuted!=null&&(t.providerExecuted=e.providerExecuted),e.providerMetadata!=null&&(t.callProviderMetadata=e.providerMetadata),c();break}case`tool-output-denied`:{let t=d(e.toolCallId);t.state=`output-denied`,c();break}case`tool-output-available`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-available`,input:t.input,output:e.output,preliminary:e.preliminary,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:P6(t),state:`output-available`,input:t.input,output:e.output,providerExecuted:e.providerExecuted,preliminary:e.preliminary,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`tool-output-error`:{let t=d(e.toolCallId);t.type===`dynamic-tool`?m({toolCallId:e.toolCallId,toolName:t.toolName,state:`output-error`,input:t.input,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t):p({toolCallId:e.toolCallId,toolName:P6(t),state:`output-error`,input:t.input,rawInput:t.rawInput,errorText:e.errorText,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,title:t.title,toolMetadata:t.toolMetadata},t),c();break}case`start-step`:r.message.parts.push({type:`step-start`});break;case`finish-step`:break;case`reset-step`:{let e=l();r.activeTextParts=w6(),r.activeReasoningParts=w6(),r.partialToolCalls=w6(),e.length>0&&(r.message.parts.splice(r.message.parts.length-e.length,e.length),c());break}case`start`:e.messageId!=null&&(r.message.id=e.messageId),await h(e.messageMetadata),(e.messageId!=null||e.messageMetadata!=null)&&c({updateStatus:!1});break;case`finish`:e.finishReason!=null&&(r.finishReason=e.finishReason),await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`message-metadata`:await h(e.messageMetadata),e.messageMetadata!=null&&c();break;case`error`:i?.(Error(e.errorText));break;default:if(C6(e)){if(n?.[e.type]!=null){let t=r.message.parts.findIndex(t=>`id`in t&&`data`in t&&t.id===e.id&&t.type===e.type),i=t>=0?t:r.message.parts.length;await OX({value:e.data,schema:n[e.type],context:{field:`message.parts[${i}].data`,entityName:e.type,entityId:e.id}})}let t=e;if(t.transient){o?.(t);break}let i=t.id==null?void 0:r.message.parts.find(e=>t.type===e.type&&t.id===e.id);i==null?r.message.parts.push(t):i.data=t.data,o?.(t),c()}}s.enqueue(e)})}}))}function R6({messageId:e,originalMessages:t=[],onStepEnd:n,onStepFinish:r,onEnd:i,onFinish:a,onError:o,stream:s,getOutcome:c}){let l=t?.[t.length-1];l?.role===`assistant`?e=l.id:l=void 0;let u=!1,d=!1,f,p=e=>{d=!0,f=e},m=s.pipeThrough(new TransformStream({transform(t,n){try{let r=t;if(t.type===`start`){let n=t;n.messageId==null&&e!=null&&(r={...n,messageId:e})}t.type===`abort`&&(u=!0),n.enqueue(r)}catch(e){throw p(e),e}}})),h=n??r,g=i??a;if(g==null&&h==null)return m;let _=I6({lastMessage:l?structuredClone(l):void 0,messageId:e??``}),v=async e=>{try{await e({state:_,write:()=>{}})}catch(e){throw p(e),e}},y=!1,b=async()=>{if(y||!g)return;y=!0;let e=_.message.id===l?.id,n=c?.()??{status:`unknown`},r=d?{status:`failed`,error:f}:n.status===`unknown`&&u?{status:`aborted`}:n;await g({isAborted:u||r.status===`aborted`,isContinuation:e,outcome:r,responseMessage:_.message,messages:[...e?t.slice(0,-1):t,_.message],finishReason:_.finishReason})},x=async()=>{if(!h)return;let e=_.message.id===l?.id;try{await h({isContinuation:e,responseMessage:structuredClone(_.message),messages:[...e?t.slice(0,-1):t,structuredClone(_.message)]})}catch(e){o(e)}};return L6({stream:m,runUpdateMessageJob:v,onError:o}).pipeThrough(new TransformStream({async transform(e,t){e.type===`finish-step`&&await x(),t.enqueue(e)},async cancel(){await b()},async flush(){await b()}}))}function z6(e,{tools:t,sendReasoning:n=!0,sendSources:r=!1,sendStart:i=!0,sendFinish:a=!0,onError:o=()=>`An error occurred.`,messageMetadata:s,responseMessageId:c}={}){let l=e=>{let n=t?.[e.toolName];return n==null?e.dynamic:n?.type===`dynamic`||void 0},u=e.type;switch(u){case`text-start`:return{type:`text-start`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`text-delta`:return{type:`text-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`text-end`:return{type:`text-end`,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`reasoning-start`:case`reasoning-end`:return n?{type:u,id:e.id,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0;case`reasoning-delta`:return n?{type:`reasoning-delta`,id:e.id,delta:e.text,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0;case`file`:case`reasoning-file`:return u===`reasoning-file`&&!n?void 0:{type:e.type,mediaType:e.file.mediaType,url:`data:${e.file.mediaType};base64,${e.file.base64}`,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`source`:return r?e.sourceType===`url`?{type:`source-url`,sourceId:e.id,url:e.url,title:e.title,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:e.sourceType===`document`?{type:`source-document`,sourceId:e.id,mediaType:e.mediaType,title:e.title,filename:e.filename,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}}:void 0:void 0;case`custom`:return{type:`custom`,kind:e.kind,...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata}};case`tool-input-start`:{let t=l(e);return{type:`tool-input-start`,toolCallId:e.id,toolName:e.toolName,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},...e.title==null?{}:{title:e.title}}}case`tool-input-delta`:return{type:`tool-input-delta`,toolCallId:e.id,inputTextDelta:e.delta};case`tool-call`:{let t=l(e);return e.invalid?{type:`tool-input-error`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},errorText:o(e.error),...e.title==null?{}:{title:e.title}}:{type:`tool-input-available`,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t},...e.title==null?{}:{title:e.title}}}case`tool-approval-request`:return{type:`tool-approval-request`,approvalId:e.approvalId,toolCallId:e.toolCall.toolCallId,...e.reason==null?{}:{reason:e.reason},...e.isAutomatic==null?{}:{isAutomatic:e.isAutomatic},...e.signature==null?{}:{signature:e.signature}};case`tool-approval-response`:return{type:`tool-approval-response`,approvalId:e.approvalId,approved:e.approved,...e.reason==null?{}:{reason:e.reason},...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted}};case`tool-result`:{let t=l(e);return{type:`tool-output-available`,toolCallId:e.toolCallId,output:e.output===void 0?null:e.output,...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...e.preliminary==null?{}:{preliminary:e.preliminary},...t==null?{}:{dynamic:t}}}case`tool-error`:{let t=l(e);return{type:`tool-output-error`,toolCallId:e.toolCallId,errorText:e.providerExecuted?typeof e.error==`string`?e.error:JSON.stringify(e.error):o(e.error),...e.providerExecuted==null?{}:{providerExecuted:e.providerExecuted},...e.providerMetadata==null?{}:{providerMetadata:e.providerMetadata},...e.toolMetadata==null?{}:{toolMetadata:e.toolMetadata},...t==null?{}:{dynamic:t}}}case`tool-output-denied`:return{type:`tool-output-denied`,toolCallId:e.toolCallId};case`error`:return{type:`error`,errorText:o(e.error)};case`start-step`:return{type:`start-step`};case`finish-step`:return{type:`finish-step`};case`start`:return i?{type:`start`,...s==null?{}:{messageMetadata:s},...c==null?{}:{messageId:c}}:void 0;case`finish`:return a?{type:`finish`,finishReason:e.finishReason,...s==null?{}:{messageMetadata:s}}:void 0;case`abort`:return e;case`tool-input-end`:case`raw`:return;default:throw Error(`Unknown chunk type: ${u}`)}}function B6({stream:e,tools:t,sendReasoning:n=!0,sendSources:r=!1,sendStart:i=!0,sendFinish:a=!0,onError:o=()=>`An error occurred.`,messageMetadata:s,originalMessages:c,generateMessageId:l,onEnd:u,onFinish:d}){let f={status:`unknown`},p=!1,m=e=>{!p&&f.status!==`completed`&&f.status!==`aborted`&&e.status!==`unknown`&&(f.status===`unknown`||e.status!==`failed`)&&(f=e)},h=e=>{p=!0,f={status:`failed`,error:e}},g=l==null?void 0:b6({originalMessages:c,responseMessageId:l}),_=e.getReader(),v=!1,y=!1,b=()=>{v||=(_.releaseLock(),!0)};return R6({stream:new ReadableStream({async pull(e){try{let{done:t,value:n}=await _.read();t?(b(),y||e.close()):e.enqueue(n)}catch(t){b(),y||(h(t),e.error(t))}},async cancel(e){if(y=!0,!v)try{await _.cancel(e)}finally{b()}}}).pipeThrough(new TransformStream({transform:async(e,c)=>{try{let l=s?.({part:e}),u=z6(e,{tools:t,sendReasoning:n,sendSources:r,sendStart:i,sendFinish:a,onError:o,messageMetadata:l,responseMessageId:g});u!=null&&c.enqueue(u),l!=null&&e.type!==`start`&&e.type!==`finish`&&c.enqueue({type:`message-metadata`,messageMetadata:l}),e.type===`finish`?m({status:`completed`}):e.type===`abort`?m({status:`aborted`}):e.type===`error`&&m({status:`failed`,error:e.error})}catch(e){throw h(e),e}}})),messageId:g??l?.(),originalMessages:c,onEnd:u??d,onError:o,getOutcome:()=>f})}function V6(e){return H6(e.pipeThrough(new TransformStream))}function H6(e){return e[Symbol.asyncIterator]=function(){let e=this.getReader(),t=!1;async function n(n){if(!t){t=!0;try{n&&await e.cancel?.call(e)}finally{try{e.releaseLock()}catch{}}}}return{async next(){if(t)return{done:!0,value:void 0};let r;try{r=await e.read()}catch(e){throw await n(!1),e}let{done:i,value:a}=r;return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(e){throw await n(!0),e}}},e}async function U6({stream:e,onError:t,abortSignal:n}){let r=e.getReader(),i=()=>{r.cancel().catch(()=>{})};n?.aborted?i():n?.addEventListener(`abort`,i,{once:!0});try{for(;;){let{done:e}=await r.read();if(e)break}}catch(e){t?.(e)}finally{n?.removeEventListener(`abort`,i),r.releaseLock()}}function W6(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function G6(){let e=[],t=null,n=!1,r=!1,i=W6(),a=()=>{r||(n=!0,i.resolve(),e.forEach(({reader:e,onCancel:t})=>{t?.(),e.cancel()}),e=[],t?.close())},o=async()=>{var s;if(r)return;if(n&&e.length===0){t?.close();return}if(e.length===0)return i=W6(),await i.promise,await o();let c=e[0];try{let{value:i,done:a}=await c.reader.read();if(r)return;a?(e.shift(),e.length===0&&n?t?.close():await o()):t?.enqueue(i)}catch(n){if(r)return;(s=c.onError)==null||s.call(c,n),t?.error(n),e.shift(),a()}};return{stream:new ReadableStream({start(e){t=e},pull:o,async cancel(){r=!0,n=!0,i.resolve();for(let{reader:t,onCancel:n}of e)n?.(),await t.cancel();e=[]}}),addStream:(t,a)=>{var o;if(r){(o=a?.onCancel)==null||o.call(a),t.cancel().catch(()=>{});return}if(n)throw Error(`Cannot add inner stream: outer stream is closed`);e.push({reader:t.getReader(),...a}),i.resolve()},close:()=>{r||(n=!0,i.resolve(),e.length===0&&t?.close())},terminate:a}}var K6=Symbol(`streamRetryAttemptBoundary`);function q6({warnings:e}){return{[K6]:!0,warnings:e}}function J6(e){return typeof e==`object`&&!!e&&K6 in e}function Y6({stream:e,tools:t,callId:n,messages:r,abortSignal:i,timeout:a,experimental_sandbox:o,toolsContext:s,toolApproval:c,runtimeContext:l,toolApprovalSecret:u,generateId:d,onToolExecutionStart:f,onToolExecutionEnd:p,executeToolInTelemetryContext:m,runInTracingChannelSpan:h}){let g=[];return e.pipeThrough(new TransformStream({async transform(e,_){if(_.enqueue(e),J6(e)){g.length=0;return}switch(e.type){case`tool-call`:{if(e.invalid)return;let n=q4(t,e.toolName);if(n==null)return;let i=await w3({tools:t,toolCall:e,toolApproval:c,messages:r,toolsContext:s,runtimeContext:l});if(i.type===`not-applicable`){n.execute!=null&&e.providerExecuted!==!0&&g.push(e);return}let a=d(),o=await l6({secret:u,approvalId:a,toolCallId:e.toolCallId,toolName:e.toolName,input:e.input});switch(i.type){case`user-approval`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,...i.reason==null?{}:{reason:i.reason},...o==null?{}:{signature:o}});return;case`denied`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,isAutomatic:!0,...o==null?{}:{signature:o}}),_.enqueue({type:`tool-approval-response`,approvalId:a,approved:!1,toolCall:e,reason:i.reason,providerExecuted:e.providerExecuted});return;case`approved`:_.enqueue({type:`tool-approval-request`,approvalId:a,toolCall:e,isAutomatic:!0,...o==null?{}:{signature:o}}),_.enqueue({type:`tool-approval-response`,approvalId:a,approved:!0,toolCall:e,reason:i.reason,providerExecuted:e.providerExecuted})}n.execute!=null&&e.providerExecuted!==!0&&g.push(e);return}case`model-call-end`:if(!c3(e.finishReason))return;await Promise.all(g.map(async e=>{try{let c=await o3({toolCall:e,tools:t,callId:n,messages:r,abortSignal:i,timeout:a,experimental_sandbox:o,toolsContext:s,onToolExecutionStart:f,onToolExecutionEnd:p,executeToolInTelemetryContext:m,runInTracingChannelSpan:h,onPreliminaryToolResult:e=>{_.enqueue(e)}});c!=null&&(_.enqueue({type:`tool-execution-end`,toolCallId:c.output.toolCallId,toolExecutionMs:c.toolExecutionMs}),_.enqueue(c.output))}catch(e){_.enqueue({type:`error`,error:e})}}));return}}}))}function X6({stream:e,tools:t,stepInputMessages:n,abortSignal:r,runtimeContext:i}){if(t==null)return e;let a=w6();return e.pipeThrough(new TransformStream({async transform(e,o){if(o.enqueue(e),!J6(e))switch(e.type){case`tool-input-start`:{a[e.id]=e.toolName;let o=q4(t,e.toolName);o?.onInputStart!=null&&await o.onInputStart({toolCallId:e.id,messages:n,abortSignal:r,context:i});break}case`tool-input-delta`:{let o=a[e.id],s=q4(t,o);s?.onInputDelta!=null&&await s.onInputDelta({inputTextDelta:e.delta,toolCallId:e.id,messages:n,abortSignal:r,context:i});break}case`tool-call`:{let o=a[e.toolCallId],s=q4(t,o);delete a[e.toolCallId],s?.onInputAvailable!=null&&await s.onInputAvailable({input:e.input,toolCallId:e.toolCallId,messages:n,abortSignal:r,context:i})}}}}))}function Z6(e){if(t8(e)||K.isInstance(e)||j0.isInstance(e))return e;let t=e8(e);if(t==null)return e;let n=Kq(e),r=n?t:e8(e8(t.response)?.error)??e8(t.error)??t;if(typeof r.message!=`string`)return e;let i=n8(r.type)??n8(t.type),a=r8(r.code)??r8(t.code),o=a8(r.statusCode)??a8(t.statusCode)??a8(r.status_code)??a8(t.status_code)??a8(r.status)??a8(t.status)??a8(r.code)??a8(t.code),s=Q6(r.message),c=o??s?.statusCode,l=i8(r.isRetryable)??i8(t.isRetryable)??i8(r.is_retryable)??i8(t.is_retryable);return new j0({message:r.message,type:i,code:a,statusCode:c,isRetryable:l??s?.isRetryable??$6(c),data:n?e.data:e})}function Q6(e){switch(e.trim().toLowerCase()){case`overloaded`:case`overloaded error`:case`model overloaded`:return{statusCode:503,isRetryable:!0};case`internal server error`:return{statusCode:500,isRetryable:!0};case`service unavailable`:return{statusCode:503,isRetryable:!0};default:return}}function $6(e){return e!=null&&(e===408||e===409||e===429||e>=500)}function e8(e){return typeof e==`object`&&e?e:void 0}function t8(e){return e instanceof Error||Object.prototype.toString.call(e)===`[object Error]`}function n8(e){return typeof e==`string`?e:void 0}function r8(e){return typeof e==`string`||typeof e==`number`?e:void 0}function i8(e){return typeof e==`boolean`?e:void 0}function a8(e){let t=typeof e==`string`&&/^\d{3}$/.test(e)?Number(e):e;return typeof t==`number`&&Number.isInteger(t)&&t>=400&&t<=599?t:void 0}var o8=ZJ({prefix:`aitxt`,size:24}),s8=ZJ({prefix:`call`,size:24});async function c8({model:e,tools:t,toolOrder:n,output:r,toolChoice:i,prompt:a,system:o,instructions:s,messages:c,allowSystemInMessages:l,download:u,abortSignal:d,headers:f,includeRawChunks:p,providerOptions:m,repairToolCall:h,refineToolInput:g,executeLanguageModelCallInTelemetryContext:_=async({execute:e})=>await e(),callId:v,toolsContext:y,experimental_sandbox:b,_internal:{generateId:x=o8,generateCallId:S=s8,now:C=Y4}={},onStart:w,onLanguageModelCallStart:T,onLanguageModelCallEnd:E,...D}){let O=R2(e),k=v??S(),A=await V4({instructions:s,system:o,prompt:a,messages:c,allowSystemInMessages:l}),j=await Z2({prompt:{instructions:A.instructions,messages:A.messages},supportedUrls:await O.supportedUrls,download:u,provider:O.provider.split(`.`)[0]}),ee=await d4({tools:t,toolOrder:n,toolsContext:y,experimental_sandbox:b}),te=l4({toolChoice:i});await X4({event:{promptMessages:j},callbacks:w});let ne={callId:k,provider:O.provider,modelId:O.modelId,instructions:A.instructions,messages:A.messages,tools:ee,...D};await X4({event:ne,callbacks:T});let re=C(),{stream:M,response:N,request:ie}=await _({...ne,execute:async()=>await O.doStream({...D,tools:ee,toolChoice:te,responseFormat:await r?.responseFormat,prompt:j,providerOptions:m,abortSignal:d,headers:f,includeRawChunks:p})});return{stream:V6(M.pipeThrough(l8({tools:t,instructions:A.instructions,messages:A.messages,repairToolCall:h,refineToolInput:g,callId:k,provider:O.provider,modelId:O.modelId,generateId:x,now:C,callStartTimestampMs:re,onLanguageModelCallEnd:E}))),response:N,request:ie}}function l8({tools:e,instructions:t,messages:n,repairToolCall:r,refineToolInput:i,callId:a,provider:o,modelId:s,generateId:c,now:l,callStartTimestampMs:u,onLanguageModelCallEnd:d}){let f=new Map,p=[],m=new Map,h=new Map,g=c(),_=s,v,y,b=[];return new TransformStream({async transform(s,c){if(u8(s)){let e=l();v==null?v=e-u:y!=null&&b.push(e-y),y=e}switch(s.type){case`error`:c.enqueue({type:`error`,error:Z6(s.error)});break;case`text-start`:p8({content:p,partIndexes:m,id:s.id,type:`text`,providerMetadata:s.providerMetadata}),c.enqueue(s);break;case`text-delta`:p8({content:p,partIndexes:m,id:s.id,type:`text`,textDelta:s.delta,providerMetadata:s.providerMetadata}),c.enqueue({type:`text-delta`,id:s.id,text:s.delta,providerMetadata:s.providerMetadata});break;case`text-end`:p8({content:p,partIndexes:m,id:s.id,type:`text`,providerMetadata:s.providerMetadata}),m.delete(s.id),c.enqueue(s);break;case`reasoning-start`:p8({content:p,partIndexes:h,id:s.id,type:`reasoning`,providerMetadata:s.providerMetadata}),c.enqueue(s);break;case`reasoning-delta`:p8({content:p,partIndexes:h,id:s.id,type:`reasoning`,textDelta:s.delta,providerMetadata:s.providerMetadata}),c.enqueue({type:`reasoning-delta`,id:s.id,text:s.delta,providerMetadata:s.providerMetadata});break;case`reasoning-end`:p8({content:p,partIndexes:h,id:s.id,type:`reasoning`,providerMetadata:s.providerMetadata}),h.delete(s.id),c.enqueue(s);break;case`file`:case`reasoning-file`:{let e=new i3({data:s.data.type===`data`?s.data.data:s.data.url.toString(),mediaType:s.mediaType});p.push({type:s.type,file:e,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata}}),c.enqueue({type:s.type,file:e,providerMetadata:s.providerMetadata});break}case`finish`:{let e=U4(s.usage),t=l()-u,n={responseTimeMs:t,effectiveOutputTokensPerSecond:t3({tokens:e.outputTokens,durationMs:t}),outputTokensPerSecond:v==null?void 0:t3({tokens:e.outputTokens,durationMs:t-v}),inputTokensPerSecond:v==null?void 0:t3({tokens:e.inputTokens,durationMs:v}),effectiveTotalTokensPerSecond:t3({tokens:K3(e.inputTokens,e.outputTokens),durationMs:t}),timeToFirstOutputMs:v,timeBetweenOutputChunksMs:b.length>0?d8(b):void 0};await X4({event:{callId:a,provider:o,modelId:_,finishReason:s.finishReason.unified,usage:e,content:p,responseId:g,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},performance:n},callbacks:d}),c.enqueue({type:`model-call-end`,finishReason:s.finishReason.unified,rawFinishReason:s.finishReason.raw,usage:e,providerMetadata:s.providerMetadata,performance:n});break}case`tool-call`:try{let a=await g3({toolCall:s,tools:e,repairToolCall:r,refineToolInput:i,instructions:t,messages:n});if(f.set(a.toolCallId,a),c.enqueue(a),p.push(a),a.invalid){a.providerExecuted||c.enqueue({type:`tool-error`,toolCallId:a.toolCallId,toolName:a.toolName,input:a.input,error:VK(a.error),dynamic:!0,title:a.title,...a.toolMetadata==null?{}:{toolMetadata:a.toolMetadata}});break}}catch(e){c.enqueue({type:`error`,error:e})}break;case`tool-approval-request`:{let e=f.get(s.toolCallId);if(e==null){c.enqueue({type:`error`,error:new t0({toolCallId:s.toolCallId,approvalId:s.approvalId})});break}let t={type:`tool-approval-request`,approvalId:s.approvalId,toolCall:e};c.enqueue(t),p.push(t);break}case`tool-result`:{let e=s.toolName,t=f.get(s.toolCallId),n=s.isError?{type:`tool-error`,toolCallId:s.toolCallId,toolName:e,input:t?.input,providerExecuted:!0,error:s.result,dynamic:s.dynamic,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},...t?.toolMetadata==null?{}:{toolMetadata:t.toolMetadata}}:{type:`tool-result`,toolCallId:s.toolCallId,toolName:e,input:t?.input,output:s.result,providerExecuted:!0,dynamic:s.dynamic,...s.providerMetadata==null?{}:{providerMetadata:s.providerMetadata},...t?.toolMetadata==null?{}:{toolMetadata:t.toolMetadata}};c.enqueue(n),p.push(n);break}case`tool-input-start`:{let t=q4(e,s.toolName);c.enqueue({...s,dynamic:s.dynamic??t?.type===`dynamic`,title:t?.title,...t?.metadata==null?{}:{toolMetadata:t.metadata}});break}case`stream-start`:c.enqueue({type:`model-call-start`,warnings:s.warnings});break;case`response-metadata`:g=s.id??g,_=s.modelId??_,c.enqueue({type:`model-call-response-metadata`,id:s.id,timestamp:s.timestamp,modelId:s.modelId});break;default:(s.type===`custom`||s.type===`source`)&&p.push(s),c.enqueue(s)}}})}function u8(e){return e.type===`text-delta`&&e.delta.length>0||e.type===`reasoning-delta`&&e.delta.length>0||e.type===`tool-input-delta`&&e.delta.length>0||e.type===`file`||e.type===`reasoning-file`||e.type===`tool-call`}function d8(e){let t=[...e].sort((e,t)=>e-t),n=e.reduce((e,t)=>e+t,0);return{min:t[0],p10:f8(t,.1),median:f8(t,.5),avg:n/e.length,p90:f8(t,.9),max:t[t.length-1]}}function f8(e,t){return e[Math.ceil(t*e.length)-1]}function p8({content:e,partIndexes:t,id:n,type:r,textDelta:i,providerMetadata:a}){let o=t.get(n);o??(o=e.push({type:r,text:``,...a==null?{}:{providerMetadata:a}})-1,t.set(n,o));let s=e[o];i!=null&&(s.text+=i),a!=null&&(s.providerMetadata=a)}var m8=ZJ({prefix:`aitxt`,size:24}),h8=ZJ({prefix:`call`,size:24}),g8={file:!0,custom:!1,source:!1,"text-start":!1,"text-end":!1,"text-delta":!0,"reasoning-start":!1,"reasoning-end":!1,"reasoning-delta":!0,"reasoning-file":!0,"tool-input-start":!1,"tool-input-end":!1,"tool-input-delta":!0,"tool-approval-request":!1,"tool-approval-response":!1,"tool-call":!0,"tool-result":!1,"tool-error":!1,"tool-execution-end":!1,"model-call-start":!1,"model-call-response-metadata":!1,"model-call-end":!1,error:!1,raw:!1};function _8(e){if(!g8[e.type])return!1;switch(e.type){case`text-delta`:case`reasoning-delta`:return e.text.length>0;case`tool-input-delta`:return e.delta.length>0;case`file`:case`reasoning-file`:case`tool-call`:return!0;default:return!1}}function v8({model:e,tools:t,toolChoice:n,instructions:r,system:i,prompt:a,messages:o,allowSystemInMessages:s,maxRetries:c,streamRetries:l,abortSignal:u,timeout:d,headers:f,stopWhen:p=W3(1),experimental_sandbox:m,output:h,toolApproval:g,experimental_toolCallers:_,experimental_toolApprovalSecret:v,experimental_telemetry:y,telemetry:b=y,prepareStep:x,providerOptions:S,activeTools:C,toolOrder:w,experimental_repairToolCall:T,repairToolCall:E=T,experimental_refineToolInput:D,experimental_transform:O,experimental_download:k,includeRawChunks:A,onChunk:j,onError:ee,onFinish:te,onEnd:ne=te,onAbort:re,onStepEnd:M,onStepFinish:N,onStart:ie,experimental_onStart:ae,onStepStart:oe,experimental_onStepStart:se,onLanguageModelCallStart:P,experimental_onLanguageModelCallStart:ce,onLanguageModelCallEnd:le,experimental_onLanguageModelCallEnd:ue,onToolExecutionStart:de,onToolExecutionEnd:fe,experimental_onToolCallStart:pe,experimental_onToolCallFinish:me,runtimeContext:he={},toolsContext:ge={},experimental_include:_e,include:ve=_e,_internal:{now:ye=Y4,generateId:be=m8,generateCallId:xe=h8}={},...Se}){let Ce=m4(d),we=h4(d),Te=g4(d),Ee=_4(d),De=we==null?void 0:new AbortController,Oe=Te==null?void 0:new AbortController,ke=Ee==null?void 0:new AbortController,Ae=ee??(({error:e})=>{console.error(e)}),je=ie??ae,Me=oe??se,Ne=P??ce,Pe=le??ue,Fe=de??pe,Ie=fe??me,Le=M??N;return new w8({model:R2(e),telemetry:b,headers:f,settings:Se,maxRetries:c,streamRetries:l,abortSignal:J4(u,Ce,De?.signal,Oe?.signal,ke?.signal),stepTimeoutMs:we,stepAbortController:De,firstChunkTimeoutMs:Te,firstChunkAbortController:Oe,chunkTimeoutMs:Ee,chunkAbortController:ke,instructions:r,system:i,prompt:a,messages:o,allowSystemInMessages:s,experimental_sandbox:m,tools:t,toolsContext:ge,runtimeContext:he,toolChoice:n,transforms:kq(O),activeTools:C,toolOrder:w,repairToolCall:E,refineToolInput:D,stopConditions:kq(p),output:h,toolApproval:g,experimental_toolCallers:_,experimental_toolApprovalSecret:v,providerOptions:S,prepareStep:x,timeout:d,onChunk:j,onError:Ae,canRetryStreamViaOnError:l!==void 0&&ee!=null,onEnd:ne,onAbort:re,onStepFinish:Le,onStart:je,onStepStart:Me,onLanguageModelCallStart:Ne,onLanguageModelCallEnd:Pe,onToolExecutionStart:Fe,onToolExecutionEnd:Ie,now:ye,generateId:be,generateCallId:xe,download:k,include:{requestBody:ve?.requestBody??!1,requestMessages:ve?.requestMessages??!1,rawChunks:ve?.rawChunks??A??!1}})}var y8=Symbol(`streamRetryBoundary`);function b8(e){return y8 in e}async function x8(e){try{await e}catch{}}function S8(e){let t,n=``,r=``,i,a=``;function o(){t=void 0,n=``,r=``,i=void 0,a=``}function s({controller:e,chunk:t}){e.enqueue(t)}function c({controller:e,partialOutput:n=void 0}){s({controller:e,chunk:{part:{type:`text-delta`,id:t,text:r,providerMetadata:i},partialOutput:n}}),r=``}return new TransformStream({async transform(l,u){if(b8(l)){o(),u.enqueue(l);return}if(l.type===`finish-step`&&r.length>0&&c({controller:u}),l.type!==`text-delta`&&l.type!==`text-start`&&l.type!==`text-end`){s({controller:u,chunk:{part:l,partialOutput:void 0}});return}if(t==null)t=l.id;else if(l.id!==t){s({controller:u,chunk:{part:l,partialOutput:void 0}});return}if(l.type===`text-start`){s({controller:u,chunk:{part:l,partialOutput:void 0}});return}if(l.type===`text-end`){r.length>0&&c({controller:u}),s({controller:u,chunk:{part:l,partialOutput:void 0}});return}if(n+=l.text,r+=l.text,i=l.providerMetadata??i,l.text.length===0&&l.providerMetadata!=null){s({controller:u,chunk:{part:l,partialOutput:void 0}});return}let d=await e.parsePartialOutput({text:n});if(d!==void 0){let e=typeof d.partial==`string`?d.partial:JSON.stringify(d.partial);e!==a&&(c({controller:u,partialOutput:d.partial}),a=e)}}})}function C8({stream:e,transforms:t,tools:n,stopStream:r}){let i=e.getReader(),a=!1,o,s,c=()=>{let e=new ReadableStream({async pull(e){let{done:t,value:n}=await i.read();if(t){a=!0,e.close();return}if(b8(n)){o=n,e.close();return}e.enqueue(n)},cancel(e){return i.cancel(e)}},{highWaterMark:0});for(let i of t)e=e.pipeThrough(i({tools:n,stopStream:r}));return e.getReader()};return new ReadableStream({async pull(e){s??=c();let{done:t,value:n}=await s.read();if(!t){e.enqueue(n);return}if(s=void 0,o!=null){e.enqueue(o),o=void 0;return}a&&e.close()},async cancel(e){await s?.cancel(e),await i.cancel(e)}})}var w8=class{constructor({model:e,telemetry:t,headers:n,settings:r,maxRetries:i,streamRetries:a,abortSignal:o,stepTimeoutMs:s,stepAbortController:c,firstChunkTimeoutMs:l,firstChunkAbortController:u,chunkTimeoutMs:d,chunkAbortController:f,instructions:p,system:m,prompt:h,messages:g,allowSystemInMessages:_,experimental_sandbox:v,tools:y,toolChoice:b,transforms:x,activeTools:S,toolOrder:C,repairToolCall:w,refineToolInput:T,stopConditions:E,output:D,toolApproval:O,experimental_toolCallers:k,experimental_toolApprovalSecret:A,providerOptions:j,prepareStep:ee,now:te,generateId:ne,generateCallId:re,timeout:M,onChunk:N,onError:ie,canRetryStreamViaOnError:ae,onEnd:oe,onAbort:se,onStepFinish:P,onStart:ce,onStepStart:le,onLanguageModelCallStart:ue,onLanguageModelCallEnd:de,onToolExecutionStart:fe,onToolExecutionEnd:pe,runtimeContext:me,toolsContext:he,download:ge,include:_e}){this._totalUsage=new qq,this._finishReason=new qq,this._rawFinishReason=new qq,this._steps=new qq,this._initialResponseMessages=new qq,this.outputSpecification=D,this.tools=y;let ve=X3({tools:y,toolCallers:k}),ye=U3({telemetry:t,includeRuntimeContext:t?.includeRuntimeContext,includeToolsContext:t?.includeToolsContext}),be,xe=[],Se,Ce,we,Te={},Ee=[],De=[],Oe=[],ke=[],Ae,je=[],Me=()=>{let e=new Set;return t=>{if(!e.has(t))return e.add(t),t;let n=ne(),r=n,i=0;for(;e.has(r);)r=`${n}-${++i}`;return e.add(r),r}},Ne=Me(),Pe=Me(),Fe=new Map,Ie=w6(),Le=w6(),Re,ze=new Set,Be=new TransformStream({async transform(t,n){if(b8(t)){let e=t[y8];xe=[],Le=w6(),Ie=w6(),Te=e.request,Ee=e.request.messages??[],De=e.warnings;return}let{part:r}=t;n.enqueue(t);let i=r.type===`error`&&ze.has(r.error);if(i||await X4({event:{chunk:r},callbacks:N}),r.type===`error`){let e=H4(r.error);y0.isInstance(e)&&(Re=e),i?ze.delete(r.error):await X4({event:{error:e},callbacks:async e=>{await ie(e)}})}if((r.type===`custom`||r.type===`source`||r.type===`tool-call`||r.type===`tool-approval-request`||r.type===`tool-approval-response`||r.type===`tool-error`)&&xe.push(r),r.type===`text-start`&&(Ie[r.id]={type:`text`,text:``,providerMetadata:r.providerMetadata},xe.push(Ie[r.id])),r.type===`text-delta`){let e=Ie[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`text part ${r.id} not found`},partialOutput:void 0});return}e.text+=r.text,e.providerMetadata=r.providerMetadata??e.providerMetadata}if(r.type===`text-end`){let e=Ie[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`text part ${r.id} not found`},partialOutput:void 0});return}e.providerMetadata=r.providerMetadata??e.providerMetadata,delete Ie[r.id]}if(r.type===`reasoning-start`&&(Le[r.id]={type:`reasoning`,text:``,providerMetadata:r.providerMetadata},xe.push(Le[r.id])),r.type===`reasoning-delta`){let e=Le[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`reasoning part ${r.id} not found`},partialOutput:void 0});return}e.text+=r.text,e.providerMetadata=r.providerMetadata??e.providerMetadata}if(r.type===`reasoning-end`){let e=Le[r.id];if(e==null){n.enqueue({part:{type:`error`,error:`reasoning part ${r.id} not found`},partialOutput:void 0});return}e.providerMetadata=r.providerMetadata??e.providerMetadata,delete Le[r.id]}if((r.type===`file`||r.type===`reasoning-file`)&&xe.push({type:r.type,file:r.file,...r.providerMetadata==null?{}:{providerMetadata:r.providerMetadata}}),r.type===`tool-result`&&!r.preliminary&&xe.push(r),r.type===`start-step`&&(xe=[],Le=w6(),Ie=w6(),Te=r.request,De=r.warnings),r.type===`finish-step`){let t=await q3({content:xe,tools:y}),n=new R3({callId:Ye,stepNumber:Oe.length,provider:e.provider,modelId:e.modelId,runtimeContext:me,toolsContext:he,content:xe,finishReason:r.finishReason,rawFinishReason:r.rawFinishReason,usage:r.usage,performance:r.performance,warnings:De,request:{...Te,messages:_e.requestMessages?B2(Ee):void 0},response:{...r.response,messages:B2(t)},providerMetadata:r.providerMetadata});await X4({event:n,callbacks:[P,ye.onStepEnd]}),b2({warnings:De,provider:e.provider,model:e.modelId}),Oe.push(n),Ae=[...je,...t],be.resolve()}r.type===`finish`&&(we=r.totalUsage,Se=r.finishReason,Ce=r.rawFinishReason)},async flush(e){try{if(Oe.length===0||Re!=null){let e=o?.aborted?o.reason:Re??new y0({message:`No output generated. Check the stream for errors.`});Je.rejectResultPromises(e);return}let e=Se??`other`,t=we??W4();Je._finishReason.resolve(e),Je._rawFinishReason.resolve(Ce),Je._totalUsage.resolve(t),Je._steps.resolve(Oe);let n=Oe[Oe.length-1],r=Oe.flatMap(e=>e.content),i=Oe.flatMap(e=>e.files),a=Oe.flatMap(e=>e.sources),s=Oe.flatMap(e=>e.toolCalls),c=Oe.flatMap(e=>e.staticToolCalls),l=Oe.flatMap(e=>e.dynamicToolCalls),u=Oe.flatMap(e=>e.toolResults),d=Oe.flatMap(e=>e.staticToolResults),f=Oe.flatMap(e=>e.dynamicToolResults),p=Oe.flatMap(e=>e.warnings??[]),m=oe==null?void 0:async e=>{let t=D==null?void 0:await Je.getOutputPromise().catch(()=>void 0);await oe({...e,...D==null?{}:{output:t}})},h={callId:Ye,toolsContext:n.toolsContext,stepNumber:n.stepNumber,model:n.model,runtimeContext:n.runtimeContext,finishReason:n.finishReason,rawFinishReason:n.rawFinishReason,usage:t,totalUsage:t,content:r,text:n.text,reasoning:n.reasoning,reasoningText:n.reasoningText,files:i,sources:a,toolCalls:s,staticToolCalls:c,dynamicToolCalls:l,toolResults:u,staticToolResults:d,dynamicToolResults:f,responseMessages:[...ke,...Oe.flatMap(e=>e.response.messages)],warnings:p,request:n.request,response:n.response,providerMetadata:n.providerMetadata,steps:Oe,finalStep:n};await Promise.all([X4({event:h,callbacks:m}),X4({event:h,callbacks:ye.onEnd})])}catch(t){e.error(t)}}}),Ve=G6();this.addStream=Ve.addStream,this.closeStream=Ve.close;let He=Ve.stream.getReader(),Ue=new ReadableStream({async start(e){e.enqueue({type:`start`})},async pull(e){async function t(){await X4({event:{callId:Ye,steps:Oe,...o?.reason===void 0?{}:{reason:o.reason}},callbacks:[se,ye.onAbort]}),e.enqueue({type:`abort`,...o?.reason===void 0?{}:{reason:VK(o.reason)}}),e.close()}try{let{done:n,value:r}=await He.read();if(n){e.close();return}if(o?.aborted){await t();return}e.enqueue(r)}catch(n){Xq(n)&&o?.aborted?await t():e.error(n)}},cancel(e){return Ve.stream.cancel(e)}}),We=!0;Ue=Ue.pipeThrough(new TransformStream({async transform(e,t){We&&t.enqueue(e)}})),Ue=C8({stream:Ue,transforms:x,tools:y,stopStream(){Ve.terminate(),We=!1}}),this.baseStream=Ue.pipeThrough(S8(D??d3())).pipeThrough(Be);let{maxRetries:Ge}=$4({maxRetries:i,abortSignal:o}),{maxRetries:Ke}=$4({maxRetries:a,abortSignal:o,parameter:`streamRetries`,defaultMaxRetries:0}),qe=c4(r),Je=this,Ye=re();(async()=>{let t=await V4({instructions:p,system:m,prompt:h,messages:g,allowSystemInMessages:_}),r={callId:Ye,operationId:`ai.streamText`,provider:e.provider,modelId:e.modelId,instructions:t.instructions,messages:t.messages,tools:y,toolChoice:b,activeTools:S,toolOrder:C,maxOutputTokens:qe.maxOutputTokens,temperature:qe.temperature,topP:qe.topP,topK:qe.topK,presencePenalty:qe.presencePenalty,frequencyPenalty:qe.frequencyPenalty,stopSequences:qe.stopSequences,seed:qe.seed,reasoning:qe.reasoning,maxRetries:Ge,timeout:M,headers:n,providerOptions:j,output:D,runtimeContext:me,toolsContext:he},i=ye.startTracingChannelContext?.call(ye,{type:`streamText`,event:r,completion:Je._totalUsage.promise.then(()=>void 0)}),a=e=>i?.run(e)??e(),x=ye.runInTracingChannelSpan==null?void 0:e=>a(()=>ye.runInTracingChannelSpan(e));await X4({event:r,callbacks:[ce,ye.onStart]});let k=t.messages,re=t.instructions,{approvedToolApprovals:oe,deniedToolApprovals:se}=n3({messages:k});if(se.length>0||oe.length>0){let{approvedToolApprovals:e,deniedToolApprovals:t,invalidToolApprovals:n}=await u6({approvedToolApprovals:oe.filter(e=>!e.toolCall.providerExecuted),tools:y,toolApproval:O,messages:k,toolsContext:he,runtimeContext:me,toolApprovalSecret:A}),r=[...se.filter(e=>!e.toolCall.providerExecuted),...t],i=r.filter(e=>e.existingToolResult==null),a=se.filter(e=>e.toolCall.providerExecuted),s,c=new ReadableStream({start(e){s=e}});Je.addStream(c);try{for(let e of[...r,...a])s?.enqueue({type:`tool-output-denied`,toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName});for(let e of n)s?.enqueue({type:`tool-error`,toolCallId:e.toolCall.toolCallId,toolName:e.toolCall.toolName,input:e.toolCall.input,error:VK(e.error),title:e.toolCall.title,...e.toolCall.dynamic===!0?{dynamic:!0}:{},...e.toolCall.toolMetadata==null?{}:{toolMetadata:e.toolCall.toolMetadata}});let t=[];if(await Promise.all(e.map(async e=>{let n=await o3({toolCall:e.toolCall,tools:y,callId:Ye,messages:k,abortSignal:o,timeout:M,experimental_sandbox:v,toolsContext:he,onToolExecutionStart:XJ(fe,ye.onToolExecutionStart),onToolExecutionEnd:XJ(pe,ye.onToolExecutionEnd),executeToolInTelemetryContext:ye.executeTool,runInTracingChannelSpan:x,onPreliminaryToolResult:e=>{s?.enqueue(e)}});n!=null&&(s?.enqueue(n.output),t.push(n.output))})),t.length>0||i.length>0||n.length>0){let e=[];for(let n of t)e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:n.toolName,output:await o4({toolCallId:n.toolCallId,input:n.input,tool:q4(y,n.toolName),output:n.type===`tool-result`?n.output:n.error,errorMode:n.type===`tool-error`?`text`:`none`})});for(let t of n)e.push({type:`tool-result`,toolCallId:t.toolCall.toolCallId,toolName:t.toolCall.toolName,output:await o4({toolCallId:t.toolCall.toolCallId,input:t.toolCall.input,tool:q4(y,t.toolCall.toolName),output:t.error,errorMode:`text`})});for(let t of i)e.push({type:`tool-result`,toolCallId:t.toolCall.toolCallId,toolName:t.toolCall.toolName,output:{type:`execution-denied`,reason:t.approvalResponse.reason}});ke.push({role:`tool`,content:e})}}finally{s?.close()}}Je._initialResponseMessages.resolve(ke);async function P({currentStep:r,usage:i}){let p=e3({abortController:c,label:`Step`,timeoutMs:s}),m;function h(){o?.aborted||(m=e3({abortController:u,label:`First chunk`,timeoutMs:l}))}function g(){m!=null&&(clearTimeout(m),m=void 0)}let x;function oe(){x!=null&&clearTimeout(x),x=e3({abortController:f,label:`Chunk`,timeoutMs:d})}function se(){x!=null&&(clearTimeout(x),x=void 0)}function ce(){p!=null&&clearTimeout(p)}function xe(){ce(),g(),se()}function Se(){o?.removeEventListener(`abort`,Se),xe()}o?.addEventListener(`abort`,Se,{once:!0});try{be=new qq;let s=ye.startTracingChannelContext?.call(ye,{type:`step`,event:{callId:Ye,stepNumber:r},completion:be.promise}),c=e=>s?.run(e)??e(),l=Oe.flatMap(e=>e.response.messages),u=[...ke,...l],d=Ae??[...k,...ke],f=await ee?.({model:e,steps:Oe,stepNumber:Oe.length,instructions:re,initialInstructions:t.instructions,messages:d,initialMessages:k,responseMessages:u,toolsContext:he,runtimeContext:me,experimental_sandbox:v}),p=f?.experimental_sandbox??v;me=f?.runtimeContext??me,he=f?.toolsContext??he;let m=R2(f?.model??e),{executionTools:x,modelTools:se}=Z3({tools:s3({tools:y,activeTools:f?.activeTools??S}),toolCallers:ve}),ce=f?.toolOrder??C,xe=await d4({tools:se,toolOrder:ce,toolsContext:he,experimental_sandbox:p}),Ce=l4({toolChoice:f?.toolChoice??b}),we=f?.messages??d;je=we;let Te=f?.instructions??f?.system??re;re=Te;let De=G2(j,f?.providerOptions),Me=b3({callSettings:qe,stepSettings:f}),Ie=te(),{retry:Le}=$4({maxRetries:Ge,abortSignal:o}),Re=!1,Be=()=>c(()=>Le(async()=>c8({model:f?.model??e,tools:se,toolOrder:ce,toolChoice:f?.toolChoice??b,instructions:Te,messages:we,allowSystemInMessages:_,repairToolCall:w,refineToolInput:T,abortSignal:o,headers:n,includeRawChunks:_e.rawChunks,providerOptions:De,download:ge,output:D,callId:Ye,executeLanguageModelCallInTelemetryContext:ye.executeLanguageModelCall,toolsContext:he,experimental_sandbox:p,onLanguageModelCallStart:XJ(ue,ye.onLanguageModelCallStart),onLanguageModelCallEnd:XJ(de,ye.onLanguageModelCallEnd),onStart:async({promptMessages:e})=>{Re||(Re=!0,await X4({event:{callId:Ye,provider:m.provider,modelId:m.modelId,stepNumber:Oe.length,instructions:Te,messages:we,tools:y,toolChoice:f?.toolChoice??b,activeTools:f?.activeTools??S,toolOrder:ce,steps:[...Oe],providerOptions:De,runtimeContext:me,toolsContext:he,output:D,promptMessages:e,stepTools:xe,stepToolChoice:Ce},callbacks:[le,ye.onStepStart]}))},_internal:{now:te},...Me}))),Ve=await Be(),He=Ve.request,Ue=Ve.response,We=Ve.stream.getReader(),Xe=0,Ze=0,Qe=[],$e=new WeakSet,et=new Set,tt=new Set,nt=!1,rt=Ke>0||ae,it=new ReadableStream({async pull(e){let t=t=>{switch(t.type){case`text-start`:et.add(t.id);break;case`text-end`:et.delete(t.id);break;case`reasoning-start`:tt.add(t.id);break;case`reasoning-end`:tt.delete(t.id)}e.enqueue(t)},n=()=>{for(let e of Qe)t(e);Qe=[]},r=()=>{for(let t of et)e.enqueue({type:`text-end`,id:t});et.clear();for(let t of tt)e.enqueue({type:`reasoning-end`,id:t});tt.clear()};for(;;){let{done:i,value:a}=await We.read();if(nt&&=(e.enqueue(q6({warnings:!i&&a.type===`model-call-start`?a.warnings:[]})),!1),i){n(),e.close();return}let o=a.type===`tool-input-start`||a.type===`tool-input-delta`||a.type===`tool-input-end`||a.type===`tool-call`||a.type===`tool-approval-request`||a.type===`tool-approval-response`||a.type===`tool-result`||a.type===`tool-error`;if(a.type===`model-call-end`){n(),t(a);return}if(rt&&a.type!==`error`&&(o||Qe.length>0)){_8(a)&&(g(),oe(),$e.add(a)),Qe.push(a);continue}if(a.type!==`error`){t(a);return}await X4({event:{chunk:a},callbacks:N});let s=H4(a.error),c;try{c=await ie({error:s})}catch{}let l=ae&&typeof c==`object`&&!!c&&`retry`in c&&c.retry===!0,u=Xe<Ke;if(!u&&!(!u&&l&&Ze<1)){n(),ze.add(a.error),e.enqueue(a);return}u?Xe++:Ze++,await We.cancel(s),Qe=[],r();let d;try{d=await Be()}catch(t){e.enqueue({type:`error`,error:t}),e.close();return}He=d.request,Ue=d.response,We=d.stream.getReader(),nt=!0}},cancel(e){return We.cancel(e)}});h();let at=X6({stream:it,tools:x,stepInputMessages:we,abortSignal:o,runtimeContext:me}),ot=ye.runInTracingChannelSpan==null?void 0:e=>c(()=>ye.runInTracingChannelSpan(e)),st=Y6({stream:at,tools:x,callId:Ye,messages:we,abortSignal:o,timeout:M,experimental_sandbox:p,toolsContext:he,toolApproval:O,runtimeContext:me,toolApprovalSecret:A,generateId:ne,onToolExecutionStart:XJ(fe,ye.onToolExecutionStart),onToolExecutionEnd:XJ(pe,ye.onToolExecutionEnd),executeToolInTelemetryContext:ye.executeTool,runInTracingChannelSpan:ot}),ct=()=>({...He,body:_e.requestBody?He?.body:void 0,messages:_e.requestMessages?B2(we):void 0});Ee=ct().messages??[];let F=[],lt=[],ut=[],dt,ft=`other`,pt,mt=!1,ht=!1,gt=W4(),_t,vt=!0,yt=()=>({responseTimeMs:0,effectiveOutputTokensPerSecond:0,outputTokensPerSecond:void 0,inputTokensPerSecond:void 0,effectiveTotalTokensPerSecond:0,timeToFirstOutputMs:void 0,timeBetweenOutputChunksMs:void 0}),bt=yt(),xt={},St=()=>({id:ne(),timestamp:new Date,modelId:e.modelId}),Ct=St(),wt=new Map,Tt=new Map,Et=(e,t)=>{e.enqueue(t)};Je.addStream(st.pipeThrough(new TransformStream({async transform(e,t){if(J6(e)){dt=e.warnings,ft=`other`,pt=void 0,mt=!1,ht=!1,gt=W4(),_t=void 0,bt=yt(),Ct=St(),wt.clear(),Tt.clear(),t.enqueue({[y8]:{request:ct(),warnings:dt}});return}if(e.type===`model-call-start`){dt=e.warnings;return}vt&&(vt=!1,Et(t,{type:`start-step`,request:ct(),warnings:dt??[]}));let n=e.type;if(_8(e)){let t=$e.has(e);!ht&&!t&&g(),ht=!0,t||oe()}switch(n){case`file`:case`custom`:case`source`:case`reasoning-file`:case`tool-input-start`:case`tool-input-end`:case`tool-input-delta`:case`tool-approval-request`:Et(t,e);break;case`text-start`:{let n=Ne(e.id);wt.set(e.id,n),Et(t,{...e,id:n});break}case`text-delta`:(e.text.length>0||e.providerMetadata!=null)&&Et(t,{...e,id:wt.get(e.id)??e.id});break;case`text-end`:Et(t,{...e,id:wt.get(e.id)??e.id}),wt.delete(e.id);break;case`reasoning-start`:{let n=Pe(e.id);Tt.set(e.id,n),Et(t,{...e,id:n});break}case`reasoning-delta`:Et(t,{...e,id:Tt.get(e.id)??e.id});break;case`reasoning-end`:Et(t,{...e,id:Tt.get(e.id)??e.id}),Tt.delete(e.id);break;case`tool-call`:Et(t,e),F.push(e);break;case`tool-approval-response`:Et(t,e),ut.push(e);break;case`tool-result`:Et(t,e),e.preliminary||lt.push(e);break;case`tool-error`:Et(t,e),lt.push(e);break;case`tool-execution-end`:xt[e.toolCallId]=e.toolExecutionMs;break;case`model-call-response-metadata`:Ct={id:e.id??Ct.id,timestamp:e.timestamp??Ct.timestamp,modelId:e.modelId??Ct.modelId};break;case`model-call-end`:mt=!0,gt=e.usage,ft=e.finishReason,pt=e.rawFinishReason,_t=e.providerMetadata,bt=e.performance;break;case`error`:mt=!0,Et(t,e),ft=`error`;break;case`raw`:_e.rawChunks&&Et(t,e);break;default:throw Error(`Unknown chunk type: ${n}`)}},async flush(e){if(!mt&&!ht){Et(e,{type:`error`,error:new y0({message:`No output generated. The model stream ended without a finish chunk.`})}),Se(),Je.closeStream();return}let t=te()-Ie,n={type:`finish-step`,finishReason:ft,rawFinishReason:pt,usage:gt,performance:{stepTimeMs:t,toolExecutionMs:xt,...bt},providerMetadata:_t,response:{...Ct,headers:Ue?.headers}};Et(e,n);let o=G4(i,gt);await be.promise;let s=F.filter(e=>e.providerExecuted!==!0),c=lt.filter(e=>e.providerExecuted!==!0),l=ut.filter(e=>e.approved===!1);for(let e of F){if(e.providerExecuted!==!0)continue;let t=q4(x,e.toolName);t?.type===`provider`&&t.supportsDeferredResults&&(lt.some(t=>(t.type===`tool-result`||t.type===`tool-error`)&&t.toolCallId===e.toolCallId)||Fe.set(e.toolCallId,{toolName:e.toolName}))}for(let e of lt)(e.type===`tool-result`||e.type===`tool-error`)&&Fe.delete(e.toolCallId);if(Se(),s.length===c.length+l.length&&(s.length>0||Fe.size>0)&&!await G3({stopConditions:E,steps:Oe}))try{await a(()=>P({currentStep:r+1,usage:o}))}catch(t){Et(e,{type:`error`,error:t}),Je.closeStream()}else Et(e,{type:`finish`,finishReason:ft,rawFinishReason:pt,totalUsage:o}),Je.closeStream()}})),{onError:Se,onCancel:Se})}catch(e){throw Se(),e}}await a(()=>P({currentStep:0,usage:W4()}))})().catch(async e=>{await ye.onError?.call(ye,{callId:Ye,error:e}),Je._initialResponseMessages.reject(e),x8(Je._initialResponseMessages.promise),Je.addStream(new ReadableStream({start(t){t.enqueue({type:`error`,error:e}),t.close()}})),Je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e.at(-1))}get content(){return this.steps.then(e=>e.flatMap(e=>e.content))}get warnings(){return this.steps.then(e=>e.flatMap(e=>e.warnings??[]))}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>C3(e.reasoning))}get sources(){return this.steps.then(e=>e.flatMap(e=>e.sources))}get files(){return this.steps.then(e=>e.flatMap(e=>e.files))}get toolCalls(){return this.steps.then(e=>e.flatMap(e=>e.toolCalls))}get staticToolCalls(){return this.steps.then(e=>e.flatMap(e=>e.staticToolCalls))}get dynamicToolCalls(){return this.steps.then(e=>e.flatMap(e=>e.dynamicToolCalls))}get toolResults(){return this.steps.then(e=>e.flatMap(e=>e.toolResults))}get staticToolResults(){return this.steps.then(e=>e.flatMap(e=>e.staticToolResults))}get dynamicToolResults(){return this.steps.then(e=>e.flatMap(e=>e.dynamicToolResults))}get usage(){return this.totalUsage}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get responseMessages(){return Promise.all([this._initialResponseMessages.promise,this.steps]).then(([e,t])=>[...e,...t.flatMap(e=>e.response.messages)])}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}get rawFinishReason(){return this.consumeStream(),this._rawFinishReason.promise}teeStream(){let[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return V6(h6({stream:this.stream}))}get stream(){return V6(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}get fullStream(){return this.stream}rejectResultPromises(e){this.rejectResultPromise({delayedPromise:this._finishReason,error:e}),this.rejectResultPromise({delayedPromise:this._rawFinishReason,error:e}),this.rejectResultPromise({delayedPromise:this._totalUsage,error:e}),this.rejectResultPromise({delayedPromise:this._steps,error:e}),this.rejectResultPromise({delayedPromise:this._initialResponseMessages,error:e})}rejectResultPromise({delayedPromise:e,error:t}){e.isPending()&&(e.reject(t),x8(e.promise))}async consumeStream(e){var t;try{await U6({stream:this.stream,onError:t=>{var n;this.rejectResultPromises(t),(n=e?.onError)==null||n.call(e,t)}})}catch(n){this.rejectResultPromises(n),(t=e?.onError)==null||t.call(e,n)}}get experimental_partialOutputStream(){return this.partialOutputStream}get partialOutputStream(){return V6(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}get elementStream(){let e=this.outputSpecification?.createElementStreamTransform();if(e==null)throw new _q({functionality:`element streams in ${this.outputSpecification?.name??`text`} mode`});return V6(this.teeStream().pipeThrough(e))}getOutputPromise(){return this.outputPromise??=this.finalStep.then(e=>(this.outputSpecification??d3()).parseCompleteOutput({text:e.text},{response:e.response,usage:e.usage,finishReason:e.finishReason})),this.outputPromise}get output(){return this.getOutputPromise()}toUIMessageStream({originalMessages:e,generateMessageId:t,onEnd:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendStart:s,sendFinish:c,onError:l}={}){return V6(B6({stream:this.stream,tools:this.tools,originalMessages:e,generateMessageId:t,onEnd:n??r,messageMetadata:i,sendReasoning:a,sendSources:o,sendStart:s,sendFinish:c,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:n,onEnd:r,onFinish:i,messageMetadata:a,sendReasoning:o,sendSources:s,sendFinish:c,sendStart:l,onError:u,...d}={}){return y6({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:n,onEnd:r??i,messageMetadata:a,sendReasoning:o,sendSources:s,sendFinish:c,sendStart:l,onError:u}),...d})}pipeTextStreamToResponse(e,t){return m6({response:e,stream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onEnd:n,onFinish:r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l,...u}={}){return v6({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onEnd:n??r,messageMetadata:i,sendReasoning:a,sendSources:o,sendFinish:s,sendStart:c,onError:l}),...u})}toTextStreamResponse(e){return f6({stream:this.textStream,...e})}};async function T8(e,t){let n=[];t?.ignoreIncompleteToolCalls&&(e=e.map(e=>({...e,parts:e.parts.filter(e=>!N6(e)||e.state===`approval-responded`||e.state===`output-available`&&e.preliminary!==!0||e.state===`output-error`||e.state===`output-denied`)})));for(let r of e)switch(r.role){case`system`:{let e=r.parts.filter(e=>e.type===`text`),t=e.reduce((e,t)=>t.providerMetadata==null?e:{...e,...t.providerMetadata},{});n.push({role:`system`,content:e.map(e=>e.text).join(``),...Object.keys(t).length>0?{providerOptions:t}:{}});break}case`user`:n.push({role:`user`,content:r.parts.map(e=>{if(E6(e))return{type:`text`,text:e.text,...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(O6(e))return{type:`file`,mediaType:e.mediaType,filename:e.filename,data:e.providerReference==null?{type:`url`,url:new URL(e.url)}:{type:`reference`,reference:e.providerReference},...e.providerMetadata==null?{}:{providerOptions:e.providerMetadata}};if(T6(e))return(t?.convertDataPart)?.call(t,e)}).filter(nY)});break;case`assistant`:if(r.parts!=null){let e=[];async function i(){if(e.length===0)return;let r=[];for(let n of e)if(E6(n))r.push({type:`text`,text:n.text,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(D6(n))r.push({type:`custom`,kind:n.kind,...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(O6(n))r.push({type:`file`,mediaType:n.mediaType,filename:n.filename,data:n.providerReference==null?{type:`url`,url:new URL(n.url)}:{type:`reference`,reference:n.providerReference},...n.providerMetadata==null?{}:{providerOptions:n.providerMetadata}});else if(k6(n))r.push({type:`reasoning-file`,data:{type:`url`,url:new URL(n.url)},mediaType:n.mediaType,providerOptions:n.providerMetadata});else if(A6(n))r.push({type:`reasoning`,text:n.text,providerOptions:n.providerMetadata});else if(N6(n)){let e=F6(n);if(n.state!==`input-streaming`&&(r.push({type:`tool-call`,toolCallId:n.toolCallId,toolName:e,input:n.state===`output-error`?n.input??(`rawInput`in n?n.rawInput:void 0):n.input,providerExecuted:n.providerExecuted,...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}}),n.approval!=null&&r.push({type:`tool-approval-request`,approvalId:n.approval.id,toolCallId:n.toolCallId,isAutomatic:n.approval.isAutomatic,...n.approval.requestReason==null?{}:{reason:n.approval.requestReason},...n.approval.signature==null?{}:{signature:n.approval.signature}}),n.providerExecuted===!0&&n.state!==`approval-responded`&&(n.state===`output-available`||n.state===`output-error`))){let i=n.resultProviderMetadata??n.callProviderMetadata;r.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:e,output:await o4({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:q4(t?.tools,e),errorMode:n.state===`output-error`?`json`:`none`}),...i==null?{}:{providerOptions:i}})}}else if(T6(n)){let e=(t?.convertDataPart)?.call(t,n);e!=null&&r.push(e)}else throw Error(`Unsupported part: ${n}`);r.length>0&&n.push({role:`assistant`,content:r});let i=e.filter(e=>N6(e)&&(e.providerExecuted!==!0||e.approval?.approved!=null));if(i.length>0){let e=[];for(let n of i)if(n.approval?.approved!=null&&e.push({type:`tool-approval-response`,approvalId:n.approval.id,approved:n.approval.approved,reason:n.approval.reason,providerExecuted:n.providerExecuted}),n.state===`approval-responded`&&n.approval?.approved===!1&&e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:F6(n),output:{type:`execution-denied`,reason:n.approval.reason},...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}}),n.providerExecuted!==!0)switch(n.state){case`output-denied`:e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:F6(n),output:{type:`error-text`,value:n.approval?.reason??`Tool call execution denied.`},...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break;case`output-error`:case`output-available`:{let r=F6(n);e.push({type:`tool-result`,toolCallId:n.toolCallId,toolName:r,output:await o4({toolCallId:n.toolCallId,input:n.input,output:n.state===`output-error`?n.errorText:n.output,tool:q4(t?.tools,r),errorMode:n.state===`output-error`?`text`:`none`}),...n.callProviderMetadata==null?{}:{providerOptions:n.callProviderMetadata}});break}}e.length>0&&n.push({role:`tool`,content:e})}e=[]}for(let t of r.parts)D6(t)||E6(t)||A6(t)||k6(t)||O6(t)||N6(t)||T6(t)?e.push(t):t.type===`step-start`&&await i();await i();break}break;default:{let e=r.role;throw new l2({originalMessage:r,message:`Unsupported role: ${e}`})}}return n}J.record(J.string(),y4.optional()),J.record(J.string(),J.string()),ZJ({prefix:`call`,size:24}),ZJ({prefix:`call`,size:24}),new TextEncoder,ZJ({prefix:`aiobj`,size:24});var E8=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{await e(),t()}catch(e){n(e)}}),this.processQueue()})}};ZJ({prefix:`aiobj`,size:24}),ZJ({prefix:`call`,size:24});async function D8(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw Error(`FileList is not supported in the current environment`);return Promise.all(Array.from(e).map(async e=>{let{name:t,type:n}=e;return{type:`file`,mediaType:n,filename:t,url:await new Promise((t,n)=>{let r=new FileReader;r.onload=e=>{t(e.target?.result)},r.onerror=e=>n(e),r.readAsDataURL(e)})}}))}var O8=class{constructor({api:e=`/api/chat`,credentials:t,headers:n,body:r,fetch:i,prepareSendMessagesRequest:a,prepareReconnectToStreamRequest:o}){this.api=e,this.credentials=t,this.headers=n,this.body=r,this.fetch=i,this.prepareSendMessagesRequest=a,this.prepareReconnectToStreamRequest=o}async sendMessages({abortSignal:e,...t}){let n=await RX(this.body),r=await RX(this.headers),i=await RX(this.credentials),a={...nJ(r),...nJ(t.headers)},o=await this.prepareSendMessagesRequest?.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...n,...t.body},headers:a,credentials:i,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId}),s=o?.api??this.api,c=o?.headers===void 0?a:nJ(o.headers),l=o?.body===void 0?{...n,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId}:o.body,u=o?.credentials??i,d=await(this.fetch??globalThis.fetch)(s,{method:`POST`,headers:{"Content-Type":`application/json`,...c},body:JSON.stringify(l),credentials:u,signal:e});if(!d.ok)throw Error(await d.text()??`Failed to fetch the chat response.`);if(!d.body)throw Error(`The response body is empty.`);return this.processResponseStream(d.body)}async reconnectToStream(e){let t=await RX(this.body),n=await RX(this.headers),r=await RX(this.credentials),i={...nJ(n),...nJ(e.headers)},a=await this.prepareReconnectToStreamRequest?.call(this,{api:this.api,id:e.chatId,body:{...t,...e.body},headers:i,credentials:r,requestMetadata:e.metadata}),o=a?.api??`${this.api}/${e.chatId}/stream`,s=a?.headers===void 0?i:nJ(a.headers),c=a?.credentials??r,l=await(this.fetch??globalThis.fetch)(o,{method:`GET`,headers:s,credentials:c,signal:e.abortSignal});if(l.status===204)return null;if(!l.ok)throw Error(await l.text()??`Failed to fetch the chat response.`);if(!l.body)throw Error(`The response body is empty.`);return this.processResponseStream(l.body)}},k8=class extends O8{constructor(e={}){super(e)}processResponseStream(e){return MX({stream:e,schema:S6}).pipeThrough(new TransformStream({async transform(e,t){if(!e.success)throw e.error;t.enqueue(e.value)}}))}},A8=class{constructor({generateId:e=QJ,id:t=e(),transport:n=new k8,messageMetadataSchema:r,dataPartSchemas:i,state:a,onError:o,onToolCall:s,onFinish:c,onData:l,sendAutomaticallyWhen:u}){this.pendingMessagePreparations=new Set,this.activeResponse=void 0,this.activeResumeRequest=void 0,this.jobExecutor=new E8,this.sendMessage=async(e,t)=>{if(e==null){await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...t});return}let n;if(`text`in e||`files`in e){let t=new AbortController;this.pendingMessagePreparations.add(t);let r;try{r=Array.isArray(e.files)?e.files:await D8(e.files)}finally{this.pendingMessagePreparations.delete(t)}if(t.signal.aborted)return;n={parts:[...r,...`text`in e&&e.text!=null?[{type:`text`,text:e.text}]:[]]}}else n=e;if(e.messageId!=null){let t=this.state.messages.findIndex(t=>t.id===e.messageId);if(t===-1)throw Error(`message with id ${e.messageId} not found`);if(this.state.messages[t].role!==`user`)throw Error(`message with id ${e.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,t+1),this.state.replaceMessage(t,{...n,id:e.messageId,role:n.role??`user`,metadata:e.metadata})}else this.state.pushMessage({...n,id:n.id??this.generateId(),role:n.role??`user`,metadata:e.metadata});await this.makeRequest({trigger:`submit-message`,messageId:e.messageId,...t})},this.regenerate=async({messageId:e,...t}={})=>{let n=e==null?this.state.messages.length-1:this.state.messages.findIndex(t=>t.id===e);if(n===-1)throw Error(`message ${e} not found`);this.state.messages=this.state.messages.slice(0,this.messages[n].role===`assistant`?n:n+1),await this.makeRequest({trigger:`regenerate-message`,messageId:e,...t})},this.resumeStream=async(e={})=>{await this.makeRequest({trigger:`resume-stream`,...e})},this.clearError=()=>{this.status===`error`&&(this.state.error=void 0,this.setStatus({status:`ready`}))},this.addToolApprovalResponse=async({id:e,approved:t,reason:n,options:r})=>this.jobExecutor.run(async()=>{let i=this.state.messages,a=i[i.length-1],o=r=>N6(r)&&r.state===`approval-requested`&&r.approval.id===e?{...r,state:`approval-responded`,approval:{...r.approval,id:e,approved:t,reason:n}}:r;this.state.replaceMessage(i.length-1,{...a,parts:a.parts.map(o)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(o)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...r})})}),this.addToolOutput=async({state:e=`output-available`,toolCallId:t,output:n,errorText:r,options:i})=>this.jobExecutor.run(async()=>{let a=this.state.messages,o=a[a.length-1],s=i=>N6(i)&&i.toolCallId===t?{...i,state:e,output:n,errorText:r}:i;this.state.replaceMessage(a.length-1,{...o,parts:o.parts.map(s)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(s)),this.status!==`streaming`&&this.status!==`submitted`&&this.sendAutomaticallyWhen&&this.shouldSendAutomatically().then(e=>{e&&this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,...i})})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var e,t;for(let e of this.pendingMessagePreparations)e.abort();(e=this.activeResumeRequest)==null||e.abortController.abort(),(t=this.activeResponse)==null||t.abortController.abort()},this.id=t,this.transport=n,this.generateId=e,this.messageMetadataSchema=r,this.dataPartSchemas=i,this.state=a,this.onError=o,this.onToolCall=s,this.onFinish=c,this.onData=l,this.sendAutomaticallyWhen=u}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async shouldSendAutomatically(){if(!this.sendAutomaticallyWhen)return!1;let e=this.sendAutomaticallyWhen({messages:this.state.messages});return e&&typeof e==`object`&&`then`in e?await e:e}async makeRequest({trigger:e,metadata:t,headers:n,body:r,messageId:i}){var a,o;let s=new AbortController,c=e===`resume-stream`?{abortController:s}:void 0;c&&((a=this.activeResumeRequest)==null||a.abortController.abort(),this.activeResumeRequest=c);let l=()=>c==null||this.activeResumeRequest===c,u=()=>{this.activeResumeRequest===c&&(this.activeResumeRequest=void 0)},d;if(e===`resume-stream`)try{let e=await this.transport.reconnectToStream({chatId:this.id,abortSignal:s.signal,metadata:t,headers:n,body:r});if(s.signal.aborted||!l()){await e?.cancel().catch(()=>{}),l()&&this.setStatus({status:`ready`}),u();return}if(e==null){this.setStatus({status:`ready`}),u();return}d=e}catch(e){if(s.signal.aborted||e.name===`AbortError`){l()&&this.setStatus({status:`ready`}),u();return}if(!l())return;this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e}),u();return}this.setStatus({status:`submitted`,error:void 0});let f=this.lastMessage,p=!1,m=!1,h=!1,g;try{let a={state:I6({lastMessage:e===`resume-stream`||e===`regenerate-message`?void 0:this.state.snapshot(f),messageId:this.generateId()}),abortController:s};g=a,a.abortController.signal.addEventListener(`abort`,()=>{p=!0}),this.activeResponse=a;let o;if(o=e===`resume-stream`?d:await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:a.abortController.signal,metadata:t,headers:n,body:r,trigger:e,messageId:i}),await U6({stream:L6({stream:o,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:e=>this.jobExecutor.run(()=>a.abortController.signal.aborted?Promise.resolve():e({state:a.state,write:({updateStatus:e=!0}={})=>{a.abortController.signal.aborted||(e&&this.setStatus({status:`streaming`}),a.state.message.id===this.lastMessage?.id?this.state.replaceMessage(this.state.messages.length-1,a.state.message):this.state.pushMessage(a.state.message))}})),onError:e=>{throw e}}),abortSignal:a.abortController.signal,onError:e=>{throw e}}),p)return l()&&this.setStatus({status:`ready`}),null;l()&&this.setStatus({status:`ready`})}catch(e){if(p||e.name===`AbortError`)return p=!0,l()&&this.setStatus({status:`ready`}),null;if(!l())return null;h=!0,e instanceof TypeError&&(e.message.toLowerCase().includes(`fetch`)||e.message.toLowerCase().includes(`network`))&&(m=!0),this.onError&&e instanceof Error&&this.onError(e),this.setStatus({status:`error`,error:e})}finally{try{g&&((o=this.onFinish)==null||o.call(this,{message:g.state.message,messages:this.state.messages,isAbort:p,isDisconnect:m,isError:h,finishReason:g.state.finishReason}))}finally{this.activeResponse===g&&(this.activeResponse=void 0),u()}}!h&&await this.shouldSendAutomatically()&&await this.makeRequest({trigger:`submit-message`,messageId:this.lastMessage?.id,metadata:t,headers:n,body:r})}},j8={accept:`*`,async add({file:e}){return{id:QJ(),type:e.type.startsWith(`image/`)?`image`:`file`,name:e.name,file:e,contentType:e.type,content:[],status:{type:`requires-action`,reason:`composer-send`}}},async send(e){return{...e,status:{type:`complete`},content:[{type:`file`,mimeType:e.contentType??``,filename:e.name,data:await IE(e.file)}]}},async remove(){}},M8=e=>OC(e),N8=`__aui_modelContent`;function P8(e){return typeof e==`object`&&!!e&&N8 in e&&Array.isArray(e[N8])}function F8(e,t){return{[N8]:t,value:e}}function I8(e){return P8(e)?{result:e.value,modelContent:e[N8]}:{result:e}}var L8=new Set([`unstable_state`,`unstable_annotations`,`unstable_data`,`steps`,`timing`,`submittedFeedback`,`isOptimistic`,`custom`]),R8=e=>{if(!e||typeof e!=`object`)return;let t={},n={};for(let[r,i]of Object.entries(e))(L8.has(r)?t:n)[r]=i;return Object.keys(n).length>0&&(t.custom={...n,...t.custom}),t};function z8(e){return e.replace(/[}\]"]+$/,``)}var B8=100;function V8(e,t){if(!e||typeof e!=`object`)return;let n=e.callProviderMetadata,r=n&&typeof n==`object`?n.mcp:void 0,i=r&&typeof r==`object`?r.app:void 0,a;if(i&&typeof i==`object`)a=i;else{let t=e.output,n=t&&typeof t==`object`?t._meta:void 0,r=n&&typeof n==`object`?n.ui:void 0;if(r&&typeof r==`object`&&typeof r.resourceUri==`string`&&VT(r.resourceUri)){let e=r;a={resourceUri:e.resourceUri,...Array.isArray(e.visibility)?{visibility:e.visibility}:{}}}else{let e=n&&typeof n==`object`?n[`ui/resourceUri`]:void 0;if(typeof e!=`string`||!VT(e))return;a={resourceUri:e}}}if(typeof a.resourceUri!=`string`||!VT(a.resourceUri))return;let o=`${typeof a.serverId==`string`?a.serverId:``} ${a.resourceUri}`,s=t?.get(o);if(s)return t.delete(o),t.set(o,s),s;let c={resourceUri:a.resourceUri};if(typeof a.mimeType==`string`&&(c.mimeType=a.mimeType),Array.isArray(a.visibility)&&(c.visibility=a.visibility.filter(e=>e===`model`||e===`app`)),typeof a.serverId==`string`&&a.serverId.length>0&&(c.serverId=a.serverId),t){if(t.size>=B8){let e=t.keys().next().value;e!==void 0&&t.delete(e)}t.set(o,c)}return c}function H8(e,t){if(e.approval&&typeof e.approval.id==`string`){let{id:t,approved:n,reason:r,isAutomatic:i}=e.approval;return{approval:{id:t,...typeof n==`boolean`&&{approved:n},...typeof r==`string`&&{reason:r},...i===!0&&{isAutomatic:!0}}}}return t?.type===`interrupt`?{interrupt:t.payload}:{}}var U8=e=>{if(e===`streaming`)return{type:`running`};if(e===`done`)return{type:`complete`}};function W8(e,t){if(!e.parts||e.parts.length===0)return[];let n=e.parts.filter(t=>t.type!==`step-start`&&(e.role!==`user`||t.type!==`file`)).map(n=>{if(n.type===`text`){let e=U8(n.state);return{type:`text`,text:n.text,...e==null?void 0:{status:e},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}}if(n.type===`reasoning`){let e=U8(n.state);return{type:`reasoning`,text:n.text,...e==null?void 0:{status:e},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}}if(N6(n)){let r=F6(n),i=n.toolCallId,a=`${e.id}:${i}`,o=n.input,s;typeof o==`object`&&o&&!Array.isArray(o)?(s=o,t.toolLastInputCache?.set(a,s)):s=t.toolLastInputCache?.get(a)??{};let c,l,u=!1;if(n.state===`output-available`){let e=I8(n.output);c=e.result,l=e.modelContent}else n.state===`output-error`?(u=!0,c={error:n.errorText}):n.state===`output-denied`&&(u=!0,c={error:n.approval?.reason||`Tool approval denied`});let d=Mj(t.toolArgsKeyOrderCache,a,s);n.state===`input-streaming`?(d=z8(d),s=yC(d)??s):(t.toolArgsKeyOrderCache?.delete(a),(n.state===`output-available`||n.state===`output-error`||n.state===`output-denied`)&&t.toolLastInputCache?.delete(a));let f=t.toolStatuses?.[i],p=V8(n,t.mcpAppMetadataCache);return{type:`tool-call`,toolName:r,toolCallId:i,argsText:d,args:s,result:c,isError:u,...l!==void 0&&{modelContent:l},...p&&{mcp:{app:p}},...n.callProviderMetadata==null?void 0:{providerMetadata:n.callProviderMetadata},...H8(n,f)}}return n.type===`source-url`?{type:`source`,sourceType:`url`,id:n.sourceId,url:n.url,...n.title==null?void 0:{title:n.title},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}:n.type===`file`?{type:`file`,data:n.url,mimeType:n.mediaType,...n.filename!=null&&{filename:n.filename}}:n.type===`source-document`?{type:`source`,sourceType:`document`,id:n.sourceId,title:n.title,mediaType:n.mediaType,...n.filename==null?void 0:{filename:n.filename},...n.providerMetadata==null?void 0:{providerMetadata:n.providerMetadata}}:n.type.startsWith(`data-`)?{type:`data`,name:n.type.substring(5),data:n.data}:k6(n)?{type:`file`,data:n.url,mimeType:n.mediaType}:D6(n)?{type:`data`,name:n.kind,data:n.providerMetadata??null}:(console.warn(`Unsupported message part type: ${n.type}`),null)}).filter(Boolean),r=new Set;return n.filter(e=>{if(e.type===`tool-call`&&e.toolCallId!=null){if(r.has(e.toolCallId))return!1;r.add(e.toolCallId)}return!0})}var G8=cD((e,t)=>{let n=new Date,r=W8(e,t);switch(e.role){case`user`:return{role:`user`,id:e.id,createdAt:n,content:r,attachments:e.parts?.filter(e=>e.type===`file`).map((e,t)=>{let n=e.mediaType??`unknown/unknown`,r=n.startsWith(`image/`);return{id:t.toString(),type:r?`image`:`file`,name:e.filename??`file`,content:[r?{type:`image`,image:e.url,filename:e.filename}:{type:`file`,filename:e.filename,data:e.url,mimeType:n}],contentType:n,status:{type:`complete`}}}),metadata:R8(e.metadata)};case`system`:case`assistant`:{let i=t.messageTiming?.[e.id],a=e.role===`assistant`&&e.id===t.optimisticMessageId;return{role:e.role,id:e.id,createdAt:n,content:r,metadata:{...R8(e.metadata),...i&&{timing:i},...a&&{isOptimistic:!0}}}}default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),K8={format:`ai-sdk/v6`,encode({message:{id:e,parts:t,...n}}){return{...n,parts:t}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},q8=(e,t)=>{let n=new Set,r=t.messages.flatMap(t=>{let r=e([t.message])[0];return r?t.parentId&&!n.has(t.parentId)?[]:(n.add(r.id),[{...t,message:r}]):(console.warn(`Skipping a stored message that could not be loaded.`),[])});return{headId:t.headId&&n.has(t.headId)?t.headId:null,messages:r}},J8=e=>e.status?.type===`requires-action`&&e.status.reason===`tool-calls`,Y8=(e,t)=>JSON.stringify(e.encode(t)),X8=(e,t,n,r,i)=>{let a=B(!1),[o,s]=Pv(0),c=xx(),l=Iv(()=>c.threadListItem.source?c.threadListItem:null,[c]),[u,d]=Pv(!1),f=B(new Set),p=B(new Set),m=B(new Map),h=B(i);V(()=>{h.current=i});let g=Fv(()=>{if(t){if(!t.withFormat)throw Error("useAISDKRuntime: ThreadHistoryAdapter is missing the required `withFormat` method.");return t.withFormat(r)}},[t,r]),_=g!=null&&!u;V(()=>{if(!g||a.current)return;let t=async()=>{try{let t=await g.load();if(t&&t.messages.length>0){for(let e of t.messages)m.current.set(r.getId(e.message),{source:e.message,content:Y8(r,e)});let i=q8(n,t);e.current.thread.import(i);let a=new ME;a.import(i);let o=a.getMessages();h.current(o.flatMap(OC)),f.current=new Set;for(let e of i.messages)f.current.add(e.message.id),J8(e.message)&&p.current.add(e.message.id)}}catch(e){console.error(`Failed to load message history:`,e)}finally{d(!0)}};if(g.pin?.(),!l()?.getState().remoteId)return d(!0),c.subscribe(()=>{l()?.getState().remoteId&&s(e=>e+1)});let i=e.current.thread.getState();if(i.isRunning||i.messages.length>0){a.current=!0,d(!0);return}a.current=!0,t()},[g,n,e,l,c,o,r]);let v=B(null),y=B(null),b=B(Promise.resolve()),x=B([]),S=B(!1),C=B(0);return V(()=>{if(!g)return;let t=g,n=e.current.thread.subscribe(()=>{let n=e.current.thread.getState(),{isRunning:r}=n,i=S.current;if(S.current=r,v.current!=null){let e=n.messages.at(-1);if(e?.role===`assistant`){let t=e.content.filter(e=>e.type===`tool-call`).length;for(;C.current<t;)x.current.push(Date.now()-v.current),C.current++}}if(r){v.current??(v.current=Date.now(),x.current=[],C.current=0,t.pin?.()),y.current&&=(clearTimeout(y.current),null);return}i&&(v.current!=null&&x.current.push(Date.now()-v.current),y.current&&clearTimeout(y.current),y.current=setTimeout(()=>{a(!1)},0))}),i=e.current.thread.getState();S.current=i.isRunning,i.isRunning?v.current??(v.current=Date.now(),x.current=[],C.current=0,t.pin?.()):i.messages.length>0&&a(!0);function a(n){y.current=null;let i=e.current.thread.getState();if(!n&&i.isRunning)return;let a=x.current,o=a.length>0?a.at(-1):void 0;if(a.length===1&&o!=null){let e=i.messages.findLast(e=>e.role===`assistant`);if(e){let t=e.content.filter(e=>e.type===`tool-call`).length;if(t>0){let e=t+1,n=o/e;a.length=0;for(let t=0;t<e;t++)a.push(Math.round((t+1)*n))}}}let s=a.length>1?a.map((e,t)=>({start_ms:t===0?0:a[t-1],end_ms:e})):void 0;v.current=null,x.current=[];let c={...o==null?void 0:{durationMs:o},...s==null?void 0:{stepTimestamps:s}};b.current=b.current.then(async()=>{let{messages:e}=i,n=null,a=e=>e.length>0?r.getId(e.at(-1)):null,s=e=>e.map((t,i)=>({parentId:i===0?n:r.getId(e[i-1]),message:t}));for(let i of e){let e=OC(i),l=i.status===void 0||i.status.type===`complete`||i.status.type===`incomplete`,u=J8(i);if(!(l||u&&t.update!==void 0)){n=a(e)??n;continue}f.current.has(i.id)||(f.current.add(i.id),p.current.add(i.id));let d=s(e);for(let e of d){let n=r.getId(e.message),i=m.current.get(n);if(!i)await t.append(e),m.current.set(n,{source:e.message,content:Y8(r,e)});else if(i.source!==e.message&&o!==void 0&&t.update){let a=Y8(r,e);if(a===i.content)i.source=e.message;else try{await t.update(e,n),m.current.set(n,{source:e.message,content:a})}catch{}}}n=a(e)??n,p.current.has(i.id)&&l&&(p.current.delete(i.id),t.reportTelemetry?.(d,c))}}).catch(e=>{console.error(`Failed to persist message history:`,e)})}return()=>{n(),y.current&&(clearTimeout(y.current),y.current=null,a(!1))}},[g,r,e]),{isLoading:_,deleteMessage:Iv(async t=>{let n=g?.delete?.bind(g);if(!n)return;let i=e.current.thread.getState().messages,a=i.findIndex(e=>e.id===t);if(a===-1)return;let o=i.slice(0,a).flatMap(OC),s=o.at(-1)?r.getId(o.at(-1)):null,c=OC(i[a]).map(e=>{let t={parentId:s,message:e};return s=r.getId(e),t}),l=b.current.then(async()=>{await n(c),f.current.delete(t),p.current.delete(t);for(let e of c)m.current.delete(r.getId(e.message))});b.current=l.catch(()=>{}),await l},[g,e,r])}},Z8=(e,t)=>e.find(e=>e.role===`assistant`&&e.id===t),Q8={getAssistantMessageId:e=>e.findLast(e=>e.role===`assistant`)?.id,getTextLength:(e,t)=>{let n=Z8(e,t);if(!n?.parts)return 0;let r=0;for(let e of n.parts)e.type===`text`&&(r+=e.text.length);return r},getToolCallCount:(e,t)=>{let n=Z8(e,t);if(!n?.parts)return 0;let r=0;for(let e of n.parts)N6(e)&&r++;return r}},$8=(e,t)=>Ate(e,t,Q8),e5=(e,t)=>({...e,id:e.id??QJ(),role:e.role??t}),t5=[],n5=(e,t,n)=>{let r=z(13),[i,a]=Pv(t5),o=B(null),s=B(!1),c=B(t),l,u;r[0]===t?(l=r[1],u=r[2]):(l=()=>{c.current=t},u=[t],r[0]=t,r[1]=l,r[2]=u),Vv(l,u);let d=B(e),f,p;r[3]===e?(f=r[4],p=r[5]):(f=()=>{d.current=e},p=[e],r[3]=e,r[4]=f,r[5]=p),Vv(f,p);let m=e!=null,h;r[6]===n?h=r[7]:(h=()=>{let e=()=>{o.current?.abort(),o.current=null,a(a5)},t=d.current;if(!t){e(),s.current=n;return}if(n){s.current||e(),s.current=!0;return}if(!s.current)return;s.current=!1;let r=c.current,i=r.at(-1);if(i?.role!==`assistant`||i.status?.type===`requires-action`)return;let l=new AbortController;o.current=l;let{signal:u}=l;(async()=>{try{await uj(t.generate({messages:r,signal:u}),{signal:u,onUpdate:a})}catch{}})()},r[6]=n,r[7]=h);let g;r[8]!==m||r[9]!==n?(g=[m,n],r[8]=m,r[9]=n,r[10]=g):g=r[10],V(h,g);let _,v;return r[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>()=>{o.current?.abort()},v=[],r[11]=_,r[12]=v):(_=r[11],v=r[12]),V(_,v),i},r5=new Set,i5=(e,t={})=>{let{adapters:n,toCreateMessage:r,cancelPendingToolCallsOnSend:i=!0,onResume:a,onResumeToolCall:o,joinStrategy:s,messageRepository:c,unstable_onBranchChange:l}=t,u=n?.suggestion,d=wC(),[f,p]=Pv({}),[m,h]=Pv(null),g=B(new Map),_=B(new Map),v=B(new Map),y=B(void 0),b=Object.values(f).some(e=>e?.type===`executing`),x=e.status===`submitted`||e.status===`streaming`,S=x||b,C=B(x),w=$8(e.messages,S),T=e.messages.at(-1),E=S&&T?.role===`assistant`?T.id:void 0,D=m?.chatId===e.id?m.ids:r5,O=Iv((e,t)=>{h(n=>{if(n?.chatId!==e||!n.ids.has(t))return n;let r=new Set(n.ids);return r.delete(t),{chatId:e,ids:r}})},[]),k=x&&T?.role===`assistant`?T.id:void 0;V(()=>{let t=C.current;C.current=x,!t&&k&&O(e.id,k)},[x,k,e.id,O]);let A=G8.useThreadMessages({isRunning:S,messages:e.messages,joinStrategy:s,metadata:Fv(()=>({toolStatuses:f,messageTiming:w,toolArgsKeyOrderCache:g.current,toolLastInputCache:_.current,mcpAppMetadataCache:v.current,...E&&{optimisticMessageId:E},...e.error&&{error:e.error.message},...D.size>0&&{cancelledMessageIds:D}}),[f,w,E,e.error,D])}),j=Fv(()=>{if(!c)return;let e=q8(G8.toThreadMessages,c);return e.messages.length>0?e:void 0},[c]),ee=n5(u,A,S),[te]=Pv(()=>({get current(){return ce}})),{isLoading:ne,deleteMessage:re}=X8(te,n?.history??d?.history,G8.toThreadMessages,K8,t=>{e.setMessages(t)}),{id:M,messages:N,status:ie,error:ae}=e,oe=Fv(()=>SK.provide({chat:e,error:ae}),[M,N,ie,ae]),se=async()=>{i&&e.setMessages(e=>{let t=e.at(-1);if(t?.role!==`assistant`)return e;let n=!1,r=t.parts?.map(e=>{if(!N6(e)||e.state===`output-available`||e.state===`output-error`||e.state===`output-denied`)return e;n=!0;let{approval:t,...r}=e;return{...r,state:`output-error`,errorText:`User cancelled tool call by sending a new message.`}});return n?[...e.slice(0,-1),{...t,parts:r}]:e})},P=B(!1),ce=sD({isRunning:x,...j!=null&&!P.current&&A.length===0?{messageRepository:j}:{messages:A},unstable_enableToolInvocations:!0,setToolStatuses:p,setMessages:t=>e.setMessages(t.map(M8).filter(Boolean).flat()),onImport:t=>e.setMessages(t.map(M8).filter(Boolean).flat()),onExportExternalState:()=>{let e=te.current.thread.export(),t=[],n=new Map;for(let r of e.messages){let e=OC(r.message),i=r.parentId==null?null:n.get(r.parentId)??r.parentId;for(let n of e)t.push({parentId:i,message:n}),i=K8.getId(n);e.length>0&&n.set(r.message.id,K8.getId(e[e.length-1]))}let r={messages:t};return e.headId!=null&&(r.headId=n.get(e.headId)??e.headId),r},onLoadExternalState:e=>{let t=q8(G8.toThreadMessages,e);te.current.thread.import(t)},onCancel:async()=>{let t=e.messages.at(-1),n=S&&t?.role===`assistant`?t.id:void 0;if(n){let t=new Set(e.messages.map(e=>e.id));h(r=>{let i=r?.chatId===e.id?[...r.ids].filter(e=>t.has(e)):[];return{chatId:e.id,ids:new Set([...i,n])}})}try{await e.stop()}catch(t){if(!(t instanceof Error&&t.name===`AbortError`))throw n&&O(e.id,n),t}},onNew:async t=>{let n=(r??wK)(t);if(!(t.startRun??t.role===`user`)){e.setMessages(e=>[...e,e5(n,t.role)]);return}y.current=t.runConfig,await se(),await e.sendMessage(n,{metadata:t.runConfig})},onEdit:async t=>{let n=(r??wK)(t);if(!(t.startRun??t.role===`user`)){e.setMessages(e=>[...CK(e,t.parentId),e5(n,t.role)]);return}y.current=t.runConfig,e.setMessages(e=>CK(e,t.parentId)),await e.sendMessage(n,{metadata:t.runConfig})},onDelete:async t=>{let n=te.current.thread.getState().messages,r=n.findIndex(e=>e.id===t);if(r===-1)return;await re(t);let i=new Set(OC(n[r]).map(e=>e.id));e.setMessages(e=>e.filter(e=>!i.has(e.id)))},onReload:async(t,n)=>{y.current=n.runConfig;let r=CK(e.messages,t);e.setMessages(r),await e.regenerate({metadata:n.runConfig})},onAddToolResult:({toolCallId:t,toolName:n,result:r,isError:i,modelContent:a})=>{let o={metadata:y.current};if(i)return Promise.resolve(e.addToolOutput({state:`output-error`,tool:n??t,toolCallId:t,errorText:typeof r==`string`?r:JSON.stringify(r),options:o}));{let i=a===void 0?r:F8(r,a);return Promise.resolve(e.addToolOutput({tool:n,toolCallId:t,output:i,options:o}))}},onRespondToToolApproval:({approvalId:t,approved:n,reason:r})=>Promise.resolve(e.addToolApprovalResponse({id:t,approved:n,...r!=null&&{reason:r},options:{metadata:y.current}})),...tM(t),...t.unstable_messageRepositoryInstance&&{unstable_messageRepositoryInstance:t.unstable_messageRepositoryInstance},...u?{suggestions:ee}:{},...a&&{onResume:a},...o&&{onResumeToolCall:o},...l&&{unstable_onBranchChange:l},adapters:{attachments:j8,...d,...n},extras:oe,isLoading:ne}),le=B(e.setMessages);return Vv(()=>{le.current=e.setMessages},[e.setMessages]),V(()=>{if(P.current||!j)return;if(e.messages.length>0){P.current=!0;return}let t=new ME;t.import(j),le.current(t.getMessages().flatMap(OC)),P.current=!0},[j,e.messages.length]),ce};function a5(e){return e.length===0?e:t5}var tre=`x-resumable-stream-id`,nre=`"type":"finish"`,rre=4096,o5=`x-assistant-ui-resumable-thread-id`,ire=new Set([101,204,205,304]),s5=class extends k8{runtime;getThreadListItem;resumable;__internal_initOptions;__internal_clone(){let e=this.constructor;return new e(this.__internal_initOptions)}constructor(e){let{resumable:t,...n}=e??{},r=n.fetch,i=n.prepareReconnectToStreamRequest;super({...n,...t&&{fetch:are(t,r),prepareReconnectToStreamRequest:sre(t,i)},prepareSendMessagesRequest:async e=>{let r=e.id,i=this.runtime?.thread.getModelContext(),a=(await(this.getThreadListItem?.()??this.runtime?.threads.mainItem)?.initialize())?.remoteId??e.id,o={...e,id:a,body:{callSettings:i?.callSettings,system:i?.system,config:i?.config,tools:Pte(i?.tools??{}),...e?.body}},s=await n.prepareSendMessagesRequest?.(o),c=t?new Headers(s?.headers??e.headers):void 0;return c?.set(o5,r),{...s,...c&&{headers:c},body:s?.body??{...o.body,id:a,messages:e.messages,trigger:e.trigger,messageId:e.messageId,metadata:e.requestMetadata}}}}),this.resumable=t,this.__internal_initOptions=e}setRuntime(e){this.runtime=e}getResumableAdapter(){return this.resumable}__internal_setGetThreadListItem(e){this.getThreadListItem=e}};function are(e,t){let n=t?(e,n)=>t(e,n):globalThis.fetch.bind(globalThis);return async(t,r)=>{let i=new Headers(r?.headers),a=i.get(o5)??void 0;i.delete(o5);let o=await n(t,{...r,headers:i}),s=o.headers.get(tre);if(s&&e.storage.setStreamId(s,a),!o.body||ire.has(o.status))return o;let c=e.isFinishEvent??ore,l=new TextDecoder,u=``,d=new TransformStream({transform(t,n){n.enqueue(t),u+=l.decode(t,{stream:!0}),c(t,u)?((!s||e.storage.getStreamId(a)===s)&&e.storage.clear(a),u=``):u.length>rre&&(u=u.slice(-1024))}});return new Response(o.body.pipeThrough(d),{status:o.status,statusText:o.statusText,headers:o.headers})}}function ore(e,t){return t.includes(nre)}function sre(e,t){return async n=>{let r=e.storage.getStreamId(n.id);if(!r)throw Error(`AssistantChatTransport: no resumable stream id available; nothing to resume`);let i=typeof e.resumeApi==`function`?e.resumeApi(r):e.resumeApi,a=await t?.({...n,api:i}),o=new Headers(a?.headers??n.headers);return o.set(o5,n.id),{...a,headers:o,api:a?.api??i}}}var cre=(e,t)=>{let n=z(7),r=Hb(),i=B(t),a=B(e),o=B(void 0),s;n[0]!==t||n[1]!==e?(s=()=>{i.current=t,a.current=e},n[0]=t,n[1]=e,n[2]=s):s=n[2],V(s);let c,l;n[3]!==r||n[4]!==e?(c=()=>{e&&r&&o.current!==r&&(o.current=r,r.addEventListener(`abort`,()=>{a.current&&i.current()},{once:!0}))},l=[r,e],n[3]=r,n[4]=e,n[5]=c,n[6]=l):(c=n[5],l=n[6]),V(c,l)},lre=c(o(((e,t)=>{function n(e,t){if(typeof e!=`function`)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let n,r=0;return function(...i){clearTimeout(n);let a=Date.now(),o=t-(a-r);o<=0?(r=a,e.apply(this,i)):n=setTimeout(()=>{r=Date.now(),e.apply(this,i)},o)}}t.exports=n}))(),1),c5=(e,t,n)=>{if(!t.has(e))throw TypeError(`Cannot `+n)},l5=(e,t,n)=>(c5(e,t,`read from private field`),n?n.call(e):t.get(e)),u5=(e,t,n)=>{if(t.has(e))throw TypeError(`Cannot add the same private member more than once`);t instanceof WeakSet?t.add(e):t.set(e,n)},d5=(e,t,n,r)=>(c5(e,t,`write to private field`),r?r.call(e,n):t.set(e,n),n);function ure(e,t){return t==null?e:(0,lre.default)(e,t)}function dre(e){return Array.isArray(e)?[...e]:typeof e==`object`&&e&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)?{...e}:e}var f5,p5,m5,h5,g5,_5,v5,y5,b5,fre=class{constructor(e=[]){u5(this,f5,void 0),u5(this,p5,`ready`),u5(this,m5,void 0),u5(this,h5,new Set),u5(this,g5,new Set),u5(this,_5,new Set),this.pushMessage=e=>{d5(this,f5,l5(this,f5).concat(e)),l5(this,v5).call(this)},this.popMessage=()=>{d5(this,f5,l5(this,f5).slice(0,-1)),l5(this,v5).call(this)},this.replaceMessage=(e,t)=>{d5(this,f5,[...l5(this,f5).slice(0,e),this.snapshot(t),...l5(this,f5).slice(e+1)]),l5(this,v5).call(this)},this.snapshot=e=>{if(typeof e!=`object`||!e||!(`parts`in e)||!Array.isArray(e.parts))return e;let t=e,n={...t,parts:t.parts.map(e=>({...e}))};return`metadata`in t&&(n.metadata=dre(t.metadata)),n},this[`~registerMessagesCallback`]=(e,t)=>{let n=t?ure(e,t):e;return l5(this,h5).add(n),()=>{l5(this,h5).delete(n)}},this[`~registerStatusCallback`]=e=>(l5(this,g5).add(e),()=>{l5(this,g5).delete(e)}),this[`~registerErrorCallback`]=e=>(l5(this,_5).add(e),()=>{l5(this,_5).delete(e)}),u5(this,v5,()=>{l5(this,h5).forEach(e=>e())}),u5(this,y5,()=>{l5(this,g5).forEach(e=>e())}),u5(this,b5,()=>{l5(this,_5).forEach(e=>e())}),d5(this,f5,e)}get status(){return l5(this,p5)}set status(e){d5(this,p5,e),l5(this,y5).call(this)}get error(){return l5(this,m5)}set error(e){d5(this,m5,e),l5(this,b5).call(this)}get messages(){return l5(this,f5)}set messages(e){d5(this,f5,[...e]),l5(this,v5).call(this)}};f5=new WeakMap,p5=new WeakMap,m5=new WeakMap,h5=new WeakMap,g5=new WeakMap,_5=new WeakMap,v5=new WeakMap,y5=new WeakMap,b5=new WeakMap;var x5,S5=class extends A8{constructor({messages:e,...t}){let n=new fre(e);super({...t,state:n}),u5(this,x5,void 0),this[`~registerMessagesCallback`]=(e,t)=>l5(this,x5)[`~registerMessagesCallback`](e,t),this[`~registerStatusCallback`]=e=>l5(this,x5)[`~registerStatusCallback`](e),this[`~registerErrorCallback`]=e=>l5(this,x5)[`~registerErrorCallback`](e),d5(this,x5,n)}};x5=new WeakMap;function pre({throttle:e,experimental_throttle:t,resume:n=!1,...r}={}){let i=e??t,a=(0,_.useRef)({});`chat`in r||(a.current={onToolCall:r.onToolCall,onData:r.onData,onFinish:r.onFinish,onError:r.onError,sendAutomaticallyWhen:r.sendAutomaticallyWhen,transport:r.transport});let o,s=()=>a.current.transport??(o??=new k8),c={...r,transport:{sendMessages:e=>s().sendMessages(e),reconnectToStream:e=>s().reconnectToStream(e)},onToolCall:e=>{var t;return(t=a.current).onToolCall?.call(t,e)},onData:e=>{var t;return(t=a.current).onData?.call(t,e)},onFinish:e=>{var t;return(t=a.current).onFinish?.call(t,e)},onError:e=>{var t;return(t=a.current).onError?.call(t,e)},sendAutomaticallyWhen:e=>{var t;return(t=a.current).sendAutomaticallyWhen?.call(t,e)??!1}},l=(0,_.useRef)(`chat`in r?r.chat:new S5(c));(`chat`in r&&r.chat!==l.current||`id`in r&&r.id!=null&&l.current.id!==r.id)&&(l.current=`chat`in r?r.chat:new S5(c));let u=l.current,d=(0,_.useRef)({chat:u,messages:u.messages});d.current.chat!==u&&(d.current={chat:u,messages:u.messages});let f=(0,_.useCallback)(e=>{let t=!0,n=u[`~registerMessagesCallback`](()=>{t&&d.current.chat===u&&(d.current={chat:u,messages:u.messages},e())},i);return d.current={chat:u,messages:u.messages},()=>{t=!1,n()}},[u,i]),p=(0,_.useCallback)(()=>d.current.messages,[]),m=(0,_.useSyncExternalStore)(f,p,p),h=(0,_.useCallback)(e=>u[`~registerStatusCallback`](()=>{d.current.chat===u&&((u.status===`ready`||u.status===`error`)&&(d.current={chat:u,messages:u.messages}),e())}),[u]),g=(0,_.useCallback)(()=>u.status,[u]),v=(0,_.useSyncExternalStore)(h,g,g),y=(0,_.useSyncExternalStore)(l.current[`~registerErrorCallback`],()=>l.current.error,()=>l.current.error),b=(0,_.useCallback)(e=>{typeof e==`function`&&(e=e(l.current.messages)),l.current.messages=e},[l]);return(0,_.useEffect)(()=>{n&&l.current.resumeStream()},[n,l]),{id:l.current.id,messages:m,setMessages:b,sendMessage:l.current.sendMessage,regenerate:l.current.regenerate,clearError:l.current.clearError,stop:l.current.stop,error:y,resumeStream:l.current.resumeStream,status:v,addToolResult:l.current.addToolOutput,addToolOutput:l.current.addToolOutput,addToolApprovalResponse:l.current.addToolApprovalResponse}}var mre=e=>{let t=B(e);return V(()=>{t.current=e}),Fv(()=>new Proxy(t.current,{get(e,n){let r=t.current[n];return typeof r==`function`?r.bind(t.current):r}}),[])},hre=e=>{if(e instanceof s5)return e.getResumableAdapter();let t=e.getResumableAdapter;if(typeof t==`function`)return t.call(e)},gre=()=>null,C5=new WeakMap,_re=e=>{if(!e)return new Set;let t=C5.get(e);return t||(t=new Set,C5.set(e,t)),t},vre=e=>{let{adapters:t,transport:n,throttle:r,toCreateMessage:i,isDisabled:a,isSendDisabled:o,unstable_capabilities:s,suggestions:c,onResume:l,onResumeToolCall:u,onResumeError:d,joinStrategy:f,messageRepository:p,unstable_onBranchChange:m,...h}=e??{};return{adapters:t,transport:n,throttle:r,toCreateMessage:i,onResume:l,onResumeToolCall:u,onResumeError:d,joinStrategy:f,messageRepository:p,unstable_onBranchChange:m,chatInit:h}},yre=(e,t)=>{let{adapters:n,transport:r,throttle:i,toCreateMessage:a,onResume:o,onResumeToolCall:s,onResumeError:c,joinStrategy:l,messageRepository:u,unstable_onBranchChange:d,chatInit:f}=vre(e),{id:p,isMainThread:m,getThreadListItem:h,stopOnClientDestroy:g=!1,chat:_,messageRepositoryInstance:v}=t,y=Fv(()=>new s5,[]),b=r??y,x=mre(b),S=pre({...f,id:p,transport:x,...i!==void 0&&{throttle:i},..._!==void 0&&{chat:_}});cre(g,()=>{S.stop().catch(()=>{})});let C=i5(S,{adapters:n,...tM(e??{}),...a&&{toCreateMessage:a},...o&&{onResume:o},...s&&{onResumeToolCall:s},...l&&{joinStrategy:l},...u&&{messageRepository:u},...v&&{unstable_messageRepositoryInstance:v},...d&&{unstable_onBranchChange:d}});b instanceof s5&&(b.setRuntime(C),b.__internal_setGetThreadListItem(h));let w=Iv(e=>C.thread.subscribe(e),[C]),T=Iv(()=>C.thread.getState().isLoading,[C]),E=zv(w,T,T),D=Fv(()=>hre(b)?.storage,[b]),O=zv(Iv(e=>m?D?.subscribe?.(e,p)??(()=>{}):()=>{},[p,m,D]),Iv(()=>m?D?.getStreamId(p)??null:null,[p,m,D]),gre),k=S.status===`submitted`||S.status===`streaming`,A=Fv(()=>_re(D),[D]),j=B(c);return V(()=>{j.current=c}),V(()=>{if(O&&!A.has(O)){if(k){A.add(O);return}E||(A.add(O),S.resumeStream().catch(e=>{console.warn(`[assistant-ui] resumable: resume failed`,e);try{j.current?.(e)}catch(e){console.error(`[assistant-ui] resumable: onResumeError callback failed`,e)}finally{D?.getStreamId(p)===O&&D.clear(p)}}))}},[S,p,k,E,O,D,A]),C},bre=e=>{let t=z(6),n=H(Sre),r=H(Cre),i=xx(),a;t[0]===i?a=t[1]:(a=()=>i.threadListItem.source?i.threadListItem:void 0,t[0]=i,t[1]=a);let o;return t[2]!==n||t[3]!==r||t[4]!==a?(o={id:n,isMainThread:r,getThreadListItem:a},t[2]=n,t[3]=r,t[4]=a,t[5]=o):o=t[5],yre(e,o)},xre=({cloud:e,onThreadIdChange:t,...n}={})=>BD({runtimeHook:function(){return bre(n)},adapter:ek({cloud:e}),allowNesting:!0,onThreadIdChange:t});function Sre(e){return e.threadListItem.id}function Cre(e){return e.threads.mainThreadId===e.threadListItem.id}var w5=`vercel.ai.error`,wre=Symbol.for(w5),T5,E5,D5=class e extends (E5=Error,T5=wre,E5){constructor({name:e,message:t,cause:n}){super(t),this[T5]=!0,this.name=e,this.cause=n}static isInstance(t){return e.hasMarker(t,w5)}static hasMarker(e,t){let n=Symbol.for(t);return typeof e==`object`&&!!e&&n in e&&typeof e[n]==`boolean`&&e[n]===!0}},O5=`AI_APICallError`,k5=`vercel.ai.error.${O5}`,Tre=Symbol.for(k5),A5,j5,M5=class extends (j5=D5,A5=Tre,j5){constructor({message:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i,responseBody:a,cause:o,isRetryable:s=r!=null&&(r===408||r===409||r===429||r>=500),data:c}){super({name:O5,message:e,cause:o}),this[A5]=!0,this.url=t,this.requestBodyValues=n,this.statusCode=r,this.responseHeaders=i,this.responseBody=a,this.isRetryable=s,this.data=c}static isInstance(e){return D5.hasMarker(e,k5)}},N5=`AI_EmptyResponseBodyError`,P5=`vercel.ai.error.${N5}`,Ere=Symbol.for(P5),F5,I5,Dre=class extends (I5=D5,F5=Ere,I5){constructor({message:e=`Empty response body`}={}){super({name:N5,message:e}),this[F5]=!0}static isInstance(e){return D5.hasMarker(e,P5)}};function L5(e){return e==null?`unknown error`:typeof e==`string`?e:e instanceof Error?e.message:JSON.stringify(e)}var R5=`AI_InvalidArgumentError`,z5=`vercel.ai.error.${R5}`,Ore=Symbol.for(z5),B5,V5,kre=class extends (V5=D5,B5=Ore,V5){constructor({message:e,cause:t,argument:n}){super({name:R5,message:e,cause:t}),this[B5]=!0,this.argument=n}static isInstance(e){return D5.hasMarker(e,z5)}},H5=`AI_JSONParseError`,U5=`vercel.ai.error.${H5}`,Are=Symbol.for(U5),W5,G5,K5=class extends (G5=D5,W5=Are,G5){constructor({text:e,cause:t}){super({name:H5,message:`JSON parsing failed: Text: ${e}.
|
|
174
|
-
Error message: ${L5(t)}`,cause:t}),this[W5]=!0,this.text=e}static isInstance(e){return D5.hasMarker(e,U5)}},q5=`AI_LoadAPIKeyError`,J5=`vercel.ai.error.${q5}`,jre=Symbol.for(J5),Y5,X5,Z5=class extends (X5=D5,Y5=jre,X5){constructor({message:e}){super({name:q5,message:e}),this[Y5]=!0}static isInstance(e){return D5.hasMarker(e,J5)}},Q5=`AI_TypeValidationError`,$5=`vercel.ai.error.${Q5}`,Mre=Symbol.for($5),e7,t7,n7=class e extends (t7=D5,e7=Mre,t7){constructor({value:e,cause:t}){super({name:Q5,message:`Type validation failed: Value: ${JSON.stringify(e)}.
|
|
175
|
-
Error message: ${L5(t)}`,cause:t}),this[e7]=!0,this.value=e}static isInstance(e){return D5.hasMarker(e,$5)}static wrap({value:t,cause:n}){return e.isInstance(n)&&n.value===t?n:new e({value:t,cause:n})}},r7;(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})(r7||={});var Nre;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(Nre||={});var Y=r7.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),i7=e=>{switch(typeof e){case`undefined`:return Y.undefined;case`string`:return Y.string;case`number`:return Number.isNaN(e)?Y.nan:Y.number;case`boolean`:return Y.boolean;case`function`:return Y.function;case`bigint`:return Y.bigint;case`symbol`:return Y.symbol;case`object`:return Array.isArray(e)?Y.array:e===null?Y.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?Y.promise:typeof Map<`u`&&e instanceof Map?Y.map:typeof Set<`u`&&e instanceof Set?Y.set:typeof Date<`u`&&e instanceof Date?Y.date:Y.object;default:return Y.unknown}},X=r7.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`]),a7=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,r7.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()}};a7.create=e=>new a7(e);var o7=(e,t)=>{let n;switch(e.code){case X.invalid_type:n=e.received===Y.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case X.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,r7.jsonStringifyReplacer)}`;break;case X.unrecognized_keys:n=`Unrecognized key(s) in object: ${r7.joinValues(e.keys,`, `)}`;break;case X.invalid_union:n=`Invalid input`;break;case X.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${r7.joinValues(e.options)}`;break;case X.invalid_enum_value:n=`Invalid enum value. Expected ${r7.joinValues(e.options)}, received '${e.received}'`;break;case X.invalid_arguments:n=`Invalid function arguments`;break;case X.invalid_return_type:n=`Invalid function return type`;break;case X.invalid_date:n=`Invalid date`;break;case X.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}"`:r7.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case X.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 X.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 X.custom:n=`Invalid input`;break;case X.invalid_intersection_types:n=`Intersection results could not be merged`;break;case X.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case X.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,r7.assertNever(e)}return{message:n}},Pre=o7;function s7(){return Pre}var c7=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 Z(e,t){let n=s7(),r=c7({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===o7?void 0:o7].filter(e=>!!e)});e.common.issues.push(r)}var l7=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 u7;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 u7;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}}},u7=Object.freeze({status:`aborted`}),d7=e=>({status:`dirty`,value:e}),f7=e=>({status:`valid`,value:e}),p7=e=>e.status===`aborted`,m7=e=>e.status===`dirty`,h7=e=>e.status===`valid`,g7=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 _7=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}},v7=(e,t)=>{if(h7(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 a7(e.common.issues);return this._error=t,this._error}}};function y7(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 b7=class{get description(){return this._def.description}_getType(e){return i7(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:i7(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new l7,ctx:{common:e.parent.common,data:e.data,parsedType:i7(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(g7(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:i7(e)};return v7(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:i7(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return h7(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=>h7(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:i7(e)},r=this._parse({data:e,path:n.path,parent:n});return v7(n,await(g7(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:X.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 Q7({schema:this,typeName:s9.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 $7.create(this,this._def)}nullable(){return e9.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return I7.create(this)}promise(){return Z7.create(this,this._def)}or(e){return z7.create([this,e],this._def)}and(e){return H7.create(this,e,this._def)}transform(e){return new Q7({...y7(this._def),schema:this,typeName:s9.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new t9({...y7(this._def),innerType:this,defaultValue:t,typeName:s9.ZodDefault})}brand(){return new i9({typeName:s9.ZodBranded,type:this,...y7(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new n9({...y7(this._def),innerType:this,catchValue:t,typeName:s9.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return a9.create(this,e)}readonly(){return o9.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Fre=/^c[^\s-]{8,}$/i,Ire=/^[0-9a-z]+$/,Lre=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Rre=/^[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,zre=/^[a-z0-9_-]{21}$/i,Bre=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Vre=/^[-+]?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)?)??$/,Hre=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ure=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,x7,Wre=/^(?:(?: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])$/,Gre=/^(?:(?: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])$/,Kre=/^(([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]))$/,qre=/^(([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])$/,Jre=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Yre=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,S7=`((\\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])))`,Xre=RegExp(`^${S7}$`);function C7(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 Zre(e){return RegExp(`^${C7(e)}$`)}function Qre(e){let t=`${S7}T${C7(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function $re(e,t){return!((t!==`v4`&&t||!Wre.test(e))&&(t!==`v6`&&t||!Kre.test(e)))}function eie(e,t){if(!Bre.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 tie(e,t){return!((t!==`v4`&&t||!Gre.test(e))&&(t!==`v6`&&t||!qre.test(e)))}var w7=class e extends b7{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Y.string){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.string,received:t.parsedType}),u7}let t=new l7,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),Z(n,{code:X.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),Z(n,{code:X.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?Z(n,{code:X.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&Z(n,{code:X.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)Hre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`email`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)x7||=new RegExp(Ure,`u`),x7.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`emoji`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)Rre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`uuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)zre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`nanoid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Fre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`cuid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Ire.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`cuid2`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)Lre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`ulid`,code:X.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),Z(n,{validation:`url`,code:X.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),Z(n,{validation:`regex`,code:X.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),Z(n,{code:X.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),Z(n,{code:X.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),Z(n,{code:X.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?Qre(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{code:X.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?Xre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{code:X.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?Zre(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{code:X.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?Vre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`duration`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?$re(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`ip`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?eie(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`jwt`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?tie(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`cidr`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?Jre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`base64`,code:X.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?Yre.test(e.data)||(n=this._getOrReturnCtx(e,n),Z(n,{validation:`base64url`,code:X.invalid_string,message:r.message}),t.dirty()):r7.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:X.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}};w7.create=e=>new w7({checks:[],typeName:s9.ZodString,coerce:e?.coerce??!1,...y7(e)});function nie(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 T7=class e extends b7{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)!==Y.number){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.number,received:t.parsedType}),u7}let t,n=new l7;for(let r of this._def.checks)r.kind===`int`?r7.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Z(t,{code:X.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),Z(t,{code:X.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),Z(t,{code:X.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?nie(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),Z(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Z(t,{code:X.not_finite,message:r.message}),n.dirty()):r7.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`&&r7.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)}};T7.create=e=>new T7({checks:[],typeName:s9.ZodNumber,coerce:e?.coerce||!1,...y7(e)});var E7=class e extends b7{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)!==Y.bigint)return this._getInvalidInput(e);let t,n=new l7;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),Z(t,{code:X.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),Z(t,{code:X.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),Z(t,{code:X.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r7.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.bigint,received:t.parsedType}),u7}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}};E7.create=e=>new E7({checks:[],typeName:s9.ZodBigInt,coerce:e?.coerce??!1,...y7(e)});var D7=class extends b7{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==Y.boolean){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.boolean,received:t.parsedType}),u7}return f7(e.data)}};D7.create=e=>new D7({typeName:s9.ZodBoolean,coerce:e?.coerce||!1,...y7(e)});var O7=class e extends b7{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Y.date){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.date,received:t.parsedType}),u7}if(Number.isNaN(e.data.getTime()))return Z(this._getOrReturnCtx(e),{code:X.invalid_date}),u7;let t=new l7,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Z(n,{code:X.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),Z(n,{code:X.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):r7.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)}};O7.create=e=>new O7({checks:[],coerce:e?.coerce||!1,typeName:s9.ZodDate,...y7(e)});var k7=class extends b7{_parse(e){if(this._getType(e)!==Y.symbol){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.symbol,received:t.parsedType}),u7}return f7(e.data)}};k7.create=e=>new k7({typeName:s9.ZodSymbol,...y7(e)});var A7=class extends b7{_parse(e){if(this._getType(e)!==Y.undefined){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.undefined,received:t.parsedType}),u7}return f7(e.data)}};A7.create=e=>new A7({typeName:s9.ZodUndefined,...y7(e)});var j7=class extends b7{_parse(e){if(this._getType(e)!==Y.null){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.null,received:t.parsedType}),u7}return f7(e.data)}};j7.create=e=>new j7({typeName:s9.ZodNull,...y7(e)});var M7=class extends b7{constructor(){super(...arguments),this._any=!0}_parse(e){return f7(e.data)}};M7.create=e=>new M7({typeName:s9.ZodAny,...y7(e)});var N7=class extends b7{constructor(){super(...arguments),this._unknown=!0}_parse(e){return f7(e.data)}};N7.create=e=>new N7({typeName:s9.ZodUnknown,...y7(e)});var P7=class extends b7{_parse(e){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.never,received:t.parsedType}),u7}};P7.create=e=>new P7({typeName:s9.ZodNever,...y7(e)});var F7=class extends b7{_parse(e){if(this._getType(e)!==Y.undefined){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.void,received:t.parsedType}),u7}return f7(e.data)}};F7.create=e=>new F7({typeName:s9.ZodVoid,...y7(e)});var I7=class e extends b7{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Y.array)return Z(t,{code:X.invalid_type,expected:Y.array,received:t.parsedType}),u7;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Z(t,{code:e?X.too_big:X.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&&(Z(t,{code:X.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&&(Z(t,{code:X.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 _7(t,e,t.path,n)))).then(e=>l7.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new _7(t,e,t.path,n)));return l7.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)}};I7.create=(e,t)=>new I7({type:e,minLength:null,maxLength:null,exactLength:null,typeName:s9.ZodArray,...y7(t)});function L7(e){if(e instanceof R7){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=$7.create(L7(r))}return new R7({...e._def,shape:()=>t})}return e instanceof I7?new I7({...e._def,type:L7(e.element)}):e instanceof $7?$7.create(L7(e.unwrap())):e instanceof e9?e9.create(L7(e.unwrap())):e instanceof U7?U7.create(e.items.map(e=>L7(e))):e}var R7=class e extends b7{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=r7.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==Y.object){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.object,received:t.parsedType}),u7}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof P7&&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 _7(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof P7){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&&(Z(n,{code:X.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 _7(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=>l7.mergeObjectSync(t,e)):l7.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:s9.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 r7.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 r7.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return L7(this)}partial(t){let n={};for(let e of r7.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 r7.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof $7;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return J7(r7.objectKeys(this.shape))}};R7.create=(e,t)=>new R7({shape:()=>e,unknownKeys:`strip`,catchall:P7.create(),typeName:s9.ZodObject,...y7(t)}),R7.strictCreate=(e,t)=>new R7({shape:()=>e,unknownKeys:`strict`,catchall:P7.create(),typeName:s9.ZodObject,...y7(t)}),R7.lazycreate=(e,t)=>new R7({shape:e,unknownKeys:`strip`,catchall:P7.create(),typeName:s9.ZodObject,...y7(t)});var z7=class extends b7{_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 a7(e.ctx.common.issues));return Z(t,{code:X.invalid_union,unionErrors:n}),u7}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 a7(e));return Z(t,{code:X.invalid_union,unionErrors:i}),u7}}get options(){return this._def.options}};z7.create=(e,t)=>new z7({options:e,typeName:s9.ZodUnion,...y7(t)});var B7=e=>e instanceof K7?B7(e.schema):e instanceof Q7?B7(e.innerType()):e instanceof q7?[e.value]:e instanceof Y7?e.options:e instanceof X7?r7.objectValues(e.enum):e instanceof t9?B7(e._def.innerType):e instanceof A7?[void 0]:e instanceof j7?[null]:e instanceof $7?[void 0,...B7(e.unwrap())]:e instanceof e9?[null,...B7(e.unwrap())]:e instanceof i9||e instanceof o9?B7(e.unwrap()):e instanceof n9?B7(e._def.innerType):[],rie=class e extends b7{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.object)return Z(t,{code:X.invalid_type,expected:Y.object,received:t.parsedType}),u7;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}):(Z(t,{code:X.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),u7)}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=B7(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:s9.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...y7(r)})}};function V7(e,t){let n=i7(e),r=i7(t);if(e===t)return{valid:!0,data:e};if(n===Y.object&&r===Y.object){let n=r7.objectKeys(t),r=r7.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=V7(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}if(n===Y.array&&r===Y.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=V7(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}return n===Y.date&&r===Y.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var H7=class extends b7{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(p7(e)||p7(r))return u7;let i=V7(e.value,r.value);return i.valid?((m7(e)||m7(r))&&t.dirty(),{status:t.value,value:i.data}):(Z(n,{code:X.invalid_intersection_types}),u7)};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}))}};H7.create=(e,t,n)=>new H7({left:e,right:t,typeName:s9.ZodIntersection,...y7(n)});var U7=class e extends b7{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.array)return Z(n,{code:X.invalid_type,expected:Y.array,received:n.parsedType}),u7;if(n.data.length<this._def.items.length)return Z(n,{code:X.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),u7;!this._def.rest&&n.data.length>this._def.items.length&&(Z(n,{code:X.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 _7(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>l7.mergeArray(t,e)):l7.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};U7.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new U7({items:e,typeName:s9.ZodTuple,rest:null,...y7(t)})};var iie=class e extends b7{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!==Y.object)return Z(n,{code:X.invalid_type,expected:Y.object,received:n.parsedType}),u7;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new _7(n,e,n.path,e)),value:a._parse(new _7(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?l7.mergeObjectAsync(t,r):l7.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof b7?new e({keyType:t,valueType:n,typeName:s9.ZodRecord,...y7(r)}):new e({keyType:w7.create(),valueType:t,typeName:s9.ZodRecord,...y7(n)})}},W7=class extends b7{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!==Y.map)return Z(n,{code:X.invalid_type,expected:Y.map,received:n.parsedType}),u7;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new _7(n,e,n.path,[a,`key`])),value:i._parse(new _7(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 u7;(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 u7;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};W7.create=(e,t,n)=>new W7({valueType:t,keyType:e,typeName:s9.ZodMap,...y7(n)});var G7=class e extends b7{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==Y.set)return Z(n,{code:X.invalid_type,expected:Y.set,received:n.parsedType}),u7;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(Z(n,{code:X.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&&(Z(n,{code:X.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 u7;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 _7(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)}};G7.create=(e,t)=>new G7({valueType:e,minSize:null,maxSize:null,typeName:s9.ZodSet,...y7(t)});var aie=class e extends b7{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==Y.function)return Z(t,{code:X.invalid_type,expected:Y.function,received:t.parsedType}),u7;function n(e,n){return c7({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s7(),o7].filter(e=>!!e),issueData:{code:X.invalid_arguments,argumentsError:n}})}function r(e,n){return c7({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s7(),o7].filter(e=>!!e),issueData:{code:X.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof Z7){let e=this;return f7(async function(...t){let o=new a7([]),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 f7(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new a7([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new a7([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:U7.create(t).rest(N7.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||U7.create([]).rest(N7.create()),returns:n||N7.create(),typeName:s9.ZodFunction,...y7(r)})}},K7=class extends b7{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})}};K7.create=(e,t)=>new K7({getter:e,typeName:s9.ZodLazy,...y7(t)});var q7=class extends b7{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return Z(t,{received:t.data,code:X.invalid_literal,expected:this._def.value}),u7}return{status:`valid`,value:e.data}}get value(){return this._def.value}};q7.create=(e,t)=>new q7({value:e,typeName:s9.ZodLiteral,...y7(t)});function J7(e,t){return new Y7({values:e,typeName:s9.ZodEnum,...y7(t)})}var Y7=class e extends b7{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return Z(t,{expected:r7.joinValues(n),received:t.parsedType,code:X.invalid_type}),u7}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return Z(t,{received:t.data,code:X.invalid_enum_value,options:n}),u7}return f7(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})}};Y7.create=J7;var X7=class extends b7{_parse(e){let t=r7.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==Y.string&&n.parsedType!==Y.number){let e=r7.objectValues(t);return Z(n,{expected:r7.joinValues(e),received:n.parsedType,code:X.invalid_type}),u7}if(this._cache||=new Set(r7.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=r7.objectValues(t);return Z(n,{received:n.data,code:X.invalid_enum_value,options:e}),u7}return f7(e.data)}get enum(){return this._def.values}};X7.create=(e,t)=>new X7({values:e,typeName:s9.ZodNativeEnum,...y7(t)});var Z7=class extends b7{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==Y.promise&&t.common.async===!1?(Z(t,{code:X.invalid_type,expected:Y.promise,received:t.parsedType}),u7):f7((t.parsedType===Y.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Z7.create=(e,t)=>new Z7({type:e,typeName:s9.ZodPromise,...y7(t)});var Q7=class extends b7{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===s9.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=>{Z(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 u7;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?u7:r.status===`dirty`||t.value===`dirty`?d7(r.value):r});{if(t.value===`aborted`)return u7;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?u7:r.status===`dirty`||t.value===`dirty`?d7(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`?u7:(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`?u7:(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(!h7(e))return u7;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=>h7(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):u7)}r7.assertNever(r)}};Q7.create=(e,t,n)=>new Q7({schema:e,typeName:s9.ZodEffects,effect:t,...y7(n)}),Q7.createWithPreprocess=(e,t,n)=>new Q7({schema:t,effect:{type:`preprocess`,transform:e},typeName:s9.ZodEffects,...y7(n)});var $7=class extends b7{_parse(e){return this._getType(e)===Y.undefined?f7(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};$7.create=(e,t)=>new $7({innerType:e,typeName:s9.ZodOptional,...y7(t)});var e9=class extends b7{_parse(e){return this._getType(e)===Y.null?f7(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};e9.create=(e,t)=>new e9({innerType:e,typeName:s9.ZodNullable,...y7(t)});var t9=class extends b7{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===Y.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};t9.create=(e,t)=>new t9({innerType:e,typeName:s9.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...y7(t)});var n9=class extends b7{_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 g7(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new a7(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new a7(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};n9.create=(e,t)=>new n9({innerType:e,typeName:s9.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...y7(t)});var r9=class extends b7{_parse(e){if(this._getType(e)!==Y.nan){let t=this._getOrReturnCtx(e);return Z(t,{code:X.invalid_type,expected:Y.nan,received:t.parsedType}),u7}return{status:`valid`,value:e.data}}};r9.create=e=>new r9({typeName:s9.ZodNaN,...y7(e)});var i9=class extends b7{_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}},a9=class e extends b7{_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`?u7:e.status===`dirty`?(t.dirty(),d7(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`?u7: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:s9.ZodPipeline})}},o9=class extends b7{_parse(e){let t=this._def.innerType._parse(e),n=e=>(h7(e)&&(e.value=Object.freeze(e.value)),e);return g7(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};o9.create=(e,t)=>new o9({innerType:e,typeName:s9.ZodReadonly,...y7(t)}),R7.lazycreate;var s9;(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`})(s9||={});var $=w7.create,c9=T7.create;r9.create,E7.create,D7.create,O7.create,k7.create,A7.create,j7.create,M7.create;var l9=N7.create;P7.create,F7.create;var u9=I7.create,d9=R7.create;R7.strictCreate,z7.create;var oie=rie.create;H7.create,U7.create;var f9=iie.create;W7.create,G7.create,aie.create,K7.create;var p9=q7.create;Y7.create,X7.create,Z7.create,Q7.create,$7.create;var sie=e9.create;Q7.createWithPreprocess,a9.create;function m9(...e){return e.reduce((e,t)=>({...e,...t??{}}),{})}function h9(e){return Object.fromEntries([...e.headers])}var g9=`AI_DownloadError`,_9=`vercel.ai.error.${g9}`,cie=Symbol.for(_9),v9,y9,b9=class extends (y9=D5,v9=cie,y9){constructor({url:e,statusCode:t,statusText:n,cause:r,message:i=r==null?`Failed to download ${e}: ${t} ${n}`:`Failed to download ${e}: ${r}`}){super({name:g9,message:i,cause:r}),this[v9]=!0,this.url=e,this.statusCode=t,this.statusText=n}static isInstance(e){return D5.hasMarker(e,_9)}};async function lie(e){try{await e.body?.cancel()}catch{}}var x9=globalThis.fetch;uie(x9);function uie(e){if(typeof e!=`function`)return!1;let t=Function.prototype.toString.call(e);return t.includes(`internal/deps/undici`)||t.includes(`lazy loading of undici`)}var die=2147483648;async function fie({response:e,url:t,maxBytes:n=die}){let r=e.headers.get(`content-length`);if(r!=null){let i=parseInt(r,10);if(!isNaN(i)&&i>n)throw await lie(e),new b9({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes (Content-Length: ${i}).`})}let i=e.body;if(i==null)return new Uint8Array;let a=i.getReader(),o=[],s=0;try{for(;;){let{done:e,value:r}=await a.read();if(e)break;if(s+=r.length,s>n)throw new b9({url:t,message:`Download of ${t} exceeded maximum size of ${n} bytes.`});o.push(r)}}finally{try{await a.cancel()}catch{}finally{a.releaseLock()}}let c=new Uint8Array(s),l=0;for(let e of o)c.set(e,l),l+=e.length;return c}var pie=(({prefix:e,size:t=16,alphabet:n=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,separator:r=`-`}={})=>{let i=()=>{let e=n.length,r=Array(t);for(let i=0;i<t;i++)r[i]=n[Math.random()*e|0];return r.join(``)};if(e==null)return i;if(n.includes(r))throw new kre({argument:`separator`,message:`The separator "${r}" must not be part of the alphabet "${n}".`});return()=>`${e}${r}${i()}`})();function S9(e){return(e instanceof Error||e instanceof DOMException)&&(e.name===`AbortError`||e.name===`ResponseAborted`||e.name===`TimeoutError`)}var mie=[`fetch failed`,`failed to fetch`],hie=new Set([`ConnectionRefused`,`ConnectionClosed`,`FailedToOpenSocket`,`ECONNRESET`,`ECONNREFUSED`,`ETIMEDOUT`,`EPIPE`,`UND_ERR_SOCKET`,`UND_ERR_HEADERS_TIMEOUT`,`UND_ERR_BODY_TIMEOUT`,`UND_ERR_CONNECT_TIMEOUT`]);function gie(e){let t=new Set,n=e;for(;n instanceof Error&&!t.has(n);){t.add(n);let e=n;if(typeof e.code==`string`&&hie.has(e.code))return e;n=n.cause}}function C9({error:e,url:t,requestBodyValues:n}){if(S9(e))return e;if(e instanceof TypeError&&mie.includes(e.message.toLowerCase())){let r=e.cause;if(r!=null)return new M5({message:`Cannot connect to API: ${r.message}`,cause:r,url:t,requestBodyValues:n,isRetryable:!0})}let r=gie(e);return r==null?e:M5.isInstance(e)?new M5({message:e.message,cause:e.cause,url:e.url,requestBodyValues:e.requestBodyValues,statusCode:e.statusCode,responseHeaders:e.responseHeaders,responseBody:e.responseBody,data:e.data,isRetryable:!0}):new M5({message:`Cannot connect to API: ${e instanceof Error?e.message:r.message}`,cause:e,url:t,requestBodyValues:n,isRetryable:!0})}function _ie(e=globalThis){return e.window?`runtime/browser`:e.navigator?.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:e.process?.versions?.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?`runtime/vercel-edge`:`runtime/unknown`}function vie(e){if(e==null)return{};let t={};if(e instanceof Headers)e.forEach((e,n)=>{t[n.toLowerCase()]=e});else{Array.isArray(e)||(e=Object.entries(e));for(let[n,r]of e)r!=null&&(t[n.toLowerCase()]=r)}return t}function yie(e,...t){let n=new Headers(vie(e)),r=n.get(`user-agent`)||``;return n.set(`user-agent`,[r,...t].filter(Boolean).join(` `)),Object.fromEntries(n.entries())}var bie=`3.0.36`;function xie({apiKey:e,environmentVariableName:t,apiKeyParameterName:n=`apiKey`,description:r}){if(typeof e==`string`)return e;if(e!=null)throw new Z5({message:`${r} API key must be a string.`});if(typeof process>`u`)throw new Z5({message:`${r} API key is missing. Pass it using the '${n}' parameter. Environment variables is not supported in this environment.`});if(e={}[t],e==null)throw new Z5({message:`${r} API key is missing. Pass it using the '${n}' parameter or the ${t} environment variable.`});if(typeof e!=`string`)throw new Z5({message:`${r} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}var Sie=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,Cie=/"(?: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 w9(e){let t=JSON.parse(e);return typeof t!=`object`||!t||Sie.test(e)===!1&&Cie.test(e)===!1?t:wie(t)}function wie(e){let t=[e];for(;t.length;){let e=t;t=[];for(let n of e){if(Object.prototype.hasOwnProperty.call(n,`__proto__`)||Object.prototype.hasOwnProperty.call(n,`constructor`)&&n.constructor!==null&&typeof n.constructor==`object`&&Object.prototype.hasOwnProperty.call(n.constructor,`prototype`))throw SyntaxError(`Object contains forbidden prototype property`);for(let e in n){let r=n[e];r&&typeof r==`object`&&t.push(r)}}}return e}function T9(e){let{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return w9(e)}try{return w9(e)}finally{Error.stackTraceLimit=t}}var E9=Symbol.for(`vercel.ai.validator`);function Tie(e){return{[E9]:!0,validate:e}}function Eie(e){return typeof e==`object`&&!!e&&E9 in e&&e[E9]===!0&&`validate`in e}function Die(e){return Eie(e)?e:`~standard`in e?Oie(e):e()}function Oie(e){return Tie(async t=>{let n=await e[`~standard`].validate(t);return n.issues==null?{success:!0,value:n.value}:{success:!1,error:new n7({value:t,cause:n.issues})}})}async function kie({value:e,schema:t}){let n=await D9({value:e,schema:t});if(!n.success)throw n7.wrap({value:e,cause:n.error});return n.value}async function D9({value:e,schema:t}){let n=Die(t);try{if(n.validate==null)return{success:!0,value:e,rawValue:e};let t=await n.validate(e);return t.success?{success:!0,value:t.value,rawValue:e}:{success:!1,error:n7.wrap({value:e,cause:t.error}),rawValue:e}}catch(t){return{success:!1,error:n7.wrap({value:e,cause:t}),rawValue:e}}}async function Aie({text:e,schema:t}){try{let n=T9(e);return t==null?n:kie({value:n,schema:t})}catch(t){throw K5.isInstance(t)||n7.isInstance(t)?t:new K5({text:e,cause:t})}}async function O9({text:e,schema:t}){try{let n=T9(e);return t==null?{success:!0,value:n,rawValue:n}:await D9({value:n,schema:t})}catch(t){return{success:!1,error:K5.isInstance(t)?t:new K5({text:e,cause:t}),rawValue:void 0}}}function jie({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Eq).pipeThrough(new TransformStream({async transform({data:e},n){e!==`[DONE]`&&n.enqueue(await O9({text:e,schema:t}))}}))}var Mie=()=>globalThis.fetch,k9=async({url:e,headers:t,body:n,failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o})=>Nie({url:e,headers:{"Content-Type":`application/json`,...t},body:{content:JSON.stringify(n),values:n},failedResponseHandler:r,successfulResponseHandler:i,abortSignal:a,fetch:o}),Nie=async({url:e,headers:t={},body:n,successfulResponseHandler:r,failedResponseHandler:i,abortSignal:a,fetch:o=Mie()})=>{try{let s=await o(e,{method:`POST`,headers:yie(t,`ai-sdk/provider-utils/${bie}`,_ie()),body:n.content,signal:a}),c=h9(s);if(!s.ok){let t;try{t=await i({response:s,url:e,requestBodyValues:n.values})}catch(t){throw S9(t)||M5.isInstance(t)?t:new M5({message:`Failed to process error response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}throw t.value}try{return await r({response:s,url:e,requestBodyValues:n.values})}catch(t){throw t instanceof Error&&(S9(t)||M5.isInstance(t))?t:new M5({message:`Failed to process successful response`,cause:t,statusCode:s.status,url:e,responseHeaders:c,requestBodyValues:n.values})}}catch(t){throw C9({error:t,url:e,requestBodyValues:n.values})}},Pie=new TextDecoder;function Fie({stream:e,url:t,requestBodyValues:n,statusCode:r,responseHeaders:i}){let a=e.getReader(),o=!1,s=()=>{o||=(a.releaseLock(),!0)};return new ReadableStream({async pull(e){try{let{done:t,value:n}=await a.read();t?(s(),e.close()):e.enqueue(n)}catch(a){if(s(),S9(a)){e.error(a);return}e.error(C9({error:new M5({message:`Failed to process successful response`,cause:a,statusCode:r,url:t,responseHeaders:i,requestBodyValues:n}),url:t,requestBodyValues:n}))}},async cancel(e){try{await a.cancel(e)}finally{s()}}})}async function A9({response:e,url:t}){return Pie.decode(await fie({response:e,url:t}))}var Iie=({errorSchema:e,errorToMessage:t,isRetryable:n})=>async({response:r,url:i,requestBodyValues:a})=>{let o=await A9({response:r,url:i}),s=h9(r);if(o.trim()===``)return{responseHeaders:s,value:new M5({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})};try{let c=await Aie({text:o,schema:e});return{responseHeaders:s,value:new M5({message:t(c),url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,data:c,isRetryable:n?.(r,c)})}}catch{return{responseHeaders:s,value:new M5({message:r.statusText,url:i,requestBodyValues:a,statusCode:r.status,responseHeaders:s,responseBody:o,isRetryable:n?.(r)})}}},Lie=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=h9(t);if(t.body==null)throw new Dre({});return{responseHeaders:i,value:jie({stream:Fie({stream:t.body,url:n,requestBodyValues:r,statusCode:t.status,responseHeaders:i}),schema:e})}},Rie=e=>async({response:t,url:n,requestBodyValues:r})=>{let i=await A9({response:t,url:n}),a=await O9({text:i,schema:e}),o=h9(t);if(!a.success)throw new M5({message:`Invalid JSON response`,cause:a.error,statusCode:t.status,responseHeaders:o,responseBody:i,url:n,requestBodyValues:r});return{responseHeaders:o,value:a.value,rawValue:a.rawValue}},{btoa:zie,atob:Bie}=globalThis,Vie={debug:(e,t)=>console.debug(`[dify-ai-provider] ${e}`,t??``),info:(e,t)=>console.log(`[dify-ai-provider] ${e}`,t??``),warn:(e,t)=>console.warn(`[dify-ai-provider] ${e}`,t??``),error:(e,t)=>console.error(`[dify-ai-provider] ${e}`,t??``)},Hie=d9({id:$(),answer:$(),task_id:$(),conversation_id:$(),message_id:$(),metadata:d9({usage:d9({completion_tokens:c9(),prompt_tokens:c9(),total_tokens:c9()})})}),Uie=d9({code:$(),message:$(),status:c9()}),j9=d9({event:$(),conversation_id:$().optional(),message_id:$().optional(),task_id:$().optional(),created_at:c9().optional()}).passthrough(),Wie=j9.extend({event:p9(`workflow_started`),workflow_run_id:$(),data:d9({id:$(),workflow_id:$(),created_at:c9()}).passthrough()}),Gie=j9.extend({event:p9(`workflow_finished`),workflow_run_id:$(),task_id:$().optional(),data:d9({id:$(),workflow_id:$(),outputs:f9(l9()).optional(),status:$().optional(),elapsed_time:c9().optional(),total_tokens:c9().optional(),total_steps:$().optional(),created_at:c9().optional(),finished_at:c9().optional()}).passthrough()}),Kie=j9.extend({event:p9(`node_started`),workflow_run_id:$(),data:d9({id:$(),node_id:$(),node_type:$()}).passthrough()}),qie=j9.extend({event:p9(`node_finished`),workflow_run_id:$(),data:d9({id:$(),node_id:$(),node_type:$()}).passthrough()}),Jie=j9.extend({event:p9(`message`),id:$().optional(),answer:$(),from_variable_selector:u9($()).optional()}),Yie=j9.extend({event:p9(`message_end`),id:$().optional(),metadata:d9({usage:d9({prompt_tokens:c9().optional(),completion_tokens:c9().optional(),total_tokens:c9().optional(),prompt_unit_price:$().optional(),prompt_price_unit:$().optional(),prompt_price:$().optional(),completion_unit_price:$().optional(),completion_price_unit:$().optional(),completion_price:$().optional(),total_price:$().optional(),currency:$().optional(),latency:c9().optional()}).passthrough(),retriever_resources:u9(l9()).optional()}).passthrough(),files:sie(u9(l9())).optional()}),Xie=j9.extend({event:p9(`tts_message`),audio:$()}),Zie=j9.extend({event:p9(`tts_message_end`),audio:$()}),Qie=j9.extend({event:p9(`agent_message`),answer:$()}),$ie=oie(`event`,[Wie,Gie,Kie,qie,Jie,Yie,Xie,Zie,j9.extend({event:p9(`agent_thought`),id:$(),position:c9(),thought:$(),observation:$(),tool:$(),tool_labels:f9($(),$()).optional(),tool_input:$(),message_files:u9(l9())}),Qie,j9.extend({event:p9(`message_replace`),answer:$()}),j9.extend({event:p9(`message_file`),id:$(),type:$(),belongs_to:$(),url:$()}),j9.extend({event:p9(`ping`)}),j9.extend({event:p9(`error`),status:c9().optional(),code:$().optional(),message:$().optional()})]).or(j9),eae=class{constructor(){this.state=`text`,this.buffer=``,this.accumulated=``,this.hasStarted=!1,this.closed=!1,this.textAccumulated=``,this.inString=!1,this.escape=!1}feed(e){let t=[];this.accumulated+=e;for(let n=0;n<e.length;n++){let r=e[n];if(!this.hasStarted){if(r.trim()===``)continue;this.hasStarted=!0}if(this.inString){this.escape?(this.escape=!1,t.push({type:`text`,content:r})):r===`\\`?(this.escape=!0,t.push({type:`text`,content:r})):(r===`"`&&(this.inString=!1),t.push({type:`text`,content:r}));continue}if(r===`"`){this.inString=!0,t.push({type:`text`,content:r});continue}switch(this.state){case`text`:r===`<`&&!this.closed?(this.state=`maybe-open`,this.buffer=`<`):t.push({type:`text`,content:r});break;case`maybe-open`:this.buffer+=r,`<think>`.startsWith(this.buffer)?this.buffer===`<think>`&&(this.state=`reasoning`,this.buffer=``):(t.push({type:`text`,content:this.buffer}),this.buffer=``,this.state=`text`);break;case`reasoning`:r===`<`?(this.state=`maybe-close`,this.buffer=`<`):t.push({type:`reasoning`,content:r});break;case`maybe-close`:this.buffer+=r,`</think>`.startsWith(this.buffer)?this.buffer===`</think>`&&(this.state=`text`,this.buffer=``,this.closed=!0):(t.push({type:`reasoning`,content:this.buffer}),this.buffer=``,this.state=`reasoning`)}}let n=[];for(let e of t){let t=n[n.length-1];t&&t.type===e.type?t.content+=e.content:n.push({...e})}for(let e of n)e.type===`text`&&(this.textAccumulated+=e.content);return n}flush(){if(!this.buffer)return[];let e=this.state===`maybe-close`?`reasoning`:`text`,t=[{type:e,content:this.buffer}];return e===`text`&&(this.textAccumulated+=this.buffer),this.buffer=``,t}reset(e){this.accumulated=``,this.buffer=``,this.state=`text`,this.closed=!1,this.hasStarted=!1,this.inString=!1,this.escape=!1,this.feed(e)}getTextWithoutThink(){return this.textAccumulated.trim()}};function M9(e,t,n){let r=[],i=e;if(!t.length)return{toolCalls:r,cleanText:i};let a=t.map(e=>e.toLowerCase()),o=[],s=0,c=!1,l=!1,u=-1;for(let i=0;i<e.length;i++){let d=e[i];if(l){l=!1;continue}if(d===`\\`){l=!0;continue}if(d===`"`){c=!c;continue}if(!c){if(d===`{`)s===0&&(u=i),s++;else if(d===`}`&&(s--,s<0&&(s=0),s===0&&u!==-1)){let s=e.substring(u,i+1);try{let e=JSON.parse(s);if(e&&typeof e==`object`&&`name`in e&&`arguments`in e){let i=String(e.name).toLowerCase(),c=a.indexOf(i);c!==-1&&(r.push({id:n(),name:t[c],input:JSON.stringify(e.arguments)}),o.push(s))}}catch{}u=-1}}}for(let e of o)i=i.replace(e,``);return{toolCalls:r,cleanText:i.trim()}}function N9(e){if(!e)return`"..."`;let t=e.type;if(t===`array`)return`[${e.items?N9(e.items):`"..."`}]`;if(t===`object`){let t=e.properties;return t?`{${Object.entries(t).slice(0,3).map(([e,t])=>`"${e}": ${N9(t)}`).join(`, `)}}`:`{}`}return t===`number`||t===`integer`?`0`:t===`boolean`?`true`:`"..."`}var P9={question:`Ask the user a question`,bash:`Execute a bash command`,read:`Read a file`,glob:`Find files by pattern`,grep:`Search file contents with regex`,edit:`Edit a file with string replacement`,write:`Write/create a file`,task:`Launch a sub-agent for complex tasks`,webfetch:`Fetch content from a URL`,todowrite:`Create/manage a task list`,skill:`Load a specialized skill`};function tae(e,t){return P9[e]?P9[e]:t?t.replace(/[\r\n]+/g,` `).split(/[.!?。]/)[0].trim().substring(0,60):e}function nae(e){if(!e?.length)return{prompt:``,toolNames:[]};let t=e.filter(e=>e.type===`function`).map(e=>({name:e.name,description:e.description,parameters:e.inputSchema}));if(!t.length)return{prompt:``,toolNames:[]};let n=t.map(e=>e.name);return{prompt:`
|
|
176
|
-
|
|
177
|
-
# Tools
|
|
178
|
-
Call tools with JSON format:
|
|
179
|
-
|
|
180
|
-
${t.map(e=>{let t=e.parameters,n=t?.properties?Object.entries(t.properties).map(([e,t])=>`"${e}": ${N9(t)}`).join(`, `):``,r=tae(e.name,e.description);return`- ${e.name}: ${r}
|
|
181
|
-
{"name": "${e.name}", "arguments": {${n}}}`}).join(`
|
|
182
|
-
`)}`,toolNames:n}}async function rae(e,t,n,r,i,a,o){try{let s;if(typeof e==`string`){let n=Buffer.from(e,`base64`);s=new Blob([n],{type:t})}else s=new Blob([e],{type:t});let c=new FormData;c.append(`file`,s,n),c.append(`user`,r);let{"content-type":l,"Content-Type":u,...d}=a(),f=await fetch(`${i}/files/upload`,{method:`POST`,headers:{...d},body:c});if(!f.ok){let e=await f.text().catch(()=>``);o?.error(`Dify file upload failed`,{status:f.status,statusText:f.statusText,body:e});return}return(await f.json()).id}catch(e){o?.error(`Dify file upload error`,{error:String(e)});return}}async function iae(e,t,n,r,i){let a=[];for(let o of e)if(Array.isArray(o.content))for(let e of o.content){if(!e||typeof e!=`object`||e.type!==`file`)continue;let o=e.mediaType||e.mimeType||``;if(!o)continue;let s,c=e.filename||`file.${o.split(`/`)[1]||`bin`}`;if(typeof e.data==`string`){let t=e.data.match(/^data:[^;]+;base64,(.+)$/);s=t?t[1]:e.data}else e.data instanceof Uint8Array&&(s=e.data);if(s){let e=rae(s,o,c,t,n,r,i).then(e=>{if(e)return{type:o.startsWith(`image/`)?`image`:`document`,transfer_method:`local_file`,upload_file_id:e};i?.warn(`Dify file upload skipped, attachment will be missing`,{filename:c,mimeType:o})});a.push(e)}}return(await Promise.all(a)).filter(e=>e!==void 0)}function aae(e){if(!e)return``;let t=e.trim(),n=t.match(/<env>([\s\S]*?)<\/env>/),r=t.match(/<directories>([\s\S]*?)<\/directories>/),i=t.match(/^You are\b[^.]*\./m);if(n||i||r){let e=[];return i&&e.push(i[0]),n&&e.push(`<env>${n[1]}</env>`),r&&e.push(`<directories>${r[1]}</directories>`),e.join(`
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
`)}return t}function oae(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function F9(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t)return t}}function sae(e,t){return Array.isArray(e)?e.map((e,n)=>{let r=oae(e)?e:{},i=F9(r,[`segment_id`,`document_id`,`id`])??`retriever-resource-${n+1}`,a=F9(r,[`document_name`,`title`,`dataset_name`,`segment_id`,`id`])??`Retriever resource ${n+1}`,o=F9(r,[`document_name`,`filename`]);return{type:`source`,sourceType:`document`,id:i,mediaType:`text/plain`,title:a,...o?{filename:o}:{},providerMetadata:{difyWorkflowData:{...t,retrieverResource:e}}}}):[]}var cae=class{constructor(e,t,n){this.settings=t,this.specificationVersion=`v2`,this.supportedUrls={},this.modelId=e,this.config=n,this.generateId=pie,this.chatMessagesEndpoint=`${this.config.baseURL}/chat-messages`,this.logger=t.logger===!1?void 0:t.logger??Vie,this.settings.responseMode||(this.settings.responseMode=`streaming`)}createErrorHandler(){return Iie({errorSchema:Uie,errorToMessage:e=>{var t;return(t=this.logger)==null||t.error(`Dify API error`,e),`Dify API error: ${e.message}`}})}get provider(){return this.config.provider}async doGenerate(e){var t,n;let{abortSignal:r}=e,{body:i,toolNames:a,requestHeaders:o}=await this.getRequestBody(e),s={...i,response_mode:`blocking`};this.settings.logMessages&&((t=this.logger)==null||t.info(``,{body:s}));let{responseHeaders:c,value:l}=await k9({url:this.chatMessagesEndpoint,headers:m9(this.config.headers(),o??e.headers),body:s,abortSignal:r,failedResponseHandler:this.createErrorHandler(),successfulResponseHandler:Rie(Hie),fetch:this.config.fetch}),u=l;this.settings.logMessages&&((n=this.logger)==null||n.info(``,{answer:u.answer,conversation_id:u.conversation_id}));let d=[];if(u.answer){let{toolCalls:e,cleanText:t}=M9(u.answer,a,this.generateId);t&&d.push({type:`text`,text:t});for(let t of e)d.push({type:`tool-call`,toolCallId:t.id,toolName:t.name,input:t.input})}return{content:d,finishReason:d.some(e=>e.type===`tool-call`)?`tool-calls`:`stop`,usage:{inputTokens:u.metadata.usage.prompt_tokens,outputTokens:u.metadata.usage.completion_tokens,totalTokens:u.metadata.usage.total_tokens},warnings:[],providerMetadata:{difyWorkflowData:{conversationId:u.conversation_id,messageId:u.message_id}},request:{body:JSON.stringify(s)},response:{id:u.id,timestamp:new Date,headers:c}}}async doStream(e){var t,n;this.settings.logMessages&&((t=this.logger)==null||t.info(``,{options:e}));let{abortSignal:r}=e,{body:i,toolNames:a,requestHeaders:o}=await this.getRequestBody(e),s={...i,response_mode:`streaming`};this.settings.logMessages&&((n=this.logger)==null||n.info(``,{body:s}));let{responseHeaders:c,value:l}=await k9({url:this.chatMessagesEndpoint,headers:m9(this.config.headers(),o??e.headers),body:s,failedResponseHandler:this.createErrorHandler(),successfulResponseHandler:Lie($ie),abortSignal:r,fetch:this.config.fetch}),u,d,f,p=!1,m=!1,h=new eae,g=this.generateId,_=this.logger,v=this.settings.logMessages;function y(){let e={};return u&&(e.conversationId=u),d&&(e.messageId=d),f&&(e.taskId=f),e}function b(){let e=y();return Object.keys(e).length?{providerMetadata:{difyWorkflowData:e}}:{}}function x(e,t){for(let n of e)n.type===`reasoning`?(p&&=(t.enqueue({type:`text-end`,id:`0`,...b()}),!1),m||(m=!0,t.enqueue({type:`reasoning-start`,id:`r0`,...b()})),t.enqueue({type:`reasoning-delta`,id:`r0`,delta:n.content,...b()})):n.content&&(m&&=(t.enqueue({type:`reasoning-end`,id:`r0`,...b()}),!1),p||(p=!0,t.enqueue({type:`text-start`,id:`0`,...b()})),t.enqueue({type:`text-delta`,id:`0`,delta:n.content,...b()}))}return{stream:l.pipeThrough(new TransformStream({transform(e,t){if(!e.success){_?.error(`Dify stream parse error`,{error:String(e.error)}),t.enqueue({type:`error`,error:e.error});return}let n=e.value;switch(v&&_?.info(``,{data:n}),n.conversation_id&&(u=n.conversation_id),n.message_id&&(d=n.message_id),n.task_id&&(f=n.task_id),n.event){case`workflow_finished`:case`message_end`:{let e=0,r=0,i=0;if(n.event===`workflow_finished`){let t=n.data||{};e=0,r=t.total_tokens??0,i=t.total_tokens??0}else{let t=n.metadata?.usage||{};e=t.prompt_tokens??0,r=t.completion_tokens??0,i=t.total_tokens??0}let{toolCalls:o}=M9(h.getTextWithoutThink(),a,g),s=o.length>0;if(v&&_?.info(``,{toolCalls:o}),x(h.flush(),t),m&&=(t.enqueue({type:`reasoning-end`,id:`r0`,...b()}),!1),p?(t.enqueue({type:`text-end`,id:`0`,...b()}),p=!1):s||(t.enqueue({type:`text-start`,id:`0`,...b()}),t.enqueue({type:`text-end`,id:`0`,...b()})),n.event===`message_end`)for(let e of sae(n.metadata?.retriever_resources,y()))t.enqueue(e);for(let e of o)t.enqueue({type:`tool-input-start`,id:e.id,toolName:e.name,...b()}),t.enqueue({type:`tool-input-delta`,id:e.id,delta:e.input,...b()}),t.enqueue({type:`tool-input-end`,id:e.id,...b()}),t.enqueue({type:`tool-call`,toolCallId:e.id,toolName:e.name,input:e.input,...b()});t.enqueue({type:`finish`,finishReason:s?`tool-calls`:`stop`,...b(),usage:{inputTokens:e,outputTokens:r,totalTokens:i}});break}case`message`:case`agent_message`:`answer`in n&&typeof n.answer==`string`&&n.answer&&(x(h.feed(n.answer),t),`id`in n&&typeof n.id==`string`&&t.enqueue({type:`response-metadata`,id:n.id}));break;case`agent_thought`:break;case`message_replace`:`answer`in n&&typeof n.answer==`string`&&n.answer&&(h.reset(n.answer),p&&=(t.enqueue({type:`text-end`,id:`0`,...b()}),!1),t.enqueue({type:`text-start`,id:`0`,...b()}),t.enqueue({type:`text-delta`,id:`0`,delta:n.answer,...b()}),p=!0);break;case`message_file`:case`ping`:break;case`error`:{let e=n,r=e.message??e.msg??`Unknown Dify error`,i=e.code??e.status??``;_?.error(`Dify stream error`,{code:i,message:r}),t.enqueue({type:`error`,error:Error(`Dify error${i?` (${i})`:``}: ${r}`)});break}}}})),request:{body:JSON.stringify(s)},response:{headers:c}}}async getRequestBody(e){var t,n;let r=e,i=e.prompt??r.messages;if(!i||!i.length)throw(t=this.logger)==null||t.error(`No messages provided`,{prompt:e.prompt}),new M5({message:`No messages provided`,url:this.chatMessagesEndpoint,requestBodyValues:e});let a=this.findConversationId(e.headers,i),o=this.buildQuery(i,a);if(!o)throw(n=this.logger)==null||n.error(`No user message found`,{messageCount:i.length,roles:i.map(e=>e.role)}),new M5({message:`No user message found`,url:this.chatMessagesEndpoint,requestBodyValues:{messageCount:i.length}});let s=e.headers?.[`user-id`]??`you_should_pass_user-id`,{"chat-id":c,"user-id":l,...u}=e.headers||{},d=await iae(i,s,this.config.baseURL,this.config.headers,this.logger),f=this.extractSystemPrompt(i),p=this.settings.injectToolsPrompt!==!1,{prompt:m,toolNames:h}=nae(e.tools),g=p?m:``,_=!a,v=[_?f:``,o,_?g:``].filter(Boolean).join(`
|
|
187
|
-
|
|
188
|
-
`);return{body:{inputs:this.settings.inputs||{},query:v,response_mode:this.settings.responseMode,conversation_id:a,user:s,...d.length?{files:d}:{}},toolNames:h,requestHeaders:u}}findConversationId(e,t){if(e?.[`chat-id`])return e[`chat-id`];for(let e=t.length-1;e>=0;e--){let n=t[e];if(Array.isArray(n.content))for(let e of n.content){let t=e?.providerMetadata?.difyWorkflowData||e?.callProviderMetadata?.difyWorkflowData;if(t?.conversationId)return t.conversationId}}}buildQuery(e,t){let n=0;if(t){n=e.length;for(let t=e.length-1;t>=0;t--){let r=e[t];if(r.role===`tool`){n=t;continue}if(r.role===`user`){n=t;break}break}}return e.slice(n).filter(e=>e.role===`user`||e.role===`tool`||!t&&e.role===`assistant`).map(e=>e.role===`tool`?this.extractToolResult(e):this.extractTextFromMessage(e)).filter(Boolean).join(`
|
|
189
|
-
|
|
190
|
-
`)}extractSystemPrompt(e){let t=e.find(e=>e.role===`system`);return aae(t?this.extractTextFromMessage(t):``)}extractTextFromMessage(e){return typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.map(e=>typeof e==`string`?e:e?.type===`text`&&e.text?e.text:``).filter(Boolean).join(` `):``}extractToolResult(e){let t=e.content;if(!Array.isArray(t))return``;let n=[];for(let e of t)if(e?.type===`tool-result`){let t=e.toolName||`tool`,r=e.output??e.result??e.content??e.text,i=r!==void 0&&typeof r==`object`&&r&&`value`in r?r.value:r,a=i===void 0?`[completed]`:typeof i==`string`?i:JSON.stringify(i);n.push(`[${t} result]: ${a}`)}return n.join(`
|
|
191
|
-
`)}};function I9(e={}){let t=(t,n={})=>new cae(t,n,{provider:`dify.chat`,baseURL:e.baseURL||`https://api.dify.ai/v1`,headers:()=>({Authorization:`Bearer ${xie({apiKey:n.apiKey,environmentVariableName:`DIFY_API_KEY`,description:`Dify API Key`})}`,"Content-Type":`application/json`,...e.headers})}),n=function(e,n){if(new.target)throw Error(`The model factory function cannot be called with the new keyword.`);return t(e,n)};return n.chat=t,n}I9();var lae=UI.BASE_URL,uae=I9({baseURL:lae}),dae=e=>new ReadableStream({start(t){t.enqueue({type:`text-start`,id:`0`}),t.enqueue({type:`text-delta`,id:`0`,delta:e}),t.enqueue({type:`text-end`,id:`0`}),t.close()}}),L9=XW(`[dify-chat-transport]`),fae=()=>{let e=hK(),t=YW();return{...e,round_type:t?`tool_result`:`new_query`,...t?{}:{tools:rG},...t?{action_result:t}:{}}},pae=class{async sendMessages(e){let{messages:t,abortSignal:n,headers:r}=e;try{let e=await T8(t);if(L9.log(`[debug] input messages roles:`,t.map(e=>e.role)),L9.log(`[debug] modelMessages count:`,e.length),L9.log(`[debug] modelMessages roles:`,e.map(e=>e.role)),L9.log(`[debug] modelMessages[-1].role:`,e[e.length-1]?.role),e.length>0){let t=e[e.length-1];t.role===`assistant`&&Array.isArray(t.content)&&L9.log(`[debug] last assistant content types:`,t.content.map(e=>typeof e==`object`&&e&&`type`in e?e.type:typeof e))}let i=e.map(e=>e.role===`assistant`&&Array.isArray(e.content)?{...e,content:e.content.filter(e=>!(typeof e==`object`&&`type`in e&&e.type===`tool-call`))}:e),a=[...i].reverse().find(e=>e.role===`assistant`);if(a&&Array.isArray(a.content)&&a.content.some(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-result`)){let e=a.content.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`tool-result`);e.length>0&&i.push({role:`tool`,content:e.map(e=>{let t=e,n=t.output??t.result;return{type:`tool-result`,toolCallId:t.toolCallId,toolName:t.toolName,output:typeof n==`string`?{type:`text`,value:n}:{type:`text`,value:JSON.stringify(n??``)}}})})}i=i.filter(e=>e.role!==`assistant`);let o=0;for(let e=i.length-1;e>=0;e--)if(i[e].role===`user`){o=e;break}i=i.slice(o),L9.log(`[debug] messages count:`,i.length),L9.log(`[debug] messages roles:`,i.map(e=>e.role)),L9.log(`[debug] conversationId:`,BW());let s={click_element:{description:aK.click_element.description,inputSchema:aK.click_element.parameters},navigate_to:{description:aK.navigate_to.description,inputSchema:aK.navigate_to.parameters},fill_input:{description:aK.fill_input.description,inputSchema:aK.fill_input.parameters},scroll_to:{description:aK.scroll_to.description,inputSchema:aK.scroll_to.parameters},highlight_element:{description:aK.highlight_element.description,inputSchema:aK.highlight_element.parameters}},c=v8({model:uae(`dify-chat`,{apiKey:UI.API_KEY,responseMode:`streaming`,injectToolsPrompt:!1,inputs:fae()}),messages:i,tools:s,abortSignal:n,headers:{"chat-id":BW()??``,"user-id":HW(),...r}}),l=c.stream.pipeThrough(new TransformStream({transform(e,t){e.type===`tool-input-start`?L9.log(`[stream] tool-input-start:`,JSON.stringify({id:e.id,toolName:e.toolName,input:e.input??e.args})):e.type===`tool-input-delta`?L9.log(`[stream] tool-input-delta:`,JSON.stringify({id:e.id,delta:e.delta??e.inputDelta})):e.type===`tool-input-end`?L9.log(`[stream] tool-input-end:`,JSON.stringify({id:e.id})):e.type===`tool-call`?L9.log(`[stream] tool-call:`,JSON.stringify({toolName:e.toolName,toolCallId:e.toolCallId,input:e.input})):e.type===`text-delta`?L9.log(`[stream] text-delta:`,JSON.stringify({delta:e.delta??e.textDelta})):e.type===`reasoning-start`?L9.log(`[stream] reasoning-start`):e.type===`reasoning-delta`?L9.log(`[stream] reasoning-delta:`,JSON.stringify({delta:e.delta??e.textDelta})):e.type===`reasoning-end`?L9.log(`[stream] reasoning-end`):e.type===`finish-step`?L9.log(`[stream] finish-step`):L9.log(`[stream] chunk type:`,e.type),t.enqueue(e)}})),u=new Set,d=new Set,f=new Set,p=!1,m=B6({stream:l.pipeThrough(new TransformStream({transform(e,t){if(e.type===`finish-step`){if(p)return;p=!0,t.enqueue(e);return}if(e.type===`tool-input-start`){if(u.has(e.id)){d.add(e.id),L9.log(`[dedup] duplicate tool-input-start skipped:`,e.toolName,`id:`,e.id.slice(0,8));return}u.add(e.id),t.enqueue(e);return}if(!(e.type===`tool-input-delta`&&d.has(e.id))&&!(e.type===`tool-input-end`&&d.has(e.id))){if(e.type===`tool-call`){let t=`${e.toolName}:${JSON.stringify(e.input)}`;if(f.has(t))return;f.add(t)}t.enqueue(e)}}}))});return c.finalStep.then(e=>{let t=e.providerMetadata?.difyWorkflowData?.conversationId;t&&(VW(t),GW(t,``),L9.log(`[conversationId] saved:`,t))},e=>{L9.error(`[conversationId] extraction failed:`,e)}),m}catch(e){let t=e instanceof Error?e.message:`Request failed, please try again later`;return L9.error(`sendMessages error:`,t),dae(`[Error] ${t}`)}}async reconnectToStream(){return null}},mae={generate:async()=>[{title:`More products`,prompt:`Show me more products`},{title:`Return policy`,prompt:`What's your return policy?`},{title:`Promotions`,prompt:`Do you have any promotions?`}]},hae=()=>{let e=(0,_.useMemo)(()=>Qy({tools:rS({toolkit:aK})}),[]);return{runtime:xre({transport:(0,_.useMemo)(()=>new pae,[]),adapters:{suggestion:mae},sendAutomaticallyWhen:()=>JW()}),config:e,clearConversation:(0,_.useCallback)(()=>{UW()},[])}},gae=KU([UU({type:nW(`start`),messageId:G().optional()}),UU({type:nW(`text-start`),id:G()}),UU({type:nW(`text-delta`),id:G(),delta:G()}),UU({type:nW(`text-end`),id:G()}),UU({type:nW(`reasoning-start`),id:G()}),UU({type:nW(`reasoning-delta`),id:G(),delta:G()}),UU({type:nW(`reasoning-end`),id:G()}),UU({type:nW(`tool-input-start`),toolCallId:G(),toolName:G()}),UU({type:nW(`tool-input-delta`),toolCallId:G(),inputTextDelta:G()}),UU({type:nW(`tool-input-available`),toolCallId:G(),toolName:G(),input:QU(G(),LU())}),UU({type:nW(`tool-output-available`),toolCallId:G(),output:LU()}),UU({type:nW(`start-step`)}),UU({type:nW(`finish-step`)}),UU({type:nW(`finish`)}),UU({type:nW(`error`),errorText:G()})]),R9=e=>{if(!e.startsWith(`data:`))return null;let t=e.slice(5).trim();if(!t||t===`[DONE]`)return null;try{let e=JSON.parse(t),n=gae.safeParse(e);return n.success?n.data:null}catch{return null}},_ae=e=>{let t=e.getReader(),n=new TextDecoder,r=``;return{async*[Symbol.asyncIterator](){try{for(;;){let{done:e,value:i}=await t.read();if(e){if(r.trim()){let e=R9(r);e&&(yield e)}return}r+=n.decode(i,{stream:!0});let a=r.split(`
|
|
192
|
-
`);r=a.pop()??``;for(let e of a){let t=e.trim();if(!t)continue;let n=R9(t);n&&(yield n)}}}finally{t.releaseLock()}}}},z9=async e=>{let t={query:e.query,inputs:e.inputs,...e.toolCallId?{toolCallId:e.toolCallId}:{},...e.toolOutput===void 0?{}:{toolOutput:e.toolOutput}},n=await fetch(HI.LOCAL_AGENT_CHAT,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>`Unknown error`);throw Error(`Local backend request failed (${n.status}): ${e}`)}if(!n.body)throw Error(`Local backend returned empty response body`);return _ae(n.body)},vae=async(e,t,n)=>z9({query:``,inputs:n,toolCallId:e,toolOutput:t}),B9=e=>{for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role!==`assistant`)continue;let r=n.content.find(e=>e.type===`tool-call`&&e.result!==void 0);if(r)return{toolCallId:r.toolCallId,result:r.result}}return null},V9=async function*(e,t){let n=``;try{for await(let r of e){if(t.aborted)return;switch(r.type){case`text-delta`:n+=r.delta,yield{content:[{type:`text`,text:n}]};break;case`reasoning-delta`:yield{content:[{type:`reasoning`,text:r.delta},...n?[{type:`text`,text:n}]:[]]};break;case`tool-input-available`:yield{content:[...n?[{type:`text`,text:n}]:[],{type:`tool-call`,toolCallId:r.toolCallId,toolName:r.toolName,args:r.input,argsText:JSON.stringify(r.input)}],status:{type:`requires-action`,reason:`tool-calls`}};return;case`error`:yield{content:[{type:`text`,text:`[Error] ${r.errorText}`}]};return}}}catch(e){yield{content:[{type:`text`,text:`[Request failed] ${e instanceof Error?e.message:`Unknown error`}`}]}}},yae=()=>({async*run({messages:e,abortSignal:t,unstable_getMessage:n}){let r=B9(e)??(n?B9([n()]):null);if(r){yield*V9(await vae(r.toolCallId,r.result,hK()),t);return}let i=mK(e);i&&(yield*V9(await z9({query:i,inputs:hK()}),t))}}),bae=e=>{let t=wj((0,_.useMemo)(()=>yae(),[]),{unstable_humanToolNames:[...e.humanToolNames]}),n=(0,_.useCallback)(()=>{},[]);return{runtime:t,config:e.config,clearConversation:n}},xae=()=>{let e=(0,_.useMemo)(()=>Qy({tools:rS({toolkit:aK})}),[]);return VI.mode===`local`?bae({config:e,humanToolNames:oK}):VI.mode===`dify-sdk`?hae():xK({config:e,humanToolNames:oK})},H9=(...e)=>e.filter((e,t,n)=>!!e&&e.trim()!==``&&n.indexOf(e)===t).join(` `).trim(),Sae=e=>e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).toLowerCase(),Cae=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,t,n)=>n?n.toUpperCase():t.toLowerCase()),U9=e=>{let t=Cae(e);return t.charAt(0).toUpperCase()+t.slice(1)},W9={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`},wae=e=>{for(let t in e)if(t.startsWith(`aria-`)||t===`role`||t===`title`)return!0;return!1},Tae=(0,_.createContext)({}),Eae=()=>(0,_.useContext)(Tae),Dae=(0,_.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=``}=Eae()??{},m=r??d?Number(n??u)*24/Number(t??l):n??u;return(0,_.createElement)(`svg`,{ref:c,...W9,width:t??l??W9.width,height:t??l??W9.height,stroke:e??f,strokeWidth:m,className:H9(`lucide`,p,i),...!a&&!wae(s)&&{"aria-hidden":`true`},...s},[...o.map(([e,t])=>(0,_.createElement)(e,t)),...Array.isArray(a)?a:[a]])}),G9=(e,t)=>{let n=(0,_.forwardRef)(({className:n,...r},i)=>(0,_.createElement)(Dae,{ref:i,iconNode:t,className:H9(`lucide-${Sae(U9(e))}`,`lucide-${e}`,n),...r}));return n.displayName=U9(e),n},Oae=G9(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),kae=G9(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Aae=G9(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),jae=G9(`refresh-cw`,[[`path`,{d:`M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8`,key:`v9h5vc`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}],[`path`,{d:`M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16`,key:`3uifl3`}],[`path`,{d:`M8 16H3v5`,key:`1cv678`}]]),Mae=G9(`thumbs-down`,[[`path`,{d:`M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z`,key:`m61m77`}],[`path`,{d:`M17 14V2`,key:`8ymqnk`}]]),Nae=G9(`thumbs-up`,[[`path`,{d:`M15 5.88 14 10h5.83a2 2 0 0 1 1.92 2.56l-2.33 8A2 2 0 0 1 17.5 22H4a2 2 0 0 1-2-2v-8a2 2 0 0 1 2-2h2.76a2 2 0 0 0 1.79-1.11L12 2a3.13 3.13 0 0 1 3 3.88Z`,key:`emmmcr`}],[`path`,{d:`M7 10v12`,key:`1qc93n`}]]),K9=(...e)=>Td(e),Pae=`flex items-center justify-center rounded-full text-foreground/45 outline-none transition-[background-color,color,scale] duration-150 hover:bg-foreground/[0.06] hover:text-foreground/90 active:scale-[0.96] focus-visible:ring-1 focus-visible:ring-foreground/20 motion-reduce:transition-none dark:hover:bg-foreground/[0.09]`,q9=`[grid-area:1/1] transition-[opacity,scale,filter] duration-200 ease-[cubic-bezier(0.2,0,0,1)] motion-reduce:transition-none`,J9=`scale-100 opacity-100 blur-none`,Y9=`scale-[0.25] opacity-0 blur-[4px]`;function X9({copied:e,reaction:t,regenerating:n,onCopy:r,onReactionChange:i,onRegenerate:a,onMore:o,helpful:s=!0,className:c,...l}){let u=K9(Pae,`size-7`,c);return(0,I.jsxs)(`div`,{"data-slot":`message-actions`,className:K9(`flex items-center gap-1`,c),...l,children:[(0,I.jsxs)(`button`,{type:`button`,"aria-label":e?`Copied response`:`Copy response`,onClick:r,className:K9(u,`grid place-items-center`,e&&`text-emerald-500`),children:[(0,I.jsx)(kae,{className:K9(q9,`size-3.5`,e?Y9:J9)}),(0,I.jsx)(Oae,{className:K9(q9,`size-3.5`,e?J9:Y9)})]}),s&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{type:`button`,"aria-label":`Mark response helpful`,"aria-pressed":t===`up`,onClick:()=>i?.(t===`up`?null:`up`),className:K9(u,t===`up`&&`bg-foreground/[0.06] text-foreground/90 dark:bg-foreground/[0.09]`),children:(0,I.jsx)(Nae,{className:`size-3.5`})}),(0,I.jsx)(`button`,{type:`button`,"aria-label":`Mark response unhelpful`,"aria-pressed":t===`down`,onClick:()=>i?.(t===`down`?null:`down`),className:K9(u,t===`down`&&`bg-foreground/[0.06] text-foreground/90 dark:bg-foreground/[0.09]`),children:(0,I.jsx)(Mae,{className:`size-3.5`})})]}),i&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`Regenerate response`,onClick:a,className:u,children:(0,I.jsx)(jae,{className:K9(`size-3.5`,n&&`animate-spin motion-reduce:animate-none`)})}),o&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`More response actions`,onClick:o,className:u,children:(0,I.jsx)(Aae,{className:`size-3.5`})})]})}var Z9=[`⠋`,`⠙`,`⠹`,`⠸`,`⠼`,`⠴`,`⠦`,`⠧`,`⠇`,`⠏`],Q9=[`Processing`,`Analyzing`,`Computing`,`Evaluating`,`Pondering`];function Fae(e,t=1200,n=80){let[r,i]=(0,_.useState)(0),[a,o]=(0,_.useState)(0);return(0,_.useEffect)(()=>{if(e===`idle`)return;let t=setInterval(()=>{i(e=>(e+1)%Z9.length)},n);return()=>clearInterval(t)},[e,n]),(0,_.useEffect)(()=>{if(e!==`thinking`)return;let n=setInterval(()=>{o(e=>(e+1)%Q9.length)},t);return()=>clearInterval(n)},[e,t]),{spinnerFrame:Z9[r],verbText:Q9[a]}}var Iae=({state:e,className:t,toolName:n,verbCycleMs:r=1200,spinnerFrameMs:i=80})=>{let{spinnerFrame:a,verbText:o}=Fae(e,r,i);if(e===`idle`)return null;let s;return s=e===`toolRunning`&&n?`Running tool: ${n}`:`${o} …`,(0,I.jsxs)(`div`,{className:t,style:{display:`flex`,alignItems:`center`,gap:8,padding:`10px`},children:[(0,I.jsx)(`span`,{style:{fontFamily:`monospace`,fontSize:16},children:a}),(0,I.jsx)(`span`,{children:s})]})};function Lae(e,t,n){return Number.isNaN(e)?t:Math.min(n,Math.max(t,e))}function Rae(e,t){return e.slice(0,Math.floor(Lae(t,0,e.length)))}function zae(e){let t=e.match(/^(https?:\/\/[^\s]+)/);return t?{href:t[1].replace(/[.,!?;:)\]}>]+$/,``),display:e}:null}function Bae({segments:e,count:t,streaming:n,className:r,...i}){let a=Rae((0,_.useMemo)(()=>e.flatMap(e=>e.text.split(` `).map(t=>({word:t,mono:e.mono??!1}))),[e]),t);return(0,I.jsxs)(`p`,{"data-slot":`streaming-text`,className:K9(`min-h-[8.5rem] max-w-sm text-sm leading-relaxed text-pretty`,r),...i,children:[a.map(({word:e,mono:t},r)=>{let i=zae(e),o=n&&a.length-1-r<2;return i?(0,I.jsxs)(`a`,{href:i.href,target:`_blank`,rel:`noopener noreferrer`,className:`text-[#FF641E] underline decoration-[#FF641E]/40 hover:decoration-[#FF641E] transition-colors`,children:[i.display,` `]},r):(0,I.jsxs)(`span`,{className:`fade-in animate-in fill-mode-both duration-500 motion-reduce:animate-none`,children:[(0,I.jsx)(`span`,{className:K9(`transition-colors duration-700 motion-reduce:transition-none`,o&&`text-blue-500 dark:text-blue-400`,t&&`bg-foreground/[0.06] rounded-md px-1.5 py-0.5 font-mono text-[0.85em]`),children:e}),` `]},r)}),n&&a.length>0&&(0,I.jsx)(`span`,{"aria-hidden":!0,className:`-mb-0.5 ml-0.5 inline-block h-4 w-0.5 animate-pulse rounded-full bg-[#FF641E]`})]})}var $9=({isUser:e=!0})=>(0,I.jsx)(YF.Parts,{components:{Text:e?()=>(0,I.jsx)(`div`,{className:`pre-line-clamp-2`,children:(0,I.jsx)(lF.Text,{})}):()=>{let e=H(e=>e.part.type!==`text`&&e.part.type!==`reasoning`?null:e.part),t=e?.text??``,n=e?.status?.type===`running`||e?.status?.type===`incomplete`,r=t?[{text:t}]:[{text:``}],i=t?t.split(/\s+/).filter(Boolean).length:0;return!t&&n?(0,I.jsx)(Iae,{state:`thinking`,className:`text-xs text-[#FF641E]`}):(0,I.jsx)(Bae,{segments:r,count:i,streaming:n})}}}),Vae=()=>{let{copy:e,isCopied:t}=tj({copyToClipboard:async e=>{await navigator.clipboard.writeText(e)}});return(0,I.jsxs)(YF.Root,{className:`flex flex-col items-end mt-6`,children:[(0,I.jsx)(`div`,{className:`max-w-[80%] rounded-2xl rounded-br-sm bg-[#FF641E]/85 px-4 py-2.5 text-sm text-white shadow-sm backdrop-blur-sm`,children:(0,I.jsx)($9,{})}),(0,I.jsx)(X9,{className:`justify-end text-white`,copied:t,helpful:!1,onCopy:e})]})},Hae=()=>{let[e,t]=(0,_.useState)(null),n=H(e=>e.thread.isRunning),{copy:r,isCopied:i}=tj({copyToClipboard:async e=>{await navigator.clipboard.writeText(e)}}),{reload:a,disabled:o}=oj(),s=(0,_.useCallback)(()=>{o||a()},[a,o]);return(0,I.jsx)(YF.Root,{className:`mt-6`,children:(0,I.jsxs)(`div`,{className:`rounded-2xl rounded-bl-sm bg-[#F5D2AF]/80 px-4 py-2.5 text-sm text-[#3C5F32] shadow-sm backdrop-blur-sm`,children:[(0,I.jsx)($9,{isUser:!1}),!n&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`flex flex-col`,children:(0,I.jsx)(NI.Suggestions,{children:()=>(0,I.jsx)(BI.Trigger,{send:!0,className:`mt-2 rounded-lg border border-[#3C5F32]/20 bg-[#F5D2AF]/40 px-3 py-2 text-sm text-[#3C5F32]/70 hover:bg-[#E2DED9]/50 cursor-pointer transition-colors`,children:(0,I.jsx)(BI.Title,{})})})}),(0,I.jsx)(X9,{className:`mt-2 justify-end`,copied:i,reaction:e,regenerating:!1,onCopy:r,onReactionChange:t,onRegenerate:s})]})]})})},Uae=()=>(0,I.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,I.jsx)(NI.Viewport,{className:`h-full px-4 overflow-y-auto custom-scrollbar`,autoScroll:!0,children:(0,I.jsx)(NI.Messages,{children:({message:e})=>e.role===`user`?(0,I.jsx)(Vae,{}):(0,I.jsx)(Hae,{})})}),(0,I.jsx)(LS,{condition:e=>e.thread.isEmpty,children:(0,I.jsxs)(`div`,{className:`pointer-events-none absolute inset-0 flex flex-col items-center justify-center gap-2 text-[#F5D2AF]/60`,children:[(0,I.jsx)(O_.message,{size:32}),(0,I.jsx)(`p`,{className:`text-lg my-4`,children:`How can I help you?`}),(0,I.jsxs)(`div`,{className:`pointer-events-auto mt-2 flex flex-wrap justify-center gap-2`,children:[(0,I.jsx)(NI.Suggestion,{prompt:`Show me popular products`,send:!0,className:`rounded-lg border border-[#F5D2AF]/40 bg-[#F5D2AF]/20 px-4 py-1 text-sm text-[#F5D2AF]/80 backdrop-blur-sm hover:bg-[#F5D2AF]/30 cursor-pointer transition-colors`,children:`🔥 Popular Products`}),(0,I.jsx)(NI.Suggestion,{prompt:`What's your return policy?`,send:!0,className:`rounded-lg border border-[#F5D2AF]/40 bg-[#F5D2AF]/20 px-4 py-1 text-sm text-[#F5D2AF]/80 backdrop-blur-sm hover:bg-[#F5D2AF]/30 cursor-pointer transition-colors`,children:`📦 Return Policy`}),(0,I.jsx)(NI.Suggestion,{prompt:`Any ongoing promotions?`,send:!0,className:`rounded-lg border border-[#F5D2AF]/40 bg-[#F5D2AF]/20 px-4 py-1 text-sm text-[#F5D2AF]/80 backdrop-blur-sm hover:bg-[#F5D2AF]/30 cursor-pointer transition-colors`,children:`🏷️ Promotions`})]})]})})]}),Wae=()=>(0,I.jsxs)(UP.Root,{className:`flex items-end gap-2 border-t border-white/10 bg-[#3C5F32]/40 p-3 backdrop-blur-lg`,children:[(0,I.jsx)(UP.Input,{placeholder:`Type a message...`,submitMode:`enter`,className:`flex-1 resize-none rounded-lg border border-[#F5D2AF]/40 bg-[#F5D2AF] px-3 py-2 text-sm text-[#3C5F32] outline-none placeholder:text-[#3C5F32]/50`,rows:1}),(0,I.jsx)(UP.Send,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-[#FF641E] text-white hover:bg-[#FF641E]/90 disabled:opacity-40`,children:(0,I.jsx)(O_.paperPlane,{size:16})})]}),Gae=()=>{let{runtime:e,config:t}=xae();return(0,I.jsx)(Qj,{runtime:e,config:t,children:(0,I.jsxs)(NI.Root,{className:`flex h-full flex-col`,children:[(0,I.jsx)(Uae,{}),(0,I.jsx)(Wae,{})]})})},Kae=XW(`[chat-dialog-panel]`),qae=({onClose:e})=>(Kae.log(`load`),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`header`,{className:`flex items-center justify-between border-b border-white/10 bg-[#3C5F32]/40 px-4 py-3 backdrop-blur-lg`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(O_.robot,{size:20,className:`text-[#F5D2AF]`}),(0,I.jsx)(`h2`,{className:`text-sm font-semibold text-[#F5D2AF]`,children:`AI Assistant`})]}),(0,I.jsxs)(Lg,{isIconOnly:!0,variant:`ghost`,size:`sm`,onPress:e,"aria-label":`Close dialog`,className:`text-[#F5D2AF] hover:bg-[#FF641E]/20`,children:[(0,I.jsx)(O_.close,{size:16}),(0,I.jsx)(Yg,{})]})]}),(0,I.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:(0,I.jsx)(Gae,{})})]})),Jae=XW(`[chat-widget]`),Yae=()=>{let[e,t]=(0,_.useState)(!1),n=()=>{Jae.log(`load`),t(e=>!e)};return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(k_,{isOpen:e,onToggle:n}),(0,I.jsx)(Ic,{children:e&&(0,I.jsx)(Ou.div,{className:`chat-dialog-glass flex h-[600px] w-[380px] flex-col overflow-hidden rounded-xl border border-white/15 bg-[#3C5F32]/80 shadow-2xl shadow-black/30 backdrop-blur-2xl`,style:{transformOrigin:`bottom right`},initial:{opacity:0,scale:.5,y:40},animate:{opacity:1,scale:1,y:0},exit:{opacity:0,scale:.5,y:40},transition:{type:`spring`,damping:25,stiffness:300},children:(0,I.jsx)(qae,{onClose:n})})})]})},Xae=XW(`[app]`),Zae=(0,_.memo)(()=>(Xae.log(`load`),(0,I.jsx)(Yae,{})));XW(`[main]`).log(`load`),(0,v.createRoot)(document.getElementById(`root`)).render((0,I.jsx)(_.StrictMode,{children:(0,I.jsx)(Zae,{})}));
|