@coveo/quantic 3.44.2 → 3.44.3

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.
@@ -24,7 +24,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
24
24
  `)}
25
25
 
26
26
  ${t}
27
- `;return new si(r)}var si=class extends Error{constructor(e){super(e),this.name="SchemaValidationError"}},ht=class{constructor(e){ae(this,"definition");this.definition=e}validate(e={},t=""){let r={...this.default,...e},n=[];for(let o in this.definition){let i=this.definition[o].validate(r[o]);i&&n.push(`${o}: ${i}`)}if(n.length)throw IA(n,t);return r}get default(){let e={};for(let t in this.definition){let r=this.definition[t].default;r!==void 0&&(e[t]=r)}return e}},De=class{constructor(e={}){ae(this,"baseConfig");this.baseConfig=e}validate(e){return this.baseConfig.required&&se(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}get required(){return this.baseConfig.required===!0}};function Je(e){return e===void 0}function TA(e){return e===null}function se(e){return Je(e)||TA(e)}var fe=class{constructor(e={}){ae(this,"value");this.value=new De(e)}validate(e){let t=this.value.validate(e);return t||(_A(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required}};function _A(e){return Je(e)||Kf(e)}function Kf(e){return typeof e=="boolean"}var oe=class{constructor(e={}){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(e)}validate(e){let t=this.value.validate(e);return t||(kA(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required}};function kA(e){return Je(e)||Yf(e)}function Yf(e){return typeof e=="number"&&!Number.isNaN(e)}var OA=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,z=class{constructor(e={}){ae(this,"value");ae(this,"config");this.config={emptyAllowed:!0,url:!1,...e},this.value=new De(this.config)}validate(e){let{emptyAllowed:t,url:r,regex:n,constrainTo:o,ISODate:i}=this.config,a=this.value.validate(e);if(a)return a;if(Je(e))return null;if(!_a(e))return"value is not a string.";if(!t&&!e.length)return"value is an empty string.";if(r)try{new URL(e)}catch{return"value is not a valid URL."}return n&&!n.test(e)?`value did not match provided regex ${n}`:o&&!o.includes(e)?`value should be one of: ${o.join(", ")}.`:i&&!(OA.test(e)&&new Date(e).toString()!=="Invalid Date")?"value is not a valid ISO8601 date string":null}get default(){return this.value.default}get required(){return this.value.required}};function _a(e){return Object.prototype.toString.call(e)==="[object String]"}var ne=class{constructor(e={}){ae(this,"config");this.config={options:{required:!1},values:{},...e}}validate(e){if(Je(e))return this.config.options.required?"value is required and is currently undefined":null;if(!Xf(e))return"value is not an object";for(let[r,n]of Object.entries(this.config.values))if(n.required&&se(e[r]))return`value does not contain ${r}`;let t="";for(let[r,n]of Object.entries(this.config.values)){let o=e[r],i=n.validate(o);i!==null&&(t+=` ${i}`)}return t===""?null:t}get default(){}get required(){return!!this.config.options.required}};function Xf(e){return e!==void 0&&typeof e=="object"}var Se=class{constructor(e={}){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(this.config)}validate(e){if(!se(e)&&!Array.isArray(e))return"value is not an array";let t=this.value.validate(e);if(t!==null)return t;if(se(e))return null;if(this.config.max!==void 0&&e.length>this.config.max)return`value contains more than ${this.config.max}`;if(this.config.min!==void 0&&e.length<this.config.min)return`value contains less than ${this.config.min}`;if(this.config.each!==void 0){let r="";return e.forEach(n=>{this.config.each.required&&se(n)&&(r=`value is null or undefined: ${e.join(",")}`);let o=this.validatePrimitiveValue(n,this.config.each);o!==null&&(r+=` ${o}`)}),r===""?null:r}return null}validatePrimitiveValue(e,t){return Kf(e)||_a(e)||Yf(e)||Xf(e)?t.validate(e):"value is not a primitive value"}get default(){}get required(){return this.value.required}};function Zf(e){return Array.isArray(e)}var Il=class{constructor(e){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(e)}validate(e){let t=this.value.validate(e);return t!==null?t:Je(e)||Object.values(this.config.enum).find(n=>n===e)?null:"value is not in enum."}get default(){return this.value.default}get required(){return this.value.required}};m();d();f();p();function Jf(e){return Array.isArray(e)}function ka(e){return e.trim()===""}var PA=new Set(["1",1,"yes",!0]);function Tl(){if(typeof navigator>"u"||typeof window>"u")return!1;let e=navigator,t=window;return[e.globalPrivacyControl,e.doNotTrack,e.msDoNotTrack,t.doNotTrack].some(r=>PA.has(r))}function em(e){let t={};for(let[r,n]of e)t[r]=n;return t}function ci(e){if(typeof e!="object"||!e)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Oa(e,t,r={}){let n;return(...o)=>{let i=r.isImmediate&&!n;if(clearTimeout(n),n=setTimeout(()=>{n=void 0,r.isImmediate||e.apply(void 0,o)},t),i)return e.apply(void 0,o)}}function NA(e){if(ka(e.openingDelimiter)||ka(e.closingDelimiter))throw Error("delimiters should be a non-empty string");if(se(e.content)||ka(e.content))return e.content;if(e.highlights.length===0)return zn(e.content);let t=e.content.length,r="",n=0;for(let o=0;o<e.highlights.length;o++){let i=e.highlights[o],a=i.offset,s=a+i.length;if(s>t)break;r+=zn(e.content.slice(n,a)),r+=e.openingDelimiter,r+=zn(e.content.slice(a,s)),r+=e.closingDelimiter,n=s}return n!==t&&(r+=zn(e.content.slice(n))),r}function FA(e,t){return e=zn(e),e.replace(/\[(.*?)\]|\{(.*?)\}|\((.*?)\)/g,(r,n,o,i)=>n?_l(n,t.notMatchDelimiters):o?_l(o,t.exactMatchDelimiters):i?_l(i,t.correctionDelimiters):r)}function _l(e,t){return t?t.open+e+t.close:e}function zn(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#x27;","`":"&#x60;"},r=`(?:${Object.keys(t).join("|")})`,n=RegExp(r),o=RegExp(r,"g");return n.test(e)?e.replace(o,i=>t[i]):e}m();d();f();p();var pm=qt(cm(),1);m();d();f();p();var $t=new Error("Failed to load reducers."),Wn=class extends Error{constructor(){super(),this.name="UnauthorizedTokenError",this.message="The token being used to perform the request is unauthorized. It may be expired or invalid."}},Jr=class extends Error{constructor(r,n){super();ae(this,"statusCode");this.name="Disconnected",this.message=`Client could not connect to the following URL: ${r}`,this.statusCode=n??0}};m();d();f();p();function um(e){let t=[];for(let r in e){let n=encodeURIComponent(r),o=encodeURIComponent(e[r]);t.push(`${n}=${o}`)}return t.join("&")}function lm(e){return typeof e!="object"||!e?!1:Object.values(e).every(ax)}function ax(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function dm(e){return e===429}var jt=class e{static call(t){return _asyncToGenerator(function*(){let r=sx(t),{logger:n}=t,o=yield e.preprocessRequest(r,t);n.info(o,"Platform request");let{url:i,...a}=o,s=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(){let c=yield A(i,a);if(dm(c.status))throw c;return c});return function s(){return _ref.apply(this,arguments)}}();try{let c=yield(0,pm.backOff)(s,{startingDelay:100,timeMultiple:2,maxDelay:800,numOfAttempts:4,jitter:"full",retry:function(){var _ref2=_asyncToGenerator(function*(u){let h=u&&dm(u.status);return h&&(n.info("Platform retrying request"),yield new Promise(v=>setTimeout(v,1e3))),h});return function retry(_x2){return _ref2.apply(this,arguments)}}()});switch(c.status){case 419:case 401:throw n.info("Platform renewing token"),new Wn;case 404:throw new Jr(i,c.status);default:return n.info({response:c,requestInfo:o},"Platform response"),c}}catch(c){return c.message==="Failed to fetch"?new Jr(i):c}})()}static preprocessRequest(t,r){return _asyncToGenerator(function*(){let{origin:n,preprocessRequest:o,logger:i,requestMetadata:a}=r,{signal:s,...c}=t,u=ci(c);try{let h=yield o(t,n,a);return{...t,...h}}catch(h){i.error(h,"Platform request preprocessing failed. Returning default request options.")}return u})()}};function It(e,t="prod",r="platform"){let n=t==="prod"?"":t,o=r==="platform"?"":`.${r}`;return`https://${e}${o}.org${n}.coveo.com`}function Kn(e,t,r="prod"){return e??It(t,r)}function wr(e,t="prod"){return`${It(e,t)}/rest/search/v2`}function Na(e,t="prod"){return`${It(e,t,"analytics")}/rest/organizations/${e}/events/v1`}function sx(e){let{url:t,method:r,requestParams:n,contentType:o,accessToken:i,signal:a}=e,s=e.method==="POST"||e.method==="PUT",c=cx(n,o);return{url:t,method:r,headers:{"Content-Type":o,Authorization:`Bearer ${i}`,...e.headers},...(s&&{body:c}),signal:a}}function cx(e,t){return t==="application/x-www-form-urlencoded"?lm(e)?um(e):"":JSON.stringify(e)}m();d();f();p();m();d();f();p();var Fa=e=>e;m();d();f();p();m();d();f();p();function Da(){return{answerSnippet:"",documentId:{contentIdKey:"",contentIdValue:""},question:"",relatedQuestions:[],score:0}}function Qt(){return{response:{results:[],searchUid:"",totalCountFiltered:0,facets:[],generateAutomaticFacets:{facets:[]},queryCorrections:[],triggers:[],questionAnswer:Da(),pipeline:"",splitTestRun:"",termsToHighlight:{},phrasesToHighlight:{},extendedResults:{}},duration:0,queryExecuted:"",error:null,automaticallyCorrected:!1,isLoading:!1,results:[],searchResponseId:"",requestId:"",questionAnswer:Da(),extendedResults:{},searchAction:void 0}}m();d();f();p();function Ar(e){let{url:t,accessToken:r,organizationId:n,authentication:o,...i}=e;return i}var xr=e=>{let{response:t}=e;return t.body?ux(e):lx(t)},ux=e=>px(e)?fx(e):dx(e)?e.body:{message:"unknown",statusCode:0,type:"unknown"},lx=e=>{let t=JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)));return{...t,message:`Client side error: ${t.message||""}`,statusCode:400,type:"ClientError"}};function dx(e){return e.body.statusCode!==void 0}function px(e){return e.body.exception!==void 0}var fx=e=>({message:e.body.exception.code,statusCode:e.response.status,type:e.body.exception.code});m();d();f();p();var Cr=class{constructor(){ae(this,"currentAbortController",null)}enqueue(t,r){var _this=this;return _asyncToGenerator(function*(){let n=_this.currentAbortController;_this.currentAbortController=new l.AbortController;let o=_this.currentAbortController;n&&(r.warnOnAbort&&r.logger.warn("Cancelling current pending search query"),n.abort());try{return yield t(o?.signal??null)}finally{_this.currentAbortController===o&&(_this.currentAbortController=null)}})()}};m();d();f();p();m();d();f();p();var di=class{constructor(t){ae(this,"_basePath");ae(this,"_params",{});this._basePath=t}addParam(t,r){this._params={...this.params,[t]:r}}get basePath(){return this._basePath}get params(){return this._params}get hasParams(){return Object.entries(this._params).length}get href(){return this.hasParams?`${this.basePath}?${Object.entries(this.params).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}`:this.basePath}};m();d();f();p();function fm(e){return((e.headers.get("content-type")||"").split(";").find(n=>n.indexOf("charset=")!==-1)||"").split("=")[1]||"UTF-8"}m();d();f();p();var ir=(e,t,r,n)=>{let o=new di(`${e.url}${n}`);return o.addParam("organizationId",e.organizationId),e.authentication&&o.addParam("authentication",e.authentication),{accessToken:e.accessToken,method:t,contentType:r,url:o.href,origin:"searchApiFetch"}};var mm=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(function*(e,t){let r=yield jt.call({...ir(e,"POST","application/x-www-form-urlencoded","/html"),requestParams:Ar(e),requestMetadata:{method:"html"},...t});if(r instanceof Error)throw r;let n=fm(r),o=yield r.arrayBuffer(),a=new TextDecoder(n).decode(o);return mx(a)?{success:a}:{error:xr({response:r,body:a})}});return function mm(_x3,_x4){return _ref3.apply(this,arguments)}}();function mx(e){return typeof e=="string"}m();d();f();p();function gx(e){return{statusCode:e.statusCode,type:e.name,message:e.message}}function hx(e){return{statusCode:e.code,type:e.name,message:e.message,ignored:!0}}function Ma(e,t){if(t&&e.name==="AbortError")return{error:hx(e)};if(e instanceof Jr)return{error:gx(e)};throw e}var qa=class{constructor(t){ae(this,"options",t);ae(this,"apiCallsQueues",{unknown:new Cr,mainSearch:new Cr,facetValues:new Cr,foldingCollection:new Cr,instantResults:new Cr})}plan(t){var _this2=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/plan"),requestParams:Ar(t),requestMetadata:{method:"plan"},..._this2.options});if(r instanceof Error)return Ma(r);let n=yield r.json();return vx(n)?{success:n}:{error:xr({response:r,body:n})}})()}querySuggest(t){var _this3=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/querySuggest"),requestMetadata:{method:"querySuggest"},requestParams:Ar(t),..._this3.options});if(r instanceof Error)return Ma(r);let n=yield r.json(),o={response:r,body:n};return yx(n)?{success:(yield _this3.options.postprocessQuerySuggestResponseMiddleware(o)).body}:{error:xr(o)}})()}search(t,r){var _this4=this;return _asyncToGenerator(function*(){let n=r?.origin??"unknown",o=yield _this4.apiCallsQueues[n].enqueue(s=>jt.call({...ir(t,"POST","application/json",""),requestParams:Ar(t),requestMetadata:{method:"search",origin:r?.origin},..._this4.options,signal:s??void 0}),{logger:_this4.options.logger,warnOnAbort:!r?.disableAbortWarning});if(o instanceof Error)return Ma(o,r?.disableAbortWarning);let i=yield o.json(),a={response:o,body:i};return gm(i)?(a.body=hm(i),{success:(yield _this4.options.postprocessSearchResponseMiddleware(a)).body}):{error:xr(a)}})()}facetSearch(t){var _this5=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/facet"),requestParams:Ar(t),requestMetadata:{method:"facetSearch"},..._this5.options});if(r instanceof Error)throw r;let n=yield r.json(),o={response:r,body:n};return(yield _this5.options.postprocessFacetSearchResponseMiddleware(o)).body})()}recommendations(t){var _this6=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json",""),requestParams:Ar(t),requestMetadata:{method:"recommendations"},..._this6.options});if(r instanceof Error)throw r;let n=yield r.json();if(gm(n)){let o={response:r,body:n};return o.body=hm(n),{success:(yield _this6.options.postprocessSearchResponseMiddleware(o)).body}}return{error:xr({response:r,body:n})}})()}html(t){var _this7=this;return _asyncToGenerator(function*(){return mm(t,{..._this7.options})})()}fieldDescriptions(t){var _this8=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"GET","application/json","/fields"),requestParams:{},requestMetadata:{method:"fieldDescriptions"},..._this8.options});if(r instanceof Error)throw r;let n=yield r.json();return Sx(n)?{success:n}:{error:xr({response:r,body:n})}})()}},ja=e=>e.success!==void 0,yt=e=>e.error!==void 0;function gm(e){return e.results!==void 0}function hm(e){let t=Da();return se(e.questionAnswer)?(e.questionAnswer=t,e):(e.questionAnswer={...t,...e.questionAnswer},e)}function yx(e){return e.completions!==void 0}function vx(e){return e.preprocessingOutput!==void 0}function Sx(e){return e.fields!==void 0}m();d();f();p();var ym=e=>e,vm=e=>e,Sm=e=>e;m();d();f();p();m();d();f();p();m();d();f();p();function et(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var bx=typeof Symbol=="function"&&Symbol.observable||"@@observable",bm=bx,Ll=()=>Math.random().toString(36).substring(7).split("").join("."),wx={INIT:`@@redux/INIT${Ll()}`,REPLACE:`@@redux/REPLACE${Ll()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ll()}`},La=wx;function Ht(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Ul(e,t,r){if(typeof e!="function")throw new Error(et(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(et(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(et(1));return r(Ul)(e,t)}let n=e,o=t,i=new Map,a=i,s=0,c=!1;function u(){a===i&&(a=new Map,i.forEach((E,R)=>{a.set(R,E)}))}function h(){if(c)throw new Error(et(3));return o}function v(E){if(typeof E!="function")throw new Error(et(4));if(c)throw new Error(et(5));let R=!0;u();let k=s++;return a.set(k,E),function(){if(R){if(c)throw new Error(et(6));R=!1,u(),a.delete(k),i=null}}}function C(E){if(!Ht(E))throw new Error(et(7));if(typeof E.type>"u")throw new Error(et(8));if(typeof E.type!="string")throw new Error(et(17));if(c)throw new Error(et(9));try{c=!0,o=n(o,E)}finally{c=!1}return(i=a).forEach(k=>{k()}),E}function g(E){if(typeof E!="function")throw new Error(et(10));n=E,C({type:La.REPLACE})}function y(){let E=v;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(et(11));function k(){let T=R;T.next&&T.next(h())}return k(),{unsubscribe:E(k)}},[bm](){return this}}}return C({type:La.INIT}),{dispatch:C,subscribe:v,getState:h,replaceReducer:g,[bm]:y}}function Ax(e){Object.keys(e).forEach(t=>{let r=e[t];if(typeof r(void 0,{type:La.INIT})>"u")throw new Error(et(12));if(typeof r(void 0,{type:La.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(et(13))})}function Yn(e){let t=Object.keys(e),r={};for(let a=0;a<t.length;a++){let s=t[a];typeof e[s]=="function"&&(r[s]=e[s])}let n=Object.keys(r),o,i;try{Ax(r)}catch(a){i=a}return function(s={},c){if(i)throw i;let u=!1,h={};for(let v=0;v<n.length;v++){let C=n[v],g=r[C],y=s[C],S=g(y,c);if(typeof S>"u"){let E=c&&c.type;throw new Error(et(14))}h[C]=S,u=u||S!==y}return u=u||n.length!==Object.keys(s).length,u?h:s}}function pi(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function wm(...e){return t=>(r,n)=>{let o=t(r,n),i=()=>{throw new Error(et(15))},a={getState:o.getState,dispatch:(c,...u)=>i(c,...u)},s=e.map(c=>c(a));return i=pi(...s)(o.dispatch),{...o,dispatch:i}}}function fi(e){return Ht(e)&&"type"in e&&typeof e.type=="string"}m();d();f();p();var Kl=Symbol.for("immer-nothing"),mi=Symbol.for("immer-draftable"),We=Symbol.for("immer-state");function tt(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var xt=Object,tn=xt.getPrototypeOf,gi="constructor",bi="prototype",Gl="configurable",Ga="enumerable",Va="writable",hi="value",ft=e=>!!e&&!!e[We];function ut(e){return e?_m(e)||Ai(e)||!!e[mi]||!!e[gi]?.[mi]||xi(e)||Ci(e):!1}var xx=xt[bi][gi].toString(),Am=new WeakMap;function _m(e){if(!e||!Zn(e))return!1;let t=tn(e);if(t===null||t===xt[bi])return!0;let r=xt.hasOwnProperty.call(t,gi)&&t[gi];if(r===Object)return!0;if(!en(r))return!1;let n=Am.get(r);return n===void 0&&(n=Function.toString.call(r),Am.set(r,n)),n===xx}function km(e){return ft(e)||tt(15,e),e[We].base_}function wi(e,t,r=!0){rn(e)===0?(r?Reflect.ownKeys(e):xt.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function rn(e){let t=e[We];return t?t.type_:Ai(e)?1:xi(e)?2:Ci(e)?3:0}var Xn=(e,t,r=rn(e))=>r===2?e.has(t):xt[bi].hasOwnProperty.call(e,t),ar=(e,t,r=rn(e))=>r===2?e.get(t):e[t],$a=(e,t,r,n=rn(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function Cx(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ai=Array.isArray,xi=e=>e instanceof Map,Ci=e=>e instanceof Set,Zn=e=>typeof e=="object",en=e=>typeof e=="function",Vl=e=>typeof e=="boolean";function Ex(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Rx=e=>Zn(e)?e?.[We]:null,sr=e=>e.copy_||e.base_;var Yl=e=>e.modified_?e.copy_:e.base_;function $l(e,t){if(xi(e))return new Map(e);if(Ci(e))return new Set(e);if(Ai(e))return Array[bi].slice.call(e);let r=_m(e);if(t===!0||t==="class_only"&&!r){let n=xt.getOwnPropertyDescriptors(e);delete n[We];let o=Reflect.ownKeys(n);for(let i=0;i<o.length;i++){let a=o[i],s=n[a];s[Va]===!1&&(s[Va]=!0,s[Gl]=!0),(s.get||s.set)&&(n[a]={[Gl]:!0,[Va]:!0,[Ga]:s[Ga],[hi]:e[a]})}return xt.create(tn(e),n)}else{let n=tn(e);if(n!==null&&r)return{...e};let o=xt.create(n);return xt.assign(o,e)}}function Xl(e,t=!1){return Ya(e)||ft(e)||!ut(e)||(rn(e)>1&&xt.defineProperties(e,{set:Ua,add:Ua,clear:Ua,delete:Ua}),xt.freeze(e),t&&wi(e,(r,n)=>{Xl(n,!0)},!1)),e}function Ix(){tt(2)}var Ua={[hi]:Ix};function Ya(e){return e===null||!Zn(e)?!0:xt.isFrozen(e)}var Qa="MapSet",Ha="Patches",xm="ArrayMethods",za={};function nn(e){let t=za[e];return t||tt(0,e),t}var Cm=e=>!!za[e];function Tx(e,t){za[e]||(za[e]=t)}var yi,Om=()=>yi,_x=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Cm(Qa)?nn(Qa):void 0,arrayMethodsPlugin_:Cm(xm)?nn(xm):void 0});function Em(e,t){t&&(e.patchPlugin_=nn(Ha),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ql(e){Hl(e),e.drafts_.forEach(kx),e.drafts_=null}function Hl(e){e===yi&&(yi=e.parent_)}var Rm=e=>yi=_x(yi,e);function kx(e){let t=e[We];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Im(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];if(e!==void 0&&e!==r){r[We].modified_&&(Ql(t),tt(4)),ut(e)&&(e=Tm(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(r[We].base_,e,t)}else e=Tm(t,r);return Ox(t,e,!0),Ql(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Kl?e:void 0}function Tm(e,t){if(Ya(t))return t;let r=t[We];if(!r)return Wa(t,e.handledSet_,e);if(!Xa(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);Fm(r,e)}return r.copy_}function Ox(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xl(t,r)}function Pm(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xa=(e,t)=>e.scope_===t,Px=[];function Nm(e,t,r,n){let o=sr(e),i=e.type_;if(n!==void 0&&ar(o,n,i)===t){$a(o,n,r,i);return}if(!e.draftLocations_){let s=e.draftLocations_=new Map;wi(o,(c,u)=>{if(ft(u)){let h=s.get(u)||[];h.push(c),s.set(u,h)}})}let a=e.draftLocations_.get(t)??Px;for(let s of a)$a(o,s,r,i)}function Nx(e,t,r){e.callbacks_.push(function(o){let i=t;if(!i||!Xa(i,o))return;o.mapSetPlugin_?.fixSetContents(i);let a=Yl(i);Nm(e,i.draft_??i,a,r),Fm(i,o)})}function Fm(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let o=n.getPath(e);o&&n.generatePatches_(e,o,t)}Pm(e)}}function Fx(e,t,r){let{scope_:n}=e;if(ft(r)){let o=r[We];Xa(o,n)&&o.callbacks_.push(function(){Ba(e);let a=Yl(o);Nm(e,r,a,t)})}else ut(r)&&e.callbacks_.push(function(){let i=sr(e);e.type_===3?i.has(r)&&Wa(r,n.handledSet_,n):ar(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Wa(ar(e.copy_,t,e.type_),n.handledSet_,n)})}function Wa(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ft(e)||t.has(e)||!ut(e)||Ya(e)||(t.add(e),wi(e,(n,o)=>{if(ft(o)){let i=o[We];if(Xa(i,r)){let a=Yl(i);$a(e,n,a,e.type_),Pm(i)}}else ut(o)&&Wa(o,t,r)})),e}function Dx(e,t){let r=Ai(e),n={type_:r?1:0,scope_:t?t.scope_:Om(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=n,i=Ka;r&&(o=[n],i=vi);let{revoke:a,proxy:s}=Proxy.revocable(o,i);return n.draft_=s,n.revoke_=a,[s,n]}var Ka={get(e,t){if(t===We)return e;let r=e.scope_.arrayMethodsPlugin_,n=e.type_===1&&typeof t=="string";if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);let o=sr(e);if(!Xn(o,t,e.type_))return qx(e,o,t);let i=o[t];if(e.finalized_||!ut(i)||n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&Ex(t))return i;if(i===Bl(e.base_,t)||Mx(e,t,i)){Ba(e);let a=e.type_===1?+t:t,s=Wl(e.scope_,i,e,a);return e.copy_[a]=s}return i},has(e,t){return t in sr(e)},ownKeys(e){return Reflect.ownKeys(sr(e))},set(e,t,r){let n=Dm(sr(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=Bl(sr(e),t),i=o?.[We];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Cx(r,o)&&(r!==void 0||Xn(e.base_,t,e.type_)))return!0;Ba(e),zl(e)}return e.copy_[t]===r&&(r!==void 0||Xn(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),Fx(e,t,r)),!0},deleteProperty(e,t){return Ba(e),Bl(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),zl(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=sr(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[Va]:!0,[Gl]:e.type_!==1||t!=="length",[Ga]:n[Ga],[hi]:r[t]}},defineProperty(){tt(11)},getPrototypeOf(e){return tn(e.base_)},setPrototypeOf(){tt(12)}},vi={};for(let e in Ka){let t=Ka[e];vi[e]=function(){let r=arguments;return r[0]=r[0][0],t.apply(this,r)}}vi.deleteProperty=function(e,t){return vi.set.call(this,e,t,void 0)};vi.set=function(e,t,r){return Ka.set.call(this,e[0],t,r,e[0])};function Bl(e,t){let r=e[We];return(r?sr(r):e)[t]}function Mx(e,t,r){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!ut(r)||r[We]?!1:e.baseRefs_.has(r)}function qx(e,t,r){let n=Dm(t,r);return n?hi in n?n[hi]:n.get?.call(e.draft_):void 0}function Dm(e,t){if(!(t in e))return;let r=tn(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=tn(r)}}function zl(e){e.modified_||(e.modified_=!0,e.parent_&&zl(e.parent_))}function Ba(e){e.copy_||(e.assigned_=new Map,e.copy_=$l(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var jx=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(en(t)&&!en(r)){let i=r;r=t;let a=this;return function(c=i,...u){return a.produce(c,h=>r.call(this,h,...u))}}en(r)||tt(6),n!==void 0&&!en(n)&&tt(7);let o;if(ut(t)){let i=Rm(this),a=Wl(i,t,void 0),s=!0;try{o=r(a),s=!1}finally{s?Ql(i):Hl(i)}return Em(i,n),Im(o,i)}else if(!t||!Zn(t)){if(o=r(t),o===void 0&&(o=t),o===Kl&&(o=void 0),this.autoFreeze_&&Xl(o,!0),n){let i=[],a=[];nn(Ha).generateReplacementPatches_(t,o,{patches_:i,inversePatches_:a}),n(i,a)}return o}else tt(1,t)},this.produceWithPatches=(t,r)=>{if(en(t))return(a,...s)=>this.produceWithPatches(a,c=>t(c,...s));let n,o;return[this.produce(t,r,(a,s)=>{n=a,o=s}),n,o]},Vl(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Vl(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Vl(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ut(e)||tt(8),ft(e)&&(e=Za(e));let t=Rm(this),r=Wl(t,e,void 0);return r[We].isManual_=!0,Hl(t),r}finishDraft(e,t){let r=e&&e[We];(!r||!r.isManual_)&&tt(9);let{scope_:n}=r;return Em(n,t),Im(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=nn(Ha).applyPatches_;return ft(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Wl(e,t,r,n){let[o,i]=xi(t)?nn(Qa).proxyMap_(t,r):Ci(t)?nn(Qa).proxySet_(t,r):Dx(t,r);return(r?.scope_??Om()).drafts_.push(o),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?Nx(r,i,n):i.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:u}=c;i.modified_&&u&&u.generatePatches_(i,[],c)}),o}function Za(e){return ft(e)||tt(10,e),Mm(e)}function Mm(e){if(!ut(e)||Ya(e))return e;let t=e[We],r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=$l(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=$l(e,!0);return wi(r,(o,i)=>{$a(r,o,Mm(i))},n),t&&(t.finalized_=!1),r}function qm(){function t(y,S=[]){if(y.key_!==void 0){let E=y.parent_.copy_??y.parent_.base_,R=Rx(ar(E,y.key_)),k=ar(E,y.key_);if(k===void 0||k!==y.draft_&&k!==y.base_&&k!==y.copy_||R!=null&&R.base_!==y.base_)return null;let I=y.parent_.type_===3,T;if(I){let _=y.parent_;T=Array.from(_.drafts_.keys()).indexOf(y.key_)}else T=y.key_;if(!(I&&E.size>T||Xn(E,T)))return null;S.push(T)}if(y.parent_)return t(y.parent_,S);S.reverse();try{r(y.copy_,S)}catch{return null}return S}function r(y,S){let E=y;for(let R=0;R<S.length-1;R++){let k=S[R];if(E=ar(E,k),!Zn(E)||E===null)throw new Error(`Cannot resolve path at '${S.join("/")}'`)}return E}let n="replace",o="add",i="remove";function a(y,S,E){if(y.scope_.processedForPatches_.has(y))return;y.scope_.processedForPatches_.add(y);let{patches_:R,inversePatches_:k}=E;switch(y.type_){case 0:case 2:return c(y,S,R,k);case 1:return s(y,S,R,k);case 3:return u(y,S,R,k)}}function s(y,S,E,R){let{base_:k,assigned_:I}=y,T=y.copy_;T.length<k.length&&([k,T]=[T,k],[E,R]=[R,E]);let _=y.allIndicesReassigned_===!0;for(let D=0;D<k.length;D++){let G=T[D],V=k[D];if((_||I?.get(D.toString()))&&G!==V){let L=G?.[We];if(L&&L.modified_)continue;let q=S.concat([D]);E.push({op:n,path:q,value:g(G)}),R.push({op:n,path:q,value:g(V)})}}for(let D=k.length;D<T.length;D++){let G=S.concat([D]);E.push({op:o,path:G,value:g(T[D])})}for(let D=T.length-1;k.length<=D;--D){let G=S.concat([D]);R.push({op:i,path:G})}}function c(y,S,E,R){let{base_:k,copy_:I,type_:T}=y;wi(y.assigned_,(_,D)=>{let G=ar(k,_,T),V=ar(I,_,T),j=D?Xn(k,_)?n:o:i;if(G===V&&j===n)return;let L=S.concat(_);E.push(j===i?{op:j,path:L}:{op:j,path:L,value:g(V)}),R.push(j===o?{op:i,path:L}:j===i?{op:o,path:L,value:g(G)}:{op:n,path:L,value:g(G)})})}function u(y,S,E,R){let{base_:k,copy_:I}=y,T=0;k.forEach(_=>{if(!I.has(_)){let D=S.concat([T]);E.push({op:i,path:D,value:_}),R.unshift({op:o,path:D,value:_})}T++}),T=0,I.forEach(_=>{if(!k.has(_)){let D=S.concat([T]);E.push({op:o,path:D,value:_}),R.unshift({op:i,path:D,value:_})}T++})}function h(y,S,E){let{patches_:R,inversePatches_:k}=E;R.push({op:n,path:[],value:S===Kl?void 0:S}),k.push({op:n,path:[],value:y})}function v(y,S){return S.forEach(E=>{let{path:R,op:k}=E,I=y;for(let G=0;G<R.length-1;G++){let V=rn(I),j=R[G];typeof j!="string"&&typeof j!="number"&&(j=""+j),(V===0||V===1)&&(j==="__proto__"||j===gi)&&tt(19),en(I)&&j===bi&&tt(19),I=ar(I,j),(I===null||!Zn(I))&&tt(18,R.join("/"))}let T=rn(I),_=C(E.value),D=R[R.length-1];switch(k){case n:switch(T){case 2:return I.set(D,_);case 3:tt(16);default:return I[D]=_}case o:switch(T){case 1:return D==="-"?I.push(_):I.splice(D,0,_);case 2:return I.set(D,_);case 3:return I.add(_);default:return I[D]=_}case i:switch(T){case 1:return I.splice(D,1);case 2:return I.delete(D);case 3:return I.delete(E.value);default:return delete I[D]}default:tt(17,k)}}),y}function C(y){if(!ut(y))return y;if(Ai(y))return y.map(C);if(xi(y))return new Map(Array.from(y.entries()).map(([E,R])=>[E,C(R)]));if(Ci(y))return new Set(Array.from(y).map(C));let S=Object.create(tn(y));for(let E in y)S[E]=C(y[E]);return Xn(y,mi)&&(S[mi]=y[mi]),S}function g(y){return ft(y)?C(y):y}Tx(Ha,{applyPatches_:v,generatePatches_:a,generateReplacementPatches_:h,getPath:t})}var Lx=w.Iterator,rq=typeof Lx?.from=="function";var Si=new jx,on=Si.produce,Zl=Si.produceWithPatches.bind(Si);var Jl=Si.applyPatches.bind(Si);m();d();f();p();function Ux(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Vx(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){let r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var jm=e=>Array.isArray(e)?e:[e];function Bx(e){let t=Array.isArray(e[0])?e[0]:e;return Vx(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Gx(e,t){let r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var $x=class{constructor(e){this.value=e}deref(){return this.value}},Qx=()=>typeof WeakRef>"u"?$x:WeakRef,Um=Qx(),Hx=0,Lm=1;function Ja(){return{s:Hx,v:void 0,o:null,p:null}}function zx(e){return e instanceof Um?e.deref():e}function Ei(e,t={}){let r=Ja(),{resultEqualityCheck:n}=t,o,i=0;function a(){let s=r,{length:c}=arguments;for(let v=0,C=c;v<C;v++){let g=arguments[v];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=s.o;y===null&&(s.o=y=new WeakMap);let S=y.get(g);S===void 0?(s=Ja(),y.set(g,s)):s=S}else{let y=s.p;y===null&&(s.p=y=new Map);let S=y.get(g);S===void 0?(s=Ja(),y.set(g,s)):s=S}}let u=s,h;if(s.s===Lm)h=s.v;else if(h=e.apply(null,arguments),i++,n){let v=zx(o);v!=null&&n(v,h)&&(h=v,i!==0&&i--),o=typeof h=="object"&&h!==null||typeof h=="function"?new Um(h):h}return u.s=Lm,u.v=h,h}return a.clearCache=()=>{r=Ja(),a.resetResultsCount()},a.resultsCount=()=>i,a.resetResultsCount=()=>{i=0},a}function Wx(e,...t){let r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...o)=>{let i=0,a=0,s,c={},u=o.pop();typeof u=="object"&&(c=u,u=o.pop()),Ux(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);let h={...r,...c},{memoize:v,memoizeOptions:C=[],argsMemoize:g=Ei,argsMemoizeOptions:y=[]}=h,S=jm(C),E=jm(y),R=Bx(o),k=v(function(){return i++,u.apply(null,arguments)},...S),I=!0,T=g(function(){a++;let D=Gx(R,arguments);return s=k.apply(null,D),s},...E);return Object.assign(T,{resultFunc:u,memoizedResultFunc:k,dependencies:R,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>s,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:v,argsMemoize:g})};return Object.assign(n,{withTypes:()=>n}),n}var $e=Wx(Ei);m();d();f();p();function Vm(e){return({dispatch:r,getState:n})=>o=>i=>typeof i=="function"?i(r,n,e):o(i)}var Bm=Vm(),Gm=Vm;var Kx=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pi:pi.apply(null,arguments)},Rq=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},Yx=e=>e&&typeof e.match=="function";function O(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(mt(0));return{type:e,payload:o.payload,...("meta"in o&&{meta:o.meta}),...("error"in o&&{error:o.error})}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>fi(n)&&n.type===e,r}var Xm=class Ri extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Ri.prototype)}static get[Symbol.species](){return Ri}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Ri(...t[0].concat(this)):new Ri(...t.concat(this))}};function $m(e){return ut(e)?on(e,()=>{}):e}function es(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function Xx(e){return typeof e=="boolean"}var Zx=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=t??{},a=new Xm;return r&&(Xx(r)?a.push(Bm):a.push(Gm(r.extraArgument))),a},Ii="RTK_autoBatch",to=()=>e=>({payload:e,meta:{[Ii]:!0}}),Qm=e=>t=>{setTimeout(t,e)},Jx=(e,t)=>r=>{let n=!1,o=()=>{n||(n=!0,cancelAnimationFrame(i),clearTimeout(a),r())},i=e(o),a=setTimeout(o,t)},eC=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,i=!1,a=!1,s=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?Jx(window.requestAnimationFrame,100):Qm(10):e.type==="callback"?e.queueNotification:Qm(e.timeout),u=()=>{a=!1,i&&(i=!1,s.forEach(h=>h()))};return Object.assign({},n,{subscribe(h){let v=()=>o&&h(),C=n.subscribe(v);return s.add(h),()=>{C(),s.delete(h)}},dispatch(h){try{return o=!h?.meta?.[Ii],i=!o,i&&(a||(a=!0,c(u))),n.dispatch(h)}finally{o=!0}}})},tC=e=>function(r){let{autoBatch:n=!0}=r??{},o=new Xm(e);return n&&o.push(eC(typeof n=="object"?n:void 0)),o};function Zm(e){let t=Zx(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=e||{},c;if(typeof r=="function")c=r;else if(Ht(r))c=Yn(r);else throw new Error(mt(1));let u;typeof n=="function"?u=n(t):u=t();let h=pi;o&&(h=Kx({trace:!1,...(typeof o=="object"&&o)}));let v=wm(...u),C=tC(v),g=typeof s=="function"?s(C):C(),y=h(...g);return Ul(c,a,y)}function Jm(e){let t={},r=[],n,o={addCase(i,a){let s=typeof i=="string"?i:i.type;if(!s)throw new Error(mt(28));if(s in t)throw new Error(mt(29));return t[s]=a,o},addAsyncThunk(i,a){return a.pending&&(t[i.pending.type]=a.pending),a.rejected&&(t[i.rejected.type]=a.rejected),a.fulfilled&&(t[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),o},addMatcher(i,a){return r.push({matcher:i,reducer:a}),o},addDefaultCase(i){return n=i,o}};return e(o),[t,r,n]}function rC(e){return typeof e=="function"}function Be(e,t){let[r,n,o]=Jm(t),i;if(rC(e))i=()=>$m(e());else{let s=$m(e);i=()=>s}function a(s=i(),c){let u=[r[c.type],...n.filter(({matcher:h})=>h(c)).map(({reducer:h})=>h)];return u.filter(h=>!!h).length===0&&(u=[o]),u.reduce((h,v)=>{if(v)if(ft(h)){let g=v(h,c);return g===void 0?h:g}else{if(ut(h))return on(h,C=>v(C,c));{let C=v(h,c);if(C===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return C}}return h},s)}return a.getInitialState=i,a}var eg=(e,t)=>Yx(e)?e.match(t):e(t);function zt(...e){return t=>e.some(r=>eg(r,t))}function eo(...e){return t=>e.every(r=>eg(r,t))}function os(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function Ti(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function is(...e){return e.length===0?t=>os(t,["pending"]):Ti(e)?zt(...e.map(t=>t.pending)):is()(e[0])}function sn(...e){return e.length===0?t=>os(t,["rejected"]):Ti(e)?zt(...e.map(t=>t.rejected)):sn()(e[0])}function _i(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?eo(sn(...e),t):Ti(e)?eo(sn(...e),t):_i()(e[0])}function cr(...e){return e.length===0?t=>os(t,["fulfilled"]):Ti(e)?zt(...e.map(t=>t.fulfilled)):cr()(e[0])}function as(...e){return e.length===0?t=>os(t,["pending","fulfilled","rejected"]):Ti(e)?zt(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):as()(e[0])}var nC="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",ki=(e=21)=>{let t="",r=e;for(;r--;)t+=nC[Math.random()*64|0];return t},oC=["name","message","stack","code"],ed=class{constructor(e,t){ae(this,"payload");ae(this,"meta");ae(this,"_type");this.payload=e,this.meta=t}},Hm=class{constructor(e,t){ae(this,"payload");ae(this,"meta");ae(this,"_type");this.payload=e,this.meta=t}},iC=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of oC)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},zm="External signal was aborted",Ie=(()=>{function e(t,r,n){let o=O(t+"/fulfilled",(c,u,h,v)=>({payload:c,meta:{...(v||{}),arg:h,requestId:u,requestStatus:"fulfilled"}})),i=O(t+"/pending",(c,u,h)=>({payload:void 0,meta:{...(h||{}),arg:u,requestId:c,requestStatus:"pending"}})),a=O(t+"/rejected",(c,u,h,v,C)=>({payload:v,error:(n&&n.serializeError||iC)(c||"Rejected"),meta:{...(C||{}),arg:h,requestId:u,rejectedWithValue:!!v,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function s(c,{signal:u}={}){return(h,v,C)=>{let g=n?.idGenerator?n.idGenerator(c):ki(),y=new l.AbortController,S,E;function R(I){E=I,y.abort()}u&&(u.aborted?R(zm):u.addEventListener("abort",()=>R(zm),{once:!0}));let k=_asyncToGenerator(function*(){let I;try{let _=n?.condition?.(c,{getState:v,extra:C});if(sC(_)&&(_=yield _),_===!1||y.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let D=new Promise((G,V)=>{S=()=>{V({name:"AbortError",message:E||"Aborted"})},y.signal.addEventListener("abort",S,{once:!0})});h(i(g,c,n?.getPendingMeta?.({requestId:g,arg:c},{getState:v,extra:C}))),I=yield Promise.race([D,Promise.resolve(r(c,{dispatch:h,getState:v,extra:C,requestId:g,signal:y.signal,abort:R,rejectWithValue:(G,V)=>new ed(G,V),fulfillWithValue:(G,V)=>new Hm(G,V)})).then(G=>{if(G instanceof ed)throw G;return G instanceof Hm?o(G.payload,g,c,G.meta):o(G,g,c)})])}catch(_){I=_ instanceof ed?a(null,g,c,_.payload,_.meta):a(_,g,c)}finally{S&&y.signal.removeEventListener("abort",S)}return n&&!n.dispatchConditionRejection&&a.match(I)&&I.meta.condition||h(I),I})();return Object.assign(k,{abort:R,requestId:g,arg:c,unwrap(){return k.then(aC)}})}}return Object.assign(s,{pending:i,rejected:a,fulfilled:o,settled:zt(a,o),typePrefix:t})}return e.withTypes=()=>e,e})();function aC(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function sC(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var tg=Symbol.for("rtk-slice-createasyncthunk"),Tq={[tg]:Ie};function cC(e,t){return`${e}/${t}`}function uC({creators:e}={}){let t=e?.asyncThunk?.[tg];return function(n){let{name:o,reducerPath:i=o}=n;if(!o)throw new Error(mt(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(dC()):n.reducers)||{},s=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(I,T){let _=typeof I=="string"?I:I.type;if(!_)throw new Error(mt(12));if(_ in c.sliceCaseReducersByType)throw new Error(mt(13));return c.sliceCaseReducersByType[_]=T,u},addMatcher(I,T){return c.sliceMatchers.push({matcher:I,reducer:T}),u},exposeAction(I,T){return c.actionCreators[I]=T,u},exposeCaseReducer(I,T){return c.sliceCaseReducersByName[I]=T,u}};s.forEach(I=>{let T=a[I],_={reducerName:I,type:cC(o,I),createNotation:typeof n.reducers=="function"};fC(T)?gC(_,T,u,t):pC(_,T,u)});function h(){let[I={},T=[],_=void 0]=typeof n.extraReducers=="function"?Jm(n.extraReducers):[n.extraReducers],D={...I,...c.sliceCaseReducersByType};return Be(n.initialState,G=>{for(let V in D)G.addCase(V,D[V]);for(let V of c.sliceMatchers)G.addMatcher(V.matcher,V.reducer);for(let V of T)G.addMatcher(V.matcher,V.reducer);_&&G.addDefaultCase(_)})}let v=I=>I,C=new Map,g=new WeakMap,y;function S(I,T){return y||(y=h()),y(I,T)}function E(){return y||(y=h()),y.getInitialState()}function R(I,T=!1){function _(G){let V=G[I];return typeof V>"u"&&T&&(V=es(g,_,E)),V}function D(G=v){let V=es(C,T,()=>new WeakMap);return es(V,G,()=>{let j={};for(let[L,q]of Object.entries(n.selectors??{}))j[L]=lC(q,G,()=>es(g,G,E),T);return j})}return{reducerPath:I,getSelectors:D,get selectors(){return D(_)},selectSlice:_}}let k={name:o,reducer:S,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:E,...R(i),injectInto(I,{reducerPath:T,..._}={}){let D=T??i;return I.inject({reducerPath:D,reducer:S},_),{...k,...R(D,!0)}}};return k}}function lC(e,t,r,n){function o(i,...a){let s=t(i);return typeof s>"u"&&n&&(s=r()),e(s,...a)}return o.unwrapped=e,o}var cn=uC();function dC(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function pC({type:e,reducerName:t,createNotation:r},n,o){let i,a;if("reducer"in n){if(r&&!mC(n))throw new Error(mt(17));i=n.reducer,a=n.prepare}else i=n;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,a?O(e,a):O(e))}function fC(e){return e._reducerDefinitionType==="asyncThunk"}function mC(e){return e._reducerDefinitionType==="reducerWithPrepare"}function gC({type:e,reducerName:t},r,n,o){if(!o)throw new Error(mt(18));let{payloadCreator:i,fulfilled:a,pending:s,rejected:c,settled:u,options:h}=r,v=o(e,i,h);n.exposeAction(t,v),a&&n.addCase(v.fulfilled,a),s&&n.addCase(v.pending,s),c&&n.addCase(v.rejected,c),u&&n.addMatcher(v.settled,u),n.exposeCaseReducer(t,{fulfilled:a||ts,pending:s||ts,rejected:c||ts,settled:u||ts})}function ts(){}var hC="task",rg="listener",ng="completed",nd="cancelled",yC=`task-${nd}`,vC=`task-${ng}`,td=`${rg}-${nd}`,SC=`${rg}-${ng}`,ss=class{constructor(e){ae(this,"code");ae(this,"name","TaskAbortError");ae(this,"message");this.code=e,this.message=`${hC} ${nd} (reason: ${e})`}},od=(e,t)=>{if(typeof e!="function")throw new TypeError(mt(32))},rs=()=>{},og=(e,t=rs)=>(e.catch(t),e),ig=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),an=e=>{if(e.aborted)throw new ss(e.reason)};function ag(e,t){let r=rs;return new Promise((n,o)=>{let i=()=>o(new ss(e.reason));if(e.aborted){i();return}r=ig(e,i),t.finally(()=>r()).then(n,o)}).finally(()=>{r=rs})}var bC=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(function*(e,t){try{return yield Promise.resolve(),{status:"ok",value:yield e()}}catch(r){return{status:r instanceof ss?"cancelled":"rejected",error:r}}finally{t?.()}});return function bC(_x5,_x6){return _ref5.apply(this,arguments)}}(),ns=e=>t=>og(ag(e,t).then(r=>(an(e),r))),sg=e=>{let t=ns(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:Jn}=Object,Wm={},cs="listenerMiddleware",wC=(e,t)=>{let r=n=>ig(e,()=>n.abort(e.reason));return(n,o)=>{od(n,"taskExecutor");let i=new l.AbortController;r(i);let a=bC(/*#__PURE__*/_asyncToGenerator(function*(){an(e),an(i.signal);let s=yield n({pause:ns(i.signal),delay:sg(i.signal),signal:i.signal});return an(i.signal),s}),()=>i.abort(vC));return o?.autoJoin&&t.push(a.catch(rs)),{result:ns(e)(a),cancel(){i.abort(yC)}}}},AC=(e,t)=>{let r=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(function*(n,o){an(t);let i=()=>{},s=[new Promise((c,u)=>{let h=e({predicate:n,effect:(v,C)=>{C.unsubscribe(),c([v,C.getState(),C.getOriginalState()])}});i=()=>{h(),u()}})];o!=null&&s.push(new Promise(c=>setTimeout(c,o,null)));try{let c=yield ag(t,Promise.race(s));return an(t),c}finally{i()}});return function r(_x7,_x8){return _ref7.apply(this,arguments)}}();return(n,o)=>og(r(n,o))},cg=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:i}=e;if(t)o=O(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(mt(21));return od(i,"options.listener"),{predicate:o,type:t,effect:i}},ug=Jn(e=>{let{type:t,predicate:r,effect:n}=cg(e);return{id:ki(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(mt(22))}}},{withTypes:()=>ug}),Km=(e,t)=>{let{type:r,effect:n,predicate:o}=cg(t);return Array.from(e.values()).find(i=>(typeof r=="string"?i.type===r:i.predicate===o)&&i.effect===n)},rd=e=>{e.pending.forEach(t=>{t.abort(td)})},xC=(e,t)=>()=>{for(let r of t.keys())rd(r);e.clear()},Ym=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},lg=Jn(O(`${cs}/add`),{withTypes:()=>lg}),CC=O(`${cs}/removeAll`),dg=Jn(O(`${cs}/remove`),{withTypes:()=>dg}),EC=(...e)=>{console.error(`${cs}/error`,...e)},pg=(e={})=>{let t=new Map,r=new Map,n=g=>{let y=r.get(g)??0;r.set(g,y+1)},o=g=>{let y=r.get(g)??1;y===1?r.delete(g):r.set(g,y-1)},{extra:i,onError:a=EC}=e;od(a,"onError");let s=g=>(g.unsubscribe=()=>t.delete(g.id),t.set(g.id,g),y=>{g.unsubscribe(),y?.cancelActive&&rd(g)}),c=g=>{let y=Km(t,g)??ug(g);return s(y)};Jn(c,{withTypes:()=>c});let u=g=>{let y=Km(t,g);return y&&(y.unsubscribe(),g.cancelActive&&rd(y)),!!y};Jn(u,{withTypes:()=>u});let h=/*#__PURE__*/function(){var _ref8=_asyncToGenerator(function*(g,y,S,E){let R=new l.AbortController,k=AC(c,R.signal),I=[];try{g.pending.add(R),n(g),yield Promise.resolve(g.effect(y,Jn({},S,{getOriginalState:E,condition:(T,_)=>k(T,_).then(Boolean),take:k,delay:sg(R.signal),pause:ns(R.signal),extra:i,signal:R.signal,fork:wC(R.signal,I),unsubscribe:g.unsubscribe,subscribe:()=>{t.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((T,_,D)=>{T!==R&&(T.abort(td),D.delete(T))})},cancel:()=>{R.abort(td),g.pending.delete(R)},throwIfCancelled:()=>{an(R.signal)}})))}catch(T){T instanceof ss||Ym(a,T,{raisedBy:"effect"})}finally{yield Promise.all(I),R.abort(SC),o(g),g.pending.delete(R)}});return function h(_x9,_x0,_x1,_x10){return _ref8.apply(this,arguments)}}(),v=xC(t,r);return{middleware:g=>y=>S=>{if(!fi(S))return y(S);if(lg.match(S))return c(S.payload);if(CC.match(S)){v();return}if(dg.match(S))return u(S.payload);let E=g.getState(),R=()=>{if(E===Wm)throw new Error(mt(23));return E},k;try{if(k=y(S),t.size>0){let I=g.getState(),T=Array.from(t.values());for(let _ of T){let D=!1;try{D=_.predicate(S,I,E)}catch(G){D=!1,Ym(a,G,{raisedBy:"predicate"})}D&&h(_,S,g,R)}}}finally{E=Wm}return k},startListening:c,stopListening:u,clearListeners:v}};function mt(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}m();d();f();p();var Y=new z({required:!0,emptyAllowed:!1}),rt=new z({required:!1,emptyAllowed:!1}),nt=new z({required:!0,emptyAllowed:!0}),Uq=new z({required:!1,emptyAllowed:!0}),us=new Se({each:Y,required:!0}),fg=new z({required:!1,emptyAllowed:!1,regex:/^\d+\.\d+\.\d+$/}),mg=new z({required:!1,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),Vq=new z({required:!0,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),ur=({message:e,name:t,stack:r})=>({message:e,name:t,stack:r}),Tt=(e,t)=>{if("required"in t)return{payload:new ht({value:t}).validate({value:e}).value};let o=new ne({options:{required:!0},values:t}).validate(e);if(o)throw new si(o);return{payload:e}},B=(e,t)=>{try{return Tt(e,t)}catch(r){return{payload:e,error:ur(r)}}},gg=(e,t,r,n)=>{let o=`Check the initialState of ${n}`;return yg(e,t,r,o,"Controller initialization error")},hg=(e,t,r,n)=>{let o=`Check the options of ${n}`;return yg(e,t,r,o,"Controller initialization error")},yg=(e,t,r,n,o)=>{try{return t.validate(r,n)}catch(i){throw e.logger.error(i,o),i}};m();d();f();p();var ro="3.55.3",vg=["@coveo/atomic","@coveo/quantic"];var id=()=>rt,Sg=()=>Y,Er=O("configuration/updateBasicConfiguration",e=>B(e,{accessToken:rt,environment:new z({required:!1,constrainTo:["prod","hipaa","stg","dev"]}),organizationId:rt})),Wt=O("configuration/updateSearchConfiguration",e=>B(e,{proxyBaseUrl:new z({required:!1,url:!0}),pipeline:new z({required:!1,emptyAllowed:!0}),searchHub:rt,timezone:rt,locale:rt,authenticationProviders:new Se({required:!1,each:Y})})),RC={enabled:new fe({default:!0}),originContext:id(),originLevel2:id(),originLevel3:id(),proxyBaseUrl:new z({required:!1,url:!0}),runtimeEnvironment:new De,anonymous:new fe({default:!1}),deviceId:rt,userDisplayName:rt,documentLocation:rt,trackingId:mg,analyticsMode:new z({constrainTo:["legacy","next"],required:!1,default:"next"}),source:new ne({options:{required:!1},values:vg.reduce((e,t)=>(e[t]=fg,e),{})})},no=O("configuration/updateAnalyticsConfiguration",e=>B(e,RC)),oo=O("configuration/analytics/disable"),io=O("configuration/analytics/enable"),ls=O("configuration/analytics/originlevel2",e=>B(e,{originLevel2:Sg()})),ds=O("configuration/analytics/originlevel3",e=>B(e,{originLevel3:Sg()})),bg=O("knowledge/setAgentId",e=>B(e,new z({required:!0})));m();d();f();p();m();d();f();p();m();d();f();p();var wg={q:new z,enableQuerySyntax:new fe,aq:new z,cq:new z,firstResult:new oe({min:0}),numberOfResults:new oe({min:0}),sortCriteria:new z,f:new ne,fExcluded:new ne,cf:new ne,nf:new ne,mnf:new ne,df:new ne,debug:new fe,sf:new ne,tab:new z,af:new ne};var Rr=O("searchParameters/restore",e=>B(e,wg)),Ag=O("searchParameters/restoreTab",e=>B(e,Y));m();d();f();p();var ps=O("debug/enable"),fs=O("debug/disable");m();d();f();p();var ms=()=>!1;var gs=Be(ms(),e=>{e.addCase(ps,()=>!0).addCase(fs,()=>!1).addCase(Rr,(t,r)=>r.payload.debug??t)});m();d();f();p();var ao=O("pipeline/set",e=>B(e,new z({required:!0,emptyAllowed:!0})));m();d();f();p();m();d();f();p();var IC=O("history/undo"),TC=O("history/redo"),Kt=O("history/snapshot"),Yj=Ie("history/back",/*#__PURE__*/function(){var _ref9=_asyncToGenerator(function*(e,{dispatch:t}){t(IC()),yield t(vt())});return function(_x11,_x12){return _ref9.apply(this,arguments)}}()),Xj=Ie("history/forward",/*#__PURE__*/function(){var _ref0=_asyncToGenerator(function*(e,{dispatch:t}){t(TC()),yield t(vt())});return function(_x13,_x14){return _ref0.apply(this,arguments)}}()),vt=Ie("history/change",/*#__PURE__*/function(){var _ref1=_asyncToGenerator(function*(e,{getState:t}){return t().history.present});return function(_x15,_x16){return _ref1.apply(this,arguments)}}());m();d();f();p();var Ir=()=>"";var so=Be(Ir(),e=>{e.addCase(ao,(t,r)=>r.payload).addCase(vt.fulfilled,(t,r)=>r.payload?.pipeline??t).addCase(Wt,(t,r)=>r.payload.pipeline||t)});m();d();f();p();m();d();f();p();var hs=O("app/setError");m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();function _C(){return typeof navigator<"u"}function xg(){try{return typeof localStorage<"u"}catch{return!1}}function Cg(){try{return typeof sessionStorage<"u"}catch{return!1}}function Eg(){return _C()&&navigator.cookieEnabled}m();d();f();p();var co=class e{static set(t,r,n){var o,i,a,s;n&&(i=new Date,i.setTime(i.getTime()+n)),s=window.location.hostname,s.indexOf(".")===-1?Rg(t,r,i):(a=s.split("."),o=a[a.length-2]+"."+a[a.length-1],Rg(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function Rg(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"+(window.location.protocol==="https:"?";Secure":"")}function Ig(){return xg()?localStorage:Eg()?new ys:Cg()?sessionStorage:new ad}var ys=class e{getItem(t){return co.get(`${e.prefix}${t}`)}removeItem(t){co.erase(`${e.prefix}${t}`)}setItem(t,r,n){co.set(`${e.prefix}${t}`,r,n)}};ys.prefix="coveo_";var ad=class{getItem(t){return null}removeItem(t){}setItem(t,r){}};var vs="__coveo.analytics.history",kC=20,OC=1e3*60,PC=75,Ss=class{constructor(t){this.store=t||Ig()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){var _this9=this;return _asyncToGenerator(function*(){t.internalTime=new Date().getTime(),t=_this9.cropQueryElement(_this9.stripEmptyQuery(t));let r=yield _this9.getHistoryWithInternalTimeAsync();r!=null?_this9.isValidEntry(t)&&_this9.setHistory([t].concat(r)):_this9.setHistory([t])})()}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){var _this0=this;return _asyncToGenerator(function*(){let t=yield _this0.getHistoryWithInternalTimeAsync();return _this0.stripEmptyQueries(_this0.stripInternalTime(t))})()}getHistoryWithInternalTime(){try{let t=this.store.getItem(vs);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){var _this1=this;return _asyncToGenerator(function*(){try{let t=yield _this1.store.getItem(vs);return t?JSON.parse(t):[]}catch{return[]}})()}setHistory(t){try{this.store.setItem(vs,JSON.stringify(t.slice(0,kC)))}catch{}}clear(){try{this.store.removeItem(vs)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,PC)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>OC:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var un=class un extends Ss{static getInstance(t){return un.instance||(un.instance=new un(t)),un.instance}constructor(t){super(t)}};ae(un,"instance",null);var gt=un;m();d();f();p();m();d();f();p();var uo=$e(e=>e.source,e=>Object.entries(e).map(([t,r])=>`${t}@${r}`).concat(`@coveo/headless@${ro}`));m();d();f();p();m();d();f();p();function lr(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function U(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function s(h){try{u(n.next(h))}catch(v){a(v)}}function c(h){try{u(n.throw(h))}catch(v){a(v)}}function u(h){h.done?i(h.value):o(h.value).then(s,c)}u((n=n.apply(e,t||[])).next())})}var Ae;(function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"})(Ae||(Ae={}));function ud(){return typeof window<"u"}function Ad(){return typeof navigator<"u"}function lo(){return typeof document<"u"}function ld(){try{return typeof localStorage<"u"}catch{return!1}}function NC(){try{return typeof sessionStorage<"u"}catch{return!1}}function Ug(){return Ad()&&navigator.cookieEnabled}var FC=[Ae.click,Ae.custom,Ae.search,Ae.view],DC=(e,t)=>FC.indexOf(e)!==-1?Object.assign({language:lo()?document.documentElement.lang:"unknown",userAgent:Ad()?navigator.userAgent:"unknown"},t):t,Pi=class e{static set(t,r,n){var o,i,a,s;n&&(i=new Date,i.setTime(i.getTime()+n)),s=window.location.hostname,s.indexOf(".")===-1?Tg(t,r,i):(a=s.split("."),o=a[a.length-2]+"."+a[a.length-1],Tg(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function Tg(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"+(window.location.protocol==="https:"?";Secure":"")}function MC(){return ld()?localStorage:Ug()?new Ni:NC()?sessionStorage:new fo}var Ni=class e{getItem(t){return Pi.get(`${e.prefix}${t}`)}removeItem(t){Pi.erase(`${e.prefix}${t}`)}setItem(t,r,n){Pi.set(`${e.prefix}${t}`,r,n)}};Ni.prefix="coveo_";var dd=class{constructor(){this.cookieStorage=new Ni}getItem(t){return localStorage.getItem(t)||this.cookieStorage.getItem(t)}removeItem(t){this.cookieStorage.removeItem(t),localStorage.removeItem(t)}setItem(t,r){localStorage.setItem(t,r),this.cookieStorage.setItem(t,r,31556926e3)}},fo=class{getItem(t){return null}removeItem(t){}setItem(t,r){}},bs="__coveo.analytics.history",qC=20,jC=1e3*60,LC=75,As=class{constructor(t){this.store=t||MC()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){return U(this,void 0,void 0,function*(){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=yield this.getHistoryWithInternalTimeAsync();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])})}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){return U(this,void 0,void 0,function*(){let t=yield this.getHistoryWithInternalTimeAsync();return this.stripEmptyQueries(this.stripInternalTime(t))})}getHistoryWithInternalTime(){try{let t=this.store.getItem(bs);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){return U(this,void 0,void 0,function*(){try{let t=yield this.store.getItem(bs);return t?JSON.parse(t):[]}catch{return[]}})}setHistory(t){try{this.store.setItem(bs,JSON.stringify(t.slice(0,qC)))}catch{}}clear(){try{this.store.removeItem(bs)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,LC)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>jC:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var UC=(e,t)=>U(void 0,void 0,void 0,function*(){return e===Ae.view?(yield VC(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}),VC=e=>U(void 0,void 0,void 0,function*(){let t=new As,r={name:"PageView",value:e,time:new Date().toISOString()};yield t.addElementAsync(r)}),BC=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function xs(e){return typeof e=="string"&&BC.test(e)}function _g(e){if(!xs(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var ot=[];for(let e=0;e<256;++e)ot.push((e+256).toString(16).slice(1));function Vg(e,t=0){return(ot[e[t+0]]+ot[e[t+1]]+ot[e[t+2]]+ot[e[t+3]]+"-"+ot[e[t+4]]+ot[e[t+5]]+"-"+ot[e[t+6]]+ot[e[t+7]]+"-"+ot[e[t+8]]+ot[e[t+9]]+"-"+ot[e[t+10]]+ot[e[t+11]]+ot[e[t+12]]+ot[e[t+13]]+ot[e[t+14]]+ot[e[t+15]]).toLowerCase()}var GC=new Uint8Array(16);function $C(){return crypto.getRandomValues(GC)}function QC(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var HC="6ba7b810-9dad-11d1-80b4-00c04fd430c8",zC="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function WC(e,t,r,n,o,i){let a=typeof r=="string"?QC(r):r,s=typeof n=="string"?_g(n):n;if(typeof n=="string"&&(n=_g(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);return c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,Vg(c)}function ln(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():KC(e,t,r)}function KC(e,t,r){e=e||{};let n=e.random??e.rng?.()??$C();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return Vg(n)}function YC(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function sd(e,t){return e<<t|e>>>32-t}function XC(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let o=e.length/4+2,i=Math.ceil(o/16),a=new Array(i);for(let s=0;s<i;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[i-1][14]=(e.length-1)*8/2**32,a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let c=new Uint32Array(80);for(let y=0;y<16;++y)c[y]=a[s][y];for(let y=16;y<80;++y)c[y]=sd(c[y-3]^c[y-8]^c[y-14]^c[y-16],1);let u=r[0],h=r[1],v=r[2],C=r[3],g=r[4];for(let y=0;y<80;++y){let S=Math.floor(y/20),E=sd(u,5)+YC(S,h,v,C)+g+t[S]+c[y]>>>0;g=C,C=v,v=sd(h,30)>>>0,h=u,u=E}r[0]=r[0]+u>>>0,r[1]=r[1]+h>>>0,r[2]=r[2]+v>>>0,r[3]=r[3]+C>>>0,r[4]=r[4]+g>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Cs(e,t,r,n){return WC(80,XC,e,t)}Cs.DNS=HC;Cs.URL=zC;var Bg="2.33.0",kg=e=>`${e.protocol}//${e.hostname}${e.pathname.indexOf("/")===0?e.pathname:`/${e.pathname}`}${e.search}`,Oi={pageview:"pageview",event:"event"},Es=class{constructor({client:t,uuidGenerator:r=ln}){this.client=t,this.uuidGenerator=r}},pd=class extends Es{constructor({client:t,uuidGenerator:r=ln}){super({client:t,uuidGenerator:r}),this.actionData={},this.pageViewId=r(),this.nextPageViewId=this.pageViewId,this.currentLocation=kg(window.location),this.lastReferrer=lo()?document.referrer:"",this.addHooks()}getApi(t){return t==="setAction"?this.setAction:null}setAction(t,r){this.action=t,this.actionData=r}clearData(){this.clearPluginData(),this.action=void 0,this.actionData={}}getLocationInformation(t,r){return Object.assign({hitType:t},this.getNextValues(t,r))}updateLocationInformation(t,r){this.updateLocationForNextPageView(t,r)}getDefaultContextInformation(t){let r={title:lo()?document.title:"",encoding:lo()?document.characterSet:"UTF-8"},n={screenResolution:`${screen.width}x${screen.height}`,screenColor:`${screen.colorDepth}-bit`},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now(),eventId:this.uuidGenerator()};return Object.assign(Object.assign(Object.assign(Object.assign({},i),n),o),r)}updateLocationForNextPageView(t,r){let{pageViewId:n,referrer:o,location:i}=this.getNextValues(t,r);this.lastReferrer=o,this.pageViewId=n,this.currentLocation=i,t===Oi.pageview&&(this.nextPageViewId=this.uuidGenerator(),this.hasSentFirstPageView=!0)}getNextValues(t,r){return{pageViewId:t===Oi.pageview?this.nextPageViewId:this.pageViewId,referrer:t===Oi.pageview&&this.hasSentFirstPageView?this.currentLocation:this.lastReferrer,location:t===Oi.pageview?this.getCurrentLocationFromPayload(r):this.currentLocation}}getCurrentLocationFromPayload(t){if(t.page){let r=o=>o.replace(/^\/?(.*)$/,"/$1");return`${(o=>o.split("/").slice(0,3).join("/"))(this.currentLocation)}${r(t.page)}`}else return kg(window.location)}},Tr=class e{constructor(t,r){if(!xs(t))throw Error("Not a valid uuid");this.clientId=t,this.creationDate=Math.floor(r/1e3)}toString(){return this.clientId.replace(/-/g,"")+"."+this.creationDate.toString()}get expired(){let t=Math.floor(Date.now()/1e3)-this.creationDate;return t<0||t>e.expirationTime}validate(t,r){return!this.expired&&this.matchReferrer(t,r)}matchReferrer(t,r){try{let n=new URL(t);return r.some(o=>new RegExp(o.replace(/\\/g,"\\\\").replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(n.host))}catch{return!1}}static fromString(t){let r=t.split(".");if(r.length!==2)return null;let[n,o]=r;if(n.length!==32||isNaN(parseInt(o)))return null;let i=n.substring(0,8)+"-"+n.substring(8,12)+"-"+n.substring(12,16)+"-"+n.substring(16,20)+"-"+n.substring(20,32);return xs(i)?new e(i,Number.parseInt(o)*1e3):null}};Tr.cvo_cid="cvo_cid";Tr.expirationTime=120;var fd=class extends Es{constructor({client:t,uuidGenerator:r=ln}){super({client:t,uuidGenerator:r})}getApi(t){switch(t){case"decorate":return this.decorate;case"acceptFrom":return this.acceptFrom;default:return null}}decorate(t){return U(this,void 0,void 0,function*(){if(!this.client.getCurrentVisitorId)throw new Error("Could not retrieve current clientId");try{let r=new URL(t),n=yield this.client.getCurrentVisitorId();return r.searchParams.set(Tr.cvo_cid,new Tr(n,Date.now()).toString()),r.toString()}catch{throw new Error("Invalid URL provided")}})}acceptFrom(t){this.client.setAcceptedLinkReferrers(t)}};fd.Id="link";var kt=Object.keys;function ws(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var cd=128,Gg=192,Og=224,Pg=240;function ZC(e){return(e&248)===Pg?4:(e&Pg)===Og?3:(e&Og)===Gg?2:1}function JC(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&cd)!=cd)break;if(r-=3,(n&Gg)!=cd){t-r>=ZC(n)*3&&(r=t);break}}return e.substring(0,r)}var md={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},eE=kt(md).map(e=>md[e]),tE=[...eE].join("|"),rE=new RegExp(`^(${tE}$)`),nE={svcAction:"svc_action",svcActionData:"svc_action_data"},oE=e=>kt(e).filter(t=>e[t]!==void 0).reduce((t,r)=>{let n=md[r]||r;return Object.assign(Object.assign({},t),{[n]:e[r]})},{}),iE=e=>rE.test(e),aE=[iE],Ng={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps",group:"group"},Fg={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr",group:"group"},lt={action:"pa",list:"pal",listSource:"pls"},Rs={id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"},sE=["loyaltyCardId","loyaltyTier","thirdPartyPersona","companyName","favoriteStore","storeName","userIndustry","userRole","userDepartment","businessUnit"],gd={id:"quoteId",affiliation:"quoteAffiliation"},hd={id:"reviewId",rating:"reviewRating",comment:"reviewComment"},cE={add:lt,bookmark_add:lt,bookmark_remove:lt,click:lt,checkout:lt,checkout_option:lt,detail:lt,impression:lt,remove:lt,refund:Object.assign(Object.assign({},lt),Rs),purchase:Object.assign(Object.assign({},lt),Rs),quickview:lt,quote:Object.assign(Object.assign({},lt),gd),review:Object.assign(Object.assign({},lt),hd)},uE=kt(Ng).map(e=>Ng[e]),lE=kt(Fg).map(e=>Fg[e]),dE=kt(lt).map(e=>lt[e]),pE=kt(Rs).map(e=>Rs[e]),fE=kt(hd).map(e=>hd[e]),mE=kt(gd).map(e=>gd[e]),gE=[...uE,"custom"].join("|"),hE=[...lE,"custom"].join("|"),$g="(pr[0-9]+)",Qg="(il[0-9]+pi[0-9]+)",yE=new RegExp(`^${$g}(${gE})$`),vE=new RegExp(`^(${Qg}(${hE}))|(il[0-9]+nm)$`),SE=new RegExp(`^(${dE.join("|")})$`),bE=new RegExp(`^(${pE.join("|")})$`),wE=new RegExp(`^${$g}custom$`),AE=new RegExp(`^${Qg}custom$`),xE=new RegExp(`^(${[...sE,...fE,...mE].join("|")})$`),CE=e=>yE.test(e),EE=e=>vE.test(e),RE=e=>SE.test(e),IE=e=>bE.test(e),TE=e=>xE.test(e),_E=[EE,CE,RE,IE,TE],kE=[wE,AE],OE={anonymizeIp:"aip"},PE={eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"},NE={hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"},FE=["contentId","contentIdKey","contentType","searchHub","tab","searchUid","permanentId","contentLocale","trackingId"],DE=Object.assign(Object.assign(Object.assign(Object.assign({},OE),PE),NE),FE.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})),yd=Object.assign(Object.assign({},DE),nE),ME=e=>{let t=!!e.action&&cE[e.action]||{};return kt(e).reduce((r,n)=>{let o=t[n]||yd[n]||n;return Object.assign(Object.assign({},r),{[o]:e[n]})},{})},qE=kt(yd).map(e=>yd[e]),jE=e=>qE.indexOf(e)!==-1,LE=e=>e==="custom",UE=e=>[..._E,...aE,jE,LE].some(t=>t(e)),VE=e=>kt(e).reduce((t,r)=>{let n=BE(r);return n?Object.assign(Object.assign({},t),GE(n,e[r])):Object.assign(Object.assign({},t),{[r]:e[r]})},{}),BE=e=>{let t;return[...kE].every(r=>{var n;return t=(n=r.exec(e))===null||n===void 0?void 0:n[1],!t}),t},GE=(e,t)=>kt(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{}),vd=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){if(!this.isAvailable())throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");let{baseUrl:n,preprocessRequest:o}=this.opts,i=yield this.getQueryParamsForEventType(t),{url:a,payload:s}=yield this.preProcessRequestAsPotentialJSONString(`${n}/analytics/${t}?${i}`,r,o),c=this.encodeForEventType(t,s),u=new Blob([c],{type:"application/x-www-form-urlencoded"});navigator.sendBeacon(a,u)})}isAvailable(){return"sendBeacon"in navigator}deleteHttpCookieVisitorId(){return Promise.resolve()}preProcessRequestAsPotentialJSONString(t,r,n){return U(this,void 0,void 0,function*(){let o=t,i=r;if(n){let a=yield n({url:t,body:JSON.stringify(r)},"analyticsBeacon"),{url:s,body:c}=a;o=s||t;try{i=JSON.parse(c)}catch(u){console.error("Unable to process the request body as a JSON string",u)}}return{payload:i,url:o}})}encodeForEventType(t,r){return this.isEventTypeLegacy(t)?this.encodeEventToJson(t,r):this.encodeEventToJson(t,r,this.opts.token)}getQueryParamsForEventType(t){return U(this,void 0,void 0,function*(){let{token:r,visitorIdProvider:n}=this.opts,o=yield n.getCurrentVisitorId();return[r&&this.isEventTypeLegacy(t)?`access_token=${r}`:"",o?`visitorId=${o}`:"","discardVisitInfo=true"].filter(i=>!!i).join("&")})}isEventTypeLegacy(t){return[Ae.click,Ae.custom,Ae.search,Ae.view].indexOf(t)!==-1}encodeEventToJson(t,r,n){let o=`${t}Event=${encodeURIComponent(JSON.stringify(r))}`;return n&&(o=`access_token=${encodeURIComponent(n)}&${o}`),o}},Sd=class{sendEvent(t,r){return U(this,void 0,void 0,function*(){return Promise.resolve()})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){return Promise.resolve()})}},Dg=w.fetch,Is=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){let{baseUrl:n,visitorIdProvider:o,preprocessRequest:i}=this.opts,a=this.shouldAppendVisitorId(t)?yield this.getVisitorIdParam():"",s={url:`${n}/analytics/${t}${a}`,credentials:"include",mode:"cors",headers:this.getHeaders(),method:"POST",body:JSON.stringify(r)},c=Object.assign(Object.assign({},s),i?yield i(s,"analyticsFetch"):{}),{url:u}=c,h=lr(c,["url"]),v;try{v=yield Dg(u,h)}catch(C){console.error("An error has occurred when sending the event.",C);return}if(v.ok){let C=yield v.json();return C.visitorId&&o.setCurrentVisitorId(C.visitorId),C}else{try{v.json()}catch{}throw console.error(`An error has occurred when sending the "${t}" event.`,v,r),new Error(`An error has occurred when sending the "${t}" event. Check the console logs for more details.`)}})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){let{baseUrl:t}=this.opts,r=`${t}/analytics/visit`;yield Dg(r,{headers:this.getHeaders(),method:"DELETE"})})}shouldAppendVisitorId(t){return[Ae.click,Ae.custom,Ae.search,Ae.view].indexOf(t)!==-1}getVisitorIdParam(){return U(this,void 0,void 0,function*(){let{visitorIdProvider:t}=this.opts,r=yield t.getCurrentVisitorId();return r?`?visitor=${r}`:""})}getHeaders(){let{token:t}=this.opts;return Object.assign(Object.assign({},t?{Authorization:`Bearer ${t}`}:{}),{"Content-Type":"application/json"})}},bd=class{constructor(t,r){ld()&&Ug()?this.storage=new dd:ld()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new fo),this.client=new Is(t),this.beaconClient=new vd(t),window.addEventListener("beforeunload",()=>{let n=r();for(let{eventType:o,payload:i}of n)this.beaconClient.sendEvent(o,i)})}getClientDependingOnEventType(t){return t==="click"&&this.beaconClient.isAvailable()?this.beaconClient:this.client}},wd=class{constructor(t,r){this.storage=r||new fo,this.client=new Is(t)}getClientDependingOnEventType(t){return this.client}},Ts=class{constructor(){this.storage=new fo,this.client=new Sd}getClientDependingOnEventType(t){return this.client}},$E="xx",QE=e=>e?.startsWith($E)||!1,HE=`
27
+ `;return new si(r)}var si=class extends Error{constructor(e){super(e),this.name="SchemaValidationError"}},ht=class{constructor(e){ae(this,"definition");this.definition=e}validate(e={},t=""){let r={...this.default,...e},n=[];for(let o in this.definition){let i=this.definition[o].validate(r[o]);i&&n.push(`${o}: ${i}`)}if(n.length)throw IA(n,t);return r}get default(){let e={};for(let t in this.definition){let r=this.definition[t].default;r!==void 0&&(e[t]=r)}return e}},De=class{constructor(e={}){ae(this,"baseConfig");this.baseConfig=e}validate(e){return this.baseConfig.required&&se(e)?"value is required.":null}get default(){return this.baseConfig.default instanceof Function?this.baseConfig.default():this.baseConfig.default}get required(){return this.baseConfig.required===!0}};function Je(e){return e===void 0}function TA(e){return e===null}function se(e){return Je(e)||TA(e)}var fe=class{constructor(e={}){ae(this,"value");this.value=new De(e)}validate(e){let t=this.value.validate(e);return t||(_A(e)?null:"value is not a boolean.")}get default(){return this.value.default}get required(){return this.value.required}};function _A(e){return Je(e)||Kf(e)}function Kf(e){return typeof e=="boolean"}var oe=class{constructor(e={}){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(e)}validate(e){let t=this.value.validate(e);return t||(kA(e)?e<this.config.min?`minimum value of ${this.config.min} not respected.`:e>this.config.max?`maximum value of ${this.config.max} not respected.`:null:"value is not a number.")}get default(){return this.value.default}get required(){return this.value.required}};function kA(e){return Je(e)||Yf(e)}function Yf(e){return typeof e=="number"&&!Number.isNaN(e)}var OA=/^\d{4}(-\d\d(-\d\d(T\d\d:\d\d(:\d\d)?(\.\d+)?(([+-]\d\d:\d\d)|Z)?)?)?)?$/i,z=class{constructor(e={}){ae(this,"value");ae(this,"config");this.config={emptyAllowed:!0,url:!1,...e},this.value=new De(this.config)}validate(e){let{emptyAllowed:t,url:r,regex:n,constrainTo:o,ISODate:i}=this.config,a=this.value.validate(e);if(a)return a;if(Je(e))return null;if(!_a(e))return"value is not a string.";if(!t&&!e.length)return"value is an empty string.";if(r)try{new URL(e)}catch{return"value is not a valid URL."}return n&&!n.test(e)?`value did not match provided regex ${n}`:o&&!o.includes(e)?`value should be one of: ${o.join(", ")}.`:i&&!(OA.test(e)&&new Date(e).toString()!=="Invalid Date")?"value is not a valid ISO8601 date string":null}get default(){return this.value.default}get required(){return this.value.required}};function _a(e){return Object.prototype.toString.call(e)==="[object String]"}var ne=class{constructor(e={}){ae(this,"config");this.config={options:{required:!1},values:{},...e}}validate(e){if(Je(e))return this.config.options.required?"value is required and is currently undefined":null;if(!Xf(e))return"value is not an object";for(let[r,n]of Object.entries(this.config.values))if(n.required&&se(e[r]))return`value does not contain ${r}`;let t="";for(let[r,n]of Object.entries(this.config.values)){let o=e[r],i=n.validate(o);i!==null&&(t+=` ${i}`)}return t===""?null:t}get default(){}get required(){return!!this.config.options.required}};function Xf(e){return e!==void 0&&typeof e=="object"}var Se=class{constructor(e={}){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(this.config)}validate(e){if(!se(e)&&!Array.isArray(e))return"value is not an array";let t=this.value.validate(e);if(t!==null)return t;if(se(e))return null;if(this.config.max!==void 0&&e.length>this.config.max)return`value contains more than ${this.config.max}`;if(this.config.min!==void 0&&e.length<this.config.min)return`value contains less than ${this.config.min}`;if(this.config.each!==void 0){let r="";return e.forEach(n=>{this.config.each.required&&se(n)&&(r=`value is null or undefined: ${e.join(",")}`);let o=this.validatePrimitiveValue(n,this.config.each);o!==null&&(r+=` ${o}`)}),r===""?null:r}return null}validatePrimitiveValue(e,t){return Kf(e)||_a(e)||Yf(e)||Xf(e)?t.validate(e):"value is not a primitive value"}get default(){}get required(){return this.value.required}};function Zf(e){return Array.isArray(e)}var Il=class{constructor(e){ae(this,"config");ae(this,"value");this.config=e,this.value=new De(e)}validate(e){let t=this.value.validate(e);return t!==null?t:Je(e)||Object.values(this.config.enum).find(n=>n===e)?null:"value is not in enum."}get default(){return this.value.default}get required(){return this.value.required}};m();d();f();p();function Jf(e){return Array.isArray(e)}function ka(e){return e.trim()===""}var PA=new Set(["1",1,"yes",!0]);function Tl(){if(typeof navigator>"u"||typeof window>"u")return!1;let e=navigator,t=window;return[e.globalPrivacyControl,e.doNotTrack,e.msDoNotTrack,t.doNotTrack].some(r=>PA.has(r))}function em(e){let t={};for(let[r,n]of e)t[r]=n;return t}function ci(e){if(typeof e!="object"||!e)return e;try{return JSON.parse(JSON.stringify(e))}catch{return e}}function Oa(e,t,r={}){let n;return(...o)=>{let i=r.isImmediate&&!n;if(clearTimeout(n),n=setTimeout(()=>{n=void 0,r.isImmediate||e.apply(void 0,o)},t),i)return e.apply(void 0,o)}}function NA(e){if(ka(e.openingDelimiter)||ka(e.closingDelimiter))throw Error("delimiters should be a non-empty string");if(se(e.content)||ka(e.content))return e.content;if(e.highlights.length===0)return zn(e.content);let t=e.content.length,r="",n=0;for(let o=0;o<e.highlights.length;o++){let i=e.highlights[o],a=i.offset,s=a+i.length;if(s>t)break;r+=zn(e.content.slice(n,a)),r+=e.openingDelimiter,r+=zn(e.content.slice(a,s)),r+=e.closingDelimiter,n=s}return n!==t&&(r+=zn(e.content.slice(n))),r}function FA(e,t){return e=zn(e),e.replace(/\[(.*?)\]|\{(.*?)\}|\((.*?)\)/g,(r,n,o,i)=>n?_l(n,t.notMatchDelimiters):o?_l(o,t.exactMatchDelimiters):i?_l(i,t.correctionDelimiters):r)}function _l(e,t){return t?t.open+e+t.close:e}function zn(e){let t={"&":"&amp;","<":"&lt;",">":"&gt;","\"":"&quot;","'":"&#x27;","`":"&#x60;"},r=`(?:${Object.keys(t).join("|")})`,n=RegExp(r),o=RegExp(r,"g");return n.test(e)?e.replace(o,i=>t[i]):e}m();d();f();p();var pm=qt(cm(),1);m();d();f();p();var $t=new Error("Failed to load reducers."),Wn=class extends Error{constructor(){super(),this.name="UnauthorizedTokenError",this.message="The token being used to perform the request is unauthorized. It may be expired or invalid."}},Jr=class extends Error{constructor(r,n){super();ae(this,"statusCode");this.name="Disconnected",this.message=`Client could not connect to the following URL: ${r}`,this.statusCode=n??0}};m();d();f();p();function um(e){let t=[];for(let r in e){let n=encodeURIComponent(r),o=encodeURIComponent(e[r]);t.push(`${n}=${o}`)}return t.join("&")}function lm(e){return typeof e!="object"||!e?!1:Object.values(e).every(ax)}function ax(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function dm(e){return e===429}var jt=class e{static call(t){return _asyncToGenerator(function*(){let r=sx(t),{logger:n}=t,o=yield e.preprocessRequest(r,t);n.info(o,"Platform request");let{url:i,...a}=o,s=/*#__PURE__*/function(){var _ref=_asyncToGenerator(function*(){let c=yield A(i,a);if(dm(c.status))throw c;return c});return function s(){return _ref.apply(this,arguments)}}();try{let c=yield(0,pm.backOff)(s,{startingDelay:100,timeMultiple:2,maxDelay:800,numOfAttempts:4,jitter:"full",retry:function(){var _ref2=_asyncToGenerator(function*(u){let h=u&&dm(u.status);return h&&(n.info("Platform retrying request"),yield new Promise(v=>setTimeout(v,1e3))),h});return function retry(_x2){return _ref2.apply(this,arguments)}}()});switch(c.status){case 419:case 401:throw n.info("Platform renewing token"),new Wn;case 404:throw new Jr(i,c.status);default:return n.info({response:c,requestInfo:o},"Platform response"),c}}catch(c){return c.message==="Failed to fetch"?new Jr(i):c}})()}static preprocessRequest(t,r){return _asyncToGenerator(function*(){let{origin:n,preprocessRequest:o,logger:i,requestMetadata:a}=r,{signal:s,...c}=t,u=ci(c);try{let h=yield o(t,n,a);return{...t,...h}}catch(h){i.error(h,"Platform request preprocessing failed. Returning default request options.")}return u})()}};function It(e,t="prod",r="platform"){let n=t==="prod"?"":t,o=r==="platform"?"":`.${r}`;return`https://${e}${o}.org${n}.coveo.com`}function Kn(e,t,r="prod"){return e??It(t,r)}function wr(e,t="prod"){return`${It(e,t)}/rest/search/v2`}function Na(e,t="prod"){return`${It(e,t,"analytics")}/rest/organizations/${e}/events/v1`}function sx(e){let{url:t,method:r,requestParams:n,contentType:o,accessToken:i,signal:a}=e,s=e.method==="POST"||e.method==="PUT",c=cx(n,o);return{url:t,method:r,headers:{"Content-Type":o,Authorization:`Bearer ${i}`,...e.headers},...(s&&{body:c}),signal:a}}function cx(e,t){return t==="application/x-www-form-urlencoded"?lm(e)?um(e):"":JSON.stringify(e)}m();d();f();p();m();d();f();p();var Fa=e=>e;m();d();f();p();m();d();f();p();function Da(){return{answerSnippet:"",documentId:{contentIdKey:"",contentIdValue:""},question:"",relatedQuestions:[],score:0}}function Qt(){return{response:{results:[],searchUid:"",totalCountFiltered:0,facets:[],generateAutomaticFacets:{facets:[]},queryCorrections:[],triggers:[],questionAnswer:Da(),pipeline:"",splitTestRun:"",termsToHighlight:{},phrasesToHighlight:{},extendedResults:{}},duration:0,queryExecuted:"",error:null,automaticallyCorrected:!1,isLoading:!1,results:[],searchResponseId:"",requestId:"",questionAnswer:Da(),extendedResults:{},searchAction:void 0}}m();d();f();p();function Ar(e){let{url:t,accessToken:r,organizationId:n,authentication:o,...i}=e;return i}var xr=e=>{let{response:t}=e;return t.body?ux(e):lx(t)},ux=e=>px(e)?fx(e):dx(e)?e.body:{message:"unknown",statusCode:0,type:"unknown"},lx=e=>{let t=JSON.parse(JSON.stringify(e,Object.getOwnPropertyNames(e)));return{...t,message:`Client side error: ${t.message||""}`,statusCode:400,type:"ClientError"}};function dx(e){return e.body.statusCode!==void 0}function px(e){return e.body.exception!==void 0}var fx=e=>({message:e.body.exception.code,statusCode:e.response.status,type:e.body.exception.code});m();d();f();p();var Cr=class{constructor(){ae(this,"currentAbortController",null)}enqueue(t,r){var _this=this;return _asyncToGenerator(function*(){let n=_this.currentAbortController;_this.currentAbortController=new l.AbortController;let o=_this.currentAbortController;n&&(r.warnOnAbort&&r.logger.warn("Cancelling current pending search query"),n.abort());try{return yield t(o?.signal??null)}finally{_this.currentAbortController===o&&(_this.currentAbortController=null)}})()}};m();d();f();p();m();d();f();p();var di=class{constructor(t){ae(this,"_basePath");ae(this,"_params",{});this._basePath=t}addParam(t,r){this._params={...this.params,[t]:r}}get basePath(){return this._basePath}get params(){return this._params}get hasParams(){return Object.entries(this._params).length}get href(){return this.hasParams?`${this.basePath}?${Object.entries(this.params).map(([t,r])=>`${t}=${encodeURIComponent(r)}`).join("&")}`:this.basePath}};m();d();f();p();function fm(e){return((e.headers.get("content-type")||"").split(";").find(n=>n.indexOf("charset=")!==-1)||"").split("=")[1]||"UTF-8"}m();d();f();p();var ir=(e,t,r,n)=>{let o=new di(`${e.url}${n}`);return o.addParam("organizationId",e.organizationId),e.authentication&&o.addParam("authentication",e.authentication),{accessToken:e.accessToken,method:t,contentType:r,url:o.href,origin:"searchApiFetch"}};var mm=/*#__PURE__*/function(){var _ref3=_asyncToGenerator(function*(e,t){let r=yield jt.call({...ir(e,"POST","application/x-www-form-urlencoded","/html"),requestParams:Ar(e),requestMetadata:{method:"html"},...t});if(r instanceof Error)throw r;let n=fm(r),o=yield r.arrayBuffer(),a=new TextDecoder(n).decode(o);return mx(a)?{success:a}:{error:xr({response:r,body:a})}});return function mm(_x3,_x4){return _ref3.apply(this,arguments)}}();function mx(e){return typeof e=="string"}m();d();f();p();function gx(e){return{statusCode:e.statusCode,type:e.name,message:e.message}}function hx(e){return{statusCode:e.code,type:e.name,message:e.message,ignored:!0}}function Ma(e,t){if(t&&e.name==="AbortError")return{error:hx(e)};if(e instanceof Jr)return{error:gx(e)};throw e}var qa=class{constructor(t){ae(this,"options",t);ae(this,"apiCallsQueues",{unknown:new Cr,mainSearch:new Cr,facetValues:new Cr,foldingCollection:new Cr,instantResults:new Cr})}plan(t){var _this2=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/plan"),requestParams:Ar(t),requestMetadata:{method:"plan"},..._this2.options});if(r instanceof Error)return Ma(r);let n=yield r.json();return vx(n)?{success:n}:{error:xr({response:r,body:n})}})()}querySuggest(t){var _this3=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/querySuggest"),requestMetadata:{method:"querySuggest"},requestParams:Ar(t),..._this3.options});if(r instanceof Error)return Ma(r);let n=yield r.json(),o={response:r,body:n};return yx(n)?{success:(yield _this3.options.postprocessQuerySuggestResponseMiddleware(o)).body}:{error:xr(o)}})()}search(t,r){var _this4=this;return _asyncToGenerator(function*(){let n=r?.origin??"unknown",o=yield _this4.apiCallsQueues[n].enqueue(s=>jt.call({...ir(t,"POST","application/json",""),requestParams:Ar(t),requestMetadata:{method:"search",origin:r?.origin},..._this4.options,signal:s??void 0}),{logger:_this4.options.logger,warnOnAbort:!r?.disableAbortWarning});if(o instanceof Error)return Ma(o,r?.disableAbortWarning);let i=yield o.json(),a={response:o,body:i};return gm(i)?(a.body=hm(i),{success:(yield _this4.options.postprocessSearchResponseMiddleware(a)).body}):{error:xr(a)}})()}facetSearch(t){var _this5=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json","/facet"),requestParams:Ar(t),requestMetadata:{method:"facetSearch"},..._this5.options});if(r instanceof Error)throw r;let n=yield r.json(),o={response:r,body:n};return(yield _this5.options.postprocessFacetSearchResponseMiddleware(o)).body})()}recommendations(t){var _this6=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"POST","application/json",""),requestParams:Ar(t),requestMetadata:{method:"recommendations"},..._this6.options});if(r instanceof Error)throw r;let n=yield r.json();if(gm(n)){let o={response:r,body:n};return o.body=hm(n),{success:(yield _this6.options.postprocessSearchResponseMiddleware(o)).body}}return{error:xr({response:r,body:n})}})()}html(t){var _this7=this;return _asyncToGenerator(function*(){return mm(t,{..._this7.options})})()}fieldDescriptions(t){var _this8=this;return _asyncToGenerator(function*(){let r=yield jt.call({...ir(t,"GET","application/json","/fields"),requestParams:{},requestMetadata:{method:"fieldDescriptions"},..._this8.options});if(r instanceof Error)throw r;let n=yield r.json();return Sx(n)?{success:n}:{error:xr({response:r,body:n})}})()}},ja=e=>e.success!==void 0,yt=e=>e.error!==void 0;function gm(e){return e.results!==void 0}function hm(e){let t=Da();return se(e.questionAnswer)?(e.questionAnswer=t,e):(e.questionAnswer={...t,...e.questionAnswer},e)}function yx(e){return e.completions!==void 0}function vx(e){return e.preprocessingOutput!==void 0}function Sx(e){return e.fields!==void 0}m();d();f();p();var ym=e=>e,vm=e=>e,Sm=e=>e;m();d();f();p();m();d();f();p();m();d();f();p();function et(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var bx=typeof Symbol=="function"&&Symbol.observable||"@@observable",bm=bx,Ll=()=>Math.random().toString(36).substring(7).split("").join("."),wx={INIT:`@@redux/INIT${Ll()}`,REPLACE:`@@redux/REPLACE${Ll()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${Ll()}`},La=wx;function Ht(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function Ul(e,t,r){if(typeof e!="function")throw new Error(et(2));if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(et(0));if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(et(1));return r(Ul)(e,t)}let n=e,o=t,i=new Map,a=i,s=0,c=!1;function u(){a===i&&(a=new Map,i.forEach((E,R)=>{a.set(R,E)}))}function h(){if(c)throw new Error(et(3));return o}function v(E){if(typeof E!="function")throw new Error(et(4));if(c)throw new Error(et(5));let R=!0;u();let k=s++;return a.set(k,E),function(){if(R){if(c)throw new Error(et(6));R=!1,u(),a.delete(k),i=null}}}function C(E){if(!Ht(E))throw new Error(et(7));if(typeof E.type>"u")throw new Error(et(8));if(typeof E.type!="string")throw new Error(et(17));if(c)throw new Error(et(9));try{c=!0,o=n(o,E)}finally{c=!1}return(i=a).forEach(k=>{k()}),E}function g(E){if(typeof E!="function")throw new Error(et(10));n=E,C({type:La.REPLACE})}function y(){let E=v;return{subscribe(R){if(typeof R!="object"||R===null)throw new Error(et(11));function k(){let T=R;T.next&&T.next(h())}return k(),{unsubscribe:E(k)}},[bm](){return this}}}return C({type:La.INIT}),{dispatch:C,subscribe:v,getState:h,replaceReducer:g,[bm]:y}}function Ax(e){Object.keys(e).forEach(t=>{let r=e[t];if(typeof r(void 0,{type:La.INIT})>"u")throw new Error(et(12));if(typeof r(void 0,{type:La.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(et(13))})}function Yn(e){let t=Object.keys(e),r={};for(let a=0;a<t.length;a++){let s=t[a];typeof e[s]=="function"&&(r[s]=e[s])}let n=Object.keys(r),o,i;try{Ax(r)}catch(a){i=a}return function(s={},c){if(i)throw i;let u=!1,h={};for(let v=0;v<n.length;v++){let C=n[v],g=r[C],y=s[C],S=g(y,c);if(typeof S>"u"){let E=c&&c.type;throw new Error(et(14))}h[C]=S,u=u||S!==y}return u=u||n.length!==Object.keys(s).length,u?h:s}}function pi(...e){return e.length===0?t=>t:e.length===1?e[0]:e.reduce((t,r)=>(...n)=>t(r(...n)))}function wm(...e){return t=>(r,n)=>{let o=t(r,n),i=()=>{throw new Error(et(15))},a={getState:o.getState,dispatch:(c,...u)=>i(c,...u)},s=e.map(c=>c(a));return i=pi(...s)(o.dispatch),{...o,dispatch:i}}}function fi(e){return Ht(e)&&"type"in e&&typeof e.type=="string"}m();d();f();p();var Kl=Symbol.for("immer-nothing"),mi=Symbol.for("immer-draftable"),We=Symbol.for("immer-state");function tt(e,...t){throw new Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var xt=Object,tn=xt.getPrototypeOf,gi="constructor",bi="prototype",Gl="configurable",Ga="enumerable",Va="writable",hi="value",ft=e=>!!e&&!!e[We];function ut(e){return e?_m(e)||Ai(e)||!!e[mi]||!!e[gi]?.[mi]||xi(e)||Ci(e):!1}var xx=xt[bi][gi].toString(),Am=new WeakMap;function _m(e){if(!e||!Zn(e))return!1;let t=tn(e);if(t===null||t===xt[bi])return!0;let r=xt.hasOwnProperty.call(t,gi)&&t[gi];if(r===Object)return!0;if(!en(r))return!1;let n=Am.get(r);return n===void 0&&(n=Function.toString.call(r),Am.set(r,n)),n===xx}function km(e){return ft(e)||tt(15,e),e[We].base_}function wi(e,t,r=!0){rn(e)===0?(r?Reflect.ownKeys(e):xt.keys(e)).forEach(o=>{t(o,e[o],e)}):e.forEach((n,o)=>t(o,n,e))}function rn(e){let t=e[We];return t?t.type_:Ai(e)?1:xi(e)?2:Ci(e)?3:0}var Xn=(e,t,r=rn(e))=>r===2?e.has(t):xt[bi].hasOwnProperty.call(e,t),ar=(e,t,r=rn(e))=>r===2?e.get(t):e[t],$a=(e,t,r,n=rn(e))=>{n===2?e.set(t,r):n===3?e.add(r):e[t]=r};function Cx(e,t){return e===t?e!==0||1/e===1/t:e!==e&&t!==t}var Ai=Array.isArray,xi=e=>e instanceof Map,Ci=e=>e instanceof Set,Zn=e=>typeof e=="object",en=e=>typeof e=="function",Vl=e=>typeof e=="boolean";function Ex(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var Rx=e=>Zn(e)?e?.[We]:null,sr=e=>e.copy_||e.base_;var Yl=e=>e.modified_?e.copy_:e.base_;function $l(e,t){if(xi(e))return new Map(e);if(Ci(e))return new Set(e);if(Ai(e))return Array[bi].slice.call(e);let r=_m(e);if(t===!0||t==="class_only"&&!r){let n=xt.getOwnPropertyDescriptors(e);delete n[We];let o=Reflect.ownKeys(n);for(let i=0;i<o.length;i++){let a=o[i],s=n[a];s[Va]===!1&&(s[Va]=!0,s[Gl]=!0),(s.get||s.set)&&(n[a]={[Gl]:!0,[Va]:!0,[Ga]:s[Ga],[hi]:e[a]})}return xt.create(tn(e),n)}else{let n=tn(e);if(n!==null&&r)return{...e};let o=xt.create(n);return xt.assign(o,e)}}function Xl(e,t=!1){return Ya(e)||ft(e)||!ut(e)||(rn(e)>1&&xt.defineProperties(e,{set:Ua,add:Ua,clear:Ua,delete:Ua}),xt.freeze(e),t&&wi(e,(r,n)=>{Xl(n,!0)},!1)),e}function Ix(){tt(2)}var Ua={[hi]:Ix};function Ya(e){return e===null||!Zn(e)?!0:xt.isFrozen(e)}var Qa="MapSet",Ha="Patches",xm="ArrayMethods",za={};function nn(e){let t=za[e];return t||tt(0,e),t}var Cm=e=>!!za[e];function Tx(e,t){za[e]||(za[e]=t)}var yi,Om=()=>yi,_x=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:Cm(Qa)?nn(Qa):void 0,arrayMethodsPlugin_:Cm(xm)?nn(xm):void 0});function Em(e,t){t&&(e.patchPlugin_=nn(Ha),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function Ql(e){Hl(e),e.drafts_.forEach(kx),e.drafts_=null}function Hl(e){e===yi&&(yi=e.parent_)}var Rm=e=>yi=_x(yi,e);function kx(e){let t=e[We];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function Im(e,t){t.unfinalizedDrafts_=t.drafts_.length;let r=t.drafts_[0];if(e!==void 0&&e!==r){r[We].modified_&&(Ql(t),tt(4)),ut(e)&&(e=Tm(t,e));let{patchPlugin_:o}=t;o&&o.generateReplacementPatches_(r[We].base_,e,t)}else e=Tm(t,r);return Ox(t,e,!0),Ql(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e!==Kl?e:void 0}function Tm(e,t){if(Ya(t))return t;let r=t[We];if(!r)return Wa(t,e.handledSet_,e);if(!Xa(r,e))return t;if(!r.modified_)return r.base_;if(!r.finalized_){let{callbacks_:n}=r;if(n)for(;n.length>0;)n.pop()(e);Fm(r,e)}return r.copy_}function Ox(e,t,r=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&Xl(t,r)}function Pm(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var Xa=(e,t)=>e.scope_===t,Px=[];function Nm(e,t,r,n){let o=sr(e),i=e.type_;if(n!==void 0&&ar(o,n,i)===t){$a(o,n,r,i);return}if(!e.draftLocations_){let s=e.draftLocations_=new Map;wi(o,(c,u)=>{if(ft(u)){let h=s.get(u)||[];h.push(c),s.set(u,h)}})}let a=e.draftLocations_.get(t)??Px;for(let s of a)$a(o,s,r,i)}function Nx(e,t,r){e.callbacks_.push(function(o){let i=t;if(!i||!Xa(i,o))return;o.mapSetPlugin_?.fixSetContents(i);let a=Yl(i);Nm(e,i.draft_??i,a,r),Fm(i,o)})}function Fm(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let o=n.getPath(e);o&&n.generatePatches_(e,o,t)}Pm(e)}}function Fx(e,t,r){let{scope_:n}=e;if(ft(r)){let o=r[We];Xa(o,n)&&o.callbacks_.push(function(){Ba(e);let a=Yl(o);Nm(e,r,a,t)})}else ut(r)&&e.callbacks_.push(function(){let i=sr(e);e.type_===3?i.has(r)&&Wa(r,n.handledSet_,n):ar(i,t,e.type_)===r&&n.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&Wa(ar(e.copy_,t,e.type_),n.handledSet_,n)})}function Wa(e,t,r){return!r.immer_.autoFreeze_&&r.unfinalizedDrafts_<1||ft(e)||t.has(e)||!ut(e)||Ya(e)||(t.add(e),wi(e,(n,o)=>{if(ft(o)){let i=o[We];if(Xa(i,r)){let a=Yl(i);$a(e,n,a,e.type_),Pm(i)}}else ut(o)&&Wa(o,t,r)})),e}function Dx(e,t){let r=Ai(e),n={type_:r?1:0,scope_:t?t.scope_:Om(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},o=n,i=Ka;r&&(o=[n],i=vi);let{revoke:a,proxy:s}=Proxy.revocable(o,i);return n.draft_=s,n.revoke_=a,[s,n]}var Ka={get(e,t){if(t===We)return e;let r=e.scope_.arrayMethodsPlugin_,n=e.type_===1&&typeof t=="string";if(n&&r?.isArrayOperationMethod(t))return r.createMethodInterceptor(e,t);let o=sr(e);if(!Xn(o,t,e.type_))return qx(e,o,t);let i=o[t];if(e.finalized_||!ut(i)||n&&e.operationMethod&&r?.isMutatingArrayMethod(e.operationMethod)&&Ex(t))return i;if(i===Bl(e.base_,t)||Mx(e,t,i)){Ba(e);let a=e.type_===1?+t:t,s=Wl(e.scope_,i,e,a);return e.copy_[a]=s}return i},has(e,t){return t in sr(e)},ownKeys(e){return Reflect.ownKeys(sr(e))},set(e,t,r){let n=Dm(sr(e),t);if(n?.set)return n.set.call(e.draft_,r),!0;if(!e.modified_){let o=Bl(sr(e),t),i=o?.[We];if(i&&i.base_===r)return e.copy_[t]=r,e.assigned_.set(t,!1),!0;if(Cx(r,o)&&(r!==void 0||Xn(e.base_,t,e.type_)))return!0;Ba(e),zl(e)}return e.copy_[t]===r&&(r!==void 0||Xn(e.copy_,t,e.type_))||Number.isNaN(r)&&Number.isNaN(e.copy_[t])||(e.copy_[t]=r,e.assigned_.set(t,!0),Fx(e,t,r)),!0},deleteProperty(e,t){return Ba(e),Bl(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),zl(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let r=sr(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n&&{[Va]:!0,[Gl]:e.type_!==1||t!=="length",[Ga]:n[Ga],[hi]:r[t]}},defineProperty(){tt(11)},getPrototypeOf(e){return tn(e.base_)},setPrototypeOf(){tt(12)}},vi={};for(let e in Ka){let t=Ka[e];vi[e]=function(){let r=arguments;return r[0]=r[0][0],t.apply(this,r)}}vi.deleteProperty=function(e,t){return vi.set.call(this,e,t,void 0)};vi.set=function(e,t,r){return Ka.set.call(this,e[0],t,r,e[0])};function Bl(e,t){let r=e[We];return(r?sr(r):e)[t]}function Mx(e,t,r){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!ut(r)||r[We]?!1:e.baseRefs_.has(r)}function qx(e,t,r){let n=Dm(t,r);return n?hi in n?n[hi]:n.get?.call(e.draft_):void 0}function Dm(e,t){if(!(t in e))return;let r=tn(e);for(;r;){let n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=tn(r)}}function zl(e){e.modified_||(e.modified_=!0,e.parent_&&zl(e.parent_))}function Ba(e){e.copy_||(e.assigned_=new Map,e.copy_=$l(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var jx=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(t,r,n)=>{if(en(t)&&!en(r)){let i=r;r=t;let a=this;return function(c=i,...u){return a.produce(c,h=>r.call(this,h,...u))}}en(r)||tt(6),n!==void 0&&!en(n)&&tt(7);let o;if(ut(t)){let i=Rm(this),a=Wl(i,t,void 0),s=!0;try{o=r(a),s=!1}finally{s?Ql(i):Hl(i)}return Em(i,n),Im(o,i)}else if(!t||!Zn(t)){if(o=r(t),o===void 0&&(o=t),o===Kl&&(o=void 0),this.autoFreeze_&&Xl(o,!0),n){let i=[],a=[];nn(Ha).generateReplacementPatches_(t,o,{patches_:i,inversePatches_:a}),n(i,a)}return o}else tt(1,t)},this.produceWithPatches=(t,r)=>{if(en(t))return(a,...s)=>this.produceWithPatches(a,c=>t(c,...s));let n,o;return[this.produce(t,r,(a,s)=>{n=a,o=s}),n,o]},Vl(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),Vl(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),Vl(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){ut(e)||tt(8),ft(e)&&(e=Za(e));let t=Rm(this),r=Wl(t,e,void 0);return r[We].isManual_=!0,Hl(t),r}finishDraft(e,t){let r=e&&e[We];(!r||!r.isManual_)&&tt(9);let{scope_:n}=r;return Em(n,t),Im(void 0,n)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let r;for(r=t.length-1;r>=0;r--){let o=t[r];if(o.path.length===0&&o.op==="replace"){e=o.value;break}}r>-1&&(t=t.slice(r+1));let n=nn(Ha).applyPatches_;return ft(e)?n(e,t):this.produce(e,o=>n(o,t))}};function Wl(e,t,r,n){let[o,i]=xi(t)?nn(Qa).proxyMap_(t,r):Ci(t)?nn(Qa).proxySet_(t,r):Dx(t,r);return(r?.scope_??Om()).drafts_.push(o),i.callbacks_=r?.callbacks_??[],i.key_=n,r&&n!==void 0?Nx(r,i,n):i.callbacks_.push(function(c){c.mapSetPlugin_?.fixSetContents(i);let{patchPlugin_:u}=c;i.modified_&&u&&u.generatePatches_(i,[],c)}),o}function Za(e){return ft(e)||tt(10,e),Mm(e)}function Mm(e){if(!ut(e)||Ya(e))return e;let t=e[We],r,n=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,r=$l(e,t.scope_.immer_.useStrictShallowCopy_),n=t.scope_.immer_.shouldUseStrictIteration()}else r=$l(e,!0);return wi(r,(o,i)=>{$a(r,o,Mm(i))},n),t&&(t.finalized_=!1),r}function qm(){function t(y,S=[]){if(y.key_!==void 0){let E=y.parent_.copy_??y.parent_.base_,R=Rx(ar(E,y.key_)),k=ar(E,y.key_);if(k===void 0||k!==y.draft_&&k!==y.base_&&k!==y.copy_||R!=null&&R.base_!==y.base_)return null;let I=y.parent_.type_===3,T;if(I){let _=y.parent_;T=Array.from(_.drafts_.keys()).indexOf(y.key_)}else T=y.key_;if(!(I&&E.size>T||Xn(E,T)))return null;S.push(T)}if(y.parent_)return t(y.parent_,S);S.reverse();try{r(y.copy_,S)}catch{return null}return S}function r(y,S){let E=y;for(let R=0;R<S.length-1;R++){let k=S[R];if(E=ar(E,k),!Zn(E)||E===null)throw new Error(`Cannot resolve path at '${S.join("/")}'`)}return E}let n="replace",o="add",i="remove";function a(y,S,E){if(y.scope_.processedForPatches_.has(y))return;y.scope_.processedForPatches_.add(y);let{patches_:R,inversePatches_:k}=E;switch(y.type_){case 0:case 2:return c(y,S,R,k);case 1:return s(y,S,R,k);case 3:return u(y,S,R,k)}}function s(y,S,E,R){let{base_:k,assigned_:I}=y,T=y.copy_;T.length<k.length&&([k,T]=[T,k],[E,R]=[R,E]);let _=y.allIndicesReassigned_===!0;for(let D=0;D<k.length;D++){let G=T[D],V=k[D];if((_||I?.get(D.toString()))&&G!==V){let L=G?.[We];if(L&&L.modified_)continue;let q=S.concat([D]);E.push({op:n,path:q,value:g(G)}),R.push({op:n,path:q,value:g(V)})}}for(let D=k.length;D<T.length;D++){let G=S.concat([D]);E.push({op:o,path:G,value:g(T[D])})}for(let D=T.length-1;k.length<=D;--D){let G=S.concat([D]);R.push({op:i,path:G})}}function c(y,S,E,R){let{base_:k,copy_:I,type_:T}=y;wi(y.assigned_,(_,D)=>{let G=ar(k,_,T),V=ar(I,_,T),j=D?Xn(k,_)?n:o:i;if(G===V&&j===n)return;let L=S.concat(_);E.push(j===i?{op:j,path:L}:{op:j,path:L,value:g(V)}),R.push(j===o?{op:i,path:L}:j===i?{op:o,path:L,value:g(G)}:{op:n,path:L,value:g(G)})})}function u(y,S,E,R){let{base_:k,copy_:I}=y,T=0;k.forEach(_=>{if(!I.has(_)){let D=S.concat([T]);E.push({op:i,path:D,value:_}),R.unshift({op:o,path:D,value:_})}T++}),T=0,I.forEach(_=>{if(!k.has(_)){let D=S.concat([T]);E.push({op:o,path:D,value:_}),R.unshift({op:i,path:D,value:_})}T++})}function h(y,S,E){let{patches_:R,inversePatches_:k}=E;R.push({op:n,path:[],value:S===Kl?void 0:S}),k.push({op:n,path:[],value:y})}function v(y,S){return S.forEach(E=>{let{path:R,op:k}=E,I=y;for(let G=0;G<R.length-1;G++){let V=rn(I),j=R[G];typeof j!="string"&&typeof j!="number"&&(j=""+j),(V===0||V===1)&&(j==="__proto__"||j===gi)&&tt(19),en(I)&&j===bi&&tt(19),I=ar(I,j),(I===null||!Zn(I))&&tt(18,R.join("/"))}let T=rn(I),_=C(E.value),D=R[R.length-1];switch(k){case n:switch(T){case 2:return I.set(D,_);case 3:tt(16);default:return I[D]=_}case o:switch(T){case 1:return D==="-"?I.push(_):I.splice(D,0,_);case 2:return I.set(D,_);case 3:return I.add(_);default:return I[D]=_}case i:switch(T){case 1:return I.splice(D,1);case 2:return I.delete(D);case 3:return I.delete(E.value);default:return delete I[D]}default:tt(17,k)}}),y}function C(y){if(!ut(y))return y;if(Ai(y))return y.map(C);if(xi(y))return new Map(Array.from(y.entries()).map(([E,R])=>[E,C(R)]));if(Ci(y))return new Set(Array.from(y).map(C));let S=Object.create(tn(y));for(let E in y)S[E]=C(y[E]);return Xn(y,mi)&&(S[mi]=y[mi]),S}function g(y){return ft(y)?C(y):y}Tx(Ha,{applyPatches_:v,generatePatches_:a,generateReplacementPatches_:h,getPath:t})}var Lx=w.Iterator,rq=typeof Lx?.from=="function";var Si=new jx,on=Si.produce,Zl=Si.produceWithPatches.bind(Si);var Jl=Si.applyPatches.bind(Si);m();d();f();p();function Ux(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!="function")throw new TypeError(t)}function Vx(e,t="expected all items to be functions, instead received the following types: "){if(!e.every(r=>typeof r=="function")){let r=e.map(n=>typeof n=="function"?`function ${n.name||"unnamed"}()`:typeof n).join(", ");throw new TypeError(`${t}[${r}]`)}}var jm=e=>Array.isArray(e)?e:[e];function Bx(e){let t=Array.isArray(e[0])?e[0]:e;return Vx(t,"createSelector expects all input-selectors to be functions, but received the following types: "),t}function Gx(e,t){let r=[],{length:n}=e;for(let o=0;o<n;o++)r.push(e[o].apply(null,t));return r}var $x=class{constructor(e){this.value=e}deref(){return this.value}},Qx=()=>typeof WeakRef>"u"?$x:WeakRef,Um=Qx(),Hx=0,Lm=1;function Ja(){return{s:Hx,v:void 0,o:null,p:null}}function zx(e){return e instanceof Um?e.deref():e}function Ei(e,t={}){let r=Ja(),{resultEqualityCheck:n}=t,o,i=0;function a(){let s=r,{length:c}=arguments;for(let v=0,C=c;v<C;v++){let g=arguments[v];if(typeof g=="function"||typeof g=="object"&&g!==null){let y=s.o;y===null&&(s.o=y=new WeakMap);let S=y.get(g);S===void 0?(s=Ja(),y.set(g,s)):s=S}else{let y=s.p;y===null&&(s.p=y=new Map);let S=y.get(g);S===void 0?(s=Ja(),y.set(g,s)):s=S}}let u=s,h;if(s.s===Lm)h=s.v;else if(h=e.apply(null,arguments),i++,n){let v=zx(o);v!=null&&n(v,h)&&(h=v,i!==0&&i--),o=typeof h=="object"&&h!==null||typeof h=="function"?new Um(h):h}return u.s=Lm,u.v=h,h}return a.clearCache=()=>{r=Ja(),a.resetResultsCount()},a.resultsCount=()=>i,a.resetResultsCount=()=>{i=0},a}function Wx(e,...t){let r=typeof e=="function"?{memoize:e,memoizeOptions:t}:e,n=(...o)=>{let i=0,a=0,s,c={},u=o.pop();typeof u=="object"&&(c=u,u=o.pop()),Ux(u,`createSelector expects an output function after the inputs, but received: [${typeof u}]`);let h={...r,...c},{memoize:v,memoizeOptions:C=[],argsMemoize:g=Ei,argsMemoizeOptions:y=[]}=h,S=jm(C),E=jm(y),R=Bx(o),k=v(function(){return i++,u.apply(null,arguments)},...S),I=!0,T=g(function(){a++;let D=Gx(R,arguments);return s=k.apply(null,D),s},...E);return Object.assign(T,{resultFunc:u,memoizedResultFunc:k,dependencies:R,dependencyRecomputations:()=>a,resetDependencyRecomputations:()=>{a=0},lastResult:()=>s,recomputations:()=>i,resetRecomputations:()=>{i=0},memoize:v,argsMemoize:g})};return Object.assign(n,{withTypes:()=>n}),n}var $e=Wx(Ei);m();d();f();p();function Vm(e){return({dispatch:r,getState:n})=>o=>i=>typeof i=="function"?i(r,n,e):o(i)}var Bm=Vm(),Gm=Vm;var Kx=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]=="object"?pi:pi.apply(null,arguments)},Rq=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__:function(){return function(e){return e}},Yx=e=>e&&typeof e.match=="function";function O(e,t){function r(...n){if(t){let o=t(...n);if(!o)throw new Error(mt(0));return{type:e,payload:o.payload,...("meta"in o&&{meta:o.meta}),...("error"in o&&{error:o.error})}}return{type:e,payload:n[0]}}return r.toString=()=>`${e}`,r.type=e,r.match=n=>fi(n)&&n.type===e,r}var Xm=class Ri extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,Ri.prototype)}static get[Symbol.species](){return Ri}concat(...t){return super.concat.apply(this,t)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new Ri(...t[0].concat(this)):new Ri(...t.concat(this))}};function $m(e){return ut(e)?on(e,()=>{}):e}function es(e,t,r){return e.has(t)?e.get(t):e.set(t,r(t)).get(t)}function Xx(e){return typeof e=="boolean"}var Zx=()=>function(t){let{thunk:r=!0,immutableCheck:n=!0,serializableCheck:o=!0,actionCreatorCheck:i=!0}=t??{},a=new Xm;return r&&(Xx(r)?a.push(Bm):a.push(Gm(r.extraArgument))),a},Ii="RTK_autoBatch",to=()=>e=>({payload:e,meta:{[Ii]:!0}}),Qm=e=>t=>{setTimeout(t,e)},Jx=(e,t)=>r=>{let n=!1,o=()=>{n||(n=!0,cancelAnimationFrame(i),clearTimeout(a),r())},i=e(o),a=setTimeout(o,t)},eC=(e={type:"raf"})=>t=>(...r)=>{let n=t(...r),o=!0,i=!1,a=!1,s=new Set,c=e.type==="tick"?queueMicrotask:e.type==="raf"?typeof window<"u"&&window.requestAnimationFrame?Jx(window.requestAnimationFrame,100):Qm(10):e.type==="callback"?e.queueNotification:Qm(e.timeout),u=()=>{a=!1,i&&(i=!1,s.forEach(h=>h()))};return Object.assign({},n,{subscribe(h){let v=()=>o&&h(),C=n.subscribe(v);return s.add(h),()=>{C(),s.delete(h)}},dispatch(h){try{return o=!h?.meta?.[Ii],i=!o,i&&(a||(a=!0,c(u))),n.dispatch(h)}finally{o=!0}}})},tC=e=>function(r){let{autoBatch:n=!0}=r??{},o=new Xm(e);return n&&o.push(eC(typeof n=="object"?n:void 0)),o};function Zm(e){let t=Zx(),{reducer:r=void 0,middleware:n,devTools:o=!0,duplicateMiddlewareCheck:i=!0,preloadedState:a=void 0,enhancers:s=void 0}=e||{},c;if(typeof r=="function")c=r;else if(Ht(r))c=Yn(r);else throw new Error(mt(1));let u;typeof n=="function"?u=n(t):u=t();let h=pi;o&&(h=Kx({trace:!1,...(typeof o=="object"&&o)}));let v=wm(...u),C=tC(v),g=typeof s=="function"?s(C):C(),y=h(...g);return Ul(c,a,y)}function Jm(e){let t={},r=[],n,o={addCase(i,a){let s=typeof i=="string"?i:i.type;if(!s)throw new Error(mt(28));if(s in t)throw new Error(mt(29));return t[s]=a,o},addAsyncThunk(i,a){return a.pending&&(t[i.pending.type]=a.pending),a.rejected&&(t[i.rejected.type]=a.rejected),a.fulfilled&&(t[i.fulfilled.type]=a.fulfilled),a.settled&&r.push({matcher:i.settled,reducer:a.settled}),o},addMatcher(i,a){return r.push({matcher:i,reducer:a}),o},addDefaultCase(i){return n=i,o}};return e(o),[t,r,n]}function rC(e){return typeof e=="function"}function Be(e,t){let[r,n,o]=Jm(t),i;if(rC(e))i=()=>$m(e());else{let s=$m(e);i=()=>s}function a(s=i(),c){let u=[r[c.type],...n.filter(({matcher:h})=>h(c)).map(({reducer:h})=>h)];return u.filter(h=>!!h).length===0&&(u=[o]),u.reduce((h,v)=>{if(v)if(ft(h)){let g=v(h,c);return g===void 0?h:g}else{if(ut(h))return on(h,C=>v(C,c));{let C=v(h,c);if(C===void 0){if(h===null)return h;throw Error("A case reducer on a non-draftable value must not return undefined")}return C}}return h},s)}return a.getInitialState=i,a}var eg=(e,t)=>Yx(e)?e.match(t):e(t);function zt(...e){return t=>e.some(r=>eg(r,t))}function eo(...e){return t=>e.every(r=>eg(r,t))}function os(e,t){if(!e||!e.meta)return!1;let r=typeof e.meta.requestId=="string",n=t.indexOf(e.meta.requestStatus)>-1;return r&&n}function Ti(e){return typeof e[0]=="function"&&"pending"in e[0]&&"fulfilled"in e[0]&&"rejected"in e[0]}function is(...e){return e.length===0?t=>os(t,["pending"]):Ti(e)?zt(...e.map(t=>t.pending)):is()(e[0])}function sn(...e){return e.length===0?t=>os(t,["rejected"]):Ti(e)?zt(...e.map(t=>t.rejected)):sn()(e[0])}function _i(...e){let t=r=>r&&r.meta&&r.meta.rejectedWithValue;return e.length===0?eo(sn(...e),t):Ti(e)?eo(sn(...e),t):_i()(e[0])}function cr(...e){return e.length===0?t=>os(t,["fulfilled"]):Ti(e)?zt(...e.map(t=>t.fulfilled)):cr()(e[0])}function as(...e){return e.length===0?t=>os(t,["pending","fulfilled","rejected"]):Ti(e)?zt(...e.flatMap(t=>[t.pending,t.rejected,t.fulfilled])):as()(e[0])}var nC="ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW",ki=(e=21)=>{let t="",r=e;for(;r--;)t+=nC[Math.random()*64|0];return t},oC=["name","message","stack","code"],ed=class{constructor(e,t){ae(this,"payload");ae(this,"meta");ae(this,"_type");this.payload=e,this.meta=t}},Hm=class{constructor(e,t){ae(this,"payload");ae(this,"meta");ae(this,"_type");this.payload=e,this.meta=t}},iC=e=>{if(typeof e=="object"&&e!==null){let t={};for(let r of oC)typeof e[r]=="string"&&(t[r]=e[r]);return t}return{message:String(e)}},zm="External signal was aborted",Ie=(()=>{function e(t,r,n){let o=O(t+"/fulfilled",(c,u,h,v)=>({payload:c,meta:{...(v||{}),arg:h,requestId:u,requestStatus:"fulfilled"}})),i=O(t+"/pending",(c,u,h)=>({payload:void 0,meta:{...(h||{}),arg:u,requestId:c,requestStatus:"pending"}})),a=O(t+"/rejected",(c,u,h,v,C)=>({payload:v,error:(n&&n.serializeError||iC)(c||"Rejected"),meta:{...(C||{}),arg:h,requestId:u,rejectedWithValue:!!v,requestStatus:"rejected",aborted:c?.name==="AbortError",condition:c?.name==="ConditionError"}}));function s(c,{signal:u}={}){return(h,v,C)=>{let g=n?.idGenerator?n.idGenerator(c):ki(),y=new l.AbortController,S,E;function R(I){E=I,y.abort()}u&&(u.aborted?R(zm):u.addEventListener("abort",()=>R(zm),{once:!0}));let k=_asyncToGenerator(function*(){let I;try{let _=n?.condition?.(c,{getState:v,extra:C});if(sC(_)&&(_=yield _),_===!1||y.signal.aborted)throw{name:"ConditionError",message:"Aborted due to condition callback returning false."};let D=new Promise((G,V)=>{S=()=>{V({name:"AbortError",message:E||"Aborted"})},y.signal.addEventListener("abort",S,{once:!0})});h(i(g,c,n?.getPendingMeta?.({requestId:g,arg:c},{getState:v,extra:C}))),I=yield Promise.race([D,Promise.resolve(r(c,{dispatch:h,getState:v,extra:C,requestId:g,signal:y.signal,abort:R,rejectWithValue:(G,V)=>new ed(G,V),fulfillWithValue:(G,V)=>new Hm(G,V)})).then(G=>{if(G instanceof ed)throw G;return G instanceof Hm?o(G.payload,g,c,G.meta):o(G,g,c)})])}catch(_){I=_ instanceof ed?a(null,g,c,_.payload,_.meta):a(_,g,c)}finally{S&&y.signal.removeEventListener("abort",S)}return n&&!n.dispatchConditionRejection&&a.match(I)&&I.meta.condition||h(I),I})();return Object.assign(k,{abort:R,requestId:g,arg:c,unwrap(){return k.then(aC)}})}}return Object.assign(s,{pending:i,rejected:a,fulfilled:o,settled:zt(a,o),typePrefix:t})}return e.withTypes=()=>e,e})();function aC(e){if(e.meta&&e.meta.rejectedWithValue)throw e.payload;if(e.error)throw e.error;return e.payload}function sC(e){return e!==null&&typeof e=="object"&&typeof e.then=="function"}var tg=Symbol.for("rtk-slice-createasyncthunk"),Tq={[tg]:Ie};function cC(e,t){return`${e}/${t}`}function uC({creators:e}={}){let t=e?.asyncThunk?.[tg];return function(n){let{name:o,reducerPath:i=o}=n;if(!o)throw new Error(mt(11));typeof process<"u";let a=(typeof n.reducers=="function"?n.reducers(dC()):n.reducers)||{},s=Object.keys(a),c={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},u={addCase(I,T){let _=typeof I=="string"?I:I.type;if(!_)throw new Error(mt(12));if(_ in c.sliceCaseReducersByType)throw new Error(mt(13));return c.sliceCaseReducersByType[_]=T,u},addMatcher(I,T){return c.sliceMatchers.push({matcher:I,reducer:T}),u},exposeAction(I,T){return c.actionCreators[I]=T,u},exposeCaseReducer(I,T){return c.sliceCaseReducersByName[I]=T,u}};s.forEach(I=>{let T=a[I],_={reducerName:I,type:cC(o,I),createNotation:typeof n.reducers=="function"};fC(T)?gC(_,T,u,t):pC(_,T,u)});function h(){let[I={},T=[],_=void 0]=typeof n.extraReducers=="function"?Jm(n.extraReducers):[n.extraReducers],D={...I,...c.sliceCaseReducersByType};return Be(n.initialState,G=>{for(let V in D)G.addCase(V,D[V]);for(let V of c.sliceMatchers)G.addMatcher(V.matcher,V.reducer);for(let V of T)G.addMatcher(V.matcher,V.reducer);_&&G.addDefaultCase(_)})}let v=I=>I,C=new Map,g=new WeakMap,y;function S(I,T){return y||(y=h()),y(I,T)}function E(){return y||(y=h()),y.getInitialState()}function R(I,T=!1){function _(G){let V=G[I];return typeof V>"u"&&T&&(V=es(g,_,E)),V}function D(G=v){let V=es(C,T,()=>new WeakMap);return es(V,G,()=>{let j={};for(let[L,q]of Object.entries(n.selectors??{}))j[L]=lC(q,G,()=>es(g,G,E),T);return j})}return{reducerPath:I,getSelectors:D,get selectors(){return D(_)},selectSlice:_}}let k={name:o,reducer:S,actions:c.actionCreators,caseReducers:c.sliceCaseReducersByName,getInitialState:E,...R(i),injectInto(I,{reducerPath:T,..._}={}){let D=T??i;return I.inject({reducerPath:D,reducer:S},_),{...k,...R(D,!0)}}};return k}}function lC(e,t,r,n){function o(i,...a){let s=t(i);return typeof s>"u"&&n&&(s=r()),e(s,...a)}return o.unwrapped=e,o}var cn=uC();function dC(){function e(t,r){return{_reducerDefinitionType:"asyncThunk",payloadCreator:t,...r}}return e.withTypes=()=>e,{reducer(t){return Object.assign({[t.name](...r){return t(...r)}}[t.name],{_reducerDefinitionType:"reducer"})},preparedReducer(t,r){return{_reducerDefinitionType:"reducerWithPrepare",prepare:t,reducer:r}},asyncThunk:e}}function pC({type:e,reducerName:t,createNotation:r},n,o){let i,a;if("reducer"in n){if(r&&!mC(n))throw new Error(mt(17));i=n.reducer,a=n.prepare}else i=n;o.addCase(e,i).exposeCaseReducer(t,i).exposeAction(t,a?O(e,a):O(e))}function fC(e){return e._reducerDefinitionType==="asyncThunk"}function mC(e){return e._reducerDefinitionType==="reducerWithPrepare"}function gC({type:e,reducerName:t},r,n,o){if(!o)throw new Error(mt(18));let{payloadCreator:i,fulfilled:a,pending:s,rejected:c,settled:u,options:h}=r,v=o(e,i,h);n.exposeAction(t,v),a&&n.addCase(v.fulfilled,a),s&&n.addCase(v.pending,s),c&&n.addCase(v.rejected,c),u&&n.addMatcher(v.settled,u),n.exposeCaseReducer(t,{fulfilled:a||ts,pending:s||ts,rejected:c||ts,settled:u||ts})}function ts(){}var hC="task",rg="listener",ng="completed",nd="cancelled",yC=`task-${nd}`,vC=`task-${ng}`,td=`${rg}-${nd}`,SC=`${rg}-${ng}`,ss=class{constructor(e){ae(this,"code");ae(this,"name","TaskAbortError");ae(this,"message");this.code=e,this.message=`${hC} ${nd} (reason: ${e})`}},od=(e,t)=>{if(typeof e!="function")throw new TypeError(mt(32))},rs=()=>{},og=(e,t=rs)=>(e.catch(t),e),ig=(e,t)=>(e.addEventListener("abort",t,{once:!0}),()=>e.removeEventListener("abort",t)),an=e=>{if(e.aborted)throw new ss(e.reason)};function ag(e,t){let r=rs;return new Promise((n,o)=>{let i=()=>o(new ss(e.reason));if(e.aborted){i();return}r=ig(e,i),t.finally(()=>r()).then(n,o)}).finally(()=>{r=rs})}var bC=/*#__PURE__*/function(){var _ref5=_asyncToGenerator(function*(e,t){try{return yield Promise.resolve(),{status:"ok",value:yield e()}}catch(r){return{status:r instanceof ss?"cancelled":"rejected",error:r}}finally{t?.()}});return function bC(_x5,_x6){return _ref5.apply(this,arguments)}}(),ns=e=>t=>og(ag(e,t).then(r=>(an(e),r))),sg=e=>{let t=ns(e);return r=>t(new Promise(n=>setTimeout(n,r)))},{assign:Jn}=Object,Wm={},cs="listenerMiddleware",wC=(e,t)=>{let r=n=>ig(e,()=>n.abort(e.reason));return(n,o)=>{od(n,"taskExecutor");let i=new l.AbortController;r(i);let a=bC(/*#__PURE__*/_asyncToGenerator(function*(){an(e),an(i.signal);let s=yield n({pause:ns(i.signal),delay:sg(i.signal),signal:i.signal});return an(i.signal),s}),()=>i.abort(vC));return o?.autoJoin&&t.push(a.catch(rs)),{result:ns(e)(a),cancel(){i.abort(yC)}}}},AC=(e,t)=>{let r=/*#__PURE__*/function(){var _ref7=_asyncToGenerator(function*(n,o){an(t);let i=()=>{},s=[new Promise((c,u)=>{let h=e({predicate:n,effect:(v,C)=>{C.unsubscribe(),c([v,C.getState(),C.getOriginalState()])}});i=()=>{h(),u()}})];o!=null&&s.push(new Promise(c=>setTimeout(c,o,null)));try{let c=yield ag(t,Promise.race(s));return an(t),c}finally{i()}});return function r(_x7,_x8){return _ref7.apply(this,arguments)}}();return(n,o)=>og(r(n,o))},cg=e=>{let{type:t,actionCreator:r,matcher:n,predicate:o,effect:i}=e;if(t)o=O(t).match;else if(r)t=r.type,o=r.match;else if(n)o=n;else if(!o)throw new Error(mt(21));return od(i,"options.listener"),{predicate:o,type:t,effect:i}},ug=Jn(e=>{let{type:t,predicate:r,effect:n}=cg(e);return{id:ki(),effect:n,type:t,predicate:r,pending:new Set,unsubscribe:()=>{throw new Error(mt(22))}}},{withTypes:()=>ug}),Km=(e,t)=>{let{type:r,effect:n,predicate:o}=cg(t);return Array.from(e.values()).find(i=>(typeof r=="string"?i.type===r:i.predicate===o)&&i.effect===n)},rd=e=>{e.pending.forEach(t=>{t.abort(td)})},xC=(e,t)=>()=>{for(let r of t.keys())rd(r);e.clear()},Ym=(e,t,r)=>{try{e(t,r)}catch(n){setTimeout(()=>{throw n},0)}},lg=Jn(O(`${cs}/add`),{withTypes:()=>lg}),CC=O(`${cs}/removeAll`),dg=Jn(O(`${cs}/remove`),{withTypes:()=>dg}),EC=(...e)=>{console.error(`${cs}/error`,...e)},pg=(e={})=>{let t=new Map,r=new Map,n=g=>{let y=r.get(g)??0;r.set(g,y+1)},o=g=>{let y=r.get(g)??1;y===1?r.delete(g):r.set(g,y-1)},{extra:i,onError:a=EC}=e;od(a,"onError");let s=g=>(g.unsubscribe=()=>t.delete(g.id),t.set(g.id,g),y=>{g.unsubscribe(),y?.cancelActive&&rd(g)}),c=g=>{let y=Km(t,g)??ug(g);return s(y)};Jn(c,{withTypes:()=>c});let u=g=>{let y=Km(t,g);return y&&(y.unsubscribe(),g.cancelActive&&rd(y)),!!y};Jn(u,{withTypes:()=>u});let h=/*#__PURE__*/function(){var _ref8=_asyncToGenerator(function*(g,y,S,E){let R=new l.AbortController,k=AC(c,R.signal),I=[];try{g.pending.add(R),n(g),yield Promise.resolve(g.effect(y,Jn({},S,{getOriginalState:E,condition:(T,_)=>k(T,_).then(Boolean),take:k,delay:sg(R.signal),pause:ns(R.signal),extra:i,signal:R.signal,fork:wC(R.signal,I),unsubscribe:g.unsubscribe,subscribe:()=>{t.set(g.id,g)},cancelActiveListeners:()=>{g.pending.forEach((T,_,D)=>{T!==R&&(T.abort(td),D.delete(T))})},cancel:()=>{R.abort(td),g.pending.delete(R)},throwIfCancelled:()=>{an(R.signal)}})))}catch(T){T instanceof ss||Ym(a,T,{raisedBy:"effect"})}finally{yield Promise.all(I),R.abort(SC),o(g),g.pending.delete(R)}});return function h(_x9,_x0,_x1,_x10){return _ref8.apply(this,arguments)}}(),v=xC(t,r);return{middleware:g=>y=>S=>{if(!fi(S))return y(S);if(lg.match(S))return c(S.payload);if(CC.match(S)){v();return}if(dg.match(S))return u(S.payload);let E=g.getState(),R=()=>{if(E===Wm)throw new Error(mt(23));return E},k;try{if(k=y(S),t.size>0){let I=g.getState(),T=Array.from(t.values());for(let _ of T){let D=!1;try{D=_.predicate(S,I,E)}catch(G){D=!1,Ym(a,G,{raisedBy:"predicate"})}D&&h(_,S,g,R)}}}finally{E=Wm}return k},startListening:c,stopListening:u,clearListeners:v}};function mt(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}m();d();f();p();var Y=new z({required:!0,emptyAllowed:!1}),rt=new z({required:!1,emptyAllowed:!1}),nt=new z({required:!0,emptyAllowed:!0}),Uq=new z({required:!1,emptyAllowed:!0}),us=new Se({each:Y,required:!0}),fg=new z({required:!1,emptyAllowed:!1,regex:/^\d+\.\d+\.\d+$/}),mg=new z({required:!1,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),Vq=new z({required:!0,emptyAllowed:!1,regex:/^[a-zA-Z0-9_\-.]{1,100}$/}),ur=({message:e,name:t,stack:r})=>({message:e,name:t,stack:r}),Tt=(e,t)=>{if("required"in t)return{payload:new ht({value:t}).validate({value:e}).value};let o=new ne({options:{required:!0},values:t}).validate(e);if(o)throw new si(o);return{payload:e}},B=(e,t)=>{try{return Tt(e,t)}catch(r){return{payload:e,error:ur(r)}}},gg=(e,t,r,n)=>{let o=`Check the initialState of ${n}`;return yg(e,t,r,o,"Controller initialization error")},hg=(e,t,r,n)=>{let o=`Check the options of ${n}`;return yg(e,t,r,o,"Controller initialization error")},yg=(e,t,r,n,o)=>{try{return t.validate(r,n)}catch(i){throw e.logger.error(i,o),i}};m();d();f();p();var ro="3.55.4",vg=["@coveo/atomic","@coveo/quantic"];var id=()=>rt,Sg=()=>Y,Er=O("configuration/updateBasicConfiguration",e=>B(e,{accessToken:rt,environment:new z({required:!1,constrainTo:["prod","hipaa","stg","dev"]}),organizationId:rt})),Wt=O("configuration/updateSearchConfiguration",e=>B(e,{proxyBaseUrl:new z({required:!1,url:!0}),pipeline:new z({required:!1,emptyAllowed:!0}),searchHub:rt,timezone:rt,locale:rt,authenticationProviders:new Se({required:!1,each:Y})})),RC={enabled:new fe({default:!0}),originContext:id(),originLevel2:id(),originLevel3:id(),proxyBaseUrl:new z({required:!1,url:!0}),runtimeEnvironment:new De,anonymous:new fe({default:!1}),deviceId:rt,userDisplayName:rt,documentLocation:rt,trackingId:mg,analyticsMode:new z({constrainTo:["legacy","next"],required:!1,default:"next"}),source:new ne({options:{required:!1},values:vg.reduce((e,t)=>(e[t]=fg,e),{})})},no=O("configuration/updateAnalyticsConfiguration",e=>B(e,RC)),oo=O("configuration/analytics/disable"),io=O("configuration/analytics/enable"),ls=O("configuration/analytics/originlevel2",e=>B(e,{originLevel2:Sg()})),ds=O("configuration/analytics/originlevel3",e=>B(e,{originLevel3:Sg()})),bg=O("knowledge/setAgentId",e=>B(e,new z({required:!0})));m();d();f();p();m();d();f();p();m();d();f();p();var wg={q:new z,enableQuerySyntax:new fe,aq:new z,cq:new z,firstResult:new oe({min:0}),numberOfResults:new oe({min:0}),sortCriteria:new z,f:new ne,fExcluded:new ne,cf:new ne,nf:new ne,mnf:new ne,df:new ne,debug:new fe,sf:new ne,tab:new z,af:new ne};var Rr=O("searchParameters/restore",e=>B(e,wg)),Ag=O("searchParameters/restoreTab",e=>B(e,Y));m();d();f();p();var ps=O("debug/enable"),fs=O("debug/disable");m();d();f();p();var ms=()=>!1;var gs=Be(ms(),e=>{e.addCase(ps,()=>!0).addCase(fs,()=>!1).addCase(Rr,(t,r)=>r.payload.debug??t)});m();d();f();p();var ao=O("pipeline/set",e=>B(e,new z({required:!0,emptyAllowed:!0})));m();d();f();p();m();d();f();p();var IC=O("history/undo"),TC=O("history/redo"),Kt=O("history/snapshot"),Yj=Ie("history/back",/*#__PURE__*/function(){var _ref9=_asyncToGenerator(function*(e,{dispatch:t}){t(IC()),yield t(vt())});return function(_x11,_x12){return _ref9.apply(this,arguments)}}()),Xj=Ie("history/forward",/*#__PURE__*/function(){var _ref0=_asyncToGenerator(function*(e,{dispatch:t}){t(TC()),yield t(vt())});return function(_x13,_x14){return _ref0.apply(this,arguments)}}()),vt=Ie("history/change",/*#__PURE__*/function(){var _ref1=_asyncToGenerator(function*(e,{getState:t}){return t().history.present});return function(_x15,_x16){return _ref1.apply(this,arguments)}}());m();d();f();p();var Ir=()=>"";var so=Be(Ir(),e=>{e.addCase(ao,(t,r)=>r.payload).addCase(vt.fulfilled,(t,r)=>r.payload?.pipeline??t).addCase(Wt,(t,r)=>r.payload.pipeline||t)});m();d();f();p();m();d();f();p();var hs=O("app/setError");m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();function _C(){return typeof navigator<"u"}function xg(){try{return typeof localStorage<"u"}catch{return!1}}function Cg(){try{return typeof sessionStorage<"u"}catch{return!1}}function Eg(){return _C()&&navigator.cookieEnabled}m();d();f();p();var co=class e{static set(t,r,n){var o,i,a,s;n&&(i=new Date,i.setTime(i.getTime()+n)),s=window.location.hostname,s.indexOf(".")===-1?Rg(t,r,i):(a=s.split("."),o=a[a.length-2]+"."+a[a.length-1],Rg(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function Rg(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"+(window.location.protocol==="https:"?";Secure":"")}function Ig(){return xg()?localStorage:Eg()?new ys:Cg()?sessionStorage:new ad}var ys=class e{getItem(t){return co.get(`${e.prefix}${t}`)}removeItem(t){co.erase(`${e.prefix}${t}`)}setItem(t,r,n){co.set(`${e.prefix}${t}`,r,n)}};ys.prefix="coveo_";var ad=class{getItem(t){return null}removeItem(t){}setItem(t,r){}};var vs="__coveo.analytics.history",kC=20,OC=1e3*60,PC=75,Ss=class{constructor(t){this.store=t||Ig()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){var _this9=this;return _asyncToGenerator(function*(){t.internalTime=new Date().getTime(),t=_this9.cropQueryElement(_this9.stripEmptyQuery(t));let r=yield _this9.getHistoryWithInternalTimeAsync();r!=null?_this9.isValidEntry(t)&&_this9.setHistory([t].concat(r)):_this9.setHistory([t])})()}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){var _this0=this;return _asyncToGenerator(function*(){let t=yield _this0.getHistoryWithInternalTimeAsync();return _this0.stripEmptyQueries(_this0.stripInternalTime(t))})()}getHistoryWithInternalTime(){try{let t=this.store.getItem(vs);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){var _this1=this;return _asyncToGenerator(function*(){try{let t=yield _this1.store.getItem(vs);return t?JSON.parse(t):[]}catch{return[]}})()}setHistory(t){try{this.store.setItem(vs,JSON.stringify(t.slice(0,kC)))}catch{}}clear(){try{this.store.removeItem(vs)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,PC)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>OC:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var un=class un extends Ss{static getInstance(t){return un.instance||(un.instance=new un(t)),un.instance}constructor(t){super(t)}};ae(un,"instance",null);var gt=un;m();d();f();p();m();d();f();p();var uo=$e(e=>e.source,e=>Object.entries(e).map(([t,r])=>`${t}@${r}`).concat(`@coveo/headless@${ro}`));m();d();f();p();m();d();f();p();function lr(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r}function U(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function s(h){try{u(n.next(h))}catch(v){a(v)}}function c(h){try{u(n.throw(h))}catch(v){a(v)}}function u(h){h.done?i(h.value):o(h.value).then(s,c)}u((n=n.apply(e,t||[])).next())})}var Ae;(function(e){e.search="search",e.click="click",e.custom="custom",e.view="view",e.collect="collect"})(Ae||(Ae={}));function ud(){return typeof window<"u"}function Ad(){return typeof navigator<"u"}function lo(){return typeof document<"u"}function ld(){try{return typeof localStorage<"u"}catch{return!1}}function NC(){try{return typeof sessionStorage<"u"}catch{return!1}}function Ug(){return Ad()&&navigator.cookieEnabled}var FC=[Ae.click,Ae.custom,Ae.search,Ae.view],DC=(e,t)=>FC.indexOf(e)!==-1?Object.assign({language:lo()?document.documentElement.lang:"unknown",userAgent:Ad()?navigator.userAgent:"unknown"},t):t,Pi=class e{static set(t,r,n){var o,i,a,s;n&&(i=new Date,i.setTime(i.getTime()+n)),s=window.location.hostname,s.indexOf(".")===-1?Tg(t,r,i):(a=s.split("."),o=a[a.length-2]+"."+a[a.length-1],Tg(t,r,i,o))}static get(t){for(var r=t+"=",n=document.cookie.split(";"),o=0;o<n.length;o++){var i=n[o];if(i=i.replace(/^\s+/,""),i.lastIndexOf(r,0)===0)return i.substring(r.length,i.length)}return null}static erase(t){e.set(t,"",-1)}};function Tg(e,t,r,n){document.cookie=`${e}=${t}`+(r?`;expires=${r.toUTCString()}`:"")+(n?`;domain=${n}`:"")+";path=/;SameSite=Lax"+(window.location.protocol==="https:"?";Secure":"")}function MC(){return ld()?localStorage:Ug()?new Ni:NC()?sessionStorage:new fo}var Ni=class e{getItem(t){return Pi.get(`${e.prefix}${t}`)}removeItem(t){Pi.erase(`${e.prefix}${t}`)}setItem(t,r,n){Pi.set(`${e.prefix}${t}`,r,n)}};Ni.prefix="coveo_";var dd=class{constructor(){this.cookieStorage=new Ni}getItem(t){return localStorage.getItem(t)||this.cookieStorage.getItem(t)}removeItem(t){this.cookieStorage.removeItem(t),localStorage.removeItem(t)}setItem(t,r){localStorage.setItem(t,r),this.cookieStorage.setItem(t,r,31556926e3)}},fo=class{getItem(t){return null}removeItem(t){}setItem(t,r){}},bs="__coveo.analytics.history",qC=20,jC=1e3*60,LC=75,As=class{constructor(t){this.store=t||MC()}addElement(t){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=this.getHistoryWithInternalTime();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])}addElementAsync(t){return U(this,void 0,void 0,function*(){t.internalTime=new Date().getTime(),t=this.cropQueryElement(this.stripEmptyQuery(t));let r=yield this.getHistoryWithInternalTimeAsync();r!=null?this.isValidEntry(t)&&this.setHistory([t].concat(r)):this.setHistory([t])})}getHistory(){let t=this.getHistoryWithInternalTime();return this.stripEmptyQueries(this.stripInternalTime(t))}getHistoryAsync(){return U(this,void 0,void 0,function*(){let t=yield this.getHistoryWithInternalTimeAsync();return this.stripEmptyQueries(this.stripInternalTime(t))})}getHistoryWithInternalTime(){try{let t=this.store.getItem(bs);return t&&typeof t=="string"?JSON.parse(t):[]}catch{return[]}}getHistoryWithInternalTimeAsync(){return U(this,void 0,void 0,function*(){try{let t=yield this.store.getItem(bs);return t?JSON.parse(t):[]}catch{return[]}})}setHistory(t){try{this.store.setItem(bs,JSON.stringify(t.slice(0,qC)))}catch{}}clear(){try{this.store.removeItem(bs)}catch{}}getMostRecentElement(){let t=this.getHistoryWithInternalTime();return Array.isArray(t)?t.sort((n,o)=>(o.internalTime||0)-(n.internalTime||0))[0]:null}cropQueryElement(t){return t.name&&t.value&&t.name.toLowerCase()==="query"&&(t.value=t.value.slice(0,LC)),t}isValidEntry(t){let r=this.getMostRecentElement();return r&&r.value==t.value?(t.internalTime||0)-(r.internalTime||0)>jC:!0}stripInternalTime(t){return Array.isArray(t)?t.map(r=>{let{name:n,time:o,value:i}=r;return{name:n,time:o,value:i}}):[]}stripEmptyQuery(t){let{name:r,time:n,value:o}=t;return r&&typeof o=="string"&&r.toLowerCase()==="query"&&o.trim()===""?{name:r,time:n}:t}stripEmptyQueries(t){return t.map(r=>this.stripEmptyQuery(r))}};var UC=(e,t)=>U(void 0,void 0,void 0,function*(){return e===Ae.view?(yield VC(t.contentIdValue),Object.assign({location:window.location.toString(),referrer:document.referrer,title:document.title},t)):t}),VC=e=>U(void 0,void 0,void 0,function*(){let t=new As,r={name:"PageView",value:e,time:new Date().toISOString()};yield t.addElementAsync(r)}),BC=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function xs(e){return typeof e=="string"&&BC.test(e)}function _g(e){if(!xs(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var ot=[];for(let e=0;e<256;++e)ot.push((e+256).toString(16).slice(1));function Vg(e,t=0){return(ot[e[t+0]]+ot[e[t+1]]+ot[e[t+2]]+ot[e[t+3]]+"-"+ot[e[t+4]]+ot[e[t+5]]+"-"+ot[e[t+6]]+ot[e[t+7]]+"-"+ot[e[t+8]]+ot[e[t+9]]+"-"+ot[e[t+10]]+ot[e[t+11]]+ot[e[t+12]]+ot[e[t+13]]+ot[e[t+14]]+ot[e[t+15]]).toLowerCase()}var GC=new Uint8Array(16);function $C(){return crypto.getRandomValues(GC)}function QC(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var HC="6ba7b810-9dad-11d1-80b4-00c04fd430c8",zC="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function WC(e,t,r,n,o,i){let a=typeof r=="string"?QC(r):r,s=typeof n=="string"?_g(n):n;if(typeof n=="string"&&(n=_g(n)),n?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+a.length);return c.set(s),c.set(a,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,Vg(c)}function ln(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():KC(e,t,r)}function KC(e,t,r){e=e||{};let n=e.random??e.rng?.()??$C();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let o=0;o<16;++o)t[r+o]=n[o];return t}return Vg(n)}function YC(e,t,r,n){switch(e){case 0:return t&r^~t&n;case 1:return t^r^n;case 2:return t&r^t&n^r&n;case 3:return t^r^n}}function sd(e,t){return e<<t|e>>>32-t}function XC(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],n=new Uint8Array(e.length+1);n.set(e),n[e.length]=128,e=n;let o=e.length/4+2,i=Math.ceil(o/16),a=new Array(i);for(let s=0;s<i;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];a[s]=c}a[i-1][14]=(e.length-1)*8/2**32,a[i-1][14]=Math.floor(a[i-1][14]),a[i-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<i;++s){let c=new Uint32Array(80);for(let y=0;y<16;++y)c[y]=a[s][y];for(let y=16;y<80;++y)c[y]=sd(c[y-3]^c[y-8]^c[y-14]^c[y-16],1);let u=r[0],h=r[1],v=r[2],C=r[3],g=r[4];for(let y=0;y<80;++y){let S=Math.floor(y/20),E=sd(u,5)+YC(S,h,v,C)+g+t[S]+c[y]>>>0;g=C,C=v,v=sd(h,30)>>>0,h=u,u=E}r[0]=r[0]+u>>>0,r[1]=r[1]+h>>>0,r[2]=r[2]+v>>>0,r[3]=r[3]+C>>>0,r[4]=r[4]+g>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}function Cs(e,t,r,n){return WC(80,XC,e,t)}Cs.DNS=HC;Cs.URL=zC;var Bg="2.33.0",kg=e=>`${e.protocol}//${e.hostname}${e.pathname.indexOf("/")===0?e.pathname:`/${e.pathname}`}${e.search}`,Oi={pageview:"pageview",event:"event"},Es=class{constructor({client:t,uuidGenerator:r=ln}){this.client=t,this.uuidGenerator=r}},pd=class extends Es{constructor({client:t,uuidGenerator:r=ln}){super({client:t,uuidGenerator:r}),this.actionData={},this.pageViewId=r(),this.nextPageViewId=this.pageViewId,this.currentLocation=kg(window.location),this.lastReferrer=lo()?document.referrer:"",this.addHooks()}getApi(t){return t==="setAction"?this.setAction:null}setAction(t,r){this.action=t,this.actionData=r}clearData(){this.clearPluginData(),this.action=void 0,this.actionData={}}getLocationInformation(t,r){return Object.assign({hitType:t},this.getNextValues(t,r))}updateLocationInformation(t,r){this.updateLocationForNextPageView(t,r)}getDefaultContextInformation(t){let r={title:lo()?document.title:"",encoding:lo()?document.characterSet:"UTF-8"},n={screenResolution:`${screen.width}x${screen.height}`,screenColor:`${screen.colorDepth}-bit`},o={language:navigator.language,userAgent:navigator.userAgent},i={time:Date.now(),eventId:this.uuidGenerator()};return Object.assign(Object.assign(Object.assign(Object.assign({},i),n),o),r)}updateLocationForNextPageView(t,r){let{pageViewId:n,referrer:o,location:i}=this.getNextValues(t,r);this.lastReferrer=o,this.pageViewId=n,this.currentLocation=i,t===Oi.pageview&&(this.nextPageViewId=this.uuidGenerator(),this.hasSentFirstPageView=!0)}getNextValues(t,r){return{pageViewId:t===Oi.pageview?this.nextPageViewId:this.pageViewId,referrer:t===Oi.pageview&&this.hasSentFirstPageView?this.currentLocation:this.lastReferrer,location:t===Oi.pageview?this.getCurrentLocationFromPayload(r):this.currentLocation}}getCurrentLocationFromPayload(t){if(t.page){let r=o=>o.replace(/^\/?(.*)$/,"/$1");return`${(o=>o.split("/").slice(0,3).join("/"))(this.currentLocation)}${r(t.page)}`}else return kg(window.location)}},Tr=class e{constructor(t,r){if(!xs(t))throw Error("Not a valid uuid");this.clientId=t,this.creationDate=Math.floor(r/1e3)}toString(){return this.clientId.replace(/-/g,"")+"."+this.creationDate.toString()}get expired(){let t=Math.floor(Date.now()/1e3)-this.creationDate;return t<0||t>e.expirationTime}validate(t,r){return!this.expired&&this.matchReferrer(t,r)}matchReferrer(t,r){try{let n=new URL(t);return r.some(o=>new RegExp(o.replace(/\\/g,"\\\\").replace(/\./g,"\\.").replace(/\*/g,".*")+"$").test(n.host))}catch{return!1}}static fromString(t){let r=t.split(".");if(r.length!==2)return null;let[n,o]=r;if(n.length!==32||isNaN(parseInt(o)))return null;let i=n.substring(0,8)+"-"+n.substring(8,12)+"-"+n.substring(12,16)+"-"+n.substring(16,20)+"-"+n.substring(20,32);return xs(i)?new e(i,Number.parseInt(o)*1e3):null}};Tr.cvo_cid="cvo_cid";Tr.expirationTime=120;var fd=class extends Es{constructor({client:t,uuidGenerator:r=ln}){super({client:t,uuidGenerator:r})}getApi(t){switch(t){case"decorate":return this.decorate;case"acceptFrom":return this.acceptFrom;default:return null}}decorate(t){return U(this,void 0,void 0,function*(){if(!this.client.getCurrentVisitorId)throw new Error("Could not retrieve current clientId");try{let r=new URL(t),n=yield this.client.getCurrentVisitorId();return r.searchParams.set(Tr.cvo_cid,new Tr(n,Date.now()).toString()),r.toString()}catch{throw new Error("Invalid URL provided")}})}acceptFrom(t){this.client.setAcceptedLinkReferrers(t)}};fd.Id="link";var kt=Object.keys;function ws(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}var cd=128,Gg=192,Og=224,Pg=240;function ZC(e){return(e&248)===Pg?4:(e&Pg)===Og?3:(e&Og)===Gg?2:1}function JC(e,t){if(t<0||e.length<=t)return e;let r=e.indexOf("%",t-2);for(r<0||r>t?r=t:t=r;r>2&&e.charAt(r-3)=="%";){let n=Number.parseInt(e.substring(r-2,r),16);if((n&cd)!=cd)break;if(r-=3,(n&Gg)!=cd){t-r>=ZC(n)*3&&(r=t);break}}return e.substring(0,r)}var md={id:"svc_ticket_id",subject:"svc_ticket_subject",description:"svc_ticket_description",category:"svc_ticket_category",productId:"svc_ticket_product_id",custom:"svc_ticket_custom"},eE=kt(md).map(e=>md[e]),tE=[...eE].join("|"),rE=new RegExp(`^(${tE}$)`),nE={svcAction:"svc_action",svcActionData:"svc_action_data"},oE=e=>kt(e).filter(t=>e[t]!==void 0).reduce((t,r)=>{let n=md[r]||r;return Object.assign(Object.assign({},t),{[n]:e[r]})},{}),iE=e=>rE.test(e),aE=[iE],Ng={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",price:"pr",quantity:"qt",coupon:"cc",position:"ps",group:"group"},Fg={id:"id",name:"nm",brand:"br",category:"ca",variant:"va",position:"ps",price:"pr",group:"group"},lt={action:"pa",list:"pal",listSource:"pls"},Rs={id:"ti",revenue:"tr",tax:"tt",shipping:"ts",coupon:"tcc",affiliation:"ta",step:"cos",option:"col"},sE=["loyaltyCardId","loyaltyTier","thirdPartyPersona","companyName","favoriteStore","storeName","userIndustry","userRole","userDepartment","businessUnit"],gd={id:"quoteId",affiliation:"quoteAffiliation"},hd={id:"reviewId",rating:"reviewRating",comment:"reviewComment"},cE={add:lt,bookmark_add:lt,bookmark_remove:lt,click:lt,checkout:lt,checkout_option:lt,detail:lt,impression:lt,remove:lt,refund:Object.assign(Object.assign({},lt),Rs),purchase:Object.assign(Object.assign({},lt),Rs),quickview:lt,quote:Object.assign(Object.assign({},lt),gd),review:Object.assign(Object.assign({},lt),hd)},uE=kt(Ng).map(e=>Ng[e]),lE=kt(Fg).map(e=>Fg[e]),dE=kt(lt).map(e=>lt[e]),pE=kt(Rs).map(e=>Rs[e]),fE=kt(hd).map(e=>hd[e]),mE=kt(gd).map(e=>gd[e]),gE=[...uE,"custom"].join("|"),hE=[...lE,"custom"].join("|"),$g="(pr[0-9]+)",Qg="(il[0-9]+pi[0-9]+)",yE=new RegExp(`^${$g}(${gE})$`),vE=new RegExp(`^(${Qg}(${hE}))|(il[0-9]+nm)$`),SE=new RegExp(`^(${dE.join("|")})$`),bE=new RegExp(`^(${pE.join("|")})$`),wE=new RegExp(`^${$g}custom$`),AE=new RegExp(`^${Qg}custom$`),xE=new RegExp(`^(${[...sE,...fE,...mE].join("|")})$`),CE=e=>yE.test(e),EE=e=>vE.test(e),RE=e=>SE.test(e),IE=e=>bE.test(e),TE=e=>xE.test(e),_E=[EE,CE,RE,IE,TE],kE=[wE,AE],OE={anonymizeIp:"aip"},PE={eventCategory:"ec",eventAction:"ea",eventLabel:"el",eventValue:"ev",page:"dp",visitorId:"cid",clientId:"cid",userId:"uid",currencyCode:"cu"},NE={hitType:"t",pageViewId:"pid",encoding:"de",location:"dl",referrer:"dr",screenColor:"sd",screenResolution:"sr",title:"dt",userAgent:"ua",language:"ul",eventId:"z",time:"tm"},FE=["contentId","contentIdKey","contentType","searchHub","tab","searchUid","permanentId","contentLocale","trackingId"],DE=Object.assign(Object.assign(Object.assign(Object.assign({},OE),PE),NE),FE.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:t}),{})),yd=Object.assign(Object.assign({},DE),nE),ME=e=>{let t=!!e.action&&cE[e.action]||{};return kt(e).reduce((r,n)=>{let o=t[n]||yd[n]||n;return Object.assign(Object.assign({},r),{[o]:e[n]})},{})},qE=kt(yd).map(e=>yd[e]),jE=e=>qE.indexOf(e)!==-1,LE=e=>e==="custom",UE=e=>[..._E,...aE,jE,LE].some(t=>t(e)),VE=e=>kt(e).reduce((t,r)=>{let n=BE(r);return n?Object.assign(Object.assign({},t),GE(n,e[r])):Object.assign(Object.assign({},t),{[r]:e[r]})},{}),BE=e=>{let t;return[...kE].every(r=>{var n;return t=(n=r.exec(e))===null||n===void 0?void 0:n[1],!t}),t},GE=(e,t)=>kt(t).reduce((r,n)=>Object.assign(Object.assign({},r),{[`${e}${n}`]:t[n]}),{}),vd=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){if(!this.isAvailable())throw new Error("navigator.sendBeacon is not supported in this browser. Consider adding a polyfill like \"sendbeacon-polyfill\".");let{baseUrl:n,preprocessRequest:o}=this.opts,i=yield this.getQueryParamsForEventType(t),{url:a,payload:s}=yield this.preProcessRequestAsPotentialJSONString(`${n}/analytics/${t}?${i}`,r,o),c=this.encodeForEventType(t,s),u=new Blob([c],{type:"application/x-www-form-urlencoded"});navigator.sendBeacon(a,u)})}isAvailable(){return"sendBeacon"in navigator}deleteHttpCookieVisitorId(){return Promise.resolve()}preProcessRequestAsPotentialJSONString(t,r,n){return U(this,void 0,void 0,function*(){let o=t,i=r;if(n){let a=yield n({url:t,body:JSON.stringify(r)},"analyticsBeacon"),{url:s,body:c}=a;o=s||t;try{i=JSON.parse(c)}catch(u){console.error("Unable to process the request body as a JSON string",u)}}return{payload:i,url:o}})}encodeForEventType(t,r){return this.isEventTypeLegacy(t)?this.encodeEventToJson(t,r):this.encodeEventToJson(t,r,this.opts.token)}getQueryParamsForEventType(t){return U(this,void 0,void 0,function*(){let{token:r,visitorIdProvider:n}=this.opts,o=yield n.getCurrentVisitorId();return[r&&this.isEventTypeLegacy(t)?`access_token=${r}`:"",o?`visitorId=${o}`:"","discardVisitInfo=true"].filter(i=>!!i).join("&")})}isEventTypeLegacy(t){return[Ae.click,Ae.custom,Ae.search,Ae.view].indexOf(t)!==-1}encodeEventToJson(t,r,n){let o=`${t}Event=${encodeURIComponent(JSON.stringify(r))}`;return n&&(o=`access_token=${encodeURIComponent(n)}&${o}`),o}},Sd=class{sendEvent(t,r){return U(this,void 0,void 0,function*(){return Promise.resolve()})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){return Promise.resolve()})}},Dg=w.fetch,Is=class{constructor(t){this.opts=t}sendEvent(t,r){return U(this,void 0,void 0,function*(){let{baseUrl:n,visitorIdProvider:o,preprocessRequest:i}=this.opts,a=this.shouldAppendVisitorId(t)?yield this.getVisitorIdParam():"",s={url:`${n}/analytics/${t}${a}`,credentials:"include",mode:"cors",headers:this.getHeaders(),method:"POST",body:JSON.stringify(r)},c=Object.assign(Object.assign({},s),i?yield i(s,"analyticsFetch"):{}),{url:u}=c,h=lr(c,["url"]),v;try{v=yield Dg(u,h)}catch(C){console.error("An error has occurred when sending the event.",C);return}if(v.ok){let C=yield v.json();return C.visitorId&&o.setCurrentVisitorId(C.visitorId),C}else{try{v.json()}catch{}throw console.error(`An error has occurred when sending the "${t}" event.`,v,r),new Error(`An error has occurred when sending the "${t}" event. Check the console logs for more details.`)}})}deleteHttpCookieVisitorId(){return U(this,void 0,void 0,function*(){let{baseUrl:t}=this.opts,r=`${t}/analytics/visit`;yield Dg(r,{headers:this.getHeaders(),method:"DELETE"})})}shouldAppendVisitorId(t){return[Ae.click,Ae.custom,Ae.search,Ae.view].indexOf(t)!==-1}getVisitorIdParam(){return U(this,void 0,void 0,function*(){let{visitorIdProvider:t}=this.opts,r=yield t.getCurrentVisitorId();return r?`?visitor=${r}`:""})}getHeaders(){let{token:t}=this.opts;return Object.assign(Object.assign({},t?{Authorization:`Bearer ${t}`}:{}),{"Content-Type":"application/json"})}},bd=class{constructor(t,r){ld()&&Ug()?this.storage=new dd:ld()?this.storage=localStorage:(console.warn("BrowserRuntime detected no valid storage available.",this),this.storage=new fo),this.client=new Is(t),this.beaconClient=new vd(t),window.addEventListener("beforeunload",()=>{let n=r();for(let{eventType:o,payload:i}of n)this.beaconClient.sendEvent(o,i)})}getClientDependingOnEventType(t){return t==="click"&&this.beaconClient.isAvailable()?this.beaconClient:this.client}},wd=class{constructor(t,r){this.storage=r||new fo,this.client=new Is(t)}getClientDependingOnEventType(t){return this.client}},Ts=class{constructor(){this.storage=new fo,this.client=new Sd}getClientDependingOnEventType(t){return this.client}},$E="xx",QE=e=>e?.startsWith($E)||!1,HE=`
28
28
  We've detected you're using React Native but have not provided the corresponding runtime,
29
29
  for an optimal experience please use the "coveo.analytics/react-native" subpackage.
30
30
  Follow the Readme on how to set it up: https://github.com/coveo/coveo.analytics.js#using-react-native
@@ -33,7 +33,7 @@ ${h}`:h;break;case"event":n.event=h;break;case"id":e(n.id=h);break;case"retry":w
33
33
  `)}var aa=function(e){vk(t,e);function t(r,n,o,i,a){var s=this.constructor,c=e.call(this,jv(r,{name:n,index:o,operation:i,tree:a}))||this;return c.name=n,c.index=o,c.operation=i,c.tree=a,Object.setPrototypeOf(c,s.prototype),c.message=jv(r,{name:n,index:o,operation:i,tree:a}),c}return t}(Error);var Qe=aa,bk=ct,qo={add:function(e,t,r){return e[t]=this.value,{newDocument:r}},remove:function(e,t,r){var n=e[t];return delete e[t],{newDocument:r,removed:n}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:function(e,t,r){var n=Tc(r,this.path);n&&(n=ct(n));var o=On(r,{op:"remove",path:this.from}).removed;return On(r,{op:"add",path:this.path,value:o}),{newDocument:r,removed:n}},copy:function(e,t,r){var n=Tc(r,this.from);return On(r,{op:"add",path:this.path,value:ct(n)}),{newDocument:r}},test:function(e,t,r){return{newDocument:r,test:sa(e[t],this.value)}},_get:function(e,t,r){return this.value=e[t],{newDocument:r}}},wk={add:function(e,t,r){return Ic(t)?e.splice(t,0,this.value):e[t]=this.value,{newDocument:r,index:t}},remove:function(e,t,r){var n=e.splice(t,1);return{newDocument:r,removed:n[0]}},replace:function(e,t,r){var n=e[t];return e[t]=this.value,{newDocument:r,removed:n}},move:qo.move,copy:qo.copy,test:qo.test,_get:qo._get};function Tc(e,t){if(t=="")return e;var r={op:"_get",path:t};return On(e,r),r.value}function On(e,t,r,n,o,i){if(r===void 0&&(r=!1),n===void 0&&(n=!0),o===void 0&&(o=!0),i===void 0&&(i=0),r&&(typeof r=="function"?r(t,0,e,t.path):_c(t,0)),t.path===""){var a={newDocument:e};if(t.op==="add")return a.newDocument=t.value,a;if(t.op==="replace")return a.newDocument=t.value,a.removed=e,a;if(t.op==="move"||t.op==="copy")return a.newDocument=Tc(e,t.from),t.op==="move"&&(a.removed=e),a;if(t.op==="test"){if(a.test=sa(e,t.value),a.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a.newDocument=e,a}else{if(t.op==="remove")return a.removed=e,a.newDocument=null,a;if(t.op==="_get")return t.value=e,a;if(r)throw new Qe("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",i,t,e);return a}}else{n||(e=ct(e));var s=t.path||"",c=s.split("/"),u=e,h=1,v=c.length,C=void 0,g=void 0,y=void 0;for(typeof r=="function"?y=r:y=_c;;){if(g=c[h],g&&g.indexOf("~")!=-1&&(g=ia(g)),o&&(g=="__proto__"||g=="prototype"&&h>0&&c[h-1]=="constructor"))throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");if(r&&C===void 0&&(u[g]===void 0?C=c.slice(0,h).join("/"):h==v-1&&(C=t.path),C!==void 0&&y(t,0,e,C)),h++,Array.isArray(u)){if(g==="-")g=u.length;else{if(r&&!Ic(g))throw new Qe("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",i,t,e);Ic(g)&&(g=~~g)}if(h>=v){if(r&&t.op==="add"&&g>u.length)throw new Qe("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",i,t,e);var a=wk[t.op].call(t,u,g,e);if(a.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a}}else if(h>=v){var a=qo[t.op].call(t,u,g,e);if(a.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",i,t,e);return a}if(u=u[g],r&&h<v&&(!u||typeof u!="object"))throw new Qe("Cannot perform operation at the desired path","OPERATION_PATH_UNRESOLVABLE",i,t,e)}}}function kc(e,t,r,n,o){if(n===void 0&&(n=!0),o===void 0&&(o=!0),r&&!Array.isArray(t))throw new Qe("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");n||(e=ct(e));for(var i=new Array(t.length),a=0,s=t.length;a<s;a++)i[a]=On(e,t[a],r,!0,o,a),e=i[a].newDocument;return i.newDocument=e,i}function Ak(e,t,r){var n=On(e,t);if(n.test===!1)throw new Qe("Test operation failed","TEST_OPERATION_FAILED",r,t,e);return n.newDocument}function _c(e,t,r,n){if(typeof e!="object"||e===null||Array.isArray(e))throw new Qe("Operation is not an object","OPERATION_NOT_AN_OBJECT",t,e,r);if(qo[e.op]){if(typeof e.path!="string")throw new Qe("Operation `path` property is not a string","OPERATION_PATH_INVALID",t,e,r);if(e.path.indexOf("/")!==0&&e.path.length>0)throw new Qe("Operation `path` property must start with \"/\"","OPERATION_PATH_INVALID",t,e,r);if((e.op==="move"||e.op==="copy")&&typeof e.from!="string")throw new Qe("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&e.value===void 0)throw new Qe("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",t,e,r);if((e.op==="add"||e.op==="replace"||e.op==="test")&&Cc(e.value))throw new Qe("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",t,e,r);if(r){if(e.op=="add"){var o=e.path.split("/").length,i=n.split("/").length;if(o!==i+1&&o!==i)throw new Qe("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",t,e,r)}else if(e.op==="replace"||e.op==="remove"||e.op==="_get"){if(e.path!==n)throw new Qe("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",t,e,r)}else if(e.op==="move"||e.op==="copy"){var a={op:"_get",path:e.from,value:void 0},s=Lv([a],r);if(s&&s.name==="OPERATION_PATH_UNRESOLVABLE")throw new Qe("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",t,e,r)}}}else throw new Qe("Operation `op` property is not one of operations defined in RFC-6902","OPERATION_OP_INVALID",t,e,r)}function Lv(e,t,r){try{if(!Array.isArray(e))throw new Qe("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(t)kc(ct(t),ct(e),r||!0);else{r=r||_c;for(var n=0;n<e.length;n++)r(e[n],n,t,void 0)}}catch(o){if(o instanceof Qe)return o;throw o}}function sa(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var r=Array.isArray(e),n=Array.isArray(t),o,i,a;if(r&&n){if(i=e.length,i!=t.length)return!1;for(o=i;o--!==0;)if(!sa(e[o],t[o]))return!1;return!0}if(r!=n)return!1;var s=Object.keys(e);if(i=s.length,i!==Object.keys(t).length)return!1;for(o=i;o--!==0;)if(!t.hasOwnProperty(s[o]))return!1;for(o=i;o--!==0;)if(a=s[o],!sa(e[a],t[a]))return!1;return!0}return e!==e&&t!==t}var Mp={};ni(Mp,{compare:()=>kk,generate:()=>Np,observe:()=>_k,unobserve:()=>Tk});m();d();f();p();var Fp=new WeakMap,xk=function(){function e(t){this.observers=new Map,this.obj=t}return e}(),Ck=function(){function e(t,r){this.callback=t,this.observer=r}return e}();function Ek(e){return Fp.get(e)}function Rk(e,t){return e.observers.get(t)}function Ik(e,t){e.observers.delete(t.callback)}function Tk(e,t){t.unobserve()}function _k(e,t){var r=[],n,o=Ek(e);if(!o)o=new xk(e),Fp.set(e,o);else{var i=Rk(o,t);n=i&&i.observer}if(n)return n;if(n={},o.value=ct(e),t){n.callback=t,n.next=null;var a=function(){Np(n)},s=function(){clearTimeout(n.next),n.next=setTimeout(a)};typeof window<"u"&&(window.addEventListener("mouseup",s),window.addEventListener("keyup",s),window.addEventListener("mousedown",s),window.addEventListener("keydown",s),window.addEventListener("change",s))}return n.patches=r,n.object=e,n.unobserve=function(){Np(n),clearTimeout(n.next),Ik(o,n),typeof window<"u"&&(window.removeEventListener("mouseup",s),window.removeEventListener("keyup",s),window.removeEventListener("mousedown",s),window.removeEventListener("keydown",s),window.removeEventListener("change",s))},o.observers.set(t,new Ck(t,n)),n}function Np(e,t){t===void 0&&(t=!1);var r=Fp.get(e.object);Dp(r.value,e.object,e.patches,"",t),e.patches.length&&kc(r.value,e.patches);var n=e.patches;return n.length>0&&(e.patches=[],e.callback&&e.callback(n)),n}function Dp(e,t,r,n,o){if(t!==e){typeof t.toJSON=="function"&&(t=t.toJSON());for(var i=Rc(t),a=Rc(e),s=!1,c=!1,u=a.length-1;u>=0;u--){var h=a[u],v=e[h];if(Ec(t,h)&&!(t[h]===void 0&&v!==void 0&&Array.isArray(t)===!1)){var C=t[h];typeof v=="object"&&v!=null&&typeof C=="object"&&C!=null&&Array.isArray(v)===Array.isArray(C)?Dp(v,C,r,n+"/"+er(h),o):v!==C&&(s=!0,o&&r.push({op:"test",path:n+"/"+er(h),value:ct(v)}),r.push({op:"replace",path:n+"/"+er(h),value:ct(C)}))}else Array.isArray(e)===Array.isArray(t)?(o&&r.push({op:"test",path:n+"/"+er(h),value:ct(v)}),r.push({op:"remove",path:n+"/"+er(h)}),c=!0):(o&&r.push({op:"test",path:n,value:e}),r.push({op:"replace",path:n,value:t}),s=!0)}if(!(!c&&i.length==a.length))for(var u=0;u<i.length;u++){var h=i[u];!Ec(e,h)&&t[h]!==void 0&&r.push({op:"add",path:n+"/"+er(h),value:ct(t[h])})}}}function kk(e,t,r){r===void 0&&(r=!1);var n=[];return Dp(e,t,n,"",r),n}var Oc=Object.assign({},Pp,Mp,{JsonPatchError:aa,deepClone:ct,escapePathComponent:er,unescapePathComponent:ia});m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();var qp=function(e,t){return qp=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(r[o]=n[o])},qp(e,t)};function tr(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");qp(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Uv(e,t,r,n){function o(i){return i instanceof r?i:new r(function(a){a(i)})}return new(r||(r=Promise))(function(i,a){function s(h){try{u(n.next(h))}catch(v){a(v)}}function c(h){try{u(n.throw(h))}catch(v){a(v)}}function u(h){h.done?i(h.value):o(h.value).then(s,c)}u((n=n.apply(e,t||[])).next())})}function Pc(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},n,o,i,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function s(u){return function(h){return c([u,h])}}function c(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(r=0)),r;)try{if(n=1,o&&(i=u[0]&2?o.return:u[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,u[1])).done)return i;switch(o=0,i&&(u=[u[0]&2,i.value]),u[0]){case 0:case 1:i=u;break;case 4:return r.label++,{value:u[1],done:!1};case 5:r.label++,o=u[1],u=[0];continue;case 7:u=r.ops.pop(),r.trys.pop();continue;default:if(i=r.trys,!(i=i.length>0&&i[i.length-1])&&(u[0]===6||u[0]===2)){r=0;continue}if(u[0]===3&&(!i||u[1]>i[0]&&u[1]<i[3])){r.label=u[1];break}if(u[0]===6&&r.label<i[1]){r.label=i[1],i=u;break}if(i&&r.label<i[2]){r.label=i[2],r.ops.push(u);break}i[2]&&r.ops.pop(),r.trys.pop();continue}u=t.call(e,r)}catch(h){u=[6,h],o=0}finally{n=i=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}function Sr(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function jo(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),o,i=[],a;try{for(;(t===void 0||t-->0)&&!(o=n.next()).done;)i.push(o.value)}catch(s){a={error:s}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(a)throw a.error}}return i}function Lo(e,t,r){if(r||arguments.length===2)for(var n=0,o=t.length,i;n<o;n++)(i||!(n in t))&&(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||Array.prototype.slice.call(t))}function Pn(e){return this instanceof Pn?(this.v=e,this):new Pn(e)}function Vv(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),o,i=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),s("next"),s("throw"),s("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(g){return function(y){return Promise.resolve(y).then(g,v)}}function s(g,y){n[g]&&(o[g]=function(S){return new Promise(function(E,R){i.push([g,S,E,R])>1||c(g,S)})},y&&(o[g]=y(o[g])))}function c(g,y){try{u(n[g](y))}catch(S){C(i[0][3],S)}}function u(g){g.value instanceof Pn?Promise.resolve(g.value.v).then(h,v):C(i[0][2],g)}function h(g){c("next",g)}function v(g){c("throw",g)}function C(g,y){g(y),i.shift(),i.length&&c(i[0][0],i[0][1])}}function Bv(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof Sr=="function"?Sr(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(i){r[i]=e[i]&&function(a){return new Promise(function(s,c){a=e[i](a),o(s,c,a.done,a.value)})}}function o(i,a,s,c){Promise.resolve(c).then(function(u){i({value:u,done:s})},a)}}m();d();f();p();function xe(e){return typeof e=="function"}m();d();f();p();m();d();f();p();m();d();f();p();function Uo(e){var t=function(n){Error.call(n),n.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Nc=Uo(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
34
34
  `+r.map(function(n,o){return o+1+") "+n.toString()}).join(`
35
35
  `):"",this.name="UnsubscriptionError",this.errors=r}});m();d();f();p();function ca(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var Vo=function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,n,o,i;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var s=Sr(a),c=s.next();!c.done;c=s.next()){var u=c.value;u.remove(this)}}catch(S){t={error:S}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}else a.remove(this);var h=this.initialTeardown;if(xe(h))try{h()}catch(S){i=S instanceof Nc?S.errors:[S]}var v=this._finalizers;if(v){this._finalizers=null;try{for(var C=Sr(v),g=C.next();!g.done;g=C.next()){var y=g.value;try{Gv(y)}catch(S){i=i??[],S instanceof Nc?i=Lo(Lo([],jo(i)),jo(S.errors)):i.push(S)}}}catch(S){n={error:S}}finally{try{g&&!g.done&&(o=C.return)&&o.call(C)}finally{if(n)throw n.error}}}if(i)throw new Nc(i)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)Gv(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&ca(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&ca(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=function(){var t=new e;return t.closed=!0,t}(),e}();var jp=Vo.EMPTY;function Fc(e){return e instanceof Vo||e&&"closed"in e&&xe(e.remove)&&xe(e.add)&&xe(e.unsubscribe)}function Gv(e){xe(e)?e():e.unsubscribe()}m();d();f();p();var Vt={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1};m();d();f();p();m();d();f();p();var Bo={setTimeout:function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];var o=Bo.delegate;return o?.setTimeout?o.setTimeout.apply(o,Lo([e,t],jo(r))):setTimeout.apply(void 0,Lo([e,t],jo(r)))},clearTimeout:function(e){var t=Bo.delegate;return(t?.clearTimeout||clearTimeout)(e)},delegate:void 0};function Dc(e){Bo.setTimeout(function(){var t=Vt.onUnhandledError;if(t)t(e);else throw e})}m();d();f();p();function ua(){}m();d();f();p();var $v=function(){return Lp("C",void 0,void 0)}();function Qv(e){return Lp("E",void 0,e)}function Hv(e){return Lp("N",e,void 0)}function Lp(e,t,r){return{kind:e,value:t,error:r}}m();d();f();p();var Nn=null;function Go(e){if(Vt.useDeprecatedSynchronousErrorHandling){var t=!Nn;if(t&&(Nn={errorThrown:!1,error:null}),e(),t){var r=Nn,n=r.errorThrown,o=r.error;if(Nn=null,n)throw o}}else e()}function zv(e){Vt.useDeprecatedSynchronousErrorHandling&&Nn&&(Nn.errorThrown=!0,Nn.error=e)}var la=function(e){tr(t,e);function t(r){var n=e.call(this)||this;return n.isStopped=!1,r?(n.destination=r,Fc(r)&&r.add(n)):n.destination=Fk,n}return t.create=function(r,n,o){return new qc(r,n,o)},t.prototype.next=function(r){this.isStopped?Vp(Hv(r),this):this._next(r)},t.prototype.error=function(r){this.isStopped?Vp(Qv(r),this):(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped?Vp($v,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(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(Vo);var Ok=Function.prototype.bind;function Up(e,t){return Ok.call(e,t)}var Pk=function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(n){Mc(n)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(n){Mc(n)}else Mc(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){Mc(r)}},e}(),qc=function(e){tr(t,e);function t(r,n,o){var i=e.call(this)||this,a;if(xe(r)||!r)a={next:r??void 0,error:n??void 0,complete:o??void 0};else{var s;i&&Vt.useDeprecatedNextContext?(s=Object.create(r),s.unsubscribe=function(){return i.unsubscribe()},a={next:r.next&&Up(r.next,s),error:r.error&&Up(r.error,s),complete:r.complete&&Up(r.complete,s)}):a=r}return i.destination=new Pk(a),i}return t}(la);function Mc(e){Vt.useDeprecatedSynchronousErrorHandling?zv(e):Dc(e)}function Nk(e){throw e}function Vp(e,t){var r=Vt.onStoppedNotification;r&&Bo.setTimeout(function(){return r(e,t)})}var Fk={closed:!0,next:ua,error:Nk,complete:ua};m();d();f();p();var $o=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();m();d();f();p();m();d();f();p();function Qo(e){return e}function jc(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return Bp(e)}function Bp(e){return e.length===0?Qo:e.length===1?e[0]:function(r){return e.reduce(function(n,o){return o(n)},r)}}var Ue=function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,n){var o=this,i=Mk(t)?t:new qc(t,r,n);return Go(function(){var a=o,s=a.operator,c=a.source;i.add(s?s.call(i,c):c?o._subscribe(i):o._trySubscribe(i))}),i},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var n=this;return r=Wv(r),new r(function(o,i){var a=new qc({next:function(s){try{t(s)}catch(c){i(c),a.unsubscribe()}},error:i,complete:o});n.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[$o]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return Bp(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=Wv(t),new t(function(n,o){var i;r.subscribe(function(a){return i=a},function(a){return o(a)},function(){return n(i)})})},e.create=function(t){return new e(t)},e}();function Wv(e){var t;return(t=e??Vt.Promise)!==null&&t!==void 0?t:Promise}function Dk(e){return e&&xe(e.next)&&xe(e.error)&&xe(e.complete)}function Mk(e){return e&&e instanceof la||Dk(e)&&Fc(e)}m();d();f();p();function qk(e){return xe(e?.lift)}function ze(e){return function(t){if(qk(t))return t.lift(function(r){try{return e(r,this)}catch(n){this.error(n)}});throw new TypeError("Unable to lift unknown Observable type")}}m();d();f();p();function Ye(e,t,r,n,o){return new jk(e,t,r,n,o)}var jk=function(e){tr(t,e);function t(r,n,o,i,a,s){var c=e.call(this,r)||this;return c.onFinalize=a,c.shouldUnsubscribe=s,c._next=n?function(u){try{n(u)}catch(h){r.error(h)}}:e.prototype._next,c._error=i?function(u){try{i(u)}catch(h){r.error(h)}finally{this.unsubscribe()}}:e.prototype._error,c._complete=o?function(){try{o()}catch(u){r.error(u)}finally{this.unsubscribe()}}:e.prototype._complete,c}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var n=this.closed;e.prototype.unsubscribe.call(this),!n&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t}(la);m();d();f();p();m();d();f();p();var Kv=Uo(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}});var rr=function(e){tr(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var n=new Yv(this,this);return n.operator=r,n},t.prototype._throwIfClosed=function(){if(this.closed)throw new Kv},t.prototype.next=function(r){var n=this;Go(function(){var o,i;if(n._throwIfClosed(),!n.isStopped){n.currentObservers||(n.currentObservers=Array.from(n.observers));try{for(var a=Sr(n.currentObservers),s=a.next();!s.done;s=a.next()){var c=s.value;c.next(r)}}catch(u){o={error:u}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(o)throw o.error}}}})},t.prototype.error=function(r){var n=this;Go(function(){if(n._throwIfClosed(),!n.isStopped){n.hasError=n.isStopped=!0,n.thrownError=r;for(var o=n.observers;o.length;)o.shift().error(r)}})},t.prototype.complete=function(){var r=this;Go(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var n=r.observers;n.length;)n.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var n=this,o=this,i=o.hasError,a=o.isStopped,s=o.observers;return i||a?jp:(this.currentObservers=null,s.push(r),new Vo(function(){n.currentObservers=null,ca(s,r)}))},t.prototype._checkFinalizedStatuses=function(r){var n=this,o=n.hasError,i=n.thrownError,a=n.isStopped;o?r.error(i):a&&r.complete()},t.prototype.asObservable=function(){var r=new Ue;return r.source=this,r},t.create=function(r,n){return new Yv(r,n)},t}(Ue);var Yv=function(e){tr(t,e);function t(r,n){var o=e.call(this)||this;return o.destination=r,o.source=n,o}return t.prototype.next=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.next)===null||o===void 0||o.call(n,r)},t.prototype.error=function(r){var n,o;(o=(n=this.destination)===null||n===void 0?void 0:n.error)===null||o===void 0||o.call(n,r)},t.prototype.complete=function(){var r,n;(n=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||n===void 0||n.call(r)},t.prototype._subscribe=function(r){var n,o;return(o=(n=this.source)===null||n===void 0?void 0:n.subscribe(r))!==null&&o!==void 0?o:jp},t}(rr);m();d();f();p();m();d();f();p();var Gp={now:function(){return(Gp.delegate||Date).now()},delegate:void 0};var Lc=function(e){tr(t,e);function t(r,n,o){r===void 0&&(r=1/0),n===void 0&&(n=1/0),o===void 0&&(o=Gp);var i=e.call(this)||this;return i._bufferSize=r,i._windowTime=n,i._timestampProvider=o,i._buffer=[],i._infiniteTimeWindow=!0,i._infiniteTimeWindow=n===1/0,i._bufferSize=Math.max(1,r),i._windowTime=Math.max(1,n),i}return t.prototype.next=function(r){var n=this,o=n.isStopped,i=n._buffer,a=n._infiniteTimeWindow,s=n._timestampProvider,c=n._windowTime;o||(i.push(r),!a&&i.push(s.now()+c)),this._trimBuffer(),e.prototype.next.call(this,r)},t.prototype._subscribe=function(r){this._throwIfClosed(),this._trimBuffer();for(var n=this._innerSubscribe(r),o=this,i=o._infiniteTimeWindow,a=o._buffer,s=a.slice(),c=0;c<s.length&&!r.closed;c+=i?1:2)r.next(s[c]);return this._checkFinalizedStatuses(r),n},t.prototype._trimBuffer=function(){var r=this,n=r._bufferSize,o=r._timestampProvider,i=r._buffer,a=r._infiniteTimeWindow,s=(a?1:2)*n;if(n<1/0&&s<i.length&&i.splice(0,i.length-s),!a){for(var c=o.now(),u=0,h=1;h<i.length&&i[h]<=c;h+=2)u=h;u&&i.splice(0,u+1)}},t}(rr);m();d();f();p();var Uc=new Ue(function(e){return e.complete()});m();d();f();p();m();d();f();p();m();d();f();p();function Xv(e){return e&&xe(e.schedule)}function Lk(e){return e[e.length-1]}function Zv(e){return Xv(Lk(e))?e.pop():void 0}m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();m();d();f();p();var Vc=function(e){return e&&typeof e.length=="number"&&typeof e!="function"};m();d();f();p();function Bc(e){return xe(e?.then)}m();d();f();p();function Gc(e){return xe(e[$o])}m();d();f();p();function $c(e){return Symbol.asyncIterator&&xe(e?.[Symbol.asyncIterator])}m();d();f();p();function Qc(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}m();d();f();p();m();d();f();p();function Uk(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var Hc=Uk();function zc(e){return xe(e?.[Hc])}m();d();f();p();function Wc(e){return Vv(this,arguments,function(){var r,n,o,i;return Pc(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,Pn(r.read())];case 3:return n=a.sent(),o=n.value,i=n.done,i?[4,Pn(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,Pn(o)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function Kc(e){return xe(e?.getReader)}function Xe(e){if(e instanceof Ue)return e;if(e!=null){if(Gc(e))return Vk(e);if(Vc(e))return Bk(e);if(Bc(e))return Gk(e);if($c(e))return Jv(e);if(zc(e))return $k(e);if(Kc(e))return Qk(e)}throw Qc(e)}function Vk(e){return new Ue(function(t){var r=e[$o]();if(xe(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function Bk(e){return new Ue(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function Gk(e){return new Ue(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Dc)})}function $k(e){return new Ue(function(t){var r,n;try{for(var o=Sr(e),i=o.next();!i.done;i=o.next()){var a=i.value;if(t.next(a),t.closed)return}}catch(s){r={error:s}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}t.complete()})}function Jv(e){return new Ue(function(t){Hk(e,t).catch(function(r){return t.error(r)})})}function Qk(e){return Jv(Wc(e))}function Hk(e,t){var r,n,o,i;return Uv(this,void 0,void 0,function(){var a,s;return Pc(this,function(c){switch(c.label){case 0:c.trys.push([0,5,6,11]),r=Bv(e),c.label=1;case 1:return[4,r.next()];case 2:if(n=c.sent(),!!n.done)return[3,4];if(a=n.value,t.next(a),t.closed)return[2];c.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return s=c.sent(),o={error:s},[3,11];case 6:return c.trys.push([6,,9,10]),n&&!n.done&&(i=r.return)?[4,i.call(r)]:[3,8];case 7:c.sent(),c.label=8;case 8:return[3,10];case 9:if(o)throw o.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}m();d();f();p();m();d();f();p();function Ft(e,t,r,n,o){n===void 0&&(n=0),o===void 0&&(o=!1);var i=t.schedule(function(){r(),o?e.add(this.schedule(null,n)):this.unsubscribe()},n);if(e.add(i),!o)return i}function Yc(e,t){return t===void 0&&(t=0),ze(function(r,n){r.subscribe(Ye(n,function(o){return Ft(n,e,function(){return n.next(o)},t)},function(){return Ft(n,e,function(){return n.complete()},t)},function(o){return Ft(n,e,function(){return n.error(o)},t)}))})}m();d();f();p();function Xc(e,t){return t===void 0&&(t=0),ze(function(r,n){n.add(e.schedule(function(){return r.subscribe(n)},t))})}function eS(e,t){return Xe(e).pipe(Xc(t),Yc(t))}m();d();f();p();function tS(e,t){return Xe(e).pipe(Xc(t),Yc(t))}m();d();f();p();function rS(e,t){return new Ue(function(r){var n=0;return t.schedule(function(){n===e.length?r.complete():(r.next(e[n++]),r.closed||this.schedule())})})}m();d();f();p();function nS(e,t){return new Ue(function(r){var n;return Ft(r,t,function(){n=e[Hc](),Ft(r,t,function(){var o,i,a;try{o=n.next(),i=o.value,a=o.done}catch(s){r.error(s);return}a?r.complete():r.next(i)},0,!0)}),function(){return xe(n?.return)&&n.return()}})}m();d();f();p();function Zc(e,t){if(!e)throw new Error("Iterable cannot be null");return new Ue(function(r){Ft(r,t,function(){var n=e[Symbol.asyncIterator]();Ft(r,t,function(){n.next().then(function(o){o.done?r.complete():r.next(o.value)})},0,!0)})})}m();d();f();p();function oS(e,t){return Zc(Wc(e),t)}function iS(e,t){if(e!=null){if(Gc(e))return eS(e,t);if(Vc(e))return rS(e,t);if(Bc(e))return tS(e,t);if($c(e))return Zc(e,t);if(zc(e))return nS(e,t);if(Kc(e))return oS(e,t)}throw Qc(e)}function Fn(e,t){return t?iS(e,t):Xe(e)}function Ge(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=Zv(e);return Fn(e,r)}m();d();f();p();function Ve(e,t){var r=xe(e)?e:function(){return e},n=function(o){return o.error(r())};return new Ue(t?function(o){return t.schedule(n,0,o)}:n)}m();d();f();p();m();d();f();p();var aS=Uo(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function Jc(e,t){var r=typeof t=="object";return new Promise(function(n,o){var i=!1,a;e.subscribe({next:function(s){a=s,i=!0},error:o,complete:function(){i?n(a):r?n(t.defaultValue):o(new aS)}})})}m();d();f();p();function Dn(e,t){return ze(function(r,n){var o=0;r.subscribe(Ye(n,function(i){n.next(e.call(t,i,o++))}))})}m();d();f();p();m();d();f();p();m();d();f();p();function sS(e,t,r,n,o,i,a,s){var c=[],u=0,h=0,v=!1,C=function(){v&&!c.length&&!u&&t.complete()},g=function(S){return u<n?y(S):c.push(S)},y=function(S){i&&t.next(S),u++;var E=!1;Xe(r(S,h++)).subscribe(Ye(t,function(R){o?.(R),i?g(R):t.next(R)},function(){E=!0},void 0,function(){if(E)try{u--;for(var R=function(){var k=c.shift();a?Ft(t,a,function(){return y(k)}):y(k)};c.length&&u<n;)R();C()}catch(k){t.error(k)}}))};return e.subscribe(Ye(t,g,function(){v=!0,C()})),function(){s?.()}}function wt(e,t,r){return r===void 0&&(r=1/0),xe(t)?wt(function(n,o){return Dn(function(i,a){return t(n,i,o,a)})(Xe(e(n,o)))},r):(typeof t=="number"&&(r=t),ze(function(n,o){return sS(n,o,e,r)}))}function $p(e){return e===void 0&&(e=1/0),wt(Qo,e)}m();d();f();p();function eu(e){return new Ue(function(t){Xe(e()).subscribe(t)})}m();d();f();p();function da(e){return ze(function(t,r){var n=null,o=!1,i;n=t.subscribe(Ye(r,void 0,void 0,function(a){i=Xe(e(a,da(e)(t))),n?(n.unsubscribe(),n=null,i.subscribe(r)):o=!0})),o&&(n.unsubscribe(),n=null,i.subscribe(r))})}m();d();f();p();function tu(e,t){return xe(t)?wt(e,t,1):wt(e,1)}m();d();f();p();function Qp(e){return ze(function(t,r){var n=!1;t.subscribe(Ye(r,function(o){n=!0,r.next(o)},function(){n||r.next(e),r.complete()}))})}m();d();f();p();function Mn(e){return ze(function(t,r){try{t.subscribe(r)}finally{r.add(e)}})}m();d();f();p();function Hp(e,t){return ze(function(r,n){var o=null,i=0,a=!1,s=function(){return a&&!o&&n.complete()};r.subscribe(Ye(n,function(c){o?.unsubscribe();var u=0,h=i++;Xe(e(c,h)).subscribe(o=Ye(n,function(v){return n.next(t?t(c,v,h,u++):v)},function(){o=null,s()}))},function(){a=!0,s()}))})}m();d();f();p();function ru(e){return ze(function(t,r){Xe(e).subscribe(Ye(r,function(){return r.complete()},ua)),!r.closed&&t.subscribe(r)})}m();d();f();p();function zp(e,t,r){var n=xe(e)||t||r?{next:e,error:t,complete:r}:e;return n?ze(function(o,i){var a;(a=n.subscribe)===null||a===void 0||a.call(n);var s=!0;o.subscribe(Ye(i,function(c){var u;(u=n.next)===null||u===void 0||u.call(n,c),i.next(c)},function(){var c;s=!1,(c=n.complete)===null||c===void 0||c.call(n),i.complete()},function(c){var u;s=!1,(u=n.error)===null||u===void 0||u.call(n,c),i.error(c)},function(){var c,u;s&&((c=n.unsubscribe)===null||c===void 0||c.call(n)),(u=n.finalize)===null||u===void 0||u.call(n)}))}):Qo}m();d();f();p();m();d();f();p();function cS(e){return` \r
36
- `.indexOf(e)>=0}function nu(e){for(var t=["topLevel"],r=0,n,o,i,a=function(k){return t.push(k)},s=function(k){return t[t.length-1]=k},c=function(k){n==null&&(n=r,o=t.length,i=k)},u=function(k){k===i&&(n=void 0,o=void 0,i=void 0)},h=function(){return t.pop()},v=function(){return r--},C=function(k){if("0"<=k&&k<="9"){a("number");return}switch(k){case"\"":a("string");return;case"-":a("numberNeedsDigit");return;case"t":a("true");return;case"f":a("false");return;case"n":a("null");return;case"[":a("arrayNeedsValue");return;case"{":a("objectNeedsKey");return}},g=e.length;r<g;r++){var y=e[r];switch(t[t.length-1]){case"topLevel":C(y);break;case"string":switch(y){case"\"":h();break;case"\\":c("stringEscape"),a("stringEscaped");break}break;case"stringEscaped":y==="u"?a("stringUnicode"):(u("stringEscape"),h());break;case"stringUnicode":r-e.lastIndexOf("u",r)===4&&(u("stringEscape"),h());break;case"number":y==="."?s("numberNeedsDigit"):y==="e"||y==="E"?s("numberNeedsExponent"):(y<"0"||y>"9")&&(v(),h());break;case"numberNeedsDigit":s("number");break;case"numberNeedsExponent":s(y==="+"||y==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(y<"a"||y>"z")&&(v(),h());break;case"arrayNeedsValue":y==="]"?h():cS(y)||(u("collectionItem"),s("arrayNeedsComma"),C(y));break;case"arrayNeedsComma":y==="]"?h():y===","&&(c("collectionItem"),s("arrayNeedsValue"));break;case"objectNeedsKey":y==="}"?h():y==="\""&&(c("collectionItem"),s("objectNeedsColon"),a("string"));break;case"objectNeedsColon":y===":"&&s("objectNeedsValue");break;case"objectNeedsValue":cS(y)||(u("collectionItem"),s("objectNeedsComma"),C(y));break;case"objectNeedsComma":y==="}"?h():y===","&&(c("collectionItem"),s("objectNeedsKey"));break}}o!=null&&(t.length=o);for(var S=[n!=null?e.slice(0,n):e],E=function(k){return S.push(k.slice(e.length-e.lastIndexOf(k[0])))},R=t.length-1;R>=0;R--)switch(t[R]){case"string":S.push("\"");break;case"numberNeedsDigit":case"numberNeedsExponent":S.push("0");break;case"true":E("true");break;case"false":E("false");break;case"null":E("null");break;case"arrayNeedsValue":case"arrayNeedsComma":S.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":S.push("}");break}return S.join("")}m();d();f();p();m();d();f();p();m();d();f();p();function lS(){let e=this.buf,t=this.pos,r=0,n=0;for(let i=0;i<28;i+=7){let a=e[t++];if(r|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}}let o=e[t++];if(r|=(o&15)<<28,n=(o&112)>>4,(o&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(n|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}}throw new Error("invalid varint")}var ou=4294967296;function Wp(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,o=0;function i(a,s){let c=Number(e.slice(a,s));o*=r,n=n*r+c,n>=ou&&(o=o+(n/ou|0),n=n%ou)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),t?pS(n,o):Yp(n,o)}function dS(e,t){let r=Yp(e,t),n=r.hi&2147483648;n&&(r=pS(r.lo,r.hi));let o=Kp(r.lo,r.hi);return n?"-"+o:o}function Kp(e,t){if({lo:e,hi:t}=zk(e,t),t<=2097151)return String(ou*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,o=t>>16&65535,i=r+n*6777216+o*6710656,a=n+o*8147497,s=o*2,c=1e7;return i>=c&&(a+=Math.floor(i/c),i%=c),a>=c&&(s+=Math.floor(a/c),a%=c),s.toString()+uS(a)+uS(i)}function zk(e,t){return{lo:e>>>0,hi:t>>>0}}function Yp(e,t){return{lo:e|0,hi:t|0}}function pS(e,t){return t=~t,e?e=~e+1:t+=1,Yp(e,t)}var uS=e=>{let t=String(e);return"0000000".slice(t.length)+t};function fS(){let e=this.buf[this.pos++];if((e&128)===0)return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)===0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;(e&128)!==0&&r<10;r++)e=this.buf[this.pos++];if((e&128)!==0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}m();d();f();p();var Bt=Wk();function Wk(){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"&&(!!w.Deno||!!w.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>n||s<r)throw new Error(`invalid int64: ${a}`);return s},uParse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>i||s<o)throw new Error(`invalid uint64: ${a}`);return s},enc(a){return e.setBigInt64(0,this.parse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(a){return e.setBigInt64(0,this.uParse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigInt64(0,!0)},uDec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),mS(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),gS(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),mS(r),Wp(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),gS(r),Wp(r)},dec(r,n){return dS(r,n)},uDec(r,n){return Kp(r,n)}}}function mS(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function gS(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}m();d();f();p();var Xp=Symbol.for("@bufbuild/protobuf/text-encoding");function Kk(e){var t;w[Xp]=Object.assign(Object.assign({},e),{encodeUtf8Into:(t=e.encodeUtf8Into)!==null&&t!==void 0?t:Jp(e.encodeUtf8.bind(e))})}function Zp(){let e=w;if(!e[Xp]){let t=new e.TextEncoder,r=new e.TextDecoder,n,o={encodeUtf8(a){return t.encode(a)},decodeUtf8(a,s){return s?(n||(n=new e.TextDecoder("utf-8",{fatal:!0})),n.decode(a)):r.decode(a)},checkUtf8(a){try{return encodeURIComponent(a),!0}catch{return!1}}};t.encodeInto&&(o.encodeUtf8Into=t.encodeInto.bind(t));let i=String.prototype.isWellFormed;i&&(o.checkUtf8=a=>i.call(a)),Kk(o)}return e[Xp]}function Jp(e){return(t,r)=>{let n=e(t);return r.set(n),{written:n.byteLength}}}var Gr;(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"})(Gr||(Gr={}));var Yk=34028234663852886e22,Xk=-34028234663852886e22,Zk=4294967295,Jk=2147483647,eO=-2147483648,ve=class{constructor(t){this.stackPos=[],this.encodeUtf8Into=t?Jp(t):Zp().encodeUtf8Into,this.buffer=yS,this.viewCache=rO,this.pos=0}ensureCapacity(t){let r=this.pos+t;if(r>this.buffer.length){let n=this.buffer.length||tO;for(;n<r;)n*=2;let o=new Uint8Array(n);this.pos>0&&o.set(this.buffer),this.buffer=o}}view(){let t=this.buffer,r=this.viewCache;if(r.byteLength===t.byteLength)return r;let n=new DataView(t.buffer);return this.viewCache=n,n}finish(){let t=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],t}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(pa),this.buffer[this.pos++]=0,this}join(){let t=this.stackPos.pop();if(t===void 0)throw new Error("invalid state, fork stack empty");let r=this.pos-t-pa,n=ef(r);return n>pa&&(this.ensureCapacity(n-pa),this.buffer.copyWithin(t+n,t+pa,this.pos)),this.pos=t,this.uint32(r),this.pos+=r,this}tag(t,r){return this.uint32((t<<3|r)>>>0)}raw(t){return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}uint32(t){if(hS(t),this.ensureCapacity(5),t<128)return this.buffer[this.pos++]=t,this;for(;t>127;)this.buffer[this.pos++]=t&127|128,t>>>=7;return this.buffer[this.pos++]=t,this}int32(t){if(tf(t),t>=0)return this.uint32(t);this.ensureCapacity(10);for(let r=0;r<9;r++)this.buffer[this.pos++]=t&127|128,t>>=7;return this.buffer[this.pos++]=1,this}bool(t){return this.ensureCapacity(1),this.buffer[this.pos++]=t?1:0,this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){typeof t!="string"&&(t=String(t));let r=t.length;if(r<=vS){this.ensureCapacity(r+1);let c=this.buffer,u=this.pos;c[u++]=r;let h=0;for(;h<r;h++){let v=t.charCodeAt(h);if(v>127)break;c[u++]=v}if(h==r)return this.pos=u,this}this.ensureCapacity(r*3+5);let n=ef(r),o=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(t,o.subarray(i+n)),s=ef(a);return s!=n&&o.copyWithin(i+s,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(t){return nO(t),this.ensureCapacity(4),this.view().setFloat32(this.pos,t,!0),this.pos+=4,this}double(t){return this.ensureCapacity(8),this.view().setFloat64(this.pos,t,!0),this.pos+=8,this}fixed32(t){return hS(t),this.ensureCapacity(4),this.view().setUint32(this.pos,t,!0),this.pos+=4,this}sfixed32(t){return tf(t),this.ensureCapacity(4),this.view().setInt32(this.pos,t,!0),this.pos+=4,this}sint32(t){return tf(t),this.uint32((t<<1^t>>31)>>>0)}sfixed64(t){let r=Bt.enc(t);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,r.lo,!0),n.setInt32(this.pos+4,r.hi,!0),this.pos+=8,this}fixed64(t){let r=Bt.uEnc(t);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,r.lo,!0),n.setInt32(this.pos+4,r.hi,!0),this.pos+=8,this}int64(t){let r=Bt.enc(t);return this.writeVarint64(r.lo,r.hi)}sint64(t){let r=Bt.enc(t),n=r.hi>>31,o=r.lo<<1^n,i=(r.hi<<1|r.lo>>>31)^n;return this.writeVarint64(o,i)}uint64(t){let r=Bt.uEnc(t);return this.writeVarint64(r.lo,r.hi)}writeVarint64(t,r){this.ensureCapacity(10);let n=this.buffer,o=this.pos;for(let s=0;s<28;s=s+7){let c=t>>>s,u=!(!(c>>>7)&&r==0);if(n[o++]=(u?c|128:c)&255,!u)return this.pos=o,this}let i=t>>>28&15|(r&7)<<4,a=r>>3!=0;if(n[o++]=(a?i|128:i)&255,!a)return this.pos=o,this;for(let s=3;s<31;s=s+7){let c=r>>>s,u=!!(c>>>7);if(n[o++]=(u?c|128:c)&255,!u)return this.pos=o,this}return n[o++]=r>>>31&1,this.pos=o,this}},tO=128,pa=1,yS=new Uint8Array(0),rO=new DataView(yS.buffer),vS=32;function ef(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var J=class{constructor(t,r=Zp().decodeUtf8){this.decodeUtf8=r,this.varint64Lo=0,this.varint64Hi=0,this.varint64=lS,this.uint32=fS,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.pos,r=this.uint32(),n=this.pos-t;if(n>5||n==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=r>>>3,i=r&7;if(o<=0||i>5)throw new Error("illegal tag: field no "+o+" wire type "+i);return[o,i]}skip(t,r,n=100){let o=this.pos;switch(t){case Gr.Varint:for(;this.buf[this.pos++]&128;);break;case Gr.Bit64:this.pos+=4;case Gr.Bit32:this.pos+=4;break;case Gr.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Gr.StartGroup:if(n<=0)throw new Error("maximum recursion depth reached");for(;;){let[a,s]=this.tag();if(s===Gr.EndGroup){if(r!==void 0&&a!==r)throw new Error("invalid end group tag");break}this.skip(s,a,n-1)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return this.varint64(),Bt.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),Bt.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let t=this.varint64Lo,r=this.varint64Hi,n=-(t&1);return t=(t>>>1|(r&1)<<31)^n,r=r>>>1^n,Bt.dec(t,r)}bool(){let t=this.buf[this.pos];return t<128?(this.pos++,t!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Bt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Bt.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 t=this.uint32(),r=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(r,r+t)}string(t){let r=this.bytes(),n=r.length;if(n<=vS){let o=new Array(n);for(let i=0;i<n;i++){let a=r[i];if(a>127)return this.decodeUtf8(r,t);o[i]=a}return String.fromCharCode.apply(String,o)}return this.decodeUtf8(r,t)}};function tf(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>Jk||e<eO)throw new Error("invalid int32: "+e)}function hS(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>Zk||e<0)throw new Error("invalid uint32: "+e)}function nO(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Yk||e<Xk))throw new Error("invalid float32: "+e)}var oO=function(e){return e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function rf(){return{fields:{}}}var fa={encode(e,t=new ve){return Object.entries(e.fields).forEach(([r,n])=>{n!==void 0&&af.encode({key:r,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=rf();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:{if(i!==10)break;let a=af.decode(r,r.uint32());a.value!==void 0&&(o.fields[a.key]=a.value);continue}}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return fa.fromPartial(e??{})},fromPartial(e){let t=rf();return t.fields=Object.entries(e.fields??{}).reduce((r,[n,o])=>(o!==void 0&&(r[n]=o),r),{}),t},wrap(e){let t=rf();if(e!==void 0)for(let r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){let t={};if(e.fields)for(let r of Object.keys(e.fields))t[r]=e.fields[r];return t}};function SS(){return{key:"",value:void 0}}var af={encode(e,t=new ve){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&ce.encode(ce.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=SS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.key=r.string();continue;case 2:if(i!==18)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return af.fromPartial(e??{})},fromPartial(e){let t=SS();return t.key=e.key??"",t.value=e.value??void 0,t}};function nf(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var ce={encode(e,t=new ve){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&&fa.encode(fa.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&ma.encode(ma.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=nf();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.nullValue=r.int32();continue;case 2:if(i!==17)break;o.numberValue=r.double();continue;case 3:if(i!==26)break;o.stringValue=r.string();continue;case 4:if(i!==32)break;o.boolValue=r.bool();continue;case 5:if(i!==42)break;o.structValue=fa.unwrap(fa.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.listValue=ma.unwrap(ma.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ce.fromPartial(e??{})},fromPartial(e){let t=nf();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=nf();if(e===null)t.nullValue=oO.NULL_VALUE;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(w.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new w.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 of(){return{values:[]}}var ma={encode(e,t=new ve){for(let r of e.values)ce.encode(ce.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=of();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(ce.unwrap(ce.decode(r,r.uint32())));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ma.fromPartial(e??{})},fromPartial(e){let t=of();return t.values=e.values?.map(r=>r)||[],t},wrap(e){let t=of();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&w.Array.isArray(e.values)?e.values:e}},iO=function(e){return e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function bS(){return{op:0,path:"",from:void 0,value:void 0}}var au={encode(e,t=new ve){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&&ce.encode(ce.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=bS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.op=r.int32();continue;case 2:if(i!==18)break;o.path=r.string();continue;case 3:if(i!==26)break;o.from=r.string();continue;case 4:if(i!==34)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return au.fromPartial(e??{})},fromPartial(e){let t=bS();return t.op=e.op??0,t.path=e.path??"",t.from=e.from??void 0,t.value=e.value??void 0,t}};function wS(){return{id:"",type:"",function:void 0}}var su={encode(e,t=new ve){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&cu.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=wS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.type=r.string();continue;case 3:if(i!==26)break;o.function=cu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return su.fromPartial(e??{})},fromPartial(e){let t=wS();return t.id=e.id??"",t.type=e.type??"",t.function=e.function!==void 0&&e.function!==null?cu.fromPartial(e.function):void 0,t}};function AS(){return{name:"",arguments:""}}var cu={encode(e,t=new ve){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=AS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.name=r.string();continue;case 2:if(i!==18)break;o.arguments=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return cu.fromPartial(e??{})},fromPartial(e){let t=AS();return t.name=e.name??"",t.arguments=e.arguments??"",t}};function xS(){return{value:"",mimeType:""}}var uu={encode(e,t=new ve){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==""&&t.uint32(18).string(e.mimeType),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=xS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=r.string();continue;case 2:if(i!==18)break;o.mimeType=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return uu.fromPartial(e??{})},fromPartial(e){let t=xS();return t.value=e.value??"",t.mimeType=e.mimeType??"",t}};function CS(){return{value:"",mimeType:void 0}}var lu={encode(e,t=new ve){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=CS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=r.string();continue;case 2:if(i!==18)break;o.mimeType=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return lu.fromPartial(e??{})},fromPartial(e){let t=CS();return t.value=e.value??"",t.mimeType=e.mimeType??void 0,t}};function ES(){return{data:void 0,url:void 0}}var Et={encode(e,t=new ve){return e.data!==void 0&&uu.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&lu.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=ES();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=uu.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.url=lu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Et.fromPartial(e??{})},fromPartial(e){let t=ES();return t.data=e.data!==void 0&&e.data!==null?uu.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?lu.fromPartial(e.url):void 0,t}};function RS(){return{text:""}}var du={encode(e,t=new ve){return e.text!==""&&t.uint32(10).string(e.text),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=RS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return du.fromPartial(e??{})},fromPartial(e){let t=RS();return t.text=e.text??"",t}};function IS(){return{source:void 0,metadata:void 0}}var pu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=IS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return pu.fromPartial(e??{})},fromPartial(e){let t=IS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function TS(){return{source:void 0,metadata:void 0}}var fu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=TS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return fu.fromPartial(e??{})},fromPartial(e){let t=TS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function _S(){return{source:void 0,metadata:void 0}}var mu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=_S();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return mu.fromPartial(e??{})},fromPartial(e){let t=_S();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function kS(){return{source:void 0,metadata:void 0}}var gu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=kS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return gu.fromPartial(e??{})},fromPartial(e){let t=kS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function OS(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var hu={encode(e,t=new ve){return e.text!==void 0&&du.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&pu.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&fu.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&mu.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&gu.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=OS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=du.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.image=pu.decode(r,r.uint32());continue;case 3:if(i!==26)break;o.audio=fu.decode(r,r.uint32());continue;case 4:if(i!==34)break;o.video=mu.decode(r,r.uint32());continue;case 5:if(i!==42)break;o.document=gu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return hu.fromPartial(e??{})},fromPartial(e){let t=OS();return t.text=e.text!==void 0&&e.text!==null?du.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?pu.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?fu.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?mu.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?gu.fromPartial(e.document):void 0,t}};function PS(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var yu={encode(e,t=new ve){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let r of e.toolCalls)su.encode(r,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let r of e.contentParts)hu.encode(r,t.uint32(66).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=PS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.role=r.string();continue;case 3:if(i!==26)break;o.content=r.string();continue;case 4:if(i!==34)break;o.name=r.string();continue;case 5:if(i!==42)break;o.toolCalls.push(su.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.toolCallId=r.string();continue;case 7:if(i!==58)break;o.error=r.string();continue;case 8:if(i!==66)break;o.contentParts.push(hu.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return yu.fromPartial(e??{})},fromPartial(e){let t=PS();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(r=>su.fromPartial(r))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(r=>hu.fromPartial(r))||[],t}};function NS(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var vu={encode(e,t=new ve){return e.id!==""&&t.uint32(10).string(e.id),e.reason!==""&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&ce.encode(ce.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=NS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.reason=r.string();continue;case 3:if(i!==26)break;o.message=r.string();continue;case 4:if(i!==34)break;o.toolCallId=r.string();continue;case 5:if(i!==42)break;o.responseSchema=ce.unwrap(ce.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=r.string();continue;case 7:if(i!==58)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return vu.fromPartial(e??{})},fromPartial(e){let t=NS();return t.id=e.id??"",t.reason=e.reason??"",t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},aO=function(e){return e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function FS(){return{type:0,timestamp:void 0,rawEvent:void 0}}var le={encode(e,t=new ve){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&ce.encode(ce.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=FS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.type=r.int32();continue;case 2:if(i!==16)break;o.timestamp=Ho(r.int64());continue;case 3:if(i!==26)break;o.rawEvent=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return le.fromPartial(e??{})},fromPartial(e){let t=FS();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function DS(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Su={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=DS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.role=r.string();continue;case 4:if(i!==34)break;o.name=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Su.fromPartial(e??{})},fromPartial(e){let t=DS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.role=e.role??void 0,t.name=e.name??void 0,t}};function MS(){return{baseEvent:void 0,messageId:"",delta:""}}var bu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=MS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return bu.fromPartial(e??{})},fromPartial(e){let t=MS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t}};function qS(){return{baseEvent:void 0,messageId:""}}var wu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=qS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return wu.fromPartial(e??{})},fromPartial(e){let t=qS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t}};function jS(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Au={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=jS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.toolCallName=r.string();continue;case 4:if(i!==34)break;o.parentMessageId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Au.fromPartial(e??{})},fromPartial(e){let t=jS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.toolCallName=e.toolCallName??"",t.parentMessageId=e.parentMessageId??void 0,t}};function LS(){return{baseEvent:void 0,toolCallId:"",delta:""}}var xu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=LS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return xu.fromPartial(e??{})},fromPartial(e){let t=LS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.delta=e.delta??"",t}};function US(){return{baseEvent:void 0,toolCallId:""}}var Cu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=US();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Cu.fromPartial(e??{})},fromPartial(e){let t=US();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t}};function VS(){return{baseEvent:void 0,snapshot:void 0}}var Eu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&ce.encode(ce.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=VS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.snapshot=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Eu.fromPartial(e??{})},fromPartial(e){let t=VS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function BS(){return{baseEvent:void 0,delta:[]}}var Ru={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.delta)au.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=BS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.delta.push(au.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Ru.fromPartial(e??{})},fromPartial(e){let t=BS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(r=>au.fromPartial(r))||[],t}};function GS(){return{baseEvent:void 0,messages:[]}}var Iu={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.messages)yu.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=GS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messages.push(yu.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Iu.fromPartial(e??{})},fromPartial(e){let t=GS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(r=>yu.fromPartial(r))||[],t}};function $S(){return{baseEvent:void 0,event:void 0,source:void 0}}var Tu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&ce.encode(ce.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=$S();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.event=ce.unwrap(ce.decode(r,r.uint32()));continue;case 3:if(i!==26)break;o.source=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Tu.fromPartial(e??{})},fromPartial(e){let t=$S();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function QS(){return{baseEvent:void 0,name:"",value:void 0}}var _u={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&ce.encode(ce.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=QS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.name=r.string();continue;case 3:if(i!==26)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return _u.fromPartial(e??{})},fromPartial(e){let t=QS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.name=e.name??"",t.value=e.value??void 0,t}};function HS(){return{baseEvent:void 0,threadId:"",runId:""}}var ku={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=HS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.threadId=r.string();continue;case 3:if(i!==26)break;o.runId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ku.fromPartial(e??{})},fromPartial(e){let t=HS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t}};function zS(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0}}var qn={encode(e,t=new ve){return e.provider!==void 0&&t.uint32(10).string(e.provider),e.model!==void 0&&t.uint32(18).string(e.model),e.inputTokens!==void 0&&t.uint32(24).int64(e.inputTokens),e.outputTokens!==void 0&&t.uint32(32).int64(e.outputTokens),e.totalTokens!==void 0&&t.uint32(40).int64(e.totalTokens),e.reasoningTokens!==void 0&&t.uint32(48).int64(e.reasoningTokens),e.cachedInputTokens!==void 0&&t.uint32(56).int64(e.cachedInputTokens),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=zS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.provider=r.string();continue;case 2:if(i!==18)break;o.model=r.string();continue;case 3:if(i!==24)break;o.inputTokens=Ho(r.int64());continue;case 4:if(i!==32)break;o.outputTokens=Ho(r.int64());continue;case 5:if(i!==40)break;o.totalTokens=Ho(r.int64());continue;case 6:if(i!==48)break;o.reasoningTokens=Ho(r.int64());continue;case 7:if(i!==56)break;o.cachedInputTokens=Ho(r.int64());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return qn.fromPartial(e??{})},fromPartial(e){let t=zS();return t.provider=e.provider??void 0,t.model=e.model??void 0,t.inputTokens=e.inputTokens??void 0,t.outputTokens=e.outputTokens??void 0,t.totalTokens=e.totalTokens??void 0,t.reasoningTokens=e.reasoningTokens??void 0,t.cachedInputTokens=e.cachedInputTokens??void 0,t}};function WS(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[],usage:[]}}var Ou={encode(e,t=new ve){e.baseEvent!==void 0&&le.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&&ce.encode(ce.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==""&&t.uint32(42).string(e.outcome);for(let r of e.interrupts)vu.encode(r,t.uint32(50).fork()).join();for(let r of e.usage)qn.encode(r,t.uint32(58).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=WS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.threadId=r.string();continue;case 3:if(i!==26)break;o.runId=r.string();continue;case 4:if(i!==34)break;o.result=ce.unwrap(ce.decode(r,r.uint32()));continue;case 5:if(i!==42)break;o.outcome=r.string();continue;case 6:if(i!==50)break;o.interrupts.push(vu.decode(r,r.uint32()));continue;case 7:if(i!==58)break;o.usage.push(qn.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Ou.fromPartial(e??{})},fromPartial(e){let t=WS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interrupts=e.interrupts?.map(r=>vu.fromPartial(r))||[],t.usage=e.usage?.map(r=>qn.fromPartial(r))||[],t}};function KS(){return{baseEvent:void 0,code:void 0,message:"",usage:[]}}var Pu={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message);for(let r of e.usage)qn.encode(r,t.uint32(34).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=KS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.code=r.string();continue;case 3:if(i!==26)break;o.message=r.string();continue;case 4:if(i!==34)break;o.usage.push(qn.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Pu.fromPartial(e??{})},fromPartial(e){let t=KS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??"",t.usage=e.usage?.map(r=>qn.fromPartial(r))||[],t}};function YS(){return{baseEvent:void 0,stepName:""}}var Nu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=YS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.stepName=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Nu.fromPartial(e??{})},fromPartial(e){let t=YS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function XS(){return{baseEvent:void 0,stepName:""}}var Fu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=XS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.stepName=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Fu.fromPartial(e??{})},fromPartial(e){let t=XS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function ZS(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Du={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=ZS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.role=r.string();continue;case 4:if(i!==34)break;o.delta=r.string();continue;case 5:if(i!==42)break;o.name=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Du.fromPartial(e??{})},fromPartial(e){let t=ZS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function JS(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Mu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=JS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.toolCallName=r.string();continue;case 4:if(i!==34)break;o.parentMessageId=r.string();continue;case 5:if(i!==42)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Mu.fromPartial(e??{})},fromPartial(e){let t=JS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.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 eb(){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 tb={encode(e,t=new ve){return e.textMessageStart!==void 0&&Su.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&bu.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&wu.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Au.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&xu.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Cu.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Eu.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Ru.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Iu.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Tu.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&_u.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&ku.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Ou.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Pu.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Nu.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Fu.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Du.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Mu.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=eb();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Su.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=bu.decode(r,r.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=wu.decode(r,r.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Au.decode(r,r.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=xu.decode(r,r.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=Cu.decode(r,r.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Eu.decode(r,r.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Ru.decode(r,r.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Iu.decode(r,r.uint32());continue;case 10:if(i!==82)break;o.raw=Tu.decode(r,r.uint32());continue;case 11:if(i!==90)break;o.custom=_u.decode(r,r.uint32());continue;case 12:if(i!==98)break;o.runStarted=ku.decode(r,r.uint32());continue;case 13:if(i!==106)break;o.runFinished=Ou.decode(r,r.uint32());continue;case 14:if(i!==114)break;o.runError=Pu.decode(r,r.uint32());continue;case 15:if(i!==122)break;o.stepStarted=Nu.decode(r,r.uint32());continue;case 16:if(i!==130)break;o.stepFinished=Fu.decode(r,r.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=Du.decode(r,r.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=Mu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return tb.fromPartial(e??{})},fromPartial(e){let t=eb();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Su.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?bu.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?wu.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Au.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?xu.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Cu.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Eu.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Ru.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Iu.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Tu.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?_u.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?ku.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Ou.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Pu.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Nu.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Fu.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Du.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Mu.fromPartial(e.toolCallChunk):void 0,t}};function Ho(e){let t=w.Number(e.toString());if(t>w.Number.MAX_SAFE_INTEGER)throw new w.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<w.Number.MIN_SAFE_INTEGER)throw new w.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var rb=e=>e&&typeof e=="object"?e:void 0;var iu=e=>{let t=rb(e);if(t){if(t.data){let r=t.data;return{type:"data",value:r.value,mimeType:r.mimeType}}if(t.url){let r=t.url;return{type:"url",value:r.value,mimeType:r.mimeType}}}},sO=e=>{let t=rb(e);if(t){if(t.text)return{type:"text",text:t.text.text};if(t.image){let r=t.image;return{type:"image",source:iu(r.source),metadata:r.metadata}}if(t.audio){let r=t.audio;return{type:"audio",source:iu(r.source),metadata:r.metadata}}if(t.video){let r=t.video;return{type:"video",source:iu(r.source),metadata:r.metadata}}if(t.document){let r=t.document;return{type:"document",source:iu(r.source),metadata:r.metadata}}}};function nb(e){let t=tb.decode(e),r=Object.values(t).find(n=>n!==void 0);if(!r)throw new Error("Invalid event");if(r.type=aO[r.baseEvent.type],r.timestamp=r.baseEvent.timestamp,r.rawEvent=r.baseEvent.rawEvent,delete r.baseEvent,r.type===M.MESSAGES_SNAPSHOT)for(let n of r.messages){let o=n;if(o.role==="user"&&Array.isArray(o.contentParts)){let i=o.contentParts.map(a=>sO(a)).filter(a=>a!==void 0);i.length>0&&(o.content=i)}Array.isArray(o.contentParts)&&o.contentParts.length===0&&(o.contentParts=void 0),o.toolCalls?.length===0&&(o.toolCalls=void 0)}if(r.type===M.RUN_FINISHED){let n=r,o=typeof n.outcome=="string"&&n.outcome!==""?n.outcome:void 0,i=Array.isArray(n.interrupts)?n.interrupts:[];delete n.interrupts,o==="interrupt"?n.outcome={type:"interrupt",interrupts:i}:o==="success"?n.outcome={type:"success"}:delete n.outcome}if((r.type===M.RUN_FINISHED||r.type===M.RUN_ERROR)&&Array.isArray(r.usage)&&r.usage.length===0&&delete r.usage,r.type===M.STATE_DELTA)for(let n of r.delta)n.op=iO[n.op].toLowerCase(),Object.keys(n).forEach(o=>{n[o]===void 0&&delete n[o]});return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n]}),xc.parse(r)}var sf="application/vnd.ag-ui.event+proto";m();d();f();p();m();d();f();p();m();d();f();p();var uO=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,cf=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(uO);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},ob=e=>e==="*"||e==="x"||e==="X",ib=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},lO=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],dO=(e,t)=>{if(ob(e)||ob(t))return 0;let[r,n]=lO(ib(e),ib(t));return r>n?1:r<n?-1:0},uf=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){let n=dO(e[r]||"0",t[r]||"0");if(n!==0)return n}return 0};var ga=(e,t)=>{let r=cf(e),n=cf(t),o=r.pop(),i=n.pop(),a=uf(r,n);return a!==0?a:o&&i?uf(o.split("."),i.split(".")):o||i?o?-1:1:0};var Re=e=>{if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function ha(){return jr()}function pf(e){if(Object.freeze(e),typeof e=="object"&&e)for(let t of Object.values(e))typeof t=="object"&&t&&!Object.isFrozen(t)&&pf(t);return e}var ab=512*1024;function sb(e,t,r){let n=0,o=[e,t],i=new WeakSet;for(;o.length>0;){let a=o.pop();if(typeof a=="string"){if(n+=a.length,n>r)return!0}else if(typeof a=="object"&&a){if(i.has(a))continue;if(i.add(a),Array.isArray(a))for(let s=0;s<a.length;s++)o.push(a[s]);else{let s=Object.keys(a);for(let c=0;c<s.length;c++){let u=s[c];if(n+=u.length,n>r)return!0;o.push(a[u])}}}}return!1}function Oe(_x88,_x89,_x90,_x91){return _Oe.apply(this,arguments)}function _Oe(){_Oe=_asyncToGenerator(function*(e,t,r,n){let o=typeof process<"u"&&process.env!==void 0,i=o&&!!process.env.VITEST_WORKER_ID,a=o&&!!process.env.VITEST_WORKER_ID,s=a&&!sb(t,r,ab),c=s?Re(t):t,u=s?Re(r):r,h=!1,v=!1,C;for(let g of e)try{s&&(pf(c),pf(u));let y=yield n(g,c,u);if(y===void 0)continue;let S=!1;if(y.messages!==void 0&&y.messages!==c&&(c=Re(y.messages),h=!0,S=!0),y.state!==void 0&&y.state!==u&&(u=Re(y.state),v=!0,S=!0),s&&S&&sb(c,u,ab)&&(s=!1),C=y.stopPropagation,C===!0)break}catch(y){if(a&&y instanceof TypeError){if(i)throw y;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",y)}else i||console.error("Subscriber error:",y);continue}return{...(h?{messages:Object.isFrozen(c)?Re(c):c}:{}),...(v?{state:Object.isFrozen(u)?Re(u):u}:{}),...(C===void 0?{}:{stopPropagation:C})}});return _Oe.apply(this,arguments)}function qu(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,r=e.lifecycle??!0,n=e.verbose??!1;return{enabled:t||r,events:t,lifecycle:r,verbose:n}}function ya(e){if(e instanceof ff)return e;if(e===!0)return new ff(qu(!0))}var ff=class{constructor(e){this.config=e}event(e,t,r,n){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof r=="string"?r:JSON.stringify(r)):console.debug(`[${e}] ${t}`,n??r))}lifecycle(e,t,r){this.config.lifecycle&&(r?console.debug(`[${e}] ${t}`,r):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function lf(e){return e.enabled?new ff(e):void 0}function pO(e,t,r){if(t){let o=e.find(a=>a.id===t);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:o?r:t,role:"assistant",toolCalls:[]};return e.push(i),i}let n={id:r,role:"assistant",toolCalls:[]};return e.push(n),n}var fb=(e,t,r,n,o)=>{let i=ya(o),a=Re(r.messages),s=Re(e.state),c={},u=v=>{v.messages!==void 0&&(a=v.messages,c.messages=v.messages),v.state!==void 0&&(s=v.state,c.state=v.state)},h=()=>{let v=Re(c);return c={},v.messages!==void 0||v.state!==void 0?Ge(v):Uc};return t.pipe(tu(/*#__PURE__*/function(){var _ref43=_asyncToGenerator(function*(v){let C=yield Oe(n,a,s,(g,y,S)=>g.onEvent?.({event:v,agent:r,input:e,messages:y,state:S}));if(u(C),C.stopPropagation===!0?i?.event("APPLY","Event dropped:",v,{type:v.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",v,{type:v.type,subscribers:n.length}),C.stopPropagation===!0)return h();switch(v.type){case M.TEXT_MESSAGE_START:{let g=yield Oe(n,a,s,(y,S,E)=>y.onTextMessageStartEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messageId:y,role:S="assistant",name:E}=v;if(!a.find(R=>R.id===y)){let R={id:y,role:S,content:"",...(E!==void 0&&{name:E})};a.push(R),u({messages:a})}}return h()}case M.TEXT_MESSAGE_CONTENT:{let{messageId:g,delta:y}=v,S=a.find(R=>R.id===g);if(!S)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${g}'`),h();let E=yield Oe(n,a,s,(R,k,I)=>R.onTextMessageContentEvent?.({event:v,messages:k,state:I,agent:r,input:e,textMessageBuffer:typeof S.content=="string"?S.content:""}));return u(E),E.stopPropagation!==!0&&(S.content=`${typeof S.content=="string"?S.content:""}${y}`,u({messages:a})),h()}case M.TEXT_MESSAGE_END:{let{messageId:g}=v,y=a.find(S=>S.id===g);return y?(u(yield Oe(n,a,s,(S,E,R)=>S.onTextMessageEndEvent?.({event:v,messages:E,state:R,agent:r,input:e,textMessageBuffer:typeof y.content=="string"?y.content:""}))),yield Promise.all(n.map(S=>{S.onNewMessage?.({message:y,messages:a,state:s,agent:r,input:e})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${g}'`),h())}case M.TOOL_CALL_START:{let g=yield Oe(n,a,s,(y,S,E)=>y.onToolCallStartEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{toolCallId:y,toolCallName:S,parentMessageId:E}=v,R=a.find(I=>I.toolCalls?.some(T=>T.id===y))?.toolCalls?.find(I=>I.id===y);if(R)return R.function.name!==S&&(console.warn(`TOOL_CALL_START: tool call '${y}' already exists with name '${R.function.name}' \u2014 updating it to '${S}'`),R.function.name=S,u({messages:a})),h();let k=pO(a,E,y);k.toolCalls??(k.toolCalls=[]),k.toolCalls.push({id:y,type:"function",function:{name:S,arguments:""}}),u({messages:a})}return h()}case M.TOOL_CALL_ARGS:{let{toolCallId:g,delta:y}=v,S=a.find(k=>k.toolCalls?.some(I=>I.id===g));if(!S)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${g}'`),h();let E=S.toolCalls?.find(k=>k.id===g);if(!E)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${g}'`),h();let R=yield Oe(n,a,s,(k,I,T)=>{let _=E.function.arguments,D=E.function.name,G={};try{G=nu(_)}catch{}return k.onToolCallArgsEvent?.({event:v,messages:I,state:T,agent:r,input:e,toolCallBuffer:_,toolCallName:D,partialToolCallArgs:G})});return u(R),R.stopPropagation!==!0&&(E.function.arguments+=y,u({messages:a})),h()}case M.TOOL_CALL_END:{let{toolCallId:g}=v,y=a.find(E=>E.toolCalls?.some(R=>R.id===g));if(!y)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${g}'`),h();let S=y.toolCalls?.find(E=>E.id===g);return S?(u(yield Oe(n,a,s,(E,R,k)=>{let I=S.function.arguments,T=S.function.name,_={};try{_=JSON.parse(I)}catch{}return E.onToolCallEndEvent?.({event:v,messages:R,state:k,agent:r,input:e,toolCallName:T,toolCallArgs:_})})),yield Promise.all(n.map(E=>{E.onNewToolCall?.({toolCall:S,messages:a,state:s,agent:r,input:e})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${g}'`),h())}case M.TOOL_CALL_RESULT:{let g=yield Oe(n,a,s,(y,S,E)=>y.onToolCallResultEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messageId:y,toolCallId:S,content:E,role:R}=v,k={id:y,toolCallId:S,role:R||"tool",content:E},I=a.findIndex(T=>T.role==="assistant"&&T.toolCalls?.some(_=>_.id===S));if(I===-1)a.push(k);else{let T=I+1;for(;T<a.length&&a[T].role==="tool";)T++;a.splice(T,0,k)}yield Promise.all(n.map(T=>{T.onNewMessage?.({message:k,messages:a,state:s,agent:r,input:e})})),u({messages:a})}return h()}case M.STATE_SNAPSHOT:{let g=yield Oe(n,a,s,(y,S,E)=>y.onStateSnapshotEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{snapshot:y}=v;s=y,u({state:s})}return h()}case M.STATE_DELTA:{let g=yield Oe(n,a,s,(y,S,E)=>y.onStateDeltaEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{delta:y}=v;try{s=Oc.applyPatch(s,y,!0,!1).newDocument,u({state:s})}catch(S){let E=S instanceof Error?S.message:String(S);console.warn(`Failed to apply state patch:
36
+ `.indexOf(e)>=0}function nu(e){for(var t=["topLevel"],r=0,n,o,i,a=function(k){return t.push(k)},s=function(k){return t[t.length-1]=k},c=function(k){n==null&&(n=r,o=t.length,i=k)},u=function(k){k===i&&(n=void 0,o=void 0,i=void 0)},h=function(){return t.pop()},v=function(){return r--},C=function(k){if("0"<=k&&k<="9"){a("number");return}switch(k){case"\"":a("string");return;case"-":a("numberNeedsDigit");return;case"t":a("true");return;case"f":a("false");return;case"n":a("null");return;case"[":a("arrayNeedsValue");return;case"{":a("objectNeedsKey");return}},g=e.length;r<g;r++){var y=e[r];switch(t[t.length-1]){case"topLevel":C(y);break;case"string":switch(y){case"\"":h();break;case"\\":c("stringEscape"),a("stringEscaped");break}break;case"stringEscaped":y==="u"?a("stringUnicode"):(u("stringEscape"),h());break;case"stringUnicode":r-e.lastIndexOf("u",r)===4&&(u("stringEscape"),h());break;case"number":y==="."?s("numberNeedsDigit"):y==="e"||y==="E"?s("numberNeedsExponent"):(y<"0"||y>"9")&&(v(),h());break;case"numberNeedsDigit":s("number");break;case"numberNeedsExponent":s(y==="+"||y==="-"?"numberNeedsDigit":"number");break;case"true":case"false":case"null":(y<"a"||y>"z")&&(v(),h());break;case"arrayNeedsValue":y==="]"?h():cS(y)||(u("collectionItem"),s("arrayNeedsComma"),C(y));break;case"arrayNeedsComma":y==="]"?h():y===","&&(c("collectionItem"),s("arrayNeedsValue"));break;case"objectNeedsKey":y==="}"?h():y==="\""&&(c("collectionItem"),s("objectNeedsColon"),a("string"));break;case"objectNeedsColon":y===":"&&s("objectNeedsValue");break;case"objectNeedsValue":cS(y)||(u("collectionItem"),s("objectNeedsComma"),C(y));break;case"objectNeedsComma":y==="}"?h():y===","&&(c("collectionItem"),s("objectNeedsKey"));break}}o!=null&&(t.length=o);for(var S=[n!=null?e.slice(0,n):e],E=function(k){return S.push(k.slice(e.length-e.lastIndexOf(k[0])))},R=t.length-1;R>=0;R--)switch(t[R]){case"string":S.push("\"");break;case"numberNeedsDigit":case"numberNeedsExponent":S.push("0");break;case"true":E("true");break;case"false":E("false");break;case"null":E("null");break;case"arrayNeedsValue":case"arrayNeedsComma":S.push("]");break;case"objectNeedsKey":case"objectNeedsColon":case"objectNeedsValue":case"objectNeedsComma":S.push("}");break}return S.join("")}m();d();f();p();m();d();f();p();m();d();f();p();function lS(){let e=this.buf,t=this.pos,r=0,n=0;for(let i=0;i<28;i+=7){let a=e[t++];if(r|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}}let o=e[t++];if(r|=(o&15)<<28,n=(o&112)>>4,(o&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}for(let i=3;i<=31;i+=7){let a=e[t++];if(n|=(a&127)<<i,(a&128)==0){this.pos=t,this.assertBounds(),this.varint64Lo=r,this.varint64Hi=n;return}}throw new Error("invalid varint")}var ou=4294967296;function Wp(e){let t=e[0]==="-";t&&(e=e.slice(1));let r=1e6,n=0,o=0;function i(a,s){let c=Number(e.slice(a,s));o*=r,n=n*r+c,n>=ou&&(o=o+(n/ou|0),n=n%ou)}return i(-24,-18),i(-18,-12),i(-12,-6),i(-6),t?pS(n,o):Yp(n,o)}function dS(e,t){let r=Yp(e,t),n=r.hi&2147483648;n&&(r=pS(r.lo,r.hi));let o=Kp(r.lo,r.hi);return n?"-"+o:o}function Kp(e,t){if({lo:e,hi:t}=zk(e,t),t<=2097151)return String(ou*t+e);let r=e&16777215,n=(e>>>24|t<<8)&16777215,o=t>>16&65535,i=r+n*6777216+o*6710656,a=n+o*8147497,s=o*2,c=1e7;return i>=c&&(a+=Math.floor(i/c),i%=c),a>=c&&(s+=Math.floor(a/c),a%=c),s.toString()+uS(a)+uS(i)}function zk(e,t){return{lo:e>>>0,hi:t>>>0}}function Yp(e,t){return{lo:e|0,hi:t|0}}function pS(e,t){return t=~t,e?e=~e+1:t+=1,Yp(e,t)}var uS=e=>{let t=String(e);return"0000000".slice(t.length)+t};function fS(){let e=this.buf[this.pos++];if((e&128)===0)return this.assertBounds(),e;let t=e&127;if(e=this.buf[this.pos++],t|=(e&127)<<7,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<14,(e&128)===0)return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(e&127)<<21,(e&128)===0)return this.assertBounds(),t;e=this.buf[this.pos++],t|=(e&15)<<28;for(let r=5;(e&128)!==0&&r<10;r++)e=this.buf[this.pos++];if((e&128)!==0)throw new Error("invalid varint");return this.assertBounds(),t>>>0}m();d();f();p();var Bt=Wk();function Wk(){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"&&(!!w.Deno||!!w.Bun||typeof process!="object"||typeof process.env!="object"||process.env.BUF_BIGINT_DISABLE!=="1")){let r=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),i=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>n||s<r)throw new Error(`invalid int64: ${a}`);return s},uParse(a){let s=typeof a=="bigint"?a:BigInt(a);if(s>i||s<o)throw new Error(`invalid uint64: ${a}`);return s},enc(a){return e.setBigInt64(0,this.parse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(a){return e.setBigInt64(0,this.uParse(a),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigInt64(0,!0)},uDec(a,s){return e.setInt32(0,a,!0),e.setInt32(4,s,!0),e.getBigUint64(0,!0)}}}return{zero:"0",supported:!1,parse(r){return typeof r!="string"&&(r=r.toString()),mS(r),r},uParse(r){return typeof r!="string"&&(r=r.toString()),gS(r),r},enc(r){return typeof r!="string"&&(r=r.toString()),mS(r),Wp(r)},uEnc(r){return typeof r!="string"&&(r=r.toString()),gS(r),Wp(r)},dec(r,n){return dS(r,n)},uDec(r,n){return Kp(r,n)}}}function mS(e){if(!/^-?[0-9]+$/.test(e))throw new Error("invalid int64: "+e)}function gS(e){if(!/^[0-9]+$/.test(e))throw new Error("invalid uint64: "+e)}m();d();f();p();var Xp;function Kk(e){var t;Xp=Object.assign(Object.assign({},e),{encodeUtf8Into:(t=e.encodeUtf8Into)!==null&&t!==void 0?t:Jp(e.encodeUtf8.bind(e))})}function Zp(){if(!Xp){let e=w;if(!e.TextEncoder||!e.TextDecoder)throw new Error("encoding API missing: install TextEncoder and TextDecoder on globalThis");let t=new e.TextEncoder,r=new e.TextDecoder,n,o={encodeUtf8(a){return t.encode(a)},decodeUtf8(a,s){return s?(n||(n=new e.TextDecoder("utf-8",{fatal:!0})),n.decode(a)):r.decode(a)},checkUtf8(a){try{return encodeURIComponent(a),!0}catch{return!1}}};t.encodeInto&&(o.encodeUtf8Into=t.encodeInto.bind(t));let i=String.prototype.isWellFormed;i&&(o.checkUtf8=a=>i.call(a)),Kk(o)}return Xp}function Jp(e){return(t,r)=>{let n=e(t);return r.set(n),{written:n.byteLength}}}var Gr;(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"})(Gr||(Gr={}));var Yk=34028234663852886e22,Xk=-34028234663852886e22,Zk=4294967295,Jk=2147483647,eO=-2147483648,ve=class{constructor(t){this.stackPos=[],this.encodeUtf8Into=t?Jp(t):Zp().encodeUtf8Into,this.buffer=yS,this.viewCache=rO,this.pos=0}ensureCapacity(t){let r=this.pos+t;if(r>this.buffer.length){let n=this.buffer.length||tO;for(;n<r;)n*=2;let o=new Uint8Array(n);this.pos>0&&o.set(this.buffer),this.buffer=o}}view(){let t=this.buffer,r=this.viewCache;if(r.byteLength===t.byteLength)return r;let n=new DataView(t.buffer);return this.viewCache=n,n}finish(){let t=this.buffer.slice(0,this.pos);return this.pos=0,this.stackPos=[],t}fork(){return this.stackPos.push(this.pos),this.ensureCapacity(pa),this.buffer[this.pos++]=0,this}join(){let t=this.stackPos.pop();if(t===void 0)throw new Error("invalid state, fork stack empty");let r=this.pos-t-pa,n=ef(r);return n>pa&&(this.ensureCapacity(n-pa),this.buffer.copyWithin(t+n,t+pa,this.pos)),this.pos=t,this.uint32(r),this.pos+=r,this}tag(t,r){return this.uint32((t<<3|r)>>>0)}raw(t){return this.ensureCapacity(t.length),this.buffer.set(t,this.pos),this.pos+=t.length,this}uint32(t){if(hS(t),this.ensureCapacity(5),t<128)return this.buffer[this.pos++]=t,this;for(;t>127;)this.buffer[this.pos++]=t&127|128,t>>>=7;return this.buffer[this.pos++]=t,this}int32(t){if(tf(t),t>=0)return this.uint32(t);this.ensureCapacity(10);for(let r=0;r<9;r++)this.buffer[this.pos++]=t&127|128,t>>=7;return this.buffer[this.pos++]=1,this}bool(t){return this.ensureCapacity(1),this.buffer[this.pos++]=t?1:0,this}bytes(t){return this.uint32(t.byteLength),this.raw(t)}string(t){typeof t!="string"&&(t=String(t));let r=t.length;if(r<=vS){this.ensureCapacity(r+1);let c=this.buffer,u=this.pos;c[u++]=r;let h=0;for(;h<r;h++){let v=t.charCodeAt(h);if(v>127)break;c[u++]=v}if(h==r)return this.pos=u,this}this.ensureCapacity(r*3+5);let n=ef(r),o=this.buffer,i=this.pos,{written:a}=this.encodeUtf8Into(t,o.subarray(i+n)),s=ef(a);return s!=n&&o.copyWithin(i+s,i+n,i+n+a),this.uint32(a),this.pos+=a,this}float(t){return nO(t),this.ensureCapacity(4),this.view().setFloat32(this.pos,t,!0),this.pos+=4,this}double(t){return this.ensureCapacity(8),this.view().setFloat64(this.pos,t,!0),this.pos+=8,this}fixed32(t){return hS(t),this.ensureCapacity(4),this.view().setUint32(this.pos,t,!0),this.pos+=4,this}sfixed32(t){return tf(t),this.ensureCapacity(4),this.view().setInt32(this.pos,t,!0),this.pos+=4,this}sint32(t){return tf(t),this.uint32((t<<1^t>>31)>>>0)}sfixed64(t){let r=Bt.enc(t);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,r.lo,!0),n.setInt32(this.pos+4,r.hi,!0),this.pos+=8,this}fixed64(t){let r=Bt.uEnc(t);this.ensureCapacity(8);let n=this.view();return n.setInt32(this.pos,r.lo,!0),n.setInt32(this.pos+4,r.hi,!0),this.pos+=8,this}int64(t){let r=Bt.enc(t);return this.writeVarint64(r.lo,r.hi)}sint64(t){let r=Bt.enc(t),n=r.hi>>31,o=r.lo<<1^n,i=(r.hi<<1|r.lo>>>31)^n;return this.writeVarint64(o,i)}uint64(t){let r=Bt.uEnc(t);return this.writeVarint64(r.lo,r.hi)}writeVarint64(t,r){this.ensureCapacity(10);let n=this.buffer,o=this.pos;for(let s=0;s<28;s=s+7){let c=t>>>s,u=!(!(c>>>7)&&r==0);if(n[o++]=(u?c|128:c)&255,!u)return this.pos=o,this}let i=t>>>28&15|(r&7)<<4,a=r>>3!=0;if(n[o++]=(a?i|128:i)&255,!a)return this.pos=o,this;for(let s=3;s<31;s=s+7){let c=r>>>s,u=!!(c>>>7);if(n[o++]=(u?c|128:c)&255,!u)return this.pos=o,this}return n[o++]=r>>>31&1,this.pos=o,this}},tO=128,pa=1,yS=new Uint8Array(0),rO=new DataView(yS.buffer),vS=32;function ef(e){return e<128?1:e<16384?2:e<2097152?3:e<268435456?4:5}var J=class{constructor(t,r=Zp().decodeUtf8){this.decodeUtf8=r,this.varint64Lo=0,this.varint64Hi=0,this.varint64=lS,this.uint32=fS,this.buf=t,this.len=t.length,this.pos=0,this.view=new DataView(t.buffer,t.byteOffset,t.byteLength)}tag(){let t=this.pos,r=this.uint32(),n=this.pos-t;if(n>5||n==5&&this.buf[this.pos-1]>15)throw new Error("illegal tag: varint overflows uint32");let o=r>>>3,i=r&7;if(o<=0||i>5)throw new Error("illegal tag: field no "+o+" wire type "+i);return[o,i]}skip(t,r,n=100){let o=this.pos;switch(t){case Gr.Varint:for(;this.buf[this.pos++]&128;);break;case Gr.Bit64:this.pos+=4;case Gr.Bit32:this.pos+=4;break;case Gr.LengthDelimited:let i=this.uint32();this.pos+=i;break;case Gr.StartGroup:if(n<=0)throw new Error("maximum recursion depth reached");for(;;){let[a,s]=this.tag();if(s===Gr.EndGroup){if(r!==void 0&&a!==r)throw new Error("invalid end group tag");break}this.skip(s,a,n-1)}break;default:throw new Error("cant skip wire type "+t)}return this.assertBounds(),this.buf.subarray(o,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return this.uint32()|0}sint32(){let t=this.uint32();return t>>>1^-(t&1)}int64(){return this.varint64(),Bt.dec(this.varint64Lo,this.varint64Hi)}uint64(){return this.varint64(),Bt.uDec(this.varint64Lo,this.varint64Hi)}sint64(){this.varint64();let t=this.varint64Lo,r=this.varint64Hi,n=-(t&1);return t=(t>>>1|(r&1)<<31)^n,r=r>>>1^n,Bt.dec(t,r)}bool(){let t=this.buf[this.pos];return t<128?(this.pos++,t!==0):(this.varint64(),this.varint64Lo!==0||this.varint64Hi!==0)}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Bt.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Bt.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 t=this.uint32(),r=this.pos;return this.pos+=t,this.assertBounds(),this.buf.subarray(r,r+t)}string(t){let r=this.bytes(),n=r.length;if(n<=vS){let o=new Array(n);for(let i=0;i<n;i++){let a=r[i];if(a>127)return this.decodeUtf8(r,t);o[i]=a}return String.fromCharCode.apply(String,o)}return this.decodeUtf8(r,t)}};function tf(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid int32: "+typeof e);if(!Number.isInteger(e)||e>Jk||e<eO)throw new Error("invalid int32: "+e)}function hS(e){if(typeof e=="string")e=Number(e);else if(typeof e!="number")throw new Error("invalid uint32: "+typeof e);if(!Number.isInteger(e)||e>Zk||e<0)throw new Error("invalid uint32: "+e)}function nO(e){if(typeof e=="string"){let t=e;if(e=Number(e),Number.isNaN(e)&&t!=="NaN")throw new Error("invalid float32: "+t)}else if(typeof e!="number")throw new Error("invalid float32: "+typeof e);if(Number.isFinite(e)&&(e>Yk||e<Xk))throw new Error("invalid float32: "+e)}var oO=function(e){return e[e.NULL_VALUE=0]="NULL_VALUE",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function rf(){return{fields:{}}}var fa={encode(e,t=new ve){return Object.entries(e.fields).forEach(([r,n])=>{n!==void 0&&af.encode({key:r,value:n},t.uint32(10).fork()).join()}),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=rf();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:{if(i!==10)break;let a=af.decode(r,r.uint32());a.value!==void 0&&(o.fields[a.key]=a.value);continue}}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return fa.fromPartial(e??{})},fromPartial(e){let t=rf();return t.fields=Object.entries(e.fields??{}).reduce((r,[n,o])=>(o!==void 0&&(r[n]=o),r),{}),t},wrap(e){let t=rf();if(e!==void 0)for(let r of Object.keys(e))t.fields[r]=e[r];return t},unwrap(e){let t={};if(e.fields)for(let r of Object.keys(e.fields))t[r]=e.fields[r];return t}};function SS(){return{key:"",value:void 0}}var af={encode(e,t=new ve){return e.key!==""&&t.uint32(10).string(e.key),e.value!==void 0&&ce.encode(ce.wrap(e.value),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=SS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.key=r.string();continue;case 2:if(i!==18)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return af.fromPartial(e??{})},fromPartial(e){let t=SS();return t.key=e.key??"",t.value=e.value??void 0,t}};function nf(){return{nullValue:void 0,numberValue:void 0,stringValue:void 0,boolValue:void 0,structValue:void 0,listValue:void 0}}var ce={encode(e,t=new ve){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&&fa.encode(fa.wrap(e.structValue),t.uint32(42).fork()).join(),e.listValue!==void 0&&ma.encode(ma.wrap(e.listValue),t.uint32(50).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=nf();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.nullValue=r.int32();continue;case 2:if(i!==17)break;o.numberValue=r.double();continue;case 3:if(i!==26)break;o.stringValue=r.string();continue;case 4:if(i!==32)break;o.boolValue=r.bool();continue;case 5:if(i!==42)break;o.structValue=fa.unwrap(fa.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.listValue=ma.unwrap(ma.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ce.fromPartial(e??{})},fromPartial(e){let t=nf();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=nf();if(e===null)t.nullValue=oO.NULL_VALUE;else if(typeof e=="boolean")t.boolValue=e;else if(typeof e=="number")t.numberValue=e;else if(typeof e=="string")t.stringValue=e;else if(w.Array.isArray(e))t.listValue=e;else if(typeof e=="object")t.structValue=e;else if(typeof e<"u")throw new w.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 of(){return{values:[]}}var ma={encode(e,t=new ve){for(let r of e.values)ce.encode(ce.wrap(r),t.uint32(10).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=of();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.values.push(ce.unwrap(ce.decode(r,r.uint32())));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ma.fromPartial(e??{})},fromPartial(e){let t=of();return t.values=e.values?.map(r=>r)||[],t},wrap(e){let t=of();return t.values=e??[],t},unwrap(e){return e?.hasOwnProperty("values")&&w.Array.isArray(e.values)?e.values:e}},iO=function(e){return e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.REPLACE=2]="REPLACE",e[e.MOVE=3]="MOVE",e[e.COPY=4]="COPY",e[e.TEST=5]="TEST",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function bS(){return{op:0,path:"",from:void 0,value:void 0}}var au={encode(e,t=new ve){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&&ce.encode(ce.wrap(e.value),t.uint32(34).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=bS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.op=r.int32();continue;case 2:if(i!==18)break;o.path=r.string();continue;case 3:if(i!==26)break;o.from=r.string();continue;case 4:if(i!==34)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return au.fromPartial(e??{})},fromPartial(e){let t=bS();return t.op=e.op??0,t.path=e.path??"",t.from=e.from??void 0,t.value=e.value??void 0,t}};function wS(){return{id:"",type:"",function:void 0}}var su={encode(e,t=new ve){return e.id!==""&&t.uint32(10).string(e.id),e.type!==""&&t.uint32(18).string(e.type),e.function!==void 0&&cu.encode(e.function,t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=wS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.type=r.string();continue;case 3:if(i!==26)break;o.function=cu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return su.fromPartial(e??{})},fromPartial(e){let t=wS();return t.id=e.id??"",t.type=e.type??"",t.function=e.function!==void 0&&e.function!==null?cu.fromPartial(e.function):void 0,t}};function AS(){return{name:"",arguments:""}}var cu={encode(e,t=new ve){return e.name!==""&&t.uint32(10).string(e.name),e.arguments!==""&&t.uint32(18).string(e.arguments),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=AS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.name=r.string();continue;case 2:if(i!==18)break;o.arguments=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return cu.fromPartial(e??{})},fromPartial(e){let t=AS();return t.name=e.name??"",t.arguments=e.arguments??"",t}};function xS(){return{value:"",mimeType:""}}var uu={encode(e,t=new ve){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==""&&t.uint32(18).string(e.mimeType),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=xS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=r.string();continue;case 2:if(i!==18)break;o.mimeType=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return uu.fromPartial(e??{})},fromPartial(e){let t=xS();return t.value=e.value??"",t.mimeType=e.mimeType??"",t}};function CS(){return{value:"",mimeType:void 0}}var lu={encode(e,t=new ve){return e.value!==""&&t.uint32(10).string(e.value),e.mimeType!==void 0&&t.uint32(18).string(e.mimeType),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=CS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.value=r.string();continue;case 2:if(i!==18)break;o.mimeType=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return lu.fromPartial(e??{})},fromPartial(e){let t=CS();return t.value=e.value??"",t.mimeType=e.mimeType??void 0,t}};function ES(){return{data:void 0,url:void 0}}var Et={encode(e,t=new ve){return e.data!==void 0&&uu.encode(e.data,t.uint32(10).fork()).join(),e.url!==void 0&&lu.encode(e.url,t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=ES();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.data=uu.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.url=lu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Et.fromPartial(e??{})},fromPartial(e){let t=ES();return t.data=e.data!==void 0&&e.data!==null?uu.fromPartial(e.data):void 0,t.url=e.url!==void 0&&e.url!==null?lu.fromPartial(e.url):void 0,t}};function RS(){return{text:""}}var du={encode(e,t=new ve){return e.text!==""&&t.uint32(10).string(e.text),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=RS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return du.fromPartial(e??{})},fromPartial(e){let t=RS();return t.text=e.text??"",t}};function IS(){return{source:void 0,metadata:void 0}}var pu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=IS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return pu.fromPartial(e??{})},fromPartial(e){let t=IS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function TS(){return{source:void 0,metadata:void 0}}var fu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=TS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return fu.fromPartial(e??{})},fromPartial(e){let t=TS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function _S(){return{source:void 0,metadata:void 0}}var mu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=_S();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return mu.fromPartial(e??{})},fromPartial(e){let t=_S();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function kS(){return{source:void 0,metadata:void 0}}var gu={encode(e,t=new ve){return e.source!==void 0&&Et.encode(e.source,t.uint32(10).fork()).join(),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=kS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.source=Et.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return gu.fromPartial(e??{})},fromPartial(e){let t=kS();return t.source=e.source!==void 0&&e.source!==null?Et.fromPartial(e.source):void 0,t.metadata=e.metadata??void 0,t}};function OS(){return{text:void 0,image:void 0,audio:void 0,video:void 0,document:void 0}}var hu={encode(e,t=new ve){return e.text!==void 0&&du.encode(e.text,t.uint32(10).fork()).join(),e.image!==void 0&&pu.encode(e.image,t.uint32(18).fork()).join(),e.audio!==void 0&&fu.encode(e.audio,t.uint32(26).fork()).join(),e.video!==void 0&&mu.encode(e.video,t.uint32(34).fork()).join(),e.document!==void 0&&gu.encode(e.document,t.uint32(42).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=OS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.text=du.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.image=pu.decode(r,r.uint32());continue;case 3:if(i!==26)break;o.audio=fu.decode(r,r.uint32());continue;case 4:if(i!==34)break;o.video=mu.decode(r,r.uint32());continue;case 5:if(i!==42)break;o.document=gu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return hu.fromPartial(e??{})},fromPartial(e){let t=OS();return t.text=e.text!==void 0&&e.text!==null?du.fromPartial(e.text):void 0,t.image=e.image!==void 0&&e.image!==null?pu.fromPartial(e.image):void 0,t.audio=e.audio!==void 0&&e.audio!==null?fu.fromPartial(e.audio):void 0,t.video=e.video!==void 0&&e.video!==null?mu.fromPartial(e.video):void 0,t.document=e.document!==void 0&&e.document!==null?gu.fromPartial(e.document):void 0,t}};function PS(){return{id:"",role:"",content:void 0,name:void 0,toolCalls:[],toolCallId:void 0,error:void 0,contentParts:[]}}var yu={encode(e,t=new ve){e.id!==""&&t.uint32(10).string(e.id),e.role!==""&&t.uint32(18).string(e.role),e.content!==void 0&&t.uint32(26).string(e.content),e.name!==void 0&&t.uint32(34).string(e.name);for(let r of e.toolCalls)su.encode(r,t.uint32(42).fork()).join();e.toolCallId!==void 0&&t.uint32(50).string(e.toolCallId),e.error!==void 0&&t.uint32(58).string(e.error);for(let r of e.contentParts)hu.encode(r,t.uint32(66).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=PS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.role=r.string();continue;case 3:if(i!==26)break;o.content=r.string();continue;case 4:if(i!==34)break;o.name=r.string();continue;case 5:if(i!==42)break;o.toolCalls.push(su.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.toolCallId=r.string();continue;case 7:if(i!==58)break;o.error=r.string();continue;case 8:if(i!==66)break;o.contentParts.push(hu.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return yu.fromPartial(e??{})},fromPartial(e){let t=PS();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(r=>su.fromPartial(r))||[],t.toolCallId=e.toolCallId??void 0,t.error=e.error??void 0,t.contentParts=e.contentParts?.map(r=>hu.fromPartial(r))||[],t}};function NS(){return{id:"",reason:"",message:void 0,toolCallId:void 0,responseSchema:void 0,expiresAt:void 0,metadata:void 0}}var vu={encode(e,t=new ve){return e.id!==""&&t.uint32(10).string(e.id),e.reason!==""&&t.uint32(18).string(e.reason),e.message!==void 0&&t.uint32(26).string(e.message),e.toolCallId!==void 0&&t.uint32(34).string(e.toolCallId),e.responseSchema!==void 0&&ce.encode(ce.wrap(e.responseSchema),t.uint32(42).fork()).join(),e.expiresAt!==void 0&&t.uint32(50).string(e.expiresAt),e.metadata!==void 0&&ce.encode(ce.wrap(e.metadata),t.uint32(58).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=NS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.id=r.string();continue;case 2:if(i!==18)break;o.reason=r.string();continue;case 3:if(i!==26)break;o.message=r.string();continue;case 4:if(i!==34)break;o.toolCallId=r.string();continue;case 5:if(i!==42)break;o.responseSchema=ce.unwrap(ce.decode(r,r.uint32()));continue;case 6:if(i!==50)break;o.expiresAt=r.string();continue;case 7:if(i!==58)break;o.metadata=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return vu.fromPartial(e??{})},fromPartial(e){let t=NS();return t.id=e.id??"",t.reason=e.reason??"",t.message=e.message??void 0,t.toolCallId=e.toolCallId??void 0,t.responseSchema=e.responseSchema??void 0,t.expiresAt=e.expiresAt??void 0,t.metadata=e.metadata??void 0,t}},aO=function(e){return e[e.TEXT_MESSAGE_START=0]="TEXT_MESSAGE_START",e[e.TEXT_MESSAGE_CONTENT=1]="TEXT_MESSAGE_CONTENT",e[e.TEXT_MESSAGE_END=2]="TEXT_MESSAGE_END",e[e.TOOL_CALL_START=3]="TOOL_CALL_START",e[e.TOOL_CALL_ARGS=4]="TOOL_CALL_ARGS",e[e.TOOL_CALL_END=5]="TOOL_CALL_END",e[e.STATE_SNAPSHOT=6]="STATE_SNAPSHOT",e[e.STATE_DELTA=7]="STATE_DELTA",e[e.MESSAGES_SNAPSHOT=8]="MESSAGES_SNAPSHOT",e[e.RAW=9]="RAW",e[e.CUSTOM=10]="CUSTOM",e[e.RUN_STARTED=11]="RUN_STARTED",e[e.RUN_FINISHED=12]="RUN_FINISHED",e[e.RUN_ERROR=13]="RUN_ERROR",e[e.STEP_STARTED=14]="STEP_STARTED",e[e.STEP_FINISHED=15]="STEP_FINISHED",e[e.UNRECOGNIZED=-1]="UNRECOGNIZED",e}({});function FS(){return{type:0,timestamp:void 0,rawEvent:void 0}}var le={encode(e,t=new ve){return e.type!==0&&t.uint32(8).int32(e.type),e.timestamp!==void 0&&t.uint32(16).int64(e.timestamp),e.rawEvent!==void 0&&ce.encode(ce.wrap(e.rawEvent),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=FS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==8)break;o.type=r.int32();continue;case 2:if(i!==16)break;o.timestamp=Ho(r.int64());continue;case 3:if(i!==26)break;o.rawEvent=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return le.fromPartial(e??{})},fromPartial(e){let t=FS();return t.type=e.type??0,t.timestamp=e.timestamp??void 0,t.rawEvent=e.rawEvent??void 0,t}};function DS(){return{baseEvent:void 0,messageId:"",role:void 0,name:void 0}}var Su={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.name!==void 0&&t.uint32(34).string(e.name),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=DS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.role=r.string();continue;case 4:if(i!==34)break;o.name=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Su.fromPartial(e??{})},fromPartial(e){let t=DS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.role=e.role??void 0,t.name=e.name??void 0,t}};function MS(){return{baseEvent:void 0,messageId:"",delta:""}}var bu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=MS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return bu.fromPartial(e??{})},fromPartial(e){let t=MS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t.delta=e.delta??"",t}};function qS(){return{baseEvent:void 0,messageId:""}}var wu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==""&&t.uint32(18).string(e.messageId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=qS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return wu.fromPartial(e??{})},fromPartial(e){let t=qS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??"",t}};function jS(){return{baseEvent:void 0,toolCallId:"",toolCallName:"",parentMessageId:void 0}}var Au={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.toolCallName!==""&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=jS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.toolCallName=r.string();continue;case 4:if(i!==34)break;o.parentMessageId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Au.fromPartial(e??{})},fromPartial(e){let t=jS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.toolCallName=e.toolCallName??"",t.parentMessageId=e.parentMessageId??void 0,t}};function LS(){return{baseEvent:void 0,toolCallId:"",delta:""}}var xu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),e.delta!==""&&t.uint32(26).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=LS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return xu.fromPartial(e??{})},fromPartial(e){let t=LS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t.delta=e.delta??"",t}};function US(){return{baseEvent:void 0,toolCallId:""}}var Cu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==""&&t.uint32(18).string(e.toolCallId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=US();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Cu.fromPartial(e??{})},fromPartial(e){let t=US();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.toolCallId=e.toolCallId??"",t}};function VS(){return{baseEvent:void 0,snapshot:void 0}}var Eu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.snapshot!==void 0&&ce.encode(ce.wrap(e.snapshot),t.uint32(18).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=VS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.snapshot=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Eu.fromPartial(e??{})},fromPartial(e){let t=VS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.snapshot=e.snapshot??void 0,t}};function BS(){return{baseEvent:void 0,delta:[]}}var Ru={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.delta)au.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=BS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.delta.push(au.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Ru.fromPartial(e??{})},fromPartial(e){let t=BS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.delta=e.delta?.map(r=>au.fromPartial(r))||[],t}};function GS(){return{baseEvent:void 0,messages:[]}}var Iu={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join();for(let r of e.messages)yu.encode(r,t.uint32(18).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=GS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messages.push(yu.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Iu.fromPartial(e??{})},fromPartial(e){let t=GS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messages=e.messages?.map(r=>yu.fromPartial(r))||[],t}};function $S(){return{baseEvent:void 0,event:void 0,source:void 0}}var Tu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.event!==void 0&&ce.encode(ce.wrap(e.event),t.uint32(18).fork()).join(),e.source!==void 0&&t.uint32(26).string(e.source),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=$S();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.event=ce.unwrap(ce.decode(r,r.uint32()));continue;case 3:if(i!==26)break;o.source=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Tu.fromPartial(e??{})},fromPartial(e){let t=$S();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.event=e.event??void 0,t.source=e.source??void 0,t}};function QS(){return{baseEvent:void 0,name:"",value:void 0}}var _u={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.name!==""&&t.uint32(18).string(e.name),e.value!==void 0&&ce.encode(ce.wrap(e.value),t.uint32(26).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=QS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.name=r.string();continue;case 3:if(i!==26)break;o.value=ce.unwrap(ce.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return _u.fromPartial(e??{})},fromPartial(e){let t=QS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.name=e.name??"",t.value=e.value??void 0,t}};function HS(){return{baseEvent:void 0,threadId:"",runId:""}}var ku={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.threadId!==""&&t.uint32(18).string(e.threadId),e.runId!==""&&t.uint32(26).string(e.runId),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=HS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.threadId=r.string();continue;case 3:if(i!==26)break;o.runId=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return ku.fromPartial(e??{})},fromPartial(e){let t=HS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t}};function zS(){return{provider:void 0,model:void 0,inputTokens:void 0,outputTokens:void 0,totalTokens:void 0,reasoningTokens:void 0,cachedInputTokens:void 0}}var qn={encode(e,t=new ve){return e.provider!==void 0&&t.uint32(10).string(e.provider),e.model!==void 0&&t.uint32(18).string(e.model),e.inputTokens!==void 0&&t.uint32(24).int64(e.inputTokens),e.outputTokens!==void 0&&t.uint32(32).int64(e.outputTokens),e.totalTokens!==void 0&&t.uint32(40).int64(e.totalTokens),e.reasoningTokens!==void 0&&t.uint32(48).int64(e.reasoningTokens),e.cachedInputTokens!==void 0&&t.uint32(56).int64(e.cachedInputTokens),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=zS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.provider=r.string();continue;case 2:if(i!==18)break;o.model=r.string();continue;case 3:if(i!==24)break;o.inputTokens=Ho(r.int64());continue;case 4:if(i!==32)break;o.outputTokens=Ho(r.int64());continue;case 5:if(i!==40)break;o.totalTokens=Ho(r.int64());continue;case 6:if(i!==48)break;o.reasoningTokens=Ho(r.int64());continue;case 7:if(i!==56)break;o.cachedInputTokens=Ho(r.int64());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return qn.fromPartial(e??{})},fromPartial(e){let t=zS();return t.provider=e.provider??void 0,t.model=e.model??void 0,t.inputTokens=e.inputTokens??void 0,t.outputTokens=e.outputTokens??void 0,t.totalTokens=e.totalTokens??void 0,t.reasoningTokens=e.reasoningTokens??void 0,t.cachedInputTokens=e.cachedInputTokens??void 0,t}};function WS(){return{baseEvent:void 0,threadId:"",runId:"",result:void 0,outcome:"",interrupts:[],usage:[]}}var Ou={encode(e,t=new ve){e.baseEvent!==void 0&&le.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&&ce.encode(ce.wrap(e.result),t.uint32(34).fork()).join(),e.outcome!==""&&t.uint32(42).string(e.outcome);for(let r of e.interrupts)vu.encode(r,t.uint32(50).fork()).join();for(let r of e.usage)qn.encode(r,t.uint32(58).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=WS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.threadId=r.string();continue;case 3:if(i!==26)break;o.runId=r.string();continue;case 4:if(i!==34)break;o.result=ce.unwrap(ce.decode(r,r.uint32()));continue;case 5:if(i!==42)break;o.outcome=r.string();continue;case 6:if(i!==50)break;o.interrupts.push(vu.decode(r,r.uint32()));continue;case 7:if(i!==58)break;o.usage.push(qn.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Ou.fromPartial(e??{})},fromPartial(e){let t=WS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.threadId=e.threadId??"",t.runId=e.runId??"",t.result=e.result??void 0,t.outcome=e.outcome??"",t.interrupts=e.interrupts?.map(r=>vu.fromPartial(r))||[],t.usage=e.usage?.map(r=>qn.fromPartial(r))||[],t}};function KS(){return{baseEvent:void 0,code:void 0,message:"",usage:[]}}var Pu={encode(e,t=new ve){e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.code!==void 0&&t.uint32(18).string(e.code),e.message!==""&&t.uint32(26).string(e.message);for(let r of e.usage)qn.encode(r,t.uint32(34).fork()).join();return t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=KS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.code=r.string();continue;case 3:if(i!==26)break;o.message=r.string();continue;case 4:if(i!==34)break;o.usage.push(qn.decode(r,r.uint32()));continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Pu.fromPartial(e??{})},fromPartial(e){let t=KS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.code=e.code??void 0,t.message=e.message??"",t.usage=e.usage?.map(r=>qn.fromPartial(r))||[],t}};function YS(){return{baseEvent:void 0,stepName:""}}var Nu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=YS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.stepName=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Nu.fromPartial(e??{})},fromPartial(e){let t=YS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function XS(){return{baseEvent:void 0,stepName:""}}var Fu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.stepName!==""&&t.uint32(18).string(e.stepName),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=XS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.stepName=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Fu.fromPartial(e??{})},fromPartial(e){let t=XS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.stepName=e.stepName??"",t}};function ZS(){return{baseEvent:void 0,messageId:void 0,role:void 0,delta:void 0,name:void 0}}var Du={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.messageId!==void 0&&t.uint32(18).string(e.messageId),e.role!==void 0&&t.uint32(26).string(e.role),e.delta!==void 0&&t.uint32(34).string(e.delta),e.name!==void 0&&t.uint32(42).string(e.name),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=ZS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.messageId=r.string();continue;case 3:if(i!==26)break;o.role=r.string();continue;case 4:if(i!==34)break;o.delta=r.string();continue;case 5:if(i!==42)break;o.name=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Du.fromPartial(e??{})},fromPartial(e){let t=ZS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.fromPartial(e.baseEvent):void 0,t.messageId=e.messageId??void 0,t.role=e.role??void 0,t.delta=e.delta??void 0,t.name=e.name??void 0,t}};function JS(){return{baseEvent:void 0,toolCallId:void 0,toolCallName:void 0,parentMessageId:void 0,delta:void 0}}var Mu={encode(e,t=new ve){return e.baseEvent!==void 0&&le.encode(e.baseEvent,t.uint32(10).fork()).join(),e.toolCallId!==void 0&&t.uint32(18).string(e.toolCallId),e.toolCallName!==void 0&&t.uint32(26).string(e.toolCallName),e.parentMessageId!==void 0&&t.uint32(34).string(e.parentMessageId),e.delta!==void 0&&t.uint32(42).string(e.delta),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=JS();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.baseEvent=le.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.toolCallId=r.string();continue;case 3:if(i!==26)break;o.toolCallName=r.string();continue;case 4:if(i!==34)break;o.parentMessageId=r.string();continue;case 5:if(i!==42)break;o.delta=r.string();continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return Mu.fromPartial(e??{})},fromPartial(e){let t=JS();return t.baseEvent=e.baseEvent!==void 0&&e.baseEvent!==null?le.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 eb(){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 tb={encode(e,t=new ve){return e.textMessageStart!==void 0&&Su.encode(e.textMessageStart,t.uint32(10).fork()).join(),e.textMessageContent!==void 0&&bu.encode(e.textMessageContent,t.uint32(18).fork()).join(),e.textMessageEnd!==void 0&&wu.encode(e.textMessageEnd,t.uint32(26).fork()).join(),e.toolCallStart!==void 0&&Au.encode(e.toolCallStart,t.uint32(34).fork()).join(),e.toolCallArgs!==void 0&&xu.encode(e.toolCallArgs,t.uint32(42).fork()).join(),e.toolCallEnd!==void 0&&Cu.encode(e.toolCallEnd,t.uint32(50).fork()).join(),e.stateSnapshot!==void 0&&Eu.encode(e.stateSnapshot,t.uint32(58).fork()).join(),e.stateDelta!==void 0&&Ru.encode(e.stateDelta,t.uint32(66).fork()).join(),e.messagesSnapshot!==void 0&&Iu.encode(e.messagesSnapshot,t.uint32(74).fork()).join(),e.raw!==void 0&&Tu.encode(e.raw,t.uint32(82).fork()).join(),e.custom!==void 0&&_u.encode(e.custom,t.uint32(90).fork()).join(),e.runStarted!==void 0&&ku.encode(e.runStarted,t.uint32(98).fork()).join(),e.runFinished!==void 0&&Ou.encode(e.runFinished,t.uint32(106).fork()).join(),e.runError!==void 0&&Pu.encode(e.runError,t.uint32(114).fork()).join(),e.stepStarted!==void 0&&Nu.encode(e.stepStarted,t.uint32(122).fork()).join(),e.stepFinished!==void 0&&Fu.encode(e.stepFinished,t.uint32(130).fork()).join(),e.textMessageChunk!==void 0&&Du.encode(e.textMessageChunk,t.uint32(138).fork()).join(),e.toolCallChunk!==void 0&&Mu.encode(e.toolCallChunk,t.uint32(146).fork()).join(),t},decode(e,t){let r=e instanceof J?e:new J(e),n=t===void 0?r.len:r.pos+t,o=eb();for(;r.pos<n;){let i=r.uint32();switch(i>>>3){case 1:if(i!==10)break;o.textMessageStart=Su.decode(r,r.uint32());continue;case 2:if(i!==18)break;o.textMessageContent=bu.decode(r,r.uint32());continue;case 3:if(i!==26)break;o.textMessageEnd=wu.decode(r,r.uint32());continue;case 4:if(i!==34)break;o.toolCallStart=Au.decode(r,r.uint32());continue;case 5:if(i!==42)break;o.toolCallArgs=xu.decode(r,r.uint32());continue;case 6:if(i!==50)break;o.toolCallEnd=Cu.decode(r,r.uint32());continue;case 7:if(i!==58)break;o.stateSnapshot=Eu.decode(r,r.uint32());continue;case 8:if(i!==66)break;o.stateDelta=Ru.decode(r,r.uint32());continue;case 9:if(i!==74)break;o.messagesSnapshot=Iu.decode(r,r.uint32());continue;case 10:if(i!==82)break;o.raw=Tu.decode(r,r.uint32());continue;case 11:if(i!==90)break;o.custom=_u.decode(r,r.uint32());continue;case 12:if(i!==98)break;o.runStarted=ku.decode(r,r.uint32());continue;case 13:if(i!==106)break;o.runFinished=Ou.decode(r,r.uint32());continue;case 14:if(i!==114)break;o.runError=Pu.decode(r,r.uint32());continue;case 15:if(i!==122)break;o.stepStarted=Nu.decode(r,r.uint32());continue;case 16:if(i!==130)break;o.stepFinished=Fu.decode(r,r.uint32());continue;case 17:if(i!==138)break;o.textMessageChunk=Du.decode(r,r.uint32());continue;case 18:if(i!==146)break;o.toolCallChunk=Mu.decode(r,r.uint32());continue}if((i&7)===4||i===0)break;r.skip(i&7)}return o},create(e){return tb.fromPartial(e??{})},fromPartial(e){let t=eb();return t.textMessageStart=e.textMessageStart!==void 0&&e.textMessageStart!==null?Su.fromPartial(e.textMessageStart):void 0,t.textMessageContent=e.textMessageContent!==void 0&&e.textMessageContent!==null?bu.fromPartial(e.textMessageContent):void 0,t.textMessageEnd=e.textMessageEnd!==void 0&&e.textMessageEnd!==null?wu.fromPartial(e.textMessageEnd):void 0,t.toolCallStart=e.toolCallStart!==void 0&&e.toolCallStart!==null?Au.fromPartial(e.toolCallStart):void 0,t.toolCallArgs=e.toolCallArgs!==void 0&&e.toolCallArgs!==null?xu.fromPartial(e.toolCallArgs):void 0,t.toolCallEnd=e.toolCallEnd!==void 0&&e.toolCallEnd!==null?Cu.fromPartial(e.toolCallEnd):void 0,t.stateSnapshot=e.stateSnapshot!==void 0&&e.stateSnapshot!==null?Eu.fromPartial(e.stateSnapshot):void 0,t.stateDelta=e.stateDelta!==void 0&&e.stateDelta!==null?Ru.fromPartial(e.stateDelta):void 0,t.messagesSnapshot=e.messagesSnapshot!==void 0&&e.messagesSnapshot!==null?Iu.fromPartial(e.messagesSnapshot):void 0,t.raw=e.raw!==void 0&&e.raw!==null?Tu.fromPartial(e.raw):void 0,t.custom=e.custom!==void 0&&e.custom!==null?_u.fromPartial(e.custom):void 0,t.runStarted=e.runStarted!==void 0&&e.runStarted!==null?ku.fromPartial(e.runStarted):void 0,t.runFinished=e.runFinished!==void 0&&e.runFinished!==null?Ou.fromPartial(e.runFinished):void 0,t.runError=e.runError!==void 0&&e.runError!==null?Pu.fromPartial(e.runError):void 0,t.stepStarted=e.stepStarted!==void 0&&e.stepStarted!==null?Nu.fromPartial(e.stepStarted):void 0,t.stepFinished=e.stepFinished!==void 0&&e.stepFinished!==null?Fu.fromPartial(e.stepFinished):void 0,t.textMessageChunk=e.textMessageChunk!==void 0&&e.textMessageChunk!==null?Du.fromPartial(e.textMessageChunk):void 0,t.toolCallChunk=e.toolCallChunk!==void 0&&e.toolCallChunk!==null?Mu.fromPartial(e.toolCallChunk):void 0,t}};function Ho(e){let t=w.Number(e.toString());if(t>w.Number.MAX_SAFE_INTEGER)throw new w.Error("Value is larger than Number.MAX_SAFE_INTEGER");if(t<w.Number.MIN_SAFE_INTEGER)throw new w.Error("Value is smaller than Number.MIN_SAFE_INTEGER");return t}var rb=e=>e&&typeof e=="object"?e:void 0;var iu=e=>{let t=rb(e);if(t){if(t.data){let r=t.data;return{type:"data",value:r.value,mimeType:r.mimeType}}if(t.url){let r=t.url;return{type:"url",value:r.value,mimeType:r.mimeType}}}},sO=e=>{let t=rb(e);if(t){if(t.text)return{type:"text",text:t.text.text};if(t.image){let r=t.image;return{type:"image",source:iu(r.source),metadata:r.metadata}}if(t.audio){let r=t.audio;return{type:"audio",source:iu(r.source),metadata:r.metadata}}if(t.video){let r=t.video;return{type:"video",source:iu(r.source),metadata:r.metadata}}if(t.document){let r=t.document;return{type:"document",source:iu(r.source),metadata:r.metadata}}}};function nb(e){let t=tb.decode(e),r=Object.values(t).find(n=>n!==void 0);if(!r)throw new Error("Invalid event");if(r.type=aO[r.baseEvent.type],r.timestamp=r.baseEvent.timestamp,r.rawEvent=r.baseEvent.rawEvent,delete r.baseEvent,r.type===M.MESSAGES_SNAPSHOT)for(let n of r.messages){let o=n;if(o.role==="user"&&Array.isArray(o.contentParts)){let i=o.contentParts.map(a=>sO(a)).filter(a=>a!==void 0);i.length>0&&(o.content=i)}Array.isArray(o.contentParts)&&o.contentParts.length===0&&(o.contentParts=void 0),o.toolCalls?.length===0&&(o.toolCalls=void 0)}if(r.type===M.RUN_FINISHED){let n=r,o=typeof n.outcome=="string"&&n.outcome!==""?n.outcome:void 0,i=Array.isArray(n.interrupts)?n.interrupts:[];delete n.interrupts,o==="interrupt"?n.outcome={type:"interrupt",interrupts:i}:o==="success"?n.outcome={type:"success"}:delete n.outcome}if((r.type===M.RUN_FINISHED||r.type===M.RUN_ERROR)&&Array.isArray(r.usage)&&r.usage.length===0&&delete r.usage,r.type===M.STATE_DELTA)for(let n of r.delta)n.op=iO[n.op].toLowerCase(),Object.keys(n).forEach(o=>{n[o]===void 0&&delete n[o]});return Object.keys(r).forEach(n=>{r[n]===void 0&&delete r[n]}),xc.parse(r)}var sf="application/vnd.ag-ui.event+proto";m();d();f();p();m();d();f();p();m();d();f();p();var uO=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,cf=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(uO);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},ob=e=>e==="*"||e==="x"||e==="X",ib=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},lO=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],dO=(e,t)=>{if(ob(e)||ob(t))return 0;let[r,n]=lO(ib(e),ib(t));return r>n?1:r<n?-1:0},uf=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){let n=dO(e[r]||"0",t[r]||"0");if(n!==0)return n}return 0};var ga=(e,t)=>{let r=cf(e),n=cf(t),o=r.pop(),i=n.pop(),a=uf(r,n);return a!==0?a:o&&i?uf(o.split("."),i.split(".")):o||i?o?-1:1:0};var Re=e=>{if(typeof structuredClone=="function")return structuredClone(e);try{return JSON.parse(JSON.stringify(e))}catch{return Array.isArray(e)?[...e]:{...e}}};function ha(){return jr()}function pf(e){if(Object.freeze(e),typeof e=="object"&&e)for(let t of Object.values(e))typeof t=="object"&&t&&!Object.isFrozen(t)&&pf(t);return e}var ab=512*1024;function sb(e,t,r){let n=0,o=[e,t],i=new WeakSet;for(;o.length>0;){let a=o.pop();if(typeof a=="string"){if(n+=a.length,n>r)return!0}else if(typeof a=="object"&&a){if(i.has(a))continue;if(i.add(a),Array.isArray(a))for(let s=0;s<a.length;s++)o.push(a[s]);else{let s=Object.keys(a);for(let c=0;c<s.length;c++){let u=s[c];if(n+=u.length,n>r)return!0;o.push(a[u])}}}}return!1}function Oe(_x88,_x89,_x90,_x91){return _Oe.apply(this,arguments)}function _Oe(){_Oe=_asyncToGenerator(function*(e,t,r,n){let o=typeof process<"u"&&process.env!==void 0,i=o&&!!process.env.VITEST_WORKER_ID,a=o&&!!process.env.VITEST_WORKER_ID,s=a&&!sb(t,r,ab),c=s?Re(t):t,u=s?Re(r):r,h=!1,v=!1,C;for(let g of e)try{s&&(pf(c),pf(u));let y=yield n(g,c,u);if(y===void 0)continue;let S=!1;if(y.messages!==void 0&&y.messages!==c&&(c=Re(y.messages),h=!0,S=!0),y.state!==void 0&&y.state!==u&&(u=Re(y.state),v=!0,S=!0),s&&S&&sb(c,u,ab)&&(s=!1),C=y.stopPropagation,C===!0)break}catch(y){if(a&&y instanceof TypeError){if(i)throw y;console.error("AG-UI: Subscriber attempted to mutate frozen inputs in-place. Return mutations via AgentStateMutation instead of mutating directly.",y)}else i||console.error("Subscriber error:",y);continue}return{...(h?{messages:Object.isFrozen(c)?Re(c):c}:{}),...(v?{state:Object.isFrozen(u)?Re(u):u}:{}),...(C===void 0?{}:{stopPropagation:C})}});return _Oe.apply(this,arguments)}function qu(e){if(!e)return{enabled:!1,events:!1,lifecycle:!1,verbose:!1};if(e===!0)return{enabled:!0,events:!0,lifecycle:!0,verbose:!0};let t=e.events??!0,r=e.lifecycle??!0,n=e.verbose??!1;return{enabled:t||r,events:t,lifecycle:r,verbose:n}}function ya(e){if(e instanceof ff)return e;if(e===!0)return new ff(qu(!0))}var ff=class{constructor(e){this.config=e}event(e,t,r,n){this.config.events&&(this.config.verbose?console.debug(`[${e}] ${t}`,typeof r=="string"?r:JSON.stringify(r)):console.debug(`[${e}] ${t}`,n??r))}lifecycle(e,t,r){this.config.lifecycle&&(r?console.debug(`[${e}] ${t}`,r):console.debug(`[${e}] ${t}`))}get eventsEnabled(){return this.config.events}get lifecycleEnabled(){return this.config.lifecycle}get enabled(){return this.config.enabled}};function lf(e){return e.enabled?new ff(e):void 0}function pO(e,t,r){if(t){let o=e.find(a=>a.id===t);if(o?.role==="assistant")return o;o&&console.warn(`TOOL_CALL_START: parentMessageId '${t}' matches a '${o.role}' message, not assistant \u2014 falling back to toolCallId`);let i={id:o?r:t,role:"assistant",toolCalls:[]};return e.push(i),i}let n={id:r,role:"assistant",toolCalls:[]};return e.push(n),n}var fb=(e,t,r,n,o)=>{let i=ya(o),a=Re(r.messages),s=Re(e.state),c={},u=v=>{v.messages!==void 0&&(a=v.messages,c.messages=v.messages),v.state!==void 0&&(s=v.state,c.state=v.state)},h=()=>{let v=Re(c);return c={},v.messages!==void 0||v.state!==void 0?Ge(v):Uc};return t.pipe(tu(/*#__PURE__*/function(){var _ref43=_asyncToGenerator(function*(v){let C=yield Oe(n,a,s,(g,y,S)=>g.onEvent?.({event:v,agent:r,input:e,messages:y,state:S}));if(u(C),C.stopPropagation===!0?i?.event("APPLY","Event dropped:",v,{type:v.type,reason:"stopPropagation by subscriber"}):i?.event("APPLY","Event applied:",v,{type:v.type,subscribers:n.length}),C.stopPropagation===!0)return h();switch(v.type){case M.TEXT_MESSAGE_START:{let g=yield Oe(n,a,s,(y,S,E)=>y.onTextMessageStartEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messageId:y,role:S="assistant",name:E}=v;if(!a.find(R=>R.id===y)){let R={id:y,role:S,content:"",...(E!==void 0&&{name:E})};a.push(R),u({messages:a})}}return h()}case M.TEXT_MESSAGE_CONTENT:{let{messageId:g,delta:y}=v,S=a.find(R=>R.id===g);if(!S)return console.warn(`TEXT_MESSAGE_CONTENT: No message found with ID '${g}'`),h();let E=yield Oe(n,a,s,(R,k,I)=>R.onTextMessageContentEvent?.({event:v,messages:k,state:I,agent:r,input:e,textMessageBuffer:typeof S.content=="string"?S.content:""}));return u(E),E.stopPropagation!==!0&&(S.content=`${typeof S.content=="string"?S.content:""}${y}`,u({messages:a})),h()}case M.TEXT_MESSAGE_END:{let{messageId:g}=v,y=a.find(S=>S.id===g);return y?(u(yield Oe(n,a,s,(S,E,R)=>S.onTextMessageEndEvent?.({event:v,messages:E,state:R,agent:r,input:e,textMessageBuffer:typeof y.content=="string"?y.content:""}))),yield Promise.all(n.map(S=>{S.onNewMessage?.({message:y,messages:a,state:s,agent:r,input:e})})),h()):(console.warn(`TEXT_MESSAGE_END: No message found with ID '${g}'`),h())}case M.TOOL_CALL_START:{let g=yield Oe(n,a,s,(y,S,E)=>y.onToolCallStartEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{toolCallId:y,toolCallName:S,parentMessageId:E}=v,R=a.find(I=>I.toolCalls?.some(T=>T.id===y))?.toolCalls?.find(I=>I.id===y);if(R)return R.function.name!==S&&(console.warn(`TOOL_CALL_START: tool call '${y}' already exists with name '${R.function.name}' \u2014 updating it to '${S}'`),R.function.name=S,u({messages:a})),h();let k=pO(a,E,y);k.toolCalls??(k.toolCalls=[]),k.toolCalls.push({id:y,type:"function",function:{name:S,arguments:""}}),u({messages:a})}return h()}case M.TOOL_CALL_ARGS:{let{toolCallId:g,delta:y}=v,S=a.find(k=>k.toolCalls?.some(I=>I.id===g));if(!S)return console.warn(`TOOL_CALL_ARGS: No message found containing tool call with ID '${g}'`),h();let E=S.toolCalls?.find(k=>k.id===g);if(!E)return console.warn(`TOOL_CALL_ARGS: No tool call found with ID '${g}'`),h();let R=yield Oe(n,a,s,(k,I,T)=>{let _=E.function.arguments,D=E.function.name,G={};try{G=nu(_)}catch{}return k.onToolCallArgsEvent?.({event:v,messages:I,state:T,agent:r,input:e,toolCallBuffer:_,toolCallName:D,partialToolCallArgs:G})});return u(R),R.stopPropagation!==!0&&(E.function.arguments+=y,u({messages:a})),h()}case M.TOOL_CALL_END:{let{toolCallId:g}=v,y=a.find(E=>E.toolCalls?.some(R=>R.id===g));if(!y)return console.warn(`TOOL_CALL_END: No message found containing tool call with ID '${g}'`),h();let S=y.toolCalls?.find(E=>E.id===g);return S?(u(yield Oe(n,a,s,(E,R,k)=>{let I=S.function.arguments,T=S.function.name,_={};try{_=JSON.parse(I)}catch{}return E.onToolCallEndEvent?.({event:v,messages:R,state:k,agent:r,input:e,toolCallName:T,toolCallArgs:_})})),yield Promise.all(n.map(E=>{E.onNewToolCall?.({toolCall:S,messages:a,state:s,agent:r,input:e})})),h()):(console.warn(`TOOL_CALL_END: No tool call found with ID '${g}'`),h())}case M.TOOL_CALL_RESULT:{let g=yield Oe(n,a,s,(y,S,E)=>y.onToolCallResultEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messageId:y,toolCallId:S,content:E,role:R}=v,k={id:y,toolCallId:S,role:R||"tool",content:E},I=a.findIndex(T=>T.role==="assistant"&&T.toolCalls?.some(_=>_.id===S));if(I===-1)a.push(k);else{let T=I+1;for(;T<a.length&&a[T].role==="tool";)T++;a.splice(T,0,k)}yield Promise.all(n.map(T=>{T.onNewMessage?.({message:k,messages:a,state:s,agent:r,input:e})})),u({messages:a})}return h()}case M.STATE_SNAPSHOT:{let g=yield Oe(n,a,s,(y,S,E)=>y.onStateSnapshotEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{snapshot:y}=v;s=y,u({state:s})}return h()}case M.STATE_DELTA:{let g=yield Oe(n,a,s,(y,S,E)=>y.onStateDeltaEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{delta:y}=v;try{s=Oc.applyPatch(s,y,!0,!1).newDocument,u({state:s})}catch(S){let E=S instanceof Error?S.message:String(S);console.warn(`Failed to apply state patch:
37
37
  Current state: ${JSON.stringify(s,null,2)}
38
38
  Patch operations: ${JSON.stringify(y,null,2)}
39
39
  Error: ${E}`)}}return h()}case M.MESSAGES_SNAPSHOT:{let g=yield Oe(n,a,s,(y,S,E)=>y.onMessagesSnapshotEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messages:y}=v,S=new Map(y.map(T=>[T.id,T])),E=y.some(T=>T.role==="activity"),R=y.some(T=>T.role==="reasoning"),k=T=>T.role==="activity"&&!E||T.role==="reasoning"&&!R;a=a.filter(T=>k(T)||S.has(T.id)).map(T=>k(T)?T:S.get(T.id));let I=new Set(a.map(T=>T.id));for(let T of y)I.has(T.id)||a.push(T);u({messages:a})}return h()}case M.ACTIVITY_SNAPSHOT:{let g=v,y=a.findIndex(I=>I.id===g.messageId),S=y>=0?a[y]:void 0,E=S?.role==="activity"?S:void 0,R=g.replace??!0,k=yield Oe(n,a,s,(I,T,_)=>I.onActivitySnapshotEvent?.({event:g,messages:T,state:_,agent:r,input:e,activityMessage:E,existingMessage:S}));if(u(k),k.stopPropagation!==!0){let I={id:g.messageId,role:"activity",activityType:g.activityType,content:Re(g.content)},T;y===-1?(a.push(I),T=I):E?R&&(a[y]={...E,activityType:g.activityType,content:Re(g.content)}):R&&(a[y]=I,T=I),u({messages:a}),T&&(yield Promise.all(n.map(_=>_.onNewMessage?.({message:T,messages:a,state:s,agent:r,input:e}))))}return h()}case M.ACTIVITY_DELTA:{let g=v,y=a.findIndex(k=>k.id===g.messageId);if(y===-1)return h();let S=a[y];if(S.role!=="activity")return console.warn(`ACTIVITY_DELTA: Message '${g.messageId}' is not an activity message`),h();let E=S,R=yield Oe(n,a,s,(k,I,T)=>k.onActivityDeltaEvent?.({event:g,messages:I,state:T,agent:r,input:e,activityMessage:E}));if(u(R),R.stopPropagation!==!0)try{let k=Re(E.content??{}),I=Oc.applyPatch(k,g.patch??[],!0,!1).newDocument;a[y]={...E,content:Re(I),activityType:g.activityType},u({messages:a})}catch(k){let I=k instanceof Error?k.message:String(k);console.warn(`Failed to apply activity patch for '${g.messageId}': ${I}`)}return h()}case M.RAW:return u(yield Oe(n,a,s,(g,y,S)=>g.onRawEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.CUSTOM:return u(yield Oe(n,a,s,(g,y,S)=>g.onCustomEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.RUN_STARTED:{let g=yield Oe(n,a,s,(y,S,E)=>y.onRunStartedEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let y=v;if(y.input?.messages){for(let S of y.input.messages)a.find(E=>E.id===S.id)||a.push(S);u({messages:a})}}return h()}case M.RUN_FINISHED:{let g=v,y=g.outcome?.type==="interrupt"?{event:g,outcome:"interrupt",interrupts:g.outcome.interrupts}:{event:g,outcome:"success",result:g.result},S=yield Oe(n,a,s,(E,R,k)=>E.onRunFinishedEvent?.({...y,messages:R,state:k,agent:r,input:e}));return u(S),S.stopPropagation!==!0&&(r.pendingInterrupts=y.outcome==="interrupt"?[...y.interrupts]:[]),h()}case M.RUN_ERROR:return u(yield Oe(n,a,s,(g,y,S)=>g.onRunErrorEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.STEP_STARTED:return u(yield Oe(n,a,s,(g,y,S)=>g.onStepStartedEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.STEP_FINISHED:return u(yield Oe(n,a,s,(g,y,S)=>g.onStepFinishedEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.TEXT_MESSAGE_CHUNK:throw Error("TEXT_MESSAGE_CHUNK must be tranformed before being applied");case M.TOOL_CALL_CHUNK:throw Error("TOOL_CALL_CHUNK must be tranformed before being applied");case M.THINKING_START:return h();case M.THINKING_END:return h();case M.THINKING_TEXT_MESSAGE_START:return h();case M.THINKING_TEXT_MESSAGE_CONTENT:return h();case M.THINKING_TEXT_MESSAGE_END:return h();case M.REASONING_START:return u(yield Oe(n,a,s,(g,y,S)=>g.onReasoningStartEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.REASONING_MESSAGE_START:{let g=yield Oe(n,a,s,(y,S,E)=>y.onReasoningMessageStartEvent?.({event:v,messages:S,state:E,agent:r,input:e}));if(u(g),g.stopPropagation!==!0){let{messageId:y}=v;if(!a.find(S=>S.id===y)){let S={id:y,role:"reasoning",content:""};a.push(S),u({messages:a})}}return h()}case M.REASONING_MESSAGE_CONTENT:{let{messageId:g,delta:y}=v,S=a.find(R=>R.id===g);if(!S)return console.warn(`REASONING_MESSAGE_CONTENT: No message found with ID '${g}'`),h();let E=yield Oe(n,a,s,(R,k,I)=>R.onReasoningMessageContentEvent?.({event:v,messages:k,state:I,agent:r,input:e,reasoningMessageBuffer:typeof S.content=="string"?S.content:""}));return u(E),E.stopPropagation!==!0&&(S.content=`${typeof S.content=="string"?S.content:""}${y}`,u({messages:a})),h()}case M.REASONING_MESSAGE_END:{let{messageId:g}=v,y=a.find(S=>S.id===g);return y?(u(yield Oe(n,a,s,(S,E,R)=>S.onReasoningMessageEndEvent?.({event:v,messages:E,state:R,agent:r,input:e,reasoningMessageBuffer:typeof y.content=="string"?y.content:""}))),yield Promise.all(n.map(S=>{S.onNewMessage?.({message:y,messages:a,state:s,agent:r,input:e})})),h()):(console.warn(`REASONING_MESSAGE_END: No message found with ID '${g}'`),h())}case M.REASONING_MESSAGE_CHUNK:throw Error("REASONING_MESSAGE_CHUNK must be transformed before being applied");case M.REASONING_END:return u(yield Oe(n,a,s,(g,y,S)=>g.onReasoningEndEvent?.({event:v,messages:y,state:S,agent:r,input:e}))),h();case M.REASONING_ENCRYPTED_VALUE:{let{subtype:g,entityId:y,encryptedValue:S}=v,E=yield Oe(n,a,s,(R,k,I)=>R.onReasoningEncryptedValueEvent?.({event:v,messages:k,state:I,agent:r,input:e}));if(u(E),E.stopPropagation!==!0){let R=!1;if(g==="tool-call"){for(let k of a)if(k.role==="assistant"&&k.toolCalls){let I=k.toolCalls.find(T=>T.id===y);if(I){I.encryptedValue=S,R=!0;break}}}else{let k=a.find(I=>I.id===y);k?.role!=="activity"&&k&&(k.encryptedValue=S,R=!0)}R&&(c.messages=a)}return h()}}return v.type,h()});return function(_x92){return _ref43.apply(this,arguments)}}()),$p(),n.length>0?Qp({}):v=>v)},df=e=>t=>{let r=ya(e),n=new Map,o=new Map,i=!1,a=!1,s=!1,c=new Map,u=!1,h=!1,v=!1,C=()=>{n.clear(),o.clear(),c.clear(),u=!1,h=!1,i=!1,a=!1,v=!0};return t.pipe(wt(g=>{let y=g.type;if(r?.event("VERIFY","Event:",g,{type:g.type}),a)return Ve(()=>new Le(`Cannot send event type '${y}': The run has already errored with 'RUN_ERROR'. No further events can be sent.`));if(i&&y!==M.RUN_ERROR&&y!==M.RUN_STARTED)return Ve(()=>new Le(`Cannot send event type '${y}': The run has already finished with 'RUN_FINISHED'. Start a new run with 'RUN_STARTED'.`));if(s){if(y===M.RUN_STARTED){if(v&&!i)return Ve(()=>new Le("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&&C()}}else if(s=!0,y!==M.RUN_STARTED&&y!==M.RUN_ERROR)return Ve(()=>new Le("First event must be 'RUN_STARTED'"));switch(y){case M.TEXT_MESSAGE_START:{let S=g.messageId;return n.has(S)?Ve(()=>new Le(`Cannot send 'TEXT_MESSAGE_START' event: A text message with ID '${S}' is already in progress. Complete it with 'TEXT_MESSAGE_END' first.`)):(n.set(S,!0),Ge(g))}case M.TEXT_MESSAGE_CONTENT:{let S=g.messageId;return n.has(S)?Ge(g):Ve(()=>new Le(`Cannot send 'TEXT_MESSAGE_CONTENT' event: No active text message found with ID '${S}'. Start a text message with 'TEXT_MESSAGE_START' first.`))}case M.TEXT_MESSAGE_END:{let S=g.messageId;return n.has(S)?(n.delete(S),Ge(g)):Ve(()=>new Le(`Cannot send 'TEXT_MESSAGE_END' event: No active text message found with ID '${S}'. A 'TEXT_MESSAGE_START' event must be sent first.`))}case M.TOOL_CALL_START:{let S=g.toolCallId;return o.has(S)?Ve(()=>new Le(`Cannot send 'TOOL_CALL_START' event: A tool call with ID '${S}' is already in progress. Complete it with 'TOOL_CALL_END' first.`)):(o.set(S,!0),Ge(g))}case M.TOOL_CALL_ARGS:{let S=g.toolCallId;return o.has(S)?Ge(g):Ve(()=>new Le(`Cannot send 'TOOL_CALL_ARGS' event: No active tool call found with ID '${S}'. Start a tool call with 'TOOL_CALL_START' first.`))}case M.TOOL_CALL_END:{let S=g.toolCallId;return o.has(S)?(o.delete(S),Ge(g)):Ve(()=>new Le(`Cannot send 'TOOL_CALL_END' event: No active tool call found with ID '${S}'. A 'TOOL_CALL_START' event must be sent first.`))}case M.STEP_STARTED:{let S=g.stepName;return c.has(S)?Ve(()=>new Le(`Step "${S}" is already active for 'STEP_STARTED'`)):(c.set(S,!0),Ge(g))}case M.STEP_FINISHED:{let S=g.stepName;return c.has(S)?(c.delete(S),Ge(g)):Ve(()=>new Le(`Cannot send 'STEP_FINISHED' for step "${S}" that was not started`))}case M.RUN_STARTED:return v=!0,Ge(g);case M.RUN_FINISHED:if(c.size>0){let S=Array.from(c.keys()).join(", ");return Ve(()=>new Le(`Cannot send 'RUN_FINISHED' while steps are still active: ${S}`))}if(n.size>0){let S=Array.from(n.keys()).join(", ");return Ve(()=>new Le(`Cannot send 'RUN_FINISHED' while text messages are still active: ${S}`))}if(o.size>0){let S=Array.from(o.keys()).join(", ");return Ve(()=>new Le(`Cannot send 'RUN_FINISHED' while tool calls are still active: ${S}`))}return i=!0,Ge(g);case M.RUN_ERROR:return a=!0,Ge(g);case M.CUSTOM:return Ge(g);case M.THINKING_TEXT_MESSAGE_START:return u?h?Ve(()=>new Le("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking message is already in progress. Complete it with 'THINKING_TEXT_MESSAGE_END' first.")):(h=!0,Ge(g)):Ve(()=>new Le("Cannot send 'THINKING_TEXT_MESSAGE_START' event: A thinking step is not in progress. Create one with 'THINKING_START' first."));case M.THINKING_TEXT_MESSAGE_CONTENT:return h?Ge(g):Ve(()=>new Le("Cannot send 'THINKING_TEXT_MESSAGE_CONTENT' event: No active thinking message found. Start a message with 'THINKING_TEXT_MESSAGE_START' first."));case M.THINKING_TEXT_MESSAGE_END:return h?(h=!1,Ge(g)):Ve(()=>new Le("Cannot send 'THINKING_TEXT_MESSAGE_END' event: No active thinking message found. A 'THINKING_TEXT_MESSAGE_START' event must be sent first."));case M.THINKING_START:return u?Ve(()=>new Le("Cannot send 'THINKING_START' event: A thinking step is already in progress. End it with 'THINKING_END' first.")):(u=!0,Ge(g));case M.THINKING_END:return u?(u=!1,Ge(g)):Ve(()=>new Le("Cannot send 'THINKING_END' event: No active thinking step found. A 'THINKING_START' event must be sent first."));default:return Ge(g)}}))},jn=function(e){return e.HEADERS="headers",e.DATA="data",e}({}),fO=e=>eu(()=>Fn(e())).pipe(Hp(t=>{if(!t.ok){let o=t.headers.get("content-type")||"";return Fn(t.text()).pipe(wt(i=>{let a=i;if(o.includes("application/json"))try{a=JSON.parse(i)}catch{}let s=Error(`HTTP ${t.status}: ${typeof a=="string"?a:JSON.stringify(a)}`);return s.status=t.status,s.payload=a,Ve(()=>s)}))}let r={type:jn.HEADERS,status:t.status,headers:t.headers},n=t.body?.getReader();return n?new Ue(o=>(o.next(r),_asyncToGenerator(function*(){try{for(;;){let{done:i,value:a}=yield n.read();if(i)break;let s={type:jn.DATA,data:a};o.next(s)}o.complete()}catch(i){o.error(i)}})(),()=>{n.cancel().catch(i=>{if(i?.name!=="AbortError")throw i})})):Ve(()=>Error("Failed to getReader() from response"))})),mO=(e,t)=>{let r=ya(t),n=new rr,o=new TextDecoder("utf-8",{fatal:!1}),i="";e.subscribe({next:s=>{if(s.type!==jn.HEADERS&&s.type===jn.DATA&&s.data){let c=o.decode(s.data,{stream:!0});i+=c;let u=i.split(/\n\n/);i=u.pop()||"";for(let h of u)a(h)}},error:s=>n.error(s),complete:()=>{i&&(i+=o.decode(),a(i)),n.complete()}});function a(s){let c=s.split(`
@@ -72,4 +72,4 @@ fast-json-patch/module/duplex.mjs:
72
72
  *)
73
73
  */if(__exports!=exports)module.exports=exports;return module.exports});
74
74
 
75
- window.coveoQuanticVersion = '3.44.2';
75
+ window.coveoQuanticVersion = '3.44.3';