site-operator 0.1.0

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.
@@ -0,0 +1,724 @@
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.SiteOperator={}))})(this,function(e){var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(e&&(t=e(e=0)),t),c=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),l=e=>{let t={};for(var r in e)n(t,r,{get:e[r],enumerable:!0});return t},u=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},d=(e,r,i)=>(i=e==null?{}:t(a(e)),u(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e)),f=e=>u(n({},`__esModule`,{value:!0}),e),p=globalThis,m=p.ShadowRoot&&(p.ShadyCSS===void 0||p.ShadyCSS.nativeShadow)&&`adoptedStyleSheets`in Document.prototype&&`replace`in CSSStyleSheet.prototype,ee=Symbol(),te=new WeakMap,ne=class{constructor(e,t,n){if(this._$cssResult$=!0,n!==ee)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o,t=this.t;if(m&&e===void 0){let n=t!==void 0&&t.length===1;n&&(e=te.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&te.set(t,e))}return e}toString(){return this.cssText}},re=e=>new ne(typeof e==`string`?e:e+``,void 0,ee),ie=(e,...t)=>new ne(e.length===1?e[0]:t.reduce((t,n,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if(typeof e==`number`)return e;throw Error(`Value passed to 'css' function must be a 'css' function result: `+e+`. Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.`)})(n)+e[r+1],e[0]),e,ee),ae=(e,t)=>{if(m)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let n of t){let t=document.createElement(`style`),r=p.litNonce;r!==void 0&&t.setAttribute(`nonce`,r),t.textContent=n.cssText,e.appendChild(t)}},oe=m?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t=``;for(let n of e.cssRules)t+=n.cssText;return re(t)})(e):e,{is:se,defineProperty:ce,getOwnPropertyDescriptor:le,getOwnPropertyNames:ue,getOwnPropertySymbols:de,getPrototypeOf:fe}=Object,pe=globalThis,me=pe.trustedTypes,he=me?me.emptyScript:``,ge=pe.reactiveElementPolyfillSupport,_e=(e,t)=>e,ve={toAttribute(e,t){switch(t){case Boolean:e=e?he:null;break;case Object:case Array:e=e==null?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=e!==null;break;case Number:n=e===null?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch{n=null}}return n}},ye=(e,t)=>!se(e,t),be={attribute:!0,type:String,converter:ve,reflect:!1,useDefault:!1,hasChanged:ye};Symbol.metadata??=Symbol(`metadata`),pe.litPropertyMetadata??=new WeakMap;var xe=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=be){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){let n=Symbol(),r=this.getPropertyDescriptor(e,n,t);r!==void 0&&ce(this.prototype,e,r)}}static getPropertyDescriptor(e,t,n){let{get:r,set:i}=le(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:r,set(t){let a=r?.call(this);i?.call(this,t),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??be}static _$Ei(){if(this.hasOwnProperty(_e(`elementProperties`)))return;let e=fe(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(_e(`finalized`)))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(_e(`properties`))){let e=this.properties,t=[...ue(e),...de(e)];for(let n of t)this.createProperty(n,e[n])}let e=this[Symbol.metadata];if(e!==null){let t=litPropertyMetadata.get(e);if(t!==void 0)for(let[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(let[e,t]of this.elementProperties){let n=this._$Eu(e,t);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){let t=[];if(Array.isArray(e)){let n=new Set(e.flat(1/0).reverse());for(let e of n)t.unshift(oe(e))}else e!==void 0&&t.push(oe(e));return t}static _$Eu(e,t){let n=t.attribute;return!1===n?void 0:typeof n==`string`?n:typeof e==`string`?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){let e=new Map,t=this.constructor.elementProperties;for(let n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){let e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return ae(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){let n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&!0===n.reflect){let i=(n.converter?.toAttribute===void 0?ve:n.converter).toAttribute(t,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,t){let n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){let e=n.getPropertyOptions(r),i=typeof e.converter==`function`?{fromAttribute:e.converter}:e.converter?.fromAttribute===void 0?ve:e.converter;this._$Em=r;let a=i.fromAttribute(t,e.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,t,n,r=!1,i){if(e!==void 0){let a=this.constructor;if(!1===r&&(i=this[e]),n??=a.getPropertyOptions(e),!((n.hasChanged??ye)(i,t)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(a._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:n,reflect:r,wrapped:i},a){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,a??t??this[e]),!0!==i||a!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(t=void 0),this._$AL.set(e,t)),!0===r&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}let e=this.constructor.elementProperties;if(e.size>0)for(let[t,n]of e){let{wrapped:e}=n,r=this[t];!0!==e||this._$AL.has(t)||r===void 0||this.C(t,void 0,n,r)}}let e=!1,t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(e=>e.hostUpdate?.()),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(e){}firstUpdated(e){}};xe.elementStyles=[],xe.shadowRootOptions={mode:`open`},xe[_e(`elementProperties`)]=new Map,xe[_e(`finalized`)]=new Map,ge?.({ReactiveElement:xe}),(pe.reactiveElementVersions??=[]).push(`2.1.2`);var Se=globalThis,Ce=e=>e,we=Se.trustedTypes,Te=we?we.createPolicy(`lit-html`,{createHTML:e=>e}):void 0,Ee=`$lit$`,De=`lit$${Math.random().toFixed(9).slice(2)}$`,Oe=`?`+De,ke=`<${Oe}>`,Ae=document,je=()=>Ae.createComment(``),Me=e=>e===null||typeof e!=`object`&&typeof e!=`function`,Ne=Array.isArray,Pe=e=>Ne(e)||typeof e?.[Symbol.iterator]==`function`,Fe=`[
2
+ \f\r]`,Ie=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Le=/-->/g,Re=/>/g,ze=RegExp(`>|${Fe}(?:([^\\s"'>=/]+)(${Fe}*=${Fe}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,`g`),Be=/'/g,Ve=/"/g,He=/^(?:script|style|textarea|title)$/i,h=(e=>(t,...n)=>({_$litType$:e,strings:t,values:n}))(1),Ue=Symbol.for(`lit-noChange`),g=Symbol.for(`lit-nothing`),We=new WeakMap,Ge=Ae.createTreeWalker(Ae,129);function Ke(e,t){if(!Ne(e)||!e.hasOwnProperty(`raw`))throw Error(`invalid template strings array`);return Te===void 0?t:Te.createHTML(t)}var qe=(e,t)=>{let n=e.length-1,r=[],i,a=t===2?`<svg>`:t===3?`<math>`:``,o=Ie;for(let t=0;t<n;t++){let n=e[t],s,c,l=-1,u=0;for(;u<n.length&&(o.lastIndex=u,c=o.exec(n),c!==null);)u=o.lastIndex,o===Ie?c[1]===`!--`?o=Le:c[1]===void 0?c[2]===void 0?c[3]!==void 0&&(o=ze):(He.test(c[2])&&(i=RegExp(`</`+c[2],`g`)),o=ze):o=Re:o===ze?c[0]===`>`?(o=i??Ie,l=-1):c[1]===void 0?l=-2:(l=o.lastIndex-c[2].length,s=c[1],o=c[3]===void 0?ze:c[3]===`"`?Ve:Be):o===Ve||o===Be?o=ze:o===Le||o===Re?o=Ie:(o=ze,i=void 0);let d=o===ze&&e[t+1].startsWith(`/>`)?` `:``;a+=o===Ie?n+ke:l>=0?(r.push(s),n.slice(0,l)+Ee+n.slice(l)+De+d):n+De+(l===-2?t:d)}return[Ke(e,a+(e[n]||`<?>`)+(t===2?`</svg>`:t===3?`</math>`:``)),r]},Je=class e{constructor({strings:t,_$litType$:n},r){let i;this.parts=[];let a=0,o=0,s=t.length-1,c=this.parts,[l,u]=qe(t,n);if(this.el=e.createElement(l,r),Ge.currentNode=this.el.content,n===2||n===3){let e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;(i=Ge.nextNode())!==null&&c.length<s;){if(i.nodeType===1){if(i.hasAttributes())for(let e of i.getAttributeNames())if(e.endsWith(Ee)){let t=u[o++],n=i.getAttribute(e).split(De),r=/([.?@])?(.*)/.exec(t);c.push({type:1,index:a,name:r[2],strings:n,ctor:r[1]===`.`?$e:r[1]===`?`?et:r[1]===`@`?tt:Qe}),i.removeAttribute(e)}else e.startsWith(De)&&(c.push({type:6,index:a}),i.removeAttribute(e));if(He.test(i.tagName)){let e=i.textContent.split(De),t=e.length-1;if(t>0){i.textContent=we?we.emptyScript:``;for(let n=0;n<t;n++)i.append(e[n],je()),Ge.nextNode(),c.push({type:2,index:++a});i.append(e[t],je())}}}else if(i.nodeType===8)if(i.data===Oe)c.push({type:2,index:a});else{let e=-1;for(;(e=i.data.indexOf(De,e+1))!==-1;)c.push({type:7,index:a}),e+=De.length-1}a++}}static createElement(e,t){let n=Ae.createElement(`template`);return n.innerHTML=e,n}};function Ye(e,t,n=e,r){if(t===Ue)return t;let i=r===void 0?n._$Cl:n._$Co?.[r],a=Me(t)?void 0:t._$litDirective$;return i?.constructor!==a&&(i?._$AO?.(!1),a===void 0?i=void 0:(i=new a(e),i._$AT(e,n,r)),r===void 0?n._$Cl=i:(n._$Co??=[])[r]=i),i!==void 0&&(t=Ye(e,i._$AS(e,t.values),i,r)),t}var Xe=class{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){let{el:{content:t},parts:n}=this._$AD,r=(e?.creationScope??Ae).importNode(t,!0);Ge.currentNode=r;let i=Ge.nextNode(),a=0,o=0,s=n[0];for(;s!==void 0;){if(a===s.index){let t;s.type===2?t=new Ze(i,i.nextSibling,this,e):s.type===1?t=new s.ctor(i,s.name,s.strings,this,e):s.type===6&&(t=new nt(i,this,e)),this._$AV.push(t),s=n[++o]}a!==s?.index&&(i=Ge.nextNode(),a++)}return Ge.currentNode=Ae,r}p(e){let t=0;for(let n of this._$AV)n!==void 0&&(n.strings===void 0?n._$AI(e[t]):(n._$AI(e,n,t),t+=n.strings.length-2)),t++}},Ze=class e{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,n,r){this.type=2,this._$AH=g,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode,t=this._$AM;return t!==void 0&&e?.nodeType===11&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=Ye(this,e,t),Me(e)?e===g||e==null||e===``?(this._$AH!==g&&this._$AR(),this._$AH=g):e!==this._$AH&&e!==Ue&&this._(e):e._$litType$===void 0?e.nodeType===void 0?Pe(e)?this.k(e):this._(e):this.T(e):this.$(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==g&&Me(this._$AH)?this._$AA.nextSibling.data=e:this.T(Ae.createTextNode(e)),this._$AH=e}$(e){let{values:t,_$litType$:n}=e,r=typeof n==`number`?this._$AC(e):(n.el===void 0&&(n.el=Je.createElement(Ke(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(t);else{let e=new Xe(r,this),n=e.u(this.options);e.p(t),this.T(n),this._$AH=e}}_$AC(e){let t=We.get(e.strings);return t===void 0&&We.set(e.strings,t=new Je(e)),t}k(t){Ne(this._$AH)||(this._$AH=[],this._$AR());let n=this._$AH,r,i=0;for(let a of t)i===n.length?n.push(r=new e(this.O(je()),this.O(je()),this,this.options)):r=n[i],r._$AI(a),i++;i<n.length&&(this._$AR(r&&r._$AB.nextSibling,i),n.length=i)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){let t=Ce(e).nextSibling;Ce(e).remove(),e=t}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}},Qe=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,r,i){this.type=1,this._$AH=g,this._$AN=void 0,this.element=e,this.name=t,this._$AM=r,this.options=i,n.length>2||n[0]!==``||n[1]!==``?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=g}_$AI(e,t=this,n,r){let i=this.strings,a=!1;if(i===void 0)e=Ye(this,e,t,0),a=!Me(e)||e!==this._$AH&&e!==Ue,a&&(this._$AH=e);else{let r=e,o,s;for(e=i[0],o=0;o<i.length-1;o++)s=Ye(this,r[n+o],t,o),s===Ue&&(s=this._$AH[o]),a||=!Me(s)||s!==this._$AH[o],s===g?e=g:e!==g&&(e+=(s??``)+i[o+1]),this._$AH[o]=s}a&&!r&&this.j(e)}j(e){e===g?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??``)}},$e=class extends Qe{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===g?void 0:e}},et=class extends Qe{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==g)}},tt=class extends Qe{constructor(e,t,n,r,i){super(e,t,n,r,i),this.type=5}_$AI(e,t=this){if((e=Ye(this,e,t,0)??g)===Ue)return;let n=this._$AH,r=e===g&&n!==g||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==g&&(n===g||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH==`function`?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}},nt=class{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){Ye(this,e)}},rt=Se.litHtmlPolyfillSupport;rt?.(Je,Ze),(Se.litHtmlVersions??=[]).push(`3.3.2`);var it=(e,t,n)=>{let r=n?.renderBefore??t,i=r._$litPart$;if(i===void 0){let e=n?.renderBefore??null;r._$litPart$=i=new Ze(t.insertBefore(je(),e),e,void 0,n??{})}return i._$AI(e),i},at=globalThis,ot=class extends xe{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){let t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=it(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Ue}};ot._$litElement$=!0,ot.finalized=!0,at.litElementHydrateSupport?.({LitElement:ot});var st=at.litElementPolyfillSupport;st?.({LitElement:ot}),(at.litElementVersions??=[]).push(`4.2.2`);var ct=e=>(t,n)=>{n===void 0?customElements.define(e,t):n.addInitializer(()=>{customElements.define(e,t)})},lt={attribute:!0,type:String,converter:ve,reflect:!1,hasChanged:ye},ut=(e=lt,t,n)=>{let{kind:r,metadata:i}=n,a=globalThis.litPropertyMetadata.get(i);if(a===void 0&&globalThis.litPropertyMetadata.set(i,a=new Map),r===`setter`&&((e=Object.create(e)).wrapped=!0),a.set(n.name,e),r===`accessor`){let{name:r}=n;return{set(n){let i=t.get.call(this);t.set.call(this,n),this.requestUpdate(r,i,e,!0,n)},init(t){return t!==void 0&&this.C(r,void 0,e,t),t}}}if(r===`setter`){let{name:r}=n;return function(n){let i=this[r];t.call(this,n),this.requestUpdate(r,i,e,!0,n)}}throw Error(`Unsupported decorator location: `+r)};function _(e){return(t,n)=>typeof n==`object`?ut(e,t,n):((e,t,n)=>{let r=t.hasOwnProperty(n);return t.constructor.createProperty(n,e),r?Object.getOwnPropertyDescriptor(t,n):void 0})(e,t,n)}function dt(e){return _({...e,state:!0,attribute:!1})}var ft=(e,t,n)=>(n.configurable=!0,n.enumerable=!0,Reflect.decorate&&typeof t!=`object`&&Object.defineProperty(e,t,n),n);function pt(e,t){return(n,r,i)=>{let a=t=>t.renderRoot?.querySelector(e)??null;if(t){let{get:e,set:t}=typeof r==`object`?n:i??(()=>{let e=Symbol();return{get(){return this[e]},set(t){this[e]=t}}})();return ft(n,r,{get(){let n=e.call(this);return n===void 0&&(n=a(this),(n!==null||this.hasUpdated)&&t.call(this,n)),n}})}return ft(n,r,{get(){return a(this)}})}}let mt=ie`
3
+ :host {
4
+ display: flex;
5
+ flex-direction: column;
6
+ height: 100vh;
7
+ background-color: var(--agent-bg-white, #ffffff);
8
+ overflow: hidden;
9
+ position: relative;
10
+ }
11
+
12
+ .chat-layout {
13
+ display: flex;
14
+ flex-direction: column;
15
+ height: 100%;
16
+ position: relative;
17
+ }
18
+
19
+ agent-chat-header {
20
+ position: absolute;
21
+ top: 0;
22
+ left: 0;
23
+ right: 0;
24
+ z-index: 10;
25
+ }
26
+
27
+ agent-chat-thread {
28
+ flex: 1;
29
+ padding-bottom: 8rem; /* Space for composer */
30
+ }
31
+
32
+ .inspector-toggle {
33
+ position: absolute;
34
+ bottom: 110px;
35
+ left: 20px;
36
+ width: 32px;
37
+ height: 32px;
38
+ border-radius: 50%;
39
+ background: #ffffff;
40
+ border: 1px solid #e5e7eb;
41
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
42
+ display: flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ cursor: pointer;
46
+ color: #6b7280;
47
+ transition: all 0.2s;
48
+ z-index: 999;
49
+ }
50
+
51
+ .inspector-toggle:hover {
52
+ background: #f3f4f6;
53
+ color: #111827;
54
+ transform: scale(1.1);
55
+ }
56
+
57
+ `,ht=ie`
58
+ :host {
59
+ display: block;
60
+ border-bottom: 1px solid var(--agent-border-zinc-200, #e4e4e7);
61
+ }
62
+
63
+ .header {
64
+ display: flex;
65
+ align-items: center;
66
+ justify-content: space-between;
67
+ height: 4rem; /* 64px */
68
+ padding: 0 1rem;
69
+ background-color: rgba(255, 255, 255, 0.8);
70
+ backdrop-filter: blur(4px);
71
+ }
72
+
73
+
74
+ h1 {
75
+ margin: 0;
76
+ font-size: 1.125rem; /* 18px */
77
+ font-weight: 600;
78
+ color: var(--agent-text-foreground, #09090b);
79
+ }
80
+
81
+ .actions {
82
+ display: flex;
83
+ gap: 0.5rem;
84
+ }
85
+ `,gt=ie`
86
+ :host {
87
+ display: inline-flex;
88
+ }
89
+
90
+ button {
91
+ display: inline-flex;
92
+ align-items: center;
93
+ justify-content: center;
94
+ background: transparent;
95
+ border: none;
96
+ cursor: pointer;
97
+ border-radius: var(--agent-radius-full, 9999px);
98
+ padding: 0.5rem;
99
+ color: var(--agent-text-zinc-500, #71717a);
100
+ transition: color 0.2s, background-color 0.2s;
101
+ }
102
+
103
+ button:hover {
104
+ color: var(--agent-text-foreground, #09090b);
105
+ background-color: var(--agent-bg-zinc-100, #f4f4f5);
106
+ }
107
+
108
+ ::slotted(svg) {
109
+ width: 1.25rem;
110
+ height: 1.25rem;
111
+ }
112
+ `;function v(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var _t=class extends ot{constructor(...e){super(...e),this.tooltip=``}static#e=this.styles=gt;render(){return h`
113
+ <button title="${this.tooltip}" aria-label="${this.tooltip||`Action`}">
114
+ <slot></slot>
115
+ </button>
116
+ `}};v([_()],_t.prototype,`tooltip`,void 0),_t=v([ct(`agent-icon-button`)],_t);let vt=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M8 2.75C8 2.47386 7.77614 2.25 7.5 2.25C7.22386 2.25 7 2.47386 7 2.75V7H2.75C2.47386 7 2.25 7.22386 2.25 7.5C2.25 7.77614 2.47386 8 2.75 8H7V12.25C7 12.5261 7.22386 12.75 7.5 12.75C7.77614 12.75 8 12.5261 8 12.25V8H12.25C12.5261 8 12.75 7.77614 12.75 7.5C12.75 7.22386 12.5261 7 12.25 7H8V2.75Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`,yt=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`,bt=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 9.50006C1 10.3285 1.67157 11.0001 2.5 11.0001H4L4 10.0001H2.5C2.22386 10.0001 2 9.7762 2 9.50006L2 2.50006C2 2.22392 2.22386 2.00006 2.5 2.00006L9.5 2.00006C9.77614 2.00006 10 2.22392 10 2.50006V4.00006H11V2.50006C11 1.67163 10.3284 1.00006 9.5 1.00006H2.5C1.67157 1.00006 1 1.67163 1 2.50006V9.50006ZM5 5.50006C5 4.67163 5.67157 4.00006 6.5 4.00006H13.5C14.3284 4.00006 15 4.67163 15 5.50006V12.5001C15 13.3285 14.3284 14.0001 13.5 14.0001H6.5C5.67157 14.0001 5 13.3285 5 12.5001V5.50006ZM6.5 5.00006H13.5C13.7761 5.00006 14 5.22392 14 5.50006V12.5001C14 12.7762 13.7761 13.0001 13.5 13.0001H6.5C6.22386 13.0001 6 12.7762 6 12.5001V5.50006C6 5.22392 6.22386 5.00006 6.5 5.00006Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`,xt=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.84998 7.49998C1.84998 4.6145 4.05979 2.21843 6.90545 1.91456V3.35016C4.97851 3.63937 3.49998 5.37979 3.49998 7.49998C3.49998 9.87062 5.27476 11.83 7.59505 12.0805C7.97776 12.1218 8.36856 12.1009 8.75239 12.0197C9.35912 11.8913 9.93282 11.6601 10.4552 11.3396C10.9575 11.0315 11.413 10.6548 11.8016 10.2195L10.9701 9.47743C10.6599 9.82496 10.2974 10.1246 9.89728 10.3701C9.6433 10.5259 9.37532 10.6559 9.09678 10.7578C9.09678 10.7578 9.09575 10.7582 9.09472 10.7586C9.01824 10.7876 8.94119 10.8142 8.8636 10.8384C8.42306 10.9757 7.96263 11.0252 7.49998 10.979C5.77663 10.8066 4.35928 9.43926 4.19539 7.71618L4.19539 7.71616C4.19065 7.66632 4.18663 7.61633 4.18335 7.56621C4.15928 7.19912 4.22558 6.83296 4.37349 6.49474L3.13488 5.7513C2.69344 6.36842 2.37893 7.07821 2.22687 7.8388C2.22271 7.8596 2.21862 7.88045 2.21461 7.90135C1.98632 9.09062 2.25732 10.3395 2.9497 11.3972L1.65039 12.5C0.73507 11.1017 0.366914 9.42169 0.672935 7.82827C0.725964 7.5522 0.813075 7.28383 0.93043 7.02568L1.84998 7.49998ZM13.849 5.89437C14.1554 6.36262 14.394 6.87979 14.5458 7.43004C14.5503 7.44641 14.5547 7.46281 14.5591 7.47924C14.8087 8.41443 14.7865 9.40028 14.5029 10.3232L12.9856 9.85698C13.1979 9.16629 13.208 8.43555 13.0211 7.74477L13.0211 7.74474C13.0205 7.74233 13.0198 7.73992 13.0192 7.73751C12.915 7.35952 12.7511 7.00424 12.5407 6.68267L13.849 5.89437ZM8.08544 13.0854L7.54452 7.49998H11.4999L8.08544 4.41452V13.0854Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`;h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.4669 3.72684C11.7558 3.91574 11.8369 4.30308 11.648 4.59198L7.39799 11.092C7.29783 11.2452 7.13556 11.3467 6.95402 11.3699C6.77247 11.3931 6.58989 11.3355 6.45446 11.2124L3.70446 8.71241C3.44905 8.48022 3.43023 8.08494 3.66242 7.82953C3.89461 7.57412 4.28989 7.55529 4.5453 7.78749L6.75292 9.79441L10.6018 3.90792C10.7907 3.61902 11.178 3.53795 11.4669 3.72684Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`;let St=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="3.75" y="3.75" width="7.5" height="7.5" fill="currentColor"></rect></svg>`,Ct=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 7.5C1.5 4.18629 4.18629 1.5 7.5 1.5C10.8137 1.5 13.5 4.18629 13.5 7.5C13.5 10.8137 10.8137 13.5 7.5 13.5C4.18629 13.5 1.5 10.8137 1.5 7.5ZM2.5 7.5C2.5 4.73858 4.73858 2.5 7.5 2.5C10.2614 2.5 12.5 4.73858 12.5 7.5C12.5 10.2614 10.8137 12.5 7.5 12.5C4.73858 12.5 2.5 10.2614 2.5 7.5ZM8 4.5V7.25L9.94491 9.19491L9.2378 9.90202L7 7.66421V4.5H8Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path><path d="M0.5 7.5H2.5L1.5 5.5L0.5 7.5Z" fill="currentColor"/></svg>`,wt=h`<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M12.8536 2.14645C12.6583 1.95118 12.3417 1.95118 12.1464 2.14645L10.5 3.79289L8.35355 1.64645C8.15829 1.45118 7.84171 1.45118 7.64645 1.64645L1.64645 7.64645C1.45118 7.84171 1.45118 8.15829 1.64645 8.35355L3.79289 10.5L2.14645 12.1464C1.95118 12.3417 1.95118 12.6583 2.14645 12.8536L2.85355 13.5607C3.04882 13.7559 3.3654 13.7559 3.56066 13.5607L5.20711 11.9142L7.35355 14.0607C7.54882 14.2559 7.8654 14.2559 8.06066 14.0607L14.0607 8.06066C14.2559 7.8654 14.2559 7.54882 14.0607 7.35355L11.9142 5.20711L13.5607 3.56066C13.7559 3.3654 13.7559 3.04882 13.5607 2.85355L12.8536 2.14645ZM11.2071 5.91421L13.3536 8.06066L8.06066 13.3536L5.91421 11.2071L8.35355 8.76777C8.54882 8.57251 8.54882 8.25593 8.35355 8.06066C8.15829 7.8654 7.84171 7.8654 7.64645 8.06066L5.20711 10.5L3.35355 8.64645L8.64645 3.35355L10.5 5.20711L8.85355 6.85355C8.65829 7.04882 8.65829 7.3654 8.85355 7.56066C9.04882 7.75593 9.3654 7.75593 9.56066 7.56066L11.2071 5.91421Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>`;var Tt=class extends ot{constructor(...e){super(...e),this.title=`Agent Chat`}static#e=this.styles=ht;_handleNewThread(){this.dispatchEvent(new CustomEvent(`new-thread`,{bubbles:!0,composed:!0}))}_handleToggleHistory(){this.dispatchEvent(new CustomEvent(`toggle-history`,{bubbles:!0,composed:!0}))}render(){return h`
117
+ <header class="header">
118
+ <h1>${this.title}</h1>
119
+ <div class="actions">
120
+ <agent-icon-button tooltip="Conversaciones" @click="${this._handleToggleHistory}">
121
+ ${Ct}
122
+ </agent-icon-button>
123
+ <agent-icon-button tooltip="Nuevo Chat" @click="${this._handleNewThread}">
124
+ ${vt}
125
+ </agent-icon-button>
126
+ </div>
127
+ </header>
128
+ `}};v([_({type:String})],Tt.prototype,`title`,void 0),Tt=v([ct(`agent-chat-header`)],Tt);let Et=ie`
129
+ :host {
130
+ display: block;
131
+ height: 100%;
132
+ overflow-y: auto;
133
+ background-color: var(--agent-bg-white, #ffffff);
134
+ padding-top: 4rem; /* Spacer for fixed header */
135
+ }
136
+
137
+ .messages-list {
138
+ display: flex;
139
+ flex-grow: 1;
140
+ flex-direction: column;
141
+ padding: 1rem;
142
+ max-width: 48rem; /* max-w-screen-md */
143
+ margin: 0 auto;
144
+ min-height: calc(100% - 4rem);
145
+ }
146
+
147
+ .empty-state {
148
+ display: flex;
149
+ flex-direction: column;
150
+ align-items: center;
151
+ justify-content: center;
152
+ height: 100%;
153
+ color: var(--agent-text-foreground, #09090b);
154
+ min-height: 50vh;
155
+ }
156
+
157
+ .empty-avatar {
158
+ width: 3rem;
159
+ height: 3rem;
160
+ border-radius: var(--agent-radius-full, 9999px);
161
+ border: 1px solid var(--agent-border-zinc-200, #e4e4e7);
162
+ display: flex;
163
+ align-items: center;
164
+ justify-content: center;
165
+ font-size: 0.875rem;
166
+ margin-bottom: 1rem;
167
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
168
+ }
169
+
170
+ .empty-avatar-img {
171
+ width: 3rem;
172
+ height: 3rem;
173
+ border-radius: var(--agent-radius-full, 9999px);
174
+ object-fit: cover;
175
+ margin-bottom: 1rem;
176
+ box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
177
+ }
178
+
179
+ .empty-text {
180
+ font-size: 1.25rem;
181
+ line-height: 1.75rem;
182
+ }
183
+ `,Dt=ie`
184
+ :host {
185
+ display: block;
186
+ margin: 1rem 0;
187
+ }
188
+
189
+ .message-container {
190
+ display: flex;
191
+ gap: 0.75rem;
192
+ max-width: 100%;
193
+ }
194
+
195
+ :host([role="user"]) .message-container {
196
+ justify-content: flex-end;
197
+ }
198
+
199
+ :host([role="assistant"]) .message-container {
200
+ justify-content: flex-start;
201
+ }
202
+
203
+ .avatar {
204
+ flex-shrink: 0;
205
+ width: 2rem;
206
+ height: 2rem;
207
+ display: flex;
208
+ align-items: center;
209
+ justify-content: center;
210
+ border-radius: var(--agent-radius-full, 9999px);
211
+ border: 1px solid var(--agent-border-zinc-200, #e4e4e7);
212
+ font-size: 0.75rem;
213
+ color: var(--agent-text-foreground, #09090b);
214
+ }
215
+
216
+ .avatar-img {
217
+ width: 2rem;
218
+ height: 2rem;
219
+ border-radius: 9999px;
220
+ object-fit: cover;
221
+ margin-right: 0.75rem;
222
+ flex-shrink: 0;
223
+ }
224
+
225
+ .content-wrapper {
226
+ display: flex;
227
+ flex-direction: column;
228
+ max-width: 80%;
229
+ }
230
+
231
+ .bubble {
232
+ padding: 0.5rem 1.25rem;
233
+ border-radius: var(--agent-radius-3xl, 1.5rem);
234
+ color: var(--agent-text-foreground, #09090b);
235
+ line-height: 1.5;
236
+ }
237
+
238
+ :host([role="user"]) .bubble {
239
+ background-color: var(--agent-bg-zinc-100, #f4f4f5);
240
+ }
241
+
242
+ :host([role="assistant"]) .bubble {
243
+ background-color: transparent;
244
+ padding-left: 0;
245
+ }
246
+
247
+ .actions {
248
+ display: flex;
249
+ gap: 0.25rem;
250
+ margin-top: 0.5rem;
251
+ opacity: 0;
252
+ transition: opacity 0.2s;
253
+ }
254
+
255
+ /* Cursor animation */
256
+ .bubble.streaming::after {
257
+ content: '';
258
+ display: inline-block;
259
+ width: 0.125rem;
260
+ height: 1em;
261
+ background-color: currentColor;
262
+ margin-left: 0.125rem;
263
+ vertical-align: text-bottom;
264
+ animation: cursor-blink 1s step-end infinite;
265
+ }
266
+
267
+ @keyframes cursor-blink {
268
+ 0%, 100% { opacity: 1; }
269
+ 50% { opacity: 0; }
270
+ }
271
+
272
+ .message-container:hover .actions {
273
+ opacity: 1;
274
+ }
275
+
276
+ .typing-indicator {
277
+ display: flex;
278
+ gap: 0.25rem;
279
+ padding: 0.25rem 0;
280
+ }
281
+
282
+ .typing-dot {
283
+ width: 0.375rem;
284
+ height: 0.375rem;
285
+ background-color: var(--agent-text-foreground, #09090b);
286
+ border-radius: 50%;
287
+ opacity: 0.4;
288
+ animation: typing 1.4s infinite ease-in-out both;
289
+ }
290
+
291
+ .typing-dot:nth-child(1) {
292
+ animation-delay: -0.32s;
293
+ }
294
+
295
+ .typing-dot:nth-child(2) {
296
+ animation-delay: -0.16s;
297
+ }
298
+
299
+ @keyframes typing {
300
+ 0%, 80%, 100% {
301
+ transform: scale(0);
302
+ }
303
+ 40% {
304
+ transform: scale(1);
305
+ }
306
+ }
307
+ `;var Ot=class extends ot{constructor(...e){super(...e),this.isLast=!1,this.isStreaming=!1,this.agentAvatar=``}static#e=this.styles=Dt;updated(e){e.has(`message`)&&(this.setAttribute(`role`,this.message.role),this.requestUpdate())}_handleCopy(){navigator.clipboard.writeText(this.message.content)}_handleReload(){this.dispatchEvent(new CustomEvent(`reload-message`,{detail:{id:this.message.id},bubbles:!0,composed:!0}))}render(){let e=this.message.role===`user`;return h`
308
+ <div class="message-container">
309
+ ${e?``:h`
310
+ ${this.agentAvatar?h`<img src="${this.agentAvatar}" class="avatar-img" alt="AI">`:h`<div class="avatar">C</div>`}
311
+ `}
312
+
313
+ <div class="content-wrapper">
314
+ <div class="bubble ${this.isStreaming?`streaming`:``}">
315
+ ${this.message.isThinking?h`
316
+ <div class="typing-indicator">
317
+ <div class="typing-dot"></div>
318
+ <div class="typing-dot"></div>
319
+ <div class="typing-dot"></div>
320
+ </div>
321
+ `:this.message.content}
322
+ </div>
323
+
324
+ ${e?``:h`
325
+ <div class="actions">
326
+ <agent-icon-button tooltip="Copy" @click="${this._handleCopy}">
327
+ ${bt}
328
+ </agent-icon-button>
329
+ <agent-icon-button tooltip="Reload" @click="${this._handleReload}">
330
+ ${xt}
331
+ </agent-icon-button>
332
+ </div>
333
+ `}
334
+ </div>
335
+ </div>
336
+ `}};v([_({type:Object})],Ot.prototype,`message`,void 0),v([_({type:Boolean})],Ot.prototype,`isLast`,void 0),v([_({type:Boolean})],Ot.prototype,`isStreaming`,void 0),v([_({type:String})],Ot.prototype,`agentAvatar`,void 0),Ot=v([ct(`agent-chat-message`)],Ot);var kt=class extends ot{constructor(...e){super(...e),this.messages=[],this.isRunning=!1,this.agentAvatar=``}static#e=this.styles=Et;updated(e){e.has(`messages`)&&this.scrollToBottom()}async scrollToBottom(){await this.updateComplete,(this.shadowRoot?.querySelector(`agent-chat-message:last-of-type`))?.scrollIntoView({behavior:`smooth`,block:`end`})}render(){return this.messages.length===0?h`
337
+ <div class="empty-state">
338
+ ${this.agentAvatar?h`<img src="${this.agentAvatar}" alt="Agent Avatar" class="empty-avatar-img">`:h`<div class="empty-avatar">SM</div>`}
339
+ <p class="empty-text">¿Cómo puedo ayudarte hoy?</p>
340
+ </div>
341
+ `:h`
342
+ <div class="messages-list">
343
+ ${this.messages.map((e,t)=>h`
344
+ <agent-chat-message
345
+ .message=${e}
346
+ .isLast=${t===this.messages.length-1}
347
+ .isStreaming=${this.isRunning&&t===this.messages.length-1}
348
+ .agentAvatar="${this.agentAvatar}">
349
+ </agent-chat-message>
350
+ `)}
351
+ </div>
352
+ `}};v([_({type:Array})],kt.prototype,`messages`,void 0),v([_({type:Boolean})],kt.prototype,`isRunning`,void 0),v([_({type:String})],kt.prototype,`agentAvatar`,void 0),kt=v([ct(`agent-chat-thread`)],kt);let At=ie`
353
+ :host {
354
+ display: block;
355
+ padding: 1rem;
356
+ position: fixed;
357
+ bottom: 0;
358
+ left: 0;
359
+ width: 100%;
360
+ /* background: linear-gradient(to top, white, transparent); */
361
+ }
362
+
363
+ .composer-container {
364
+ max-width: 48rem; /* max-w-screen-md */
365
+ margin: 0 auto;
366
+ display: flex;
367
+ align-items: flex-end;
368
+ background-color: var(--agent-bg-zinc-100, #f4f4f5);
369
+ border-radius: var(--agent-radius-3xl, 1.5rem);
370
+ padding-left: 0.5rem;
371
+ transition: background-color 0.2s;
372
+ }
373
+
374
+ .composer-container:focus-within {
375
+ background-color: #e4e4e780; /* zinc-200/50 approx */
376
+ }
377
+
378
+ textarea {
379
+ flex-grow: 1;
380
+ background: transparent;
381
+ border: none;
382
+ resize: none;
383
+ max-height: 10rem;
384
+ padding: 0.875rem;
385
+ font-size: 0.875rem;
386
+ line-height: 1.25rem;
387
+ color: var(--agent-text-foreground, #09090b);
388
+ outline: none;
389
+ height: 3rem; /* default roughly h-12 */
390
+ }
391
+
392
+ textarea::placeholder {
393
+ color: var(--agent-text-zinc-500, #71717a);
394
+ }
395
+
396
+ .action-button {
397
+ margin: 0.5rem;
398
+ display: flex;
399
+ align-items: center;
400
+ justify-content: center;
401
+ width: 2rem;
402
+ height: 2rem;
403
+ border-radius: var(--agent-radius-full, 9999px);
404
+ background-color: var(--agent-bg-black, #09090b);
405
+ color: var(--agent-text-white, #ffffff);
406
+ transition: opacity 0.2s;
407
+ cursor: pointer;
408
+ }
409
+
410
+ .action-button:disabled {
411
+ opacity: 0.1;
412
+ cursor: not-allowed;
413
+ }
414
+
415
+ /* Make sure icons are sized well inside the circle */
416
+ .action-button svg {
417
+ width: 1.25rem;
418
+ height: 1.25rem;
419
+ }
420
+
421
+ .disclaimer {
422
+ text-align: center;
423
+ color: var(--agent-text-zinc-500, #71717a);
424
+ font-size: 0.75rem;
425
+ padding: 0.5rem;
426
+ }
427
+ `;var jt=class extends ot{constructor(...e){super(...e),this.isRunning=!1,this._value=``}static#e=this.styles=At;_handleInput(e){this._value=e.target.value,this._adjustHeight()}_handleKeyDown(e){e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),this._handleSubmit())}_adjustHeight(){this._textarea&&(this._textarea.style.height=`auto`,this._textarea.style.height=`${Math.min(this._textarea.scrollHeight,160)}px`)}async _handleSubmit(){this._value.trim()&&(this.dispatchEvent(new CustomEvent(`send`,{detail:{content:this._value},bubbles:!0,composed:!0})),this._value=``,await this.updateComplete,this._textarea.style.height=`3rem`)}_handleStop(){this.dispatchEvent(new CustomEvent(`cancel`,{bubbles:!0,composed:!0}))}render(){return h`
428
+ <div class="composer-container">
429
+ <textarea
430
+ placeholder="Enviar un mensaje a Agent"
431
+ .value="${this._value}"
432
+ @input="${this._handleInput}"
433
+ @keydown="${this._handleKeyDown}"
434
+ ?disabled="${this.isRunning}"
435
+ rows="1"
436
+ ></textarea>
437
+
438
+ ${this.isRunning?h`<button class="action-button" @click="${this._handleStop}">${St}</button>`:h`<button class="action-button" ?disabled="${!this._value.trim()}" @click="${this._handleSubmit}">${yt}</button>`}
439
+ </div>
440
+ <p class="disclaimer">
441
+ Agent puede cometer errores. Verifica la información importante.
442
+ </p>
443
+ `}};v([_({type:Boolean})],jt.prototype,`isRunning`,void 0),v([dt()],jt.prototype,`_value`,void 0),v([pt(`textarea`)],jt.prototype,`_textarea`,void 0),jt=v([ct(`agent-chat-composer`)],jt);let Mt=ie`
444
+ :host {
445
+ display: block;
446
+ position: absolute;
447
+ top: 4rem;
448
+ left: 0;
449
+ bottom: 0;
450
+ width: 260px;
451
+ background: #ffffff;
452
+ border-right: 1px solid #e5e5e5;
453
+ transform: translateX(-100%);
454
+ transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
455
+ z-index: 20;
456
+ box-shadow: 2px 0 8px rgba(0,0,0,0.05);
457
+ }
458
+
459
+ :host([open]) {
460
+ transform: translateX(0);
461
+ }
462
+
463
+ .header {
464
+ height: 60px;
465
+ padding: 0 1rem;
466
+ border-bottom: 1px solid #f0f0f0;
467
+ font-weight: 600;
468
+ font-size: 0.95rem;
469
+ color: #1a1a1a;
470
+ display: flex;
471
+ align-items: center;
472
+ background: #fafafa;
473
+ }
474
+
475
+ .list {
476
+ list-style: none;
477
+ padding: 0;
478
+ margin: 0;
479
+ overflow-y: auto;
480
+ height: calc(100% - 60px);
481
+ }
482
+
483
+ .item {
484
+ padding: 1rem;
485
+ cursor: pointer;
486
+ border-bottom: 1px solid #f5f5f5;
487
+ transition: all 0.2s ease;
488
+ white-space: nowrap;
489
+ overflow: hidden;
490
+ text-overflow: ellipsis;
491
+ font-size: 0.9rem;
492
+ color: #4a4a4a;
493
+ }
494
+
495
+ .item:hover {
496
+ background-color: #f9f9f9;
497
+ color: #1a1a1a;
498
+ }
499
+
500
+ .empty-state {
501
+ padding: 2rem 1rem;
502
+ text-align: center;
503
+ color: #999;
504
+ font-size: 0.9rem;
505
+ }
506
+ `;var Nt=class extends ot{constructor(...e){super(...e),this.conversations=[],this.open=!1}static#e=this.styles=Mt;_handleSelect(e){this.dispatchEvent(new CustomEvent(`select-thread`,{detail:{conversation:e},bubbles:!0,composed:!0}))}render(){return h`
507
+ <div class="header">
508
+ Conversaciones
509
+ </div>
510
+ <ul class="list">
511
+ ${this.conversations.length===0?h`<div class="empty-state">No hay conversaciones recientes</div>`:this.conversations.map(e=>h`
512
+ <li class="item" @click="${()=>this._handleSelect(e)}">
513
+ ${e.title}
514
+ </li>
515
+ `)}
516
+ </ul>
517
+ `}};v([_({type:Array})],Nt.prototype,`conversations`,void 0),v([_({type:Boolean,reflect:!0})],Nt.prototype,`open`,void 0),Nt=v([ct(`agent-chat-history-list`)],Nt);let y=new class extends EventTarget{constructor(...e){super(...e),this._context=null,this._messages=[],this._stream=[]}get context(){return this._context}get messages(){return this._messages}get stream(){return this._stream}setContext(e){this._context=e,this.notify()}setMessages(e){this._messages=[...e],this.notify()}addEvent(e,t){this._stream=[{event:e,content:t,time:new Date().toTimeString().split(` `)[0]},...this._stream].slice(0,100),this.notify()}clearStream(){this._stream=[],this.notify()}notify(){this.dispatchEvent(new CustomEvent(`inspector-change`))}},Pt=ie`
518
+ :host {
519
+ position: absolute;
520
+ bottom: 60px;
521
+ left: 20px;
522
+ width: 400px;
523
+ max-height: 500px;
524
+ background: #ffffff;
525
+ border: 1px solid #e5e7eb;
526
+ border-radius: 12px;
527
+ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
528
+ display: flex;
529
+ flex-direction: column;
530
+ overflow: hidden;
531
+ z-index: 1000;
532
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
533
+ }
534
+
535
+ .header {
536
+ padding: 12px 16px;
537
+ background: #f9fafb;
538
+ border-bottom: 1px solid #e5e7eb;
539
+ display: flex;
540
+ justify-content: space-between;
541
+ align-items: center;
542
+ cursor: move;
543
+ user-select: none;
544
+ }
545
+
546
+ .header h3 {
547
+ margin: 0;
548
+ font-size: 14px;
549
+ font-weight: 600;
550
+ color: #111827;
551
+ }
552
+
553
+ .close-button {
554
+ background: none;
555
+ border: none;
556
+ color: #6b7280;
557
+ cursor: pointer;
558
+ padding: 4px;
559
+ border-radius: 4px;
560
+ display: flex;
561
+ align-items: center;
562
+ justify-content: center;
563
+ }
564
+
565
+ .close-button:hover {
566
+ background: #f3f4f6;
567
+ color: #111827;
568
+ }
569
+
570
+ .tabs {
571
+ display: flex;
572
+ background: #f3f4f6;
573
+ padding: 4px;
574
+ gap: 4px;
575
+ }
576
+
577
+ .tab {
578
+ flex: 1;
579
+ padding: 6px;
580
+ font-size: 12px;
581
+ font-weight: 500;
582
+ text-align: center;
583
+ color: #6b7280;
584
+ cursor: pointer;
585
+ border-radius: 6px;
586
+ transition: all 0.2s;
587
+ }
588
+
589
+ .tab:hover {
590
+ color: #374151;
591
+ }
592
+
593
+ .tab.active {
594
+ background: #ffffff;
595
+ color: #111827;
596
+ box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
597
+ }
598
+
599
+ .content {
600
+ flex: 1;
601
+ overflow-y: auto;
602
+ padding: 16px;
603
+ font-size: 12px;
604
+ }
605
+
606
+ pre {
607
+ margin: 0;
608
+ white-space: pre-wrap;
609
+ word-break: break-all;
610
+ background: #f9fafb;
611
+ padding: 8px;
612
+ border-radius: 6px;
613
+ border: 1px solid #e5e7eb;
614
+ color: #374151;
615
+ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
616
+ }
617
+
618
+ .event-item {
619
+ margin-bottom: 12px;
620
+ padding-bottom: 12px;
621
+ border-bottom: 1px solid #f3f4f6;
622
+ }
623
+
624
+ .event-item:last-child {
625
+ border-bottom: none;
626
+ }
627
+
628
+ .event-header {
629
+ display: flex;
630
+ justify-content: space-between;
631
+ margin-bottom: 4px;
632
+ }
633
+
634
+ .event-name {
635
+ font-weight: 600;
636
+ color: #6366f1;
637
+ }
638
+
639
+ .event-time {
640
+ color: #9ca3af;
641
+ font-size: 10px;
642
+ }
643
+
644
+ .event-content {
645
+ margin-top: 4px;
646
+ }
647
+ `;var Ft=class extends ot{constructor(...e){super(...e),this._activeTab=`stream`,this._context=null,this._messages=[],this._stream=[],this._isDragging=!1,this._currentX=0,this._currentY=0,this._initialX=0,this._initialY=0,this._xOffset=0,this._yOffset=0,this._onInspectorChange=()=>{this._updateData()}}static#e=this.styles=Pt;connectedCallback(){super.connectedCallback(),y.addEventListener(`inspector-change`,this._onInspectorChange),this._updateData()}disconnectedCallback(){super.disconnectedCallback(),y.removeEventListener(`inspector-change`,this._onInspectorChange)}_updateData(){this._context=y.context,this._messages=y.messages,this._stream=y.stream,this.requestUpdate()}_handleClose(){this.dispatchEvent(new CustomEvent(`close`))}_dragStart(e){e.type===`touchstart`?(this._initialX=e.touches[0].clientX-this._xOffset,this._initialY=e.touches[0].clientY-this._yOffset):(this._initialX=e.clientX-this._xOffset,this._initialY=e.clientY-this._yOffset),!e.target.closest(`.close-button`)&&(this._isDragging=!0)}_drag(e){this._isDragging&&(e.preventDefault(),e.type===`touchmove`?(this._currentX=e.touches[0].clientX-this._initialX,this._currentY=e.touches[0].clientY-this._initialY):(this._currentX=e.clientX-this._initialX,this._currentY=e.clientY-this._initialY),this._xOffset=this._currentX,this._yOffset=this._currentY,this._setTranslate(this._currentX,this._currentY))}_dragEnd(){this._initialX=this._currentX,this._initialY=this._currentY,this._isDragging=!1}_setTranslate(e,t){this.style.transform=`translate3d(${e}px, ${t}px, 0)`}render(){return h`
648
+ <div class="header"
649
+ @mousedown="${this._dragStart}"
650
+ @touchstart="${this._dragStart}"
651
+ @mousemove="${this._drag}"
652
+ @touchmove="${this._drag}"
653
+ @mouseup="${this._dragEnd}"
654
+ @touchend="${this._dragEnd}"
655
+ @mouseleave="${this._dragEnd}"
656
+ >
657
+ <h3>Inspector</h3>
658
+ <button class="close-button" @click="${this._handleClose}">
659
+ <svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31317L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z" fill="currentColor" fill-rule="evenodd" clip-rule="evenodd"></path></svg>
660
+ </button>
661
+ </div>
662
+ <div class="tabs">
663
+ <div class="tab ${this._activeTab===`context`?`active`:``}" @click="${()=>this._activeTab=`context`}">Context</div>
664
+ <div class="tab ${this._activeTab===`messages`?`active`:``}" @click="${()=>this._activeTab=`messages`}">Messages</div>
665
+ <div class="tab ${this._activeTab===`stream`?`active`:``}" @click="${()=>this._activeTab=`stream`}">Stream</div>
666
+ </div>
667
+ <div class="content">
668
+ ${this._renderContent()}
669
+ </div>
670
+ `}_renderContent(){switch(this._activeTab){case`context`:return h`<pre>${JSON.stringify(this._context,null,2)}</pre>`;case`messages`:return h`<pre>${JSON.stringify(this._messages,null,2)}</pre>`;case`stream`:return h`
671
+ <div class="stream-list">
672
+ ${this._stream.map(e=>h`
673
+ <div class="event-item">
674
+ <div class="event-header">
675
+ <span class="event-name">${e.event}</span>
676
+ <span class="event-time">${e.time}</span>
677
+ </div>
678
+ <div class="event-content">
679
+ <pre>${JSON.stringify(e.content,null,2)}</pre>
680
+ </div>
681
+ </div>
682
+ `)}
683
+ ${this._stream.length===0?h`<div style="color: #9ca3af; text-align: center; padding: 20px;">No events yet</div>`:``}
684
+ </div>
685
+ `}}};v([dt()],Ft.prototype,`_activeTab`,void 0),v([dt()],Ft.prototype,`_context`,void 0),v([dt()],Ft.prototype,`_messages`,void 0),v([dt()],Ft.prototype,`_stream`,void 0),Ft=v([ct(`agent-inspector-window`)],Ft);var b;(function(e){e.assertEqual=e=>{};function t(e){}e.assertIs=t;function n(e){throw Error()}e.assertNever=n,e.arrayToEnum=e=>{let t={};for(let n of e)t[n]=n;return t},e.getValidEnumValues=t=>{let n=e.objectKeys(t).filter(e=>typeof t[t[e]]!=`number`),r={};for(let e of n)r[e]=t[e];return e.objectValues(r)},e.objectValues=t=>e.objectKeys(t).map(function(e){return t[e]}),e.objectKeys=typeof Object.keys==`function`?e=>Object.keys(e):e=>{let t=[];for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(let n of e)if(t(n))return n},e.isInteger=typeof Number.isInteger==`function`?e=>Number.isInteger(e):e=>typeof e==`number`&&Number.isFinite(e)&&Math.floor(e)===e;function r(e,t=` | `){return e.map(e=>typeof e==`string`?`'${e}'`:e).join(t)}e.joinValues=r,e.jsonStringifyReplacer=(e,t)=>typeof t==`bigint`?t.toString():t})(b||={});var It;(function(e){e.mergeShapes=(e,t)=>({...e,...t})})(It||={});let x=b.arrayToEnum([`string`,`nan`,`number`,`integer`,`float`,`boolean`,`date`,`bigint`,`symbol`,`function`,`undefined`,`null`,`array`,`object`,`unknown`,`promise`,`void`,`never`,`map`,`set`]),Lt=e=>{switch(typeof e){case`undefined`:return x.undefined;case`string`:return x.string;case`number`:return Number.isNaN(e)?x.nan:x.number;case`boolean`:return x.boolean;case`function`:return x.function;case`bigint`:return x.bigint;case`symbol`:return x.symbol;case`object`:return Array.isArray(e)?x.array:e===null?x.null:e.then&&typeof e.then==`function`&&e.catch&&typeof e.catch==`function`?x.promise:typeof Map<`u`&&e instanceof Map?x.map:typeof Set<`u`&&e instanceof Set?x.set:typeof Date<`u`&&e instanceof Date?x.date:x.object;default:return x.unknown}},S=b.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`]);var Rt=class e extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name=`ZodError`,this.issues=e}format(e){let t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(let i of e.issues)if(i.code===`invalid_union`)i.unionErrors.map(r);else if(i.code===`invalid_return_type`)r(i.returnTypeError);else if(i.code===`invalid_arguments`)r(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){let n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(t){if(!(t instanceof e))throw Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,b.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=e=>e.message){let t={},n=[];for(let r of this.issues)if(r.path.length>0){let n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Rt.create=e=>new Rt(e);var zt=(e,t)=>{let n;switch(e.code){case S.invalid_type:n=e.received===x.undefined?`Required`:`Expected ${e.expected}, received ${e.received}`;break;case S.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,b.jsonStringifyReplacer)}`;break;case S.unrecognized_keys:n=`Unrecognized key(s) in object: ${b.joinValues(e.keys,`, `)}`;break;case S.invalid_union:n=`Invalid input`;break;case S.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${b.joinValues(e.options)}`;break;case S.invalid_enum_value:n=`Invalid enum value. Expected ${b.joinValues(e.options)}, received '${e.received}'`;break;case S.invalid_arguments:n=`Invalid function arguments`;break;case S.invalid_return_type:n=`Invalid function return type`;break;case S.invalid_date:n=`Invalid date`;break;case S.invalid_string:typeof e.validation==`object`?`includes`in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==`number`&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):`startsWith`in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:`endsWith`in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:b.assertNever(e.validation):n=e.validation===`regex`?`Invalid`:`Invalid ${e.validation}`;break;case S.too_small:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at least`:`more than`} ${e.minimum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at least`:`over`} ${e.minimum} character(s)`:e.type===`number`||e.type===`bigint`?`Number must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${e.minimum}`:e.type===`date`?`Date must be ${e.exact?`exactly equal to `:e.inclusive?`greater than or equal to `:`greater than `}${new Date(Number(e.minimum))}`:`Invalid input`;break;case S.too_big:n=e.type===`array`?`Array must contain ${e.exact?`exactly`:e.inclusive?`at most`:`less than`} ${e.maximum} element(s)`:e.type===`string`?`String must contain ${e.exact?`exactly`:e.inclusive?`at most`:`under`} ${e.maximum} character(s)`:e.type===`number`?`Number must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`bigint`?`BigInt must be ${e.exact?`exactly`:e.inclusive?`less than or equal to`:`less than`} ${e.maximum}`:e.type===`date`?`Date must be ${e.exact?`exactly`:e.inclusive?`smaller than or equal to`:`smaller than`} ${new Date(Number(e.maximum))}`:`Invalid input`;break;case S.custom:n=`Invalid input`;break;case S.invalid_intersection_types:n=`Intersection results could not be merged`;break;case S.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case S.not_finite:n=`Number must be finite`;break;default:n=t.defaultError,b.assertNever(e)}return{message:n}},Bt=zt;function Vt(){return Bt}let Ht=e=>{let{data:t,path:n,errorMaps:r,issueData:i}=e,a=[...n,...i.path||[]],o={...i,path:a};if(i.message!==void 0)return{...i,path:a,message:i.message};let s=``,c=r.filter(e=>!!e).slice().reverse();for(let e of c)s=e(o,{data:t,defaultError:s}).message;return{...i,path:a,message:s}};function C(e,t){let n=Vt(),r=Ht({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===zt?void 0:zt].filter(e=>!!e)});e.common.issues.push(r)}var Ut=class e{constructor(){this.value=`valid`}dirty(){this.value===`valid`&&(this.value=`dirty`)}abort(){this.value!==`aborted`&&(this.value=`aborted`)}static mergeArray(e,t){let n=[];for(let r of t){if(r.status===`aborted`)return w;r.status===`dirty`&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(t,n){let r=[];for(let e of n){let t=await e.key,n=await e.value;r.push({key:t,value:n})}return e.mergeObjectSync(t,r)}static mergeObjectSync(e,t){let n={};for(let r of t){let{key:t,value:i}=r;if(t.status===`aborted`||i.status===`aborted`)return w;t.status===`dirty`&&e.dirty(),i.status===`dirty`&&e.dirty(),t.value!==`__proto__`&&(i.value!==void 0||r.alwaysSet)&&(n[t.value]=i.value)}return{status:e.value,value:n}}};let w=Object.freeze({status:`aborted`}),Wt=e=>({status:`dirty`,value:e}),T=e=>({status:`valid`,value:e}),Gt=e=>e.status===`aborted`,Kt=e=>e.status===`dirty`,qt=e=>e.status===`valid`,Jt=e=>typeof Promise<`u`&&e instanceof Promise;var E;(function(e){e.errToObj=e=>typeof e==`string`?{message:e}:e||{},e.toString=e=>typeof e==`string`?e:e?.message})(E||={});var Yt=class{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Xt=(e,t)=>{if(qt(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw Error(`Validation failed but no issues detected.`);return{success:!1,get error(){return this._error||=new Rt(e.common.issues),this._error}}};function D(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:r,description:i}=e;if(t&&(n||r))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return t?{errorMap:t,description:i}:{errorMap:(t,i)=>{let{message:a}=e;return t.code===`invalid_enum_value`?{message:a??i.defaultError}:i.data===void 0?{message:a??r??i.defaultError}:t.code===`invalid_type`?{message:a??n??i.defaultError}:{message:i.defaultError}},description:i}}var O=class{get description(){return this._def.description}_getType(e){return Lt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Lt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ut,ctx:{common:e.parent.common,data:e.data,parsedType:Lt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(Jt(t))throw Error(`Synchronous parse encountered promise.`);return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lt(e)};return Xt(n,this._parseSync({data:e,path:n.path,parent:n}))}"~validate"(e){let t={common:{issues:[],async:!!this[`~standard`].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lt(e)};if(!this[`~standard`].async)try{let n=this._parseSync({data:e,path:[],parent:t});return qt(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes(`encountered`)&&(this[`~standard`].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>qt(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Lt(e)},r=this._parse({data:e,path:n.path,parent:n});return Xt(n,await(Jt(r)?r:Promise.resolve(r)))}refine(e,t){let n=e=>typeof t==`string`||t===void 0?{message:t}:typeof t==`function`?t(e):t;return this._refinement((t,r)=>{let i=e(t),a=()=>r.addIssue({code:S.custom,...n(t)});return typeof Promise<`u`&&i instanceof Promise?i.then(e=>e?!0:(a(),!1)):i?!0:(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t==`function`?t(n,r):t),!1))}_refinement(e){return new er({schema:this,typeName:k.ZodEffects,effect:{type:`refinement`,refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this[`~standard`]={version:1,vendor:`zod`,validate:e=>this[`~validate`](e)}}optional(){return tr.create(this,this._def)}nullable(){return nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fn.create(this)}promise(){return $n.create(this,this._def)}or(e){return Rn.create([this,e],this._def)}and(e){return Hn.create(this,e,this._def)}transform(e){return new er({...D(this._def),schema:this,typeName:k.ZodEffects,effect:{type:`transform`,transform:e}})}default(e){let t=typeof e==`function`?e:()=>e;return new rr({...D(this._def),innerType:this,defaultValue:t,typeName:k.ZodDefault})}brand(){return new or({typeName:k.ZodBranded,type:this,...D(this._def)})}catch(e){let t=typeof e==`function`?e:()=>e;return new ir({...D(this._def),innerType:this,catchValue:t,typeName:k.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return sr.create(this,e)}readonly(){return cr.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},Zt=/^c[^\s-]{8,}$/i,Qt=/^[0-9a-z]+$/,$t=/^[0-9A-HJKMNP-TV-Z]{26}$/i,en=/^[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,tn=/^[a-z0-9_-]{21}$/i,nn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rn=/^[-+]?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)?)??$/,an=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,on=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`,sn,cn=/^(?:(?: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])$/,ln=/^(?:(?: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])$/,un=/^(([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]))$/,dn=/^(([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])$/,fn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,pn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,mn=`((\\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])))`,hn=RegExp(`^${mn}$`);function gn(e){let t=`[0-5]\\d`;e.precision?t=`${t}\\.\\d{${e.precision}}`:e.precision??(t=`${t}(\\.\\d+)?`);let n=e.precision?`+`:`?`;return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function _n(e){return RegExp(`^${gn(e)}$`)}function vn(e){let t=`${mn}T${gn(e)}`,n=[];return n.push(e.local?`Z?`:`Z`),e.offset&&n.push(`([+-]\\d{2}:?\\d{2})`),t=`${t}(${n.join(`|`)})`,RegExp(`^${t}$`)}function yn(e,t){return!!((t===`v4`||!t)&&cn.test(e)||(t===`v6`||!t)&&un.test(e))}function bn(e,t){if(!nn.test(e))return!1;try{let[n]=e.split(`.`);if(!n)return!1;let r=n.replace(/-/g,`+`).replace(/_/g,`/`).padEnd(n.length+(4-n.length%4)%4,`=`),i=JSON.parse(atob(r));return!(typeof i!=`object`||!i||`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&i.alg!==t)}catch{return!1}}function xn(e,t){return!!((t===`v4`||!t)&&ln.test(e)||(t===`v6`||!t)&&dn.test(e))}var Sn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.string,received:t.parsedType}),w}let t=new Ut,n;for(let r of this._def.checks)if(r.kind===`min`)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:S.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`max`)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:S.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!1,message:r.message}),t.dirty());else if(r.kind===`length`){let i=e.data.length>r.value,a=e.data.length<r.value;(i||a)&&(n=this._getOrReturnCtx(e,n),i?C(n,{code:S.too_big,maximum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}):a&&C(n,{code:S.too_small,minimum:r.value,type:`string`,inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if(r.kind===`email`)an.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`email`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`emoji`)sn||=new RegExp(on,`u`),sn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`emoji`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`uuid`)en.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`uuid`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`nanoid`)tn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`nanoid`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid`)Zt.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`cuid`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`cuid2`)Qt.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`cuid2`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`ulid`)$t.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`ulid`,code:S.invalid_string,message:r.message}),t.dirty());else if(r.kind===`url`)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),C(n,{validation:`url`,code:S.invalid_string,message:r.message}),t.dirty()}else r.kind===`regex`?(r.regex.lastIndex=0,r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`regex`,code:S.invalid_string,message:r.message}),t.dirty())):r.kind===`trim`?e.data=e.data.trim():r.kind===`includes`?e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty()):r.kind===`toLowerCase`?e.data=e.data.toLowerCase():r.kind===`toUpperCase`?e.data=e.data.toUpperCase():r.kind===`startsWith`?e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty()):r.kind===`endsWith`?e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty()):r.kind===`datetime`?vn(r).test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:`datetime`,message:r.message}),t.dirty()):r.kind===`date`?hn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:`date`,message:r.message}),t.dirty()):r.kind===`time`?_n(r).test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{code:S.invalid_string,validation:`time`,message:r.message}),t.dirty()):r.kind===`duration`?rn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`duration`,code:S.invalid_string,message:r.message}),t.dirty()):r.kind===`ip`?yn(e.data,r.version)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`ip`,code:S.invalid_string,message:r.message}),t.dirty()):r.kind===`jwt`?bn(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`jwt`,code:S.invalid_string,message:r.message}),t.dirty()):r.kind===`cidr`?xn(e.data,r.version)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`cidr`,code:S.invalid_string,message:r.message}),t.dirty()):r.kind===`base64`?fn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`base64`,code:S.invalid_string,message:r.message}),t.dirty()):r.kind===`base64url`?pn.test(e.data)||(n=this._getOrReturnCtx(e,n),C(n,{validation:`base64url`,code:S.invalid_string,message:r.message}),t.dirty()):b.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:S.invalid_string,...E.errToObj(n)})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}email(e){return this._addCheck({kind:`email`,...E.errToObj(e)})}url(e){return this._addCheck({kind:`url`,...E.errToObj(e)})}emoji(e){return this._addCheck({kind:`emoji`,...E.errToObj(e)})}uuid(e){return this._addCheck({kind:`uuid`,...E.errToObj(e)})}nanoid(e){return this._addCheck({kind:`nanoid`,...E.errToObj(e)})}cuid(e){return this._addCheck({kind:`cuid`,...E.errToObj(e)})}cuid2(e){return this._addCheck({kind:`cuid2`,...E.errToObj(e)})}ulid(e){return this._addCheck({kind:`ulid`,...E.errToObj(e)})}base64(e){return this._addCheck({kind:`base64`,...E.errToObj(e)})}base64url(e){return this._addCheck({kind:`base64url`,...E.errToObj(e)})}jwt(e){return this._addCheck({kind:`jwt`,...E.errToObj(e)})}ip(e){return this._addCheck({kind:`ip`,...E.errToObj(e)})}cidr(e){return this._addCheck({kind:`cidr`,...E.errToObj(e)})}datetime(e){return typeof e==`string`?this._addCheck({kind:`datetime`,precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:`datetime`,precision:e?.precision===void 0?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...E.errToObj(e?.message)})}date(e){return this._addCheck({kind:`date`,message:e})}time(e){return typeof e==`string`?this._addCheck({kind:`time`,precision:null,message:e}):this._addCheck({kind:`time`,precision:e?.precision===void 0?null:e?.precision,...E.errToObj(e?.message)})}duration(e){return this._addCheck({kind:`duration`,...E.errToObj(e)})}regex(e,t){return this._addCheck({kind:`regex`,regex:e,...E.errToObj(t)})}includes(e,t){return this._addCheck({kind:`includes`,value:e,position:t?.position,...E.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:`startsWith`,value:e,...E.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:`endsWith`,value:e,...E.errToObj(t)})}min(e,t){return this._addCheck({kind:`min`,value:e,...E.errToObj(t)})}max(e,t){return this._addCheck({kind:`max`,value:e,...E.errToObj(t)})}length(e,t){return this._addCheck({kind:`length`,value:e,...E.errToObj(t)})}nonempty(e){return this.min(1,E.errToObj(e))}trim(){return new e({...this._def,checks:[...this._def.checks,{kind:`trim`}]})}toLowerCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toLowerCase`}]})}toUpperCase(){return new e({...this._def,checks:[...this._def.checks,{kind:`toUpperCase`}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind===`datetime`)}get isDate(){return!!this._def.checks.find(e=>e.kind===`date`)}get isTime(){return!!this._def.checks.find(e=>e.kind===`time`)}get isDuration(){return!!this._def.checks.find(e=>e.kind===`duration`)}get isEmail(){return!!this._def.checks.find(e=>e.kind===`email`)}get isURL(){return!!this._def.checks.find(e=>e.kind===`url`)}get isEmoji(){return!!this._def.checks.find(e=>e.kind===`emoji`)}get isUUID(){return!!this._def.checks.find(e=>e.kind===`uuid`)}get isNANOID(){return!!this._def.checks.find(e=>e.kind===`nanoid`)}get isCUID(){return!!this._def.checks.find(e=>e.kind===`cuid`)}get isCUID2(){return!!this._def.checks.find(e=>e.kind===`cuid2`)}get isULID(){return!!this._def.checks.find(e=>e.kind===`ulid`)}get isIP(){return!!this._def.checks.find(e=>e.kind===`ip`)}get isCIDR(){return!!this._def.checks.find(e=>e.kind===`cidr`)}get isBase64(){return!!this._def.checks.find(e=>e.kind===`base64`)}get isBase64url(){return!!this._def.checks.find(e=>e.kind===`base64url`)}get minLength(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Sn.create=e=>new Sn({checks:[],typeName:k.ZodString,coerce:e?.coerce??!1,...D(e)});function Cn(e,t){let n=(e.toString().split(`.`)[1]||``).length,r=(t.toString().split(`.`)[1]||``).length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(`.`,``))%Number.parseInt(t.toFixed(i).replace(`.`,``))/10**i}var wn=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==x.number){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.number,received:t.parsedType}),w}let t,n=new Ut;for(let r of this._def.checks)r.kind===`int`?b.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),C(t,{code:S.invalid_type,expected:`integer`,received:`float`,message:r.message}),n.dirty()):r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.too_small,minimum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.too_big,maximum:r.value,type:`number`,inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty()):r.kind===`multipleOf`?Cn(e.data,r.value)!==0&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):r.kind===`finite`?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),C(t,{code:S.not_finite,message:r.message}),n.dirty()):b.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit(`min`,e,!0,E.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,E.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,E.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,E.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:E.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}int(e){return this._addCheck({kind:`int`,message:E.toString(e)})}positive(e){return this._addCheck({kind:`min`,value:0,inclusive:!1,message:E.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:0,inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:0,inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:0,inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:E.toString(t)})}finite(e){return this._addCheck({kind:`finite`,message:E.toString(e)})}safe(e){return this._addCheck({kind:`min`,inclusive:!0,value:-(2**53-1),message:E.toString(e)})._addCheck({kind:`max`,inclusive:!0,value:2**53-1,message:E.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind===`int`||e.kind===`multipleOf`&&b.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind===`finite`||n.kind===`int`||n.kind===`multipleOf`)return!0;else n.kind===`min`?(t===null||n.value>t)&&(t=n.value):n.kind===`max`&&(e===null||n.value<e)&&(e=n.value);return Number.isFinite(t)&&Number.isFinite(e)}};wn.create=e=>new wn({checks:[],typeName:k.ZodNumber,coerce:e?.coerce||!1,...D(e)});var Tn=class e extends O{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==x.bigint)return this._getInvalidInput(e);let t,n=new Ut;for(let r of this._def.checks)r.kind===`min`?(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.too_small,type:`bigint`,minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`max`?(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.too_big,type:`bigint`,maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty()):r.kind===`multipleOf`?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),C(t,{code:S.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):b.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.bigint,received:t.parsedType}),w}gte(e,t){return this.setLimit(`min`,e,!0,E.toString(t))}gt(e,t){return this.setLimit(`min`,e,!1,E.toString(t))}lte(e,t){return this.setLimit(`max`,e,!0,E.toString(t))}lt(e,t){return this.setLimit(`max`,e,!1,E.toString(t))}setLimit(t,n,r,i){return new e({...this._def,checks:[...this._def.checks,{kind:t,value:n,inclusive:r,message:E.toString(i)}]})}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}positive(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!1,message:E.toString(e)})}negative(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!1,message:E.toString(e)})}nonpositive(e){return this._addCheck({kind:`max`,value:BigInt(0),inclusive:!0,message:E.toString(e)})}nonnegative(e){return this._addCheck({kind:`min`,value:BigInt(0),inclusive:!0,message:E.toString(e)})}multipleOf(e,t){return this._addCheck({kind:`multipleOf`,value:e,message:E.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e}};Tn.create=e=>new Tn({checks:[],typeName:k.ZodBigInt,coerce:e?.coerce??!1,...D(e)});var En=class extends O{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.boolean,received:t.parsedType}),w}return T(e.data)}};En.create=e=>new En({typeName:k.ZodBoolean,coerce:e?.coerce||!1,...D(e)});var Dn=class e extends O{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.date,received:t.parsedType}),w}if(Number.isNaN(e.data.getTime()))return C(this._getOrReturnCtx(e),{code:S.invalid_date}),w;let t=new Ut,n;for(let r of this._def.checks)r.kind===`min`?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:S.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:`date`}),t.dirty()):r.kind===`max`?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),C(n,{code:S.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:`date`}),t.dirty()):b.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(t){return new e({...this._def,checks:[...this._def.checks,t]})}min(e,t){return this._addCheck({kind:`min`,value:e.getTime(),message:E.toString(t)})}max(e,t){return this._addCheck({kind:`max`,value:e.getTime(),message:E.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind===`min`&&(e===null||t.value>e)&&(e=t.value);return e==null?null:new Date(e)}get maxDate(){let e=null;for(let t of this._def.checks)t.kind===`max`&&(e===null||t.value<e)&&(e=t.value);return e==null?null:new Date(e)}};Dn.create=e=>new Dn({checks:[],coerce:e?.coerce||!1,typeName:k.ZodDate,...D(e)});var On=class extends O{_parse(e){if(this._getType(e)!==x.symbol){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.symbol,received:t.parsedType}),w}return T(e.data)}};On.create=e=>new On({typeName:k.ZodSymbol,...D(e)});var kn=class extends O{_parse(e){if(this._getType(e)!==x.undefined){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.undefined,received:t.parsedType}),w}return T(e.data)}};kn.create=e=>new kn({typeName:k.ZodUndefined,...D(e)});var An=class extends O{_parse(e){if(this._getType(e)!==x.null){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.null,received:t.parsedType}),w}return T(e.data)}};An.create=e=>new An({typeName:k.ZodNull,...D(e)});var jn=class extends O{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}};jn.create=e=>new jn({typeName:k.ZodAny,...D(e)});var Mn=class extends O{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}};Mn.create=e=>new Mn({typeName:k.ZodUnknown,...D(e)});var Nn=class extends O{_parse(e){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.never,received:t.parsedType}),w}};Nn.create=e=>new Nn({typeName:k.ZodNever,...D(e)});var Pn=class extends O{_parse(e){if(this._getType(e)!==x.undefined){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.void,received:t.parsedType}),w}return T(e.data)}};Pn.create=e=>new Pn({typeName:k.ZodVoid,...D(e)});var Fn=class e extends O{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==x.array)return C(t,{code:S.invalid_type,expected:x.array,received:t.parsedType}),w;if(r.exactLength!==null){let e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(C(t,{code:e?S.too_big:S.too_small,minimum:i?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:`array`,inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&t.data.length<r.minLength.value&&(C(t,{code:S.too_small,minimum:r.minLength.value,type:`array`,inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(C(t,{code:S.too_big,maximum:r.maxLength.value,type:`array`,inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new Yt(t,e,t.path,n)))).then(e=>Ut.mergeArray(n,e));let i=[...t.data].map((e,n)=>r.type._parseSync(new Yt(t,e,t.path,n)));return Ut.mergeArray(n,i)}get element(){return this._def.type}min(t,n){return new e({...this._def,minLength:{value:t,message:E.toString(n)}})}max(t,n){return new e({...this._def,maxLength:{value:t,message:E.toString(n)}})}length(t,n){return new e({...this._def,exactLength:{value:t,message:E.toString(n)}})}nonempty(e){return this.min(1,e)}};Fn.create=(e,t)=>new Fn({type:e,minLength:null,maxLength:null,exactLength:null,typeName:k.ZodArray,...D(t)});function In(e){if(e instanceof Ln){let t={};for(let n in e.shape){let r=e.shape[n];t[n]=tr.create(In(r))}return new Ln({...e._def,shape:()=>t})}else if(e instanceof Fn)return new Fn({...e._def,type:In(e.element)});else if(e instanceof tr)return tr.create(In(e.unwrap()));else if(e instanceof nr)return nr.create(In(e.unwrap()));else if(e instanceof Un)return Un.create(e.items.map(e=>In(e)));else return e}var Ln=class e extends O{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape();return this._cached={shape:e,keys:b.objectKeys(e)},this._cached}_parse(e){if(this._getType(e)!==x.object){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.object,received:t.parsedType}),w}let{status:t,ctx:n}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),a=[];if(!(this._def.catchall instanceof Nn&&this._def.unknownKeys===`strip`))for(let e in n.data)i.includes(e)||a.push(e);let o=[];for(let e of i){let t=r[e],i=n.data[e];o.push({key:{status:`valid`,value:e},value:t._parse(new Yt(n,i,n.path,e)),alwaysSet:e in n.data})}if(this._def.catchall instanceof Nn){let e=this._def.unknownKeys;if(e===`passthrough`)for(let e of a)o.push({key:{status:`valid`,value:e},value:{status:`valid`,value:n.data[e]}});else if(e===`strict`)a.length>0&&(C(n,{code:S.unrecognized_keys,keys:a}),t.dirty());else if(e!==`strip`)throw Error(`Internal ZodObject error: invalid unknownKeys value.`)}else{let e=this._def.catchall;for(let t of a){let r=n.data[t];o.push({key:{status:`valid`,value:t},value:e._parse(new Yt(n,r,n.path,t)),alwaysSet:t in n.data})}}return n.common.async?Promise.resolve().then(async()=>{let e=[];for(let t of o){let n=await t.key,r=await t.value;e.push({key:n,value:r,alwaysSet:t.alwaysSet})}return e}).then(e=>Ut.mergeObjectSync(t,e)):Ut.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(t){return E.errToObj,new e({...this._def,unknownKeys:`strict`,...t===void 0?{}:{errorMap:(e,n)=>{let r=this._def.errorMap?.(e,n).message??n.defaultError;return e.code===`unrecognized_keys`?{message:E.errToObj(t).message??r}:{message:r}}}})}strip(){return new e({...this._def,unknownKeys:`strip`})}passthrough(){return new e({...this._def,unknownKeys:`passthrough`})}extend(t){return new e({...this._def,shape:()=>({...this._def.shape(),...t})})}merge(t){return new e({unknownKeys:t._def.unknownKeys,catchall:t._def.catchall,shape:()=>({...this._def.shape(),...t._def.shape()}),typeName:k.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(t){return new e({...this._def,catchall:t})}pick(t){let n={};for(let e of b.objectKeys(t))t[e]&&this.shape[e]&&(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}omit(t){let n={};for(let e of b.objectKeys(this.shape))t[e]||(n[e]=this.shape[e]);return new e({...this._def,shape:()=>n})}deepPartial(){return In(this)}partial(t){let n={};for(let e of b.objectKeys(this.shape)){let r=this.shape[e];t&&!t[e]?n[e]=r:n[e]=r.optional()}return new e({...this._def,shape:()=>n})}required(t){let n={};for(let e of b.objectKeys(this.shape))if(t&&!t[e])n[e]=this.shape[e];else{let t=this.shape[e];for(;t instanceof tr;)t=t._def.innerType;n[e]=t}return new e({...this._def,shape:()=>n})}keyof(){return Xn(b.objectKeys(this.shape))}};Ln.create=(e,t)=>new Ln({shape:()=>e,unknownKeys:`strip`,catchall:Nn.create(),typeName:k.ZodObject,...D(t)}),Ln.strictCreate=(e,t)=>new Ln({shape:()=>e,unknownKeys:`strict`,catchall:Nn.create(),typeName:k.ZodObject,...D(t)}),Ln.lazycreate=(e,t)=>new Ln({shape:e,unknownKeys:`strip`,catchall:Nn.create(),typeName:k.ZodObject,...D(t)});var Rn=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function r(e){for(let t of e)if(t.result.status===`valid`)return t.result;for(let n of e)if(n.result.status===`dirty`)return t.common.issues.push(...n.ctx.common.issues),n.result;let n=e.map(e=>new Rt(e.ctx.common.issues));return C(t,{code:S.invalid_union,unionErrors:n}),w}if(t.common.async)return Promise.all(n.map(async e=>{let n={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:n}),ctx:n}})).then(r);{let e,r=[];for(let i of n){let n={...t,common:{...t.common,issues:[]},parent:null},a=i._parseSync({data:t.data,path:t.path,parent:n});if(a.status===`valid`)return a;a.status===`dirty`&&!e&&(e={result:a,ctx:n}),n.common.issues.length&&r.push(n.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;let i=r.map(e=>new Rt(e));return C(t,{code:S.invalid_union,unionErrors:i}),w}}get options(){return this._def.options}};Rn.create=(e,t)=>new Rn({options:e,typeName:k.ZodUnion,...D(t)});var zn=e=>e instanceof Jn?zn(e.schema):e instanceof er?zn(e.innerType()):e instanceof Yn?[e.value]:e instanceof Zn?e.options:e instanceof Qn?b.objectValues(e.enum):e instanceof rr?zn(e._def.innerType):e instanceof kn?[void 0]:e instanceof An?[null]:e instanceof tr?[void 0,...zn(e.unwrap())]:e instanceof nr?[null,...zn(e.unwrap())]:e instanceof or||e instanceof cr?zn(e.unwrap()):e instanceof ir?zn(e._def.innerType):[],Bn=class e extends O{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return C(t,{code:S.invalid_type,expected:x.object,received:t.parsedType}),w;let n=this.discriminator,r=t.data[n],i=this.optionsMap.get(r);return i?t.common.async?i._parseAsync({data:t.data,path:t.path,parent:t}):i._parseSync({data:t.data,path:t.path,parent:t}):(C(t,{code:S.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),w)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(t,n,r){let i=new Map;for(let e of n){let n=zn(e.shape[t]);if(!n.length)throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);for(let r of n){if(i.has(r))throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);i.set(r,e)}}return new e({typeName:k.ZodDiscriminatedUnion,discriminator:t,options:n,optionsMap:i,...D(r)})}};function Vn(e,t){let n=Lt(e),r=Lt(t);if(e===t)return{valid:!0,data:e};if(n===x.object&&r===x.object){let n=b.objectKeys(t),r=b.objectKeys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Vn(e[n],t[n]);if(!r.valid)return{valid:!1};i[n]=r.data}return{valid:!0,data:i}}else if(n===x.array&&r===x.array){if(e.length!==t.length)return{valid:!1};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Vn(i,a);if(!o.valid)return{valid:!1};n.push(o.data)}return{valid:!0,data:n}}else if(n===x.date&&r===x.date&&+e==+t)return{valid:!0,data:e};else return{valid:!1}}var Hn=class extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=(e,r)=>{if(Gt(e)||Gt(r))return w;let i=Vn(e.value,r.value);return i.valid?((Kt(e)||Kt(r))&&t.dirty(),{status:t.value,value:i.data}):(C(n,{code:S.invalid_intersection_types}),w)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([e,t])=>r(e,t)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};Hn.create=(e,t,n)=>new Hn({left:e,right:t,typeName:k.ZodIntersection,...D(n)});var Un=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.array)return C(n,{code:S.invalid_type,expected:x.array,received:n.parsedType}),w;if(n.data.length<this._def.items.length)return C(n,{code:S.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),w;!this._def.rest&&n.data.length>this._def.items.length&&(C(n,{code:S.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:`array`}),t.dirty());let r=[...n.data].map((e,t)=>{let r=this._def.items[t]||this._def.rest;return r?r._parse(new Yt(n,e,n.path,t)):null}).filter(e=>!!e);return n.common.async?Promise.all(r).then(e=>Ut.mergeArray(t,e)):Ut.mergeArray(t,r)}get items(){return this._def.items}rest(t){return new e({...this._def,rest:t})}};Un.create=(e,t)=>{if(!Array.isArray(e))throw Error(`You must pass an array of schemas to z.tuple([ ... ])`);return new Un({items:e,typeName:k.ZodTuple,rest:null,...D(t)})};var Wn=class e extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.object)return C(n,{code:S.invalid_type,expected:x.object,received:n.parsedType}),w;let r=[],i=this._def.keyType,a=this._def.valueType;for(let e in n.data)r.push({key:i._parse(new Yt(n,e,n.path,e)),value:a._parse(new Yt(n,n.data[e],n.path,e)),alwaysSet:e in n.data});return n.common.async?Ut.mergeObjectAsync(t,r):Ut.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(t,n,r){return n instanceof O?new e({keyType:t,valueType:n,typeName:k.ZodRecord,...D(r)}):new e({keyType:Sn.create(),valueType:t,typeName:k.ZodRecord,...D(n)})}},Gn=class extends O{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.map)return C(n,{code:S.invalid_type,expected:x.map,received:n.parsedType}),w;let r=this._def.keyType,i=this._def.valueType,a=[...n.data.entries()].map(([e,t],a)=>({key:r._parse(new Yt(n,e,n.path,[a,`key`])),value:i._parse(new Yt(n,t,n.path,[a,`value`]))}));if(n.common.async){let e=new Map;return Promise.resolve().then(async()=>{for(let n of a){let r=await n.key,i=await n.value;if(r.status===`aborted`||i.status===`aborted`)return w;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}})}else{let e=new Map;for(let n of a){let r=n.key,i=n.value;if(r.status===`aborted`||i.status===`aborted`)return w;(r.status===`dirty`||i.status===`dirty`)&&t.dirty(),e.set(r.value,i.value)}return{status:t.value,value:e}}}};Gn.create=(e,t,n)=>new Gn({valueType:t,keyType:e,typeName:k.ZodMap,...D(n)});var Kn=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==x.set)return C(n,{code:S.invalid_type,expected:x.set,received:n.parsedType}),w;let r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(C(n,{code:S.too_small,minimum:r.minSize.value,type:`set`,inclusive:!0,exact:!1,message:r.minSize.message}),t.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(C(n,{code:S.too_big,maximum:r.maxSize.value,type:`set`,inclusive:!0,exact:!1,message:r.maxSize.message}),t.dirty());let i=this._def.valueType;function a(e){let n=new Set;for(let r of e){if(r.status===`aborted`)return w;r.status===`dirty`&&t.dirty(),n.add(r.value)}return{status:t.value,value:n}}let o=[...n.data.values()].map((e,t)=>i._parse(new Yt(n,e,n.path,t)));return n.common.async?Promise.all(o).then(e=>a(e)):a(o)}min(t,n){return new e({...this._def,minSize:{value:t,message:E.toString(n)}})}max(t,n){return new e({...this._def,maxSize:{value:t,message:E.toString(n)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Kn.create=(e,t)=>new Kn({valueType:e,minSize:null,maxSize:null,typeName:k.ZodSet,...D(t)});var qn=class e extends O{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return C(t,{code:S.invalid_type,expected:x.function,received:t.parsedType}),w;function n(e,n){return Ht({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vt(),zt].filter(e=>!!e),issueData:{code:S.invalid_arguments,argumentsError:n}})}function r(e,n){return Ht({data:e,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Vt(),zt].filter(e=>!!e),issueData:{code:S.invalid_return_type,returnTypeError:n}})}let i={errorMap:t.common.contextualErrorMap},a=t.data;if(this._def.returns instanceof $n){let e=this;return T(async function(...t){let o=new Rt([]),s=await e._def.args.parseAsync(t,i).catch(e=>{throw o.addIssue(n(t,e)),o}),c=await Reflect.apply(a,this,s);return await e._def.returns._def.type.parseAsync(c,i).catch(e=>{throw o.addIssue(r(c,e)),o})})}else{let e=this;return T(function(...t){let o=e._def.args.safeParse(t,i);if(!o.success)throw new Rt([n(t,o.error)]);let s=Reflect.apply(a,this,o.data),c=e._def.returns.safeParse(s,i);if(!c.success)throw new Rt([r(s,c.error)]);return c.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...t){return new e({...this._def,args:Un.create(t).rest(Mn.create())})}returns(t){return new e({...this._def,returns:t})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(t,n,r){return new e({args:t||Un.create([]).rest(Mn.create()),returns:n||Mn.create(),typeName:k.ZodFunction,...D(r)})}},Jn=class extends O{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Jn.create=(e,t)=>new Jn({getter:e,typeName:k.ZodLazy,...D(t)});var Yn=class extends O{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return C(t,{received:t.data,code:S.invalid_literal,expected:this._def.value}),w}return{status:`valid`,value:e.data}}get value(){return this._def.value}};Yn.create=(e,t)=>new Yn({value:e,typeName:k.ZodLiteral,...D(t)});function Xn(e,t){return new Zn({values:e,typeName:k.ZodEnum,...D(t)})}var Zn=class e extends O{_parse(e){if(typeof e.data!=`string`){let t=this._getOrReturnCtx(e),n=this._def.values;return C(t,{expected:b.joinValues(n),received:t.parsedType,code:S.invalid_type}),w}if(this._cache||=new Set(this._def.values),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return C(t,{received:t.data,code:S.invalid_enum_value,options:n}),w}return T(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(t,n=this._def){return e.create(t,{...this._def,...n})}exclude(t,n=this._def){return e.create(this.options.filter(e=>!t.includes(e)),{...this._def,...n})}};Zn.create=Xn;var Qn=class extends O{_parse(e){let t=b.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==x.string&&n.parsedType!==x.number){let e=b.objectValues(t);return C(n,{expected:b.joinValues(e),received:n.parsedType,code:S.invalid_type}),w}if(this._cache||=new Set(b.getValidEnumValues(this._def.values)),!this._cache.has(e.data)){let e=b.objectValues(t);return C(n,{received:n.data,code:S.invalid_enum_value,options:e}),w}return T(e.data)}get enum(){return this._def.values}};Qn.create=(e,t)=>new Qn({values:e,typeName:k.ZodNativeEnum,...D(t)});var $n=class extends O{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);return t.parsedType!==x.promise&&t.common.async===!1?(C(t,{code:S.invalid_type,expected:x.promise,received:t.parsedType}),w):T((t.parsedType===x.promise?t.data:Promise.resolve(t.data)).then(e=>this._def.type.parseAsync(e,{path:t.path,errorMap:t.common.contextualErrorMap})))}};$n.create=(e,t)=>new $n({type:e,typeName:k.ZodPromise,...D(t)});var er=class extends O{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===k.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,i={addIssue:e=>{C(n,e),e.fatal?t.abort():t.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),r.type===`preprocess`){let e=r.transform(n.data,i);if(n.common.async)return Promise.resolve(e).then(async e=>{if(t.value===`aborted`)return w;let r=await this._def.schema._parseAsync({data:e,path:n.path,parent:n});return r.status===`aborted`?w:r.status===`dirty`||t.value===`dirty`?Wt(r.value):r});{if(t.value===`aborted`)return w;let r=this._def.schema._parseSync({data:e,path:n.path,parent:n});return r.status===`aborted`?w:r.status===`dirty`||t.value===`dirty`?Wt(r.value):r}}if(r.type===`refinement`){let e=e=>{let t=r.refinement(e,i);if(n.common.async)return Promise.resolve(t);if(t instanceof Promise)throw Error(`Async refinement encountered during synchronous parse operation. Use .parseAsync instead.`);return e};if(n.common.async===!1){let r=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return r.status===`aborted`?w:(r.status===`dirty`&&t.dirty(),e(r.value),{status:t.value,value:r.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(n=>n.status===`aborted`?w:(n.status===`dirty`&&t.dirty(),e(n.value).then(()=>({status:t.value,value:n.value}))))}if(r.type===`transform`)if(n.common.async===!1){let e=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!qt(e))return w;let a=r.transform(e.value,i);if(a instanceof Promise)throw Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(e=>qt(e)?Promise.resolve(r.transform(e.value,i)).then(e=>({status:t.value,value:e})):w);b.assertNever(r)}};er.create=(e,t,n)=>new er({schema:e,typeName:k.ZodEffects,effect:t,...D(n)}),er.createWithPreprocess=(e,t,n)=>new er({schema:t,effect:{type:`preprocess`,transform:e},typeName:k.ZodEffects,...D(n)});var tr=class extends O{_parse(e){return this._getType(e)===x.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tr.create=(e,t)=>new tr({innerType:e,typeName:k.ZodOptional,...D(t)});var nr=class extends O{_parse(e){return this._getType(e)===x.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};nr.create=(e,t)=>new nr({innerType:e,typeName:k.ZodNullable,...D(t)});var rr=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===x.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};rr.create=(e,t)=>new rr({innerType:e,typeName:k.ZodDefault,defaultValue:typeof t.default==`function`?t.default:()=>t.default,...D(t)});var ir=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Jt(r)?r.then(e=>({status:`valid`,value:e.status===`valid`?e.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})})):{status:`valid`,value:r.status===`valid`?r.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};ir.create=(e,t)=>new ir({innerType:e,typeName:k.ZodCatch,catchValue:typeof t.catch==`function`?t.catch:()=>t.catch,...D(t)});var ar=class extends O{_parse(e){if(this._getType(e)!==x.nan){let t=this._getOrReturnCtx(e);return C(t,{code:S.invalid_type,expected:x.nan,received:t.parsedType}),w}return{status:`valid`,value:e.data}}};ar.create=e=>new ar({typeName:k.ZodNaN,...D(e)});var or=class extends O{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},sr=class e extends O{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let e=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?w:e.status===`dirty`?(t.dirty(),Wt(e.value)):this._def.out._parseAsync({data:e.value,path:n.path,parent:n})})();{let e=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return e.status===`aborted`?w:e.status===`dirty`?(t.dirty(),{status:`dirty`,value:e.value}):this._def.out._parseSync({data:e.value,path:n.path,parent:n})}}static create(t,n){return new e({in:t,out:n,typeName:k.ZodPipeline})}},cr=class extends O{_parse(e){let t=this._def.innerType._parse(e),n=e=>(qt(e)&&(e.value=Object.freeze(e.value)),e);return Jt(t)?t.then(e=>n(e)):n(t)}unwrap(){return this._def.innerType}};cr.create=(e,t)=>new cr({innerType:e,typeName:k.ZodReadonly,...D(t)}),Ln.lazycreate;var k;(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`})(k||={});var A=Sn.create,lr=wn.create;ar.create,Tn.create;var ur=En.create;Dn.create,On.create,kn.create,An.create;var j=jn.create;Mn.create,Nn.create,Pn.create;var dr=Fn.create,M=Ln.create;Ln.strictCreate;var fr=Rn.create,pr=Bn.create;Hn.create,Un.create;var mr=Wn.create;Gn.create,Kn.create,qn.create,Jn.create;var N=Yn.create,hr=Zn.create,gr=Qn.create;$n.create,er.create,tr.create,nr.create,er.createWithPreprocess,sr.create;var _r=M({name:A(),arguments:A()}),vr=M({id:A(),type:N(`function`),function:_r}),yr=M({id:A(),role:A(),content:A().optional(),name:A().optional()}),br=M({type:N(`text`),text:A()}),xr=M({type:N(`binary`),mimeType:A(),id:A().optional(),url:A().optional(),data:A().optional(),filename:A().optional()}),Sr=(e,t)=>{!e.id&&!e.url&&!e.data&&t.addIssue({code:S.custom,message:`BinaryInputContent requires at least one of id, url, or data.`,path:[`id`]})};xr.superRefine((e,t)=>{Sr(e,t)});var Cr=pr(`type`,[br,xr]).superRefine((e,t)=>{e.type===`binary`&&Sr(e,t)}),wr=pr(`role`,[yr.extend({role:N(`developer`),content:A()}),yr.extend({role:N(`system`),content:A()}),yr.extend({role:N(`assistant`),content:A().optional(),toolCalls:dr(vr).optional()}),yr.extend({role:N(`user`),content:fr([A(),dr(Cr)])}),M({id:A(),content:A(),role:N(`tool`),toolCallId:A(),error:A().optional()}),M({id:A(),role:N(`activity`),activityType:A(),content:mr(j())})]);fr([N(`developer`),N(`system`),N(`assistant`),N(`user`),N(`tool`),N(`activity`)]);var Tr=M({description:A(),value:A()}),Er=M({name:A(),description:A(),parameters:j()}),Dr=M({threadId:A(),runId:A(),parentRunId:A().optional(),state:j(),messages:dr(wr),tools:dr(Er),context:dr(Tr),forwardedProps:j()}),Or=j(),P=class extends Error{constructor(e){super(e)}},kr=class extends P{constructor(){super(`Connect not implemented. This method is not supported by the current agent.`)}},Ar=fr([N(`developer`),N(`system`),N(`assistant`),N(`user`)]),F=(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))(F||{}),I=M({type:gr(F),timestamp:lr().optional(),rawEvent:j().optional()}),jr=I.extend({type:N(`TEXT_MESSAGE_START`),messageId:A(),role:Ar.default(`assistant`)}),Mr=I.extend({type:N(`TEXT_MESSAGE_CONTENT`),messageId:A(),delta:A().refine(e=>e.length>0,`Delta must not be an empty string`)}),Nr=I.extend({type:N(`TEXT_MESSAGE_END`),messageId:A()}),Pr=I.extend({type:N(`TEXT_MESSAGE_CHUNK`),messageId:A().optional(),role:Ar.optional(),delta:A().optional()}),Fr=I.extend({type:N(`THINKING_TEXT_MESSAGE_START`)}),Ir=Mr.omit({messageId:!0,type:!0}).extend({type:N(`THINKING_TEXT_MESSAGE_CONTENT`)}),Lr=I.extend({type:N(`THINKING_TEXT_MESSAGE_END`)}),Rr=I.extend({type:N(`TOOL_CALL_START`),toolCallId:A(),toolCallName:A(),parentMessageId:A().optional()}),zr=I.extend({type:N(`TOOL_CALL_ARGS`),toolCallId:A(),delta:A()}),Br=I.extend({type:N(`TOOL_CALL_END`),toolCallId:A()}),Vr=I.extend({messageId:A(),type:N(`TOOL_CALL_RESULT`),toolCallId:A(),content:A(),role:N(`tool`).optional()}),Hr=I.extend({type:N(`TOOL_CALL_CHUNK`),toolCallId:A().optional(),toolCallName:A().optional(),parentMessageId:A().optional(),delta:A().optional()}),Ur=pr(`type`,[jr,Mr,Nr,Pr,I.extend({type:N(`THINKING_START`),title:A().optional()}),I.extend({type:N(`THINKING_END`)}),Fr,Ir,Lr,Rr,zr,Br,Hr,Vr,I.extend({type:N(`STATE_SNAPSHOT`),snapshot:Or}),I.extend({type:N(`STATE_DELTA`),delta:dr(j())}),I.extend({type:N(`MESSAGES_SNAPSHOT`),messages:dr(wr)}),I.extend({type:N(`ACTIVITY_SNAPSHOT`),messageId:A(),activityType:A(),content:mr(j()),replace:ur().optional().default(!0)}),I.extend({type:N(`ACTIVITY_DELTA`),messageId:A(),activityType:A(),patch:dr(j())}),I.extend({type:N(`RAW`),event:j(),source:A().optional()}),I.extend({type:N(`CUSTOM`),name:A(),value:j()}),I.extend({type:N(`RUN_STARTED`),threadId:A(),runId:A(),parentRunId:A().optional(),input:Dr.optional()}),I.extend({type:N(`RUN_FINISHED`),threadId:A(),runId:A(),result:j().optional()}),I.extend({type:N(`RUN_ERROR`),message:A(),code:A().optional()}),I.extend({type:N(`STEP_STARTED`),stepName:A()}),I.extend({type:N(`STEP_FINISHED`),stepName:A()})]);function L(e){return typeof e==`function`}function Wr(e){return L(e?.lift)}function Gr(e){return function(t){if(Wr(t))return t.lift(function(t){try{return e(t,this)}catch(e){this.error(e)}});throw TypeError(`Unable to lift unknown Observable type`)}}var Kr=function(e,t){return Kr=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},Kr(e,t)};function qr(e,t){if(typeof t!=`function`&&t!==null)throw TypeError(`Class extends value `+String(t)+` is not a constructor or null`);Kr(e,t);function n(){this.constructor=e}e.prototype=t===null?Object.create(t):(n.prototype=t.prototype,new n)}function Jr(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})}function Yr(e,t){var n={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},r,i,a,o=Object.create((typeof Iterator==`function`?Iterator:Object).prototype);return o.next=s(0),o.throw=s(1),o.return=s(2),typeof Symbol==`function`&&(o[Symbol.iterator]=function(){return this}),o;function s(e){return function(t){return c([e,t])}}function c(s){if(r)throw TypeError(`Generator is already executing.`);for(;o&&(o=0,s[0]&&(n=0)),n;)try{if(r=1,i&&(a=s[0]&2?i.return:s[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,s[1])).done)return a;switch(i=0,a&&(s=[s[0]&2,a.value]),s[0]){case 0:case 1:a=s;break;case 4:return n.label++,{value:s[1],done:!1};case 5:n.label++,i=s[1],s=[0];continue;case 7:s=n.ops.pop(),n.trys.pop();continue;default:if((a=n.trys,!(a=a.length>0&&a[a.length-1]))&&(s[0]===6||s[0]===2)){n=0;continue}if(s[0]===3&&(!a||s[1]>a[0]&&s[1]<a[3])){n.label=s[1];break}if(s[0]===6&&n.label<a[1]){n.label=a[1],a=s;break}if(a&&n.label<a[2]){n.label=a[2],n.ops.push(s);break}a[2]&&n.ops.pop(),n.trys.pop();continue}s=t.call(e,n)}catch(e){s=[6,e],i=0}finally{r=a=0}if(s[0]&5)throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}}function Xr(e){var t=typeof Symbol==`function`&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&typeof e.length==`number`)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?`Object is not iterable.`:`Symbol.iterator is not defined.`)}function Zr(e,t){var n=typeof Symbol==`function`&&e[Symbol.iterator];if(!n)return e;var r=n.call(e),i,a=[],o;try{for(;(t===void 0||t-- >0)&&!(i=r.next()).done;)a.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(o)throw o.error}}return a}function Qr(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}function $r(e){return this instanceof $r?(this.v=e,this):new $r(e)}function ei(e,t,n){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var r=n.apply(e,t||[]),i,a=[];return i=Object.create((typeof AsyncIterator==`function`?AsyncIterator:Object).prototype),s(`next`),s(`throw`),s(`return`,o),i[Symbol.asyncIterator]=function(){return this},i;function o(e){return function(t){return Promise.resolve(t).then(e,d)}}function s(e,t){r[e]&&(i[e]=function(t){return new Promise(function(n,r){a.push([e,t,n,r])>1||c(e,t)})},t&&(i[e]=t(i[e])))}function c(e,t){try{l(r[e](t))}catch(e){f(a[0][3],e)}}function l(e){e.value instanceof $r?Promise.resolve(e.value.v).then(u,d):f(a[0][2],e)}function u(e){c(`next`,e)}function d(e){c(`throw`,e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ti(e){if(!Symbol.asyncIterator)throw TypeError(`Symbol.asyncIterator is not defined.`);var t=e[Symbol.asyncIterator],n;return t?t.call(e):(e=typeof Xr==`function`?Xr(e):e[Symbol.iterator](),n={},r(`next`),r(`throw`),r(`return`),n[Symbol.asyncIterator]=function(){return this},n);function r(t){n[t]=e[t]&&function(n){return new Promise(function(r,a){n=e[t](n),i(r,a,n.done,n.value)})}}function i(e,t,n,r){Promise.resolve(r).then(function(t){e({value:t,done:n})},t)}}var ni=(function(e){return e&&typeof e.length==`number`&&typeof e!=`function`});function ri(e){return L(e?.then)}function ii(e){var t=e(function(e){Error.call(e),e.stack=Error().stack});return t.prototype=Object.create(Error.prototype),t.prototype.constructor=t,t}var ai=ii(function(e){return function(t){e(this),this.message=t?t.length+` errors occurred during unsubscription:
686
+ `+t.map(function(e,t){return t+1+`) `+e.toString()}).join(`
687
+ `):``,this.name=`UnsubscriptionError`,this.errors=t}});function oi(e,t){if(e){var n=e.indexOf(t);0<=n&&e.splice(n,1)}}var si=function(){function e(e){this.initialTeardown=e,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var e,t,n,r,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var o=Xr(a),s=o.next();!s.done;s=o.next())s.value.remove(this)}catch(t){e={error:t}}finally{try{s&&!s.done&&(t=o.return)&&t.call(o)}finally{if(e)throw e.error}}else a.remove(this);var c=this.initialTeardown;if(L(c))try{c()}catch(e){i=e instanceof ai?e.errors:[e]}var l=this._finalizers;if(l){this._finalizers=null;try{for(var u=Xr(l),d=u.next();!d.done;d=u.next()){var f=d.value;try{ui(f)}catch(e){i??=[],e instanceof ai?i=Qr(Qr([],Zr(i)),Zr(e.errors)):i.push(e)}}}catch(e){n={error:e}}finally{try{d&&!d.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}}if(i)throw new ai(i)}},e.prototype.add=function(t){if(t&&t!==this)if(this.closed)ui(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=this._finalizers??[]).push(t)}},e.prototype._hasParent=function(e){var t=this._parentage;return t===e||Array.isArray(t)&&t.includes(e)},e.prototype._addParent=function(e){var t=this._parentage;this._parentage=Array.isArray(t)?(t.push(e),t):t?[t,e]:e},e.prototype._removeParent=function(e){var t=this._parentage;t===e?this._parentage=null:Array.isArray(t)&&oi(t,e)},e.prototype.remove=function(t){var n=this._finalizers;n&&oi(n,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e}(),ci=si.EMPTY;function li(e){return e instanceof si||e&&`closed`in e&&L(e.remove)&&L(e.add)&&L(e.unsubscribe)}function ui(e){L(e)?e():e.unsubscribe()}var di={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},fi={setTimeout:function(e,t){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];var i=fi.delegate;return i?.setTimeout?i.setTimeout.apply(i,Qr([e,t],Zr(n))):setTimeout.apply(void 0,Qr([e,t],Zr(n)))},clearTimeout:function(e){return(fi.delegate?.clearTimeout||clearTimeout)(e)},delegate:void 0};function pi(e){fi.setTimeout(function(){var t=di.onUnhandledError;if(t)t(e);else throw e})}function mi(){}var hi=(function(){return vi(`C`,void 0,void 0)})();function gi(e){return vi(`E`,void 0,e)}function _i(e){return vi(`N`,e,void 0)}function vi(e,t,n){return{kind:e,value:t,error:n}}var yi=null;function bi(e){if(di.useDeprecatedSynchronousErrorHandling){var t=!yi;if(t&&(yi={errorThrown:!1,error:null}),e(),t){var n=yi,r=n.errorThrown,i=n.error;if(yi=null,r)throw i}}else e()}function xi(e){di.useDeprecatedSynchronousErrorHandling&&yi&&(yi.errorThrown=!0,yi.error=e)}var Si=function(e){qr(t,e);function t(t){var n=e.call(this)||this;return n.isStopped=!1,t?(n.destination=t,li(t)&&t.add(n)):n.destination=Ai,n}return t.create=function(e,t,n){return new Ei(e,t,n)},t.prototype.next=function(e){this.isStopped?ki(_i(e),this):this._next(e)},t.prototype.error=function(e){this.isStopped?ki(gi(e),this):(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped?ki(hi,this):(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(si),Ci=Function.prototype.bind;function wi(e,t){return Ci.call(e,t)}var Ti=function(){function e(e){this.partialObserver=e}return e.prototype.next=function(e){var t=this.partialObserver;if(t.next)try{t.next(e)}catch(e){Di(e)}},e.prototype.error=function(e){var t=this.partialObserver;if(t.error)try{t.error(e)}catch(e){Di(e)}else Di(e)},e.prototype.complete=function(){var e=this.partialObserver;if(e.complete)try{e.complete()}catch(e){Di(e)}},e}(),Ei=function(e){qr(t,e);function t(t,n,r){var i=e.call(this)||this,a;if(L(t)||!t)a={next:t??void 0,error:n??void 0,complete:r??void 0};else{var o;i&&di.useDeprecatedNextContext?(o=Object.create(t),o.unsubscribe=function(){return i.unsubscribe()},a={next:t.next&&wi(t.next,o),error:t.error&&wi(t.error,o),complete:t.complete&&wi(t.complete,o)}):a=t}return i.destination=new Ti(a),i}return t}(Si);function Di(e){di.useDeprecatedSynchronousErrorHandling?xi(e):pi(e)}function Oi(e){throw e}function ki(e,t){var n=di.onStoppedNotification;n&&fi.setTimeout(function(){return n(e,t)})}var Ai={closed:!0,next:mi,error:Oi,complete:mi},ji=(function(){return typeof Symbol==`function`&&Symbol.observable||`@@observable`})();function Mi(e){return e}function Ni(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pi(e)}function Pi(e){return e.length===0?Mi:e.length===1?e[0]:function(t){return e.reduce(function(e,t){return t(e)},t)}}var R=function(){function e(e){e&&(this._subscribe=e)}return e.prototype.lift=function(t){var n=new e;return n.source=this,n.operator=t,n},e.prototype.subscribe=function(e,t,n){var r=this,i=Li(e)?e:new Ei(e,t,n);return bi(function(){var e=r,t=e.operator,n=e.source;i.add(t?t.call(i,n):n?r._subscribe(i):r._trySubscribe(i))}),i},e.prototype._trySubscribe=function(e){try{return this._subscribe(e)}catch(t){e.error(t)}},e.prototype.forEach=function(e,t){var n=this;return t=Fi(t),new t(function(t,r){var i=new Ei({next:function(t){try{e(t)}catch(e){r(e),i.unsubscribe()}},error:r,complete:t});n.subscribe(i)})},e.prototype._subscribe=function(e){return this.source?.subscribe(e)},e.prototype[ji]=function(){return this},e.prototype.pipe=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Pi(e)(this)},e.prototype.toPromise=function(e){var t=this;return e=Fi(e),new e(function(e,n){var r;t.subscribe(function(e){return r=e},function(e){return n(e)},function(){return e(r)})})},e.create=function(t){return new e(t)},e}();function Fi(e){return e??di.Promise??Promise}function Ii(e){return e&&L(e.next)&&L(e.error)&&L(e.complete)}function Li(e){return e&&e instanceof Si||Ii(e)&&li(e)}function Ri(e){return L(e[ji])}function zi(e){return Symbol.asyncIterator&&L(e?.[Symbol.asyncIterator])}function Bi(e){return TypeError(`You provided `+(typeof e==`object`&&e?`an invalid object`:`'`+e+`'`)+` where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.`)}function Vi(){return typeof Symbol!=`function`||!Symbol.iterator?`@@iterator`:Symbol.iterator}var Hi=Vi();function Ui(e){return L(e?.[Hi])}function Wi(e){return ei(this,arguments,function(){var t,n,r,i;return Yr(this,function(a){switch(a.label){case 0:t=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,$r(t.read())];case 3:return n=a.sent(),r=n.value,i=n.done,i?[4,$r(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,$r(r)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return t.releaseLock(),[7];case 10:return[2]}})})}function Gi(e){return L(e?.getReader)}function Ki(e){if(e instanceof R)return e;if(e!=null){if(Ri(e))return qi(e);if(ni(e))return Ji(e);if(ri(e))return Yi(e);if(zi(e))return Zi(e);if(Ui(e))return Xi(e);if(Gi(e))return Qi(e)}throw Bi(e)}function qi(e){return new R(function(t){var n=e[ji]();if(L(n.subscribe))return n.subscribe(t);throw TypeError(`Provided object does not correctly implement Symbol.observable`)})}function Ji(e){return new R(function(t){for(var n=0;n<e.length&&!t.closed;n++)t.next(e[n]);t.complete()})}function Yi(e){return new R(function(t){e.then(function(e){t.closed||(t.next(e),t.complete())},function(e){return t.error(e)}).then(null,pi)})}function Xi(e){return new R(function(t){var n,r;try{for(var i=Xr(e),a=i.next();!a.done;a=i.next()){var o=a.value;if(t.next(o),t.closed)return}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}t.complete()})}function Zi(e){return new R(function(t){$i(e,t).catch(function(e){return t.error(e)})})}function Qi(e){return Zi(Wi(e))}function $i(e,t){var n,r,i,a;return Jr(this,void 0,void 0,function(){var o,s;return Yr(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),n=ti(e),c.label=1;case 1:return[4,n.next()];case 2:if(r=c.sent(),r.done)return[3,4];if(o=r.value,t.next(o),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),i={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),r&&!r.done&&(a=n.return)?[4,a.call(n)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(i)throw i.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function ea(e,t,n,r,i){return new ta(e,t,n,r,i)}var ta=function(e){qr(t,e);function t(t,n,r,i,a,o){var s=e.call(this,t)||this;return s.onFinalize=a,s.shouldUnsubscribe=o,s._next=n?function(e){try{n(e)}catch(e){t.error(e)}}:e.prototype._next,s._error=i?function(e){try{i(e)}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=r?function(){try{r()}catch(e){t.error(e)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var t;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((t=this.onFinalize)==null||t.call(this))}},t}(Si),na={now:function(){return(na.delegate||Date).now()},delegate:void 0};function ra(e){return e&&L(e.schedule)}function ia(e){return e[e.length-1]}function aa(e){return ra(ia(e))?e.pop():void 0}function oa(e,t,n,r,i){r===void 0&&(r=0),i===void 0&&(i=!1);var a=t.schedule(function(){n(),i?e.add(this.schedule(null,r)):this.unsubscribe()},r);if(e.add(a),!i)return a}function sa(e){return Gr(function(t,n){var r=null,i=!1,a;r=t.subscribe(ea(n,void 0,void 0,function(o){a=Ki(e(o,sa(e)(t))),r?(r.unsubscribe(),r=null,a.subscribe(n)):i=!0})),i&&(r.unsubscribe(),r=null,a.subscribe(n))})}function ca(e,t){return t===void 0&&(t=0),Gr(function(n,r){n.subscribe(ea(r,function(n){return oa(r,e,function(){return r.next(n)},t)},function(){return oa(r,e,function(){return r.complete()},t)},function(n){return oa(r,e,function(){return r.error(n)},t)}))})}function la(e,t){return t===void 0&&(t=0),Gr(function(n,r){r.add(e.schedule(function(){return n.subscribe(r)},t))})}function ua(e,t){return Ki(e).pipe(la(t),ca(t))}function da(e,t){return Ki(e).pipe(la(t),ca(t))}function fa(e,t){return new R(function(n){var r=0;return t.schedule(function(){r===e.length?n.complete():(n.next(e[r++]),n.closed||this.schedule())})})}function pa(e,t){return new R(function(n){var r;return oa(n,t,function(){r=e[Hi](),oa(n,t,function(){var e,t,i;try{e=r.next(),t=e.value,i=e.done}catch(e){n.error(e);return}i?n.complete():n.next(t)},0,!0)}),function(){return L(r?.return)&&r.return()}})}function ma(e,t){if(!e)throw Error(`Iterable cannot be null`);return new R(function(n){oa(n,t,function(){var r=e[Symbol.asyncIterator]();oa(n,t,function(){r.next().then(function(e){e.done?n.complete():n.next(e.value)})},0,!0)})})}function ha(e,t){return ma(Wi(e),t)}function ga(e,t){if(e!=null){if(Ri(e))return ua(e,t);if(ni(e))return fa(e,t);if(ri(e))return da(e,t);if(zi(e))return ma(e,t);if(Ui(e))return pa(e,t);if(Gi(e))return ha(e,t)}throw Bi(e)}function _a(e,t){return t?ga(e,t):Ki(e)}function va(e,t){return Gr(function(n,r){var i=0;n.subscribe(ea(r,function(n){r.next(e.call(t,n,i++))}))})}function ya(e,t,n,r,i,a,o,s){var c=[],l=0,u=0,d=!1,f=function(){d&&!c.length&&!l&&t.complete()},p=function(e){return l<r?m(e):c.push(e)},m=function(e){a&&t.next(e),l++;var s=!1;Ki(n(e,u++)).subscribe(ea(t,function(e){i?.(e),a?p(e):t.next(e)},function(){s=!0},void 0,function(){if(s)try{l--;for(var e=function(){var e=c.shift();o?oa(t,o,function(){return m(e)}):m(e)};c.length&&l<r;)e();f()}catch(e){t.error(e)}}))};return e.subscribe(ea(t,p,function(){d=!0,f()})),function(){s?.()}}function ba(e,t,n){return n===void 0&&(n=1/0),L(t)?ba(function(n,r){return va(function(e,i){return t(n,e,r,i)})(Ki(e(n,r)))},n):(typeof t==`number`&&(n=t),Gr(function(t,r){return ya(t,r,e,n)}))}function xa(e){return e===void 0&&(e=1/0),ba(Mi,e)}function Sa(e,t){return L(t)?ba(e,t,1):ba(e,1)}var Ca=ii(function(e){return function(){e(this),this.name=`ObjectUnsubscribedError`,this.message=`object unsubscribed`}}),wa=function(e){qr(t,e);function t(){var t=e.call(this)||this;return t.closed=!1,t.currentObservers=null,t.observers=[],t.isStopped=!1,t.hasError=!1,t.thrownError=null,t}return t.prototype.lift=function(e){var t=new Ta(this,this);return t.operator=e,t},t.prototype._throwIfClosed=function(){if(this.closed)throw new Ca},t.prototype.next=function(e){var t=this;bi(function(){var n,r;if(t._throwIfClosed(),!t.isStopped){t.currentObservers||=Array.from(t.observers);try{for(var i=Xr(t.currentObservers),a=i.next();!a.done;a=i.next())a.value.next(e)}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}}})},t.prototype.error=function(e){var t=this;bi(function(){if(t._throwIfClosed(),!t.isStopped){t.hasError=t.isStopped=!0,t.thrownError=e;for(var n=t.observers;n.length;)n.shift().error(e)}})},t.prototype.complete=function(){var e=this;bi(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var t=e.observers;t.length;)t.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,`observed`,{get:function(){return this.observers?.length>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(t){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,t)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var t=this,n=this,r=n.hasError,i=n.isStopped,a=n.observers;return r||i?ci:(this.currentObservers=null,a.push(e),new si(function(){t.currentObservers=null,oi(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var t=this,n=t.hasError,r=t.thrownError,i=t.isStopped;n?e.error(r):i&&e.complete()},t.prototype.asObservable=function(){var e=new R;return e.source=this,e},t.create=function(e,t){return new Ta(e,t)},t}(R),Ta=function(e){qr(t,e);function t(t,n){var r=e.call(this)||this;return r.destination=t,r.source=n,r}return t.prototype.next=function(e){var t,n;(n=(t=this.destination)?.next)==null||n.call(t,e)},t.prototype.error=function(e){var t,n;(n=(t=this.destination)?.error)==null||n.call(t,e)},t.prototype.complete=function(){var e,t;(t=(e=this.destination)?.complete)==null||t.call(e)},t.prototype._subscribe=function(e){return this.source?.subscribe(e)??ci},t}(wa);function Ea(e){return Gr(function(t,n){var r=!1;t.subscribe(ea(n,function(e){r=!0,n.next(e)},function(){r||n.next(e),n.complete()}))})}var Da=new R(function(e){return e.complete()});function z(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return _a(e,aa(e))}function B(e,t){var n=L(e)?e:function(){return e},r=function(e){return e.error(n())};return new R(t?function(e){return t.schedule(r,0,e)}:r)}var Oa=ii(function(e){return function(){e(this),this.name=`EmptyError`,this.message=`no elements in sequence`}});function ka(e){return Gr(function(t,n){try{t.subscribe(n)}finally{n.add(e)}})}var Aa=function(e){qr(t,e);function t(t,n,r){t===void 0&&(t=1/0),n===void 0&&(n=1/0),r===void 0&&(r=na);var i=e.call(this)||this;return i._bufferSize=t,i._windowTime=n,i._timestampProvider=r,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,t),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(t){var n=this,r=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,o=n._timestampProvider,s=n._windowTime;r||(i.push(t),!a&&i.push(o.now()+s)),this._trimBuffer(),e.prototype.next.call(this,t)},t.prototype._subscribe=function(e){this._throwIfClosed(),this._trimBuffer();for(var t=this._innerSubscribe(e),n=this,r=n._infiniteTimeWindow,i=n._buffer.slice(),a=0;a<i.length&&!e.closed;a+=r?1:2)e.next(i[a]);return this._checkFinalizedStatuses(e),t},t.prototype._trimBuffer=function(){var e=this,t=e._bufferSize,n=e._timestampProvider,r=e._buffer,i=e._infiniteTimeWindow,a=(i?1:2)*t;if(t<1/0&&a<r.length&&r.splice(0,r.length-a),!i){for(var o=n.now(),s=0,c=1;c<r.length&&r[c]<=o;c+=2)s=c;s&&r.splice(0,s+1)}},t}(wa);function ja(e,t){return Gr(function(n,r){var i=null,a=0,o=!1,s=function(){return o&&!i&&r.complete()};n.subscribe(ea(r,function(n){i?.unsubscribe();var o=0,c=a++;Ki(e(n,c)).subscribe(i=ea(r,function(e){return r.next(t?t(n,e,c,o++):e)},function(){i=null,s()}))},function(){o=!0,s()}))})}function Ma(e){return Gr(function(t,n){Ki(e).subscribe(ea(n,function(){return n.complete()},mi)),!n.closed&&t.subscribe(n)})}function Na(e,t,n){var r=L(e)||t||n?{next:e,error:t,complete:n}:e;return r?Gr(function(e,t){var n;(n=r.subscribe)==null||n.call(r);var i=!0;e.subscribe(ea(t,function(e){var n;(n=r.next)==null||n.call(r,e),t.next(e)},function(){var e;i=!1,(e=r.complete)==null||e.call(r),t.complete()},function(e){var n;i=!1,(n=r.error)==null||n.call(r,e),t.error(e)},function(){var e,t;i&&((e=r.unsubscribe)==null||e.call(r)),(t=r.finalize)==null||t.call(r)}))}):Mi}function Pa(e,t){var n=typeof t==`object`;return new Promise(function(r,i){var a=!1,o;e.subscribe({next:function(e){o=e,a=!0},error:i,complete:function(){a?r(o):n?r(t.defaultValue):i(new Oa)}})})}function Fa(e){return new R(function(t){Ki(e()).subscribe(t)})}var V=[];for(let e=0;e<256;++e)V.push((e+256).toString(16).slice(1));function Ia(e,t=0){return(V[e[t+0]]+V[e[t+1]]+V[e[t+2]]+V[e[t+3]]+`-`+V[e[t+4]]+V[e[t+5]]+`-`+V[e[t+6]]+V[e[t+7]]+`-`+V[e[t+8]]+V[e[t+9]]+`-`+V[e[t+10]]+V[e[t+11]]+V[e[t+12]]+V[e[t+13]]+V[e[t+14]]+V[e[t+15]]).toLowerCase()}var La,Ra=new Uint8Array(16);function za(){if(!La){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);La=crypto.getRandomValues.bind(crypto)}return La(Ra)}var Ba={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Va(e,t,n){if(Ba.randomUUID&&!t&&!e)return Ba.randomUUID();e||={};let r=e.random??e.rng?.()??za();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return Ia(r)}var Ha=Va,Ua=(function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},e(t,n)};return function(t,n){e(t,n);function r(){this.constructor=t}t.prototype=n===null?Object.create(n):(r.prototype=n.prototype,new r)}})(),Wa=Object.prototype.hasOwnProperty;function Ga(e,t){return Wa.call(e,t)}function Ka(e){if(Array.isArray(e)){for(var t=Array(e.length),n=0;n<t.length;n++)t[n]=``+n;return t}if(Object.keys)return Object.keys(e);var r=[];for(var i in e)Ga(e,i)&&r.push(i);return r}function qa(e){switch(typeof e){case`object`:return JSON.parse(JSON.stringify(e));case`undefined`:return null;default:return e}}function Ja(e){for(var t=0,n=e.length,r;t<n;){if(r=e.charCodeAt(t),r>=48&&r<=57){t++;continue}return!1}return!0}function Ya(e){return e.indexOf(`/`)===-1&&e.indexOf(`~`)===-1?e:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Xa(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}function Za(e){if(e===void 0)return!0;if(e){if(Array.isArray(e)){for(var t=0,n=e.length;t<n;t++)if(Za(e[t]))return!0}else if(typeof e==`object`){for(var r=Ka(e),i=r.length,a=0;a<i;a++)if(Za(e[r[a]]))return!0}}return!1}function Qa(e,t){var n=[e];for(var r in t){var i=typeof t[r]==`object`?JSON.stringify(t[r],null,2):t[r];i!==void 0&&n.push(r+`: `+i)}return n.join(`
688
+ `)}var $a=function(e){Ua(t,e);function t(t,n,r,i,a){var o=this.constructor,s=e.call(this,Qa(t,{name:n,index:r,operation:i,tree:a}))||this;return s.name=n,s.index=r,s.operation=i,s.tree=a,Object.setPrototypeOf(s,o.prototype),s.message=Qa(t,{name:n,index:r,operation:i,tree:a}),s}return t}(Error),eo=l({JsonPatchError:()=>H,_areEquals:()=>uo,applyOperation:()=>ao,applyPatch:()=>oo,applyReducer:()=>so,deepClone:()=>to,getValueByPointer:()=>io,validate:()=>lo,validator:()=>co}),H=$a,to=qa,no={add:function(e,t,n){return e[t]=this.value,{newDocument:n}},remove:function(e,t,n){var r=e[t];return delete e[t],{newDocument:n,removed:r}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:function(e,t,n){var r=io(n,this.path);r&&=qa(r);var i=ao(n,{op:`remove`,path:this.from}).removed;return ao(n,{op:`add`,path:this.path,value:i}),{newDocument:n,removed:r}},copy:function(e,t,n){var r=io(n,this.from);return ao(n,{op:`add`,path:this.path,value:qa(r)}),{newDocument:n}},test:function(e,t,n){return{newDocument:n,test:uo(e[t],this.value)}},_get:function(e,t,n){return this.value=e[t],{newDocument:n}}},ro={add:function(e,t,n){return Ja(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:n,index:t}},remove:function(e,t,n){return{newDocument:n,removed:e.splice(t,1)[0]}},replace:function(e,t,n){var r=e[t];return e[t]=this.value,{newDocument:n,removed:r}},move:no.move,copy:no.copy,test:no.test,_get:no._get};function io(e,t){if(t==``)return e;var n={op:`_get`,path:t};return ao(e,n),n.value}function ao(e,t,n,r,i,a){if(n===void 0&&(n=!1),r===void 0&&(r=!0),i===void 0&&(i=!0),a===void 0&&(a=0),n&&(typeof n==`function`?n(t,0,e,t.path):co(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=io(e,t.from),t.op===`move`&&(o.removed=e),o;if(t.op===`test`){if(o.test=uo(e,t.value),o.test===!1)throw new H(`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;else if(t.op===`_get`)return t.value=e,o;else if(n)throw new H("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,a,t,e);else return o}else{r||(e=qa(e));var s=(t.path||``).split(`/`),c=e,l=1,u=s.length,d=void 0,f=void 0,p=void 0;for(p=typeof n==`function`?n:co;;){if(f=s[l],f&&f.indexOf(`~`)!=-1&&(f=Xa(f)),i&&(f==`__proto__`||f==`prototype`&&l>0&&s[l-1]==`constructor`))throw TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(n&&d===void 0&&(c[f]===void 0?d=s.slice(0,l).join(`/`):l==u-1&&(d=t.path),d!==void 0&&p(t,0,e,d)),l++,Array.isArray(c)){if(f===`-`)f=c.length;else if(n&&!Ja(f))throw new H(`Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index`,`OPERATION_PATH_ILLEGAL_ARRAY_INDEX`,a,t,e);else Ja(f)&&(f=~~f);if(l>=u){if(n&&t.op===`add`&&f>c.length)throw new H(`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=ro[t.op].call(t,c,f,e);if(o.test===!1)throw new H(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}}else if(l>=u){var o=no[t.op].call(t,c,f,e);if(o.test===!1)throw new H(`Test operation failed`,`TEST_OPERATION_FAILED`,a,t,e);return o}if(c=c[f],n&&l<u&&(!c||typeof c!=`object`))throw new H(`Cannot perform operation at the desired path`,`OPERATION_PATH_UNRESOLVABLE`,a,t,e)}}}function oo(e,t,n,r,i){if(r===void 0&&(r=!0),i===void 0&&(i=!0),n&&!Array.isArray(t))throw new H(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);r||(e=qa(e));for(var a=Array(t.length),o=0,s=t.length;o<s;o++)a[o]=ao(e,t[o],n,!0,i,o),e=a[o].newDocument;return a.newDocument=e,a}function so(e,t,n){var r=ao(e,t);if(r.test===!1)throw new H(`Test operation failed`,`TEST_OPERATION_FAILED`,n,t,e);return r.newDocument}function co(e,t,n,r){if(typeof e!=`object`||!e||Array.isArray(e))throw new H(`Operation is not an object`,`OPERATION_NOT_AN_OBJECT`,t,e,n);if(no[e.op]){if(typeof e.path!=`string`)throw new H("Operation `path` property is not a string",`OPERATION_PATH_INVALID`,t,e,n);if(e.path.indexOf(`/`)!==0&&e.path.length>0)throw new H('Operation `path` property must start with "/"',`OPERATION_PATH_INVALID`,t,e,n);if((e.op===`move`||e.op===`copy`)&&typeof e.from!=`string`)throw new H("Operation `from` property is not present (applicable in `move` and `copy` operations)",`OPERATION_FROM_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&e.value===void 0)throw new H("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_REQUIRED`,t,e,n);if((e.op===`add`||e.op===`replace`||e.op===`test`)&&Za(e.value))throw new H("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)",`OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED`,t,e,n);if(n){if(e.op==`add`){var i=e.path.split(`/`).length,a=r.split(`/`).length;if(i!==a+1&&i!==a)throw new H("Cannot perform an `add` operation at the desired path",`OPERATION_PATH_CANNOT_ADD`,t,e,n)}else if(e.op===`replace`||e.op===`remove`||e.op===`_get`){if(e.path!==r)throw new H(`Cannot perform the operation at a path that does not exist`,`OPERATION_PATH_UNRESOLVABLE`,t,e,n)}else if(e.op===`move`||e.op===`copy`){var o=lo([{op:`_get`,path:e.from,value:void 0}],n);if(o&&o.name===`OPERATION_PATH_UNRESOLVABLE`)throw new H(`Cannot perform the operation from a path that does not exist`,`OPERATION_FROM_UNRESOLVABLE`,t,e,n)}}}else throw new H("Operation `op` property is not one of operations defined in RFC-6902",`OPERATION_OP_INVALID`,t,e,n)}function lo(e,t,n){try{if(!Array.isArray(e))throw new H(`Patch sequence must be an array`,`SEQUENCE_NOT_AN_ARRAY`);if(t)oo(qa(t),qa(e),n||!0);else{n||=co;for(var r=0;r<e.length;r++)n(e[r],r,t,void 0)}}catch(e){if(e instanceof H)return e;throw e}}function uo(e,t){if(e===t)return!0;if(e&&t&&typeof e==`object`&&typeof t==`object`){var n=Array.isArray(e),r=Array.isArray(t),i,a,o;if(n&&r){if(a=e.length,a!=t.length)return!1;for(i=a;i--!==0;)if(!uo(e[i],t[i]))return!1;return!0}if(n!=r)return!1;var s=Object.keys(e);if(a=s.length,a!==Object.keys(t).length)return!1;for(i=a;i--!==0;)if(!t.hasOwnProperty(s[i]))return!1;for(i=a;i--!==0;)if(o=s[i],!uo(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}var fo=l({compare:()=>Co,generate:()=>xo,observe:()=>bo,unobserve:()=>yo}),po=new WeakMap,mo=function(){function e(e){this.observers=new Map,this.obj=e}return e}(),ho=function(){function e(e,t){this.callback=e,this.observer=t}return e}();function go(e){return po.get(e)}function _o(e,t){return e.observers.get(t)}function vo(e,t){e.observers.delete(t.callback)}function yo(e,t){t.unobserve()}function bo(e,t){var n=[],r,i=go(e);if(!i)i=new mo(e),po.set(e,i);else{var a=_o(i,t);r=a&&a.observer}if(r)return r;if(r={},i.value=qa(e),t){r.callback=t,r.next=null;var o=function(){xo(r)},s=function(){clearTimeout(r.next),r.next=setTimeout(o)};typeof window<`u`&&(window.addEventListener(`mouseup`,s),window.addEventListener(`keyup`,s),window.addEventListener(`mousedown`,s),window.addEventListener(`keydown`,s),window.addEventListener(`change`,s))}return r.patches=n,r.object=e,r.unobserve=function(){xo(r),clearTimeout(r.next),vo(i,r),typeof window<`u`&&(window.removeEventListener(`mouseup`,s),window.removeEventListener(`keyup`,s),window.removeEventListener(`mousedown`,s),window.removeEventListener(`keydown`,s),window.removeEventListener(`change`,s))},i.observers.set(t,new ho(t,r)),r}function xo(e,t){t===void 0&&(t=!1);var n=po.get(e.object);So(n.value,e.object,e.patches,``,t),e.patches.length&&oo(n.value,e.patches);var r=e.patches;return r.length>0&&(e.patches=[],e.callback&&e.callback(r)),r}function So(e,t,n,r,i){if(t!==e){typeof t.toJSON==`function`&&(t=t.toJSON());for(var a=Ka(t),o=Ka(e),s=!1,c=o.length-1;c>=0;c--){var l=o[c],u=e[l];if(Ga(t,l)&&!(t[l]===void 0&&u!==void 0&&Array.isArray(t)===!1)){var d=t[l];typeof u==`object`&&u&&typeof d==`object`&&d&&Array.isArray(u)===Array.isArray(d)?So(u,d,n,r+`/`+Ya(l),i):u!==d&&(i&&n.push({op:`test`,path:r+`/`+Ya(l),value:qa(u)}),n.push({op:`replace`,path:r+`/`+Ya(l),value:qa(d)}))}else Array.isArray(e)===Array.isArray(t)?(i&&n.push({op:`test`,path:r+`/`+Ya(l),value:qa(u)}),n.push({op:`remove`,path:r+`/`+Ya(l)}),s=!0):(i&&n.push({op:`test`,path:r,value:e}),n.push({op:`replace`,path:r,value:t}))}if(!(!s&&a.length==o.length))for(var c=0;c<a.length;c++){var l=a[c];!Ga(e,l)&&t[l]!==void 0&&n.push({op:`add`,path:r+`/`+Ya(l),value:qa(t[l])})}}}function Co(e,t,n){n===void 0&&(n=!1);var r=[];return So(e,t,r,``,n),r}Object.assign({},eo,fo,{JsonPatchError:$a,deepClone:qa,escapePathComponent:Ya,unescapePathComponent:Xa});function wo(e){return` \r
689
+ `.indexOf(e)>=0}function To(e){for(var t=[`topLevel`],n=0,r,i,a,o=function(e){return t.push(e)},s=function(e){return t[t.length-1]=e},c=function(e){r??(r=n,i=t.length,a=e)},l=function(e){e===a&&(r=void 0,i=void 0,a=void 0)},u=function(){return t.pop()},d=function(){return n--},f=function(e){if(`0`<=e&&e<=`9`){o(`number`);return}switch(e){case`"`:o(`string`);return;case`-`:o(`numberNeedsDigit`);return;case`t`:o(`true`);return;case`f`:o(`false`);return;case`n`:o(`null`);return;case`[`:o(`arrayNeedsValue`);return;case`{`:o(`objectNeedsKey`);return}},p=e.length;n<p;n++){var m=e[n];switch(t[t.length-1]){case`topLevel`:f(m);break;case`string`:switch(m){case`"`:u();break;case`\\`:c(`stringEscape`),o(`stringEscaped`);break}break;case`stringEscaped`:m===`u`?o(`stringUnicode`):(l(`stringEscape`),u());break;case`stringUnicode`:n-e.lastIndexOf(`u`,n)===4&&(l(`stringEscape`),u());break;case`number`:m===`.`?s(`numberNeedsDigit`):m===`e`||m===`E`?s(`numberNeedsExponent`):(m<`0`||m>`9`)&&(d(),u());break;case`numberNeedsDigit`:s(`number`);break;case`numberNeedsExponent`:s(m===`+`||m===`-`?`numberNeedsDigit`:`number`);break;case`true`:case`false`:case`null`:(m<`a`||m>`z`)&&(d(),u());break;case`arrayNeedsValue`:m===`]`?u():wo(m)||(l(`collectionItem`),s(`arrayNeedsComma`),f(m));break;case`arrayNeedsComma`:m===`]`?u():m===`,`&&(c(`collectionItem`),s(`arrayNeedsValue`));break;case`objectNeedsKey`:m===`}`?u():m===`"`&&(c(`collectionItem`),s(`objectNeedsColon`),o(`string`));break;case`objectNeedsColon`:m===`:`&&s(`objectNeedsValue`);break;case`objectNeedsValue`:wo(m)||(l(`collectionItem`),s(`objectNeedsComma`),f(m));break;case`objectNeedsComma`:m===`}`?u():m===`,`&&(c(`collectionItem`),s(`objectNeedsKey`));break}}i!=null&&(t.length=i);for(var ee=[r==null?e:e.slice(0,r)],te=function(t){return ee.push(t.slice(e.length-e.lastIndexOf(t[0])))},ne=t.length-1;ne>=0;ne--)switch(t[ne]){case`string`:ee.push(`"`);break;case`numberNeedsDigit`:case`numberNeedsExponent`:ee.push(`0`);break;case`true`:te(`true`);break;case`false`:te(`false`);break;case`null`:te(`null`);break;case`arrayNeedsValue`:case`arrayNeedsComma`:ee.push(`]`);break;case`objectNeedsKey`:case`objectNeedsColon`:case`objectNeedsValue`:case`objectNeedsComma`:ee.push(`}`);break}return ee.join(``)}function Eo(){let e=0,t=0;for(let n=0;n<28;n+=7){let r=this.buf[this.pos++];if(e|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(n&15)<<28,t=(n&112)>>4,!(n&128))return this.assertBounds(),[e,t];for(let n=3;n<=31;n+=7){let r=this.buf[this.pos++];if(t|=(r&127)<<n,!(r&128))return this.assertBounds(),[e,t]}throw Error(`invalid varint`)}function Do(e,t,n){for(let r=0;r<28;r+=7){let i=e>>>r,a=!(!(i>>>7)&&t==0),o=(a?i|128:i)&255;if(n.push(o),!a)return}let r=e>>>28&15|(t&7)<<4,i=!!(t>>3);if(n.push((i?r|128:r)&255),i){for(let e=3;e<31;e+=7){let r=t>>>e,i=!!(r>>>7),a=(i?r|128:r)&255;if(n.push(a),!i)return}n.push(t>>>31&1)}}var Oo=4294967296;function ko(e){let t=e[0]===`-`;t&&(e=e.slice(1));let n=1e6,r=0,i=0;function a(t,a){let o=Number(e.slice(t,a));i*=n,r=r*n+o,r>=Oo&&(i+=r/Oo|0,r%=Oo)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?Po(r,i):No(r,i)}function Ao(e,t){let n=No(e,t),r=n.hi&2147483648;r&&(n=Po(n.lo,n.hi));let i=jo(n.lo,n.hi);return r?`-`+i:i}function jo(e,t){if({lo:e,hi:t}=Mo(e,t),t<=2097151)return String(Oo*t+e);let n=e&16777215,r=(e>>>24|t<<8)&16777215,i=t>>16&65535,a=n+r*6777216+i*6710656,o=r+i*8147497,s=i*2,c=1e7;return a>=c&&(o+=Math.floor(a/c),a%=c),o>=c&&(s+=Math.floor(o/c),o%=c),s.toString()+Fo(o)+Fo(a)}function Mo(e,t){return{lo:e>>>0,hi:t>>>0}}function No(e,t){return{lo:e|0,hi:t|0}}function Po(e,t){return t=~t,e?e=~e+1:t+=1,No(e,t)}var Fo=e=>{let t=String(e);return`0000000`.slice(t.length)+t};function Io(e,t){if(e>=0){for(;e>127;)t.push(e&127|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(e&127|128),e>>=7;t.push(1)}}function Lo(){let e=this.buf[this.pos++],t=e&127;if(!(e&128)||(e=this.buf[this.pos++],t|=(e&127)<<7,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<14,!(e&128))||(e=this.buf[this.pos++],t|=(e&127)<<21,!(e&128)))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let t=5;e&128&&t<10;t++)e=this.buf[this.pos++];if(e&128)throw Error(`invalid varint`);return this.assertBounds(),t>>>0}let Ro=zo();function zo(){let e=new DataView(new ArrayBuffer(8));if(typeof BigInt==`function`&&typeof e.getBigInt64==`function`&&typeof e.getBigUint64==`function`&&typeof e.setBigInt64==`function`&&typeof e.setBigUint64==`function`&&(globalThis.Deno||typeof process!=`object`||typeof process.env!=`object`||process.env.BUF_BIGINT_DISABLE!==`1`)){let t=BigInt(`-9223372036854775808`),n=BigInt(`9223372036854775807`),r=BigInt(`0`),i=BigInt(`18446744073709551615`);return{zero:BigInt(0),supported:!0,parse(e){let r=typeof e==`bigint`?e:BigInt(e);if(r>n||r<t)throw Error(`invalid int64: ${e}`);return r},uParse(e){let t=typeof e==`bigint`?e:BigInt(e);if(t>i||t<r)throw Error(`invalid uint64: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)},uDec(t,n){return e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0)}}}return{zero:`0`,supported:!1,parse(e){return typeof e!=`string`&&(e=e.toString()),Bo(e),e},uParse(e){return typeof e!=`string`&&(e=e.toString()),Vo(e),e},enc(e){return typeof e!=`string`&&(e=e.toString()),Bo(e),ko(e)},uEnc(e){return typeof e!=`string`&&(e=e.toString()),Vo(e),ko(e)},dec(e,t){return Ao(e,t)},uDec(e,t){return jo(e,t)}}}function Bo(e){if(!/^-?[0-9]+$/.test(e))throw Error(`invalid int64: `+e)}function Vo(e){if(!/^[0-9]+$/.test(e))throw Error(`invalid uint64: `+e)}var Ho=Symbol.for(`@bufbuild/protobuf/text-encoding`);function Uo(){if(globalThis[Ho]==null){let e=new globalThis.TextEncoder,t=new globalThis.TextDecoder;globalThis[Ho]={encodeUtf8(t){return e.encode(t)},decodeUtf8(e){return t.decode(e)},checkUtf8(e){try{return!0}catch{return!1}}}}return globalThis[Ho]}var Wo;(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`})(Wo||={});var U=class{constructor(e=Uo().encodeUtf8){this.encodeUtf8=e,this.stack=[],this.chunks=[],this.buf=[]}finish(){this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]);let e=0;for(let t=0;t<this.chunks.length;t++)e+=this.chunks[t].length;let t=new Uint8Array(e),n=0;for(let e=0;e<this.chunks.length;e++)t.set(this.chunks[e],n),n+=this.chunks[e].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw Error(`invalid state, fork stack empty`);return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Ko(e);e>127;)this.buf.push(e&127|128),e>>>=7;return this.buf.push(e),this}int32(e){return Go(e),Io(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.encodeUtf8(e);return this.uint32(t.byteLength),this.raw(t)}float(e){qo(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){Ko(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){Go(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return Go(e),e=(e<<1^e>>31)>>>0,Io(e,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Ro.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Ro.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Ro.enc(e);return Do(t.lo,t.hi,this.buf),this}sint64(e){let t=Ro.enc(e),n=t.hi>>31;return Do(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Ro.uEnc(e);return Do(t.lo,t.hi,this.buf),this}},W=class{constructor(e,t=Uo().decodeUtf8){this.decodeUtf8=t,this.varint64=Eo,this.uint32=Lo,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength)}tag(){let e=this.uint32(),t=e>>>3,n=e&7;if(t<=0||n<0||n>5)throw Error(`illegal tag: field no `+t+` wire type `+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Wo.Varint:for(;this.buf[this.pos++]&128;);break;case Wo.Bit64:this.pos+=4;case Wo.Bit32:this.pos+=4;break;case Wo.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Wo.StartGroup:for(;;){let[e,n]=this.tag();if(n===Wo.EndGroup){if(t!==void 0&&e!==t)throw Error(`invalid end group tag`);break}this.skip(n,e)}break;default:throw Error(`cant skip wire type `+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw RangeError(`premature EOF`)}int32(){return this.uint32()|0}sint32(){let e=this.uint32();return e>>>1^-(e&1)}int64(){return Ro.dec(...this.varint64())}uint64(){return Ro.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(e&1);return e=(e>>>1|(t&1)<<31)^n,t=t>>>1^n,Ro.dec(e,t)}bool(){let[e,t]=this.varint64();return e!==0||t!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Ro.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ro.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.decodeUtf8(this.bytes())}};function Go(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid int32: `+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw Error(`invalid int32: `+e)}function Ko(e){if(typeof e==`string`)e=Number(e);else if(typeof e!=`number`)throw Error(`invalid uint32: `+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw Error(`invalid uint32: `+e)}function qo(e){if(typeof e==`string`){let t=e;if(e=Number(e),Number.isNaN(e)&&t!==`NaN`)throw Error(`invalid float32: `+t)}else if(typeof e!=`number`)throw Error(`invalid float32: `+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw Error(`invalid float32: `+e)}function Jo(){return{fields:{}}}var Yo={encode(e,t=new U){return Object.entries(e.fields).forEach(([e,n])=>{n!==void 0&&Zo.encode({key:e,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Jo();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:{if(e!==10)break;let t=Zo.decode(n,n.uint32());t.value!==void 0&&(i.fields[t.key]=t.value);continue}}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Yo.fromPartial(e??{})},fromPartial(e){let t=Jo();return t.fields=Object.entries(e.fields??{}).reduce((e,[t,n])=>(n!==void 0&&(e[t]=n),e),{}),t},wrap(e){let t=Jo();if(e!==void 0)for(let n of Object.keys(e))t.fields[n]=e[n];return t},unwrap(e){let t={};if(e.fields)for(let n of Object.keys(e.fields))t[n]=e.fields[n];return t}};function Xo(){return{key:``,value:void 0}}var Zo={encode(e,t=new U){return e.key!==``&&t.uint32(10).string(e.key),e.value!==void 0&&G.encode(G.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Xo();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.key=n.string();continue;case 2:if(e!==18)break;i.value=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Zo.fromPartial(e??{})},fromPartial(e){let t=Xo();return t.key=e.key??``,t.value=e.value??void 0,t}};function Qo(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var G={encode(e,t=new U){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&&Yo.encode(Yo.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&es.encode(es.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Qo();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.nullValue=n.int32();continue;case 2:if(e!==17)break;i.numberValue=n.double();continue;case 3:if(e!==26)break;i.stringValue=n.string();continue;case 4:if(e!==32)break;i.boolValue=n.bool();continue;case 5:if(e!==42)break;i.structValue=Yo.unwrap(Yo.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.listValue=es.unwrap(es.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return G.fromPartial(e??{})},fromPartial(e){let t=Qo();return t.nullValue=e.nullValue??void 0,t.numberValue=e.numberValue??void 0,t.stringValue=e.stringValue??void 0,t.boolValue=e.boolValue??void 0,t.structValue=e.structValue??void 0,t.listValue=e.listValue??void 0,t},wrap(e){let t=Qo();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(e!==void 0)throw new globalThis.Error(`Unsupported any value type: `+typeof e);return t},unwrap(e){if(e.stringValue!==void 0)return e.stringValue;if(e?.numberValue!==void 0)return e.numberValue;if(e?.boolValue!==void 0)return e.boolValue;if(e?.structValue!==void 0)return e.structValue;if(e?.listValue!==void 0)return e.listValue;if(e?.nullValue!==void 0)return null}};function $o(){return{values:[]}}var es={encode(e,t=new U){for(let n of e.values)G.encode(G.wrap(n),t.uint32(10).fork()).join();return t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=$o();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.values.push(G.unwrap(G.decode(n,n.uint32())));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return es.fromPartial(e??{})},fromPartial(e){let t=$o();return t.values=e.values?.map(e=>e)||[],t},wrap(e){let t=$o();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty(`values`)&&globalThis.Array.isArray(e.values)?e.values:e}},ts=(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))(ts||{});function ns(){return{op:0,path:``,from:void 0,value:void 0}}var rs={encode(e,t=new U){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&&G.encode(G.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=ns();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.op=n.int32();continue;case 2:if(e!==18)break;i.path=n.string();continue;case 3:if(e!==26)break;i.from=n.string();continue;case 4:if(e!==34)break;i.value=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return rs.fromPartial(e??{})},fromPartial(e){let t=ns();return t.op=e.op??0,t.path=e.path??``,t.from=e.from??void 0,t.value=e.value??void 0,t}};function is(){return{id:``,type:``,function:void 0}}var as={encode(e,t=new U){return e.id!==``&&t.uint32(10).string(e.id),e.type!==``&&t.uint32(18).string(e.type),e.function!==void 0&&ss.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=is();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.type=n.string();continue;case 3:if(e!==26)break;i.function=ss.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return as.fromPartial(e??{})},fromPartial(e){let t=is();return t.id=e.id??``,t.type=e.type??``,t.function=e.function!==void 0&&e.function!==null?ss.fromPartial(e.function):void 0,t}};function os(){return{name:``,arguments:``}}var ss={encode(e,t=new U){return e.name!==``&&t.uint32(10).string(e.name),e.arguments!==``&&t.uint32(18).string(e.arguments),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=os();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.name=n.string();continue;case 2:if(e!==18)break;i.arguments=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ss.fromPartial(e??{})},fromPartial(e){let t=os();return t.name=e.name??``,t.arguments=e.arguments??``,t}};function cs(){return{id:``,role:``,content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0}}var ls={encode(e,t=new U){e.id!==``&&t.uint32(10).string(e.id),e.role!==``&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let n of e.toolCalls)as.encode(n,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 n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=cs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.id=n.string();continue;case 2:if(e!==18)break;i.role=n.string();continue;case 3:if(e!==26)break;i.content=n.string();continue;case 4:if(e!==34)break;i.name=n.string();continue;case 5:if(e!==42)break;i.toolCalls.push(as.decode(n,n.uint32()));continue;case 6:if(e!==50)break;i.toolCallId=n.string();continue;case 7:if(e!==58)break;i.error=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ls.fromPartial(e??{})},fromPartial(e){let t=cs();return t.id=e.id??``,t.role=e.role??``,t.content=e.content??void 0,t.name=e.name??void 0,t.toolCalls=e.toolCalls?.map(e=>as.fromPartial(e))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t}},us=(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))(us||{});function ds(){return{type:0,timestamp:void 0,rawEvent:void 0}}var K={encode(e,t=new U){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&G.encode(G.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=ds();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==8)break;i.type=n.int32();continue;case 2:if(e!==16)break;i.timestamp=Xs(n.int64());continue;case 3:if(e!==26)break;i.rawEvent=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return K.fromPartial(e??{})},fromPartial(e){let t=ds();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function fs(){return{baseEvent:void 0,messageId:``,role:void 0}}var ps={encode(e,t=new U){return e.baseEvent!==void 0&&K.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 n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=fs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ps.fromPartial(e??{})},fromPartial(e){let t=fs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.role=e.role??void 0,t}};function ms(){return{baseEvent:void 0,messageId:``,delta:``}}var hs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=ms();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return hs.fromPartial(e??{})},fromPartial(e){let t=ms();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t.delta=e.delta??``,t}};function gs(){return{baseEvent:void 0,messageId:``}}var _s={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==``&&t.uint32(18).string(e.messageId),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=gs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return _s.fromPartial(e??{})},fromPartial(e){let t=gs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??``,t}};function vs(){return{baseEvent:void 0,toolCallId:``,toolCallName:``,parentMessageId:void 0}}var ys={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.toolCallName!==``&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=vs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ys.fromPartial(e??{})},fromPartial(e){let t=vs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.toolCallName=e.toolCallName??``,t.parentMessageId=e.parentMessageId??void 0,t}};function bs(){return{baseEvent:void 0,toolCallId:``,delta:``}}var xs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),e.delta!==``&&t.uint32(26).string(e.delta),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=bs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return xs.fromPartial(e??{})},fromPartial(e){let t=bs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t.delta=e.delta??``,t}};function Ss(){return{baseEvent:void 0,toolCallId:``}}var Cs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==``&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Ss();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Cs.fromPartial(e??{})},fromPartial(e){let t=Ss();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??``,t}};function ws(){return{baseEvent:void 0,snapshot:void 0}}var Ts={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&G.encode(G.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=ws();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.snapshot=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ts.fromPartial(e??{})},fromPartial(e){let t=ws();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function Es(){return{baseEvent:void 0,delta:[]}}var Ds={encode(e,t=new U){e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.delta)rs.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Es();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.delta.push(rs.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ds.fromPartial(e??{})},fromPartial(e){let t=Es();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(e=>rs.fromPartial(e))||[],t}};function Os(){return{baseEvent:void 0,messages:[]}}var ks={encode(e,t=new U){e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join();for(let n of e.messages)ls.encode(n,t.uint32(18).fork()).join();return t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Os();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messages.push(ls.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return ks.fromPartial(e??{})},fromPartial(e){let t=Os();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(e=>ls.fromPartial(e))||[],t}};function As(){return{baseEvent:void 0,event:void 0,source:void 0}}var js={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&G.encode(G.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=As();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.event=G.unwrap(G.decode(n,n.uint32()));continue;case 3:if(e!==26)break;i.source=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return js.fromPartial(e??{})},fromPartial(e){let t=As();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function Ms(){return{baseEvent:void 0,name:``,value:void 0}}var Ns={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==``&&t.uint32(18).string(e.name),e.value!==void 0&&G.encode(G.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Ms();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.name=n.string();continue;case 3:if(e!==26)break;i.value=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ns.fromPartial(e??{})},fromPartial(e){let t=Ms();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.name=e.name??``,t.value=e.value??void 0,t}};function Ps(){return{baseEvent:void 0,threadId:``,runId:``}}var Fs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==``&&t.uint32(18).string(e.threadId),e.runId!==``&&t.uint32(26).string(e.runId),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Ps();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Fs.fromPartial(e??{})},fromPartial(e){let t=Ps();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t}};function Is(){return{baseEvent:void 0,threadId:``,runId:``,result:void 0}}var Ls={encode(e,t=new U){return e.baseEvent!==void 0&&K.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&&G.encode(G.wrap(e.result),t.uint32(34).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Is();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.threadId=n.string();continue;case 3:if(e!==26)break;i.runId=n.string();continue;case 4:if(e!==34)break;i.result=G.unwrap(G.decode(n,n.uint32()));continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ls.fromPartial(e??{})},fromPartial(e){let t=Is();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??``,t.runId=e.runId??``,t.result=e.result??void 0,t}};function Rs(){return{baseEvent:void 0,code:void 0,message:``}}var zs={encode(e,t=new U){return e.baseEvent!==void 0&&K.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 n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Rs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.code=n.string();continue;case 3:if(e!==26)break;i.message=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return zs.fromPartial(e??{})},fromPartial(e){let t=Rs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??``,t}};function Bs(){return{baseEvent:void 0,stepName:``}}var Vs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Bs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Vs.fromPartial(e??{})},fromPartial(e){let t=Bs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function Hs(){return{baseEvent:void 0,stepName:``}}var Us={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==``&&t.uint32(18).string(e.stepName),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Hs();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.stepName=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Us.fromPartial(e??{})},fromPartial(e){let t=Hs();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??``,t}};function Ws(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0}}var Gs={encode(e,t=new U){return e.baseEvent!==void 0&&K.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 n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Ws();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.messageId=n.string();continue;case 3:if(e!==26)break;i.role=n.string();continue;case 4:if(e!==34)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Gs.fromPartial(e??{})},fromPartial(e){let t=Ws();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t}};function Ks(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var qs={encode(e,t=new U){return e.baseEvent!==void 0&&K.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Ks();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.baseEvent=K.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.toolCallId=n.string();continue;case 3:if(e!==26)break;i.toolCallName=n.string();continue;case 4:if(e!==34)break;i.parentMessageId=n.string();continue;case 5:if(e!==42)break;i.delta=n.string();continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return qs.fromPartial(e??{})},fromPartial(e){let t=Ks();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?K.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??void 0,t.toolCallName=e.toolCallName??void 0,t.parentMessageId=e.parentMessageId??void 0,t.delta=e.delta??void 0,t}};function Js(){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 Ys={encode(e,t=new U){return e.textMessageStart!==void 0&&ps.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&hs.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&_s.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&ys.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&xs.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Cs.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Ts.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Ds.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&ks.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&js.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&Ns.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&Fs.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Ls.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&zs.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Vs.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Us.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Gs.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&qs.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let n=e instanceof W?e:new W(e),r=t===void 0?n.len:n.pos+t,i=Js();for(;n.pos<r;){let e=n.uint32();switch(e>>>3){case 1:if(e!==10)break;i.textMessageStart=ps.decode(n,n.uint32());continue;case 2:if(e!==18)break;i.textMessageContent=hs.decode(n,n.uint32());continue;case 3:if(e!==26)break;i.textMessageEnd=_s.decode(n,n.uint32());continue;case 4:if(e!==34)break;i.toolCallStart=ys.decode(n,n.uint32());continue;case 5:if(e!==42)break;i.toolCallArgs=xs.decode(n,n.uint32());continue;case 6:if(e!==50)break;i.toolCallEnd=Cs.decode(n,n.uint32());continue;case 7:if(e!==58)break;i.stateSnapshot=Ts.decode(n,n.uint32());continue;case 8:if(e!==66)break;i.stateDelta=Ds.decode(n,n.uint32());continue;case 9:if(e!==74)break;i.messagesSnapshot=ks.decode(n,n.uint32());continue;case 10:if(e!==82)break;i.raw=js.decode(n,n.uint32());continue;case 11:if(e!==90)break;i.custom=Ns.decode(n,n.uint32());continue;case 12:if(e!==98)break;i.runStarted=Fs.decode(n,n.uint32());continue;case 13:if(e!==106)break;i.runFinished=Ls.decode(n,n.uint32());continue;case 14:if(e!==114)break;i.runError=zs.decode(n,n.uint32());continue;case 15:if(e!==122)break;i.stepStarted=Vs.decode(n,n.uint32());continue;case 16:if(e!==130)break;i.stepFinished=Us.decode(n,n.uint32());continue;case 17:if(e!==138)break;i.textMessageChunk=Gs.decode(n,n.uint32());continue;case 18:if(e!==146)break;i.toolCallChunk=qs.decode(n,n.uint32());continue}if((e&7)==4||e===0)break;n.skip(e&7)}return i},create(e){return Ys.fromPartial(e??{})},fromPartial(e){let t=Js();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?ps.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?hs.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?_s.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?ys.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?xs.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Cs.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Ts.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Ds.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?ks.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?js.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?Ns.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?Fs.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Ls.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?zs.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Vs.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Us.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Gs.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?qs.fromPartial(e.toolCallChunk):void 0,t}};function Xs(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 Zs(e){let t=Ys.decode(e),n=Object.values(t).find(e=>e!==void 0);if(!n)throw Error(`Invalid event`);if(n.type=us[n.baseEvent.type],n.timestamp=n.baseEvent.timestamp,n.rawEvent=n.baseEvent.rawEvent,n.type===F.MESSAGES_SNAPSHOT)for(let e of n.messages){let t=e;t.toolCalls?.length===0&&(t.toolCalls=void 0)}if(n.type===F.STATE_DELTA)for(let e of n.delta)e.op=ts[e.op].toLowerCase(),Object.keys(e).forEach(t=>{e[t]===void 0&&delete e[t]});return Object.keys(n).forEach(e=>{n[e]===void 0&&delete n[e]}),Ur.parse(n)}let Qs=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,$s=e=>{if(typeof e!=`string`)throw TypeError(`Invalid argument expected string`);let t=e.match(Qs);if(!t)throw Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t};var ec=e=>e===`*`||e===`x`||e===`X`,tc=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},nc=(e,t)=>typeof e==typeof t?[e,t]:[String(e),String(t)],rc=(e,t)=>{if(ec(e)||ec(t))return 0;let[n,r]=nc(tc(e),tc(t));return n>r?1:n<r?-1:0};let ic=(e,t)=>{for(let n=0;n<Math.max(e.length,t.length);n++){let r=rc(e[n]||`0`,t[n]||`0`);if(r!==0)return r}return 0},ac=(e,t)=>{let n=$s(e),r=$s(t),i=n.pop(),a=r.pop(),o=ic(n,r);return o===0?i&&a?ic(i.split(`.`),a.split(`.`)):i||a?i?-1:1:0:o};var oc=Object.defineProperty,sc=Object.defineProperties,cc=Object.getOwnPropertyDescriptors,lc=Object.getOwnPropertySymbols,uc=Object.prototype.hasOwnProperty,dc=Object.prototype.propertyIsEnumerable,fc=(e,t,n)=>t in e?oc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,q=(e,t)=>{for(var n in t||={})uc.call(t,n)&&fc(e,n,t[n]);if(lc)for(var n of lc(t))dc.call(t,n)&&fc(e,n,t[n]);return e},pc=(e,t)=>sc(e,cc(t)),mc=(e,t)=>{var n={};for(var r in e)uc.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&lc)for(var r of lc(e))t.indexOf(r)<0&&dc.call(e,r)&&(n[r]=e[r]);return n},J=e=>{if(typeof structuredClone==`function`)return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return q({},e)}};async function Y(e,t,n,r){let i=t,a=n,o;for(let t of e)try{let e=await r(t,J(i),J(a));if(e===void 0)continue;if(e.messages!==void 0&&(i=e.messages),e.state!==void 0&&(a=e.state),o=e.stopPropagation,o===!0)break}catch(e){process.env.NODE_ENV===`test`||process.env.JEST_WORKER_ID!==void 0||console.error(`Subscriber error:`,e);continue}return q(q(q({},JSON.stringify(i)===JSON.stringify(t)?{}:{messages:i}),JSON.stringify(a)===JSON.stringify(n)?{}:{state:a}),o===void 0?{}:{stopPropagation:o})}var hc=(e,t,n,r)=>{let i=J(n.messages),a=J(e.state),o={},s=e=>{e.messages!==void 0&&(i=e.messages,o.messages=e.messages),e.state!==void 0&&(a=e.state,o.state=e.state)},c=()=>{let e=J(o);return o={},e.messages!==void 0||e.state!==void 0?z(e):Da};return t.pipe(Sa(async t=>{var o;let l=await Y(r,i,a,(r,i,a)=>r.onEvent?.call(r,{event:t,agent:n,input:e,messages:i,state:a}));if(s(l),l.stopPropagation===!0)return c();switch(t.type){case F.TEXT_MESSAGE_START:{let o=await Y(r,i,a,(r,i,a)=>r.onTextMessageStartEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{messageId:e,role:n=`assistant`}=t,r={id:e,role:n,content:``};i.push(r),s({messages:i})}return c()}case F.TEXT_MESSAGE_CONTENT:{let{messageId:o,delta:l}=t,u=i.find(e=>e.id===o);if(!u)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${o}'`),c();let d=await Y(r,i,a,(r,i,a)=>r.onTextMessageContentEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof u.content==`string`?u.content:``}));return s(d),d.stopPropagation!==!0&&(u.content=`${typeof u.content==`string`?u.content:``}${l}`,s({messages:i})),c()}case F.TEXT_MESSAGE_END:{let{messageId:o}=t,l=i.find(e=>e.id===o);return l?(s(await Y(r,i,a,(r,i,a)=>r.onTextMessageEndEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e,textMessageBuffer:typeof l.content==`string`?l.content:``}))),await Promise.all(r.map(t=>{var r;(r=t.onNewMessage)==null||r.call(t,{message:l,messages:i,state:a,agent:n,input:e})})),c()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${o}'`),c())}case F.TOOL_CALL_START:{let o=await Y(r,i,a,(r,i,a)=>r.onToolCallStartEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{toolCallId:e,toolCallName:n,parentMessageId:r}=t,a;r&&i.length>0&&i[i.length-1].id===r?a=i[i.length-1]:(a={id:r||e,role:`assistant`,toolCalls:[]},i.push(a)),a.toolCalls??=[],a.toolCalls.push({id:e,type:`function`,function:{name:n,arguments:``}}),s({messages:i})}return c()}case F.TOOL_CALL_ARGS:{let{toolCallId:o,delta:l}=t,u=i.find(e=>e.toolCalls?.some(e=>e.id===o));if(!u)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${o}'`),c();let d=u.toolCalls.find(e=>e.id===o);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${o}'`),c();let f=await Y(r,i,a,(r,i,a)=>{let o=d.function.arguments,s=d.function.name,c={};try{c=To(o)}catch{}return r.onToolCallArgsEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e,toolCallBuffer:o,toolCallName:s,partialToolCallArgs:c})});return s(f),f.stopPropagation!==!0&&(d.function.arguments+=l,s({messages:i})),c()}case F.TOOL_CALL_END:{let{toolCallId:o}=t,l=i.find(e=>e.toolCalls?.some(e=>e.id===o));if(!l)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${o}'`),c();let u=l.toolCalls.find(e=>e.id===o);return u?(s(await Y(r,i,a,(r,i,a)=>{let o=u.function.arguments,s=u.function.name,c={};try{c=JSON.parse(o)}catch{}return r.onToolCallEndEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e,toolCallName:s,toolCallArgs:c})})),await Promise.all(r.map(t=>{var r;(r=t.onNewToolCall)==null||r.call(t,{toolCall:u,messages:i,state:a,agent:n,input:e})})),c()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${o}'`),c())}case F.TOOL_CALL_RESULT:{let o=await Y(r,i,a,(r,i,a)=>r.onToolCallResultEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{messageId:o,toolCallId:c,content:l,role:u}=t,d={id:o,toolCallId:c,role:u||`tool`,content:l};i.push(d),await Promise.all(r.map(t=>{var r;(r=t.onNewMessage)==null||r.call(t,{message:d,messages:i,state:a,agent:n,input:e})})),s({messages:i})}return c()}case F.STATE_SNAPSHOT:{let o=await Y(r,i,a,(r,i,a)=>r.onStateSnapshotEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{snapshot:e}=t;a=e,s({state:a})}return c()}case F.STATE_DELTA:{let o=await Y(r,i,a,(r,i,a)=>r.onStateDeltaEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{delta:e}=t;try{a=oo(a,e,!0,!1).newDocument,s({state:a})}catch(t){let n=t instanceof Error?t.message:String(t);console.warn(`Failed to apply state patch:
690
+ Current state: ${JSON.stringify(a,null,2)}
691
+ Patch operations: ${JSON.stringify(e,null,2)}
692
+ Error: ${n}`)}}return c()}case F.MESSAGES_SNAPSHOT:{let o=await Y(r,i,a,(r,i,a)=>r.onMessagesSnapshotEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(o),o.stopPropagation!==!0){let{messages:e}=t;i=e,s({messages:i})}return c()}case F.ACTIVITY_SNAPSHOT:{let o=t,l=i.findIndex(e=>e.id===o.messageId),u=l>=0?i[l]:void 0,d=u?.role===`activity`?u:void 0,f=o.replace??!0,p=await Y(r,i,a,(t,r,i)=>t.onActivitySnapshotEvent?.call(t,{event:o,messages:r,state:i,agent:n,input:e,activityMessage:d,existingMessage:u}));if(s(p),p.stopPropagation!==!0){let t={id:o.messageId,role:`activity`,activityType:o.activityType,content:J(o.content)},c;l===-1?(i.push(t),c=t):d?f&&(i[l]=pc(q({},d),{activityType:o.activityType,content:J(o.content)})):f&&(i[l]=t,c=t),s({messages:i}),c&&await Promise.all(r.map(t=>t.onNewMessage?.call(t,{message:c,messages:i,state:a,agent:n,input:e})))}return c()}case F.ACTIVITY_DELTA:{let o=t,l=i.findIndex(e=>e.id===o.messageId);if(l===-1)return console.warn(`ACTIVITY_DELTA: No message found with ID '${o.messageId}' to apply patch`),c();let u=i[l];if(u.role!==`activity`)return console.warn(`ACTIVITY_DELTA: Message '${o.messageId}' is not an activity message`),c();let d=u,f=await Y(r,i,a,(t,r,i)=>t.onActivityDeltaEvent?.call(t,{event:o,messages:r,state:i,agent:n,input:e,activityMessage:d}));if(s(f),f.stopPropagation!==!0)try{let e=oo(J(d.content??{}),o.patch??[],!0,!1).newDocument;i[l]=pc(q({},d),{content:J(e),activityType:o.activityType}),s({messages:i})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`Failed to apply activity patch for '${o.messageId}': ${t}`)}return c()}case F.RAW:return s(await Y(r,i,a,(r,i,a)=>r.onRawEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}))),c();case F.CUSTOM:return s(await Y(r,i,a,(r,i,a)=>r.onCustomEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}))),c();case F.RUN_STARTED:{let l=await Y(r,i,a,(r,i,a)=>r.onRunStartedEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}));if(s(l),l.stopPropagation!==!0){let e=t;if((o=e.input)!=null&&o.messages){for(let t of e.input.messages)i.find(e=>e.id===t.id)||i.push(t);s({messages:i})}}return c()}case F.RUN_FINISHED:return s(await Y(r,i,a,(r,i,a)=>r.onRunFinishedEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e,result:t.result}))),c();case F.RUN_ERROR:return s(await Y(r,i,a,(r,i,a)=>r.onRunErrorEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}))),c();case F.STEP_STARTED:return s(await Y(r,i,a,(r,i,a)=>r.onStepStartedEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}))),c();case F.STEP_FINISHED:return s(await Y(r,i,a,(r,i,a)=>r.onStepFinishedEvent?.call(r,{event:t,messages:i,state:a,agent:n,input:e}))),c();case F.TEXT_MESSAGE_CHUNK:throw Error(`TEXT_MESSAGE_CHUNK must be tranformed before being applied`);case F.TOOL_CALL_CHUNK:throw Error(`TOOL_CALL_CHUNK must be tranformed before being applied`);case F.THINKING_START:return c();case F.THINKING_END:return c();case F.THINKING_TEXT_MESSAGE_START:return c();case F.THINKING_TEXT_MESSAGE_CONTENT:return c();case F.THINKING_TEXT_MESSAGE_END:return c()}return t.type,c()}),xa(),r.length>0?Ea({}):e=>e)},gc=e=>t=>{let n=new Map,r=new Map,i=!1,a=!1,o=!1,s=new Map,c=!1,l=!1,u=!1,d=()=>{n.clear(),r.clear(),s.clear(),c=!1,l=!1,i=!1,a=!1,u=!0};return t.pipe(ba(t=>{let f=t.type;if(e&&console.debug(`[VERIFY]:`,JSON.stringify(t)),a)return B(()=>new P(`Cannot send event type '${f}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&f!==F.RUN_ERROR&&f!==F.RUN_STARTED)return B(()=>new P(`Cannot send event type '${f}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(o){if(f===F.RUN_STARTED){if(u&&!i)return B(()=>new P(`Cannot send 'RUN_STARTED' while a run is still active. The previous run must be finished with 'RUN_FINISHED' before starting a new run.`));i&&d()}}else if(o=!0,f!==F.RUN_STARTED&&f!==F.RUN_ERROR)return B(()=>new P(`First event must be 'RUN_STARTED'`));switch(f){case F.TEXT_MESSAGE_START:{let e=t.messageId;return n.has(e)?B(()=>new P(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${e}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(n.set(e,!0),z(t))}case F.TEXT_MESSAGE_CONTENT:{let e=t.messageId;return n.has(e)?z(t):B(()=>new P(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${e}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case F.TEXT_MESSAGE_END:{let e=t.messageId;return n.has(e)?(n.delete(e),z(t)):B(()=>new P(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${e}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case F.TOOL_CALL_START:{let e=t.toolCallId;return r.has(e)?B(()=>new P(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${e}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(r.set(e,!0),z(t))}case F.TOOL_CALL_ARGS:{let e=t.toolCallId;return r.has(e)?z(t):B(()=>new P(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${e}'. Start a tool call with 'TOOL_CALL_START' first.`))}case F.TOOL_CALL_END:{let e=t.toolCallId;return r.has(e)?(r.delete(e),z(t)):B(()=>new P(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${e}'. A 'TOOL_CALL_START' event must be sent first.`))}case F.STEP_STARTED:{let e=t.stepName;return s.has(e)?B(()=>new P(`Step "${e}" is already active for 'STEP_STARTED'`)):(s.set(e,!0),z(t))}case F.STEP_FINISHED:{let e=t.stepName;return s.has(e)?(s.delete(e),z(t)):B(()=>new P(`Cannot send 'STEP_FINISHED' for step "${e}" that was not started`))}case F.RUN_STARTED:return u=!0,z(t);case F.RUN_FINISHED:if(s.size>0){let e=Array.from(s.keys()).join(`, `);return B(()=>new P(`Cannot send 'RUN_FINISHED' while steps are still active: ${e}`))}if(n.size>0){let e=Array.from(n.keys()).join(`, `);return B(()=>new P(`Cannot send 'RUN_FINISHED' while text messages are still active: ${e}`))}if(r.size>0){let e=Array.from(r.keys()).join(`, `);return B(()=>new P(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${e}`))}return i=!0,z(t);case F.RUN_ERROR:return a=!0,z(t);case F.CUSTOM:return z(t);case F.THINKING_TEXT_MESSAGE_START:return c?l?B(()=>new P(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.`)):(l=!0,z(t)):B(()=>new P(`Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first.`));case F.THINKING_TEXT_MESSAGE_CONTENT:return l?z(t):B(()=>new P(`Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first.`));case F.THINKING_TEXT_MESSAGE_END:return l?(l=!1,z(t)):B(()=>new P(`Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first.`));case F.THINKING_START:return c?B(()=>new P(`Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.`)):(c=!0,z(t));case F.THINKING_END:return c?(c=!1,z(t)):B(()=>new P(`Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first.`));default:return z(t)}}))},_c=(e,t)=>Fa(()=>_a(fetch(e,t))).pipe(ja(e=>{if(!e.ok){let t=e.headers.get(`content-type`)||``;return _a(e.text()).pipe(ba(n=>{let r=n;if(t.includes(`application/json`))try{r=JSON.parse(n)}catch{}let i=Error(`HTTP ${e.status}: ${typeof r==`string`?r:JSON.stringify(r)}`);return i.status=e.status,i.payload=r,B(()=>i)}))}let t={type:`headers`,status:e.status,headers:e.headers},n=e.body?.getReader();return n?new R(e=>(e.next(t),(async()=>{try{for(;;){let{done:t,value:r}=await n.read();if(t)break;let i={type:`data`,data:r};e.next(i)}e.complete()}catch(t){e.error(t)}})(),()=>{n.cancel().catch(e=>{if(e?.name!==`AbortError`)throw e})})):B(()=>Error(`Failed to getReader() from response`))})),vc=e=>{let t=new wa,n=new TextDecoder(`utf-8`,{fatal:!1}),r=``;e.subscribe({next:e=>{if(e.type!==`headers`&&e.type===`data`&&e.data){let t=n.decode(e.data,{stream:!0});r+=t;let a=r.split(/\n\n/);r=a.pop()||``;for(let e of a)i(e)}},error:e=>t.error(e),complete:()=>{r&&(r+=n.decode(),i(r)),t.complete()}});function i(e){let n=e.split(`
693
+ `),r=[];for(let e of n)e.startsWith(`data: `)&&r.push(e.slice(6));if(r.length>0)try{let e=r.join(`
694
+ `),n=JSON.parse(e);t.next(n)}catch(e){t.error(e)}}return t.asObservable()},yc=e=>{let t=new wa,n=new Uint8Array;e.subscribe({next:e=>{if(e.type!==`headers`&&e.type===`data`&&e.data){let t=new Uint8Array(n.length+e.data.length);t.set(n,0),t.set(e.data,n.length),n=t,r()}},error:e=>t.error(e),complete:()=>{if(n.length>0)try{r()}catch{console.warn(`Incomplete or invalid protocol buffer data at stream end`)}t.complete()}});function r(){for(;n.length>=4;){let e=4+new DataView(n.buffer,n.byteOffset,4).getUint32(0,!1);if(n.length<e)break;try{let r=Zs(n.slice(4,e));t.next(r),n=n.slice(e)}catch(e){let n=e instanceof Error?e.message:String(e);t.error(Error(`Failed to decode protocol buffer message: ${n}`));return}}}return t.asObservable()},bc=e=>{let t=new wa,n=new Aa,r=!1;return e.subscribe({next:e=>{n.next(e),e.type===`headers`&&!r?(r=!0,e.headers.get(`content-type`)===`application/vnd.ag-ui.event+proto`?yc(n).subscribe({next:e=>t.next(e),error:e=>t.error(e),complete:()=>t.complete()}):vc(n).subscribe({next:e=>{try{let n=Ur.parse(e);t.next(n)}catch(e){t.error(e)}},error:e=>{if(e?.name===`AbortError`){t.next({type:F.RUN_ERROR,rawEvent:e}),t.complete();return}return t.error(e)},complete:()=>t.complete()})):r||t.error(Error(`No headers event received before data events`))},error:e=>{n.error(e),t.error(e)},complete:()=>{n.complete()}}),t.asObservable()},X=hr([`TextMessageStart`,`TextMessageContent`,`TextMessageEnd`,`ActionExecutionStart`,`ActionExecutionArgs`,`ActionExecutionEnd`,`ActionExecutionResult`,`AgentStateMessage`,`MetaEvent`,`RunStarted`,`RunFinished`,`RunError`,`NodeStarted`,`NodeFinished`]),xc=hr([`LangGraphInterruptEvent`,`PredictState`,`Exit`]);pr(`type`,[M({type:N(X.enum.TextMessageStart),messageId:A(),parentMessageId:A().optional(),role:A().optional()}),M({type:N(X.enum.TextMessageContent),messageId:A(),content:A()}),M({type:N(X.enum.TextMessageEnd),messageId:A()}),M({type:N(X.enum.ActionExecutionStart),actionExecutionId:A(),actionName:A(),parentMessageId:A().optional()}),M({type:N(X.enum.ActionExecutionArgs),actionExecutionId:A(),args:A()}),M({type:N(X.enum.ActionExecutionEnd),actionExecutionId:A()}),M({type:N(X.enum.ActionExecutionResult),actionName:A(),actionExecutionId:A(),result:A()}),M({type:N(X.enum.AgentStateMessage),threadId:A(),agentName:A(),nodeName:A(),runId:A(),active:ur(),role:A(),state:A(),running:ur()}),M({type:N(X.enum.MetaEvent),name:xc,value:j()}),M({type:N(X.enum.RunError),message:A(),code:A().optional()})]),M({id:A(),role:A(),content:A(),parentMessageId:A().optional()}),M({id:A(),name:A(),arguments:j(),parentMessageId:A().optional()}),M({id:A(),result:j(),actionExecutionId:A(),actionName:A()});var Sc=e=>{if(typeof e==`string`)return e;if(!Array.isArray(e))return;let t=e.filter(e=>e.type===`text`).map(e=>e.text).filter(e=>e.length>0);if(t.length!==0)return t.join(`
695
+ `)},Cc=(e,t,n)=>r=>{let i={},a=!0,o=!0,s=``,c=null,l=null,u=[],d={},f=e=>{typeof e==`object`&&e&&(`messages`in e&&delete e.messages,i=e)};return r.pipe(ba(r=>{switch(r.type){case F.TEXT_MESSAGE_START:{let e=r;return[{type:X.enum.TextMessageStart,messageId:e.messageId,role:e.role}]}case F.TEXT_MESSAGE_CONTENT:{let e=r;return[{type:X.enum.TextMessageContent,messageId:e.messageId,content:e.delta}]}case F.TEXT_MESSAGE_END:{let e=r;return[{type:X.enum.TextMessageEnd,messageId:e.messageId}]}case F.TOOL_CALL_START:{let e=r;return u.push({id:e.toolCallId,type:`function`,function:{name:e.toolCallName,arguments:``}}),o=!0,d[e.toolCallId]=e.toolCallName,[{type:X.enum.ActionExecutionStart,actionExecutionId:e.toolCallId,actionName:e.toolCallName,parentMessageId:e.parentMessageId}]}case F.TOOL_CALL_ARGS:{let c=r,d=u.find(e=>e.id===c.toolCallId);if(!d)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${c.toolCallId}'`),[];d.function.arguments+=c.delta;let p=!1;if(l){let e=l.find(e=>e.tool==d.function.name);if(e)try{let t=JSON.parse(To(d.function.arguments));e.tool_argument&&e.tool_argument in t?(f(pc(q({},i),{[e.state_key]:t[e.tool_argument]})),p=!0):e.tool_argument||(f(pc(q({},i),{[e.state_key]:t})),p=!0)}catch{}}return[{type:X.enum.ActionExecutionArgs,actionExecutionId:c.toolCallId,args:c.delta},...p?[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]:[]]}case F.TOOL_CALL_END:{let e=r;return[{type:X.enum.ActionExecutionEnd,actionExecutionId:e.toolCallId}]}case F.TOOL_CALL_RESULT:{let e=r;return[{type:X.enum.ActionExecutionResult,actionExecutionId:e.toolCallId,result:e.content,actionName:d[e.toolCallId]||`unknown`}]}case F.RAW:return[];case F.CUSTOM:{let e=r;switch(e.name){case`Exit`:a=!1;break;case`PredictState`:l=e.value;break}return[{type:X.enum.MetaEvent,name:e.name,value:e.value}]}case F.STATE_SNAPSHOT:return f(r.snapshot),[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}];case F.STATE_DELTA:{let c=oo(i,r.delta,!0,!1);return c?(f(c.newDocument),[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:o}]):[]}case F.MESSAGES_SNAPSHOT:return c=r.messages,[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(q(q({},i),c?{messages:c}:{})),active:!0}];case F.RUN_STARTED:return[];case F.RUN_FINISHED:return c&&(i.messages=c),Object.keys(i).length===0?[]:[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(q(q({},i),c?{messages:wc(c)}:{})),active:!1}];case F.RUN_ERROR:{let e=r;return[{type:X.enum.RunError,message:e.message,code:e.code}]}case F.STEP_STARTED:return s=r.stepName,u=[],l=null,[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!0}];case F.STEP_FINISHED:return u=[],l=null,[{type:X.enum.AgentStateMessage,threadId:e,agentName:n,nodeName:s,runId:t,running:a,role:`assistant`,state:JSON.stringify(i),active:!1}];default:return[]}}))};function wc(e){var t;let n=[];for(let r of e)if(r.role===`assistant`||r.role===`user`||r.role===`system`){let e=Sc(r.content);if(e){let t={id:r.id,role:r.role,content:e};n.push(t)}if(r.role===`assistant`&&r.toolCalls&&r.toolCalls.length>0)for(let e of r.toolCalls){let t={id:e.id,name:e.function.name,arguments:JSON.parse(e.function.arguments),parentMessageId:r.id};n.push(t)}}else if(r.role===`tool`){let i=`unknown`;for(let n of e)if(n.role===`assistant`&&(t=n.toolCalls)!=null&&t.length){for(let e of n.toolCalls)if(e.id===r.toolCallId){i=e.function.name;break}}let a={id:r.id,result:r.content,actionExecutionId:r.toolCallId,actionName:i};n.push(a)}return n}var Tc=e=>t=>{let n,r,i,a=()=>{if(!n||i!==`text`)throw Error(`No text message to close`);let t={type:F.TEXT_MESSAGE_END,messageId:n.messageId};return i=void 0,n=void 0,e&&console.debug(`[TRANSFORM]: TEXT_MESSAGE_END`,JSON.stringify(t)),t},o=()=>{if(!r||i!==`tool`)throw Error(`No tool call to close`);let t={type:F.TOOL_CALL_END,toolCallId:r.toolCallId};return i=void 0,r=void 0,e&&console.debug(`[TRANSFORM]: TOOL_CALL_END`,JSON.stringify(t)),t},s=()=>i===`text`?[a()]:i===`tool`?[o()]:[];return t.pipe(ba(t=>{switch(t.type){case F.TEXT_MESSAGE_START:case F.TEXT_MESSAGE_CONTENT:case F.TEXT_MESSAGE_END:case F.TOOL_CALL_START:case F.TOOL_CALL_ARGS:case F.TOOL_CALL_END:case F.TOOL_CALL_RESULT:case F.STATE_SNAPSHOT:case F.STATE_DELTA:case F.MESSAGES_SNAPSHOT:case F.CUSTOM:case F.RUN_STARTED:case F.RUN_FINISHED:case F.RUN_ERROR:case F.STEP_STARTED:case F.STEP_FINISHED:case F.THINKING_START:case F.THINKING_END:case F.THINKING_TEXT_MESSAGE_START:case F.THINKING_TEXT_MESSAGE_CONTENT:case F.THINKING_TEXT_MESSAGE_END:return[...s(),t];case F.RAW:case F.ACTIVITY_SNAPSHOT:case F.ACTIVITY_DELTA:return[t];case F.TEXT_MESSAGE_CHUNK:let a=t,o=[];if((i!==`text`||a.messageId!==void 0&&a.messageId!==n?.messageId)&&o.push(...s()),i!==`text`){if(a.messageId===void 0)throw Error(`First TEXT_MESSAGE_CHUNK must have a messageId`);n={messageId:a.messageId},i=`text`;let t={type:F.TEXT_MESSAGE_START,messageId:a.messageId,role:a.role||`assistant`};o.push(t),e&&console.debug(`[TRANSFORM]: TEXT_MESSAGE_START`,JSON.stringify(t))}if(a.delta!==void 0){let t={type:F.TEXT_MESSAGE_CONTENT,messageId:n.messageId,delta:a.delta};o.push(t),e&&console.debug(`[TRANSFORM]: TEXT_MESSAGE_CONTENT`,JSON.stringify(t))}return o;case F.TOOL_CALL_CHUNK:let c=t,l=[];if((i!==`tool`||c.toolCallId!==void 0&&c.toolCallId!==r?.toolCallId)&&l.push(...s()),i!==`tool`){if(c.toolCallId===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallId`);if(c.toolCallName===void 0)throw Error(`First TOOL_CALL_CHUNK must have a toolCallName`);r={toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId},i=`tool`;let t={type:F.TOOL_CALL_START,toolCallId:c.toolCallId,toolCallName:c.toolCallName,parentMessageId:c.parentMessageId};l.push(t),e&&console.debug(`[TRANSFORM]: TOOL_CALL_START`,JSON.stringify(t))}if(c.delta!==void 0){let t={type:F.TOOL_CALL_ARGS,toolCallId:r.toolCallId,delta:c.delta};l.push(t),e&&console.debug(`[TRANSFORM]: TOOL_CALL_ARGS`,JSON.stringify(t))}return l}return t.type,[]}),ka(()=>{s()}))},Ec=class{runNext(e,t){return t.run(e).pipe(Tc(!1))}runNextWithState(e,t){let n=J(e.messages||[]),r=J(e.state||{}),i=new Aa;return hc(e,i,t,[]).subscribe(e=>{e.messages!==void 0&&(n=e.messages),e.state!==void 0&&(r=e.state)}),this.runNext(e,t).pipe(Sa(async e=>(i.next(e),await new Promise(e=>setTimeout(e,0)),{event:e,messages:J(n),state:J(r)})))}},Dc=class extends Ec{constructor(e){super(),this.fn=e}run(e,t){return this.fn(e,t)}};function Oc(e){let t=e.content;if(Array.isArray(t)){let n=t.filter(e=>typeof e==`object`&&!!e&&`type`in e&&e.type===`text`&&typeof e.text==`string`).map(e=>e.text).join(``);return pc(q({},e),{content:n})}return typeof t==`string`?e:pc(q({},e),{content:``})}var kc=class extends Ec{run(e,t){let n=e,{parentRunId:r}=n,i=mc(n,[`parentRunId`]),a=pc(q({},i),{messages:i.messages.map(Oc)});return this.runNext(a,t)}},Ac={name:`@ag-ui/client`,author:`Markus Ecker <markus.ecker@gmail.com>`,version:`0.0.42`,private:!1,publishConfig:{access:`public`},main:`./dist/index.js`,module:`./dist/index.mjs`,types:`./dist/index.d.ts`,sideEffects:!1,files:[`dist/**`,`README.md`],scripts:{build:`tsup`,dev:`tsup --watch`,clean:`rm -rf dist .turbo node_modules`,typecheck:`tsc --noEmit`,test:`jest`,"link:global":`pnpm link --global`,"unlink:global":`pnpm unlink --global`},dependencies:{"@ag-ui/core":`workspace:*`,"@ag-ui/encoder":`workspace:*`,"@ag-ui/proto":`workspace:*`,"@types/uuid":`^10.0.0`,"compare-versions":`^6.1.1`,"fast-json-patch":`^3.1.1`,rxjs:`7.8.1`,"untruncate-json":`^0.0.1`,uuid:`^11.1.0`,zod:`^3.22.4`},devDependencies:{"@types/jest":`^29.5.14`,"@types/node":`^20.11.19`,jest:`^29.7.0`,"ts-jest":`^29.1.2`,tsup:`^8.0.2`,typescript:`^5.3.3`}},jc=class{constructor({agentId:e,description:t,threadId:n,initialMessages:r,initialState:i,debug:a}={}){this.debug=!1,this.subscribers=[],this.isRunning=!1,this.middlewares=[],this.agentId=e,this.description=t??``,this.threadId=n??Ha(),this.messages=J(r??[]),this.state=J(i??{}),this.debug=a??!1,ac(this.maxVersion,`0.0.39`)<=0&&this.middlewares.unshift(new kc)}get maxVersion(){return Ac.version}subscribe(e){return this.subscribers.push(e),{unsubscribe:()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}}use(...e){let t=e.map(e=>typeof e==`function`?new Dc(e):e);return this.middlewares.push(...t),this}async runAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Ha();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{r=e.result}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new wa;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await Pa(Ni(()=>this.middlewares.length===0?this.run(n):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e)}),this).run(n),Tc(this.debug),gc(this.debug),e=>e.pipe(Ma(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),sa(e=>(this.isRunning=!1,this.onError(n,e,a))),ka(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(z(null)));let s=J(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}connect(e){throw new kr}async connectAgent(e,t){try{this.isRunning=!0,this.agentId=this.agentId??Ha();let n=this.prepareRunAgentInput(e),r,i=new Set(this.messages.map(e=>e.id)),a=[{onRunFinishedEvent:e=>{r=e.result}},...this.subscribers,t??{}];await this.onInitialize(n,a),this.activeRunDetach$=new wa;let o;this.activeRunCompletionPromise=new Promise(e=>{o=e}),await Pa(Ni(()=>this.connect(n),Tc(this.debug),gc(this.debug),e=>e.pipe(Ma(this.activeRunDetach$)),e=>this.apply(n,e,a),e=>this.processApplyEvents(n,e,a),sa(e=>(this.isRunning=!1,e instanceof kr?Da:this.onError(n,e,a))),ka(()=>{this.isRunning=!1,this.onFinalize(n,a),o?.(),o=void 0,this.activeRunCompletionPromise=void 0,this.activeRunDetach$=void 0}))(z(null)));let s=J(this.messages).filter(e=>!i.has(e.id));return{result:r,newMessages:s}}finally{this.isRunning=!1}}abortRun(){}async detachActiveRun(){var e;if(!this.activeRunDetach$)return;let t=this.activeRunCompletionPromise??Promise.resolve();this.activeRunDetach$.next(),(e=this.activeRunDetach$)==null||e.complete(),await t}apply(e,t,n){return hc(e,t,this,n)}processApplyEvents(e,t,n){return t.pipe(Na(t=>{t.messages&&(this.messages=t.messages,n.forEach(t=>{var n;(n=t.onMessagesChanged)==null||n.call(t,{messages:this.messages,state:this.state,agent:this,input:e})})),t.state&&(this.state=t.state,n.forEach(t=>{var n;(n=t.onStateChanged)==null||n.call(t,{state:this.state,messages:this.messages,agent:this,input:e})}))}))}prepareRunAgentInput(e){let t=J(this.messages).filter(e=>e.role!==`activity`);return{threadId:this.threadId,runId:e?.runId||Ha(),tools:J(e?.tools??[]),context:J(e?.context??[]),forwardedProps:J(e?.forwardedProps??{}),state:J(this.state),messages:t}}async onInitialize(e,t){let n=await Y(t,this.messages,this.state,(t,n,r)=>t.onRunInitialized?.call(t,{messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages&&(this.messages=n.messages,e.messages=n.messages,t.forEach(t=>{var n;(n=t.onMessagesChanged)==null||n.call(t,{messages:this.messages,state:this.state,agent:this,input:e})})),n.state&&(this.state=n.state,e.state=n.state,t.forEach(t=>{var n;(n=t.onStateChanged)==null||n.call(t,{state:this.state,messages:this.messages,agent:this,input:e})})))}onError(e,t,n){return _a(Y(n,this.messages,this.state,(n,r,i)=>n.onRunFailed?.call(n,{error:t,messages:r,state:i,agent:this,input:e}))).pipe(va(r=>{let i=r;if((i.messages!==void 0||i.state!==void 0)&&(i.messages!==void 0&&(this.messages=i.messages,n.forEach(t=>{var n;(n=t.onMessagesChanged)==null||n.call(t,{messages:this.messages,state:this.state,agent:this,input:e})})),i.state!==void 0&&(this.state=i.state,n.forEach(t=>{var n;(n=t.onStateChanged)==null||n.call(t,{state:this.state,messages:this.messages,agent:this,input:e})}))),i.stopPropagation!==!0)throw console.error(`Agent execution failed:`,t),t;return{}}))}async onFinalize(e,t){let n=await Y(t,this.messages,this.state,(t,n,r)=>t.onRunFinalized?.call(t,{messages:n,state:r,agent:this,input:e}));(n.messages!==void 0||n.state!==void 0)&&(n.messages!==void 0&&(this.messages=n.messages,t.forEach(t=>{var n;(n=t.onMessagesChanged)==null||n.call(t,{messages:this.messages,state:this.state,agent:this,input:e})})),n.state!==void 0&&(this.state=n.state,t.forEach(t=>{var n;(n=t.onStateChanged)==null||n.call(t,{state:this.state,messages:this.messages,agent:this,input:e})})))}clone(){let e=Object.create(Object.getPrototypeOf(this));return e.agentId=this.agentId,e.description=this.description,e.threadId=this.threadId,e.messages=J(this.messages),e.state=J(this.state),e.debug=this.debug,e.isRunning=this.isRunning,e.subscribers=[...this.subscribers],e.middlewares=[...this.middlewares],e}addMessage(e){this.messages.push(e),(async()=>{for(let t of this.subscribers)await t.onNewMessage?.call(t,{message:e,messages:this.messages,state:this.state,agent:this});if(e.role===`assistant`&&e.toolCalls)for(let t of e.toolCalls)for(let e of this.subscribers)await e.onNewToolCall?.call(e,{toolCall:t,messages:this.messages,state:this.state,agent:this});for(let e of this.subscribers)await e.onMessagesChanged?.call(e,{messages:this.messages,state:this.state,agent:this})})()}addMessages(e){this.messages.push(...e),(async()=>{for(let t of e){for(let e of this.subscribers)await e.onNewMessage?.call(e,{message:t,messages:this.messages,state:this.state,agent:this});if(t.role===`assistant`&&t.toolCalls)for(let e of t.toolCalls)for(let t of this.subscribers)await t.onNewToolCall?.call(t,{toolCall:e,messages:this.messages,state:this.state,agent:this})}for(let e of this.subscribers)await e.onMessagesChanged?.call(e,{messages:this.messages,state:this.state,agent:this})})()}setMessages(e){this.messages=J(e),(async()=>{for(let e of this.subscribers)await e.onMessagesChanged?.call(e,{messages:this.messages,state:this.state,agent:this})})()}setState(e){this.state=J(e),(async()=>{for(let e of this.subscribers)await e.onStateChanged?.call(e,{messages:this.messages,state:this.state,agent:this})})()}legacy_to_be_removed_runAgentBridged(e){this.agentId=this.agentId??Ha();let t=this.prepareRunAgentInput(e);return(this.middlewares.length===0?this.run(t):this.middlewares.reduceRight((e,t)=>({run:n=>t.run(n,e)}),this).run(t)).pipe(Tc(this.debug),gc(this.debug),Cc(this.threadId,t.runId,this.agentId),e=>e.pipe(va(e=>(this.debug&&console.debug(`[LEGACY]:`,JSON.stringify(e)),e))))}},Mc=class extends jc{constructor(e){super(e),this.abortController=new AbortController,this.url=e.url,this.headers=J(e.headers??{})}requestInit(e){return{method:`POST`,headers:pc(q({},this.headers),{"Content-Type":`application/json`,Accept:`text/event-stream`}),body:JSON.stringify(e),signal:this.abortController.signal}}runAgent(e,t){return this.abortController=e?.abortController??new AbortController,super.runAgent(e,t)}abortRun(){this.abortController.abort(),super.abortRun()}run(e){return bc(_c(this.url,this.requestInit(e)))}clone(){let e=super.clone();e.url=this.url,e.headers=J(this.headers??{});let t=new AbortController,n=this.abortController.signal;return n.aborted&&t.abort(n.reason),e.abortController=t,e}},Nc={thread:`thr`,message:`msg`,toolCall:`tc`,workflow:`wf`,task:`tsk`,attachment:`atc`,sdkHiddenContext:`shcx`};function Pc(e){return`${Nc[e]}_${crypto.randomUUID().replace(/-/g,``).slice(0,8)}`}var Fc=class e{constructor(){this._spec=null}static getInstance(){return e._instance||=new e,e._instance}registerPortal(e){console.log(`Registering portal spec`,e),this._spec=e}async executePlan(e){if(!this._spec)return console.warn(`No portal registered. Cannot execute plan.`),{status:`error`,details:`No portal registered`};console.log(`Executing plan:`,e);try{for(let t of e.steps){let e=this._spec.actions[t.action];if(e)console.log(`Executing portal action: ${t.action}`,t.args),await e(t.args);else throw console.warn(`Action ${t.action} not found in portal spec.`),Error(`Action ${t.action} not found`)}return{status:`ok`}}catch(e){return console.error(`Error executing plan:`,e),{status:`error`,details:e.message||e}}}get specs(){return this._spec}};let Ic=Fc.getInstance();var Lc=class{constructor(e){this.service=e}onRunStartedEvent(e){y.addEvent(`onRunStartedEvent`,e.event),this.service.addPlaceholderMessage()}onTextMessageStartEvent(e){y.addEvent(`onTextMessageStartEvent`,e.event),this.service.prepareMessageForStreaming(e.event.messageId)}onTextMessageContentEvent(e){y.addEvent(`onTextMessageContentEvent`,e.event);let t=e.event.delta||e.event.content||``;this.service.appendMessageContent(e.event.messageId,t)}onMessagesSnapshotEvent(e){y.addEvent(`onMessagesSnapshotEvent`,e.event);let t=e.event.messages.map(e=>{let t=``;return t=typeof e.content==`string`?e.content:Array.isArray(e.content)?e.content.filter(e=>e.type===`text`).map(e=>e.text).join(``):JSON.stringify(e.content),{id:e.id,role:e.role,content:t,createdAt:Date.now()}});this.service.setMessages(t),this.service.setMessages(t)}async onToolCallEndEvent(e){if(y.addEvent(`onToolCallEndEvent`,e.event),e.toolCallName===`executePlan`){console.log(`ChatSubscriber: Received executePlan tool call`,e.toolCallArgs);let t=await Ic.executePlan(e.toolCallArgs);console.log(`ChatSubscriber: executePlan result`,t)}}async onClientToolCall(e){y.addEvent(`onClientToolCall`,e.event),e.toolName===`executePlan`&&(console.log(`ChatSubscriber: Received executePlan client tool call`,e.args),await Ic.executePlan(e.args))}};let Rc=new class{constructor(){this.baseUrl=`http://localhost:8003/api/v2/conversations`}async getConversations(){let e=await fetch(`${this.baseUrl}`);if(!e.ok)throw Error(`Failed to fetch conversations: ${e.statusText}`);return e.json()}async createConversation(e){let t={...e,title:e.title||`Nueva conversación`},n=await fetch(this.baseUrl,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`Failed to create conversation: ${n.statusText}`);return n.json()}async updateConversation(e,t){let n=await fetch(`${this.baseUrl}/${e}`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok)throw Error(`Failed to update conversation: ${n.statusText}`);return n.json()}async deleteConversation(e){let t=await fetch(`${this.baseUrl}/${e}`,{method:`DELETE`});if(!t.ok)throw Error(`Failed to delete conversation: ${t.statusText}`)}},zc=new class extends EventTarget{constructor(){super(),this._thread={id:``,messages:[],isRunning:!1},this._conversations=[],this._appContext=null,this.subscriber=new Lc(this)}initialize(e){this.agent=new Mc({url:e.backendUrl}),this._appContext={appName:e.appName,currentPage:`home`,inspector:e.inspector},y.setContext(this._appContext),y.setMessages(this._thread.messages)}get thread(){return this._thread}get conversations(){return this._conversations}setAppContext(e){this._appContext=e,y.setContext(e),this.notify()}async sendMessage(e){if(!this.agent){console.error(`ChatService not initialized. Call initialize() first.`);return}if(!this._thread.id)try{let t=await Rc.createConversation({title:e.slice(0,30)+(e.length>30?`...`:``)});this._thread.id=t.id,this.agent.threadId=this._thread.id}catch(e){console.error(`Failed to create conversation during sendMessage`,e);return}let t={id:Pc(`message`),role:`user`,content:e,createdAt:Date.now()};this._thread.messages=[...this._thread.messages,t],this._thread.isRunning=!0,this.notify();try{this.agent.threadId=this._thread.id,this.agent.addMessage({id:t.id,role:t.role,content:t.content});let e=[{value:new Date().toLocaleString(),description:`Current date and time`}];this._appContext&&e.push({value:JSON.stringify(this._appContext),description:`AgentState`}),this.agent.state=this._appContext,await this.agent.runAgent({context:e},this.subscriber)}catch(e){console.error(`Failed to send message`,e)}finally{this._thread.isRunning=!1,this.notify()}}addPlaceholderMessage(){let e={id:`thinking-placeholder`,role:`assistant`,content:``,createdAt:Date.now(),isThinking:!0};this._thread.messages=[...this._thread.messages,e],this.notify()}prepareMessageForStreaming(e){this._thread.messages=this._thread.messages.map(t=>t.isThinking?{...t,id:e,isThinking:!1}:t),this.notify()}appendMessageContent(e,t){this._thread.messages=this._thread.messages.map(n=>n.id===e?{...n,content:n.content+t}:n),this.notify()}setMessages(e){this._thread.messages=e,this.notify()}async startNewThread(){this._thread={id:``,messages:[],isRunning:!1},this.agent&&(this.agent.threadId=``),this.notify()}async refreshConversations(){try{this._conversations=(await Rc.getConversations()).map(e=>({id:e.id,title:e.title})),this.notify()}catch(e){console.error(`Failed to refresh conversations`,e)}}notify(){y.setMessages(this._thread.messages),this.dispatchEvent(new CustomEvent(`state-change`))}};var Bc=class{constructor(e){this._onStateChange=()=>{this._host.requestUpdate()},this._host=e,this._host.addController(this)}initialize(e){return zc.initialize(e)}hostConnected(){zc.addEventListener(`state-change`,this._onStateChange)}hostDisconnected(){zc.removeEventListener(`state-change`,this._onStateChange)}get thread(){return zc.thread}get conversations(){return zc.conversations}sendMessage(e){return zc.sendMessage(e)}startNewThread(){return zc.startNewThread()}setAppContext(e){return zc.setAppContext(e)}refreshConversations(){return zc.refreshConversations()}},Vc=l({DOMException:()=>ll,Headers:()=>Z,Request:()=>el,Response:()=>rl,fetch:()=>il});function Hc(e){return e&&DataView.prototype.isPrototypeOf(e)}function Uc(e){if(typeof e!=`string`&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||e===``)throw TypeError(`Invalid character in header field name: "`+e+`"`);return e.toLowerCase()}function Wc(e){return typeof e!=`string`&&(e=String(e)),e}function Gc(e){var t={next:function(){var t=e.shift();return{done:t===void 0,value:t}}};return $.iterable&&(t[Symbol.iterator]=function(){return t}),t}function Z(e){this.map={},e instanceof Z?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(e.length!=2)throw TypeError(`Headers constructor: expected name/value pair to be length 2, found`+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function Kc(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(TypeError(`Already read`));e.bodyUsed=!0}}function qc(e){return new Promise(function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}})}function Jc(e){var t=new FileReader,n=qc(t);return t.readAsArrayBuffer(e),n}function Yc(e){var t=new FileReader,n=qc(t),r=/charset=([A-Za-z0-9_-]+)/.exec(e.type),i=r?r[1]:`utf-8`;return t.readAsText(e,i),n}function Xc(e){for(var t=new Uint8Array(e),n=Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join(``)}function Zc(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function Qc(){return this.bodyUsed=!1,this._initBody=function(e){this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?typeof e==`string`?this._bodyText=e:$.blob&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:$.formData&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:$.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():$.arrayBuffer&&$.blob&&Hc(e)?(this._bodyArrayBuffer=Zc(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):$.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||ol(e))?this._bodyArrayBuffer=Zc(e):this._bodyText=e=Object.prototype.toString.call(e):(this._noBody=!0,this._bodyText=``),this.headers.get(`content-type`)||(typeof e==`string`?this.headers.set(`content-type`,`text/plain;charset=UTF-8`):this._bodyBlob&&this._bodyBlob.type?this.headers.set(`content-type`,this._bodyBlob.type):$.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set(`content-type`,`application/x-www-form-urlencoded;charset=UTF-8`))},$.blob&&(this.blob=function(){var e=Kc(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw Error(`could not read FormData body as blob`);return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer)return Kc(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer));if($.blob)return this.blob().then(Jc);throw Error(`could not read as ArrayBuffer`)},this.text=function(){var e=Kc(this);if(e)return e;if(this._bodyBlob)return Yc(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Xc(this._bodyArrayBuffer));if(this._bodyFormData)throw Error(`could not read FormData body as text`);return Promise.resolve(this._bodyText)},$.formData&&(this.formData=function(){return this.text().then(tl)}),this.json=function(){return this.text().then(JSON.parse)},this}function $c(e){var t=e.toUpperCase();return sl.indexOf(t)>-1?t:e}function el(e,t){if(!(this instanceof el))throw TypeError(`Please use the "new" operator, this DOM object constructor cannot be called as a function.`);t||={};var n=t.body;if(e instanceof el){if(e.bodyUsed)throw TypeError(`Already read`);this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new Z(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,!n&&e._bodyInit!=null&&(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||`same-origin`,(t.headers||!this.headers)&&(this.headers=new Z(t.headers)),this.method=$c(t.method||this.method||`GET`),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if(`AbortController`in Q)return new AbortController().signal}(),this.referrer=null,(this.method===`GET`||this.method===`HEAD`)&&n)throw TypeError(`Body not allowed for GET or HEAD requests`);if(this._initBody(n),(this.method===`GET`||this.method===`HEAD`)&&(t.cache===`no-store`||t.cache===`no-cache`)){var r=/([?&])_=[^&]*/;r.test(this.url)?this.url=this.url.replace(r,`$1_=`+new Date().getTime()):this.url+=(/\?/.test(this.url)?`&`:`?`)+`_=`+new Date().getTime()}}function tl(e){var t=new FormData;return e.trim().split(`&`).forEach(function(e){if(e){var n=e.split(`=`),r=n.shift().replace(/\+/g,` `),i=n.join(`=`).replace(/\+/g,` `);t.append(decodeURIComponent(r),decodeURIComponent(i))}}),t}function nl(e){var t=new Z;return e.replace(/\r?\n[\t ]+/g,` `).split(`\r`).map(function(e){return e.indexOf(`
696
+ `)===0?e.substr(1,e.length):e}).forEach(function(e){var n=e.split(`:`),r=n.shift().trim();if(r){var i=n.join(`:`).trim();try{t.append(r,i)}catch(e){console.warn(`Response `+e.message)}}}),t}function rl(e,t){if(!(this instanceof rl))throw TypeError(`Please use the "new" operator, this DOM object constructor cannot be called as a function.`);if(t||={},this.type=`default`,this.status=t.status===void 0?200:t.status,this.status<200||this.status>599)throw RangeError(`Failed to construct 'Response': The status provided (0) is outside the range [200, 599].`);this.ok=this.status>=200&&this.status<300,this.statusText=t.statusText===void 0?``:``+t.statusText,this.headers=new Z(t.headers),this.url=t.url||``,this._initBody(e)}function il(e,t){return new Promise(function(n,r){var i=new el(e,t);if(i.signal&&i.signal.aborted)return r(new ll(`Aborted`,`AbortError`));var a=new XMLHttpRequest;function o(){a.abort()}a.onload=function(){var e={statusText:a.statusText,headers:nl(a.getAllResponseHeaders()||``)};i.url.indexOf(`file://`)===0&&(a.status<200||a.status>599)?e.status=200:e.status=a.status,e.url=`responseURL`in a?a.responseURL:e.headers.get(`X-Request-URL`);var t=`response`in a?a.response:a.responseText;setTimeout(function(){n(new rl(t,e))},0)},a.onerror=function(){setTimeout(function(){r(TypeError(`Network request failed`))},0)},a.ontimeout=function(){setTimeout(function(){r(TypeError(`Network request timed out`))},0)},a.onabort=function(){setTimeout(function(){r(new ll(`Aborted`,`AbortError`))},0)};function s(e){try{return e===``&&Q.location.href?Q.location.href:e}catch{return e}}if(a.open(i.method,s(i.url),!0),i.credentials===`include`?a.withCredentials=!0:i.credentials===`omit`&&(a.withCredentials=!1),`responseType`in a&&($.blob?a.responseType=`blob`:$.arrayBuffer&&(a.responseType=`arraybuffer`)),t&&typeof t.headers==`object`&&!(t.headers instanceof Z||Q.Headers&&t.headers instanceof Q.Headers)){var c=[];Object.getOwnPropertyNames(t.headers).forEach(function(e){c.push(Uc(e)),a.setRequestHeader(e,Wc(t.headers[e]))}),i.headers.forEach(function(e,t){c.indexOf(t)===-1&&a.setRequestHeader(t,e)})}else i.headers.forEach(function(e,t){a.setRequestHeader(t,e)});i.signal&&(i.signal.addEventListener(`abort`,o),a.onreadystatechange=function(){a.readyState===4&&i.signal.removeEventListener(`abort`,o)}),a.send(i._bodyInit===void 0?null:i._bodyInit)})}var Q,$,al,ol,sl,cl,ll,ul=s((()=>{Q=typeof globalThis<`u`&&globalThis||typeof self<`u`&&self||typeof global<`u`&&global||{},$={searchParams:`URLSearchParams`in Q,iterable:`Symbol`in Q&&`iterator`in Symbol,blob:`FileReader`in Q&&`Blob`in Q&&(function(){try{return new Blob,!0}catch{return!1}})(),formData:`FormData`in Q,arrayBuffer:`ArrayBuffer`in Q},$.arrayBuffer&&(al=[`[object Int8Array]`,`[object Uint8Array]`,`[object Uint8ClampedArray]`,`[object Int16Array]`,`[object Uint16Array]`,`[object Int32Array]`,`[object Uint32Array]`,`[object Float32Array]`,`[object Float64Array]`],ol=ArrayBuffer.isView||function(e){return e&&al.indexOf(Object.prototype.toString.call(e))>-1}),Z.prototype.append=function(e,t){e=Uc(e),t=Wc(t);var n=this.map[e];this.map[e]=n?n+`, `+t:t},Z.prototype.delete=function(e){delete this.map[Uc(e)]},Z.prototype.get=function(e){return e=Uc(e),this.has(e)?this.map[e]:null},Z.prototype.has=function(e){return this.map.hasOwnProperty(Uc(e))},Z.prototype.set=function(e,t){this.map[Uc(e)]=Wc(t)},Z.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},Z.prototype.keys=function(){var e=[];return this.forEach(function(t,n){e.push(n)}),Gc(e)},Z.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),Gc(e)},Z.prototype.entries=function(){var e=[];return this.forEach(function(t,n){e.push([n,t])}),Gc(e)},$.iterable&&(Z.prototype[Symbol.iterator]=Z.prototype.entries),sl=[`CONNECT`,`DELETE`,`GET`,`HEAD`,`OPTIONS`,`PATCH`,`POST`,`PUT`,`TRACE`],el.prototype.clone=function(){return new el(this,{body:this._bodyInit})},Qc.call(el.prototype),Qc.call(rl.prototype),rl.prototype.clone=function(){return new rl(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Z(this.headers),url:this.url})},rl.error=function(){var e=new rl(null,{status:200,statusText:``});return e.ok=!1,e.status=0,e.type=`error`,e},cl=[301,302,303,307,308],rl.redirect=function(e,t){if(cl.indexOf(t)===-1)throw RangeError(`Invalid status code`);return new rl(null,{status:t,headers:{location:e}})},ll=Q.DOMException;try{new ll}catch{ll=function(e,t){this.message=e,this.name=t,this.stack=Error(e).stack},ll.prototype=Object.create(Error.prototype),ll.prototype.constructor=ll}il.polyfill=!0,Q.fetch||(Q.fetch=il,Q.Headers=Z,Q.Request=el,Q.Response=rl)})),dl=d(c(((e,t)=>{t.exports=(function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}return n.m=e,n.c=t,n.p=``,n(0)})([(function(e,t,n){e.exports=n(1)(typeof importScripts==`function`?self:window)}),(function(e,t,n){function r(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}else return Array.from(e)}var i=[];function a(e){for(var t=arguments.length,n=Array(t>1?t-1:0),a=1;a<t;a++)n[a-1]=arguments[a];var o=i.reduce(function(e,t){return[t].concat(e)},[]),s=Promise.resolve(n);return o.forEach(function(e){var t=e.request,n=e.requestError;(t||n)&&(s=s.then(function(e){return t.apply(void 0,r(e))},n))}),s=s.then(function(t){var n=new(Function.prototype.bind.apply(Request,[null].concat(r(t))));return e(n).then(function(e){return e.request=n,e}).catch(function(e){return e.request=n,Promise.reject(e)})}),o.forEach(function(e){var t=e.response,n=e.responseError;(t||n)&&(s=s.then(t,n))}),s}e.exports=function(e){if(!e.fetch)try{n(2)}catch{throw Error(`No fetch available. Unable to register fetch-intercept`)}return e.fetch=function(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return a.apply(void 0,[e].concat(n))}}(e.fetch),{register:function(e){return i.push(e),function(){var t=i.indexOf(e);t>=0&&i.splice(t,1)}},clear:function(){i=[]}}}}),(function(e,t){e.exports=(ul(),f(Vc))})])}))(),1);new class{constructor(){this.unregister=null}init(){this.unregister&&this.unregister(),this.unregister=dl.default.register({request:(e,t)=>{let n=new Headers(t?.headers||{});return n.has(`Authorization`)||n.append(`Authorization`,`Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6InhmcDRfR0tObWNBMHl3UUNrZ1BXVkJjTHZmRDVfZXZKOWg3bUhGbExBVWMiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiIwZWZhNWFhNy04OWRiLTQ5MTYtYmZlNC0wNTM3MjhlZWY2M2QiLCJpc3MiOiJodHRwczovL3NrY290ZXN0LmIyY2xvZ2luLmNvbS8wZGI2ZGJjMy02OTA4LTQ1MTctYTdmMi04MWVhNjg1YTI1ZTIvdjIuMC8iLCJleHAiOjE3NjgzMTEzNjksIm5iZiI6MTc2ODMxMDQ2OSwibmFtZSI6IlZpYW5hIFZlbGFzcXVleiwgSm9zZSBTdGV2ZW4iLCJpZHBfYWNjZXNzX3Rva2VuIjoiZXlKMGVYQWlPaUpLVjFRaUxDSnViMjVqWlNJNkltWkNlRzgzZHpFeExUSnZSMnhMVFZwU1NtcDJlRUV0WkZSdWNWbGpUVmRXUlRVMlRUTlZVemRVZURRaUxDSmhiR2NpT2lKU1V6STFOaUlzSW5nMWRDSTZJbEJqV0RrNFIxZzBNakJVTVZnMmMwSkVhM3BvVVcxeFozZE5WU0lzSW10cFpDSTZJbEJqV0RrNFIxZzBNakJVTVZnMmMwSkVhM3BvVVcxeFozZE5WU0o5LmV5SmhkV1FpT2lJd01EQXdNREF3TXkwd01EQXdMVEF3TURBdFl6QXdNQzB3TURBd01EQXdNREF3TURBaUxDSnBjM01pT2lKb2RIUndjem92TDNOMGN5NTNhVzVrYjNkekxtNWxkQzh3T0RJM01XWTBNaTA0TVdWbUxUUTFaRFl0T0RGaFl5MDBPVGMzTm1NMFltVTJNVFV2SWl3aWFXRjBJam94TnpZNE16QTNOVFEzTENKdVltWWlPakUzTmpnek1EYzFORGNzSW1WNGNDSTZNVGMyT0RNeE1qZzNOQ3dpWVdOamRDSTZNQ3dpWVdOeUlqb2lNU0lzSW1GamNuTWlPbHNpY0RFaVhTd2lZV2x2SWpvaVFWcFJRV0V2T0dGQlFVRkJPVTh3ZFdWU1ZuTlBaR3R4ZHpKUkwxWjBialJ1Y0hKdWNGTnhXWGRFY2tOeE1sQkxVMk5rU2xaNFZHRlhlakJ3WWpSUlkxVm1halJEUTI5Tk1GTTBMM0JrTUhKVk0zSXJaMlZ4TnpKUk9YTjZMM1ZMY0RaRVZteDRlVVpPUVhCdU1VUjZRamhaVjI1a1lWRkdOVkJNYWtGNU1XVjJlSEEwUkZVNGJYZHRSM1JLUjBGcVJFcFVTV012TkZoaGJqQm5ibkY0WkN0WlZFaHdSazkyYVc5aU5qTkNUVnBITWxGb1EwVlpVV2xvZVdWU2FqQm5jRW8xUWxOdk4zcEJkVzFDSWl3aVlXMXlJanBiSW5CM1pDSXNJbTFtWVNKZExDSmhjSEJmWkdsemNHeGhlVzVoYldVaU9pSkVZV3hwTFZCeVpDSXNJbUZ3Y0dsa0lqb2laR1prTURrNVlqQXRaV05pT1MwME0yVTFMV0kzWWpjdE5USTVObUk0TUdFME5qSXdJaXdpWVhCd2FXUmhZM0lpT2lJeElpd2labUZ0YVd4NVgyNWhiV1VpT2lKV2FXRnVZU0JXWld4aGMzRjFaWG9pTENKbmFYWmxibDl1WVcxbElqb2lTbTl6WlNCVGRHVjJaVzRpTENKcFpIUjVjQ0k2SW5WelpYSWlMQ0pwY0dGa1pISWlPaUl6T0M0NUxqSXlNQzR4TXpJaUxDSnVZVzFsSWpvaVZtbGhibUVnVm1Wc1lYTnhkV1Y2TENCS2IzTmxJRk4wWlhabGJpSXNJbTlwWkNJNkltVXdNbU0wTmpaakxXVTVaRGd0TkdGa01pMDVaVGhrTFdReFltUTJObUV6TkRNd01pSXNJbTl1Y0hKbGJWOXphV1FpT2lKVExURXROUzB5TVMweU5EZzVPVGM1T1RRd0xUSTFOVEl3TVRnM016RXRNVGN3TWpjeE9UTTFPUzB5TVRrNE1DSXNJbkJzWVhSbUlqb2lPQ0lzSW5CMWFXUWlPaUl4TURBek1qQXdNVUV4UWpCQ016azBJaXdpY21naU9pSXhMa0ZVVVVGUmFEaHVRMDh0UWpGclYwSnlSV3d6WWtWMmJVWlJUVUZCUVVGQlFVRkJRWGRCUVVGQlFVRkJRVUZDVVVGUmF6QkJRUzRpTENKelkzQWlPaUpOWVdsc0xsSmxZV1FnVFdGcGJDNVRaVzVrSUc5d1pXNXBaQ0J3Y205bWFXeGxJRlZ6WlhJdVVtVmhaQ0JsYldGcGJDSXNJbk5wWkNJNklqQXdNVEJoT1dKaExUVTFOakV0WXpoa01DMWtPRGd3TFRKak9HSmhNRGRqTVdJME15SXNJbk5wWjI1cGJsOXpkR0YwWlNJNld5SnJiWE5wSWwwc0luTjFZaUk2SW5GaFNsbFhNelEzT0RWcFdFUktVbDlyYVZCa1NuSm5VWGhoVGs5d1RsaHRhVmhFV0dVM1NVTktaMWtpTENKMFpXNWhiblJmY21WbmFXOXVYM05qYjNCbElqb2lVMEVpTENKMGFXUWlPaUl3T0RJM01XWTBNaTA0TVdWbUxUUTFaRFl0T0RGaFl5MDBPVGMzTm1NMFltVTJNVFVpTENKMWJtbHhkV1ZmYm1GdFpTSTZJbXAyYVdGdVlVQnphMkZ1WkdsaExtTnZiUzVqYnlJc0luVndiaUk2SW1wMmFXRnVZVUJ6YTJGdVpHbGhMbU52YlM1amJ5SXNJblYwYVNJNklsSjFhR2hmYTJsblkxVjVlRmt6VGtwMlZFcE5RVUVpTENKMlpYSWlPaUl4TGpBaUxDSjNhV1J6SWpwYkltSTNPV1ppWmpSa0xUTmxaamt0TkRZNE9TMDRNVFF6TFRjMllqRTVOR1U0TlRVd09TSmRMQ0o0YlhOZllXTmtJam94TnpVeU5UZzVNVEk0TENKNGJYTmZZV04wWDJaamRDSTZJamtnTXlJc0luaHRjMTltZEdRaU9pSk5kVTFuWVVRd1Uwa3piakozYlRBMFQwSkJjM0JXVFRndFlVRTBUbDltV0Zob01FcElXbEpsVUdaWlFtUllUbnBpTTFZd1lVTXhhMk15TVhvaUxDSjRiWE5mYVdSeVpXd2lPaUl4SURRaUxDSjRiWE5mYzNRaU9uc2ljM1ZpSWpvaWMzUkNiazAzV25FME1td3hVa1l5ZEV0RU1GaEJVbVpoVGtOUlFXOW9WbTFmVUZWWFltSnJSbDlST0NKOUxDSjRiWE5mYzNWaVgyWmpkQ0k2SWpNZ05DSXNJbmh0YzE5MFkyUjBJam94TXprek5qQXpNelF4TENKNGJYTmZkRzUwWDJaamRDSTZJak1nTVRRaWZRLlFiTFF0NDBJYUYzS3Ixekd0dEVncF9JQndEdThEd25UUGg5X1NCbXZkTmg4bDVWb2VacnpTOEppTi1RMFB5dHZINXJ1dmdoaFViVVliTVduMjE4bWRPQ2RrbmhRSzA1eHBSQmFqeUVReExSQ2FxSnhlcTJUWElqdEgxN19zcl80UkgyVFpnYnhqcENpV1RRbThCTDlBbXJ1cndGZnVKYnlyaFJMbHpzbjNMRXZtNmpvMXlfeUtyWkVLLXNFaU55dEZjYU1GTzVFUjZDUnVtRFl6MlhiZ0NzRXhhczFFTm5yTE9yZVhfYmJqQXdNT1p3cU55OGJnTlVnRXJOMU56dzlGM0pxOEM5dndpaUhkQ1ZKS0JlN1ViZDBPUEpsN21GOVRRRWN4ekc1XzJzZlpsWnFCS0w1dGNkUEdVdWc1MmNQZXRnWGJfTG1kb2xkYWdMZEJEbkdFdyIsInN1YiI6Ijg4MjBkNmI2LTcyNWItNDA0NC1hZGNiLWEzZTE4YTM4ZTRmYyIsImdpdmVuX25hbWUiOiJKb3NlIFN0ZXZlbiIsImZhbWlseV9uYW1lIjoiVmlhbmEgVmVsYXNxdWV6IiwiZW1haWwiOiJqdmlhbmFAc2thbmRpYS5jb20uY28iLCJub25jZSI6IjAxOWJiNzE1LTdlYjMtN2NjNC1iYjY5LTY4ZjUxYzM5NjQxZiIsImF6cCI6IjBlZmE1YWE3LTg5ZGItNDkxNi1iZmU0LTA1MzcyOGVlZjYzZCIsInZlciI6IjEuMCIsImlhdCI6MTc2ODMxMDQ2OX0.cwGadIBQg-do5ttWAJrBHo_JMTQ_AxhfYPZwRIPke5oAKIMxMqgiJ52Uma6NFC1SiUQX1afgkZBP3xsgeSt-aB27J1YgAH3yywZCCdwI88dPejsAOhLz_AdhR9YBndSUEabiau8q3F1D5UNgwaijt-1ziRgzj1ngVzqC3v5EQJ1KM2kP0Am_xXxJkZFTkWpS2Vv7du-vFjabkkMFzVzsksf5PYfoHL4HL7mvrXOjrFPX4KTM2fYAs6qUc274hPvMh-JaU6KbiFAFRFVW6UqhbgZ9FYI_eVEMzlmNG0aQhJ4cy0Iac59J9ZQV-6UvpiFFegIDIrdfqqCguKgCFXe7Tg`),[e,{...t,headers:n}]},requestError:e=>Promise.reject(e),response:e=>e,responseError:e=>Promise.reject(e)}),console.log(`Fetch interceptor initialized with test Authorization header.`)}destroy(){this.unregister&&(this.unregister(),this.unregister=null,console.log(`Fetch interceptor destroyed.`))}}().init();var fl=class extends ot{constructor(...e){super(...e),this._chatController=new Bc(this),this.backendUrl=`http://localhost:8001/ag_ui`,this.appName=`Lit-Chat-App`,this.agentAvatar=``,this._historyOpen=!1,this._inspectorOpen=!1,this._inspectorEnabled=!1}static#e=this.styles=mt;willUpdate(e){(e.has(`backendUrl`)||e.has(`appName`))&&(this._chatController.initialize({backendUrl:this.backendUrl,appName:this.appName,inspector:this.hasAttribute(`inspector`)||this.inspector}),this._inspectorEnabled=this.hasAttribute(`inspector`)||this.inspector)}_handleSend(e){this._chatController.sendMessage(e.detail.content)}_handleNewThread(){this._chatController.startNewThread()}setAppContext(e){this._chatController.setAppContext(e)}_toggleHistory(){this._historyOpen=!this._historyOpen,this._historyOpen&&this._chatController.refreshConversations()}_handleSelectThread(e){console.log(`Selected conversation:`,e.detail.conversation),this._historyOpen=!1}_toggleInspector(){this._inspectorOpen=!this._inspectorOpen}render(){return h`
697
+ <div class="chat-layout">
698
+ <agent-chat-header
699
+ @new-thread="${this._handleNewThread}"
700
+ @toggle-history="${this._toggleHistory}"
701
+ ></agent-chat-header>
702
+ <agent-chat-history-list
703
+ .conversations="${this._chatController.conversations}"
704
+ ?open="${this._historyOpen}"
705
+ @select-thread="${this._handleSelectThread}"
706
+ ></agent-chat-history-list>
707
+ <agent-chat-thread
708
+ .messages="${this._chatController.thread.messages}"
709
+ ?isRunning="${this._chatController.thread.isRunning}"
710
+ .agentAvatar="${this.agentAvatar}">
711
+ </agent-chat-thread>
712
+ <agent-chat-composer ?isRunning="${this._chatController.thread.isRunning}" @send="${this._handleSend}"></agent-chat-composer>
713
+
714
+ ${this._inspectorEnabled?h`
715
+ <button class="inspector-toggle" @click="${this._toggleInspector}" title="Inspector">
716
+ ${wt}
717
+ </button>
718
+ `:``}
719
+
720
+ ${this._inspectorOpen?h`
721
+ <agent-inspector-window @close="${this._toggleInspector}"></agent-inspector-window>
722
+ `:``}
723
+ </div>
724
+ `}};v([_({type:String,attribute:`backend-url`})],fl.prototype,`backendUrl`,void 0),v([_({type:String,attribute:`app-name`})],fl.prototype,`appName`,void 0),v([_({type:String,attribute:`agent-avatar`})],fl.prototype,`agentAvatar`,void 0),v([dt()],fl.prototype,`_historyOpen`,void 0),v([dt()],fl.prototype,`_inspectorOpen`,void 0),v([dt()],fl.prototype,`_inspectorEnabled`,void 0),fl=v([ct(`agent-chat`)],fl);function pl(e,t={}){let n=document.createElement(`agent-chat`);return Object.keys(t).forEach(e=>{e in n&&(n[e]=t[e])}),e.appendChild(n),n}function ml(){}Object.defineProperty(e,`AgentChat`,{enumerable:!0,get:function(){return fl}}),e.ChatPortalService=Fc,e.chatPortalService=Ic,e.mount=pl,e.register=ml});