@copilotkitnext/runtime 0.0.22-alpha.2 → 0.0.22-alpha.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-PFDQ4YNE.mjs +936 -0
- package/dist/chunk-PFDQ4YNE.mjs.map +1 -0
- package/dist/express.js +1002 -366
- package/dist/express.js.map +1 -1
- package/dist/express.mjs +315 -363
- package/dist/express.mjs.map +1 -1
- package/dist/index.js +1192 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +256 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-PXQQQ6KP.mjs +0 -23
- package/dist/chunk-PXQQQ6KP.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,1193 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=r;}});});var Ne=d(Tn=>{Object.defineProperty(Tn,"__esModule",{value:true});Tn.arrRemove=void 0;function om(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1);}}Tn.arrRemove=om;});var ue=d(ne=>{var Vc=ne&&ne.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")},Bc=ne&&ne.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},Gc=ne&&ne.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(ne,"__esModule",{value:true});ne.isSubscription=ne.EMPTY_SUBSCRIPTION=ne.Subscription=void 0;var Gr=U(),Bs=Vs(),Hc=Ne(),Gs=function(){function e(t){this.initialTeardown=t,this.closed=false,this._parentage=null,this._finalizers=null;}return e.prototype.unsubscribe=function(){var t,r,n,i,a;if(!this.closed){this.closed=true;var o=this._parentage;if(o)if(this._parentage=null,Array.isArray(o))try{for(var s=Vc(o),u=s.next();!u.done;u=s.next()){var c=u.value;c.remove(this);}}catch(y){t={error:y};}finally{try{u&&!u.done&&(r=s.return)&&r.call(s);}finally{if(t)throw t.error}}else o.remove(this);var f=this.initialTeardown;if(Gr.isFunction(f))try{f();}catch(y){a=y instanceof Bs.UnsubscriptionError?y.errors:[y];}var v=this._finalizers;if(v){this._finalizers=null;try{for(var h=Vc(v),m=h.next();!m.done;m=h.next()){var _=m.value;try{Wc(_);}catch(y){a=a??[],y instanceof Bs.UnsubscriptionError?a=Gc(Gc([],Bc(a)),Bc(y.errors)):a.push(y);}}}catch(y){n={error:y};}finally{try{m&&!m.done&&(i=h.return)&&i.call(h);}finally{if(n)throw n.error}}}if(a)throw new Bs.UnsubscriptionError(a)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Wc(t);else {if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this);}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t);}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t;},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&Hc.arrRemove(r,t);},e.prototype.remove=function(t){var r=this._finalizers;r&&Hc.arrRemove(r,t),t instanceof e&&t._removeParent(this);},e.EMPTY=function(){var t=new e;return t.closed=true,t}(),e}();ne.Subscription=Gs;ne.EMPTY_SUBSCRIPTION=Gs.EMPTY;function sm(e){return e instanceof Gs||e&&"closed"in e&&Gr.isFunction(e.remove)&&Gr.isFunction(e.add)&&Gr.isFunction(e.unsubscribe)}ne.isSubscription=sm;function Wc(e){Gr.isFunction(e)?e():e.unsubscribe();}});var $t=d(In=>{Object.defineProperty(In,"__esModule",{value:true});In.config=void 0;In.config={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:false,useDeprecatedNextContext:false};});var Hs=d(Se=>{var $c=Se&&Se.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},zc=Se&&Se.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Se,"__esModule",{value:true});Se.timeoutProvider=void 0;Se.timeoutProvider={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=Se.timeoutProvider.delegate;return i?.setTimeout?i.setTimeout.apply(i,zc([e,t],$c(r))):setTimeout.apply(void 0,zc([e,t],$c(r)))},clearTimeout:function(e){var t=Se.timeoutProvider.delegate;return (t?.clearTimeout||clearTimeout)(e)},delegate:void 0};});var Ws=d(xn=>{Object.defineProperty(xn,"__esModule",{value:true});xn.reportUnhandledError=void 0;var um=$t(),cm=Hs();function lm(e){cm.timeoutProvider.setTimeout(function(){var t=um.config.onUnhandledError;if(t)t(e);else throw e});}xn.reportUnhandledError=lm;});var J=d(Rn=>{Object.defineProperty(Rn,"__esModule",{value:true});Rn.noop=void 0;function fm(){}Rn.noop=fm;});var Jc=d(Oe=>{Object.defineProperty(Oe,"__esModule",{value:true});Oe.createNotification=Oe.nextNotification=Oe.errorNotification=Oe.COMPLETE_NOTIFICATION=void 0;Oe.COMPLETE_NOTIFICATION=function(){return Pn("C",void 0,void 0)}();function dm(e){return Pn("E",void 0,e)}Oe.errorNotification=dm;function pm(e){return Pn("N",e,void 0)}Oe.nextNotification=pm;function Pn(e,t,r){return {kind:e,value:t,error:r}}Oe.createNotification=Pn;});var qn=d(zt=>{Object.defineProperty(zt,"__esModule",{value:true});zt.captureError=zt.errorContext=void 0;var Xc=$t(),_t=null;function vm(e){if(Xc.config.useDeprecatedSynchronousErrorHandling){var t=!_t;if(t&&(_t={errorThrown:false,error:null}),e(),t){var r=_t,n=r.errorThrown,i=r.error;if(_t=null,n)throw i}}else e();}zt.errorContext=vm;function hm(e){Xc.config.useDeprecatedSynchronousErrorHandling&&_t&&(_t.errorThrown=true,_t.error=e);}zt.captureError=hm;});var Jt=d(me=>{var Yc=me&&me.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(me,"__esModule",{value:true});me.EMPTY_OBSERVER=me.SafeSubscriber=me.Subscriber=void 0;var mm=U(),Kc=ue(),Xs=$t(),_m=Ws(),Zc=J(),$s=Jc(),ym=Hs(),bm=qn(),Qc=function(e){Yc(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=false,r?(n.destination=r,Kc.isSubscription(r)&&r.add(n)):n.destination=me.EMPTY_OBSERVER,n}return t.create=function(r,n,i){return new el(r,n,i)},t.prototype.next=function(r){this.isStopped?Js($s.nextNotification(r),this):this._next(r);},t.prototype.error=function(r){this.isStopped?Js($s.errorNotification(r),this):(this.isStopped=true,this._error(r));},t.prototype.complete=function(){this.isStopped?Js($s.COMPLETE_NOTIFICATION,this):(this.isStopped=true,this._complete());},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=true,e.prototype.unsubscribe.call(this),this.destination=null);},t.prototype._next=function(r){this.destination.next(r);},t.prototype._error=function(r){try{this.destination.error(r);}finally{this.unsubscribe();}},t.prototype._complete=function(){try{this.destination.complete();}finally{this.unsubscribe();}},t}(Kc.Subscription);me.Subscriber=Qc;var gm=Function.prototype.bind;function zs(e,t){return gm.call(e,t)}var Em=function(){function e(t){this.partialObserver=t;}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t);}catch(n){Cn(n);}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t);}catch(n){Cn(n);}else Cn(t);},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete();}catch(r){Cn(r);}},e}(),el=function(e){Yc(t,e);function t(r,n,i){var a=e.call(this)||this,o;if(mm.isFunction(r)||!r)o={next:r??void 0,error:n??void 0,complete:i??void 0};else {var s;a&&Xs.config.useDeprecatedNextContext?(s=Object.create(r),s.unsubscribe=function(){return a.unsubscribe()},o={next:r.next&&zs(r.next,s),error:r.error&&zs(r.error,s),complete:r.complete&&zs(r.complete,s)}):o=r;}return a.destination=new Em(o),a}return t}(Qc);me.SafeSubscriber=el;function Cn(e){Xs.config.useDeprecatedSynchronousErrorHandling?bm.captureError(e):_m.reportUnhandledError(e);}function Sm(e){throw e}function Js(e,t){var r=Xs.config.onStoppedNotification;r&&ym.timeoutProvider.setTimeout(function(){return r(e,t)});}me.EMPTY_OBSERVER={closed:true,next:Zc.noop,error:Sm,complete:Zc.noop};});var Hr=d(Nn=>{Object.defineProperty(Nn,"__esModule",{value:true});Nn.observable=void 0;Nn.observable=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();});var X=d(Mn=>{Object.defineProperty(Mn,"__esModule",{value:true});Mn.identity=void 0;function Om(e){return e}Mn.identity=Om;});var Wr=d(Xt=>{Object.defineProperty(Xt,"__esModule",{value:true});Xt.pipeFromArray=Xt.pipe=void 0;var wm=X();function Am(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return tl(e)}Xt.pipe=Am;function tl(e){return e.length===0?wm.identity:e.length===1?e[0]:function(r){return e.reduce(function(n,i){return i(n)},r)}}Xt.pipeFromArray=tl;});var V=d(kn=>{Object.defineProperty(kn,"__esModule",{value:true});kn.Observable=void 0;var Zs=Jt(),Tm=ue(),Im=Hr(),xm=Wr(),Rm=$t(),Ks=U(),Pm=qn(),qm=function(){function e(t){t&&(this._subscribe=t);}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var i=this,a=Nm(t)?t:new Zs.SafeSubscriber(t,r,n);return Pm.errorContext(function(){var o=i,s=o.operator,u=o.source;a.add(s?s.call(a,u):u?i._subscribe(a):i._trySubscribe(a));}),a},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r);}},e.prototype.forEach=function(t,r){var n=this;return r=rl(r),new r(function(i,a){var o=new Zs.SafeSubscriber({next:function(s){try{t(s);}catch(u){a(u),o.unsubscribe();}},error:a,complete:i});n.subscribe(o);})},e.prototype._subscribe=function(t){var r;return (r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[Im.observable]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return xm.pipeFromArray(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=rl(t),new t(function(n,i){var a;r.subscribe(function(o){return a=o},function(o){return i(o)},function(){return n(a)});})},e.create=function(t){return new e(t)},e}();kn.Observable=qm;function rl(e){var t;return (t=e??Rm.config.Promise)!==null&&t!==void 0?t:Promise}function Cm(e){return e&&Ks.isFunction(e.next)&&Ks.isFunction(e.error)&&Ks.isFunction(e.complete)}function Nm(e){return e&&e instanceof Zs.Subscriber||Cm(e)&&Tm.isSubscription(e)}});var S=d(Kt=>{Object.defineProperty(Kt,"__esModule",{value:true});Kt.operate=Kt.hasLift=void 0;var Mm=U();function nl(e){return Mm.isFunction(e?.lift)}Kt.hasLift=nl;function km(e){return function(t){if(nl(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n);}});throw new TypeError("Unable to lift unknown Observable type")}}Kt.operate=km;});var x=d(He=>{var jm=He&&He.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(He,"__esModule",{value:true});He.OperatorSubscriber=He.createOperatorSubscriber=void 0;var Lm=Jt();function Fm(e,t,r,n,i){return new il(e,t,r,n,i)}He.createOperatorSubscriber=Fm;var il=function(e){jm(t,e);function t(r,n,i,a,o,s){var u=e.call(this,r)||this;return u.onFinalize=o,u.shouldUnsubscribe=s,u._next=n?function(c){try{n(c);}catch(f){r.error(f);}}:e.prototype._next,u._error=a?function(c){try{a(c);}catch(f){r.error(f);}finally{this.unsubscribe();}}:e.prototype._error,u._complete=i?function(){try{i();}catch(c){r.error(c);}finally{this.unsubscribe();}}:e.prototype._complete,u}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this));}},t}(Lm.Subscriber);He.OperatorSubscriber=il;});var Ys=d(jn=>{Object.defineProperty(jn,"__esModule",{value:true});jn.refCount=void 0;var Dm=S(),Um=x();function Vm(){return Dm.operate(function(e,t){var r=null;e._refCount++;var n=Um.createOperatorSubscriber(t,void 0,void 0,void 0,function(){if(!e||e._refCount<=0||0<--e._refCount){r=null;return}var i=e._connection,a=r;r=null,i&&(!a||i===a)&&i.unsubscribe(),t.unsubscribe();});e.subscribe(n),n.closed||(r=e.connect());})}jn.refCount=Vm;});var $r=d(Zt=>{var Bm=Zt&&Zt.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(Zt,"__esModule",{value:true});Zt.ConnectableObservable=void 0;var Gm=V(),al=ue(),Hm=Ys(),Wm=x(),$m=S(),zm=function(e){Bm(t,e);function t(r,n){var i=e.call(this)||this;return i.source=r,i.subjectFactory=n,i._subject=null,i._refCount=0,i._connection=null,$m.hasLift(r)&&(i.lift=r.lift),i}return t.prototype._subscribe=function(r){return this.getSubject().subscribe(r)},t.prototype.getSubject=function(){var r=this._subject;return (!r||r.isStopped)&&(this._subject=this.subjectFactory()),this._subject},t.prototype._teardown=function(){this._refCount=0;var r=this._connection;this._subject=this._connection=null,r?.unsubscribe();},t.prototype.connect=function(){var r=this,n=this._connection;if(!n){n=this._connection=new al.Subscription;var i=this.getSubject();n.add(this.source.subscribe(Wm.createOperatorSubscriber(i,void 0,function(){r._teardown(),i.complete();},function(a){r._teardown(),i.error(a);},function(){return r._teardown()}))),n.closed&&(this._connection=null,n=al.Subscription.EMPTY);}return n},t.prototype.refCount=function(){return Hm.refCount()(this)},t}(Gm.Observable);Zt.ConnectableObservable=zm;});var ol=d(zr=>{Object.defineProperty(zr,"__esModule",{value:true});zr.performanceTimestampProvider=void 0;zr.performanceTimestampProvider={now:function(){return (zr.performanceTimestampProvider.delegate||performance).now()},delegate:void 0};});var Qs=d(_e=>{var sl=_e&&_e.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},ul=_e&&_e.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(_e,"__esModule",{value:true});_e.animationFrameProvider=void 0;var Jm=ue();_e.animationFrameProvider={schedule:function(e){var t=requestAnimationFrame,r=cancelAnimationFrame,n=_e.animationFrameProvider.delegate;n&&(t=n.requestAnimationFrame,r=n.cancelAnimationFrame);var i=t(function(a){r=void 0,e(a);});return new Jm.Subscription(function(){return r?.(i)})},requestAnimationFrame:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=_e.animationFrameProvider.delegate;return (r?.requestAnimationFrame||requestAnimationFrame).apply(void 0,ul([],sl(e)))},cancelAnimationFrame:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=_e.animationFrameProvider.delegate;return (r?.cancelAnimationFrame||cancelAnimationFrame).apply(void 0,ul([],sl(e)))},delegate:void 0};});var fl=d(Ln=>{Object.defineProperty(Ln,"__esModule",{value:true});Ln.animationFrames=void 0;var Xm=V(),Km=ol(),cl=Qs();function Zm(e){return e?ll(e):Ym}Ln.animationFrames=Zm;function ll(e){return new Xm.Observable(function(t){var r=e||Km.performanceTimestampProvider,n=r.now(),i=0,a=function(){t.closed||(i=cl.animationFrameProvider.requestAnimationFrame(function(o){i=0;var s=r.now();t.next({timestamp:e?s:o,elapsed:s-n}),a();}));};return a(),function(){i&&cl.animationFrameProvider.cancelAnimationFrame(i);}})}var Ym=ll();});var eu=d(Fn=>{Object.defineProperty(Fn,"__esModule",{value:true});Fn.ObjectUnsubscribedError=void 0;var Qm=Ge();Fn.ObjectUnsubscribedError=Qm.createErrorClass(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed";}});});var K=d(we=>{var pl=we&&we.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}(),e_=we&&we.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(we,"__esModule",{value:true});we.AnonymousSubject=we.Subject=void 0;var dl=V(),ru=ue(),t_=eu(),r_=Ne(),tu=qn(),vl=function(e){pl(t,e);function t(){var r=e.call(this)||this;return r.closed=false,r.currentObservers=null,r.observers=[],r.isStopped=false,r.hasError=false,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new nu(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new t_.ObjectUnsubscribedError},t.prototype.next=function(r){var n=this;tu.errorContext(function(){var i,a;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var o=e_(n.currentObservers),s=o.next();!s.done;s=o.next()){var u=s.value;u.next(r);}}catch(c){i={error:c};}finally{try{s&&!s.done&&(a=o.return)&&a.call(o);}finally{if(i)throw i.error}}}});},t.prototype.error=function(r){var n=this;tu.errorContext(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=true,n.thrownError=r;for(var i=n.observers;i.length;)i.shift().error(r);}});},t.prototype.complete=function(){var r=this;tu.errorContext(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=true;for(var n=r.observers;n.length;)n.shift().complete();}});},t.prototype.unsubscribe=function(){this.isStopped=this.closed=true,this.observers=this.currentObservers=null;},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return ((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:false,configurable:true}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,i=this,a=i.hasError,o=i.isStopped,s=i.observers;return a||o?ru.EMPTY_SUBSCRIPTION:(this.currentObservers=null,s.push(r),new ru.Subscription(function(){n.currentObservers=null,r_.arrRemove(s,r);}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,a=n.thrownError,o=n.isStopped;i?r.error(a):o&&r.complete();},t.prototype.asObservable=function(){var r=new dl.Observable;return r.source=this,r},t.create=function(r,n){return new nu(r,n)},t}(dl.Observable);we.Subject=vl;var nu=function(e){pl(t,e);function t(r,n){var i=e.call(this)||this;return i.destination=r,i.source=n,i}return t.prototype.next=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.next)===null||i===void 0||i.call(n,r);},t.prototype.error=function(r){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.error)===null||i===void 0||i.call(n,r);},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r);},t.prototype._subscribe=function(r){var n,i;return (i=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&i!==void 0?i:ru.EMPTY_SUBSCRIPTION},t}(vl);we.AnonymousSubject=nu;});var iu=d(Yt=>{var n_=Yt&&Yt.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(Yt,"__esModule",{value:true});Yt.BehaviorSubject=void 0;var i_=K(),a_=function(e){n_(t,e);function t(r){var n=e.call(this)||this;return n._value=r,n}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:false,configurable:true}),t.prototype._subscribe=function(r){var n=e.prototype._subscribe.call(this,r);return !n.closed&&r.next(this._value),n},t.prototype.getValue=function(){var r=this,n=r.hasError,i=r.thrownError,a=r._value;if(n)throw i;return this._throwIfClosed(),a},t.prototype.next=function(r){e.prototype.next.call(this,this._value=r);},t}(i_.Subject);Yt.BehaviorSubject=a_;});var Dn=d(Jr=>{Object.defineProperty(Jr,"__esModule",{value:true});Jr.dateTimestampProvider=void 0;Jr.dateTimestampProvider={now:function(){return (Jr.dateTimestampProvider.delegate||Date).now()},delegate:void 0};});var Un=d(Qt=>{var o_=Qt&&Qt.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(Qt,"__esModule",{value:true});Qt.ReplaySubject=void 0;var s_=K(),u_=Dn(),c_=function(e){o_(t,e);function t(r,n,i){r===void 0&&(r=1/0),n===void 0&&(n=1/0),i===void 0&&(i=u_.dateTimestampProvider);var a=e.call(this)||this;return a._bufferSize=r,a._windowTime=n,a._timestampProvider=i,a._buffer=[],a._infiniteTimeWindow=true,a._infiniteTimeWindow=n===1/0,a._bufferSize=Math.max(1,r),a._windowTime=Math.max(1,n),a}return t.prototype.next=function(r){var n=this,i=n.isStopped,a=n._buffer,o=n._infiniteTimeWindow,s=n._timestampProvider,u=n._windowTime;i||(a.push(r),!o&&a.push(s.now()+u)),this._trimBuffer(),e.prototype.next.call(this,r);},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),i=this,a=i._infiniteTimeWindow,o=i._buffer,s=o.slice(),u=0;u<s.length&&!r.closed;u+=a?1:2)r.next(s[u]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,i=r._timestampProvider,a=r._buffer,o=r._infiniteTimeWindow,s=(o?1:2)*n;if(n<1/0&&s<a.length&&a.splice(0,a.length-s),!o){for(var u=i.now(),c=0,f=1;f<a.length&&a[f]<=u;f+=2)c=f;c&&a.splice(0,c+1);}},t}(s_.Subject);Qt.ReplaySubject=c_;});var Vn=d(er=>{var l_=er&&er.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(er,"__esModule",{value:true});er.AsyncSubject=void 0;var f_=K(),d_=function(e){l_(t,e);function t(){var r=e!==null&&e.apply(this,arguments)||this;return r._value=null,r._hasValue=false,r._isComplete=false,r}return t.prototype._checkFinalizedStatuses=function(r){var n=this,i=n.hasError,a=n._hasValue,o=n._value,s=n.thrownError,u=n.isStopped,c=n._isComplete;i?r.error(s):(u||c)&&(a&&r.next(o),r.complete());},t.prototype.next=function(r){this.isStopped||(this._value=r,this._hasValue=true);},t.prototype.complete=function(){var r=this,n=r._hasValue,i=r._value,a=r._isComplete;a||(this._isComplete=true,n&&e.prototype.next.call(this,i),e.prototype.complete.call(this));},t}(f_.Subject);er.AsyncSubject=d_;});var hl=d(tr=>{var p_=tr&&tr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(tr,"__esModule",{value:true});tr.Action=void 0;var v_=ue(),h_=function(e){p_(t,e);function t(r,n){return e.call(this)||this}return t.prototype.schedule=function(r,n){return this},t}(v_.Subscription);tr.Action=h_;});var yl=d(Ae=>{var ml=Ae&&Ae.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},_l=Ae&&Ae.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Ae,"__esModule",{value:true});Ae.intervalProvider=void 0;Ae.intervalProvider={setInterval:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var i=Ae.intervalProvider.delegate;return i?.setInterval?i.setInterval.apply(i,_l([e,t],ml(r))):setInterval.apply(void 0,_l([e,t],ml(r)))},clearInterval:function(e){var t=Ae.intervalProvider.delegate;return (t?.clearInterval||clearInterval)(e)},delegate:void 0};});var nr=d(rr=>{var m_=rr&&rr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(rr,"__esModule",{value:true});rr.AsyncAction=void 0;var __=hl(),bl=yl(),y_=Ne(),b_=function(e){m_(t,e);function t(r,n){var i=e.call(this,r,n)||this;return i.scheduler=r,i.work=n,i.pending=false,i}return t.prototype.schedule=function(r,n){var i;if(n===void 0&&(n=0),this.closed)return this;this.state=r;var a=this.id,o=this.scheduler;return a!=null&&(this.id=this.recycleAsyncId(o,a,n)),this.pending=true,this.delay=n,this.id=(i=this.id)!==null&&i!==void 0?i:this.requestAsyncId(o,this.id,n),this},t.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),bl.intervalProvider.setInterval(r.flush.bind(r,this),i)},t.prototype.recycleAsyncId=function(r,n,i){if(i===void 0&&(i=0),i!=null&&this.delay===i&&this.pending===false)return n;n!=null&&bl.intervalProvider.clearInterval(n);},t.prototype.execute=function(r,n){if(this.closed)return new Error("executing a cancelled action");this.pending=false;var i=this._execute(r,n);if(i)return i;this.pending===false&&this.id!=null&&(this.id=this.recycleAsyncId(this.scheduler,this.id,null));},t.prototype._execute=function(r,n){var i=false,a;try{this.work(r);}catch(o){i=true,a=o||new Error("Scheduled action threw falsy error");}if(i)return this.unsubscribe(),a},t.prototype.unsubscribe=function(){if(!this.closed){var r=this,n=r.id,i=r.scheduler,a=i.actions;this.work=this.state=this.scheduler=null,this.pending=false,y_.arrRemove(a,this),n!=null&&(this.id=this.recycleAsyncId(i,n,null)),this.delay=null,e.prototype.unsubscribe.call(this);}},t}(__.Action);rr.AsyncAction=b_;});var El=d(ir=>{Object.defineProperty(ir,"__esModule",{value:true});ir.TestTools=ir.Immediate=void 0;var g_=1,au,Bn={};function gl(e){return e in Bn?(delete Bn[e],true):false}ir.Immediate={setImmediate:function(e){var t=g_++;return Bn[t]=true,au||(au=Promise.resolve()),au.then(function(){return gl(t)&&e()}),t},clearImmediate:function(e){gl(e);}};ir.TestTools={pending:function(){return Object.keys(Bn).length}};});var Ol=d(Te=>{var E_=Te&&Te.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},S_=Te&&Te.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Te,"__esModule",{value:true});Te.immediateProvider=void 0;var Sl=El(),O_=Sl.Immediate.setImmediate,w_=Sl.Immediate.clearImmediate;Te.immediateProvider={setImmediate:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Te.immediateProvider.delegate;return (r?.setImmediate||O_).apply(void 0,S_([],E_(e)))},clearImmediate:function(e){var t=Te.immediateProvider.delegate;return (t?.clearImmediate||w_)(e)},delegate:void 0};});var Al=d(ar=>{var A_=ar&&ar.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(ar,"__esModule",{value:true});ar.AsapAction=void 0;var T_=nr(),wl=Ol(),I_=function(e){A_(t,e);function t(r,n){var i=e.call(this,r,n)||this;return i.scheduler=r,i.work=n,i}return t.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),i!==null&&i>0?e.prototype.requestAsyncId.call(this,r,n,i):(r.actions.push(this),r._scheduled||(r._scheduled=wl.immediateProvider.setImmediate(r.flush.bind(r,void 0))))},t.prototype.recycleAsyncId=function(r,n,i){var a;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,i);var o=r.actions;n!=null&&((a=o[o.length-1])===null||a===void 0?void 0:a.id)!==n&&(wl.immediateProvider.clearImmediate(n),r._scheduled===n&&(r._scheduled=void 0));},t}(T_.AsyncAction);ar.AsapAction=I_;});var ou=d(Gn=>{Object.defineProperty(Gn,"__esModule",{value:true});Gn.Scheduler=void 0;var x_=Dn(),R_=function(){function e(t,r){r===void 0&&(r=e.now),this.schedulerActionCtor=t,this.now=r;}return e.prototype.schedule=function(t,r,n){return r===void 0&&(r=0),new this.schedulerActionCtor(this,t).schedule(n,r)},e.now=x_.dateTimestampProvider.now,e}();Gn.Scheduler=R_;});var sr=d(or=>{var P_=or&&or.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(or,"__esModule",{value:true});or.AsyncScheduler=void 0;var Tl=ou(),q_=function(e){P_(t,e);function t(r,n){n===void 0&&(n=Tl.Scheduler.now);var i=e.call(this,r,n)||this;return i.actions=[],i._active=false,i}return t.prototype.flush=function(r){var n=this.actions;if(this._active){n.push(r);return}var i;this._active=true;do if(i=r.execute(r.state,r.delay))break;while(r=n.shift());if(this._active=false,i){for(;r=n.shift();)r.unsubscribe();throw i}},t}(Tl.Scheduler);or.AsyncScheduler=q_;});var Il=d(ur=>{var C_=ur&&ur.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(ur,"__esModule",{value:true});ur.AsapScheduler=void 0;var N_=sr(),M_=function(e){C_(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=true;var n=this._scheduled;this._scheduled=void 0;var i=this.actions,a;r=r||i.shift();do if(a=r.execute(r.state,r.delay))break;while((r=i[0])&&r.id===n&&i.shift());if(this._active=false,a){for(;(r=i[0])&&r.id===n&&i.shift();)r.unsubscribe();throw a}},t}(N_.AsyncScheduler);ur.AsapScheduler=M_;});var xl=d(yt=>{Object.defineProperty(yt,"__esModule",{value:true});yt.asap=yt.asapScheduler=void 0;var k_=Al(),j_=Il();yt.asapScheduler=new j_.AsapScheduler(k_.AsapAction);yt.asap=yt.asapScheduler;});var ie=d(bt=>{Object.defineProperty(bt,"__esModule",{value:true});bt.async=bt.asyncScheduler=void 0;var L_=nr(),F_=sr();bt.asyncScheduler=new F_.AsyncScheduler(L_.AsyncAction);bt.async=bt.asyncScheduler;});var Rl=d(cr=>{var D_=cr&&cr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(cr,"__esModule",{value:true});cr.QueueAction=void 0;var U_=nr(),V_=function(e){D_(t,e);function t(r,n){var i=e.call(this,r,n)||this;return i.scheduler=r,i.work=n,i}return t.prototype.schedule=function(r,n){return n===void 0&&(n=0),n>0?e.prototype.schedule.call(this,r,n):(this.delay=n,this.state=r,this.scheduler.flush(this),this)},t.prototype.execute=function(r,n){return n>0||this.closed?e.prototype.execute.call(this,r,n):this._execute(r,n)},t.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),i!=null&&i>0||i==null&&this.delay>0?e.prototype.requestAsyncId.call(this,r,n,i):(r.flush(this),0)},t}(U_.AsyncAction);cr.QueueAction=V_;});var Pl=d(lr=>{var B_=lr&&lr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(lr,"__esModule",{value:true});lr.QueueScheduler=void 0;var G_=sr(),H_=function(e){B_(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t}(G_.AsyncScheduler);lr.QueueScheduler=H_;});var ql=d(gt=>{Object.defineProperty(gt,"__esModule",{value:true});gt.queue=gt.queueScheduler=void 0;var W_=Rl(),$_=Pl();gt.queueScheduler=new $_.QueueScheduler(W_.QueueAction);gt.queue=gt.queueScheduler;});var Nl=d(fr=>{var z_=fr&&fr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(fr,"__esModule",{value:true});fr.AnimationFrameAction=void 0;var J_=nr(),Cl=Qs(),X_=function(e){z_(t,e);function t(r,n){var i=e.call(this,r,n)||this;return i.scheduler=r,i.work=n,i}return t.prototype.requestAsyncId=function(r,n,i){return i===void 0&&(i=0),i!==null&&i>0?e.prototype.requestAsyncId.call(this,r,n,i):(r.actions.push(this),r._scheduled||(r._scheduled=Cl.animationFrameProvider.requestAnimationFrame(function(){return r.flush(void 0)})))},t.prototype.recycleAsyncId=function(r,n,i){var a;if(i===void 0&&(i=0),i!=null?i>0:this.delay>0)return e.prototype.recycleAsyncId.call(this,r,n,i);var o=r.actions;n!=null&&((a=o[o.length-1])===null||a===void 0?void 0:a.id)!==n&&(Cl.animationFrameProvider.cancelAnimationFrame(n),r._scheduled=void 0);},t}(J_.AsyncAction);fr.AnimationFrameAction=X_;});var Ml=d(dr=>{var K_=dr&&dr.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(dr,"__esModule",{value:true});dr.AnimationFrameScheduler=void 0;var Z_=sr(),Y_=function(e){K_(t,e);function t(){return e!==null&&e.apply(this,arguments)||this}return t.prototype.flush=function(r){this._active=true;var n=this._scheduled;this._scheduled=void 0;var i=this.actions,a;r=r||i.shift();do if(a=r.execute(r.state,r.delay))break;while((r=i[0])&&r.id===n&&i.shift());if(this._active=false,a){for(;(r=i[0])&&r.id===n&&i.shift();)r.unsubscribe();throw a}},t}(Z_.AsyncScheduler);dr.AnimationFrameScheduler=Y_;});var kl=d(Et=>{Object.defineProperty(Et,"__esModule",{value:true});Et.animationFrame=Et.animationFrameScheduler=void 0;var Q_=Nl(),ey=Ml();Et.animationFrameScheduler=new ey.AnimationFrameScheduler(Q_.AnimationFrameAction);Et.animationFrame=Et.animationFrameScheduler;});var Fl=d(We=>{var jl=We&&We.__extends||function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)Object.prototype.hasOwnProperty.call(i,a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}();Object.defineProperty(We,"__esModule",{value:true});We.VirtualAction=We.VirtualTimeScheduler=void 0;var ty=nr(),ry=ue(),ny=sr(),iy=function(e){jl(t,e);function t(r,n){r===void 0&&(r=Ll),n===void 0&&(n=1/0);var i=e.call(this,r,function(){return i.frame})||this;return i.maxFrames=n,i.frame=0,i.index=-1,i}return t.prototype.flush=function(){for(var r=this,n=r.actions,i=r.maxFrames,a,o;(o=n[0])&&o.delay<=i&&(n.shift(),this.frame=o.delay,!(a=o.execute(o.state,o.delay))););if(a){for(;o=n.shift();)o.unsubscribe();throw a}},t.frameTimeFactor=10,t}(ny.AsyncScheduler);We.VirtualTimeScheduler=iy;var Ll=function(e){jl(t,e);function t(r,n,i){i===void 0&&(i=r.index+=1);var a=e.call(this,r,n)||this;return a.scheduler=r,a.work=n,a.index=i,a.active=true,a.index=r.index=i,a}return t.prototype.schedule=function(r,n){if(n===void 0&&(n=0),Number.isFinite(n)){if(!this.id)return e.prototype.schedule.call(this,r,n);this.active=false;var i=new t(this.scheduler,this.work);return this.add(i),i.schedule(r,n)}else return ry.Subscription.EMPTY},t.prototype.requestAsyncId=function(r,n,i){i===void 0&&(i=0),this.delay=r.frame+i;var a=r.actions;return a.push(this),a.sort(t.sortActions),1},t.prototype.recycleAsyncId=function(r,n,i){},t.prototype._execute=function(r,n){if(this.active===true)return e.prototype._execute.call(this,r,n)},t.sortActions=function(r,n){return r.delay===n.delay?r.index===n.index?0:r.index>n.index?1:-1:r.delay>n.delay?1:-1},t}(ty.AsyncAction);We.VirtualAction=Ll;});var ye=d(St=>{Object.defineProperty(St,"__esModule",{value:true});St.empty=St.EMPTY=void 0;var Dl=V();St.EMPTY=new Dl.Observable(function(e){return e.complete()});function ay(e){return e?oy(e):St.EMPTY}St.empty=ay;function oy(e){return new Dl.Observable(function(t){return e.schedule(function(){return t.complete()})})}});var Xr=d(Hn=>{Object.defineProperty(Hn,"__esModule",{value:true});Hn.isScheduler=void 0;var sy=U();function uy(e){return e&&sy.isFunction(e.schedule)}Hn.isScheduler=uy;});var ae=d($e=>{Object.defineProperty($e,"__esModule",{value:true});$e.popNumber=$e.popScheduler=$e.popResultSelector=void 0;var cy=U(),ly=Xr();function su(e){return e[e.length-1]}function fy(e){return cy.isFunction(su(e))?e.pop():void 0}$e.popResultSelector=fy;function dy(e){return ly.isScheduler(su(e))?e.pop():void 0}$e.popScheduler=dy;function py(e,t){return typeof su(e)=="number"?e.pop():t}$e.popNumber=py;});var $n=d(Wn=>{Object.defineProperty(Wn,"__esModule",{value:true});Wn.isArrayLike=void 0;Wn.isArrayLike=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};});var uu=d(zn=>{Object.defineProperty(zn,"__esModule",{value:true});zn.isPromise=void 0;var vy=U();function hy(e){return vy.isFunction(e?.then)}zn.isPromise=hy;});var cu=d(Jn=>{Object.defineProperty(Jn,"__esModule",{value:true});Jn.isInteropObservable=void 0;var my=Hr(),_y=U();function yy(e){return _y.isFunction(e[my.observable])}Jn.isInteropObservable=yy;});var lu=d(Xn=>{Object.defineProperty(Xn,"__esModule",{value:true});Xn.isAsyncIterable=void 0;var by=U();function gy(e){return Symbol.asyncIterator&&by.isFunction(e?.[Symbol.asyncIterator])}Xn.isAsyncIterable=gy;});var fu=d(Kn=>{Object.defineProperty(Kn,"__esModule",{value:true});Kn.createInvalidObservableTypeError=void 0;function Ey(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}Kn.createInvalidObservableTypeError=Ey;});var du=d(pr=>{Object.defineProperty(pr,"__esModule",{value:true});pr.iterator=pr.getSymbolIterator=void 0;function Ul(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}pr.getSymbolIterator=Ul;pr.iterator=Ul();});var pu=d(Zn=>{Object.defineProperty(Zn,"__esModule",{value:true});Zn.isIterable=void 0;var Sy=du(),Oy=U();function wy(e){return Oy.isFunction(e?.[Sy.iterator])}Zn.isIterable=wy;});var Yn=d(fe=>{var Ay=fe&&fe.__generator||function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(c){return function(f){return u([c,f])}}function u(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(f){c=[6,f],i=0;}finally{n=a=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:true}}},vr=fe&&fe.__await||function(e){return this instanceof vr?(this.v=e,this):new vr(e)},Ty=fe&&fe.__asyncGenerator||function(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,a=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(h){n[h]&&(i[h]=function(m){return new Promise(function(_,y){a.push([h,m,_,y])>1||s(h,m);})});}function s(h,m){try{u(n[h](m));}catch(_){v(a[0][3],_);}}function u(h){h.value instanceof vr?Promise.resolve(h.value.v).then(c,f):v(a[0][2],h);}function c(h){s("next",h);}function f(h){s("throw",h);}function v(h,m){h(m),a.shift(),a.length&&s(a[0][0],a[0][1]);}};Object.defineProperty(fe,"__esModule",{value:true});fe.isReadableStreamLike=fe.readableStreamLikeToAsyncGenerator=void 0;var Iy=U();function xy(e){return Ty(this,arguments,function(){var r,n,i,a;return Ay(this,function(o){switch(o.label){case 0:r=e.getReader(),o.label=1;case 1:o.trys.push([1,,9,10]),o.label=2;case 2:return [4,vr(r.read())];case 3:return n=o.sent(),i=n.value,a=n.done,a?[4,vr(void 0)]:[3,5];case 4:return [2,o.sent()];case 5:return [4,vr(i)];case 6:return [4,o.sent()];case 7:return o.sent(),[3,2];case 8:return [3,10];case 9:return r.releaseLock(),[7];case 10:return [2]}})})}fe.readableStreamLikeToAsyncGenerator=xy;function Ry(e){return Iy.isFunction(e?.getReader)}fe.isReadableStreamLike=Ry;});var C=d(H=>{var Py=H&&H.__awaiter||function(e,t,r,n){function i(a){return a instanceof r?a:new r(function(o){o(a);})}return new(r||(r=Promise))(function(a,o){function s(f){try{c(n.next(f));}catch(v){o(v);}}function u(f){try{c(n.throw(f));}catch(v){o(v);}}function c(f){f.done?a(f.value):i(f.value).then(s,u);}c((n=n.apply(e,t||[])).next());})},qy=H&&H.__generator||function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(c){return function(f){return u([c,f])}}function u(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(f){c=[6,f],i=0;}finally{n=a=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:true}}},Cy=H&&H.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof vu=="function"?vu(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(a){r[a]=e[a]&&function(o){return new Promise(function(s,u){o=e[a](o),i(s,u,o.done,o.value);})};}function i(a,o,s,u){Promise.resolve(u).then(function(c){a({value:c,done:s});},o);}},vu=H&&H.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(H,"__esModule",{value:true});H.fromReadableStreamLike=H.fromAsyncIterable=H.fromIterable=H.fromPromise=H.fromArrayLike=H.fromInteropObservable=H.innerFrom=void 0;var Ny=$n(),My=uu(),hr=V(),ky=cu(),jy=lu(),Ly=fu(),Fy=pu(),Vl=Yn(),Dy=U(),Uy=Ws(),Vy=Hr();function By(e){if(e instanceof hr.Observable)return e;if(e!=null){if(ky.isInteropObservable(e))return Bl(e);if(Ny.isArrayLike(e))return Gl(e);if(My.isPromise(e))return Hl(e);if(jy.isAsyncIterable(e))return hu(e);if(Fy.isIterable(e))return Wl(e);if(Vl.isReadableStreamLike(e))return $l(e)}throw Ly.createInvalidObservableTypeError(e)}H.innerFrom=By;function Bl(e){return new hr.Observable(function(t){var r=e[Vy.observable]();if(Dy.isFunction(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}H.fromInteropObservable=Bl;function Gl(e){return new hr.Observable(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete();})}H.fromArrayLike=Gl;function Hl(e){return new hr.Observable(function(t){e.then(function(r){t.closed||(t.next(r),t.complete());},function(r){return t.error(r)}).then(null,Uy.reportUnhandledError);})}H.fromPromise=Hl;function Wl(e){return new hr.Observable(function(t){var r,n;try{for(var i=vu(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(s){r={error:s};}finally{try{a&&!a.done&&(n=i.return)&&n.call(i);}finally{if(r)throw r.error}}t.complete();})}H.fromIterable=Wl;function hu(e){return new hr.Observable(function(t){Gy(e,t).catch(function(r){return t.error(r)});})}H.fromAsyncIterable=hu;function $l(e){return hu(Vl.readableStreamLikeToAsyncGenerator(e))}H.fromReadableStreamLike=$l;function Gy(e,t){var r,n,i,a;return Py(this,void 0,void 0,function(){var o,s;return qy(this,function(u){switch(u.label){case 0:u.trys.push([0,5,6,11]),r=Cy(e),u.label=1;case 1:return [4,r.next()];case 2:if(n=u.sent(),!!n.done)return [3,4];if(o=n.value,t.next(o),t.closed)return [2];u.label=3;case 3:return [3,1];case 4:return [3,11];case 5:return s=u.sent(),i={error:s},[3,11];case 6:return u.trys.push([6,,9,10]),n&&!n.done&&(a=r.return)?[4,a.call(r)]:[3,8];case 7:u.sent(),u.label=8;case 8:return [3,10];case 9:if(i)throw i.error;return [7];case 10:return [7];case 11:return t.complete(),[2]}})})}});var Me=d(Qn=>{Object.defineProperty(Qn,"__esModule",{value:true});Qn.executeSchedule=void 0;function Hy(e,t,r,n,i){n===void 0&&(n=0),i===void 0&&(i=false);var a=t.schedule(function(){r(),i?e.add(this.schedule(null,n)):this.unsubscribe();},n);if(e.add(a),!i)return a}Qn.executeSchedule=Hy;});var Kr=d(ei=>{Object.defineProperty(ei,"__esModule",{value:true});ei.observeOn=void 0;var mu=Me(),Wy=S(),$y=x();function zy(e,t){return t===void 0&&(t=0),Wy.operate(function(r,n){r.subscribe($y.createOperatorSubscriber(n,function(i){return mu.executeSchedule(n,e,function(){return n.next(i)},t)},function(){return mu.executeSchedule(n,e,function(){return n.complete()},t)},function(i){return mu.executeSchedule(n,e,function(){return n.error(i)},t)}));})}ei.observeOn=zy;});var Zr=d(ti=>{Object.defineProperty(ti,"__esModule",{value:true});ti.subscribeOn=void 0;var Jy=S();function Xy(e,t){return t===void 0&&(t=0),Jy.operate(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t));})}ti.subscribeOn=Xy;});var zl=d(ri=>{Object.defineProperty(ri,"__esModule",{value:true});ri.scheduleObservable=void 0;var Ky=C(),Zy=Kr(),Yy=Zr();function Qy(e,t){return Ky.innerFrom(e).pipe(Yy.subscribeOn(t),Zy.observeOn(t))}ri.scheduleObservable=Qy;});var Jl=d(ni=>{Object.defineProperty(ni,"__esModule",{value:true});ni.schedulePromise=void 0;var eb=C(),tb=Kr(),rb=Zr();function nb(e,t){return eb.innerFrom(e).pipe(rb.subscribeOn(t),tb.observeOn(t))}ni.schedulePromise=nb;});var Xl=d(ii=>{Object.defineProperty(ii,"__esModule",{value:true});ii.scheduleArray=void 0;var ib=V();function ab(e,t){return new ib.Observable(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule());})})}ii.scheduleArray=ab;});var _u=d(ai=>{Object.defineProperty(ai,"__esModule",{value:true});ai.scheduleIterable=void 0;var ob=V(),sb=du(),ub=U(),Kl=Me();function cb(e,t){return new ob.Observable(function(r){var n;return Kl.executeSchedule(r,t,function(){n=e[sb.iterator](),Kl.executeSchedule(r,t,function(){var i,a,o;try{i=n.next(),a=i.value,o=i.done;}catch(s){r.error(s);return}o?r.complete():r.next(a);},0,true);}),function(){return ub.isFunction(n?.return)&&n.return()}})}ai.scheduleIterable=cb;});var yu=d(oi=>{Object.defineProperty(oi,"__esModule",{value:true});oi.scheduleAsyncIterable=void 0;var lb=V(),Zl=Me();function fb(e,t){if(!e)throw new Error("Iterable cannot be null");return new lb.Observable(function(r){Zl.executeSchedule(r,t,function(){var n=e[Symbol.asyncIterator]();Zl.executeSchedule(r,t,function(){n.next().then(function(i){i.done?r.complete():r.next(i.value);});},0,true);});})}oi.scheduleAsyncIterable=fb;});var Yl=d(si=>{Object.defineProperty(si,"__esModule",{value:true});si.scheduleReadableStreamLike=void 0;var db=yu(),pb=Yn();function vb(e,t){return db.scheduleAsyncIterable(pb.readableStreamLikeToAsyncGenerator(e),t)}si.scheduleReadableStreamLike=vb;});var bu=d(ui=>{Object.defineProperty(ui,"__esModule",{value:true});ui.scheduled=void 0;var hb=zl(),mb=Jl(),_b=Xl(),yb=_u(),bb=yu(),gb=cu(),Eb=uu(),Sb=$n(),Ob=pu(),wb=lu(),Ab=fu(),Tb=Yn(),Ib=Yl();function xb(e,t){if(e!=null){if(gb.isInteropObservable(e))return hb.scheduleObservable(e,t);if(Sb.isArrayLike(e))return _b.scheduleArray(e,t);if(Eb.isPromise(e))return mb.schedulePromise(e,t);if(wb.isAsyncIterable(e))return bb.scheduleAsyncIterable(e,t);if(Ob.isIterable(e))return yb.scheduleIterable(e,t);if(Tb.isReadableStreamLike(e))return Ib.scheduleReadableStreamLike(e,t)}throw Ab.createInvalidObservableTypeError(e)}ui.scheduled=xb;});var ke=d(ci=>{Object.defineProperty(ci,"__esModule",{value:true});ci.from=void 0;var Rb=bu(),Pb=C();function qb(e,t){return t?Rb.scheduled(e,t):Pb.innerFrom(e)}ci.from=qb;});var fi=d(li=>{Object.defineProperty(li,"__esModule",{value:true});li.of=void 0;var Cb=ae(),Nb=ke();function Mb(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Cb.popScheduler(e);return Nb.from(e,r)}li.of=Mb;});var gu=d(di=>{Object.defineProperty(di,"__esModule",{value:true});di.throwError=void 0;var kb=V(),jb=U();function Lb(e,t){var r=jb.isFunction(e)?e:function(){return e},n=function(i){return i.error(r())};return new kb.Observable(t?function(i){return t.schedule(n,0,i)}:n)}di.throwError=Lb;});var pi=d(je=>{Object.defineProperty(je,"__esModule",{value:true});je.observeNotification=je.Notification=je.NotificationKind=void 0;var Fb=ye(),Db=fi(),Ub=gu(),Vb=U();(function(e){e.NEXT="N",e.ERROR="E",e.COMPLETE="C";})(je.NotificationKind||(je.NotificationKind={}));var Gb=function(){function e(t,r,n){this.kind=t,this.value=r,this.error=n,this.hasValue=t==="N";}return e.prototype.observe=function(t){return Ql(this,t)},e.prototype.do=function(t,r,n){var i=this,a=i.kind,o=i.value,s=i.error;return a==="N"?t?.(o):a==="E"?r?.(s):n?.()},e.prototype.accept=function(t,r,n){var i;return Vb.isFunction((i=t)===null||i===void 0?void 0:i.next)?this.observe(t):this.do(t,r,n)},e.prototype.toObservable=function(){var t=this,r=t.kind,n=t.value,i=t.error,a=r==="N"?Db.of(n):r==="E"?Ub.throwError(function(){return i}):r==="C"?Fb.EMPTY:0;if(!a)throw new TypeError("Unexpected notification kind "+r);return a},e.createNext=function(t){return new e("N",t)},e.createError=function(t){return new e("E",void 0,t)},e.createComplete=function(){return e.completeNotification},e.completeNotification=new e("C"),e}();je.Notification=Gb;function Ql(e,t){var r,n,i,a=e,o=a.kind,s=a.value,u=a.error;if(typeof o!="string")throw new TypeError('Invalid notification, missing "kind"');o==="N"?(r=t.next)===null||r===void 0||r.call(t,s):o==="E"?(n=t.error)===null||n===void 0||n.call(t,u):(i=t.complete)===null||i===void 0||i.call(t);}je.observeNotification=Ql;});var tf=d(vi=>{Object.defineProperty(vi,"__esModule",{value:true});vi.isObservable=void 0;var Hb=V(),ef=U();function Wb(e){return !!e&&(e instanceof Hb.Observable||ef.isFunction(e.lift)&&ef.isFunction(e.subscribe))}vi.isObservable=Wb;});var ze=d(hi=>{Object.defineProperty(hi,"__esModule",{value:true});hi.EmptyError=void 0;var $b=Ge();hi.EmptyError=$b.createErrorClass(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence";}});});var rf=d(mi=>{Object.defineProperty(mi,"__esModule",{value:true});mi.lastValueFrom=void 0;var zb=ze();function Jb(e,t){var r=typeof t=="object";return new Promise(function(n,i){var a=false,o;e.subscribe({next:function(s){o=s,a=true;},error:i,complete:function(){a?n(o):r?n(t.defaultValue):i(new zb.EmptyError);}});})}mi.lastValueFrom=Jb;});var nf=d(_i=>{Object.defineProperty(_i,"__esModule",{value:true});_i.firstValueFrom=void 0;var Xb=ze(),Kb=Jt();function Zb(e,t){var r=typeof t=="object";return new Promise(function(n,i){var a=new Kb.SafeSubscriber({next:function(o){n(o),a.unsubscribe();},error:i,complete:function(){r?n(t.defaultValue):i(new Xb.EmptyError);}});e.subscribe(a);})}_i.firstValueFrom=Zb;});var Eu=d(yi=>{Object.defineProperty(yi,"__esModule",{value:true});yi.ArgumentOutOfRangeError=void 0;var Yb=Ge();yi.ArgumentOutOfRangeError=Yb.createErrorClass(function(e){return function(){e(this),this.name="ArgumentOutOfRangeError",this.message="argument out of range";}});});var Su=d(bi=>{Object.defineProperty(bi,"__esModule",{value:true});bi.NotFoundError=void 0;var Qb=Ge();bi.NotFoundError=Qb.createErrorClass(function(e){return function(r){e(this),this.name="NotFoundError",this.message=r;}});});var Ou=d(gi=>{Object.defineProperty(gi,"__esModule",{value:true});gi.SequenceError=void 0;var eg=Ge();gi.SequenceError=eg.createErrorClass(function(e){return function(r){e(this),this.name="SequenceError",this.message=r;}});});var Si=d(Ei=>{Object.defineProperty(Ei,"__esModule",{value:true});Ei.isValidDate=void 0;function tg(e){return e instanceof Date&&!isNaN(e)}Ei.isValidDate=tg;});var Oi=d(Ot=>{Object.defineProperty(Ot,"__esModule",{value:true});Ot.timeout=Ot.TimeoutError=void 0;var rg=ie(),ng=Si(),ig=S(),ag=C(),og=Ge(),sg=x(),ug=Me();Ot.TimeoutError=og.createErrorClass(function(e){return function(r){r===void 0&&(r=null),e(this),this.message="Timeout has occurred",this.name="TimeoutError",this.info=r;}});function cg(e,t){var r=ng.isValidDate(e)?{first:e}:typeof e=="number"?{each:e}:e,n=r.first,i=r.each,a=r.with,o=a===void 0?lg:a,s=r.scheduler,u=s===void 0?t??rg.asyncScheduler:s,c=r.meta,f=c===void 0?null:c;if(n==null&&i==null)throw new TypeError("No timeout provided.");return ig.operate(function(v,h){var m,_,y=null,g=0,I=function(L){_=ug.executeSchedule(h,u,function(){try{m.unsubscribe(),ag.innerFrom(o({meta:f,lastValue:y,seen:g})).subscribe(h);}catch(B){h.error(B);}},L);};m=v.subscribe(sg.createOperatorSubscriber(h,function(L){_?.unsubscribe(),g++,h.next(y=L),i>0&&I(i);},void 0,void 0,function(){_?.closed||_?.unsubscribe(),y=null;})),!g&&I(n!=null?typeof n=="number"?n:+n-u.now():i);})}Ot.timeout=cg;function lg(e){throw new Ot.TimeoutError(e)}});var Je=d(wi=>{Object.defineProperty(wi,"__esModule",{value:true});wi.map=void 0;var fg=S(),dg=x();function pg(e,t){return fg.operate(function(r,n){var i=0;r.subscribe(dg.createOperatorSubscriber(n,function(a){n.next(e.call(t,a,i++));}));})}wi.map=pg;});var Ke=d(Xe=>{var vg=Xe&&Xe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},hg=Xe&&Xe.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Xe,"__esModule",{value:true});Xe.mapOneOrManyArgs=void 0;var mg=Je(),_g=Array.isArray;function yg(e,t){return _g(t)?e.apply(void 0,hg([],vg(t))):e(t)}function bg(e){return mg.map(function(t){return yg(e,t)})}Xe.mapOneOrManyArgs=bg;});var Au=d(Ze=>{var gg=Ze&&Ze.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},af=Ze&&Ze.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Ze,"__esModule",{value:true});Ze.bindCallbackInternals=void 0;var Eg=Xr(),Sg=V(),Og=Zr(),wg=Ke(),Ag=Kr(),Tg=Vn();function wu(e,t,r,n){if(r)if(Eg.isScheduler(r))n=r;else return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return wu(e,t,n).apply(this,i).pipe(wg.mapOneOrManyArgs(r))};return n?function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];return wu(e,t).apply(this,i).pipe(Og.subscribeOn(n),Ag.observeOn(n))}:function(){for(var i=this,a=[],o=0;o<arguments.length;o++)a[o]=arguments[o];var s=new Tg.AsyncSubject,u=true;return new Sg.Observable(function(c){var f=s.subscribe(c);if(u){u=false;var v=false,h=false;t.apply(i,af(af([],gg(a)),[function(){for(var m=[],_=0;_<arguments.length;_++)m[_]=arguments[_];if(e){var y=m.shift();if(y!=null){s.error(y);return}}s.next(1<m.length?m:m[0]),h=true,v&&s.complete();}])),h&&s.complete(),v=true;}return f})}}Ze.bindCallbackInternals=wu;});var of=d(Ai=>{Object.defineProperty(Ai,"__esModule",{value:true});Ai.bindCallback=void 0;var Ig=Au();function xg(e,t,r){return Ig.bindCallbackInternals(false,e,t,r)}Ai.bindCallback=xg;});var sf=d(Ti=>{Object.defineProperty(Ti,"__esModule",{value:true});Ti.bindNodeCallback=void 0;var Rg=Au();function Pg(e,t,r){return Rg.bindCallbackInternals(true,e,t,r)}Ti.bindNodeCallback=Pg;});var Tu=d(Ii=>{Object.defineProperty(Ii,"__esModule",{value:true});Ii.argsArgArrayOrObject=void 0;var qg=Array.isArray,Cg=Object.getPrototypeOf,Ng=Object.prototype,Mg=Object.keys;function kg(e){if(e.length===1){var t=e[0];if(qg(t))return {args:t,keys:null};if(jg(t)){var r=Mg(t);return {args:r.map(function(n){return t[n]}),keys:r}}}return {args:e,keys:null}}Ii.argsArgArrayOrObject=kg;function jg(e){return e&&typeof e=="object"&&Cg(e)===Ng}});var Iu=d(xi=>{Object.defineProperty(xi,"__esModule",{value:true});xi.createObject=void 0;function Lg(e,t){return e.reduce(function(r,n,i){return r[n]=t[i],r},{})}xi.createObject=Lg;});var Ri=d(mr=>{Object.defineProperty(mr,"__esModule",{value:true});mr.combineLatestInit=mr.combineLatest=void 0;var Fg=V(),Dg=Tu(),lf=ke(),ff=X(),Ug=Ke(),uf=ae(),Vg=Iu(),Bg=x(),Gg=Me();function Hg(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=uf.popScheduler(e),n=uf.popResultSelector(e),i=Dg.argsArgArrayOrObject(e),a=i.args,o=i.keys;if(a.length===0)return lf.from([],r);var s=new Fg.Observable(df(a,r,o?function(u){return Vg.createObject(o,u)}:ff.identity));return n?s.pipe(Ug.mapOneOrManyArgs(n)):s}mr.combineLatest=Hg;function df(e,t,r){return r===void 0&&(r=ff.identity),function(n){cf(t,function(){for(var i=e.length,a=new Array(i),o=i,s=i,u=function(f){cf(t,function(){var v=lf.from(e[f],t),h=false;v.subscribe(Bg.createOperatorSubscriber(n,function(m){a[f]=m,h||(h=true,s--),s||n.next(r(a.slice()));},function(){--o||n.complete();}));},n);},c=0;c<i;c++)u(c);},n);}}mr.combineLatestInit=df;function cf(e,t,r){e?Gg.executeSchedule(r,e,t):t();}});var qi=d(Pi=>{Object.defineProperty(Pi,"__esModule",{value:true});Pi.mergeInternals=void 0;var Wg=C(),$g=Me(),pf=x();function zg(e,t,r,n,i,a,o,s){var u=[],c=0,f=0,v=false,h=function(){v&&!u.length&&!c&&t.complete();},m=function(y){return c<n?_(y):u.push(y)},_=function(y){a&&t.next(y),c++;var g=false;Wg.innerFrom(r(y,f++)).subscribe(pf.createOperatorSubscriber(t,function(I){i?.(I),a?m(I):t.next(I);},function(){g=true;},void 0,function(){if(g)try{c--;for(var I=function(){var L=u.shift();o?$g.executeSchedule(t,o,function(){return _(L)}):_(L);};u.length&&c<n;)I();h();}catch(L){t.error(L);}}));};return e.subscribe(pf.createOperatorSubscriber(t,m,function(){v=true,h();})),function(){s?.();}}Pi.mergeInternals=zg;});var Le=d(Ci=>{Object.defineProperty(Ci,"__esModule",{value:true});Ci.mergeMap=void 0;var Jg=Je(),Xg=C(),Kg=S(),Zg=qi(),Yg=U();function vf(e,t,r){return r===void 0&&(r=1/0),Yg.isFunction(t)?vf(function(n,i){return Jg.map(function(a,o){return t(n,a,i,o)})(Xg.innerFrom(e(n,i)))},r):(typeof t=="number"&&(r=t),Kg.operate(function(n,i){return Zg.mergeInternals(n,i,e,r)}))}Ci.mergeMap=vf;});var Yr=d(Ni=>{Object.defineProperty(Ni,"__esModule",{value:true});Ni.mergeAll=void 0;var Qg=Le(),e0=X();function t0(e){return e===void 0&&(e=1/0),Qg.mergeMap(e0.identity,e)}Ni.mergeAll=t0;});var ki=d(Mi=>{Object.defineProperty(Mi,"__esModule",{value:true});Mi.concatAll=void 0;var r0=Yr();function n0(){return r0.mergeAll(1)}Mi.concatAll=n0;});var Qr=d(ji=>{Object.defineProperty(ji,"__esModule",{value:true});ji.concat=void 0;var i0=ki(),a0=ae(),o0=ke();function s0(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return i0.concatAll()(o0.from(e,a0.popScheduler(e)))}ji.concat=s0;});var en=d(Li=>{Object.defineProperty(Li,"__esModule",{value:true});Li.defer=void 0;var u0=V(),c0=C();function l0(e){return new u0.Observable(function(t){c0.innerFrom(e()).subscribe(t);})}Li.defer=l0;});var hf=d(Fi=>{Object.defineProperty(Fi,"__esModule",{value:true});Fi.connectable=void 0;var f0=K(),d0=V(),p0=en(),v0={connector:function(){return new f0.Subject},resetOnDisconnect:true};function h0(e,t){t===void 0&&(t=v0);var r=null,n=t.connector,i=t.resetOnDisconnect,a=i===void 0?true:i,o=n(),s=new d0.Observable(function(u){return o.subscribe(u)});return s.connect=function(){return (!r||r.closed)&&(r=p0.defer(function(){return e}).subscribe(o),a&&r.add(function(){return o=n()})),r},s}Fi.connectable=h0;});var mf=d(Di=>{Object.defineProperty(Di,"__esModule",{value:true});Di.forkJoin=void 0;var m0=V(),_0=Tu(),y0=C(),b0=ae(),g0=x(),E0=Ke(),S0=Iu();function O0(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=b0.popResultSelector(e),n=_0.argsArgArrayOrObject(e),i=n.args,a=n.keys,o=new m0.Observable(function(s){var u=i.length;if(!u){s.complete();return}for(var c=new Array(u),f=u,v=u,h=function(_){var y=false;y0.innerFrom(i[_]).subscribe(g0.createOperatorSubscriber(s,function(g){y||(y=true,v--),c[_]=g;},function(){return f--},void 0,function(){(!f||!y)&&(v||s.next(a?S0.createObject(a,c):c),s.complete());}));},m=0;m<u;m++)h(m);});return r?o.pipe(E0.mapOneOrManyArgs(r)):o}Di.forkJoin=O0;});var yf=d(_r=>{var w0=_r&&_r.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a};Object.defineProperty(_r,"__esModule",{value:true});_r.fromEvent=void 0;var A0=C(),T0=V(),I0=Le(),x0=$n(),wt=U(),R0=Ke(),P0=["addListener","removeListener"],q0=["addEventListener","removeEventListener"],C0=["on","off"];function xu(e,t,r,n){if(wt.isFunction(r)&&(n=r,r=void 0),n)return xu(e,t,r).pipe(R0.mapOneOrManyArgs(n));var i=w0(k0(e)?q0.map(function(s){return function(u){return e[s](t,u,r)}}):N0(e)?P0.map(_f(e,t)):M0(e)?C0.map(_f(e,t)):[],2),a=i[0],o=i[1];if(!a&&x0.isArrayLike(e))return I0.mergeMap(function(s){return xu(s,t,r)})(A0.innerFrom(e));if(!a)throw new TypeError("Invalid event target");return new T0.Observable(function(s){var u=function(){for(var c=[],f=0;f<arguments.length;f++)c[f]=arguments[f];return s.next(1<c.length?c:c[0])};return a(u),function(){return o(u)}})}_r.fromEvent=xu;function _f(e,t){return function(r){return function(n){return e[r](t,n)}}}function N0(e){return wt.isFunction(e.addListener)&&wt.isFunction(e.removeListener)}function M0(e){return wt.isFunction(e.on)&&wt.isFunction(e.off)}function k0(e){return wt.isFunction(e.addEventListener)&&wt.isFunction(e.removeEventListener)}});var gf=d(Ui=>{Object.defineProperty(Ui,"__esModule",{value:true});Ui.fromEventPattern=void 0;var j0=V(),L0=U(),F0=Ke();function bf(e,t,r){return r?bf(e,t).pipe(F0.mapOneOrManyArgs(r)):new j0.Observable(function(n){var i=function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];return n.next(o.length===1?o[0]:o)},a=e(i);return L0.isFunction(t)?function(){return t(i,a)}:void 0})}Ui.fromEventPattern=bf;});var Sf=d(yr=>{var D0=yr&&yr.__generator||function(e,t){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,o;return o={next:s(0),throw:s(1),return:s(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function s(c){return function(f){return u([c,f])}}function u(c){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,i=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(c[0]===6&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r);}catch(f){c=[6,f],i=0;}finally{n=a=0;}if(c[0]&5)throw c[1];return {value:c[0]?c[1]:void 0,done:true}}};Object.defineProperty(yr,"__esModule",{value:true});yr.generate=void 0;var Ef=X(),U0=Xr(),V0=en(),B0=_u();function G0(e,t,r,n,i){var a,o,s,u;arguments.length===1?(a=e,u=a.initialState,t=a.condition,r=a.iterate,o=a.resultSelector,s=o===void 0?Ef.identity:o,i=a.scheduler):(u=e,!n||U0.isScheduler(n)?(s=Ef.identity,i=n):s=n);function c(){var f;return D0(this,function(v){switch(v.label){case 0:f=u,v.label=1;case 1:return !t||t(f)?[4,s(f)]:[3,4];case 2:v.sent(),v.label=3;case 3:return f=r(f),[3,1];case 4:return [2]}})}return V0.defer(i?function(){return B0.scheduleIterable(c(),i)}:c)}yr.generate=G0;});var Of=d(Vi=>{Object.defineProperty(Vi,"__esModule",{value:true});Vi.iif=void 0;var H0=en();function W0(e,t,r){return H0.defer(function(){return e()?t:r})}Vi.iif=W0;});var Ye=d(Bi=>{Object.defineProperty(Bi,"__esModule",{value:true});Bi.timer=void 0;var $0=V(),z0=ie(),J0=Xr(),X0=Si();function K0(e,t,r){e===void 0&&(e=0),r===void 0&&(r=z0.async);var n=-1;return t!=null&&(J0.isScheduler(t)?r=t:n=t),new $0.Observable(function(i){var a=X0.isValidDate(e)?+e-r.now():e;a<0&&(a=0);var o=0;return r.schedule(function(){i.closed||(i.next(o++),0<=n?this.schedule(void 0,n):i.complete());},a)})}Bi.timer=K0;});var Ru=d(Gi=>{Object.defineProperty(Gi,"__esModule",{value:true});Gi.interval=void 0;var Z0=ie(),Y0=Ye();function Q0(e,t){return e===void 0&&(e=0),t===void 0&&(t=Z0.asyncScheduler),e<0&&(e=0),Y0.timer(e,e,t)}Gi.interval=Q0;});var Af=d(Hi=>{Object.defineProperty(Hi,"__esModule",{value:true});Hi.merge=void 0;var eE=Yr(),tE=C(),rE=ye(),wf=ae(),nE=ke();function iE(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=wf.popScheduler(e),n=wf.popNumber(e,1/0),i=e;return i.length?i.length===1?tE.innerFrom(i[0]):eE.mergeAll(n)(nE.from(i,r)):rE.EMPTY}Hi.merge=iE;});var Pu=d(At=>{Object.defineProperty(At,"__esModule",{value:true});At.never=At.NEVER=void 0;var aE=V(),oE=J();At.NEVER=new aE.Observable(oE.noop);function sE(){return At.NEVER}At.never=sE;});var Tt=d(Wi=>{Object.defineProperty(Wi,"__esModule",{value:true});Wi.argsOrArgArray=void 0;var uE=Array.isArray;function cE(e){return e.length===1&&uE(e[0])?e[0]:e}Wi.argsOrArgArray=cE;});var qu=d($i=>{Object.defineProperty($i,"__esModule",{value:true});$i.onErrorResumeNext=void 0;var lE=V(),fE=Tt(),dE=x(),Tf=J(),pE=C();function vE(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=fE.argsOrArgArray(e);return new lE.Observable(function(n){var i=0,a=function(){if(i<r.length){var o=void 0;try{o=pE.innerFrom(r[i++]);}catch{a();return}var s=new dE.OperatorSubscriber(n,void 0,Tf.noop,Tf.noop);o.subscribe(s),s.add(a);}else n.complete();};a();})}$i.onErrorResumeNext=vE;});var If=d(zi=>{Object.defineProperty(zi,"__esModule",{value:true});zi.pairs=void 0;var hE=ke();function mE(e,t){return hE.from(Object.entries(e),t)}zi.pairs=mE;});var xf=d(Ji=>{Object.defineProperty(Ji,"__esModule",{value:true});Ji.not=void 0;function _E(e,t){return function(r,n){return !e.call(t,r,n)}}Ji.not=_E;});var It=d(Xi=>{Object.defineProperty(Xi,"__esModule",{value:true});Xi.filter=void 0;var yE=S(),bE=x();function gE(e,t){return yE.operate(function(r,n){var i=0;r.subscribe(bE.createOperatorSubscriber(n,function(a){return e.call(t,a,i++)&&n.next(a)}));})}Xi.filter=gE;});var qf=d(Ki=>{Object.defineProperty(Ki,"__esModule",{value:true});Ki.partition=void 0;var EE=xf(),Rf=It(),Pf=C();function SE(e,t,r){return [Rf.filter(t,r)(Pf.innerFrom(e)),Rf.filter(EE.not(t,r))(Pf.innerFrom(e))]}Ki.partition=SE;});var Cu=d(br=>{Object.defineProperty(br,"__esModule",{value:true});br.raceInit=br.race=void 0;var OE=V(),Cf=C(),wE=Tt(),AE=x();function TE(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e=wE.argsOrArgArray(e),e.length===1?Cf.innerFrom(e[0]):new OE.Observable(Nf(e))}br.race=TE;function Nf(e){return function(t){for(var r=[],n=function(a){r.push(Cf.innerFrom(e[a]).subscribe(AE.createOperatorSubscriber(t,function(o){if(r){for(var s=0;s<r.length;s++)s!==a&&r[s].unsubscribe();r=null;}t.next(o);})));},i=0;r&&!t.closed&&i<e.length;i++)n(i);}}br.raceInit=Nf;});var Mf=d(Zi=>{Object.defineProperty(Zi,"__esModule",{value:true});Zi.range=void 0;var IE=V(),xE=ye();function RE(e,t,r){if(t==null&&(t=e,e=0),t<=0)return xE.EMPTY;var n=t+e;return new IE.Observable(r?function(i){var a=e;return r.schedule(function(){a<n?(i.next(a++),this.schedule()):i.complete();})}:function(i){for(var a=e;a<n&&!i.closed;)i.next(a++);i.complete();})}Zi.range=RE;});var kf=d(Yi=>{Object.defineProperty(Yi,"__esModule",{value:true});Yi.using=void 0;var PE=V(),qE=C(),CE=ye();function NE(e,t){return new PE.Observable(function(r){var n=e(),i=t(n),a=i?qE.innerFrom(i):CE.EMPTY;return a.subscribe(r),function(){n&&n.unsubscribe();}})}Yi.using=NE;});var Qi=d(Qe=>{var ME=Qe&&Qe.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},kE=Qe&&Qe.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Qe,"__esModule",{value:true});Qe.zip=void 0;var jE=V(),LE=C(),FE=Tt(),DE=ye(),UE=x(),VE=ae();function BE(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=VE.popResultSelector(e),n=FE.argsOrArgArray(e);return n.length?new jE.Observable(function(i){var a=n.map(function(){return []}),o=n.map(function(){return false});i.add(function(){a=o=null;});for(var s=function(c){LE.innerFrom(n[c]).subscribe(UE.createOperatorSubscriber(i,function(f){if(a[c].push(f),a.every(function(h){return h.length})){var v=a.map(function(h){return h.shift()});i.next(r?r.apply(void 0,kE([],ME(v))):v),a.some(function(h,m){return !h.length&&o[m]})&&i.complete();}},function(){o[c]=true,!a[c].length&&i.complete();}));},u=0;!i.closed&&u<n.length;u++)s(u);return function(){a=o=null;}}):DE.EMPTY}Qe.zip=BE;});var Lf=d(jf=>{Object.defineProperty(jf,"__esModule",{value:true});});var Nu=d(ea=>{Object.defineProperty(ea,"__esModule",{value:true});ea.audit=void 0;var GE=S(),HE=C(),Ff=x();function WE(e){return GE.operate(function(t,r){var n=false,i=null,a=null,o=false,s=function(){if(a?.unsubscribe(),a=null,n){n=false;var c=i;i=null,r.next(c);}o&&r.complete();},u=function(){a=null,o&&r.complete();};t.subscribe(Ff.createOperatorSubscriber(r,function(c){n=true,i=c,a||HE.innerFrom(e(c)).subscribe(a=Ff.createOperatorSubscriber(r,s,u));},function(){o=true,(!n||!a||a.closed)&&r.complete();}));})}ea.audit=WE;});var Df=d(ta=>{Object.defineProperty(ta,"__esModule",{value:true});ta.auditTime=void 0;var $E=ie(),zE=Nu(),JE=Ye();function XE(e,t){return t===void 0&&(t=$E.asyncScheduler),zE.audit(function(){return JE.timer(e,t)})}ta.auditTime=XE;});var Vf=d(ra=>{Object.defineProperty(ra,"__esModule",{value:true});ra.buffer=void 0;var KE=S(),ZE=J(),Uf=x(),YE=C();function QE(e){return KE.operate(function(t,r){var n=[];return t.subscribe(Uf.createOperatorSubscriber(r,function(i){return n.push(i)},function(){r.next(n),r.complete();})),YE.innerFrom(e).subscribe(Uf.createOperatorSubscriber(r,function(){var i=n;n=[],r.next(i);},ZE.noop)),function(){n=null;}})}ra.buffer=QE;});var Bf=d(gr=>{var Mu=gr&&gr.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(gr,"__esModule",{value:true});gr.bufferCount=void 0;var eS=S(),tS=x(),rS=Ne();function nS(e,t){return t===void 0&&(t=null),t=t??e,eS.operate(function(r,n){var i=[],a=0;r.subscribe(tS.createOperatorSubscriber(n,function(o){var s,u,c,f,v=null;a++%t===0&&i.push([]);try{for(var h=Mu(i),m=h.next();!m.done;m=h.next()){var _=m.value;_.push(o),e<=_.length&&(v=v??[],v.push(_));}}catch(I){s={error:I};}finally{try{m&&!m.done&&(u=h.return)&&u.call(h);}finally{if(s)throw s.error}}if(v)try{for(var y=Mu(v),g=y.next();!g.done;g=y.next()){var _=g.value;rS.arrRemove(i,_),n.next(_);}}catch(I){c={error:I};}finally{try{g&&!g.done&&(f=y.return)&&f.call(y);}finally{if(c)throw c.error}}},function(){var o,s;try{for(var u=Mu(i),c=u.next();!c.done;c=u.next()){var f=c.value;n.next(f);}}catch(v){o={error:v};}finally{try{c&&!c.done&&(s=u.return)&&s.call(u);}finally{if(o)throw o.error}}n.complete();},void 0,function(){i=null;}));})}gr.bufferCount=nS;});var Hf=d(Er=>{var iS=Er&&Er.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Er,"__esModule",{value:true});Er.bufferTime=void 0;var aS=ue(),oS=S(),sS=x(),uS=Ne(),cS=ie(),lS=ae(),Gf=Me();function fS(e){for(var t,r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=(t=lS.popScheduler(n))!==null&&t!==void 0?t:cS.asyncScheduler,o=(r=n[0])!==null&&r!==void 0?r:null,s=n[1]||1/0;return oS.operate(function(u,c){var f=[],v=false,h=function(y){var g=y.buffer,I=y.subs;I.unsubscribe(),uS.arrRemove(f,y),c.next(g),v&&m();},m=function(){if(f){var y=new aS.Subscription;c.add(y);var g=[],I={buffer:g,subs:y};f.push(I),Gf.executeSchedule(y,a,function(){return h(I)},e);}};o!==null&&o>=0?Gf.executeSchedule(c,a,m,o,true):v=true,m();var _=sS.createOperatorSubscriber(c,function(y){var g,I,L=f.slice();try{for(var B=iS(L),ce=B.next();!ce.done;ce=B.next()){var Ee=ce.value,le=Ee.buffer;le.push(y),s<=le.length&&h(Ee);}}catch(he){g={error:he};}finally{try{ce&&!ce.done&&(I=B.return)&&I.call(B);}finally{if(g)throw g.error}}},function(){for(;f?.length;)c.next(f.shift().buffer);_?.unsubscribe(),c.complete(),c.unsubscribe();},void 0,function(){return f=null});u.subscribe(_);})}Er.bufferTime=fS;});var zf=d(Sr=>{var dS=Sr&&Sr.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Sr,"__esModule",{value:true});Sr.bufferToggle=void 0;var pS=ue(),vS=S(),Wf=C(),ku=x(),$f=J(),hS=Ne();function mS(e,t){return vS.operate(function(r,n){var i=[];Wf.innerFrom(e).subscribe(ku.createOperatorSubscriber(n,function(a){var o=[];i.push(o);var s=new pS.Subscription,u=function(){hS.arrRemove(i,o),n.next(o),s.unsubscribe();};s.add(Wf.innerFrom(t(a)).subscribe(ku.createOperatorSubscriber(n,u,$f.noop)));},$f.noop)),r.subscribe(ku.createOperatorSubscriber(n,function(a){var o,s;try{for(var u=dS(i),c=u.next();!c.done;c=u.next()){var f=c.value;f.push(a);}}catch(v){o={error:v};}finally{try{c&&!c.done&&(s=u.return)&&s.call(u);}finally{if(o)throw o.error}}},function(){for(;i.length>0;)n.next(i.shift());n.complete();}));})}Sr.bufferToggle=mS;});var Xf=d(na=>{Object.defineProperty(na,"__esModule",{value:true});na.bufferWhen=void 0;var _S=S(),yS=J(),Jf=x(),bS=C();function gS(e){return _S.operate(function(t,r){var n=null,i=null,a=function(){i?.unsubscribe();var o=n;n=[],o&&r.next(o),bS.innerFrom(e()).subscribe(i=Jf.createOperatorSubscriber(r,a,yS.noop));};a(),t.subscribe(Jf.createOperatorSubscriber(r,function(o){return n?.push(o)},function(){n&&r.next(n),r.complete();},void 0,function(){return n=i=null}));})}na.bufferWhen=gS;});var Zf=d(ia=>{Object.defineProperty(ia,"__esModule",{value:true});ia.catchError=void 0;var ES=C(),SS=x(),OS=S();function Kf(e){return OS.operate(function(t,r){var n=null,i=false,a;n=t.subscribe(SS.createOperatorSubscriber(r,void 0,void 0,function(o){a=ES.innerFrom(e(o,Kf(e)(t))),n?(n.unsubscribe(),n=null,a.subscribe(r)):i=true;})),i&&(n.unsubscribe(),n=null,a.subscribe(r));})}ia.catchError=Kf;});var ju=d(aa=>{Object.defineProperty(aa,"__esModule",{value:true});aa.scanInternals=void 0;var wS=x();function AS(e,t,r,n,i){return function(a,o){var s=r,u=t,c=0;a.subscribe(wS.createOperatorSubscriber(o,function(f){var v=c++;u=s?e(u,f,v):(s=true,f),n&&o.next(u);},i&&function(){s&&o.next(u),o.complete();}));}}aa.scanInternals=AS;});var Or=d(oa=>{Object.defineProperty(oa,"__esModule",{value:true});oa.reduce=void 0;var TS=ju(),IS=S();function xS(e,t){return IS.operate(TS.scanInternals(e,t,arguments.length>=2,false,true))}oa.reduce=xS;});var Lu=d(sa=>{Object.defineProperty(sa,"__esModule",{value:true});sa.toArray=void 0;var RS=Or(),PS=S(),qS=function(e,t){return e.push(t),e};function CS(){return PS.operate(function(e,t){RS.reduce(qS,[])(e).subscribe(t);})}sa.toArray=CS;});var Fu=d(ua=>{Object.defineProperty(ua,"__esModule",{value:true});ua.joinAllInternals=void 0;var NS=X(),MS=Ke(),kS=Wr(),jS=Le(),LS=Lu();function FS(e,t){return kS.pipe(LS.toArray(),jS.mergeMap(function(r){return e(r)}),t?MS.mapOneOrManyArgs(t):NS.identity)}ua.joinAllInternals=FS;});var Du=d(ca=>{Object.defineProperty(ca,"__esModule",{value:true});ca.combineLatestAll=void 0;var DS=Ri(),US=Fu();function VS(e){return US.joinAllInternals(DS.combineLatest,e)}ca.combineLatestAll=VS;});var Yf=d(la=>{Object.defineProperty(la,"__esModule",{value:true});la.combineAll=void 0;var BS=Du();la.combineAll=BS.combineLatestAll;});var rd=d(et=>{var Qf=et&&et.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},ed=et&&et.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(et,"__esModule",{value:true});et.combineLatest=void 0;var GS=Ri(),HS=S(),WS=Tt(),$S=Ke(),zS=Wr(),JS=ae();function td(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=JS.popResultSelector(e);return r?zS.pipe(td.apply(void 0,ed([],Qf(e))),$S.mapOneOrManyArgs(r)):HS.operate(function(n,i){GS.combineLatestInit(ed([n],Qf(WS.argsOrArgArray(e))))(i);})}et.combineLatest=td;});var nd=d(tt=>{var XS=tt&&tt.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},KS=tt&&tt.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(tt,"__esModule",{value:true});tt.combineLatestWith=void 0;var ZS=rd();function YS(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return ZS.combineLatest.apply(void 0,KS([],XS(e)))}tt.combineLatestWith=YS;});var Uu=d(fa=>{Object.defineProperty(fa,"__esModule",{value:true});fa.concatMap=void 0;var id=Le(),QS=U();function eO(e,t){return QS.isFunction(t)?id.mergeMap(e,t,1):id.mergeMap(e,1)}fa.concatMap=eO;});var od=d(da=>{Object.defineProperty(da,"__esModule",{value:true});da.concatMapTo=void 0;var ad=Uu(),tO=U();function rO(e,t){return tO.isFunction(t)?ad.concatMap(function(){return e},t):ad.concatMap(function(){return e})}da.concatMapTo=rO;});var sd=d(rt=>{var nO=rt&&rt.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},iO=rt&&rt.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(rt,"__esModule",{value:true});rt.concat=void 0;var aO=S(),oO=ki(),sO=ae(),uO=ke();function cO(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=sO.popScheduler(e);return aO.operate(function(n,i){oO.concatAll()(uO.from(iO([n],nO(e)),r)).subscribe(i);})}rt.concat=cO;});var ud=d(nt=>{var lO=nt&&nt.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},fO=nt&&nt.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(nt,"__esModule",{value:true});nt.concatWith=void 0;var dO=sd();function pO(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return dO.concat.apply(void 0,fO([],lO(e)))}nt.concatWith=pO;});var cd=d(pa=>{Object.defineProperty(pa,"__esModule",{value:true});pa.fromSubscribable=void 0;var vO=V();function hO(e){return new vO.Observable(function(t){return e.subscribe(t)})}pa.fromSubscribable=hO;});var ha=d(va=>{Object.defineProperty(va,"__esModule",{value:true});va.connect=void 0;var mO=K(),_O=C(),yO=S(),bO=cd(),gO={connector:function(){return new mO.Subject}};function EO(e,t){t===void 0&&(t=gO);var r=t.connector;return yO.operate(function(n,i){var a=r();_O.innerFrom(e(bO.fromSubscribable(a))).subscribe(i),i.add(n.subscribe(a));})}va.connect=EO;});var ld=d(ma=>{Object.defineProperty(ma,"__esModule",{value:true});ma.count=void 0;var SO=Or();function OO(e){return SO.reduce(function(t,r,n){return !e||e(r,n)?t+1:t},0)}ma.count=OO;});var dd=d(_a=>{Object.defineProperty(_a,"__esModule",{value:true});_a.debounce=void 0;var wO=S(),AO=J(),fd=x(),TO=C();function IO(e){return wO.operate(function(t,r){var n=false,i=null,a=null,o=function(){if(a?.unsubscribe(),a=null,n){n=false;var s=i;i=null,r.next(s);}};t.subscribe(fd.createOperatorSubscriber(r,function(s){a?.unsubscribe(),n=true,i=s,a=fd.createOperatorSubscriber(r,o,AO.noop),TO.innerFrom(e(s)).subscribe(a);},function(){o(),r.complete();},void 0,function(){i=a=null;}));})}_a.debounce=IO;});var pd=d(ya=>{Object.defineProperty(ya,"__esModule",{value:true});ya.debounceTime=void 0;var xO=ie(),RO=S(),PO=x();function qO(e,t){return t===void 0&&(t=xO.asyncScheduler),RO.operate(function(r,n){var i=null,a=null,o=null,s=function(){if(i){i.unsubscribe(),i=null;var c=a;a=null,n.next(c);}};function u(){var c=o+e,f=t.now();if(f<c){i=this.schedule(void 0,c-f),n.add(i);return}s();}r.subscribe(PO.createOperatorSubscriber(n,function(c){a=c,o=t.now(),i||(i=t.schedule(u,e),n.add(i));},function(){s(),n.complete();},void 0,function(){a=i=null;}));})}ya.debounceTime=qO;});var tn=d(ba=>{Object.defineProperty(ba,"__esModule",{value:true});ba.defaultIfEmpty=void 0;var CO=S(),NO=x();function MO(e){return CO.operate(function(t,r){var n=false;t.subscribe(NO.createOperatorSubscriber(r,function(i){n=true,r.next(i);},function(){n||r.next(e),r.complete();}));})}ba.defaultIfEmpty=MO;});var rn=d(ga=>{Object.defineProperty(ga,"__esModule",{value:true});ga.take=void 0;var kO=ye(),jO=S(),LO=x();function FO(e){return e<=0?function(){return kO.EMPTY}:jO.operate(function(t,r){var n=0;t.subscribe(LO.createOperatorSubscriber(r,function(i){++n<=e&&(r.next(i),e<=n&&r.complete());}));})}ga.take=FO;});var Vu=d(Ea=>{Object.defineProperty(Ea,"__esModule",{value:true});Ea.ignoreElements=void 0;var DO=S(),UO=x(),VO=J();function BO(){return DO.operate(function(e,t){e.subscribe(UO.createOperatorSubscriber(t,VO.noop));})}Ea.ignoreElements=BO;});var Bu=d(Sa=>{Object.defineProperty(Sa,"__esModule",{value:true});Sa.mapTo=void 0;var GO=Je();function HO(e){return GO.map(function(){return e})}Sa.mapTo=HO;});var Gu=d(Oa=>{Object.defineProperty(Oa,"__esModule",{value:true});Oa.delayWhen=void 0;var WO=Qr(),vd=rn(),$O=Vu(),zO=Bu(),JO=Le(),XO=C();function hd(e,t){return t?function(r){return WO.concat(t.pipe(vd.take(1),$O.ignoreElements()),r.pipe(hd(e)))}:JO.mergeMap(function(r,n){return XO.innerFrom(e(r,n)).pipe(vd.take(1),zO.mapTo(r))})}Oa.delayWhen=hd;});var md=d(wa=>{Object.defineProperty(wa,"__esModule",{value:true});wa.delay=void 0;var KO=ie(),ZO=Gu(),YO=Ye();function QO(e,t){t===void 0&&(t=KO.asyncScheduler);var r=YO.timer(e,t);return ZO.delayWhen(function(){return r})}wa.delay=QO;});var _d=d(Aa=>{Object.defineProperty(Aa,"__esModule",{value:true});Aa.dematerialize=void 0;var ew=pi(),tw=S(),rw=x();function nw(){return tw.operate(function(e,t){e.subscribe(rw.createOperatorSubscriber(t,function(r){return ew.observeNotification(r,t)}));})}Aa.dematerialize=nw;});var bd=d(Ta=>{Object.defineProperty(Ta,"__esModule",{value:true});Ta.distinct=void 0;var iw=S(),yd=x(),aw=J(),ow=C();function sw(e,t){return iw.operate(function(r,n){var i=new Set;r.subscribe(yd.createOperatorSubscriber(n,function(a){var o=e?e(a):a;i.has(o)||(i.add(o),n.next(a));})),t&&ow.innerFrom(t).subscribe(yd.createOperatorSubscriber(n,function(){return i.clear()},aw.noop));})}Ta.distinct=sw;});var Hu=d(Ia=>{Object.defineProperty(Ia,"__esModule",{value:true});Ia.distinctUntilChanged=void 0;var uw=X(),cw=S(),lw=x();function fw(e,t){return t===void 0&&(t=uw.identity),e=e??dw,cw.operate(function(r,n){var i,a=true;r.subscribe(lw.createOperatorSubscriber(n,function(o){var s=t(o);(a||!e(i,s))&&(a=false,i=s,n.next(o));}));})}Ia.distinctUntilChanged=fw;function dw(e,t){return e===t}});var gd=d(xa=>{Object.defineProperty(xa,"__esModule",{value:true});xa.distinctUntilKeyChanged=void 0;var pw=Hu();function vw(e,t){return pw.distinctUntilChanged(function(r,n){return t?t(r[e],n[e]):r[e]===n[e]})}xa.distinctUntilKeyChanged=vw;});var nn=d(Ra=>{Object.defineProperty(Ra,"__esModule",{value:true});Ra.throwIfEmpty=void 0;var hw=ze(),mw=S(),_w=x();function yw(e){return e===void 0&&(e=bw),mw.operate(function(t,r){var n=false;t.subscribe(_w.createOperatorSubscriber(r,function(i){n=true,r.next(i);},function(){return n?r.complete():r.error(e())}));})}Ra.throwIfEmpty=yw;function bw(){return new hw.EmptyError}});var Sd=d(Pa=>{Object.defineProperty(Pa,"__esModule",{value:true});Pa.elementAt=void 0;var Ed=Eu(),gw=It(),Ew=nn(),Sw=tn(),Ow=rn();function ww(e,t){if(e<0)throw new Ed.ArgumentOutOfRangeError;var r=arguments.length>=2;return function(n){return n.pipe(gw.filter(function(i,a){return a===e}),Ow.take(1),r?Sw.defaultIfEmpty(t):Ew.throwIfEmpty(function(){return new Ed.ArgumentOutOfRangeError}))}}Pa.elementAt=ww;});var Od=d(it=>{var Aw=it&&it.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},Tw=it&&it.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(it,"__esModule",{value:true});it.endWith=void 0;var Iw=Qr(),xw=fi();function Rw(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return function(r){return Iw.concat(r,xw.of.apply(void 0,Tw([],Aw(e))))}}it.endWith=Rw;});var wd=d(qa=>{Object.defineProperty(qa,"__esModule",{value:true});qa.every=void 0;var Pw=S(),qw=x();function Cw(e,t){return Pw.operate(function(r,n){var i=0;r.subscribe(qw.createOperatorSubscriber(n,function(a){e.call(t,a,i++,r)||(n.next(false),n.complete());},function(){n.next(true),n.complete();}));})}qa.every=Cw;});var Wu=d(Ca=>{Object.defineProperty(Ca,"__esModule",{value:true});Ca.exhaustMap=void 0;var Nw=Je(),Ad=C(),Mw=S(),Td=x();function Id(e,t){return t?function(r){return r.pipe(Id(function(n,i){return Ad.innerFrom(e(n,i)).pipe(Nw.map(function(a,o){return t(n,a,i,o)}))}))}:Mw.operate(function(r,n){var i=0,a=null,o=false;r.subscribe(Td.createOperatorSubscriber(n,function(s){a||(a=Td.createOperatorSubscriber(n,void 0,function(){a=null,o&&n.complete();}),Ad.innerFrom(e(s,i++)).subscribe(a));},function(){o=true,!a&&n.complete();}));})}Ca.exhaustMap=Id;});var $u=d(Na=>{Object.defineProperty(Na,"__esModule",{value:true});Na.exhaustAll=void 0;var kw=Wu(),jw=X();function Lw(){return kw.exhaustMap(jw.identity)}Na.exhaustAll=Lw;});var xd=d(Ma=>{Object.defineProperty(Ma,"__esModule",{value:true});Ma.exhaust=void 0;var Fw=$u();Ma.exhaust=Fw.exhaustAll;});var Rd=d(ka=>{Object.defineProperty(ka,"__esModule",{value:true});ka.expand=void 0;var Dw=S(),Uw=qi();function Vw(e,t,r){return t===void 0&&(t=1/0),t=(t||0)<1?1/0:t,Dw.operate(function(n,i){return Uw.mergeInternals(n,i,e,t,void 0,true,r)})}ka.expand=Vw;});var Pd=d(ja=>{Object.defineProperty(ja,"__esModule",{value:true});ja.finalize=void 0;var Bw=S();function Gw(e){return Bw.operate(function(t,r){try{t.subscribe(r);}finally{r.add(e);}})}ja.finalize=Gw;});var zu=d(wr=>{Object.defineProperty(wr,"__esModule",{value:true});wr.createFind=wr.find=void 0;var Hw=S(),Ww=x();function $w(e,t){return Hw.operate(qd(e,t,"value"))}wr.find=$w;function qd(e,t,r){var n=r==="index";return function(i,a){var o=0;i.subscribe(Ww.createOperatorSubscriber(a,function(s){var u=o++;e.call(t,s,u,i)&&(a.next(n?u:s),a.complete());},function(){a.next(n?-1:void 0),a.complete();}));}}wr.createFind=qd;});var Cd=d(La=>{Object.defineProperty(La,"__esModule",{value:true});La.findIndex=void 0;var zw=S(),Jw=zu();function Xw(e,t){return zw.operate(Jw.createFind(e,t,"index"))}La.findIndex=Xw;});var Nd=d(Fa=>{Object.defineProperty(Fa,"__esModule",{value:true});Fa.first=void 0;var Kw=ze(),Zw=It(),Yw=rn(),Qw=tn(),eA=nn(),tA=X();function rA(e,t){var r=arguments.length>=2;return function(n){return n.pipe(e?Zw.filter(function(i,a){return e(i,a,n)}):tA.identity,Yw.take(1),r?Qw.defaultIfEmpty(t):eA.throwIfEmpty(function(){return new Kw.EmptyError}))}}Fa.first=rA;});var kd=d(Da=>{Object.defineProperty(Da,"__esModule",{value:true});Da.groupBy=void 0;var nA=V(),iA=C(),aA=K(),oA=S(),Md=x();function sA(e,t,r,n){return oA.operate(function(i,a){var o;!t||typeof t=="function"?o=t:(r=t.duration,o=t.element,n=t.connector);var s=new Map,u=function(_){s.forEach(_),_(a);},c=function(_){return u(function(y){return y.error(_)})},f=0,v=false,h=new Md.OperatorSubscriber(a,function(_){try{var y=e(_),g=s.get(y);if(!g){s.set(y,g=n?n():new aA.Subject);var I=m(y,g);if(a.next(I),r){var L=Md.createOperatorSubscriber(g,function(){g.complete(),L?.unsubscribe();},void 0,void 0,function(){return s.delete(y)});h.add(iA.innerFrom(r(I)).subscribe(L));}}g.next(o?o(_):_);}catch(B){c(B);}},function(){return u(function(_){return _.complete()})},c,function(){return s.clear()},function(){return v=true,f===0});i.subscribe(h);function m(_,y){var g=new nA.Observable(function(I){f++;var L=y.subscribe(I);return function(){L.unsubscribe(),--f===0&&v&&h.unsubscribe();}});return g.key=_,g}})}Da.groupBy=sA;});var jd=d(Ua=>{Object.defineProperty(Ua,"__esModule",{value:true});Ua.isEmpty=void 0;var uA=S(),cA=x();function lA(){return uA.operate(function(e,t){e.subscribe(cA.createOperatorSubscriber(t,function(){t.next(false),t.complete();},function(){t.next(true),t.complete();}));})}Ua.isEmpty=lA;});var Ju=d(Ar=>{var fA=Ar&&Ar.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ar,"__esModule",{value:true});Ar.takeLast=void 0;var dA=ye(),pA=S(),vA=x();function hA(e){return e<=0?function(){return dA.EMPTY}:pA.operate(function(t,r){var n=[];t.subscribe(vA.createOperatorSubscriber(r,function(i){n.push(i),e<n.length&&n.shift();},function(){var i,a;try{for(var o=fA(n),s=o.next();!s.done;s=o.next()){var u=s.value;r.next(u);}}catch(c){i={error:c};}finally{try{s&&!s.done&&(a=o.return)&&a.call(o);}finally{if(i)throw i.error}}r.complete();},void 0,function(){n=null;}));})}Ar.takeLast=hA;});var Ld=d(Va=>{Object.defineProperty(Va,"__esModule",{value:true});Va.last=void 0;var mA=ze(),_A=It(),yA=Ju(),bA=nn(),gA=tn(),EA=X();function SA(e,t){var r=arguments.length>=2;return function(n){return n.pipe(e?_A.filter(function(i,a){return e(i,a,n)}):EA.identity,yA.takeLast(1),r?gA.defaultIfEmpty(t):bA.throwIfEmpty(function(){return new mA.EmptyError}))}}Va.last=SA;});var Fd=d(Ba=>{Object.defineProperty(Ba,"__esModule",{value:true});Ba.materialize=void 0;var Xu=pi(),OA=S(),wA=x();function AA(){return OA.operate(function(e,t){e.subscribe(wA.createOperatorSubscriber(t,function(r){t.next(Xu.Notification.createNext(r));},function(){t.next(Xu.Notification.createComplete()),t.complete();},function(r){t.next(Xu.Notification.createError(r)),t.complete();}));})}Ba.materialize=AA;});var Dd=d(Ga=>{Object.defineProperty(Ga,"__esModule",{value:true});Ga.max=void 0;var TA=Or(),IA=U();function xA(e){return TA.reduce(IA.isFunction(e)?function(t,r){return e(t,r)>0?t:r}:function(t,r){return t>r?t:r})}Ga.max=xA;});var Ud=d(Ha=>{Object.defineProperty(Ha,"__esModule",{value:true});Ha.flatMap=void 0;var RA=Le();Ha.flatMap=RA.mergeMap;});var Bd=d(Wa=>{Object.defineProperty(Wa,"__esModule",{value:true});Wa.mergeMapTo=void 0;var Vd=Le(),PA=U();function qA(e,t,r){return r===void 0&&(r=1/0),PA.isFunction(t)?Vd.mergeMap(function(){return e},t,r):(typeof t=="number"&&(r=t),Vd.mergeMap(function(){return e},r))}Wa.mergeMapTo=qA;});var Gd=d($a=>{Object.defineProperty($a,"__esModule",{value:true});$a.mergeScan=void 0;var CA=S(),NA=qi();function MA(e,t,r){return r===void 0&&(r=1/0),CA.operate(function(n,i){var a=t;return NA.mergeInternals(n,i,function(o,s){return e(a,o,s)},r,function(o){a=o;},false,void 0,function(){return a=null})})}$a.mergeScan=MA;});var Wd=d(at=>{var kA=at&&at.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},jA=at&&at.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(at,"__esModule",{value:true});at.merge=void 0;var LA=S(),FA=Tt(),DA=Yr(),Hd=ae(),UA=ke();function VA(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Hd.popScheduler(e),n=Hd.popNumber(e,1/0);return e=FA.argsOrArgArray(e),LA.operate(function(i,a){DA.mergeAll(n)(UA.from(jA([i],kA(e)),r)).subscribe(a);})}at.merge=VA;});var $d=d(ot=>{var BA=ot&&ot.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},GA=ot&&ot.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(ot,"__esModule",{value:true});ot.mergeWith=void 0;var HA=Wd();function WA(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return HA.merge.apply(void 0,GA([],BA(e)))}ot.mergeWith=WA;});var zd=d(za=>{Object.defineProperty(za,"__esModule",{value:true});za.min=void 0;var $A=Or(),zA=U();function JA(e){return $A.reduce(zA.isFunction(e)?function(t,r){return e(t,r)<0?t:r}:function(t,r){return t<r?t:r})}za.min=JA;});var Xa=d(Ja=>{Object.defineProperty(Ja,"__esModule",{value:true});Ja.multicast=void 0;var XA=$r(),Jd=U(),KA=ha();function ZA(e,t){var r=Jd.isFunction(e)?e:function(){return e};return Jd.isFunction(t)?KA.connect(t,{connector:r}):function(n){return new XA.ConnectableObservable(n,r)}}Ja.multicast=ZA;});var Kd=d(Ie=>{var YA=Ie&&Ie.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},QA=Ie&&Ie.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(Ie,"__esModule",{value:true});Ie.onErrorResumeNext=Ie.onErrorResumeNextWith=void 0;var eT=Tt(),tT=qu();function Xd(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=eT.argsOrArgArray(e);return function(n){return tT.onErrorResumeNext.apply(void 0,QA([n],YA(r)))}}Ie.onErrorResumeNextWith=Xd;Ie.onErrorResumeNext=Xd;});var Zd=d(Ka=>{Object.defineProperty(Ka,"__esModule",{value:true});Ka.pairwise=void 0;var rT=S(),nT=x();function iT(){return rT.operate(function(e,t){var r,n=false;e.subscribe(nT.createOperatorSubscriber(t,function(i){var a=r;r=i,n&&t.next([a,i]),n=true;}));})}Ka.pairwise=iT;});var Yd=d(Za=>{Object.defineProperty(Za,"__esModule",{value:true});Za.pluck=void 0;var aT=Je();function oT(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=e.length;if(r===0)throw new Error("list of properties cannot be empty.");return aT.map(function(n){for(var i=n,a=0;a<r;a++){var o=i?.[e[a]];if(typeof o<"u")i=o;else return}return i})}Za.pluck=oT;});var Qd=d(Ya=>{Object.defineProperty(Ya,"__esModule",{value:true});Ya.publish=void 0;var sT=K(),uT=Xa(),cT=ha();function lT(e){return e?function(t){return cT.connect(e)(t)}:function(t){return uT.multicast(new sT.Subject)(t)}}Ya.publish=lT;});var ep=d(Qa=>{Object.defineProperty(Qa,"__esModule",{value:true});Qa.publishBehavior=void 0;var fT=iu(),dT=$r();function pT(e){return function(t){var r=new fT.BehaviorSubject(e);return new dT.ConnectableObservable(t,function(){return r})}}Qa.publishBehavior=pT;});var tp=d(eo=>{Object.defineProperty(eo,"__esModule",{value:true});eo.publishLast=void 0;var vT=Vn(),hT=$r();function mT(){return function(e){var t=new vT.AsyncSubject;return new hT.ConnectableObservable(e,function(){return t})}}eo.publishLast=mT;});var np=d(to=>{Object.defineProperty(to,"__esModule",{value:true});to.publishReplay=void 0;var _T=Un(),yT=Xa(),rp=U();function bT(e,t,r,n){r&&!rp.isFunction(r)&&(n=r);var i=rp.isFunction(r)?r:void 0;return function(a){return yT.multicast(new _T.ReplaySubject(e,t,n),i)(a)}}to.publishReplay=bT;});var ip=d(st=>{var gT=st&&st.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},ET=st&&st.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(st,"__esModule",{value:true});st.raceWith=void 0;var ST=Cu(),OT=S(),wT=X();function AT(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return e.length?OT.operate(function(r,n){ST.raceInit(ET([r],gT(e)))(n);}):wT.identity}st.raceWith=AT;});var op=d(ro=>{Object.defineProperty(ro,"__esModule",{value:true});ro.repeat=void 0;var TT=ye(),IT=S(),ap=x(),xT=C(),RT=Ye();function PT(e){var t,r=1/0,n;return e!=null&&(typeof e=="object"?(t=e.count,r=t===void 0?1/0:t,n=e.delay):r=e),r<=0?function(){return TT.EMPTY}:IT.operate(function(i,a){var o=0,s,u=function(){if(s?.unsubscribe(),s=null,n!=null){var f=typeof n=="number"?RT.timer(n):xT.innerFrom(n(o)),v=ap.createOperatorSubscriber(a,function(){v.unsubscribe(),c();});f.subscribe(v);}else c();},c=function(){var f=false;s=i.subscribe(ap.createOperatorSubscriber(a,void 0,function(){++o<r?s?u():f=true:a.complete();})),f&&u();};c();})}ro.repeat=PT;});var up=d(no=>{Object.defineProperty(no,"__esModule",{value:true});no.repeatWhen=void 0;var qT=C(),CT=K(),NT=S(),sp=x();function MT(e){return NT.operate(function(t,r){var n,i=false,a,o=false,s=false,u=function(){return s&&o&&(r.complete(),true)},c=function(){return a||(a=new CT.Subject,qT.innerFrom(e(a)).subscribe(sp.createOperatorSubscriber(r,function(){n?f():i=true;},function(){o=true,u();}))),a},f=function(){s=false,n=t.subscribe(sp.createOperatorSubscriber(r,void 0,function(){s=true,!u()&&c().next();})),i&&(n.unsubscribe(),n=null,i=false,f());};f();})}no.repeatWhen=MT;});var lp=d(io=>{Object.defineProperty(io,"__esModule",{value:true});io.retry=void 0;var kT=S(),cp=x(),jT=X(),LT=Ye(),FT=C();function DT(e){e===void 0&&(e=1/0);var t;e&&typeof e=="object"?t=e:t={count:e};var r=t.count,n=r===void 0?1/0:r,i=t.delay,a=t.resetOnSuccess,o=a===void 0?false:a;return n<=0?jT.identity:kT.operate(function(s,u){var c=0,f,v=function(){var h=false;f=s.subscribe(cp.createOperatorSubscriber(u,function(m){o&&(c=0),u.next(m);},void 0,function(m){if(c++<n){var _=function(){f?(f.unsubscribe(),f=null,v()):h=true;};if(i!=null){var y=typeof i=="number"?LT.timer(i):FT.innerFrom(i(m,c)),g=cp.createOperatorSubscriber(u,function(){g.unsubscribe(),_();},function(){u.complete();});y.subscribe(g);}else _();}else u.error(m);})),h&&(f.unsubscribe(),f=null,v());};v();})}io.retry=DT;});var dp=d(ao=>{Object.defineProperty(ao,"__esModule",{value:true});ao.retryWhen=void 0;var UT=C(),VT=K(),BT=S(),fp=x();function GT(e){return BT.operate(function(t,r){var n,i=false,a,o=function(){n=t.subscribe(fp.createOperatorSubscriber(r,void 0,void 0,function(s){a||(a=new VT.Subject,UT.innerFrom(e(a)).subscribe(fp.createOperatorSubscriber(r,function(){return n?o():i=true}))),a&&a.next(s);})),i&&(n.unsubscribe(),n=null,i=false,o());};o();})}ao.retryWhen=GT;});var Ku=d(oo=>{Object.defineProperty(oo,"__esModule",{value:true});oo.sample=void 0;var HT=C(),WT=S(),$T=J(),pp=x();function zT(e){return WT.operate(function(t,r){var n=false,i=null;t.subscribe(pp.createOperatorSubscriber(r,function(a){n=true,i=a;})),HT.innerFrom(e).subscribe(pp.createOperatorSubscriber(r,function(){if(n){n=false;var a=i;i=null,r.next(a);}},$T.noop));})}oo.sample=zT;});var vp=d(so=>{Object.defineProperty(so,"__esModule",{value:true});so.sampleTime=void 0;var JT=ie(),XT=Ku(),KT=Ru();function ZT(e,t){return t===void 0&&(t=JT.asyncScheduler),XT.sample(KT.interval(e,t))}so.sampleTime=ZT;});var hp=d(uo=>{Object.defineProperty(uo,"__esModule",{value:true});uo.scan=void 0;var YT=S(),QT=ju();function e1(e,t){return YT.operate(QT.scanInternals(e,t,arguments.length>=2,true))}uo.scan=e1;});var _p=d(co=>{Object.defineProperty(co,"__esModule",{value:true});co.sequenceEqual=void 0;var t1=S(),r1=x(),n1=C();function i1(e,t){return t===void 0&&(t=function(r,n){return r===n}),t1.operate(function(r,n){var i=mp(),a=mp(),o=function(u){n.next(u),n.complete();},s=function(u,c){var f=r1.createOperatorSubscriber(n,function(v){var h=c.buffer,m=c.complete;h.length===0?m?o(false):u.buffer.push(v):!t(v,h.shift())&&o(false);},function(){u.complete=true;var v=c.complete,h=c.buffer;v&&o(h.length===0),f?.unsubscribe();});return f};r.subscribe(s(i,a)),n1.innerFrom(e).subscribe(s(a,i));})}co.sequenceEqual=i1;function mp(){return {buffer:[],complete:false}}});var Yu=d(ut=>{var a1=ut&&ut.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},o1=ut&&ut.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(ut,"__esModule",{value:true});ut.share=void 0;var yp=C(),s1=K(),bp=Jt(),u1=S();function c1(e){e===void 0&&(e={});var t=e.connector,r=t===void 0?function(){return new s1.Subject}:t,n=e.resetOnError,i=n===void 0?true:n,a=e.resetOnComplete,o=a===void 0?true:a,s=e.resetOnRefCountZero,u=s===void 0?true:s;return function(c){var f,v,h,m=0,_=false,y=false,g=function(){v?.unsubscribe(),v=void 0;},I=function(){g(),f=h=void 0,_=y=false;},L=function(){var B=f;I(),B?.unsubscribe();};return u1.operate(function(B,ce){m++,!y&&!_&&g();var Ee=h=h??r();ce.add(function(){m--,m===0&&!y&&!_&&(v=Zu(L,u));}),Ee.subscribe(ce),!f&&m>0&&(f=new bp.SafeSubscriber({next:function(le){return Ee.next(le)},error:function(le){y=true,g(),v=Zu(I,i,le),Ee.error(le);},complete:function(){_=true,g(),v=Zu(I,o),Ee.complete();}}),yp.innerFrom(B).subscribe(f));})(c)}}ut.share=c1;function Zu(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];if(t===true){e();return}if(t!==false){var i=new bp.SafeSubscriber({next:function(){i.unsubscribe(),e();}});return yp.innerFrom(t.apply(void 0,o1([],a1(r)))).subscribe(i)}}});var gp=d(lo=>{Object.defineProperty(lo,"__esModule",{value:true});lo.shareReplay=void 0;var l1=Un(),f1=Yu();function d1(e,t,r){var n,i,a,o,s=false;return e&&typeof e=="object"?(n=e.bufferSize,o=n===void 0?1/0:n,i=e.windowTime,t=i===void 0?1/0:i,a=e.refCount,s=a===void 0?false:a,r=e.scheduler):o=e??1/0,f1.share({connector:function(){return new l1.ReplaySubject(o,t,r)},resetOnError:true,resetOnComplete:false,resetOnRefCountZero:s})}lo.shareReplay=d1;});var Ep=d(fo=>{Object.defineProperty(fo,"__esModule",{value:true});fo.single=void 0;var p1=ze(),v1=Ou(),h1=Su(),m1=S(),_1=x();function y1(e){return m1.operate(function(t,r){var n=false,i,a=false,o=0;t.subscribe(_1.createOperatorSubscriber(r,function(s){a=true,(!e||e(s,o++,t))&&(n&&r.error(new v1.SequenceError("Too many matching values")),n=true,i=s);},function(){n?(r.next(i),r.complete()):r.error(a?new h1.NotFoundError("No matching values"):new p1.EmptyError);}));})}fo.single=y1;});var Sp=d(po=>{Object.defineProperty(po,"__esModule",{value:true});po.skip=void 0;var b1=It();function g1(e){return b1.filter(function(t,r){return e<=r})}po.skip=g1;});var Op=d(vo=>{Object.defineProperty(vo,"__esModule",{value:true});vo.skipLast=void 0;var E1=X(),S1=S(),O1=x();function w1(e){return e<=0?E1.identity:S1.operate(function(t,r){var n=new Array(e),i=0;return t.subscribe(O1.createOperatorSubscriber(r,function(a){var o=i++;if(o<e)n[o]=a;else {var s=o%e,u=n[s];n[s]=a,r.next(u);}})),function(){n=null;}})}vo.skipLast=w1;});var Ap=d(ho=>{Object.defineProperty(ho,"__esModule",{value:true});ho.skipUntil=void 0;var A1=S(),wp=x(),T1=C(),I1=J();function x1(e){return A1.operate(function(t,r){var n=false,i=wp.createOperatorSubscriber(r,function(){i?.unsubscribe(),n=true;},I1.noop);T1.innerFrom(e).subscribe(i),t.subscribe(wp.createOperatorSubscriber(r,function(a){return n&&r.next(a)}));})}ho.skipUntil=x1;});var Tp=d(mo=>{Object.defineProperty(mo,"__esModule",{value:true});mo.skipWhile=void 0;var R1=S(),P1=x();function q1(e){return R1.operate(function(t,r){var n=false,i=0;t.subscribe(P1.createOperatorSubscriber(r,function(a){return (n||(n=!e(a,i++)))&&r.next(a)}));})}mo.skipWhile=q1;});var xp=d(_o=>{Object.defineProperty(_o,"__esModule",{value:true});_o.startWith=void 0;var Ip=Qr(),C1=ae(),N1=S();function M1(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=C1.popScheduler(e);return N1.operate(function(n,i){(r?Ip.concat(e,n,r):Ip.concat(e,n)).subscribe(i);})}_o.startWith=M1;});var an=d(yo=>{Object.defineProperty(yo,"__esModule",{value:true});yo.switchMap=void 0;var k1=C(),j1=S(),Rp=x();function L1(e,t){return j1.operate(function(r,n){var i=null,a=0,o=false,s=function(){return o&&!i&&n.complete()};r.subscribe(Rp.createOperatorSubscriber(n,function(u){i?.unsubscribe();var c=0,f=a++;k1.innerFrom(e(u,f)).subscribe(i=Rp.createOperatorSubscriber(n,function(v){return n.next(t?t(u,v,f,c++):v)},function(){i=null,s();}));},function(){o=true,s();}));})}yo.switchMap=L1;});var Pp=d(bo=>{Object.defineProperty(bo,"__esModule",{value:true});bo.switchAll=void 0;var F1=an(),D1=X();function U1(){return F1.switchMap(D1.identity)}bo.switchAll=U1;});var Cp=d(go=>{Object.defineProperty(go,"__esModule",{value:true});go.switchMapTo=void 0;var qp=an(),V1=U();function B1(e,t){return V1.isFunction(t)?qp.switchMap(function(){return e},t):qp.switchMap(function(){return e})}go.switchMapTo=B1;});var Np=d(Eo=>{Object.defineProperty(Eo,"__esModule",{value:true});Eo.switchScan=void 0;var G1=an(),H1=S();function W1(e,t){return H1.operate(function(r,n){var i=t;return G1.switchMap(function(a,o){return e(i,a,o)},function(a,o){return i=o,o})(r).subscribe(n),function(){i=null;}})}Eo.switchScan=W1;});var Mp=d(So=>{Object.defineProperty(So,"__esModule",{value:true});So.takeUntil=void 0;var $1=S(),z1=x(),J1=C(),X1=J();function K1(e){return $1.operate(function(t,r){J1.innerFrom(e).subscribe(z1.createOperatorSubscriber(r,function(){return r.complete()},X1.noop)),!r.closed&&t.subscribe(r);})}So.takeUntil=K1;});var kp=d(Oo=>{Object.defineProperty(Oo,"__esModule",{value:true});Oo.takeWhile=void 0;var Z1=S(),Y1=x();function Q1(e,t){return t===void 0&&(t=false),Z1.operate(function(r,n){var i=0;r.subscribe(Y1.createOperatorSubscriber(n,function(a){var o=e(a,i++);(o||t)&&n.next(a),!o&&n.complete();}));})}Oo.takeWhile=Q1;});var jp=d(wo=>{Object.defineProperty(wo,"__esModule",{value:true});wo.tap=void 0;var eI=U(),tI=S(),rI=x(),nI=X();function iI(e,t,r){var n=eI.isFunction(e)||t||r?{next:e,error:t,complete:r}:e;return n?tI.operate(function(i,a){var o;(o=n.subscribe)===null||o===void 0||o.call(n);var s=true;i.subscribe(rI.createOperatorSubscriber(a,function(u){var c;(c=n.next)===null||c===void 0||c.call(n,u),a.next(u);},function(){var u;s=false,(u=n.complete)===null||u===void 0||u.call(n),a.complete();},function(u){var c;s=false,(c=n.error)===null||c===void 0||c.call(n,u),a.error(u);},function(){var u,c;s&&((u=n.unsubscribe)===null||u===void 0||u.call(n)),(c=n.finalize)===null||c===void 0||c.call(n);}));}):nI.identity}wo.tap=iI;});var Qu=d(Ao=>{Object.defineProperty(Ao,"__esModule",{value:true});Ao.throttle=void 0;var aI=S(),Lp=x(),oI=C();function sI(e,t){return aI.operate(function(r,n){var i=t??{},a=i.leading,o=a===void 0?true:a,s=i.trailing,u=s===void 0?false:s,c=false,f=null,v=null,h=false,m=function(){v?.unsubscribe(),v=null,u&&(g(),h&&n.complete());},_=function(){v=null,h&&n.complete();},y=function(I){return v=oI.innerFrom(e(I)).subscribe(Lp.createOperatorSubscriber(n,m,_))},g=function(){if(c){c=false;var I=f;f=null,n.next(I),!h&&y(I);}};r.subscribe(Lp.createOperatorSubscriber(n,function(I){c=true,f=I,!(v&&!v.closed)&&(o?g():y(I));},function(){h=true,!(u&&c&&v&&!v.closed)&&n.complete();}));})}Ao.throttle=sI;});var Fp=d(To=>{Object.defineProperty(To,"__esModule",{value:true});To.throttleTime=void 0;var uI=ie(),cI=Qu(),lI=Ye();function fI(e,t,r){t===void 0&&(t=uI.asyncScheduler);var n=lI.timer(e,t);return cI.throttle(function(){return n},r)}To.throttleTime=fI;});var Up=d(Tr=>{Object.defineProperty(Tr,"__esModule",{value:true});Tr.TimeInterval=Tr.timeInterval=void 0;var dI=ie(),pI=S(),vI=x();function hI(e){return e===void 0&&(e=dI.asyncScheduler),pI.operate(function(t,r){var n=e.now();t.subscribe(vI.createOperatorSubscriber(r,function(i){var a=e.now(),o=a-n;n=a,r.next(new Dp(i,o));}));})}Tr.timeInterval=hI;var Dp=function(){function e(t,r){this.value=t,this.interval=r;}return e}();Tr.TimeInterval=Dp;});var Vp=d(Io=>{Object.defineProperty(Io,"__esModule",{value:true});Io.timeoutWith=void 0;var mI=ie(),_I=Si(),yI=Oi();function bI(e,t,r){var n,i,a;if(r=r??mI.async,_I.isValidDate(e)?n=e:typeof e=="number"&&(i=e),t)a=function(){return t};else throw new TypeError("No observable provided to switch to");if(n==null&&i==null)throw new TypeError("No timeout provided.");return yI.timeout({first:n,each:i,scheduler:r,with:a})}Io.timeoutWith=bI;});var Bp=d(xo=>{Object.defineProperty(xo,"__esModule",{value:true});xo.timestamp=void 0;var gI=Dn(),EI=Je();function SI(e){return e===void 0&&(e=gI.dateTimestampProvider),EI.map(function(t){return {value:t,timestamp:e.now()}})}xo.timestamp=SI;});var Wp=d(Ro=>{Object.defineProperty(Ro,"__esModule",{value:true});Ro.window=void 0;var Gp=K(),OI=S(),Hp=x(),wI=J(),AI=C();function TI(e){return OI.operate(function(t,r){var n=new Gp.Subject;r.next(n.asObservable());var i=function(a){n.error(a),r.error(a);};return t.subscribe(Hp.createOperatorSubscriber(r,function(a){return n?.next(a)},function(){n.complete(),r.complete();},i)),AI.innerFrom(e).subscribe(Hp.createOperatorSubscriber(r,function(){n.complete(),r.next(n=new Gp.Subject);},wI.noop,i)),function(){n?.unsubscribe(),n=null;}})}Ro.window=TI;});var zp=d(Ir=>{var II=Ir&&Ir.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(Ir,"__esModule",{value:true});Ir.windowCount=void 0;var $p=K(),xI=S(),RI=x();function PI(e,t){t===void 0&&(t=0);var r=t>0?t:e;return xI.operate(function(n,i){var a=[new $p.Subject],s=0;i.next(a[0].asObservable()),n.subscribe(RI.createOperatorSubscriber(i,function(u){var c,f;try{for(var v=II(a),h=v.next();!h.done;h=v.next()){var m=h.value;m.next(u);}}catch(g){c={error:g};}finally{try{h&&!h.done&&(f=v.return)&&f.call(v);}finally{if(c)throw c.error}}var _=s-e+1;if(_>=0&&_%r===0&&a.shift().complete(),++s%r===0){var y=new $p.Subject;a.push(y),i.next(y.asObservable());}},function(){for(;a.length>0;)a.shift().complete();i.complete();},function(u){for(;a.length>0;)a.shift().error(u);i.error(u);},function(){a=null;}));})}Ir.windowCount=PI;});var Xp=d(Po=>{Object.defineProperty(Po,"__esModule",{value:true});Po.windowTime=void 0;var qI=K(),CI=ie(),NI=ue(),MI=S(),kI=x(),jI=Ne(),LI=ae(),Jp=Me();function FI(e){for(var t,r,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=(t=LI.popScheduler(n))!==null&&t!==void 0?t:CI.asyncScheduler,o=(r=n[0])!==null&&r!==void 0?r:null,s=n[1]||1/0;return MI.operate(function(u,c){var f=[],v=false,h=function(g){var I=g.window,L=g.subs;I.complete(),L.unsubscribe(),jI.arrRemove(f,g),v&&m();},m=function(){if(f){var g=new NI.Subscription;c.add(g);var I=new qI.Subject,L={window:I,subs:g,seen:0};f.push(L),c.next(I.asObservable()),Jp.executeSchedule(g,a,function(){return h(L)},e);}};o!==null&&o>=0?Jp.executeSchedule(c,a,m,o,true):v=true,m();var _=function(g){return f.slice().forEach(g)},y=function(g){_(function(I){var L=I.window;return g(L)}),g(c),c.unsubscribe();};return u.subscribe(kI.createOperatorSubscriber(c,function(g){_(function(I){I.window.next(g),s<=++I.seen&&h(I);});},function(){return y(function(g){return g.complete()})},function(g){return y(function(I){return I.error(g)})})),function(){f=null;}})}Po.windowTime=FI;});var Yp=d(xr=>{var DI=xr&&xr.__values||function(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};Object.defineProperty(xr,"__esModule",{value:true});xr.windowToggle=void 0;var UI=K(),VI=ue(),BI=S(),Kp=C(),ec=x(),Zp=J(),GI=Ne();function HI(e,t){return BI.operate(function(r,n){var i=[],a=function(o){for(;0<i.length;)i.shift().error(o);n.error(o);};Kp.innerFrom(e).subscribe(ec.createOperatorSubscriber(n,function(o){var s=new UI.Subject;i.push(s);var u=new VI.Subscription,c=function(){GI.arrRemove(i,s),s.complete(),u.unsubscribe();},f;try{f=Kp.innerFrom(t(o));}catch(v){a(v);return}n.next(s.asObservable()),u.add(f.subscribe(ec.createOperatorSubscriber(n,c,Zp.noop,a)));},Zp.noop)),r.subscribe(ec.createOperatorSubscriber(n,function(o){var s,u,c=i.slice();try{for(var f=DI(c),v=f.next();!v.done;v=f.next()){var h=v.value;h.next(o);}}catch(m){s={error:m};}finally{try{v&&!v.done&&(u=f.return)&&u.call(f);}finally{if(s)throw s.error}}},function(){for(;0<i.length;)i.shift().complete();n.complete();},a,function(){for(;0<i.length;)i.shift().unsubscribe();}));})}xr.windowToggle=HI;});var ev=d(qo=>{Object.defineProperty(qo,"__esModule",{value:true});qo.windowWhen=void 0;var WI=K(),$I=S(),Qp=x(),zI=C();function JI(e){return $I.operate(function(t,r){var n,i,a=function(s){n.error(s),r.error(s);},o=function(){i?.unsubscribe(),n?.complete(),n=new WI.Subject,r.next(n.asObservable());var s;try{s=zI.innerFrom(e());}catch(u){a(u);return}s.subscribe(i=Qp.createOperatorSubscriber(r,o,o,a));};o(),t.subscribe(Qp.createOperatorSubscriber(r,function(s){return n.next(s)},function(){n.complete(),r.complete();},a,function(){i?.unsubscribe(),n=null;}));})}qo.windowWhen=JI;});var iv=d(ct=>{var tv=ct&&ct.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},rv=ct&&ct.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(ct,"__esModule",{value:true});ct.withLatestFrom=void 0;var XI=S(),nv=x(),KI=C(),ZI=X(),YI=J(),QI=ae();function ex(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=QI.popResultSelector(e);return XI.operate(function(n,i){for(var a=e.length,o=new Array(a),s=e.map(function(){return false}),u=false,c=function(v){KI.innerFrom(e[v]).subscribe(nv.createOperatorSubscriber(i,function(h){o[v]=h,!u&&!s[v]&&(s[v]=true,(u=s.every(ZI.identity))&&(s=null));},YI.noop));},f=0;f<a;f++)c(f);n.subscribe(nv.createOperatorSubscriber(i,function(v){if(u){var h=rv([v],tv(o));i.next(r?r.apply(void 0,rv([],tv(h))):h);}}));})}ct.withLatestFrom=ex;});var av=d(Co=>{Object.defineProperty(Co,"__esModule",{value:true});Co.zipAll=void 0;var tx=Qi(),rx=Fu();function nx(e){return rx.joinAllInternals(tx.zip,e)}Co.zipAll=nx;});var ov=d(lt=>{var ix=lt&<.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},ax=lt&<.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(lt,"__esModule",{value:true});lt.zip=void 0;var ox=Qi(),sx=S();function ux(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return sx.operate(function(r,n){ox.zip.apply(void 0,ax([r],ix(e))).subscribe(n);})}lt.zip=ux;});var sv=d(ft=>{var cx=ft&&ft.__read||function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)a.push(i.value);}catch(s){o={error:s};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return a},lx=ft&&ft.__spreadArray||function(e,t){for(var r=0,n=t.length,i=e.length;r<n;r++,i++)e[i]=t[r];return e};Object.defineProperty(ft,"__esModule",{value:true});ft.zipWith=void 0;var fx=ov();function dx(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return fx.zip.apply(void 0,lx([],cx(e)))}ft.zipWith=dx;});var vv=d(l=>{var px=l&&l.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r),Object.defineProperty(e,n,{enumerable:true,get:function(){return t[r]}});}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r];}),vx=l&&l.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&px(t,e,r);};Object.defineProperty(l,"__esModule",{value:true});l.interval=l.iif=l.generate=l.fromEventPattern=l.fromEvent=l.from=l.forkJoin=l.empty=l.defer=l.connectable=l.concat=l.combineLatest=l.bindNodeCallback=l.bindCallback=l.UnsubscriptionError=l.TimeoutError=l.SequenceError=l.ObjectUnsubscribedError=l.NotFoundError=l.EmptyError=l.ArgumentOutOfRangeError=l.firstValueFrom=l.lastValueFrom=l.isObservable=l.identity=l.noop=l.pipe=l.NotificationKind=l.Notification=l.Subscriber=l.Subscription=l.Scheduler=l.VirtualAction=l.VirtualTimeScheduler=l.animationFrameScheduler=l.animationFrame=l.queueScheduler=l.queue=l.asyncScheduler=l.async=l.asapScheduler=l.asap=l.AsyncSubject=l.ReplaySubject=l.BehaviorSubject=l.Subject=l.animationFrames=l.observable=l.ConnectableObservable=l.Observable=void 0;l.filter=l.expand=l.exhaustMap=l.exhaustAll=l.exhaust=l.every=l.endWith=l.elementAt=l.distinctUntilKeyChanged=l.distinctUntilChanged=l.distinct=l.dematerialize=l.delayWhen=l.delay=l.defaultIfEmpty=l.debounceTime=l.debounce=l.count=l.connect=l.concatWith=l.concatMapTo=l.concatMap=l.concatAll=l.combineLatestWith=l.combineLatestAll=l.combineAll=l.catchError=l.bufferWhen=l.bufferToggle=l.bufferTime=l.bufferCount=l.buffer=l.auditTime=l.audit=l.config=l.NEVER=l.EMPTY=l.scheduled=l.zip=l.using=l.timer=l.throwError=l.range=l.race=l.partition=l.pairs=l.onErrorResumeNext=l.of=l.never=l.merge=void 0;l.switchMap=l.switchAll=l.subscribeOn=l.startWith=l.skipWhile=l.skipUntil=l.skipLast=l.skip=l.single=l.shareReplay=l.share=l.sequenceEqual=l.scan=l.sampleTime=l.sample=l.refCount=l.retryWhen=l.retry=l.repeatWhen=l.repeat=l.reduce=l.raceWith=l.publishReplay=l.publishLast=l.publishBehavior=l.publish=l.pluck=l.pairwise=l.onErrorResumeNextWith=l.observeOn=l.multicast=l.min=l.mergeWith=l.mergeScan=l.mergeMapTo=l.mergeMap=l.flatMap=l.mergeAll=l.max=l.materialize=l.mapTo=l.map=l.last=l.isEmpty=l.ignoreElements=l.groupBy=l.first=l.findIndex=l.find=l.finalize=void 0;l.zipWith=l.zipAll=l.withLatestFrom=l.windowWhen=l.windowToggle=l.windowTime=l.windowCount=l.window=l.toArray=l.timestamp=l.timeoutWith=l.timeout=l.timeInterval=l.throwIfEmpty=l.throttleTime=l.throttle=l.tap=l.takeWhile=l.takeUntil=l.takeLast=l.take=l.switchScan=l.switchMapTo=void 0;var hx=V();Object.defineProperty(l,"Observable",{enumerable:true,get:function(){return hx.Observable}});var mx=$r();Object.defineProperty(l,"ConnectableObservable",{enumerable:true,get:function(){return mx.ConnectableObservable}});var _x=Hr();Object.defineProperty(l,"observable",{enumerable:true,get:function(){return _x.observable}});var yx=fl();Object.defineProperty(l,"animationFrames",{enumerable:true,get:function(){return yx.animationFrames}});var bx=K();Object.defineProperty(l,"Subject",{enumerable:true,get:function(){return bx.Subject}});var gx=iu();Object.defineProperty(l,"BehaviorSubject",{enumerable:true,get:function(){return gx.BehaviorSubject}});var Ex=Un();Object.defineProperty(l,"ReplaySubject",{enumerable:true,get:function(){return Ex.ReplaySubject}});var Sx=Vn();Object.defineProperty(l,"AsyncSubject",{enumerable:true,get:function(){return Sx.AsyncSubject}});var uv=xl();Object.defineProperty(l,"asap",{enumerable:true,get:function(){return uv.asap}});Object.defineProperty(l,"asapScheduler",{enumerable:true,get:function(){return uv.asapScheduler}});var cv=ie();Object.defineProperty(l,"async",{enumerable:true,get:function(){return cv.async}});Object.defineProperty(l,"asyncScheduler",{enumerable:true,get:function(){return cv.asyncScheduler}});var lv=ql();Object.defineProperty(l,"queue",{enumerable:true,get:function(){return lv.queue}});Object.defineProperty(l,"queueScheduler",{enumerable:true,get:function(){return lv.queueScheduler}});var fv=kl();Object.defineProperty(l,"animationFrame",{enumerable:true,get:function(){return fv.animationFrame}});Object.defineProperty(l,"animationFrameScheduler",{enumerable:true,get:function(){return fv.animationFrameScheduler}});var dv=Fl();Object.defineProperty(l,"VirtualTimeScheduler",{enumerable:true,get:function(){return dv.VirtualTimeScheduler}});Object.defineProperty(l,"VirtualAction",{enumerable:true,get:function(){return dv.VirtualAction}});var Ox=ou();Object.defineProperty(l,"Scheduler",{enumerable:true,get:function(){return Ox.Scheduler}});var wx=ue();Object.defineProperty(l,"Subscription",{enumerable:true,get:function(){return wx.Subscription}});var Ax=Jt();Object.defineProperty(l,"Subscriber",{enumerable:true,get:function(){return Ax.Subscriber}});var pv=pi();Object.defineProperty(l,"Notification",{enumerable:true,get:function(){return pv.Notification}});Object.defineProperty(l,"NotificationKind",{enumerable:true,get:function(){return pv.NotificationKind}});var Tx=Wr();Object.defineProperty(l,"pipe",{enumerable:true,get:function(){return Tx.pipe}});var Ix=J();Object.defineProperty(l,"noop",{enumerable:true,get:function(){return Ix.noop}});var xx=X();Object.defineProperty(l,"identity",{enumerable:true,get:function(){return xx.identity}});var Rx=tf();Object.defineProperty(l,"isObservable",{enumerable:true,get:function(){return Rx.isObservable}});var Px=rf();Object.defineProperty(l,"lastValueFrom",{enumerable:true,get:function(){return Px.lastValueFrom}});var qx=nf();Object.defineProperty(l,"firstValueFrom",{enumerable:true,get:function(){return qx.firstValueFrom}});var Cx=Eu();Object.defineProperty(l,"ArgumentOutOfRangeError",{enumerable:true,get:function(){return Cx.ArgumentOutOfRangeError}});var Nx=ze();Object.defineProperty(l,"EmptyError",{enumerable:true,get:function(){return Nx.EmptyError}});var Mx=Su();Object.defineProperty(l,"NotFoundError",{enumerable:true,get:function(){return Mx.NotFoundError}});var kx=eu();Object.defineProperty(l,"ObjectUnsubscribedError",{enumerable:true,get:function(){return kx.ObjectUnsubscribedError}});var jx=Ou();Object.defineProperty(l,"SequenceError",{enumerable:true,get:function(){return jx.SequenceError}});var Lx=Oi();Object.defineProperty(l,"TimeoutError",{enumerable:true,get:function(){return Lx.TimeoutError}});var Fx=Vs();Object.defineProperty(l,"UnsubscriptionError",{enumerable:true,get:function(){return Fx.UnsubscriptionError}});var Dx=of();Object.defineProperty(l,"bindCallback",{enumerable:true,get:function(){return Dx.bindCallback}});var Ux=sf();Object.defineProperty(l,"bindNodeCallback",{enumerable:true,get:function(){return Ux.bindNodeCallback}});var Vx=Ri();Object.defineProperty(l,"combineLatest",{enumerable:true,get:function(){return Vx.combineLatest}});var Bx=Qr();Object.defineProperty(l,"concat",{enumerable:true,get:function(){return Bx.concat}});var Gx=hf();Object.defineProperty(l,"connectable",{enumerable:true,get:function(){return Gx.connectable}});var Hx=en();Object.defineProperty(l,"defer",{enumerable:true,get:function(){return Hx.defer}});var Wx=ye();Object.defineProperty(l,"empty",{enumerable:true,get:function(){return Wx.empty}});var $x=mf();Object.defineProperty(l,"forkJoin",{enumerable:true,get:function(){return $x.forkJoin}});var zx=ke();Object.defineProperty(l,"from",{enumerable:true,get:function(){return zx.from}});var Jx=yf();Object.defineProperty(l,"fromEvent",{enumerable:true,get:function(){return Jx.fromEvent}});var Xx=gf();Object.defineProperty(l,"fromEventPattern",{enumerable:true,get:function(){return Xx.fromEventPattern}});var Kx=Sf();Object.defineProperty(l,"generate",{enumerable:true,get:function(){return Kx.generate}});var Zx=Of();Object.defineProperty(l,"iif",{enumerable:true,get:function(){return Zx.iif}});var Yx=Ru();Object.defineProperty(l,"interval",{enumerable:true,get:function(){return Yx.interval}});var Qx=Af();Object.defineProperty(l,"merge",{enumerable:true,get:function(){return Qx.merge}});var eR=Pu();Object.defineProperty(l,"never",{enumerable:true,get:function(){return eR.never}});var tR=fi();Object.defineProperty(l,"of",{enumerable:true,get:function(){return tR.of}});var rR=qu();Object.defineProperty(l,"onErrorResumeNext",{enumerable:true,get:function(){return rR.onErrorResumeNext}});var nR=If();Object.defineProperty(l,"pairs",{enumerable:true,get:function(){return nR.pairs}});var iR=qf();Object.defineProperty(l,"partition",{enumerable:true,get:function(){return iR.partition}});var aR=Cu();Object.defineProperty(l,"race",{enumerable:true,get:function(){return aR.race}});var oR=Mf();Object.defineProperty(l,"range",{enumerable:true,get:function(){return oR.range}});var sR=gu();Object.defineProperty(l,"throwError",{enumerable:true,get:function(){return sR.throwError}});var uR=Ye();Object.defineProperty(l,"timer",{enumerable:true,get:function(){return uR.timer}});var cR=kf();Object.defineProperty(l,"using",{enumerable:true,get:function(){return cR.using}});var lR=Qi();Object.defineProperty(l,"zip",{enumerable:true,get:function(){return lR.zip}});var fR=bu();Object.defineProperty(l,"scheduled",{enumerable:true,get:function(){return fR.scheduled}});var dR=ye();Object.defineProperty(l,"EMPTY",{enumerable:true,get:function(){return dR.EMPTY}});var pR=Pu();Object.defineProperty(l,"NEVER",{enumerable:true,get:function(){return pR.NEVER}});vx(Lf(),l);var vR=$t();Object.defineProperty(l,"config",{enumerable:true,get:function(){return vR.config}});var hR=Nu();Object.defineProperty(l,"audit",{enumerable:true,get:function(){return hR.audit}});var mR=Df();Object.defineProperty(l,"auditTime",{enumerable:true,get:function(){return mR.auditTime}});var _R=Vf();Object.defineProperty(l,"buffer",{enumerable:true,get:function(){return _R.buffer}});var yR=Bf();Object.defineProperty(l,"bufferCount",{enumerable:true,get:function(){return yR.bufferCount}});var bR=Hf();Object.defineProperty(l,"bufferTime",{enumerable:true,get:function(){return bR.bufferTime}});var gR=zf();Object.defineProperty(l,"bufferToggle",{enumerable:true,get:function(){return gR.bufferToggle}});var ER=Xf();Object.defineProperty(l,"bufferWhen",{enumerable:true,get:function(){return ER.bufferWhen}});var SR=Zf();Object.defineProperty(l,"catchError",{enumerable:true,get:function(){return SR.catchError}});var OR=Yf();Object.defineProperty(l,"combineAll",{enumerable:true,get:function(){return OR.combineAll}});var wR=Du();Object.defineProperty(l,"combineLatestAll",{enumerable:true,get:function(){return wR.combineLatestAll}});var AR=nd();Object.defineProperty(l,"combineLatestWith",{enumerable:true,get:function(){return AR.combineLatestWith}});var TR=ki();Object.defineProperty(l,"concatAll",{enumerable:true,get:function(){return TR.concatAll}});var IR=Uu();Object.defineProperty(l,"concatMap",{enumerable:true,get:function(){return IR.concatMap}});var xR=od();Object.defineProperty(l,"concatMapTo",{enumerable:true,get:function(){return xR.concatMapTo}});var RR=ud();Object.defineProperty(l,"concatWith",{enumerable:true,get:function(){return RR.concatWith}});var PR=ha();Object.defineProperty(l,"connect",{enumerable:true,get:function(){return PR.connect}});var qR=ld();Object.defineProperty(l,"count",{enumerable:true,get:function(){return qR.count}});var CR=dd();Object.defineProperty(l,"debounce",{enumerable:true,get:function(){return CR.debounce}});var NR=pd();Object.defineProperty(l,"debounceTime",{enumerable:true,get:function(){return NR.debounceTime}});var MR=tn();Object.defineProperty(l,"defaultIfEmpty",{enumerable:true,get:function(){return MR.defaultIfEmpty}});var kR=md();Object.defineProperty(l,"delay",{enumerable:true,get:function(){return kR.delay}});var jR=Gu();Object.defineProperty(l,"delayWhen",{enumerable:true,get:function(){return jR.delayWhen}});var LR=_d();Object.defineProperty(l,"dematerialize",{enumerable:true,get:function(){return LR.dematerialize}});var FR=bd();Object.defineProperty(l,"distinct",{enumerable:true,get:function(){return FR.distinct}});var DR=Hu();Object.defineProperty(l,"distinctUntilChanged",{enumerable:true,get:function(){return DR.distinctUntilChanged}});var UR=gd();Object.defineProperty(l,"distinctUntilKeyChanged",{enumerable:true,get:function(){return UR.distinctUntilKeyChanged}});var VR=Sd();Object.defineProperty(l,"elementAt",{enumerable:true,get:function(){return VR.elementAt}});var BR=Od();Object.defineProperty(l,"endWith",{enumerable:true,get:function(){return BR.endWith}});var GR=wd();Object.defineProperty(l,"every",{enumerable:true,get:function(){return GR.every}});var HR=xd();Object.defineProperty(l,"exhaust",{enumerable:true,get:function(){return HR.exhaust}});var WR=$u();Object.defineProperty(l,"exhaustAll",{enumerable:true,get:function(){return WR.exhaustAll}});var $R=Wu();Object.defineProperty(l,"exhaustMap",{enumerable:true,get:function(){return $R.exhaustMap}});var zR=Rd();Object.defineProperty(l,"expand",{enumerable:true,get:function(){return zR.expand}});var JR=It();Object.defineProperty(l,"filter",{enumerable:true,get:function(){return JR.filter}});var XR=Pd();Object.defineProperty(l,"finalize",{enumerable:true,get:function(){return XR.finalize}});var KR=zu();Object.defineProperty(l,"find",{enumerable:true,get:function(){return KR.find}});var ZR=Cd();Object.defineProperty(l,"findIndex",{enumerable:true,get:function(){return ZR.findIndex}});var YR=Nd();Object.defineProperty(l,"first",{enumerable:true,get:function(){return YR.first}});var QR=kd();Object.defineProperty(l,"groupBy",{enumerable:true,get:function(){return QR.groupBy}});var eP=Vu();Object.defineProperty(l,"ignoreElements",{enumerable:true,get:function(){return eP.ignoreElements}});var tP=jd();Object.defineProperty(l,"isEmpty",{enumerable:true,get:function(){return tP.isEmpty}});var rP=Ld();Object.defineProperty(l,"last",{enumerable:true,get:function(){return rP.last}});var nP=Je();Object.defineProperty(l,"map",{enumerable:true,get:function(){return nP.map}});var iP=Bu();Object.defineProperty(l,"mapTo",{enumerable:true,get:function(){return iP.mapTo}});var aP=Fd();Object.defineProperty(l,"materialize",{enumerable:true,get:function(){return aP.materialize}});var oP=Dd();Object.defineProperty(l,"max",{enumerable:true,get:function(){return oP.max}});var sP=Yr();Object.defineProperty(l,"mergeAll",{enumerable:true,get:function(){return sP.mergeAll}});var uP=Ud();Object.defineProperty(l,"flatMap",{enumerable:true,get:function(){return uP.flatMap}});var cP=Le();Object.defineProperty(l,"mergeMap",{enumerable:true,get:function(){return cP.mergeMap}});var lP=Bd();Object.defineProperty(l,"mergeMapTo",{enumerable:true,get:function(){return lP.mergeMapTo}});var fP=Gd();Object.defineProperty(l,"mergeScan",{enumerable:true,get:function(){return fP.mergeScan}});var dP=$d();Object.defineProperty(l,"mergeWith",{enumerable:true,get:function(){return dP.mergeWith}});var pP=zd();Object.defineProperty(l,"min",{enumerable:true,get:function(){return pP.min}});var vP=Xa();Object.defineProperty(l,"multicast",{enumerable:true,get:function(){return vP.multicast}});var hP=Kr();Object.defineProperty(l,"observeOn",{enumerable:true,get:function(){return hP.observeOn}});var mP=Kd();Object.defineProperty(l,"onErrorResumeNextWith",{enumerable:true,get:function(){return mP.onErrorResumeNextWith}});var _P=Zd();Object.defineProperty(l,"pairwise",{enumerable:true,get:function(){return _P.pairwise}});var yP=Yd();Object.defineProperty(l,"pluck",{enumerable:true,get:function(){return yP.pluck}});var bP=Qd();Object.defineProperty(l,"publish",{enumerable:true,get:function(){return bP.publish}});var gP=ep();Object.defineProperty(l,"publishBehavior",{enumerable:true,get:function(){return gP.publishBehavior}});var EP=tp();Object.defineProperty(l,"publishLast",{enumerable:true,get:function(){return EP.publishLast}});var SP=np();Object.defineProperty(l,"publishReplay",{enumerable:true,get:function(){return SP.publishReplay}});var OP=ip();Object.defineProperty(l,"raceWith",{enumerable:true,get:function(){return OP.raceWith}});var wP=Or();Object.defineProperty(l,"reduce",{enumerable:true,get:function(){return wP.reduce}});var AP=op();Object.defineProperty(l,"repeat",{enumerable:true,get:function(){return AP.repeat}});var TP=up();Object.defineProperty(l,"repeatWhen",{enumerable:true,get:function(){return TP.repeatWhen}});var IP=lp();Object.defineProperty(l,"retry",{enumerable:true,get:function(){return IP.retry}});var xP=dp();Object.defineProperty(l,"retryWhen",{enumerable:true,get:function(){return xP.retryWhen}});var RP=Ys();Object.defineProperty(l,"refCount",{enumerable:true,get:function(){return RP.refCount}});var PP=Ku();Object.defineProperty(l,"sample",{enumerable:true,get:function(){return PP.sample}});var qP=vp();Object.defineProperty(l,"sampleTime",{enumerable:true,get:function(){return qP.sampleTime}});var CP=hp();Object.defineProperty(l,"scan",{enumerable:true,get:function(){return CP.scan}});var NP=_p();Object.defineProperty(l,"sequenceEqual",{enumerable:true,get:function(){return NP.sequenceEqual}});var MP=Yu();Object.defineProperty(l,"share",{enumerable:true,get:function(){return MP.share}});var kP=gp();Object.defineProperty(l,"shareReplay",{enumerable:true,get:function(){return kP.shareReplay}});var jP=Ep();Object.defineProperty(l,"single",{enumerable:true,get:function(){return jP.single}});var LP=Sp();Object.defineProperty(l,"skip",{enumerable:true,get:function(){return LP.skip}});var FP=Op();Object.defineProperty(l,"skipLast",{enumerable:true,get:function(){return FP.skipLast}});var DP=Ap();Object.defineProperty(l,"skipUntil",{enumerable:true,get:function(){return DP.skipUntil}});var UP=Tp();Object.defineProperty(l,"skipWhile",{enumerable:true,get:function(){return UP.skipWhile}});var VP=xp();Object.defineProperty(l,"startWith",{enumerable:true,get:function(){return VP.startWith}});var BP=Zr();Object.defineProperty(l,"subscribeOn",{enumerable:true,get:function(){return BP.subscribeOn}});var GP=Pp();Object.defineProperty(l,"switchAll",{enumerable:true,get:function(){return GP.switchAll}});var HP=an();Object.defineProperty(l,"switchMap",{enumerable:true,get:function(){return HP.switchMap}});var WP=Cp();Object.defineProperty(l,"switchMapTo",{enumerable:true,get:function(){return WP.switchMapTo}});var $P=Np();Object.defineProperty(l,"switchScan",{enumerable:true,get:function(){return $P.switchScan}});var zP=rn();Object.defineProperty(l,"take",{enumerable:true,get:function(){return zP.take}});var JP=Ju();Object.defineProperty(l,"takeLast",{enumerable:true,get:function(){return JP.takeLast}});var XP=Mp();Object.defineProperty(l,"takeUntil",{enumerable:true,get:function(){return XP.takeUntil}});var KP=kp();Object.defineProperty(l,"takeWhile",{enumerable:true,get:function(){return KP.takeWhile}});var ZP=jp();Object.defineProperty(l,"tap",{enumerable:true,get:function(){return ZP.tap}});var YP=Qu();Object.defineProperty(l,"throttle",{enumerable:true,get:function(){return YP.throttle}});var QP=Fp();Object.defineProperty(l,"throttleTime",{enumerable:true,get:function(){return QP.throttleTime}});var eq=nn();Object.defineProperty(l,"throwIfEmpty",{enumerable:true,get:function(){return eq.throwIfEmpty}});var tq=Up();Object.defineProperty(l,"timeInterval",{enumerable:true,get:function(){return tq.timeInterval}});var rq=Oi();Object.defineProperty(l,"timeout",{enumerable:true,get:function(){return rq.timeout}});var nq=Vp();Object.defineProperty(l,"timeoutWith",{enumerable:true,get:function(){return nq.timeoutWith}});var iq=Bp();Object.defineProperty(l,"timestamp",{enumerable:true,get:function(){return iq.timestamp}});var aq=Lu();Object.defineProperty(l,"toArray",{enumerable:true,get:function(){return aq.toArray}});var oq=Wp();Object.defineProperty(l,"window",{enumerable:true,get:function(){return oq.window}});var sq=zp();Object.defineProperty(l,"windowCount",{enumerable:true,get:function(){return sq.windowCount}});var uq=Xp();Object.defineProperty(l,"windowTime",{enumerable:true,get:function(){return uq.windowTime}});var cq=Yp();Object.defineProperty(l,"windowToggle",{enumerable:true,get:function(){return cq.windowToggle}});var lq=ev();Object.defineProperty(l,"windowWhen",{enumerable:true,get:function(){return lq.windowWhen}});var fq=iv();Object.defineProperty(l,"withLatestFrom",{enumerable:true,get:function(){return fq.withLatestFrom}});var dq=av();Object.defineProperty(l,"zipAll",{enumerable:true,get:function(){return dq.zipAll}});var pq=sv();Object.defineProperty(l,"zipWith",{enumerable:true,get:function(){return pq.zipWith}});});var wc=d(T=>{Object.defineProperty(T,"__esModule",{value:true});T.Allow=T.ALL=T.COLLECTION=T.ATOM=T.SPECIAL=T.INF=T._INFINITY=T.INFINITY=T.NAN=T.BOOL=T.NULL=T.OBJ=T.ARR=T.NUM=T.STR=void 0;T.STR=1;T.NUM=2;T.ARR=4;T.OBJ=8;T.NULL=16;T.BOOL=32;T.NAN=64;T.INFINITY=128;T._INFINITY=256;T.INF=T.INFINITY|T._INFINITY;T.SPECIAL=T.NULL|T.BOOL|T.INF|T.NAN;T.ATOM=T.STR|T.NUM|T.SPECIAL;T.COLLECTION=T.ARR|T.OBJ;T.ALL=T.ATOM|T.COLLECTION;T.Allow={STR:T.STR,NUM:T.NUM,ARR:T.ARR,OBJ:T.OBJ,NULL:T.NULL,BOOL:T.BOOL,NAN:T.NAN,INFINITY:T.INFINITY,_INFINITY:T._INFINITY,INF:T.INF,SPECIAL:T.SPECIAL,ATOM:T.ATOM,COLLECTION:T.COLLECTION,ALL:T.ALL};T.default=T.Allow;});var Eh=d(ee=>{var $N=ee&&ee.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:true,get:function(){return t[r]}}),Object.defineProperty(e,n,i);}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r];}),zN=ee&&ee.__exportStar||function(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&$N(t,e,r);};Object.defineProperty(ee,"__esModule",{value:true});ee.Allow=ee.MalformedJSON=ee.PartialJSON=ee.parseJSON=ee.parse=void 0;var re=wc();Object.defineProperty(ee,"Allow",{enumerable:true,get:function(){return re.Allow}});zN(wc(),ee);var ys=class extends Error{};ee.PartialJSON=ys;var bs=class extends Error{};ee.MalformedJSON=bs;function gh(e,t=re.Allow.ALL){if(typeof e!="string")throw new TypeError(`expecting str, got ${typeof e}`);if(!e.trim())throw new Error(`${e} is empty`);return JN(e.trim(),t)}ee.parseJSON=gh;var JN=(e,t)=>{let r=e.length,n=0,i=h=>{throw new ys(`${h} at position ${n}`)},a=h=>{throw new bs(`${h} at position ${n}`)},o=()=>(v(),n>=r&&i("Unexpected end of input"),e[n]==='"'?s():e[n]==="{"?u():e[n]==="["?c():e.substring(n,n+4)==="null"||re.Allow.NULL&t&&r-n<4&&"null".startsWith(e.substring(n))?(n+=4,null):e.substring(n,n+4)==="true"||re.Allow.BOOL&t&&r-n<4&&"true".startsWith(e.substring(n))?(n+=4,true):e.substring(n,n+5)==="false"||re.Allow.BOOL&t&&r-n<5&&"false".startsWith(e.substring(n))?(n+=5,false):e.substring(n,n+8)==="Infinity"||re.Allow.INFINITY&t&&r-n<8&&"Infinity".startsWith(e.substring(n))?(n+=8,1/0):e.substring(n,n+9)==="-Infinity"||re.Allow._INFINITY&t&&1<r-n&&r-n<9&&"-Infinity".startsWith(e.substring(n))?(n+=9,-1/0):e.substring(n,n+3)==="NaN"||re.Allow.NAN&t&&r-n<3&&"NaN".startsWith(e.substring(n))?(n+=3,NaN):f()),s=()=>{let h=n,m=false;for(n++;n<r&&(e[n]!=='"'||m&&e[n-1]==="\\");)m=e[n]==="\\"?!m:false,n++;if(e.charAt(n)=='"')try{return JSON.parse(e.substring(h,++n-Number(m)))}catch(_){a(String(_));}else if(re.Allow.STR&t)try{return JSON.parse(e.substring(h,n-Number(m))+'"')}catch{return JSON.parse(e.substring(h,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal");},u=()=>{n++,v();let h={};try{for(;e[n]!=="}";){if(v(),n>=r&&re.Allow.OBJ&t)return h;let m=s();v(),n++;try{let _=o();h[m]=_;}catch(_){if(re.Allow.OBJ&t)return h;throw _}v(),e[n]===","&&n++;}}catch{if(re.Allow.OBJ&t)return h;i("Expected '}' at end of object");}return n++,h},c=()=>{n++;let h=[];try{for(;e[n]!=="]";)h.push(o()),v(),e[n]===","&&n++;}catch{if(re.Allow.ARR&t)return h;i("Expected ']' at end of array");}return n++,h},f=()=>{if(n===0){e==="-"&&a("Not sure what '-' is");try{return JSON.parse(e)}catch(m){if(re.Allow.NUM&t)try{return JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch{}a(String(m));}}let h=n;for(e[n]==="-"&&n++;e[n]&&",]}".indexOf(e[n])===-1;)n++;n==r&&!(re.Allow.NUM&t)&&i("Unterminated number literal");try{return JSON.parse(e.substring(h,n))}catch{e.substring(h,n)==="-"&&i("Not sure what '-' is");try{return JSON.parse(e.substring(h,e.lastIndexOf("e")))}catch(_){a(String(_));}}},v=()=>{for(;n<r&&`
|
|
4
|
-
\r `.includes(e[n]);)n++;};return o()},XN=gh;ee.parse=XN;});var Uc={version:"0.0.22-alpha.2"};var Sn=class{};var gs=Dc(vv());var p={};Us(p,{BRAND:()=>Dq,DIRTY:()=>xt,EMPTY_PATH:()=>_q,INVALID:()=>P,NEVER:()=>OC,OK:()=>te,ParseStatus:()=>Z,Schema:()=>M,ZodAny:()=>vt,ZodArray:()=>Ve,ZodBigInt:()=>Pt,ZodBoolean:()=>qt,ZodBranded:()=>sn,ZodCatch:()=>Bt,ZodDate:()=>Ct,ZodDefault:()=>Vt,ZodDiscriminatedUnion:()=>ko,ZodEffects:()=>ve,ZodEnum:()=>Dt,ZodError:()=>oe,ZodFirstPartyTypeKind:()=>q,ZodFunction:()=>Lo,ZodIntersection:()=>jt,ZodIssueCode:()=>b,ZodLazy:()=>Lt,ZodLiteral:()=>Ft,ZodMap:()=>Mr,ZodNaN:()=>jr,ZodNativeEnum:()=>Ut,ZodNever:()=>be,ZodNull:()=>Mt,ZodNullable:()=>Pe,ZodNumber:()=>Rt,ZodObject:()=>se,ZodOptional:()=>de,ZodParsedType:()=>O,ZodPipeline:()=>un,ZodPromise:()=>ht,ZodReadonly:()=>Gt,ZodRecord:()=>jo,ZodSchema:()=>M,ZodSet:()=>kr,ZodString:()=>pt,ZodSymbol:()=>Cr,ZodTransformer:()=>ve,ZodTuple:()=>Re,ZodType:()=>M,ZodUndefined:()=>Nt,ZodUnion:()=>kt,ZodUnknown:()=>Ue,ZodVoid:()=>Nr,addIssueToContext:()=>E,any:()=>Jq,array:()=>Yq,bigint:()=>Gq,boolean:()=>Av,coerce:()=>SC,custom:()=>Sv,date:()=>Hq,datetimeRegex:()=>gv,defaultErrorMap:()=>Fe,discriminatedUnion:()=>rC,effect:()=>vC,enum:()=>fC,function:()=>uC,getErrorMap:()=>Rr,getParsedType:()=>xe,instanceof:()=>Vq,intersection:()=>nC,isAborted:()=>No,isAsync:()=>Pr,isDirty:()=>Mo,isValid:()=>dt,late:()=>Uq,lazy:()=>cC,literal:()=>lC,makeIssue:()=>on,map:()=>oC,nan:()=>Bq,nativeEnum:()=>dC,never:()=>Kq,null:()=>zq,nullable:()=>mC,number:()=>wv,object:()=>Qq,objectUtil:()=>tc,oboolean:()=>EC,onumber:()=>gC,optional:()=>hC,ostring:()=>bC,pipeline:()=>yC,preprocess:()=>_C,promise:()=>pC,quotelessJson:()=>vq,record:()=>aC,set:()=>sC,setErrorMap:()=>mq,strictObject:()=>eC,string:()=>Ov,symbol:()=>Wq,transformer:()=>vC,tuple:()=>iC,undefined:()=>$q,union:()=>tC,unknown:()=>Xq,util:()=>k,void:()=>Zq});var k;(function(e){e.assertEqual=i=>{};function t(i){}e.assertIs=t;function r(i){throw new Error}e.assertNever=r,e.arrayToEnum=i=>{let a={};for(let o of i)a[o]=o;return a},e.getValidEnumValues=i=>{let a=e.objectKeys(i).filter(s=>typeof i[i[s]]!="number"),o={};for(let s of a)o[s]=i[s];return e.objectValues(o)},e.objectValues=i=>e.objectKeys(i).map(function(a){return i[a]}),e.objectKeys=typeof Object.keys=="function"?i=>Object.keys(i):i=>{let a=[];for(let o in i)Object.prototype.hasOwnProperty.call(i,o)&&a.push(o);return a},e.find=(i,a)=>{for(let o of i)if(a(o))return o},e.isInteger=typeof Number.isInteger=="function"?i=>Number.isInteger(i):i=>typeof i=="number"&&Number.isFinite(i)&&Math.floor(i)===i;function n(i,a=" | "){return i.map(o=>typeof o=="string"?`'${o}'`:o).join(a)}e.joinValues=n,e.jsonStringifyReplacer=(i,a)=>typeof a=="bigint"?a.toString():a;})(k||(k={}));var tc;(function(e){e.mergeShapes=(t,r)=>({...t,...r});})(tc||(tc={}));var O=k.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),xe=e=>{switch(typeof e){case "undefined":return O.undefined;case "string":return O.string;case "number":return Number.isNaN(e)?O.nan:O.number;case "boolean":return O.boolean;case "function":return O.function;case "bigint":return O.bigint;case "symbol":return O.symbol;case "object":return Array.isArray(e)?O.array:e===null?O.null:e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?O.promise:typeof Map<"u"&&e instanceof Map?O.map:typeof Set<"u"&&e instanceof Set?O.set:typeof Date<"u"&&e instanceof Date?O.date:O.object;default:return O.unknown}};var b=k.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"]),vq=e=>JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:"),oe=class e extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n];},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n];};let r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t;}format(t){let r=t||function(a){return a.message},n={_errors:[]},i=a=>{for(let o of a.issues)if(o.code==="invalid_union")o.unionErrors.map(i);else if(o.code==="invalid_return_type")i(o.returnTypeError);else if(o.code==="invalid_arguments")i(o.argumentsError);else if(o.path.length===0)n._errors.push(r(o));else {let s=n,u=0;for(;u<o.path.length;){let c=o.path[u];u===o.path.length-1?(s[c]=s[c]||{_errors:[]},s[c]._errors.push(r(o))):s[c]=s[c]||{_errors:[]},s=s[c],u++;}}};return i(this),n}static assert(t){if(!(t instanceof e))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,k.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){let r={},n=[];for(let i of this.issues)if(i.path.length>0){let a=i.path[0];r[a]=r[a]||[],r[a].push(t(i));}else n.push(t(i));return {formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}};oe.create=e=>new oe(e);var hq=(e,t)=>{let r;switch(e.code){case b.invalid_type:e.received===O.undefined?r="Required":r=`Expected ${e.expected}, received ${e.received}`;break;case b.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(e.expected,k.jsonStringifyReplacer)}`;break;case b.unrecognized_keys:r=`Unrecognized key(s) in object: ${k.joinValues(e.keys,", ")}`;break;case b.invalid_union:r="Invalid input";break;case b.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${k.joinValues(e.options)}`;break;case b.invalid_enum_value:r=`Invalid enum value. Expected ${k.joinValues(e.options)}, received '${e.received}'`;break;case b.invalid_arguments:r="Invalid function arguments";break;case b.invalid_return_type:r="Invalid function return type";break;case b.invalid_date:r="Invalid date";break;case b.invalid_string:typeof e.validation=="object"?"includes"in e.validation?(r=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?r=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?r=`Invalid input: must end with "${e.validation.endsWith}"`:k.assertNever(e.validation):e.validation!=="regex"?r=`Invalid ${e.validation}`:r="Invalid";break;case b.too_small:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="bigint"?r=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:r="Invalid input";break;case b.too_big:e.type==="array"?r=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:e.type==="string"?r=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:e.type==="number"?r=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="bigint"?r=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:e.type==="date"?r=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:r="Invalid input";break;case b.custom:r="Invalid input";break;case b.invalid_intersection_types:r="Intersection results could not be merged";break;case b.not_multiple_of:r=`Number must be a multiple of ${e.multipleOf}`;break;case b.not_finite:r="Number must be finite";break;default:r=t.defaultError,k.assertNever(e);}return {message:r}},Fe=hq;var hv=Fe;function mq(e){hv=e;}function Rr(){return hv}var on=e=>{let{data:t,path:r,errorMaps:n,issueData:i}=e,a=[...r,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return {...i,path:a,message:i.message};let s="",u=n.filter(c=>!!c).slice().reverse();for(let c of u)s=c(o,{data:t,defaultError:s}).message;return {...i,path:a,message:s}},_q=[];function E(e,t){let r=Rr(),n=on({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Fe?void 0:Fe].filter(i=>!!i)});e.common.issues.push(n);}var Z=class e{constructor(){this.value="valid";}dirty(){this.value==="valid"&&(this.value="dirty");}abort(){this.value!=="aborted"&&(this.value="aborted");}static mergeArray(t,r){let n=[];for(let i of r){if(i.status==="aborted")return P;i.status==="dirty"&&t.dirty(),n.push(i.value);}return {status:t.value,value:n}}static async mergeObjectAsync(t,r){let n=[];for(let i of r){let a=await i.key,o=await i.value;n.push({key:a,value:o});}return e.mergeObjectSync(t,n)}static mergeObjectSync(t,r){let n={};for(let i of r){let{key:a,value:o}=i;if(a.status==="aborted"||o.status==="aborted")return P;a.status==="dirty"&&t.dirty(),o.status==="dirty"&&t.dirty(),a.value!=="__proto__"&&(typeof o.value<"u"||i.alwaysSet)&&(n[a.value]=o.value);}return {status:t.value,value:n}}},P=Object.freeze({status:"aborted"}),xt=e=>({status:"dirty",value:e}),te=e=>({status:"valid",value:e}),No=e=>e.status==="aborted",Mo=e=>e.status==="dirty",dt=e=>e.status==="valid",Pr=e=>typeof Promise<"u"&&e instanceof Promise;var A;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message;})(A||(A={}));var pe=class{constructor(t,r,n,i){this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=i;}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}},mv=(e,t)=>{if(dt(t))return {success:true,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return {success:false,get error(){if(this._error)return this._error;let r=new oe(e.common.issues);return this._error=r,this._error}}};function N(e){if(!e)return {};let{errorMap:t,invalid_type_error:r,required_error:n,description:i}=e;if(t&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(o,s)=>{let{message:u}=e;return o.code==="invalid_enum_value"?{message:u??s.defaultError}:typeof s.data>"u"?{message:u??n??s.defaultError}:o.code!=="invalid_type"?{message:s.defaultError}:{message:u??r??s.defaultError}},description:i}}var M=class{get description(){return this._def.description}_getType(t){return xe(t.data)}_getOrReturnCtx(t,r){return r||{common:t.parent.common,data:t.data,parsedType:xe(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}_processInputParams(t){return {status:new Z,ctx:{common:t.parent.common,data:t.data,parsedType:xe(t.data),schemaErrorMap:this._def.errorMap,path:t.path,parent:t.parent}}}_parseSync(t){let r=this._parse(t);if(Pr(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(t){let r=this._parse(t);return Promise.resolve(r)}parse(t,r){let n=this.safeParse(t,r);if(n.success)return n.data;throw n.error}safeParse(t,r){let n={common:{issues:[],async:r?.async??false,contextualErrorMap:r?.errorMap},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:xe(t)},i=this._parseSync({data:t,path:n.path,parent:n});return mv(n,i)}"~validate"(t){let r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:xe(t)};if(!this["~standard"].async)try{let n=this._parseSync({data:t,path:[],parent:r});return dt(n)?{value:n.value}:{issues:r.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=true),r.common={issues:[],async:true};}return this._parseAsync({data:t,path:[],parent:r}).then(n=>dt(n)?{value:n.value}:{issues:r.common.issues})}async parseAsync(t,r){let n=await this.safeParseAsync(t,r);if(n.success)return n.data;throw n.error}async safeParseAsync(t,r){let n={common:{issues:[],contextualErrorMap:r?.errorMap,async:true},path:r?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:xe(t)},i=this._parse({data:t,path:n.path,parent:n}),a=await(Pr(i)?i:Promise.resolve(i));return mv(n,a)}refine(t,r){let n=i=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(i):r;return this._refinement((i,a)=>{let o=t(i),s=()=>a.addIssue({code:b.custom,...n(i)});return typeof Promise<"u"&&o instanceof Promise?o.then(u=>u?true:(s(),false)):o?true:(s(),false)})}refinement(t,r){return this._refinement((n,i)=>t(n)?true:(i.addIssue(typeof r=="function"?r(n,i):r),false))}_refinement(t){return new ve({schema:this,typeName:q.ZodEffects,effect:{type:"refinement",refinement:t}})}superRefine(t){return this._refinement(t)}constructor(t){this.spa=this.safeParseAsync,this._def=t,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:r=>this["~validate"](r)};}optional(){return de.create(this,this._def)}nullable(){return Pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ve.create(this)}promise(){return ht.create(this,this._def)}or(t){return kt.create([this,t],this._def)}and(t){return jt.create(this,t,this._def)}transform(t){return new ve({...N(this._def),schema:this,typeName:q.ZodEffects,effect:{type:"transform",transform:t}})}default(t){let r=typeof t=="function"?t:()=>t;return new Vt({...N(this._def),innerType:this,defaultValue:r,typeName:q.ZodDefault})}brand(){return new sn({typeName:q.ZodBranded,type:this,...N(this._def)})}catch(t){let r=typeof t=="function"?t:()=>t;return new Bt({...N(this._def),innerType:this,catchValue:r,typeName:q.ZodCatch})}describe(t){let r=this.constructor;return new r({...this._def,description:t})}pipe(t){return un.create(this,t)}readonly(){return Gt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},yq=/^c[^\s-]{8,}$/i,bq=/^[0-9a-z]+$/,gq=/^[0-9A-HJKMNP-TV-Z]{26}$/i,Eq=/^[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,Sq=/^[a-z0-9_-]{21}$/i,Oq=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,wq=/^[-+]?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)?)??$/,Aq=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tq="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",rc,Iq=/^(?:(?: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])$/,xq=/^(?:(?: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])$/,Rq=/^(([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]))$/,Pq=/^(([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])$/,qq=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Cq=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,yv="((\\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])))",Nq=new RegExp(`^${yv}$`);function bv(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision==null&&(t=`${t}(\\.\\d+)?`);let r=e.precision?"+":"?";return `([01]\\d|2[0-3]):[0-5]\\d(:${t})${r}`}function Mq(e){return new RegExp(`^${bv(e)}$`)}function gv(e){let t=`${yv}T${bv(e)}`,r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${r.join("|")})`,new RegExp(`^${t}$`)}function kq(e,t){return !!((t==="v4"||!t)&&Iq.test(e)||(t==="v6"||!t)&&Rq.test(e))}function jq(e,t){if(!Oq.test(e))return false;try{let[r]=e.split(".");if(!r)return !1;let n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),i=JSON.parse(atob(n));return !(typeof i!="object"||i===null||"typ"in i&&i?.typ!=="JWT"||!i.alg||t&&i.alg!==t)}catch{return false}}function Lq(e,t){return !!((t==="v4"||!t)&&xq.test(e)||(t==="v6"||!t)&&Pq.test(e))}var pt=class e extends M{_parse(t){if(this._def.coerce&&(t.data=String(t.data)),this._getType(t)!==O.string){let a=this._getOrReturnCtx(t);return E(a,{code:b.invalid_type,expected:O.string,received:a.parsedType}),P}let n=new Z,i;for(let a of this._def.checks)if(a.kind==="min")t.data.length<a.value&&(i=this._getOrReturnCtx(t,i),E(i,{code:b.too_small,minimum:a.value,type:"string",inclusive:true,exact:false,message:a.message}),n.dirty());else if(a.kind==="max")t.data.length>a.value&&(i=this._getOrReturnCtx(t,i),E(i,{code:b.too_big,maximum:a.value,type:"string",inclusive:true,exact:false,message:a.message}),n.dirty());else if(a.kind==="length"){let o=t.data.length>a.value,s=t.data.length<a.value;(o||s)&&(i=this._getOrReturnCtx(t,i),o?E(i,{code:b.too_big,maximum:a.value,type:"string",inclusive:true,exact:true,message:a.message}):s&&E(i,{code:b.too_small,minimum:a.value,type:"string",inclusive:true,exact:true,message:a.message}),n.dirty());}else if(a.kind==="email")Aq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"email",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")rc||(rc=new RegExp(Tq,"u")),rc.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"emoji",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")Eq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"uuid",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")Sq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"nanoid",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")yq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"cuid",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")bq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"cuid2",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")gq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"ulid",code:b.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(t.data);}catch{i=this._getOrReturnCtx(t,i),E(i,{validation:"url",code:b.invalid_string,message:a.message}),n.dirty();}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"regex",code:b.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?t.data=t.data.trim():a.kind==="includes"?t.data.includes(a.value,a.position)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?t.data=t.data.toLowerCase():a.kind==="toUpperCase"?t.data=t.data.toUpperCase():a.kind==="startsWith"?t.data.startsWith(a.value)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?t.data.endsWith(a.value)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?gv(a).test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Nq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Mq(a).test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{code:b.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?wq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"duration",code:b.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?kq(t.data,a.version)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"ip",code:b.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?jq(t.data,a.alg)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"jwt",code:b.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?Lq(t.data,a.version)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"cidr",code:b.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?qq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"base64",code:b.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?Cq.test(t.data)||(i=this._getOrReturnCtx(t,i),E(i,{validation:"base64url",code:b.invalid_string,message:a.message}),n.dirty()):k.assertNever(a);return {status:n.value,value:t.data}}_regex(t,r,n){return this.refinement(i=>t.test(i),{validation:r,code:b.invalid_string,...A.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(t){return this._addCheck({kind:"email",...A.errToObj(t)})}url(t){return this._addCheck({kind:"url",...A.errToObj(t)})}emoji(t){return this._addCheck({kind:"emoji",...A.errToObj(t)})}uuid(t){return this._addCheck({kind:"uuid",...A.errToObj(t)})}nanoid(t){return this._addCheck({kind:"nanoid",...A.errToObj(t)})}cuid(t){return this._addCheck({kind:"cuid",...A.errToObj(t)})}cuid2(t){return this._addCheck({kind:"cuid2",...A.errToObj(t)})}ulid(t){return this._addCheck({kind:"ulid",...A.errToObj(t)})}base64(t){return this._addCheck({kind:"base64",...A.errToObj(t)})}base64url(t){return this._addCheck({kind:"base64url",...A.errToObj(t)})}jwt(t){return this._addCheck({kind:"jwt",...A.errToObj(t)})}ip(t){return this._addCheck({kind:"ip",...A.errToObj(t)})}cidr(t){return this._addCheck({kind:"cidr",...A.errToObj(t)})}datetime(t){return typeof t=="string"?this._addCheck({kind:"datetime",precision:null,offset:false,local:false,message:t}):this._addCheck({kind:"datetime",precision:typeof t?.precision>"u"?null:t?.precision,offset:t?.offset??false,local:t?.local??false,...A.errToObj(t?.message)})}date(t){return this._addCheck({kind:"date",message:t})}time(t){return typeof t=="string"?this._addCheck({kind:"time",precision:null,message:t}):this._addCheck({kind:"time",precision:typeof t?.precision>"u"?null:t?.precision,...A.errToObj(t?.message)})}duration(t){return this._addCheck({kind:"duration",...A.errToObj(t)})}regex(t,r){return this._addCheck({kind:"regex",regex:t,...A.errToObj(r)})}includes(t,r){return this._addCheck({kind:"includes",value:t,position:r?.position,...A.errToObj(r?.message)})}startsWith(t,r){return this._addCheck({kind:"startsWith",value:t,...A.errToObj(r)})}endsWith(t,r){return this._addCheck({kind:"endsWith",value:t,...A.errToObj(r)})}min(t,r){return this._addCheck({kind:"min",value:t,...A.errToObj(r)})}max(t,r){return this._addCheck({kind:"max",value:t,...A.errToObj(r)})}length(t,r){return this._addCheck({kind:"length",value:t,...A.errToObj(r)})}nonempty(t){return this.min(1,A.errToObj(t))}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(t=>t.kind==="datetime")}get isDate(){return !!this._def.checks.find(t=>t.kind==="date")}get isTime(){return !!this._def.checks.find(t=>t.kind==="time")}get isDuration(){return !!this._def.checks.find(t=>t.kind==="duration")}get isEmail(){return !!this._def.checks.find(t=>t.kind==="email")}get isURL(){return !!this._def.checks.find(t=>t.kind==="url")}get isEmoji(){return !!this._def.checks.find(t=>t.kind==="emoji")}get isUUID(){return !!this._def.checks.find(t=>t.kind==="uuid")}get isNANOID(){return !!this._def.checks.find(t=>t.kind==="nanoid")}get isCUID(){return !!this._def.checks.find(t=>t.kind==="cuid")}get isCUID2(){return !!this._def.checks.find(t=>t.kind==="cuid2")}get isULID(){return !!this._def.checks.find(t=>t.kind==="ulid")}get isIP(){return !!this._def.checks.find(t=>t.kind==="ip")}get isCIDR(){return !!this._def.checks.find(t=>t.kind==="cidr")}get isBase64(){return !!this._def.checks.find(t=>t.kind==="base64")}get isBase64url(){return !!this._def.checks.find(t=>t.kind==="base64url")}get minLength(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxLength(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};pt.create=e=>new pt({checks:[],typeName:q.ZodString,coerce:e?.coerce??false,...N(e)});function Fq(e,t){let r=(e.toString().split(".")[1]||"").length,n=(t.toString().split(".")[1]||"").length,i=r>n?r:n,a=Number.parseInt(e.toFixed(i).replace(".","")),o=Number.parseInt(t.toFixed(i).replace(".",""));return a%o/10**i}var Rt=class e extends M{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf;}_parse(t){if(this._def.coerce&&(t.data=Number(t.data)),this._getType(t)!==O.number){let a=this._getOrReturnCtx(t);return E(a,{code:b.invalid_type,expected:O.number,received:a.parsedType}),P}let n,i=new Z;for(let a of this._def.checks)a.kind==="int"?k.isInteger(t.data)||(n=this._getOrReturnCtx(t,n),E(n,{code:b.invalid_type,expected:"integer",received:"float",message:a.message}),i.dirty()):a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:false,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:false,message:a.message}),i.dirty()):a.kind==="multipleOf"?Fq(t.data,a.value)!==0&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):a.kind==="finite"?Number.isFinite(t.data)||(n=this._getOrReturnCtx(t,n),E(n,{code:b.not_finite,message:a.message}),i.dirty()):k.assertNever(a);return {status:i.value,value:t.data}}gte(t,r){return this.setLimit("min",t,true,A.toString(r))}gt(t,r){return this.setLimit("min",t,false,A.toString(r))}lte(t,r){return this.setLimit("max",t,true,A.toString(r))}lt(t,r){return this.setLimit("max",t,false,A.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:A.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(t){return this._addCheck({kind:"int",message:A.toString(t)})}positive(t){return this._addCheck({kind:"min",value:0,inclusive:false,message:A.toString(t)})}negative(t){return this._addCheck({kind:"max",value:0,inclusive:false,message:A.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:0,inclusive:true,message:A.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:0,inclusive:true,message:A.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:A.toString(r)})}finite(t){return this._addCheck({kind:"finite",message:A.toString(t)})}safe(t){return this._addCheck({kind:"min",inclusive:true,value:Number.MIN_SAFE_INTEGER,message:A.toString(t)})._addCheck({kind:"max",inclusive:true,value:Number.MAX_SAFE_INTEGER,message:A.toString(t)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}get isInt(){return !!this._def.checks.find(t=>t.kind==="int"||t.kind==="multipleOf"&&k.isInteger(t.value))}get isFinite(){let t=null,r=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return true;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(t===null||n.value<t)&&(t=n.value);}return Number.isFinite(r)&&Number.isFinite(t)}};Rt.create=e=>new Rt({checks:[],typeName:q.ZodNumber,coerce:e?.coerce||false,...N(e)});var Pt=class e extends M{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte;}_parse(t){if(this._def.coerce)try{t.data=BigInt(t.data);}catch{return this._getInvalidInput(t)}if(this._getType(t)!==O.bigint)return this._getInvalidInput(t);let n,i=new Z;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?t.data<a.value:t.data<=a.value)&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="max"?(a.inclusive?t.data>a.value:t.data>=a.value)&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),i.dirty()):a.kind==="multipleOf"?t.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(t,n),E(n,{code:b.not_multiple_of,multipleOf:a.value,message:a.message}),i.dirty()):k.assertNever(a);return {status:i.value,value:t.data}}_getInvalidInput(t){let r=this._getOrReturnCtx(t);return E(r,{code:b.invalid_type,expected:O.bigint,received:r.parsedType}),P}gte(t,r){return this.setLimit("min",t,true,A.toString(r))}gt(t,r){return this.setLimit("min",t,false,A.toString(r))}lte(t,r){return this.setLimit("max",t,true,A.toString(r))}lt(t,r){return this.setLimit("max",t,false,A.toString(r))}setLimit(t,r,n,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:r,inclusive:n,message:A.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:false,message:A.toString(t)})}negative(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:false,message:A.toString(t)})}nonpositive(t){return this._addCheck({kind:"max",value:BigInt(0),inclusive:true,message:A.toString(t)})}nonnegative(t){return this._addCheck({kind:"min",value:BigInt(0),inclusive:true,message:A.toString(t)})}multipleOf(t,r){return this._addCheck({kind:"multipleOf",value:t,message:A.toString(r)})}get minValue(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t}get maxValue(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t}};Pt.create=e=>new Pt({checks:[],typeName:q.ZodBigInt,coerce:e?.coerce??false,...N(e)});var qt=class extends M{_parse(t){if(this._def.coerce&&(t.data=!!t.data),this._getType(t)!==O.boolean){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.boolean,received:n.parsedType}),P}return te(t.data)}};qt.create=e=>new qt({typeName:q.ZodBoolean,coerce:e?.coerce||false,...N(e)});var Ct=class e extends M{_parse(t){if(this._def.coerce&&(t.data=new Date(t.data)),this._getType(t)!==O.date){let a=this._getOrReturnCtx(t);return E(a,{code:b.invalid_type,expected:O.date,received:a.parsedType}),P}if(Number.isNaN(t.data.getTime())){let a=this._getOrReturnCtx(t);return E(a,{code:b.invalid_date}),P}let n=new Z,i;for(let a of this._def.checks)a.kind==="min"?t.data.getTime()<a.value&&(i=this._getOrReturnCtx(t,i),E(i,{code:b.too_small,message:a.message,inclusive:true,exact:false,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?t.data.getTime()>a.value&&(i=this._getOrReturnCtx(t,i),E(i,{code:b.too_big,message:a.message,inclusive:true,exact:false,maximum:a.value,type:"date"}),n.dirty()):k.assertNever(a);return {status:n.value,value:new Date(t.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(t,r){return this._addCheck({kind:"min",value:t.getTime(),message:A.toString(r)})}max(t,r){return this._addCheck({kind:"max",value:t.getTime(),message:A.toString(r)})}get minDate(){let t=null;for(let r of this._def.checks)r.kind==="min"&&(t===null||r.value>t)&&(t=r.value);return t!=null?new Date(t):null}get maxDate(){let t=null;for(let r of this._def.checks)r.kind==="max"&&(t===null||r.value<t)&&(t=r.value);return t!=null?new Date(t):null}};Ct.create=e=>new Ct({checks:[],coerce:e?.coerce||false,typeName:q.ZodDate,...N(e)});var Cr=class extends M{_parse(t){if(this._getType(t)!==O.symbol){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.symbol,received:n.parsedType}),P}return te(t.data)}};Cr.create=e=>new Cr({typeName:q.ZodSymbol,...N(e)});var Nt=class extends M{_parse(t){if(this._getType(t)!==O.undefined){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.undefined,received:n.parsedType}),P}return te(t.data)}};Nt.create=e=>new Nt({typeName:q.ZodUndefined,...N(e)});var Mt=class extends M{_parse(t){if(this._getType(t)!==O.null){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.null,received:n.parsedType}),P}return te(t.data)}};Mt.create=e=>new Mt({typeName:q.ZodNull,...N(e)});var vt=class extends M{constructor(){super(...arguments),this._any=true;}_parse(t){return te(t.data)}};vt.create=e=>new vt({typeName:q.ZodAny,...N(e)});var Ue=class extends M{constructor(){super(...arguments),this._unknown=true;}_parse(t){return te(t.data)}};Ue.create=e=>new Ue({typeName:q.ZodUnknown,...N(e)});var be=class extends M{_parse(t){let r=this._getOrReturnCtx(t);return E(r,{code:b.invalid_type,expected:O.never,received:r.parsedType}),P}};be.create=e=>new be({typeName:q.ZodNever,...N(e)});var Nr=class extends M{_parse(t){if(this._getType(t)!==O.undefined){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.void,received:n.parsedType}),P}return te(t.data)}};Nr.create=e=>new Nr({typeName:q.ZodVoid,...N(e)});var Ve=class e extends M{_parse(t){let{ctx:r,status:n}=this._processInputParams(t),i=this._def;if(r.parsedType!==O.array)return E(r,{code:b.invalid_type,expected:O.array,received:r.parsedType}),P;if(i.exactLength!==null){let o=r.data.length>i.exactLength.value,s=r.data.length<i.exactLength.value;(o||s)&&(E(r,{code:o?b.too_big:b.too_small,minimum:s?i.exactLength.value:void 0,maximum:o?i.exactLength.value:void 0,type:"array",inclusive:true,exact:true,message:i.exactLength.message}),n.dirty());}if(i.minLength!==null&&r.data.length<i.minLength.value&&(E(r,{code:b.too_small,minimum:i.minLength.value,type:"array",inclusive:true,exact:false,message:i.minLength.message}),n.dirty()),i.maxLength!==null&&r.data.length>i.maxLength.value&&(E(r,{code:b.too_big,maximum:i.maxLength.value,type:"array",inclusive:true,exact:false,message:i.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((o,s)=>i.type._parseAsync(new pe(r,o,r.path,s)))).then(o=>Z.mergeArray(n,o));let a=[...r.data].map((o,s)=>i.type._parseSync(new pe(r,o,r.path,s)));return Z.mergeArray(n,a)}get element(){return this._def.type}min(t,r){return new e({...this._def,minLength:{value:t,message:A.toString(r)}})}max(t,r){return new e({...this._def,maxLength:{value:t,message:A.toString(r)}})}length(t,r){return new e({...this._def,exactLength:{value:t,message:A.toString(r)}})}nonempty(t){return this.min(1,t)}};Ve.create=(e,t)=>new Ve({type:e,minLength:null,maxLength:null,exactLength:null,typeName:q.ZodArray,...N(t)});function qr(e){if(e instanceof se){let t={};for(let r in e.shape){let n=e.shape[r];t[r]=de.create(qr(n));}return new se({...e._def,shape:()=>t})}else return e instanceof Ve?new Ve({...e._def,type:qr(e.element)}):e instanceof de?de.create(qr(e.unwrap())):e instanceof Pe?Pe.create(qr(e.unwrap())):e instanceof Re?Re.create(e.items.map(t=>qr(t))):e}var se=class e extends M{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend;}_getCached(){if(this._cached!==null)return this._cached;let t=this._def.shape(),r=k.objectKeys(t);return this._cached={shape:t,keys:r},this._cached}_parse(t){if(this._getType(t)!==O.object){let c=this._getOrReturnCtx(t);return E(c,{code:b.invalid_type,expected:O.object,received:c.parsedType}),P}let{status:n,ctx:i}=this._processInputParams(t),{shape:a,keys:o}=this._getCached(),s=[];if(!(this._def.catchall instanceof be&&this._def.unknownKeys==="strip"))for(let c in i.data)o.includes(c)||s.push(c);let u=[];for(let c of o){let f=a[c],v=i.data[c];u.push({key:{status:"valid",value:c},value:f._parse(new pe(i,v,i.path,c)),alwaysSet:c in i.data});}if(this._def.catchall instanceof be){let c=this._def.unknownKeys;if(c==="passthrough")for(let f of s)u.push({key:{status:"valid",value:f},value:{status:"valid",value:i.data[f]}});else if(c==="strict")s.length>0&&(E(i,{code:b.unrecognized_keys,keys:s}),n.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else {let c=this._def.catchall;for(let f of s){let v=i.data[f];u.push({key:{status:"valid",value:f},value:c._parse(new pe(i,v,i.path,f)),alwaysSet:f in i.data});}}return i.common.async?Promise.resolve().then(async()=>{let c=[];for(let f of u){let v=await f.key,h=await f.value;c.push({key:v,value:h,alwaysSet:f.alwaysSet});}return c}).then(c=>Z.mergeObjectSync(n,c)):Z.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(t){return A.errToObj,new e({...this._def,unknownKeys:"strict",...t!==void 0?{errorMap:(r,n)=>{let i=this._def.errorMap?.(r,n).message??n.defaultError;return r.code==="unrecognized_keys"?{message:A.errToObj(t).message??i}:{message:i}}}:{}})}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:q.ZodObject})}setKey(t,r){return this.augment({[t]:r})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let r={};for(let n of k.objectKeys(t))t[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}omit(t){let r={};for(let n of k.objectKeys(this.shape))t[n]||(r[n]=this.shape[n]);return new e({...this._def,shape:()=>r})}deepPartial(){return qr(this)}partial(t){let r={};for(let n of k.objectKeys(this.shape)){let i=this.shape[n];t&&!t[n]?r[n]=i:r[n]=i.optional();}return new e({...this._def,shape:()=>r})}required(t){let r={};for(let n of k.objectKeys(this.shape))if(t&&!t[n])r[n]=this.shape[n];else {let a=this.shape[n];for(;a instanceof de;)a=a._def.innerType;r[n]=a;}return new e({...this._def,shape:()=>r})}keyof(){return Ev(k.objectKeys(this.shape))}};se.create=(e,t)=>new se({shape:()=>e,unknownKeys:"strip",catchall:be.create(),typeName:q.ZodObject,...N(t)});se.strictCreate=(e,t)=>new se({shape:()=>e,unknownKeys:"strict",catchall:be.create(),typeName:q.ZodObject,...N(t)});se.lazycreate=(e,t)=>new se({shape:e,unknownKeys:"strip",catchall:be.create(),typeName:q.ZodObject,...N(t)});var kt=class extends M{_parse(t){let{ctx:r}=this._processInputParams(t),n=this._def.options;function i(a){for(let s of a)if(s.result.status==="valid")return s.result;for(let s of a)if(s.result.status==="dirty")return r.common.issues.push(...s.ctx.common.issues),s.result;let o=a.map(s=>new oe(s.ctx.common.issues));return E(r,{code:b.invalid_union,unionErrors:o}),P}if(r.common.async)return Promise.all(n.map(async a=>{let o={...r,common:{...r.common,issues:[]},parent:null};return {result:await a._parseAsync({data:r.data,path:r.path,parent:o}),ctx:o}})).then(i);{let a,o=[];for(let u of n){let c={...r,common:{...r.common,issues:[]},parent:null},f=u._parseSync({data:r.data,path:r.path,parent:c});if(f.status==="valid")return f;f.status==="dirty"&&!a&&(a={result:f,ctx:c}),c.common.issues.length&&o.push(c.common.issues);}if(a)return r.common.issues.push(...a.ctx.common.issues),a.result;let s=o.map(u=>new oe(u));return E(r,{code:b.invalid_union,unionErrors:s}),P}}get options(){return this._def.options}};kt.create=(e,t)=>new kt({options:e,typeName:q.ZodUnion,...N(t)});var De=e=>e instanceof Lt?De(e.schema):e instanceof ve?De(e.innerType()):e instanceof Ft?[e.value]:e instanceof Dt?e.options:e instanceof Ut?k.objectValues(e.enum):e instanceof Vt?De(e._def.innerType):e instanceof Nt?[void 0]:e instanceof Mt?[null]:e instanceof de?[void 0,...De(e.unwrap())]:e instanceof Pe?[null,...De(e.unwrap())]:e instanceof sn||e instanceof Gt?De(e.unwrap()):e instanceof Bt?De(e._def.innerType):[],ko=class e extends M{_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==O.object)return E(r,{code:b.invalid_type,expected:O.object,received:r.parsedType}),P;let n=this.discriminator,i=r.data[n],a=this.optionsMap.get(i);return a?r.common.async?a._parseAsync({data:r.data,path:r.path,parent:r}):a._parseSync({data:r.data,path:r.path,parent:r}):(E(r,{code:b.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),P)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,r,n){let i=new Map;for(let a of r){let o=De(a.shape[t]);if(!o.length)throw new Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let s of o){if(i.has(s))throw new Error(`Discriminator property ${String(t)} has duplicate value ${String(s)}`);i.set(s,a);}}return new e({typeName:q.ZodDiscriminatedUnion,discriminator:t,options:r,optionsMap:i,...N(n)})}};function nc(e,t){let r=xe(e),n=xe(t);if(e===t)return {valid:true,data:e};if(r===O.object&&n===O.object){let i=k.objectKeys(t),a=k.objectKeys(e).filter(s=>i.indexOf(s)!==-1),o={...e,...t};for(let s of a){let u=nc(e[s],t[s]);if(!u.valid)return {valid:false};o[s]=u.data;}return {valid:true,data:o}}else if(r===O.array&&n===O.array){if(e.length!==t.length)return {valid:false};let i=[];for(let a=0;a<e.length;a++){let o=e[a],s=t[a],u=nc(o,s);if(!u.valid)return {valid:false};i.push(u.data);}return {valid:true,data:i}}else return r===O.date&&n===O.date&&+e==+t?{valid:true,data:e}:{valid:false}}var jt=class extends M{_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=(a,o)=>{if(No(a)||No(o))return P;let s=nc(a.value,o.value);return s.valid?((Mo(a)||Mo(o))&&r.dirty(),{status:r.value,value:s.data}):(E(n,{code:b.invalid_intersection_types}),P)};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(([a,o])=>i(a,o)):i(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};jt.create=(e,t,r)=>new jt({left:e,right:t,typeName:q.ZodIntersection,...N(r)});var Re=class e extends M{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==O.array)return E(n,{code:b.invalid_type,expected:O.array,received:n.parsedType}),P;if(n.data.length<this._def.items.length)return E(n,{code:b.too_small,minimum:this._def.items.length,inclusive:true,exact:false,type:"array"}),P;!this._def.rest&&n.data.length>this._def.items.length&&(E(n,{code:b.too_big,maximum:this._def.items.length,inclusive:true,exact:false,type:"array"}),r.dirty());let a=[...n.data].map((o,s)=>{let u=this._def.items[s]||this._def.rest;return u?u._parse(new pe(n,o,n.path,s)):null}).filter(o=>!!o);return n.common.async?Promise.all(a).then(o=>Z.mergeArray(r,o)):Z.mergeArray(r,a)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Re.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Re({items:e,typeName:q.ZodTuple,rest:null,...N(t)})};var jo=class e extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==O.object)return E(n,{code:b.invalid_type,expected:O.object,received:n.parsedType}),P;let i=[],a=this._def.keyType,o=this._def.valueType;for(let s in n.data)i.push({key:a._parse(new pe(n,s,n.path,s)),value:o._parse(new pe(n,n.data[s],n.path,s)),alwaysSet:s in n.data});return n.common.async?Z.mergeObjectAsync(r,i):Z.mergeObjectSync(r,i)}get element(){return this._def.valueType}static create(t,r,n){return r instanceof M?new e({keyType:t,valueType:r,typeName:q.ZodRecord,...N(n)}):new e({keyType:pt.create(),valueType:t,typeName:q.ZodRecord,...N(r)})}},Mr=class extends M{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==O.map)return E(n,{code:b.invalid_type,expected:O.map,received:n.parsedType}),P;let i=this._def.keyType,a=this._def.valueType,o=[...n.data.entries()].map(([s,u],c)=>({key:i._parse(new pe(n,s,n.path,[c,"key"])),value:a._parse(new pe(n,u,n.path,[c,"value"]))}));if(n.common.async){let s=new Map;return Promise.resolve().then(async()=>{for(let u of o){let c=await u.key,f=await u.value;if(c.status==="aborted"||f.status==="aborted")return P;(c.status==="dirty"||f.status==="dirty")&&r.dirty(),s.set(c.value,f.value);}return {status:r.value,value:s}})}else {let s=new Map;for(let u of o){let c=u.key,f=u.value;if(c.status==="aborted"||f.status==="aborted")return P;(c.status==="dirty"||f.status==="dirty")&&r.dirty(),s.set(c.value,f.value);}return {status:r.value,value:s}}}};Mr.create=(e,t,r)=>new Mr({valueType:t,keyType:e,typeName:q.ZodMap,...N(r)});var kr=class e extends M{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.parsedType!==O.set)return E(n,{code:b.invalid_type,expected:O.set,received:n.parsedType}),P;let i=this._def;i.minSize!==null&&n.data.size<i.minSize.value&&(E(n,{code:b.too_small,minimum:i.minSize.value,type:"set",inclusive:true,exact:false,message:i.minSize.message}),r.dirty()),i.maxSize!==null&&n.data.size>i.maxSize.value&&(E(n,{code:b.too_big,maximum:i.maxSize.value,type:"set",inclusive:true,exact:false,message:i.maxSize.message}),r.dirty());let a=this._def.valueType;function o(u){let c=new Set;for(let f of u){if(f.status==="aborted")return P;f.status==="dirty"&&r.dirty(),c.add(f.value);}return {status:r.value,value:c}}let s=[...n.data.values()].map((u,c)=>a._parse(new pe(n,u,n.path,c)));return n.common.async?Promise.all(s).then(u=>o(u)):o(s)}min(t,r){return new e({...this._def,minSize:{value:t,message:A.toString(r)}})}max(t,r){return new e({...this._def,maxSize:{value:t,message:A.toString(r)}})}size(t,r){return this.min(t,r).max(t,r)}nonempty(t){return this.min(1,t)}};kr.create=(e,t)=>new kr({valueType:e,minSize:null,maxSize:null,typeName:q.ZodSet,...N(t)});var Lo=class e extends M{constructor(){super(...arguments),this.validate=this.implement;}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==O.function)return E(r,{code:b.invalid_type,expected:O.function,received:r.parsedType}),P;function n(s,u){return on({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rr(),Fe].filter(c=>!!c),issueData:{code:b.invalid_arguments,argumentsError:u}})}function i(s,u){return on({data:s,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Rr(),Fe].filter(c=>!!c),issueData:{code:b.invalid_return_type,returnTypeError:u}})}let a={errorMap:r.common.contextualErrorMap},o=r.data;if(this._def.returns instanceof ht){let s=this;return te(async function(...u){let c=new oe([]),f=await s._def.args.parseAsync(u,a).catch(m=>{throw c.addIssue(n(u,m)),c}),v=await Reflect.apply(o,this,f);return await s._def.returns._def.type.parseAsync(v,a).catch(m=>{throw c.addIssue(i(v,m)),c})})}else {let s=this;return te(function(...u){let c=s._def.args.safeParse(u,a);if(!c.success)throw new oe([n(u,c.error)]);let f=Reflect.apply(o,this,c.data),v=s._def.returns.safeParse(f,a);if(!v.success)throw new oe([i(f,v.error)]);return v.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Re.create(t).rest(Ue.create())})}returns(t){return new e({...this._def,returns:t})}implement(t){return this.parse(t)}strictImplement(t){return this.parse(t)}static create(t,r,n){return new e({args:t||Re.create([]).rest(Ue.create()),returns:r||Ue.create(),typeName:q.ZodFunction,...N(n)})}},Lt=class extends M{get schema(){return this._def.getter()}_parse(t){let{ctx:r}=this._processInputParams(t);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}};Lt.create=(e,t)=>new Lt({getter:e,typeName:q.ZodLazy,...N(t)});var Ft=class extends M{_parse(t){if(t.data!==this._def.value){let r=this._getOrReturnCtx(t);return E(r,{received:r.data,code:b.invalid_literal,expected:this._def.value}),P}return {status:"valid",value:t.data}}get value(){return this._def.value}};Ft.create=(e,t)=>new Ft({value:e,typeName:q.ZodLiteral,...N(t)});function Ev(e,t){return new Dt({values:e,typeName:q.ZodEnum,...N(t)})}var Dt=class e extends M{_parse(t){if(typeof t.data!="string"){let r=this._getOrReturnCtx(t),n=this._def.values;return E(r,{expected:k.joinValues(n),received:r.parsedType,code:b.invalid_type}),P}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(t.data)){let r=this._getOrReturnCtx(t),n=this._def.values;return E(r,{received:r.data,code:b.invalid_enum_value,options:n}),P}return te(t.data)}get options(){return this._def.values}get enum(){let t={};for(let r of this._def.values)t[r]=r;return t}get Values(){let t={};for(let r of this._def.values)t[r]=r;return t}get Enum(){let t={};for(let r of this._def.values)t[r]=r;return t}extract(t,r=this._def){return e.create(t,{...this._def,...r})}exclude(t,r=this._def){return e.create(this.options.filter(n=>!t.includes(n)),{...this._def,...r})}};Dt.create=Ev;var Ut=class extends M{_parse(t){let r=k.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(t);if(n.parsedType!==O.string&&n.parsedType!==O.number){let i=k.objectValues(r);return E(n,{expected:k.joinValues(i),received:n.parsedType,code:b.invalid_type}),P}if(this._cache||(this._cache=new Set(k.getValidEnumValues(this._def.values))),!this._cache.has(t.data)){let i=k.objectValues(r);return E(n,{received:n.data,code:b.invalid_enum_value,options:i}),P}return te(t.data)}get enum(){return this._def.values}};Ut.create=(e,t)=>new Ut({values:e,typeName:q.ZodNativeEnum,...N(t)});var ht=class extends M{unwrap(){return this._def.type}_parse(t){let{ctx:r}=this._processInputParams(t);if(r.parsedType!==O.promise&&r.common.async===false)return E(r,{code:b.invalid_type,expected:O.promise,received:r.parsedType}),P;let n=r.parsedType===O.promise?r.data:Promise.resolve(r.data);return te(n.then(i=>this._def.type.parseAsync(i,{path:r.path,errorMap:r.common.contextualErrorMap})))}};ht.create=(e,t)=>new ht({type:e,typeName:q.ZodPromise,...N(t)});var ve=class extends M{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(t){let{status:r,ctx:n}=this._processInputParams(t),i=this._def.effect||null,a={addIssue:o=>{E(n,o),o.fatal?r.abort():r.dirty();},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),i.type==="preprocess"){let o=i.transform(n.data,a);if(n.common.async)return Promise.resolve(o).then(async s=>{if(r.value==="aborted")return P;let u=await this._def.schema._parseAsync({data:s,path:n.path,parent:n});return u.status==="aborted"?P:u.status==="dirty"?xt(u.value):r.value==="dirty"?xt(u.value):u});{if(r.value==="aborted")return P;let s=this._def.schema._parseSync({data:o,path:n.path,parent:n});return s.status==="aborted"?P:s.status==="dirty"?xt(s.value):r.value==="dirty"?xt(s.value):s}}if(i.type==="refinement"){let o=s=>{let u=i.refinement(s,a);if(n.common.async)return Promise.resolve(u);if(u instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return s};if(n.common.async===false){let s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?P:(s.status==="dirty"&&r.dirty(),o(s.value),{status:r.value,value:s.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>s.status==="aborted"?P:(s.status==="dirty"&&r.dirty(),o(s.value).then(()=>({status:r.value,value:s.value}))))}if(i.type==="transform")if(n.common.async===false){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!dt(o))return P;let s=i.transform(o.value,a);if(s instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return {status:r.value,value:s}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>dt(o)?Promise.resolve(i.transform(o.value,a)).then(s=>({status:r.value,value:s})):P);k.assertNever(i);}};ve.create=(e,t,r)=>new ve({schema:e,typeName:q.ZodEffects,effect:t,...N(r)});ve.createWithPreprocess=(e,t,r)=>new ve({schema:t,effect:{type:"preprocess",transform:e},typeName:q.ZodEffects,...N(r)});var de=class extends M{_parse(t){return this._getType(t)===O.undefined?te(void 0):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};de.create=(e,t)=>new de({innerType:e,typeName:q.ZodOptional,...N(t)});var Pe=class extends M{_parse(t){return this._getType(t)===O.null?te(null):this._def.innerType._parse(t)}unwrap(){return this._def.innerType}};Pe.create=(e,t)=>new Pe({innerType:e,typeName:q.ZodNullable,...N(t)});var Vt=class extends M{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return r.parsedType===O.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}};Vt.create=(e,t)=>new Vt({innerType:e,typeName:q.ZodDefault,defaultValue:typeof t.default=="function"?t.default:()=>t.default,...N(t)});var Bt=class extends M{_parse(t){let{ctx:r}=this._processInputParams(t),n={...r,common:{...r.common,issues:[]}},i=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Pr(i)?i.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new oe(n.common.issues)},input:n.data})})):{status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new oe(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Bt.create=(e,t)=>new Bt({innerType:e,typeName:q.ZodCatch,catchValue:typeof t.catch=="function"?t.catch:()=>t.catch,...N(t)});var jr=class extends M{_parse(t){if(this._getType(t)!==O.nan){let n=this._getOrReturnCtx(t);return E(n,{code:b.invalid_type,expected:O.nan,received:n.parsedType}),P}return {status:"valid",value:t.data}}};jr.create=e=>new jr({typeName:q.ZodNaN,...N(e)});var Dq=Symbol("zod_brand"),sn=class extends M{_parse(t){let{ctx:r}=this._processInputParams(t),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}},un=class e extends M{_parse(t){let{status:r,ctx:n}=this._processInputParams(t);if(n.common.async)return (async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?P:a.status==="dirty"?(r.dirty(),xt(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let i=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?P:i.status==="dirty"?(r.dirty(),{status:"dirty",value:i.value}):this._def.out._parseSync({data:i.value,path:n.path,parent:n})}}static create(t,r){return new e({in:t,out:r,typeName:q.ZodPipeline})}},Gt=class extends M{_parse(t){let r=this._def.innerType._parse(t),n=i=>(dt(i)&&(i.value=Object.freeze(i.value)),i);return Pr(r)?r.then(i=>n(i)):n(r)}unwrap(){return this._def.innerType}};Gt.create=(e,t)=>new Gt({innerType:e,typeName:q.ZodReadonly,...N(t)});function _v(e,t){let r=typeof e=="function"?e(t):typeof e=="string"?{message:e}:e;return typeof r=="string"?{message:r}:r}function Sv(e,t={},r){return e?vt.create().superRefine((n,i)=>{let a=e(n);if(a instanceof Promise)return a.then(o=>{if(!o){let s=_v(t,n),u=s.fatal??r??true;i.addIssue({code:"custom",...s,fatal:u});}});if(!a){let o=_v(t,n),s=o.fatal??r??true;i.addIssue({code:"custom",...o,fatal:s});}}):vt.create()}var Uq={object:se.lazycreate},q;(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";})(q||(q={}));var Vq=(e,t={message:`Input not instance of ${e.name}`})=>Sv(r=>r instanceof e,t),Ov=pt.create,wv=Rt.create,Bq=jr.create,Gq=Pt.create,Av=qt.create,Hq=Ct.create,Wq=Cr.create,$q=Nt.create,zq=Mt.create,Jq=vt.create,Xq=Ue.create,Kq=be.create,Zq=Nr.create,Yq=Ve.create,Qq=se.create,eC=se.strictCreate,tC=kt.create,rC=ko.create,nC=jt.create,iC=Re.create,aC=jo.create,oC=Mr.create,sC=kr.create,uC=Lo.create,cC=Lt.create,lC=Ft.create,fC=Dt.create,dC=Ut.create,pC=ht.create,vC=ve.create,hC=de.create,mC=Pe.create,_C=ve.createWithPreprocess,yC=un.create,bC=()=>Ov().optional(),gC=()=>wv().optional(),EC=()=>Av().optional(),SC={string:e=>pt.create({...e,coerce:true}),number:e=>Rt.create({...e,coerce:true}),boolean:e=>qt.create({...e,coerce:true}),bigint:e=>Pt.create({...e,coerce:true}),date:e=>Ct.create({...e,coerce:true})};var OC=P;var wC=p.object({name:p.string(),arguments:p.string()}),AC=p.object({id:p.string(),type:p.literal("function"),function:wC}),Fo=p.object({id:p.string(),role:p.string(),content:p.string().optional(),name:p.string().optional()}),TC=p.object({type:p.literal("text"),text:p.string()}),Tv=p.object({type:p.literal("binary"),mimeType:p.string(),id:p.string().optional(),url:p.string().optional(),data:p.string().optional(),filename:p.string().optional()}),Iv=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:p.ZodIssueCode.custom,message:"BinaryInputContent requires at least one of id, url, or data.",path:["id"]});};Tv.superRefine((e,t)=>{Iv(e,t);});var IC=p.discriminatedUnion("type",[TC,Tv]),xC=IC.superRefine((e,t)=>{e.type==="binary"&&Iv(e,t);}),RC=Fo.extend({role:p.literal("developer"),content:p.string()}),PC=Fo.extend({role:p.literal("system"),content:p.string()}),qC=Fo.extend({role:p.literal("assistant"),content:p.string().optional(),toolCalls:p.array(AC).optional()}),CC=Fo.extend({role:p.literal("user"),content:p.union([p.string(),p.array(xC)])}),NC=p.object({id:p.string(),content:p.string(),role:p.literal("tool"),toolCallId:p.string(),error:p.string().optional()}),MC=p.object({id:p.string(),role:p.literal("activity"),activityType:p.string(),content:p.record(p.any())}),xv=p.discriminatedUnion("role",[RC,PC,qC,CC,NC,MC]);p.union([p.literal("developer"),p.literal("system"),p.literal("assistant"),p.literal("user"),p.literal("tool"),p.literal("activity")]);var kC=p.object({description:p.string(),value:p.string()}),jC=p.object({name:p.string(),description:p.string(),parameters:p.any()}),cn=p.object({threadId:p.string(),runId:p.string(),parentRunId:p.string().optional(),state:p.any(),messages:p.array(xv),tools:p.array(jC),context:p.array(kC),forwardedProps:p.any()}),LC=p.any();var Rv=p.union([p.literal("developer"),p.literal("system"),p.literal("assistant"),p.literal("user")]),j=(e=>(e.TEXT_MESSAGE_START="TEXT_MESSAGE_START",e.TEXT_MESSAGE_CONTENT="TEXT_MESSAGE_CONTENT",e.TEXT_MESSAGE_END="TEXT_MESSAGE_END",e.TEXT_MESSAGE_CHUNK="TEXT_MESSAGE_CHUNK",e.THINKING_TEXT_MESSAGE_START="THINKING_TEXT_MESSAGE_START",e.THINKING_TEXT_MESSAGE_CONTENT="THINKING_TEXT_MESSAGE_CONTENT",e.THINKING_TEXT_MESSAGE_END="THINKING_TEXT_MESSAGE_END",e.TOOL_CALL_START="TOOL_CALL_START",e.TOOL_CALL_ARGS="TOOL_CALL_ARGS",e.TOOL_CALL_END="TOOL_CALL_END",e.TOOL_CALL_CHUNK="TOOL_CALL_CHUNK",e.TOOL_CALL_RESULT="TOOL_CALL_RESULT",e.THINKING_START="THINKING_START",e.THINKING_END="THINKING_END",e.STATE_SNAPSHOT="STATE_SNAPSHOT",e.STATE_DELTA="STATE_DELTA",e.MESSAGES_SNAPSHOT="MESSAGES_SNAPSHOT",e.ACTIVITY_SNAPSHOT="ACTIVITY_SNAPSHOT",e.ACTIVITY_DELTA="ACTIVITY_DELTA",e.RAW="RAW",e.CUSTOM="CUSTOM",e.RUN_STARTED="RUN_STARTED",e.RUN_FINISHED="RUN_FINISHED",e.RUN_ERROR="RUN_ERROR",e.STEP_STARTED="STEP_STARTED",e.STEP_FINISHED="STEP_FINISHED",e))(j||{}),G=p.object({type:p.nativeEnum(j),timestamp:p.number().optional(),rawEvent:p.any().optional()}),FC=G.extend({type:p.literal("TEXT_MESSAGE_START"),messageId:p.string(),role:Rv.default("assistant")}),Pv=G.extend({type:p.literal("TEXT_MESSAGE_CONTENT"),messageId:p.string(),delta:p.string().refine(e=>e.length>0,"Delta must not be an empty string")}),DC=G.extend({type:p.literal("TEXT_MESSAGE_END"),messageId:p.string()}),UC=G.extend({type:p.literal("TEXT_MESSAGE_CHUNK"),messageId:p.string().optional(),role:Rv.optional(),delta:p.string().optional()}),VC=G.extend({type:p.literal("THINKING_TEXT_MESSAGE_START")}),BC=Pv.omit({messageId:true,type:true}).extend({type:p.literal("THINKING_TEXT_MESSAGE_CONTENT")}),GC=G.extend({type:p.literal("THINKING_TEXT_MESSAGE_END")}),HC=G.extend({type:p.literal("TOOL_CALL_START"),toolCallId:p.string(),toolCallName:p.string(),parentMessageId:p.string().optional()}),WC=G.extend({type:p.literal("TOOL_CALL_ARGS"),toolCallId:p.string(),delta:p.string()}),$C=G.extend({type:p.literal("TOOL_CALL_END"),toolCallId:p.string()}),zC=G.extend({messageId:p.string(),type:p.literal("TOOL_CALL_RESULT"),toolCallId:p.string(),content:p.string(),role:p.literal("tool").optional()}),JC=G.extend({type:p.literal("TOOL_CALL_CHUNK"),toolCallId:p.string().optional(),toolCallName:p.string().optional(),parentMessageId:p.string().optional(),delta:p.string().optional()}),XC=G.extend({type:p.literal("THINKING_START"),title:p.string().optional()}),KC=G.extend({type:p.literal("THINKING_END")}),ZC=G.extend({type:p.literal("STATE_SNAPSHOT"),snapshot:LC}),YC=G.extend({type:p.literal("STATE_DELTA"),delta:p.array(p.any())}),QC=G.extend({type:p.literal("MESSAGES_SNAPSHOT"),messages:p.array(xv)}),eN=G.extend({type:p.literal("ACTIVITY_SNAPSHOT"),messageId:p.string(),activityType:p.string(),content:p.record(p.any()),replace:p.boolean().optional().default(true)}),tN=G.extend({type:p.literal("ACTIVITY_DELTA"),messageId:p.string(),activityType:p.string(),patch:p.array(p.any())}),rN=G.extend({type:p.literal("RAW"),event:p.any(),source:p.string().optional()}),nN=G.extend({type:p.literal("CUSTOM"),name:p.string(),value:p.any()}),iN=G.extend({type:p.literal("RUN_STARTED"),threadId:p.string(),runId:p.string(),parentRunId:p.string().optional(),input:cn.optional()}),aN=G.extend({type:p.literal("RUN_FINISHED"),threadId:p.string(),runId:p.string(),result:p.any().optional()}),oN=G.extend({type:p.literal("RUN_ERROR"),message:p.string(),code:p.string().optional()}),sN=G.extend({type:p.literal("STEP_STARTED"),stepName:p.string()}),uN=G.extend({type:p.literal("STEP_FINISHED"),stepName:p.string()});p.discriminatedUnion("type",[FC,Pv,DC,UC,XC,KC,VC,BC,GC,HC,WC,$C,JC,zC,ZC,YC,QC,eN,tN,rN,nN,iN,aN,oN,sN,uN]);var Y=[];for(let e=0;e<256;++e)Y.push((e+256).toString(16).slice(1));function Cv(e,t=0){return (Y[e[t+0]]+Y[e[t+1]]+Y[e[t+2]]+Y[e[t+3]]+"-"+Y[e[t+4]]+Y[e[t+5]]+"-"+Y[e[t+6]]+Y[e[t+7]]+"-"+Y[e[t+8]]+Y[e[t+9]]+"-"+Y[e[t+10]]+Y[e[t+11]]+Y[e[t+12]]+Y[e[t+13]]+Y[e[t+14]]+Y[e[t+15]]).toLowerCase()}var Uo=new Uint8Array(256),Do=Uo.length;function ic(){return Do>Uo.length-16&&(crypto.randomFillSync(Uo),Do=0),Uo.slice(Do,Do+=16)}var ac={randomUUID:crypto.randomUUID};function fN(e,t,r){if(ac.randomUUID&&!t&&!e)return ac.randomUUID();e=e||{};let n=e.random??e.rng?.()??ic();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[r+i]=n[i];return t}return Cv(n)}var oc=fN;var sc={};Us(sc,{JsonPatchError:()=>W,_areEquals:()=>dn,applyOperation:()=>Ht,applyPatch:()=>Fr,applyReducer:()=>mN,deepClone:()=>vN,getValueByPointer:()=>Wo,validate:()=>Mv,validator:()=>$o});var dN=function(){var e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i;}||function(n,i){for(var a in i)i.hasOwnProperty(a)&&(n[a]=i[a]);},e(t,r)};return function(t,r){e(t,r);function n(){this.constructor=t;}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n);}}(),pN=Object.prototype.hasOwnProperty;function Bo(e,t){return pN.call(e,t)}function Go(e){if(Array.isArray(e)){for(var t=new Array(e.length),r=0;r<t.length;r++)t[r]=""+r;return t}if(Object.keys)return Object.keys(e);var n=[];for(var i in e)Bo(e,i)&&n.push(i);return n}function Q(e){switch(typeof e){case "object":return JSON.parse(JSON.stringify(e));case "undefined":return null;default:return e}}function Ho(e){for(var t=0,r=e.length,n;t<r;){if(n=e.charCodeAt(t),n>=48&&n<=57){t++;continue}return false}return true}function qe(e){return e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function ln(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function Vo(e){if(e===void 0)return true;if(e){if(Array.isArray(e)){for(var t=0,r=e.length;t<r;t++)if(Vo(e[t]))return true}else if(typeof e=="object"){for(var n=Go(e),i=n.length,a=0;a<i;a++)if(Vo(e[n[a]]))return true}}return false}function Nv(e,t){var r=[e];for(var n in t){var i=typeof t[n]=="object"?JSON.stringify(t[n],null,2):t[n];typeof i<"u"&&r.push(n+": "+i);}return r.join(`
|
|
5
|
-
`)}var fn=function(e){dN(t,e);function t(r,n,i,a,o){var s=this.constructor,u=e.call(this,Nv(r,{name:n,index:i,operation:a,tree:o}))||this;return u.name=n,u.index=i,u.operation=a,u.tree=o,Object.setPrototypeOf(u,s.prototype),u.message=Nv(r,{name:n,index:i,operation:a,tree:o}),u}return t}(Error);var W=fn,vN=Q,Lr={add:function(e,t,r){return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){var n=e[t];return delete e[t],{newDocument:r,removed:n}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){var n=Wo(r,this.path);n&&(n=Q(n));var i=Ht(r,{op:"remove",path:this.from}).removed;return Ht(r,{op:"add",path:this.path,value:i}),{newDocument:r,removed:n}},copy:function(e,t,r){var n=Wo(r,this.from);return Ht(r,{op:"add",path:this.path,value:Q(n)}),{newDocument:r}},test:function(e,t,r){return {newDocument:r,test:dn(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},hN={add:function(e,t,r){return Ho(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){var n=e.splice(t,1);return {newDocument:r,removed:n[0]}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:Lr.move,copy:Lr.copy,test:Lr.test,_get:Lr._get};function Wo(e,t){if(t=="")return e;var r={op:"_get",path:t};return Ht(e,r),r.value}function Ht(e,t,r,n,i,a){if(r===void 0&&(r=false),n===void 0&&(n=true),i===void 0&&(i=true),a===void 0&&(a=0),r&&(typeof r=="function"?r(t,0,e,t.path):$o(t,0)),t.path===""){var o={newDocument:e};if(t.op==="add")return o.newDocument=t.value,o;if(t.op==="replace")return o.newDocument=t.value,o.removed=e,o;if(t.op==="move"||t.op==="copy")return o.newDocument=Wo(e,t.from),t.op==="move"&&(o.removed=e),o;if(t.op==="test"){if(o.test=dn(e,t.value),o.test===false)throw new W("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o.newDocument=e,o}else {if(t.op==="remove")return o.removed=e,o.newDocument=null,o;if(t.op==="_get")return t.value=e,o;if(r)throw new W("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",a,t,e);return o}}else {n||(e=Q(e));var s=t.path||"",u=s.split("/"),c=e,f=1,v=u.length,h=void 0,m=void 0,_=void 0;for(typeof r=="function"?_=r:_=$o;;){if(m=u[f],m&&m.indexOf("~")!=-1&&(m=ln(m)),i&&(m=="__proto__"||m=="prototype"&&f>0&&u[f-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&h===void 0&&(c[m]===void 0?h=u.slice(0,f).join("/"):f==v-1&&(h=t.path),h!==void 0&&_(t,0,e,h)),f++,Array.isArray(c)){if(m==="-")m=c.length;else {if(r&&!Ho(m))throw new W("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index","OPERATION_PATH_ILLEGAL_ARRAY_INDEX",a,t,e);Ho(m)&&(m=~~m);}if(f>=v){if(r&&t.op==="add"&&m>c.length)throw new W("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",a,t,e);var o=hN[t.op].call(t,c,m,e);if(o.test===false)throw new W("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o}}else if(f>=v){var o=Lr[t.op].call(t,c,m,e);if(o.test===false)throw new W("Test operation failed","TEST_OPERATION_FAILED",a,t,e);return o}if(c=c[m],r&&f<v&&(!c||typeof c!="object"))throw new W("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",a,t,e)}}}function Fr(e,t,r,n,i){if(n===void 0&&(n=true),i===void 0&&(i=true),r&&!Array.isArray(t))throw new W("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=Q(e));for(var a=new Array(t.length),o=0,s=t.length;o<s;o++)a[o]=Ht(e,t[o],r,true,i,o),e=a[o].newDocument;return a.newDocument=e,a}function mN(e,t,r){var n=Ht(e,t);if(n.test===false)throw new W("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function $o(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new W("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(Lr[e.op]){if(typeof e.path!="string")throw new W("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new W('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new W("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new W("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Vo(e.value))throw new W("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var i=e.path.split("/").length,a=n.split("/").length;if(i!==a+1&&i!==a)throw new W("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new W("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var o={op:"_get",path:e.from,value:void 0},s=Mv([o],r);if(s&&s.name==="OPERATION_PATH_UNRESOLVABLE")throw new W("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new W("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function Mv(e,t,r){try{if(!Array.isArray(e))throw new W("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)Fr(Q(t),Q(e),r||!0);else {r=r||$o;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0);}}catch(i){if(i instanceof W)return i;throw i}}function dn(e,t){if(e===t)return true;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),i,a,o;if(r&&n){if(a=e.length,a!=t.length)return false;for(i=a;i--!==0;)if(!dn(e[i],t[i]))return false;return true}if(r!=n)return false;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return false;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return false;for(i=a;i--!==0;)if(o=s[i],!dn(e[o],t[o]))return false;return true}return e!==e&&t!==t}var fc={};Us(fc,{compare:()=>wN,generate:()=>uc,observe:()=>ON,unobserve:()=>SN});var cc=new WeakMap,_N=function(){function e(t){this.observers=new Map,this.obj=t;}return e}(),yN=function(){function e(t,r){this.callback=t,this.observer=r;}return e}();function bN(e){return cc.get(e)}function gN(e,t){return e.observers.get(t)}function EN(e,t){e.observers.delete(t.callback);}function SN(e,t){t.unobserve();}function ON(e,t){var r=[],n,i=bN(e);if(!i)i=new _N(e),cc.set(e,i);else {var a=gN(i,t);n=a&&a.observer;}if(n)return n;if(n={},i.value=Q(e),t){n.callback=t,n.next=null;var o=function(){uc(n);},s=function(){clearTimeout(n.next),n.next=setTimeout(o);};typeof window<"u"&&(window.addEventListener("mouseup",s),window.addEventListener("keyup",s),window.addEventListener("mousedown",s),window.addEventListener("keydown",s),window.addEventListener("change",s));}return n.patches=r,n.object=e,n.unobserve=function(){uc(n),clearTimeout(n.next),EN(i,n),typeof window<"u"&&(window.removeEventListener("mouseup",s),window.removeEventListener("keyup",s),window.removeEventListener("mousedown",s),window.removeEventListener("keydown",s),window.removeEventListener("change",s));},i.observers.set(t,new yN(t,n)),n}function uc(e,t){t===void 0&&(t=false);var r=cc.get(e.object);lc(r.value,e.object,e.patches,"",t),e.patches.length&&Fr(r.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function lc(e,t,r,n,i){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var a=Go(t),o=Go(e),s=false,u=false,c=o.length-1;c>=0;c--){var f=o[c],v=e[f];if(Bo(t,f)&&!(t[f]===void 0&&v!==void 0&&Array.isArray(t)===false)){var h=t[f];typeof v=="object"&&v!=null&&typeof h=="object"&&h!=null&&Array.isArray(v)===Array.isArray(h)?lc(v,h,r,n+"/"+qe(f),i):v!==h&&(s=true,i&&r.push({op:"test",path:n+"/"+qe(f),value:Q(v)}),r.push({op:"replace",path:n+"/"+qe(f),value:Q(h)}));}else Array.isArray(e)===Array.isArray(t)?(i&&r.push({op:"test",path:n+"/"+qe(f),value:Q(v)}),r.push({op:"remove",path:n+"/"+qe(f)}),u=true):(i&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}),s=true);}if(!(!u&&a.length==o.length))for(var c=0;c<a.length;c++){var f=a[c];!Bo(e,f)&&t[f]!==void 0&&r.push({op:"add",path:n+"/"+qe(f),value:Q(t[f])});}}}function wN(e,t,r){r===void 0&&(r=false);var n=[];return lc(e,t,n,"",r),n}Object.assign({},sc,fc,{JsonPatchError:fn,deepClone:Q,escapePathComponent:qe,unescapePathComponent:ln});function jv(){let e=0,t=0;for(let n=0;n<28;n+=7){let i=this.buf[this.pos++];if(e|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[e,t]}let r=this.buf[this.pos++];if(e|=(r&15)<<28,t=(r&112)>>4,(r&128)==0)return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let i=this.buf[this.pos++];if(t|=(i&127)<<n,(i&128)==0)return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function Jo(e,t,r){for(let a=0;a<28;a=a+7){let o=e>>>a,s=!(!(o>>>7)&&t==0),u=(s?o|128:o)&255;if(r.push(u),!s)return}let n=e>>>28&15|(t&7)<<4,i=t>>3!=0;if(r.push((i?n|128:n)&255),!!i){for(let a=3;a<31;a=a+7){let o=t>>>a,s=!!(o>>>7),u=(s?o|128:o)&255;if(r.push(u),!s)return}r.push(t>>>31&1);}}var zo=4294967296;function dc(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,i=0;function a(o,s){let u=Number(e.slice(o,s));i*=r,n=n*r+u,n>=zo&&(i=i+(n/zo|0),n=n%zo);}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Fv(n,i):vc(n,i)}function Lv(e,t){let r=vc(e,t),n=r.hi&2147483648;n&&(r=Fv(r.lo,r.hi));let i=pc(r.lo,r.hi);return n?"-"+i:i}function pc(e,t){if({lo:e,hi:t}=AN(e,t),t<=2097151)return String(zo*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=r+n*6777216+i*6710656,o=n+i*8147497,s=i*2,u=1e7;return a>=u&&(o+=Math.floor(a/u),a%=u),o>=u&&(s+=Math.floor(o/u),o%=u),s.toString()+kv(o)+kv(a)}function AN(e,t){return {lo:e>>>0,hi:t>>>0}}function vc(e,t){return {lo:e|0,hi:t|0}}function Fv(e,t){return t=~t,e?e=~e+1:t+=1,vc(e,t)}var kv=e=>{let t=String(e);return "0000000".slice(t.length)+t};function hc(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e=e>>>7;t.push(e);}else {for(let r=0;r<9;r++)t.push(e&127|128),e=e>>7;t.push(1);}}function Dv(){let e=this.buf[this.pos++],t=e&127;if((e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)==0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)==0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;(e&128)!==0&&r<10;r++)e=this.buf[this.pos++];if((e&128)!=0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var ge=TN();function TN(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof e.getBigInt64=="function"&&typeof e.getBigUint64=="function"&&typeof e.setBigInt64=="function"&&typeof e.setBigUint64=="function"&&(typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),i=BigInt("0"),a=BigInt("18446744073709551615");return {zero:BigInt(0),supported:true,parse(o){let s=typeof o=="bigint"?o:BigInt(o);if(s>n||s<r)throw new Error(`invalid int64: ${o}`);return s},uParse(o){let s=typeof o=="bigint"?o:BigInt(o);if(s>a||s<i)throw new Error(`invalid uint64: ${o}`);return s},enc(o){return e.setBigInt64(0,this.parse(o),true),{lo:e.getInt32(0,true),hi:e.getInt32(4,true)}},uEnc(o){return e.setBigInt64(0,this.uParse(o),true),{lo:e.getInt32(0,true),hi:e.getInt32(4,true)}},dec(o,s){return e.setInt32(0,o,true),e.setInt32(4,s,true),e.getBigInt64(0,true)},uDec(o,s){return e.setInt32(0,o,true),e.setInt32(4,s,true),e.getBigUint64(0,true)}}}return {zero:"0",supported:false,parse(r){return typeof r!="string"&&(r=r.toString()),Uv(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),Vv(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),Uv(r),dc(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),Vv(r),dc(r)},dec(r,n){return Lv(r,n)},uDec(r,n){return pc(r,n)}}}function Uv(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function Vv(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}var mc=Symbol.for("@bufbuild/protobuf/text-encoding");function _c(){if(globalThis[mc]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[mc]={encodeUtf8(r){return e.encode(r)},decodeUtf8(r){return t.decode(r)},checkUtf8(r){try{return encodeURIComponent(r),!0}catch{return false}}};}return globalThis[mc]}var mt;(function(e){e[e.Varint=0]="Varint",e[e.Bit64=1]="Bit64",e[e.LengthDelimited=2]="LengthDelimited",e[e.StartGroup=3]="StartGroup",e[e.EndGroup=4]="EndGroup",e[e.Bit32=5]="Bit32";})(mt||(mt={}));var IN=34028234663852886e22,xN=-34028234663852886e22,RN=4294967295,PN=2147483647,qN=-2147483648,F=class{constructor(t=_c().encodeUtf8){this.encodeUtf8=t,this.stack=[],this.chunks=[],this.buf=[];}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let t=0;for(let i=0;i<this.chunks.length;i++)t+=this.chunks[i].length;let r=new Uint8Array(t),n=0;for(let i=0;i<this.chunks.length;i++)r.set(this.chunks[i],n),n+=this.chunks[i].length;return this.chunks=[],r}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let t=this.finish(),r=this.stack.pop();if(!r)throw new Error("invalid state, fork stack empty");return this.chunks=r.chunks,this.buf=r.buf,this.uint32(t.byteLength),this.raw(t)}tag(t,r){return this.uint32((t<<3|r)>>>0)}raw(t){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(t),this}uint32(t){for(Bv(t);t>127;)this.buf.push(t&127|128),t=t>>>7;return this.buf.push(t),this}int32(t){return yc(t),hc(t,this.buf),this}bool(t){return this.buf.push(t?1:0),this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){let r=this.encodeUtf8(t);return this.uint32(r.byteLength),this.raw(r)}float(t){CN(t);let r=new Uint8Array(4);return new DataView(r.buffer).setFloat32(0,t,true),this.raw(r)}double(t){let r=new Uint8Array(8);return new DataView(r.buffer).setFloat64(0,t,true),this.raw(r)}fixed32(t){Bv(t);let r=new Uint8Array(4);return new DataView(r.buffer).setUint32(0,t,true),this.raw(r)}sfixed32(t){yc(t);let r=new Uint8Array(4);return new DataView(r.buffer).setInt32(0,t,true),this.raw(r)}sint32(t){return yc(t),t=(t<<1^t>>31)>>>0,hc(t,this.buf),this}sfixed64(t){let r=new Uint8Array(8),n=new DataView(r.buffer),i=ge.enc(t);return n.setInt32(0,i.lo,true),n.setInt32(4,i.hi,true),this.raw(r)}fixed64(t){let r=new Uint8Array(8),n=new DataView(r.buffer),i=ge.uEnc(t);return n.setInt32(0,i.lo,true),n.setInt32(4,i.hi,true),this.raw(r)}int64(t){let r=ge.enc(t);return Jo(r.lo,r.hi,this.buf),this}sint64(t){let r=ge.enc(t),n=r.hi>>31,i=r.lo<<1^n,a=(r.hi<<1|r.lo>>>31)^n;return Jo(i,a,this.buf),this}uint64(t){let r=ge.uEnc(t);return Jo(r.lo,r.hi,this.buf),this}},w=class{constructor(t,r=_c().decodeUtf8){this.decodeUtf8=r,this.varint64=jv,this.uint32=Dv,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength);}tag(){let t=this.uint32(),r=t>>>3,n=t&7;if(r<=0||n<0||n>5)throw new Error("illegal tag: field no "+r+" wire type "+n);return [r,n]}skip(t,r){let n=this.pos;switch(t){case mt.Varint:for(;this.buf[this.pos++]&128;);break;case mt.Bit64:this.pos+=4;case mt.Bit32:this.pos+=4;break;case mt.LengthDelimited:let i=this.uint32();this.pos+=i;break;case mt.StartGroup:for(;;){let[a,o]=this.tag();if(o===mt.EndGroup){if(r!==void 0&&a!==r)throw new Error("invalid end group tag");break}this.skip(o,a);}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return ge.dec(...this.varint64())}uint64(){return ge.uDec(...this.varint64())}sint64(){let[t,r]=this.varint64(),n=-(t&1);return t=(t>>>1|(r&1)<<31)^n,r=r>>>1^n,ge.dec(t,r)}bool(){let[t,r]=this.varint64();return t!==0||r!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,true)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,true)}fixed64(){return ge.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ge.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,true)}double(){return this.view.getFloat64((this.pos+=8)-8,true)}bytes(){let t=this.uint32(),r=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(r,r+t)}string(){return this.decodeUtf8(this.bytes())}};function yc(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>PN||e<qN)throw new Error("invalid int32: "+e)}function Bv(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>RN||e<0)throw new Error("invalid uint32: "+e)}function CN(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>IN||e<xN))throw new Error("invalid float32: "+e)}function bc(){return {fields:{}}}var pn={encode(e,t=new F){return Object.entries(e.fields).forEach(([r,n])=>{n!==void 0&&Sc.encode({key:r,value:n},t.uint32(10).fork()).join();}),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=bc();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;let o=Sc.decode(r,r.uint32());o.value!==void 0&&(i.fields[o.key]=o.value);continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return pn.fromPartial(e??{})},fromPartial(e){var t;let r=bc();return r.fields=Object.entries((t=e.fields)!=null?t:{}).reduce((n,[i,a])=>(a!==void 0&&(n[i]=a),n),{}),r},wrap(e){let t=bc();if(e!==void 0)for(let r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){let t={};if(e.fields)for(let r of Object.keys(e.fields))t[r]=e.fields[r];return t}};function Gv(){return {key:"",value:void 0}}var Sc={encode(e,t=new F){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&D.encode(D.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Gv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.key=r.string();continue}case 2:{if(a!==18)break;i.value=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Sc.fromPartial(e??{})},fromPartial(e){var t,r;let n=Gv();return n.key=(t=e.key)!=null?t:"",n.value=(r=e.value)!=null?r:void 0,n}};function gc(){return {nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var D={encode(e,t=new F){return e.nullValue!==void 0&&t.uint32(8).int32(e.nullValue),e.numberValue!==void 0&&t.uint32(17).double(e.numberValue),e.stringValue!==void 0&&t.uint32(26).string(e.stringValue),e.boolValue!==void 0&&t.uint32(32).bool(e.boolValue),e.structValue!==void 0&&pn.encode(pn.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&vn.encode(vn.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=gc();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==8)break;i.nullValue=r.int32();continue}case 2:{if(a!==17)break;i.numberValue=r.double();continue}case 3:{if(a!==26)break;i.stringValue=r.string();continue}case 4:{if(a!==32)break;i.boolValue=r.bool();continue}case 5:{if(a!==42)break;i.structValue=pn.unwrap(pn.decode(r,r.uint32()));continue}case 6:{if(a!==50)break;i.listValue=vn.unwrap(vn.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return D.fromPartial(e??{})},fromPartial(e){var t,r,n,i,a,o;let s=gc();return s.nullValue=(t=e.nullValue)!=null?t:void 0,s.numberValue=(r=e.numberValue)!=null?r:void 0,s.stringValue=(n=e.stringValue)!=null?n:void 0,s.boolValue=(i=e.boolValue)!=null?i:void 0,s.structValue=(a=e.structValue)!=null?a:void 0,s.listValue=(o=e.listValue)!=null?o:void 0,s},wrap(e){let t=gc();if(e===null)t.nullValue=0;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(globalThis.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new globalThis.Error("Unsupported any value type: "+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function Ec(){return {values:[]}}var vn={encode(e,t=new F){for(let r of e.values)D.encode(D.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Ec();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.values.push(D.unwrap(D.decode(r,r.uint32())));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return vn.fromPartial(e??{})},fromPartial(e){var t;let r=Ec();return r.values=((t=e.values)==null?void 0:t.map(n=>n))||[],r},wrap(e){let t=Ec();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&globalThis.Array.isArray(e.values)?e.values:e}},vh=(e=>(e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(vh||{});function Hv(){return {op:0,path:"",from:void 0,value:void 0}}var Xo={encode(e,t=new F){return e.op!==0&&t.uint32(8).int32(e.op),e.path!==""&&t.uint32(18).string(e.path),e.from!==void 0&&t.uint32(26).string(e.from),e.value!==void 0&&D.encode(D.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Hv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==8)break;i.op=r.int32();continue}case 2:{if(a!==18)break;i.path=r.string();continue}case 3:{if(a!==26)break;i.from=r.string();continue}case 4:{if(a!==34)break;i.value=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Xo.fromPartial(e??{})},fromPartial(e){var t,r,n,i;let a=Hv();return a.op=(t=e.op)!=null?t:0,a.path=(r=e.path)!=null?r:"",a.from=(n=e.from)!=null?n:void 0,a.value=(i=e.value)!=null?i:void 0,a}};function Wv(){return {id:"",type:"",function:void 0}}var Ko={encode(e,t=new F){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&Zo.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Wv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.id=r.string();continue}case 2:{if(a!==18)break;i.type=r.string();continue}case 3:{if(a!==26)break;i.function=Zo.decode(r,r.uint32());continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Ko.fromPartial(e??{})},fromPartial(e){var t,r;let n=Wv();return n.id=(t=e.id)!=null?t:"",n.type=(r=e.type)!=null?r:"",n.function=e.function!==void 0&&e.function!==null?Zo.fromPartial(e.function):void 0,n}};function $v(){return {name:"",arguments:""}}var Zo={encode(e,t=new F){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=$v();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.name=r.string();continue}case 2:{if(a!==18)break;i.arguments=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Zo.fromPartial(e??{})},fromPartial(e){var t,r;let n=$v();return n.name=(t=e.name)!=null?t:"",n.arguments=(r=e.arguments)!=null?r:"",n}};function zv(){return {id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0}}var Yo={encode(e,t=new F){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let r of e.toolCalls)Ko.encode(r,t.uint32(42).fork()).join();return e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=zv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.id=r.string();continue}case 2:{if(a!==18)break;i.role=r.string();continue}case 3:{if(a!==26)break;i.content=r.string();continue}case 4:{if(a!==34)break;i.name=r.string();continue}case 5:{if(a!==42)break;i.toolCalls.push(Ko.decode(r,r.uint32()));continue}case 6:{if(a!==50)break;i.toolCallId=r.string();continue}case 7:{if(a!==58)break;i.error=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Yo.fromPartial(e??{})},fromPartial(e){var t,r,n,i,a,o,s;let u=zv();return u.id=(t=e.id)!=null?t:"",u.role=(r=e.role)!=null?r:"",u.content=(n=e.content)!=null?n:void 0,u.name=(i=e.name)!=null?i:void 0,u.toolCalls=((a=e.toolCalls)==null?void 0:a.map(c=>Ko.fromPartial(c)))||[],u.toolCallId=(o=e.toolCallId)!=null?o:void 0,u.error=(s=e.error)!=null?s:void 0,u}},hh=(e=>(e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e))(hh||{});function Jv(){return {type:0,timestamp:void 0,rawEvent:void 0}}var R={encode(e,t=new F){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&D.encode(D.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Jv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==8)break;i.type=r.int32();continue}case 2:{if(a!==16)break;i.timestamp=NN(r.int64());continue}case 3:{if(a!==26)break;i.rawEvent=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return R.fromPartial(e??{})},fromPartial(e){var t,r,n;let i=Jv();return i.type=(t=e.type)!=null?t:0,i.timestamp=(r=e.timestamp)!=null?r:void 0,i.rawEvent=(n=e.rawEvent)!=null?n:void 0,i}};function Xv(){return {baseEvent:void 0,messageId:"",role:void 0}}var Qo={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Xv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.messageId=r.string();continue}case 3:{if(a!==26)break;i.role=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return Qo.fromPartial(e??{})},fromPartial(e){var t,r;let n=Xv();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.messageId=(t=e.messageId)!=null?t:"",n.role=(r=e.role)!=null?r:void 0,n}};function Kv(){return {baseEvent:void 0,messageId:"",delta:""}}var es={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Kv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.messageId=r.string();continue}case 3:{if(a!==26)break;i.delta=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return es.fromPartial(e??{})},fromPartial(e){var t,r;let n=Kv();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.messageId=(t=e.messageId)!=null?t:"",n.delta=(r=e.delta)!=null?r:"",n}};function Zv(){return {baseEvent:void 0,messageId:""}}var ts={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Zv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.messageId=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ts.fromPartial(e??{})},fromPartial(e){var t;let r=Zv();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.messageId=(t=e.messageId)!=null?t:"",r}};function Yv(){return {baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var rs={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Yv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.toolCallId=r.string();continue}case 3:{if(a!==26)break;i.toolCallName=r.string();continue}case 4:{if(a!==34)break;i.parentMessageId=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return rs.fromPartial(e??{})},fromPartial(e){var t,r,n;let i=Yv();return i.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,i.toolCallId=(t=e.toolCallId)!=null?t:"",i.toolCallName=(r=e.toolCallName)!=null?r:"",i.parentMessageId=(n=e.parentMessageId)!=null?n:void 0,i}};function Qv(){return {baseEvent:void 0,toolCallId:"",delta:""}}var ns={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=Qv();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.toolCallId=r.string();continue}case 3:{if(a!==26)break;i.delta=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ns.fromPartial(e??{})},fromPartial(e){var t,r;let n=Qv();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.toolCallId=(t=e.toolCallId)!=null?t:"",n.delta=(r=e.delta)!=null?r:"",n}};function eh(){return {baseEvent:void 0,toolCallId:""}}var is={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=eh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.toolCallId=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return is.fromPartial(e??{})},fromPartial(e){var t;let r=eh();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.toolCallId=(t=e.toolCallId)!=null?t:"",r}};function th(){return {baseEvent:void 0,snapshot:void 0}}var as={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&D.encode(D.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=th();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.snapshot=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return as.fromPartial(e??{})},fromPartial(e){var t;let r=th();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.snapshot=(t=e.snapshot)!=null?t:void 0,r}};function rh(){return {baseEvent:void 0,delta:[]}}var os={encode(e,t=new F){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.delta)Xo.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=rh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.delta.push(Xo.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return os.fromPartial(e??{})},fromPartial(e){var t;let r=rh();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.delta=((t=e.delta)==null?void 0:t.map(n=>Xo.fromPartial(n)))||[],r}};function nh(){return {baseEvent:void 0,messages:[]}}var ss={encode(e,t=new F){e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.messages)Yo.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=nh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.messages.push(Yo.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ss.fromPartial(e??{})},fromPartial(e){var t;let r=nh();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.messages=((t=e.messages)==null?void 0:t.map(n=>Yo.fromPartial(n)))||[],r}};function ih(){return {baseEvent:void 0,event:void 0,source:void 0}}var us={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&D.encode(D.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=ih();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.event=D.unwrap(D.decode(r,r.uint32()));continue}case 3:{if(a!==26)break;i.source=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return us.fromPartial(e??{})},fromPartial(e){var t,r;let n=ih();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.event=(t=e.event)!=null?t:void 0,n.source=(r=e.source)!=null?r:void 0,n}};function ah(){return {baseEvent:void 0,name:"",value:void 0}}var cs={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&D.encode(D.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=ah();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.name=r.string();continue}case 3:{if(a!==26)break;i.value=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return cs.fromPartial(e??{})},fromPartial(e){var t,r;let n=ah();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.name=(t=e.name)!=null?t:"",n.value=(r=e.value)!=null?r:void 0,n}};function oh(){return {baseEvent:void 0,threadId:"",runId:""}}var ls={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=oh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.threadId=r.string();continue}case 3:{if(a!==26)break;i.runId=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ls.fromPartial(e??{})},fromPartial(e){var t,r;let n=oh();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.threadId=(t=e.threadId)!=null?t:"",n.runId=(r=e.runId)!=null?r:"",n}};function sh(){return {baseEvent:void 0,threadId:"",runId:"",result:void 0}}var fs={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),e.result!==void 0&&D.encode(D.wrap(e.result),t.uint32(34).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=sh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.threadId=r.string();continue}case 3:{if(a!==26)break;i.runId=r.string();continue}case 4:{if(a!==34)break;i.result=D.unwrap(D.decode(r,r.uint32()));continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return fs.fromPartial(e??{})},fromPartial(e){var t,r,n;let i=sh();return i.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,i.threadId=(t=e.threadId)!=null?t:"",i.runId=(r=e.runId)!=null?r:"",i.result=(n=e.result)!=null?n:void 0,i}};function uh(){return {baseEvent:void 0,code:void 0,message:""}}var ds={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=uh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.code=r.string();continue}case 3:{if(a!==26)break;i.message=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ds.fromPartial(e??{})},fromPartial(e){var t,r;let n=uh();return n.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,n.code=(t=e.code)!=null?t:void 0,n.message=(r=e.message)!=null?r:"",n}};function ch(){return {baseEvent:void 0,stepName:""}}var ps={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=ch();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.stepName=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ps.fromPartial(e??{})},fromPartial(e){var t;let r=ch();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.stepName=(t=e.stepName)!=null?t:"",r}};function lh(){return {baseEvent:void 0,stepName:""}}var vs={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=lh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.stepName=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return vs.fromPartial(e??{})},fromPartial(e){var t;let r=lh();return r.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,r.stepName=(t=e.stepName)!=null?t:"",r}};function fh(){return {baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0}}var hs={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=fh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.messageId=r.string();continue}case 3:{if(a!==26)break;i.role=r.string();continue}case 4:{if(a!==34)break;i.delta=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return hs.fromPartial(e??{})},fromPartial(e){var t,r,n;let i=fh();return i.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,i.messageId=(t=e.messageId)!=null?t:void 0,i.role=(r=e.role)!=null?r:void 0,i.delta=(n=e.delta)!=null?n:void 0,i}};function dh(){return {baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var ms={encode(e,t=new F){return e.baseEvent!==void 0&&R.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=dh();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.baseEvent=R.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.toolCallId=r.string();continue}case 3:{if(a!==26)break;i.toolCallName=r.string();continue}case 4:{if(a!==34)break;i.parentMessageId=r.string();continue}case 5:{if(a!==42)break;i.delta=r.string();continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return ms.fromPartial(e??{})},fromPartial(e){var t,r,n,i;let a=dh();return a.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?R.fromPartial(e.baseEvent):void 0,a.toolCallId=(t=e.toolCallId)!=null?t:void 0,a.toolCallName=(r=e.toolCallName)!=null?r:void 0,a.parentMessageId=(n=e.parentMessageId)!=null?n:void 0,a.delta=(i=e.delta)!=null?i:void 0,a}};function ph(){return {textMessageStart:void 0,textMessageContent:void 0,textMessageEnd:void 0,toolCallStart:void 0,toolCallArgs:void 0,toolCallEnd:void 0,stateSnapshot:void 0,stateDelta:void 0,messagesSnapshot:void 0,raw:void 0,custom:void 0,runStarted:void 0,runFinished:void 0,runError:void 0,stepStarted:void 0,stepFinished:void 0,textMessageChunk:void 0,toolCallChunk:void 0}}var mh={encode(e,t=new F){return e.textMessageStart!==void 0&&Qo.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&es.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&ts.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&rs.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&ns.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&is.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&as.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&os.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&ss.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&us.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&cs.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&ls.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&fs.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&ds.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&ps.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&vs.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&hs.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&ms.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let r=e instanceof w?e:new w(e),n=t===void 0?r.len:r.pos+t,i=ph();for(;r.pos<n;){let a=r.uint32();switch(a>>>3){case 1:{if(a!==10)break;i.textMessageStart=Qo.decode(r,r.uint32());continue}case 2:{if(a!==18)break;i.textMessageContent=es.decode(r,r.uint32());continue}case 3:{if(a!==26)break;i.textMessageEnd=ts.decode(r,r.uint32());continue}case 4:{if(a!==34)break;i.toolCallStart=rs.decode(r,r.uint32());continue}case 5:{if(a!==42)break;i.toolCallArgs=ns.decode(r,r.uint32());continue}case 6:{if(a!==50)break;i.toolCallEnd=is.decode(r,r.uint32());continue}case 7:{if(a!==58)break;i.stateSnapshot=as.decode(r,r.uint32());continue}case 8:{if(a!==66)break;i.stateDelta=os.decode(r,r.uint32());continue}case 9:{if(a!==74)break;i.messagesSnapshot=ss.decode(r,r.uint32());continue}case 10:{if(a!==82)break;i.raw=us.decode(r,r.uint32());continue}case 11:{if(a!==90)break;i.custom=cs.decode(r,r.uint32());continue}case 12:{if(a!==98)break;i.runStarted=ls.decode(r,r.uint32());continue}case 13:{if(a!==106)break;i.runFinished=fs.decode(r,r.uint32());continue}case 14:{if(a!==114)break;i.runError=ds.decode(r,r.uint32());continue}case 15:{if(a!==122)break;i.stepStarted=ps.decode(r,r.uint32());continue}case 16:{if(a!==130)break;i.stepFinished=vs.decode(r,r.uint32());continue}case 17:{if(a!==138)break;i.textMessageChunk=hs.decode(r,r.uint32());continue}case 18:{if(a!==146)break;i.toolCallChunk=ms.decode(r,r.uint32());continue}}if((a&7)===4||a===0)break;r.skip(a&7);}return i},create(e){return mh.fromPartial(e??{})},fromPartial(e){let t=ph();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Qo.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?es.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?ts.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?rs.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?ns.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?is.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?as.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?os.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?ss.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?us.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?cs.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?ls.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?fs.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?ds.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?ps.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?vs.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?hs.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?ms.fromPartial(e.toolCallChunk):void 0,t}};function NN(e){let t=globalThis.Number(e.toString());if(t>globalThis.Number.MAX_SAFE_INTEGER)throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<globalThis.Number.MIN_SAFE_INTEGER)throw new globalThis.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}function MN(e){return e.toLowerCase().replace(/_([a-z])/g,(t,r)=>r.toUpperCase())}function _h(e){let t=MN(e.type),{type:r,timestamp:n,rawEvent:i,...a}=e;r===j.MESSAGES_SNAPSHOT&&(a.messages=a.messages.map(s=>s.toolCalls===void 0?{...s,toolCalls:[]}:s)),r===j.STATE_DELTA&&(a.delta=a.delta.map(s=>({...s,op:vh[s.op.toUpperCase()]})));let o={[t]:{baseEvent:{type:hh[e.type],timestamp:n,rawEvent:i},...a}};return mh.encode(o).finish()}var Dr="application/vnd.ag-ui.event+proto";var Ce=p.enum(["TextMessageStart","TextMessageContent","TextMessageEnd","ActionExecutionStart","ActionExecutionArgs","ActionExecutionEnd","ActionExecutionResult","AgentStateMessage","MetaEvent","RunStarted","RunFinished","RunError","NodeStarted","NodeFinished"]),kN=p.enum(["LangGraphInterruptEvent","PredictState","Exit"]),jN=p.object({type:p.literal(Ce.enum.TextMessageStart),messageId:p.string(),parentMessageId:p.string().optional(),role:p.string().optional()}),LN=p.object({type:p.literal(Ce.enum.TextMessageContent),messageId:p.string(),content:p.string()}),FN=p.object({type:p.literal(Ce.enum.TextMessageEnd),messageId:p.string()}),DN=p.object({type:p.literal(Ce.enum.ActionExecutionStart),actionExecutionId:p.string(),actionName:p.string(),parentMessageId:p.string().optional()}),UN=p.object({type:p.literal(Ce.enum.ActionExecutionArgs),actionExecutionId:p.string(),args:p.string()}),VN=p.object({type:p.literal(Ce.enum.ActionExecutionEnd),actionExecutionId:p.string()}),BN=p.object({type:p.literal(Ce.enum.ActionExecutionResult),actionName:p.string(),actionExecutionId:p.string(),result:p.string()}),GN=p.object({type:p.literal(Ce.enum.AgentStateMessage),threadId:p.string(),agentName:p.string(),nodeName:p.string(),runId:p.string(),active:p.boolean(),role:p.string(),state:p.string(),running:p.boolean()}),HN=p.object({type:p.literal(Ce.enum.MetaEvent),name:kN,value:p.any()}),WN=p.object({type:p.literal(Ce.enum.RunError),message:p.string(),code:p.string().optional()});p.discriminatedUnion("type",[jN,LN,FN,DN,UN,VN,BN,GN,HN,WN]);p.object({id:p.string(),role:p.string(),content:p.string(),parentMessageId:p.string().optional()});p.object({id:p.string(),name:p.string(),arguments:p.any(),parentMessageId:p.string().optional()});p.object({id:p.string(),result:p.any(),actionExecutionId:p.string(),actionName:p.string()});function _s(e){let t=[],r=new Map,n=new Map;for(let i of e)if(i.type===j.TEXT_MESSAGE_START){let a=i,o=a.messageId;r.has(o)||r.set(o,{contents:[],otherEvents:[]});let s=r.get(o);s.start=a;}else if(i.type===j.TEXT_MESSAGE_CONTENT){let a=i,o=a.messageId;r.has(o)||r.set(o,{contents:[],otherEvents:[]}),r.get(o).contents.push(a);}else if(i.type===j.TEXT_MESSAGE_END){let a=i,o=a.messageId;r.has(o)||r.set(o,{contents:[],otherEvents:[]});let s=r.get(o);s.end=a,yh(o,s,t),r.delete(o);}else if(i.type===j.TOOL_CALL_START){let a=i,o=a.toolCallId;n.has(o)||n.set(o,{args:[],otherEvents:[]});let s=n.get(o);s.start=a;}else if(i.type===j.TOOL_CALL_ARGS){let a=i,o=a.toolCallId;n.has(o)||n.set(o,{args:[],otherEvents:[]}),n.get(o).args.push(a);}else if(i.type===j.TOOL_CALL_END){let a=i,o=a.toolCallId;n.has(o)||n.set(o,{args:[],otherEvents:[]});let s=n.get(o);s.end=a,bh(o,s,t),n.delete(o);}else {let a=false;for(let[o,s]of r)if(s.start&&!s.end){s.otherEvents.push(i),a=true;break}if(!a){for(let[o,s]of n)if(s.start&&!s.end){s.otherEvents.push(i),a=true;break}}a||t.push(i);}for(let[i,a]of r)yh(i,a,t);for(let[i,a]of n)bh(i,a,t);return t}function yh(e,t,r){if(t.start&&r.push(t.start),t.contents.length>0){let n=t.contents.map(a=>a.delta).join(""),i={type:j.TEXT_MESSAGE_CONTENT,messageId:e,delta:n};r.push(i);}t.end&&r.push(t.end);for(let n of t.otherEvents)r.push(n);}function bh(e,t,r){if(t.start&&r.push(t.start),t.args.length>0){let n=t.args.map(a=>a.delta).join(""),i={type:j.TOOL_CALL_ARGS,toolCallId:e,delta:n};r.push(i);}t.end&&r.push(t.end);for(let n of t.otherEvents)r.push(n);}Dc(Eh());function Sh(){return oc()}var z=console;var Oh="Run stopped by user",ZN="Run ended without emitting a terminal event";function hn(e,t={}){let{stopRequested:r=false,interruptionMessage:n}=t,i=n??Oh,a=n&&n!==Oh?n:ZN,o=[],s=new Set,u=new Map;for(let m of e)switch(m.type){case j.TEXT_MESSAGE_START:{let _=m.messageId;typeof _=="string"&&s.add(_);break}case j.TEXT_MESSAGE_END:{let _=m.messageId;typeof _=="string"&&s.delete(_);break}case j.TOOL_CALL_START:{let _=m.toolCallId;typeof _=="string"&&u.set(_,{hasEnd:false,hasResult:false});break}case j.TOOL_CALL_END:{let _=m.toolCallId,y=_?u.get(_):void 0;y&&(y.hasEnd=true);break}case j.TOOL_CALL_RESULT:{let _=m.toolCallId,y=_?u.get(_):void 0;y&&(y.hasResult=true);break}}let c=e.some(m=>m.type===j.RUN_FINISHED),f=e.some(m=>m.type===j.RUN_ERROR),h=!(c||f);for(let m of s){let _={type:j.TEXT_MESSAGE_END,messageId:m};e.push(_),o.push(_);}for(let[m,_]of u){if(!_.hasEnd){let y={type:j.TOOL_CALL_END,toolCallId:m};e.push(y),o.push(y);}if(h&&!_.hasResult){let y={type:j.TOOL_CALL_RESULT,toolCallId:m,messageId:`${m??Sh()}-result`,role:"tool",content:JSON.stringify(r?{status:"stopped",reason:"stop_requested",message:i}:{status:"error",reason:"missing_terminal_event",message:a})};e.push(y),o.push(y);}}if(h)if(r){let m={type:j.RUN_FINISHED};e.push(m),o.push(m);}else {let m={type:j.RUN_ERROR,message:a,code:"INCOMPLETE_STREAM"};e.push(m),o.push(m);}return o}var Ac=class{constructor(t){this.threadId=t;}subject=null;isRunning=false;currentRunId=null;historicRuns=[];agent=null;runSubject=null;stopRequested=false;currentEvents=null},mn=new Map,Es=class extends Sn{run(t){let r=mn.get(t.threadId);r||(r=new Ac(t.threadId),mn.set(t.threadId,r));let n=r;if(n.isRunning)throw new Error("Thread already running");n.isRunning=true,n.currentRunId=t.input.runId,n.agent=t.agent,n.stopRequested=false;let i=new Set,a=[];n.currentEvents=a;let o=new Set;for(let v of n.historicRuns)for(let h of v.events)if("messageId"in h&&typeof h.messageId=="string"&&o.add(h.messageId),h.type===j.RUN_STARTED){let _=h.input?.messages??[];for(let y of _)o.add(y.id);}let s=new gs.ReplaySubject(1/0),u=n.subject;n.subject=s;let c=new gs.ReplaySubject(1/0);n.runSubject=c;let f=async()=>{let h=n.historicRuns[n.historicRuns.length-1]?.runId??null;try{await t.agent.runAgent(t.input,{onEvent:({event:_})=>{let y=_;if(_.type===j.RUN_STARTED){let g=_;if(!g.input){let I=t.input.messages?t.input.messages.filter(B=>!o.has(B.id)):void 0,L={...t.input,...I!==void 0?{messages:I}:{}};y={...g,input:L};}}c.next(y),s.next(y),a.push(y);},onNewMessage:({message:_})=>{i.has(_.id)||i.add(_.id);},onRunStartedEvent:()=>{if(t.input.messages)for(let _ of t.input.messages)i.has(_.id)||i.add(_.id);}});let m=hn(a,{stopRequested:n.stopRequested});for(let _ of m)c.next(_),s.next(_);if(n.currentRunId){let _=_s(a);n.historicRuns.push({threadId:t.threadId,runId:n.currentRunId,parentRunId:h,events:_,createdAt:Date.now()});}n.currentEvents=null,n.currentRunId=null,n.agent=null,n.runSubject=null,n.stopRequested=!1,n.isRunning=!1,c.complete(),s.complete();}catch{let m=hn(a,{stopRequested:n.stopRequested});for(let _ of m)c.next(_),s.next(_);if(n.currentRunId&&a.length>0){let _=_s(a);n.historicRuns.push({threadId:t.threadId,runId:n.currentRunId,parentRunId:h,events:_,createdAt:Date.now()});}n.currentEvents=null,n.currentRunId=null,n.agent=null,n.runSubject=null,n.stopRequested=false,n.isRunning=false,c.complete(),s.complete();}};return u&&u.subscribe({next:v=>s.next(v),error:v=>s.error(v),complete:()=>{}}),f(),c.asObservable()}connect(t){let r=mn.get(t.threadId),n=new gs.ReplaySubject(1/0);if(!r)return n.complete(),n.asObservable();let i=[];for(let s of r.historicRuns)i.push(...s.events);let a=_s(i),o=new Set;for(let s of a)n.next(s),"messageId"in s&&typeof s.messageId=="string"&&o.add(s.messageId);return r.subject&&(r.isRunning||r.stopRequested)?r.subject.subscribe({next:s=>{"messageId"in s&&typeof s.messageId=="string"&&o.has(s.messageId)||n.next(s);},complete:()=>n.complete(),error:s=>n.error(s)}):n.complete(),n.asObservable()}isRunning(t){let r=mn.get(t.threadId);return Promise.resolve(r?.isRunning??false)}stop(t){let r=mn.get(t.threadId);if(!r||!r.isRunning||r.stopRequested)return Promise.resolve(false);r.stopRequested=true,r.isRunning=false;let n=r.agent;if(!n)return r.stopRequested=false,r.isRunning=false,Promise.resolve(false);try{return n.abortRun(),Promise.resolve(!0)}catch(i){return console.error("Failed to abort agent run",i),r.stopRequested=false,r.isRunning=true,Promise.resolve(false)}}};var Ah=Uc.version,wh=class{agents;transcriptionService;beforeRequestMiddleware;afterRequestMiddleware;runner;constructor({agents:t,transcriptionService:r,beforeRequestMiddleware:n,afterRequestMiddleware:i,runner:a}){this.agents=t,this.transcriptionService=r,this.beforeRequestMiddleware=n,this.afterRequestMiddleware=i,this.runner=a??new Es;}};var Tc=(e,t,r)=>(n,i)=>{let a=-1;return o(0);async function o(s){if(s<=a)throw new Error("next() called multiple times");a=s;let u,c=false,f;if(e[s]?(f=e[s][0][0],n.req.routeIndex=s):f=s===e.length&&i||void 0,f)try{u=await f(n,()=>o(s+1));}catch(v){if(v instanceof Error&&t)n.error=v,u=await t(v,n),c=true;else throw v}else n.finalized===false&&r&&(u=await r(n));return u&&(n.finalized===false||c)&&(n.res=u),n}};var Th=Symbol();var Ih=async(e,t=Object.create(null))=>{let{all:r=false,dot:n=false}=t,a=(e instanceof Ss?e.raw.headers:e.headers).get("Content-Type");return a?.startsWith("multipart/form-data")||a?.startsWith("application/x-www-form-urlencoded")?YN(e,{all:r,dot:n}):{}};async function YN(e,t){let r=await e.formData();return r?QN(r,t):{}}function QN(e,t){let r=Object.create(null);return e.forEach((n,i)=>{t.all||i.endsWith("[]")?eM(r,i,n):r[i]=n;}),t.dot&&Object.entries(r).forEach(([n,i])=>{n.includes(".")&&(tM(r,n,i),delete r[n]);}),r}var eM=(e,t,r)=>{e[t]!==void 0?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:t.endsWith("[]")?e[t]=[r]:e[t]=r;},tM=(e,t,r)=>{let n=e,i=t.split(".");i.forEach((a,o)=>{o===i.length-1?n[a]=r:((!n[a]||typeof n[a]!="object"||Array.isArray(n[a])||n[a]instanceof File)&&(n[a]=Object.create(null)),n=n[a]);});};var xc=e=>{let t=e.split("/");return t[0]===""&&t.shift(),t},xh=e=>{let{groups:t,path:r}=rM(e),n=xc(r);return nM(n,t)},rM=e=>{let t=[];return e=e.replace(/\{[^}]+\}/g,(r,n)=>{let i=`@${n}`;return t.push([i,r]),i}),{groups:t,path:e}},nM=(e,t)=>{for(let r=t.length-1;r>=0;r--){let[n]=t[r];for(let i=e.length-1;i>=0;i--)if(e[i].includes(n)){e[i]=e[i].replace(n,t[r][1]);break}}return e},Os={},Rh=(e,t)=>{if(e==="*")return "*";let r=e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);if(r){let n=`${e}#${t}`;return Os[n]||(r[2]?Os[n]=t&&t[0]!==":"&&t[0]!=="*"?[n,r[1],new RegExp(`^${r[2]}(?=/${t})`)]:[e,r[1],new RegExp(`^${r[2]}$`)]:Os[n]=[e,r[1],true]),Os[n]}return null},ws=(e,t)=>{try{return t(e)}catch{return e.replace(/(?:%[0-9A-Fa-f]{2})+/g,r=>{try{return t(r)}catch{return r}})}},iM=e=>ws(e,decodeURI),Rc=e=>{let t=e.url,r=t.indexOf("/",t.charCodeAt(9)===58?13:8),n=r;for(;n<t.length;n++){let i=t.charCodeAt(n);if(i===37){let a=t.indexOf("?",n),o=t.slice(r,a===-1?void 0:a);return iM(o.includes("%25")?o.replace(/%25/g,"%2525"):o)}else if(i===63)break}return t.slice(r,n)};var Ph=e=>{let t=Rc(e);return t.length>1&&t.at(-1)==="/"?t.slice(0,-1):t},Wt=(e,t,...r)=>(r.length&&(t=Wt(t,...r)),`${e?.[0]==="/"?"":"/"}${e}${t==="/"?"":`${e?.at(-1)==="/"?"":"/"}${t?.[0]==="/"?t.slice(1):t}`}`),As=e=>{if(e.charCodeAt(e.length-1)!==63||!e.includes(":"))return null;let t=e.split("/"),r=[],n="";return t.forEach(i=>{if(i!==""&&!/\:/.test(i))n+="/"+i;else if(/\:/.test(i))if(/\?/.test(i)){r.length===0&&n===""?r.push("/"):r.push(n);let a=i.replace("?","");n+="/"+a,r.push(n);}else n+="/"+i;}),r.filter((i,a,o)=>o.indexOf(i)===a)},Ic=e=>/[%+]/.test(e)?(e.indexOf("+")!==-1&&(e=e.replace(/\+/g," ")),e.indexOf("%")!==-1?ws(e,Pc):e):e,qh=(e,t,r)=>{let n;if(!r&&t&&!/[%+]/.test(t)){let o=e.indexOf(`?${t}`,8);for(o===-1&&(o=e.indexOf(`&${t}`,8));o!==-1;){let s=e.charCodeAt(o+t.length+1);if(s===61){let u=o+t.length+2,c=e.indexOf("&",u);return Ic(e.slice(u,c===-1?void 0:c))}else if(s==38||isNaN(s))return "";o=e.indexOf(`&${t}`,o+1);}if(n=/[%+]/.test(e),!n)return}let i={};n??=/[%+]/.test(e);let a=e.indexOf("?",8);for(;a!==-1;){let o=e.indexOf("&",a+1),s=e.indexOf("=",a);s>o&&o!==-1&&(s=-1);let u=e.slice(a+1,s===-1?o===-1?void 0:o:s);if(n&&(u=Ic(u)),a=o,u==="")continue;let c;s===-1?c="":(c=e.slice(s+1,o===-1?void 0:o),n&&(c=Ic(c))),r?(i[u]&&Array.isArray(i[u])||(i[u]=[]),i[u].push(c)):i[u]??=c;}return t?i[t]:i},Ch=qh,Nh=(e,t)=>qh(e,t,true),Pc=decodeURIComponent;var Mh=e=>ws(e,Pc),Ss=class{raw;#t;#e;routeIndex=0;path;bodyCache={};constructor(e,t="/",r=[[]]){this.raw=e,this.path=t,this.#e=r,this.#t={};}param(e){return e?this.#r(e):this.#a()}#r(e){let t=this.#e[0][this.routeIndex][1][e],r=this.#i(t);return r?/\%/.test(r)?Mh(r):r:void 0}#a(){let e={},t=Object.keys(this.#e[0][this.routeIndex][1]);for(let r of t){let n=this.#i(this.#e[0][this.routeIndex][1][r]);n&&typeof n=="string"&&(e[r]=/\%/.test(n)?Mh(n):n);}return e}#i(e){return this.#e[1]?this.#e[1][e]:e}query(e){return Ch(this.url,e)}queries(e){return Nh(this.url,e)}header(e){if(e)return this.raw.headers.get(e)??void 0;let t={};return this.raw.headers.forEach((r,n)=>{t[n]=r;}),t}async parseBody(e){return this.bodyCache.parsedBody??=await Ih(this,e)}#n=e=>{let{bodyCache:t,raw:r}=this,n=t[e];if(n)return n;let i=Object.keys(t)[0];return i?t[i].then(a=>(i==="json"&&(a=JSON.stringify(a)),new Response(a)[e]())):t[e]=r[e]()};json(){return this.#n("text").then(e=>JSON.parse(e))}text(){return this.#n("text")}arrayBuffer(){return this.#n("arrayBuffer")}blob(){return this.#n("blob")}formData(){return this.#n("formData")}addValidatedData(e,t){this.#t[e]=t;}valid(e){return this.#t[e]}get url(){return this.raw.url}get method(){return this.raw.method}get[Th](){return this.#e}get matchedRoutes(){return this.#e[0].map(([[,e]])=>e)}get routePath(){return this.#e[0].map(([[,e]])=>e)[this.routeIndex].path}};var kh={Stringify:1},aM=(e,t)=>{let r=new String(e);return r.isEscaped=true,r.callbacks=t,r};var qc=async(e,t,r,n,i)=>{typeof e=="object"&&!(e instanceof String)&&(e instanceof Promise||(e=e.toString()),e instanceof Promise&&(e=await e));let a=e.callbacks;if(!a?.length)return Promise.resolve(e);i?i[0]+=e:i=[e];let o=Promise.all(a.map(s=>s({phase:t,buffer:i,context:n}))).then(s=>Promise.all(s.filter(Boolean).map(u=>qc(u,t,false,n,i))).then(()=>i[0]));return r?aM(await o,a):o};var oM="text/plain; charset=UTF-8",Cc=(e,t)=>({"Content-Type":e,...t}),jh=class{#t;#e;env={};#r;finalized=false;error;#a;#i;#n;#l;#u;#c;#s;#f;#d;constructor(e,t){this.#t=e,t&&(this.#i=t.executionCtx,this.env=t.env,this.#c=t.notFoundHandler,this.#d=t.path,this.#f=t.matchResult);}get req(){return this.#e??=new Ss(this.#t,this.#d,this.#f),this.#e}get event(){if(this.#i&&"respondWith"in this.#i)return this.#i;throw Error("This context has no FetchEvent")}get executionCtx(){if(this.#i)return this.#i;throw Error("This context has no ExecutionContext")}get res(){return this.#n||=new Response(null,{headers:this.#s??=new Headers})}set res(e){if(this.#n&&e){e=new Response(e.body,e);for(let[t,r]of this.#n.headers.entries())if(t!=="content-type")if(t==="set-cookie"){let n=this.#n.headers.getSetCookie();e.headers.delete("set-cookie");for(let i of n)e.headers.append("set-cookie",i);}else e.headers.set(t,r);}this.#n=e,this.finalized=true;}render=(...e)=>(this.#u??=t=>this.html(t),this.#u(...e));setLayout=e=>this.#l=e;getLayout=()=>this.#l;setRenderer=e=>{this.#u=e;};header=(e,t,r)=>{this.finalized&&(this.#n=new Response(this.#n.body,this.#n));let n=this.#n?this.#n.headers:this.#s??=new Headers;t===void 0?n.delete(e):r?.append?n.append(e,t):n.set(e,t);};status=e=>{this.#a=e;};set=(e,t)=>{this.#r??=new Map,this.#r.set(e,t);};get=e=>this.#r?this.#r.get(e):void 0;get var(){return this.#r?Object.fromEntries(this.#r):{}}#o(e,t,r){let n=this.#n?new Headers(this.#n.headers):this.#s??new Headers;if(typeof t=="object"&&"headers"in t){let a=t.headers instanceof Headers?t.headers:new Headers(t.headers);for(let[o,s]of a)o.toLowerCase()==="set-cookie"?n.append(o,s):n.set(o,s);}if(r)for(let[a,o]of Object.entries(r))if(typeof o=="string")n.set(a,o);else {n.delete(a);for(let s of o)n.append(a,s);}let i=typeof t=="number"?t:t?.status??this.#a;return new Response(e,{status:i,headers:n})}newResponse=(...e)=>this.#o(...e);body=(e,t,r)=>this.#o(e,t,r);text=(e,t,r)=>!this.#s&&!this.#a&&!t&&!r&&!this.finalized?new Response(e):this.#o(e,t,Cc(oM,r));json=(e,t,r)=>this.#o(JSON.stringify(e),t,Cc("application/json",r));html=(e,t,r)=>{let n=i=>this.#o(i,t,Cc("text/html; charset=UTF-8",r));return typeof e=="object"?qc(e,kh.Stringify,false,{}).then(n):n(e)};redirect=(e,t)=>{let r=String(e);return this.header("Location",/[^\x00-\xFF]/.test(r)?encodeURI(r):r),this.newResponse(null,t??302)};notFound=()=>(this.#c??=()=>new Response,this.#c(this))};var $="ALL",Lh="all",Fh=["get","post","put","delete","options","patch"],Ts="Can not add a route since the matcher is already built.",Is=class extends Error{};var Dh="__COMPOSED_HANDLER";var sM=e=>e.text("404 Not Found",404),Uh=(e,t)=>{if("getResponse"in e){let r=e.getResponse();return t.newResponse(r.body,r)}return console.error(e),t.text("Internal Server Error",500)},Nc=class{get;post;put;delete;options;patch;all;on;use;router;getPath;_basePath="/";#t="/";routes=[];constructor(e={}){[...Fh,Lh].forEach(i=>{this[i]=(a,...o)=>(typeof a=="string"?this.#t=a:this.#a(i,this.#t,a),o.forEach(s=>{this.#a(i,this.#t,s);}),this);}),this.on=(i,a,...o)=>{for(let s of [a].flat()){this.#t=s;for(let u of [i].flat())o.map(c=>{this.#a(u.toUpperCase(),this.#t,c);});}return this},this.use=(i,...a)=>(typeof i=="string"?this.#t=i:(this.#t="*",a.unshift(i)),a.forEach(o=>{this.#a($,this.#t,o);}),this);let{strict:r,...n}=e;Object.assign(this,n),this.getPath=r??true?e.getPath??Rc:Ph;}#e(){let e=new Nc({router:this.router,getPath:this.getPath});return e.errorHandler=this.errorHandler,e.#r=this.#r,e.routes=this.routes,e}#r=sM;errorHandler=Uh;route(e,t){let r=this.basePath(e);return t.routes.map(n=>{let i;t.errorHandler===Uh?i=n.handler:(i=async(a,o)=>(await Tc([],t.errorHandler)(a,()=>n.handler(a,o))).res,i[Dh]=n.handler),r.#a(n.method,n.path,i);}),this}basePath(e){let t=this.#e();return t._basePath=Wt(this._basePath,e),t}onError=e=>(this.errorHandler=e,this);notFound=e=>(this.#r=e,this);mount(e,t,r){let n,i;r&&(typeof r=="function"?i=r:(i=r.optionHandler,r.replaceRequest===false?n=s=>s:n=r.replaceRequest));let a=i?s=>{let u=i(s);return Array.isArray(u)?u:[u]}:s=>{let u;try{u=s.executionCtx;}catch{}return [s.env,u]};n||=(()=>{let s=Wt(this._basePath,e),u=s==="/"?0:s.length;return c=>{let f=new URL(c.url);return f.pathname=f.pathname.slice(u)||"/",new Request(f,c)}})();let o=async(s,u)=>{let c=await t(n(s.req.raw),...a(s));if(c)return c;await u();};return this.#a($,Wt(e,"*"),o),this}#a(e,t,r){e=e.toUpperCase(),t=Wt(this._basePath,t);let n={basePath:this._basePath,path:t,method:e,handler:r};this.router.add(e,t,[r,n]),this.routes.push(n);}#i(e,t){if(e instanceof Error)return this.errorHandler(e,t);throw e}#n(e,t,r,n){if(n==="HEAD")return (async()=>new Response(null,await this.#n(e,t,r,"GET")))();let i=this.getPath(e,{env:r}),a=this.router.match(n,i),o=new jh(e,{path:i,matchResult:a,env:r,executionCtx:t,notFoundHandler:this.#r});if(a[0].length===1){let u;try{u=a[0][0][0][0](o,async()=>{o.res=await this.#r(o);});}catch(c){return this.#i(c,o)}return u instanceof Promise?u.then(c=>c||(o.finalized?o.res:this.#r(o))).catch(c=>this.#i(c,o)):u??this.#r(o)}let s=Tc(a[0],this.errorHandler,this.#r);return (async()=>{try{let u=await s(o);if(!u.finalized)throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");return u.res}catch(u){return this.#i(u,o)}})()}fetch=(e,...t)=>this.#n(e,t[1],t[0],e.method);request=(e,t,r,n)=>e instanceof Request?this.fetch(t?new Request(e,t):e,r,n):(e=e.toString(),this.fetch(new Request(/^https?:\/\//.test(e)?e:`http://localhost${Wt("/",e)}`,t),r,n));fire=()=>{addEventListener("fetch",e=>{e.respondWith(this.#n(e.request,e,void 0,e.request.method));});}};var xs="[^/]+",_n=".*",yn="(?:|/.*)",Ur=Symbol(),uM=new Set(".\\+*[^]$()");function cM(e,t){return e.length===1?t.length===1?e<t?-1:1:-1:t.length===1||e===_n||e===yn?1:t===_n||t===yn?-1:e===xs?1:t===xs?-1:e.length===t.length?e<t?-1:1:t.length-e.length}var Rs=class{#t;#e;#r=Object.create(null);insert(e,t,r,n,i){if(e.length===0){if(this.#t!==void 0)throw Ur;if(i)return;this.#t=t;return}let[a,...o]=e,s=a==="*"?o.length===0?["","",_n]:["","",xs]:a==="/*"?["","",yn]:a.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/),u;if(s){let c=s[1],f=s[2]||xs;if(c&&s[2]&&(f=f.replace(/^\((?!\?:)(?=[^)]+\)$)/,"(?:"),/\((?!\?:)/.test(f)))throw Ur;if(u=this.#r[f],!u){if(Object.keys(this.#r).some(v=>v!==_n&&v!==yn))throw Ur;if(i)return;u=this.#r[f]=new Rs,c!==""&&(u.#e=n.varIndex++);}!i&&c!==""&&r.push([c,u.#e]);}else if(u=this.#r[a],!u){if(Object.keys(this.#r).some(c=>c.length>1&&c!==_n&&c!==yn))throw Ur;if(i)return;u=this.#r[a]=new Rs;}u.insert(o,t,r,n,i);}buildRegExpStr(){let t=Object.keys(this.#r).sort(cM).map(r=>{let n=this.#r[r];return (typeof n.#e=="number"?`(${r})@${n.#e}`:uM.has(r)?`\\${r}`:r)+n.buildRegExpStr()});return typeof this.#t=="number"&&t.unshift(`#${this.#t}`),t.length===0?"":t.length===1?t[0]:"(?:"+t.join("|")+")"}};var Vh=class{#t={varIndex:0};#e=new Rs;insert(e,t,r){let n=[],i=[];for(let o=0;;){let s=false;if(e=e.replace(/\{[^}]+\}/g,u=>{let c=`@\\${o}`;return i[o]=[c,u],o++,s=true,c}),!s)break}let a=e.match(/(?::[^\/]+)|(?:\/\*$)|./g)||[];for(let o=i.length-1;o>=0;o--){let[s]=i[o];for(let u=a.length-1;u>=0;u--)if(a[u].indexOf(s)!==-1){a[u]=a[u].replace(s,i[o][1]);break}}return this.#e.insert(a,t,n,this.#t,r),n}buildRegExp(){let e=this.#e.buildRegExpStr();if(e==="")return [/^$/,[],[]];let t=0,r=[],n=[];return e=e.replace(/#(\d+)|@(\d+)|\.\*\$/g,(i,a,o)=>a!==void 0?(r[++t]=Number(a),"$()"):(o!==void 0&&(n[Number(o)]=++t),"")),[new RegExp(`^${e}`),r,n]}};var Bh=[],lM=[/^$/,[],Object.create(null)],Gh=Object.create(null);function Hh(e){return Gh[e]??=new RegExp(e==="*"?"":`^${e.replace(/\/\*$|([.\\+*[^\]$()])/g,(t,r)=>r?`\\${r}`:"(?:|/.*)")}$`)}function fM(){Gh=Object.create(null);}function dM(e){let t=new Vh,r=[];if(e.length===0)return lM;let n=e.map(c=>[!/\*|\/:/.test(c[0]),...c]).sort(([c,f],[v,h])=>c?1:v?-1:f.length-h.length),i=Object.create(null);for(let c=0,f=-1,v=n.length;c<v;c++){let[h,m,_]=n[c];h?i[m]=[_.map(([g])=>[g,Object.create(null)]),Bh]:f++;let y;try{y=t.insert(m,f,h);}catch(g){throw g===Ur?new Is(m):g}h||(r[f]=_.map(([g,I])=>{let L=Object.create(null);for(I-=1;I>=0;I--){let[B,ce]=y[I];L[B]=ce;}return [g,L]}));}let[a,o,s]=t.buildRegExp();for(let c=0,f=r.length;c<f;c++)for(let v=0,h=r[c].length;v<h;v++){let m=r[c][v]?.[1];if(!m)continue;let _=Object.keys(m);for(let y=0,g=_.length;y<g;y++)m[_[y]]=s[m[_[y]]];}let u=[];for(let c in o)u[c]=r[o[c]];return [a,u,i]}function Vr(e,t){if(e){for(let r of Object.keys(e).sort((n,i)=>i.length-n.length))if(Hh(r).test(t))return [...e[r]]}}var Mc=class{name="RegExpRouter";#t;#e;constructor(){this.#t={[$]:Object.create(null)},this.#e={[$]:Object.create(null)};}add(e,t,r){let n=this.#t,i=this.#e;if(!n||!i)throw new Error(Ts);n[e]||[n,i].forEach(s=>{s[e]=Object.create(null),Object.keys(s[$]).forEach(u=>{s[e][u]=[...s[$][u]];});}),t==="/*"&&(t="*");let a=(t.match(/\/:/g)||[]).length;if(/\*$/.test(t)){let s=Hh(t);e===$?Object.keys(n).forEach(u=>{n[u][t]||=Vr(n[u],t)||Vr(n[$],t)||[];}):n[e][t]||=Vr(n[e],t)||Vr(n[$],t)||[],Object.keys(n).forEach(u=>{(e===$||e===u)&&Object.keys(n[u]).forEach(c=>{s.test(c)&&n[u][c].push([r,a]);});}),Object.keys(i).forEach(u=>{(e===$||e===u)&&Object.keys(i[u]).forEach(c=>s.test(c)&&i[u][c].push([r,a]));});return}let o=As(t)||[t];for(let s=0,u=o.length;s<u;s++){let c=o[s];Object.keys(i).forEach(f=>{(e===$||e===f)&&(i[f][c]||=[...Vr(n[f],c)||Vr(n[$],c)||[]],i[f][c].push([r,a-u+s+1]));});}}match(e,t){fM();let r=this.#r();return this.match=(n,i)=>{let a=r[n]||r[$],o=a[2][i];if(o)return o;let s=i.match(a[0]);if(!s)return [[],Bh];let u=s.indexOf("",1);return [a[1][u],s]},this.match(e,t)}#r(){let e=Object.create(null);return Object.keys(this.#e).concat(Object.keys(this.#t)).forEach(t=>{e[t]||=this.#a(t);}),this.#t=this.#e=void 0,e}#a(e){let t=[],r=e===$;return [this.#t,this.#e].forEach(n=>{let i=n[e]?Object.keys(n[e]).map(a=>[a,n[e][a]]):[];i.length!==0?(r||=true,t.push(...i)):e!==$&&t.push(...Object.keys(n[$]).map(a=>[a,n[$][a]]));}),r?dM(t):null}};var kc=class{name="SmartRouter";#t=[];#e=[];constructor(e){this.#t=e.routers;}add(e,t,r){if(!this.#e)throw new Error(Ts);this.#e.push([e,t,r]);}match(e,t){if(!this.#e)throw new Error("Fatal error");let r=this.#t,n=this.#e,i=r.length,a=0,o;for(;a<i;a++){let s=r[a];try{for(let u=0,c=n.length;u<c;u++)s.add(...n[u]);o=s.match(e,t);}catch(u){if(u instanceof Is)continue;throw u}this.match=s.match.bind(s),this.#t=[s],this.#e=void 0;break}if(a===i)throw new Error("Fatal error");return this.name=`SmartRouter + ${this.activeRouter.name}`,o}get activeRouter(){if(this.#e||this.#t.length!==1)throw new Error("No active router has been determined yet.");return this.#t[0]}};var bn=Object.create(null),jc=class{#t;#e;#r;#a=0;#i=bn;constructor(e,t,r){if(this.#e=r||Object.create(null),this.#t=[],e&&t){let n=Object.create(null);n[e]={handler:t,possibleKeys:[],score:0},this.#t=[n];}this.#r=[];}insert(e,t,r){this.#a=++this.#a;let n=this,i=xh(t),a=[];for(let o=0,s=i.length;o<s;o++){let u=i[o],c=i[o+1],f=Rh(u,c),v=Array.isArray(f)?f[0]:u;if(v in n.#e){n=n.#e[v],f&&a.push(f[1]);continue}n.#e[v]=new jc,f&&(n.#r.push(f),a.push(f[1])),n=n.#e[v];}return n.#t.push({[e]:{handler:r,possibleKeys:a.filter((o,s,u)=>u.indexOf(o)===s),score:this.#a}}),n}#n(e,t,r,n){let i=[];for(let a=0,o=e.#t.length;a<o;a++){let s=e.#t[a],u=s[t]||s[$],c={};if(u!==void 0&&(u.params=Object.create(null),i.push(u),r!==bn||n&&n!==bn))for(let f=0,v=u.possibleKeys.length;f<v;f++){let h=u.possibleKeys[f],m=c[u.score];u.params[h]=n?.[h]&&!m?n[h]:r[h]??n?.[h],c[u.score]=true;}}return i}search(e,t){let r=[];this.#i=bn;let i=[this],a=xc(t),o=[];for(let s=0,u=a.length;s<u;s++){let c=a[s],f=s===u-1,v=[];for(let h=0,m=i.length;h<m;h++){let _=i[h],y=_.#e[c];y&&(y.#i=_.#i,f?(y.#e["*"]&&r.push(...this.#n(y.#e["*"],e,_.#i)),r.push(...this.#n(y,e,_.#i))):v.push(y));for(let g=0,I=_.#r.length;g<I;g++){let L=_.#r[g],B=_.#i===bn?{}:{..._.#i};if(L==="*"){let Be=_.#e["*"];Be&&(r.push(...this.#n(Be,e,_.#i)),Be.#i=B,v.push(Be));continue}if(!c)continue;let[ce,Ee,le]=L,he=_.#e[ce],Jh=a.slice(s).join("/");if(le instanceof RegExp){let Be=le.exec(Jh);if(Be){if(B[Ee]=Be[0],r.push(...this.#n(he,e,_.#i,B)),Object.keys(he.#e).length){he.#i=B;let Xh=Be[0].match(/\//)?.length??0;(o[Xh]||=[]).push(he);}continue}}(le===true||le.test(c))&&(B[Ee]=c,f?(r.push(...this.#n(he,e,B,_.#i)),he.#e["*"]&&r.push(...this.#n(he.#e["*"],e,B,_.#i))):(he.#i=B,v.push(he)));}}i=v.concat(o.shift()??[]);}return r.length>1&&r.sort((s,u)=>s.score-u.score),[r.map(({handler:s,params:u})=>[s,u])]}};var Lc=class{name="TrieRouter";#t;constructor(){this.#t=new jc;}add(e,t,r){let n=As(t);if(n){for(let i=0,a=n.length;i<a;i++)this.#t.insert(e,n[i],r);return}this.#t.insert(e,t,r);}match(e,t){return this.#t.search(e,t)}};var gn=class extends Nc{constructor(e={}){super(e),this.router=e.router??new kc({routers:[new Mc,new Lc]});}};var Ps=e=>{let r={...{origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH"],allowHeaders:[],exposeHeaders:[]},...e},n=(a=>typeof a=="string"?a==="*"?()=>a:o=>a===o?o:null:typeof a=="function"?a:o=>a.includes(o)?o:null)(r.origin),i=(a=>typeof a=="function"?a:Array.isArray(a)?()=>a:()=>[])(r.allowMethods);return async function(o,s){function u(f,v){o.res.headers.set(f,v);}let c=n(o.req.header("origin")||"",o);if(c&&u("Access-Control-Allow-Origin",c),r.origin!=="*"){let f=o.req.header("Vary");f?u("Vary",f):u("Vary","Origin");}if(r.credentials&&u("Access-Control-Allow-Credentials","true"),r.exposeHeaders?.length&&u("Access-Control-Expose-Headers",r.exposeHeaders.join(",")),o.req.method==="OPTIONS"){r.maxAge!=null&&u("Access-Control-Max-Age",r.maxAge.toString());let f=i(o.req.header("origin")||"",o);f.length&&u("Access-Control-Allow-Methods",f.join(","));let v=r.allowHeaders;if(!v?.length){let h=o.req.header("Access-Control-Request-Headers");h&&(v=h.split(/\s*,\s*/));}return v?.length&&(u("Access-Control-Allow-Headers",v.join(",")),o.res.headers.append("Vary","Access-Control-Request-Headers")),o.res.headers.delete("Content-Length"),o.res.headers.delete("Content-Type"),new Response(null,{headers:o.res.headers,status:204,statusText:"No Content"})}await s();}};function pM(e,t){let r=hM(e===void 0?"*/*":e||"");if(!t)return r.filter(i=>i.q>0).sort((i,a)=>a.q-i.q||a.i-i.i||0).map(bM);let n=t.map(function(a,o){return mM(a,r,o)});return n.filter(i=>i.q>0).sort(yM).map(function(a){return t[n.indexOf(a)]})}var vM=/^\s*([^\s\/;]+)\/([^;\s]+)\s*(?:;(.*))?$/;function hM(e){let t=EM(e),r=[];for(let n=0,i=0;n<t.length;n++){let a=Wh(t[n].trim(),n);a&&(r[i++]=a);}return r}function Wh(e,t){let r=vM.exec(e);if(!r)return null;let n=Object.create(null),i=1,a=r[2],o=r[1];if(r[3]){let s=SM(r[3]).map(gM);for(let u=0;u<s.length;u++){let c=s[u],f=c[0].toLowerCase(),v=c[1],h=v&&v[0]==='"'&&v[v.length-1]==='"'?v.slice(1,-1):v;if(f==="q"){i=parseFloat(h);break}n[f]=h;}}return {type:o,subtype:a,params:n,q:i,i:t}}function mM(e,t,r){let n={o:-1,q:0,s:0};for(let i=0;i<t.length;i++){let a=_M(e,t[i],r);a&&(n.s-a.s||n.q-a.q||n.o-a.o)<0&&(n.o=a.o,n.q=a.q,n.s=a.s,n.i=a.i);}return n}function _M(e,t,r){let n=Wh(e,0),i=0;if(!n)return null;if(t.type.toLowerCase()==n.type.toLowerCase())i|=4;else if(t.type!="*")return null;if(t.subtype.toLowerCase()==n.subtype.toLowerCase())i|=2;else if(t.subtype!="*")return null;let a=Object.keys(t.params);if(a.length>0)if(a.every(function(o){return t.params[o]=="*"||(t.params[o]||"").toLowerCase()==(n.params[o]||"").toLowerCase()}))i|=1;else return null;return {i:r,o:t.i,q:t.q,s:i}}function yM(e,t){return t.q-e.q||t.s-e.s||(e.o||0)-(t.o||0)||(e.i||0)-(t.i||0)||0}function bM(e){return e.type+"/"+e.subtype}function $h(e){let t=0,r=0;for(;(r=e.indexOf('"',r))!==-1;)t++,r++;return t}function gM(e){let t=e.indexOf("="),r,n="";return t===-1?r=e:(r=e.slice(0,t),n=e.slice(t+1)),[r,n]}function EM(e){let t=e.split(","),r=[t[0]];for(let n=1,i=0;n<t.length;n++)$h(r[i])%2==0?r[++i]=t[n]:r[i]+=","+t[n];return r}function SM(e){let t=e.split(";"),r=[t[0]];for(let n=1,i=0;n<t.length;n++)$h(r[i])%2==0?r[++i]=t[n]:r[i]+=";"+t[n];for(let n=0;n<r.length;n++)r[n]=r[n].trim();return r}var qs=class{constructor(e){this.acceptsProtobuf=e?.accept?this.isProtobufAccepted(e.accept):false;}getContentType(){return this.acceptsProtobuf?Dr:"text/event-stream"}encode(e){return this.encodeSSE(e)}encodeSSE(e){return `data: ${JSON.stringify(e)}
|
|
6
|
-
|
|
7
|
-
`}encodeBinary(e){if(this.acceptsProtobuf)return this.encodeProtobuf(e);{let t=this.encodeSSE(e);return new TextEncoder().encode(t)}}encodeProtobuf(e){let t=_h(e),r=t.length,n=new ArrayBuffer(4+r);new DataView(n).setUint32(0,r,false);let a=new Uint8Array(n);return a.set(t,4),a}isProtobufAccepted(e){return pM(e,[Dr]).includes(Dr)}};async function Cs({runtime:e,request:t,agentId:r}){try{let n=await e.agents;if(!n[r])return new Response(JSON.stringify({error:"Agent not found",message:`Agent '${r}' does not exist`}),{status:404,headers:{"Content-Type":"application/json"}});let a=n[r].clone();if(a&&"headers"in a){let f=h=>{let m=h.toLowerCase();return m==="authorization"||m.startsWith("x-")},v={};t.headers.forEach((h,m)=>{f(m)&&(v[m]=h);}),a.headers={...a.headers,...v};}let o=new TransformStream,s=o.writable.getWriter(),u=new qs,c=!1;return (async()=>{let f;try{let v=await t.json();f=cn.parse(v);}catch{return new Response(JSON.stringify({error:"Invalid request body"}),{status:400})}a.setMessages(f.messages),a.setState(f.state),a.threadId=f.threadId,e.runner.run({threadId:f.threadId,agent:a,input:f}).subscribe({next:async v=>{if(!t.signal.aborted&&!c)try{await s.write(u.encode(v));}catch(h){h instanceof Error&&h.name==="AbortError"&&(c=!0);}},error:async v=>{if(console.error("Error running agent:",v),!c)try{await s.close(),c=!0;}catch{}},complete:async()=>{if(!c)try{await s.close(),c=!0;}catch{}}});})().catch(f=>{if(console.error("Error running agent:",f),console.error("Error stack:",f instanceof Error?f.stack:"No stack trace"),console.error("Error details:",{name:f instanceof Error?f.name:"Unknown",message:f instanceof Error?f.message:String(f),cause:f instanceof Error?f.cause:void 0}),!c)try{s.close(),c=!0;}catch{}}),new Response(o.readable,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}catch(n){return console.error("Error running agent:",n),console.error("Error stack:",n instanceof Error?n.stack:"No stack trace"),console.error("Error details:",{name:n instanceof Error?n.name:"Unknown",message:n instanceof Error?n.message:String(n),cause:n instanceof Error?n.cause:void 0}),new Response(JSON.stringify({error:"Failed to run agent",message:n instanceof Error?n.message:"Unknown error"}),{status:500,headers:{"Content-Type":"application/json"}})}}async function Ns({runtime:e}){try{let t=await e.agents,r=Object.entries(t).reduce((i,[a,o])=>(i[a]={name:a,description:o.description,className:o.constructor.name},i),{}),n={version:Ah,agents:r,audioFileTranscriptionEnabled:!!e.transcriptionService};return new Response(JSON.stringify(n),{status:200,headers:{"Content-Type":"application/json"}})}catch(t){return new Response(JSON.stringify({error:"Failed to retrieve runtime information",message:t instanceof Error?t.message:"Unknown error"}),{status:500,headers:{"Content-Type":"application/json"}})}}async function Ms({runtime:e,request:t}){try{if(!e.transcriptionService)return new Response(JSON.stringify({error:"Transcription service not configured",message:"No transcription service has been configured in the runtime"}),{status:503,headers:{"Content-Type":"application/json"}});let r=t.headers.get("content-type");if(!r||!r.includes("multipart/form-data"))return new Response(JSON.stringify({error:"Invalid content type",message:"Request must contain multipart/form-data with an audio file"}),{status:400,headers:{"Content-Type":"application/json"}});let i=(await t.formData()).get("audio");if(!i||!(i instanceof File))return new Response(JSON.stringify({error:"Missing audio file",message:"No audio file found in form data. Please include an 'audio' field."}),{status:400,headers:{"Content-Type":"application/json"}});let a=["audio/mpeg","audio/mp3","audio/mp4","audio/wav","audio/webm","audio/ogg","audio/flac","audio/aac"];if(!(a.includes(i.type)||i.type===""||i.type==="application/octet-stream"))return new Response(JSON.stringify({error:"Invalid file type",message:`Unsupported audio file type: ${i.type}. Supported types: ${a.join(", ")}, or files with unknown/empty types`}),{status:400,headers:{"Content-Type":"application/json"}});let s=await e.transcriptionService.transcribeFile({audioFile:i,mimeType:i.type,size:i.size});return new Response(JSON.stringify({text:s,size:i.size,type:i.type}),{status:200,headers:{"Content-Type":"application/json"}})}catch(r){return new Response(JSON.stringify({error:"Transcription failed",message:r instanceof Error?r.message:"Unknown error occurred during transcription"}),{status:500,headers:{"Content-Type":"application/json"}})}}async function ks({runtime:e,request:t,path:r}){let n=e.beforeRequestMiddleware;if(n){if(typeof n=="function")return n({runtime:e,request:t,path:r});z.warn({mw:n},"Unsupported beforeRequestMiddleware value \u2013 skipped");}}async function js({runtime:e,response:t,path:r}){let n=e.afterRequestMiddleware;if(n){if(typeof n=="function")return n({runtime:e,response:t,path:r});z.warn({mw:n},"Unsupported afterRequestMiddleware value \u2013 skipped");}}async function Ls({runtime:e,request:t,agentId:r}){try{if(!(await e.agents)[r])return new Response(JSON.stringify({error:"Agent not found",message:`Agent '${r}' does not exist`}),{status:404,headers:{"Content-Type":"application/json"}});let i=new TransformStream,a=i.writable.getWriter(),o=new qs,s=!1;return (async()=>{let u;try{let c=await t.json();u=cn.parse(c);}catch{return new Response(JSON.stringify({error:"Invalid request body"}),{status:400})}e.runner.connect({threadId:u.threadId}).subscribe({next:async c=>{if(!t.signal.aborted&&!s)try{await a.write(o.encode(c));}catch(f){f instanceof Error&&f.name==="AbortError"&&(s=!0);}},error:async c=>{if(console.error("Error running agent:",c),!s)try{await a.close(),s=!0;}catch{}},complete:async()=>{if(!s)try{await a.close(),s=!0;}catch{}}});})().catch(u=>{if(console.error("Error running agent:",u),console.error("Error stack:",u instanceof Error?u.stack:"No stack trace"),console.error("Error details:",{name:u instanceof Error?u.name:"Unknown",message:u instanceof Error?u.message:String(u),cause:u instanceof Error?u.cause:void 0}),!s)try{a.close(),s=!0;}catch{}}),new Response(i.readable,{status:200,headers:{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"}})}catch(n){return console.error("Error running agent:",n),console.error("Error stack:",n instanceof Error?n.stack:"No stack trace"),console.error("Error details:",{name:n instanceof Error?n.name:"Unknown",message:n instanceof Error?n.message:String(n),cause:n instanceof Error?n.cause:void 0}),new Response(JSON.stringify({error:"Failed to run agent",message:n instanceof Error?n.message:"Unknown error"}),{status:500,headers:{"Content-Type":"application/json"}})}}async function Fs({runtime:e,request:t,agentId:r,threadId:n}){try{return (await e.agents)[r]?await e.runner.stop({threadId:n})?new Response(JSON.stringify({stopped:!0,interrupt:{type:j.RUN_ERROR,message:"Run stopped by user",code:"STOPPED"}}),{status:200,headers:{"Content-Type":"application/json"}}):new Response(JSON.stringify({stopped:!1,message:`No active run for thread '${n}'.`}),{status:200,headers:{"Content-Type":"application/json"}}):new Response(JSON.stringify({error:"Agent not found",message:`Agent '${r}' does not exist`}),{status:404,headers:{"Content-Type":"application/json"}})}catch(i){return console.error("Error stopping agent run:",i),new Response(JSON.stringify({error:"Failed to stop agent",message:i instanceof Error?i.message:"Unknown error"}),{status:500,headers:{"Content-Type":"application/json"}})}}function PU({runtime:e,basePath:t}){return new gn().basePath(t).use("*",Ps({origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH","OPTIONS"],allowHeaders:["*"]})).use("*",async(n,i)=>{let a=n.req.raw,o=n.req.path;try{let s=await ks({runtime:e,request:a,path:o});s&&n.set("modifiedRequest",s);}catch(s){if(z.error({err:s,url:a.url,path:o},"Error running before request middleware"),s instanceof Response)return s;throw s}await i();}).use("*",async(n,i)=>{await i();let a=n.res,o=n.req.path;js({runtime:e,response:a,path:o}).catch(s=>{z.error({err:s,url:n.req.url,path:o},"Error running after request middleware");});}).post("/agent/:agentId/run",async n=>{let i=n.req.param("agentId"),a=n.get("modifiedRequest")||n.req.raw;try{return await Cs({runtime:e,request:a,agentId:i})}catch(o){throw z.error({err:o,url:a.url,path:n.req.path},"Error running request handler"),o}}).post("/agent/:agentId/connect",async n=>{let i=n.req.param("agentId"),a=n.get("modifiedRequest")||n.req.raw;try{return await Ls({runtime:e,request:a,agentId:i})}catch(o){throw z.error({err:o,url:a.url,path:n.req.path},"Error running request handler"),o}}).post("/agent/:agentId/stop/:threadId",async n=>{let i=n.req.param("agentId"),a=n.req.param("threadId"),o=n.get("modifiedRequest")||n.req.raw;try{return await Fs({runtime:e,request:o,agentId:i,threadId:a})}catch(s){throw z.error({err:s,url:o.url,path:n.req.path},"Error running request handler"),s}}).get("/info",async n=>{let i=n.get("modifiedRequest")||n.req.raw;try{return await Ns({runtime:e,request:i})}catch(a){throw z.error({err:a,url:i.url,path:n.req.path},"Error running request handler"),a}}).post("/transcribe",async n=>{let i=n.get("modifiedRequest")||n.req.raw;try{return await Ms({runtime:e,request:i})}catch(a){throw z.error({err:a,url:i.url,path:n.req.path},"Error running request handler"),a}}).notFound(n=>n.json({error:"Not found"},404))}var OM=["agent/run","agent/connect","agent/stop","info","transcribe"];async function zh(e){if(!(e.headers.get("content-type")||"").includes("application/json"))throw Br("Single-route endpoint expects JSON payloads",415);let r;try{r=await e.clone().json();}catch{throw Br("Invalid JSON payload",400)}return {method:wM(r.method),params:r.params,body:r.body}}function En(e,t){let r=e?.[t];if(typeof r=="string"&&r.trim().length>0)return r;throw Br(`Missing or invalid parameter '${t}'`,400)}function Fc(e,t){if(t==null)throw Br("Missing request body for JSON handler",400);let r=new Headers(e.headers);r.set("content-type","application/json"),r.delete("content-length");let n=AM(t);return new Request(e.url,{method:"POST",headers:r,body:n,signal:e.signal})}function Br(e,t){return new Response(JSON.stringify({error:"invalid_request",message:e}),{status:t,headers:{"Content-Type":"application/json"}})}function wM(e){if(!e)throw Br("Missing method field",400);if(OM.includes(e))return e;throw Br(`Unsupported method '${e}'`,400)}function AM(e){return typeof e=="string"||e instanceof Blob||e instanceof ArrayBuffer||e instanceof Uint8Array||e instanceof FormData||e instanceof URLSearchParams?e:JSON.stringify(e)}function HU({runtime:e,basePath:t}){let r=new gn,n=TM(t);return r.basePath(n).use("*",Ps({origin:"*",allowMethods:["GET","HEAD","PUT","POST","DELETE","PATCH","OPTIONS"],allowHeaders:["*"]})).use("*",async(i,a)=>{let o=i.req.raw,s=i.req.path;try{let u=await ks({runtime:e,request:o,path:s});u&&i.set("modifiedRequest",u);}catch(u){if(z.error({err:u,url:o.url,path:s},"Error running before request middleware"),u instanceof Response)return u;throw u}await a();}).use("*",async(i,a)=>{await a();let o=i.res,s=i.req.path;js({runtime:e,response:o,path:s}).catch(u=>{z.error({err:u,url:i.req.url,path:s},"Error running after request middleware");});}).post("/",async i=>{let a=i.get("modifiedRequest")||i.req.raw,o;try{o=await zh(a);}catch(s){return s instanceof Response?(z.warn({url:a.url},"Invalid single-route payload"),s):(z.warn({err:s,url:a.url},"Invalid single-route payload"),i.json({error:"invalid_request",message:s instanceof Error?s.message:"Invalid request payload"},400))}try{switch(o.method){case "agent/run":{let s=En(o.params,"agentId"),u=Fc(a,o.body);return await Cs({runtime:e,request:u,agentId:s})}case "agent/connect":{let s=En(o.params,"agentId"),u=Fc(a,o.body);return await Ls({runtime:e,request:u,agentId:s})}case "agent/stop":{let s=En(o.params,"agentId"),u=En(o.params,"threadId");return await Fs({runtime:e,request:a,agentId:s,threadId:u})}case "info":return await Ns({runtime:e,request:a});case "transcribe":return await Ms({runtime:e,request:a});default:return o.method}}catch(s){if(s instanceof Response)return s;throw z.error({err:s,url:a.url,method:o.method},"Error running single-route handler"),s}}).notFound(i=>i.json({error:"Not found"},404))}function TM(e){if(!e)throw new Error("basePath must be provided for single-route endpoint");return e.startsWith("/")?e.length>1&&e.endsWith("/")?e.slice(0,-1):e:`/${e}`}/*! Bundled license information:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AgentRunner: () => AgentRunner,
|
|
24
|
+
CopilotRuntime: () => CopilotRuntime,
|
|
25
|
+
InMemoryAgentRunner: () => InMemoryAgentRunner,
|
|
26
|
+
VERSION: () => VERSION,
|
|
27
|
+
createCopilotEndpoint: () => createCopilotEndpoint,
|
|
28
|
+
createCopilotEndpointSingleRoute: () => createCopilotEndpointSingleRoute,
|
|
29
|
+
finalizeRunEvents: () => import_shared5.finalizeRunEvents
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(index_exports);
|
|
32
|
+
|
|
33
|
+
// package.json
|
|
34
|
+
var package_default = {
|
|
35
|
+
name: "@copilotkitnext/runtime",
|
|
36
|
+
version: "0.0.22-alpha.4",
|
|
37
|
+
description: "Server-side runtime package for CopilotKit2",
|
|
38
|
+
main: "dist/index.js",
|
|
39
|
+
types: "dist/index.d.ts",
|
|
40
|
+
exports: {
|
|
41
|
+
".": {
|
|
42
|
+
types: "./dist/index.d.ts",
|
|
43
|
+
import: "./dist/index.mjs",
|
|
44
|
+
require: "./dist/index.js"
|
|
45
|
+
},
|
|
46
|
+
"./express": {
|
|
47
|
+
types: "./dist/express.d.ts",
|
|
48
|
+
import: "./dist/express.mjs",
|
|
49
|
+
require: "./dist/express.js"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
publishConfig: {
|
|
53
|
+
access: "public"
|
|
54
|
+
},
|
|
55
|
+
scripts: {
|
|
56
|
+
build: "tsup",
|
|
57
|
+
prepublishOnly: "pnpm run build",
|
|
58
|
+
dev: "tsup --watch",
|
|
59
|
+
lint: "eslint . --max-warnings 0",
|
|
60
|
+
"check-types": "tsc --noEmit",
|
|
61
|
+
clean: "rm -rf dist",
|
|
62
|
+
test: "vitest run",
|
|
63
|
+
"test:watch": "vitest",
|
|
64
|
+
"test:coverage": "vitest run --coverage"
|
|
65
|
+
},
|
|
66
|
+
devDependencies: {
|
|
67
|
+
"@copilotkitnext/eslint-config": "workspace:*",
|
|
68
|
+
"@copilotkitnext/typescript-config": "workspace:*",
|
|
69
|
+
"@types/cors": "^2.8.17",
|
|
70
|
+
"@types/express": "^4.17.21",
|
|
71
|
+
"@types/node": "^22.15.3",
|
|
72
|
+
eslint: "^9.30.0",
|
|
73
|
+
openai: "^5.9.0",
|
|
74
|
+
supertest: "^7.1.1",
|
|
75
|
+
tsup: "^8.5.0",
|
|
76
|
+
typescript: "5.8.2",
|
|
77
|
+
vitest: "^3.0.5"
|
|
78
|
+
},
|
|
79
|
+
dependencies: {
|
|
80
|
+
"@ag-ui/client": "0.0.41-alpha.0",
|
|
81
|
+
"@ag-ui/core": "0.0.41-alpha.0",
|
|
82
|
+
"@ag-ui/encoder": "0.0.41-alpha.0",
|
|
83
|
+
"@copilotkitnext/shared": "workspace:*",
|
|
84
|
+
cors: "^2.8.5",
|
|
85
|
+
express: "^4.21.2",
|
|
86
|
+
hono: "^4.6.13",
|
|
87
|
+
rxjs: "7.8.1"
|
|
88
|
+
},
|
|
89
|
+
peerDependencies: {
|
|
90
|
+
openai: "^5.9.0"
|
|
91
|
+
},
|
|
92
|
+
peerDependenciesMeta: {},
|
|
93
|
+
engines: {
|
|
94
|
+
node: ">=18"
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
// src/runner/agent-runner.ts
|
|
99
|
+
var AgentRunner = class {
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
// src/runner/in-memory.ts
|
|
103
|
+
var import_rxjs = require("rxjs");
|
|
104
|
+
var import_client = require("@ag-ui/client");
|
|
105
|
+
var import_shared = require("@copilotkitnext/shared");
|
|
106
|
+
var InMemoryEventStore = class {
|
|
107
|
+
constructor(threadId) {
|
|
108
|
+
this.threadId = threadId;
|
|
109
|
+
}
|
|
110
|
+
/** The subject that current consumers subscribe to. */
|
|
111
|
+
subject = null;
|
|
112
|
+
/** True while a run is actively producing events. */
|
|
113
|
+
isRunning = false;
|
|
114
|
+
/** Current run ID */
|
|
115
|
+
currentRunId = null;
|
|
116
|
+
/** Historic completed runs */
|
|
117
|
+
historicRuns = [];
|
|
118
|
+
/** Currently running agent instance (if any). */
|
|
119
|
+
agent = null;
|
|
120
|
+
/** Subject returned from run() while the run is active. */
|
|
121
|
+
runSubject = null;
|
|
122
|
+
/** True once stop() has been requested but the run has not yet finalized. */
|
|
123
|
+
stopRequested = false;
|
|
124
|
+
/** Reference to the events emitted in the current run. */
|
|
125
|
+
currentEvents = null;
|
|
126
|
+
};
|
|
127
|
+
var GLOBAL_STORE = /* @__PURE__ */ new Map();
|
|
128
|
+
var InMemoryAgentRunner = class extends AgentRunner {
|
|
129
|
+
run(request) {
|
|
130
|
+
let existingStore = GLOBAL_STORE.get(request.threadId);
|
|
131
|
+
if (!existingStore) {
|
|
132
|
+
existingStore = new InMemoryEventStore(request.threadId);
|
|
133
|
+
GLOBAL_STORE.set(request.threadId, existingStore);
|
|
134
|
+
}
|
|
135
|
+
const store = existingStore;
|
|
136
|
+
if (store.isRunning) {
|
|
137
|
+
throw new Error("Thread already running");
|
|
138
|
+
}
|
|
139
|
+
store.isRunning = true;
|
|
140
|
+
store.currentRunId = request.input.runId;
|
|
141
|
+
store.agent = request.agent;
|
|
142
|
+
store.stopRequested = false;
|
|
143
|
+
const seenMessageIds = /* @__PURE__ */ new Set();
|
|
144
|
+
const currentRunEvents = [];
|
|
145
|
+
store.currentEvents = currentRunEvents;
|
|
146
|
+
const historicMessageIds = /* @__PURE__ */ new Set();
|
|
147
|
+
for (const run of store.historicRuns) {
|
|
148
|
+
for (const event of run.events) {
|
|
149
|
+
if ("messageId" in event && typeof event.messageId === "string") {
|
|
150
|
+
historicMessageIds.add(event.messageId);
|
|
151
|
+
}
|
|
152
|
+
if (event.type === import_client.EventType.RUN_STARTED) {
|
|
153
|
+
const runStarted = event;
|
|
154
|
+
const messages = runStarted.input?.messages ?? [];
|
|
155
|
+
for (const message of messages) {
|
|
156
|
+
historicMessageIds.add(message.id);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const nextSubject = new import_rxjs.ReplaySubject(Infinity);
|
|
162
|
+
const prevSubject = store.subject;
|
|
163
|
+
store.subject = nextSubject;
|
|
164
|
+
const runSubject = new import_rxjs.ReplaySubject(Infinity);
|
|
165
|
+
store.runSubject = runSubject;
|
|
166
|
+
const runAgent = async () => {
|
|
167
|
+
const lastRun = store.historicRuns[store.historicRuns.length - 1];
|
|
168
|
+
const parentRunId = lastRun?.runId ?? null;
|
|
169
|
+
try {
|
|
170
|
+
await request.agent.runAgent(request.input, {
|
|
171
|
+
onEvent: ({ event }) => {
|
|
172
|
+
let processedEvent = event;
|
|
173
|
+
if (event.type === import_client.EventType.RUN_STARTED) {
|
|
174
|
+
const runStartedEvent = event;
|
|
175
|
+
if (!runStartedEvent.input) {
|
|
176
|
+
const sanitizedMessages = request.input.messages ? request.input.messages.filter(
|
|
177
|
+
(message) => !historicMessageIds.has(message.id)
|
|
178
|
+
) : void 0;
|
|
179
|
+
const updatedInput = {
|
|
180
|
+
...request.input,
|
|
181
|
+
...sanitizedMessages !== void 0 ? { messages: sanitizedMessages } : {}
|
|
182
|
+
};
|
|
183
|
+
processedEvent = {
|
|
184
|
+
...runStartedEvent,
|
|
185
|
+
input: updatedInput
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
runSubject.next(processedEvent);
|
|
190
|
+
nextSubject.next(processedEvent);
|
|
191
|
+
currentRunEvents.push(processedEvent);
|
|
192
|
+
},
|
|
193
|
+
onNewMessage: ({ message }) => {
|
|
194
|
+
if (!seenMessageIds.has(message.id)) {
|
|
195
|
+
seenMessageIds.add(message.id);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
onRunStartedEvent: () => {
|
|
199
|
+
if (request.input.messages) {
|
|
200
|
+
for (const message of request.input.messages) {
|
|
201
|
+
if (!seenMessageIds.has(message.id)) {
|
|
202
|
+
seenMessageIds.add(message.id);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
const appendedEvents = (0, import_shared.finalizeRunEvents)(currentRunEvents, {
|
|
209
|
+
stopRequested: store.stopRequested
|
|
210
|
+
});
|
|
211
|
+
for (const event of appendedEvents) {
|
|
212
|
+
runSubject.next(event);
|
|
213
|
+
nextSubject.next(event);
|
|
214
|
+
}
|
|
215
|
+
if (store.currentRunId) {
|
|
216
|
+
const compactedEvents = (0, import_client.compactEvents)(currentRunEvents);
|
|
217
|
+
store.historicRuns.push({
|
|
218
|
+
threadId: request.threadId,
|
|
219
|
+
runId: store.currentRunId,
|
|
220
|
+
parentRunId,
|
|
221
|
+
events: compactedEvents,
|
|
222
|
+
createdAt: Date.now()
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
store.currentEvents = null;
|
|
226
|
+
store.currentRunId = null;
|
|
227
|
+
store.agent = null;
|
|
228
|
+
store.runSubject = null;
|
|
229
|
+
store.stopRequested = false;
|
|
230
|
+
store.isRunning = false;
|
|
231
|
+
runSubject.complete();
|
|
232
|
+
nextSubject.complete();
|
|
233
|
+
} catch {
|
|
234
|
+
const appendedEvents = (0, import_shared.finalizeRunEvents)(currentRunEvents, {
|
|
235
|
+
stopRequested: store.stopRequested
|
|
236
|
+
});
|
|
237
|
+
for (const event of appendedEvents) {
|
|
238
|
+
runSubject.next(event);
|
|
239
|
+
nextSubject.next(event);
|
|
240
|
+
}
|
|
241
|
+
if (store.currentRunId && currentRunEvents.length > 0) {
|
|
242
|
+
const compactedEvents = (0, import_client.compactEvents)(currentRunEvents);
|
|
243
|
+
store.historicRuns.push({
|
|
244
|
+
threadId: request.threadId,
|
|
245
|
+
runId: store.currentRunId,
|
|
246
|
+
parentRunId,
|
|
247
|
+
events: compactedEvents,
|
|
248
|
+
createdAt: Date.now()
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
store.currentEvents = null;
|
|
252
|
+
store.currentRunId = null;
|
|
253
|
+
store.agent = null;
|
|
254
|
+
store.runSubject = null;
|
|
255
|
+
store.stopRequested = false;
|
|
256
|
+
store.isRunning = false;
|
|
257
|
+
runSubject.complete();
|
|
258
|
+
nextSubject.complete();
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
if (prevSubject) {
|
|
262
|
+
prevSubject.subscribe({
|
|
263
|
+
next: (e) => nextSubject.next(e),
|
|
264
|
+
error: (err) => nextSubject.error(err),
|
|
265
|
+
complete: () => {
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
runAgent();
|
|
270
|
+
return runSubject.asObservable();
|
|
271
|
+
}
|
|
272
|
+
connect(request) {
|
|
273
|
+
const store = GLOBAL_STORE.get(request.threadId);
|
|
274
|
+
const connectionSubject = new import_rxjs.ReplaySubject(Infinity);
|
|
275
|
+
if (!store) {
|
|
276
|
+
connectionSubject.complete();
|
|
277
|
+
return connectionSubject.asObservable();
|
|
278
|
+
}
|
|
279
|
+
const allHistoricEvents = [];
|
|
280
|
+
for (const run of store.historicRuns) {
|
|
281
|
+
allHistoricEvents.push(...run.events);
|
|
282
|
+
}
|
|
283
|
+
const compactedEvents = (0, import_client.compactEvents)(allHistoricEvents);
|
|
284
|
+
const emittedMessageIds = /* @__PURE__ */ new Set();
|
|
285
|
+
for (const event of compactedEvents) {
|
|
286
|
+
connectionSubject.next(event);
|
|
287
|
+
if ("messageId" in event && typeof event.messageId === "string") {
|
|
288
|
+
emittedMessageIds.add(event.messageId);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (store.subject && (store.isRunning || store.stopRequested)) {
|
|
292
|
+
store.subject.subscribe({
|
|
293
|
+
next: (event) => {
|
|
294
|
+
if ("messageId" in event && typeof event.messageId === "string" && emittedMessageIds.has(event.messageId)) {
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
connectionSubject.next(event);
|
|
298
|
+
},
|
|
299
|
+
complete: () => connectionSubject.complete(),
|
|
300
|
+
error: (err) => connectionSubject.error(err)
|
|
301
|
+
});
|
|
302
|
+
} else {
|
|
303
|
+
connectionSubject.complete();
|
|
304
|
+
}
|
|
305
|
+
return connectionSubject.asObservable();
|
|
306
|
+
}
|
|
307
|
+
isRunning(request) {
|
|
308
|
+
const store = GLOBAL_STORE.get(request.threadId);
|
|
309
|
+
return Promise.resolve(store?.isRunning ?? false);
|
|
310
|
+
}
|
|
311
|
+
stop(request) {
|
|
312
|
+
const store = GLOBAL_STORE.get(request.threadId);
|
|
313
|
+
if (!store || !store.isRunning) {
|
|
314
|
+
return Promise.resolve(false);
|
|
315
|
+
}
|
|
316
|
+
if (store.stopRequested) {
|
|
317
|
+
return Promise.resolve(false);
|
|
318
|
+
}
|
|
319
|
+
store.stopRequested = true;
|
|
320
|
+
store.isRunning = false;
|
|
321
|
+
const agent = store.agent;
|
|
322
|
+
if (!agent) {
|
|
323
|
+
store.stopRequested = false;
|
|
324
|
+
store.isRunning = false;
|
|
325
|
+
return Promise.resolve(false);
|
|
326
|
+
}
|
|
327
|
+
try {
|
|
328
|
+
agent.abortRun();
|
|
329
|
+
return Promise.resolve(true);
|
|
330
|
+
} catch (error) {
|
|
331
|
+
console.error("Failed to abort agent run", error);
|
|
332
|
+
store.stopRequested = false;
|
|
333
|
+
store.isRunning = true;
|
|
334
|
+
return Promise.resolve(false);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// src/runtime.ts
|
|
340
|
+
var VERSION = package_default.version;
|
|
341
|
+
var CopilotRuntime = class {
|
|
342
|
+
agents;
|
|
343
|
+
transcriptionService;
|
|
344
|
+
beforeRequestMiddleware;
|
|
345
|
+
afterRequestMiddleware;
|
|
346
|
+
runner;
|
|
347
|
+
constructor({
|
|
348
|
+
agents,
|
|
349
|
+
transcriptionService,
|
|
350
|
+
beforeRequestMiddleware,
|
|
351
|
+
afterRequestMiddleware,
|
|
352
|
+
runner
|
|
353
|
+
}) {
|
|
354
|
+
this.agents = agents;
|
|
355
|
+
this.transcriptionService = transcriptionService;
|
|
356
|
+
this.beforeRequestMiddleware = beforeRequestMiddleware;
|
|
357
|
+
this.afterRequestMiddleware = afterRequestMiddleware;
|
|
358
|
+
this.runner = runner ?? new InMemoryAgentRunner();
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// src/endpoints/hono.ts
|
|
363
|
+
var import_hono = require("hono");
|
|
364
|
+
var import_cors = require("hono/cors");
|
|
365
|
+
|
|
366
|
+
// src/handlers/handle-run.ts
|
|
367
|
+
var import_client2 = require("@ag-ui/client");
|
|
368
|
+
var import_encoder = require("@ag-ui/encoder");
|
|
369
|
+
async function handleRunAgent({
|
|
370
|
+
runtime,
|
|
371
|
+
request,
|
|
372
|
+
agentId
|
|
373
|
+
}) {
|
|
374
|
+
try {
|
|
375
|
+
const agents = await runtime.agents;
|
|
376
|
+
if (!agents[agentId]) {
|
|
377
|
+
return new Response(
|
|
378
|
+
JSON.stringify({
|
|
379
|
+
error: "Agent not found",
|
|
380
|
+
message: `Agent '${agentId}' does not exist`
|
|
381
|
+
}),
|
|
382
|
+
{
|
|
383
|
+
status: 404,
|
|
384
|
+
headers: { "Content-Type": "application/json" }
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
const registeredAgent = agents[agentId];
|
|
389
|
+
const agent = registeredAgent.clone();
|
|
390
|
+
if (agent && "headers" in agent) {
|
|
391
|
+
const shouldForward = (headerName) => {
|
|
392
|
+
const lower = headerName.toLowerCase();
|
|
393
|
+
return lower === "authorization" || lower.startsWith("x-");
|
|
394
|
+
};
|
|
395
|
+
const forwardableHeaders = {};
|
|
396
|
+
request.headers.forEach((value, key) => {
|
|
397
|
+
if (shouldForward(key)) {
|
|
398
|
+
forwardableHeaders[key] = value;
|
|
399
|
+
}
|
|
400
|
+
});
|
|
401
|
+
agent.headers = {
|
|
402
|
+
...agent.headers,
|
|
403
|
+
...forwardableHeaders
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
const stream = new TransformStream();
|
|
407
|
+
const writer = stream.writable.getWriter();
|
|
408
|
+
const encoder = new import_encoder.EventEncoder();
|
|
409
|
+
let streamClosed = false;
|
|
410
|
+
(async () => {
|
|
411
|
+
let input;
|
|
412
|
+
try {
|
|
413
|
+
const requestBody = await request.json();
|
|
414
|
+
input = import_client2.RunAgentInputSchema.parse(requestBody);
|
|
415
|
+
} catch {
|
|
416
|
+
return new Response(
|
|
417
|
+
JSON.stringify({
|
|
418
|
+
error: "Invalid request body"
|
|
419
|
+
}),
|
|
420
|
+
{ status: 400 }
|
|
421
|
+
);
|
|
422
|
+
}
|
|
423
|
+
agent.setMessages(input.messages);
|
|
424
|
+
agent.setState(input.state);
|
|
425
|
+
agent.threadId = input.threadId;
|
|
426
|
+
runtime.runner.run({
|
|
427
|
+
threadId: input.threadId,
|
|
428
|
+
agent,
|
|
429
|
+
input
|
|
430
|
+
}).subscribe({
|
|
431
|
+
next: async (event) => {
|
|
432
|
+
if (!request.signal.aborted && !streamClosed) {
|
|
433
|
+
try {
|
|
434
|
+
await writer.write(encoder.encode(event));
|
|
435
|
+
} catch (error) {
|
|
436
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
437
|
+
streamClosed = true;
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
},
|
|
442
|
+
error: async (error) => {
|
|
443
|
+
console.error("Error running agent:", error);
|
|
444
|
+
if (!streamClosed) {
|
|
445
|
+
try {
|
|
446
|
+
await writer.close();
|
|
447
|
+
streamClosed = true;
|
|
448
|
+
} catch {
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
},
|
|
452
|
+
complete: async () => {
|
|
453
|
+
if (!streamClosed) {
|
|
454
|
+
try {
|
|
455
|
+
await writer.close();
|
|
456
|
+
streamClosed = true;
|
|
457
|
+
} catch {
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
})().catch((error) => {
|
|
463
|
+
console.error("Error running agent:", error);
|
|
464
|
+
console.error(
|
|
465
|
+
"Error stack:",
|
|
466
|
+
error instanceof Error ? error.stack : "No stack trace"
|
|
467
|
+
);
|
|
468
|
+
console.error("Error details:", {
|
|
469
|
+
name: error instanceof Error ? error.name : "Unknown",
|
|
470
|
+
message: error instanceof Error ? error.message : String(error),
|
|
471
|
+
cause: error instanceof Error ? error.cause : void 0
|
|
472
|
+
});
|
|
473
|
+
if (!streamClosed) {
|
|
474
|
+
try {
|
|
475
|
+
writer.close();
|
|
476
|
+
streamClosed = true;
|
|
477
|
+
} catch {
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
return new Response(stream.readable, {
|
|
482
|
+
status: 200,
|
|
483
|
+
headers: {
|
|
484
|
+
"Content-Type": "text/event-stream",
|
|
485
|
+
"Cache-Control": "no-cache",
|
|
486
|
+
Connection: "keep-alive"
|
|
487
|
+
}
|
|
488
|
+
});
|
|
489
|
+
} catch (error) {
|
|
490
|
+
console.error("Error running agent:", error);
|
|
491
|
+
console.error(
|
|
492
|
+
"Error stack:",
|
|
493
|
+
error instanceof Error ? error.stack : "No stack trace"
|
|
494
|
+
);
|
|
495
|
+
console.error("Error details:", {
|
|
496
|
+
name: error instanceof Error ? error.name : "Unknown",
|
|
497
|
+
message: error instanceof Error ? error.message : String(error),
|
|
498
|
+
cause: error instanceof Error ? error.cause : void 0
|
|
499
|
+
});
|
|
500
|
+
return new Response(
|
|
501
|
+
JSON.stringify({
|
|
502
|
+
error: "Failed to run agent",
|
|
503
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
504
|
+
}),
|
|
505
|
+
{
|
|
506
|
+
status: 500,
|
|
507
|
+
headers: { "Content-Type": "application/json" }
|
|
508
|
+
}
|
|
509
|
+
);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
// src/handlers/get-runtime-info.ts
|
|
514
|
+
async function handleGetRuntimeInfo({
|
|
515
|
+
runtime
|
|
516
|
+
}) {
|
|
517
|
+
try {
|
|
518
|
+
const agents = await runtime.agents;
|
|
519
|
+
const agentsDict = Object.entries(agents).reduce(
|
|
520
|
+
(acc, [name, agent]) => {
|
|
521
|
+
acc[name] = {
|
|
522
|
+
name,
|
|
523
|
+
description: agent.description,
|
|
524
|
+
className: agent.constructor.name
|
|
525
|
+
};
|
|
526
|
+
return acc;
|
|
527
|
+
},
|
|
528
|
+
{}
|
|
529
|
+
);
|
|
530
|
+
const runtimeInfo = {
|
|
531
|
+
version: VERSION,
|
|
532
|
+
agents: agentsDict,
|
|
533
|
+
audioFileTranscriptionEnabled: !!runtime.transcriptionService
|
|
534
|
+
};
|
|
535
|
+
return new Response(JSON.stringify(runtimeInfo), {
|
|
536
|
+
status: 200,
|
|
537
|
+
headers: { "Content-Type": "application/json" }
|
|
538
|
+
});
|
|
539
|
+
} catch (error) {
|
|
540
|
+
return new Response(
|
|
541
|
+
JSON.stringify({
|
|
542
|
+
error: "Failed to retrieve runtime information",
|
|
543
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
544
|
+
}),
|
|
545
|
+
{
|
|
546
|
+
status: 500,
|
|
547
|
+
headers: { "Content-Type": "application/json" }
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
// src/handlers/handle-transcribe.ts
|
|
554
|
+
async function handleTranscribe({
|
|
555
|
+
runtime,
|
|
556
|
+
request
|
|
557
|
+
}) {
|
|
558
|
+
try {
|
|
559
|
+
if (!runtime.transcriptionService) {
|
|
560
|
+
return new Response(
|
|
561
|
+
JSON.stringify({
|
|
562
|
+
error: "Transcription service not configured",
|
|
563
|
+
message: "No transcription service has been configured in the runtime"
|
|
564
|
+
}),
|
|
565
|
+
{
|
|
566
|
+
status: 503,
|
|
567
|
+
headers: { "Content-Type": "application/json" }
|
|
568
|
+
}
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
const contentType = request.headers.get("content-type");
|
|
572
|
+
if (!contentType || !contentType.includes("multipart/form-data")) {
|
|
573
|
+
return new Response(
|
|
574
|
+
JSON.stringify({
|
|
575
|
+
error: "Invalid content type",
|
|
576
|
+
message: "Request must contain multipart/form-data with an audio file"
|
|
577
|
+
}),
|
|
578
|
+
{
|
|
579
|
+
status: 400,
|
|
580
|
+
headers: { "Content-Type": "application/json" }
|
|
581
|
+
}
|
|
582
|
+
);
|
|
583
|
+
}
|
|
584
|
+
const formData = await request.formData();
|
|
585
|
+
const audioFile = formData.get("audio");
|
|
586
|
+
if (!audioFile || !(audioFile instanceof File)) {
|
|
587
|
+
return new Response(
|
|
588
|
+
JSON.stringify({
|
|
589
|
+
error: "Missing audio file",
|
|
590
|
+
message: "No audio file found in form data. Please include an 'audio' field."
|
|
591
|
+
}),
|
|
592
|
+
{
|
|
593
|
+
status: 400,
|
|
594
|
+
headers: { "Content-Type": "application/json" }
|
|
595
|
+
}
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
const validAudioTypes = [
|
|
599
|
+
"audio/mpeg",
|
|
600
|
+
"audio/mp3",
|
|
601
|
+
"audio/mp4",
|
|
602
|
+
"audio/wav",
|
|
603
|
+
"audio/webm",
|
|
604
|
+
"audio/ogg",
|
|
605
|
+
"audio/flac",
|
|
606
|
+
"audio/aac"
|
|
607
|
+
];
|
|
608
|
+
const isValidType = validAudioTypes.includes(audioFile.type) || audioFile.type === "" || audioFile.type === "application/octet-stream";
|
|
609
|
+
if (!isValidType) {
|
|
610
|
+
return new Response(
|
|
611
|
+
JSON.stringify({
|
|
612
|
+
error: "Invalid file type",
|
|
613
|
+
message: `Unsupported audio file type: ${audioFile.type}. Supported types: ${validAudioTypes.join(", ")}, or files with unknown/empty types`
|
|
614
|
+
}),
|
|
615
|
+
{
|
|
616
|
+
status: 400,
|
|
617
|
+
headers: { "Content-Type": "application/json" }
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
const transcription = await runtime.transcriptionService.transcribeFile({
|
|
622
|
+
audioFile,
|
|
623
|
+
mimeType: audioFile.type,
|
|
624
|
+
size: audioFile.size
|
|
625
|
+
});
|
|
626
|
+
return new Response(
|
|
627
|
+
JSON.stringify({
|
|
628
|
+
text: transcription,
|
|
629
|
+
size: audioFile.size,
|
|
630
|
+
type: audioFile.type
|
|
631
|
+
}),
|
|
632
|
+
{
|
|
633
|
+
status: 200,
|
|
634
|
+
headers: { "Content-Type": "application/json" }
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
} catch (error) {
|
|
638
|
+
return new Response(
|
|
639
|
+
JSON.stringify({
|
|
640
|
+
error: "Transcription failed",
|
|
641
|
+
message: error instanceof Error ? error.message : "Unknown error occurred during transcription"
|
|
642
|
+
}),
|
|
643
|
+
{
|
|
644
|
+
status: 500,
|
|
645
|
+
headers: { "Content-Type": "application/json" }
|
|
646
|
+
}
|
|
647
|
+
);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// src/endpoints/hono.ts
|
|
652
|
+
var import_shared3 = require("@copilotkitnext/shared");
|
|
653
|
+
|
|
654
|
+
// src/middleware.ts
|
|
655
|
+
var import_shared2 = require("@copilotkitnext/shared");
|
|
656
|
+
async function callBeforeRequestMiddleware({
|
|
657
|
+
runtime,
|
|
658
|
+
request,
|
|
659
|
+
path
|
|
660
|
+
}) {
|
|
661
|
+
const mw = runtime.beforeRequestMiddleware;
|
|
662
|
+
if (!mw) return;
|
|
663
|
+
if (typeof mw === "function") {
|
|
664
|
+
return mw({ runtime, request, path });
|
|
665
|
+
}
|
|
666
|
+
import_shared2.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value \u2013 skipped");
|
|
667
|
+
return;
|
|
668
|
+
}
|
|
669
|
+
async function callAfterRequestMiddleware({
|
|
670
|
+
runtime,
|
|
671
|
+
response,
|
|
672
|
+
path
|
|
673
|
+
}) {
|
|
674
|
+
const mw = runtime.afterRequestMiddleware;
|
|
675
|
+
if (!mw) return;
|
|
676
|
+
if (typeof mw === "function") {
|
|
677
|
+
return mw({ runtime, response, path });
|
|
678
|
+
}
|
|
679
|
+
import_shared2.logger.warn({ mw }, "Unsupported afterRequestMiddleware value \u2013 skipped");
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// src/handlers/handle-connect.ts
|
|
683
|
+
var import_client3 = require("@ag-ui/client");
|
|
684
|
+
var import_encoder2 = require("@ag-ui/encoder");
|
|
685
|
+
async function handleConnectAgent({
|
|
686
|
+
runtime,
|
|
687
|
+
request,
|
|
688
|
+
agentId
|
|
689
|
+
}) {
|
|
690
|
+
try {
|
|
691
|
+
const agents = await runtime.agents;
|
|
692
|
+
if (!agents[agentId]) {
|
|
693
|
+
return new Response(
|
|
694
|
+
JSON.stringify({
|
|
695
|
+
error: "Agent not found",
|
|
696
|
+
message: `Agent '${agentId}' does not exist`
|
|
697
|
+
}),
|
|
698
|
+
{
|
|
699
|
+
status: 404,
|
|
700
|
+
headers: { "Content-Type": "application/json" }
|
|
701
|
+
}
|
|
702
|
+
);
|
|
703
|
+
}
|
|
704
|
+
const stream = new TransformStream();
|
|
705
|
+
const writer = stream.writable.getWriter();
|
|
706
|
+
const encoder = new import_encoder2.EventEncoder();
|
|
707
|
+
let streamClosed = false;
|
|
708
|
+
(async () => {
|
|
709
|
+
let input;
|
|
710
|
+
try {
|
|
711
|
+
const requestBody = await request.json();
|
|
712
|
+
input = import_client3.RunAgentInputSchema.parse(requestBody);
|
|
713
|
+
} catch {
|
|
714
|
+
return new Response(
|
|
715
|
+
JSON.stringify({
|
|
716
|
+
error: "Invalid request body"
|
|
717
|
+
}),
|
|
718
|
+
{ status: 400 }
|
|
719
|
+
);
|
|
720
|
+
}
|
|
721
|
+
runtime.runner.connect({
|
|
722
|
+
threadId: input.threadId
|
|
723
|
+
}).subscribe({
|
|
724
|
+
next: async (event) => {
|
|
725
|
+
if (!request.signal.aborted && !streamClosed) {
|
|
726
|
+
try {
|
|
727
|
+
await writer.write(encoder.encode(event));
|
|
728
|
+
} catch (error) {
|
|
729
|
+
if (error instanceof Error && error.name === "AbortError") {
|
|
730
|
+
streamClosed = true;
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
},
|
|
735
|
+
error: async (error) => {
|
|
736
|
+
console.error("Error running agent:", error);
|
|
737
|
+
if (!streamClosed) {
|
|
738
|
+
try {
|
|
739
|
+
await writer.close();
|
|
740
|
+
streamClosed = true;
|
|
741
|
+
} catch {
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
},
|
|
745
|
+
complete: async () => {
|
|
746
|
+
if (!streamClosed) {
|
|
747
|
+
try {
|
|
748
|
+
await writer.close();
|
|
749
|
+
streamClosed = true;
|
|
750
|
+
} catch {
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
})().catch((error) => {
|
|
756
|
+
console.error("Error running agent:", error);
|
|
757
|
+
console.error(
|
|
758
|
+
"Error stack:",
|
|
759
|
+
error instanceof Error ? error.stack : "No stack trace"
|
|
760
|
+
);
|
|
761
|
+
console.error("Error details:", {
|
|
762
|
+
name: error instanceof Error ? error.name : "Unknown",
|
|
763
|
+
message: error instanceof Error ? error.message : String(error),
|
|
764
|
+
cause: error instanceof Error ? error.cause : void 0
|
|
765
|
+
});
|
|
766
|
+
if (!streamClosed) {
|
|
767
|
+
try {
|
|
768
|
+
writer.close();
|
|
769
|
+
streamClosed = true;
|
|
770
|
+
} catch {
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
});
|
|
774
|
+
return new Response(stream.readable, {
|
|
775
|
+
status: 200,
|
|
776
|
+
headers: {
|
|
777
|
+
"Content-Type": "text/event-stream",
|
|
778
|
+
"Cache-Control": "no-cache",
|
|
779
|
+
Connection: "keep-alive"
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
} catch (error) {
|
|
783
|
+
console.error("Error running agent:", error);
|
|
784
|
+
console.error(
|
|
785
|
+
"Error stack:",
|
|
786
|
+
error instanceof Error ? error.stack : "No stack trace"
|
|
787
|
+
);
|
|
788
|
+
console.error("Error details:", {
|
|
789
|
+
name: error instanceof Error ? error.name : "Unknown",
|
|
790
|
+
message: error instanceof Error ? error.message : String(error),
|
|
791
|
+
cause: error instanceof Error ? error.cause : void 0
|
|
792
|
+
});
|
|
793
|
+
return new Response(
|
|
794
|
+
JSON.stringify({
|
|
795
|
+
error: "Failed to run agent",
|
|
796
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
797
|
+
}),
|
|
798
|
+
{
|
|
799
|
+
status: 500,
|
|
800
|
+
headers: { "Content-Type": "application/json" }
|
|
801
|
+
}
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
// src/handlers/handle-stop.ts
|
|
807
|
+
var import_client4 = require("@ag-ui/client");
|
|
808
|
+
async function handleStopAgent({
|
|
809
|
+
runtime,
|
|
810
|
+
request,
|
|
811
|
+
agentId,
|
|
812
|
+
threadId
|
|
813
|
+
}) {
|
|
814
|
+
try {
|
|
815
|
+
const agents = await runtime.agents;
|
|
816
|
+
if (!agents[agentId]) {
|
|
817
|
+
return new Response(
|
|
818
|
+
JSON.stringify({
|
|
819
|
+
error: "Agent not found",
|
|
820
|
+
message: `Agent '${agentId}' does not exist`
|
|
821
|
+
}),
|
|
822
|
+
{
|
|
823
|
+
status: 404,
|
|
824
|
+
headers: { "Content-Type": "application/json" }
|
|
825
|
+
}
|
|
826
|
+
);
|
|
827
|
+
}
|
|
828
|
+
const stopped = await runtime.runner.stop({ threadId });
|
|
829
|
+
if (!stopped) {
|
|
830
|
+
return new Response(
|
|
831
|
+
JSON.stringify({
|
|
832
|
+
stopped: false,
|
|
833
|
+
message: `No active run for thread '${threadId}'.`
|
|
834
|
+
}),
|
|
835
|
+
{
|
|
836
|
+
status: 200,
|
|
837
|
+
headers: { "Content-Type": "application/json" }
|
|
838
|
+
}
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
return new Response(
|
|
842
|
+
JSON.stringify({
|
|
843
|
+
stopped: true,
|
|
844
|
+
interrupt: {
|
|
845
|
+
type: import_client4.EventType.RUN_ERROR,
|
|
846
|
+
message: "Run stopped by user",
|
|
847
|
+
code: "STOPPED"
|
|
848
|
+
}
|
|
849
|
+
}),
|
|
850
|
+
{
|
|
851
|
+
status: 200,
|
|
852
|
+
headers: { "Content-Type": "application/json" }
|
|
853
|
+
}
|
|
854
|
+
);
|
|
855
|
+
} catch (error) {
|
|
856
|
+
console.error("Error stopping agent run:", error);
|
|
857
|
+
return new Response(
|
|
858
|
+
JSON.stringify({
|
|
859
|
+
error: "Failed to stop agent",
|
|
860
|
+
message: error instanceof Error ? error.message : "Unknown error"
|
|
861
|
+
}),
|
|
862
|
+
{
|
|
863
|
+
status: 500,
|
|
864
|
+
headers: { "Content-Type": "application/json" }
|
|
865
|
+
}
|
|
866
|
+
);
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
// src/endpoints/hono.ts
|
|
871
|
+
function createCopilotEndpoint({ runtime, basePath }) {
|
|
872
|
+
const app = new import_hono.Hono();
|
|
873
|
+
return app.basePath(basePath).use(
|
|
874
|
+
"*",
|
|
875
|
+
(0, import_cors.cors)({
|
|
876
|
+
origin: "*",
|
|
877
|
+
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
|
|
878
|
+
allowHeaders: ["*"]
|
|
879
|
+
})
|
|
880
|
+
).use("*", async (c, next) => {
|
|
881
|
+
const request = c.req.raw;
|
|
882
|
+
const path = c.req.path;
|
|
883
|
+
try {
|
|
884
|
+
const maybeModifiedRequest = await callBeforeRequestMiddleware({
|
|
885
|
+
runtime,
|
|
886
|
+
request,
|
|
887
|
+
path
|
|
888
|
+
});
|
|
889
|
+
if (maybeModifiedRequest) {
|
|
890
|
+
c.set("modifiedRequest", maybeModifiedRequest);
|
|
891
|
+
}
|
|
892
|
+
} catch (error) {
|
|
893
|
+
import_shared3.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
|
|
894
|
+
if (error instanceof Response) {
|
|
895
|
+
return error;
|
|
896
|
+
}
|
|
897
|
+
throw error;
|
|
898
|
+
}
|
|
899
|
+
await next();
|
|
900
|
+
}).use("*", async (c, next) => {
|
|
901
|
+
await next();
|
|
902
|
+
const response = c.res;
|
|
903
|
+
const path = c.req.path;
|
|
904
|
+
callAfterRequestMiddleware({
|
|
905
|
+
runtime,
|
|
906
|
+
response,
|
|
907
|
+
path
|
|
908
|
+
}).catch((error) => {
|
|
909
|
+
import_shared3.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
|
|
910
|
+
});
|
|
911
|
+
}).post("/agent/:agentId/run", async (c) => {
|
|
912
|
+
const agentId = c.req.param("agentId");
|
|
913
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
914
|
+
try {
|
|
915
|
+
return await handleRunAgent({
|
|
916
|
+
runtime,
|
|
917
|
+
request,
|
|
918
|
+
agentId
|
|
919
|
+
});
|
|
920
|
+
} catch (error) {
|
|
921
|
+
import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
922
|
+
throw error;
|
|
923
|
+
}
|
|
924
|
+
}).post("/agent/:agentId/connect", async (c) => {
|
|
925
|
+
const agentId = c.req.param("agentId");
|
|
926
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
927
|
+
try {
|
|
928
|
+
return await handleConnectAgent({
|
|
929
|
+
runtime,
|
|
930
|
+
request,
|
|
931
|
+
agentId
|
|
932
|
+
});
|
|
933
|
+
} catch (error) {
|
|
934
|
+
import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
935
|
+
throw error;
|
|
936
|
+
}
|
|
937
|
+
}).post("/agent/:agentId/stop/:threadId", async (c) => {
|
|
938
|
+
const agentId = c.req.param("agentId");
|
|
939
|
+
const threadId = c.req.param("threadId");
|
|
940
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
941
|
+
try {
|
|
942
|
+
return await handleStopAgent({
|
|
943
|
+
runtime,
|
|
944
|
+
request,
|
|
945
|
+
agentId,
|
|
946
|
+
threadId
|
|
947
|
+
});
|
|
948
|
+
} catch (error) {
|
|
949
|
+
import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
950
|
+
throw error;
|
|
951
|
+
}
|
|
952
|
+
}).get("/info", async (c) => {
|
|
953
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
954
|
+
try {
|
|
955
|
+
return await handleGetRuntimeInfo({
|
|
956
|
+
runtime,
|
|
957
|
+
request
|
|
958
|
+
});
|
|
959
|
+
} catch (error) {
|
|
960
|
+
import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
961
|
+
throw error;
|
|
962
|
+
}
|
|
963
|
+
}).post("/transcribe", async (c) => {
|
|
964
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
965
|
+
try {
|
|
966
|
+
return await handleTranscribe({
|
|
967
|
+
runtime,
|
|
968
|
+
request
|
|
969
|
+
});
|
|
970
|
+
} catch (error) {
|
|
971
|
+
import_shared3.logger.error({ err: error, url: request.url, path: c.req.path }, "Error running request handler");
|
|
972
|
+
throw error;
|
|
973
|
+
}
|
|
974
|
+
}).notFound((c) => {
|
|
975
|
+
return c.json({ error: "Not found" }, 404);
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
// src/endpoints/hono-single.ts
|
|
980
|
+
var import_hono2 = require("hono");
|
|
981
|
+
var import_cors2 = require("hono/cors");
|
|
982
|
+
var import_shared4 = require("@copilotkitnext/shared");
|
|
983
|
+
|
|
984
|
+
// src/endpoints/single-route-helpers.ts
|
|
985
|
+
var METHOD_NAMES = [
|
|
986
|
+
"agent/run",
|
|
987
|
+
"agent/connect",
|
|
988
|
+
"agent/stop",
|
|
989
|
+
"info",
|
|
990
|
+
"transcribe"
|
|
991
|
+
];
|
|
992
|
+
async function parseMethodCall(request) {
|
|
993
|
+
const contentType = request.headers.get("content-type") || "";
|
|
994
|
+
if (!contentType.includes("application/json")) {
|
|
995
|
+
throw createResponseError("Single-route endpoint expects JSON payloads", 415);
|
|
996
|
+
}
|
|
997
|
+
let jsonEnvelope;
|
|
998
|
+
try {
|
|
999
|
+
jsonEnvelope = await request.clone().json();
|
|
1000
|
+
} catch (error) {
|
|
1001
|
+
throw createResponseError("Invalid JSON payload", 400);
|
|
1002
|
+
}
|
|
1003
|
+
const method = validateMethod(jsonEnvelope.method);
|
|
1004
|
+
return {
|
|
1005
|
+
method,
|
|
1006
|
+
params: jsonEnvelope.params,
|
|
1007
|
+
body: jsonEnvelope.body
|
|
1008
|
+
};
|
|
1009
|
+
}
|
|
1010
|
+
function expectString(params, key) {
|
|
1011
|
+
const value = params?.[key];
|
|
1012
|
+
if (typeof value === "string" && value.trim().length > 0) {
|
|
1013
|
+
return value;
|
|
1014
|
+
}
|
|
1015
|
+
throw createResponseError(`Missing or invalid parameter '${key}'`, 400);
|
|
1016
|
+
}
|
|
1017
|
+
function createJsonRequest(base, body) {
|
|
1018
|
+
if (body === void 0 || body === null) {
|
|
1019
|
+
throw createResponseError("Missing request body for JSON handler", 400);
|
|
1020
|
+
}
|
|
1021
|
+
const headers = new Headers(base.headers);
|
|
1022
|
+
headers.set("content-type", "application/json");
|
|
1023
|
+
headers.delete("content-length");
|
|
1024
|
+
const serializedBody = serializeJsonBody(body);
|
|
1025
|
+
return new Request(base.url, {
|
|
1026
|
+
method: "POST",
|
|
1027
|
+
headers,
|
|
1028
|
+
body: serializedBody,
|
|
1029
|
+
signal: base.signal
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
function createResponseError(message, status) {
|
|
1033
|
+
return new Response(
|
|
1034
|
+
JSON.stringify({
|
|
1035
|
+
error: "invalid_request",
|
|
1036
|
+
message
|
|
1037
|
+
}),
|
|
1038
|
+
{
|
|
1039
|
+
status,
|
|
1040
|
+
headers: {
|
|
1041
|
+
"Content-Type": "application/json"
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
);
|
|
1045
|
+
}
|
|
1046
|
+
function validateMethod(method) {
|
|
1047
|
+
if (!method) {
|
|
1048
|
+
throw createResponseError("Missing method field", 400);
|
|
1049
|
+
}
|
|
1050
|
+
if (METHOD_NAMES.includes(method)) {
|
|
1051
|
+
return method;
|
|
1052
|
+
}
|
|
1053
|
+
throw createResponseError(`Unsupported method '${method}'`, 400);
|
|
1054
|
+
}
|
|
1055
|
+
function serializeJsonBody(body) {
|
|
1056
|
+
if (typeof body === "string") {
|
|
1057
|
+
return body;
|
|
1058
|
+
}
|
|
1059
|
+
if (body instanceof Blob || body instanceof ArrayBuffer || body instanceof Uint8Array) {
|
|
1060
|
+
return body;
|
|
1061
|
+
}
|
|
1062
|
+
if (body instanceof FormData || body instanceof URLSearchParams) {
|
|
1063
|
+
return body;
|
|
1064
|
+
}
|
|
1065
|
+
return JSON.stringify(body);
|
|
1066
|
+
}
|
|
1067
|
+
|
|
1068
|
+
// src/endpoints/hono-single.ts
|
|
1069
|
+
function createCopilotEndpointSingleRoute({ runtime, basePath }) {
|
|
1070
|
+
const app = new import_hono2.Hono();
|
|
1071
|
+
const routePath = normalizePath(basePath);
|
|
1072
|
+
return app.basePath(routePath).use(
|
|
1073
|
+
"*",
|
|
1074
|
+
(0, import_cors2.cors)({
|
|
1075
|
+
origin: "*",
|
|
1076
|
+
allowMethods: ["GET", "HEAD", "PUT", "POST", "DELETE", "PATCH", "OPTIONS"],
|
|
1077
|
+
allowHeaders: ["*"]
|
|
1078
|
+
})
|
|
1079
|
+
).use("*", async (c, next) => {
|
|
1080
|
+
const request = c.req.raw;
|
|
1081
|
+
const path = c.req.path;
|
|
1082
|
+
try {
|
|
1083
|
+
const maybeModifiedRequest = await callBeforeRequestMiddleware({
|
|
1084
|
+
runtime,
|
|
1085
|
+
request,
|
|
1086
|
+
path
|
|
1087
|
+
});
|
|
1088
|
+
if (maybeModifiedRequest) {
|
|
1089
|
+
c.set("modifiedRequest", maybeModifiedRequest);
|
|
1090
|
+
}
|
|
1091
|
+
} catch (error) {
|
|
1092
|
+
import_shared4.logger.error({ err: error, url: request.url, path }, "Error running before request middleware");
|
|
1093
|
+
if (error instanceof Response) {
|
|
1094
|
+
return error;
|
|
1095
|
+
}
|
|
1096
|
+
throw error;
|
|
1097
|
+
}
|
|
1098
|
+
await next();
|
|
1099
|
+
}).use("*", async (c, next) => {
|
|
1100
|
+
await next();
|
|
1101
|
+
const response = c.res;
|
|
1102
|
+
const path = c.req.path;
|
|
1103
|
+
callAfterRequestMiddleware({
|
|
1104
|
+
runtime,
|
|
1105
|
+
response,
|
|
1106
|
+
path
|
|
1107
|
+
}).catch((error) => {
|
|
1108
|
+
import_shared4.logger.error({ err: error, url: c.req.url, path }, "Error running after request middleware");
|
|
1109
|
+
});
|
|
1110
|
+
}).post("/", async (c) => {
|
|
1111
|
+
const request = c.get("modifiedRequest") || c.req.raw;
|
|
1112
|
+
let methodCall;
|
|
1113
|
+
try {
|
|
1114
|
+
methodCall = await parseMethodCall(request);
|
|
1115
|
+
} catch (error) {
|
|
1116
|
+
if (error instanceof Response) {
|
|
1117
|
+
import_shared4.logger.warn({ url: request.url }, "Invalid single-route payload");
|
|
1118
|
+
return error;
|
|
1119
|
+
}
|
|
1120
|
+
import_shared4.logger.warn({ err: error, url: request.url }, "Invalid single-route payload");
|
|
1121
|
+
return c.json(
|
|
1122
|
+
{
|
|
1123
|
+
error: "invalid_request",
|
|
1124
|
+
message: error instanceof Error ? error.message : "Invalid request payload"
|
|
1125
|
+
},
|
|
1126
|
+
400
|
|
1127
|
+
);
|
|
1128
|
+
}
|
|
1129
|
+
try {
|
|
1130
|
+
switch (methodCall.method) {
|
|
1131
|
+
case "agent/run": {
|
|
1132
|
+
const agentId = expectString(methodCall.params, "agentId");
|
|
1133
|
+
const handlerRequest = createJsonRequest(request, methodCall.body);
|
|
1134
|
+
return await handleRunAgent({ runtime, request: handlerRequest, agentId });
|
|
1135
|
+
}
|
|
1136
|
+
case "agent/connect": {
|
|
1137
|
+
const agentId = expectString(methodCall.params, "agentId");
|
|
1138
|
+
const handlerRequest = createJsonRequest(request, methodCall.body);
|
|
1139
|
+
return await handleConnectAgent({ runtime, request: handlerRequest, agentId });
|
|
1140
|
+
}
|
|
1141
|
+
case "agent/stop": {
|
|
1142
|
+
const agentId = expectString(methodCall.params, "agentId");
|
|
1143
|
+
const threadId = expectString(methodCall.params, "threadId");
|
|
1144
|
+
return await handleStopAgent({ runtime, request, agentId, threadId });
|
|
1145
|
+
}
|
|
1146
|
+
case "info": {
|
|
1147
|
+
return await handleGetRuntimeInfo({ runtime, request });
|
|
1148
|
+
}
|
|
1149
|
+
case "transcribe": {
|
|
1150
|
+
return await handleTranscribe({ runtime, request });
|
|
1151
|
+
}
|
|
1152
|
+
default: {
|
|
1153
|
+
const exhaustiveCheck = methodCall.method;
|
|
1154
|
+
return exhaustiveCheck;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
} catch (error) {
|
|
1158
|
+
if (error instanceof Response) {
|
|
1159
|
+
return error;
|
|
1160
|
+
}
|
|
1161
|
+
import_shared4.logger.error({ err: error, url: request.url, method: methodCall.method }, "Error running single-route handler");
|
|
1162
|
+
throw error;
|
|
1163
|
+
}
|
|
1164
|
+
}).notFound((c) => {
|
|
1165
|
+
return c.json({ error: "Not found" }, 404);
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
function normalizePath(path) {
|
|
1169
|
+
if (!path) {
|
|
1170
|
+
throw new Error("basePath must be provided for single-route endpoint");
|
|
1171
|
+
}
|
|
1172
|
+
if (!path.startsWith("/")) {
|
|
1173
|
+
return `/${path}`;
|
|
1174
|
+
}
|
|
1175
|
+
if (path.length > 1 && path.endsWith("/")) {
|
|
1176
|
+
return path.slice(0, -1);
|
|
1177
|
+
}
|
|
1178
|
+
return path;
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
// src/runner/index.ts
|
|
1182
|
+
var import_shared5 = require("@copilotkitnext/shared");
|
|
1183
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1184
|
+
0 && (module.exports = {
|
|
1185
|
+
AgentRunner,
|
|
1186
|
+
CopilotRuntime,
|
|
1187
|
+
InMemoryAgentRunner,
|
|
1188
|
+
VERSION,
|
|
1189
|
+
createCopilotEndpoint,
|
|
1190
|
+
createCopilotEndpointSingleRoute,
|
|
1191
|
+
finalizeRunEvents
|
|
1192
|
+
});
|
|
23
1193
|
//# sourceMappingURL=index.js.map
|