@careevolution/mydatahelps-ui 3.6.1-SurveyAnswerLog.34 → 3.6.1-SurveyAnswerLog.35

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.
@@ -411,7 +411,7 @@ body {
411
411
  * https://github.com/Starcounter-Jack/JSON-Patch
412
412
  * (c) 2013-2021 Joachim Wester
413
413
  * MIT license
414
- */function qx(e,t,a,n,i){if(t!==e){"function"==typeof t.toJSON&&(t=t.toJSON());for(var r=_x(t),o=_x(e),s=!1,l=o.length-1;l>=0;l--){var c=e[d=o[l]];if(!Ex(t,d)||void 0===t[d]&&void 0!==c&&!1===Array.isArray(t))Array.isArray(e)===Array.isArray(t)?(i&&a.push({op:"test",path:n+"/"+Px(d),value:Cx(c)}),a.push({op:"remove",path:n+"/"+Px(d)}),s=!0):(i&&a.push({op:"test",path:n,value:e}),a.push({op:"replace",path:n,value:t}));else{var u=t[d];"object"==typeof c&&null!=c&&"object"==typeof u&&null!=u&&Array.isArray(c)===Array.isArray(u)?qx(c,u,a,n+"/"+Px(d),i):c!==u&&(i&&a.push({op:"test",path:n+"/"+Px(d),value:Cx(c)}),a.push({op:"replace",path:n+"/"+Px(d),value:Cx(u)}))}}if(s||r.length!=o.length)for(l=0;l<r.length;l++){var d;Ex(e,d=r[l])||void 0===t[d]||a.push({op:"add",path:n+"/"+Px(d),value:Cx(t[d])})}}}function Ux(e,t,a=!1){var n=[];return qx(e,t,n,"",a),n}const Wx=new class{getStore(){}run(e,t){return t()}enterWith(e){}},Vx=Symbol.for("ls:tracing_async_local_storage"),$x=Symbol.for("lc:child_config"),Gx=Symbol.for("lc:context_variables");const Kx=new class{getInstance(){return globalThis[Vx]??Wx}getRunnableConfig(){const e=this.getInstance();return e.getStore()?.extra?.[$x]}runWithConfig(e,t,a){const n=Nw._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),r=i.getStore(),o=n?.getParentRunId(),s=n?.handlers?.find((e=>"langchain_tracer"===e?.name));let l;return s&&o?l=s.convertToRunTree(o):a||(l=new mw({name:"<runnable_lambda>",tracingEnabled:!1})),l&&(l.extra={...l.extra,[$x]:e}),void 0!==r&&void 0!==r[Gx]&&(l[Gx]=r[Gx]),i.run(l,t)}initializeGlobalInstance(e){void 0===globalThis[Vx]&&(globalThis[Vx]=e)}};async function Zx(e,t){if(void 0===t)return e;let a;return Promise.race([e.catch((e=>{if(!t?.aborted)throw e})),new Promise(((e,n)=>{a=()=>{n(new Error("Aborted"))},t.addEventListener("abort",a),t.aborted&&n(new Error("Aborted"))}))]).finally((()=>t.removeEventListener("abort",a)))}class Yx extends ReadableStream{constructor(){super(...arguments),Object.defineProperty(this,"reader",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{const e=await this.reader.read();return e.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}}catch(e){throw this.reader.releaseLock(),e}}async return(){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}return{done:!0,value:void 0}}async throw(e){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}throw e}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(e){const t=e.getReader();return new Yx({start:e=>function a(){return t.read().then((({done:t,value:n})=>{if(!t)return e.enqueue(n),a();e.close()}))}(),cancel(){t.releaseLock()}})}static fromAsyncGenerator(e){return new Yx({async pull(t){const{value:a,done:n}=await e.next();n&&t.close(),t.enqueue(a)},async cancel(t){await e.return(t)}})}}function Xx(e,t=2){const a=Array.from({length:t},(()=>[]));return a.map((async function*(t){for(;;)if(0===t.length){const t=await e.next();for(const e of a)e.push(t)}else{if(t[0].done)return;yield t.shift().value}}))}function Qx(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if("string"==typeof e&&"string"==typeof t)return e+t;if("number"==typeof e&&"number"==typeof t)return e+t;if("concat"in e&&"function"==typeof e.concat)return e.concat(t);if("object"==typeof e&&"object"==typeof t){const a={...e};for(const[e,n]of Object.entries(t))e in a&&!Array.isArray(a[e])?a[e]=Qx(a[e],n):a[e]=n;return a}throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}class Jx{constructor(e){Object.defineProperty(this,"generator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResultUsed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise(((t,a)=>{Kx.runWithConfig(e.config,(async()=>{this.firstResult=e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,a):this.firstResult.then((e=>t(void 0)),a)}),!0)}))}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Kx.runWithConfig(this.config,this.signal?async()=>Zx(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}}async function ek(e,t,a,n,...i){const r=new Jx({generator:t,startSetup:a,signal:n}),o=await r.setup;return{output:e(r,o,...i),setup:o}}var tk=Object.freeze({__proto__:null,AsyncGeneratorWithSetup:Jx,IterableReadableStream:Yx,atee:Xx,concat:Qx,pipeGeneratorWithSetup:ek});class ak{constructor(e){Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.ops=e.ops??[]}concat(e){const t=this.ops.concat(e.ops),a=Fx({},t);return new nk({ops:t,state:a[a.length-1].newDocument})}}class nk extends ak{constructor(e){super(e),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=e.state}concat(e){const t=this.ops.concat(e.ops),a=Fx(this.state,e.ops);return new nk({ops:t,state:a[a.length-1].newDocument})}static fromRunLogPatch(e){const t=Fx({},e.ops);return new nk({ops:e.ops,state:t[t.length-1].newDocument})}}const ik=e=>"log_stream_tracer"===e.name;async function rk(e,t){if("original"===t)throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");const{inputs:a}=e;return["retriever","llm","prompt"].includes(e.run_type)?a:1!==Object.keys(a).length||""!==a?.input?a.input:void 0}async function ok(e,t){const{outputs:a}=e;return"original"===t||["retriever","llm","prompt"].includes(e.run_type)?a:void 0!==a&&1===Object.keys(a).length&&void 0!==a?.output?a.output:a}class sk extends Ug{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_schemaFormat",{enumerable:!0,configurable:!0,writable:!0,value:"original"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyMapByRunId",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"counterMapByRunName",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"log_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Yx.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;const t=e.tags??[];let a=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(e.run_type)),void 0!==this.includeTags&&(a=a||void 0!==t.find((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(e.run_type)),void 0!==this.excludeTags&&(a=a&&t.every((e=>!this.excludeTags?.includes(e)))),a}async*tapOutputIterable(e,t){for await(const a of t){if(e!==this.rootId){const t=this.keyMapByRunId[e];t&&await this.writer.write(new ak({ops:[{op:"add",path:`/logs/${t}/streamed_output/-`,value:a}]}))}yield a}}async onRunCreate(e){if(void 0===this.rootId&&(this.rootId=e.id,await this.writer.write(new ak({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;void 0===this.counterMapByRunName[e.name]&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;const t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=1===t?e.name:`${e.name}:${t}`;const a={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};"streaming_events"===this._schemaFormat&&(a.inputs=await rk(e,this._schemaFormat)),await this.writer.write(new ak({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:a}]}))}async onRunUpdate(e){try{const t=this.keyMapByRunId[e.id];if(void 0===t)return;const a=[];"streaming_events"===this._schemaFormat&&a.push({op:"replace",path:`/logs/${t}/inputs`,value:await rk(e,this._schemaFormat)}),a.push({op:"add",path:`/logs/${t}/final_output`,value:await ok(e,this._schemaFormat)}),void 0!==e.end_time&&a.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});const n=new ak({ops:a});await this.writer.write(n)}finally{if(e.id===this.rootId){const t=new ak({ops:[{op:"replace",path:"/final_output",value:await ok(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,a){const n=this.keyMapByRunId[e.id];if(void 0===n)return;let i;i=void 0!==e.inputs.messages?function(e){return void 0!==e&&void 0!==e.message}(a?.chunk)?a?.chunk:new vf({id:`run-${e.id}`,content:t}):t;const r=new ak({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:i}]});await this.writer.write(r)}}var lk=Object.freeze({__proto__:null,LogStreamCallbackHandler:sk,RunLog:nk,RunLogPatch:ak,isLogStreamHandler:ik});const ck="__run";class uk{constructor(e){Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generationInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.text=e.text,this.generationInfo=e.generationInfo}concat(e){return new uk({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo}})}}class dk extends uk{constructor(e){super(e),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.message=e.message}concat(e){return new dk({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo},message:this.message.concat(e.message)})}}var mk=Object.freeze({__proto__:null,ChatGenerationChunk:dk,GenerationChunk:uk,RUN_KEY:ck});function hk({name:e,serialized:t}){return void 0!==e?e:void 0!==t?.name?t.name:void 0!==t?.id&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}const pk=e=>"event_stream_tracer"===e.name;class gk extends Ug{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runInfoMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"tappedPromises",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"event_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Yx.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){const t=e.tags??[];let a=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(e.runType)),void 0!==this.includeTags&&(a=a||void 0!==t.find((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(e.runType)),void 0!==this.excludeTags&&(a=a&&t.every((e=>!this.excludeTags?.includes(e)))),a}async*tapOutputIterable(e,t){const a=await t.next();if(a.done)return;const n=this.runInfoMap.get(e);if(void 0===n)return void(yield a.value);function i(e,t){return"llm"===e&&"string"==typeof t?new uk({text:t}):t}let r=this.tappedPromises.get(e);if(void 0===r){let o;r=new Promise((e=>{o=e})),this.tappedPromises.set(e,r);try{const r={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...r,data:{chunk:i(n.runType,a.value)}},n),yield a.value;for await(const e of t)"tool"!==n.runType&&"retriever"!==n.runType&&await this.send({...r,data:{chunk:i(n.runType,e)}},n),yield e}finally{o()}}else{yield a.value;for await(const e of t)yield e}}async send(e,t){this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){const a=this.tappedPromises.get(e.run_id);void 0!==a?a.then((()=>{this.send(e,t)})):await this.send(e,t)}async onLLMStart(e){const t=hk(e),a=void 0!==e.inputs.messages?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:a,inputs:e.inputs};this.runInfoMap.set(e.id,n);const i=`on_${a}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,a){const n=this.runInfoMap.get(e.id);let i,r;if(void 0===n)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(1!==this.runInfoMap.size){if("chat_model"===n.runType)r="on_chat_model_stream",i=void 0===a?.chunk?new vf({content:t,id:`run-${e.id}`}):a.chunk.message;else{if("llm"!==n.runType)throw new Error(`Unexpected run type ${n.runType}`);r="on_llm_stream",i=void 0===a?.chunk?new uk({text:t}):a.chunk}await this.send({event:r,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}async onLLMEnd(e){const t=this.runInfoMap.get(e.id);let a;if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);const n=e.outputs?.generations;let i;if("chat_model"===t.runType){for(const e of n??[]){if(void 0!==i)break;i=e[0]?.message}a="on_chat_model_end"}else{if("llm"!==t.runType)throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);i={generations:n?.map((e=>e.map((e=>({text:e.text,generationInfo:e.generationInfo}))))),llmOutput:e.outputs?.llmOutput??{}},a="on_llm_end"}await this.sendEndEvent({event:a,data:{output:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){const t=hk(e),a=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type};let i={};""===e.inputs.input&&1===Object.keys(e.inputs).length?(i={},n.inputs={}):void 0!==e.inputs.input?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${a}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onChainEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);const a=`on_${e.run_type}_end`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&1===Object.keys(n).length&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:a,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){const t=hk(e),a={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,a),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},a)}async onToolEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(void 0===t.inputs)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);const a=void 0===e.outputs?.output?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:a,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){const t=hk(e),a={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,a),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},a)}async onRetrieverEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,a){const n=this.runInfoMap.get(a);if(void 0===n)throw new Error(`handleCustomEvent: Run ID ${a} not found in run map.`);await this.send({event:"on_custom_event",run_id:a,name:e,tags:n.tags,metadata:n.metadata,data:t},n)}async finish(){const e=[...this.tappedPromises.values()];Promise.all(e).finally((()=>{this.writer.close()}))}}async function fk(e){return Nw._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function yk(...e){const t={};for(const a of e.filter((e=>!!e)))for(const e of Object.keys(a))if("metadata"===e)t[e]={...t[e],...a[e]};else if("tags"===e){const n=t[e]??[];t[e]=[...new Set(n.concat(a[e]??[]))]}else if("configurable"===e)t[e]={...t[e],...a[e]};else if("timeout"===e)void 0===t.timeout?t.timeout=a.timeout:void 0!==a.timeout&&(t.timeout=Math.min(t.timeout,a.timeout));else if("signal"===e)void 0===t.signal?t.signal=a.signal:void 0!==a.signal&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,a.signal]):t.signal=a.signal);else if("callbacks"===e){const e=t.callbacks,n=a.callbacks;if(Array.isArray(n))if(e)if(Array.isArray(e))t.callbacks=e.concat(n);else{const a=e.copy();for(const e of n)a.addHandler(jw(e),!0);t.callbacks=a}else t.callbacks=n;else if(n)if(e)if(Array.isArray(e)){const a=n.copy();for(const t of e)a.addHandler(jw(t),!0);t.callbacks=a}else t.callbacks=new Nw(n._parentRunId,{handlers:e.handlers.concat(n.handlers),inheritableHandlers:e.inheritableHandlers.concat(n.inheritableHandlers),tags:Array.from(new Set(e.tags.concat(n.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(n.inheritableTags))),metadata:{...e.metadata,...n.metadata}});else t.callbacks=n}else{const n=e;t[n]=a[n]??t[n]}return t}const bk=new Set(["string","number","boolean"]);function vk(e){const t=Kx.getRunnableConfig();let a={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){const{runId:e,runName:n,...i}=t;a=Object.entries(i).reduce(((e,[t,a])=>(void 0!==a&&(e[t]=a),e)),a)}if(e&&(a=Object.entries(e).reduce(((e,[t,a])=>(void 0!==a&&(e[t]=a),e)),a)),a?.configurable)for(const e of Object.keys(a.configurable))bk.has(typeof a.configurable[e])&&!a.metadata?.[e]&&(a.metadata||(a.metadata={}),a.metadata[e]=a.configurable[e]);if(void 0!==a.timeout){if(a.timeout<=0)throw new Error("Timeout must be a positive number");const e=AbortSignal.timeout(a.timeout);void 0!==a.signal?"any"in AbortSignal&&(a.signal=AbortSignal.any([a.signal,e])):a.signal=e,delete a.timeout}return a}function wk(e={},{callbacks:t,maxConcurrency:a,recursionLimit:n,runName:i,configurable:r,runId:o}={}){const s=vk(e);return void 0!==t&&(delete s.runName,s.callbacks=t),void 0!==n&&(s.recursionLimit=n),void 0!==a&&(s.maxConcurrency=a),void 0!==i&&(s.runName=i),void 0!==r&&(s.configurable={...s.configurable,...r}),void 0!==o&&delete s.runId,s}class xk extends Ug{constructor({config:e,onStart:t,onEnd:a,onError:n}){super({_awaitHandler:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RootListenersTracer"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.config=e,this.argOnStart=t,this.argOnEnd=a,this.argOnError=n}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}}function kk(e){return!!e&&e.lc_runnable}class Ak{constructor(e){Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let a=void 0===this.includeNames&&void 0===this.includeTypes&&void 0===this.includeTags;const n=e.tags??[];return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(t)),void 0!==this.includeTags&&(a=a||n.some((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(t)),void 0!==this.excludeTags&&(a=a&&n.every((e=>!this.excludeTags?.includes(e)))),a}}const Sk=Symbol("Let zodToJsonSchema decide on which parser to use"),Ek={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},_k=e=>{const t=(e=>({...Ek,...e}))(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map((([e,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}])))}};function Ck(e,t,a,n){n?.errorMessages&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function Tk(e,t,a,n,i){e[t]=a,Ck(e,t,n,i)}function Pk(e,t,a){const n=a??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(((a,n)=>Pk(e,t,a)))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ok(e,t)}}const Ok=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const n of e.checks)switch(n.kind){case"min":Tk(a,"minimum",n.value,n.message,t);break;case"max":Tk(a,"maximum",n.value,n.message,t)}return a};let Dk;const Mk={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===Dk&&(Dk=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Dk),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function Ik(e,t){const a={type:"string"};function n(e){return"escape"===t.patternStrategy?Nk(e):e}if(e.checks)for(const i of e.checks)switch(i.kind){case"min":Tk(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t);break;case"max":Tk(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":jk(a,"email",i.message,t);break;case"format:idn-email":jk(a,"idn-email",i.message,t);break;case"pattern:zod":zk(a,Mk.email,i.message,t)}break;case"url":jk(a,"uri",i.message,t);break;case"uuid":jk(a,"uuid",i.message,t);break;case"regex":zk(a,i.regex,i.message,t);break;case"cuid":zk(a,Mk.cuid,i.message,t);break;case"cuid2":zk(a,Mk.cuid2,i.message,t);break;case"startsWith":zk(a,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":zk(a,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":jk(a,"date-time",i.message,t);break;case"date":jk(a,"date",i.message,t);break;case"time":jk(a,"time",i.message,t);break;case"duration":jk(a,"duration",i.message,t);break;case"length":Tk(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t),Tk(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"includes":zk(a,RegExp(n(i.value)),i.message,t);break;case"ip":"v6"!==i.version&&jk(a,"ipv4",i.message,t),"v4"!==i.version&&jk(a,"ipv6",i.message,t);break;case"emoji":zk(a,Mk.emoji,i.message,t);break;case"ulid":zk(a,Mk.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":jk(a,"binary",i.message,t);break;case"contentEncoding:base64":Tk(a,"contentEncoding","base64",i.message,t);break;case"pattern:zod":zk(a,Mk.base64,i.message,t)}break;case"nanoid":zk(a,Mk.nanoid,i.message,t)}return a}const Nk=e=>Array.from(e).map((e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`)).join(""),jk=(e,t,a,n)=>{e.format||e.anyOf?.some((e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&n.errorMessages&&{errorMessage:{format:a}}})):Tk(e,"format",t,a,n)},zk=(e,t,a,n)=>{e.pattern||e.allOf?.some((e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:Rk(t,n),...a&&n.errorMessages&&{errorMessage:{pattern:a}}})):Tk(e,"pattern",Rk(t,n),a,n)},Rk=(e,t)=>{const a="function"==typeof e?e():e;if(!t.applyRegexFlags||!a.flags)return a.source;const n=a.flags.includes("i"),i=a.flags.includes("m"),r=a.flags.includes("s"),o=n?a.source.toLowerCase():a.source;let s="",l=!1,c=!1,u=!1;for(let e=0;e<o.length;e++)if(l)s+=o[e],l=!1;else{if(n)if(c){if(o[e].match(/[a-z]/)){u?(s+=o[e],s+=`${o[e-2]}-${o[e]}`.toUpperCase(),u=!1):"-"===o[e+1]&&o[e+2]?.match(/[a-z]/)?(s+=o[e],u=!0):s+=`${o[e]}${o[e].toUpperCase()}`;continue}}else if(o[e].match(/[a-z]/)){s+=`[${o[e]}${o[e].toUpperCase()}]`;continue}if(i){if("^"===o[e]){s+="(^|(?<=[\r\n]))";continue}if("$"===o[e]){s+="($|(?=[\r\n]))";continue}}r&&"."===o[e]?s+=c?`${o[e]}\r\n`:`[${o[e]}\r\n]`:(s+=o[e],"\\"===o[e]?l=!0:c&&"]"===o[e]?c=!1:c||"["!==o[e]||(c=!0))}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),a.source}return s};function Lk(e,t){if("openApi3"===t.target&&e.keyType?._def.typeName===Qh.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce(((a,n)=>({...a,[n]:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}})),{}),additionalProperties:!1};const a={type:"object",additionalProperties:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if("openApi3"===t.target)return a;if(e.keyType?._def.typeName===Qh.ZodString&&e.keyType._def.checks?.length){const n=Object.entries(Ik(e.keyType._def,t)).reduce(((e,[t,a])=>"type"===t?e:{...e,[t]:a}),{});return{...a,propertyNames:n}}return e.keyType?._def.typeName===Qh.ZodEnum?{...a,propertyNames:{enum:e.keyType._def.values}}:a}const Fk={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const Bk=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]}))).filter((e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0)));return a.length?{anyOf:a}:void 0};function Hk(e,t){return"strict"===t.removeAdditionalStrategy?"ZodNever"===e.catchall._def.typeName?"strict"!==e.unknownKeys:qk(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:"ZodNever"===e.catchall._def.typeName?"passthrough"===e.unknownKeys:qk(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function qk(e,t,a=!1){const n=t.seen.get(e);if(t.override){const i=t.override?.(e,t,n,a);if(i!==Sk)return i}if(n&&!a){const e=Uk(n,t);if(void 0!==e)return e}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const r=Vk(e,e.typeName,t);return r&&$k(e,t,r),i.jsonSchema=r,r}const Uk=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Wk(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every(((e,a)=>t.currentPath[a]===e))?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):"seen"===t.$refStrategy?{}:void 0}},Wk=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")},Vk=(e,t,a)=>{switch(t){case Qh.ZodString:return Ik(e,a);case Qh.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"int":a.type="integer",Ck(a,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?Tk(a,"minimum",n.value,n.message,t):Tk(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Tk(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Tk(a,"maximum",n.value,n.message,t):Tk(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Tk(a,"maximum",n.value,n.message,t));break;case"multipleOf":Tk(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodObject:return function(e,t){const a={type:"object",...Object.entries(e.shape()).reduce(((e,[a,n])=>{if(void 0===n||void 0===n._def)return e;const i=qk(n._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});return void 0===i?e:{properties:{...e.properties,[a]:i},required:n.isOptional()?e.required:[...e.required,a]}}),{properties:{},required:[]}),additionalProperties:Hk(e,t)};return a.required.length||delete a.required,a}(e,a);case Qh.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?Tk(a,"minimum",n.value,n.message,t):Tk(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Tk(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Tk(a,"maximum",n.value,n.message,t):Tk(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Tk(a,"maximum",n.value,n.message,t));break;case"multipleOf":Tk(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodBoolean:return{type:"boolean"};case Qh.ZodDate:return Pk(e,a);case Qh.ZodUndefined:return{not:{}};case Qh.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Qh.ZodArray:return function(e,t){const a={type:"array"};return e.type?._def?.typeName!==Qh.ZodAny&&(a.items=qk(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Tk(a,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Tk(a,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Tk(a,"minItems",e.exactLength.value,e.exactLength.message,t),Tk(a,"maxItems",e.exactLength.value,e.exactLength.message,t)),a}(e,a);case Qh.ZodUnion:case Qh.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Bk(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every((e=>e._def.typeName in Fk&&(!e._def.checks||!e._def.checks.length)))){const e=a.reduce(((e,t)=>{const a=Fk[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e}),[]);return{type:e.length>1?e:e[0]}}if(a.every((e=>"ZodLiteral"===e._def.typeName&&!e.description))){const e=a.reduce(((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}}),[]);if(e.length===a.length){const t=e.filter(((e,t,a)=>a.indexOf(e)===t));return{type:t.length>1?t:t[0],enum:a.reduce(((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value]),[])}}}else if(a.every((e=>"ZodEnum"===e._def.typeName)))return{type:"string",enum:a.reduce(((e,t)=>[...e,...t._def.values.filter((t=>!e.includes(t)))]),[])};return Bk(e,t)}(e,a);case Qh.ZodIntersection:return function(e,t){const a=[qk(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),qk(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter((e=>!!e));let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return a.forEach((e=>{if((e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e)(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...n}=e;t=n}else n=void 0;i.push(t)}})),i.length?{allOf:i,...n}:void 0}(e,a);case Qh.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[]),additionalItems:qk(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[])}}(e,a);case Qh.ZodRecord:return Lk(e,a);case Qh.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Qh.ZodEnum:return function(e){return{type:"string",enum:e.values}}(e);case Qh.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter((e=>"number"!=typeof t[t[e]])),n=a.map((e=>t[e])),i=Array.from(new Set(n.map((e=>typeof e))));return{type:1===i.length?"string"===i[0]?"string":"number":["string","number"],enum:n}}(e);case Qh.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:Fk[e.innerType._def.typeName],nullable:!0}:{type:[Fk[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Qh.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return qk(e.innerType._def,t);const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:{}},a]}:{}})(e,a);case Qh.ZodMap:return function(e,t){return"record"===t.mapStrategy?Lk(e,t):{type:"array",maxItems:125,items:{type:"array",items:[qk(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}}}(e,a);case Qh.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Tk(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Tk(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Qh.ZodLazy:return qk(e.getter()._def,a);case Qh.ZodPromise:return function(e,t){return qk(e.type._def,t)}(e,a);case Qh.ZodNaN:case Qh.ZodNever:return{not:{}};case Qh.ZodEffects:return function(e,t){return"input"===t.effectStrategy?qk(e.schema._def,t):{}}(e,a);case Qh.ZodAny:case Qh.ZodUnknown:return{};case Qh.ZodDefault:return function(e,t){return{...qk(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Qh.ZodBranded:return function(e,t){return qk(e.type._def,t)}(e,a);case Qh.ZodReadonly:case Qh.ZodCatch:return((e,t)=>qk(e.innerType._def,t))(e,a);case Qh.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return qk(e.in._def,t);if("output"===t.pipeStrategy)return qk(e.out._def,t);const a=qk(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,qk(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter((e=>void 0!==e))}})(e,a);case Qh.ZodFunction:case Qh.ZodVoid:case Qh.ZodSymbol:default:return}},$k=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a),Gk=(e,t)=>{const a=_k(t),n=void 0,i=t?.name,r=qk(e._def,a,!1)??{},o=void 0===i?r:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,i].join("/"),[a.definitionPath]:{...n,[i]:r}};return"jsonSchema7"===a.target?o.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"===a.target&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};function Kk(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}const Zk=["*","_","`"];function Yk(e,t,a){const{firstNode:n,lastNode:i,nodeColors:r,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:l=9}=a??{};let c=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%\ngraph TD;\n`:"graph TD;\n";if(o){const t="default",a={[t]:"{0}({1})"};void 0!==n&&(a[n]="{0}([{1}]):::first"),void 0!==i&&(a[i]="{0}([{1}]):::last");for(const[n,i]of Object.entries(e)){const e=i.name.split(":").pop()??"",r=Zk.some((t=>e.startsWith(t)&&e.endsWith(t)))?`<p>${e}</p>`:e;let o=r;Object.keys(i.metadata??{}).length&&(o+=`<hr/><small><em>${Object.entries(i.metadata??{}).map((([e,t])=>`${e} = ${t}`)).join("\n")}</em></small>`);const s=(a[n]??a[t]).replace("{0}",Kk(n)).replace("{1}",o);c+=`\t${s}\n`}}const u={};for(const e of t){const t=e.source.split(":"),a=e.target.split(":"),n=t.filter(((e,t)=>e===a[t])).join(":");u[n]||(u[n]=[]),u[n].push(e)}const d=new Set;function m(e,t){const a=1===e.length&&e[0].source===e[0].target;if(t&&!a){const e=t.split(":").pop();if(d.has(e))throw new Error(`Found duplicate subgraph '${e}' -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(e),c+=`\tsubgraph ${e}\n`}for(const t of e){const{source:e,target:a,data:n,conditional:i}=t;let r="";if(void 0!==n){let e=n;const t=e.split(" ");t.length>l&&(e=Array.from({length:Math.ceil(t.length/l)},((e,a)=>t.slice(a*l,(a+1)*l).join(" "))).join("&nbsp;<br>&nbsp;")),r=i?` -. &nbsp;${e}&nbsp; .-> `:` -- &nbsp;${e}&nbsp; --\x3e `}else r=i?" -.-> ":" --\x3e ";c+=`\t${Kk(e)}${r}${Kk(a)};\n`}for(const e in u)e.startsWith(`${t}:`)&&e!==t&&m(u[e],e);t&&!a&&(c+="\tend\n")}m(u[""]??[],"");for(const e in u)e.includes(":")||""===e||m(u[e],e);return o&&(c+=function(e){let t="";for(const[a,n]of Object.entries(e))t+=`\tclassDef ${a} ${n};\n`;return t}(r??{})),c}function Xk(e,t){if(void 0!==e&&!Rp(e))return e;if(!kk(t))return t.name??"UnknownSchema";try{let e=t.getName();return e=e.startsWith("Runnable")?e.slice(8):e,e}catch(e){return t.getName()}}function Qk(e){return kk(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...Gk(e.data.schema),title:e.data.name}}}let Jk=class e{constructor(e){Object.defineProperty(this,"nodes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"edges",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.nodes=e?.nodes??this.nodes,this.edges=e?.edges??this.edges}toJSON(){const e={};return Object.values(this.nodes).forEach(((t,a)=>{e[t.id]=Rp(t.id)?a:t.id})),{nodes:Object.values(this.nodes).map((t=>({id:e[t.id],...Qk(t)}))),edges:this.edges.map((t=>{const a={source:e[t.source],target:e[t.target]};return void 0!==t.data&&(a.data=t.data),void 0!==t.conditional&&(a.conditional=t.conditional),a}))}}addNode(e,t,a){if(void 0!==t&&void 0!==this.nodes[t])throw new Error(`Node with id ${t} already exists`);const n=t??Xp(),i={id:n,data:e,name:Xk(t,e),metadata:a};return this.nodes[n]=i,i}removeNode(e){delete this.nodes[e.id],this.edges=this.edges.filter((t=>t.source!==e.id&&t.target!==e.id))}addEdge(e,t,a,n){if(void 0===this.nodes[e.id])throw new Error(`Source node ${e.id} not in graph`);if(void 0===this.nodes[t.id])throw new Error(`Target node ${t.id} not in graph`);const i={source:e.id,target:t.id,data:a,conditional:n};return this.edges.push(i),i}firstNode(){return eA(this)}lastNode(){return tA(this)}extend(e,t=""){let a=t;const n=Object.values(e.nodes).map((e=>e.id));n.every(Rp)&&(a="");const i=e=>a?`${a}:${e}`:e;Object.entries(e.nodes).forEach((([e,t])=>{this.nodes[i(e)]={...t,id:i(e)}}));const r=e.edges.map((e=>({...e,source:i(e.source),target:i(e.target)})));this.edges=[...this.edges,...r];const o=e.firstNode(),s=e.lastNode();return[o?{id:i(o.id),data:o.data}:void 0,s?{id:i(s.id),data:s.data}:void 0]}trimFirstNode(){const e=this.firstNode();e&&eA(this,[e.id])&&this.removeNode(e)}trimLastNode(){const e=this.lastNode();e&&tA(this,[e.id])&&this.removeNode(e)}reid(){const t=Object.fromEntries(Object.values(this.nodes).map((e=>[e.id,e.name]))),a=new Map;Object.values(t).forEach((e=>{a.set(e,(a.get(e)||0)+1)}));const n=e=>{const n=t[e];return Rp(e)&&1===a.get(n)?n:e};return new e({nodes:Object.fromEntries(Object.entries(this.nodes).map((([e,t])=>[n(e),{...t,id:n(e)}]))),edges:this.edges.map((e=>({...e,source:n(e.source),target:n(e.target)})))})}drawMermaid(e){const{withStyles:t,curveStyle:a,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:i}=e??{},r=this.reid(),o=r.firstNode(),s=r.lastNode();return Yk(r.nodes,r.edges,{firstNode:o?.id,lastNode:s?.id,withStyles:t,curveStyle:a,nodeColors:n,wrapLabelNWords:i})}async drawMermaidPng(e){return async function(e,t){let{backgroundColor:a="white"}=t??{};const n=btoa(e);void 0!==a&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(a)||(a=`!${a}`));const i=`https://mermaid.ink/img/${n}?bgColor=${a}`,r=await fetch(i);if(!r.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${r.status}`,`Status text: ${r.statusText}`].join("\n"));return await r.blob()}(this.drawMermaid(e),{backgroundColor:e?.backgroundColor})}};function eA(e,t=[]){const a=new Set(e.edges.filter((e=>!t.includes(e.source))).map((e=>e.target))),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||a.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function tA(e,t=[]){const a=new Set(e.edges.filter((e=>!t.includes(e.target))).map((e=>e.source))),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||a.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function aA(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.iterator]&&"function"==typeof e.next}function nA(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.asyncIterator]}function*iA(e,t){for(;;){const{value:a,done:n}=Kx.runWithConfig(e,t.next.bind(t),!0);if(n)break;yield a}}async function*rA(e,t){const a=t[Symbol.asyncIterator]();for(;;){const{value:n,done:i}=await Kx.runWithConfig(e,a.next.bind(t),!0);if(i)break;yield n}}function oA(e,t){return!e||Array.isArray(e)||e instanceof Date||"object"!=typeof e?{[t]:e}:e}class sA extends Sg{constructor(){super(...arguments),Object.defineProperty(this,"lc_runnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}getName(e){const t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}bind(e){return new lA({bound:this,kwargs:e,config:{}})}map(){return new cA({bound:this})}withRetry(e){return new uA({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new lA({bound:this,config:e,kwargs:{}})}withFallbacks(e){const t=Array.isArray(e)?e:e.fallbacks;return new gA({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(vk);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");const a=Object.fromEntries(Object.entries(e).filter((([e])=>"runId"!==e)));return Array.from({length:t},((t,n)=>vk(0===n?e:a)))}return Array.from({length:t},(()=>vk(e)))}async batch(e,t,a){const n=this._getOptionsList(t??{},e.length),i=n[0]?.maxConcurrency??a?.maxConcurrency,r=new ix({maxConcurrency:i,onFailedAttempt:e=>{throw e}}),o=e.map(((e,t)=>r.call((async()=>{try{return await this.invoke(e,n[t])}catch(e){if(a?.returnExceptions)return e;throw e}}))));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this._streamIterator(e,a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;t=vk(void 0===e?e:{callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});const a={...e};return delete a.callbacks,delete a.tags,delete a.metadata,delete a.runName,delete a.configurable,delete a.recursionLimit,delete a.maxConcurrency,delete a.runId,delete a.timeout,delete a.signal,[t,a]}async _callWithConfig(e,t,a){const n=vk(a),i=await fk(n),r=await(i?.handleChainStart(this.toJSON(),oA(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName()));let o;delete n.runId;try{const i=e.call(this,t,n,r);o=await Zx(i,a?.signal)}catch(e){throw await(r?.handleChainError(e)),e}return await(r?.handleChainEnd(oA(o,"output"))),o}async _batchWithConfig(e,t,a,n){const i=this._getOptionsList(a??{},t.length),r=await Promise.all(i.map(fk)),o=await Promise.all(r.map((async(e,a)=>{const n=await(e?.handleChainStart(this.toJSON(),oA(t[a],"input"),i[a].runId,i[a].runType,void 0,void 0,i[a].runName??this.getName()));return delete i[a].runId,n})));let s;try{const a=e.call(this,t,i,o,n);s=await Zx(a,i?.[0]?.signal)}catch(e){throw await Promise.all(o.map((t=>t?.handleChainError(e)))),e}return await Promise.all(o.map((e=>e?.handleChainEnd(oA(s,"output"))))),s}async*_transformStreamWithConfig(e,t,a){let n,i,r=!0,o=!0;const s=vk(a),l=await fk(s);let c;try{const u=await ek(t.bind(this),async function*(){for await(const t of e){if(r)if(void 0===n)n=t;else try{n=Qx(n,t)}catch{n=void 0,r=!1}yield t}}(),(async()=>l?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName())),a?.signal,s);delete s.runId,c=u.setup;const d=c?.handlers.find(pk);let m=u.output;void 0!==d&&void 0!==c&&(m=d.tapOutputIterable(c.runId,m));const h=c?.handlers.find(ik);void 0!==h&&void 0!==c&&(m=h.tapOutputIterable(c.runId,m));for await(const e of m)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch{i=void 0,o=!1}}catch(e){throw await(c?.handleChainError(e,void 0,void 0,void 0,{inputs:oA(n,"input")})),e}await(c?.handleChainEnd(i??{},void 0,void 0,void 0,{inputs:oA(n,"input")}))}getGraph(e){const t=new Jk,a=t.addNode({name:`${this.getName()}Input`,schema:jp.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:jp.any()});return t.addEdge(a,n),t.addEdge(n,i),t}pipe(e){return new dA({first:this,last:fA(e)})}pick(e){return this.pipe(new bA(e))}assign(e){return this.pipe(new yA(new mA({steps:e})))}async*transform(e,t){let a;for await(const t of e)a=void 0===a?t:Qx(a,t);yield*this._streamIterator(a,vk(t))}async*streamLog(e,t,a){const n=new sk({...a,autoClose:!1,_schemaFormat:"original"}),i=vk(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,a){const{callbacks:n}=a;if(void 0===n)a.callbacks=[t];else if(Array.isArray(n))a.callbacks=n.concat([t]);else{const e=n.copy();e.addHandler(t,!0),a.callbacks=e}const i=this.stream(e,a);const r=async function(){try{const e=await i;for await(const a of e){const e=new ak({ops:[{op:"add",path:"/streamed_output/-",value:a}]});await t.writer.write(e)}}finally{await t.writer.close()}}();try{for await(const e of t)yield e}finally{await r}}streamEvents(e,t,a){let n;if("v1"===t.version)n=this._streamEventsV1(e,t,a);else{if("v2"!==t.version)throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');n=this._streamEventsV2(e,t,a)}return"text/event-stream"===t.encoding?function(e){const t=new TextEncoder,a=new ReadableStream({async start(a){for await(const n of e)a.enqueue(t.encode(`event: data\ndata: ${JSON.stringify(n)}\n\n`));a.enqueue(t.encode("event: end\n\n")),a.close()}});return Yx.fromReadableStream(a)}(n):Yx.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,a){const n=new gk({...a,autoClose:!1}),i=vk(t),r=i.runId??Xp();i.runId=r;const o=i.callbacks;if(void 0===o)i.callbacks=[n];else if(Array.isArray(o))i.callbacks=o.concat(n);else{const e=o.copy();e.addHandler(n,!0),i.callbacks=e}const s=this;const l=async function(){try{const t=await s.stream(e,i),a=n.tapOutputIterable(r,t);for await(const e of a);}finally{await n.finish()}}();let c,u=!1;try{for await(const t of n)u?(t.run_id===c&&t.event.endsWith("_end")&&t.data?.input&&delete t.data.input,yield t):(t.data.input=e,u=!0,c=t.run_id,yield t)}finally{await l}}async*_streamEventsV1(e,t,a){let n,i=!1;const r=vk(t),o=r.tags??[],s=r.metadata??{},l=r.runName??this.getName(),c=new sk({...a,autoClose:!1,_schemaFormat:"streaming_events"}),u=new Ak({...a}),d=this._streamLog(e,c,r);for await(const t of d){if(n=n?n.concat(t):nk.fromRunLogPatch(t),void 0===n.state)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;const t={...n.state},a={run_id:t.id,event:`on_${t.type}_start`,name:l,tags:o,metadata:s,data:{input:e}};u.includeEvent(a,t.type)&&(yield a)}const a=t.ops.filter((e=>e.path.startsWith("/logs/"))).map((e=>e.path.split("/")[2])),r=[...new Set(a)];for(const e of r){let t,a={};const i=n.state.logs[e];if(t=void 0===i.end_time?i.streamed_output.length>0?"stream":"start":"end","start"===t)void 0!==i.inputs&&(a.input=i.inputs);else if("end"===t)void 0!==i.inputs&&(a.input=i.inputs),a.output=i.final_output;else if("stream"===t){const e=i.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${i.name}"`);a={chunk:i.streamed_output[0]},i.streamed_output=[]}yield{event:`on_${i.type}_${t}`,name:i.name,run_id:i.id,tags:i.tags,metadata:i.metadata,data:a}}const{state:c}=n;if(c.streamed_output.length>0){const e=c.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${c.name}"`);const t={chunk:c.streamed_output[0]};c.streamed_output=[];const a={event:`on_${c.type}_stream`,run_id:c.id,tags:o,metadata:s,name:l,data:t};u.includeEvent(a,c.type)&&(yield a)}}const m=n?.state;if(void 0!==m){const e={event:`on_${m.type}_end`,name:l,run_id:m.id,tags:o,metadata:s,data:{output:m.final_output}};u.includeEvent(e,m.type)&&(yield e)}}static isRunnable(e){return kk(e)}withListeners({onStart:e,onEnd:t,onError:a}){return new lA({bound:this,config:{},configFactories:[n=>({callbacks:[new xk({config:n,onStart:e,onEnd:t,onError:a})]})]})}asTool(e){return function(e,t){const a=t.name??e.getName(),n=t.description??t.schema?.description;if(t.schema.constructor===jp.ZodString)return new vA({name:a,description:n,schema:jp.object({input:jp.string()}).transform((e=>e.input)),bound:e});return new vA({name:a,description:n,schema:t.schema,bound:e})}(this,e)}}class lA extends sA{static lc_name(){return"RunnableBinding"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"configFactories",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound,this.kwargs=e.kwargs,this.config=e.config,this.configFactories=e.configFactories}getName(e){return this.bound.getName(e)}async _mergeConfig(...e){const t=yk(this.config,...e);return yk(t,...this.configFactories?await Promise.all(this.configFactories.map((async e=>await e(t)))):[])}bind(e){return new this.constructor({bound:this.bound,kwargs:{...this.kwargs,...e},config:this.config})}withConfig(e){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...e}})}withRetry(e){return new this.constructor({bound:this.bound.withRetry(e),kwargs:this.kwargs,config:this.config})}async invoke(e,t){return this.bound.invoke(e,await this._mergeConfig(vk(t),this.kwargs))}async batch(e,t,a){const n=Array.isArray(t)?await Promise.all(t.map((async e=>this._mergeConfig(vk(e),this.kwargs)))):await this._mergeConfig(vk(t),this.kwargs);return this.bound.batch(e,n,a)}async*_streamIterator(e,t){yield*this.bound._streamIterator(e,await this._mergeConfig(vk(t),this.kwargs))}async stream(e,t){return this.bound.stream(e,await this._mergeConfig(vk(t),this.kwargs))}async*transform(e,t){yield*this.bound.transform(e,await this._mergeConfig(vk(t),this.kwargs))}streamEvents(e,t,a){const n=this;return Yx.fromAsyncGenerator(async function*(){yield*n.bound.streamEvents(e,{...await n._mergeConfig(vk(t),n.kwargs),version:t.version},a)}())}static isRunnableBinding(e){return e.bound&&sA.isRunnable(e.bound)}withListeners({onStart:e,onEnd:t,onError:a}){return new lA({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new xk({config:n,onStart:e,onEnd:t,onError:a})]})]})}}class cA extends sA{static lc_name(){return"RunnableEach"}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound}bind(e){return new cA({bound:this.bound.bind(e)})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _invoke(e,t,a){return this.bound.batch(e,wk(t,{callbacks:a?.getChild()}))}withListeners({onStart:e,onEnd:t,onError:a}){return new cA({bound:this.bound.withListeners({onStart:e,onEnd:t,onError:a})})}}class uA extends lA{static lc_name(){return"RunnableRetry"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"maxAttemptNumber",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:()=>{}}),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,a){const n=e>1?`retry:attempt:${e}`:void 0;return wk(t,{callbacks:a?.getChild(n)})}async _invoke(e,t,a){return qf((n=>super.invoke(e,this._patchConfigForRetry(n,t,a))),{onFailedAttempt:t=>this.onFailedAttempt(t,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,a,n){const i={};try{await qf((async r=>{const o=e.map(((e,t)=>t)).filter((e=>void 0===i[e.toString()]||i[e.toString()]instanceof Error)),s=o.map((t=>e[t])),l=o.map((e=>this._patchConfigForRetry(r,t?.[e],a?.[e]))),c=await super.batch(s,l,{...n,returnExceptions:!0});let u;for(let e=0;e<c.length;e+=1){const t=c[e],a=o[e];t instanceof Error&&void 0===u&&(u=t,u.input=s[e]),i[a.toString()]=t}if(u)throw u;return c}),{onFailedAttempt:e=>this.onFailedAttempt(e,e.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(e){if(!0!==n?.returnExceptions)throw e}return Object.keys(i).sort(((e,t)=>parseInt(e,10)-parseInt(t,10))).map((e=>i[parseInt(e,10)]))}async batch(e,t,a){return this._batchWithConfig(this._batch.bind(this),e,t,a)}}class dA extends sA{static lc_name(){return"RunnableSequence"}constructor(e){super(e),Object.defineProperty(this,"first",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"middle",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitSequenceTags",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),this.first=e.first,this.middle=e.middle??this.middle,this.last=e.last,this.name=e.name,this.omitSequenceTags=e.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(e,t){const a=vk(t),n=await fk(a),i=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),a.runId,void 0,void 0,void 0,a?.runName));delete a.runId;let r,o=e;try{const e=[this.first,...this.middle];for(let n=0;n<e.length;n+=1){const r=e[n].invoke(o,wk(a,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${n+1}`)}));o=await Zx(r,t?.signal)}if(t?.signal?.aborted)throw new Error("Aborted");r=await this.last.invoke(o,wk(a,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(oA(r,"output"))),r}async batch(e,t,a){const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(fk)),r=await Promise.all(i.map((async(t,a)=>{const i=await(t?.handleChainStart(this.toJSON(),oA(e[a],"input"),n[a].runId,void 0,void 0,void 0,n[a].runName));return delete n[a].runId,i})));let o=e;try{for(let e=0;e<this.steps.length;e+=1){const t=this.steps[e].batch(o,r.map(((t,a)=>{const i=t?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`);return wk(n[a],{callbacks:i})})),a);o=await Zx(t,n[0]?.signal)}}catch(e){throw await Promise.all(r.map((t=>t?.handleChainError(e)))),e}return await Promise.all(r.map((e=>e?.handleChainEnd(oA(o,"output"))))),o}async*_streamIterator(e,t){const a=await fk(t),{runId:n,...i}=t??{},r=await(a?.handleChainStart(this.toJSON(),oA(e,"input"),n,void 0,void 0,void 0,i?.runName)),o=[this.first,...this.middle,this.last];let s,l=!0;try{let a=o[0].transform(async function*(){yield e}(),wk(i,{callbacks:r?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let e=1;e<o.length;e+=1){const t=o[e];a=await t.transform(a,wk(i,{callbacks:r?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`)}))}for await(const e of a)if(t?.signal?.throwIfAborted(),yield e,l)if(void 0===s)s=e;else try{s=Qx(s,e)}catch(e){s=void 0,l=!1}}catch(e){throw await(r?.handleChainError(e)),e}await(r?.handleChainEnd(oA(s,"output")))}getGraph(e){const t=new Jk;let a=null;return this.steps.forEach(((n,i)=>{const r=n.getGraph(e);0!==i&&r.trimFirstNode(),i!==this.steps.length-1&&r.trimLastNode(),t.extend(r);const o=r.firstNode();if(!o)throw new Error(`Runnable ${n} has no first node`);a&&t.addEdge(a,o),a=r.lastNode()})),t}pipe(e){return dA.isRunnableSequence(e)?new dA({first:this.first,middle:this.middle.concat([this.last,e.first,...e.middle]),last:e.last,name:this.name??e.name}):new dA({first:this.first,middle:[...this.middle,this.last],last:fA(e),name:this.name})}static isRunnableSequence(e){return Array.isArray(e.middle)&&sA.isRunnable(e)}static from([e,...t],a){let n={};return"string"==typeof a?n.name=a:void 0!==a&&(n=a),new dA({...n,first:fA(e),middle:t.slice(0,-1).map(fA),last:fA(t[t.length-1])})}}class mA extends sA{static lc_name(){return"RunnableMap"}getStepsKeys(){return Object.keys(this.steps)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.steps={};for(const[t,a]of Object.entries(e.steps))this.steps[t]=fA(a)}static from(e){return new mA({steps:e})}async invoke(e,t){const a=vk(t),n=await fk(a),i=await(n?.handleChainStart(this.toJSON(),{input:e},a.runId,void 0,void 0,void 0,a?.runName));delete a.runId;const r={};try{const n=Object.entries(this.steps).map((async([t,n])=>{r[t]=await n.invoke(e,wk(a,{callbacks:i?.getChild(`map:key:${t}`)}))}));await Zx(Promise.all(n),t?.signal)}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(r)),r}async*_transform(e,t,a){const n={...this.steps},i=Xx(e,Object.keys(n).length),r=new Map(Object.entries(n).map((([e,n],r)=>{const o=n.transform(i[r],wk(a,{callbacks:t?.getChild(`map:key:${e}`)}));return[e,o.next().then((t=>({key:e,gen:o,result:t})))]})));for(;r.size;){const e=Promise.race(r.values()),{key:t,result:n,gen:i}=await Zx(e,a?.signal);r.delete(t),n.done||(yield{[t]:n.value},r.set(t,i.next().then((e=>({key:t,gen:i,result:e})))))}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class hA extends sA{constructor(e){if(super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!ww(e.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=e.func}async invoke(e,t){const[a]=this._getOptionsList(t??{},1),n=await fk(a);return Zx(this.func(wk(a,{callbacks:n}),e),a?.signal)}async*_streamIterator(e,t){const[a]=this._getOptionsList(t??{},1),n=await this.invoke(e,t);if(nA(n))for await(const e of n)a?.signal?.throwIfAborted(),yield e;else if((e=>null!=e&&"object"==typeof e&&"next"in e&&"function"==typeof e.next)(n))for(;;){a?.signal?.throwIfAborted();const e=n.next();if(e.done)break;yield e.value}else yield n}static from(e){return new hA({func:e})}}class pA extends sA{static lc_name(){return"RunnableLambda"}constructor(e){if(ww(e.func))return hA.from(e.func);super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e){if(ww(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}(e.func),this.func=e.func}static from(e){return new pA({func:e})}async _invoke(e,t,a){return new Promise(((n,i)=>{const r=wk(t,{callbacks:a?.getChild(),recursionLimit:(t?.recursionLimit??25)-1});Kx.runWithConfig(r,(async()=>{try{let a=await this.func(e,{...r});if(a&&sA.isRunnable(a)){if(0===t?.recursionLimit)throw new Error("Recursion limit reached.");a=await a.invoke(e,{...r,recursionLimit:(r.recursionLimit??25)-1})}else if(nA(a)){let e;for await(const n of rA(r,a))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=Qx(e,n)}catch(t){e=n}a=e}else if(aA(a)){let e;for(const n of iA(r,a))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=Qx(e,n)}catch(t){e=n}a=e}n(a)}catch(e){i(e)}}))}))}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async*_transform(e,t,a){let n;for await(const t of e)if(void 0===n)n=t;else try{n=Qx(n,t)}catch(e){n=t}const i=wk(a,{callbacks:t?.getChild(),recursionLimit:(a?.recursionLimit??25)-1}),r=await new Promise(((e,t)=>{Kx.runWithConfig(i,(async()=>{try{const t=await this.func(n,{...i,config:i});e(t)}catch(e){t(e)}}))}));if(r&&sA.isRunnable(r)){if(0===a?.recursionLimit)throw new Error("Recursion limit reached.");const e=await r.stream(n,i);for await(const t of e)yield t}else if(nA(r))for await(const e of rA(i,r))a?.signal?.throwIfAborted(),yield e;else if(aA(r))for(const e of iA(i,r))a?.signal?.throwIfAborted(),yield e;else yield r}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class gA extends sA{static lc_name(){return"RunnableWithFallbacks"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(const e of this.fallbacks)yield e}async invoke(e,t){const a=vk(t),n=await fk(t),{runId:i,...r}=a,o=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),i,void 0,void 0,void 0,r?.runName));let s;for(const t of this.runnables()){a?.signal?.throwIfAborted();try{const a=await t.invoke(e,wk(r,{callbacks:o?.getChild()}));return await(o?.handleChainEnd(oA(a,"output"))),a}catch(e){void 0===s&&(s=e)}}if(void 0===s)throw new Error("No error stored at end of fallback.");throw await(o?.handleChainError(s)),s}async*_streamIterator(e,t){const a=vk(t),n=await fk(t),{runId:i,...r}=a,o=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),i,void 0,void 0,void 0,r?.runName));let s,l,c;for(const t of this.runnables()){a?.signal?.throwIfAborted();const n=wk(r,{callbacks:o?.getChild()});try{l=await t.stream(e,n);break}catch(e){void 0===s&&(s=e)}}if(void 0===l){const e=s??new Error("No error stored at end of fallback.");throw await(o?.handleChainError(e)),e}try{for await(const e of l){yield e;try{c=void 0===c?c:Qx(c,e)}catch(e){c=void 0}}}catch(e){throw await(o?.handleChainError(e)),e}await(o?.handleChainEnd(oA(c,"output")))}async batch(e,t,a){if(a?.returnExceptions)throw new Error("Not implemented.");const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map((e=>fk(e)))),r=await Promise.all(i.map((async(t,a)=>{const i=await(t?.handleChainStart(this.toJSON(),oA(e[a],"input"),n[a].runId,void 0,void 0,void 0,n[a].runName));return delete n[a].runId,i})));let o;for(const t of this.runnables()){n[0].signal?.throwIfAborted();try{const i=await t.batch(e,r.map(((e,t)=>wk(n[t],{callbacks:e?.getChild()}))),a);return await Promise.all(r.map(((e,t)=>e?.handleChainEnd(oA(i[t],"output"))))),i}catch(e){void 0===o&&(o=e)}}if(!o)throw new Error("No error stored at end of fallbacks.");throw await Promise.all(r.map((e=>e?.handleChainError(o)))),o}}function fA(e){if("function"==typeof e)return new pA({func:e});if(sA.isRunnable(e))return e;if(Array.isArray(e)||"object"!=typeof e)throw new Error("Expected a Runnable, function or object.\nInstead got an unsupported type.");{const t={};for(const[a,n]of Object.entries(e))t[a]=fA(n);return new mA({steps:t})}}class yA extends sA{static lc_name(){return"RunnableAssign"}constructor(e){e instanceof mA&&(e={mapper:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"mapper",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mapper=e.mapper}async invoke(e,t){const a=await this.mapper.invoke(e,t);return{...e,...a}}async*_transform(e,t,a){const n=this.mapper.getStepsKeys(),[i,r]=Xx(e),o=this.mapper.transform(r,wk(a,{callbacks:t?.getChild()})),s=o.next();for await(const e of i){if("object"!=typeof e||Array.isArray(e))throw new Error("RunnableAssign can only be used with objects as input, got "+typeof e);const t=Object.fromEntries(Object.entries(e).filter((([e])=>!n.includes(e))));Object.keys(t).length>0&&(yield t)}yield(await s).value;for await(const e of o)yield e}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class bA extends sA{static lc_name(){return"RunnablePick"}constructor(e){("string"==typeof e||Array.isArray(e))&&(e={keys:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keys=e.keys}async _pick(e){if("string"==typeof this.keys)return e[this.keys];{const t=this.keys.map((t=>[t,e[t]])).filter((e=>void 0!==e[1]));return 0===t.length?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(const t of e){const e=await this._pick(t);void 0!==e&&(yield e)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class vA extends lA{constructor(e){super({bound:dA.from([pA.from((async e=>{let t;if(Jg(e))try{t=await this.schema.parseAsync(e.args)}catch(t){throw new ef("Received tool input did not match expected schema",JSON.stringify(e.args))}else t=e;return t})).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name}),config:e.config??{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}}const wA=e=>e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,xA=e=>{switch(wA(e)){case"gpt-3.5-turbo-16k":return 16384;case"gpt-3.5-turbo":return 4096;case"gpt-4-32k":return 32768;case"gpt-4":return 8192;case"text-davinci-003":default:return 4097;case"text-curie-001":case"text-babbage-001":case"text-ada-001":case"code-cushman-001":return 2048;case"code-davinci-002":return 8e3}};function kA(e){return!("object"!=typeof e||!e)&&!!("type"in e&&"function"===e.type&&"function"in e&&"object"==typeof e.function&&e.function&&"name"in e.function&&"parameters"in e.function)}class AA extends sA{get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),Object.defineProperty(this,"verbose",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verbose=e.verbose??!1,this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}}class SA extends AA{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}constructor({callbacks:e,callbackManager:t,...a}){const{cache:n,...i}=a;super({callbacks:e??t,...i}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_encoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cache="object"==typeof n?n:n?Zw.global():void 0,this.caller=new ix(a??{})}async getNumTokens(e){if("string"!=typeof e)return 0;let t=Math.ceil(e.length/4);if(!this._encoding)try{this._encoding=await kx("modelName"in this?wA(this.modelName):"gpt2")}catch(e){console.warn("Failed to calculate number of tokens, falling back to approximate count",e)}if(this._encoding)try{t=this._encoding.encode(e).length}catch(e){console.warn("Failed to calculate number of tokens, falling back to approximate count",e)}return t}static _convertInputToPromptValue(e){return"string"==typeof e?new Qw(e):Array.isArray(e)?new Jw(e.map(Of)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){const a={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()},n=Object.entries(a).filter((([e,t])=>void 0!==t)),i=n.map((([e,t])=>`${e}:${JSON.stringify(t)}`)).sort().join(",");return i}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}}var EA=Object.freeze({__proto__:null,BaseLangChain:AA,BaseLanguageModel:SA,calculateMaxTokens:async({prompt:e,modelName:t})=>{let a;try{a=(await kx(wA(t))).encode(e).length}catch(t){console.warn("Failed to calculate number of tokens, falling back to approximate count"),a=Math.ceil(e.length/4)}return xA(t)-a},getEmbeddingContextSize:e=>"text-embedding-ada-002"===e?8191:2046,getModelContextSize:xA,getModelNameForTiktoken:wA,isOpenAITool:kA});function _A(e){return"function"==typeof e?.parse}class CA extends AA{get lc_namespace(){return["langchain","tools"]}constructor(e){super(e??{}),Object.defineProperty(this,"returnDirect",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"verboseParsingErrors",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"responseFormat",{enumerable:!0,configurable:!0,writable:!0,value:"content"}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat}async invoke(e,t){let a,n;Jg(e)?(a=e.id,n=e.args):n=e;const i=vk(t);return this.call(n,{...i,configurable:{...i.configurable,tool_call_id:a}})}async call(e,t,a){let n;try{n=await this.schema.parseAsync(e)}catch(t){let a="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(a=`${a}\nDetails: ${t.message}`),new ef(a,JSON.stringify(e))}const i=Cw(t),r=await Nw.configure(i.callbacks,this.callbacks,i.tags||a,this.tags,i.metadata,this.metadata,{verbose:this.verbose}),o=await(r?.handleToolStart(this.toJSON(),"string"==typeof n?n:JSON.stringify(n),i.runId,void 0,void 0,void 0,i.runName));let s,l,c,u;delete i.runId;try{s=await this._call(n,o,i)}catch(e){throw await(o?.handleToolError(e)),e}if("content_and_artifact"===this.responseFormat){if(!Array.isArray(s)||2!==s.length)throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.\nResult: ${JSON.stringify(s)}`);[l,c]=s}else l=s;i&&"configurable"in i&&(u=i.configurable.tool_call_id);const d=function(e){const{content:t,artifact:a,toolCallId:n}=e;return n?"string"==typeof t||Array.isArray(t)&&t.every((e=>"object"==typeof e))?new pf({content:t,artifact:a,tool_call_id:n,name:e.name}):new pf({content:MA(t),artifact:a,tool_call_id:n,name:e.name}):t}({content:l,artifact:c,toolCallId:u,name:this.name});return await(o?.handleToolEnd(d)),d}}class TA extends CA{constructor(e){super(e),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:jp.object({input:jp.string().optional()}).transform((e=>e.input))})}call(e,t){return super.call("string"!=typeof e&&e?e:{input:e},t)}}class PA extends TA{static lc_name(){return"DynamicTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){const a=Cw(t);return void 0===a.runName&&(a.runName=this.name),super.call(e,a)}async _call(e,t,a){return this.func(e,t,a)}}class OA extends CA{static lc_name(){return"DynamicStructuredTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=_A(e.schema)?e.schema:jp.object({}).passthrough()}async call(e,t,a){const n=Cw(t);return void 0===n.runName&&(n.runName=this.name),super.call(e,n,a)}_call(e,t,a){return this.func(e,t,a)}}function DA(e,t){if(!t.schema||_A(t.schema)&&(!("shape"in t.schema)||!t.schema.shape))return new PA({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,a,n)=>new Promise(((i,r)=>{const o=wk(n,{callbacks:a?.getChild()});Kx.runWithConfig(o,(async()=>{try{i(e(t,o))}catch(e){r(e)}}))}))});const a=t.description??t.schema.description??`${t.name} tool`;return new OA({...t,description:a,schema:t.schema,func:async(t,a,n)=>new Promise(((i,r)=>{const o=wk(n,{callbacks:a?.getChild()});Kx.runWithConfig(o,(async()=>{try{i(e(t,o))}catch(e){r(e)}}))}))})}function MA(e){try{return JSON.stringify(e,null,2)}catch(t){return`${e}`}}var IA=Object.freeze({__proto__:null,BaseToolkit:class{getTools(){return this.tools}},DynamicStructuredTool:OA,DynamicTool:PA,StructuredTool:CA,Tool:TA,ToolInputParsingException:ef,tool:DA});function NA(e,t,a){var n={Feed:e,ClientLocalTime:Pi(new Date)};t&&(n.PageID=t),a&&(n.PageDate=a);var i=new URLSearchParams(n).toString();return w.invokeCustomApi("HealthAndWellnessApi.NewsFeed","GET",i,!0)}function jA(){return w.baseUrl&&(w.baseUrl.startsWith("https://mdhorg.ce.dev")||w.baseUrl.startsWith("https://mydatahelps.dev"))}const zA=jp.object({namespace:jp.enum(["Fitbit","AppleHealth","Garmin","Dexcom","HealthConnect"]).describe("The namespace of the device data, representing the manufacturer of the devices used to collect the data."),type:jp.string().describe("The device data type is specific to the namespace. Example data types for AppleHealth are Steps, Heart Rate."),observedAfter:jp.string().optional().describe('The start of the date range for the query. This is a datetime in the participant\'s local timezone, passed without the timezone offset.\n This is exclusive. For example, if you want to query data for 11/26/2024, you would pass in "observedAfter": "2024-11-26T00:00:00". An event\n that happened at 11/26/2024 00:00:00 would not be included in the results.'),observedBefore:jp.string().optional().describe('The end of the date range for the query. This is a datetime in the participant\'s local timezone, passed without the timezone offset.\n This is exclusive. For example, if you want to query data for up to 11/26/2024, you would pass in "observedBefore": "2024-11-26T00:00:00". An event\n that happened at 11/26/2024 00:00:00 would not be included in the results.'),dataSource:jp.object({sourceName:jp.string().optional().describe('The name of the device that the data is coming from. Examples: "Oura", "Mike\'s iPhone".\n You can prompt the user for the device name if it is unclear what that is from the user\'s question.'),sourceIdentifier:jp.string().optional().describe('The identifier of the device that the data is coming from. Examples: "com.ouraring.oura", "com.apple.health.E0BCE94D-0698-4E79-951C-A98A07D698B0".'),sourceProductType:jp.string().optional().describe('The product type of the device that the data is coming from. Examples: "iPhone15,3".'),sourceOperatingSystemVersion:jp.string().optional().describe('The operating system version of the device that the data is coming from. Examples: "17.6.1".')}).optional().describe("These can be used to restrict the returned results to data coming from a specific device only."),properties:jp.record(jp.string(),jp.string()).optional().describe("Filters to apply to the properties of the data points.")}),RA=DA((async e=>{const t=await w.persistParticipantInfo(e.demographics,e.customFields);return JSON.stringify(t)}),{name:"persistParticipantInfo",description:"Can be used to save data about the current participant, including dynamic information in the participant's custom fields.",schema:jp.object({demographics:jp.object({email:jp.string().optional().describe("The email address of the participant."),mobilePhone:jp.string().optional().describe("The mobile phone number of the participant."),firstName:jp.string().optional().describe("The first name of the participant."),middleName:jp.string().optional().describe("The middle name of the participant."),lastName:jp.string().optional().describe("The last name of the participant."),dateOfBirth:jp.string().optional().describe("The date of birth of the participant."),gender:jp.string().optional().describe("The gender of the participant."),preferredLanguage:jp.string().optional().describe("The preferred language of the participant."),street1:jp.string().optional().describe("The first line of the participant's street address."),street2:jp.string().optional().describe("The second line of the participant's street address."),city:jp.string().optional().describe("The city of the participant."),state:jp.string().optional().describe("The state of the participant."),postalCode:jp.string().optional().describe("The postal code of the participant."),unsubscribedFromEmails:jp.string().optional().describe("Whether the participant is unsubscribed from email messages."),unsubscribedFromSms:jp.string().optional().describe("Whether the participant is unsubscribed from SMS messages.")}).optional().describe("Demographic information about the participant."),customFields:jp.record(jp.string(),jp.string()).optional().describe("Custom fields where dynamic information can be saved for the participant.")})}),LA=jp.object({endDate:jp.string().optional().describe("The end of the date range for the query. This is a datetime in the participant's local timezone."),startDate:jp.string().optional().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),pageSize:jp.number().optional().describe("The number of items to return."),pageID:jp.string().optional().describe("The page ID to continue from.")}),FA=DA((async e=>{const t=await w.queryAppleHealthWorkouts(e);return JSON.stringify(t)}),{name:"queryAppleHealthWorkouts",description:"Query the participant's workouts from Apple Health.",schema:LA}),BA=DA((async e=>{const t=await w.queryAppleHealthActivitySummaries(e);return JSON.stringify(t)}),{name:"queryAppleHealthActivitySummaries",description:"Query the participant's Apple Health activity summaries. These include Active Energy Burned,\n Active Energy Burned Goal, Apple Exercise Time, Apple Exercise Time Goal, Apple Stand Hours and Apple Stand Hours Goal.",schema:LA}),HA=DA((async e=>{const t=await w.queryNotifications(e);return JSON.stringify(t)}),{name:"queryNotifications",description:"Query notifications sent to the participant.",schema:jp.object({type:jp.enum(["Sms","Push","Email"]).optional().describe("The type of notification to query."),statusCode:jp.enum(["Succeeded","Unsubscribed","MissingContactInfo","NoRegisteredMobileDevice","NoAssociatedUser","ServiceError"]).optional().describe("The status code of the notification."),sentBefore:jp.string().optional().describe("The end of the date range for the query. This is a datetime in the participant's local timezone."),sentAfter:jp.string().optional().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),identifier:jp.string().optional().describe("The identifier of the notification.")})}),qA=DA((async e=>{const t=await w.querySurveyAnswers(e);return JSON.stringify(t)}),{name:"querySurveyAnswers",description:"Query answers to surveys the participant has completed.",schema:jp.object({surveyResultID:jp.string().optional().describe("The ID of the survey result."),surveyID:jp.string().optional().describe("The ID of the survey."),surveyName:jp.string().optional().describe("The name of the survey."),after:jp.string().optional().describe("The start of the date range for the query. Survey answers submitted after this date will be retrieved.\n This is a datetime in the participant's local timezone."),before:jp.string().optional().describe("The end of the date range for the query. Survey answers submitted before this date will be retrieved.\n This is a datetime in the participant's local timezone."),stepIdentifier:jp.string().optional().describe("The step identifier."),resultIdentifier:jp.string().optional().describe("The result identifier."),answer:jp.string().optional().describe("A particular answer."),pageID:jp.string().optional().describe("The page ID to continue from.")})}),UA=DA((async e=>{let t=await w.queryDeviceDataV2(e);return JSON.stringify(t.deviceDataPoints.map((({value:e,startDate:t,startDateOffset:a,observationDate:n,observationDateOffset:i,units:r,dataSource:o})=>({value:e,startDate:t,startDateOffset:a,observationDate:n,observationDateOffset:i,units:r,dataSource:o?.sourceName}))))}),{name:"queryDeviceDataV2",description:"Can query a participant's device data. This represents raw individual fine grained data points, not aggregated in any way.\n \n Before using this tool call the getDeviceDataV2AllDataTypes tool to see which data types are available. If a particular data type is not available\n use the queryDailyData tool instead.\n\n For sleep this is the function you would query to determine the time a participant went to bed or woke up. For sleep a day consists of from 6 pm the \n previous day to 6 pm the day of (For example 11/26/2024 sleep is from 11/25/2024 at 6 pm to 11/26/2024 at 6 pm). To determine the time a participant\n went to bed look at the startDate of the first not awake and not in bed sleep stage for that day. To determine wake up times look at the observationDate\n of the last not awake and not in bed sleep stage for that day.",schema:zA}),WA=DA((async e=>{let t=await w.queryDeviceDataV2Aggregate(e);return JSON.stringify(t.intervals.map((({date:e,statistics:t})=>({date:e,statistics:t}))))}),{name:"queryDeviceDataV2Aggregate",description:"Can query a participant's aggregated device data. This can be used to get for instance a participant's hourly steps \n count or their min max heart rate every day.",schema:zA.extend({intervalAmount:jp.number().describe("The number of periods to aggregate over. Together with intervalType this can be 1 Days or 3 Minutes."),intervalType:jp.enum(["Minutes","Hours","Days","Weeks","Months"]).describe("The type of interval to aggregate over. Together with intervalAmount this can be 1 Days or 3 Minutes."),aggregateFunctions:jp.array(jp.enum(["sum","avg","count","min","max"])).describe("The aggregations functions to apply to the granular data.")})}),VA=DA((async e=>{let t=await w.queryDeviceDataV2DailySleep(e);return JSON.stringify(t.sleepStageSummaries.map((({date:e,duration:t,value:a})=>({date:e,duration:t,value:a}))))}),{name:"queryDeviceDataV2DailySleep",description:"Can query daily aggregated sleep data. This will include sleep broken down by sleep stage.\n Use this function when you need to do sleep aggregate queries instead of deviceDataV2Aggregate.",schema:zA.extend({type:jp.string().describe("The device data type is specific to the namespace. For Apple Health this is called Sleep Analysis, for Fitbit it is called Sleep.")})}),$A=DA((async e=>{let t=await wu(e.type,new Date(e.startDate),new Date(e.endDate),!1);return JSON.stringify(t)}),{name:"queryDailyData",description:"Query daily data for a participant. Before using this tool call the getAllDailyDataTypes tool to see which data types are available.",schema:jp.object({type:jp.string().describe("The type of daily data to query."),startDate:jp.string().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),endDate:jp.string().describe("The end of the date range for the query. This is a datetime in the participant's local timezone.")})}),GA=DA((async()=>{let e=await w.getDeviceDataV2AllDataTypes();return JSON.stringify(e)}),{name:"getDeviceDataV2AllDataTypes",description:"Get all the device data types that can be queried with the queryDeviceDataV2 tool. Only types that are enabled can be queried.",schema:jp.object({})}),KA=DA((async()=>JSON.stringify(ku())),{name:"getAllDailyDataTypes",description:"Get all the daily data types that can be queried with the queryDailyData tool.",schema:jp.object({})}),ZA=DA((async e=>{const t=await NA(e.feed,e.pageID,e.pageDate);return JSON.stringify(t)}),{name:"getEhrNewsFeedPage",description:"Get electronic health record (EHR) data for the participant.",schema:jp.object({feed:jp.enum(["Immunizations","LabReports","Procedures","Reports"]).describe("The type of feed to query."),pageID:jp.string().optional().describe("The page ID to continue from if you need to fetch more results."),pageDate:jp.string().optional().describe("The date of the page to continue from if you are doing a time-based query.")})}),YA=DA((async(e,t)=>{let a=jA()?"https://api.mydatahelps.dev/run-code":"https://api.mydatahelps.org/run-code",n=await fetch(a,{method:"POST",body:JSON.stringify({code:e.code}),headers:{"Content-Type":"application/json",Authorization:`Bearer ${w.token.access_token}`}}).then((e=>e.json()));if(n.image){let e=t?.configurable?.participantId;t.store?.put([e,"graphing"],"lastGraph",{image:n.image})}return n.image||"error: unable to generate image"}),{name:"graphing",description:"If the user asks for something to be graphed, use this tool. This tool returns a base 64 encoded string\n that represents an image. After using this tool, the LLM should respond with 'Your generated graph is displayed above.' without interpreting \n or including the image content in the response. The UI will handle displaying the image.",schema:jp.object({code:jp.string().describe('The python code that, when executed, will generate an image representing the graph. Use matplotlib.pyplot\n to generate the graph. The code should not include any imports, as the necessary imports will be added automatically "import matplotlib.pyplot as plt".')})}),XA=DA((async e=>{let t=await w.queryFiles(e);return JSON.stringify(t)}),{name:"uploadedFileQuery",description:"Use this tool to query files uploaded by the current participant. \n AI-generated graphs are saved under the 'ai-graph' category.",schema:jp.object({category:jp.string().optional().describe("Category of files to query for.")})}),QA=DA((async e=>{let t=await w.getFileDownloadUrl(e.key);return JSON.stringify(t)}),{name:"getUploadedFile",description:"Use this tool to get a file uploaded by the current participant. This tool returns a presigned URL to download the file. \n If the file is an image, the LLM should respond with 'Please see your uploaded file above.' and nothing else.\n Do not include a link to the file in your response.",schema:jp.object({key:jp.string().describe("The file key of the file to get.")})}),JA=DA((async(e,t)=>{let a=t.configurable?.participantId,n=await(t.store?.get([a,"graphing"],"lastGraph"));if(!n||!n.value||!n.value.image)return"Unable to find your last graph.";const i=atob(n.value.image),r=i.length,o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=i.charCodeAt(e);const s=new Blob([o],{type:"image/png"}),l=new File([s],e.fileName,{type:"image/png"});return await w.uploadFile(l,"ai-graph"),"Successfully saved your last graph to your files."}),{name:"saveLastGraph",description:"Save the last graph generated by the graphing tool.",schema:jp.object({fileName:jp.string().describe("The name of the file to save. This should be descriptive but reasonably short, no more than 50 characters. It should\n end with the '.png' file extension.")})});var eS=Object.freeze({__proto__:null,GetAllDailyDataTypesTool:KA,GetDeviceDataV2AllDataTypesTool:GA,GetEhrNewsFeedPageTool:ZA,GetUploadedFileTool:QA,GraphingTool:YA,PersistParticipantInfoTool:RA,QueryAppleHealthActivitySummariesTool:BA,QueryAppleHealthWorkoutsTool:FA,QueryDailyDataTool:$A,QueryDailySleepTool:VA,QueryDeviceDataV2AggregateTool:WA,QueryDeviceDataV2Tool:UA,QueryNotificationsTool:HA,QuerySurveyAnswersTool:qA,SaveLastGraphTool:JA,UploadedFileQueryTool:XA});class tS{constructor(e){this.type=e}}class aS extends tS{constructor(e){super("static integer"),this.staticValue=e}getValue(){return Promise.resolve(this.staticValue)}}class nS extends tS{constructor(e){super("random integer"),this.maxValue=e}getValue(){return Promise.resolve(Math.floor(Math.random()*(this.maxValue+1)))}}class iS extends tS{constructor(e){super("custom field integer"),this.customField=e}async getValue(){if(!this.customField)return;let e=await w.getParticipantInfo();if(e.customFields.hasOwnProperty(this.customField)){const t=e.customFields[this.customField],a=parseInt(t);if(!Number.isNaN(a))return a}}}class rS extends tS{constructor(e,t){if(t<0)throw new Error("daysInPast must be a non-negative number");super("days with data"),this.dataType=e,this.daysInPast=t}async getValue(){const e=Hr(),t=Dr(e,this.daysInPast),a=await wu(this.dataType,t,e);return a&&0!==a.length?Object.keys(a).reduce(((e,t)=>e+(a[t]>0?1:0)),0):0}}const oS=e=>new aS(e),sS=e=>new nS(e),lS=e=>new iS(e),cS=(e,t)=>new rS(e,t);function uS(e,t,a,n){const i={};let r=e;for(;r<=t;){const e=Wr(r);0!==dS(0,1)&&(i[e]=dS(a,n)),r=un(r,{days:1})}return i}function dS(e,t){return Math.floor(Math.random()*(t-e+1))+e}function mS(e){return!!e&&void 0!==e.surveyName}function hS(e){return async(t,a)=>{const n={surveyName:e.surveyName,stepIdentifier:e.stepIdentifier,after:un(t,{days:-1}).toISOString(),before:un(a,{days:1}).toISOString()};e.resultIdentifier&&(n.resultIdentifier=e.resultIdentifier);const i=await Mu(n).then((e=>e.sort(((e,t)=>Sn(e.date,t.date))))),r={};let o=t;for(;o<=a;){const e=Wr(o),t=i.find((t=>Wr(t.date)===e))?.answers[0];if(t){const a=parseInt(t);Number.isNaN(a)||(r[e]=a)}o=un(o,{days:1})}return r}}const pS=()=>({calculate:(e,t)=>{const a=t.filter((e=>e>0));return a.length>0?a.reduce(((e,t)=>e+t),0)/a.length:void 0}}),gS=()=>({calculate:(e,t)=>{if(0!==e.length)return 100*t.filter((e=>e>0)).length/e.length}}),fS=(e,t)=>({evaluate:a=>void 0!==t?a>=e&&a<=t:a>=e}),yS=()=>({format:e=>e>=1e3?El(e/1e3,1)+"k":El(e)}),bS=()=>({format:e=>El(e/60,1)+so("hours-abbreviation")}),vS=e=>({format:t=>{let a=El(t);return e&&(a+=e),a}}),wS="Not Entered";function xS(e,t,a){const n={},i=(e,t)=>{if(!(void 0!==t&&t>=0))return wS;for(let a=0;a<e.length;a++){const n=e[a];if(!(void 0!==n.minimumValue&&n.minimumValue>t)&&!(void 0!==n.maximumValue&&n.maximumValue<t))return n.label}};let r=e;for(;r<=t;){const e=Wr(r),t=i(a.configuration.thresholds,a.result[e]);t&&(n.hasOwnProperty(t)||(n[t]=[]),n[t].push(e)),r=un(r,{days:1})}return n}function kS(e){try{return{success:!0,regex:new RegExp(e)}}catch{return{success:!1,regex:void 0}}}function AS(){return{load:async(e,t)=>{const a=(await Mu({surveyName:e.surveyName,resultIdentifier:[e.fileResultIdentifier,e.typeResultIdentifier,e.nameResultIdentifier,e.dateResultIdentifier,e.notesResultIdentifier]})).reduce(((e,t)=>{const a=t.surveyResultID;return e[a]=e[a]??[],e[a].push(t),e}),{}),n=[];for(const i of Object.values(a)){const a=await CS(i,e,t);a&&n.push(a)}return n}}}function SS(){return{load:async(e,t)=>CS(await Mu({surveyResultID:e,resultIdentifier:[t.fileResultIdentifier,t.typeResultIdentifier,t.nameResultIdentifier,t.dateResultIdentifier,t.notesResultIdentifier]}),t,!0)}}function ES(e,t){return(a,n)=>{const i=a[e],r=n[e];return i===r?a.name.localeCompare(n.name):void 0===i?1:void 0===r?-1:"asc"===t?i.localeCompare(r):r.localeCompare(i)}}function _S(e){let t="";return e.date&&(t+=Sl(e.date,"P")),e.type&&(t.length>0&&(t+=" - "),t+=e.type),t}async function CS(e,t,a){const n=e.find((e=>e.resultIdentifier===t.fileResultIdentifier)),i=e.find((e=>e.resultIdentifier===t.nameResultIdentifier));if(!n||!i)return;const r=e.find((e=>e.resultIdentifier===t.typeResultIdentifier)),o=e.find((e=>e.resultIdentifier===t.dateResultIdentifier)),s=e.find((e=>e.resultIdentifier===t.notesResultIdentifier)),l=n.surveyResultID,{fileKey:c,fileUrl:u}=a?await async function(e){const t=await w.queryFiles({category:`surveyresult_${e}`});if(t.files.length>0){const e=t.files[0].key,a=(await w.getFileDownloadUrl(e))?.preSignedUrl;return{fileKey:e,fileUrl:a}}return{}}(l):{};return{surveyResultId:l,file:n.answers[0],fileType:n.answers[0].toLowerCase().endsWith(".pdf")?"pdf":"image",name:i.answers[0],type:r?.answers[0],date:o?.answers[0],notes:s?.answers[0],fileKey:c,fileUrl:u}}function TS(e,t,a,n,i,r){const o=Array.from({length:a.length},(()=>[]));let s=e;for(;s<t;){for(let e=0;e<o.length;e++){const t=pu(Wr(s)+a[e]);o[e].push({stepIdentifier:a[e],resultIdentifier:a[e],date:Pi(un(s,{hours:12})),answers:[(t%(i-n)+n).toString()]})}s=un(s,r)}return o}async function PS(e,t,a,n,i){const[r,o]=await Promise.all([OS(e,a,n,i),DS(t,a,n,!!i)]),s={};let l=a;for(;l<n;){const e=Wr(l);s[e]={date:Mr(e),surveyAnswers:r[e]??[],dataPoints:o[e]??[]},l=un(l,{days:1})}return s}async function OS(e,t,a,n){if(0===e.length)return{};if(n)return function(e,t,a,n){const i=Array.from({length:10},((e,t)=>`result${t+1}`)),r=e.reduce(((e,r)=>{const o=kn([un(Hr(),{days:n?1:0}),a]);return TS(t,o,i,0,5,{days:1}).flat().forEach((t=>{e.push({...t,surveyName:r})})),e}),[]);return r.reduce(((e,t)=>{const a=Wr(t.date),i=n&&Pr(t.date),r=pu(a)%3!=0,o=pu(a+"_"+t.surveyName)%3!=0,s=pu(a+"_"+t.surveyName+"_"+t.resultIdentifier)%3!=0;return(i||r&&o&&s)&&(e[a]??=[],e[a].push({...t,answers:i&&"0"===t.answers[0]?["1"]:t.answers})),e}),{})}(e,t,a,n.endsWith("with today"));const i=jn({start:t,end:un(a,{days:-1})}).reduce(((e,t)=>{const a=Wr(t).substring(0,8)+"*";return e.includes(a)||e.push(a),e}),[]).join(",");return async function(e,t,a){const n={surveyName:e,event:t},i=(await Mu(n)).sort(((e,t)=>t.date.localeCompare(e.date))),r=i.reduce(((e,t)=>{const a=`${t.surveyName}-${t.event}`;return e[a]??=t.surveyResultID.toString(),e}),{}),o=Object.values(r);return i.filter((e=>o.includes(e.surveyResultID.toString()))).reduce(((e,t)=>{const n=Mr(t.event);if(!a||n>=a.start&&n<a.end){const a=Wr(n);e[a]??=[],e[a].push(t)}return e}),{})}(e,i,{start:t,end:a})}async function DS(e,t,a,n){if(0===e.length)return{};return(await Promise.all(e.map((e=>wu(e,t,a,n))))).reduce(((t,a,n)=>(Object.entries(a).forEach((([a,i])=>{t[a]??=[],t[a].push({type:e[n],value:i})})),t)),{})}function MS(e){const a=r(Ka),n=["mdhui-basic-badge"];return"xl"===e.size&&n.push("mdhui-basic-badge-xl"),"xs"===e.size&&n.push("mdhui-basic-badge-xs"),t.createElement("div",{className:n.join(" "),style:{backgroundColor:ze(a.colorScheme,e.backgroundColor),color:"#FFD379"}},t.createElement(je,{className:"mdhui-basic-badge-icon",icon:N,size:"2x"}),t.createElement("div",{className:"mdhui-basic-badge-children"},e.children))}A(".mdhui-basic-badge {\n width: 32px;\n height: 32px;\n border-radius: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #ddd;\n color: #152850;\n position: relative;\n overflow: hidden;\n font-size: 8px;\n box-shadow: 1px 2px 2px rgba(0, 0, 0, .2);\n color: #FFD379;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl {\n width: 150px;\n height: 150px;\n font-size: 58px;\n}\n\n\n.mdhui-basic-badge .mdhui-basic-badge-children {\n display: none;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl .mdhui-basic-badge-children {\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n color: #000;\n text-align: center;\n font-size: 17px;\n top: 58px;\n font-weight: bold;\n}\n\n.mdhui-basic-badge .mdhui-basic-badge-icon {\n filter: drop-shadow(1px 1px 1px #666);\n margin-top: -1px;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl .mdhui-basic-badge-icon {\n margin-top: -7px;\n}");function IS(e){let a="normal";return e.systolic>180||e.diastolic>120?a="hypertensive-crisis":e.systolic>140||e.diastolic>90?a="hypertension-stage-2":e.systolic>130||e.diastolic>80?a="hypertension-stage-1":e.systolic>120?a="elevated":(e.systolic<90||e.systolic<60)&&(a="low"),t.createElement(Ya,{className:"mdhui-blood-pressure-reading",indicatorPosition:"topRight",indicator:e.indicator??t.createElement(je,{icon:re}),onClick:e.onClick,innerRef:e.innerRef},t.createElement("div",{className:"mdhui-blood-pressure-reading-title"},t.createElement(je,{icon:G})," ",so("blood-pressure-reading-title")),t.createElement("div",{className:"mdhui-blood-pressure-reading-value-wrapper"},t.createElement("div",{className:"mdhui-blood-pressure-reading-value"},El(e.systolic)," / ",El(e.diastolic)," mmHg"),t.createElement("div",{className:`mdhui-blood-pressure-reading-classification ${a}`},so(`blood-pressure-reading-classification-${a}`))),t.createElement("div",{className:"mdhui-blood-pressure-reading-date"},Sl(e.date,"PPP p")),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator"},t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar normal"},("normal"===a||"low"==a)&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar elevated"},"elevated"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertension-stage-1"},"hypertension-stage-1"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertension-stage-2"},"hypertension-stage-2"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertensive-crisis"},"hypertensive-crisis"===a&&t.createElement(je,{icon:F}))))}A(".mdhui-blood-pressure-reading {\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-title {\n font-size: .88em;\n font-weight: 600;\n z-index: 1;\n position: relative;\n color: rgb(196, 41, 28);\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-value-wrapper {\n display: flex;\n align-items: center;\n justify-content: left;\n gap: 8px;\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-value {\n font-size: 1.2em;\n position: relative;\n font-weight: bold;\n margin-top: 4px;\n display: block;\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-date {\n font-size: 0.8em;\n color: var(--mdhui-text-color-2);\n margin-top: 4px;\n}\n\n.mdhui-blood-pressure-reading-classification {\n font-size: .88em;\n border-radius: 4px;\n padding: 4px 8px;\n font-weight: bold;\n}\n\n.mdhui-blood-pressure-reading-classification.normal,\n.mdhui-blood-pressure-reading-classification.low {\n background-color: #a6ce39;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.elevated {\n background-color: #ffec01;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertension-stage-1 {\n background-color: #ffb601;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertension-stage-2 {\n background-color: #ba3a03;\n color: #FFF;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertensive-crisis {\n background-color: #990612;\n color: #FFF;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator {\n display: flex;\n margin-top: 8px;\n margin-bottom: 8px;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar {\n height: 8px;\n background: #a6ce39;\n flex-grow: 1;\n text-align: center;\n position: relative;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar .svg-inline--fa {\n position: absolute;\n left: calc(50% - 6px);\n top: 8px;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.normal {\n background: #a6ce39;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.elevated {\n background: #ffec01;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertension-stage-1 {\n background: #ffb601;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertension-stage-2 {\n background: #ba3a03;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertensive-crisis {\n background: #990612;\n}");function NS(e){let a=["mdhui-loading-indicator"];return e.className&&a.push(e.className),"inline"==e.variant&&a.push("mdhui-loading-indicator-inline"),t.createElement("div",{ref:e.innerRef,style:{color:e.color},className:a.join(" ")},t.createElement(je,{icon:W,spin:!0}))}A(".mdhui-loading-indicator {\n padding: 16px;\n color: var(--mdhui-text-color-4);\n text-align: center;\n}\n\n.mdhui-loading-indicator.mdhui-loading-indicator-inline {\n display: inline;\n padding: 0;\n}");function jS(e){let a=["mdhui-button"];e.className&&a.push(e.className),(e.fullWidth??1)&&a.push("mdhui-button-full-width"),e.defaultMargin&&a.push("mdhui-button-default-margin");let n=r(Ka),i=ze(n?.colorScheme,e.color),o="#FFF";return"subtle"===e.variant?(o=ze(n?.colorScheme,e.color)||"var(--mdhui-color-primary)",i="transparent"):"light"===e.variant&&(o=ze(n?.colorScheme,e.color)||"var(--mdhui-color-primary)",i="var(--mdhui-background-color-1)"),t.createElement("button",{ref:e.innerRef,style:{backgroundColor:e.disabled?void 0:i,color:e.disabled?void 0:o},className:a.join(" "),disabled:e.disabled||e.loading,onClick:t=>{e.disabled||e.loading||(e.stopPropagation&&t.stopPropagation(),e.onClick(t))}},e.loading&&t.createElement(t.Fragment,null,t.createElement(NS,{variant:"inline",color:"inherit"})," "),e.children)}A(".mdhui-button {\n box-sizing: border-box;\n padding: 16px;\n background: var(--mdhui-color-primary);\n font-size: 17px;\n line-height: 17px;\n color: #FFF;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n font-weight: bold;\n text-align: center;\n}\n\n.mdhui-button:disabled {\n color: var(--mdhui-text-color-3);\n background: var(--mdhui-background-color-2);\n cursor: default;\n}\n\n.mdhui-button.mdhui-button-default-margin {\n margin: 16px;\n display: block;\n}\n\n.mdhui-button.mdhui-button-full-width {\n width: 100%;\n display: block;\n}\n\n.mdhui-button.mdhui-button-default-margin.mdhui-button-full-width\n{\n width: calc(100% - 32px);\n}");function zS(e){var a=[],n=Array.from(Array(7).keys()),i=e.weekStartsOn&&e.weekStartsOn<7?e.weekStartsOn:0;if(i)for(;n[0]!==i;)n.push(n.shift());const r=n.map((e=>ul(e)));var o=function(e,t){return 32-new Date(t,e,32).getDate()};return function(){var t=new Date(e.year,e.month).getDay()-i;t<0&&(t=7+t);var n=[],r=1;for(let a=0;a<6;a++){var s={days:[]};for(let n=0;n<7;n++)if(0===a&&n<t)s.days[n]={day:void 0};else{if(r>o(e.month,e.year))break;s.days[n]={day:r},r++}n.push(s)}a=n}(),t.createElement("div",{ref:e.innerRef,className:"mdhui-calendar"+(e.className?` ${e.className}`:"")},t.createElement("table",{cellPadding:"0",cellSpacing:"0"},t.createElement("thead",null,t.createElement("tr",null,r.map(((e,a)=>t.createElement("th",{key:a},e))))),t.createElement("tbody",null,a.map(((a,n)=>t.createElement("tr",{key:n},a.days.map(((a,n)=>t.createElement("td",{key:n},e.dayRenderer(e.year,e.month,a.day))))))))))}A(".mdhui-calendar {\n padding-bottom: 16px;\n}\n\n.mdhui-calendar table {\n width: 100%;\n font-size: 14px;\n}\n\n.mdhui-calendar table tr th {\n font-size: 14px;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n padding-bottom: 16px;\n padding-top: 16px;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n text-align: center;\n}\n\n.mdhui-calendar table tr td {\n padding-top: 16px;\n vertical-align: top;\n text-align: center;\n height: 50px;\n padding-bottom: 0;\n position: relative;\n}");function RS(e){const a=r(Ka);if(!e.day)return t.createElement("div",{ref:e.innerRef});const n=e=>{let t=1===e.getDate(),a=0===e.getDay();return!t&&!a},i=e=>{let t=e.getDate()===(e=>new Date(e.getFullYear(),e.getMonth()+1,0).getDate())(e),a=6===e.getDay();return!t&&!a},o=t=>{if(e.stateConfiguration&&e.computeStateForDay){const a=e.computeStateForDay(t);if(void 0===a)return[];const n=e.stateConfiguration[a];return n?[{...n.streak?{streakIdentifier:a}:void 0,...n}]:[]}return e.computeStatesForDay?.(t)??[]},s=new Date(e.year,e.month,e.day),l=o(un(s,{days:-1})),c=o(s),u=o(un(s,{days:1})),d=["mdhui-calendar-day"],m={};Pr(s)?d.push("mdhui-calendar-day-today"):Oi(s,new Date)&&d.push("mdhui-calendar-day-future");const h=c.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),p=l.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),g=u.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),f=c.reduce(((e,t)=>(t.streakIdentifier&&p.includes(t.streakIdentifier)&&e.push(t.streakColor),e)),[]),y=c.reduce(((e,t)=>(t.streakIdentifier&&g.includes(t.streakIdentifier)&&e.push(t.streakColor),e)),[]),b=(e,t)=>{const n=e.map((e=>ze(a.colorScheme,e)??"#ddd")),i=100/n.length;let r="linear-gradient(to bottom, ",o=0;for(let e=0;e<n.length;e++)r=r+n[e]+" "+o+"%, ",o+=i,r=r+n[e]+" "+o+"%",e!=n.length-1&&(r+=", ");return r+=`) ${"left"===t?"calc(0% - 1px)":"calc(100% + 1px)"} / 50% 100% no-repeat`,r};h.length>0&&(f.length>0&&y.length>0&&n(s)&&i(s)?m.background=b(f,"left")+", "+b(y,"right"):f.length>0&&n(s)?m.background=b(f,"left"):y.length>0&&i(s)&&(m.background=b(y,"right")));const v=t=>{const n=t.map((e=>ze(a.colorScheme,e)??"transparent")),i=100/n.length;let r=`conic-gradient(from ${e.multiStateStartAngle??270}deg at 50% 50%,`,o=0;for(let e=0;e<n.length;e++)r=r+n[e]+" "+o+"%, ",o+=i,r=r+n[e]+" "+o+"%",e!=n.length-1&&(r+=", ");return r+=")",r},w=(e=>{if(0===e.length)return;if(1===e.length&&!e[0].combineWhenSolo)return e[0];const t=e.map((e=>e.backgroundColor??"var(--mdhui-border-color-2)")),n=v(t),i=v(e.map(((e,a)=>e.borderColor??t[a]))),r=ze(a.colorScheme,{lightMode:"#eee",darkMode:"#444"})?.replace("#","%23"),o=ze(a.colorScheme,{lightMode:"#888",darkMode:"#333"})?.replace("#","%23");return{...e[0],borderColor:"transparent",textColor:"var(--mdhui-text-color-1)",style:{...e[0].style,background:`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="32" fill="${r}"/></svg>') center / 100% 100% no-repeat content-box content-box, url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="34" fill="${o}"/></svg>') center / 100% 100% no-repeat content-box content-box, `+n+" center / 100% 100% no-repeat padding-box padding-box, "+i+" center / 100% 100% no-repeat border-box border-box"}}})(c),x=w?{...w.backgroundColor&&{background:ze(a.colorScheme,w.backgroundColor)},...w.borderColor&&{border:`2px solid ${ze(a.colorScheme,w.borderColor)}`,marginTop:"-12px"},...w.textColor&&{color:ze(a.colorScheme,w.textColor)},...w.style}:void 0,k=t.createElement("div",{className:"mdhui-calendar-day-value",style:x},s.getDate(),c.note&&t.createElement("div",{className:"mdhui-calendar-day-note-wrapper",style:{backgroundColor:c.noteBackgroundColor?ze(a.colorScheme,c.noteBackgroundColor):void 0,border:c.noteBorderColor?`1px solid ${ze(a.colorScheme,c.noteBorderColor)}`:void 0,color:c.noteTextColor?ze(a.colorScheme,c.noteTextColor):void 0}},t.createElement("span",{className:"mdhui-calendar-day-note"},c.note)));return t.createElement("div",{ref:e.innerRef,className:d.join(" "),style:m},e.onClick?t.createElement(S,{onClick:()=>e.onClick(s),children:k}):k)}A(".mdhui-calendar table tr:has(.mdhui-calendar-day) td {\n height: 40px;\n}\n\n.mdhui-calendar-day {\n display: inline-block;\n width: 100%;\n height: 21px;\n margin-top: 5px;\n}\n\n.mdhui-calendar-day .mdhui-unstyled-button {\n margin: 0 auto;\n}\n\n.mdhui-calendar-day-value {\n position: relative;\n background: var(--mdhui-border-color-2);\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 50%;\n text-align: center;\n vertical-align: middle;\n margin: -10px auto 0;\n font-size: 15px;\n font-weight: bold;\n}\n\n.mdhui-calendar-day-today .mdhui-calendar-day-value {\n background: #369CFF;\n color: #fff;\n border: 2px solid var(--mdhui-background-color-0);\n margin-top: -12px;\n}\n\n.mdhui-calendar-day-future .mdhui-calendar-day-value {\n background: var(--mdhui-background-color-0);\n color: var(--mdhui-text-color-4);\n border: 2px solid var(--mdhui-border-color-2);\n margin-top: -12px;\n}\n\n.mdhui-calendar-day-note-wrapper {\n position: absolute;\n bottom: -12px;\n right: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--mdhui-border-color-1);\n border: 1px solid var(--mdhui-border-color-2);\n border-radius: 8px;\n color: var(--mdhui-text-color-0);\n height: 16px;\n min-width: 16px;\n max-width: 40px;\n padding: 0 4px;\n font-size: 0.62em;\n box-sizing: border-box;\n}\n\n.mdhui-calendar-day-note {\n max-width: 100%;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}");A(".mdhui-card {\n border-radius: var(--mdhui-card-border-radius);\n margin: 16px;\n background: var(--mdhui-background-color-0);\n box-shadow: var(--mdhui-box-shadow-0);\n animation: var(--mdhui-fadein-animation);\n -moz-animation: var(--mdhui-fadein-animation);\n -webkit-animation: var(--mdhui-fadein-animation);\n position: relative;\n overflow: hidden;\n display: flow-root;\n}\n\n.mdhui-card:empty {\n display: none;\n}\n\n.mdhui-card.allow-overflow {\n overflow: visible;\n}\n\n.mdhui-card-subtle {\n box-shadow: none;\n background: none !important;\n border: solid 1px var(--mdhui-border-color-1);\n}\n\n.mdhui-card-highlight\n{\n background: var(--mdhui-color-primary);\n color: #FFF;\n --mdhui-text-color-0: #FFF;\n --mdhui-text-color-1: #FFF;\n --mdhui-text-color-2: #FFF;\n --mdhui-text-color-3: #FFF;\n --mdhui-text-color-4: #FFF;\n}");function LS(){return t.createElement("div",{className:"mdhui-shiny-overlay"})}function FS(e){if(!e.children)return null;let a=["mdhui-card"];e.allowOverflow&&a.push("allow-overflow"),e.className&&a.push(e.className);let n=e.variant||"default";a.push(`mdhui-card-${n}`),"highlight"==n&&a.push("mdhui-color-scheme-dark");let i=r(Ka),o=ze(i?.colorScheme,e.backgroundColor);return t.createElement("div",{style:{...e.style,backgroundColor:o},ref:e.innerRef,className:a.join(" ")},e.children,e.children&&"highlight"===n&&t.createElement(LS,null))}A(".mdhui-shiny-overlay\n{\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background: var(--mdhui-overlay-gradient);\n pointer-events: none;\n}\n");function BS(e){let a=r(Ka);return t.createElement("div",{style:{color:ze(a.colorScheme,e.color)},ref:e.innerRef,className:"mdhui-card-title"},e.title,e.onDetailClick&&e.detailLinkText&&t.createElement("a",{className:"detail-link",onClick:()=>e.onDetailClick?e.onDetailClick():null},e.detailLinkText))}A(".mdhui-card-title {\n padding: 16px;\n font-weight: bold;\n padding-bottom: 0;\n position: relative;\n color: var(--mdhui-text-color-0);\n}\n\n.mdhui-card-title .detail-link {\n position: absolute;\n right: 16px;\n bottom: 0;\n font-size: .88em;\n cursor: pointer;\n}");const HS={};function qS(e,t){"string"!=typeof t&&(t=qS.defaultChars);const a=function(e){let t=HS[e];if(t)return t;t=HS[e]=[];for(let e=0;e<128;e++){const a=String.fromCharCode(e);t.push(a)}for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);t[n]="%"+("0"+n.toString(16).toUpperCase()).slice(-2)}return t}(t);return e.replace(/(%[a-f0-9]{2})+/gi,(function(e){let t="";for(let n=0,i=e.length;n<i;n+=3){const r=parseInt(e.slice(n+1,n+3),16);if(r<128)t+=a[r];else{if(192==(224&r)&&n+3<i){const a=parseInt(e.slice(n+4,n+6),16);if(128==(192&a)){const e=r<<6&1984|63&a;t+=e<128?"��":String.fromCharCode(e),n+=3;continue}}if(224==(240&r)&&n+6<i){const a=parseInt(e.slice(n+4,n+6),16),i=parseInt(e.slice(n+7,n+9),16);if(128==(192&a)&&128==(192&i)){const e=r<<12&61440|a<<6&4032|63&i;t+=e<2048||e>=55296&&e<=57343?"���":String.fromCharCode(e),n+=6;continue}}if(240==(248&r)&&n+9<i){const a=parseInt(e.slice(n+4,n+6),16),i=parseInt(e.slice(n+7,n+9),16),o=parseInt(e.slice(n+10,n+12),16);if(128==(192&a)&&128==(192&i)&&128==(192&o)){let e=r<<18&1835008|a<<12&258048|i<<6&4032|63&o;e<65536||e>1114111?t+="����":(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(1023&e))),n+=9;continue}}t+="�"}}return t}))}qS.defaultChars=";/?:@&=+$,#",qS.componentChars="";const US={};function WS(e,t,a){"string"!=typeof t&&(a=t,t=WS.defaultChars),void 0===a&&(a=!0);const n=function(e){let t=US[e];if(t)return t;t=US[e]=[];for(let e=0;e<128;e++){const a=String.fromCharCode(e);/^[0-9a-z]$/i.test(a)?t.push(a):t.push("%"+("0"+e.toString(16).toUpperCase()).slice(-2))}for(let a=0;a<e.length;a++)t[e.charCodeAt(a)]=e[a];return t}(t);let i="";for(let t=0,r=e.length;t<r;t++){const o=e.charCodeAt(t);if(a&&37===o&&t+2<r&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3)))i+=e.slice(t,t+3),t+=2;else if(o<128)i+=n[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<r){const a=e.charCodeAt(t+1);if(a>=56320&&a<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+="%EF%BF%BD"}else i+=encodeURIComponent(e[t])}return i}function VS(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&-1!==e.hostname.indexOf(":")?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function $S(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}WS.defaultChars=";/?:@&=+$,-_.!~*'()#",WS.componentChars="-_.!~*'()";const GS=/^([a-z0-9.+-]+:)/i,KS=/:[0-9]*$/,ZS=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,YS=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),XS=["'"].concat(YS),QS=["%","/","?",";","#"].concat(XS),JS=["/","?","#"],eE=/^[+a-z0-9A-Z_-]{0,63}$/,tE=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,aE={javascript:!0,"javascript:":!0},nE={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function iE(e,t){if(e&&e instanceof $S)return e;const a=new $S;return a.parse(e,t),a}$S.prototype.parse=function(e,t){let a,n,i,r=e;if(r=r.trim(),!t&&1===e.split("#").length){const e=ZS.exec(r);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=GS.exec(r);if(o&&(o=o[0],a=o.toLowerCase(),this.protocol=o,r=r.substr(o.length)),(t||o||r.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i="//"===r.substr(0,2),!i||o&&aE[o]||(r=r.substr(2),this.slashes=!0)),!aE[o]&&(i||o&&!nE[o])){let e,t,a=-1;for(let e=0;e<JS.length;e++)n=r.indexOf(JS[e]),-1!==n&&(-1===a||n<a)&&(a=n);t=-1===a?r.lastIndexOf("@"):r.lastIndexOf("@",a),-1!==t&&(e=r.slice(0,t),r=r.slice(t+1),this.auth=e),a=-1;for(let e=0;e<QS.length;e++)n=r.indexOf(QS[e]),-1!==n&&(-1===a||n<a)&&(a=n);-1===a&&(a=r.length),":"===r[a-1]&&a--;const i=r.slice(0,a);r=r.slice(a),this.parseHost(i),this.hostname=this.hostname||"";const o="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!o){const e=this.hostname.split(/\./);for(let t=0,a=e.length;t<a;t++){const a=e[t];if(a&&!a.match(eE)){let n="";for(let e=0,t=a.length;e<t;e++)a.charCodeAt(e)>127?n+="x":n+=a[e];if(!n.match(eE)){const n=e.slice(0,t),i=e.slice(t+1),o=a.match(tE);o&&(n.push(o[1]),i.unshift(o[2])),i.length&&(r=i.join(".")+r),this.hostname=n.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const s=r.indexOf("#");-1!==s&&(this.hash=r.substr(s),r=r.slice(0,s));const l=r.indexOf("?");return-1!==l&&(this.search=r.substr(l),r=r.slice(0,l)),r&&(this.pathname=r),nE[a]&&this.hostname&&!this.pathname&&(this.pathname=""),this},$S.prototype.parseHost=function(e){let t=KS.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var rE,oE=Object.freeze({__proto__:null,decode:qS,encode:WS,format:VS,parse:iE}),sE=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,lE=/[\0-\x1F\x7F-\x9F]/,cE=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,uE=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,dE=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,mE=Object.freeze({__proto__:null,Any:sE,Cc:lE,Cf:/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,P:cE,S:uE,Z:dE}),hE=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map((e=>e.charCodeAt(0)))),pE=new Uint16Array("Ȁaglq\tɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map((e=>e.charCodeAt(0))));const gE=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),fE=null!==(rE=String.fromCodePoint)&&void 0!==rE?rE:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|1023&e),t+=String.fromCharCode(e),t};var yE;!function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"}(yE||(yE={}));var bE,vE,wE;function xE(e){return e>=yE.ZERO&&e<=yE.NINE}function kE(e){return e>=yE.UPPER_A&&e<=yE.UPPER_F||e>=yE.LOWER_A&&e<=yE.LOWER_F}function AE(e){return e===yE.EQUALS||function(e){return e>=yE.UPPER_A&&e<=yE.UPPER_Z||e>=yE.LOWER_A&&e<=yE.LOWER_Z||xE(e)}(e)}!function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"}(bE||(bE={})),function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"}(vE||(vE={})),function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"}(wE||(wE={}));class SE{constructor(e,t,a){this.decodeTree=e,this.emitCodePoint=t,this.errors=a,this.state=vE.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=wE.Strict}startEntity(e){this.decodeMode=e,this.state=vE.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case vE.EntityStart:return e.charCodeAt(t)===yE.NUM?(this.state=vE.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=vE.NamedEntity,this.stateNamedEntity(e,t));case vE.NumericStart:return this.stateNumericStart(e,t);case vE.NumericDecimal:return this.stateNumericDecimal(e,t);case vE.NumericHex:return this.stateNumericHex(e,t);case vE.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(32|e.charCodeAt(t))===yE.LOWER_X?(this.state=vE.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=vE.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,a,n){if(t!==a){const i=a-t;this.result=this.result*Math.pow(n,i)+parseInt(e.substr(t,i),n),this.consumed+=i}}stateNumericHex(e,t){const a=t;for(;t<e.length;){const n=e.charCodeAt(t);if(!xE(n)&&!kE(n))return this.addToNumericResult(e,a,t,16),this.emitNumericEntity(n,3);t+=1}return this.addToNumericResult(e,a,t,16),-1}stateNumericDecimal(e,t){const a=t;for(;t<e.length;){const n=e.charCodeAt(t);if(!xE(n))return this.addToNumericResult(e,a,t,10),this.emitNumericEntity(n,2);t+=1}return this.addToNumericResult(e,a,t,10),-1}emitNumericEntity(e,t){var a;if(this.consumed<=t)return null===(a=this.errors)||void 0===a||a.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===yE.SEMI)this.consumed+=1;else if(this.decodeMode===wE.Strict)return 0;return this.emitCodePoint(function(e){var t;return e>=55296&&e<=57343||e>1114111?65533:null!==(t=gE.get(e))&&void 0!==t?t:e}(this.result),this.consumed),this.errors&&(e!==yE.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){const{decodeTree:a}=this;let n=a[this.treeIndex],i=(n&bE.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const r=e.charCodeAt(t);if(this.treeIndex=_E(a,n,this.treeIndex+Math.max(1,i),r),this.treeIndex<0)return 0===this.result||this.decodeMode===wE.Attribute&&(0===i||AE(r))?0:this.emitNotTerminatedNamedEntity();if(n=a[this.treeIndex],i=(n&bE.VALUE_LENGTH)>>14,0!==i){if(r===yE.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==wE.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:t,decodeTree:a}=this,n=(a[t]&bE.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,n,this.consumed),null===(e=this.errors)||void 0===e||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,a){const{decodeTree:n}=this;return this.emitCodePoint(1===t?n[e]&~bE.VALUE_LENGTH:n[e+1],a),3===t&&this.emitCodePoint(n[e+2],a),a}end(){var e;switch(this.state){case vE.NamedEntity:return 0===this.result||this.decodeMode===wE.Attribute&&this.result!==this.treeIndex?0:this.emitNotTerminatedNamedEntity();case vE.NumericDecimal:return this.emitNumericEntity(0,2);case vE.NumericHex:return this.emitNumericEntity(0,3);case vE.NumericStart:return null===(e=this.errors)||void 0===e||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case vE.EntityStart:return 0}}}function EE(e){let t="";const a=new SE(e,(e=>t+=fE(e)));return function(e,n){let i=0,r=0;for(;(r=e.indexOf("&",r))>=0;){t+=e.slice(i,r),a.startEntity(n);const o=a.write(e,r+1);if(o<0){i=r+a.end();break}i=r+o,r=0===o?i+1:i}const o=t+e.slice(i);return t="",o}}function _E(e,t,a,n){const i=(t&bE.BRANCH_LENGTH)>>7,r=t&bE.JUMP_TABLE;if(0===i)return 0!==r&&n===r?a:-1;if(r){const t=n-r;return t<0||t>=i?-1:e[a+t]-1}let o=a,s=o+i-1;for(;o<=s;){const t=o+s>>>1,a=e[t];if(a<n)o=t+1;else{if(!(a>n))return e[t+i];s=t-1}}return-1}const CE=EE(hE);function TE(e,t=wE.Legacy){return CE(e,t)}function PE(e){return"[object String]"===function(e){return Object.prototype.toString.call(e)}(e)}EE(pE);const OE=Object.prototype.hasOwnProperty;function DE(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){if(t){if("object"!=typeof t)throw new TypeError(t+"must be object");Object.keys(t).forEach((function(a){e[a]=t[a]}))}})),e}function ME(e,t,a){return[].concat(e.slice(0,t),a,e.slice(t+1))}function IE(e){return!(e>=55296&&e<=57343)&&(!(e>=64976&&e<=65007)&&(!!(65535&~e&&65534!=(65535&e))&&(!(e>=0&&e<=8)&&(11!==e&&(!(e>=14&&e<=31)&&(!(e>=127&&e<=159)&&!(e>1114111)))))))}function NE(e){if(e>65535){const t=55296+((e-=65536)>>10),a=56320+(1023&e);return String.fromCharCode(t,a)}return String.fromCharCode(e)}const jE=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,zE=new RegExp(jE.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),RE=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function LE(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(zE,(function(e,t,a){return t||function(e,t){if(35===t.charCodeAt(0)&&RE.test(t)){const a="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return IE(a)?NE(a):e}const a=TE(e);return a!==e?a:e}(e,a)}))}const FE=/[&<>"]/,BE=/[&<>"]/g,HE={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function qE(e){return HE[e]}function UE(e){return FE.test(e)?e.replace(BE,qE):e}const WE=/[.?*+^$[\]\\(){}|-]/g;function VE(e){switch(e){case 9:case 32:return!0}return!1}function $E(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function GE(e){return cE.test(e)||uE.test(e)}function KE(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function ZE(e){return e=e.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(e=e.replace(/ẞ/g,"ß")),e.toLowerCase().toUpperCase()}const YE={mdurl:oE,ucmicro:mE};var XE=Object.freeze({__proto__:null,arrayReplaceAt:ME,assign:DE,escapeHtml:UE,escapeRE:function(e){return e.replace(WE,"\\$&")},fromCodePoint:NE,has:function(e,t){return OE.call(e,t)},isMdAsciiPunct:KE,isPunctChar:GE,isSpace:VE,isString:PE,isValidEntityCode:IE,isWhiteSpace:$E,lib:YE,normalizeReference:ZE,unescapeAll:LE,unescapeMd:function(e){return e.indexOf("\\")<0?e:e.replace(jE,"$1")}});var QE=Object.freeze({__proto__:null,parseLinkDestination:function(e,t,a){let n,i=t;const r={ok:!1,pos:0,str:""};if(60===e.charCodeAt(i)){for(i++;i<a;){if(n=e.charCodeAt(i),10===n)return r;if(60===n)return r;if(62===n)return r.pos=i+1,r.str=LE(e.slice(t+1,i)),r.ok=!0,r;92===n&&i+1<a?i+=2:i++}return r}let o=0;for(;i<a&&(n=e.charCodeAt(i),32!==n)&&!(n<32||127===n);)if(92===n&&i+1<a){if(32===e.charCodeAt(i+1))break;i+=2}else{if(40===n&&(o++,o>32))return r;if(41===n){if(0===o)break;o--}i++}return t===i||0!==o||(r.str=LE(e.slice(t,i)),r.pos=i,r.ok=!0),r},parseLinkLabel:function(e,t,a){let n,i,r,o;const s=e.posMax,l=e.pos;for(e.pos=t+1,n=1;e.pos<s;){if(r=e.src.charCodeAt(e.pos),93===r&&(n--,0===n)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),91===r)if(o===e.pos-1)n++;else if(a)return e.pos=l,-1}let c=-1;return i&&(c=e.pos),e.pos=l,c},parseLinkTitle:function(e,t,a,n){let i,r=t;const o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(n)o.str=n.str,o.marker=n.marker;else{if(r>=a)return o;let n=e.charCodeAt(r);if(34!==n&&39!==n&&40!==n)return o;t++,r++,40===n&&(n=41),o.marker=n}for(;r<a;){if(i=e.charCodeAt(r),i===o.marker)return o.pos=r+1,o.str+=LE(e.slice(t,r)),o.ok=!0,o;if(40===i&&41===o.marker)return o;92===i&&r+1<a&&r++,r++}return o.can_continue=!0,o.str+=LE(e.slice(t,r)),o}});const JE={};function e_(){this.rules=DE({},JE)}function t_(){this.__rules__=[],this.__cache__=null}function a_(e,t,a){this.type=e,this.tag=t,this.attrs=null,this.map=null,this.nesting=a,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}function n_(e,t,a){this.src=e,this.env=a,this.tokens=[],this.inlineMode=!1,this.md=t}JE.code_inline=function(e,t,a,n,i){const r=e[t];return"<code"+i.renderAttrs(r)+">"+UE(r.content)+"</code>"},JE.code_block=function(e,t,a,n,i){const r=e[t];return"<pre"+i.renderAttrs(r)+"><code>"+UE(e[t].content)+"</code></pre>\n"},JE.fence=function(e,t,a,n,i){const r=e[t],o=r.info?LE(r.info).trim():"";let s,l="",c="";if(o){const e=o.split(/(\s+)/g);l=e[0],c=e.slice(2).join("")}if(s=a.highlight&&a.highlight(r.content,l,c)||UE(r.content),0===s.indexOf("<pre"))return s+"\n";if(o){const e=r.attrIndex("class"),t=r.attrs?r.attrs.slice():[];e<0?t.push(["class",a.langPrefix+l]):(t[e]=t[e].slice(),t[e][1]+=" "+a.langPrefix+l);const n={attrs:t};return`<pre><code${i.renderAttrs(n)}>${s}</code></pre>\n`}return`<pre><code${i.renderAttrs(r)}>${s}</code></pre>\n`},JE.image=function(e,t,a,n,i){const r=e[t];return r.attrs[r.attrIndex("alt")][1]=i.renderInlineAsText(r.children,a,n),i.renderToken(e,t,a)},JE.hardbreak=function(e,t,a){return a.xhtmlOut?"<br />\n":"<br>\n"},JE.softbreak=function(e,t,a){return a.breaks?a.xhtmlOut?"<br />\n":"<br>\n":"\n"},JE.text=function(e,t){return UE(e[t].content)},JE.html_block=function(e,t){return e[t].content},JE.html_inline=function(e,t){return e[t].content},e_.prototype.renderAttrs=function(e){let t,a,n;if(!e.attrs)return"";for(n="",t=0,a=e.attrs.length;t<a;t++)n+=" "+UE(e.attrs[t][0])+'="'+UE(e.attrs[t][1])+'"';return n},e_.prototype.renderToken=function(e,t,a){const n=e[t];let i="";if(n.hidden)return"";n.block&&-1!==n.nesting&&t&&e[t-1].hidden&&(i+="\n"),i+=(-1===n.nesting?"</":"<")+n.tag,i+=this.renderAttrs(n),0===n.nesting&&a.xhtmlOut&&(i+=" /");let r=!1;if(n.block&&(r=!0,1===n.nesting&&t+1<e.length)){const a=e[t+1];("inline"===a.type||a.hidden||-1===a.nesting&&a.tag===n.tag)&&(r=!1)}return i+=r?">\n":">",i},e_.prototype.renderInline=function(e,t,a){let n="";const i=this.rules;for(let r=0,o=e.length;r<o;r++){const o=e[r].type;void 0!==i[o]?n+=i[o](e,r,t,a,this):n+=this.renderToken(e,r,t)}return n},e_.prototype.renderInlineAsText=function(e,t,a){let n="";for(let i=0,r=e.length;i<r;i++)switch(e[i].type){case"text":case"html_inline":case"html_block":n+=e[i].content;break;case"image":n+=this.renderInlineAsText(e[i].children,t,a);break;case"softbreak":case"hardbreak":n+="\n"}return n},e_.prototype.render=function(e,t,a){let n="";const i=this.rules;for(let r=0,o=e.length;r<o;r++){const o=e[r].type;"inline"===o?n+=this.renderInline(e[r].children,t,a):void 0!==i[o]?n+=i[o](e,r,t,a,this):n+=this.renderToken(e,r,t,a)}return n},t_.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},t_.prototype.__compile__=function(){const e=this,t=[""];e.__rules__.forEach((function(e){e.enabled&&e.alt.forEach((function(e){t.indexOf(e)<0&&t.push(e)}))})),e.__cache__={},t.forEach((function(t){e.__cache__[t]=[],e.__rules__.forEach((function(a){a.enabled&&(t&&a.alt.indexOf(t)<0||e.__cache__[t].push(a.fn))}))}))},t_.prototype.at=function(e,t,a){const n=this.__find__(e),i=a||{};if(-1===n)throw new Error("Parser rule not found: "+e);this.__rules__[n].fn=t,this.__rules__[n].alt=i.alt||[],this.__cache__=null},t_.prototype.before=function(e,t,a,n){const i=this.__find__(e),r=n||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:a,alt:r.alt||[]}),this.__cache__=null},t_.prototype.after=function(e,t,a,n){const i=this.__find__(e),r=n||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:a,alt:r.alt||[]}),this.__cache__=null},t_.prototype.push=function(e,t,a){const n=a||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:n.alt||[]}),this.__cache__=null},t_.prototype.enable=function(e,t){Array.isArray(e)||(e=[e]);const a=[];return e.forEach((function(e){const n=this.__find__(e);if(n<0){if(t)return;throw new Error("Rules manager: invalid rule name "+e)}this.__rules__[n].enabled=!0,a.push(e)}),this),this.__cache__=null,a},t_.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach((function(e){e.enabled=!1})),this.enable(e,t)},t_.prototype.disable=function(e,t){Array.isArray(e)||(e=[e]);const a=[];return e.forEach((function(e){const n=this.__find__(e);if(n<0){if(t)return;throw new Error("Rules manager: invalid rule name "+e)}this.__rules__[n].enabled=!1,a.push(e)}),this),this.__cache__=null,a},t_.prototype.getRules=function(e){return null===this.__cache__&&this.__compile__(),this.__cache__[e]||[]},a_.prototype.attrIndex=function(e){if(!this.attrs)return-1;const t=this.attrs;for(let a=0,n=t.length;a<n;a++)if(t[a][0]===e)return a;return-1},a_.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},a_.prototype.attrSet=function(e,t){const a=this.attrIndex(e),n=[e,t];a<0?this.attrPush(n):this.attrs[a]=n},a_.prototype.attrGet=function(e){const t=this.attrIndex(e);let a=null;return t>=0&&(a=this.attrs[t][1]),a},a_.prototype.attrJoin=function(e,t){const a=this.attrIndex(e);a<0?this.attrPush([e,t]):this.attrs[a][1]=this.attrs[a][1]+" "+t},n_.prototype.Token=a_;const i_=/\r\n?|\n/g,r_=/\0/g;function o_(e){return/^<a[>\s]/i.test(e)}function s_(e){return/^<\/a\s*>/i.test(e)}const l_=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,c_=/\((c|tm|r)\)/i,u_=/\((c|tm|r)\)/gi,d_={c:"©",r:"®",tm:"™"};function m_(e,t){return d_[t.toLowerCase()]}function h_(e){let t=0;for(let a=e.length-1;a>=0;a--){const n=e[a];"text"!==n.type||t||(n.content=n.content.replace(u_,m_)),"link_open"===n.type&&"auto"===n.info&&t--,"link_close"===n.type&&"auto"===n.info&&t++}}function p_(e){let t=0;for(let a=e.length-1;a>=0;a--){const n=e[a];"text"!==n.type||t||l_.test(n.content)&&(n.content=n.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===n.type&&"auto"===n.info&&t--,"link_close"===n.type&&"auto"===n.info&&t++}}const g_=/['"]/,f_=/['"]/g,y_="’";function b_(e,t,a){return e.slice(0,t)+a+e.slice(t+1)}function v_(e,t){let a;const n=[];for(let i=0;i<e.length;i++){const r=e[i],o=e[i].level;for(a=n.length-1;a>=0&&!(n[a].level<=o);a--);if(n.length=a+1,"text"!==r.type)continue;let s=r.content,l=0,c=s.length;e:for(;l<c;){f_.lastIndex=l;const u=f_.exec(s);if(!u)break;let d=!0,m=!0;l=u.index+1;const h="'"===u[0];let p=32;if(u.index-1>=0)p=s.charCodeAt(u.index-1);else for(a=i-1;a>=0&&("softbreak"!==e[a].type&&"hardbreak"!==e[a].type);a--)if(e[a].content){p=e[a].content.charCodeAt(e[a].content.length-1);break}let g=32;if(l<c)g=s.charCodeAt(l);else for(a=i+1;a<e.length&&("softbreak"!==e[a].type&&"hardbreak"!==e[a].type);a++)if(e[a].content){g=e[a].content.charCodeAt(0);break}const f=KE(p)||GE(String.fromCharCode(p)),y=KE(g)||GE(String.fromCharCode(g)),b=$E(p),v=$E(g);if(v?d=!1:y&&(b||f||(d=!1)),b?m=!1:f&&(v||y||(m=!1)),34===g&&'"'===u[0]&&p>=48&&p<=57&&(m=d=!1),d&&m&&(d=f,m=y),d||m){if(m)for(a=n.length-1;a>=0;a--){let d=n[a];if(n[a].level<o)break;if(d.single===h&&n[a].level===o){let o,m;d=n[a],h?(o=t.md.options.quotes[2],m=t.md.options.quotes[3]):(o=t.md.options.quotes[0],m=t.md.options.quotes[1]),r.content=b_(r.content,u.index,m),e[d.token].content=b_(e[d.token].content,d.pos,o),l+=m.length-1,d.token===i&&(l+=o.length-1),s=r.content,c=s.length,n.length=a;continue e}}d?n.push({token:i,pos:u.index,single:h,level:o}):m&&h&&(r.content=b_(r.content,u.index,y_))}else h&&(r.content=b_(r.content,u.index,y_))}}}const w_=[["normalize",function(e){let t;t=e.src.replace(i_,"\n"),t=t.replace(r_,"�"),e.src=t}],["block",function(e){let t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}],["inline",function(e){const t=e.tokens;for(let a=0,n=t.length;a<n;a++){const n=t[a];"inline"===n.type&&e.md.inline.parse(n.content,e.md,e.env,n.children)}}],["linkify",function(e){const t=e.tokens;if(e.md.options.linkify)for(let a=0,n=t.length;a<n;a++){if("inline"!==t[a].type||!e.md.linkify.pretest(t[a].content))continue;let n=t[a].children,i=0;for(let r=n.length-1;r>=0;r--){const o=n[r];if("link_close"!==o.type){if("html_inline"===o.type&&(o_(o.content)&&i>0&&i--,s_(o.content)&&i++),!(i>0)&&"text"===o.type&&e.md.linkify.test(o.content)){const i=o.content;let s=e.md.linkify.match(i);const l=[];let c=o.level,u=0;s.length>0&&0===s[0].index&&r>0&&"text_special"===n[r-1].type&&(s=s.slice(1));for(let t=0;t<s.length;t++){const a=s[t].url,n=e.md.normalizeLink(a);if(!e.md.validateLink(n))continue;let r=s[t].text;r=s[t].schema?"mailto:"!==s[t].schema||/^mailto:/i.test(r)?e.md.normalizeLinkText(r):e.md.normalizeLinkText("mailto:"+r).replace(/^mailto:/,""):e.md.normalizeLinkText("http://"+r).replace(/^http:\/\//,"");const o=s[t].index;if(o>u){const t=new e.Token("text","",0);t.content=i.slice(u,o),t.level=c,l.push(t)}const d=new e.Token("link_open","a",1);d.attrs=[["href",n]],d.level=c++,d.markup="linkify",d.info="auto",l.push(d);const m=new e.Token("text","",0);m.content=r,m.level=c,l.push(m);const h=new e.Token("link_close","a",-1);h.level=--c,h.markup="linkify",h.info="auto",l.push(h),u=s[t].lastIndex}if(u<i.length){const t=new e.Token("text","",0);t.content=i.slice(u),t.level=c,l.push(t)}t[a].children=n=ME(n,r,l)}}else for(r--;n[r].level!==o.level&&"link_open"!==n[r].type;)r--}}}],["replacements",function(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)"inline"===e.tokens[t].type&&(c_.test(e.tokens[t].content)&&h_(e.tokens[t].children),l_.test(e.tokens[t].content)&&p_(e.tokens[t].children))}],["smartquotes",function(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)"inline"===e.tokens[t].type&&g_.test(e.tokens[t].content)&&v_(e.tokens[t].children,e)}],["text_join",function(e){let t,a;const n=e.tokens,i=n.length;for(let e=0;e<i;e++){if("inline"!==n[e].type)continue;const i=n[e].children,r=i.length;for(t=0;t<r;t++)"text_special"===i[t].type&&(i[t].type="text");for(t=a=0;t<r;t++)"text"===i[t].type&&t+1<r&&"text"===i[t+1].type?i[t+1].content=i[t].content+i[t+1].content:(t!==a&&(i[a]=i[t]),a++);t!==a&&(i.length=a)}}]];function x_(){this.ruler=new t_;for(let e=0;e<w_.length;e++)this.ruler.push(w_[e][0],w_[e][1])}function k_(e,t,a,n){this.src=e,this.md=t,this.env=a,this.tokens=n,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const i=this.src;for(let e=0,t=0,a=0,n=0,r=i.length,o=!1;t<r;t++){const s=i.charCodeAt(t);if(!o){if(VE(s)){a++,9===s?n+=4-n%4:n++;continue}o=!0}10!==s&&t!==r-1||(10!==s&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(a),this.sCount.push(n),this.bsCount.push(0),o=!1,a=0,n=0,e=t+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}x_.prototype.process=function(e){const t=this.ruler.getRules("");for(let a=0,n=t.length;a<n;a++)t[a](e)},x_.prototype.State=n_,k_.prototype.push=function(e,t,a){const n=new a_(e,t,a);return n.block=!0,a<0&&this.level--,n.level=this.level,a>0&&this.level++,this.tokens.push(n),n},k_.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},k_.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},k_.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t;e++){if(!VE(this.src.charCodeAt(e)))break}return e},k_.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!VE(this.src.charCodeAt(--e)))return e+1;return e},k_.prototype.skipChars=function(e,t){for(let a=this.src.length;e<a&&this.src.charCodeAt(e)===t;e++);return e},k_.prototype.skipCharsBack=function(e,t,a){if(e<=a)return e;for(;e>a;)if(t!==this.src.charCodeAt(--e))return e+1;return e},k_.prototype.getLines=function(e,t,a,n){if(e>=t)return"";const i=new Array(t-e);for(let r=0,o=e;o<t;o++,r++){let e=0;const s=this.bMarks[o];let l,c=s;for(l=o+1<t||n?this.eMarks[o]+1:this.eMarks[o];c<l&&e<a;){const t=this.src.charCodeAt(c);if(VE(t))9===t?e+=4-(e+this.bsCount[o])%4:e++;else{if(!(c-s<this.tShift[o]))break;e++}c++}i[r]=e>a?new Array(e-a+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return i.join("")},k_.prototype.Token=a_;function A_(e,t){const a=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];return e.src.slice(a,n)}function S_(e){const t=[],a=e.length;let n=0,i=e.charCodeAt(n),r=!1,o=0,s="";for(;n<a;)124===i&&(r?(s+=e.substring(o,n-1),o=n):(t.push(s+e.substring(o,n)),s="",o=n+1)),r=92===i,n++,i=e.charCodeAt(n);return t.push(s+e.substring(o)),t}function E_(e,t){const a=e.eMarks[t];let n=e.bMarks[t]+e.tShift[t];const i=e.src.charCodeAt(n++);if(42!==i&&45!==i&&43!==i)return-1;if(n<a){if(!VE(e.src.charCodeAt(n)))return-1}return n}function __(e,t){const a=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];let i=a;if(i+1>=n)return-1;let r=e.src.charCodeAt(i++);if(r<48||r>57)return-1;for(;;){if(i>=n)return-1;if(r=e.src.charCodeAt(i++),!(r>=48&&r<=57)){if(41===r||46===r)break;return-1}if(i-a>=10)return-1}return i<n&&(r=e.src.charCodeAt(i),!VE(r))?-1:i}const C_="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",T_="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",P_=new RegExp("^(?:"+C_+"|"+T_+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),O_=new RegExp("^(?:"+C_+"|"+T_+")"),D_=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"].join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(O_.source+"\\s*$"),/^$/,!1]];const M_=[["table",function(e,t,a,n){if(t+2>a)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent)return!1;if(e.sCount[i]-e.blkIndent>=4)return!1;let r=e.bMarks[i]+e.tShift[i];if(r>=e.eMarks[i])return!1;const o=e.src.charCodeAt(r++);if(124!==o&&45!==o&&58!==o)return!1;if(r>=e.eMarks[i])return!1;const s=e.src.charCodeAt(r++);if(124!==s&&45!==s&&58!==s&&!VE(s))return!1;if(45===o&&VE(s))return!1;for(;r<e.eMarks[i];){const t=e.src.charCodeAt(r);if(124!==t&&45!==t&&58!==t&&!VE(t))return!1;r++}let l=A_(e,t+1),c=l.split("|");const u=[];for(let e=0;e<c.length;e++){const t=c[e].trim();if(!t){if(0===e||e===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;58===t.charCodeAt(t.length-1)?u.push(58===t.charCodeAt(0)?"center":"right"):58===t.charCodeAt(0)?u.push("left"):u.push("")}if(l=A_(e,t).trim(),-1===l.indexOf("|"))return!1;if(e.sCount[t]-e.blkIndent>=4)return!1;c=S_(l),c.length&&""===c[0]&&c.shift(),c.length&&""===c[c.length-1]&&c.pop();const d=c.length;if(0===d||d!==u.length)return!1;if(n)return!0;const m=e.parentType;e.parentType="table";const h=e.md.block.ruler.getRules("blockquote"),p=[t,0];e.push("table_open","table",1).map=p,e.push("thead_open","thead",1).map=[t,t+1],e.push("tr_open","tr",1).map=[t,t+1];for(let t=0;t<c.length;t++){const a=e.push("th_open","th",1);u[t]&&(a.attrs=[["style","text-align:"+u[t]]]);const n=e.push("inline","",0);n.content=c[t].trim(),n.children=[],e.push("th_close","th",-1)}let g;e.push("tr_close","tr",-1),e.push("thead_close","thead",-1);let f=0;for(i=t+2;i<a&&!(e.sCount[i]<e.blkIndent);i++){let n=!1;for(let t=0,r=h.length;t<r;t++)if(h[t](e,i,a,!0)){n=!0;break}if(n)break;if(l=A_(e,i).trim(),!l)break;if(e.sCount[i]-e.blkIndent>=4)break;if(c=S_(l),c.length&&""===c[0]&&c.shift(),c.length&&""===c[c.length-1]&&c.pop(),f+=d-c.length,f>65536)break;if(i===t+2){e.push("tbody_open","tbody",1).map=g=[t+2,0]}e.push("tr_open","tr",1).map=[i,i+1];for(let t=0;t<d;t++){const a=e.push("td_open","td",1);u[t]&&(a.attrs=[["style","text-align:"+u[t]]]);const n=e.push("inline","",0);n.content=c[t]?c[t].trim():"",n.children=[],e.push("td_close","td",-1)}e.push("tr_close","tr",-1)}return g&&(e.push("tbody_close","tbody",-1),g[1]=i),e.push("table_close","table",-1),p[1]=i,e.parentType=m,e.line=i,!0},["paragraph","reference"]],["code",function(e,t,a){if(e.sCount[t]-e.blkIndent<4)return!1;let n=t+1,i=n;for(;n<a;)if(e.isEmpty(n))n++;else{if(!(e.sCount[n]-e.blkIndent>=4))break;n++,i=n}e.line=i;const r=e.push("code_block","code",0);return r.content=e.getLines(t,i,4+e.blkIndent,!1)+"\n",r.map=[t,e.line],!0}],["fence",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(i+3>r)return!1;const o=e.src.charCodeAt(i);if(126!==o&&96!==o)return!1;let s=i;i=e.skipChars(i,o);let l=i-s;if(l<3)return!1;const c=e.src.slice(s,i),u=e.src.slice(i,r);if(96===o&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(n)return!0;let d=t,m=!1;for(;(d++,!(d>=a))&&(i=s=e.bMarks[d]+e.tShift[d],r=e.eMarks[d],!(i<r&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4||(i=e.skipChars(i,o),i-s<l||(i=e.skipSpaces(i),i<r)))){m=!0;break}l=e.sCount[t],e.line=d+(m?1:0);const h=e.push("fence","code",0);return h.info=u,h.content=e.getLines(t+1,d,l,!0),h.markup=c,h.map=[t,e.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];const o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4)return!1;if(62!==e.src.charCodeAt(i))return!1;if(n)return!0;const s=[],l=[],c=[],u=[],d=e.md.block.ruler.getRules("blockquote"),m=e.parentType;e.parentType="blockquote";let h,p=!1;for(h=t;h<a;h++){const t=e.sCount[h]<e.blkIndent;if(i=e.bMarks[h]+e.tShift[h],r=e.eMarks[h],i>=r)break;if(62===e.src.charCodeAt(i++)&&!t){let t,a,n=e.sCount[h]+1;32===e.src.charCodeAt(i)?(i++,n++,a=!1,t=!0):9===e.src.charCodeAt(i)?(t=!0,(e.bsCount[h]+n)%4==3?(i++,n++,a=!1):a=!0):t=!1;let o=n;for(s.push(e.bMarks[h]),e.bMarks[h]=i;i<r;){const t=e.src.charCodeAt(i);if(!VE(t))break;9===t?o+=4-(o+e.bsCount[h]+(a?1:0))%4:o++,i++}p=i>=r,l.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(t?1:0),c.push(e.sCount[h]),e.sCount[h]=o-n,u.push(e.tShift[h]),e.tShift[h]=i-e.bMarks[h];continue}if(p)break;let n=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,h,a,!0)){n=!0;break}if(n){e.lineMax=h,0!==e.blkIndent&&(s.push(e.bMarks[h]),l.push(e.bsCount[h]),u.push(e.tShift[h]),c.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}s.push(e.bMarks[h]),l.push(e.bsCount[h]),u.push(e.tShift[h]),c.push(e.sCount[h]),e.sCount[h]=-1}const g=e.blkIndent;e.blkIndent=0;const f=e.push("blockquote_open","blockquote",1);f.markup=">";const y=[t,0];f.map=y,e.md.block.tokenize(e,t,h),e.push("blockquote_close","blockquote",-1).markup=">",e.lineMax=o,e.parentType=m,y[1]=e.line;for(let a=0;a<u.length;a++)e.bMarks[a+t]=s[a],e.tShift[a+t]=u[a],e.sCount[a+t]=c[a],e.bsCount[a+t]=l[a];return e.blkIndent=g,!0},["paragraph","reference","blockquote","list"]],["hr",function(e,t,a,n){const i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let r=e.bMarks[t]+e.tShift[t];const o=e.src.charCodeAt(r++);if(42!==o&&45!==o&&95!==o)return!1;let s=1;for(;r<i;){const t=e.src.charCodeAt(r++);if(t!==o&&!VE(t))return!1;t===o&&s++}if(s<3)return!1;if(n)return!0;e.line=t+1;const l=e.push("hr","hr",0);return l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o)),!0},["paragraph","reference","blockquote","list"]],["list",function(e,t,a,n){let i,r,o,s,l=t,c=!0;if(e.sCount[l]-e.blkIndent>=4)return!1;if(e.listIndent>=0&&e.sCount[l]-e.listIndent>=4&&e.sCount[l]<e.blkIndent)return!1;let u,d,m,h=!1;if(n&&"paragraph"===e.parentType&&e.sCount[l]>=e.blkIndent&&(h=!0),(m=__(e,l))>=0){if(u=!0,o=e.bMarks[l]+e.tShift[l],d=Number(e.src.slice(o,m-1)),h&&1!==d)return!1}else{if(!((m=E_(e,l))>=0))return!1;u=!1}if(h&&e.skipSpaces(m)>=e.eMarks[l])return!1;if(n)return!0;const p=e.src.charCodeAt(m-1),g=e.tokens.length;u?(s=e.push("ordered_list_open","ol",1),1!==d&&(s.attrs=[["start",d]])):s=e.push("bullet_list_open","ul",1);const f=[l,0];s.map=f,s.markup=String.fromCharCode(p);let y=!1;const b=e.md.block.ruler.getRules("list"),v=e.parentType;for(e.parentType="list";l<a;){r=m,i=e.eMarks[l];const t=e.sCount[l]+m-(e.bMarks[l]+e.tShift[l]);let n=t;for(;r<i;){const t=e.src.charCodeAt(r);if(9===t)n+=4-(n+e.bsCount[l])%4;else{if(32!==t)break;n++}r++}const d=r;let h;h=d>=i?1:n-t,h>4&&(h=1);const g=t+h;s=e.push("list_item_open","li",1),s.markup=String.fromCharCode(p);const f=[l,0];s.map=f,u&&(s.info=e.src.slice(o,m-1));const v=e.tight,w=e.tShift[l],x=e.sCount[l],k=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=g,e.tight=!0,e.tShift[l]=d-e.bMarks[l],e.sCount[l]=n,d>=i&&e.isEmpty(l+1)?e.line=Math.min(e.line+2,a):e.md.block.tokenize(e,l,a,!0),e.tight&&!y||(c=!1),y=e.line-l>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=k,e.tShift[l]=w,e.sCount[l]=x,e.tight=v,s=e.push("list_item_close","li",-1),s.markup=String.fromCharCode(p),l=e.line,f[1]=l,l>=a)break;if(e.sCount[l]<e.blkIndent)break;if(e.sCount[l]-e.blkIndent>=4)break;let A=!1;for(let t=0,n=b.length;t<n;t++)if(b[t](e,l,a,!0)){A=!0;break}if(A)break;if(u){if(m=__(e,l),m<0)break;o=e.bMarks[l]+e.tShift[l]}else if(m=E_(e,l),m<0)break;if(p!==e.src.charCodeAt(m-1))break}return s=u?e.push("ordered_list_close","ol",-1):e.push("bullet_list_close","ul",-1),s.markup=String.fromCharCode(p),f[1]=l,e.line=l,e.parentType=v,c&&function(e,t){const a=e.level+2;for(let n=t+2,i=e.tokens.length-2;n<i;n++)e.tokens[n].level===a&&"paragraph_open"===e.tokens[n].type&&(e.tokens[n+2].hidden=!0,e.tokens[n].hidden=!0,n+=2)}(e,g),!0},["paragraph","reference","blockquote"]],["reference",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4)return!1;if(91!==e.src.charCodeAt(i))return!1;function s(t){const a=e.lineMax;if(t>=a||e.isEmpty(t))return null;let n=!1;if(e.sCount[t]-e.blkIndent>3&&(n=!0),e.sCount[t]<0&&(n=!0),!n){const n=e.md.block.ruler.getRules("reference"),i=e.parentType;e.parentType="reference";let r=!1;for(let i=0,o=n.length;i<o;i++)if(n[i](e,t,a,!0)){r=!0;break}if(e.parentType=i,r)return null}const i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(i,r+1)}let l=e.src.slice(i,r+1);r=l.length;let c=-1;for(i=1;i<r;i++){const e=l.charCodeAt(i);if(91===e)return!1;if(93===e){c=i;break}if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(92===e&&(i++,i<r&&10===l.charCodeAt(i))){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}}if(c<0||58!==l.charCodeAt(c+1))return!1;for(i=c+2;i<r;i++){const e=l.charCodeAt(i);if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(!VE(e))break}const u=e.md.helpers.parseLinkDestination(l,i,r);if(!u.ok)return!1;const d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;const m=i,h=o,p=i;for(;i<r;i++){const e=l.charCodeAt(i);if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(!VE(e))break}let g,f=e.md.helpers.parseLinkTitle(l,i,r);for(;f.can_continue;){const t=s(o);if(null===t)break;l+=t,i=r,r=l.length,o++,f=e.md.helpers.parseLinkTitle(l,i,r,f)}for(i<r&&p!==i&&f.ok?(g=f.str,i=f.pos):(g="",i=m,o=h);i<r;){if(!VE(l.charCodeAt(i)))break;i++}if(i<r&&10!==l.charCodeAt(i)&&g)for(g="",i=m,o=h;i<r;){if(!VE(l.charCodeAt(i)))break;i++}if(i<r&&10!==l.charCodeAt(i))return!1;const y=ZE(l.slice(1,c));return!!y&&(n||(void 0===e.env.references&&(e.env.references={}),void 0===e.env.references[y]&&(e.env.references[y]={title:g,href:d}),e.line=o),!0)}],["html_block",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(!e.md.options.html)return!1;if(60!==e.src.charCodeAt(i))return!1;let o=e.src.slice(i,r),s=0;for(;s<D_.length&&!D_[s][0].test(o);s++);if(s===D_.length)return!1;if(n)return D_[s][2];let l=t+1;if(!D_[s][1].test(o))for(;l<a&&!(e.sCount[l]<e.blkIndent);l++)if(i=e.bMarks[l]+e.tShift[l],r=e.eMarks[l],o=e.src.slice(i,r),D_[s][1].test(o)){0!==o.length&&l++;break}e.line=l;const c=e.push("html_block","",0);return c.map=[t,l],c.content=e.getLines(t,l,e.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(35!==o||i>=r)return!1;let s=1;for(o=e.src.charCodeAt(++i);35===o&&i<r&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<r&&!VE(o))return!1;if(n)return!0;r=e.skipSpacesBack(r,i);const l=e.skipCharsBack(r,35,i);l>i&&VE(e.src.charCodeAt(l-1))&&(r=l),e.line=t+1;const c=e.push("heading_open","h"+String(s),1);c.markup="########".slice(0,s),c.map=[t,e.line];const u=e.push("inline","",0);return u.content=e.src.slice(i,r).trim(),u.map=[t,e.line],u.children=[],e.push("heading_close","h"+String(s),-1).markup="########".slice(0,s),!0},["paragraph","reference","blockquote"]],["lheading",function(e,t,a){const n=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const i=e.parentType;e.parentType="paragraph";let r,o=0,s=t+1;for(;s<a&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s];const a=e.eMarks[s];if(t<a&&(r=e.src.charCodeAt(t),(45===r||61===r)&&(t=e.skipChars(t,r),t=e.skipSpaces(t),t>=a))){o=61===r?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,r=n.length;i<r;i++)if(n[i](e,s,a,!0)){t=!0;break}if(t)break}if(!o)return!1;const l=e.getLines(t,s,e.blkIndent,!1).trim();e.line=s+1;const c=e.push("heading_open","h"+String(o),1);c.markup=String.fromCharCode(r),c.map=[t,e.line];const u=e.push("inline","",0);return u.content=l,u.map=[t,e.line-1],u.children=[],e.push("heading_close","h"+String(o),-1).markup=String.fromCharCode(r),e.parentType=i,!0}],["paragraph",function(e,t,a){const n=e.md.block.ruler.getRules("paragraph"),i=e.parentType;let r=t+1;for(e.parentType="paragraph";r<a&&!e.isEmpty(r);r++){if(e.sCount[r]-e.blkIndent>3)continue;if(e.sCount[r]<0)continue;let t=!1;for(let i=0,o=n.length;i<o;i++)if(n[i](e,r,a,!0)){t=!0;break}if(t)break}const o=e.getLines(t,r,e.blkIndent,!1).trim();e.line=r,e.push("paragraph_open","p",1).map=[t,e.line];const s=e.push("inline","",0);return s.content=o,s.map=[t,e.line],s.children=[],e.push("paragraph_close","p",-1),e.parentType=i,!0}]];function I_(){this.ruler=new t_;for(let e=0;e<M_.length;e++)this.ruler.push(M_[e][0],M_[e][1],{alt:(M_[e][2]||[]).slice()})}function N_(e,t,a,n){this.src=e,this.env=a,this.md=t,this.tokens=n,this.tokens_meta=Array(n.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}function j_(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}I_.prototype.tokenize=function(e,t,a){const n=this.ruler.getRules(""),i=n.length,r=e.md.options.maxNesting;let o=t,s=!1;for(;o<a&&(e.line=o=e.skipEmptyLines(o),!(o>=a))&&!(e.sCount[o]<e.blkIndent);){if(e.level>=r){e.line=a;break}const t=e.line;let l=!1;for(let r=0;r<i;r++)if(l=n[r](e,o,a,!1),l){if(t>=e.line)throw new Error("block rule didn't increment state.line");break}if(!l)throw new Error("none of the block rules matched");e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<a&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}},I_.prototype.parse=function(e,t,a,n){if(!e)return;const i=new this.State(e,t,a,n);this.tokenize(i,i.line,i.lineMax)},I_.prototype.State=k_,N_.prototype.pushPending=function(){const e=new a_("text","",0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending="",e},N_.prototype.push=function(e,t,a){this.pending&&this.pushPending();const n=new a_(e,t,a);let i=null;return a<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,a>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(i),n},N_.prototype.scanDelims=function(e,t){const a=this.posMax,n=this.src.charCodeAt(e),i=e>0?this.src.charCodeAt(e-1):32;let r=e;for(;r<a&&this.src.charCodeAt(r)===n;)r++;const o=r-e,s=r<a?this.src.charCodeAt(r):32,l=KE(i)||GE(String.fromCharCode(i)),c=KE(s)||GE(String.fromCharCode(s)),u=$E(i),d=$E(s),m=!d&&(!c||u||l),h=!u&&(!l||d||c);return{can_open:m&&(t||!h||l),can_close:h&&(t||!m||c),length:o}},N_.prototype.Token=a_;const z_=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;const R_=[];for(let e=0;e<256;e++)R_.push(0);function L_(e,t){let a;const n=[],i=t.length;for(let r=0;r<i;r++){const i=t[r];if(126!==i.marker)continue;if(-1===i.end)continue;const o=t[i.end];a=e.tokens[i.token],a.type="s_open",a.tag="s",a.nesting=1,a.markup="~~",a.content="",a=e.tokens[o.token],a.type="s_close",a.tag="s",a.nesting=-1,a.markup="~~",a.content="","text"===e.tokens[o.token-1].type&&"~"===e.tokens[o.token-1].content&&n.push(o.token-1)}for(;n.length;){const t=n.pop();let i=t+1;for(;i<e.tokens.length&&"s_close"===e.tokens[i].type;)i++;i--,t!==i&&(a=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=a)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(e){R_[e.charCodeAt(0)]=1}));var F_={tokenize:function(e,t){const a=e.pos,n=e.src.charCodeAt(a);if(t)return!1;if(126!==n)return!1;const i=e.scanDelims(e.pos,!0);let r=i.length;const o=String.fromCharCode(n);if(r<2)return!1;let s;r%2&&(s=e.push("text","",0),s.content=o,r--);for(let t=0;t<r;t+=2)s=e.push("text","",0),s.content=o+o,e.delimiters.push({marker:n,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0},postProcess:function(e){const t=e.tokens_meta,a=e.tokens_meta.length;L_(e,e.delimiters);for(let n=0;n<a;n++)t[n]&&t[n].delimiters&&L_(e,t[n].delimiters)}};function B_(e,t){for(let a=t.length-1;a>=0;a--){const n=t[a];if(95!==n.marker&&42!==n.marker)continue;if(-1===n.end)continue;const i=t[n.end],r=a>0&&t[a-1].end===n.end+1&&t[a-1].marker===n.marker&&t[a-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=r?"strong_open":"em_open",s.tag=r?"strong":"em",s.nesting=1,s.markup=r?o+o:o,s.content="";const l=e.tokens[i.token];l.type=r?"strong_close":"em_close",l.tag=r?"strong":"em",l.nesting=-1,l.markup=r?o+o:o,l.content="",r&&(e.tokens[t[a-1].token].content="",e.tokens[t[n.end+1].token].content="",a--)}}var H_={tokenize:function(e,t){const a=e.pos,n=e.src.charCodeAt(a);if(t)return!1;if(95!==n&&42!==n)return!1;const i=e.scanDelims(e.pos,42===n);for(let t=0;t<i.length;t++){e.push("text","",0).content=String.fromCharCode(n),e.delimiters.push({marker:n,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0},postProcess:function(e){const t=e.tokens_meta,a=e.tokens_meta.length;B_(e,e.delimiters);for(let n=0;n<a;n++)t[n]&&t[n].delimiters&&B_(e,t[n].delimiters)}};const q_=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,U_=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;const W_=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,V_=/^&([a-z][a-z0-9]{1,31});/i;function $_(e){const t={},a=e.length;if(!a)return;let n=0,i=-2;const r=[];for(let o=0;o<a;o++){const a=e[o];if(r.push(0),e[n].marker===a.marker&&i===a.token-1||(n=o),i=a.token,a.length=a.length||0,!a.close)continue;t.hasOwnProperty(a.marker)||(t[a.marker]=[-1,-1,-1,-1,-1,-1]);const s=t[a.marker][(a.open?3:0)+a.length%3];let l=n-r[n]-1,c=l;for(;l>s;l-=r[l]+1){const t=e[l];if(t.marker===a.marker&&(t.open&&t.end<0)){let n=!1;if((t.close||a.open)&&(t.length+a.length)%3==0&&(t.length%3==0&&a.length%3==0||(n=!0)),!n){const n=l>0&&!e[l-1].open?r[l-1]+1:0;r[o]=o-l+n,r[l]=n,a.open=!1,t.end=o,t.close=!1,c=-1,i=-2;break}}}-1!==c&&(t[a.marker][(a.open?3:0)+(a.length||0)%3]=c)}}const G_=[["text",function(e,t){let a=e.pos;for(;a<e.posMax&&!j_(e.src.charCodeAt(a));)a++;return a!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,a)),e.pos=a,!0)}],["linkify",function(e,t){if(!e.md.options.linkify)return!1;if(e.linkLevel>0)return!1;const a=e.pos;if(a+3>e.posMax)return!1;if(58!==e.src.charCodeAt(a))return!1;if(47!==e.src.charCodeAt(a+1))return!1;if(47!==e.src.charCodeAt(a+2))return!1;const n=e.pending.match(z_);if(!n)return!1;const i=n[1],r=e.md.linkify.matchAtStart(e.src.slice(a-i.length));if(!r)return!1;let o=r.url;if(o.length<=i.length)return!1;o=o.replace(/\*+$/,"");const s=e.md.normalizeLink(o);if(!e.md.validateLink(s))return!1;if(!t){e.pending=e.pending.slice(0,-i.length);const t=e.push("link_open","a",1);t.attrs=[["href",s]],t.markup="linkify",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(o);const a=e.push("link_close","a",-1);a.markup="linkify",a.info="auto"}return e.pos+=o.length-i.length,!0}],["newline",function(e,t){let a=e.pos;if(10!==e.src.charCodeAt(a))return!1;const n=e.pending.length-1,i=e.posMax;if(!t)if(n>=0&&32===e.pending.charCodeAt(n))if(n>=1&&32===e.pending.charCodeAt(n-1)){let t=n-1;for(;t>=1&&32===e.pending.charCodeAt(t-1);)t--;e.pending=e.pending.slice(0,t),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(a++;a<i&&VE(e.src.charCodeAt(a));)a++;return e.pos=a,!0}],["escape",function(e,t){let a=e.pos;const n=e.posMax;if(92!==e.src.charCodeAt(a))return!1;if(a++,a>=n)return!1;let i=e.src.charCodeAt(a);if(10===i){for(t||e.push("hardbreak","br",0),a++;a<n&&(i=e.src.charCodeAt(a),VE(i));)a++;return e.pos=a,!0}let r=e.src[a];if(i>=55296&&i<=56319&&a+1<n){const t=e.src.charCodeAt(a+1);t>=56320&&t<=57343&&(r+=e.src[a+1],a++)}const o="\\"+r;if(!t){const t=e.push("text_special","",0);i<256&&0!==R_[i]?t.content=r:t.content=o,t.markup=o,t.info="escape"}return e.pos=a+1,!0}],["backticks",function(e,t){let a=e.pos;if(96!==e.src.charCodeAt(a))return!1;const n=a;a++;const i=e.posMax;for(;a<i&&96===e.src.charCodeAt(a);)a++;const r=e.src.slice(n,a),o=r.length;if(e.backticksScanned&&(e.backticks[o]||0)<=n)return t||(e.pending+=r),e.pos+=o,!0;let s,l=a;for(;-1!==(s=e.src.indexOf("`",l));){for(l=s+1;l<i&&96===e.src.charCodeAt(l);)l++;const n=l-s;if(n===o){if(!t){const t=e.push("code_inline","code",0);t.markup=r,t.content=e.src.slice(a,s).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return e.pos=l,!0}e.backticks[n]=s}return e.backticksScanned=!0,t||(e.pending+=r),e.pos+=o,!0}],["strikethrough",F_.tokenize],["emphasis",H_.tokenize],["link",function(e,t){let a,n,i,r,o="",s="",l=e.pos,c=!0;if(91!==e.src.charCodeAt(e.pos))return!1;const u=e.pos,d=e.posMax,m=e.pos+1,h=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(h<0)return!1;let p=h+1;if(p<d&&40===e.src.charCodeAt(p)){for(c=!1,p++;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);if(p>=d)return!1;if(l=p,i=e.md.helpers.parseLinkDestination(e.src,p,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?p=i.pos:o="",l=p;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);if(i=e.md.helpers.parseLinkTitle(e.src,p,e.posMax),p<d&&l!==p&&i.ok)for(s=i.str,p=i.pos;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);}(p>=d||41!==e.src.charCodeAt(p))&&(c=!0),p++}if(c){if(void 0===e.env.references)return!1;if(p<d&&91===e.src.charCodeAt(p)?(l=p+1,p=e.md.helpers.parseLinkLabel(e,p),p>=0?n=e.src.slice(l,p++):p=h+1):p=h+1,n||(n=e.src.slice(m,h)),r=e.env.references[ZE(n)],!r)return e.pos=u,!1;o=r.href,s=r.title}if(!t){e.pos=m,e.posMax=h;const t=[["href",o]];e.push("link_open","a",1).attrs=t,s&&t.push(["title",s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=p,e.posMax=d,!0}],["image",function(e,t){let a,n,i,r,o,s,l,c,u="";const d=e.pos,m=e.posMax;if(33!==e.src.charCodeAt(e.pos))return!1;if(91!==e.src.charCodeAt(e.pos+1))return!1;const h=e.pos+2,p=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(p<0)return!1;if(r=p+1,r<m&&40===e.src.charCodeAt(r)){for(r++;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);if(r>=m)return!1;for(c=r,s=e.md.helpers.parseLinkDestination(e.src,r,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?r=s.pos:u=""),c=r;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);if(s=e.md.helpers.parseLinkTitle(e.src,r,e.posMax),r<m&&c!==r&&s.ok)for(l=s.str,r=s.pos;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);else l="";if(r>=m||41!==e.src.charCodeAt(r))return e.pos=d,!1;r++}else{if(void 0===e.env.references)return!1;if(r<m&&91===e.src.charCodeAt(r)?(c=r+1,r=e.md.helpers.parseLinkLabel(e,r),r>=0?i=e.src.slice(c,r++):r=p+1):r=p+1,i||(i=e.src.slice(h,p)),o=e.env.references[ZE(i)],!o)return e.pos=d,!1;u=o.href,l=o.title}if(!t){n=e.src.slice(h,p);const t=[];e.md.inline.parse(n,e.md,e.env,t);const a=e.push("image","img",0),i=[["src",u],["alt",""]];a.attrs=i,a.children=t,a.content=n,l&&i.push(["title",l])}return e.pos=r,e.posMax=m,!0}],["autolink",function(e,t){let a=e.pos;if(60!==e.src.charCodeAt(a))return!1;const n=e.pos,i=e.posMax;for(;;){if(++a>=i)return!1;const t=e.src.charCodeAt(a);if(60===t)return!1;if(62===t)break}const r=e.src.slice(n+1,a);if(U_.test(r)){const a=e.md.normalizeLink(r);if(!e.md.validateLink(a))return!1;if(!t){const t=e.push("link_open","a",1);t.attrs=[["href",a]],t.markup="autolink",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(r);const n=e.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return e.pos+=r.length+2,!0}if(q_.test(r)){const a=e.md.normalizeLink("mailto:"+r);if(!e.md.validateLink(a))return!1;if(!t){const t=e.push("link_open","a",1);t.attrs=[["href",a]],t.markup="autolink",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(r);const n=e.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return e.pos+=r.length+2,!0}return!1}],["html_inline",function(e,t){if(!e.md.options.html)return!1;const a=e.posMax,n=e.pos;if(60!==e.src.charCodeAt(n)||n+2>=a)return!1;const i=e.src.charCodeAt(n+1);if(33!==i&&63!==i&&47!==i&&!function(e){const t=32|e;return t>=97&&t<=122}(i))return!1;const r=e.src.slice(n).match(P_);if(!r)return!1;if(!t){const t=e.push("html_inline","",0);t.content=r[0],function(e){return/^<a[>\s]/i.test(e)}(t.content)&&e.linkLevel++,function(e){return/^<\/a\s*>/i.test(e)}(t.content)&&e.linkLevel--}return e.pos+=r[0].length,!0}],["entity",function(e,t){const a=e.pos,n=e.posMax;if(38!==e.src.charCodeAt(a))return!1;if(a+1>=n)return!1;if(35===e.src.charCodeAt(a+1)){const n=e.src.slice(a).match(W_);if(n){if(!t){const t="x"===n[1][0].toLowerCase()?parseInt(n[1].slice(1),16):parseInt(n[1],10),a=e.push("text_special","",0);a.content=IE(t)?NE(t):NE(65533),a.markup=n[0],a.info="entity"}return e.pos+=n[0].length,!0}}else{const n=e.src.slice(a).match(V_);if(n){const a=TE(n[0]);if(a!==n[0]){if(!t){const t=e.push("text_special","",0);t.content=a,t.markup=n[0],t.info="entity"}return e.pos+=n[0].length,!0}}}return!1}]],K_=[["balance_pairs",function(e){const t=e.tokens_meta,a=e.tokens_meta.length;$_(e.delimiters);for(let e=0;e<a;e++)t[e]&&t[e].delimiters&&$_(t[e].delimiters)}],["strikethrough",F_.postProcess],["emphasis",H_.postProcess],["fragments_join",function(e){let t,a,n=0;const i=e.tokens,r=e.tokens.length;for(t=a=0;t<r;t++)i[t].nesting<0&&n--,i[t].level=n,i[t].nesting>0&&n++,"text"===i[t].type&&t+1<r&&"text"===i[t+1].type?i[t+1].content=i[t].content+i[t+1].content:(t!==a&&(i[a]=i[t]),a++);t!==a&&(i.length=a)}]];function Z_(){this.ruler=new t_;for(let e=0;e<G_.length;e++)this.ruler.push(G_[e][0],G_[e][1]);this.ruler2=new t_;for(let e=0;e<K_.length;e++)this.ruler2.push(K_[e][0],K_[e][1])}function Y_(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){t&&Object.keys(t).forEach((function(a){e[a]=t[a]}))})),e}function X_(e){return Object.prototype.toString.call(e)}function Q_(e){return"[object Function]"===X_(e)}function J_(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}Z_.prototype.skipToken=function(e){const t=e.pos,a=this.ruler.getRules(""),n=a.length,i=e.md.options.maxNesting,r=e.cache;if(void 0!==r[t])return void(e.pos=r[t]);let o=!1;if(e.level<i){for(let i=0;i<n;i++)if(e.level++,o=a[i](e,!0),e.level--,o){if(t>=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;o||e.pos++,r[t]=e.pos},Z_.prototype.tokenize=function(e){const t=this.ruler.getRules(""),a=t.length,n=e.posMax,i=e.md.options.maxNesting;for(;e.pos<n;){const r=e.pos;let o=!1;if(e.level<i)for(let n=0;n<a;n++)if(o=t[n](e,!1),o){if(r>=e.pos)throw new Error("inline rule didn't increment state.pos");break}if(o){if(e.pos>=n)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},Z_.prototype.parse=function(e,t,a,n){const i=new this.State(e,t,a,n);this.tokenize(i);const r=this.ruler2.getRules(""),o=r.length;for(let e=0;e<o;e++)r[e](i)},Z_.prototype.State=N_;const eC={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};const tC={"http:":{validate:function(e,t,a){const n=e.slice(t);return a.re.http||(a.re.http=new RegExp("^\\/\\/"+a.re.src_auth+a.re.src_host_port_strict+a.re.src_path,"i")),a.re.http.test(n)?n.match(a.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,a){const n=e.slice(t);return a.re.no_http||(a.re.no_http=new RegExp("^"+a.re.src_auth+"(?:localhost|(?:(?:"+a.re.src_domain+")\\.)+"+a.re.src_domain_root+")"+a.re.src_port+a.re.src_host_terminator+a.re.src_path,"i")),a.re.no_http.test(n)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:n.match(a.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,a){const n=e.slice(t);return a.re.mailto||(a.re.mailto=new RegExp("^"+a.re.src_email_name+"@"+a.re.src_host_strict,"i")),a.re.mailto.test(n)?n.match(a.re.mailto)[0].length:0}}},aC="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",nC="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function iC(e){const t=e.re=function(e){const t={};e=e||{},t.src_Any=sE.source,t.src_Cc=lE.source,t.src_Z=dE.source,t.src_P=cE.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");const a="[><|]";return t.src_pseudo_letter="(?:(?![><|]|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|[><|]|"+t.src_ZPCc+")(?!"+(e["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+a+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]|$)|"+(e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+"|$)|;(?!"+t.src_ZCc+"|$)|\\!+(?!"+t.src_ZCc+"|[!]|$)|\\?(?!"+t.src_ZCc+"|[?]|$))+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy='(^|[><|]|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}(e.__opts__),a=e.__tlds__.slice();function n(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||a.push(aC),a.push(t.src_xn),t.src_tlds=a.join("|"),t.email_fuzzy=RegExp(n(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(n(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(n(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(n(t.tpl_host_fuzzy_test),"i");const i=[];function r(e,t){throw new Error('(LinkifyIt) Invalid schema "'+e+'": '+t)}e.__compiled__={},Object.keys(e.__schemas__).forEach((function(t){const a=e.__schemas__[t];if(null===a)return;const n={validate:null,link:null};if(e.__compiled__[t]=n,function(e){return"[object Object]"===X_(e)}(a))return!function(e){return"[object RegExp]"===X_(e)}(a.validate)?Q_(a.validate)?n.validate=a.validate:r(t,a):n.validate=function(e){return function(t,a){const n=t.slice(a);return e.test(n)?n.match(e)[0].length:0}}(a.validate),void(Q_(a.normalize)?n.normalize=a.normalize:a.normalize?r(t,a):n.normalize=function(e,t){t.normalize(e)});!function(e){return"[object String]"===X_(e)}(a)?r(t,a):i.push(t)})),i.forEach((function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)})),e.__compiled__[""]={validate:null,normalize:function(e,t){t.normalize(e)}};const o=Object.keys(e.__compiled__).filter((function(t){return t.length>0&&e.__compiled__[t]})).map(J_).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+o+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+o+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),function(e){e.__index__=-1,e.__text_cache__=""}(e)}function rC(e,t){const a=e.__index__,n=e.__last_index__,i=e.__text_cache__.slice(a,n);this.schema=e.__schema__.toLowerCase(),this.index=a+t,this.lastIndex=n+t,this.raw=i,this.text=i,this.url=i}function oC(e,t){const a=new rC(e,t);return e.__compiled__[a.schema].normalize(a,e),a}function sC(e,t){if(!(this instanceof sC))return new sC(e,t);t||function(e){return Object.keys(e||{}).reduce((function(e,t){return e||eC.hasOwnProperty(t)}),!1)}(e)&&(t=e,e={}),this.__opts__=Y_({},eC,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=Y_({},tC,e),this.__compiled__={},this.__tlds__=nC,this.__tlds_replaced__=!1,this.re={},iC(this)}sC.prototype.add=function(e,t){return this.__schemas__[e]=t,iC(this),this},sC.prototype.set=function(e){return this.__opts__=Y_(this.__opts__,e),this},sC.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,a,n,i,r,o,s,l,c;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;null!==(t=s.exec(e));)if(i=this.testSchemaAt(e,t[2],s.lastIndex),i){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=e.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l<this.__index__)&&null!==(a=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(r=a.index+a[1].length,(this.__index__<0||r<this.__index__)&&(this.__schema__="",this.__index__=r,this.__last_index__=a.index+a[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(c=e.indexOf("@"),c>=0&&null!==(n=e.match(this.re.email_fuzzy))&&(r=n.index+n[1].length,o=n.index+n[0].length,(this.__index__<0||r<this.__index__||r===this.__index__&&o>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=r,this.__last_index__=o))),this.__index__>=0},sC.prototype.pretest=function(e){return this.re.pretest.test(e)},sC.prototype.testSchemaAt=function(e,t,a){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,a,this):0},sC.prototype.match=function(e){const t=[];let a=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(oC(this,a)),a=this.__last_index__);let n=a?e.slice(a):e;for(;this.test(n);)t.push(oC(this,a)),n=n.slice(this.__last_index__),a+=this.__last_index__;return t.length?t:null},sC.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const t=this.re.schema_at_start.exec(e);if(!t)return null;const a=this.testSchemaAt(e,t[2],t[0].length);return a?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+a,oC(this,0)):null},sC.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter((function(e,t,a){return e!==a[t-1]})).reverse(),iC(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,iC(this),this)},sC.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},sC.prototype.onCompile=function(){};const lC=2147483647,cC=36,uC=/^xn--/,dC=/[^\0-\x7F]/,mC=/[\x2E\u3002\uFF0E\uFF61]/g,hC={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pC=Math.floor,gC=String.fromCharCode;function fC(e){throw new RangeError(hC[e])}function yC(e,t){const a=e.split("@");let n="";a.length>1&&(n=a[0]+"@",e=a[1]);const i=function(e,t){const a=[];let n=e.length;for(;n--;)a[n]=t(e[n]);return a}((e=e.replace(mC,".")).split("."),t).join(".");return n+i}function bC(e){const t=[];let a=0;const n=e.length;for(;a<n;){const i=e.charCodeAt(a++);if(i>=55296&&i<=56319&&a<n){const n=e.charCodeAt(a++);56320==(64512&n)?t.push(((1023&i)<<10)+(1023&n)+65536):(t.push(i),a--)}else t.push(i)}return t}const vC=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},wC=function(e,t,a){let n=0;for(e=a?pC(e/700):e>>1,e+=pC(e/t);e>455;n+=cC)e=pC(e/35);return pC(n+36*e/(e+38))},xC=function(e){const t=[],a=e.length;let n=0,i=128,r=72,o=e.lastIndexOf("-");o<0&&(o=0);for(let a=0;a<o;++a)e.charCodeAt(a)>=128&&fC("not-basic"),t.push(e.charCodeAt(a));for(let l=o>0?o+1:0;l<a;){const o=n;for(let t=1,i=cC;;i+=cC){l>=a&&fC("invalid-input");const o=(s=e.charCodeAt(l++))>=48&&s<58?s-48+26:s>=65&&s<91?s-65:s>=97&&s<123?s-97:cC;o>=cC&&fC("invalid-input"),o>pC((lC-n)/t)&&fC("overflow"),n+=o*t;const c=i<=r?1:i>=r+26?26:i-r;if(o<c)break;const u=cC-c;t>pC(lC/u)&&fC("overflow"),t*=u}const c=t.length+1;r=wC(n-o,c,0==o),pC(n/c)>lC-i&&fC("overflow"),i+=pC(n/c),n%=c,t.splice(n++,0,i)}var s;return String.fromCodePoint(...t)},kC=function(e){const t=[],a=(e=bC(e)).length;let n=128,i=0,r=72;for(const a of e)a<128&&t.push(gC(a));const o=t.length;let s=o;for(o&&t.push("-");s<a;){let a=lC;for(const t of e)t>=n&&t<a&&(a=t);const l=s+1;a-n>pC((lC-i)/l)&&fC("overflow"),i+=(a-n)*l,n=a;for(const a of e)if(a<n&&++i>lC&&fC("overflow"),a===n){let e=i;for(let a=cC;;a+=cC){const n=a<=r?1:a>=r+26?26:a-r;if(e<n)break;const i=e-n,o=cC-n;t.push(gC(vC(n+i%o,0))),e=pC(i/o)}t.push(gC(vC(e,0))),r=wC(i,l,s===o),i=0,++s}++i,++n}return t.join("")},AC={version:"2.3.1",ucs2:{decode:bC,encode:e=>String.fromCodePoint(...e)},decode:xC,encode:kC,toASCII:function(e){return yC(e,(function(e){return dC.test(e)?"xn--"+kC(e):e}))},toUnicode:function(e){return yC(e,(function(e){return uC.test(e)?xC(e.slice(4).toLowerCase()):e}))}};const SC={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}},EC=/^(vbscript|javascript|file|data):/,_C=/^data:image\/(gif|png|jpeg|webp);/;function CC(e){const t=e.trim().toLowerCase();return!EC.test(t)||_C.test(t)}const TC=["http:","https:","mailto:"];function PC(e){const t=iE(e,!0);if(t.hostname&&(!t.protocol||TC.indexOf(t.protocol)>=0))try{t.hostname=AC.toASCII(t.hostname)}catch(e){}return WS(VS(t))}function OC(e){const t=iE(e,!0);if(t.hostname&&(!t.protocol||TC.indexOf(t.protocol)>=0))try{t.hostname=AC.toUnicode(t.hostname)}catch(e){}return qS(VS(t),qS.defaultChars+"%")}function DC(e,t){if(!(this instanceof DC))return new DC(e,t);t||PE(e)||(t=e||{},e="default"),this.inline=new Z_,this.block=new I_,this.core=new x_,this.renderer=new e_,this.linkify=new sC,this.validateLink=CC,this.normalizeLink=PC,this.normalizeLinkText=OC,this.utils=XE,this.helpers=DE({},QE),this.options={},this.configure(e),t&&this.set(t)}DC.prototype.set=function(e){return DE(this.options,e),this},DC.prototype.configure=function(e){const t=this;if(PE(e)){const t=e;if(!(e=SC[t]))throw new Error('Wrong `markdown-it` preset "'+t+'", check name')}if(!e)throw new Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach((function(a){e.components[a].rules&&t[a].ruler.enableOnly(e.components[a].rules),e.components[a].rules2&&t[a].ruler2.enableOnly(e.components[a].rules2)})),this},DC.prototype.enable=function(e,t){let a=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){a=a.concat(this[t].ruler.enable(e,!0))}),this),a=a.concat(this.inline.ruler2.enable(e,!0));const n=e.filter((function(e){return a.indexOf(e)<0}));if(n.length&&!t)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this},DC.prototype.disable=function(e,t){let a=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){a=a.concat(this[t].ruler.disable(e,!0))}),this),a=a.concat(this.inline.ruler2.disable(e,!0));const n=e.filter((function(e){return a.indexOf(e)<0}));if(n.length&&!t)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this},DC.prototype.use=function(e){const t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},DC.prototype.parse=function(e,t){if("string"!=typeof e)throw new Error("Input data should be a String");const a=new this.core.State(e,this,t);return this.core.process(a),a.tokens},DC.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},DC.prototype.parseInline=function(e,t){const a=new this.core.State(e,this,t);return a.inlineMode=!0,this.core.process(a),a.tokens},DC.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var MC=Object.defineProperty,IC=Object.defineProperties,NC=Object.getOwnPropertyDescriptor,jC=Object.getOwnPropertyDescriptors,zC=Object.getOwnPropertyNames,RC=Object.getOwnPropertySymbols,LC=Object.prototype.hasOwnProperty,FC=Object.prototype.propertyIsEnumerable,BC=(e,t,a)=>t in e?MC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,HC=(e,t)=>{for(var a in t||(t={}))LC.call(t,a)&&BC(e,a,t[a]);if(RC)for(var a of RC(t))FC.call(t,a)&&BC(e,a,t[a]);return e},qC=(e,t)=>IC(e,jC(t)),UC={};((e,t)=>{for(var a in t)MC(e,a,{get:t[a],enumerable:!0})})(UC,{default:()=>XC});var WC,VC=(WC=UC,((e,t,a,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of zC(t))LC.call(e,i)||i===a||MC(e,i,{get:()=>t[i],enumerable:!(n=NC(t,i))||n.enumerable});return e})(MC({},"__esModule",{value:!0}),WC));function $C(e,t,a,n,i){try{return t.highlight(n,{language:""!==i?i:"plaintext",ignoreIllegals:a}).value}catch(t){return e.utils.escapeHtml(n)}}function GC(e,t,a,n,i){if(""!==i)return $C(e,t,a,n,i);try{return t.highlightAuto(n).value}catch(t){return e.utils.escapeHtml(n)}}function KC(e){return function(...t){return e(...t).replace('<code class="','<code class="hljs ').replace("<code>",'<code class="hljs">')}}function ZC(e){var t,a;for(const n of e.tokens)if("inline"===n.type&&null!=n.children)for(const[i,r]of n.children.entries()){if("code_inline"!==r.type)continue;const o=n.children[i+1];if(null==o)continue;const s=/^{:?\.([^}]+)}/.exec(o.content);if(null==s)continue;const l=s[1];o.content=o.content.slice(s[0].length);let c=null!=(t=r.attrGet("class"))?t:"";c+=`${null!=(a=e.md.options.langPrefix)?a:"language-"}${l}`,r.attrSet("class",c),r.meta=qC(HC({},r.meta),{highlightLanguage:l})}}function YC(e,t,a,n,i){var r,o;const s=e[t];if(null==a.highlight)throw new Error("`options.highlight` was null, this is not supposed to happen");const l=a.highlight(s.content,null!=(o=null==(r=s.meta)?void 0:r.highlightLanguage)?o:"","");return`<code${i.renderAttrs(s)}>${l}</code>`}function XC(e,t){const a=HC(HC({},XC.defaults),t);if(null==a.hljs)throw new Error("Please pass a highlight.js instance for the required `hljs` option.");null!=a.register&&function(e,t){for(const[a,n]of Object.entries(t))e.registerLanguage(a,n)}(a.hljs,a.register),e.options.highlight=(a.auto?GC:$C).bind(null,e,a.hljs,a.ignoreIllegals),null!=e.renderer.rules.fence&&(e.renderer.rules.fence=KC(e.renderer.rules.fence)),a.code&&null!=e.renderer.rules.code_block&&(e.renderer.rules.code_block=KC(e.renderer.rules.code_block)),a.inline&&(e.core.ruler.before("linkify","inline_code_language",ZC),e.renderer.rules.code_inline=KC(YC))}XC.defaults={auto:!1,code:!1,inline:!1,ignoreIllegals:!1};var QC=Gt(VC.default);function JC(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const a=e[t],n=typeof a;"object"!==n&&"function"!==n||Object.isFrozen(a)||JC(a)})),e}let eT=class{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function tT(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function aT(e,...t){const a=Object.create(null);for(const t in e)a[t]=e[t];return t.forEach((function(e){for(const t in e)a[t]=e[t]})),a}const nT=e=>!!e.scope;class iT{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=tT(e)}openNode(e){if(!nT(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const a=e.split(".");return[`${t}${a.shift()}`,...a.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){nT(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const rT=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class oT{constructor(){this.rootNode=rT(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=rT({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{oT._collapse(e)})))}}class sT extends oT{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const a=e.root;t&&(a.scope=`language:${t}`),this.add(a)}toHTML(){return new iT(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function lT(e){return e?"string"==typeof e?e:e.source:null}function cT(e){return mT("(?=",e,")")}function uT(e){return mT("(?:",e,")*")}function dT(e){return mT("(?:",e,")?")}function mT(...e){const t=e.map((e=>lT(e))).join("");return t}function hT(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e),a="("+(t.capture?"":"?:")+e.map((e=>lT(e))).join("|")+")";return a}function pT(e){return new RegExp(e.toString()+"|").exec("").length-1}const gT=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function fT(e,{joinWith:t}){let a=0;return e.map((e=>{a+=1;const t=a;let n=lT(e),i="";for(;n.length>0;){const e=gT.exec(n);if(!e){i+=n;break}i+=n.substring(0,e.index),n=n.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&a++)}return i})).map((e=>`(${e})`)).join(t)}const yT="[a-zA-Z]\\w*",bT="[a-zA-Z_]\\w*",vT="\\b\\d+(\\.\\d+)?",wT="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",xT="\\b(0b[01]+)",kT={begin:"\\\\[\\s\\S]",relevance:0},AT={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[kT]},ST={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[kT]},ET=function(e,t,a={}){const n=aT({scope:"comment",begin:e,end:t,contains:[]},a);n.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=hT("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return n.contains.push({begin:mT(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),n},_T=ET("//","$"),CT=ET("/\\*","\\*/"),TT=ET("#","$"),PT={scope:"number",begin:vT,relevance:0},OT={scope:"number",begin:wT,relevance:0},DT={scope:"number",begin:xT,relevance:0},MT={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[kT,{begin:/\[/,end:/\]/,relevance:0,contains:[kT]}]},IT={scope:"title",begin:yT,relevance:0},NT={scope:"title",begin:bT,relevance:0},jT={begin:"\\.\\s*"+bT,relevance:0};var zT=Object.freeze({__proto__:null,APOS_STRING_MODE:AT,BACKSLASH_ESCAPE:kT,BINARY_NUMBER_MODE:DT,BINARY_NUMBER_RE:xT,COMMENT:ET,C_BLOCK_COMMENT_MODE:CT,C_LINE_COMMENT_MODE:_T,C_NUMBER_MODE:OT,C_NUMBER_RE:wT,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:TT,IDENT_RE:yT,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:jT,NUMBER_MODE:PT,NUMBER_RE:vT,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:ST,REGEXP_MODE:MT,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=mT(t,/.*\b/,e.binary,/\b.*/)),aT({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:IT,UNDERSCORE_IDENT_RE:bT,UNDERSCORE_TITLE_MODE:NT});function RT(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function LT(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function FT(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=RT,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function BT(e,t){Array.isArray(e.illegal)&&(e.illegal=hT(...e.illegal))}function HT(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function qT(e,t){void 0===e.relevance&&(e.relevance=1)}const UT=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const a=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=a.keywords,e.begin=mT(a.beforeMatch,cT(a.begin)),e.starts={relevance:0,contains:[Object.assign(a,{endsParent:!0})]},e.relevance=0,delete a.beforeMatch},WT=["of","and","for","in","not","or","if","then","parent","list","value"],VT="keyword";function $T(e,t,a=VT){const n=Object.create(null);return"string"==typeof e?i(a,e.split(" ")):Array.isArray(e)?i(a,e):Object.keys(e).forEach((function(a){Object.assign(n,$T(e[a],t,a))})),n;function i(e,a){t&&(a=a.map((e=>e.toLowerCase()))),a.forEach((function(t){const a=t.split("|");n[a[0]]=[e,GT(a[0],a[1])]}))}}function GT(e,t){return t?Number(t):function(e){return WT.includes(e.toLowerCase())}(e)?0:1}const KT={},ZT=e=>{console.error(e)},YT=(e,...t)=>{console.log(`WARN: ${e}`,...t)},XT=(e,t)=>{KT[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),KT[`${e}/${t}`]=!0)},QT=new Error;function JT(e,t,{key:a}){let n=0;const i=e[a],r={},o={};for(let e=1;e<=t.length;e++)o[e+n]=i[e],r[e+n]=!0,n+=pT(t[e-1]);e[a]=o,e[a]._emit=r,e[a]._multi=!0}function eP(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ZT("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),QT;if("object"!=typeof e.beginScope||null===e.beginScope)throw ZT("beginScope must be object"),QT;JT(e,e.begin,{key:"beginScope"}),e.begin=fT(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ZT("skip, excludeEnd, returnEnd not compatible with endScope: {}"),QT;if("object"!=typeof e.endScope||null===e.endScope)throw ZT("endScope must be object"),QT;JT(e,e.end,{key:"endScope"}),e.end=fT(e.end,{joinWith:""})}}(e)}function tP(e){function t(t,a){return new RegExp(lT(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(a?"g":""))}class a{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=pT(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(fT(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const a=t.findIndex(((e,t)=>t>0&&void 0!==e)),n=this.matchIndexes[a];return t.splice(0,a),Object.assign(t,n)}}class n{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new a;return this.rules.slice(e).forEach((([e,a])=>t.addRule(e,a))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let a=t.exec(e);if(this.resumingScanAtSamePosition())if(a&&a.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,a=t.exec(e)}return a&&(this.regexIndex+=a.position+1,this.regexIndex===this.count&&this.considerAll()),a}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=aT(e.classNameAliases||{}),function a(i,r){const o=i;if(i.isCompiled)return o;[LT,HT,eP,UT].forEach((e=>e(i,r))),e.compilerExtensions.forEach((e=>e(i,r))),i.__beforeBegin=null,[FT,BT,qT].forEach((e=>e(i,r))),i.isCompiled=!0;let s=null;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),s=i.keywords.$pattern,delete i.keywords.$pattern),s=s||/\w+/,i.keywords&&(i.keywords=$T(i.keywords,e.case_insensitive)),o.keywordPatternRe=t(s,!0),r&&(i.begin||(i.begin=/\B|\b/),o.beginRe=t(o.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(o.endRe=t(o.end)),o.terminatorEnd=lT(o.end)||"",i.endsWithParent&&r.terminatorEnd&&(o.terminatorEnd+=(i.end?"|":"")+r.terminatorEnd)),i.illegal&&(o.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map((function(e){return function(e){e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return aT(e,{variants:null},t)})));if(e.cachedVariants)return e.cachedVariants;if(aP(e))return aT(e,{starts:e.starts?aT(e.starts):null});if(Object.isFrozen(e))return aT(e);return e}("self"===e?i:e)}))),i.contains.forEach((function(e){a(e,o)})),i.starts&&a(i.starts,r),o.matcher=function(e){const t=new n;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(o),o}(e)}function aP(e){return!!e&&(e.endsWithParent||aP(e.starts))}class nP extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const iP=tT,rP=aT,oP=Symbol("nomatch"),sP=function(e){const t=Object.create(null),a=Object.create(null),n=[];let i=!0;const r="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let s={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:sT};function l(e){return s.noHighlightRe.test(e)}function c(e,t,a){let n="",i="";"object"==typeof t?(n=e,a=t.ignoreIllegals,i=t.language):(XT("10.7.0","highlight(lang, code, ...args) has been deprecated."),XT("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),i=e,n=t),void 0===a&&(a=!0);const r={code:n,language:i};b("before:highlight",r);const o=r.result?r.result:u(r.language,r.code,a);return o.code=r.code,b("after:highlight",o),o}function u(e,a,n,o){const l=Object.create(null);function c(){if(!E.keywords)return void C.addText(T);let e=0;E.keywordPatternRe.lastIndex=0;let t=E.keywordPatternRe.exec(T),a="";for(;t;){a+=T.substring(e,t.index);const i=k.case_insensitive?t[0].toLowerCase():t[0],r=(n=i,E.keywords[n]);if(r){const[e,n]=r;if(C.addText(a),a="",l[i]=(l[i]||0)+1,l[i]<=7&&(P+=n),e.startsWith("_"))a+=t[0];else{const a=k.classNameAliases[e]||e;h(t[0],a)}}else a+=t[0];e=E.keywordPatternRe.lastIndex,t=E.keywordPatternRe.exec(T)}var n;a+=T.substring(e),C.addText(a)}function m(){null!=E.subLanguage?function(){if(""===T)return;let e=null;if("string"==typeof E.subLanguage){if(!t[E.subLanguage])return void C.addText(T);e=u(E.subLanguage,T,!0,_[E.subLanguage]),_[E.subLanguage]=e._top}else e=d(T,E.subLanguage.length?E.subLanguage:null);E.relevance>0&&(P+=e.relevance),C.__addSublanguage(e._emitter,e.language)}():c(),T=""}function h(e,t){""!==e&&(C.startScope(t),C.addText(e),C.endScope())}function p(e,t){let a=1;const n=t.length-1;for(;a<=n;){if(!e._emit[a]){a++;continue}const n=k.classNameAliases[e[a]]||e[a],i=t[a];n?h(i,n):(T=i,c(),T=""),a++}}function f(e,t){return e.scope&&"string"==typeof e.scope&&C.openNode(k.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(h(T,k.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),T=""):e.beginScope._multi&&(p(e.beginScope,t),T="")),E=Object.create(e,{parent:{value:E}}),E}function y(e,t,a){let n=function(e,t){const a=e&&e.exec(t);return a&&0===a.index}(e.endRe,a);if(n){if(e["on:end"]){const a=new eT(e);e["on:end"](t,a),a.isMatchIgnored&&(n=!1)}if(n){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return y(e.parent,t,a)}function b(e){return 0===E.matcher.regexIndex?(T+=e[0],1):(M=!0,0)}function v(e){const t=e[0],n=a.substring(e.index),i=y(E,e,n);if(!i)return oP;const r=E;E.endScope&&E.endScope._wrap?(m(),h(t,E.endScope._wrap)):E.endScope&&E.endScope._multi?(m(),p(E.endScope,e)):r.skip?T+=t:(r.returnEnd||r.excludeEnd||(T+=t),m(),r.excludeEnd&&(T=t));do{E.scope&&C.closeNode(),E.skip||E.subLanguage||(P+=E.relevance),E=E.parent}while(E!==i.parent);return i.starts&&f(i.starts,e),r.returnEnd?0:t.length}let w={};function x(t,r){const o=r&&r[0];if(T+=t,null==o)return m(),0;if("begin"===w.type&&"end"===r.type&&w.index===r.index&&""===o){if(T+=a.slice(r.index,r.index+1),!i){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=r,"begin"===r.type)return function(e){const t=e[0],a=e.rule,n=new eT(a),i=[a.__beforeBegin,a["on:begin"]];for(const a of i)if(a&&(a(e,n),n.isMatchIgnored))return b(t);return a.skip?T+=t:(a.excludeBegin&&(T+=t),m(),a.returnBegin||a.excludeBegin||(T=t)),f(a,e),a.returnBegin?0:t.length}(r);if("illegal"===r.type&&!n){const e=new Error('Illegal lexeme "'+o+'" for mode "'+(E.scope||"<unnamed>")+'"');throw e.mode=E,e}if("end"===r.type){const e=v(r);if(e!==oP)return e}if("illegal"===r.type&&""===o)return 1;if(D>1e5&&D>3*r.index){throw new Error("potential infinite loop, way more iterations than matches")}return T+=o,o.length}const k=g(e);if(!k)throw ZT(r.replace("{}",e)),new Error('Unknown language: "'+e+'"');const A=tP(k);let S="",E=o||A;const _={},C=new s.__emitter(s);!function(){const e=[];for(let t=E;t!==k;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>C.openNode(e)))}();let T="",P=0,O=0,D=0,M=!1;try{if(k.__emitTokens)k.__emitTokens(a,C);else{for(E.matcher.considerAll();;){D++,M?M=!1:E.matcher.considerAll(),E.matcher.lastIndex=O;const e=E.matcher.exec(a);if(!e)break;const t=x(a.substring(O,e.index),e);O=e.index+t}x(a.substring(O))}return C.finalize(),S=C.toHTML(),{language:e,value:S,relevance:P,illegal:!1,_emitter:C,_top:E}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:iP(a),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:O,context:a.slice(O-100,O+100),mode:t.mode,resultSoFar:S},_emitter:C};if(i)return{language:e,value:iP(a),illegal:!1,relevance:0,errorRaised:t,_emitter:C,_top:E};throw t}}function d(e,a){a=a||s.languages||Object.keys(t);const n=function(e){const t={value:iP(e),illegal:!1,relevance:0,_top:o,_emitter:new s.__emitter(s)};return t._emitter.addText(e),t}(e),i=a.filter(g).filter(y).map((t=>u(t,e,!1)));i.unshift(n);const r=i.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(g(e.language).supersetOf===t.language)return 1;if(g(t.language).supersetOf===e.language)return-1}return 0})),[l,c]=r,d=l;return d.secondBest=c,d}function m(e){let t=null;const n=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const a=s.languageDetectRe.exec(t);if(a){const t=g(a[1]);return t||(YT(r.replace("{}",a[1])),YT("Falling back to no-highlight mode for this block.",e)),t?a[1]:"no-highlight"}return t.split(/\s+/).find((e=>l(e)||g(e)))}(e);if(l(n))return;if(b("before:highlightElement",{el:e,language:n}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(s.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),s.throwUnescapedHTML)){throw new nP("One of your code blocks includes unescaped HTML.",e.innerHTML)}t=e;const i=t.textContent,o=n?c(i,{language:n,ignoreIllegals:!0}):d(i);e.innerHTML=o.value,e.dataset.highlighted="yes",function(e,t,n){const i=t&&a[t]||n;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,n,o.language),e.result={language:o.language,re:o.relevance,relevance:o.relevance},o.secondBest&&(e.secondBest={language:o.secondBest.language,relevance:o.secondBest.relevance}),b("after:highlightElement",{el:e,result:o,text:i})}let h=!1;function p(){if("loading"===document.readyState)return void(h=!0);document.querySelectorAll(s.cssSelector).forEach(m)}function g(e){return e=(e||"").toLowerCase(),t[e]||t[a[e]]}function f(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{a[e.toLowerCase()]=t}))}function y(e){const t=g(e);return t&&!t.disableAutodetect}function b(e,t){const a=e;n.forEach((function(e){e[a]&&e[a](t)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){h&&p()}),!1),Object.assign(e,{highlight:c,highlightAuto:d,highlightAll:p,highlightElement:m,highlightBlock:function(e){return XT("10.7.0","highlightBlock will be removed entirely in v12.0"),XT("10.7.0","Please use highlightElement now."),m(e)},configure:function(e){s=rP(s,e)},initHighlighting:()=>{p(),XT("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){p(),XT("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(a,n){let r=null;try{r=n(e)}catch(e){if(ZT("Language definition for '{}' could not be registered.".replace("{}",a)),!i)throw e;ZT(e),r=o}r.name||(r.name=a),t[a]=r,r.rawDefinition=n.bind(null,e),r.aliases&&f(r.aliases,{languageName:a})},unregisterLanguage:function(e){delete t[e];for(const t of Object.keys(a))a[t]===e&&delete a[t]},listLanguages:function(){return Object.keys(t)},getLanguage:g,registerAliases:f,autoDetection:y,inherit:rP,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),n.push(e)},removePlugin:function(e){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}),e.debugMode=function(){i=!1},e.safeMode=function(){i=!0},e.versionString="11.10.0",e.regex={concat:mT,lookahead:cT,either:hT,optional:dT,anyNumberOfTimes:uT};for(const e in zT)"object"==typeof zT[e]&&JC(zT[e]);return Object.assign(e,zT),e},lP=sP({});lP.newInstance=()=>sP({});var cP=lP;lP.HighlightJS=lP,lP.default=lP;var uP=Gt(cP);const dP="[A-Za-z$_][0-9A-Za-z$_]*",mP=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],hP=["true","false","null","undefined","NaN","Infinity"],pP=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],gP=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],fP=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yP=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bP=[].concat(fP,pP,gP);var vP={},wP={},xP={};Object.defineProperty(xP,"__esModule",{value:!0}),xP.default=function(e){var t,a,n=e.match(EP),i=n&&n[1]?n[1].toLowerCase():"";switch(i){case kP:var r=PP(e);if(!_P.test(e))null===(t=null==(s=r.querySelector(AP))?void 0:s.parentNode)||void 0===t||t.removeChild(s);if(!CP.test(e))null===(a=null==(s=r.querySelector(SP))?void 0:s.parentNode)||void 0===a||a.removeChild(s);return r.querySelectorAll(kP);case AP:case SP:var o=TP(e).querySelectorAll(i);return CP.test(e)&&_P.test(e)?o[0].parentNode.childNodes:o;default:return IP?IP(e):(s=TP(e,SP).querySelector(SP)).childNodes;var s}};var kP="html",AP="head",SP="body",EP=/<([a-zA-Z]+[0-9]?)/,_P=/<head[^]*>/i,CP=/<body[^]*>/i,TP=function(e,t){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},PP=function(e,t){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},OP="object"==typeof window&&window.DOMParser;if("function"==typeof OP){var DP=new OP;TP=PP=function(e,t){return t&&(e="<".concat(t,">").concat(e,"</").concat(t,">")),DP.parseFromString(e,"text/html")}}if("object"==typeof document&&document.implementation){var MP=document.implementation.createHTMLDocument();TP=function(e,t){if(t){var a=MP.documentElement.querySelector(t);return a&&(a.innerHTML=e),MP}return MP.documentElement.innerHTML=e,MP}}var IP,NP="object"==typeof document&&document.createElement("template");NP&&NP.content&&(IP=function(e){return NP.innerHTML=e,NP.content.childNodes});var jP,zP,RP={},LP={},FP={};jP=FP,Object.defineProperty(jP,"__esModule",{value:!0}),jP.Doctype=jP.CDATA=jP.Tag=jP.Style=jP.Script=jP.Comment=jP.Directive=jP.Text=jP.Root=jP.isTag=jP.ElementType=void 0,function(e){e.Root="root",e.Text="text",e.Directive="directive",e.Comment="comment",e.Script="script",e.Style="style",e.Tag="tag",e.CDATA="cdata",e.Doctype="doctype"}(zP=jP.ElementType||(jP.ElementType={})),jP.isTag=function(e){return e.type===zP.Tag||e.type===zP.Script||e.type===zP.Style},jP.Root=zP.Root,jP.Text=zP.Text,jP.Directive=zP.Directive,jP.Comment=zP.Comment,jP.Script=zP.Script,jP.Style=zP.Style,jP.Tag=zP.Tag,jP.CDATA=zP.CDATA,jP.Doctype=zP.Doctype;var BP,HP={},qP=$t&&$t.__extends||(BP=function(e,t){return BP=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])},BP(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function a(){this.constructor=e}BP(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}),UP=$t&&$t.__assign||function(){return UP=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var i in t=arguments[a])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},UP.apply(this,arguments)};Object.defineProperty(HP,"__esModule",{value:!0}),HP.cloneNode=HP.hasChildren=HP.isDocument=HP.isDirective=HP.isComment=HP.isText=HP.isCDATA=HP.isTag=HP.Element=HP.Document=HP.CDATA=HP.NodeWithChildren=HP.ProcessingInstruction=HP.Comment=HP.Text=HP.DataNode=HP.Node=void 0;var WP=FP,VP=function(){function e(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(e){return void 0===e&&(e=!1),oO(this,e)},e}();HP.Node=VP;var $P=function(e){function t(t){var a=e.call(this)||this;return a.data=t,a}return qP(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(VP);HP.DataNode=$P;var GP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Text,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),t}($P);HP.Text=GP;var KP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Comment,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),t}($P);HP.Comment=KP;var ZP=function(e){function t(t,a){var n=e.call(this,a)||this;return n.name=t,n.type=WP.ElementType.Directive,n}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),t}($P);HP.ProcessingInstruction=ZP;var YP=function(e){function t(t){var a=e.call(this)||this;return a.children=t,a}return qP(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return null!==(e=this.children[0])&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(VP);HP.NodeWithChildren=YP;var XP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.CDATA,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),t}(YP);HP.CDATA=XP;var QP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Root,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),t}(YP);HP.Document=QP;var JP=function(e){function t(t,a,n,i){void 0===n&&(n=[]),void 0===i&&(i="script"===t?WP.ElementType.Script:"style"===t?WP.ElementType.Style:WP.ElementType.Tag);var r=e.call(this,n)||this;return r.name=t,r.attribs=a,r.type=i,r}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map((function(t){var a,n;return{name:t,value:e.attribs[t],namespace:null===(a=e["x-attribsNamespace"])||void 0===a?void 0:a[t],prefix:null===(n=e["x-attribsPrefix"])||void 0===n?void 0:n[t]}}))},enumerable:!1,configurable:!0}),t}(YP);function eO(e){return(0,WP.isTag)(e)}function tO(e){return e.type===WP.ElementType.CDATA}function aO(e){return e.type===WP.ElementType.Text}function nO(e){return e.type===WP.ElementType.Comment}function iO(e){return e.type===WP.ElementType.Directive}function rO(e){return e.type===WP.ElementType.Root}function oO(e,t){var a;if(void 0===t&&(t=!1),aO(e))a=new GP(e.data);else if(nO(e))a=new KP(e.data);else if(eO(e)){var n=t?sO(e.children):[],i=new JP(e.name,UP({},e.attribs),n);n.forEach((function(e){return e.parent=i})),null!=e.namespace&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]=UP({},e["x-attribsNamespace"])),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]=UP({},e["x-attribsPrefix"])),a=i}else if(tO(e)){n=t?sO(e.children):[];var r=new XP(n);n.forEach((function(e){return e.parent=r})),a=r}else if(rO(e)){n=t?sO(e.children):[];var o=new QP(n);n.forEach((function(e){return e.parent=o})),e["x-mode"]&&(o["x-mode"]=e["x-mode"]),a=o}else{if(!iO(e))throw new Error("Not implemented yet: ".concat(e.type));var s=new ZP(e.name,e.data);null!=e["x-name"]&&(s["x-name"]=e["x-name"],s["x-publicId"]=e["x-publicId"],s["x-systemId"]=e["x-systemId"]),a=s}return a.startIndex=e.startIndex,a.endIndex=e.endIndex,null!=e.sourceCodeLocation&&(a.sourceCodeLocation=e.sourceCodeLocation),a}function sO(e){for(var t=e.map((function(e){return oO(e,!0)})),a=1;a<t.length;a++)t[a].prev=t[a-1],t[a-1].next=t[a];return t}HP.Element=JP,HP.isTag=eO,HP.isCDATA=tO,HP.isText=aO,HP.isComment=nO,HP.isDirective=iO,HP.isDocument=rO,HP.hasChildren=function(e){return Object.prototype.hasOwnProperty.call(e,"children")},HP.cloneNode=oO,function(e){var t=$t&&$t.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var i=Object.getOwnPropertyDescriptor(t,a);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,i)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),a=$t&&$t.__exportStar||function(e,a){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(a,n)||t(a,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var n=FP,i=HP;a(HP,e);var r={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function e(e,t,a){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,"function"==typeof t&&(a=t,t=r),"object"==typeof e&&(t=e,e=void 0),this.callback=null!=e?e:null,this.options=null!=t?t:r,this.elementCB=null!=a?a:null}return e.prototype.onparserinit=function(e){this.parser=e},e.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},e.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},e.prototype.onerror=function(e){this.handleCallback(e)},e.prototype.onclosetag=function(){this.lastNode=null;var e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)},e.prototype.onopentag=function(e,t){var a=this.options.xmlMode?n.ElementType.Tag:void 0,r=new i.Element(e,t,void 0,a);this.addNode(r),this.tagStack.push(r)},e.prototype.ontext=function(e){var t=this.lastNode;if(t&&t.type===n.ElementType.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{var a=new i.Text(e);this.addNode(a),this.lastNode=a}},e.prototype.oncomment=function(e){if(this.lastNode&&this.lastNode.type===n.ElementType.Comment)this.lastNode.data+=e;else{var t=new i.Comment(e);this.addNode(t),this.lastNode=t}},e.prototype.oncommentend=function(){this.lastNode=null},e.prototype.oncdatastart=function(){var e=new i.Text(""),t=new i.CDATA([e]);this.addNode(t),e.parent=t,this.lastNode=e},e.prototype.oncdataend=function(){this.lastNode=null},e.prototype.onprocessinginstruction=function(e,t){var a=new i.ProcessingInstruction(e,t);this.addNode(a)},e.prototype.handleCallback=function(e){if("function"==typeof this.callback)this.callback(e,this.dom);else if(e)throw e},e.prototype.addNode=function(e){var t=this.tagStack[this.tagStack.length-1],a=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),a&&(e.prev=a,a.next=e),e.parent=t,this.lastNode=null},e}();e.DomHandler=o,e.default=o}(LP);var lO={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce((function(e,t){return e[t.toLowerCase()]=t,e}),{})}(lO),Object.defineProperty(RP,"__esModule",{value:!0}),RP.formatAttributes=dO,RP.formatDOM=function e(t,a,n){void 0===a&&(a=null);for(var i,r=[],o=0,s=t.length;o<s;o++){var l=t[o];switch(l.nodeType){case 1:var c=mO(l.nodeName);(i=new cO.Element(c,dO(l.attributes))).children=e("template"===c?l.content.childNodes:l.childNodes,i);break;case 3:i=new cO.Text(l.nodeValue);break;case 8:i=new cO.Comment(l.nodeValue);break;default:continue}var u=r[o-1]||null;u&&(u.next=i),i.parent=a,i.prev=u,i.next=null,r.push(i)}n&&((i=new cO.ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n)).next=r[0]||null,i.parent=a,r.unshift(i),r[1]&&(r[1].prev=r[0]));return r};var cO=LP,uO=lO;function dO(e){for(var t={},a=0,n=e.length;a<n;a++){var i=e[a];t[i.name]=i.value}return t}function mO(e){var t=function(e){return uO.CASE_SENSITIVE_TAG_NAMES_MAP[e]}(e=e.toLowerCase());return t||e}var hO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wP,"__esModule",{value:!0}),wP.default=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];var t=e.match(fO),a=t?t[1]:void 0;return(0,gO.formatDOM)((0,pO.default)(e),null,a)};var pO=hO(xP),gO=RP,fO=/<(![a-zA-Z\s]+)>/;var yO={},bO={},vO={};vO.SAME=0;vO.CAMELCASE=1,vO.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1};function wO(e,t,a,n,i,r,o){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=a,this.propertyName=e,this.type=t,this.sanitizeURL=r,this.removeEmptyString=o}const xO={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach((e=>{xO[e]=new wO(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((([e,t])=>{xO[e]=new wO(e,1,!1,t,null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((e=>{xO[e]=new wO(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((e=>{xO[e]=new wO(e,2,!1,e,null,!1,!1)})),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach((e=>{xO[e]=new wO(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((e=>{xO[e]=new wO(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((e=>{xO[e]=new wO(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((e=>{xO[e]=new wO(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((e=>{xO[e]=new wO(e,5,!1,e.toLowerCase(),null,!1,!1)}));const kO=/[\-\:]([a-z])/g,AO=e=>e[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,null,!1,!1)})),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((e=>{xO[e]=new wO(e,1,!1,e.toLowerCase(),null,!1,!1)}));xO.xlinkHref=new wO("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((e=>{xO[e]=new wO(e,1,!1,e.toLowerCase(),null,!0,!0)}));const{CAMELCASE:SO,SAME:EO,possibleStandardNames:_O}=vO,CO=RegExp.prototype.test.bind(new RegExp("^(data|aria)-[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$")),TO=Object.keys(_O).reduce(((e,t)=>{const a=_O[t];return a===EO?e[t]=t:a===SO?e[t.toLowerCase()]=t:e[t]=a,e}),{});bO.BOOLEAN=3,bO.BOOLEANISH_STRING=2,bO.NUMERIC=5,bO.OVERLOADED_BOOLEAN=4,bO.POSITIVE_NUMERIC=6,bO.RESERVED=0,bO.STRING=1,bO.getPropertyInfo=function(e){return xO.hasOwnProperty(e)?xO[e]:null},bO.isCustomAttribute=CO,bO.possibleStandardNames=TO;var PO={},OO={},DO=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,MO=/\n/g,IO=/^\s*/,NO=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,jO=/^:\s*/,zO=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,RO=/^[;\s]*/,LO=/^\s+|\s+$/g,FO="";function BO(e){return e?e.replace(LO,FO):FO}var HO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(OO,"__esModule",{value:!0});var qO=HO((function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var a=1,n=1;function i(e){var t=e.match(MO);t&&(a+=t.length);var i=e.lastIndexOf("\n");n=~i?e.length-i:n+e.length}function r(){var e={line:a,column:n};return function(t){return t.position=new o(e),c(),t}}function o(e){this.start=e,this.end={line:a,column:n},this.source=t.source}function s(i){var r=new Error(t.source+":"+a+":"+n+": "+i);if(r.reason=i,r.filename=t.source,r.line=a,r.column=n,r.source=e,!t.silent)throw r}function l(t){var a=t.exec(e);if(a){var n=a[0];return i(n),e=e.slice(n.length),a}}function c(){l(IO)}function u(e){var t;for(e=e||[];t=d();)!1!==t&&e.push(t);return e}function d(){var t=r();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var a=2;FO!=e.charAt(a)&&("*"!=e.charAt(a)||"/"!=e.charAt(a+1));)++a;if(a+=2,FO===e.charAt(a-1))return s("End of comment missing");var o=e.slice(2,a-2);return n+=2,i(o),e=e.slice(a),n+=2,t({type:"comment",comment:o})}}function m(){var e=r(),t=l(NO);if(t){if(d(),!l(jO))return s("property missing ':'");var a=l(zO),n=e({type:"declaration",property:BO(t[0].replace(DO,FO)),value:a?BO(a[0].replace(DO,FO)):FO});return l(RO),n}}return o.prototype.content=e,c(),function(){var e,t=[];for(u(t);e=m();)!1!==e&&(t.push(e),u(t));return t}()}));OO.default=function(e,t){var a=null;if(!e||"string"!=typeof e)return a;var n=(0,qO.default)(e),i="function"==typeof t;return n.forEach((function(e){if("declaration"===e.type){var n=e.property,r=e.value;i?t(n,r,e):r&&((a=a||{})[n]=r)}})),a};var UO={};Object.defineProperty(UO,"__esModule",{value:!0}),UO.camelCase=void 0;var WO=/^--[a-zA-Z0-9-]+$/,VO=/-([a-z])/g,$O=/^[^-]+$/,GO=/^-(webkit|moz|ms|o|khtml)-/,KO=/^-(ms)-/,ZO=function(e,t){return t.toUpperCase()},YO=function(e,t){return"".concat(t,"-")};UO.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||$O.test(e)||WO.test(e)}(e)?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(KO,YO):e.replace(GO,YO)).replace(VO,ZO))};var XO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},QO=XO(OO),JO=UO;function eD(e,t){var a={};return e&&"string"==typeof e?((0,QO.default)(e,(function(e,n){e&&n&&(a[(0,JO.camelCase)(e,t)]=n)})),a):a}eD.default=eD;var tD=eD;!function(e){var a=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=function(e,t){if(!e.includes("-"))return Boolean(t&&"string"==typeof t.is);if(r.has(e))return!1;return!0},e.setStyleProp=function(e,t){if("string"!=typeof e)return;if(!e.trim())return void(t.style={});try{t.style=(0,i.default)(e,o)}catch(e){t.style={}}};var n=t,i=a(tD),r=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);var o={reactCompat:!0};e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);e.canTextBeChildOfNode=function(t){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(t.name)};e.returnFirstArg=function(e){return e}}(PO),Object.defineProperty(yO,"__esModule",{value:!0}),yO.default=function(e,t){void 0===e&&(e={});var a={},n=Boolean(e.type&&oD[e.type]);for(var i in e){var r=e[i];if((0,aD.isCustomAttribute)(i))a[i]=r;else{var o=i.toLowerCase(),s=sD(o);if(s){var l=(0,aD.getPropertyInfo)(s);switch(iD.includes(s)&&rD.includes(t)&&!n&&(s=sD("default"+o)),a[s]=r,l&&l.type){case aD.BOOLEAN:a[s]=!0;break;case aD.OVERLOADED_BOOLEAN:""===r&&(a[s]=!0)}}else nD.PRESERVE_CUSTOM_ATTRIBUTES&&(a[i]=r)}}return(0,nD.setStyleProp)(e.style,a),a};var aD=bO,nD=PO,iD=["checked","value"],rD=["input","select","textarea"],oD={reset:!0,submit:!0};function sD(e){return aD.possibleStandardNames[e]}var lD={},cD=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lD,"__esModule",{value:!0}),lD.default=function e(t,a){void 0===a&&(a={});for(var n=[],i="function"==typeof a.replace,r=a.transform||mD.returnFirstArg,o=a.library||hD,s=o.cloneElement,l=o.createElement,c=o.isValidElement,u=t.length,d=0;d<u;d++){var m=t[d];if(i){var h=a.replace(m,d);if(c(h)){u>1&&(h=s(h,{key:h.key||d})),n.push(r(h,m,d));continue}}if("text"!==m.type){var p=m,g={};pD(p)?((0,mD.setStyleProp)(p.attribs.style,p.attribs),g=p.attribs):p.attribs&&(g=(0,dD.default)(p.attribs,p.name));var f=void 0;switch(m.type){case"script":case"style":m.children[0]&&(g.dangerouslySetInnerHTML={__html:m.children[0].data});break;case"tag":"textarea"===m.name&&m.children[0]?g.defaultValue=m.children[0].data:m.children&&m.children.length&&(f=e(m.children,a));break;default:continue}u>1&&(g.key=d),n.push(r(l(m.name,g,f),m,d))}else{var y=!m.data.trim().length;if(y&&m.parent&&!(0,mD.canTextBeChildOfNode)(m.parent))continue;if(a.trim&&y)continue;n.push(r(m.data,m,d))}}return 1===n.length?n[0]:n};var uD=t,dD=cD(yO),mD=PO,hD={cloneElement:uD.cloneElement,createElement:uD.createElement,isValidElement:uD.isValidElement};function pD(e){return mD.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&(0,mD.isCustomComponent)(e.name,e.attribs)}var gD={},fD={},yD=$t&&$t.__extends||function(){var e=function(t,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])},e(t,a)};return function(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");function n(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(n.prototype=a.prototype,new n)}}(),bD=$t&&$t.__assign||function(){return bD=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var i in t=arguments[a])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},bD.apply(this,arguments)};Object.defineProperty(fD,"__esModule",{value:!0}),fD.cloneNode=fD.hasChildren=fD.isDocument=fD.isDirective=fD.isComment=fD.isText=fD.isCDATA=fD.isTag=fD.Element=fD.Document=fD.CDATA=fD.NodeWithChildren=fD.ProcessingInstruction=fD.Comment=fD.Text=fD.DataNode=fD.Node=void 0;var vD=FP,wD=function(){function e(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(e){return void 0===e&&(e=!1),jD(this,e)},e}();fD.Node=wD;var xD=function(e){function t(t){var a=e.call(this)||this;return a.data=t,a}return yD(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(wD);fD.DataNode=xD;var kD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Text,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),t}(xD);fD.Text=kD;var AD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Comment,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),t}(xD);fD.Comment=AD;var SD=function(e){function t(t,a){var n=e.call(this,a)||this;return n.name=t,n.type=vD.ElementType.Directive,n}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),t}(xD);fD.ProcessingInstruction=SD;var ED=function(e){function t(t){var a=e.call(this)||this;return a.children=t,a}return yD(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return null!==(e=this.children[0])&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(wD);fD.NodeWithChildren=ED;var _D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.CDATA,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),t}(ED);fD.CDATA=_D;var CD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Root,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),t}(ED);fD.Document=CD;var TD=function(e){function t(t,a,n,i){void 0===n&&(n=[]),void 0===i&&(i="script"===t?vD.ElementType.Script:"style"===t?vD.ElementType.Style:vD.ElementType.Tag);var r=e.call(this,n)||this;return r.name=t,r.attribs=a,r.type=i,r}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map((function(t){var a,n;return{name:t,value:e.attribs[t],namespace:null===(a=e["x-attribsNamespace"])||void 0===a?void 0:a[t],prefix:null===(n=e["x-attribsPrefix"])||void 0===n?void 0:n[t]}}))},enumerable:!1,configurable:!0}),t}(ED);function PD(e){return(0,vD.isTag)(e)}function OD(e){return e.type===vD.ElementType.CDATA}function DD(e){return e.type===vD.ElementType.Text}function MD(e){return e.type===vD.ElementType.Comment}function ID(e){return e.type===vD.ElementType.Directive}function ND(e){return e.type===vD.ElementType.Root}function jD(e,t){var a;if(void 0===t&&(t=!1),DD(e))a=new kD(e.data);else if(MD(e))a=new AD(e.data);else if(PD(e)){var n=t?zD(e.children):[],i=new TD(e.name,bD({},e.attribs),n);n.forEach((function(e){return e.parent=i})),null!=e.namespace&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]=bD({},e["x-attribsNamespace"])),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]=bD({},e["x-attribsPrefix"])),a=i}else if(OD(e)){n=t?zD(e.children):[];var r=new _D(n);n.forEach((function(e){return e.parent=r})),a=r}else if(ND(e)){n=t?zD(e.children):[];var o=new CD(n);n.forEach((function(e){return e.parent=o})),e["x-mode"]&&(o["x-mode"]=e["x-mode"]),a=o}else{if(!ID(e))throw new Error("Not implemented yet: ".concat(e.type));var s=new SD(e.name,e.data);null!=e["x-name"]&&(s["x-name"]=e["x-name"],s["x-publicId"]=e["x-publicId"],s["x-systemId"]=e["x-systemId"]),a=s}return a.startIndex=e.startIndex,a.endIndex=e.endIndex,null!=e.sourceCodeLocation&&(a.sourceCodeLocation=e.sourceCodeLocation),a}function zD(e){for(var t=e.map((function(e){return jD(e,!0)})),a=1;a<t.length;a++)t[a].prev=t[a-1],t[a-1].next=t[a];return t}fD.Element=TD,fD.isTag=PD,fD.isCDATA=OD,fD.isText=DD,fD.isComment=MD,fD.isDirective=ID,fD.isDocument=ND,fD.hasChildren=function(e){return Object.prototype.hasOwnProperty.call(e,"children")},fD.cloneNode=jD,function(e){var t=$t&&$t.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var i=Object.getOwnPropertyDescriptor(t,a);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,i)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),a=$t&&$t.__exportStar||function(e,a){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(a,n)||t(a,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var n=FP,i=fD;a(fD,e);var r={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function e(e,t,a){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,"function"==typeof t&&(a=t,t=r),"object"==typeof e&&(t=e,e=void 0),this.callback=null!=e?e:null,this.options=null!=t?t:r,this.elementCB=null!=a?a:null}return e.prototype.onparserinit=function(e){this.parser=e},e.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},e.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},e.prototype.onerror=function(e){this.handleCallback(e)},e.prototype.onclosetag=function(){this.lastNode=null;var e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)},e.prototype.onopentag=function(e,t){var a=this.options.xmlMode?n.ElementType.Tag:void 0,r=new i.Element(e,t,void 0,a);this.addNode(r),this.tagStack.push(r)},e.prototype.ontext=function(e){var t=this.lastNode;if(t&&t.type===n.ElementType.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{var a=new i.Text(e);this.addNode(a),this.lastNode=a}},e.prototype.oncomment=function(e){if(this.lastNode&&this.lastNode.type===n.ElementType.Comment)this.lastNode.data+=e;else{var t=new i.Comment(e);this.addNode(t),this.lastNode=t}},e.prototype.oncommentend=function(){this.lastNode=null},e.prototype.oncdatastart=function(){var e=new i.Text(""),t=new i.CDATA([e]);this.addNode(t),e.parent=t,this.lastNode=e},e.prototype.oncdataend=function(){this.lastNode=null},e.prototype.onprocessinginstruction=function(e,t){var a=new i.ProcessingInstruction(e,t);this.addNode(a)},e.prototype.handleCallback=function(e){if("function"==typeof this.callback)this.callback(e,this.dom);else if(e)throw e},e.prototype.addNode=function(e){var t=this.tagStack[this.tagStack.length-1],a=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),a&&(e.prev=a,a.next=e),e.parent=t,this.lastNode=null},e}();e.DomHandler=o,e.default=o}(gD),function(e){var t=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];return(0,i.default)((0,a.default)(e,(null==t?void 0:t.htmlparser2)||o),t)};var a=t(wP);e.htmlToDOM=a.default;var n=t(yO);e.attributesToProps=n.default;var i=t(lD);e.domToReact=i.default;var r=gD;Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return r.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return r.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return r.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return r.Text}});var o={lowerCaseAttributeNames:!1}}(vP);var RD=Gt(vP),LD=RD.default||RD;A("pre code.hljs {\n display: block;\n overflow-x: auto;\n padding: 1em\n}\ncode.hljs {\n padding: 3px 5px\n}\n/*\n\nAtom One Dark by Daniel Gamage\nOriginal One Dark Syntax theme from https://github.com/atom/one-dark-syntax\n\nbase: #282c34\nmono-1: #abb2bf\nmono-2: #818896\nmono-3: #5c6370\nhue-1: #56b6c2\nhue-2: #61aeee\nhue-3: #c678dd\nhue-4: #98c379\nhue-5: #e06c75\nhue-5-2: #be5046\nhue-6: #d19a66\nhue-6-2: #e6c07b\n\n*/\n.hljs {\n color: #abb2bf;\n background: #282c34\n}\n.hljs-comment,\n.hljs-quote {\n color: #5c6370;\n font-style: italic\n}\n.hljs-doctag,\n.hljs-keyword,\n.hljs-formula {\n color: #c678dd\n}\n.hljs-section,\n.hljs-name,\n.hljs-selector-tag,\n.hljs-deletion,\n.hljs-subst {\n color: #e06c75\n}\n.hljs-literal {\n color: #56b6c2\n}\n.hljs-string,\n.hljs-regexp,\n.hljs-addition,\n.hljs-attribute,\n.hljs-meta .hljs-string {\n color: #98c379\n}\n.hljs-attr,\n.hljs-variable,\n.hljs-template-variable,\n.hljs-type,\n.hljs-selector-class,\n.hljs-selector-attr,\n.hljs-selector-pseudo,\n.hljs-number {\n color: #d19a66\n}\n.hljs-symbol,\n.hljs-bullet,\n.hljs-link,\n.hljs-meta,\n.hljs-selector-id,\n.hljs-title {\n color: #61aeee\n}\n.hljs-built_in,\n.hljs-title.class_,\n.hljs-class .hljs-title {\n color: #e6c07b\n}\n.hljs-emphasis {\n font-style: italic\n}\n.hljs-strong {\n font-weight: bold\n}\n.hljs-link {\n text-decoration: underline\n}");A(".mdhui-chat {\n background: var(--mdhui-background-color-0);\n font-size: 0.88em;\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n min-height: 150px;\n}\n\n.mdhui-chat .mdhui-chat-log {\n overflow: hidden;\n flex: 1 1 0%;\n}\n\n.mdhui-chat .mdhui-chat-messages-scroll-wrapper {\n overflow-y: auto;\n height: 100%;\n}\n\n.mdhui-chat .mdhui-chat-messages {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n min-height: 100%;\n width: 100%;\n}\n\n.mdhui-chat p,\n.mdhui-chat ul {\n margin: .25rem 0;\n word-break: break-word;\n}\n\n.mdhui-chat input,\n.mdhui-chat button {\n min-height: var(--mdhui-touch);\n min-width: var(--mdhui-touch);\n border: 0;\n}\n\n.mdhui-chat .mdhui-chat-send-button {\n position: absolute;\n right: 4px;\n cursor: pointer;\n text-align: center;\n}\n\n.mdhui-chat .mdhui-chat-send-button:disabled {\n cursor: default;\n color: var(--mdhui-text-color-3);\n}\n\n.mdhui-chat input {\n flex: 1;\n font-size: 1em;\n color: var(--mdhui-text-color-1);\n padding: var(--mdhui-padding-md) var(--mdhui-touch) var(--mdhui-padding-md) var(--mdhui-padding-md);\n box-sizing: border-box;\n outline-offset: -1px;\n background: var(--mdhui-background-color-0);\n}\n\n.mdhui-chat .mdhui-chat-input-group {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n background: #fff;\n border-top: 1px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-chat .mdhui-chat-message,\n.mdhui-chat .mdhui-chat-message-loading {\n padding: var(--mdhui-padding-xxs) var(--mdhui-padding-md);\n position: relative;\n}\n\n.mdhui-chat .mdhui-chat-received-message-row {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n}\n\n.mdhui-chat .mdhui-chat-sent-message-row {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n padding-right: var(--mdhui-padding-md);\n}\n\n.mdhui-chat .mdhui-chat-sent-message {\n background: var(--mdhui-background-color-1);\n max-width: 70%;\n padding: var(--mdhui-padding-xs) var(--mdhui-padding-sm);\n border-radius: var(--mdhui-card-border-radius);\n}\n\n.mdhui-chat .mdhui-chat-message .svg-inline--fa,\n.mdhui-chat .mdhui-chat-message-loading .svg-inline--fa {\n color: var(--mdhui-text-color-3);\n margin-top: .35rem;\n margin-right: .25rem;\n}\n\n.mdhui-chat .mdhui-chat-message-loading .svg-inline--fa {\n font-weight: 700;\n}\n\n.mdhui-chat input:focus-visible {\n outline: 1px solid var(--mdhui-color-primary);\n}\n\n.mdhui-chat .mdhui-chat-suggestions {\n display: flex;\n justify-content: center;\n padding: 0 var(--mdhui-padding-xxs);\n}\n\n.mdhui-chat .mdhui-chat-suggestion {\n padding: var(--mdhui-padding-xs) var(--mdhui-padding-sm);\n margin: var(--mdhui-padding-xs) var(--mdhui-padding-xxs);\n border-radius: var(--mdhui-card-border-radius);\n background: var(--mdhui-background-color-1);\n cursor: pointer;\n}\n"),uP.registerLanguage("javascript",(function(e){const t=e.regex,a=dP,n="<>",i="</>",r={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{const a=e[0].length+e.index,n=e.input[a];if("<"===n||","===n)return void t.ignoreMatch();let i;">"===n&&(((e,{after:t})=>{const a="</"+e[0].slice(1);return-1!==e.input.indexOf(a,t)})(e,{after:a})||t.ignoreMatch());const r=e.input.substring(a);((i=r.match(/^\s*=/))||(i=r.match(/^\s+extends\s+/))&&0===i.index)&&t.ignoreMatch()}},o={$pattern:dP,keyword:mP,literal:hP,built_in:bP,"variable.language":yP},s="[0-9](_?[0-9])*",l=`\\.(${s})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${c})((${l})|\\.)?|(${l}))[eE][+-]?(${s})\\b`},{begin:`\\b(${c})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},d={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"css"}},p={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,d]},f={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},y=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,p,g,{match:/\$\d+/},u];d.contains=y.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(y)});const b=[].concat(f,d.contains),v=b.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(b)}]),w={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v},x={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,t.concat(a,"(",t.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...pP,...gP]}},A={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},S={match:t.concat(/\b/,function(e){return t.concat("(?!",e.join("|"),")")}([...fP,"super","import"].map((e=>`${e}\\s*\\(`))),a,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},E={begin:t.concat(/\./,t.lookahead(t.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},_={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",T={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:v,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,p,g,f,{match:/\$\d+/},u,k,{className:"attr",begin:a+t.lookahead(":"),relevance:0},T,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[f,e.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:n,end:i},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r.begin,"on:begin":r.isTrulyOpeningTag,end:r.end}],subLanguage:"xml",contains:[{begin:r.begin,end:r.end,skip:!0,contains:["self"]}]}]},A,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,e.inherit(e.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},E,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},S,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},x,_,{match:/\$[(.]/}]}}));const FD=new DC({breaks:!0}).use(QC,{inline:!0,hljs:uP});function BD(e){const[a,n]=c(""),i=s(null);l((()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)}),[e.messages]);const r=async function(){let t=a;e.onSendMessage(t),n("")};return t.createElement("div",{className:"mdhui-chat",ref:e.innerRef},t.createElement("div",{className:"mdhui-chat-log"},t.createElement("div",{className:"mdhui-chat-messages-scroll-wrapper",ref:i},t.createElement("div",{className:"mdhui-chat-messages"},e.messages.map(((e,a)=>"sent"===e.type?t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-sent-message-row"},t.createElement("div",{className:"mdhui-chat-sent-message"},LD(FD.render(e.content)))):"received-image"===e.type?t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-received-message-row"},t.createElement("img",{src:e.content,className:e.cssClass})):t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-received-message-row"},e.icon,t.createElement("div",{className:"mdhui-chat-received-message"+(e.cssClass?" "+e.cssClass:"")},LD(FD.render(e.content)))))),e.loading&&t.createElement("div",{className:"mdhui-chat-message-loading"},t.createElement(je,{icon:Ee,spin:!0}),e.loading)))),e.suggestions&&e.onSuggestionSelected&&t.createElement("div",{className:"mdhui-chat-suggestions"},e.suggestions.map((a=>t.createElement("div",{key:a,className:"mdhui-chat-suggestion",onClick:()=>e.onSuggestionSelected?.(a)},a)))),t.createElement("div",{className:"mdhui-chat-input"},t.createElement("div",{className:"mdhui-chat-input-group"},t.createElement("input",{type:"text",value:a,onChange:e=>n(e.target.value),onKeyDown:t=>{!e.inputDisabled&&a&&"Enter"===t.key&&r()}}),t.createElement(S,{onClick:r,className:"mdhui-chat-send-button",disabled:e.inputDisabled||!a},t.createElement(je,{icon:De})))))}function HD(e){const a="Month"===e.intervalType?{months:1}:"Day"===e.intervalType?{days:1}:"6Month"===e.intervalType?{months:6}:{weeks:1};var n=un(e.intervalStart,a),i=!1,r=new Date;e.intervalStart<=r&&r<n&&(i=!0);let o=["mdhui-date-range-navigator"];return"rounded"==e.variant&&o.push("mdhui-date-range-navigator-rounded"),e.sticky&&o.push("mdhui-date-range-navigator-sticky"),e.className&&o.push(e.className),t.createElement("div",{ref:e.innerRef,className:o.join(" ")},t.createElement("div",{className:"mdhui-date-range-navigator-inner"},t.createElement(S,{title:"Previous",className:"navigator-button navigate-previous",onClick:()=>{return t=Ur(e.intervalStart,a),void e.onIntervalChange(t,un(t,a));var t}},t.createElement(je,{icon:ke})),yl(e.intervalType,e.intervalStart),!i&&t.createElement(S,{title:"Next",className:"navigator-button navigate-next",onClick:()=>{return t=un(e.intervalStart,a),void e.onIntervalChange(t,un(t,a));var t}},t.createElement(je,{icon:Ae}))))}A(".mdhui-card .mdhui-date-range-navigator:first-child {\n border-radius: var(--mdhui-card-border-radius) var(--mdhui-card-border-radius) 0px 0px;\n}\n\n.mdhui-date-range-navigator {\n padding: 16px;\n text-align: center;\n font-weight: bold;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n background: var(--mdhui-background-color-0);\n z-index: 1;\n position: relative;\n}\n\n.mdhui-date-range-navigator.mdhui-date-range-navigator-sticky {\n position: sticky;\n position: -webkit-sticky;\n top: 0;\n padding-top: calc(16px + env(safe-area-inset-top, 0px));\n}\n\n.mdhui-date-range-navigator .navigator-button {\n position: absolute;\n top: 0;\n padding: 16px;\n color: var(--mdhui-color-primary);\n height: 100%;\n}\n\n.mdhui-date-range-navigator .navigate-previous {\n left: 0;\n}\n\n.mdhui-date-range-navigator .navigate-next {\n right: 0;\n}\n\n.mdhui-date-range-navigator-rounded {\n padding: 16px;\n border: none;\n background: var(--mdhui-background-color-1);\n}\n\n.mdhui-date-range-navigator-rounded .mdhui-date-range-navigator-inner {\n line-height: 40px;\n border-radius: 32px;\n background: var(--mdhui-background-color-2);\n position: relative;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button {\n padding: 0;\n width: 36px;\n height: 36px;\n background: var(--mdhui-background-color-0);\n color: var(--mdhui-color-primary);\n border-radius: 31px;\n cursor: pointer;\n position: absolute;\n top: 2px;\n line-height: 36px;\n display: flex;\n align-items: center;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button.navigate-previous {\n left: 2px;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button.navigate-next {\n right: 2px;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button svg {\n margin: 0 auto;\n}\n\n.mdhui-navigation-bar .mdhui-date-range-navigator-rounded {\n margin: 0;\n}");const qD=o(null);function UD(e){let a=e.initialIntervalStart||_u();"Week"===e.intervalType&&(a=Eu(e.weekStartsOn)),"Day"===e.intervalType&&(a=vn(new Date));const[n,i]=c(null),r=s();return r.current=n,l((()=>{i({intervalType:e.intervalType,intervalStart:a,update:e=>{i({...r.current,...e})}})}),[e.intervalType,e.weekStartsOn]),n?t.createElement("div",{ref:e.innerRef},t.createElement(qD.Provider,{value:n},!e.useCustomNavigator&&t.createElement(HD,{sticky:e.sticky,intervalType:e.intervalType,intervalStart:n.intervalStart,onIntervalChange:e=>i({...n,intervalStart:e}),variant:e.variant}),e.children)):null}function WD(e){let a=`h${e.order||1}`,n=["mdhui-title"];e.className&&n.push(e.className);let i=r(Ka),o=ze(i?.colorScheme,e.color);"top"===e.imageAlignment&&n.push("mdhui-title-image-top"),e.defaultMargin&&n.push("mdhui-title-default-margin");let s=null;if(e.image&&e.autosizeImage){switch(s=24,e.order){case 1:s=40;break;case 2:s=30;break;case 3:s=24;break;case 4:s=20;break;case 5:s=16;break;case 6:s=12}"top"==e.imageAlignment&&(s*=2)}return t.createElement("div",{className:n.join(" "),ref:e.innerRef},e.image&&t.createElement("div",{className:"mdhui-title-image "+(e.autosizeImage?"mdhui-title-image-autosize":""),style:{width:s+"px"}},e.image),t.createElement(a,{style:{...e.style,color:o}},e.children),e.accessory)}function VD(){}function $D(e){let a=r(qD);return a||(a={intervalStart:vn(new Date),intervalType:"Day",update:VD}),t.createElement(WD,{defaultMargin:e.defaultMargin,order:e.order||3,color:e.color,style:e.style,innerRef:e.innerRef},yl(a.intervalType,a.intervalStart,"long"))}A(".mdhui-title {\n display: flex;\n align-items: center;\n gap: var(--mdhui-padding-md);\n}\n\n.mdhui-title.mdhui-title-default-margin {\n margin: var(--mdhui-padding-md);\n}\n\n.mdhui-title.mdhui-title-image-top {\n display: block;\n}\n\n.mdhui-title .mdhui-title-image\n{\n display: flex;\n}\n\n.mdhui-title .mdhui-title-image-autosize img {\n width: 100%;\n}\n\n.mdhui-title h1,\n.mdhui-title h2,\n.mdhui-title h3,\n.mdhui-title h4,\n.mdhui-title h5,\n.mdhui-title h6 {\n margin: 0;\n padding: 0;\n flex-grow: 1;\n}\n\n\n.mdhui-title.mdhui-title-image-top h1,\n.mdhui-title.mdhui-title-image-top h2,\n.mdhui-title.mdhui-title-image-top h3,\n.mdhui-title.mdhui-title-image-top h4,\n.mdhui-title.mdhui-title-image-top h5,\n.mdhui-title.mdhui-title-image-top h6 {\n margin-top: var(--mdhui-padding-md);\n}\n\n.mdhui-title h1 {\n font-size: 2em;\n}\n\n.mdhui-title h2 {\n font-size: 1.5em;\n}\n\n.mdhui-title h3 {\n font-size: 1.17em;\n}\n\n.mdhui-title h4 {\n font-size: 1em;\n}\n\n.mdhui-title h5 {\n font-size: 0.83em;\n}\n\n.mdhui-title h6 {\n font-size: 0.67em;\n}");function GD(e){for(var a=100/e.primaryColors.length,n="conic-gradient(",i=0,r=0;r<e.primaryColors.length;r++)n=n+e.primaryColors[r]+" "+i+"%, ",i+=a,n=n+e.primaryColors[r]+" "+i+"%",r!=e.primaryColors.length-1&&(n+=", ");var o={background:n+=")"};let s=["mdhui-day-tracker-symbol"];return e.className&&s.push(e.className),"large"==e.size&&s.push("mdhui-day-tracker-symbol-large"),t.createElement("div",{ref:e.innerRef,className:s.join(" ")},t.createElement("div",{className:"day-circle",style:o},e.secondaryColors.slice(0,3).map(((e,a)=>t.createElement("div",{key:a,className:"secondary-color",style:{background:e}}))),e.secondaryColors.length>3&&t.createElement("div",{className:"more-items"},"+")))}A(".mdhui-day-tracker-symbol {\n padding: 10px;\n}\n\n.mdhui-day-tracker-symbol .day-circle {\n font-size: 12px;\n height: 30px;\n width: 30px;\n display: inline-block;\n border-radius: 17px;\n line-height: 30px;\n background: var(--mdhui-background-color-2);\n position: relative;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color {\n position: absolute;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:first-child {\n left: 36.6%;\n top: -33.33%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:nth-child(2) {\n left: 0%;\n top: -23.333%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:nth-child(3) {\n left: 73%;\n top: -23.333%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .more-items {\n position: absolute;\n left: 30px;\n top: 0px;\n font-size: 10px;\n height: 8px;\n width: 7px;\n line-height: 6px;\n}\n\n.mdhui-day-tracker-symbol.mdhui-day-tracker-symbol-large {\n transform: scale(2);\n padding-top: 34px;\n padding-bottom: 22px;\n}");function KD(e){const a=r(Ka),n=[...Array(e.tickCount).keys()];let i=e.value;void 0!==i&&i<0&&(i=0),void 0!==i&&i>=e.tickCount&&(i=e.tickCount-1);let o=e.sliderColor?ze(a.colorScheme,e.sliderColor):"var(--mdhui-color-primary)",s=i?`calc((((100% - 16px) / ${e.tickCount-1}) * ${i}) + 8px)`:"0%",l={background:`linear-gradient(to right, ${o} 0%, ${o} ${s}, var(--mdhui-background-color-2) ${s}, var(--mdhui-background-color-2) 100%)`},c={gridTemplateColumns:n.slice(0,-1).map((e=>"1fr")).join(" ")};const u=t=>{e.onChange&&e.onChange(t)};return t.createElement("div",{className:"mdhui-discrete-scale",ref:e.innerRef},t.createElement("div",{className:"mdhui-discrete-scale-slider",style:l}," "),t.createElement("div",{className:"mdhui-discrete-scale-ticks",style:c},n.slice(0,-1).map(((a,n)=>t.createElement("div",{key:n,className:"mdhui-discrete-scale-ticks-section"},t.createElement(S,{className:"mdhui-discrete-scale-ticks-section-button",onClick:()=>u(a),style:{left:0===n?"-10px":"-50%",width:0===n?"calc(50% + 10px)":"100%"}},t.createElement("div",{className:"mdhui-discrete-scale-ticks-section-marker",style:{background:a===i?o:"transparent",left:0===n?"-1px":"calc(50% - 11px)"}}," ")),n===e.tickCount-2&&t.createElement(S,{className:"mdhui-discrete-scale-ticks-section-button",onClick:()=>u(a+1),style:{left:"calc(50% + 2px)",width:"calc(50% + 10px)"}},t.createElement("div",{className:"mdhui-discrete-scale-ticks-section-marker",style:{background:a+1===i?o:"transparent",right:"1px"}}," ")))))),t.createElement("div",{className:"mdhui-discrete-scale-labels"},t.createElement("div",{className:"mdhui-discrete-scale-labels-min"},e.minLabel),void 0!==e.value&&t.createElement(S,{onClick:()=>{e.onChange&&e.onChange(void 0)}},t.createElement("div",{className:"mdhui-discrete-scale-clear-button",style:{color:o}},so("clear"))),void 0===e.value&&t.createElement(t.Fragment,null," "),t.createElement("div",{className:"mdhui-discrete-scale-labels-max"},e.maxLabel)))}A(".mdhui-discrete-scale {\n padding: 16px;\n}\n\n.mdhui-discrete-scale-slider {\n height: 10px;\n border: 1px solid var(--mdhui-border-color-2);\n border-radius: 5px;\n margin-bottom: 4px;\n}\n\n.mdhui-discrete-scale-ticks {\n padding: 0 8px;\n display: grid;\n align-items: center;\n margin-bottom: 8px;\n}\n\n.mdhui-discrete-scale-ticks-section {\n position: relative;\n height: 5px;\n border-right: 2px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-discrete-scale-ticks-section:first-child {\n border-left: 2px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-discrete-scale-ticks-section-button.mdhui-unstyled-button {\n position: absolute;\n top: -20px;\n height: 20px;\n}\n\n.mdhui-discrete-scale-ticks-section-marker {\n position: absolute;\n top: 0;\n height: 20px;\n width: 20px;\n border-radius: 10px;\n}\n\n.mdhui-discrete-scale-labels {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n font-size: 0.8em;\n color: var(--mdhui-text-color-2);\n}\n\n.mdhui-discrete-scale-clear-button {\n text-align: center;\n text-decoration: underline;\n}\n\n.mdhui-discrete-scale-labels-max {\n text-align: right;\n}");function ZD(){return t.createElement("div",{className:"mdhui-divider"})}A(".mdhui-divider {\n height: 0x;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n}");var YD;function XD(e){const a=e.axis.xIncrement,n=e.axis.yRange.values[0],i=e.axis.yRange.values[1],r=i-n,o=e.dumbbell?.class??YD["mdhui-dumbbell-in-range"],s=YD[o],l=[s],c=[s],u={left:e.index*a+"%"},d=e.dumbbell&&e.dumbbell.dataPoint?e.dumbbell.dataPoint.dataSet1.values:[],m=e.dumbbell&&e.dumbbell.dataPoint?e.dumbbell.dataPoint.dataSet2.values:[],h=d.length>1?d[1]:d[0],p=m.length>1?m[1]:m[0],g=p===m[0],f=d[0]-n,y=D(f+4.5,r);var b=`${y}%`;const v=d[0]<n,w=h<n;var x=h-d[0];!w&&v?(l.push("mdhui-dumbbell-partial-out-of-range-pill"),l.push("mdhui-dumbbell-bottom-lower-out-of-range"),x=h-n,b="10px"):l.push("mdhui-dumbbell-pill");const k=M(`${x}px`,b),A=p>i,S=m[0]>i;var E=0,_=D(E=g&&S?i-9:m[0]-n,r),C=0;g||(C=(p>i?i+11:p)-E);const T=g?{bottom:`${_}%`}:M(`${C}px`,`${_}%`);!S&&A?(c.push("mdhui-dumbbell-partial-out-of-range-pill"),c.push("mdhui-dumbbell-top-upper-out-of-range")):c.push("mdhui-dumbbell-pill");var P=D((S?i-n:E)-(w||d[0]<0?0:f),r);const O={height:`${P=P>100?100:P}%`,bottom:w||f<=0?"10px":`${y}%`,left:"5px"};function D(e,t){return e/t*100}function M(e,t){return{height:e,bottom:t}}return t.createElement("div",{className:"mdhui-dumbbell",style:u},e.dumbbell?.dataPoint&&t.createElement(t.Fragment,null,S&&t.createElement("div",{className:"mdhui-dumbbell-full-out-of-range-pill mdhui-dumbbell-top-upper-out-of-range"}),!S&&t.createElement("div",{className:c.join(" "),style:T}),t.createElement("div",{className:`mdhui-dumbbell-line ${s}`,style:O}),w&&t.createElement("div",{className:"mdhui-dumbbell-full-out-of-range-pill mdhui-dumbbell-bottom-lower-out-of-range"}),!w&&t.createElement("div",{className:l.join(" "),style:k})),t.createElement("div",{className:"mdhui-dumbbell-x-axis mdhui-dumbbell-axis-text",key:`xAxis${e.index+1}`},e.dumbbell?.xValue))}function QD(e){const a=e.axis.yRange.values[0],n=e.axis.yRange.values[1]-a;return t.createElement("div",{className:"mdhui-dumbbell-visualization"},t.createElement("div",{className:"mdhui-dumbbell-chart"},e.dumbbells.map(((a,n)=>t.createElement(XD,{key:`mdhui-dumbbell-${n}`,dumbbell:a,axis:e.axis,index:n+1}))),function(){const a=n/e.axis.yIncrement,i=[];for(var r=e.axis.yRange.values[0],o={bottom:"0%"},s=0;s<a+1;s++){var l=`yAxis${s+1}`,c=r;let u=["mdhui-dumbbell-axis-text"];s!=a&&0!=s||u.push("mdhui-dumbbell-axis-text-hidden"),i.push(t.createElement("div",{className:"mdhui-dumbbell-y-axis",style:o,key:l},t.createElement("div",{className:u.join(" ")},c))),r+=e.axis.yIncrement,o={bottom:(s+1)*e.axis.yIncrement/n*100+"%"}}return i}()))}A(".mdhui-dumbbell-visualization {\n padding-top: var(--mdhui-padding-sm);\n padding-bottom: var(--mdhui-padding-md);\n overflow: hidden;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart{\n height: 200px;\n width: 100%;\n position: relative;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell-y-axis{\n position: absolute;\n flex-flow: nowrap;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n width: 100%;\n border-top-width: 1px;\n border-top-style: solid;\n border-top-color: var(--mdhui-border-color-0);\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-x-axis{\n position: absolute;\n bottom: -15px;\n margin-left: -2.5px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-axis-text{\n color: var(--mdhui-text-color-4);\n font-size: 10px;\n font-style: normal;\n font-weight: 700;\n line-height: normal;\n display: flex;\n justify-content: right;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-y-axis \n.mdhui-dumbbell-axis-text{\n margin-right: 15px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell-y-axis .mdhui-dumbbell-axis-text-hidden{\n visibility: hidden;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell{\n bottom: 0px;\n height: 100%;\n position: absolute;\n }\n\n .mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n .mdhui-dumbbell-pill{\n position: absolute;\n width: 9px;\n border-radius: 25px;\n border-style: solid;\n border-width: 2px;\n z-index: 1;\n min-height: 9px;\n min-width: 9px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-full-out-of-range-pill{\n background-color: var(--mdhui-color-danger);\n border-color:var(--mdhui-color-danger);\n position: absolute;\n width: 9px;\n height: 9px;\n border-style: solid;\n border-width: 2px;\n z-index: 1;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-partial-out-of-range-pill{\n position: absolute;\n z-index: 1;\n width: 9px;\n border-style: solid;\n border-width: 2px;\n min-height: 9px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-top-upper-out-of-range{\n border-bottom-left-radius: 25px;\n border-bottom-right-radius: 25px; \n bottom: 100%;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-bottom-lower-out-of-range{\n border-top-left-radius: 25px;\n border-top-right-radius: 25px; \n border-bottom: 0;\n bottom: 10px; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-bottom{\n bottom: 10px; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-top{\n bottom: 100%; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-line {\n position: absolute;\n border-left-style: solid;\n border-left-width: 2px;\n width: 1px;\n z-index: 1;\n }\n\n .mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n .mdhui-dumbbell-in-range {\n background-color: var(--mdhui-color-primary);\n border-color: var(--mdhui-color-primary);\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-out-of-range {\n background-color: var(--mdhui-color-danger);\n border-color: var(--mdhui-color-danger);\n}"),function(e){e[e["mdhui-dumbbell-in-range"]=0]="mdhui-dumbbell-in-range",e[e["mdhui-dumbbell-out-of-range"]=1]="mdhui-dumbbell-out-of-range"}(YD||(YD={}));A(".mdhui-face\n{\n width: 40px;\n height: 40px;\n display: inline-block;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n}\n\n .mdhui-face img\n {\n width: 100%;\n height: 100%;\n opacity: .7;\n display: block;\n }\n\n .mdhui-face.mdhui-face-selected\n {\n background: #eec04c;\n }");var JD="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c224c-29.824%2c0-58.232%2c12.632-77.96%2c34.664c-2.944%2c3.296-2.664%2c8.344%2c0.624%2c11.296c1.52%2c1.368%2c3.432%2c2.04%2c5.336%2c2.04 c2.192%2c0%2c4.384-0.896%2c5.96-2.664C134.656%2c250.688%2c158.728%2c240%2c184%2c240c25.28%2c0%2c49.352%2c10.688%2c66.04%2c29.336 c2.944%2c3.296%2c8.008%2c3.568%2c11.296%2c0.624c3.288-2.944%2c3.568-8%2c0.624-11.296C242.24%2c236.64%2c213.832%2c224%2c184%2c224z'/%3e %3cpath d='M184%2c0C82.536%2c0%2c0%2c82.544%2c0%2c184s82.536%2c184%2c184%2c184s184-82.544%2c184-184S285.464%2c0%2c184%2c0z M184%2c352 c-92.632%2c0-168-75.36-168-168S91.368%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.632%2c352%2c184%2c352z'/%3e %3cpath d='M280%2c128c-4.424%2c0-8%2c3.584-8%2c8c0%2c13.232-10.768%2c24-24%2c24s-24-10.768-24-24c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8 c0%2c22.056%2c17.944%2c40%2c40%2c40c22.056%2c0%2c40-17.944%2c40-40C288%2c131.584%2c284.424%2c128%2c280%2c128z'/%3e %3cpath d='M160%2c136c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8c0%2c13.232-10.768%2c24-24%2c24s-24-10.768-24-24c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8 c0%2c22.056%2c17.944%2c40%2c40%2c40C142.056%2c176%2c160%2c158.056%2c160%2c136z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",eM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184c101.464%2c0%2c184-82.544%2c184-184S285.464%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16c92.632%2c0%2c168%2c75.36%2c168%2c168S276.632%2c352%2c184%2c352z'/%3e %3cpath d='M144%2c152c0-13.232-10.768-24-24-24s-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24S144%2c165.232%2c144%2c152z M112%2c152c0-4.408%2c3.592-8%2c8-8 s8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8S112%2c156.408%2c112%2c152z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.416%2c0-8-3.592-8-8s3.584-8%2c8-8c4.416%2c0%2c8%2c3.592%2c8%2c8S252.416%2c160%2c248%2c160z'/%3e %3cpath d='M184%2c224c-29.824%2c0-58.24%2c12.632-77.96%2c34.664c-2.944%2c3.296-2.664%2c8.352%2c0.624%2c11.296 c3.296%2c2.952%2c8.352%2c2.664%2c11.296-0.624C134.648%2c250.688%2c158.72%2c240%2c184%2c240c25.28%2c0%2c49.352%2c10.688%2c66.04%2c29.336 c1.576%2c1.768%2c3.768%2c2.664%2c5.96%2c2.664c1.896%2c0%2c3.816-0.672%2c5.336-2.04c3.288-2.944%2c3.568-8%2c0.624-11.296 C242.24%2c236.64%2c213.832%2c224%2c184%2c224z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",tM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M120%2c176c13.232%2c0%2c24-10.768%2c24-24s-10.768-24-24-24s-24%2c10.768-24%2c24S106.768%2c176%2c120%2c176z M120%2c144 c4.408%2c0%2c8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8s-8-3.592-8-8S115.592%2c144%2c120%2c144z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.408%2c0-8-3.592-8-8s3.592-8%2c8-8c4.408%2c0%2c8%2c3.592%2c8%2c8S252.408%2c160%2c248%2c160z'/%3e %3cpath d='M264%2c224H104c-4.416%2c0-8%2c3.584-8%2c8c0%2c4.416%2c3.584%2c8%2c8%2c8h160c4.416%2c0%2c8-3.584%2c8-8C272%2c227.584%2c268.416%2c224%2c264%2c224z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",aM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M144%2c152c0-13.232-10.768-24-24-24s-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24S144%2c165.232%2c144%2c152z M112%2c152c0-4.408%2c3.592-8%2c8-8 s8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8S112%2c156.408%2c112%2c152z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.408%2c0-8-3.592-8-8s3.592-8%2c8-8c4.408%2c0%2c8%2c3.592%2c8%2c8S252.408%2c160%2c248%2c160z'/%3e %3cpath d='M261.336%2c226.04c-3.296-2.952-8.36-2.664-11.296%2c0.624C233.352%2c245.312%2c209.288%2c256%2c184%2c256 c-25.28%2c0-49.352-10.688-66.04-29.336c-2.952-3.288-8-3.576-11.296-0.624c-3.296%2c2.944-3.568%2c8-0.624%2c11.296 C125.76%2c259.368%2c154.176%2c272%2c184%2c272c29.832%2c0%2c58.248-12.64%2c77.96-34.664C264.904%2c234.04%2c264.624%2c228.984%2c261.336%2c226.04z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",nM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M261.336%2c226.04c-3.296-2.952-8.36-2.664-11.296%2c0.624C233.352%2c245.312%2c209.288%2c256%2c184%2c256 c-25.28%2c0-49.352-10.688-66.04-29.336c-2.952-3.288-8-3.576-11.296-0.624c-3.296%2c2.944-3.568%2c8-0.624%2c11.296 C125.76%2c259.368%2c154.176%2c272%2c184%2c272c29.832%2c0%2c58.248-12.64%2c77.96-34.664C264.904%2c234.04%2c264.624%2c228.984%2c261.336%2c226.04z'/%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M248%2c128c-22.056%2c0-40%2c17.944-40%2c40c0%2c4.416%2c3.584%2c8%2c8%2c8c4.416%2c0%2c8-3.584%2c8-8c0-13.232%2c10.768-24%2c24-24s24%2c10.768%2c24%2c24 c0%2c4.416%2c3.584%2c8%2c8%2c8c4.416%2c0%2c8-3.584%2c8-8C288%2c145.944%2c270.056%2c128%2c248%2c128z'/%3e %3cpath d='M144%2c168c0%2c4.416%2c3.584%2c8%2c8%2c8s8-3.584%2c8-8c0-22.056-17.944-40-40-40c-22.056%2c0-40%2c17.944-40%2c40c0%2c4.416%2c3.584%2c8%2c8%2c8 s8-3.584%2c8-8c0-13.232%2c10.768-24%2c24-24S144%2c154.768%2c144%2c168z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e";function iM(e){let a={};"dark"!=r(Ka).colorScheme||e.selected||(a.filter="invert(1)");var n="mdhui-face";function i(){return 1==e.faceValue?JD:2==e.faceValue?eM:3==e.faceValue?tM:4==e.faceValue?aM:5==e.faceValue?nM:void 0}e.selected&&(n+=" mdhui-face-selected"),e.className&&(n+=" "+e.className);const o=e.faceValue?so(`face-value-${e.faceValue}`):"";return e.onClick?t.createElement(S,{innerRef:e.innerRef,className:n,onClick:e.onClick,"aria-label":o},t.createElement("img",{src:i(),style:a,alt:o}),t.createElement(LS,null)):t.createElement("div",{className:n},t.createElement("img",{src:i(),style:a,alt:o}),t.createElement(LS,null))}function rM(e){let a,n,i,r,o,s;if(e.glucoseReadings&&e.glucoseReadings.length>0){let t=e.glucoseReadings.map((e=>e.value));a=Math.min(...t),n=Math.max(...t),i=t.reduce(((e,t)=>e+t),0)/t.length}e.steps&&e.steps.length>0&&(r=e.steps.reduce(((e,t)=>e+t.value),0)),e.sleepMinutes&&(o=Math.floor(e.sleepMinutes/60),s=Math.floor(e.sleepMinutes%60));let l=60*(o||0)+(s||0);return t.createElement("div",{className:"mdhui-glucose-stats",ref:e.innerRef},t.createElement(oM,{loading:e.loading,label:so("minimal"===e.variant?"glucose-stats-range-label-minimal":"glucose-stats-range-label"),icon:"minimal"===e.variant?void 0:he,iconColor:"#d36540",value:a&&n?`${El(a)} - ${El(n)} mg/dL`:void 0,invert:"minimal"===e.variant}),t.createElement(oM,{loading:e.loading,label:so("minimal"===e.variant?"glucose-stats-avg-label-minimal":"glucose-stats-avg-label"),icon:"minimal"===e.variant?void 0:he,iconColor:"#d36540",value:i?`${El(i)} mg/dL`:void 0,invert:"minimal"===e.variant}),"minimal"!==e.variant&&t.createElement(t.Fragment,null,t.createElement(oM,{loading:e.loading,label:so("glucose-stats-steps-label"),icon:_e,iconColor:"#f5b722",value:r?`${El(r)}`:void 0}),t.createElement(oM,{loading:e.loading,label:so("glucose-stats-sleep-label"),icon:me,iconColor:"#8287bb",value:o||s?_l(l):void 0})))}function oM(e){return t.createElement("div",{className:"mdhui-glucose-stat"},!e.invert&&t.createElement("div",{className:"mdhui-glucose-stat-label"},e.label),e.loading&&t.createElement(NS,null),!e.loading&&e.value&&t.createElement("div",{className:"mdhui-glucose-stat-value"},e.icon&&t.createElement(je,{icon:e.icon,color:e.iconColor})," ",e.value),!e.loading&&!e.value&&t.createElement("div",{className:"mdhui-glucose-stat-value-not-available"},"--"),e.invert&&t.createElement("div",{className:"mdhui-glucose-stat-label"},e.label))}A(".mdhui-glucose-stats {\n display: grid;\n grid-template-columns: 1fr 1fr;\n align-items: center;\n grid-column-gap: 16px;\n grid-row-gap: 16px;\n padding: 16px;\n}\n\n.mdhui-glucose-stats .mdhui-loading-indicator {\n padding: 0;\n text-align: left;\n}\n\n.mdhui-glucose-stat-label {\n text-transform: uppercase;\n font-size: 0.65em;\n margin-bottom: 4px;\n}\n\n.mdhui-glucose-stat-value {\n font-size: 0.95em;\n font-weight: bold;\n color: var(--mdhui-text-color-0);\n margin-bottom: 1px;\n}\n\n.mdhui-glucose-stat-value-not-available {\n font-size: 0.95em;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n margin-bottom: 1px;\n}");A(".mdhui-grid {\n display: flex;\n gap: var(--mdhui-padding-md);\n flex-wrap: wrap;\n}\n\n.mdhui-grid.mdhui-grid-default-margin {\n margin: var(--mdhui-padding-md);\n}\n\n.mdhui-grid .mdhui-grid-column {\n flex-grow: 0;\n flex-shrink: 0;\n}\n\n.mdhui-grid .mdhui-grid-column.mdhui-card {\n margin: 0;\n}\n\n.mdhui-grid .mdhui-grid-column:empty {\n display: none;\n}");const sM=o({gap:16});function lM(e){let a=["mdhui-grid"];e.className&&a.push(e.className),e.defaultMargin&&a.push("mdhui-grid-default-margin");const n={...e.style},i=e.gap||0===e.gap?e.gap:16;return n.gap=`${i}px`,t.createElement(sM.Provider,{value:{gap:i}},t.createElement("div",{ref:e.innerRef,className:a.join(" "),style:n},e.children))}lM.Column=function(e){if(!e.children)return null;const a=`calc(${e.span/12*100}% - ${t.useContext(sM).gap}px)`,n={...e.style,width:a};return"card"===e.variant?t.createElement(FS,{innerRef:e.innerRef,className:"mdhui-grid-column",style:n},e.children):t.createElement("div",{ref:e.innerRef,className:"mdhui-grid-column",style:n},e.children)};function cM(e){const a=r(Ka);let n=0;e.entries.forEach((function(e){e.value>n&&(n=e.value)}));var i=[...e.entries].sort(((e,t)=>t.value-e.value||(e.label>t.label?1:t.label>e.label?-1:0)));return t.createElement("div",{ref:e.innerRef,className:"mdhui-histogram "+(e.className||"")},i.map(((i,r)=>t.createElement("div",{className:"mdhui-histogram-entry"+(i.onSelect?" mdhui-histogram-entry-clickable":""),key:r,onClick:()=>i.onSelect?.()},t.createElement("div",{className:"mdhui-histogram-entry-bar-wrapper"},t.createElement("div",{className:"mdhui-histogram-entry-bar",style:{background:i.color,width:i.value/n*100+"%"}},t.createElement(LS,null)),t.createElement("div",{className:"mdhui-histogram-entry-value",style:{width:8*n.toString().length+"px"}},i.value)),t.createElement("div",{className:"mdhui-histogram-entry-label",style:i.onSelect&&e.linkColor?{color:ze(a.colorScheme,e.linkColor)}:void 0},i.label)))))}A(".mdhui-histogram\n{\n padding: 16px;\n}\n\n .mdhui-histogram .mdhui-histogram-entry\n {\n padding-top: 8px;\n font-size: 15px;\n }\n\n .mdhui-histogram .mdhui-histogram-entry.mdhui-histogram-entry-clickable\n {\n cursor: pointer;\n }\n\n .mdhui-histogram .mdhui-histogram-entry.mdhui-histogram-entry-clickable .mdhui-histogram-entry-label\n {\n text-decoration: underline;\n color: var(--mdhui-color-primary);\n }\n\n .mdhui-histogram .mdhui-histogram-entry-bar-wrapper\n {\n display: flex;\n }\n\n .mdhui-histogram .mdhui-histogram-entry-bar\n {\n position: relative;\n height: 16px;\n border-radius: 8px;\n }\n\n .mdhui-histogram .mdhui-histogram-entry-value\n {\n padding-left: 4px;\n line-height: 16px;\n font-size: 12px;\n font-weight: bold;\n }\n");function uM(e){const a=r(Ka),n=e.configuration.shouldHighlight(e.data),i=n?e.configuration.iconColor??"var(--mdhui-color-primary)":{lightMode:"#ccc",darkMode:"#555"},o=n?e.configuration.iconTextColor??"var(--mdhui-background-color-0)":"var(--mdhui-background-color-0)",s=ze(a.colorScheme,i),l=ze(a.colorScheme,o),c=["mdhui-insights-badge"];"xsmall"===e.variant&&c.push("mdhui-insights-badge-xsmall"),n&&c.push("mdhui-insights-badge-highlighted");const u={background:s,borderColor:s,...n&&e.configuration.customHighlightStyling};return t.createElement("div",{className:c.join(" "),style:u,ref:e.innerRef},e.configuration.icon?t.createElement(je,{className:"mdhui-insights-badge-icon",icon:e.configuration.icon,style:{color:l}}):t.createElement("div",{className:"mdhui-insights-badge-label"},e.configuration.identifier.substring(0,1).toUpperCase()))}A(".mdhui-insights-badge {\n width: 32px;\n height: 32px;\n border: 1px solid var(--mdhui-border-color-1);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n}\n\n.mdhui-insights-badge.mdhui-insights-badge-xsmall {\n width: 20px;\n height: 20px;\n font-size: 12px;\n}\n\n.mdhui-insights-badge .mdhui-insights-badge-icon {\n color: var(--mdhui-background-color-0);\n}\n\n.mdhui-insights-badge .mdhui-insights-badge-label {\n color: var(--mdhui-text-color-2);\n line-height: 40px;\n}\n\n.mdhui-insights-badge.mdhui-insights-badge-highlighted .mdhui-insights-badge-label {\n color: var(--mdhui-text-color-1);\n}");A(".mdhui-insights-calendar .mdhui-calendar {\n padding-bottom: 8px;\n}\n\n.mdhui-insights-calendar .mdhui-week-calendar {\n border-top: none;\n border-bottom: none;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day {\n margin: 8px 0 0;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-label {\n font-size: 14px;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n text-align: center;\n margin-bottom: 16px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-footer {\n margin: 24px 2px 0;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-badges {\n margin-bottom: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 2px;\n flex-wrap: wrap;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-footer {\n border-top: 1px solid var(--mdhui-border-color-1);\n position: relative;\n min-height: 38px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend {\n padding: 8px 40px 8px;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 12px;\n flex-wrap: wrap;\n box-sizing: border-box;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry-color {\n height: 16px;\n width: 16px;\n border-radius: 50%;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry-label {\n font-size: 0.7em;\n color: var(--mdhui-text-color-2);\n font-weight: bold;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-loading-indicator.mdhui-loading-indicator {\n position: absolute;\n bottom: 8px;\n right: 16px;\n padding: 0;\n}");var dM={prefix:"far",iconName:"lightbulb",icon:[384,512,[128161],"f0eb","M297.2 248.9C311.6 228.3 320 203.2 320 176c0-70.7-57.3-128-128-128S64 105.3 64 176c0 27.2 8.4 52.3 22.8 72.9c3.7 5.3 8.1 11.3 12.8 17.7l0 0c12.9 17.7 28.3 38.9 39.8 59.8c10.4 19 15.7 38.8 18.3 57.5H109c-2.2-12-5.9-23.7-11.8-34.5c-9.9-18-22.2-34.9-34.5-51.8l0 0 0 0c-5.2-7.1-10.4-14.2-15.4-21.4C27.6 247.9 16 213.3 16 176C16 78.8 94.8 0 192 0s176 78.8 176 176c0 37.3-11.6 71.9-31.4 100.3c-5 7.2-10.2 14.3-15.4 21.4l0 0 0 0c-12.3 16.8-24.6 33.7-34.5 51.8c-5.9 10.8-9.6 22.5-11.8 34.5H226.4c2.6-18.7 7.9-38.6 18.3-57.5c11.5-20.9 26.9-42.1 39.8-59.8l0 0 0 0 0 0c4.7-6.4 9-12.4 12.7-17.7zM192 128c-26.5 0-48 21.5-48 48c0 8.8-7.2 16-16 16s-16-7.2-16-16c0-44.2 35.8-80 80-80c8.8 0 16 7.2 16 16s-7.2 16-16 16zm0 384c-44.2 0-80-35.8-80-80V416H272v16c0 44.2-35.8 80-80 80z"]},mM={prefix:"far",iconName:"circle-check",icon:[512,512,[61533,"check-circle"],"f058","M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-111 111-47-47c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l64 64c9.4 9.4 24.6 9.4 33.9 0L369 209z"]},hM={prefix:"far",iconName:"circle",icon:[512,512,[128308,128309,128992,128993,128994,128995,128996,9679,9898,9899,11044,61708,61915],"f111","M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256z"]},pM={prefix:"far",iconName:"sun",icon:[512,512,[9728],"f185","M375.7 19.7c-1.5-8-6.9-14.7-14.4-17.8s-16.1-2.2-22.8 2.4L256 61.1 173.5 4.2c-6.7-4.6-15.3-5.5-22.8-2.4s-12.9 9.8-14.4 17.8l-18.1 98.5L19.7 136.3c-8 1.5-14.7 6.9-17.8 14.4s-2.2 16.1 2.4 22.8L61.1 256 4.2 338.5c-4.6 6.7-5.5 15.3-2.4 22.8s9.8 13 17.8 14.4l98.5 18.1 18.1 98.5c1.5 8 6.9 14.7 14.4 17.8s16.1 2.2 22.8-2.4L256 450.9l82.5 56.9c6.7 4.6 15.3 5.5 22.8 2.4s12.9-9.8 14.4-17.8l18.1-98.5 98.5-18.1c8-1.5 14.7-6.9 17.8-14.4s2.2-16.1-2.4-22.8L450.9 256l56.9-82.5c4.6-6.7 5.5-15.3 2.4-22.8s-9.8-12.9-17.8-14.4l-98.5-18.1L375.7 19.7zM269.6 110l65.6-45.2 14.4 78.3c1.8 9.8 9.5 17.5 19.3 19.3l78.3 14.4L402 242.4c-5.7 8.2-5.7 19 0 27.2l45.2 65.6-78.3 14.4c-9.8 1.8-17.5 9.5-19.3 19.3l-14.4 78.3L269.6 402c-8.2-5.7-19-5.7-27.2 0l-65.6 45.2-14.4-78.3c-1.8-9.8-9.5-17.5-19.3-19.3L64.8 335.2 110 269.6c5.7-8.2 5.7-19 0-27.2L64.8 176.8l78.3-14.4c9.8-1.8 17.5-9.5 19.3-19.3l14.4-78.3L242.4 110c8.2 5.7 19 5.7 27.2 0zM256 368a112 112 0 1 0 0-224 112 112 0 1 0 0 224zM192 256a64 64 0 1 1 128 0 64 64 0 1 1 -128 0z"]};class gM extends of{constructor(e){super({...e,content:""}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e.id}_getType(){return"remove"}get _printableFields(){return{...super._printableFields,id:this.id}}}const fM=(e,t)=>{const a=[...new Set(t?.map((e=>{if("string"==typeof e)return e;const t=new e({});if(!("_getType"in t)||"function"!=typeof t._getType)throw new Error("Invalid type provided.");return t._getType()})))],n=e._getType();return a.some((e=>e===n))};function yM(e,t={}){const{includeNames:a,excludeNames:n,includeTypes:i,excludeTypes:r,includeIds:o,excludeIds:s}=t,l=[];for(const t of e)n&&t.name&&n.includes(t.name)||r&&fM(t,r)||s&&t.id&&s.includes(t.id)||(i||o||a?(a&&t.name&&a.some((e=>e===t.name))||i&&fM(t,i)||o&&t.id&&o.some((e=>e===t.id)))&&l.push(t):l.push(t));return l}function bM(e){if(!e.length)return[];const t=[];for(const a of e){const e=a,n=t.pop();if(n)if("tool"===e._getType()||e._getType()!==n._getType())t.push(n,e);else{const a=If(n),i=If(e),r=a.concat(i);"string"==typeof a.content&&"string"==typeof i.content&&(r.content=`${a.content}\n${i.content}`),t.push(AM(r))}else t.push(e)}return t}async function vM(e,t){const{maxTokens:a,tokenCounter:n,strategy:i="last",allowPartial:r=!1,endOn:o,startOn:s,includeSystem:l=!1,textSplitter:c}=t;if(s&&"first"===i)throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(l&&"first"===i)throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let u;u="getNumTokens"in n?async e=>(await Promise.all(e.map((e=>n.getNumTokens(e.content))))).reduce(((e,t)=>e+t),0):async e=>n(e);let d=SM;if(c&&(d="splitText"in c?c.splitText:async e=>c(e)),"first"===i)return wM(e,{maxTokens:a,tokenCounter:u,textSplitter:d,partialStrategy:r?"first":void 0,endOn:o});if("last"===i)return async function(e,t){const{allowPartial:a=!1,includeSystem:n=!1,endOn:i,startOn:r,...o}=t;if(i){const t=Array.isArray(i)?i:[i];for(;e&&!fM(e[e.length-1],t);)e.pop()}const s=n&&"system"===e[0]._getType();let l=s?e.slice(0,1).concat(e.slice(1).reverse()):e.reverse();return l=await wM(l,{...o,partialStrategy:a?"last":void 0,endOn:r}),s?[l[0],...l.slice(1).reverse()]:l.reverse()}(e,{maxTokens:a,tokenCounter:u,textSplitter:d,allowPartial:r,includeSystem:l,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function wM(e,t){const{maxTokens:a,tokenCounter:n,textSplitter:i,partialStrategy:r,endOn:o}=t;let s=[...e],l=0;for(let e=0;e<s.length;e+=1){const t=e>0?s.slice(0,-e):s;if(await n(t)<=a){l=s.length-e;break}}if(l<s.length-1&&r){let e=!1;if(Array.isArray(s[l].content)){const t=s[l];if("string"==typeof t.content)throw new Error("Expected content to be an array.");const i=t.content.length,o="last"===r?[...t.content].reverse():t.content;for(let c=1;c<=i;c+=1){const i="first"===r?o.slice(0,c):o.slice(-c),u=Object.fromEntries(Object.entries(t).filter((([e])=>"type"!==e&&!e.startsWith("lc_")))),d=kM(t._getType(),{...u,content:i}),m=[...s.slice(0,l),d];if(!(await n(m)<=a))break;s=m,l+=1,e=!0}e&&"last"===r&&(t.content=[...o].reverse())}if(!e){const e=s[l];let t;if(Array.isArray(e.content)&&e.content.some((e=>"string"==typeof e||"text"===e.type))){const a=e.content.find((e=>"text"===e.type&&e.text));t=a?.text}else"string"==typeof e.content&&(t=e.content);if(t){const o=await i(t),c=o.length;"last"===r&&o.reverse();for(let t=0;t<c-1;t+=1)if(o.pop(),e.content=o.join(""),await n([...s.slice(0,l),e])<=a){"last"===r&&(e.content=[...o].reverse().join("")),s=[...s.slice(0,l),e],l+=1;break}}}}if(o){const e=Array.isArray(o)?o:[o];for(;l>0&&!fM(s[l-1],e);)l-=1}return s.slice(0,l)}const xM={human:{message:Sf,messageChunk:Ef},ai:{message:ff,messageChunk:vf},system:{message:_f,messageChunk:Cf},tool:{message:pf,messageChunk:gf},function:{message:kf,messageChunk:Af},generic:{message:wf,messageChunk:xf},remove:{message:gM,messageChunk:gM}};function kM(e,t,a){let n;switch(e){case"human":n=new Sf(t);break;case"ai":n=new ff(t);break;case"system":n=new _f(t);break;case"tool":if(!("tool_call_id"in t))throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");n=new pf(t);break;case"function":if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new kf(t);break;case"generic":if(!("role"in t))throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");n=new wf(t);break;default:throw new Error(`Unrecognized message type ${e}`)}if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function AM(e){const t=e._getType();let a;const n=Object.fromEntries(Object.entries(e).filter((([e])=>!["type","tool_call_chunks"].includes(e)&&!e.startsWith("lc_"))));if(t in xM&&(a=kM(t,n)),!a)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(xM)}`);return a}function SM(e){const t=e.split("\n");return Promise.resolve([...t.slice(0,-1).map((e=>`${e}\n`)),t[t.length-1]])}var EM=Object.freeze({__proto__:null,AIMessage:ff,AIMessageChunk:vf,BaseMessage:of,BaseMessageChunk:uf,ChatMessage:wf,ChatMessageChunk:xf,FunctionMessage:kf,FunctionMessageChunk:Af,HumanMessage:Sf,HumanMessageChunk:Ef,RemoveMessage:gM,SystemMessage:_f,SystemMessageChunk:Cf,ToolMessage:pf,ToolMessageChunk:gf,_isMessageFieldWithRole:df,_mergeDicts:sf,_mergeLists:lf,_mergeObj:cf,_mergeStatus:rf,coerceMessageLikeToMessage:Of,convertToChunk:If,defaultTextSplitter:SM,filterMessages:function(e,t){return Array.isArray(e)?yM(e,t):pA.from((t=>yM(t,e)))},getBufferString:Df,isAIMessage:yf,isAIMessageChunk:bf,isBaseMessage:mf,isBaseMessageChunk:hf,isChatMessage:function(e){return"generic"===e._getType()},isChatMessageChunk:function(e){return"generic"===e._getType()},isFunctionMessage:function(e){return"function"===e._getType()},isFunctionMessageChunk:function(e){return"function"===e._getType()},isHumanMessage:function(e){return"human"===e.getType()},isHumanMessageChunk:function(e){return"human"===e.getType()},isOpenAIToolCallArray:function(e){return Array.isArray(e)&&e.every((e=>"number"==typeof e.index))},isSystemMessage:function(e){return"system"===e._getType()},isSystemMessageChunk:function(e){return"system"===e._getType()},isToolMessage:function(e){return"tool"===e._getType()},isToolMessageChunk:function(e){return"tool"===e._getType()},mapChatMessagesToStoredMessages:function(e){return e.map((e=>e.toDict()))},mapStoredMessageToChatMessage:Mf,mapStoredMessagesToChatMessages:function(e){return e.map(Mf)},mergeContent:nf,mergeMessageRuns:function(e){return Array.isArray(e)?bM(e):pA.from(bM)},trimMessages:function(e,t){if(Array.isArray(e)){const a=e;if(!t)throw new Error("Options parameter is required when providing messages.");return vM(a,t)}{const t=e;return pA.from((e=>vM(e,t)))}}});const _M="4.68.1";let CM,TM,PM,OM,DM,MM,IM,NM,jM,zM=!1;class RM{constructor(e){this.body=e}get[Symbol.toStringTag](){return"MultipartBody"}}CM||function(e,t={auto:!1}){if(zM)throw new Error(`you must \`import 'openai/shims/${e.kind}'\` before importing anything else from openai`);if(CM)throw new Error(`can't \`import 'openai/shims/${e.kind}'\` after \`import 'openai/shims/${CM}'\``);zM=t.auto,CM=e.kind,TM=e.fetch,PM=e.FormData,OM=e.File,DM=e.ReadableStream,MM=e.getMultipartRequestOptions,IM=e.getDefaultAgent,NM=e.fileFromPath,jM=e.isFsReadStream}(function({manuallyImported:e}={}){const t=e?"You may need to use polyfills":"Add one of these imports before your first `import … from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n";let a,n,i,r;try{a=fetch,n=Request,i=Response,r=Headers}catch(e){throw new Error(`this environment is missing the following Web Fetch API type: ${e.message}. ${t}`)}return{kind:"web",fetch:a,Request:n,Response:i,Headers:r,FormData:"undefined"!=typeof FormData?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${t}`)}},Blob:"undefined"!=typeof Blob?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${t}`)}},File:"undefined"!=typeof File?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${t}`)}},ReadableStream:"undefined"!=typeof ReadableStream?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${t}`)}},getMultipartRequestOptions:async(e,t)=>({...t,body:new RM(e)}),getDefaultAgent:e=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:e=>!1}}(),{auto:!0});class LM{constructor(){this.buffer=[],this.trailingCR=!1}decode(e){let t=this.decodeText(e);if(this.trailingCR&&(t="\r"+t,this.trailingCR=!1),t.endsWith("\r")&&(this.trailingCR=!0,t=t.slice(0,-1)),!t)return[];const a=LM.NEWLINE_CHARS.has(t[t.length-1]||"");let n=t.split(LM.NEWLINE_REGEXP);return a&&n.pop(),1!==n.length||a?(this.buffer.length>0&&(n=[this.buffer.join("")+n[0],...n.slice(1)],this.buffer=[]),a||(this.buffer=[n.pop()||""]),n):(this.buffer.push(n[0]),[])}decodeText(e){if(null==e)return"";if("string"==typeof e)return e;if("undefined"!=typeof Buffer){if(e instanceof Buffer)return e.toString();if(e instanceof Uint8Array)return Buffer.from(e).toString();throw new OI(`Unexpected: received non-Uint8Array (${e.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if("undefined"!=typeof TextDecoder){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(e);throw new OI(`Unexpected: received non-Uint8Array/ArrayBuffer (${e.constructor.name}) in a web platform. Please report this error.`)}throw new OI("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length&&!this.trailingCR)return[];const e=[this.buffer.join("")];return this.buffer=[],this.trailingCR=!1,e}}LM.NEWLINE_CHARS=new Set(["\n","\r"]),LM.NEWLINE_REGEXP=/\r\n|[\n\r]/g;class FM{constructor(e,t){this.iterator=e,this.controller=t}static fromSSEResponse(e,t){let a=!1;return new FM((async function*(){if(a)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let n=!1;try{for await(const a of async function*(e,t){if(!e.body)throw t.abort(),new OI("Attempted to iterate over a response with no body");const a=new HM,n=new LM,i=qM(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const a of e){if(null==a)continue;const e=a instanceof ArrayBuffer?new Uint8Array(a):"string"==typeof a?(new TextEncoder).encode(a):a;let n,i=new Uint8Array(t.length+e.length);for(i.set(t),i.set(e,t.length),t=i;-1!==(n=BM(t));)yield t.slice(0,n),t=t.slice(n)}t.length>0&&(yield t)}(i))for(const t of n.decode(e)){const e=a.decode(t);e&&(yield e)}for(const e of n.flush()){const t=a.decode(e);t&&(yield t)}}(e,t))if(!n)if(a.data.startsWith("[DONE]"))n=!0;else if(null===a.event){let e;try{e=JSON.parse(a.data)}catch(e){throw console.error("Could not parse message into JSON:",a.data),console.error("From chunk:",a.raw),e}if(e&&e.error)throw new DI(void 0,e.error,void 0,void 0);yield e}else{let e;try{e=JSON.parse(a.data)}catch(e){throw console.error("Could not parse message into JSON:",a.data),console.error("From chunk:",a.raw),e}if("error"==a.event)throw new DI(void 0,e.error,e.message,void 0);yield{event:a.event,data:e}}n=!0}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}finally{n||t.abort()}}),t)}static fromReadableStream(e,t){let a=!1;return new FM((async function*(){if(a)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let n=!1;try{for await(const t of async function*(){const t=new LM,a=qM(e);for await(const e of a)for(const a of t.decode(e))yield a;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}finally{n||t.abort()}}),t)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],t=[],a=this.iterator(),n=n=>({next:()=>{if(0===n.length){const n=a.next();e.push(n),t.push(n)}return n.shift()}});return[new FM((()=>n(e)),this.controller),new FM((()=>n(t)),this.controller)]}toReadableStream(){const e=this;let t;const a=new TextEncoder;return new DM({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:i}=await t.next();if(i)return e.close();const r=a.encode(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}function BM(e){for(let t=0;t<e.length-2;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}class HM{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,a,n]=function(e,t){const a=e.indexOf(t);if(-1!==a)return[e.substring(0,a),t,e.substring(a+t.length)];return[e,"",""]}(e,":");return n.startsWith(" ")&&(n=n.substring(1)),"event"===t?this.event=n:"data"===t&&this.data.push(n),null}}function qM(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const UM=e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob,WM=e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&VM(e),VM=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function $M(e,t,a){if(e=await e,WM(e))return e;if(UM(e)){const n=await e.blob();t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()??"unknown_file");const i=VM(n)?[await n.arrayBuffer()]:[n];return new OM(i,t,a)}const n=await async function(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(VM(e))t.push(await e.arrayBuffer());else{if(!KM(e))throw new Error(`Unexpected data type: ${typeof e}; constructor: ${e?.constructor?.name}; props: ${function(e){const t=Object.getOwnPropertyNames(e);return`[${t.map((e=>`"${e}"`)).join(", ")}]`}(e)}`);for await(const a of e)t.push(a)}return t}(e);if(t||(t=function(e){return GM(e.name)||GM(e.filename)||GM(e.path)?.split(/[\\/]/).pop()}(e)??"unknown_file"),!a?.type){const e=n[0]?.type;"string"==typeof e&&(a={...a,type:e})}return new OM(n,t,a)}const GM=e=>"string"==typeof e?e:"undefined"!=typeof Buffer&&e instanceof Buffer?String(e):void 0,KM=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],ZM=e=>e&&"object"==typeof e&&e.body&&"MultipartBody"===e[Symbol.toStringTag],YM=async e=>{const t=await XM(e.body);return MM(t,e)},XM=async e=>{const t=new PM;return await Promise.all(Object.entries(e||{}).map((([e,a])=>QM(t,e,a)))),t},QM=async(e,t,a)=>{if(void 0!==a){if(null==a)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof a||"number"==typeof a||"boolean"==typeof a)e.append(t,String(a));else if((e=>WM(e)||UM(e)||jM(e))(a)){const n=await $M(a);e.append(t,n)}else if(Array.isArray(a))await Promise.all(a.map((a=>QM(e,t+"[]",a))));else{if("object"!=typeof a)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${a} instead`);await Promise.all(Object.entries(a).map((([a,n])=>QM(e,`${t}[${a}]`,n))))}}};var JM,eI=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},tI=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};async function aI(e){const{response:t}=e;if(e.options.stream)return _I("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller):FM.fromSSEResponse(t,e.controller);if(204===t.status)return null;if(e.options.__binaryResponse)return t;const a=t.headers.get("content-type");if(a?.includes("application/json")||a?.includes("application/vnd.api+json")){const e=await t.json();return _I("response",t.status,t.url,t.headers,e),nI(e,t)}const n=await t.text();return _I("response",t.status,t.url,t.headers,n),n}function nI(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class iI extends Promise{constructor(e,t=aI){super((e=>{e(null)})),this.responsePromise=e,this.parseResponse=t}_thenUnwrap(e){return new iI(this.responsePromise,(async t=>nI(e(await this.parseResponse(t),t),t.response)))}asResponse(){return this.responsePromise.then((e=>e.response))}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}class rI{constructor({baseURL:e,maxRetries:t=2,timeout:a=6e5,httpAgent:n,fetch:i}){this.baseURL=e,this.maxRetries=wI("maxRetries",t),this.timeout=wI("timeout",a),this.httpAgent=n,this.fetch=i??TM}authHeaders(e){return{}}defaultHeaders(e){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...gI(),...this.authHeaders(e)}}validateHeaders(e,t){}defaultIdempotencyKey(){return`stainless-node-retry-${CI()}`}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,a){return this.request(Promise.resolve(a).then((async a=>{const n=a&&VM(a?.body)?new DataView(await a.body.arrayBuffer()):a?.body instanceof DataView?a.body:a?.body instanceof ArrayBuffer?new DataView(a.body):a&&ArrayBuffer.isView(a?.body)?new DataView(a.body.buffer):a?.body;return{method:e,path:t,...a,body:n}})))}getAPIList(e,t,a){return this.requestAPIList(t,{method:"get",path:e,...a})}calculateContentLength(e){if("string"==typeof e){if("undefined"!=typeof Buffer)return Buffer.byteLength(e,"utf8").toString();if("undefined"!=typeof TextEncoder){return(new TextEncoder).encode(e).length.toString()}}else if(ArrayBuffer.isView(e))return e.byteLength.toString();return null}buildRequest(e,{retryCount:t=0}={}){const{method:a,path:n,query:i,headers:r={}}=e,o=ArrayBuffer.isView(e.body)||e.__binaryRequest&&"string"==typeof e.body?e.body:ZM(e.body)?e.body.body:e.body?JSON.stringify(e.body,null,2):null,s=this.calculateContentLength(o),l=this.buildURL(n,i);"timeout"in e&&wI("timeout",e.timeout);const c=e.timeout??this.timeout,u=e.httpAgent??this.httpAgent??IM(l),d=c+1e3;"number"==typeof u?.options?.timeout&&d>(u.options.timeout??0)&&(u.options.timeout=d),this.idempotencyHeader&&"get"!==a&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);return{req:{method:a,...o&&{body:o},headers:this.buildHeaders({options:e,headers:r,contentLength:s,retryCount:t}),...u&&{agent:u},signal:e.signal??null},url:l,timeout:c}}buildHeaders({options:e,headers:t,contentLength:a,retryCount:n}){const i={};a&&(i["content-length"]=a);const r=this.defaultHeaders(e);return EI(i,r),EI(i,t),ZM(e.body)&&"node"!==CM&&delete i["content-type"],void 0===TI(r,"x-stainless-retry-count")&&void 0===TI(t,"x-stainless-retry-count")&&(i["x-stainless-retry-count"]=String(n)),this.validateHeaders(i,t),i}async prepareOptions(e){}async prepareRequest(e,{url:t,options:a}){}parseHeaders(e){return e?Symbol.iterator in e?Object.fromEntries(Array.from(e).map((e=>[...e]))):{...e}:{}}makeStatusError(e,t,a,n){return DI.generate(e,t,a,n)}request(e,t=null){return new iI(this.makeRequest(e,t))}async makeRequest(e,t){const a=await e,n=a.maxRetries??this.maxRetries;null==t&&(t=n),await this.prepareOptions(a);const{req:i,url:r,timeout:o}=this.buildRequest(a,{retryCount:n-t});if(await this.prepareRequest(i,{url:r,options:a}),_I("request",r,a,i.headers),a.signal?.aborted)throw new MI;const s=new AbortController,l=await this.fetchWithTimeout(r,i,o,s).catch(xI);if(l instanceof Error){if(a.signal?.aborted)throw new MI;if(t)return this.retryRequest(a,t);if("AbortError"===l.name)throw new NI;throw new II({cause:l})}const c=lI(l.headers);if(!l.ok){if(t&&this.shouldRetry(l)){return _I(`response (error; ${`retrying, ${t} attempts remaining`})`,l.status,r,c),this.retryRequest(a,t,c)}const e=await l.text().catch((e=>xI(e).message)),n=fI(e),i=n?void 0:e;_I(`response (error; ${t?"(error; no more retries left)":"(error; not retryable)"})`,l.status,r,c,i);throw this.makeStatusError(l.status,n,i,c)}return{response:l,options:a,controller:s}}requestAPIList(e,t){const a=this.makeRequest(t,null);return new sI(this,a,e)}buildURL(e,t){const a=bI(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),n=this.defaultQuery();return AI(n)||(t={...n,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}stringifyQuery(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new OI(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)})).join("&")}async fetchWithTimeout(e,t,a,n){const{signal:i,...r}=t||{};i&&i.addEventListener("abort",(()=>n.abort()));const o=setTimeout((()=>n.abort()),a);return this.getRequestClient().fetch.call(void 0,e,{signal:n.signal,...r}).finally((()=>{clearTimeout(o)}))}getRequestClient(){return{fetch:this.fetch}}shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,a){let n;const i=a?.["retry-after-ms"];if(i){const e=parseFloat(i);Number.isNaN(e)||(n=e)}const r=a?.["retry-after"];if(r&&!n){const e=parseFloat(r);n=Number.isNaN(e)?Date.parse(r)-Date.now():1e3*e}if(!(n&&0<=n&&n<6e4)){const a=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,a)}return await vI(n),this.makeRequest(e,t-1)}calculateDefaultRetryTimeoutMillis(e,t){const a=t-e;return Math.min(.5*Math.pow(2,a),8)*(1-.25*Math.random())*1e3}getUserAgent(){return`${this.constructor.name}/JS ${_M}`}}class oI{constructor(e,t,a,n){JM.set(this,void 0),eI(this,JM,e,"f"),this.options=n,this.response=t,this.body=a}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageInfo()}async getNextPage(){const e=this.nextPageInfo();if(!e)throw new OI("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");const t={...this.options};if("params"in e&&"object"==typeof t.query)t.query={...t.query,...e.params};else if("url"in e){const a=[...Object.entries(t.query||{}),...e.url.searchParams.entries()];for(const[t,n]of a)e.url.searchParams.set(t,n);t.query=void 0,t.path=e.url.toString()}return await tI(this,JM,"f").requestAPIList(this.constructor,t)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(JM=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class sI extends iI{constructor(e,t,a){super(t,(async t=>new a(e,t.response,await aI(t),t.options)))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}const lI=e=>new Proxy(Object.fromEntries(e.entries()),{get(e,t){const a=t.toString();return e[a.toLowerCase()]||e[a]}}),cI={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},uI=e=>"object"==typeof e&&null!==e&&!AI(e)&&Object.keys(e).every((e=>SI(cI,e))),dI=()=>{if("undefined"!=typeof Deno&&null!=Deno.build)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":hI(Deno.build.os),"X-Stainless-Arch":mI(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if("[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0))return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":hI(process.platform),"X-Stainless-Arch":mI(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};const e=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:a}of e){const e=a.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const mI=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",hI=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let pI;const gI=()=>pI??(pI=dI()),fI=e=>{try{return JSON.parse(e)}catch(e){return}},yI=new RegExp("^(?:[a-z]+:)?//","i"),bI=e=>yI.test(e),vI=e=>new Promise((t=>setTimeout(t,e))),wI=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new OI(`${e} must be an integer`);if(t<0)throw new OI(`${e} must be a positive integer`);return t},xI=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e)try{return new Error(JSON.stringify(e))}catch{}return new Error(e)},kI=e=>"undefined"!=typeof process?process.env?.[e]?.trim()??void 0:"undefined"!=typeof Deno?Deno.env?.get?.(e)?.trim():void 0;function AI(e){if(!e)return!0;for(const t in e)return!1;return!0}function SI(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function EI(e,t){for(const a in t){if(!SI(t,a))continue;const n=a.toLowerCase();if(!n)continue;const i=t[a];null===i?delete e[n]:void 0!==i&&(e[n]=i)}}function _I(e,...t){"undefined"!=typeof process&&"true"===process?.env?.DEBUG&&console.log(`OpenAI:DEBUG:${e}`,...t)}const CI=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),TI=(e,t)=>{const a=t.toLowerCase();if((e=>"function"==typeof e?.get)(e)){const n=t[0]?.toUpperCase()+t.substring(1).replace(/([^\w])(\w)/g,((e,t,a)=>t+a.toUpperCase()));for(const i of[t,a,t.toUpperCase(),n]){const t=e.get(i);if(t)return t}}for(const[n,i]of Object.entries(e))if(n.toLowerCase()===a)return Array.isArray(i)?(i.length<=1||console.warn(`Received ${i.length} entries for the ${t} header, using the first entry.`),i[0]):i};function PI(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}let OI=class extends Error{},DI=class e extends OI{constructor(t,a,n,i){super(`${e.makeMessage(t,a,n)}`),this.status=t,this.headers=i,this.request_id=i?.["x-request-id"];const r=a;this.error=r,this.code=r?.code,this.param=r?.param,this.type=r?.type}static makeMessage(e,t,a){const n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):a;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(t,a,n,i){if(!t)return new II({message:n,cause:xI(a)});const r=a?.error;return 400===t?new jI(t,r,n,i):401===t?new zI(t,r,n,i):403===t?new RI(t,r,n,i):404===t?new LI(t,r,n,i):409===t?new FI(t,r,n,i):422===t?new BI(t,r,n,i):429===t?new HI(t,r,n,i):t>=500?new qI(t,r,n,i):new e(t,r,n,i)}},MI=class extends DI{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0),this.status=void 0}},II=class extends DI{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),this.status=void 0,t&&(this.cause=t)}},NI=class extends II{constructor({message:e}={}){super({message:e??"Request timed out."})}},jI=class extends DI{constructor(){super(...arguments),this.status=400}},zI=class extends DI{constructor(){super(...arguments),this.status=401}},RI=class extends DI{constructor(){super(...arguments),this.status=403}},LI=class extends DI{constructor(){super(...arguments),this.status=404}},FI=class extends DI{constructor(){super(...arguments),this.status=409}},BI=class extends DI{constructor(){super(...arguments),this.status=422}},HI=class extends DI{constructor(){super(...arguments),this.status=429}},qI=class extends DI{};class UI extends OI{constructor(){super("Could not parse response content as the length limit was reached")}}class WI extends OI{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var VI=Object.freeze({__proto__:null,APIConnectionError:II,APIConnectionTimeoutError:NI,APIError:DI,APIUserAbortError:MI,AuthenticationError:zI,BadRequestError:jI,ConflictError:FI,ContentFilterFinishReasonError:WI,InternalServerError:qI,LengthFinishReasonError:UI,NotFoundError:LI,OpenAIError:OI,PermissionDeniedError:RI,RateLimitError:HI,UnprocessableEntityError:BI});const $I="RFC3986",GI={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},KI=Array.isArray,ZI=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),YI=1024;function XI(e,t){if(KI(e)){const a=[];for(let n=0;n<e.length;n+=1)a.push(t(e[n]));return a}return t(e)}const QI=Object.prototype.hasOwnProperty,JI={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},eN=Array.isArray,tN=Array.prototype.push,aN=function(e,t){tN.apply(e,eN(t)?t:[t])},nN=Date.prototype.toISOString,iN={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,a,n,i)=>{if(0===e.length)return e;let r=e;if("symbol"==typeof e?r=Symbol.prototype.toString.call(e):"string"!=typeof e&&(r=String(e)),"iso-8859-1"===a)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));let o="";for(let e=0;e<r.length;e+=YI){const t=r.length>=YI?r.slice(e,e+YI):r,a=[];for(let e=0;e<t.length;++e){let n=t.charCodeAt(e);45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||"RFC1738"===i&&(40===n||41===n)?a[a.length]=t.charAt(e):n<128?a[a.length]=ZI[n]:n<2048?a[a.length]=ZI[192|n>>6]+ZI[128|63&n]:n<55296||n>=57344?a[a.length]=ZI[224|n>>12]+ZI[128|n>>6&63]+ZI[128|63&n]:(e+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),a[a.length]=ZI[240|n>>18]+ZI[128|n>>12&63]+ZI[128|n>>6&63]+ZI[128|63&n])}o+=a.join("")}return o},encodeValuesOnly:!1,format:$I,formatter:GI[$I],indices:!1,serializeDate:e=>nN.call(e),skipNulls:!1,strictNullHandling:!1};const rN={};function oN(e,t,a,n,i,r,o,s,l,c,u,d,m,h,p,g,f,y){let b=e,v=y,w=0,x=!1;for(;void 0!==(v=v.get(rN))&&!x;){const t=v.get(e);if(w+=1,void 0!==t){if(t===w)throw new RangeError("Cyclic object value");x=!0}void 0===v.get(rN)&&(w=0)}if("function"==typeof c?b=c(t,b):b instanceof Date?b=m?.(b):"comma"===a&&eN(b)&&(b=XI(b,(function(e){return e instanceof Date?m?.(e):e}))),null===b){if(r)return l&&!g?l(t,iN.encoder,f,"key",h):t;b=""}if("string"==typeof(k=b)||"number"==typeof k||"boolean"==typeof k||"symbol"==typeof k||"bigint"==typeof k||function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}(b)){if(l){const e=g?t:l(t,iN.encoder,f,"key",h);return[p?.(e)+"="+p?.(l(b,iN.encoder,f,"value",h))]}return[p?.(t)+"="+p?.(String(b))]}var k;const A=[];if(void 0===b)return A;let S;if("comma"===a&&eN(b))g&&l&&(b=XI(b,l)),S=[{value:b.length>0?b.join(",")||null:void 0}];else if(eN(c))S=c;else{const e=Object.keys(b);S=u?e.sort(u):e}const E=s?String(t).replace(/\./g,"%2E"):String(t),_=n&&eN(b)&&1===b.length?E+"[]":E;if(i&&eN(b)&&0===b.length)return _+"[]";for(let t=0;t<S.length;++t){const v=S[t],x="object"==typeof v&&void 0!==v.value?v.value:b[v];if(o&&null===x)continue;const k=d&&s?v.replace(/\./g,"%2E"):v,E=eN(b)?"function"==typeof a?a(_,k):_:_+(d?"."+k:"["+k+"]");y.set(e,w);const C=new WeakMap;C.set(rN,y),aN(A,oN(x,E,a,n,i,r,o,s,"comma"===a&&g&&eN(b)?null:l,c,u,d,m,h,p,g,f,C))}return A}function sN(e,t={}){let a=e;const n=function(e=iN){if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");const t=e.charset||iN.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let a=$I;if(void 0!==e.format){if(!QI.call(GI,e.format))throw new TypeError("Unknown format option provided.");a=e.format}const n=GI[a];let i,r=iN.filter;if(("function"==typeof e.filter||eN(e.filter))&&(r=e.filter),i=e.arrayFormat&&e.arrayFormat in JI?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":iN.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const o=void 0===e.allowDots?1==!!e.encodeDotInKeys||iN.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:iN.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:iN.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:iN.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?iN.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:iN.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:iN.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:iN.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:iN.encodeValuesOnly,filter:r,format:a,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:iN.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:iN.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:iN.strictNullHandling}}(t);let i,r;"function"==typeof n.filter?(r=n.filter,a=r("",a)):eN(n.filter)&&(r=n.filter,i=r);const o=[];if("object"!=typeof a||null===a)return"";const s=JI[n.arrayFormat],l="comma"===s&&n.commaRoundTrip;i||(i=Object.keys(a)),n.sort&&i.sort(n.sort);const c=new WeakMap;for(let e=0;e<i.length;++e){const t=i[e];n.skipNulls&&null===a[t]||aN(o,oN(a[t],t,s,l,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}const u=o.join(n.delimiter);let d=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),u.length>0?d+u:""}let lN=class extends oI{constructor(e,t,a,n){super(e,t,a,n),this.data=a.data||[],this.object=a.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}};class cN extends oI{constructor(e,t,a,n){super(e,t,a,n),this.data=a.data||[]}getPaginatedItems(){return this.data??[]}nextPageParams(){const e=this.nextPageInfo();if(!e)return null;if("params"in e)return e.params;const t=Object.fromEntries(e.url.searchParams);return Object.keys(t).length?t:null}nextPageInfo(){const e=this.getPaginatedItems();if(!e.length)return null;const t=e[e.length-1]?.id;return t?{params:{after:t}}:null}}class uN{constructor(e){this._client=e}}let dN=class extends uN{create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}};dN||(dN={});let mN=class extends uN{constructor(){super(...arguments),this.completions=new dN(this._client)}};(mN||(mN={})).Completions=dN;class hN extends uN{create(e,t){return this._client.post("/audio/speech",{body:e,...t,__binaryResponse:!0})}}hN||(hN={});class pN extends uN{create(e,t){return this._client.post("/audio/transcriptions",YM({body:e,...t}))}}pN||(pN={});class gN extends uN{create(e,t){return this._client.post("/audio/translations",YM({body:e,...t}))}}gN||(gN={});class fN extends uN{constructor(){super(...arguments),this.transcriptions=new pN(this._client),this.translations=new gN(this._client),this.speech=new hN(this._client)}}!function(e){e.Transcriptions=pN,e.Translations=gN,e.Speech=hN}(fN||(fN={}));class yN extends uN{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(`/batches/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/batches",bN,{query:e,...t})}cancel(e,t){return this._client.post(`/batches/${e}/cancel`,t)}}class bN extends cN{}!function(e){e.BatchesPage=bN}(yN||(yN={}));class vN extends uN{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/assistants/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/assistants",wN,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class wN extends cN{}function xN(e){return"function"==typeof e.parse}!function(e){e.AssistantsPage=wN}(vN||(vN={}));const kN=e=>"assistant"===e?.role,AN=e=>"function"===e?.role,SN=e=>"tool"===e?.role;var EN,_N,CN,TN,PN,ON,DN,MN,IN,NN,jN,zN,RN,LN=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},FN=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};class BN{constructor(){EN.add(this),this.controller=new AbortController,_N.set(this,void 0),CN.set(this,(()=>{})),TN.set(this,(()=>{})),PN.set(this,void 0),ON.set(this,(()=>{})),DN.set(this,(()=>{})),MN.set(this,{}),IN.set(this,!1),NN.set(this,!1),jN.set(this,!1),zN.set(this,!1),LN(this,_N,new Promise(((e,t)=>{LN(this,CN,e,"f"),LN(this,TN,t,"f")})),"f"),LN(this,PN,new Promise(((e,t)=>{LN(this,ON,e,"f"),LN(this,DN,t,"f")})),"f"),FN(this,_N,"f").catch((()=>{})),FN(this,PN,"f").catch((()=>{}))}_run(e){setTimeout((()=>{e().then((()=>{this._emitFinal(),this._emit("end")}),FN(this,EN,"m",RN).bind(this))}),0)}_connected(){this.ended||(FN(this,CN,"f").call(this),this._emit("connect"))}get ended(){return FN(this,IN,"f")}get errored(){return FN(this,NN,"f")}get aborted(){return FN(this,jN,"f")}abort(){this.controller.abort()}on(e,t){return(FN(this,MN,"f")[e]||(FN(this,MN,"f")[e]=[])).push({listener:t}),this}off(e,t){const a=FN(this,MN,"f")[e];if(!a)return this;const n=a.findIndex((e=>e.listener===t));return n>=0&&a.splice(n,1),this}once(e,t){return(FN(this,MN,"f")[e]||(FN(this,MN,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise(((t,a)=>{LN(this,zN,!0,"f"),"error"!==e&&this.once("error",a),this.once(e,t)}))}async done(){LN(this,zN,!0,"f"),await FN(this,PN,"f")}_emit(e,...t){if(FN(this,IN,"f"))return;"end"===e&&(LN(this,IN,!0,"f"),FN(this,ON,"f").call(this));const a=FN(this,MN,"f")[e];if(a&&(FN(this,MN,"f")[e]=a.filter((e=>!e.once)),a.forEach((({listener:e})=>e(...t)))),"abort"===e){const e=t[0];return FN(this,zN,"f")||a?.length||Promise.reject(e),FN(this,TN,"f").call(this,e),FN(this,DN,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];FN(this,zN,"f")||a?.length||Promise.reject(e),FN(this,TN,"f").call(this,e),FN(this,DN,"f").call(this,e),this._emit("end")}}_emitFinal(){}}function HN(e){return"auto-parseable-response-format"===e?.$brand}function qN(e){return"auto-parseable-tool"===e?.$brand}function UN(e,t){const a=e.choices.map((e=>{if("length"===e.finish_reason)throw new UI;if("content_filter"===e.finish_reason)throw new WI;return{...e,message:{...e.message,tool_calls:e.message.tool_calls?.map((e=>function(e,t){const a=e.tools?.find((e=>e.function?.name===t.function.name));return{...t,function:{...t.function,parsed_arguments:qN(a)?a.$parseRaw(t.function.arguments):a?.function.strict?JSON.parse(t.function.arguments):null}}}(t,e)))??[],parsed:e.message.content&&!e.message.refusal?WN(t,e.message.content):null}}}));return{...e,choices:a}}function WN(e,t){if("json_schema"!==e.response_format?.type)return null;if("json_schema"===e.response_format?.type){if("$parseRaw"in e.response_format){return e.response_format.$parseRaw(t)}return JSON.parse(t)}return null}function VN(e,t){if(!e)return!1;const a=e.tools?.find((e=>e.function?.name===t.function.name));return qN(a)||a?.function.strict||!1}function $N(e){return!!HN(e.response_format)||(e.tools?.some((e=>qN(e)||"function"===e.type&&!0===e.function.strict))??!1)}_N=new WeakMap,CN=new WeakMap,TN=new WeakMap,PN=new WeakMap,ON=new WeakMap,DN=new WeakMap,MN=new WeakMap,IN=new WeakMap,NN=new WeakMap,jN=new WeakMap,zN=new WeakMap,EN=new WeakSet,RN=function(e){if(LN(this,NN,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new MI),e instanceof MI)return LN(this,jN,!0,"f"),this._emit("abort",e);if(e instanceof OI)return this._emit("error",e);if(e instanceof Error){const t=new OI(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new OI(String(e)))};var GN,KN,ZN,YN,XN,QN,JN,ej,tj=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};const aj=10;class nj extends BN{constructor(){super(...arguments),GN.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t)if(this._emit("message",e),(AN(e)||SN(e))&&e.content)this._emit("functionCallResult",e.content);else if(kN(e)&&e.function_call)this._emit("functionCall",e.function_call);else if(kN(e)&&e.tool_calls)for(const t of e.tool_calls)"function"===t.type&&this._emit("functionCall",t.function)}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new OI("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),tj(this,GN,"m",KN).call(this)}async finalMessage(){return await this.done(),tj(this,GN,"m",ZN).call(this)}async finalFunctionCall(){return await this.done(),tj(this,GN,"m",YN).call(this)}async finalFunctionCallResult(){return await this.done(),tj(this,GN,"m",XN).call(this)}async totalUsage(){return await this.done(),tj(this,GN,"m",QN).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const t=tj(this,GN,"m",ZN).call(this);t&&this._emit("finalMessage",t);const a=tj(this,GN,"m",KN).call(this);a&&this._emit("finalContent",a);const n=tj(this,GN,"m",YN).call(this);n&&this._emit("finalFunctionCall",n);const i=tj(this,GN,"m",XN).call(this);null!=i&&this._emit("finalFunctionCallResult",i),this._chatCompletions.some((e=>e.usage))&&this._emit("totalUsage",tj(this,GN,"m",QN).call(this))}async _createChatCompletion(e,t,a){const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort()))),tj(this,GN,"m",JN).call(this,t);const i=await e.chat.completions.create({...t,stream:!1},{...a,signal:this.controller.signal});return this._connected(),this._addChatCompletion(UN(i,t))}async _runChatCompletion(e,t,a){for(const e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,a)}async _runFunctions(e,t,a){const n="function",{function_call:i="auto",stream:r,...o}=t,s="string"!=typeof i&&i?.name,{maxChatCompletions:l=aj}=a||{},c={};for(const e of t.functions)c[e.name||e.function.name]=e;const u=t.functions.map((e=>({name:e.name||e.function.name,parameters:e.parameters,description:e.description})));for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){const t=await this._createChatCompletion(e,{...o,function_call:i,functions:u,messages:[...this.messages]},a),r=t.choices[0]?.message;if(!r)throw new OI("missing message in ChatCompletion response");if(!r.function_call)return;const{name:l,arguments:d}=r.function_call,m=c[l];if(!m){const e=`Invalid function_call: ${JSON.stringify(l)}. Available options are: ${u.map((e=>JSON.stringify(e.name))).join(", ")}. Please try again`;this._addMessage({role:n,name:l,content:e});continue}if(s&&s!==l){const e=`Invalid function_call: ${JSON.stringify(l)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:n,name:l,content:e});continue}let h;try{h=xN(m)?await m.parse(d):d}catch(e){this._addMessage({role:n,name:l,content:e instanceof Error?e.message:String(e)});continue}const p=await m.function(h,this),g=tj(this,GN,"m",ej).call(this,p);if(this._addMessage({role:n,name:l,content:g}),s)return}}async _runTools(e,t,a){const n="tool",{tool_choice:i="auto",stream:r,...o}=t,s="string"!=typeof i&&i?.function?.name,{maxChatCompletions:l=aj}=a||{},c=t.tools.map((e=>{if(qN(e)){if(!e.$callback)throw new OI("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e})),u={};for(const e of c)"function"===e.type&&(u[e.function.name||e.function.function.name]=e.function);const d="tools"in t?c.map((e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e)):void 0;for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){const t=await this._createChatCompletion(e,{...o,tool_choice:i,tools:d,messages:[...this.messages]},a),r=t.choices[0]?.message;if(!r)throw new OI("missing message in ChatCompletion response");if(!r.tool_calls?.length)return;for(const e of r.tool_calls){if("function"!==e.type)continue;const t=e.id,{name:a,arguments:i}=e.function,r=u[a];if(!r){const e=`Invalid tool_call: ${JSON.stringify(a)}. Available options are: ${Object.keys(u).map((e=>JSON.stringify(e))).join(", ")}. Please try again`;this._addMessage({role:n,tool_call_id:t,content:e});continue}if(s&&s!==a){const e=`Invalid tool_call: ${JSON.stringify(a)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:n,tool_call_id:t,content:e});continue}let o;try{o=xN(r)?await r.parse(i):i}catch(e){const a=e instanceof Error?e.message:String(e);this._addMessage({role:n,tool_call_id:t,content:a});continue}const l=await r.function(o,this),c=tj(this,GN,"m",ej).call(this,l);if(this._addMessage({role:n,tool_call_id:t,content:c}),s)return}}}}GN=new WeakSet,KN=function(){return tj(this,GN,"m",ZN).call(this).content??null},ZN=function(){let e=this.messages.length;for(;e-- >0;){const t=this.messages[e];if(kN(t)){const{function_call:e,...a}=t,n={...a,content:t.content??null,refusal:t.refusal??null};return e&&(n.function_call=e),n}}throw new OI("stream ended without producing a ChatCompletionMessage with role=assistant")},YN=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(kN(t)&&t?.function_call)return t.function_call;if(kN(t)&&t?.tool_calls?.length)return t.tool_calls.at(-1)?.function}},XN=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(AN(t)&&null!=t.content)return t.content;if(SN(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some((e=>"assistant"===e.role&&e.tool_calls?.some((e=>"function"===e.type&&e.id===t.tool_call_id)))))return t.content}},QN=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},JN=function(e){if(null!=e.n&&e.n>1)throw new OI("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},ej=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class ij extends nj{static runFunctions(e,t,a){const n=new ij,i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run((()=>n._runFunctions(e,t,i))),n}static runTools(e,t,a){const n=new ij,i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run((()=>n._runTools(e,t,i))),n}_addMessage(e,t=!0){super._addMessage(e,t),kN(e)&&e.content&&this._emit("content",e.content)}}const rj=1,oj=2,sj=4,lj=8,cj=16,uj=32,dj=64,mj=128,hj=256,pj=511;class gj extends Error{}class fj extends Error{}const yj=(e,t)=>{const a=e.length;let n=0;const i=e=>{throw new gj(`${e} at position ${n}`)},r=e=>{throw new fj(`${e} at position ${n}`)},o=()=>(d(),n>=a&&i("Unexpected end of input"),'"'===e[n]?s():"{"===e[n]?l():"["===e[n]?c():"null"===e.substring(n,n+4)||cj&t&&a-n<4&&"null".startsWith(e.substring(n))?(n+=4,null):"true"===e.substring(n,n+4)||uj&t&&a-n<4&&"true".startsWith(e.substring(n))?(n+=4,!0):"false"===e.substring(n,n+5)||uj&t&&a-n<5&&"false".startsWith(e.substring(n))?(n+=5,!1):"Infinity"===e.substring(n,n+8)||mj&t&&a-n<8&&"Infinity".startsWith(e.substring(n))?(n+=8,1/0):"-Infinity"===e.substring(n,n+9)||hj&t&&1<a-n&&a-n<9&&"-Infinity".startsWith(e.substring(n))?(n+=9,-1/0):"NaN"===e.substring(n,n+3)||dj&t&&a-n<3&&"NaN".startsWith(e.substring(n))?(n+=3,NaN):u()),s=()=>{const o=n;let s=!1;for(n++;n<a&&('"'!==e[n]||s&&"\\"===e[n-1]);)s="\\"===e[n]&&!s,n++;if('"'==e.charAt(n))try{return JSON.parse(e.substring(o,++n-Number(s)))}catch(e){r(String(e))}else if(rj&t)try{return JSON.parse(e.substring(o,n-Number(s))+'"')}catch(t){return JSON.parse(e.substring(o,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},l=()=>{n++,d();const r={};try{for(;"}"!==e[n];){if(d(),n>=a&&lj&t)return r;const i=s();d(),n++;try{const e=o();Object.defineProperty(r,i,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(lj&t)return r;throw e}d(),","===e[n]&&n++}}catch(e){if(lj&t)return r;i("Expected '}' at end of object")}return n++,r},c=()=>{n++;const a=[];try{for(;"]"!==e[n];)a.push(o()),d(),","===e[n]&&n++}catch(e){if(sj&t)return a;i("Expected ']' at end of array")}return n++,a},u=()=>{if(0===n){"-"===e&&oj&t&&i("Not sure what '-' is");try{return JSON.parse(e)}catch(a){if(oj&t)try{return"."===e[e.length-1]?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch(e){}r(String(a))}}const o=n;for("-"===e[n]&&n++;e[n]&&!",]}".includes(e[n]);)n++;n!=a||oj&t||i("Unterminated number literal");try{return JSON.parse(e.substring(o,n))}catch(a){"-"===e.substring(o,n)&&oj&t&&i("Not sure what '-' is");try{return JSON.parse(e.substring(o,e.lastIndexOf("e")))}catch(e){r(String(e))}}},d=()=>{for(;n<a&&" \n\r\t".includes(e[n]);)n++};return o()},bj=e=>function(e,t=pj){if("string"!=typeof e)throw new TypeError("expecting str, got "+typeof e);if(!e.trim())throw new Error(`${e} is empty`);return yj(e.trim(),t)}(e,pj^oj);var vj,wj,xj,kj,Aj,Sj,Ej,_j,Cj,Tj,Pj,Oj,Dj=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},Mj=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};class Ij extends nj{constructor(e){super(),vj.add(this),wj.set(this,void 0),xj.set(this,void 0),kj.set(this,void 0),Dj(this,wj,e,"f"),Dj(this,xj,[],"f")}get currentChatCompletionSnapshot(){return Mj(this,kj,"f")}static fromReadableStream(e){const t=new Ij(null);return t._run((()=>t._fromReadableStream(e))),t}static createChatCompletion(e,t,a){const n=new Ij(t);return n._run((()=>n._runChatCompletion(e,{...t,stream:!0},{...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"stream"}}))),n}async _createChatCompletion(e,t,a){super._createChatCompletion;const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort()))),Mj(this,vj,"m",Aj).call(this);const i=await e.chat.completions.create({...t,stream:!0},{...a,signal:this.controller.signal});this._connected();for await(const e of i)Mj(this,vj,"m",Ej).call(this,e);if(i.controller.signal?.aborted)throw new MI;return this._addChatCompletion(Mj(this,vj,"m",Tj).call(this))}async _fromReadableStream(e,t){const a=t?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",(()=>this.controller.abort()))),Mj(this,vj,"m",Aj).call(this),this._connected();const n=FM.fromReadableStream(e,this.controller);let i;for await(const e of n)i&&i!==e.id&&this._addChatCompletion(Mj(this,vj,"m",Tj).call(this)),Mj(this,vj,"m",Ej).call(this,e),i=e.id;if(n.controller.signal?.aborted)throw new MI;return this._addChatCompletion(Mj(this,vj,"m",Tj).call(this))}[(wj=new WeakMap,xj=new WeakMap,kj=new WeakMap,vj=new WeakSet,Aj=function(){this.ended||Dj(this,kj,void 0,"f")},Sj=function(e){let t=Mj(this,xj,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},Mj(this,xj,"f")[e.index]=t,t)},Ej=function(e){if(this.ended)return;const t=Mj(this,vj,"m",Oj).call(this,e);this._emit("chunk",e,t);for(const a of e.choices){const e=t.choices[a.index];null!=a.delta.content&&"assistant"===e.message?.role&&e.message?.content&&(this._emit("content",a.delta.content,e.message.content),this._emit("content.delta",{delta:a.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=a.delta.refusal&&"assistant"===e.message?.role&&e.message?.refusal&&this._emit("refusal.delta",{delta:a.delta.refusal,snapshot:e.message.refusal}),null!=a.logprobs?.content&&"assistant"===e.message?.role&&this._emit("logprobs.content.delta",{content:a.logprobs?.content,snapshot:e.logprobs?.content??[]}),null!=a.logprobs?.refusal&&"assistant"===e.message?.role&&this._emit("logprobs.refusal.delta",{refusal:a.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});const n=Mj(this,vj,"m",Sj).call(this,e);e.finish_reason&&(Mj(this,vj,"m",Cj).call(this,e),null!=n.current_tool_call_index&&Mj(this,vj,"m",_j).call(this,e,n.current_tool_call_index));for(const t of a.delta.tool_calls??[])n.current_tool_call_index!==t.index&&(Mj(this,vj,"m",Cj).call(this,e),null!=n.current_tool_call_index&&Mj(this,vj,"m",_j).call(this,e,n.current_tool_call_index)),n.current_tool_call_index=t.index;for(const t of a.delta.tool_calls??[]){const a=e.message.tool_calls?.[t.index];a?.type&&("function"===a?.type&&this._emit("tool_calls.function.arguments.delta",{name:a.function?.name,index:t.index,arguments:a.function.arguments,parsed_arguments:a.function.parsed_arguments,arguments_delta:t.function?.arguments??""}))}}},_j=function(e,t){if(Mj(this,vj,"m",Sj).call(this,e).done_tool_calls.has(t))return;const a=e.message.tool_calls?.[t];if(!a)throw new Error("no tool call snapshot");if(!a.type)throw new Error("tool call snapshot missing `type`");if("function"===a.type){const e=Mj(this,wj,"f")?.tools?.find((e=>"function"===e.type&&e.function.name===a.function.name));this._emit("tool_calls.function.arguments.done",{name:a.function.name,index:t,arguments:a.function.arguments,parsed_arguments:qN(e)?e.$parseRaw(a.function.arguments):e?.function.strict?JSON.parse(a.function.arguments):null})}else a.type},Cj=function(e){const t=Mj(this,vj,"m",Sj).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;const a=Mj(this,vj,"m",Pj).call(this);this._emit("content.done",{content:e.message.content,parsed:a?a.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},Tj=function(){if(this.ended)throw new OI("stream has ended, this shouldn't happen");const e=Mj(this,kj,"f");if(!e)throw new OI("request ended without sending any chunks");return Dj(this,kj,void 0,"f"),Dj(this,xj,[],"f"),function(e,t){const{id:a,choices:n,created:i,model:r,system_fingerprint:o,...s}=e,l={...s,id:a,choices:n.map((({message:t,finish_reason:a,index:n,logprobs:i,...r})=>{if(!a)throw new OI(`missing finish_reason for choice ${n}`);const{content:o=null,function_call:s,tool_calls:l,...c}=t,u=t.role;if(!u)throw new OI(`missing role for choice ${n}`);if(s){const{arguments:e,name:l}=s;if(null==e)throw new OI(`missing function_call.arguments for choice ${n}`);if(!l)throw new OI(`missing function_call.name for choice ${n}`);return{...r,message:{content:o,function_call:{arguments:e,name:l},role:u,refusal:t.refusal??null},finish_reason:a,index:n,logprobs:i}}return l?{...r,index:n,finish_reason:a,logprobs:i,message:{...c,role:u,content:o,refusal:t.refusal??null,tool_calls:l.map(((t,a)=>{const{function:i,type:r,id:o,...s}=t,{arguments:l,name:c,...u}=i||{};if(null==o)throw new OI(`missing choices[${n}].tool_calls[${a}].id\n${Nj(e)}`);if(null==r)throw new OI(`missing choices[${n}].tool_calls[${a}].type\n${Nj(e)}`);if(null==c)throw new OI(`missing choices[${n}].tool_calls[${a}].function.name\n${Nj(e)}`);if(null==l)throw new OI(`missing choices[${n}].tool_calls[${a}].function.arguments\n${Nj(e)}`);return{...s,id:o,type:r,function:{...u,name:c,arguments:l}}}))}}:{...r,message:{...c,content:o,role:u,refusal:t.refusal??null},finish_reason:a,index:n,logprobs:i}})),created:i,model:r,object:"chat.completion",...o?{system_fingerprint:o}:{}};return function(e,t){return t&&$N(t)?UN(e,t):{...e,choices:e.choices.map((e=>({...e,message:{...e.message,parsed:null,tool_calls:e.message.tool_calls??[]}})))}}(l,t)}(e,Mj(this,wj,"f"))},Pj=function(){const e=Mj(this,wj,"f")?.response_format;return HN(e)?e:null},Oj=function(e){var t,a,n,i;let r=Mj(this,kj,"f");const{choices:o,...s}=e;r?Object.assign(r,s):r=Dj(this,kj,{...s,choices:[]},"f");for(const{delta:o,finish_reason:s,index:l,logprobs:c=null,...u}of e.choices){let e=r.choices[l];if(e||(e=r.choices[l]={finish_reason:s,index:l,message:{},logprobs:c,...u}),c)if(e.logprobs){const{content:n,refusal:i,...r}=c;Object.assign(e.logprobs,r),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),i&&((a=e.logprobs).refusal??(a.refusal=[]),e.logprobs.refusal.push(...i))}else e.logprobs=Object.assign({},c);if(s&&(e.finish_reason=s,Mj(this,wj,"f")&&$N(Mj(this,wj,"f")))){if("length"===s)throw new UI;if("content_filter"===s)throw new WI}if(Object.assign(e,u),!o)continue;const{content:d,refusal:m,function_call:h,role:p,tool_calls:g,...f}=o;if(Object.assign(e.message,f),m&&(e.message.refusal=(e.message.refusal||"")+m),p&&(e.message.role=p),h&&(e.message.function_call?(h.name&&(e.message.function_call.name=h.name),h.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=h.arguments)):e.message.function_call=h),d&&(e.message.content=(e.message.content||"")+d,!e.message.refusal&&Mj(this,vj,"m",Pj).call(this)&&(e.message.parsed=bj(e.message.content))),g){e.message.tool_calls||(e.message.tool_calls=[]);for(const{index:t,id:a,type:n,function:r,...o}of g){const s=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(s,o),a&&(s.id=a),n&&(s.type=n),r&&(s.function??(s.function={name:r.name??"",arguments:""})),r?.name&&(s.function.name=r.name),r?.arguments&&(s.function.arguments+=r.arguments,VN(Mj(this,wj,"f"),s)&&(s.function.parsed_arguments=bj(s.function.arguments)))}}}return r},Symbol.asyncIterator)](){const e=[],t=[];let a=!1;return this.on("chunk",(a=>{const n=t.shift();n?n.resolve(a):e.push(a)})),this.on("end",(()=>{a=!0;for(const e of t)e.resolve(void 0);t.length=0})),this.on("abort",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),this.on("error",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),{next:async()=>{if(!e.length)return a?{value:void 0,done:!0}:new Promise(((e,a)=>t.push({resolve:e,reject:a}))).then((e=>e?{value:e,done:!1}:{value:void 0,done:!0}));return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new FM(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Nj(e){return JSON.stringify(e)}class jj extends Ij{static fromReadableStream(e){const t=new jj(null);return t._run((()=>t._fromReadableStream(e))),t}static runFunctions(e,t,a){const n=new jj(null),i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run((()=>n._runFunctions(e,t,i))),n}static runTools(e,t,a){const n=new jj(t),i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run((()=>n._runTools(e,t,i))),n}}let zj=class extends uN{parse(e,t){return function(e){for(const t of e??[]){if("function"!==t.type)throw new OI(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new OI(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((t=>UN(t,e)))}runFunctions(e,t){return e.stream?jj.runFunctions(this._client,e,t):ij.runFunctions(this._client,e,t)}runTools(e,t){return e.stream?jj.runTools(this._client,e,t):ij.runTools(this._client,e,t)}stream(e,t){return Ij.createChatCompletion(this._client,e,t)}};class Rj extends uN{constructor(){super(...arguments),this.completions=new zj(this._client)}}!function(e){e.Completions=zj}(Rj||(Rj={}));var Lj,Fj,Bj,Hj,qj,Uj,Wj,Vj,$j,Gj,Kj,Zj,Yj,Xj,Qj,Jj,ez,tz,az,nz,iz,rz,oz=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},sz=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a};class lz extends BN{constructor(){super(...arguments),Lj.add(this),Fj.set(this,[]),Bj.set(this,{}),Hj.set(this,{}),qj.set(this,void 0),Uj.set(this,void 0),Wj.set(this,void 0),Vj.set(this,void 0),$j.set(this,void 0),Gj.set(this,void 0),Kj.set(this,void 0),Zj.set(this,void 0),Yj.set(this,void 0)}[(Fj=new WeakMap,Bj=new WeakMap,Hj=new WeakMap,qj=new WeakMap,Uj=new WeakMap,Wj=new WeakMap,Vj=new WeakMap,$j=new WeakMap,Gj=new WeakMap,Kj=new WeakMap,Zj=new WeakMap,Yj=new WeakMap,Lj=new WeakSet,Symbol.asyncIterator)](){const e=[],t=[];let a=!1;return this.on("event",(a=>{const n=t.shift();n?n.resolve(a):e.push(a)})),this.on("end",(()=>{a=!0;for(const e of t)e.resolve(void 0);t.length=0})),this.on("abort",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),this.on("error",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),{next:async()=>{if(!e.length)return a?{value:void 0,done:!0}:new Promise(((e,a)=>t.push({resolve:e,reject:a}))).then((e=>e?{value:e,done:!1}:{value:void 0,done:!0}));return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const t=new lz;return t._run((()=>t._fromReadableStream(e))),t}async _fromReadableStream(e,t){const a=t?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",(()=>this.controller.abort()))),this._connected();const n=FM.fromReadableStream(e,this.controller);for await(const e of n)oz(this,Lj,"m",Xj).call(this,e);if(n.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}toReadableStream(){return new FM(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,a,n,i){const r=new lz;return r._run((()=>r._runToolAssistantStream(e,t,a,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}}))),r}async _createToolAssistantStream(e,t,a,n,i){const r=i?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",(()=>this.controller.abort())));const o={...n,stream:!0},s=await e.submitToolOutputs(t,a,o,{...i,signal:this.controller.signal});this._connected();for await(const e of s)oz(this,Lj,"m",Xj).call(this,e);if(s.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}static createThreadAssistantStream(e,t,a){const n=new lz;return n._run((()=>n._threadAssistantStream(e,t,{...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"stream"}}))),n}static createAssistantStream(e,t,a,n){const i=new lz;return i._run((()=>i._runAssistantStream(e,t,a,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}}))),i}currentEvent(){return oz(this,Kj,"f")}currentRun(){return oz(this,Zj,"f")}currentMessageSnapshot(){return oz(this,qj,"f")}currentRunStepSnapshot(){return oz(this,Yj,"f")}async finalRunSteps(){return await this.done(),Object.values(oz(this,Bj,"f"))}async finalMessages(){return await this.done(),Object.values(oz(this,Hj,"f"))}async finalRun(){if(await this.done(),!oz(this,Uj,"f"))throw Error("Final run was not received.");return oz(this,Uj,"f")}async _createThreadAssistantStream(e,t,a){const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort())));const i={...t,stream:!0},r=await e.createAndRun(i,{...a,signal:this.controller.signal});this._connected();for await(const e of r)oz(this,Lj,"m",Xj).call(this,e);if(r.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}async _createAssistantStream(e,t,a,n){const i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",(()=>this.controller.abort())));const r={...a,stream:!0},o=await e.create(t,r,{...n,signal:this.controller.signal});this._connected();for await(const e of o)oz(this,Lj,"m",Xj).call(this,e);if(o.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}static accumulateDelta(e,t){for(const[a,n]of Object.entries(t)){if(!e.hasOwnProperty(a)){e[a]=n;continue}let t=e[a];if(null!=t)if("index"!==a&&"type"!==a){if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else{if(!PI(t)||!PI(n)){if(Array.isArray(t)&&Array.isArray(n)){if(t.every((e=>"string"==typeof e||"number"==typeof e))){t.push(...n);continue}for(const e of n){if(!PI(e))throw new Error(`Expected array delta entry to be an object but got: ${e}`);const a=e.index;if(null==a)throw console.error(e),new Error("Expected array delta entry to have an `index` property");if("number"!=typeof a)throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);const n=t[a];null==n?t.push(e):t[a]=this.accumulateDelta(n,e)}continue}throw Error(`Unhandled record type: ${a}, deltaValue: ${n}, accValue: ${t}`)}t=this.accumulateDelta(t,n)}e[a]=t}else e[a]=n;else e[a]=n}return e}_addRun(e){return e}async _threadAssistantStream(e,t,a){return await this._createThreadAssistantStream(t,e,a)}async _runAssistantStream(e,t,a,n){return await this._createAssistantStream(t,e,a,n)}async _runToolAssistantStream(e,t,a,n,i){return await this._createToolAssistantStream(a,e,t,n,i)}}Xj=function(e){if(!this.ended)switch(sz(this,Kj,e,"f"),oz(this,Lj,"m",tz).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":oz(this,Lj,"m",rz).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":oz(this,Lj,"m",ez).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":oz(this,Lj,"m",Jj).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},Qj=function(){if(this.ended)throw new OI("stream has ended, this shouldn't happen");if(!oz(this,Uj,"f"))throw Error("Final run has not been received");return oz(this,Uj,"f")},Jj=function(e){const[t,a]=oz(this,Lj,"m",nz).call(this,e,oz(this,qj,"f"));sz(this,qj,t,"f"),oz(this,Hj,"f")[t.id]=t;for(const e of a){const a=t.content[e.index];"text"==a?.type&&this._emit("textCreated",a.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(const a of e.data.delta.content){if("text"==a.type&&a.text){let e=a.text,n=t.content[a.index];if(!n||"text"!=n.type)throw Error("The snapshot associated with this text delta is not text or missing");this._emit("textDelta",e,n.text)}if(a.index!=oz(this,Wj,"f")){if(oz(this,Vj,"f"))switch(oz(this,Vj,"f").type){case"text":this._emit("textDone",oz(this,Vj,"f").text,oz(this,qj,"f"));break;case"image_file":this._emit("imageFileDone",oz(this,Vj,"f").image_file,oz(this,qj,"f"))}sz(this,Wj,a.index,"f")}sz(this,Vj,t.content[a.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==oz(this,Wj,"f")){const t=e.data.content[oz(this,Wj,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,oz(this,qj,"f"));break;case"text":this._emit("textDone",t.text,oz(this,qj,"f"))}}oz(this,qj,"f")&&this._emit("messageDone",e.data),sz(this,qj,void 0,"f")}},ez=function(e){const t=oz(this,Lj,"m",az).call(this,e);switch(sz(this,Yj,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const a=e.data.delta;if(a.step_details&&"tool_calls"==a.step_details.type&&a.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(const e of a.step_details.tool_calls)e.index==oz(this,$j,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(oz(this,Gj,"f")&&this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,$j,e.index,"f"),sz(this,Gj,t.step_details.tool_calls[e.index],"f"),oz(this,Gj,"f")&&this._emit("toolCallCreated",oz(this,Gj,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":sz(this,Yj,void 0,"f");"tool_calls"==e.data.step_details.type&&oz(this,Gj,"f")&&(this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,Gj,void 0,"f")),this._emit("runStepDone",e.data,t)}},tz=function(e){oz(this,Fj,"f").push(e),this._emit("event",e)},az=function(e){switch(e.event){case"thread.run.step.created":return oz(this,Bj,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=oz(this,Bj,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let a=e.data;if(a.delta){const n=lz.accumulateDelta(t,a.delta);oz(this,Bj,"f")[e.data.id]=n}return oz(this,Bj,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":oz(this,Bj,"f")[e.data.id]=e.data}if(oz(this,Bj,"f")[e.data.id])return oz(this,Bj,"f")[e.data.id];throw new Error("No snapshot available")},nz=function(e,t){let a=[];switch(e.event){case"thread.message.created":return[e.data,a];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(const e of n.delta.content)if(e.index in t.content){let a=t.content[e.index];t.content[e.index]=oz(this,Lj,"m",iz).call(this,e,a)}else t.content[e.index]=e,a.push(e);return[t,a];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,a];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},iz=function(e,t){return lz.accumulateDelta(t,e)},rz=function(e){switch(sz(this,Zj,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":sz(this,Uj,e.data,"f"),oz(this,Gj,"f")&&(this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,Gj,void 0,"f"))}};class cz extends uN{create(e,t,a){return this._client.post(`/threads/${e}/messages`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/threads/${e}/messages/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}update(e,t,a,n){return this._client.post(`/threads/${e}/messages/${t}`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/messages`,uz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t,a){return this._client.delete(`/threads/${e}/messages/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}}class uz extends cN{}!function(e){e.MessagesPage=uz}(cz||(cz={}));class dz extends uN{retrieve(e,t,a,n={},i){return uI(n)?this.retrieve(e,t,a,{},n):this._client.get(`/threads/${e}/runs/${t}/steps/${a}`,{query:n,...i,headers:{"OpenAI-Beta":"assistants=v2",...i?.headers}})}list(e,t,a={},n){return uI(a)?this.list(e,t,{},a):this._client.getAPIList(`/threads/${e}/runs/${t}/steps`,mz,{query:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}}class mz extends cN{}!function(e){e.RunStepsPage=mz}(dz||(dz={}));class hz extends uN{constructor(){super(...arguments),this.steps=new dz(this._client)}create(e,t,a){const{include:n,...i}=t;return this._client.post(`/threads/${e}/runs`,{query:{include:n},body:i,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers},stream:t.stream??!1})}retrieve(e,t,a){return this._client.get(`/threads/${e}/runs/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}update(e,t,a,n){return this._client.post(`/threads/${e}/runs/${t}`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/runs`,pz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}cancel(e,t,a){return this._client.post(`/threads/${e}/runs/${t}/cancel`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t,a);return await this.poll(e,n.id,a)}createAndStream(e,t,a){return lz.createAssistantStream(e,this._client.beta.threads.runs,t,a)}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const{data:i,response:r}=await this.retrieve(e,t,{...a,headers:{...a?.headers,...n}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=r.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,a){return lz.createAssistantStream(e,this._client.beta.threads.runs,t,a)}submitToolOutputs(e,t,a,n){return this._client.post(`/threads/${e}/runs/${t}/submit_tool_outputs`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers},stream:a.stream??!1})}async submitToolOutputsAndPoll(e,t,a,n){const i=await this.submitToolOutputs(e,t,a,n);return await this.poll(e,i.id,n)}submitToolOutputsStream(e,t,a,n){return lz.createToolAssistantStream(e,t,this._client.beta.threads.runs,a,n)}}class pz extends cN{}!function(e){e.RunsPage=pz,e.Steps=dz,e.RunStepsPage=mz}(hz||(hz={}));class gz extends uN{constructor(){super(...arguments),this.runs=new hz(this._client),this.messages=new cz(this._client)}create(e={},t){return uI(e)?this.create({},e):this._client.post("/threads",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/threads/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t){return this._client.delete(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers},stream:e.stream??!1})}async createAndRunPoll(e,t){const a=await this.createAndRun(e,t);return await this.runs.poll(a.thread_id,a.id,t)}createAndRunStream(e,t){return lz.createThreadAssistantStream(e,this._client.beta.threads,t)}}!function(e){e.Runs=hz,e.RunsPage=pz,e.Messages=cz,e.MessagesPage=uz}(gz||(gz={}));let fz=class extends uN{create(e,t,a){return this._client.post(`/vector_stores/${e}/files`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/vector_stores/${e}/files/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/vector_stores/${e}/files`,yz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t,a){return this._client.delete(`/vector_stores/${e}/files/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t,a);return await this.poll(e,n.id,a)}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const i=await this.retrieve(e,t,{...a,headers:n}).withResponse(),r=i.data;switch(r.status){case"in_progress":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=i.response.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"failed":case"completed":return r}}}async upload(e,t,a){const n=await this._client.files.create({file:t,purpose:"assistants"},a);return this.create(e,{file_id:n.id},a)}async uploadAndPoll(e,t,a){const n=await this.upload(e,t,a);return await this.poll(e,n.id,a)}};class yz extends cN{}(fz||(fz={})).VectorStoreFilesPage=yz;class bz extends uN{create(e,t,a){return this._client.post(`/vector_stores/${e}/file_batches`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/vector_stores/${e}/file_batches/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}cancel(e,t,a){return this._client.post(`/vector_stores/${e}/file_batches/${t}/cancel`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t);return await this.poll(e,n.id,a)}listFiles(e,t,a={},n){return uI(a)?this.listFiles(e,t,{},a):this._client.getAPIList(`/vector_stores/${e}/file_batches/${t}/files`,yz,{query:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const{data:i,response:r}=await this.retrieve(e,t,{...a,headers:n}).withResponse();switch(i.status){case"in_progress":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=r.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(e,{files:t,fileIds:a=[]},n){if(null==t||0==t.length)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const i=n?.maxConcurrency??5,r=Math.min(i,t.length),o=this._client,s=t.values(),l=[...a];const c=Array(r).fill(s).map((async function(e){for(let t of e){const e=await o.files.create({file:t,purpose:"assistants"},n);l.push(e.id)}}));return await(async e=>{const t=await Promise.allSettled(e),a=t.filter((e=>"rejected"===e.status));if(a.length){for(const e of a)console.error(e.reason);throw new Error(`${a.length} promise(s) failed - see the above errors`)}const n=[];for(const e of t)"fulfilled"===e.status&&n.push(e.value);return n})(c),await this.createAndPoll(e,{file_ids:l})}}bz||(bz={});class vz extends uN{constructor(){super(...arguments),this.files=new fz(this._client),this.fileBatches=new bz(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/vector_stores/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/vector_stores",wz,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class wz extends cN{}!function(e){e.VectorStoresPage=wz,e.Files=fz,e.VectorStoreFilesPage=yz,e.FileBatches=bz}(vz||(vz={}));class xz extends uN{constructor(){super(...arguments),this.vectorStores=new vz(this._client),this.chat=new Rj(this._client),this.assistants=new vN(this._client),this.threads=new gz(this._client)}}!function(e){e.VectorStores=vz,e.VectorStoresPage=wz,e.Chat=Rj,e.Assistants=vN,e.AssistantsPage=wN,e.Threads=gz}(xz||(xz={}));class kz extends uN{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}kz||(kz={});let Az=class extends uN{create(e,t){return this._client.post("/embeddings",{body:e,...t})}};Az||(Az={});class Sz extends uN{create(e,t){return this._client.post("/files",YM({body:e,...t}))}retrieve(e,t){return this._client.get(`/files/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/files",Ez,{query:e,...t})}del(e,t){return this._client.delete(`/files/${e}`,t)}content(e,t){return this._client.get(`/files/${e}/content`,{...t,__binaryResponse:!0})}retrieveContent(e,t){return this._client.get(`/files/${e}/content`,{...t,headers:{Accept:"application/json",...t?.headers}})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:a=18e5}={}){const n=new Set(["processed","error","deleted"]),i=Date.now();let r=await this.retrieve(e);for(;!r.status||!n.has(r.status);)if(await vI(t),r=await this.retrieve(e),Date.now()-i>a)throw new NI({message:`Giving up on waiting for file ${e} to finish processing after ${a} milliseconds.`});return r}}class Ez extends lN{}!function(e){e.FileObjectsPage=Ez}(Sz||(Sz={}));class _z extends uN{list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/checkpoints`,Cz,{query:t,...a})}}class Cz extends cN{}!function(e){e.FineTuningJobCheckpointsPage=Cz}(_z||(_z={}));class Tz extends uN{constructor(){super(...arguments),this.checkpoints=new _z(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(`/fine_tuning/jobs/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/fine_tuning/jobs",Pz,{query:e,...t})}cancel(e,t){return this._client.post(`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},a){return uI(t)?this.listEvents(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/events`,Oz,{query:t,...a})}}class Pz extends cN{}class Oz extends cN{}!function(e){e.FineTuningJobsPage=Pz,e.FineTuningJobEventsPage=Oz,e.Checkpoints=_z,e.FineTuningJobCheckpointsPage=Cz}(Tz||(Tz={}));class Dz extends uN{constructor(){super(...arguments),this.jobs=new Tz(this._client)}}!function(e){e.Jobs=Tz,e.FineTuningJobsPage=Pz,e.FineTuningJobEventsPage=Oz}(Dz||(Dz={}));class Mz extends uN{createVariation(e,t){return this._client.post("/images/variations",YM({body:e,...t}))}edit(e,t){return this._client.post("/images/edits",YM({body:e,...t}))}generate(e,t){return this._client.post("/images/generations",{body:e,...t})}}Mz||(Mz={});class Iz extends uN{retrieve(e,t){return this._client.get(`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",Nz,e)}del(e,t){return this._client.delete(`/models/${e}`,t)}}class Nz extends lN{}!function(e){e.ModelsPage=Nz}(Iz||(Iz={}));class jz extends uN{create(e,t){return this._client.post("/moderations",{body:e,...t})}}jz||(jz={});class zz extends uN{create(e,t,a){return this._client.post(`/uploads/${e}/parts`,YM({body:t,...a}))}}zz||(zz={});class Rz extends uN{constructor(){super(...arguments),this.parts=new zz(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(`/uploads/${e}/cancel`,t)}complete(e,t,a){return this._client.post(`/uploads/${e}/complete`,{body:t,...a})}}var Lz;!function(e){e.Parts=zz}(Rz||(Rz={}));let Fz=class extends rI{constructor({baseURL:e=kI("OPENAI_BASE_URL"),apiKey:t=kI("OPENAI_API_KEY"),organization:a=kI("OPENAI_ORG_ID")??null,project:n=kI("OPENAI_PROJECT_ID")??null,...i}={}){if(void 0===t)throw new OI("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");const r={apiKey:t,organization:a,project:n,...i,baseURL:e||"https://api.openai.com/v1"};if(!r.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new OI("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");super({baseURL:r.baseURL,timeout:r.timeout??6e5,httpAgent:r.httpAgent,maxRetries:r.maxRetries,fetch:r.fetch}),this.completions=new kz(this),this.chat=new mN(this),this.embeddings=new Az(this),this.files=new Sz(this),this.images=new Mz(this),this.audio=new fN(this),this.moderations=new jz(this),this.models=new Iz(this),this.fineTuning=new Dz(this),this.beta=new xz(this),this.batches=new yN(this),this.uploads=new Rz(this),this._options=r,this.apiKey=t,this.organization=a,this.project=n}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return sN(e,{arrayFormat:"brackets"})}};Lz=Fz,Fz.OpenAI=Lz,Fz.DEFAULT_TIMEOUT=6e5,Fz.OpenAIError=OI,Fz.APIError=DI,Fz.APIConnectionError=II,Fz.APIConnectionTimeoutError=NI,Fz.APIUserAbortError=MI,Fz.NotFoundError=LI,Fz.ConflictError=FI,Fz.RateLimitError=HI,Fz.BadRequestError=jI,Fz.AuthenticationError=zI,Fz.InternalServerError=qI,Fz.PermissionDeniedError=RI,Fz.UnprocessableEntityError=BI,Fz.toFile=$M,Fz.fileFromPath=NM;const{OpenAIError:Bz,APIError:Hz,APIConnectionError:qz,APIConnectionTimeoutError:Uz,APIUserAbortError:Wz,NotFoundError:Vz,ConflictError:$z,RateLimitError:Gz,BadRequestError:Kz,AuthenticationError:Zz,InternalServerError:Yz,PermissionDeniedError:Xz,UnprocessableEntityError:Qz}=VI;var Jz;(Jz=Fz||(Fz={})).Page=lN,Jz.CursorPage=cN,Jz.Completions=kz,Jz.Chat=mN,Jz.Embeddings=Az,Jz.Files=Sz,Jz.FileObjectsPage=Ez,Jz.Images=Mz,Jz.Audio=fN,Jz.Moderations=jz,Jz.Models=Iz,Jz.ModelsPage=Nz,Jz.FineTuning=Dz,Jz.Beta=xz,Jz.Batches=yN,Jz.BatchesPage=bN,Jz.Uploads=Rz;class eR extends sA{static lc_name(){return"RunnablePassthrough"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e&&(this.func=e.func)}async invoke(e,t){const a=vk(t);return this.func&&await this.func(e,a),this._callWithConfig((e=>Promise.resolve(e)),e,a)}async*transform(e,t){const a=vk(t);let n,i=!0;for await(const t of this._transformStreamWithConfig(e,(e=>e),a))if(yield t,i)if(void 0===n)n=t;else try{n=Qx(n,t)}catch{n=void 0,i=!1}this.func&&void 0!==n&&await this.func(n,a)}static assign(e){return new yA(new mA({steps:e}))}}class tR extends SA{constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","chat_models",this._llmType()]})}_separateRunnableConfigFromCallOptionsCompat(e){const[t,a]=super._separateRunnableConfigFromCallOptions(e);return a.signal=t.signal,[t,a]}async invoke(e,t){const a=tR._convertInputToPromptValue(e);return(await this.generatePrompt([a],t,t?.callbacks)).generations[0][0].message}async*_streamResponseChunks(e,t,a){throw new Error("Not implemented.")}async*_streamIterator(e,t){if(this._streamResponseChunks===tR.prototype._streamResponseChunks)yield this.invoke(e,t);else{const a=tR._convertInputToPromptValue(e).toChatMessages(),[n,i]=this._separateRunnableConfigFromCallOptionsCompat(t),r={...n.metadata,...this.getLsParams(i)},o=await Nw.configure(n.callbacks,this.callbacks,n.tags,this.tags,r,this.metadata,{verbose:this.verbose}),s={options:i,invocation_params:this?.invocationParams(i),batch_size:1},l=await(o?.handleChatModelStart(this.toJSON(),[a],n.runId,void 0,s,void 0,void 0,n.runName));let c,u;try{for await(const e of this._streamResponseChunks(a,i,l?.[0])){if(null==e.message.id){const t=l?.at(0)?.runId;null!=t&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata},yield e.message,c=c?c.concat(e):e,bf(e.message)&&void 0!==e.message.usage_metadata&&(u={tokenUsage:{promptTokens:e.message.usage_metadata.input_tokens,completionTokens:e.message.usage_metadata.output_tokens,totalTokens:e.message.usage_metadata.total_tokens}})}}catch(e){throw await Promise.all((l??[]).map((t=>t?.handleLLMError(e)))),e}await Promise.all((l??[]).map((e=>e?.handleLLMEnd({generations:[[c]],llmOutput:u}))))}}getLsParams(e){return{ls_model_type:"chat",ls_stop:e.stop}}async _generateUncached(e,t,a){const n=e.map((e=>e.map(Of))),i={...a.metadata,...this.getLsParams(t)},r=await Nw.configure(a.callbacks,this.callbacks,a.tags,this.tags,i,this.metadata,{verbose:this.verbose}),o={options:t,invocation_params:this?.invocationParams(t),batch_size:1},s=await(r?.handleChatModelStart(this.toJSON(),n,a.runId,void 0,o,void 0,void 0,a.runName)),l=[],c=[];if(!!s?.[0].handlers.find((e=>pk(e)||ik(e)))&&1===n.length&&this._streamResponseChunks!==tR.prototype._streamResponseChunks)try{const e=await this._streamResponseChunks(n[0],t,s?.[0]);let a,i;for await(const t of e){if(null==t.message.id){const e=s?.at(0)?.runId;null!=e&&t.message._updateId(`run-${e}`)}a=void 0===a?t:Qx(a,t),bf(t.message)&&void 0!==t.message.usage_metadata&&(i={tokenUsage:{promptTokens:t.message.usage_metadata.input_tokens,completionTokens:t.message.usage_metadata.output_tokens,totalTokens:t.message.usage_metadata.total_tokens}})}if(void 0===a)throw new Error("Received empty response from chat model call.");l.push([a]),await(s?.[0].handleLLMEnd({generations:l,llmOutput:i}))}catch(e){throw await(s?.[0].handleLLMError(e)),e}else{const e=await Promise.allSettled(n.map(((e,a)=>this._generate(e,{...t,promptIndex:a},s?.[a]))));await Promise.all(e.map((async(e,t)=>{if("fulfilled"===e.status){const a=e.value;for(const e of a.generations){if(null==e.message.id){const t=s?.at(0)?.runId;null!=t&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata}}return 1===a.generations.length&&(a.generations[0].message.response_metadata={...a.llmOutput,...a.generations[0].message.response_metadata}),l[t]=a.generations,c[t]=a.llmOutput,s?.[t]?.handleLLMEnd({generations:[a.generations],llmOutput:a.llmOutput})}return await(s?.[t]?.handleLLMError(e.reason)),Promise.reject(e.reason)})))}const u={generations:l,llmOutput:c.length?this._combineLLMOutput?.(...c):void 0};return Object.defineProperty(u,ck,{value:s?{runIds:s?.map((e=>e.runId))}:void 0,configurable:!0}),u}async _generateCached({messages:e,cache:t,llmStringKey:a,parsedOptions:n,handledOptions:i}){const r=e.map((e=>e.map(Of))),o={...i.metadata,...this.getLsParams(n)},s=await Nw.configure(i.callbacks,this.callbacks,i.tags,this.tags,o,this.metadata,{verbose:this.verbose}),l={options:n,invocation_params:this?.invocationParams(n),batch_size:1,cached:!0},c=await(s?.handleChatModelStart(this.toJSON(),r,i.runId,void 0,l,void 0,void 0,i.runName)),u=[],d=await Promise.allSettled(r.map((async(e,n)=>{const i=tR._convertInputToPromptValue(e).toString(),r=await t.lookup(i,a);return null==r&&u.push(n),r}))),m=d.map(((e,t)=>({result:e,runManager:c?.[t]}))).filter((({result:e})=>"fulfilled"===e.status&&null!=e.value||"rejected"===e.status)),h=[];await Promise.all(m.map((async({result:e,runManager:t},a)=>{if("fulfilled"===e.status){const n=e.value;return h[a]=n,n.length&&await(t?.handleLLMNewToken(n[0].text)),t?.handleLLMEnd({generations:[n]})}return await(t?.handleLLMError(e.reason)),Promise.reject(e.reason)})));const p={generations:h,missingPromptIndices:u};return Object.defineProperty(p,ck,{value:c?{runIds:c?.map((e=>e.runId))}:void 0,configurable:!0}),p}async generate(e,t,a){let n;n=Array.isArray(t)?{stop:t}:t;const i=e.map((e=>e.map(Of))),[r,o]=this._separateRunnableConfigFromCallOptionsCompat(n);if(r.callbacks=r.callbacks??a,!this.cache)return this._generateUncached(i,o,r);const{cache:s}=this,l=this._getSerializedCacheKeyParametersForCall(o),{generations:c,missingPromptIndices:u}=await this._generateCached({messages:i,cache:s,llmStringKey:l,parsedOptions:o,handledOptions:r});let d={};if(u.length>0){const e=await this._generateUncached(u.map((e=>i[e])),o,r);await Promise.all(e.generations.map((async(e,t)=>{const a=u[t];c[a]=e;const n=tR._convertInputToPromptValue(i[a]).toString();return s.update(n,l,e)}))),d=e.llmOutput??{}}return{generations:c,llmOutput:d}}invocationParams(e){return{}}_modelType(){return"base_chat_model"}serialize(){return{...this.invocationParams(),_type:this._llmType(),_model:this._modelType()}}async generatePrompt(e,t,a){const n=e.map((e=>e.toChatMessages()));return this.generate(n,t,a)}async call(e,t,a){return(await this.generate([e.map(Of)],t,a)).generations[0][0].message}async callPrompt(e,t,a){const n=e.toChatMessages();return this.call(n,t,a)}async predictMessages(e,t,a){return this.call(e,t,a)}async predict(e,t,a){const n=new Sf(e),i=await this.call([n],t,a);if("string"!=typeof i.content)throw new Error("Cannot use predict when output is not a string.");return i.content}withStructuredOutput(e,t){if("function"!=typeof this.bindTools)throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');const a=e,n=t?.name,i=a.description??"A function available to call.",r=t?.method,o=t?.includeRaw;if("jsonMode"===r)throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let s,l=n??"extract";_A(a)?s=[{type:"function",function:{name:l,description:i,parameters:Gk(a)}}]:("name"in a&&(l=a.name),s=[{type:"function",function:{name:l,description:i,parameters:a}}]);const c=this.bindTools(s),u=pA.from((e=>{if(!e.tool_calls||0===e.tool_calls.length)throw new Error("No tool calls found in the response.");const t=e.tool_calls.find((e=>e.name===l));if(!t)throw new Error(`No tool call found with name ${l}.`);return t.args}));if(!o)return c.pipe(u).withConfig({runName:"StructuredOutput"});const d=eR.assign({parsed:(e,t)=>u.invoke(e.raw,t)}),m=eR.assign({parsed:()=>null}),h=d.withFallbacks({fallbacks:[m]});return dA.from([{raw:c},h]).withConfig({runName:"StructuredOutputRunnable"})}}var aR=Object.freeze({__proto__:null,BaseChatModel:tR,SimpleChatModel:class extends tR{async _generate(e,t,a){const n=await this._call(e,t,a),i=new ff(n);if("string"!=typeof i.content)throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}},createChatMessageChunkEncoderStream:function(){const e=new TextEncoder;return new TransformStream({transform(t,a){a.enqueue(e.encode("string"==typeof t.content?t.content:JSON.stringify(t.content)))}})}});var nR=Object.freeze({__proto__:null,RouterRunnable:class extends sA{static lc_name(){return"RouterRunnable"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnables=e.runnables}async invoke(e,t){const{key:a,input:n}=e,i=this.runnables[a];if(void 0===i)throw new Error(`No runnable associated with key "${a}".`);return i.invoke(n,vk(t))}async batch(e,t,a){const n=e.map((e=>e.key)),i=e.map((e=>e.input)),r=n.find((e=>void 0===this.runnables[e]));if(void 0!==r)throw new Error("One or more keys do not have a corresponding runnable.");const o=n.map((e=>this.runnables[e])),s=this._getOptionsList(t??{},e.length),l=s[0]?.maxConcurrency??a?.maxConcurrency,c=l&&l>0?l:e.length,u=[];for(let e=0;e<i.length;e+=c){const t=i.slice(e,e+c).map(((e,t)=>o[t].invoke(e,s[t]))),a=await Promise.all(t);u.push(a)}return u.flat()}async stream(e,t){const{key:a,input:n}=e,i=this.runnables[a];if(void 0===i)throw new Error(`No runnable associated with key "${a}".`);return i.stream(n,t)}},Runnable:sA,RunnableAssign:yA,RunnableBinding:lA,RunnableBranch:class extends sA{static lc_name(){return"RunnableBranch"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"default",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"branches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");return new this({branches:e.slice(0,-1).map((([e,t])=>[fA(e),fA(t)])),default:fA(e[e.length-1])})}async _invoke(e,t,a){let n;for(let i=0;i<this.branches.length;i+=1){const[r,o]=this.branches[i];if(await r.invoke(e,wk(t,{callbacks:a?.getChild(`condition:${i+1}`)}))){n=await o.invoke(e,wk(t,{callbacks:a?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,wk(t,{callbacks:a?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){const a=await fk(t),n=await(a?.handleChainStart(this.toJSON(),oA(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName));let i,r,o=!0;try{for(let a=0;a<this.branches.length;a+=1){const[s,l]=this.branches[a];if(await s.invoke(e,wk(t,{callbacks:n?.getChild(`condition:${a+1}`)}))){r=await l.stream(e,wk(t,{callbacks:n?.getChild(`branch:${a+1}`)}));for await(const e of r)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch(e){i=void 0,o=!1}break}}if(void 0===r){r=await this.default.stream(e,wk(t,{callbacks:n?.getChild("branch:default")}));for await(const e of r)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch(e){i=void 0,o=!1}}}catch(e){throw await(n?.handleChainError(e)),e}await(n?.handleChainEnd(i??{}))}},RunnableEach:cA,RunnableLambda:pA,RunnableMap:mA,RunnableParallel:class extends mA{},RunnablePassthrough:eR,RunnablePick:bA,RunnableRetry:uA,RunnableSequence:dA,RunnableToolLike:vA,RunnableWithFallbacks:gA,RunnableWithMessageHistory:class extends lA{constructor(e){let t=pA.from(((e,t)=>this._enterHistory(e,t??{}))).withConfig({runName:"loadHistory"});const a=e.historyMessagesKey??e.inputMessagesKey;a&&(t=eR.assign({[a]:t}).withConfig({runName:"insertHistory"}));const n=t.pipe(e.runnable.withListeners({onEnd:(e,t)=>this._exitHistory(e,t??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"historyMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getMessageHistory",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if("object"!=typeof e||Array.isArray(e)||mf(e))t=e;else{let a;a=this.inputMessagesKey?this.inputMessagesKey:1===Object.keys(e).length?Object.keys(e)[0]:"input",t=Array.isArray(e[a])&&Array.isArray(e[a][0])?e[a][0]:e[a]}if("string"==typeof t)return[new Sf(t)];if(Array.isArray(t))return t;if(mf(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.\nGot ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(Array.isArray(e)||mf(e)||"string"==typeof e)t=e;else{let a;a=void 0!==this.outputMessagesKey?this.outputMessagesKey:1===Object.keys(e).length?Object.keys(e)[0]:"output",t=void 0!==e.generations?e.generations[0][0].message:e[a]}if("string"==typeof t)return[new ff(t)];if(Array.isArray(t))return t;if(mf(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){const a=t?.configurable?.messageHistory,n=await a.getMessages();return void 0===this.historyMessagesKey?n.concat(this._getInputMessages(e)):n}async _exitHistory(e,t){const a=t.configurable?.messageHistory;let n;n=Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?e.inputs[0]:e.inputs;let i=this._getInputMessages(n);if(void 0===this.historyMessagesKey){const e=await a.getMessages();i=i.slice(e.length)}const r=e.outputs;if(!r)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);const o=this._getOutputMessages(r);await a.addMessages([...i,...o])}async _mergeConfig(...e){const t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){const e={[this.inputMessagesKey??"input"]:"foo"},t={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()\neg. chain.invoke(${JSON.stringify(e)}, ${JSON.stringify(t)})`)}const{sessionId:a}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(a),t}},_coerceToRunnable:fA,ensureConfig:vk,getCallbackManagerForConfig:fk,mergeConfigs:yk,patchConfig:wk});class iR extends sA{parseResultWithPrompt(e,t,a){return this.parseResult(e,a)}_baseMessageToString(e){return"string"==typeof e.content?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return"string"==typeof e?this._callWithConfig((async(e,t)=>this.parseResult([{text:e}],t?.callbacks)),e,{...t,runType:"parser"}):this._callWithConfig((async(e,t)=>this.parseResult([{message:e,text:this._baseMessageToString(e)}],t?.callbacks)),e,{...t,runType:"parser"})}}class rR extends iR{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,a){return this.parse(e,a)}_type(){throw new Error("_type not implemented")}}class oR extends Error{constructor(e,t,a,n=!1){if(super(e),Object.defineProperty(this,"llmOutput",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"observation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendToLLM",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.llmOutput=t,this.observation=a,this.sendToLLM=n,n&&(void 0===a||void 0===t))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Qg(this,"OUTPUT_PARSING_FAILURE")}}function sR(e,t){const a=typeof e;if(a!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;const a=e.length;if(a!==t.length)return!1;for(let n=0;n<a;n++)if(!sR(e[n],t[n]))return!1;return!0}if("object"===a){if(!e||!t)return e===t;const a=Object.keys(e),n=Object.keys(t);if(a.length!==n.length)return!1;for(const n of a)if(!sR(e[n],t[n]))return!1;return!0}return e===t}function lR(e){return encodeURI(function(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}(e))}const cR={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uR={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},dR={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};let mR="undefined"!=typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function hR(e,t=Object.create(null),a=mR,n=""){if(e&&"object"==typeof e&&!Array.isArray(e)){const i=e.$id||e.id;if(i){const r=new URL(i,a.href);r.hash.length>1?t[r.href]=e:(r.hash="",""===n?a=r:hR(e,t,a))}}else if(!0!==e&&!1!==e)return t;const i=a.href+(n?"#"+n:"");if(void 0!==t[i])throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&void 0===e.__absolute_ref__){const t=new URL(e.$ref,a.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){const t=new URL(e.$recursiveRef,a.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){t[new URL("#"+e.$anchor,a.href).href]=e}for(let i in e){if(dR[i])continue;const r=`${n}/${lR(i)}`,o=e[i];if(Array.isArray(o)){if(cR[i]){const e=o.length;for(let n=0;n<e;n++)hR(o[n],t,a,`${r}/${n}`)}}else if(uR[i])for(let e in o)hR(o[e],t,a,`${r}/${lR(e)}`);else hR(o,t,a,r)}return t}const pR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gR=[0,31,28,31,30,31,30,31,31,30,31,30,31],fR=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,yR=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,bR=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,vR=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,wR=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,xR=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,kR=/^(?:\/(?:[^~/]|~0|~1)*)*$/,AR=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,SR=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,ER=/^\d\d\d\d-[0-1]\d-[0-3]\d$/,_R=/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,CR=/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,TR=/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,PR=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,OR=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;function DR(e){return e.test.bind(e)}const MR={date:NR,time:jR.bind(void 0,!1),"date-time":function(e){const t=e.split(zR);return 2==t.length&&NR(t[0])&&jR(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return RR.test(e)&&LR.test(e)},"uri-reference":DR(bR),"uri-template":DR(vR),url:DR(wR),email:e=>{if('"'===e[0])return!1;const[t,a,...n]=e.split("@");return!(!t||!a||0!==n.length||t.length>64||a.length>253)&&("."!==t[0]&&!t.endsWith(".")&&!t.includes("..")&&(!(!/^[a-z0-9.-]+$/i.test(a)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))&&a.split(".").every((e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e)))))},hostname:DR(yR),ipv4:DR(PR),ipv6:DR(OR),regex:function(e){if(FR.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:DR(xR),"json-pointer":DR(kR),"json-pointer-uri-fragment":DR(AR),"relative-json-pointer":DR(SR)},IR={...MR,date:DR(ER),time:DR(_R),"date-time":DR(CR),"uri-reference":DR(TR)};function NR(e){const t=e.match(pR);if(!t)return!1;const a=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(2==n&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(a)?29:gR[n])}function jR(e,t){const a=t.match(fR);if(!a)return!1;const n=+a[1],i=+a[2],r=+a[3],o=!!a[5];return(n<=23&&i<=59&&r<=59||23==n&&59==i&&60==r)&&(!e||o)}const zR=/t|\s/i;const RR=/\/|:/,LR=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;const FR=/[^\\]\\Z/;function BR(e,t,a="2019-09",n=hR(t),i=!0,r=null,o="#",s="#",l=Object.create(null)){if(!0===t)return{valid:!0,errors:[]};if(!1===t)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};const c=typeof e;let u;switch(c){case"boolean":case"number":case"string":u=c;break;case"object":u=null===e?"null":Array.isArray(e)?"array":"object";break;default:throw new Error(`Instances of "${c}" type are not supported.`)}const{$ref:d,$recursiveRef:m,$recursiveAnchor:h,type:p,const:g,enum:f,required:y,not:b,anyOf:v,allOf:w,oneOf:x,if:k,then:A,else:S,format:E,properties:_,patternProperties:C,additionalProperties:T,unevaluatedProperties:P,minProperties:O,maxProperties:D,propertyNames:M,dependentRequired:I,dependentSchemas:N,dependencies:j,prefixItems:z,items:R,additionalItems:L,unevaluatedItems:F,contains:B,minContains:H,maxContains:q,minItems:U,maxItems:W,uniqueItems:V,minimum:$,maximum:G,exclusiveMinimum:K,exclusiveMaximum:Z,multipleOf:Y,minLength:X,maxLength:Q,pattern:J,__absolute_ref__:ee,__absolute_recursive_ref__:te}=t,ae=[];if(!0===h&&null===r&&(r=t),"#"===m){const c=null===r?n[te]:r,u=`${s}/$recursiveRef`,d=BR(e,null===r?t:r,a,n,i,c,o,u,l);d.valid||ae.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:u,error:"A subschema had errors."},...d.errors)}if(void 0!==d){const t=n[ee||d];if(void 0===t){let e=`Unresolved $ref "${d}".`;throw ee&&ee!==d&&(e+=` Absolute URI "${ee}".`),e+=`\nKnown schemas:\n- ${Object.keys(n).join("\n- ")}`,new Error(e)}const c=`${s}/$ref`,u=BR(e,t,a,n,i,r,o,c,l);if(u.valid||ae.push({instanceLocation:o,keyword:"$ref",keywordLocation:c,error:"A subschema had errors."},...u.errors),"4"===a||"7"===a)return{valid:0===ae.length,errors:ae}}if(Array.isArray(p)){let t=p.length,a=!1;for(let n=0;n<t;n++)if(u===p[n]||"integer"===p[n]&&"number"===u&&e%1==0&&e==e){a=!0;break}a||ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p.join('", "')}".`})}else"integer"===p?("number"!==u||e%1||e!=e)&&ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p}".`}):void 0!==p&&u!==p&&ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p}".`});if(void 0!==g&&("object"===u||"array"===u?sR(e,g)||ae.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):e!==g&&ae.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==f&&("object"===u||"array"===u?f.some((t=>sR(e,t)))||ae.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(f)}.`}):f.some((t=>e===t))||ae.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(f)}.`})),void 0!==b){const t=`${s}/not`;BR(e,b,a,n,i,r,o,t).valid&&ae.push({instanceLocation:o,keyword:"not",keywordLocation:t,error:'Instance matched "not" schema.'})}let ne=[];if(void 0!==v){const t=`${s}/anyOf`,c=ae.length;let u=!1;for(let s=0;s<v.length;s++){const c=v[s],d=Object.create(l),m=BR(e,c,a,n,i,!0===h?r:null,o,`${t}/${s}`,d);ae.push(...m.errors),u=u||m.valid,m.valid&&ne.push(d)}u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:t,error:"Instance does not match any subschemas."})}if(void 0!==w){const t=`${s}/allOf`,c=ae.length;let u=!0;for(let s=0;s<w.length;s++){const c=w[s],d=Object.create(l),m=BR(e,c,a,n,i,!0===h?r:null,o,`${t}/${s}`,d);ae.push(...m.errors),u=u&&m.valid,m.valid&&ne.push(d)}u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"allOf",keywordLocation:t,error:"Instance does not match every subschema."})}if(void 0!==x){const t=`${s}/oneOf`,c=ae.length,u=x.filter(((s,c)=>{const u=Object.create(l),d=BR(e,s,a,n,i,!0===h?r:null,o,`${t}/${c}`,u);return ae.push(...d.errors),d.valid&&ne.push(u),d.valid})).length;1===u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if("object"!==u&&"array"!==u||Object.assign(l,...ne),void 0!==k){const t=`${s}/if`;if(BR(e,k,a,n,i,r,o,t,l).valid){if(void 0!==A){const c=BR(e,A,a,n,i,r,o,`${s}/then`,l);c.valid||ae.push({instanceLocation:o,keyword:"if",keywordLocation:t,error:'Instance does not match "then" schema.'},...c.errors)}}else if(void 0!==S){const c=BR(e,S,a,n,i,r,o,`${s}/else`,l);c.valid||ae.push({instanceLocation:o,keyword:"if",keywordLocation:t,error:'Instance does not match "else" schema.'},...c.errors)}}if("object"===u){if(void 0!==y)for(const t of y)t in e||ae.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});const t=Object.keys(e);if(void 0!==O&&t.length<O&&ae.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${O} properties.`}),void 0!==D&&t.length>D&&ae.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${D} properties.`}),void 0!==M){const t=`${s}/propertyNames`;for(const s in e){const e=`${o}/${lR(s)}`,l=BR(s,M,a,n,i,r,e,t);l.valid||ae.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:t,error:`Property name "${s}" does not match schema.`},...l.errors)}}if(void 0!==I){const t=`${s}/dependantRequired`;for(const a in I)if(a in e){const n=I[a];for(const i of n)i in e||ae.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:t,error:`Instance has "${a}" but does not have "${i}".`})}}if(void 0!==N)for(const t in N){const c=`${s}/dependentSchemas`;if(t in e){const s=BR(e,N[t],a,n,i,r,o,`${c}/${lR(t)}`,l);s.valid||ae.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:c,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(void 0!==j){const t=`${s}/dependencies`;for(const s in j)if(s in e){const l=j[s];if(Array.isArray(l))for(const a of l)a in e||ae.push({instanceLocation:o,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not have "${a}".`});else{const c=BR(e,l,a,n,i,r,o,`${t}/${lR(s)}`);c.valid||ae.push({instanceLocation:o,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...c.errors)}}}const c=Object.create(null);let u=!1;if(void 0!==_){const t=`${s}/properties`;for(const s in _){if(!(s in e))continue;const d=`${o}/${lR(s)}`,m=BR(e[s],_[s],a,n,i,r,d,`${t}/${lR(s)}`);if(m.valid)l[s]=c[s]=!0;else if(u=i,ae.push({instanceLocation:o,keyword:"properties",keywordLocation:t,error:`Property "${s}" does not match schema.`},...m.errors),u)break}}if(!u&&void 0!==C){const t=`${s}/patternProperties`;for(const s in C){const d=new RegExp(s),m=C[s];for(const h in e){if(!d.test(h))continue;const p=`${o}/${lR(h)}`,g=BR(e[h],m,a,n,i,r,p,`${t}/${lR(s)}`);g.valid?l[h]=c[h]=!0:(u=i,ae.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:t,error:`Property "${h}" matches pattern "${s}" but does not match associated schema.`},...g.errors))}}}if(u||void 0===T){if(!u&&void 0!==P){const t=`${s}/unevaluatedProperties`;for(const s in e)if(!l[s]){const c=`${o}/${lR(s)}`,u=BR(e[s],P,a,n,i,r,c,t);u.valid?l[s]=!0:ae.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else{const t=`${s}/additionalProperties`;for(const s in e){if(c[s])continue;const d=`${o}/${lR(s)}`,m=BR(e[s],T,a,n,i,r,d,t);m.valid?l[s]=!0:(u=i,ae.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...m.errors))}}}else if("array"===u){void 0!==W&&e.length>W&&ae.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${W}).`}),void 0!==U&&e.length<U&&ae.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${U}).`});const t=e.length;let c=0,u=!1;if(void 0!==z){const d=`${s}/prefixItems`,m=Math.min(z.length,t);for(;c<m;c++){const t=BR(e[c],z[c],a,n,i,r,`${o}/${c}`,`${d}/${c}`);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}}if(void 0!==R){const d=`${s}/items`;if(Array.isArray(R)){const s=Math.min(R.length,t);for(;c<s;c++){const t=BR(e[c],R[c],a,n,i,r,`${o}/${c}`,`${d}/${c}`);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}}else for(;c<t;c++){const t=BR(e[c],R,a,n,i,r,`${o}/${c}`,d);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}if(!u&&void 0!==L){const d=`${s}/additionalItems`;for(;c<t;c++){const t=BR(e[c],L,a,n,i,r,`${o}/${c}`,d);l[c]=!0,t.valid||(u=i,ae.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:d,error:"Items did not match additional items schema."},...t.errors))}}}if(void 0!==B)if(0===t&&void 0===H)ae.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==H&&t<H)ae.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${H}).`});else{const c=`${s}/contains`,u=ae.length;let d=0;for(let s=0;s<t;s++){const t=BR(e[s],B,a,n,i,r,`${o}/${s}`,c);t.valid?(l[s]=!0,d++):ae.push(...t.errors)}d>=(H||0)&&(ae.length=u),void 0===H&&void 0===q&&0===d?ae.splice(u,0,{instanceLocation:o,keyword:"contains",keywordLocation:c,error:"Array does not contain item matching schema."}):void 0!==H&&d<H?ae.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${H} items matching schema. Only ${d} items were found.`}):void 0!==q&&d>q&&ae.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${q} items matching schema. ${d} items were found.`})}if(!u&&void 0!==F){const u=`${s}/unevaluatedItems`;for(;c<t;c++){if(l[c])continue;const t=BR(e[c],F,a,n,i,r,`${o}/${c}`,u);l[c]=!0,t.valid||ae.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:u,error:"Items did not match unevaluated items schema."},...t.errors)}}if(V)for(let a=0;a<t;a++){const n=e[a],i="object"==typeof n&&null!==n;for(let r=0;r<t;r++){if(a===r)continue;const t=e[r];(n===t||i&&("object"==typeof t&&null!==t)&&sR(n,t))&&(ae.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${a} and ${r}.`}),a=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===a?(void 0!==$&&(!0===K&&e<=$||e<$)&&ae.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${K?"or equal to ":""} ${$}.`}),void 0!==G&&(!0===Z&&e>=G||e>G)&&ae.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Z?"or equal to ":""} ${G}.`})):(void 0!==$&&e<$&&ae.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${$}.`}),void 0!==G&&e>G&&ae.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${G}.`}),void 0!==K&&e<=K&&ae.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${K}.`}),void 0!==Z&&e>=Z&&ae.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Z}.`})),void 0!==Y){const t=e%Y;Math.abs(0-t)>=1.1920929e-7&&Math.abs(Y-t)>=1.1920929e-7&&ae.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Y}.`})}}else if("string"===u){const t=void 0===X&&void 0===Q?0:function(e){let t,a=0,n=e.length,i=0;for(;i<n;)a++,t=e.charCodeAt(i++),t>=55296&&t<=56319&&i<n&&(t=e.charCodeAt(i),56320==(64512&t)&&i++);return a}(e);void 0!==X&&t<X&&ae.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${X}).`}),void 0!==Q&&t>Q&&ae.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Q}).`}),void 0===J||new RegExp(J).test(e)||ae.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),void 0!==E&&IR[E]&&!IR[E](e)&&ae.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${E}".`})}return{valid:0===ae.length,errors:ae}}class HR extends rR{async*_transform(e){for await(const t of e)"string"==typeof t?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}}class qR extends HR{constructor(e){super(e),Object.defineProperty(this,"diff",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.diff=e?.diff??this.diff}async*_transform(e){let t,a;for await(const n of e){if("string"!=typeof n&&"string"!=typeof n.content)throw new Error("Cannot handle non-string output.");let e;if(hf(n)){if("string"!=typeof n.content)throw new Error("Cannot handle non-string message output.");e=new dk({message:n,text:n.content})}else if(mf(n)){if("string"!=typeof n.content)throw new Error("Cannot handle non-string message output.");e=new dk({message:If(n),text:n.content})}else e=new uk({text:n});a=void 0===a?e:a.concat(e);const i=await this.parsePartialResult([a]);null==i||sR(i,t)||(this.diff?yield this._diff(t,i):yield i,t=i)}}getFormatInstructions(){return""}}class UR extends HR{constructor(){super(...arguments),Object.defineProperty(this,"re",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async*_transform(e){let t="";for await(const a of e)if(t+="string"==typeof a?a:a.content,this.re){const e=[...t.matchAll(this.re)];if(e.length>1){let a=0;for(const t of e.slice(0,-1))yield[t[1]],a+=(t.index??0)+t[0].length;t=t.slice(a)}}else{const e=await this.parse(t);if(e.length>1){for(const t of e.slice(0,-1))yield[t];t=e[e.length-1]}}for(const e of await this.parse(t))yield[e]}}class WR extends rR{static lc_name(){return"StructuredOutputParser"}toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","output_parsers","structured"]})}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const t=jp.object(Object.fromEntries(Object.entries(e).map((([e,t])=>[e,jp.string().describe(t)]))));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.\n\n"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.\n\nFor example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}}}\nwould match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.\nThus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.\n\nYour output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!\n\nHere is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:\n\`\`\`json\n${JSON.stringify(Gk(this.schema))}\n\`\`\`\n`}async parse(e){try{const t=(e.includes("```")?e.trim().split(/```(?:json)?/)[1]:e.trim()).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,((e,t)=>`"${t.replace(/\n/g,"\\n")}"`)).replace(/\n/g,"");return await this.schema.parseAsync(JSON.parse(t))}catch(t){throw new oR(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}}class VR extends WR{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){const t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:\n\`\`\`json\n${this._schemaToInstruction(Gk(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}\n\`\`\``}_schemaToInstruction(e,t=2){const a=e;if("type"in a){let e,n=!1;if(Array.isArray(a.type)){const t=a.type.findIndex((e=>"null"===e));-1!==t&&(n=!0,a.type.splice(t,1)),e=a.type.join(" | ")}else e=a.type;if("object"===a.type&&a.properties){const e=a.description?` // ${a.description}`:"",n=Object.entries(a.properties).map((([e,n])=>{const i=a.required?.includes(e)?"":" (optional)";return`${" ".repeat(t)}"${e}": ${this._schemaToInstruction(n,t+2)}${i}`})).join("\n");return`{\n${n}\n${" ".repeat(t-2)}}${e}`}if("array"===a.type&&a.items){const e=a.description?` // ${a.description}`:"";return`array[\n${" ".repeat(t)}${this._schemaToInstruction(a.items,t+2)}\n${" ".repeat(t-2)}] ${e}`}const i=n?" (nullable)":"";return`${e}${a.description?` // ${a.description}`:""}${i}`}if("anyOf"in a)return a.anyOf.map((e=>this._schemaToInstruction(e,t))).join(`\n${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const t=jp.object(Object.fromEntries(Object.entries(e).map((([e,t])=>[e,jp.string().describe(t)]))));return new this(t)}}var $R=Object.freeze({__proto__:null,applyPatch:Fx,compare:Ux});class GR extends qR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0})}static lc_name(){return"JsonOutputParser"}_diff(e,t){if(t)return e?Ux(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return tf(e[0].text)}async parse(e){return tf(e,JSON.parse)}getFormatInstructions(){return""}}const KR=function(){const e={parser:function(e,t){return new a(e,t)}};e.SAXParser=a,e.SAXStream=r,e.createStream=function(e,t){return new r(e,t)},e.MAX_BUFFER_LENGTH=65536;const t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function a(n,i){if(!(this instanceof a))return new a(n,i);var r=this;!function(e){for(var a=0,n=t.length;a<n;a++)e[t[a]]=""}(r),r.q=r.c="",r.bufferCheckPosition=e.MAX_BUFFER_LENGTH,r.opt=i||{},r.opt.lowercase=r.opt.lowercase||r.opt.lowercasetags,r.looseCase=r.opt.lowercase?"toLowerCase":"toUpperCase",r.tags=[],r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.strict=!!n,r.noscript=!(!n&&!r.opt.noscript),r.state=w.BEGIN,r.strictEntities=r.opt.strictEntities,r.ENTITIES=r.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),r.attribList=[],r.opt.xmlns&&(r.ns=Object.create(u)),r.trackPosition=!1!==r.opt.position,r.trackPosition&&(r.position=r.line=r.column=0),k(r,"onready")}e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var a in e)e.hasOwnProperty(a)&&t.push(a);return t}),a.prototype={end:function(){C(this)},write:function(a){var n=this;if(this.error)throw this.error;if(n.closed)return _(n,"Cannot write after close. Assign an onready handler.");if(null===a)return C(n);"object"==typeof a&&(a=a.toString());var i=0,r="";for(;r=z(a,i++),n.c=r,r;)switch(n.trackPosition&&(n.position++,"\n"===r?(n.line++,n.column=0):n.column++),n.state){case w.BEGIN:if(n.state=w.BEGIN_WHITESPACE,"\ufeff"===r)continue;j(n,r);continue;case w.BEGIN_WHITESPACE:j(n,r);continue;case w.TEXT:if(n.sawRoot&&!n.closedRoot){for(var l=i-1;r&&"<"!==r&&"&"!==r;)(r=z(a,i++))&&n.trackPosition&&(n.position++,"\n"===r?(n.line++,n.column=0):n.column++);n.textNode+=a.substring(l,i-1)}"<"!==r||n.sawRoot&&n.closedRoot&&!n.strict?(g(r)||n.sawRoot&&!n.closedRoot||T(n,"Text data outside of root node."),"&"===r?n.state=w.TEXT_ENTITY:n.textNode+=r):(n.state=w.OPEN_WAKA,n.startTagPosition=n.position);continue;case w.SCRIPT:"<"===r?n.state=w.SCRIPT_ENDING:n.script+=r;continue;case w.SCRIPT_ENDING:"/"===r?n.state=w.CLOSE_TAG:(n.script+="<"+r,n.state=w.SCRIPT);continue;case w.OPEN_WAKA:if("!"===r)n.state=w.SGML_DECL,n.sgmlDecl="";else if(g(r));else if(b(d,r))n.state=w.OPEN_TAG,n.tagName=r;else if("/"===r)n.state=w.CLOSE_TAG,n.tagName="";else if("?"===r)n.state=w.PROC_INST,n.procInstName=n.procInstBody="";else{if(T(n,"Unencoded <"),n.startTagPosition+1<n.position){var c=n.position-n.startTagPosition;r=new Array(c).join(" ")+r}n.textNode+="<"+r,n.state=w.TEXT}continue;case w.SGML_DECL:(n.sgmlDecl+r).toUpperCase()===o?(A(n,"onopencdata"),n.state=w.CDATA,n.sgmlDecl="",n.cdata=""):n.sgmlDecl+r==="--"?(n.state=w.COMMENT,n.comment="",n.sgmlDecl=""):(n.sgmlDecl+r).toUpperCase()===s?(n.state=w.DOCTYPE,(n.doctype||n.sawRoot)&&T(n,"Inappropriately located doctype declaration"),n.doctype="",n.sgmlDecl=""):">"===r?(A(n,"onsgmldeclaration",n.sgmlDecl),n.sgmlDecl="",n.state=w.TEXT):f(r)?(n.state=w.SGML_DECL_QUOTED,n.sgmlDecl+=r):n.sgmlDecl+=r;continue;case w.SGML_DECL_QUOTED:r===n.q&&(n.state=w.SGML_DECL,n.q=""),n.sgmlDecl+=r;continue;case w.DOCTYPE:">"===r?(n.state=w.TEXT,A(n,"ondoctype",n.doctype),n.doctype=!0):(n.doctype+=r,"["===r?n.state=w.DOCTYPE_DTD:f(r)&&(n.state=w.DOCTYPE_QUOTED,n.q=r));continue;case w.DOCTYPE_QUOTED:n.doctype+=r,r===n.q&&(n.q="",n.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:n.doctype+=r,"]"===r?n.state=w.DOCTYPE:f(r)&&(n.state=w.DOCTYPE_DTD_QUOTED,n.q=r);continue;case w.DOCTYPE_DTD_QUOTED:n.doctype+=r,r===n.q&&(n.state=w.DOCTYPE_DTD,n.q="");continue;case w.COMMENT:"-"===r?n.state=w.COMMENT_ENDING:n.comment+=r;continue;case w.COMMENT_ENDING:"-"===r?(n.state=w.COMMENT_ENDED,n.comment=E(n.opt,n.comment),n.comment&&A(n,"oncomment",n.comment),n.comment=""):(n.comment+="-"+r,n.state=w.COMMENT);continue;case w.COMMENT_ENDED:">"!==r?(T(n,"Malformed comment"),n.comment+="--"+r,n.state=w.COMMENT):n.state=w.TEXT;continue;case w.CDATA:"]"===r?n.state=w.CDATA_ENDING:n.cdata+=r;continue;case w.CDATA_ENDING:"]"===r?n.state=w.CDATA_ENDING_2:(n.cdata+="]"+r,n.state=w.CDATA);continue;case w.CDATA_ENDING_2:">"===r?(n.cdata&&A(n,"oncdata",n.cdata),A(n,"onclosecdata"),n.cdata="",n.state=w.TEXT):"]"===r?n.cdata+="]":(n.cdata+="]]"+r,n.state=w.CDATA);continue;case w.PROC_INST:"?"===r?n.state=w.PROC_INST_ENDING:g(r)?n.state=w.PROC_INST_BODY:n.procInstName+=r;continue;case w.PROC_INST_BODY:if(!n.procInstBody&&g(r))continue;"?"===r?n.state=w.PROC_INST_ENDING:n.procInstBody+=r;continue;case w.PROC_INST_ENDING:">"===r?(A(n,"onprocessinginstruction",{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody="",n.state=w.TEXT):(n.procInstBody+="?"+r,n.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:b(m,r)?n.tagName+=r:(P(n),">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:(g(r)||T(n,"Invalid character in tag name"),n.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:">"===r?(M(n,!0),I(n)):(T(n,"Forward-slash in opening tag not followed by >"),n.state=w.ATTRIB);continue;case w.ATTRIB:if(g(r))continue;">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:b(d,r)?(n.attribName=r,n.attribValue="",n.state=w.ATTRIB_NAME):T(n,"Invalid attribute name");continue;case w.ATTRIB_NAME:"="===r?n.state=w.ATTRIB_VALUE:">"===r?(T(n,"Attribute without value"),n.attribValue=n.attribName,D(n),M(n)):g(r)?n.state=w.ATTRIB_NAME_SAW_WHITE:b(m,r)?n.attribName+=r:T(n,"Invalid attribute name");continue;case w.ATTRIB_NAME_SAW_WHITE:if("="===r)n.state=w.ATTRIB_VALUE;else{if(g(r))continue;T(n,"Attribute without value"),n.tag.attributes[n.attribName]="",n.attribValue="",A(n,"onattribute",{name:n.attribName,value:""}),n.attribName="",">"===r?M(n):b(d,r)?(n.attribName=r,n.state=w.ATTRIB_NAME):(T(n,"Invalid attribute name"),n.state=w.ATTRIB)}continue;case w.ATTRIB_VALUE:if(g(r))continue;f(r)?(n.q=r,n.state=w.ATTRIB_VALUE_QUOTED):(T(n,"Unquoted attribute value"),n.state=w.ATTRIB_VALUE_UNQUOTED,n.attribValue=r);continue;case w.ATTRIB_VALUE_QUOTED:if(r!==n.q){"&"===r?n.state=w.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=r;continue}D(n),n.q="",n.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:g(r)?n.state=w.ATTRIB:">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:b(d,r)?(T(n,"No whitespace between attributes"),n.attribName=r,n.attribValue="",n.state=w.ATTRIB_NAME):T(n,"Invalid attribute name");continue;case w.ATTRIB_VALUE_UNQUOTED:if(!y(r)){"&"===r?n.state=w.ATTRIB_VALUE_ENTITY_U:n.attribValue+=r;continue}D(n),">"===r?M(n):n.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(n.tagName)">"===r?I(n):b(m,r)?n.tagName+=r:n.script?(n.script+="</"+n.tagName,n.tagName="",n.state=w.SCRIPT):(g(r)||T(n,"Invalid tagname in closing tag"),n.state=w.CLOSE_TAG_SAW_WHITE);else{if(g(r))continue;v(d,r)?n.script?(n.script+="</"+r,n.state=w.SCRIPT):T(n,"Invalid tagname in closing tag."):n.tagName=r}continue;case w.CLOSE_TAG_SAW_WHITE:if(g(r))continue;">"===r?I(n):T(n,"Invalid characters in closing tag");continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var u,x;switch(n.state){case w.TEXT_ENTITY:u=w.TEXT,x="textNode";break;case w.ATTRIB_VALUE_ENTITY_Q:u=w.ATTRIB_VALUE_QUOTED,x="attribValue";break;case w.ATTRIB_VALUE_ENTITY_U:u=w.ATTRIB_VALUE_UNQUOTED,x="attribValue"}if(";"===r)if(n.opt.unparsedEntities){var k=N(n);n.entity="",n.state=u,n.write(k)}else n[x]+=N(n),n.entity="",n.state=u;else b(n.entity.length?p:h,r)?n.entity+=r:(T(n,"Invalid character in entity name"),n[x]+="&"+n.entity+r,n.entity="",n.state=u);continue;default:throw new Error(n,"Unknown state: "+n.state)}n.position>=n.bufferCheckPosition&&function(a){for(var n=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,r=0,o=t.length;r<o;r++){var s=a[t[r]].length;if(s>n)switch(t[r]){case"textNode":S(a);break;case"cdata":A(a,"oncdata",a.cdata),a.cdata="";break;case"script":A(a,"onscript",a.script),a.script="";break;default:_(a,"Max buffer length exceeded: "+t[r])}i=Math.max(i,s)}var l=e.MAX_BUFFER_LENGTH-i;a.bufferCheckPosition=l+a.position}(n);return n}
414
+ */function qx(e,t,a,n,i){if(t!==e){"function"==typeof t.toJSON&&(t=t.toJSON());for(var r=_x(t),o=_x(e),s=!1,l=o.length-1;l>=0;l--){var c=e[d=o[l]];if(!Ex(t,d)||void 0===t[d]&&void 0!==c&&!1===Array.isArray(t))Array.isArray(e)===Array.isArray(t)?(i&&a.push({op:"test",path:n+"/"+Px(d),value:Cx(c)}),a.push({op:"remove",path:n+"/"+Px(d)}),s=!0):(i&&a.push({op:"test",path:n,value:e}),a.push({op:"replace",path:n,value:t}));else{var u=t[d];"object"==typeof c&&null!=c&&"object"==typeof u&&null!=u&&Array.isArray(c)===Array.isArray(u)?qx(c,u,a,n+"/"+Px(d),i):c!==u&&(i&&a.push({op:"test",path:n+"/"+Px(d),value:Cx(c)}),a.push({op:"replace",path:n+"/"+Px(d),value:Cx(u)}))}}if(s||r.length!=o.length)for(l=0;l<r.length;l++){var d;Ex(e,d=r[l])||void 0===t[d]||a.push({op:"add",path:n+"/"+Px(d),value:Cx(t[d])})}}}function Ux(e,t,a=!1){var n=[];return qx(e,t,n,"",a),n}const Wx=new class{getStore(){}run(e,t){return t()}enterWith(e){}},Vx=Symbol.for("ls:tracing_async_local_storage"),$x=Symbol.for("lc:child_config"),Gx=Symbol.for("lc:context_variables");const Kx=new class{getInstance(){return globalThis[Vx]??Wx}getRunnableConfig(){const e=this.getInstance();return e.getStore()?.extra?.[$x]}runWithConfig(e,t,a){const n=Nw._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata),i=this.getInstance(),r=i.getStore(),o=n?.getParentRunId(),s=n?.handlers?.find((e=>"langchain_tracer"===e?.name));let l;return s&&o?l=s.convertToRunTree(o):a||(l=new mw({name:"<runnable_lambda>",tracingEnabled:!1})),l&&(l.extra={...l.extra,[$x]:e}),void 0!==r&&void 0!==r[Gx]&&(l[Gx]=r[Gx]),i.run(l,t)}initializeGlobalInstance(e){void 0===globalThis[Vx]&&(globalThis[Vx]=e)}};async function Zx(e,t){if(void 0===t)return e;let a;return Promise.race([e.catch((e=>{if(!t?.aborted)throw e})),new Promise(((e,n)=>{a=()=>{n(new Error("Aborted"))},t.addEventListener("abort",a),t.aborted&&n(new Error("Aborted"))}))]).finally((()=>t.removeEventListener("abort",a)))}class Yx extends ReadableStream{constructor(){super(...arguments),Object.defineProperty(this,"reader",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}ensureReader(){this.reader||(this.reader=this.getReader())}async next(){this.ensureReader();try{const e=await this.reader.read();return e.done?(this.reader.releaseLock(),{done:!0,value:void 0}):{done:!1,value:e.value}}catch(e){throw this.reader.releaseLock(),e}}async return(){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}return{done:!0,value:void 0}}async throw(e){if(this.ensureReader(),this.locked){const e=this.reader.cancel();this.reader.releaseLock(),await e}throw e}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}static fromReadableStream(e){const t=e.getReader();return new Yx({start:e=>function a(){return t.read().then((({done:t,value:n})=>{if(!t)return e.enqueue(n),a();e.close()}))}(),cancel(){t.releaseLock()}})}static fromAsyncGenerator(e){return new Yx({async pull(t){const{value:a,done:n}=await e.next();n&&t.close(),t.enqueue(a)},async cancel(t){await e.return(t)}})}}function Xx(e,t=2){const a=Array.from({length:t},(()=>[]));return a.map((async function*(t){for(;;)if(0===t.length){const t=await e.next();for(const e of a)e.push(t)}else{if(t[0].done)return;yield t.shift().value}}))}function Qx(e,t){if(Array.isArray(e)&&Array.isArray(t))return e.concat(t);if("string"==typeof e&&"string"==typeof t)return e+t;if("number"==typeof e&&"number"==typeof t)return e+t;if("concat"in e&&"function"==typeof e.concat)return e.concat(t);if("object"==typeof e&&"object"==typeof t){const a={...e};for(const[e,n]of Object.entries(t))e in a&&!Array.isArray(a[e])?a[e]=Qx(a[e],n):a[e]=n;return a}throw new Error(`Cannot concat ${typeof e} and ${typeof t}`)}class Jx{constructor(e){Object.defineProperty(this,"generator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"setup",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"signal",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResult",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"firstResultUsed",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.generator=e.generator,this.config=e.config,this.signal=e.signal??this.config?.signal,this.setup=new Promise(((t,a)=>{Kx.runWithConfig(e.config,(async()=>{this.firstResult=e.generator.next(),e.startSetup?this.firstResult.then(e.startSetup).then(t,a):this.firstResult.then((e=>t(void 0)),a)}),!0)}))}async next(...e){return this.signal?.throwIfAborted(),this.firstResultUsed?Kx.runWithConfig(this.config,this.signal?async()=>Zx(this.generator.next(...e),this.signal):async()=>this.generator.next(...e),!0):(this.firstResultUsed=!0,this.firstResult)}async return(e){return this.generator.return(e)}async throw(e){return this.generator.throw(e)}[Symbol.asyncIterator](){return this}async[Symbol.asyncDispose](){await this.return()}}async function ek(e,t,a,n,...i){const r=new Jx({generator:t,startSetup:a,signal:n}),o=await r.setup;return{output:e(r,o,...i),setup:o}}var tk=Object.freeze({__proto__:null,AsyncGeneratorWithSetup:Jx,IterableReadableStream:Yx,atee:Xx,concat:Qx,pipeGeneratorWithSetup:ek});class ak{constructor(e){Object.defineProperty(this,"ops",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.ops=e.ops??[]}concat(e){const t=this.ops.concat(e.ops),a=Fx({},t);return new nk({ops:t,state:a[a.length-1].newDocument})}}class nk extends ak{constructor(e){super(e),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.state=e.state}concat(e){const t=this.ops.concat(e.ops),a=Fx(this.state,e.ops);return new nk({ops:t,state:a[a.length-1].newDocument})}static fromRunLogPatch(e){const t=Fx({},e.ops);return new nk({ops:e.ops,state:t[t.length-1].newDocument})}}const ik=e=>"log_stream_tracer"===e.name;async function rk(e,t){if("original"===t)throw new Error("Do not assign inputs with original schema drop the key for now. When inputs are added to streamLog they should be added with standardized schema for streaming events.");const{inputs:a}=e;return["retriever","llm","prompt"].includes(e.run_type)?a:1!==Object.keys(a).length||""!==a?.input?a.input:void 0}async function ok(e,t){const{outputs:a}=e;return"original"===t||["retriever","llm","prompt"].includes(e.run_type)?a:void 0!==a&&1===Object.keys(a).length&&void 0!==a?.output?a.output:a}class sk extends Ug{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_schemaFormat",{enumerable:!0,configurable:!0,writable:!0,value:"original"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"keyMapByRunId",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"counterMapByRunName",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"log_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this._schemaFormat=e?._schemaFormat??this._schemaFormat,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Yx.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){if(e.id===this.rootId)return!1;const t=e.tags??[];let a=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(e.run_type)),void 0!==this.includeTags&&(a=a||void 0!==t.find((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(e.run_type)),void 0!==this.excludeTags&&(a=a&&t.every((e=>!this.excludeTags?.includes(e)))),a}async*tapOutputIterable(e,t){for await(const a of t){if(e!==this.rootId){const t=this.keyMapByRunId[e];t&&await this.writer.write(new ak({ops:[{op:"add",path:`/logs/${t}/streamed_output/-`,value:a}]}))}yield a}}async onRunCreate(e){if(void 0===this.rootId&&(this.rootId=e.id,await this.writer.write(new ak({ops:[{op:"replace",path:"",value:{id:e.id,name:e.name,type:e.run_type,streamed_output:[],final_output:void 0,logs:{}}}]}))),!this._includeRun(e))return;void 0===this.counterMapByRunName[e.name]&&(this.counterMapByRunName[e.name]=0),this.counterMapByRunName[e.name]+=1;const t=this.counterMapByRunName[e.name];this.keyMapByRunId[e.id]=1===t?e.name:`${e.name}:${t}`;const a={id:e.id,name:e.name,type:e.run_type,tags:e.tags??[],metadata:e.extra?.metadata??{},start_time:new Date(e.start_time).toISOString(),streamed_output:[],streamed_output_str:[],final_output:void 0,end_time:void 0};"streaming_events"===this._schemaFormat&&(a.inputs=await rk(e,this._schemaFormat)),await this.writer.write(new ak({ops:[{op:"add",path:`/logs/${this.keyMapByRunId[e.id]}`,value:a}]}))}async onRunUpdate(e){try{const t=this.keyMapByRunId[e.id];if(void 0===t)return;const a=[];"streaming_events"===this._schemaFormat&&a.push({op:"replace",path:`/logs/${t}/inputs`,value:await rk(e,this._schemaFormat)}),a.push({op:"add",path:`/logs/${t}/final_output`,value:await ok(e,this._schemaFormat)}),void 0!==e.end_time&&a.push({op:"add",path:`/logs/${t}/end_time`,value:new Date(e.end_time).toISOString()});const n=new ak({ops:a});await this.writer.write(n)}finally{if(e.id===this.rootId){const t=new ak({ops:[{op:"replace",path:"/final_output",value:await ok(e,this._schemaFormat)}]});await this.writer.write(t),this.autoClose&&await this.writer.close()}}}async onLLMNewToken(e,t,a){const n=this.keyMapByRunId[e.id];if(void 0===n)return;let i;i=void 0!==e.inputs.messages?function(e){return void 0!==e&&void 0!==e.message}(a?.chunk)?a?.chunk:new vf({id:`run-${e.id}`,content:t}):t;const r=new ak({ops:[{op:"add",path:`/logs/${n}/streamed_output_str/-`,value:t},{op:"add",path:`/logs/${n}/streamed_output/-`,value:i}]});await this.writer.write(r)}}var lk=Object.freeze({__proto__:null,LogStreamCallbackHandler:sk,RunLog:nk,RunLogPatch:ak,isLogStreamHandler:ik});const ck="__run";class uk{constructor(e){Object.defineProperty(this,"text",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"generationInfo",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.text=e.text,this.generationInfo=e.generationInfo}concat(e){return new uk({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo}})}}class dk extends uk{constructor(e){super(e),Object.defineProperty(this,"message",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.message=e.message}concat(e){return new dk({text:this.text+e.text,generationInfo:{...this.generationInfo,...e.generationInfo},message:this.message.concat(e.message)})}}var mk=Object.freeze({__proto__:null,ChatGenerationChunk:dk,GenerationChunk:uk,RUN_KEY:ck});function hk({name:e,serialized:t}){return void 0!==e?e:void 0!==t?.name?t.name:void 0!==t?.id&&Array.isArray(t?.id)?t.id[t.id.length-1]:"Unnamed"}const pk=e=>"event_stream_tracer"===e.name;class gk extends Ug{constructor(e){super({_awaitHandler:!0,...e}),Object.defineProperty(this,"autoClose",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"runInfoMap",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"tappedPromises",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"transformStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"writer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"receiveStream",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"event_stream_tracer"}),this.autoClose=e?.autoClose??!0,this.includeNames=e?.includeNames,this.includeTypes=e?.includeTypes,this.includeTags=e?.includeTags,this.excludeNames=e?.excludeNames,this.excludeTypes=e?.excludeTypes,this.excludeTags=e?.excludeTags,this.transformStream=new TransformStream,this.writer=this.transformStream.writable.getWriter(),this.receiveStream=Yx.fromReadableStream(this.transformStream.readable)}[Symbol.asyncIterator](){return this.receiveStream}async persistRun(e){}_includeRun(e){const t=e.tags??[];let a=void 0===this.includeNames&&void 0===this.includeTags&&void 0===this.includeTypes;return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(e.runType)),void 0!==this.includeTags&&(a=a||void 0!==t.find((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(e.runType)),void 0!==this.excludeTags&&(a=a&&t.every((e=>!this.excludeTags?.includes(e)))),a}async*tapOutputIterable(e,t){const a=await t.next();if(a.done)return;const n=this.runInfoMap.get(e);if(void 0===n)return void(yield a.value);function i(e,t){return"llm"===e&&"string"==typeof t?new uk({text:t}):t}let r=this.tappedPromises.get(e);if(void 0===r){let o;r=new Promise((e=>{o=e})),this.tappedPromises.set(e,r);try{const r={event:`on_${n.runType}_stream`,run_id:e,name:n.name,tags:n.tags,metadata:n.metadata,data:{}};await this.send({...r,data:{chunk:i(n.runType,a.value)}},n),yield a.value;for await(const e of t)"tool"!==n.runType&&"retriever"!==n.runType&&await this.send({...r,data:{chunk:i(n.runType,e)}},n),yield e}finally{o()}}else{yield a.value;for await(const e of t)yield e}}async send(e,t){this._includeRun(t)&&await this.writer.write(e)}async sendEndEvent(e,t){const a=this.tappedPromises.get(e.run_id);void 0!==a?a.then((()=>{this.send(e,t)})):await this.send(e,t)}async onLLMStart(e){const t=hk(e),a=void 0!==e.inputs.messages?"chat_model":"llm",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:a,inputs:e.inputs};this.runInfoMap.set(e.id,n);const i=`on_${a}_start`;await this.send({event:i,data:{input:e.inputs},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onLLMNewToken(e,t,a){const n=this.runInfoMap.get(e.id);let i,r;if(void 0===n)throw new Error(`onLLMNewToken: Run ID ${e.id} not found in run map.`);if(1!==this.runInfoMap.size){if("chat_model"===n.runType)r="on_chat_model_stream",i=void 0===a?.chunk?new vf({content:t,id:`run-${e.id}`}):a.chunk.message;else{if("llm"!==n.runType)throw new Error(`Unexpected run type ${n.runType}`);r="on_llm_stream",i=void 0===a?.chunk?new uk({text:t}):a.chunk}await this.send({event:r,data:{chunk:i},run_id:e.id,name:n.name,tags:n.tags,metadata:n.metadata},n)}}async onLLMEnd(e){const t=this.runInfoMap.get(e.id);let a;if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onLLMEnd: Run ID ${e.id} not found in run map.`);const n=e.outputs?.generations;let i;if("chat_model"===t.runType){for(const e of n??[]){if(void 0!==i)break;i=e[0]?.message}a="on_chat_model_end"}else{if("llm"!==t.runType)throw new Error(`onLLMEnd: Unexpected run type: ${t.runType}`);i={generations:n?.map((e=>e.map((e=>({text:e.text,generationInfo:e.generationInfo}))))),llmOutput:e.outputs?.llmOutput??{}},a="on_llm_end"}await this.sendEndEvent({event:a,data:{output:i,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onChainStart(e){const t=hk(e),a=e.run_type??"chain",n={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:e.run_type};let i={};""===e.inputs.input&&1===Object.keys(e.inputs).length?(i={},n.inputs={}):void 0!==e.inputs.input?(i.input=e.inputs.input,n.inputs=e.inputs.input):(i.input=e.inputs,n.inputs=e.inputs),this.runInfoMap.set(e.id,n),await this.send({event:`on_${a}_start`,data:i,name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},n)}async onChainEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onChainEnd: Run ID ${e.id} not found in run map.`);const a=`on_${e.run_type}_end`,n=e.inputs??t.inputs??{},i={output:e.outputs?.output??e.outputs,input:n};n.input&&1===Object.keys(n).length&&(i.input=n.input,t.inputs=n.input),await this.sendEndEvent({event:a,data:i,run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata??{}},t)}async onToolStart(e){const t=hk(e),a={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"tool",inputs:e.inputs??{}};this.runInfoMap.set(e.id,a),await this.send({event:"on_tool_start",data:{input:e.inputs??{}},name:t,run_id:e.id,tags:e.tags??[],metadata:e.extra?.metadata??{}},a)}async onToolEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onToolEnd: Run ID ${e.id} not found in run map.`);if(void 0===t.inputs)throw new Error(`onToolEnd: Run ID ${e.id} is a tool call, and is expected to have traced inputs.`);const a=void 0===e.outputs?.output?e.outputs:e.outputs.output;await this.sendEndEvent({event:"on_tool_end",data:{output:a,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async onRetrieverStart(e){const t=hk(e),a={tags:e.tags??[],metadata:e.extra?.metadata??{},name:t,runType:"retriever",inputs:{query:e.inputs.query}};this.runInfoMap.set(e.id,a),await this.send({event:"on_retriever_start",data:{input:{query:e.inputs.query}},name:t,tags:e.tags??[],run_id:e.id,metadata:e.extra?.metadata??{}},a)}async onRetrieverEnd(e){const t=this.runInfoMap.get(e.id);if(this.runInfoMap.delete(e.id),void 0===t)throw new Error(`onRetrieverEnd: Run ID ${e.id} not found in run map.`);await this.sendEndEvent({event:"on_retriever_end",data:{output:e.outputs?.documents??e.outputs,input:t.inputs},run_id:e.id,name:t.name,tags:t.tags,metadata:t.metadata},t)}async handleCustomEvent(e,t,a){const n=this.runInfoMap.get(a);if(void 0===n)throw new Error(`handleCustomEvent: Run ID ${a} not found in run map.`);await this.send({event:"on_custom_event",run_id:a,name:e,tags:n.tags,metadata:n.metadata,data:t},n)}async finish(){const e=[...this.tappedPromises.values()];Promise.all(e).finally((()=>{this.writer.close()}))}}async function fk(e){return Nw._configureSync(e?.callbacks,void 0,e?.tags,void 0,e?.metadata)}function yk(...e){const t={};for(const a of e.filter((e=>!!e)))for(const e of Object.keys(a))if("metadata"===e)t[e]={...t[e],...a[e]};else if("tags"===e){const n=t[e]??[];t[e]=[...new Set(n.concat(a[e]??[]))]}else if("configurable"===e)t[e]={...t[e],...a[e]};else if("timeout"===e)void 0===t.timeout?t.timeout=a.timeout:void 0!==a.timeout&&(t.timeout=Math.min(t.timeout,a.timeout));else if("signal"===e)void 0===t.signal?t.signal=a.signal:void 0!==a.signal&&("any"in AbortSignal?t.signal=AbortSignal.any([t.signal,a.signal]):t.signal=a.signal);else if("callbacks"===e){const e=t.callbacks,n=a.callbacks;if(Array.isArray(n))if(e)if(Array.isArray(e))t.callbacks=e.concat(n);else{const a=e.copy();for(const e of n)a.addHandler(jw(e),!0);t.callbacks=a}else t.callbacks=n;else if(n)if(e)if(Array.isArray(e)){const a=n.copy();for(const t of e)a.addHandler(jw(t),!0);t.callbacks=a}else t.callbacks=new Nw(n._parentRunId,{handlers:e.handlers.concat(n.handlers),inheritableHandlers:e.inheritableHandlers.concat(n.inheritableHandlers),tags:Array.from(new Set(e.tags.concat(n.tags))),inheritableTags:Array.from(new Set(e.inheritableTags.concat(n.inheritableTags))),metadata:{...e.metadata,...n.metadata}});else t.callbacks=n}else{const n=e;t[n]=a[n]??t[n]}return t}const bk=new Set(["string","number","boolean"]);function vk(e){const t=Kx.getRunnableConfig();let a={tags:[],metadata:{},recursionLimit:25,runId:void 0};if(t){const{runId:e,runName:n,...i}=t;a=Object.entries(i).reduce(((e,[t,a])=>(void 0!==a&&(e[t]=a),e)),a)}if(e&&(a=Object.entries(e).reduce(((e,[t,a])=>(void 0!==a&&(e[t]=a),e)),a)),a?.configurable)for(const e of Object.keys(a.configurable))bk.has(typeof a.configurable[e])&&!a.metadata?.[e]&&(a.metadata||(a.metadata={}),a.metadata[e]=a.configurable[e]);if(void 0!==a.timeout){if(a.timeout<=0)throw new Error("Timeout must be a positive number");const e=AbortSignal.timeout(a.timeout);void 0!==a.signal?"any"in AbortSignal&&(a.signal=AbortSignal.any([a.signal,e])):a.signal=e,delete a.timeout}return a}function wk(e={},{callbacks:t,maxConcurrency:a,recursionLimit:n,runName:i,configurable:r,runId:o}={}){const s=vk(e);return void 0!==t&&(delete s.runName,s.callbacks=t),void 0!==n&&(s.recursionLimit=n),void 0!==a&&(s.maxConcurrency=a),void 0!==i&&(s.runName=i),void 0!==r&&(s.configurable={...s.configurable,...r}),void 0!==o&&delete s.runId,s}class xk extends Ug{constructor({config:e,onStart:t,onEnd:a,onError:n}){super({_awaitHandler:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"RootListenersTracer"}),Object.defineProperty(this,"rootId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnStart",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnEnd",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"argOnError",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.config=e,this.argOnStart=t,this.argOnEnd=a,this.argOnError=n}persistRun(e){return Promise.resolve()}async onRunCreate(e){this.rootId||(this.rootId=e.id,this.argOnStart&&await this.argOnStart(e,this.config))}async onRunUpdate(e){e.id===this.rootId&&(e.error?this.argOnError&&await this.argOnError(e,this.config):this.argOnEnd&&await this.argOnEnd(e,this.config))}}function kk(e){return!!e&&e.lc_runnable}class Ak{constructor(e){Object.defineProperty(this,"includeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"includeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTypes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"excludeTags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.includeNames=e.includeNames,this.includeTypes=e.includeTypes,this.includeTags=e.includeTags,this.excludeNames=e.excludeNames,this.excludeTypes=e.excludeTypes,this.excludeTags=e.excludeTags}includeEvent(e,t){let a=void 0===this.includeNames&&void 0===this.includeTypes&&void 0===this.includeTags;const n=e.tags??[];return void 0!==this.includeNames&&(a=a||this.includeNames.includes(e.name)),void 0!==this.includeTypes&&(a=a||this.includeTypes.includes(t)),void 0!==this.includeTags&&(a=a||n.some((e=>this.includeTags?.includes(e)))),void 0!==this.excludeNames&&(a=a&&!this.excludeNames.includes(e.name)),void 0!==this.excludeTypes&&(a=a&&!this.excludeTypes.includes(t)),void 0!==this.excludeTags&&(a=a&&n.every((e=>!this.excludeTags?.includes(e)))),a}}const Sk=Symbol("Let zodToJsonSchema decide on which parser to use"),Ek={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},_k=e=>{const t=(e=>({...Ek,...e}))(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:a,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map((([e,a])=>[a._def,{def:a._def,path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}])))}};function Ck(e,t,a,n){n?.errorMessages&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function Tk(e,t,a,n,i){e[t]=a,Ck(e,t,n,i)}function Pk(e,t,a){const n=a??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(((a,n)=>Pk(e,t,a)))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return Ok(e,t)}}const Ok=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const n of e.checks)switch(n.kind){case"min":Tk(a,"minimum",n.value,n.message,t);break;case"max":Tk(a,"maximum",n.value,n.message,t)}return a};let Dk;const Mk={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===Dk&&(Dk=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Dk),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function Ik(e,t){const a={type:"string"};function n(e){return"escape"===t.patternStrategy?Nk(e):e}if(e.checks)for(const i of e.checks)switch(i.kind){case"min":Tk(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t);break;case"max":Tk(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":jk(a,"email",i.message,t);break;case"format:idn-email":jk(a,"idn-email",i.message,t);break;case"pattern:zod":zk(a,Mk.email,i.message,t)}break;case"url":jk(a,"uri",i.message,t);break;case"uuid":jk(a,"uuid",i.message,t);break;case"regex":zk(a,i.regex,i.message,t);break;case"cuid":zk(a,Mk.cuid,i.message,t);break;case"cuid2":zk(a,Mk.cuid2,i.message,t);break;case"startsWith":zk(a,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":zk(a,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":jk(a,"date-time",i.message,t);break;case"date":jk(a,"date",i.message,t);break;case"time":jk(a,"time",i.message,t);break;case"duration":jk(a,"duration",i.message,t);break;case"length":Tk(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t),Tk(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"includes":zk(a,RegExp(n(i.value)),i.message,t);break;case"ip":"v6"!==i.version&&jk(a,"ipv4",i.message,t),"v4"!==i.version&&jk(a,"ipv6",i.message,t);break;case"emoji":zk(a,Mk.emoji,i.message,t);break;case"ulid":zk(a,Mk.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":jk(a,"binary",i.message,t);break;case"contentEncoding:base64":Tk(a,"contentEncoding","base64",i.message,t);break;case"pattern:zod":zk(a,Mk.base64,i.message,t)}break;case"nanoid":zk(a,Mk.nanoid,i.message,t)}return a}const Nk=e=>Array.from(e).map((e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`)).join(""),jk=(e,t,a,n)=>{e.format||e.anyOf?.some((e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&n.errorMessages&&{errorMessage:{format:a}}})):Tk(e,"format",t,a,n)},zk=(e,t,a,n)=>{e.pattern||e.allOf?.some((e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:Rk(t,n),...a&&n.errorMessages&&{errorMessage:{pattern:a}}})):Tk(e,"pattern",Rk(t,n),a,n)},Rk=(e,t)=>{const a="function"==typeof e?e():e;if(!t.applyRegexFlags||!a.flags)return a.source;const n=a.flags.includes("i"),i=a.flags.includes("m"),r=a.flags.includes("s"),o=n?a.source.toLowerCase():a.source;let s="",l=!1,c=!1,u=!1;for(let e=0;e<o.length;e++)if(l)s+=o[e],l=!1;else{if(n)if(c){if(o[e].match(/[a-z]/)){u?(s+=o[e],s+=`${o[e-2]}-${o[e]}`.toUpperCase(),u=!1):"-"===o[e+1]&&o[e+2]?.match(/[a-z]/)?(s+=o[e],u=!0):s+=`${o[e]}${o[e].toUpperCase()}`;continue}}else if(o[e].match(/[a-z]/)){s+=`[${o[e]}${o[e].toUpperCase()}]`;continue}if(i){if("^"===o[e]){s+="(^|(?<=[\r\n]))";continue}if("$"===o[e]){s+="($|(?=[\r\n]))";continue}}r&&"."===o[e]?s+=c?`${o[e]}\r\n`:`[${o[e]}\r\n]`:(s+=o[e],"\\"===o[e]?l=!0:c&&"]"===o[e]?c=!1:c||"["!==o[e]||(c=!0))}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),a.source}return s};function Lk(e,t){if("openApi3"===t.target&&e.keyType?._def.typeName===Qh.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce(((a,n)=>({...a,[n]:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}})),{}),additionalProperties:!1};const a={type:"object",additionalProperties:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if("openApi3"===t.target)return a;if(e.keyType?._def.typeName===Qh.ZodString&&e.keyType._def.checks?.length){const n=Object.entries(Ik(e.keyType._def,t)).reduce(((e,[t,a])=>"type"===t?e:{...e,[t]:a}),{});return{...a,propertyNames:n}}return e.keyType?._def.typeName===Qh.ZodEnum?{...a,propertyNames:{enum:e.keyType._def.values}}:a}const Fk={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const Bk=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]}))).filter((e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0)));return a.length?{anyOf:a}:void 0};function Hk(e,t){return"strict"===t.removeAdditionalStrategy?"ZodNever"===e.catchall._def.typeName?"strict"!==e.unknownKeys:qk(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:"ZodNever"===e.catchall._def.typeName?"passthrough"===e.unknownKeys:qk(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function qk(e,t,a=!1){const n=t.seen.get(e);if(t.override){const i=t.override?.(e,t,n,a);if(i!==Sk)return i}if(n&&!a){const e=Uk(n,t);if(void 0!==e)return e}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const r=Vk(e,e.typeName,t);return r&&$k(e,t,r),i.jsonSchema=r,r}const Uk=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:Wk(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every(((e,a)=>t.currentPath[a]===e))?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):"seen"===t.$refStrategy?{}:void 0}},Wk=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")},Vk=(e,t,a)=>{switch(t){case Qh.ZodString:return Ik(e,a);case Qh.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"int":a.type="integer",Ck(a,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?Tk(a,"minimum",n.value,n.message,t):Tk(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Tk(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Tk(a,"maximum",n.value,n.message,t):Tk(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Tk(a,"maximum",n.value,n.message,t));break;case"multipleOf":Tk(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodObject:return function(e,t){const a={type:"object",...Object.entries(e.shape()).reduce(((e,[a,n])=>{if(void 0===n||void 0===n._def)return e;const i=qk(n._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});return void 0===i?e:{properties:{...e.properties,[a]:i},required:n.isOptional()?e.required:[...e.required,a]}}),{properties:{},required:[]}),additionalProperties:Hk(e,t)};return a.required.length||delete a.required,a}(e,a);case Qh.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?Tk(a,"minimum",n.value,n.message,t):Tk(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),Tk(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?Tk(a,"maximum",n.value,n.message,t):Tk(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),Tk(a,"maximum",n.value,n.message,t));break;case"multipleOf":Tk(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodBoolean:return{type:"boolean"};case Qh.ZodDate:return Pk(e,a);case Qh.ZodUndefined:return{not:{}};case Qh.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Qh.ZodArray:return function(e,t){const a={type:"array"};return e.type?._def?.typeName!==Qh.ZodAny&&(a.items=qk(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&Tk(a,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&Tk(a,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(Tk(a,"minItems",e.exactLength.value,e.exactLength.message,t),Tk(a,"maxItems",e.exactLength.value,e.exactLength.message,t)),a}(e,a);case Qh.ZodUnion:case Qh.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return Bk(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every((e=>e._def.typeName in Fk&&(!e._def.checks||!e._def.checks.length)))){const e=a.reduce(((e,t)=>{const a=Fk[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e}),[]);return{type:e.length>1?e:e[0]}}if(a.every((e=>"ZodLiteral"===e._def.typeName&&!e.description))){const e=a.reduce(((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}}),[]);if(e.length===a.length){const t=e.filter(((e,t,a)=>a.indexOf(e)===t));return{type:t.length>1?t:t[0],enum:a.reduce(((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value]),[])}}}else if(a.every((e=>"ZodEnum"===e._def.typeName)))return{type:"string",enum:a.reduce(((e,t)=>[...e,...t._def.values.filter((t=>!e.includes(t)))]),[])};return Bk(e,t)}(e,a);case Qh.ZodIntersection:return function(e,t){const a=[qk(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),qk(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter((e=>!!e));let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return a.forEach((e=>{if((e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e)(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...n}=e;t=n}else n=void 0;i.push(t)}})),i.length?{allOf:i,...n}:void 0}(e,a);case Qh.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[]),additionalItems:qk(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map(((e,a)=>qk(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[])}}(e,a);case Qh.ZodRecord:return Lk(e,a);case Qh.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Qh.ZodEnum:return function(e){return{type:"string",enum:e.values}}(e);case Qh.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter((e=>"number"!=typeof t[t[e]])),n=a.map((e=>t[e])),i=Array.from(new Set(n.map((e=>typeof e))));return{type:1===i.length?"string"===i[0]?"string":"number":["string","number"],enum:n}}(e);case Qh.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target?{type:Fk[e.innerType._def.typeName],nullable:!0}:{type:[Fk[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Qh.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return qk(e.innerType._def,t);const a=qk(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:{}},a]}:{}})(e,a);case Qh.ZodMap:return function(e,t){return"record"===t.mapStrategy?Lk(e,t):{type:"array",maxItems:125,items:{type:"array",items:[qk(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}}}(e,a);case Qh.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:qk(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&Tk(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&Tk(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Qh.ZodLazy:return qk(e.getter()._def,a);case Qh.ZodPromise:return function(e,t){return qk(e.type._def,t)}(e,a);case Qh.ZodNaN:case Qh.ZodNever:return{not:{}};case Qh.ZodEffects:return function(e,t){return"input"===t.effectStrategy?qk(e.schema._def,t):{}}(e,a);case Qh.ZodAny:case Qh.ZodUnknown:return{};case Qh.ZodDefault:return function(e,t){return{...qk(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Qh.ZodBranded:return function(e,t){return qk(e.type._def,t)}(e,a);case Qh.ZodReadonly:case Qh.ZodCatch:return((e,t)=>qk(e.innerType._def,t))(e,a);case Qh.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return qk(e.in._def,t);if("output"===t.pipeStrategy)return qk(e.out._def,t);const a=qk(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,qk(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter((e=>void 0!==e))}})(e,a);case Qh.ZodFunction:case Qh.ZodVoid:case Qh.ZodSymbol:default:return}},$k=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a),Gk=(e,t)=>{const a=_k(t),n=void 0,i=t?.name,r=qk(e._def,a,!1)??{},o=void 0===i?r:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,i].join("/"),[a.definitionPath]:{...n,[i]:r}};return"jsonSchema7"===a.target?o.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"===a.target&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),o};function Kk(e){return e.replace(/[^a-zA-Z-_0-9]/g,"_")}const Zk=["*","_","`"];function Yk(e,t,a){const{firstNode:n,lastNode:i,nodeColors:r,withStyles:o=!0,curveStyle:s="linear",wrapLabelNWords:l=9}=a??{};let c=o?`%%{init: {'flowchart': {'curve': '${s}'}}}%%\ngraph TD;\n`:"graph TD;\n";if(o){const t="default",a={[t]:"{0}({1})"};void 0!==n&&(a[n]="{0}([{1}]):::first"),void 0!==i&&(a[i]="{0}([{1}]):::last");for(const[n,i]of Object.entries(e)){const e=i.name.split(":").pop()??"",r=Zk.some((t=>e.startsWith(t)&&e.endsWith(t)))?`<p>${e}</p>`:e;let o=r;Object.keys(i.metadata??{}).length&&(o+=`<hr/><small><em>${Object.entries(i.metadata??{}).map((([e,t])=>`${e} = ${t}`)).join("\n")}</em></small>`);const s=(a[n]??a[t]).replace("{0}",Kk(n)).replace("{1}",o);c+=`\t${s}\n`}}const u={};for(const e of t){const t=e.source.split(":"),a=e.target.split(":"),n=t.filter(((e,t)=>e===a[t])).join(":");u[n]||(u[n]=[]),u[n].push(e)}const d=new Set;function m(e,t){const a=1===e.length&&e[0].source===e[0].target;if(t&&!a){const e=t.split(":").pop();if(d.has(e))throw new Error(`Found duplicate subgraph '${e}' -- this likely means that you're reusing a subgraph node with the same name. Please adjust your graph to have subgraph nodes with unique names.`);d.add(e),c+=`\tsubgraph ${e}\n`}for(const t of e){const{source:e,target:a,data:n,conditional:i}=t;let r="";if(void 0!==n){let e=n;const t=e.split(" ");t.length>l&&(e=Array.from({length:Math.ceil(t.length/l)},((e,a)=>t.slice(a*l,(a+1)*l).join(" "))).join("&nbsp;<br>&nbsp;")),r=i?` -. &nbsp;${e}&nbsp; .-> `:` -- &nbsp;${e}&nbsp; --\x3e `}else r=i?" -.-> ":" --\x3e ";c+=`\t${Kk(e)}${r}${Kk(a)};\n`}for(const e in u)e.startsWith(`${t}:`)&&e!==t&&m(u[e],e);t&&!a&&(c+="\tend\n")}m(u[""]??[],"");for(const e in u)e.includes(":")||""===e||m(u[e],e);return o&&(c+=function(e){let t="";for(const[a,n]of Object.entries(e))t+=`\tclassDef ${a} ${n};\n`;return t}(r??{})),c}function Xk(e,t){if(void 0!==e&&!Rp(e))return e;if(!kk(t))return t.name??"UnknownSchema";try{let e=t.getName();return e=e.startsWith("Runnable")?e.slice(8):e,e}catch(e){return t.getName()}}function Qk(e){return kk(e.data)?{type:"runnable",data:{id:e.data.lc_id,name:e.data.getName()}}:{type:"schema",data:{...Gk(e.data.schema),title:e.data.name}}}let Jk=class e{constructor(e){Object.defineProperty(this,"nodes",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"edges",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.nodes=e?.nodes??this.nodes,this.edges=e?.edges??this.edges}toJSON(){const e={};return Object.values(this.nodes).forEach(((t,a)=>{e[t.id]=Rp(t.id)?a:t.id})),{nodes:Object.values(this.nodes).map((t=>({id:e[t.id],...Qk(t)}))),edges:this.edges.map((t=>{const a={source:e[t.source],target:e[t.target]};return void 0!==t.data&&(a.data=t.data),void 0!==t.conditional&&(a.conditional=t.conditional),a}))}}addNode(e,t,a){if(void 0!==t&&void 0!==this.nodes[t])throw new Error(`Node with id ${t} already exists`);const n=t??Xp(),i={id:n,data:e,name:Xk(t,e),metadata:a};return this.nodes[n]=i,i}removeNode(e){delete this.nodes[e.id],this.edges=this.edges.filter((t=>t.source!==e.id&&t.target!==e.id))}addEdge(e,t,a,n){if(void 0===this.nodes[e.id])throw new Error(`Source node ${e.id} not in graph`);if(void 0===this.nodes[t.id])throw new Error(`Target node ${t.id} not in graph`);const i={source:e.id,target:t.id,data:a,conditional:n};return this.edges.push(i),i}firstNode(){return eA(this)}lastNode(){return tA(this)}extend(e,t=""){let a=t;const n=Object.values(e.nodes).map((e=>e.id));n.every(Rp)&&(a="");const i=e=>a?`${a}:${e}`:e;Object.entries(e.nodes).forEach((([e,t])=>{this.nodes[i(e)]={...t,id:i(e)}}));const r=e.edges.map((e=>({...e,source:i(e.source),target:i(e.target)})));this.edges=[...this.edges,...r];const o=e.firstNode(),s=e.lastNode();return[o?{id:i(o.id),data:o.data}:void 0,s?{id:i(s.id),data:s.data}:void 0]}trimFirstNode(){const e=this.firstNode();e&&eA(this,[e.id])&&this.removeNode(e)}trimLastNode(){const e=this.lastNode();e&&tA(this,[e.id])&&this.removeNode(e)}reid(){const t=Object.fromEntries(Object.values(this.nodes).map((e=>[e.id,e.name]))),a=new Map;Object.values(t).forEach((e=>{a.set(e,(a.get(e)||0)+1)}));const n=e=>{const n=t[e];return Rp(e)&&1===a.get(n)?n:e};return new e({nodes:Object.fromEntries(Object.entries(this.nodes).map((([e,t])=>[n(e),{...t,id:n(e)}]))),edges:this.edges.map((e=>({...e,source:n(e.source),target:n(e.target)})))})}drawMermaid(e){const{withStyles:t,curveStyle:a,nodeColors:n={default:"fill:#f2f0ff,line-height:1.2",first:"fill-opacity:0",last:"fill:#bfb6fc"},wrapLabelNWords:i}=e??{},r=this.reid(),o=r.firstNode(),s=r.lastNode();return Yk(r.nodes,r.edges,{firstNode:o?.id,lastNode:s?.id,withStyles:t,curveStyle:a,nodeColors:n,wrapLabelNWords:i})}async drawMermaidPng(e){return async function(e,t){let{backgroundColor:a="white"}=t??{};const n=btoa(e);void 0!==a&&(/^#(?:[0-9a-fA-F]{3}){1,2}$/.test(a)||(a=`!${a}`));const i=`https://mermaid.ink/img/${n}?bgColor=${a}`,r=await fetch(i);if(!r.ok)throw new Error(["Failed to render the graph using the Mermaid.INK API.",`Status code: ${r.status}`,`Status text: ${r.statusText}`].join("\n"));return await r.blob()}(this.drawMermaid(e),{backgroundColor:e?.backgroundColor})}};function eA(e,t=[]){const a=new Set(e.edges.filter((e=>!t.includes(e.source))).map((e=>e.target))),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||a.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function tA(e,t=[]){const a=new Set(e.edges.filter((e=>!t.includes(e.target))).map((e=>e.source))),n=[];for(const i of Object.values(e.nodes))t.includes(i.id)||a.has(i.id)||n.push(i);return 1===n.length?n[0]:void 0}function aA(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.iterator]&&"function"==typeof e.next}function nA(e){return"object"==typeof e&&null!==e&&"function"==typeof e[Symbol.asyncIterator]}function*iA(e,t){for(;;){const{value:a,done:n}=Kx.runWithConfig(e,t.next.bind(t),!0);if(n)break;yield a}}async function*rA(e,t){const a=t[Symbol.asyncIterator]();for(;;){const{value:n,done:i}=await Kx.runWithConfig(e,a.next.bind(t),!0);if(i)break;yield n}}function oA(e,t){return!e||Array.isArray(e)||e instanceof Date||"object"!=typeof e?{[t]:e}:e}class sA extends Sg{constructor(){super(...arguments),Object.defineProperty(this,"lc_runnable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}getName(e){const t=this.name??this.constructor.lc_name()??this.constructor.name;return e?`${t}${e}`:t}bind(e){return new lA({bound:this,kwargs:e,config:{}})}map(){return new cA({bound:this})}withRetry(e){return new uA({bound:this,kwargs:{},config:{},maxAttemptNumber:e?.stopAfterAttempt,...e})}withConfig(e){return new lA({bound:this,config:e,kwargs:{}})}withFallbacks(e){const t=Array.isArray(e)?e:e.fallbacks;return new gA({runnable:this,fallbacks:t})}_getOptionsList(e,t=0){if(Array.isArray(e)&&e.length!==t)throw new Error(`Passed "options" must be an array with the same length as the inputs, but got ${e.length} options for ${t} inputs`);if(Array.isArray(e))return e.map(vk);if(t>1&&!Array.isArray(e)&&e.runId){console.warn("Provided runId will be used only for the first element of the batch.");const a=Object.fromEntries(Object.entries(e).filter((([e])=>"runId"!==e)));return Array.from({length:t},((t,n)=>vk(0===n?e:a)))}return Array.from({length:t},(()=>vk(e)))}async batch(e,t,a){const n=this._getOptionsList(t??{},e.length),i=n[0]?.maxConcurrency??a?.maxConcurrency,r=new ix({maxConcurrency:i,onFailedAttempt:e=>{throw e}}),o=e.map(((e,t)=>r.call((async()=>{try{return await this.invoke(e,n[t])}catch(e){if(a?.returnExceptions)return e;throw e}}))));return Promise.all(o)}async*_streamIterator(e,t){yield this.invoke(e,t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this._streamIterator(e,a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}_separateRunnableConfigFromCallOptions(e){let t;t=vk(void 0===e?e:{callbacks:e.callbacks,tags:e.tags,metadata:e.metadata,runName:e.runName,configurable:e.configurable,recursionLimit:e.recursionLimit,maxConcurrency:e.maxConcurrency,runId:e.runId,timeout:e.timeout,signal:e.signal});const a={...e};return delete a.callbacks,delete a.tags,delete a.metadata,delete a.runName,delete a.configurable,delete a.recursionLimit,delete a.maxConcurrency,delete a.runId,delete a.timeout,delete a.signal,[t,a]}async _callWithConfig(e,t,a){const n=vk(a),i=await fk(n),r=await(i?.handleChainStart(this.toJSON(),oA(t,"input"),n.runId,n?.runType,void 0,void 0,n?.runName??this.getName()));let o;delete n.runId;try{const i=e.call(this,t,n,r);o=await Zx(i,a?.signal)}catch(e){throw await(r?.handleChainError(e)),e}return await(r?.handleChainEnd(oA(o,"output"))),o}async _batchWithConfig(e,t,a,n){const i=this._getOptionsList(a??{},t.length),r=await Promise.all(i.map(fk)),o=await Promise.all(r.map((async(e,a)=>{const n=await(e?.handleChainStart(this.toJSON(),oA(t[a],"input"),i[a].runId,i[a].runType,void 0,void 0,i[a].runName??this.getName()));return delete i[a].runId,n})));let s;try{const a=e.call(this,t,i,o,n);s=await Zx(a,i?.[0]?.signal)}catch(e){throw await Promise.all(o.map((t=>t?.handleChainError(e)))),e}return await Promise.all(o.map((e=>e?.handleChainEnd(oA(s,"output"))))),s}async*_transformStreamWithConfig(e,t,a){let n,i,r=!0,o=!0;const s=vk(a),l=await fk(s);let c;try{const u=await ek(t.bind(this),async function*(){for await(const t of e){if(r)if(void 0===n)n=t;else try{n=Qx(n,t)}catch{n=void 0,r=!1}yield t}}(),(async()=>l?.handleChainStart(this.toJSON(),{input:""},s.runId,s.runType,void 0,void 0,s.runName??this.getName())),a?.signal,s);delete s.runId,c=u.setup;const d=c?.handlers.find(pk);let m=u.output;void 0!==d&&void 0!==c&&(m=d.tapOutputIterable(c.runId,m));const h=c?.handlers.find(ik);void 0!==h&&void 0!==c&&(m=h.tapOutputIterable(c.runId,m));for await(const e of m)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch{i=void 0,o=!1}}catch(e){throw await(c?.handleChainError(e,void 0,void 0,void 0,{inputs:oA(n,"input")})),e}await(c?.handleChainEnd(i??{},void 0,void 0,void 0,{inputs:oA(n,"input")}))}getGraph(e){const t=new Jk,a=t.addNode({name:`${this.getName()}Input`,schema:jp.any()}),n=t.addNode(this),i=t.addNode({name:`${this.getName()}Output`,schema:jp.any()});return t.addEdge(a,n),t.addEdge(n,i),t}pipe(e){return new dA({first:this,last:fA(e)})}pick(e){return this.pipe(new bA(e))}assign(e){return this.pipe(new yA(new mA({steps:e})))}async*transform(e,t){let a;for await(const t of e)a=void 0===a?t:Qx(a,t);yield*this._streamIterator(a,vk(t))}async*streamLog(e,t,a){const n=new sk({...a,autoClose:!1,_schemaFormat:"original"}),i=vk(t);yield*this._streamLog(e,n,i)}async*_streamLog(e,t,a){const{callbacks:n}=a;if(void 0===n)a.callbacks=[t];else if(Array.isArray(n))a.callbacks=n.concat([t]);else{const e=n.copy();e.addHandler(t,!0),a.callbacks=e}const i=this.stream(e,a);const r=async function(){try{const e=await i;for await(const a of e){const e=new ak({ops:[{op:"add",path:"/streamed_output/-",value:a}]});await t.writer.write(e)}}finally{await t.writer.close()}}();try{for await(const e of t)yield e}finally{await r}}streamEvents(e,t,a){let n;if("v1"===t.version)n=this._streamEventsV1(e,t,a);else{if("v2"!==t.version)throw new Error('Only versions "v1" and "v2" of the schema are currently supported.');n=this._streamEventsV2(e,t,a)}return"text/event-stream"===t.encoding?function(e){const t=new TextEncoder,a=new ReadableStream({async start(a){for await(const n of e)a.enqueue(t.encode(`event: data\ndata: ${JSON.stringify(n)}\n\n`));a.enqueue(t.encode("event: end\n\n")),a.close()}});return Yx.fromReadableStream(a)}(n):Yx.fromAsyncGenerator(n)}async*_streamEventsV2(e,t,a){const n=new gk({...a,autoClose:!1}),i=vk(t),r=i.runId??Xp();i.runId=r;const o=i.callbacks;if(void 0===o)i.callbacks=[n];else if(Array.isArray(o))i.callbacks=o.concat(n);else{const e=o.copy();e.addHandler(n,!0),i.callbacks=e}const s=this;const l=async function(){try{const t=await s.stream(e,i),a=n.tapOutputIterable(r,t);for await(const e of a);}finally{await n.finish()}}();let c,u=!1;try{for await(const t of n)u?(t.run_id===c&&t.event.endsWith("_end")&&t.data?.input&&delete t.data.input,yield t):(t.data.input=e,u=!0,c=t.run_id,yield t)}finally{await l}}async*_streamEventsV1(e,t,a){let n,i=!1;const r=vk(t),o=r.tags??[],s=r.metadata??{},l=r.runName??this.getName(),c=new sk({...a,autoClose:!1,_schemaFormat:"streaming_events"}),u=new Ak({...a}),d=this._streamLog(e,c,r);for await(const t of d){if(n=n?n.concat(t):nk.fromRunLogPatch(t),void 0===n.state)throw new Error('Internal error: "streamEvents" state is missing. Please open a bug report.');if(!i){i=!0;const t={...n.state},a={run_id:t.id,event:`on_${t.type}_start`,name:l,tags:o,metadata:s,data:{input:e}};u.includeEvent(a,t.type)&&(yield a)}const a=t.ops.filter((e=>e.path.startsWith("/logs/"))).map((e=>e.path.split("/")[2])),r=[...new Set(a)];for(const e of r){let t,a={};const i=n.state.logs[e];if(t=void 0===i.end_time?i.streamed_output.length>0?"stream":"start":"end","start"===t)void 0!==i.inputs&&(a.input=i.inputs);else if("end"===t)void 0!==i.inputs&&(a.input=i.inputs),a.output=i.final_output;else if("stream"===t){const e=i.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${i.name}"`);a={chunk:i.streamed_output[0]},i.streamed_output=[]}yield{event:`on_${i.type}_${t}`,name:i.name,run_id:i.id,tags:i.tags,metadata:i.metadata,data:a}}const{state:c}=n;if(c.streamed_output.length>0){const e=c.streamed_output.length;if(1!==e)throw new Error(`Expected exactly one chunk of streamed output, got ${e} instead. Encountered in: "${c.name}"`);const t={chunk:c.streamed_output[0]};c.streamed_output=[];const a={event:`on_${c.type}_stream`,run_id:c.id,tags:o,metadata:s,name:l,data:t};u.includeEvent(a,c.type)&&(yield a)}}const m=n?.state;if(void 0!==m){const e={event:`on_${m.type}_end`,name:l,run_id:m.id,tags:o,metadata:s,data:{output:m.final_output}};u.includeEvent(e,m.type)&&(yield e)}}static isRunnable(e){return kk(e)}withListeners({onStart:e,onEnd:t,onError:a}){return new lA({bound:this,config:{},configFactories:[n=>({callbacks:[new xk({config:n,onStart:e,onEnd:t,onError:a})]})]})}asTool(e){return function(e,t){const a=t.name??e.getName(),n=t.description??t.schema?.description;if(t.schema.constructor===jp.ZodString)return new vA({name:a,description:n,schema:jp.object({input:jp.string()}).transform((e=>e.input)),bound:e});return new vA({name:a,description:n,schema:t.schema,bound:e})}(this,e)}}class lA extends sA{static lc_name(){return"RunnableBinding"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"config",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"kwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"configFactories",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound,this.kwargs=e.kwargs,this.config=e.config,this.configFactories=e.configFactories}getName(e){return this.bound.getName(e)}async _mergeConfig(...e){const t=yk(this.config,...e);return yk(t,...this.configFactories?await Promise.all(this.configFactories.map((async e=>await e(t)))):[])}bind(e){return new this.constructor({bound:this.bound,kwargs:{...this.kwargs,...e},config:this.config})}withConfig(e){return new this.constructor({bound:this.bound,kwargs:this.kwargs,config:{...this.config,...e}})}withRetry(e){return new this.constructor({bound:this.bound.withRetry(e),kwargs:this.kwargs,config:this.config})}async invoke(e,t){return this.bound.invoke(e,await this._mergeConfig(vk(t),this.kwargs))}async batch(e,t,a){const n=Array.isArray(t)?await Promise.all(t.map((async e=>this._mergeConfig(vk(e),this.kwargs)))):await this._mergeConfig(vk(t),this.kwargs);return this.bound.batch(e,n,a)}async*_streamIterator(e,t){yield*this.bound._streamIterator(e,await this._mergeConfig(vk(t),this.kwargs))}async stream(e,t){return this.bound.stream(e,await this._mergeConfig(vk(t),this.kwargs))}async*transform(e,t){yield*this.bound.transform(e,await this._mergeConfig(vk(t),this.kwargs))}streamEvents(e,t,a){const n=this;return Yx.fromAsyncGenerator(async function*(){yield*n.bound.streamEvents(e,{...await n._mergeConfig(vk(t),n.kwargs),version:t.version},a)}())}static isRunnableBinding(e){return e.bound&&sA.isRunnable(e.bound)}withListeners({onStart:e,onEnd:t,onError:a}){return new lA({bound:this.bound,kwargs:this.kwargs,config:this.config,configFactories:[n=>({callbacks:[new xk({config:n,onStart:e,onEnd:t,onError:a})]})]})}}class cA extends sA{static lc_name(){return"RunnableEach"}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"bound",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.bound=e.bound}bind(e){return new cA({bound:this.bound.bind(e)})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _invoke(e,t,a){return this.bound.batch(e,wk(t,{callbacks:a?.getChild()}))}withListeners({onStart:e,onEnd:t,onError:a}){return new cA({bound:this.bound.withListeners({onStart:e,onEnd:t,onError:a})})}}class uA extends lA{static lc_name(){return"RunnableRetry"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"maxAttemptNumber",{enumerable:!0,configurable:!0,writable:!0,value:3}),Object.defineProperty(this,"onFailedAttempt",{enumerable:!0,configurable:!0,writable:!0,value:()=>{}}),this.maxAttemptNumber=e.maxAttemptNumber??this.maxAttemptNumber,this.onFailedAttempt=e.onFailedAttempt??this.onFailedAttempt}_patchConfigForRetry(e,t,a){const n=e>1?`retry:attempt:${e}`:void 0;return wk(t,{callbacks:a?.getChild(n)})}async _invoke(e,t,a){return qf((n=>super.invoke(e,this._patchConfigForRetry(n,t,a))),{onFailedAttempt:t=>this.onFailedAttempt(t,e),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async _batch(e,t,a,n){const i={};try{await qf((async r=>{const o=e.map(((e,t)=>t)).filter((e=>void 0===i[e.toString()]||i[e.toString()]instanceof Error)),s=o.map((t=>e[t])),l=o.map((e=>this._patchConfigForRetry(r,t?.[e],a?.[e]))),c=await super.batch(s,l,{...n,returnExceptions:!0});let u;for(let e=0;e<c.length;e+=1){const t=c[e],a=o[e];t instanceof Error&&void 0===u&&(u=t,u.input=s[e]),i[a.toString()]=t}if(u)throw u;return c}),{onFailedAttempt:e=>this.onFailedAttempt(e,e.input),retries:Math.max(this.maxAttemptNumber-1,0),randomize:!0})}catch(e){if(!0!==n?.returnExceptions)throw e}return Object.keys(i).sort(((e,t)=>parseInt(e,10)-parseInt(t,10))).map((e=>i[parseInt(e,10)]))}async batch(e,t,a){return this._batchWithConfig(this._batch.bind(this),e,t,a)}}class dA extends sA{static lc_name(){return"RunnableSequence"}constructor(e){super(e),Object.defineProperty(this,"first",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"middle",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"last",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"omitSequenceTags",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),this.first=e.first,this.middle=e.middle??this.middle,this.last=e.last,this.name=e.name,this.omitSequenceTags=e.omitSequenceTags??this.omitSequenceTags}get steps(){return[this.first,...this.middle,this.last]}async invoke(e,t){const a=vk(t),n=await fk(a),i=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),a.runId,void 0,void 0,void 0,a?.runName));delete a.runId;let r,o=e;try{const e=[this.first,...this.middle];for(let n=0;n<e.length;n+=1){const r=e[n].invoke(o,wk(a,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${n+1}`)}));o=await Zx(r,t?.signal)}if(t?.signal?.aborted)throw new Error("Aborted");r=await this.last.invoke(o,wk(a,{callbacks:i?.getChild(this.omitSequenceTags?void 0:`seq:step:${this.steps.length}`)}))}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(oA(r,"output"))),r}async batch(e,t,a){const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map(fk)),r=await Promise.all(i.map((async(t,a)=>{const i=await(t?.handleChainStart(this.toJSON(),oA(e[a],"input"),n[a].runId,void 0,void 0,void 0,n[a].runName));return delete n[a].runId,i})));let o=e;try{for(let e=0;e<this.steps.length;e+=1){const t=this.steps[e].batch(o,r.map(((t,a)=>{const i=t?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`);return wk(n[a],{callbacks:i})})),a);o=await Zx(t,n[0]?.signal)}}catch(e){throw await Promise.all(r.map((t=>t?.handleChainError(e)))),e}return await Promise.all(r.map((e=>e?.handleChainEnd(oA(o,"output"))))),o}async*_streamIterator(e,t){const a=await fk(t),{runId:n,...i}=t??{},r=await(a?.handleChainStart(this.toJSON(),oA(e,"input"),n,void 0,void 0,void 0,i?.runName)),o=[this.first,...this.middle,this.last];let s,l=!0;try{let a=o[0].transform(async function*(){yield e}(),wk(i,{callbacks:r?.getChild(this.omitSequenceTags?void 0:"seq:step:1")}));for(let e=1;e<o.length;e+=1){const t=o[e];a=await t.transform(a,wk(i,{callbacks:r?.getChild(this.omitSequenceTags?void 0:`seq:step:${e+1}`)}))}for await(const e of a)if(t?.signal?.throwIfAborted(),yield e,l)if(void 0===s)s=e;else try{s=Qx(s,e)}catch(e){s=void 0,l=!1}}catch(e){throw await(r?.handleChainError(e)),e}await(r?.handleChainEnd(oA(s,"output")))}getGraph(e){const t=new Jk;let a=null;return this.steps.forEach(((n,i)=>{const r=n.getGraph(e);0!==i&&r.trimFirstNode(),i!==this.steps.length-1&&r.trimLastNode(),t.extend(r);const o=r.firstNode();if(!o)throw new Error(`Runnable ${n} has no first node`);a&&t.addEdge(a,o),a=r.lastNode()})),t}pipe(e){return dA.isRunnableSequence(e)?new dA({first:this.first,middle:this.middle.concat([this.last,e.first,...e.middle]),last:e.last,name:this.name??e.name}):new dA({first:this.first,middle:[...this.middle,this.last],last:fA(e),name:this.name})}static isRunnableSequence(e){return Array.isArray(e.middle)&&sA.isRunnable(e)}static from([e,...t],a){let n={};return"string"==typeof a?n.name=a:void 0!==a&&(n=a),new dA({...n,first:fA(e),middle:t.slice(0,-1).map(fA),last:fA(t[t.length-1])})}}class mA extends sA{static lc_name(){return"RunnableMap"}getStepsKeys(){return Object.keys(this.steps)}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"steps",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.steps={};for(const[t,a]of Object.entries(e.steps))this.steps[t]=fA(a)}static from(e){return new mA({steps:e})}async invoke(e,t){const a=vk(t),n=await fk(a),i=await(n?.handleChainStart(this.toJSON(),{input:e},a.runId,void 0,void 0,void 0,a?.runName));delete a.runId;const r={};try{const n=Object.entries(this.steps).map((async([t,n])=>{r[t]=await n.invoke(e,wk(a,{callbacks:i?.getChild(`map:key:${t}`)}))}));await Zx(Promise.all(n),t?.signal)}catch(e){throw await(i?.handleChainError(e)),e}return await(i?.handleChainEnd(r)),r}async*_transform(e,t,a){const n={...this.steps},i=Xx(e,Object.keys(n).length),r=new Map(Object.entries(n).map((([e,n],r)=>{const o=n.transform(i[r],wk(a,{callbacks:t?.getChild(`map:key:${e}`)}));return[e,o.next().then((t=>({key:e,gen:o,result:t})))]})));for(;r.size;){const e=Promise.race(r.values()),{key:t,result:n,gen:i}=await Zx(e,a?.signal);r.delete(t),n.done||(yield{[t]:n.value},r.set(t,i.next().then((e=>({key:t,gen:i,result:e})))))}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class hA extends sA{constructor(e){if(super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!ww(e.func))throw new Error("RunnableTraceable requires a function that is wrapped in traceable higher-order function");this.func=e.func}async invoke(e,t){const[a]=this._getOptionsList(t??{},1),n=await fk(a);return Zx(this.func(wk(a,{callbacks:n}),e),a?.signal)}async*_streamIterator(e,t){const[a]=this._getOptionsList(t??{},1),n=await this.invoke(e,t);if(nA(n))for await(const e of n)a?.signal?.throwIfAborted(),yield e;else if((e=>null!=e&&"object"==typeof e&&"next"in e&&"function"==typeof e.next)(n))for(;;){a?.signal?.throwIfAborted();const e=n.next();if(e.done)break;yield e.value}else yield n}static from(e){return new hA({func:e})}}class pA extends sA{static lc_name(){return"RunnableLambda"}constructor(e){if(ww(e.func))return hA.from(e.func);super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),function(e){if(ww(e))throw new Error("RunnableLambda requires a function that is not wrapped in traceable higher-order function. This shouldn't happen.")}(e.func),this.func=e.func}static from(e){return new pA({func:e})}async _invoke(e,t,a){return new Promise(((n,i)=>{const r=wk(t,{callbacks:a?.getChild(),recursionLimit:(t?.recursionLimit??25)-1});Kx.runWithConfig(r,(async()=>{try{let a=await this.func(e,{...r});if(a&&sA.isRunnable(a)){if(0===t?.recursionLimit)throw new Error("Recursion limit reached.");a=await a.invoke(e,{...r,recursionLimit:(r.recursionLimit??25)-1})}else if(nA(a)){let e;for await(const n of rA(r,a))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=Qx(e,n)}catch(t){e=n}a=e}else if(aA(a)){let e;for(const n of iA(r,a))if(t?.signal?.throwIfAborted(),void 0===e)e=n;else try{e=Qx(e,n)}catch(t){e=n}a=e}n(a)}catch(e){i(e)}}))}))}async invoke(e,t){return this._callWithConfig(this._invoke.bind(this),e,t)}async*_transform(e,t,a){let n;for await(const t of e)if(void 0===n)n=t;else try{n=Qx(n,t)}catch(e){n=t}const i=wk(a,{callbacks:t?.getChild(),recursionLimit:(a?.recursionLimit??25)-1}),r=await new Promise(((e,t)=>{Kx.runWithConfig(i,(async()=>{try{const t=await this.func(n,{...i,config:i});e(t)}catch(e){t(e)}}))}));if(r&&sA.isRunnable(r)){if(0===a?.recursionLimit)throw new Error("Recursion limit reached.");const e=await r.stream(n,i);for await(const t of e)yield t}else if(nA(r))for await(const e of rA(i,r))a?.signal?.throwIfAborted(),yield e;else if(aA(r))for(const e of iA(i,r))a?.signal?.throwIfAborted(),yield e;else yield r}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class gA extends sA{static lc_name(){return"RunnableWithFallbacks"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"fallbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.fallbacks=e.fallbacks}*runnables(){yield this.runnable;for(const e of this.fallbacks)yield e}async invoke(e,t){const a=vk(t),n=await fk(t),{runId:i,...r}=a,o=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),i,void 0,void 0,void 0,r?.runName));let s;for(const t of this.runnables()){a?.signal?.throwIfAborted();try{const a=await t.invoke(e,wk(r,{callbacks:o?.getChild()}));return await(o?.handleChainEnd(oA(a,"output"))),a}catch(e){void 0===s&&(s=e)}}if(void 0===s)throw new Error("No error stored at end of fallback.");throw await(o?.handleChainError(s)),s}async*_streamIterator(e,t){const a=vk(t),n=await fk(t),{runId:i,...r}=a,o=await(n?.handleChainStart(this.toJSON(),oA(e,"input"),i,void 0,void 0,void 0,r?.runName));let s,l,c;for(const t of this.runnables()){a?.signal?.throwIfAborted();const n=wk(r,{callbacks:o?.getChild()});try{l=await t.stream(e,n);break}catch(e){void 0===s&&(s=e)}}if(void 0===l){const e=s??new Error("No error stored at end of fallback.");throw await(o?.handleChainError(e)),e}try{for await(const e of l){yield e;try{c=void 0===c?c:Qx(c,e)}catch(e){c=void 0}}}catch(e){throw await(o?.handleChainError(e)),e}await(o?.handleChainEnd(oA(c,"output")))}async batch(e,t,a){if(a?.returnExceptions)throw new Error("Not implemented.");const n=this._getOptionsList(t??{},e.length),i=await Promise.all(n.map((e=>fk(e)))),r=await Promise.all(i.map((async(t,a)=>{const i=await(t?.handleChainStart(this.toJSON(),oA(e[a],"input"),n[a].runId,void 0,void 0,void 0,n[a].runName));return delete n[a].runId,i})));let o;for(const t of this.runnables()){n[0].signal?.throwIfAborted();try{const i=await t.batch(e,r.map(((e,t)=>wk(n[t],{callbacks:e?.getChild()}))),a);return await Promise.all(r.map(((e,t)=>e?.handleChainEnd(oA(i[t],"output"))))),i}catch(e){void 0===o&&(o=e)}}if(!o)throw new Error("No error stored at end of fallbacks.");throw await Promise.all(r.map((e=>e?.handleChainError(o)))),o}}function fA(e){if("function"==typeof e)return new pA({func:e});if(sA.isRunnable(e))return e;if(Array.isArray(e)||"object"!=typeof e)throw new Error("Expected a Runnable, function or object.\nInstead got an unsupported type.");{const t={};for(const[a,n]of Object.entries(e))t[a]=fA(n);return new mA({steps:t})}}class yA extends sA{static lc_name(){return"RunnableAssign"}constructor(e){e instanceof mA&&(e={mapper:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"mapper",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.mapper=e.mapper}async invoke(e,t){const a=await this.mapper.invoke(e,t);return{...e,...a}}async*_transform(e,t,a){const n=this.mapper.getStepsKeys(),[i,r]=Xx(e),o=this.mapper.transform(r,wk(a,{callbacks:t?.getChild()})),s=o.next();for await(const e of i){if("object"!=typeof e||Array.isArray(e))throw new Error("RunnableAssign can only be used with objects as input, got "+typeof e);const t=Object.fromEntries(Object.entries(e).filter((([e])=>!n.includes(e))));Object.keys(t).length>0&&(yield t)}yield(await s).value;for await(const e of o)yield e}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class bA extends sA{static lc_name(){return"RunnablePick"}constructor(e){("string"==typeof e||Array.isArray(e))&&(e={keys:e}),super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"keys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keys=e.keys}async _pick(e){if("string"==typeof this.keys)return e[this.keys];{const t=this.keys.map((t=>[t,e[t]])).filter((e=>void 0!==e[1]));return 0===t.length?void 0:Object.fromEntries(t)}}async invoke(e,t){return this._callWithConfig(this._pick.bind(this),e,t)}async*_transform(e){for await(const t of e){const e=await this._pick(t);void 0!==e&&(yield e)}}transform(e,t){return this._transformStreamWithConfig(e,this._transform.bind(this),t)}async stream(e,t){const a=vk(t),n=new Jx({generator:this.transform(async function*(){yield e}(),a),config:a});return await n.setup,Yx.fromAsyncGenerator(n)}}class vA extends lA{constructor(e){super({bound:dA.from([pA.from((async e=>{let t;if(Jg(e))try{t=await this.schema.parseAsync(e.args)}catch(t){throw new ef("Received tool input did not match expected schema",JSON.stringify(e.args))}else t=e;return t})).withConfig({runName:`${e.name}:parse_input`}),e.bound]).withConfig({runName:e.name}),config:e.config??{}}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.schema=e.schema}static lc_name(){return"RunnableToolLike"}}const wA=e=>e.startsWith("gpt-3.5-turbo-16k")?"gpt-3.5-turbo-16k":e.startsWith("gpt-3.5-turbo-")?"gpt-3.5-turbo":e.startsWith("gpt-4-32k")?"gpt-4-32k":e.startsWith("gpt-4-")?"gpt-4":e.startsWith("gpt-4o")?"gpt-4o":e,xA=e=>{switch(wA(e)){case"gpt-3.5-turbo-16k":return 16384;case"gpt-3.5-turbo":return 4096;case"gpt-4-32k":return 32768;case"gpt-4":return 8192;case"text-davinci-003":default:return 4097;case"text-curie-001":case"text-babbage-001":case"text-ada-001":case"code-cushman-001":return 2048;case"code-davinci-002":return 8e3}};function kA(e){return!("object"!=typeof e||!e)&&!!("type"in e&&"function"===e.type&&"function"in e&&"object"==typeof e.function&&e.function&&"name"in e.function&&"parameters"in e.function)}class AA extends sA{get lc_attributes(){return{callbacks:void 0,verbose:void 0}}constructor(e){super(e),Object.defineProperty(this,"verbose",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"callbacks",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.verbose=e.verbose??!1,this.callbacks=e.callbacks,this.tags=e.tags??[],this.metadata=e.metadata??{}}}class SA extends AA{get callKeys(){return["stop","timeout","signal","tags","metadata","callbacks"]}constructor({callbacks:e,callbackManager:t,...a}){const{cache:n,...i}=a;super({callbacks:e??t,...i}),Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_encoding",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cache="object"==typeof n?n:n?Zw.global():void 0,this.caller=new ix(a??{})}async getNumTokens(e){if("string"!=typeof e)return 0;let t=Math.ceil(e.length/4);if(!this._encoding)try{this._encoding=await kx("modelName"in this?wA(this.modelName):"gpt2")}catch(e){console.warn("Failed to calculate number of tokens, falling back to approximate count",e)}if(this._encoding)try{t=this._encoding.encode(e).length}catch(e){console.warn("Failed to calculate number of tokens, falling back to approximate count",e)}return t}static _convertInputToPromptValue(e){return"string"==typeof e?new Qw(e):Array.isArray(e)?new Jw(e.map(Of)):e}_identifyingParams(){return{}}_getSerializedCacheKeyParametersForCall({config:e,...t}){const a={...this._identifyingParams(),...t,_type:this._llmType(),_model:this._modelType()},n=Object.entries(a).filter((([e,t])=>void 0!==t)),i=n.map((([e,t])=>`${e}:${JSON.stringify(t)}`)).sort().join(",");return i}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}static async deserialize(e){throw new Error("Use .toJSON() instead")}}var EA=Object.freeze({__proto__:null,BaseLangChain:AA,BaseLanguageModel:SA,calculateMaxTokens:async({prompt:e,modelName:t})=>{let a;try{a=(await kx(wA(t))).encode(e).length}catch(t){console.warn("Failed to calculate number of tokens, falling back to approximate count"),a=Math.ceil(e.length/4)}return xA(t)-a},getEmbeddingContextSize:e=>"text-embedding-ada-002"===e?8191:2046,getModelContextSize:xA,getModelNameForTiktoken:wA,isOpenAITool:kA});function _A(e){return"function"==typeof e?.parse}class CA extends AA{get lc_namespace(){return["langchain","tools"]}constructor(e){super(e??{}),Object.defineProperty(this,"returnDirect",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"verboseParsingErrors",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"responseFormat",{enumerable:!0,configurable:!0,writable:!0,value:"content"}),this.verboseParsingErrors=e?.verboseParsingErrors??this.verboseParsingErrors,this.responseFormat=e?.responseFormat??this.responseFormat}async invoke(e,t){let a,n;Jg(e)?(a=e.id,n=e.args):n=e;const i=vk(t);return this.call(n,{...i,configurable:{...i.configurable,tool_call_id:a}})}async call(e,t,a){let n;try{n=await this.schema.parseAsync(e)}catch(t){let a="Received tool input did not match expected schema";throw this.verboseParsingErrors&&(a=`${a}\nDetails: ${t.message}`),new ef(a,JSON.stringify(e))}const i=Cw(t),r=await Nw.configure(i.callbacks,this.callbacks,i.tags||a,this.tags,i.metadata,this.metadata,{verbose:this.verbose}),o=await(r?.handleToolStart(this.toJSON(),"string"==typeof n?n:JSON.stringify(n),i.runId,void 0,void 0,void 0,i.runName));let s,l,c,u;delete i.runId;try{s=await this._call(n,o,i)}catch(e){throw await(o?.handleToolError(e)),e}if("content_and_artifact"===this.responseFormat){if(!Array.isArray(s)||2!==s.length)throw new Error(`Tool response format is "content_and_artifact" but the output was not a two-tuple.\nResult: ${JSON.stringify(s)}`);[l,c]=s}else l=s;i&&"configurable"in i&&(u=i.configurable.tool_call_id);const d=function(e){const{content:t,artifact:a,toolCallId:n}=e;return n?"string"==typeof t||Array.isArray(t)&&t.every((e=>"object"==typeof e))?new pf({content:t,artifact:a,tool_call_id:n,name:e.name}):new pf({content:MA(t),artifact:a,tool_call_id:n,name:e.name}):t}({content:l,artifact:c,toolCallId:u,name:this.name});return await(o?.handleToolEnd(d)),d}}class TA extends CA{constructor(e){super(e),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:jp.object({input:jp.string().optional()}).transform((e=>e.input))})}call(e,t){return super.call("string"!=typeof e&&e?e:{input:e},t)}}class PA extends TA{static lc_name(){return"DynamicTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect}async call(e,t){const a=Cw(t);return void 0===a.runName&&(a.runName=this.name),super.call(e,a)}async _call(e,t,a){return this.func(e,t,a)}}class OA extends CA{static lc_name(){return"DynamicStructuredTool"}constructor(e){super(e),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"description",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=e.name,this.description=e.description,this.func=e.func,this.returnDirect=e.returnDirect??this.returnDirect,this.schema=_A(e.schema)?e.schema:jp.object({}).passthrough()}async call(e,t,a){const n=Cw(t);return void 0===n.runName&&(n.runName=this.name),super.call(e,n,a)}_call(e,t,a){return this.func(e,t,a)}}function DA(e,t){if(!t.schema||_A(t.schema)&&(!("shape"in t.schema)||!t.schema.shape))return new PA({...t,description:t.description??t.schema?.description??`${t.name} tool`,func:async(t,a,n)=>new Promise(((i,r)=>{const o=wk(n,{callbacks:a?.getChild()});Kx.runWithConfig(o,(async()=>{try{i(e(t,o))}catch(e){r(e)}}))}))});const a=t.description??t.schema.description??`${t.name} tool`;return new OA({...t,description:a,schema:t.schema,func:async(t,a,n)=>new Promise(((i,r)=>{const o=wk(n,{callbacks:a?.getChild()});Kx.runWithConfig(o,(async()=>{try{i(e(t,o))}catch(e){r(e)}}))}))})}function MA(e){try{return JSON.stringify(e,null,2)}catch(t){return`${e}`}}var IA=Object.freeze({__proto__:null,BaseToolkit:class{getTools(){return this.tools}},DynamicStructuredTool:OA,DynamicTool:PA,StructuredTool:CA,Tool:TA,ToolInputParsingException:ef,tool:DA});function NA(e,t,a){var n={Feed:e,ClientLocalTime:Pi(new Date)};t&&(n.PageID=t),a&&(n.PageDate=a);var i=new URLSearchParams(n).toString();return w.invokeCustomApi("HealthAndWellnessApi.NewsFeed","GET",i,!0)}function jA(){return w.baseUrl&&(w.baseUrl.startsWith("https://mdhorg.ce.dev")||w.baseUrl.startsWith("https://mydatahelps.dev"))}const zA=jp.object({namespace:jp.enum(["Fitbit","AppleHealth","Garmin","Dexcom","HealthConnect"]).describe("The namespace of the device data, representing the manufacturer of the devices used to collect the data."),type:jp.string().describe("The device data type is specific to the namespace. Example data types for AppleHealth are Steps, Heart Rate."),observedAfter:jp.string().optional().describe('The start of the date range for the query. This is a datetime in the participant\'s local timezone, passed without the timezone offset.\n This is exclusive. For example, if you want to query data for 11/26/2024, you would pass in "observedAfter": "2024-11-26T00:00:00". An event\n that happened at 11/26/2024 00:00:00 would not be included in the results.'),observedBefore:jp.string().optional().describe('The end of the date range for the query. This is a datetime in the participant\'s local timezone, passed without the timezone offset.\n This is exclusive. For example, if you want to query data for up to 11/26/2024, you would pass in "observedBefore": "2024-11-26T00:00:00". An event\n that happened at 11/26/2024 00:00:00 would not be included in the results.'),dataSource:jp.object({sourceName:jp.string().optional().describe('The name of the device that the data is coming from. Examples: "Oura", "Mike\'s iPhone".\n You can prompt the user for the device name if it is unclear what that is from the user\'s question.'),sourceIdentifier:jp.string().optional().describe('The identifier of the device that the data is coming from. Examples: "com.ouraring.oura", "com.apple.health.E0BCE94D-0698-4E79-951C-A98A07D698B0".'),sourceProductType:jp.string().optional().describe('The product type of the device that the data is coming from. Examples: "iPhone15,3".'),sourceOperatingSystemVersion:jp.string().optional().describe('The operating system version of the device that the data is coming from. Examples: "17.6.1".')}).optional().describe("These can be used to restrict the returned results to data coming from a specific device only."),properties:jp.record(jp.string(),jp.string()).optional().describe("Filters to apply to the properties of the data points.")}),RA=DA((async e=>{const t=await w.persistParticipantInfo(e.demographics,e.customFields);return JSON.stringify(t)}),{name:"persistParticipantInfo",description:"Can be used to save data about the current participant, including dynamic information in the participant's custom fields.",schema:jp.object({demographics:jp.object({email:jp.string().optional().describe("The email address of the participant."),mobilePhone:jp.string().optional().describe("The mobile phone number of the participant."),firstName:jp.string().optional().describe("The first name of the participant."),middleName:jp.string().optional().describe("The middle name of the participant."),lastName:jp.string().optional().describe("The last name of the participant."),dateOfBirth:jp.string().optional().describe("The date of birth of the participant."),gender:jp.string().optional().describe("The gender of the participant."),preferredLanguage:jp.string().optional().describe("The preferred language of the participant."),street1:jp.string().optional().describe("The first line of the participant's street address."),street2:jp.string().optional().describe("The second line of the participant's street address."),city:jp.string().optional().describe("The city of the participant."),state:jp.string().optional().describe("The state of the participant."),postalCode:jp.string().optional().describe("The postal code of the participant."),unsubscribedFromEmails:jp.string().optional().describe("Whether the participant is unsubscribed from email messages."),unsubscribedFromSms:jp.string().optional().describe("Whether the participant is unsubscribed from SMS messages.")}).optional().describe("Demographic information about the participant."),customFields:jp.record(jp.string(),jp.string()).optional().describe("Custom fields where dynamic information can be saved for the participant.")})}),LA=jp.object({endDate:jp.string().optional().describe("The end of the date range for the query. This is a datetime in the participant's local timezone."),startDate:jp.string().optional().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),pageSize:jp.number().optional().describe("The number of items to return."),pageID:jp.string().optional().describe("The page ID to continue from.")}),FA=DA((async e=>{const t=await w.queryAppleHealthWorkouts(e);return JSON.stringify(t)}),{name:"queryAppleHealthWorkouts",description:"Query the participant's workouts from Apple Health.",schema:LA}),BA=DA((async e=>{const t=await w.queryAppleHealthActivitySummaries(e);return JSON.stringify(t)}),{name:"queryAppleHealthActivitySummaries",description:"Query the participant's Apple Health activity summaries. These include Active Energy Burned,\n Active Energy Burned Goal, Apple Exercise Time, Apple Exercise Time Goal, Apple Stand Hours and Apple Stand Hours Goal.",schema:LA}),HA=DA((async e=>{const t=await w.queryNotifications(e);return JSON.stringify(t)}),{name:"queryNotifications",description:"Query notifications sent to the participant.",schema:jp.object({type:jp.enum(["Sms","Push","Email"]).optional().describe("The type of notification to query."),statusCode:jp.enum(["Succeeded","Unsubscribed","MissingContactInfo","NoRegisteredMobileDevice","NoAssociatedUser","ServiceError"]).optional().describe("The status code of the notification."),sentBefore:jp.string().optional().describe("The end of the date range for the query. This is a datetime in the participant's local timezone."),sentAfter:jp.string().optional().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),identifier:jp.string().optional().describe("The identifier of the notification.")})}),qA=DA((async e=>{const t=await w.querySurveyAnswers(e);return JSON.stringify(t)}),{name:"querySurveyAnswers",description:"Query answers to surveys the participant has completed.",schema:jp.object({surveyResultID:jp.string().optional().describe("The ID of the survey result."),surveyID:jp.string().optional().describe("The ID of the survey."),surveyName:jp.string().optional().describe("The name of the survey."),after:jp.string().optional().describe("The start of the date range for the query. Survey answers submitted after this date will be retrieved.\n This is a datetime in the participant's local timezone."),before:jp.string().optional().describe("The end of the date range for the query. Survey answers submitted before this date will be retrieved.\n This is a datetime in the participant's local timezone."),stepIdentifier:jp.string().optional().describe("The step identifier."),resultIdentifier:jp.string().optional().describe("The result identifier."),answer:jp.string().optional().describe("A particular answer."),pageID:jp.string().optional().describe("The page ID to continue from.")})}),UA=DA((async e=>{let t=await w.queryDeviceDataV2(e);return JSON.stringify(t.deviceDataPoints.map((({value:e,startDate:t,startDateOffset:a,observationDate:n,observationDateOffset:i,units:r,dataSource:o})=>({value:e,startDate:t,startDateOffset:a,observationDate:n,observationDateOffset:i,units:r,dataSource:o?.sourceName}))))}),{name:"queryDeviceDataV2",description:"Can query a participant's device data. This represents raw individual fine grained data points, not aggregated in any way.\n \n Before using this tool call the getDeviceDataV2AllDataTypes tool to see which data types are available. If a particular data type is not available\n use the queryDailyData tool instead.\n\n For sleep this is the function you would query to determine the time a participant went to bed or woke up. For sleep a day consists of from 6 pm the \n previous day to 6 pm the day of (For example 11/26/2024 sleep is from 11/25/2024 at 6 pm to 11/26/2024 at 6 pm). To determine the time a participant\n went to bed look at the startDate of the first not awake and not in bed sleep stage for that day. To determine wake up times look at the observationDate\n of the last not awake and not in bed sleep stage for that day.",schema:zA}),WA=DA((async e=>{let t=await w.queryDeviceDataV2Aggregate(e);return JSON.stringify(t.intervals.map((({date:e,statistics:t})=>({date:e,statistics:t}))))}),{name:"queryDeviceDataV2Aggregate",description:"Can query a participant's aggregated device data. This can be used to get for instance a participant's hourly steps \n count or their min max heart rate every day.",schema:zA.extend({intervalAmount:jp.number().describe("The number of periods to aggregate over. Together with intervalType this can be 1 Days or 3 Minutes."),intervalType:jp.enum(["Minutes","Hours","Days","Weeks","Months"]).describe("The type of interval to aggregate over. Together with intervalAmount this can be 1 Days or 3 Minutes."),aggregateFunctions:jp.array(jp.enum(["sum","avg","count","min","max"])).describe("The aggregations functions to apply to the granular data.")})}),VA=DA((async e=>{let t=await w.queryDeviceDataV2DailySleep(e);return JSON.stringify(t.sleepStageSummaries.map((({date:e,duration:t,value:a})=>({date:e,duration:t,value:a}))))}),{name:"queryDeviceDataV2DailySleep",description:"Can query daily aggregated sleep data. This will include sleep broken down by sleep stage.\n Use this function when you need to do sleep aggregate queries instead of deviceDataV2Aggregate.",schema:zA.extend({type:jp.string().describe("The device data type is specific to the namespace. For Apple Health this is called Sleep Analysis, for Fitbit it is called Sleep.")})}),$A=DA((async e=>{let t=await wu(e.type,new Date(e.startDate),new Date(e.endDate),!1);return JSON.stringify(t)}),{name:"queryDailyData",description:"Query daily data for a participant. Before using this tool call the getAllDailyDataTypes tool to see which data types are available.",schema:jp.object({type:jp.string().describe("The type of daily data to query."),startDate:jp.string().describe("The start of the date range for the query. This is a datetime in the participant's local timezone."),endDate:jp.string().describe("The end of the date range for the query. This is a datetime in the participant's local timezone.")})}),GA=DA((async()=>{let e=await w.getDeviceDataV2AllDataTypes();return JSON.stringify(e)}),{name:"getDeviceDataV2AllDataTypes",description:"Get all the device data types that can be queried with the queryDeviceDataV2 tool. Only types that are enabled can be queried.",schema:jp.object({})}),KA=DA((async()=>JSON.stringify(ku())),{name:"getAllDailyDataTypes",description:"Get all the daily data types that can be queried with the queryDailyData tool.",schema:jp.object({})}),ZA=DA((async e=>{const t=await NA(e.feed,e.pageID,e.pageDate);return JSON.stringify(t)}),{name:"getEhrNewsFeedPage",description:"Get electronic health record (EHR) data for the participant.",schema:jp.object({feed:jp.enum(["Immunizations","LabReports","Procedures","Reports"]).describe("The type of feed to query."),pageID:jp.string().optional().describe("The page ID to continue from if you need to fetch more results."),pageDate:jp.string().optional().describe("The date of the page to continue from if you are doing a time-based query.")})}),YA=DA((async(e,t)=>{let a=jA()?"https://api.mydatahelps.dev/run-code":"https://api.mydatahelps.org/run-code",n=await fetch(a,{method:"POST",body:JSON.stringify({code:e.code}),headers:{"Content-Type":"application/json",Authorization:`Bearer ${w.token.access_token}`}}).then((e=>e.json()));if(n.image){let e=t?.configurable?.participantId;t.store?.put([e,"graphing"],"lastGraph",{image:n.image})}return n.image||"error: unable to generate image"}),{name:"graphing",description:"If the user asks for something to be graphed, use this tool. This tool returns a base 64 encoded string\n that represents an image. After using this tool, the LLM should respond with 'Your generated graph is displayed above.' without interpreting \n or including the image content in the response. The UI will handle displaying the image.",schema:jp.object({code:jp.string().describe('The python code that, when executed, will generate an image representing the graph. Use matplotlib.pyplot\n to generate the graph. The code should not include any imports, as the necessary imports will be added automatically "import matplotlib.pyplot as plt".')})}),XA=DA((async e=>{let t=await w.queryFiles(e);return JSON.stringify(t)}),{name:"uploadedFileQuery",description:"Use this tool to query files uploaded by the current participant. \n AI-generated graphs are saved under the 'ai-graph' category.",schema:jp.object({category:jp.string().optional().describe("Category of files to query for.")})}),QA=DA((async e=>{let t=await w.getFileDownloadUrl(e.key);return JSON.stringify(t)}),{name:"getUploadedFile",description:"Use this tool to get a file uploaded by the current participant. This tool returns a presigned URL to download the file. \n If the file is an image, the LLM should respond with 'Please see your uploaded file above.' and nothing else.\n Do not include a link to the file in your response.",schema:jp.object({key:jp.string().describe("The file key of the file to get.")})}),JA=DA((async(e,t)=>{let a=t.configurable?.participantId,n=await(t.store?.get([a,"graphing"],"lastGraph"));if(!n||!n.value||!n.value.image)return"Unable to find your last graph.";const i=atob(n.value.image),r=i.length,o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=i.charCodeAt(e);const s=new Blob([o],{type:"image/png"}),l=new File([s],e.fileName,{type:"image/png"});return await w.uploadFile(l,"ai-graph"),"Successfully saved your last graph to your files."}),{name:"saveLastGraph",description:"Save the last graph generated by the graphing tool.",schema:jp.object({fileName:jp.string().describe("The name of the file to save. This should be descriptive but reasonably short, no more than 50 characters. It should\n end with the '.png' file extension.")})});var eS=Object.freeze({__proto__:null,GetAllDailyDataTypesTool:KA,GetDeviceDataV2AllDataTypesTool:GA,GetEhrNewsFeedPageTool:ZA,GetUploadedFileTool:QA,GraphingTool:YA,PersistParticipantInfoTool:RA,QueryAppleHealthActivitySummariesTool:BA,QueryAppleHealthWorkoutsTool:FA,QueryDailyDataTool:$A,QueryDailySleepTool:VA,QueryDeviceDataV2AggregateTool:WA,QueryDeviceDataV2Tool:UA,QueryNotificationsTool:HA,QuerySurveyAnswersTool:qA,SaveLastGraphTool:JA,UploadedFileQueryTool:XA});class tS{constructor(e){this.type=e}}class aS extends tS{constructor(e){super("static integer"),this.staticValue=e}getValue(){return Promise.resolve(this.staticValue)}}class nS extends tS{constructor(e){super("random integer"),this.maxValue=e}getValue(){return Promise.resolve(Math.floor(Math.random()*(this.maxValue+1)))}}class iS extends tS{constructor(e){super("custom field integer"),this.customField=e}async getValue(){if(!this.customField)return;let e=await w.getParticipantInfo();if(e.customFields.hasOwnProperty(this.customField)){const t=e.customFields[this.customField],a=parseInt(t);if(!Number.isNaN(a))return a}}}class rS extends tS{constructor(e,t){if(t<0)throw new Error("daysInPast must be a non-negative number");super("days with data"),this.dataType=e,this.daysInPast=t}async getValue(){const e=Hr(),t=Dr(e,this.daysInPast),a=await wu(this.dataType,t,e);return a&&0!==a.length?Object.keys(a).reduce(((e,t)=>e+(a[t]>0?1:0)),0):0}}const oS=e=>new aS(e),sS=e=>new nS(e),lS=e=>new iS(e),cS=(e,t)=>new rS(e,t);function uS(e,t,a,n){const i={};let r=e;for(;r<=t;){const e=Wr(r);0!==dS(0,1)&&(i[e]=dS(a,n)),r=un(r,{days:1})}return i}function dS(e,t){return Math.floor(Math.random()*(t-e+1))+e}function mS(e){return!!e&&void 0!==e.surveyName}function hS(e){return async(t,a)=>{const n={surveyName:e.surveyName,stepIdentifier:e.stepIdentifier,after:un(t,{days:-1}).toISOString(),before:un(a,{days:1}).toISOString()};e.resultIdentifier&&(n.resultIdentifier=e.resultIdentifier);const i=await Mu(n).then((e=>e.sort(((e,t)=>Sn(e.date,t.date))))),r={};let o=t;for(;o<=a;){const e=Wr(o),t=i.find((t=>Wr(t.date)===e))?.answers[0];if(t){const a=parseInt(t);Number.isNaN(a)||(r[e]=a)}o=un(o,{days:1})}return r}}const pS=()=>({calculate:(e,t)=>{const a=t.filter((e=>e>0));return a.length>0?a.reduce(((e,t)=>e+t),0)/a.length:void 0}}),gS=()=>({calculate:(e,t)=>{if(0!==e.length)return 100*t.filter((e=>e>0)).length/e.length}}),fS=(e,t)=>({evaluate:a=>void 0!==t?a>=e&&a<=t:a>=e}),yS=()=>({format:e=>e>=1e3?El(e/1e3,1)+"k":El(e)}),bS=()=>({format:e=>El(e/60,1)+so("hours-abbreviation")}),vS=e=>({format:t=>{let a=El(t);return e&&(a+=e),a}}),wS="Not Entered";function xS(e,t,a){const n={},i=(e,t)=>{if(!(void 0!==t&&t>=0))return wS;for(let a=0;a<e.length;a++){const n=e[a];if(!(void 0!==n.minimumValue&&n.minimumValue>t)&&!(void 0!==n.maximumValue&&n.maximumValue<t))return n.label}};let r=e;for(;r<=t;){const e=Wr(r),t=i(a.configuration.thresholds,a.result[e]);t&&(n.hasOwnProperty(t)||(n[t]=[]),n[t].push(e)),r=un(r,{days:1})}return n}function kS(e){try{return{success:!0,regex:new RegExp(e)}}catch{return{success:!1,regex:void 0}}}function AS(){return{load:async(e,t)=>{const a=(await Mu({surveyName:e.surveyName,resultIdentifier:[e.fileResultIdentifier,e.typeResultIdentifier,e.nameResultIdentifier,e.dateResultIdentifier,e.notesResultIdentifier]})).reduce(((e,t)=>{const a=t.surveyResultID;return e[a]=e[a]??[],e[a].push(t),e}),{}),n=[];for(const i of Object.values(a)){const a=await CS(i,e,t);a&&n.push(a)}return n}}}function SS(){return{load:async(e,t)=>CS(await Mu({surveyResultID:e,resultIdentifier:[t.fileResultIdentifier,t.typeResultIdentifier,t.nameResultIdentifier,t.dateResultIdentifier,t.notesResultIdentifier]}),t,!0)}}function ES(e,t){return(a,n)=>{const i=a[e],r=n[e];return i===r?a.name.localeCompare(n.name):void 0===i?1:void 0===r?-1:"asc"===t?i.localeCompare(r):r.localeCompare(i)}}function _S(e){let t="";return e.date&&(t+=Sl(e.date,"P")),e.type&&(t.length>0&&(t+=" - "),t+=e.type),t}async function CS(e,t,a){const n=e.find((e=>e.resultIdentifier===t.fileResultIdentifier)),i=e.find((e=>e.resultIdentifier===t.nameResultIdentifier));if(!n||!i)return;const r=e.find((e=>e.resultIdentifier===t.typeResultIdentifier)),o=e.find((e=>e.resultIdentifier===t.dateResultIdentifier)),s=e.find((e=>e.resultIdentifier===t.notesResultIdentifier)),l=n.surveyResultID,{fileKey:c,fileUrl:u}=a?await async function(e){const t=await w.queryFiles({category:`surveyresult_${e}`});if(t.files.length>0){const e=t.files[0].key,a=(await w.getFileDownloadUrl(e))?.preSignedUrl;return{fileKey:e,fileUrl:a}}return{}}(l):{};return{surveyResultId:l,file:n.answers[0],fileType:n.answers[0].toLowerCase().endsWith(".pdf")?"pdf":"image",name:i.answers[0],type:r?.answers[0],date:o?.answers[0],notes:s?.answers[0],fileKey:c,fileUrl:u}}function TS(e,t,a,n,i,r){const o=Array.from({length:a.length},(()=>[]));let s=e;for(;s<t;){for(let e=0;e<o.length;e++){const t=pu(Wr(s)+a[e]);o[e].push({stepIdentifier:a[e],resultIdentifier:a[e],date:Pi(un(s,{hours:12})),answers:[(t%(i-n)+n).toString()]})}s=un(s,r)}return o}async function PS(e,t,a,n,i){const[r,o]=await Promise.all([OS(e,a,n,i),DS(t,a,n,!!i)]),s={};let l=a;for(;l<n;){const e=Wr(l);s[e]={date:Mr(e),surveyAnswers:r[e]??[],dataPoints:o[e]??[]},l=un(l,{days:1})}return s}async function OS(e,t,a,n){if(0===e.length)return{};if(n)return function(e,t,a,n){const i=Array.from({length:10},((e,t)=>`result${t+1}`)),r=e.reduce(((e,r)=>{const o=kn([un(Hr(),{days:n?1:0}),a]);return TS(t,o,i,0,5,{days:1}).flat().forEach((t=>{e.push({...t,surveyName:r})})),e}),[]);return r.reduce(((e,t)=>{const a=Wr(t.date),i=n&&Pr(t.date),r=pu(a)%3!=0,o=pu(a+"_"+t.surveyName)%3!=0,s=pu(a+"_"+t.surveyName+"_"+t.resultIdentifier)%3!=0;return(i||r&&o&&s)&&(e[a]??=[],e[a].push({...t,answers:i&&"0"===t.answers[0]?["1"]:t.answers})),e}),{})}(e,t,a,n.endsWith("with today"));const i=jn({start:t,end:un(a,{days:-1})}).reduce(((e,t)=>{const a=Wr(t).substring(0,8)+"*";return e.includes(a)||e.push(a),e}),[]).join(",");return async function(e,t,a){const n={surveyName:e,event:t},i=(await Mu(n)).sort(((e,t)=>t.date.localeCompare(e.date))),r=i.reduce(((e,t)=>{const a=`${t.surveyName}-${t.event}`;return e[a]??=t.surveyResultID.toString(),e}),{}),o=Object.values(r);return i.filter((e=>o.includes(e.surveyResultID.toString()))).reduce(((e,t)=>{const n=Mr(t.event);if(!a||n>=a.start&&n<a.end){const a=Wr(n);e[a]??=[],e[a].push(t)}return e}),{})}(e,i,{start:t,end:a})}async function DS(e,t,a,n){if(0===e.length)return{};return(await Promise.all(e.map((e=>wu(e,t,a,n))))).reduce(((t,a,n)=>(Object.entries(a).forEach((([a,i])=>{t[a]??=[],t[a].push({type:e[n],value:i})})),t)),{})}function MS(e){const a=r(Ka),n=["mdhui-basic-badge"];return"xl"===e.size&&n.push("mdhui-basic-badge-xl"),"xs"===e.size&&n.push("mdhui-basic-badge-xs"),t.createElement("div",{className:n.join(" "),style:{backgroundColor:ze(a.colorScheme,e.backgroundColor),color:"#FFD379"}},t.createElement(je,{className:"mdhui-basic-badge-icon",icon:N,size:"2x"}),t.createElement("div",{className:"mdhui-basic-badge-children"},e.children))}A(".mdhui-basic-badge {\n width: 32px;\n height: 32px;\n border-radius: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n background: #ddd;\n color: #152850;\n position: relative;\n overflow: hidden;\n font-size: 8px;\n box-shadow: 1px 2px 2px rgba(0, 0, 0, .2);\n color: #FFD379;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl {\n width: 150px;\n height: 150px;\n font-size: 58px;\n}\n\n\n.mdhui-basic-badge .mdhui-basic-badge-children {\n display: none;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl .mdhui-basic-badge-children {\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n width: 100%;\n color: #000;\n text-align: center;\n font-size: 17px;\n top: 58px;\n font-weight: bold;\n}\n\n.mdhui-basic-badge .mdhui-basic-badge-icon {\n filter: drop-shadow(1px 1px 1px #666);\n margin-top: -1px;\n}\n\n.mdhui-basic-badge.mdhui-basic-badge-xl .mdhui-basic-badge-icon {\n margin-top: -7px;\n}");function IS(e){let a="normal";return e.systolic>180||e.diastolic>120?a="hypertensive-crisis":e.systolic>140||e.diastolic>90?a="hypertension-stage-2":e.systolic>130||e.diastolic>80?a="hypertension-stage-1":e.systolic>120?a="elevated":(e.systolic<90||e.systolic<60)&&(a="low"),t.createElement(Ya,{className:"mdhui-blood-pressure-reading",indicatorPosition:"topRight",indicator:e.indicator??t.createElement(je,{icon:re}),onClick:e.onClick,innerRef:e.innerRef},t.createElement("div",{className:"mdhui-blood-pressure-reading-title"},t.createElement(je,{icon:G})," ",so("blood-pressure-reading-title")),t.createElement("div",{className:"mdhui-blood-pressure-reading-value-wrapper"},t.createElement("div",{className:"mdhui-blood-pressure-reading-value"},El(e.systolic)," / ",El(e.diastolic)," mmHg"),t.createElement("div",{className:`mdhui-blood-pressure-reading-classification ${a}`},so(`blood-pressure-reading-classification-${a}`))),t.createElement("div",{className:"mdhui-blood-pressure-reading-date"},Sl(e.date,"PPP p")),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator"},t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar normal"},("normal"===a||"low"==a)&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar elevated"},"elevated"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertension-stage-1"},"hypertension-stage-1"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertension-stage-2"},"hypertension-stage-2"===a&&t.createElement(je,{icon:F})),t.createElement("div",{className:"mdhui-blood-pressure-reading-classification-indicator-bar hypertensive-crisis"},"hypertensive-crisis"===a&&t.createElement(je,{icon:F}))))}A(".mdhui-blood-pressure-reading {\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-title {\n font-size: .88em;\n font-weight: 600;\n z-index: 1;\n position: relative;\n color: rgb(196, 41, 28);\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-value-wrapper {\n display: flex;\n align-items: center;\n justify-content: left;\n gap: 8px;\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-value {\n font-size: 1.2em;\n position: relative;\n font-weight: bold;\n margin-top: 4px;\n display: block;\n}\n\n.mdhui-blood-pressure-reading .mdhui-blood-pressure-reading-date {\n font-size: 0.8em;\n color: var(--mdhui-text-color-2);\n margin-top: 4px;\n}\n\n.mdhui-blood-pressure-reading-classification {\n font-size: .88em;\n border-radius: 4px;\n padding: 4px 8px;\n font-weight: bold;\n}\n\n.mdhui-blood-pressure-reading-classification.normal,\n.mdhui-blood-pressure-reading-classification.low {\n background-color: #a6ce39;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.elevated {\n background-color: #ffec01;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertension-stage-1 {\n background-color: #ffb601;\n color: #333;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertension-stage-2 {\n background-color: #ba3a03;\n color: #FFF;\n}\n\n.mdhui-blood-pressure-reading-classification.hypertensive-crisis {\n background-color: #990612;\n color: #FFF;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator {\n display: flex;\n margin-top: 8px;\n margin-bottom: 8px;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar {\n height: 8px;\n background: #a6ce39;\n flex-grow: 1;\n text-align: center;\n position: relative;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar .svg-inline--fa {\n position: absolute;\n left: calc(50% - 6px);\n top: 8px;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.normal {\n background: #a6ce39;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.elevated {\n background: #ffec01;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertension-stage-1 {\n background: #ffb601;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertension-stage-2 {\n background: #ba3a03;\n}\n\n.mdhui-blood-pressure-reading-classification-indicator .mdhui-blood-pressure-reading-classification-indicator-bar.hypertensive-crisis {\n background: #990612;\n}");function NS(e){let a=["mdhui-loading-indicator"];return e.className&&a.push(e.className),"inline"==e.variant&&a.push("mdhui-loading-indicator-inline"),t.createElement("div",{ref:e.innerRef,style:{color:e.color},className:a.join(" ")},t.createElement(je,{icon:W,spin:!0}))}A(".mdhui-loading-indicator {\n padding: 16px;\n color: var(--mdhui-text-color-4);\n text-align: center;\n}\n\n.mdhui-loading-indicator.mdhui-loading-indicator-inline {\n display: inline;\n padding: 0;\n}");function jS(e){let a=["mdhui-button"];e.className&&a.push(e.className),(e.fullWidth??1)&&a.push("mdhui-button-full-width"),e.defaultMargin&&a.push("mdhui-button-default-margin");let n=r(Ka),i=ze(n?.colorScheme,e.color),o="#FFF";return"subtle"===e.variant?(o=ze(n?.colorScheme,e.color)||"var(--mdhui-color-primary)",i="transparent"):"light"===e.variant&&(o=ze(n?.colorScheme,e.color)||"var(--mdhui-color-primary)",i="var(--mdhui-background-color-1)"),t.createElement("button",{ref:e.innerRef,style:{backgroundColor:e.disabled?void 0:i,color:e.disabled?void 0:o},className:a.join(" "),disabled:e.disabled||e.loading,onClick:t=>{e.disabled||e.loading||(e.stopPropagation&&t.stopPropagation(),e.onClick(t))}},e.loading&&t.createElement(t.Fragment,null,t.createElement(NS,{variant:"inline",color:"inherit"})," "),e.children)}A(".mdhui-button {\n box-sizing: border-box;\n padding: 16px;\n background: var(--mdhui-color-primary);\n font-size: 17px;\n line-height: 17px;\n color: #FFF;\n border: none;\n border-radius: 6px;\n cursor: pointer;\n font-weight: bold;\n text-align: center;\n}\n\n.mdhui-button:disabled {\n color: var(--mdhui-text-color-3);\n background: var(--mdhui-background-color-2);\n cursor: default;\n}\n\n.mdhui-button.mdhui-button-default-margin {\n margin: 16px;\n display: block;\n}\n\n.mdhui-button.mdhui-button-full-width {\n width: 100%;\n display: block;\n}\n\n.mdhui-button.mdhui-button-default-margin.mdhui-button-full-width\n{\n width: calc(100% - 32px);\n}");function zS(e){var a=[],n=Array.from(Array(7).keys()),i=e.weekStartsOn&&e.weekStartsOn<7?e.weekStartsOn:0;if(i)for(;n[0]!==i;)n.push(n.shift());const r=n.map((e=>ul(e)));var o=function(e,t){return 32-new Date(t,e,32).getDate()};return function(){var t=new Date(e.year,e.month).getDay()-i;t<0&&(t=7+t);var n=[],r=1;for(let a=0;a<6;a++){var s={days:[]};for(let n=0;n<7;n++)if(0===a&&n<t)s.days[n]={day:void 0};else{if(r>o(e.month,e.year))break;s.days[n]={day:r},r++}n.push(s)}a=n}(),t.createElement("div",{ref:e.innerRef,className:"mdhui-calendar"+(e.className?` ${e.className}`:"")},t.createElement("table",{cellPadding:"0",cellSpacing:"0"},t.createElement("thead",null,t.createElement("tr",null,r.map(((e,a)=>t.createElement("th",{key:a},e))))),t.createElement("tbody",null,a.map(((a,n)=>t.createElement("tr",{key:n},a.days.map(((a,n)=>t.createElement("td",{key:n},e.dayRenderer(e.year,e.month,a.day))))))))))}A(".mdhui-calendar {\n padding-bottom: 16px;\n}\n\n.mdhui-calendar table {\n width: 100%;\n font-size: 14px;\n}\n\n.mdhui-calendar table tr th {\n font-size: 14px;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n padding-bottom: 16px;\n padding-top: 16px;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n text-align: center;\n}\n\n.mdhui-calendar table tr td {\n padding-top: 16px;\n vertical-align: top;\n text-align: center;\n height: 50px;\n padding-bottom: 0;\n position: relative;\n}");function RS(e){const a=r(Ka);if(!e.day)return t.createElement("div",{ref:e.innerRef});const n=e=>{let t=1===e.getDate(),a=0===e.getDay();return!t&&!a},i=e=>{let t=e.getDate()===(e=>new Date(e.getFullYear(),e.getMonth()+1,0).getDate())(e),a=6===e.getDay();return!t&&!a},o=t=>{if(e.stateConfiguration&&e.computeStateForDay){const a=e.computeStateForDay(t);if(void 0===a)return[];const n=e.stateConfiguration[a];return n?[{...n.streak?{streakIdentifier:a}:void 0,...n}]:[]}return e.computeStatesForDay?.(t)??[]},s=new Date(e.year,e.month,e.day),l=o(un(s,{days:-1})),c=o(s),u=o(un(s,{days:1})),d=["mdhui-calendar-day"],m={};Pr(s)?d.push("mdhui-calendar-day-today"):Oi(s,new Date)&&d.push("mdhui-calendar-day-future");const h=c.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),p=l.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),g=u.map((e=>e.streakIdentifier)).filter((e=>void 0!==e)),f=c.reduce(((e,t)=>(t.streakIdentifier&&p.includes(t.streakIdentifier)&&e.push(t.streakColor),e)),[]),y=c.reduce(((e,t)=>(t.streakIdentifier&&g.includes(t.streakIdentifier)&&e.push(t.streakColor),e)),[]),b=(e,t)=>{const n=e.map((e=>ze(a.colorScheme,e)??"#ddd")),i=100/n.length;let r="linear-gradient(to bottom, ",o=0;for(let e=0;e<n.length;e++)r=r+n[e]+" "+o+"%, ",o+=i,r=r+n[e]+" "+o+"%",e!=n.length-1&&(r+=", ");return r+=`) ${"left"===t?"calc(0% - 1px)":"calc(100% + 1px)"} / 50% 100% no-repeat`,r};h.length>0&&(f.length>0&&y.length>0&&n(s)&&i(s)?m.background=b(f,"left")+", "+b(y,"right"):f.length>0&&n(s)?m.background=b(f,"left"):y.length>0&&i(s)&&(m.background=b(y,"right")));const v=t=>{const n=t.map((e=>ze(a.colorScheme,e)??"transparent")),i=100/n.length;let r=`conic-gradient(from ${e.multiStateStartAngle??270}deg at 50% 50%,`,o=0;for(let e=0;e<n.length;e++)r=r+n[e]+" "+o+"%, ",o+=i,r=r+n[e]+" "+o+"%",e!=n.length-1&&(r+=", ");return r+=")",r},w=(e=>{if(0===e.length)return;if(1===e.length&&!e[0].combineWhenSolo)return e[0];const t=e.map((e=>e.backgroundColor??"var(--mdhui-border-color-2)")),n=v(t),i=v(e.map(((e,a)=>e.borderColor??t[a]))),r=ze(a.colorScheme,{lightMode:"#eee",darkMode:"#444"})?.replace("#","%23"),o=ze(a.colorScheme,{lightMode:"#888",darkMode:"#333"})?.replace("#","%23");return{...e[0],borderColor:"transparent",textColor:"var(--mdhui-text-color-1)",style:{...e[0].style,background:`url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="32" fill="${r}"/></svg>') center / 100% 100% no-repeat content-box content-box, url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><circle cx="50" cy="50" r="34" fill="${o}"/></svg>') center / 100% 100% no-repeat content-box content-box, `+n+" center / 100% 100% no-repeat padding-box padding-box, "+i+" center / 100% 100% no-repeat border-box border-box"}}})(c),x=w?{...w.backgroundColor&&{background:ze(a.colorScheme,w.backgroundColor)},...w.borderColor&&{border:`2px solid ${ze(a.colorScheme,w.borderColor)}`,marginTop:"-12px"},...w.textColor&&{color:ze(a.colorScheme,w.textColor)},...w.style}:void 0,k=t.createElement("div",{className:"mdhui-calendar-day-value",style:x},s.getDate(),c.note&&t.createElement("div",{className:"mdhui-calendar-day-note-wrapper",style:{backgroundColor:c.noteBackgroundColor?ze(a.colorScheme,c.noteBackgroundColor):void 0,border:c.noteBorderColor?`1px solid ${ze(a.colorScheme,c.noteBorderColor)}`:void 0,color:c.noteTextColor?ze(a.colorScheme,c.noteTextColor):void 0}},t.createElement("span",{className:"mdhui-calendar-day-note"},c.note)));return t.createElement("div",{ref:e.innerRef,className:d.join(" "),style:m},e.onClick?t.createElement(S,{onClick:()=>e.onClick(s),children:k}):k)}A(".mdhui-calendar table tr:has(.mdhui-calendar-day) td {\n height: 40px;\n}\n\n.mdhui-calendar-day {\n display: inline-block;\n width: 100%;\n height: 21px;\n margin-top: 5px;\n}\n\n.mdhui-calendar-day .mdhui-unstyled-button {\n margin: 0 auto;\n}\n\n.mdhui-calendar-day-value {\n position: relative;\n background: var(--mdhui-border-color-2);\n height: 40px;\n width: 40px;\n line-height: 40px;\n border-radius: 50%;\n text-align: center;\n vertical-align: middle;\n margin: -10px auto 0;\n font-size: 15px;\n font-weight: bold;\n}\n\n.mdhui-calendar-day-today .mdhui-calendar-day-value {\n background: #369CFF;\n color: #fff;\n border: 2px solid var(--mdhui-background-color-0);\n margin-top: -12px;\n}\n\n.mdhui-calendar-day-future .mdhui-calendar-day-value {\n background: var(--mdhui-background-color-0);\n color: var(--mdhui-text-color-4);\n border: 2px solid var(--mdhui-border-color-2);\n margin-top: -12px;\n}\n\n.mdhui-calendar-day-note-wrapper {\n position: absolute;\n bottom: -12px;\n right: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n background: var(--mdhui-border-color-1);\n border: 1px solid var(--mdhui-border-color-2);\n border-radius: 8px;\n color: var(--mdhui-text-color-0);\n height: 16px;\n min-width: 16px;\n max-width: 40px;\n padding: 0 4px;\n font-size: 0.62em;\n box-sizing: border-box;\n}\n\n.mdhui-calendar-day-note {\n max-width: 100%;\n overflow: hidden;\n white-space: nowrap;\n text-overflow: ellipsis;\n}");A(".mdhui-card {\n border-radius: var(--mdhui-card-border-radius);\n margin: 16px;\n background: var(--mdhui-background-color-0);\n box-shadow: var(--mdhui-box-shadow-0);\n animation: var(--mdhui-fadein-animation);\n -moz-animation: var(--mdhui-fadein-animation);\n -webkit-animation: var(--mdhui-fadein-animation);\n position: relative;\n overflow: hidden;\n display: flow-root;\n}\n\n.mdhui-card:empty {\n display: none;\n}\n\n.mdhui-card.allow-overflow {\n overflow: visible;\n}\n\n.mdhui-card-subtle {\n box-shadow: none;\n background: none !important;\n border: solid 1px var(--mdhui-border-color-1);\n}\n\n.mdhui-card-highlight\n{\n background: var(--mdhui-color-primary);\n color: #FFF;\n --mdhui-text-color-0: #FFF;\n --mdhui-text-color-1: #FFF;\n --mdhui-text-color-2: #FFF;\n --mdhui-text-color-3: #FFF;\n --mdhui-text-color-4: #FFF;\n}");function LS(){return t.createElement("div",{className:"mdhui-shiny-overlay"})}function FS(e){if(!e.children)return null;let a=["mdhui-card"];e.allowOverflow&&a.push("allow-overflow"),e.className&&a.push(e.className);let n=e.variant||"default";a.push(`mdhui-card-${n}`),"highlight"==n&&a.push("mdhui-color-scheme-dark");let i=r(Ka),o=ze(i?.colorScheme,e.backgroundColor);return t.createElement("div",{style:{...e.style,backgroundColor:o},ref:e.innerRef,className:a.join(" ")},e.children,e.children&&"highlight"===n&&t.createElement(LS,null))}A(".mdhui-shiny-overlay\n{\n position: absolute;\n left: 0;\n right: 0;\n bottom: 0;\n top: 0;\n background: var(--mdhui-overlay-gradient);\n pointer-events: none;\n}\n");function BS(e){let a=r(Ka);return t.createElement("div",{style:{color:ze(a.colorScheme,e.color)},ref:e.innerRef,className:"mdhui-card-title"},e.title,e.onDetailClick&&e.detailLinkText&&t.createElement("a",{className:"detail-link",onClick:()=>e.onDetailClick?e.onDetailClick():null},e.detailLinkText))}A(".mdhui-card-title {\n padding: 16px;\n font-weight: bold;\n padding-bottom: 0;\n position: relative;\n color: var(--mdhui-text-color-0);\n}\n\n.mdhui-card-title .detail-link {\n position: absolute;\n right: 16px;\n bottom: 0;\n font-size: .88em;\n cursor: pointer;\n}");const HS={};function qS(e,t){"string"!=typeof t&&(t=qS.defaultChars);const a=function(e){let t=HS[e];if(t)return t;t=HS[e]=[];for(let e=0;e<128;e++){const a=String.fromCharCode(e);t.push(a)}for(let a=0;a<e.length;a++){const n=e.charCodeAt(a);t[n]="%"+("0"+n.toString(16).toUpperCase()).slice(-2)}return t}(t);return e.replace(/(%[a-f0-9]{2})+/gi,(function(e){let t="";for(let n=0,i=e.length;n<i;n+=3){const r=parseInt(e.slice(n+1,n+3),16);if(r<128)t+=a[r];else{if(192==(224&r)&&n+3<i){const a=parseInt(e.slice(n+4,n+6),16);if(128==(192&a)){const e=r<<6&1984|63&a;t+=e<128?"��":String.fromCharCode(e),n+=3;continue}}if(224==(240&r)&&n+6<i){const a=parseInt(e.slice(n+4,n+6),16),i=parseInt(e.slice(n+7,n+9),16);if(128==(192&a)&&128==(192&i)){const e=r<<12&61440|a<<6&4032|63&i;t+=e<2048||e>=55296&&e<=57343?"���":String.fromCharCode(e),n+=6;continue}}if(240==(248&r)&&n+9<i){const a=parseInt(e.slice(n+4,n+6),16),i=parseInt(e.slice(n+7,n+9),16),o=parseInt(e.slice(n+10,n+12),16);if(128==(192&a)&&128==(192&i)&&128==(192&o)){let e=r<<18&1835008|a<<12&258048|i<<6&4032|63&o;e<65536||e>1114111?t+="����":(e-=65536,t+=String.fromCharCode(55296+(e>>10),56320+(1023&e))),n+=9;continue}}t+="�"}}return t}))}qS.defaultChars=";/?:@&=+$,#",qS.componentChars="";const US={};function WS(e,t,a){"string"!=typeof t&&(a=t,t=WS.defaultChars),void 0===a&&(a=!0);const n=function(e){let t=US[e];if(t)return t;t=US[e]=[];for(let e=0;e<128;e++){const a=String.fromCharCode(e);/^[0-9a-z]$/i.test(a)?t.push(a):t.push("%"+("0"+e.toString(16).toUpperCase()).slice(-2))}for(let a=0;a<e.length;a++)t[e.charCodeAt(a)]=e[a];return t}(t);let i="";for(let t=0,r=e.length;t<r;t++){const o=e.charCodeAt(t);if(a&&37===o&&t+2<r&&/^[0-9a-f]{2}$/i.test(e.slice(t+1,t+3)))i+=e.slice(t,t+3),t+=2;else if(o<128)i+=n[o];else if(o>=55296&&o<=57343){if(o>=55296&&o<=56319&&t+1<r){const a=e.charCodeAt(t+1);if(a>=56320&&a<=57343){i+=encodeURIComponent(e[t]+e[t+1]),t++;continue}}i+="%EF%BF%BD"}else i+=encodeURIComponent(e[t])}return i}function VS(e){let t="";return t+=e.protocol||"",t+=e.slashes?"//":"",t+=e.auth?e.auth+"@":"",e.hostname&&-1!==e.hostname.indexOf(":")?t+="["+e.hostname+"]":t+=e.hostname||"",t+=e.port?":"+e.port:"",t+=e.pathname||"",t+=e.search||"",t+=e.hash||"",t}function $S(){this.protocol=null,this.slashes=null,this.auth=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.pathname=null}WS.defaultChars=";/?:@&=+$,-_.!~*'()#",WS.componentChars="-_.!~*'()";const GS=/^([a-z0-9.+-]+:)/i,KS=/:[0-9]*$/,ZS=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,YS=["{","}","|","\\","^","`"].concat(["<",">",'"',"`"," ","\r","\n","\t"]),XS=["'"].concat(YS),QS=["%","/","?",";","#"].concat(XS),JS=["/","?","#"],eE=/^[+a-z0-9A-Z_-]{0,63}$/,tE=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,aE={javascript:!0,"javascript:":!0},nE={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function iE(e,t){if(e&&e instanceof $S)return e;const a=new $S;return a.parse(e,t),a}$S.prototype.parse=function(e,t){let a,n,i,r=e;if(r=r.trim(),!t&&1===e.split("#").length){const e=ZS.exec(r);if(e)return this.pathname=e[1],e[2]&&(this.search=e[2]),this}let o=GS.exec(r);if(o&&(o=o[0],a=o.toLowerCase(),this.protocol=o,r=r.substr(o.length)),(t||o||r.match(/^\/\/[^@\/]+@[^@\/]+/))&&(i="//"===r.substr(0,2),!i||o&&aE[o]||(r=r.substr(2),this.slashes=!0)),!aE[o]&&(i||o&&!nE[o])){let e,t,a=-1;for(let e=0;e<JS.length;e++)n=r.indexOf(JS[e]),-1!==n&&(-1===a||n<a)&&(a=n);t=-1===a?r.lastIndexOf("@"):r.lastIndexOf("@",a),-1!==t&&(e=r.slice(0,t),r=r.slice(t+1),this.auth=e),a=-1;for(let e=0;e<QS.length;e++)n=r.indexOf(QS[e]),-1!==n&&(-1===a||n<a)&&(a=n);-1===a&&(a=r.length),":"===r[a-1]&&a--;const i=r.slice(0,a);r=r.slice(a),this.parseHost(i),this.hostname=this.hostname||"";const o="["===this.hostname[0]&&"]"===this.hostname[this.hostname.length-1];if(!o){const e=this.hostname.split(/\./);for(let t=0,a=e.length;t<a;t++){const a=e[t];if(a&&!a.match(eE)){let n="";for(let e=0,t=a.length;e<t;e++)a.charCodeAt(e)>127?n+="x":n+=a[e];if(!n.match(eE)){const n=e.slice(0,t),i=e.slice(t+1),o=a.match(tE);o&&(n.push(o[1]),i.unshift(o[2])),i.length&&(r=i.join(".")+r),this.hostname=n.join(".");break}}}}this.hostname.length>255&&(this.hostname=""),o&&(this.hostname=this.hostname.substr(1,this.hostname.length-2))}const s=r.indexOf("#");-1!==s&&(this.hash=r.substr(s),r=r.slice(0,s));const l=r.indexOf("?");return-1!==l&&(this.search=r.substr(l),r=r.slice(0,l)),r&&(this.pathname=r),nE[a]&&this.hostname&&!this.pathname&&(this.pathname=""),this},$S.prototype.parseHost=function(e){let t=KS.exec(e);t&&(t=t[0],":"!==t&&(this.port=t.substr(1)),e=e.substr(0,e.length-t.length)),e&&(this.hostname=e)};var rE,oE=Object.freeze({__proto__:null,decode:qS,encode:WS,format:VS,parse:iE}),sE=/[\0-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,lE=/[\0-\x1F\x7F-\x9F]/,cE=/[!-#%-\*,-\/:;\?@\[-\]_\{\}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061D-\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1B7D\u1B7E\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52-\u2E5D\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59\uDF86-\uDF89]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDEB9\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2\uDF00-\uDF09]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDF43-\uDF4F\uDFFF]|\uD809[\uDC70-\uDC74]|\uD80B[\uDFF1\uDFF2]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,uE=/[\$\+<->\^`\|~\xA2-\xA6\xA8\xA9\xAC\xAE-\xB1\xB4\xB8\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0384\u0385\u03F6\u0482\u058D-\u058F\u0606-\u0608\u060B\u060E\u060F\u06DE\u06E9\u06FD\u06FE\u07F6\u07FE\u07FF\u0888\u09F2\u09F3\u09FA\u09FB\u0AF1\u0B70\u0BF3-\u0BFA\u0C7F\u0D4F\u0D79\u0E3F\u0F01-\u0F03\u0F13\u0F15-\u0F17\u0F1A-\u0F1F\u0F34\u0F36\u0F38\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE\u0FCF\u0FD5-\u0FD8\u109E\u109F\u1390-\u1399\u166D\u17DB\u1940\u19DE-\u19FF\u1B61-\u1B6A\u1B74-\u1B7C\u1FBD\u1FBF-\u1FC1\u1FCD-\u1FCF\u1FDD-\u1FDF\u1FED-\u1FEF\u1FFD\u1FFE\u2044\u2052\u207A-\u207C\u208A-\u208C\u20A0-\u20C0\u2100\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F\u218A\u218B\u2190-\u2307\u230C-\u2328\u232B-\u2426\u2440-\u244A\u249C-\u24E9\u2500-\u2767\u2794-\u27C4\u27C7-\u27E5\u27F0-\u2982\u2999-\u29D7\u29DC-\u29FB\u29FE-\u2B73\u2B76-\u2B95\u2B97-\u2BFF\u2CE5-\u2CEA\u2E50\u2E51\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFF\u3004\u3012\u3013\u3020\u3036\u3037\u303E\u303F\u309B\u309C\u3190\u3191\u3196-\u319F\u31C0-\u31E3\u31EF\u3200-\u321E\u322A-\u3247\u3250\u3260-\u327F\u328A-\u32B0\u32C0-\u33FF\u4DC0-\u4DFF\uA490-\uA4C6\uA700-\uA716\uA720\uA721\uA789\uA78A\uA828-\uA82B\uA836-\uA839\uAA77-\uAA79\uAB5B\uAB6A\uAB6B\uFB29\uFBB2-\uFBC2\uFD40-\uFD4F\uFDCF\uFDFC-\uFDFF\uFE62\uFE64-\uFE66\uFE69\uFF04\uFF0B\uFF1C-\uFF1E\uFF3E\uFF40\uFF5C\uFF5E\uFFE0-\uFFE6\uFFE8-\uFFEE\uFFFC\uFFFD]|\uD800[\uDD37-\uDD3F\uDD79-\uDD89\uDD8C-\uDD8E\uDD90-\uDD9C\uDDA0\uDDD0-\uDDFC]|\uD802[\uDC77\uDC78\uDEC8]|\uD805\uDF3F|\uD807[\uDFD5-\uDFF1]|\uD81A[\uDF3C-\uDF3F\uDF45]|\uD82F\uDC9C|\uD833[\uDF50-\uDFC3]|\uD834[\uDC00-\uDCF5\uDD00-\uDD26\uDD29-\uDD64\uDD6A-\uDD6C\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDDEA\uDE00-\uDE41\uDE45\uDF00-\uDF56]|\uD835[\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85\uDE86]|\uD838[\uDD4F\uDEFF]|\uD83B[\uDCAC\uDCB0\uDD2E\uDEF0\uDEF1]|\uD83C[\uDC00-\uDC2B\uDC30-\uDC93\uDCA0-\uDCAE\uDCB1-\uDCBF\uDCC1-\uDCCF\uDCD1-\uDCF5\uDD0D-\uDDAD\uDDE6-\uDE02\uDE10-\uDE3B\uDE40-\uDE48\uDE50\uDE51\uDE60-\uDE65\uDF00-\uDFFF]|\uD83D[\uDC00-\uDED7\uDEDC-\uDEEC\uDEF0-\uDEFC\uDF00-\uDF76\uDF7B-\uDFD9\uDFE0-\uDFEB\uDFF0]|\uD83E[\uDC00-\uDC0B\uDC10-\uDC47\uDC50-\uDC59\uDC60-\uDC87\uDC90-\uDCAD\uDCB0\uDCB1\uDD00-\uDE53\uDE60-\uDE6D\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC5\uDECE-\uDEDB\uDEE0-\uDEE8\uDEF0-\uDEF8\uDF00-\uDF92\uDF94-\uDFCA]/,dE=/[ \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/,mE=Object.freeze({__proto__:null,Any:sE,Cc:lE,Cf:/[\xAD\u0600-\u0605\u061C\u06DD\u070F\u0890\u0891\u08E2\u180E\u200B-\u200F\u202A-\u202E\u2060-\u2064\u2066-\u206F\uFEFF\uFFF9-\uFFFB]|\uD804[\uDCBD\uDCCD]|\uD80D[\uDC30-\uDC3F]|\uD82F[\uDCA0-\uDCA3]|\uD834[\uDD73-\uDD7A]|\uDB40[\uDC01\uDC20-\uDC7F]/,P:cE,S:uE,Z:dE}),hE=new Uint16Array('ᵁ<Õıʊҝջאٵ۞ޢߖࠏ੊ઑඡ๭༉༦჊ረዡᐕᒝᓃᓟᔥ\0\0\0\0\0\0ᕫᛍᦍᰒᷝ὾⁠↰⊍⏀⏻⑂⠤⤒ⴈ⹈⿎〖㊺㘹㞬㣾㨨㩱㫠㬮ࠀEMabcfglmnoprstu\\bfms„‹•˜¦³¹ÈÏlig耻Æ䃆P耻&䀦cute耻Á䃁reve;䄂Āiyx}rc耻Â䃂;䐐r;쀀𝔄rave耻À䃀pha;䎑acr;䄀d;橓Āgp¡on;䄄f;쀀𝔸plyFunction;恡ing耻Å䃅Ācs¾Ãr;쀀𝒜ign;扔ilde耻Ã䃃ml耻Ä䃄ЀaceforsuåûþėĜĢħĪĀcrêòkslash;或Ŷöø;櫧ed;挆y;䐑ƀcrtąċĔause;戵noullis;愬a;䎒r;쀀𝔅pf;쀀𝔹eve;䋘còēmpeq;扎܀HOacdefhilorsuōőŖƀƞƢƵƷƺǜȕɳɸɾcy;䐧PY耻©䂩ƀcpyŝŢźute;䄆Ā;iŧŨ拒talDifferentialD;慅leys;愭ȀaeioƉƎƔƘron;䄌dil耻Ç䃇rc;䄈nint;戰ot;䄊ĀdnƧƭilla;䂸terDot;䂷òſi;䎧rcleȀDMPTLJNjǑǖot;抙inus;抖lus;投imes;抗oĀcsǢǸkwiseContourIntegral;戲eCurlyĀDQȃȏoubleQuote;思uote;怙ȀlnpuȞȨɇɕonĀ;eȥȦ户;橴ƀgitȯȶȺruent;扡nt;戯ourIntegral;戮ĀfrɌɎ;愂oduct;成nterClockwiseContourIntegral;戳oss;樯cr;쀀𝒞pĀ;Cʄʅ拓ap;才րDJSZacefiosʠʬʰʴʸˋ˗ˡ˦̳ҍĀ;oŹʥtrahd;椑cy;䐂cy;䐅cy;䐏ƀgrsʿ˄ˇger;怡r;憡hv;櫤Āayː˕ron;䄎;䐔lĀ;t˝˞戇a;䎔r;쀀𝔇Āaf˫̧Ācm˰̢riticalȀADGT̖̜̀̆cute;䂴oŴ̋̍;䋙bleAcute;䋝rave;䁠ilde;䋜ond;拄ferentialD;慆Ѱ̽\0\0\0͔͂\0Ѕf;쀀𝔻ƀ;DE͈͉͍䂨ot;惜qual;扐blèCDLRUVͣͲ΂ϏϢϸontourIntegraìȹoɴ͹\0\0ͻ»͉nArrow;懓Āeo·ΤftƀARTΐΖΡrrow;懐ightArrow;懔eåˊngĀLRΫτeftĀARγιrrow;柸ightArrow;柺ightArrow;柹ightĀATϘϞrrow;懒ee;抨pɁϩ\0\0ϯrrow;懑ownArrow;懕erticalBar;戥ǹABLRTaВЪаўѿͼrrowƀ;BUНОТ憓ar;椓pArrow;懵reve;䌑eft˒к\0ц\0ѐightVector;楐eeVector;楞ectorĀ;Bљњ憽ar;楖ightǔѧ\0ѱeeVector;楟ectorĀ;BѺѻ懁ar;楗eeĀ;A҆҇护rrow;憧ĀctҒҗr;쀀𝒟rok;䄐ࠀNTacdfglmopqstuxҽӀӄӋӞӢӧӮӵԡԯԶՒ՝ՠեG;䅊H耻Ð䃐cute耻É䃉ƀaiyӒӗӜron;䄚rc耻Ê䃊;䐭ot;䄖r;쀀𝔈rave耻È䃈ement;戈ĀapӺӾcr;䄒tyɓԆ\0\0ԒmallSquare;旻erySmallSquare;斫ĀgpԦԪon;䄘f;쀀𝔼silon;䎕uĀaiԼՉlĀ;TՂՃ橵ilde;扂librium;懌Āci՗՚r;愰m;橳a;䎗ml耻Ë䃋Āipժկsts;戃onentialE;慇ʀcfiosօֈ֍ֲ׌y;䐤r;쀀𝔉lledɓ֗\0\0֣mallSquare;旼erySmallSquare;斪Ͱֺ\0ֿ\0\0ׄf;쀀𝔽All;戀riertrf;愱cò׋؀JTabcdfgorstר׬ׯ׺؀ؒؖ؛؝أ٬ٲcy;䐃耻>䀾mmaĀ;d׷׸䎓;䏜reve;䄞ƀeiy؇،ؐdil;䄢rc;䄜;䐓ot;䄠r;쀀𝔊;拙pf;쀀𝔾eater̀EFGLSTصلَٖٛ٦qualĀ;Lؾؿ扥ess;招ullEqual;执reater;檢ess;扷lantEqual;橾ilde;扳cr;쀀𝒢;扫ЀAacfiosuڅڋږڛڞڪھۊRDcy;䐪Āctڐڔek;䋇;䁞irc;䄤r;愌lbertSpace;愋ǰگ\0ڲf;愍izontalLine;攀Āctۃۅòکrok;䄦mpńېۘownHumðįqual;扏܀EJOacdfgmnostuۺ۾܃܇܎ܚܞܡܨ݄ݸދޏޕcy;䐕lig;䄲cy;䐁cute耻Í䃍Āiyܓܘrc耻Î䃎;䐘ot;䄰r;愑rave耻Ì䃌ƀ;apܠܯܿĀcgܴܷr;䄪inaryI;慈lieóϝǴ݉\0ݢĀ;eݍݎ戬Āgrݓݘral;戫section;拂isibleĀCTݬݲomma;恣imes;恢ƀgptݿރވon;䄮f;쀀𝕀a;䎙cr;愐ilde;䄨ǫޚ\0ޞcy;䐆l耻Ï䃏ʀcfosuެ޷޼߂ߐĀiyޱ޵rc;䄴;䐙r;쀀𝔍pf;쀀𝕁ǣ߇\0ߌr;쀀𝒥rcy;䐈kcy;䐄΀HJacfosߤߨ߽߬߱ࠂࠈcy;䐥cy;䐌ppa;䎚Āey߶߻dil;䄶;䐚r;쀀𝔎pf;쀀𝕂cr;쀀𝒦րJTaceflmostࠥࠩࠬࡐࡣ঳সে্਷ੇcy;䐉耻<䀼ʀcmnpr࠷࠼ࡁࡄࡍute;䄹bda;䎛g;柪lacetrf;愒r;憞ƀaeyࡗ࡜ࡡron;䄽dil;䄻;䐛Āfsࡨ॰tԀACDFRTUVarࡾࢩࢱࣦ࣠ࣼयज़ΐ४Ānrࢃ࢏gleBracket;柨rowƀ;BR࢙࢚࢞憐ar;懤ightArrow;懆eiling;挈oǵࢷ\0ࣃbleBracket;柦nǔࣈ\0࣒eeVector;楡ectorĀ;Bࣛࣜ懃ar;楙loor;挊ightĀAV࣯ࣵrrow;憔ector;楎Āerँगeƀ;AVउऊऐ抣rrow;憤ector;楚iangleƀ;BEतथऩ抲ar;槏qual;抴pƀDTVषूौownVector;楑eeVector;楠ectorĀ;Bॖॗ憿ar;楘ectorĀ;B॥०憼ar;楒ightáΜs̀EFGLSTॾঋকঝঢভqualGreater;拚ullEqual;扦reater;扶ess;檡lantEqual;橽ilde;扲r;쀀𝔏Ā;eঽা拘ftarrow;懚idot;䄿ƀnpw৔ਖਛgȀLRlr৞৷ਂਐeftĀAR০৬rrow;柵ightArrow;柷ightArrow;柶eftĀarγਊightáοightáϊf;쀀𝕃erĀLRਢਬeftArrow;憙ightArrow;憘ƀchtਾੀੂòࡌ;憰rok;䅁;扪Ѐacefiosuਗ਼੝੠੷੼અઋ઎p;椅y;䐜Ādl੥੯iumSpace;恟lintrf;愳r;쀀𝔐nusPlus;戓pf;쀀𝕄cò੶;䎜ҀJacefostuણધભીଔଙඑ඗ඞcy;䐊cute;䅃ƀaey઴હાron;䅇dil;䅅;䐝ƀgswે૰଎ativeƀMTV૓૟૨ediumSpace;怋hiĀcn૦૘ë૙eryThiî૙tedĀGL૸ଆreaterGreateòٳessLesóੈLine;䀊r;쀀𝔑ȀBnptଢନଷ଺reak;恠BreakingSpace;䂠f;愕ڀ;CDEGHLNPRSTV୕ୖ୪୼஡௫ఄ౞಄ದ೘ൡඅ櫬Āou୛୤ngruent;扢pCap;扭oubleVerticalBar;戦ƀlqxஃஊ஛ement;戉ualĀ;Tஒஓ扠ilde;쀀≂̸ists;戄reater΀;EFGLSTஶஷ஽௉௓௘௥扯qual;扱ullEqual;쀀≧̸reater;쀀≫̸ess;批lantEqual;쀀⩾̸ilde;扵umpń௲௽ownHump;쀀≎̸qual;쀀≏̸eĀfsఊధtTriangleƀ;BEచఛడ拪ar;쀀⧏̸qual;括s̀;EGLSTవశ఼ౄోౘ扮qual;扰reater;扸ess;쀀≪̸lantEqual;쀀⩽̸ilde;扴estedĀGL౨౹reaterGreater;쀀⪢̸essLess;쀀⪡̸recedesƀ;ESಒಓಛ技qual;쀀⪯̸lantEqual;拠ĀeiಫಹverseElement;戌ghtTriangleƀ;BEೋೌ೒拫ar;쀀⧐̸qual;拭ĀquೝഌuareSuĀbp೨೹setĀ;E೰ೳ쀀⊏̸qual;拢ersetĀ;Eഃആ쀀⊐̸qual;拣ƀbcpഓതൎsetĀ;Eഛഞ쀀⊂⃒qual;抈ceedsȀ;ESTലള഻െ抁qual;쀀⪰̸lantEqual;拡ilde;쀀≿̸ersetĀ;E൘൛쀀⊃⃒qual;抉ildeȀ;EFT൮൯൵ൿ扁qual;扄ullEqual;扇ilde;扉erticalBar;戤cr;쀀𝒩ilde耻Ñ䃑;䎝܀Eacdfgmoprstuvලෂ෉෕ෛ෠෧෼ขภยา฿ไlig;䅒cute耻Ó䃓Āiy෎ීrc耻Ô䃔;䐞blac;䅐r;쀀𝔒rave耻Ò䃒ƀaei෮ෲ෶cr;䅌ga;䎩cron;䎟pf;쀀𝕆enCurlyĀDQฎบoubleQuote;怜uote;怘;橔Āclวฬr;쀀𝒪ash耻Ø䃘iŬื฼de耻Õ䃕es;樷ml耻Ö䃖erĀBP๋๠Āar๐๓r;怾acĀek๚๜;揞et;掴arenthesis;揜Ҁacfhilors๿ງຊຏຒດຝະ໼rtialD;戂y;䐟r;쀀𝔓i;䎦;䎠usMinus;䂱Āipຢອncareplanåڝf;愙Ȁ;eio຺ູ໠໤檻cedesȀ;EST່້໏໚扺qual;檯lantEqual;扼ilde;找me;怳Ādp໩໮uct;戏ortionĀ;aȥ໹l;戝Āci༁༆r;쀀𝒫;䎨ȀUfos༑༖༛༟OT耻"䀢r;쀀𝔔pf;愚cr;쀀𝒬؀BEacefhiorsu༾གྷཇའཱིྦྷྪྭ႖ႩႴႾarr;椐G耻®䂮ƀcnrཎནབute;䅔g;柫rĀ;tཛྷཝ憠l;椖ƀaeyཧཬཱron;䅘dil;䅖;䐠Ā;vླྀཹ愜erseĀEUྂྙĀlq྇ྎement;戋uilibrium;懋pEquilibrium;楯r»ཹo;䎡ghtЀACDFTUVa࿁࿫࿳ဢဨၛႇϘĀnr࿆࿒gleBracket;柩rowƀ;BL࿜࿝࿡憒ar;懥eftArrow;懄eiling;按oǵ࿹\0စbleBracket;柧nǔည\0နeeVector;楝ectorĀ;Bဝသ懂ar;楕loor;挋Āerိ၃eƀ;AVဵံြ抢rrow;憦ector;楛iangleƀ;BEၐၑၕ抳ar;槐qual;抵pƀDTVၣၮၸownVector;楏eeVector;楜ectorĀ;Bႂႃ憾ar;楔ectorĀ;B႑႒懀ar;楓Āpuႛ႞f;愝ndImplies;楰ightarrow;懛ĀchႹႼr;愛;憱leDelayed;槴ڀHOacfhimoqstuფჱჷჽᄙᄞᅑᅖᅡᅧᆵᆻᆿĀCcჩხHcy;䐩y;䐨FTcy;䐬cute;䅚ʀ;aeiyᄈᄉᄎᄓᄗ檼ron;䅠dil;䅞rc;䅜;䐡r;쀀𝔖ortȀDLRUᄪᄴᄾᅉownArrow»ОeftArrow»࢚ightArrow»࿝pArrow;憑gma;䎣allCircle;战pf;쀀𝕊ɲᅭ\0\0ᅰt;戚areȀ;ISUᅻᅼᆉᆯ斡ntersection;抓uĀbpᆏᆞsetĀ;Eᆗᆘ抏qual;抑ersetĀ;Eᆨᆩ抐qual;抒nion;抔cr;쀀𝒮ar;拆ȀbcmpᇈᇛሉላĀ;sᇍᇎ拐etĀ;Eᇍᇕqual;抆ĀchᇠህeedsȀ;ESTᇭᇮᇴᇿ扻qual;檰lantEqual;扽ilde;承Tháྌ;我ƀ;esሒሓሣ拑rsetĀ;Eሜም抃qual;抇et»ሓրHRSacfhiorsሾቄ቉ቕ቞ቱቶኟዂወዑORN耻Þ䃞ADE;愢ĀHc቎ቒcy;䐋y;䐦Ābuቚቜ;䀉;䎤ƀaeyብቪቯron;䅤dil;䅢;䐢r;쀀𝔗Āeiቻ኉Dzኀ\0ኇefore;戴a;䎘Ācn኎ኘkSpace;쀀  Space;怉ldeȀ;EFTካኬኲኼ戼qual;扃ullEqual;扅ilde;扈pf;쀀𝕋ipleDot;惛Āctዖዛr;쀀𝒯rok;䅦ૡዷጎጚጦ\0ጬጱ\0\0\0\0\0ጸጽ፷ᎅ\0᏿ᐄᐊᐐĀcrዻጁute耻Ú䃚rĀ;oጇገ憟cir;楉rǣጓ\0጖y;䐎ve;䅬Āiyጞጣrc耻Û䃛;䐣blac;䅰r;쀀𝔘rave耻Ù䃙acr;䅪Ādiፁ፩erĀBPፈ፝Āarፍፐr;䁟acĀekፗፙ;揟et;掵arenthesis;揝onĀ;P፰፱拃lus;抎Āgp፻፿on;䅲f;쀀𝕌ЀADETadps᎕ᎮᎸᏄϨᏒᏗᏳrrowƀ;BDᅐᎠᎤar;椒ownArrow;懅ownArrow;憕quilibrium;楮eeĀ;AᏋᏌ报rrow;憥ownáϳerĀLRᏞᏨeftArrow;憖ightArrow;憗iĀ;lᏹᏺ䏒on;䎥ing;䅮cr;쀀𝒰ilde;䅨ml耻Ü䃜ҀDbcdefosvᐧᐬᐰᐳᐾᒅᒊᒐᒖash;披ar;櫫y;䐒ashĀ;lᐻᐼ抩;櫦Āerᑃᑅ;拁ƀbtyᑌᑐᑺar;怖Ā;iᑏᑕcalȀBLSTᑡᑥᑪᑴar;戣ine;䁼eparator;杘ilde;所ThinSpace;怊r;쀀𝔙pf;쀀𝕍cr;쀀𝒱dash;抪ʀcefosᒧᒬᒱᒶᒼirc;䅴dge;拀r;쀀𝔚pf;쀀𝕎cr;쀀𝒲Ȁfiosᓋᓐᓒᓘr;쀀𝔛;䎞pf;쀀𝕏cr;쀀𝒳ҀAIUacfosuᓱᓵᓹᓽᔄᔏᔔᔚᔠcy;䐯cy;䐇cy;䐮cute耻Ý䃝Āiyᔉᔍrc;䅶;䐫r;쀀𝔜pf;쀀𝕐cr;쀀𝒴ml;䅸ЀHacdefosᔵᔹᔿᕋᕏᕝᕠᕤcy;䐖cute;䅹Āayᕄᕉron;䅽;䐗ot;䅻Dzᕔ\0ᕛoWidtè૙a;䎖r;愨pf;愤cr;쀀𝒵௡ᖃᖊᖐ\0ᖰᖶᖿ\0\0\0\0ᗆᗛᗫᙟ᙭\0ᚕ᚛ᚲᚹ\0ᚾcute耻á䃡reve;䄃̀;Ediuyᖜᖝᖡᖣᖨᖭ戾;쀀∾̳;房rc耻â䃢te肻´̆;䐰lig耻æ䃦Ā;r²ᖺ;쀀𝔞rave耻à䃠ĀepᗊᗖĀfpᗏᗔsym;愵èᗓha;䎱ĀapᗟcĀclᗤᗧr;䄁g;樿ɤᗰ\0\0ᘊʀ;adsvᗺᗻᗿᘁᘇ戧nd;橕;橜lope;橘;橚΀;elmrszᘘᘙᘛᘞᘿᙏᙙ戠;榤e»ᘙsdĀ;aᘥᘦ戡ѡᘰᘲᘴᘶᘸᘺᘼᘾ;榨;榩;榪;榫;榬;榭;榮;榯tĀ;vᙅᙆ戟bĀ;dᙌᙍ抾;榝Āptᙔᙗh;戢»¹arr;捼Āgpᙣᙧon;䄅f;쀀𝕒΀;Eaeiop዁ᙻᙽᚂᚄᚇᚊ;橰cir;橯;扊d;手s;䀧roxĀ;e዁ᚒñᚃing耻å䃥ƀctyᚡᚦᚨr;쀀𝒶;䀪mpĀ;e዁ᚯñʈilde耻ã䃣ml耻ä䃤Āciᛂᛈoninôɲnt;樑ࠀNabcdefiklnoprsu᛭ᛱᜰ᜼ᝃᝈ᝸᝽០៦ᠹᡐᜍ᤽᥈ᥰot;櫭Ācrᛶ᜞kȀcepsᜀᜅᜍᜓong;扌psilon;䏶rime;怵imĀ;e᜚᜛戽q;拍Ŷᜢᜦee;抽edĀ;gᜬᜭ挅e»ᜭrkĀ;t፜᜷brk;掶Āoyᜁᝁ;䐱quo;怞ʀcmprtᝓ᝛ᝡᝤᝨausĀ;eĊĉptyv;榰séᜌnoõēƀahwᝯ᝱ᝳ;䎲;愶een;扬r;쀀𝔟g΀costuvwឍឝឳេ៕៛៞ƀaiuបពរðݠrc;旯p»፱ƀdptឤឨឭot;樀lus;樁imes;樂ɱឹ\0\0ើcup;樆ar;昅riangleĀdu៍្own;施p;斳plus;樄eåᑄåᒭarow;植ƀako៭ᠦᠵĀcn៲ᠣkƀlst៺֫᠂ozenge;槫riangleȀ;dlr᠒᠓᠘᠝斴own;斾eft;旂ight;斸k;搣Ʊᠫ\0ᠳƲᠯ\0ᠱ;斒;斑4;斓ck;斈ĀeoᠾᡍĀ;qᡃᡆ쀀=⃥uiv;쀀≡⃥t;挐Ȁptwxᡙᡞᡧᡬf;쀀𝕓Ā;tᏋᡣom»Ꮜtie;拈؀DHUVbdhmptuvᢅᢖᢪᢻᣗᣛᣬ᣿ᤅᤊᤐᤡȀLRlrᢎᢐᢒᢔ;敗;敔;敖;敓ʀ;DUduᢡᢢᢤᢦᢨ敐;敦;敩;敤;敧ȀLRlrᢳᢵᢷᢹ;敝;敚;敜;教΀;HLRhlrᣊᣋᣍᣏᣑᣓᣕ救;敬;散;敠;敫;敢;敟ox;槉ȀLRlrᣤᣦᣨᣪ;敕;敒;攐;攌ʀ;DUduڽ᣷᣹᣻᣽;敥;敨;攬;攴inus;抟lus;択imes;抠ȀLRlrᤙᤛᤝ᤟;敛;敘;攘;攔΀;HLRhlrᤰᤱᤳᤵᤷ᤻᤹攂;敪;敡;敞;攼;攤;攜Āevģ᥂bar耻¦䂦Ȁceioᥑᥖᥚᥠr;쀀𝒷mi;恏mĀ;e᜚᜜lƀ;bhᥨᥩᥫ䁜;槅sub;柈Ŭᥴ᥾lĀ;e᥹᥺怢t»᥺pƀ;Eeįᦅᦇ;檮Ā;qۜۛೡᦧ\0᧨ᨑᨕᨲ\0ᨷᩐ\0\0᪴\0\0᫁\0\0ᬡᬮ᭍᭒\0᯽\0ᰌƀcpr᦭ᦲ᧝ute;䄇̀;abcdsᦿᧀᧄ᧊᧕᧙戩nd;橄rcup;橉Āau᧏᧒p;橋p;橇ot;橀;쀀∩︀Āeo᧢᧥t;恁îړȀaeiu᧰᧻ᨁᨅǰ᧵\0᧸s;橍on;䄍dil耻ç䃧rc;䄉psĀ;sᨌᨍ橌m;橐ot;䄋ƀdmnᨛᨠᨦil肻¸ƭptyv;榲t脀¢;eᨭᨮ䂢räƲr;쀀𝔠ƀceiᨽᩀᩍy;䑇ckĀ;mᩇᩈ朓ark»ᩈ;䏇r΀;Ecefms᩟᩠ᩢᩫ᪤᪪᪮旋;槃ƀ;elᩩᩪᩭ䋆q;扗eɡᩴ\0\0᪈rrowĀlr᩼᪁eft;憺ight;憻ʀRSacd᪒᪔᪖᪚᪟»ཇ;擈st;抛irc;抚ash;抝nint;樐id;櫯cir;槂ubsĀ;u᪻᪼晣it»᪼ˬ᫇᫔᫺\0ᬊonĀ;eᫍᫎ䀺Ā;qÇÆɭ᫙\0\0᫢aĀ;t᫞᫟䀬;䁀ƀ;fl᫨᫩᫫戁îᅠeĀmx᫱᫶ent»᫩eóɍǧ᫾\0ᬇĀ;dኻᬂot;橭nôɆƀfryᬐᬔᬗ;쀀𝕔oäɔ脀©;sŕᬝr;愗Āaoᬥᬩrr;憵ss;朗Ācuᬲᬷr;쀀𝒸Ābpᬼ᭄Ā;eᭁᭂ櫏;櫑Ā;eᭉᭊ櫐;櫒dot;拯΀delprvw᭠᭬᭷ᮂᮬᯔ᯹arrĀlr᭨᭪;椸;椵ɰ᭲\0\0᭵r;拞c;拟arrĀ;p᭿ᮀ憶;椽̀;bcdosᮏᮐᮖᮡᮥᮨ截rcap;橈Āauᮛᮞp;橆p;橊ot;抍r;橅;쀀∪︀Ȁalrv᮵ᮿᯞᯣrrĀ;mᮼᮽ憷;椼yƀevwᯇᯔᯘqɰᯎ\0\0ᯒreã᭳uã᭵ee;拎edge;拏en耻¤䂤earrowĀlrᯮ᯳eft»ᮀight»ᮽeäᯝĀciᰁᰇoninôǷnt;戱lcty;挭ঀAHabcdefhijlorstuwz᰸᰻᰿ᱝᱩᱵᲊᲞᲬᲷ᳻᳿ᴍᵻᶑᶫᶻ᷆᷍rò΁ar;楥Ȁglrs᱈ᱍ᱒᱔ger;怠eth;愸òᄳhĀ;vᱚᱛ怐»ऊūᱡᱧarow;椏aã̕Āayᱮᱳron;䄏;䐴ƀ;ao̲ᱼᲄĀgrʿᲁr;懊tseq;橷ƀglmᲑᲔᲘ耻°䂰ta;䎴ptyv;榱ĀirᲣᲨsht;楿;쀀𝔡arĀlrᲳᲵ»ࣜ»သʀaegsv᳂͸᳖᳜᳠mƀ;oș᳊᳔ndĀ;ș᳑uit;晦amma;䏝in;拲ƀ;io᳧᳨᳸䃷de脀÷;o᳧ᳰntimes;拇nø᳷cy;䑒cɯᴆ\0\0ᴊrn;挞op;挍ʀlptuwᴘᴝᴢᵉᵕlar;䀤f;쀀𝕕ʀ;emps̋ᴭᴷᴽᵂqĀ;d͒ᴳot;扑inus;戸lus;戔quare;抡blebarwedgåúnƀadhᄮᵝᵧownarrowóᲃarpoonĀlrᵲᵶefôᲴighôᲶŢᵿᶅkaro÷གɯᶊ\0\0ᶎrn;挟op;挌ƀcotᶘᶣᶦĀryᶝᶡ;쀀𝒹;䑕l;槶rok;䄑Ādrᶰᶴot;拱iĀ;fᶺ᠖斿Āah᷀᷃ròЩaòྦangle;榦Āci᷒ᷕy;䑟grarr;柿ऀDacdefglmnopqrstuxḁḉḙḸոḼṉṡṾấắẽỡἪἷὄ὎὚ĀDoḆᴴoôᲉĀcsḎḔute耻é䃩ter;橮ȀaioyḢḧḱḶron;䄛rĀ;cḭḮ扖耻ê䃪lon;払;䑍ot;䄗ĀDrṁṅot;扒;쀀𝔢ƀ;rsṐṑṗ檚ave耻è䃨Ā;dṜṝ檖ot;檘Ȁ;ilsṪṫṲṴ檙nters;揧;愓Ā;dṹṺ檕ot;檗ƀapsẅẉẗcr;䄓tyƀ;svẒẓẕ戅et»ẓpĀ1;ẝẤijạả;怄;怅怃ĀgsẪẬ;䅋p;怂ĀgpẴẸon;䄙f;쀀𝕖ƀalsỄỎỒrĀ;sỊị拕l;槣us;橱iƀ;lvỚớở䎵on»ớ;䏵ȀcsuvỪỳἋἣĀioữḱrc»Ḯɩỹ\0\0ỻíՈantĀglἂἆtr»ṝess»Ṻƀaeiἒ἖Ἒls;䀽st;扟vĀ;DȵἠD;橸parsl;槥ĀDaἯἳot;打rr;楱ƀcdiἾὁỸr;愯oô͒ĀahὉὋ;䎷耻ð䃰Āmrὓὗl耻ë䃫o;悬ƀcipὡὤὧl;䀡sôծĀeoὬὴctatioîՙnentialåչৡᾒ\0ᾞ\0ᾡᾧ\0\0ῆῌ\0ΐ\0ῦῪ \0 ⁚llingdotseñṄy;䑄male;晀ƀilrᾭᾳ῁lig;耀ffiɩᾹ\0\0᾽g;耀ffig;耀ffl;쀀𝔣lig;耀filig;쀀fjƀaltῙ῜ῡt;晭ig;耀flns;斱of;䆒ǰ΅\0ῳf;쀀𝕗ĀakֿῷĀ;vῼ´拔;櫙artint;樍Āao‌⁕Ācs‑⁒ႉ‸⁅⁈\0⁐β•‥‧‪‬\0‮耻½䂽;慓耻¼䂼;慕;慙;慛Ƴ‴\0‶;慔;慖ʴ‾⁁\0\0⁃耻¾䂾;慗;慜5;慘ƶ⁌\0⁎;慚;慝8;慞l;恄wn;挢cr;쀀𝒻ࢀEabcdefgijlnorstv₂₉₟₥₰₴⃰⃵⃺⃿℃ℒℸ̗ℾ⅒↞Ā;lٍ₇;檌ƀcmpₐₕ₝ute;䇵maĀ;dₜ᳚䎳;檆reve;䄟Āiy₪₮rc;䄝;䐳ot;䄡Ȁ;lqsؾق₽⃉ƀ;qsؾٌ⃄lanô٥Ȁ;cdl٥⃒⃥⃕c;檩otĀ;o⃜⃝檀Ā;l⃢⃣檂;檄Ā;e⃪⃭쀀⋛︀s;檔r;쀀𝔤Ā;gٳ؛mel;愷cy;䑓Ȁ;Eajٚℌℎℐ;檒;檥;檤ȀEaesℛℝ℩ℴ;扩pĀ;p℣ℤ檊rox»ℤĀ;q℮ℯ檈Ā;q℮ℛim;拧pf;쀀𝕘Āci⅃ⅆr;愊mƀ;el٫ⅎ⅐;檎;檐茀>;cdlqr׮ⅠⅪⅮⅳⅹĀciⅥⅧ;檧r;橺ot;拗Par;榕uest;橼ʀadelsↄⅪ←ٖ↛ǰ↉\0↎proø₞r;楸qĀlqؿ↖lesó₈ií٫Āen↣↭rtneqq;쀀≩︀Å↪ԀAabcefkosy⇄⇇⇱⇵⇺∘∝∯≨≽ròΠȀilmr⇐⇔⇗⇛rsðᒄf»․ilôکĀdr⇠⇤cy;䑊ƀ;cwࣴ⇫⇯ir;楈;憭ar;意irc;䄥ƀalr∁∎∓rtsĀ;u∉∊晥it»∊lip;怦con;抹r;쀀𝔥sĀew∣∩arow;椥arow;椦ʀamopr∺∾≃≞≣rr;懿tht;戻kĀlr≉≓eftarrow;憩ightarrow;憪f;쀀𝕙bar;怕ƀclt≯≴≸r;쀀𝒽asè⇴rok;䄧Ābp⊂⊇ull;恃hen»ᱛૡ⊣\0⊪\0⊸⋅⋎\0⋕⋳\0\0⋸⌢⍧⍢⍿\0⎆⎪⎴cute耻í䃭ƀ;iyݱ⊰⊵rc耻î䃮;䐸Ācx⊼⊿y;䐵cl耻¡䂡ĀfrΟ⋉;쀀𝔦rave耻ì䃬Ȁ;inoܾ⋝⋩⋮Āin⋢⋦nt;樌t;戭fin;槜ta;愩lig;䄳ƀaop⋾⌚⌝ƀcgt⌅⌈⌗r;䄫ƀelpܟ⌏⌓inåގarôܠh;䄱f;抷ed;䆵ʀ;cfotӴ⌬⌱⌽⍁are;愅inĀ;t⌸⌹戞ie;槝doô⌙ʀ;celpݗ⍌⍐⍛⍡al;抺Āgr⍕⍙eróᕣã⍍arhk;樗rod;樼Ȁcgpt⍯⍲⍶⍻y;䑑on;䄯f;쀀𝕚a;䎹uest耻¿䂿Āci⎊⎏r;쀀𝒾nʀ;EdsvӴ⎛⎝⎡ӳ;拹ot;拵Ā;v⎦⎧拴;拳Ā;iݷ⎮lde;䄩ǫ⎸\0⎼cy;䑖l耻ï䃯̀cfmosu⏌⏗⏜⏡⏧⏵Āiy⏑⏕rc;䄵;䐹r;쀀𝔧ath;䈷pf;쀀𝕛ǣ⏬\0⏱r;쀀𝒿rcy;䑘kcy;䑔Ѐacfghjos␋␖␢␧␭␱␵␻ppaĀ;v␓␔䎺;䏰Āey␛␠dil;䄷;䐺r;쀀𝔨reen;䄸cy;䑅cy;䑜pf;쀀𝕜cr;쀀𝓀஀ABEHabcdefghjlmnoprstuv⑰⒁⒆⒍⒑┎┽╚▀♎♞♥♹♽⚚⚲⛘❝❨➋⟀⠁⠒ƀart⑷⑺⑼rò৆òΕail;椛arr;椎Ā;gঔ⒋;檋ar;楢ॣ⒥\0⒪\0⒱\0\0\0\0\0⒵Ⓔ\0ⓆⓈⓍ\0⓹ute;䄺mptyv;榴raîࡌbda;䎻gƀ;dlࢎⓁⓃ;榑åࢎ;檅uo耻«䂫rЀ;bfhlpst࢙ⓞⓦⓩ⓫⓮⓱⓵Ā;f࢝ⓣs;椟s;椝ë≒p;憫l;椹im;楳l;憢ƀ;ae⓿─┄檫il;椙Ā;s┉┊檭;쀀⪭︀ƀabr┕┙┝rr;椌rk;杲Āak┢┬cĀek┨┪;䁻;䁛Āes┱┳;榋lĀdu┹┻;榏;榍Ȁaeuy╆╋╖╘ron;䄾Ādi═╔il;䄼ìࢰâ┩;䐻Ȁcqrs╣╦╭╽a;椶uoĀ;rนᝆĀdu╲╷har;楧shar;楋h;憲ʀ;fgqs▋▌উ◳◿扤tʀahlrt▘▤▷◂◨rrowĀ;t࢙□aé⓶arpoonĀdu▯▴own»њp»०eftarrows;懇ightƀahs◍◖◞rrowĀ;sࣴࢧarpoonó྘quigarro÷⇰hreetimes;拋ƀ;qs▋ও◺lanôবʀ;cdgsব☊☍☝☨c;檨otĀ;o☔☕橿Ā;r☚☛檁;檃Ā;e☢☥쀀⋚︀s;檓ʀadegs☳☹☽♉♋pproøⓆot;拖qĀgq♃♅ôউgtò⒌ôছiíলƀilr♕࣡♚sht;楼;쀀𝔩Ā;Eজ♣;檑š♩♶rĀdu▲♮Ā;l॥♳;楪lk;斄cy;䑙ʀ;achtੈ⚈⚋⚑⚖rò◁orneòᴈard;楫ri;旺Āio⚟⚤dot;䅀ustĀ;a⚬⚭掰che»⚭ȀEaes⚻⚽⛉⛔;扨pĀ;p⛃⛄檉rox»⛄Ā;q⛎⛏檇Ā;q⛎⚻im;拦Ѐabnoptwz⛩⛴⛷✚✯❁❇❐Ānr⛮⛱g;柬r;懽rëࣁgƀlmr⛿✍✔eftĀar০✇ightá৲apsto;柼ightá৽parrowĀlr✥✩efô⓭ight;憬ƀafl✶✹✽r;榅;쀀𝕝us;樭imes;樴š❋❏st;戗áፎƀ;ef❗❘᠀旊nge»❘arĀ;l❤❥䀨t;榓ʀachmt❳❶❼➅➇ròࢨorneòᶌarĀ;d྘➃;業;怎ri;抿̀achiqt➘➝ੀ➢➮➻quo;怹r;쀀𝓁mƀ;egল➪➬;檍;檏Ābu┪➳oĀ;rฟ➹;怚rok;䅂萀<;cdhilqrࠫ⟒☹⟜⟠⟥⟪⟰Āci⟗⟙;檦r;橹reå◲mes;拉arr;楶uest;橻ĀPi⟵⟹ar;榖ƀ;ef⠀भ᠛旃rĀdu⠇⠍shar;楊har;楦Āen⠗⠡rtneqq;쀀≨︀Å⠞܀Dacdefhilnopsu⡀⡅⢂⢎⢓⢠⢥⢨⣚⣢⣤ઃ⣳⤂Dot;戺Ȁclpr⡎⡒⡣⡽r耻¯䂯Āet⡗⡙;時Ā;e⡞⡟朠se»⡟Ā;sျ⡨toȀ;dluျ⡳⡷⡻owîҌefôएðᏑker;斮Āoy⢇⢌mma;権;䐼ash;怔asuredangle»ᘦr;쀀𝔪o;愧ƀcdn⢯⢴⣉ro耻µ䂵Ȁ;acdᑤ⢽⣀⣄sôᚧir;櫰ot肻·Ƶusƀ;bd⣒ᤃ⣓戒Ā;uᴼ⣘;横ţ⣞⣡p;櫛ò−ðઁĀdp⣩⣮els;抧f;쀀𝕞Āct⣸⣽r;쀀𝓂pos»ᖝƀ;lm⤉⤊⤍䎼timap;抸ఀGLRVabcdefghijlmoprstuvw⥂⥓⥾⦉⦘⧚⧩⨕⨚⩘⩝⪃⪕⪤⪨⬄⬇⭄⭿⮮ⰴⱧⱼ⳩Āgt⥇⥋;쀀⋙̸Ā;v⥐௏쀀≫⃒ƀelt⥚⥲⥶ftĀar⥡⥧rrow;懍ightarrow;懎;쀀⋘̸Ā;v⥻ే쀀≪⃒ightarrow;懏ĀDd⦎⦓ash;抯ash;抮ʀbcnpt⦣⦧⦬⦱⧌la»˞ute;䅄g;쀀∠⃒ʀ;Eiop඄⦼⧀⧅⧈;쀀⩰̸d;쀀≋̸s;䅉roø඄urĀ;a⧓⧔普lĀ;s⧓ସdz⧟\0⧣p肻 ଷmpĀ;e௹ఀʀaeouy⧴⧾⨃⨐⨓ǰ⧹\0⧻;橃on;䅈dil;䅆ngĀ;dൾ⨊ot;쀀⩭̸p;橂;䐽ash;怓΀;Aadqsxஒ⨩⨭⨻⩁⩅⩐rr;懗rĀhr⨳⨶k;椤Ā;oᏲᏰot;쀀≐̸uiöୣĀei⩊⩎ar;椨í஘istĀ;s஠டr;쀀𝔫ȀEest௅⩦⩹⩼ƀ;qs஼⩭௡ƀ;qs஼௅⩴lanô௢ií௪Ā;rஶ⪁»ஷƀAap⪊⪍⪑rò⥱rr;憮ar;櫲ƀ;svྍ⪜ྌĀ;d⪡⪢拼;拺cy;䑚΀AEadest⪷⪺⪾⫂⫅⫶⫹rò⥦;쀀≦̸rr;憚r;急Ȁ;fqs఻⫎⫣⫯tĀar⫔⫙rro÷⫁ightarro÷⪐ƀ;qs఻⪺⫪lanôౕĀ;sౕ⫴»శiíౝĀ;rవ⫾iĀ;eచథiäඐĀpt⬌⬑f;쀀𝕟膀¬;in⬙⬚⬶䂬nȀ;Edvஉ⬤⬨⬮;쀀⋹̸ot;쀀⋵̸ǡஉ⬳⬵;拷;拶iĀ;vಸ⬼ǡಸ⭁⭃;拾;拽ƀaor⭋⭣⭩rȀ;ast୻⭕⭚⭟lleì୻l;쀀⫽⃥;쀀∂̸lint;樔ƀ;ceಒ⭰⭳uåಥĀ;cಘ⭸Ā;eಒ⭽ñಘȀAait⮈⮋⮝⮧rò⦈rrƀ;cw⮔⮕⮙憛;쀀⤳̸;쀀↝̸ghtarrow»⮕riĀ;eೋೖ΀chimpqu⮽⯍⯙⬄୸⯤⯯Ȁ;cerല⯆ഷ⯉uå൅;쀀𝓃ortɭ⬅\0\0⯖ará⭖mĀ;e൮⯟Ā;q൴൳suĀbp⯫⯭å೸åഋƀbcp⯶ⰑⰙȀ;Ees⯿ⰀഢⰄ抄;쀀⫅̸etĀ;eഛⰋqĀ;qണⰀcĀ;eലⰗñസȀ;EesⰢⰣൟⰧ抅;쀀⫆̸etĀ;e൘ⰮqĀ;qൠⰣȀgilrⰽⰿⱅⱇìௗlde耻ñ䃱çృiangleĀlrⱒⱜeftĀ;eచⱚñదightĀ;eೋⱥñ೗Ā;mⱬⱭ䎽ƀ;esⱴⱵⱹ䀣ro;愖p;怇ҀDHadgilrsⲏⲔⲙⲞⲣⲰⲶⳓⳣash;抭arr;椄p;쀀≍⃒ash;抬ĀetⲨⲬ;쀀≥⃒;쀀>⃒nfin;槞ƀAetⲽⳁⳅrr;椂;쀀≤⃒Ā;rⳊⳍ쀀<⃒ie;쀀⊴⃒ĀAtⳘⳜrr;椃rie;쀀⊵⃒im;쀀∼⃒ƀAan⳰⳴ⴂrr;懖rĀhr⳺⳽k;椣Ā;oᏧᏥear;椧ቓ᪕\0\0\0\0\0\0\0\0\0\0\0\0\0ⴭ\0ⴸⵈⵠⵥ⵲ⶄᬇ\0\0ⶍⶫ\0ⷈⷎ\0ⷜ⸙⸫⸾⹃Ācsⴱ᪗ute耻ó䃳ĀiyⴼⵅrĀ;c᪞ⵂ耻ô䃴;䐾ʀabios᪠ⵒⵗLjⵚlac;䅑v;樸old;榼lig;䅓Ācr⵩⵭ir;榿;쀀𝔬ͯ⵹\0\0⵼\0ⶂn;䋛ave耻ò䃲;槁Ābmⶈ෴ar;榵Ȁacitⶕ⶘ⶥⶨrò᪀Āir⶝ⶠr;榾oss;榻nå๒;槀ƀaeiⶱⶵⶹcr;䅍ga;䏉ƀcdnⷀⷅǍron;䎿;榶pf;쀀𝕠ƀaelⷔ⷗ǒr;榷rp;榹΀;adiosvⷪⷫⷮ⸈⸍⸐⸖戨rò᪆Ȁ;efmⷷⷸ⸂⸅橝rĀ;oⷾⷿ愴f»ⷿ耻ª䂪耻º䂺gof;抶r;橖lope;橗;橛ƀclo⸟⸡⸧ò⸁ash耻ø䃸l;折iŬⸯ⸴de耻õ䃵esĀ;aǛ⸺s;樶ml耻ö䃶bar;挽ૡ⹞\0⹽\0⺀⺝\0⺢⺹\0\0⻋ຜ\0⼓\0\0⼫⾼\0⿈rȀ;astЃ⹧⹲຅脀¶;l⹭⹮䂶leìЃɩ⹸\0\0⹻m;櫳;櫽y;䐿rʀcimpt⺋⺏⺓ᡥ⺗nt;䀥od;䀮il;怰enk;怱r;쀀𝔭ƀimo⺨⺰⺴Ā;v⺭⺮䏆;䏕maô੶ne;明ƀ;tv⺿⻀⻈䏀chfork»´;䏖Āau⻏⻟nĀck⻕⻝kĀ;h⇴⻛;愎ö⇴sҀ;abcdemst⻳⻴ᤈ⻹⻽⼄⼆⼊⼎䀫cir;樣ir;樢Āouᵀ⼂;樥;橲n肻±ຝim;樦wo;樧ƀipu⼙⼠⼥ntint;樕f;쀀𝕡nd耻£䂣Ԁ;Eaceinosu່⼿⽁⽄⽇⾁⾉⾒⽾⾶;檳p;檷uå໙Ā;c໎⽌̀;acens່⽙⽟⽦⽨⽾pproø⽃urlyeñ໙ñ໎ƀaes⽯⽶⽺pprox;檹qq;檵im;拨iíໟmeĀ;s⾈ຮ怲ƀEas⽸⾐⽺ð⽵ƀdfp໬⾙⾯ƀals⾠⾥⾪lar;挮ine;挒urf;挓Ā;t໻⾴ï໻rel;抰Āci⿀⿅r;쀀𝓅;䏈ncsp;怈̀fiopsu⿚⋢⿟⿥⿫⿱r;쀀𝔮pf;쀀𝕢rime;恗cr;쀀𝓆ƀaeo⿸〉〓tĀei⿾々rnionóڰnt;樖stĀ;e【】䀿ñἙô༔઀ABHabcdefhilmnoprstux぀けさすムㄎㄫㅇㅢㅲㆎ㈆㈕㈤㈩㉘㉮㉲㊐㊰㊷ƀartぇおがròႳòϝail;検aròᱥar;楤΀cdenqrtとふへみわゔヌĀeuねぱ;쀀∽̱te;䅕iãᅮmptyv;榳gȀ;del࿑らるろ;榒;榥å࿑uo耻»䂻rր;abcfhlpstw࿜ガクシスゼゾダッデナp;極Ā;f࿠ゴs;椠;椳s;椞ë≝ð✮l;楅im;楴l;憣;憝Āaiパフil;椚oĀ;nホボ戶aló༞ƀabrョリヮrò៥rk;杳ĀakンヽcĀekヹ・;䁽;䁝Āes㄂㄄;榌lĀduㄊㄌ;榎;榐Ȁaeuyㄗㄜㄧㄩron;䅙Ādiㄡㄥil;䅗ì࿲âヺ;䑀Ȁclqsㄴㄷㄽㅄa;椷dhar;楩uoĀ;rȎȍh;憳ƀacgㅎㅟངlȀ;ipsླྀㅘㅛႜnåႻarôྩt;断ƀilrㅩဣㅮsht;楽;쀀𝔯ĀaoㅷㆆrĀduㅽㅿ»ѻĀ;l႑ㆄ;楬Ā;vㆋㆌ䏁;䏱ƀgns㆕ㇹㇼht̀ahlrstㆤㆰ㇂㇘㇤㇮rrowĀ;t࿜ㆭaéトarpoonĀduㆻㆿowîㅾp»႒eftĀah㇊㇐rrowó࿪arpoonóՑightarrows;應quigarro÷ニhreetimes;拌g;䋚ingdotseñἲƀahm㈍㈐㈓rò࿪aòՑ;怏oustĀ;a㈞㈟掱che»㈟mid;櫮Ȁabpt㈲㈽㉀㉒Ānr㈷㈺g;柭r;懾rëဃƀafl㉇㉊㉎r;榆;쀀𝕣us;樮imes;樵Āap㉝㉧rĀ;g㉣㉤䀩t;榔olint;樒arò㇣Ȁachq㉻㊀Ⴜ㊅quo;怺r;쀀𝓇Ābu・㊊oĀ;rȔȓƀhir㊗㊛㊠reåㇸmes;拊iȀ;efl㊪ၙᠡ㊫方tri;槎luhar;楨;愞ൡ㋕㋛㋟㌬㌸㍱\0㍺㎤\0\0㏬㏰\0㐨㑈㑚㒭㒱㓊㓱\0㘖\0\0㘳cute;䅛quï➺Ԁ;Eaceinpsyᇭ㋳㋵㋿㌂㌋㌏㌟㌦㌩;檴ǰ㋺\0㋼;檸on;䅡uåᇾĀ;dᇳ㌇il;䅟rc;䅝ƀEas㌖㌘㌛;檶p;檺im;择olint;樓iíሄ;䑁otƀ;be㌴ᵇ㌵担;橦΀Aacmstx㍆㍊㍗㍛㍞㍣㍭rr;懘rĀhr㍐㍒ë∨Ā;oਸ਼਴t耻§䂧i;䀻war;椩mĀin㍩ðnuóñt;朶rĀ;o㍶⁕쀀𝔰Ȁacoy㎂㎆㎑㎠rp;景Āhy㎋㎏cy;䑉;䑈rtɭ㎙\0\0㎜iäᑤaraì⹯耻­䂭Āgm㎨㎴maƀ;fv㎱㎲㎲䏃;䏂Ѐ;deglnprካ㏅㏉㏎㏖㏞㏡㏦ot;橪Ā;q኱ኰĀ;E㏓㏔檞;檠Ā;E㏛㏜檝;檟e;扆lus;樤arr;楲aròᄽȀaeit㏸㐈㐏㐗Āls㏽㐄lsetmé㍪hp;樳parsl;槤Ādlᑣ㐔e;挣Ā;e㐜㐝檪Ā;s㐢㐣檬;쀀⪬︀ƀflp㐮㐳㑂tcy;䑌Ā;b㐸㐹䀯Ā;a㐾㐿槄r;挿f;쀀𝕤aĀdr㑍ЂesĀ;u㑔㑕晠it»㑕ƀcsu㑠㑹㒟Āau㑥㑯pĀ;sᆈ㑫;쀀⊓︀pĀ;sᆴ㑵;쀀⊔︀uĀbp㑿㒏ƀ;esᆗᆜ㒆etĀ;eᆗ㒍ñᆝƀ;esᆨᆭ㒖etĀ;eᆨ㒝ñᆮƀ;afᅻ㒦ְrť㒫ֱ»ᅼaròᅈȀcemt㒹㒾㓂㓅r;쀀𝓈tmîñiì㐕aræᆾĀar㓎㓕rĀ;f㓔ឿ昆Āan㓚㓭ightĀep㓣㓪psiloîỠhé⺯s»⡒ʀbcmnp㓻㕞ሉ㖋㖎Ҁ;Edemnprs㔎㔏㔑㔕㔞㔣㔬㔱㔶抂;櫅ot;檽Ā;dᇚ㔚ot;櫃ult;櫁ĀEe㔨㔪;櫋;把lus;檿arr;楹ƀeiu㔽㕒㕕tƀ;en㔎㕅㕋qĀ;qᇚ㔏eqĀ;q㔫㔨m;櫇Ābp㕚㕜;櫕;櫓c̀;acensᇭ㕬㕲㕹㕻㌦pproø㋺urlyeñᇾñᇳƀaes㖂㖈㌛pproø㌚qñ㌗g;晪ڀ123;Edehlmnps㖩㖬㖯ሜ㖲㖴㗀㗉㗕㗚㗟㗨㗭耻¹䂹耻²䂲耻³䂳;櫆Āos㖹㖼t;檾ub;櫘Ā;dሢ㗅ot;櫄sĀou㗏㗒l;柉b;櫗arr;楻ult;櫂ĀEe㗤㗦;櫌;抋lus;櫀ƀeiu㗴㘉㘌tƀ;enሜ㗼㘂qĀ;qሢ㖲eqĀ;q㗧㗤m;櫈Ābp㘑㘓;櫔;櫖ƀAan㘜㘠㘭rr;懙rĀhr㘦㘨ë∮Ā;oਫ਩war;椪lig耻ß䃟௡㙑㙝㙠ዎ㙳㙹\0㙾㛂\0\0\0\0\0㛛㜃\0㜉㝬\0\0\0㞇ɲ㙖\0\0㙛get;挖;䏄rë๟ƀaey㙦㙫㙰ron;䅥dil;䅣;䑂lrec;挕r;쀀𝔱Ȁeiko㚆㚝㚵㚼Dz㚋\0㚑eĀ4fኄኁaƀ;sv㚘㚙㚛䎸ym;䏑Ācn㚢㚲kĀas㚨㚮pproø዁im»ኬsðኞĀas㚺㚮ð዁rn耻þ䃾Ǭ̟㛆⋧es膀×;bd㛏㛐㛘䃗Ā;aᤏ㛕r;樱;樰ƀeps㛡㛣㜀á⩍Ȁ;bcf҆㛬㛰㛴ot;挶ir;櫱Ā;o㛹㛼쀀𝕥rk;櫚á㍢rime;怴ƀaip㜏㜒㝤dåቈ΀adempst㜡㝍㝀㝑㝗㝜㝟ngleʀ;dlqr㜰㜱㜶㝀㝂斵own»ᶻeftĀ;e⠀㜾ñम;扜ightĀ;e㊪㝋ñၚot;旬inus;樺lus;樹b;槍ime;樻ezium;揢ƀcht㝲㝽㞁Āry㝷㝻;쀀𝓉;䑆cy;䑛rok;䅧Āio㞋㞎xô᝷headĀlr㞗㞠eftarro÷ࡏightarrow»ཝऀAHabcdfghlmoprstuw㟐㟓㟗㟤㟰㟼㠎㠜㠣㠴㡑㡝㡫㢩㣌㣒㣪㣶ròϭar;楣Ācr㟜㟢ute耻ú䃺òᅐrǣ㟪\0㟭y;䑞ve;䅭Āiy㟵㟺rc耻û䃻;䑃ƀabh㠃㠆㠋ròᎭlac;䅱aòᏃĀir㠓㠘sht;楾;쀀𝔲rave耻ù䃹š㠧㠱rĀlr㠬㠮»ॗ»ႃlk;斀Āct㠹㡍ɯ㠿\0\0㡊rnĀ;e㡅㡆挜r»㡆op;挏ri;旸Āal㡖㡚cr;䅫肻¨͉Āgp㡢㡦on;䅳f;쀀𝕦̀adhlsuᅋ㡸㡽፲㢑㢠ownáᎳarpoonĀlr㢈㢌efô㠭ighô㠯iƀ;hl㢙㢚㢜䏅»ᏺon»㢚parrows;懈ƀcit㢰㣄㣈ɯ㢶\0\0㣁rnĀ;e㢼㢽挝r»㢽op;挎ng;䅯ri;旹cr;쀀𝓊ƀdir㣙㣝㣢ot;拰lde;䅩iĀ;f㜰㣨»᠓Āam㣯㣲rò㢨l耻ü䃼angle;榧ހABDacdeflnoprsz㤜㤟㤩㤭㦵㦸㦽㧟㧤㧨㧳㧹㧽㨁㨠ròϷarĀ;v㤦㤧櫨;櫩asèϡĀnr㤲㤷grt;榜΀eknprst㓣㥆㥋㥒㥝㥤㦖appá␕othinçẖƀhir㓫⻈㥙opô⾵Ā;hᎷ㥢ïㆍĀiu㥩㥭gmá㎳Ābp㥲㦄setneqĀ;q㥽㦀쀀⊊︀;쀀⫋︀setneqĀ;q㦏㦒쀀⊋︀;쀀⫌︀Āhr㦛㦟etá㚜iangleĀlr㦪㦯eft»थight»ၑy;䐲ash»ံƀelr㧄㧒㧗ƀ;beⷪ㧋㧏ar;抻q;扚lip;拮Ābt㧜ᑨaòᑩr;쀀𝔳tré㦮suĀbp㧯㧱»ജ»൙pf;쀀𝕧roð໻tré㦴Ācu㨆㨋r;쀀𝓋Ābp㨐㨘nĀEe㦀㨖»㥾nĀEe㦒㨞»㦐igzag;榚΀cefoprs㨶㨻㩖㩛㩔㩡㩪irc;䅵Ādi㩀㩑Ābg㩅㩉ar;機eĀ;qᗺ㩏;扙erp;愘r;쀀𝔴pf;쀀𝕨Ā;eᑹ㩦atèᑹcr;쀀𝓌ૣណ㪇\0㪋\0㪐㪛\0\0㪝㪨㪫㪯\0\0㫃㫎\0㫘ៜ៟tré៑r;쀀𝔵ĀAa㪔㪗ròσrò৶;䎾ĀAa㪡㪤ròθrò৫að✓is;拻ƀdptឤ㪵㪾Āfl㪺ឩ;쀀𝕩imåឲĀAa㫇㫊ròώròਁĀcq㫒ីr;쀀𝓍Āpt៖㫜ré។Ѐacefiosu㫰㫽㬈㬌㬑㬕㬛㬡cĀuy㫶㫻te耻ý䃽;䑏Āiy㬂㬆rc;䅷;䑋n耻¥䂥r;쀀𝔶cy;䑗pf;쀀𝕪cr;쀀𝓎Ācm㬦㬩y;䑎l耻ÿ䃿Ԁacdefhiosw㭂㭈㭔㭘㭤㭩㭭㭴㭺㮀cute;䅺Āay㭍㭒ron;䅾;䐷ot;䅼Āet㭝㭡træᕟa;䎶r;쀀𝔷cy;䐶grarr;懝pf;쀀𝕫cr;쀀𝓏Ājn㮅㮇;怍j;怌'.split("").map((e=>e.charCodeAt(0)))),pE=new Uint16Array("Ȁaglq\tɭ\0\0p;䀦os;䀧t;䀾t;䀼uot;䀢".split("").map((e=>e.charCodeAt(0))));const gE=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),fE=null!==(rE=String.fromCodePoint)&&void 0!==rE?rE:function(e){let t="";return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|1023&e),t+=String.fromCharCode(e),t};var yE;!function(e){e[e.NUM=35]="NUM",e[e.SEMI=59]="SEMI",e[e.EQUALS=61]="EQUALS",e[e.ZERO=48]="ZERO",e[e.NINE=57]="NINE",e[e.LOWER_A=97]="LOWER_A",e[e.LOWER_F=102]="LOWER_F",e[e.LOWER_X=120]="LOWER_X",e[e.LOWER_Z=122]="LOWER_Z",e[e.UPPER_A=65]="UPPER_A",e[e.UPPER_F=70]="UPPER_F",e[e.UPPER_Z=90]="UPPER_Z"}(yE||(yE={}));var bE,vE,wE;function xE(e){return e>=yE.ZERO&&e<=yE.NINE}function kE(e){return e>=yE.UPPER_A&&e<=yE.UPPER_F||e>=yE.LOWER_A&&e<=yE.LOWER_F}function AE(e){return e===yE.EQUALS||function(e){return e>=yE.UPPER_A&&e<=yE.UPPER_Z||e>=yE.LOWER_A&&e<=yE.LOWER_Z||xE(e)}(e)}!function(e){e[e.VALUE_LENGTH=49152]="VALUE_LENGTH",e[e.BRANCH_LENGTH=16256]="BRANCH_LENGTH",e[e.JUMP_TABLE=127]="JUMP_TABLE"}(bE||(bE={})),function(e){e[e.EntityStart=0]="EntityStart",e[e.NumericStart=1]="NumericStart",e[e.NumericDecimal=2]="NumericDecimal",e[e.NumericHex=3]="NumericHex",e[e.NamedEntity=4]="NamedEntity"}(vE||(vE={})),function(e){e[e.Legacy=0]="Legacy",e[e.Strict=1]="Strict",e[e.Attribute=2]="Attribute"}(wE||(wE={}));class SE{constructor(e,t,a){this.decodeTree=e,this.emitCodePoint=t,this.errors=a,this.state=vE.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=wE.Strict}startEntity(e){this.decodeMode=e,this.state=vE.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1}write(e,t){switch(this.state){case vE.EntityStart:return e.charCodeAt(t)===yE.NUM?(this.state=vE.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=vE.NamedEntity,this.stateNamedEntity(e,t));case vE.NumericStart:return this.stateNumericStart(e,t);case vE.NumericDecimal:return this.stateNumericDecimal(e,t);case vE.NumericHex:return this.stateNumericHex(e,t);case vE.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(32|e.charCodeAt(t))===yE.LOWER_X?(this.state=vE.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=vE.NumericDecimal,this.stateNumericDecimal(e,t))}addToNumericResult(e,t,a,n){if(t!==a){const i=a-t;this.result=this.result*Math.pow(n,i)+parseInt(e.substr(t,i),n),this.consumed+=i}}stateNumericHex(e,t){const a=t;for(;t<e.length;){const n=e.charCodeAt(t);if(!xE(n)&&!kE(n))return this.addToNumericResult(e,a,t,16),this.emitNumericEntity(n,3);t+=1}return this.addToNumericResult(e,a,t,16),-1}stateNumericDecimal(e,t){const a=t;for(;t<e.length;){const n=e.charCodeAt(t);if(!xE(n))return this.addToNumericResult(e,a,t,10),this.emitNumericEntity(n,2);t+=1}return this.addToNumericResult(e,a,t,10),-1}emitNumericEntity(e,t){var a;if(this.consumed<=t)return null===(a=this.errors)||void 0===a||a.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===yE.SEMI)this.consumed+=1;else if(this.decodeMode===wE.Strict)return 0;return this.emitCodePoint(function(e){var t;return e>=55296&&e<=57343||e>1114111?65533:null!==(t=gE.get(e))&&void 0!==t?t:e}(this.result),this.consumed),this.errors&&(e!==yE.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){const{decodeTree:a}=this;let n=a[this.treeIndex],i=(n&bE.VALUE_LENGTH)>>14;for(;t<e.length;t++,this.excess++){const r=e.charCodeAt(t);if(this.treeIndex=_E(a,n,this.treeIndex+Math.max(1,i),r),this.treeIndex<0)return 0===this.result||this.decodeMode===wE.Attribute&&(0===i||AE(r))?0:this.emitNotTerminatedNamedEntity();if(n=a[this.treeIndex],i=(n&bE.VALUE_LENGTH)>>14,0!==i){if(r===yE.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==wE.Strict&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}}return-1}emitNotTerminatedNamedEntity(){var e;const{result:t,decodeTree:a}=this,n=(a[t]&bE.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,n,this.consumed),null===(e=this.errors)||void 0===e||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,a){const{decodeTree:n}=this;return this.emitCodePoint(1===t?n[e]&~bE.VALUE_LENGTH:n[e+1],a),3===t&&this.emitCodePoint(n[e+2],a),a}end(){var e;switch(this.state){case vE.NamedEntity:return 0===this.result||this.decodeMode===wE.Attribute&&this.result!==this.treeIndex?0:this.emitNotTerminatedNamedEntity();case vE.NumericDecimal:return this.emitNumericEntity(0,2);case vE.NumericHex:return this.emitNumericEntity(0,3);case vE.NumericStart:return null===(e=this.errors)||void 0===e||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case vE.EntityStart:return 0}}}function EE(e){let t="";const a=new SE(e,(e=>t+=fE(e)));return function(e,n){let i=0,r=0;for(;(r=e.indexOf("&",r))>=0;){t+=e.slice(i,r),a.startEntity(n);const o=a.write(e,r+1);if(o<0){i=r+a.end();break}i=r+o,r=0===o?i+1:i}const o=t+e.slice(i);return t="",o}}function _E(e,t,a,n){const i=(t&bE.BRANCH_LENGTH)>>7,r=t&bE.JUMP_TABLE;if(0===i)return 0!==r&&n===r?a:-1;if(r){const t=n-r;return t<0||t>=i?-1:e[a+t]-1}let o=a,s=o+i-1;for(;o<=s;){const t=o+s>>>1,a=e[t];if(a<n)o=t+1;else{if(!(a>n))return e[t+i];s=t-1}}return-1}const CE=EE(hE);function TE(e,t=wE.Legacy){return CE(e,t)}function PE(e){return"[object String]"===function(e){return Object.prototype.toString.call(e)}(e)}EE(pE);const OE=Object.prototype.hasOwnProperty;function DE(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){if(t){if("object"!=typeof t)throw new TypeError(t+"must be object");Object.keys(t).forEach((function(a){e[a]=t[a]}))}})),e}function ME(e,t,a){return[].concat(e.slice(0,t),a,e.slice(t+1))}function IE(e){return!(e>=55296&&e<=57343)&&(!(e>=64976&&e<=65007)&&(!!(65535&~e&&65534!=(65535&e))&&(!(e>=0&&e<=8)&&(11!==e&&(!(e>=14&&e<=31)&&(!(e>=127&&e<=159)&&!(e>1114111)))))))}function NE(e){if(e>65535){const t=55296+((e-=65536)>>10),a=56320+(1023&e);return String.fromCharCode(t,a)}return String.fromCharCode(e)}const jE=/\\([!"#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~])/g,zE=new RegExp(jE.source+"|"+/&([a-z#][a-z0-9]{1,31});/gi.source,"gi"),RE=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))$/i;function LE(e){return e.indexOf("\\")<0&&e.indexOf("&")<0?e:e.replace(zE,(function(e,t,a){return t||function(e,t){if(35===t.charCodeAt(0)&&RE.test(t)){const a="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10);return IE(a)?NE(a):e}const a=TE(e);return a!==e?a:e}(e,a)}))}const FE=/[&<>"]/,BE=/[&<>"]/g,HE={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"};function qE(e){return HE[e]}function UE(e){return FE.test(e)?e.replace(BE,qE):e}const WE=/[.?*+^$[\]\\(){}|-]/g;function VE(e){switch(e){case 9:case 32:return!0}return!1}function $E(e){if(e>=8192&&e<=8202)return!0;switch(e){case 9:case 10:case 11:case 12:case 13:case 32:case 160:case 5760:case 8239:case 8287:case 12288:return!0}return!1}function GE(e){return cE.test(e)||uE.test(e)}function KE(e){switch(e){case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 41:case 42:case 43:case 44:case 45:case 46:case 47:case 58:case 59:case 60:case 61:case 62:case 63:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 124:case 125:case 126:return!0;default:return!1}}function ZE(e){return e=e.trim().replace(/\s+/g," "),"Ṿ"==="ẞ".toLowerCase()&&(e=e.replace(/ẞ/g,"ß")),e.toLowerCase().toUpperCase()}const YE={mdurl:oE,ucmicro:mE};var XE=Object.freeze({__proto__:null,arrayReplaceAt:ME,assign:DE,escapeHtml:UE,escapeRE:function(e){return e.replace(WE,"\\$&")},fromCodePoint:NE,has:function(e,t){return OE.call(e,t)},isMdAsciiPunct:KE,isPunctChar:GE,isSpace:VE,isString:PE,isValidEntityCode:IE,isWhiteSpace:$E,lib:YE,normalizeReference:ZE,unescapeAll:LE,unescapeMd:function(e){return e.indexOf("\\")<0?e:e.replace(jE,"$1")}});var QE=Object.freeze({__proto__:null,parseLinkDestination:function(e,t,a){let n,i=t;const r={ok:!1,pos:0,str:""};if(60===e.charCodeAt(i)){for(i++;i<a;){if(n=e.charCodeAt(i),10===n)return r;if(60===n)return r;if(62===n)return r.pos=i+1,r.str=LE(e.slice(t+1,i)),r.ok=!0,r;92===n&&i+1<a?i+=2:i++}return r}let o=0;for(;i<a&&(n=e.charCodeAt(i),32!==n)&&!(n<32||127===n);)if(92===n&&i+1<a){if(32===e.charCodeAt(i+1))break;i+=2}else{if(40===n&&(o++,o>32))return r;if(41===n){if(0===o)break;o--}i++}return t===i||0!==o||(r.str=LE(e.slice(t,i)),r.pos=i,r.ok=!0),r},parseLinkLabel:function(e,t,a){let n,i,r,o;const s=e.posMax,l=e.pos;for(e.pos=t+1,n=1;e.pos<s;){if(r=e.src.charCodeAt(e.pos),93===r&&(n--,0===n)){i=!0;break}if(o=e.pos,e.md.inline.skipToken(e),91===r)if(o===e.pos-1)n++;else if(a)return e.pos=l,-1}let c=-1;return i&&(c=e.pos),e.pos=l,c},parseLinkTitle:function(e,t,a,n){let i,r=t;const o={ok:!1,can_continue:!1,pos:0,str:"",marker:0};if(n)o.str=n.str,o.marker=n.marker;else{if(r>=a)return o;let n=e.charCodeAt(r);if(34!==n&&39!==n&&40!==n)return o;t++,r++,40===n&&(n=41),o.marker=n}for(;r<a;){if(i=e.charCodeAt(r),i===o.marker)return o.pos=r+1,o.str+=LE(e.slice(t,r)),o.ok=!0,o;if(40===i&&41===o.marker)return o;92===i&&r+1<a&&r++,r++}return o.can_continue=!0,o.str+=LE(e.slice(t,r)),o}});const JE={};function e_(){this.rules=DE({},JE)}function t_(){this.__rules__=[],this.__cache__=null}function a_(e,t,a){this.type=e,this.tag=t,this.attrs=null,this.map=null,this.nesting=a,this.level=0,this.children=null,this.content="",this.markup="",this.info="",this.meta=null,this.block=!1,this.hidden=!1}function n_(e,t,a){this.src=e,this.env=a,this.tokens=[],this.inlineMode=!1,this.md=t}JE.code_inline=function(e,t,a,n,i){const r=e[t];return"<code"+i.renderAttrs(r)+">"+UE(r.content)+"</code>"},JE.code_block=function(e,t,a,n,i){const r=e[t];return"<pre"+i.renderAttrs(r)+"><code>"+UE(e[t].content)+"</code></pre>\n"},JE.fence=function(e,t,a,n,i){const r=e[t],o=r.info?LE(r.info).trim():"";let s,l="",c="";if(o){const e=o.split(/(\s+)/g);l=e[0],c=e.slice(2).join("")}if(s=a.highlight&&a.highlight(r.content,l,c)||UE(r.content),0===s.indexOf("<pre"))return s+"\n";if(o){const e=r.attrIndex("class"),t=r.attrs?r.attrs.slice():[];e<0?t.push(["class",a.langPrefix+l]):(t[e]=t[e].slice(),t[e][1]+=" "+a.langPrefix+l);const n={attrs:t};return`<pre><code${i.renderAttrs(n)}>${s}</code></pre>\n`}return`<pre><code${i.renderAttrs(r)}>${s}</code></pre>\n`},JE.image=function(e,t,a,n,i){const r=e[t];return r.attrs[r.attrIndex("alt")][1]=i.renderInlineAsText(r.children,a,n),i.renderToken(e,t,a)},JE.hardbreak=function(e,t,a){return a.xhtmlOut?"<br />\n":"<br>\n"},JE.softbreak=function(e,t,a){return a.breaks?a.xhtmlOut?"<br />\n":"<br>\n":"\n"},JE.text=function(e,t){return UE(e[t].content)},JE.html_block=function(e,t){return e[t].content},JE.html_inline=function(e,t){return e[t].content},e_.prototype.renderAttrs=function(e){let t,a,n;if(!e.attrs)return"";for(n="",t=0,a=e.attrs.length;t<a;t++)n+=" "+UE(e.attrs[t][0])+'="'+UE(e.attrs[t][1])+'"';return n},e_.prototype.renderToken=function(e,t,a){const n=e[t];let i="";if(n.hidden)return"";n.block&&-1!==n.nesting&&t&&e[t-1].hidden&&(i+="\n"),i+=(-1===n.nesting?"</":"<")+n.tag,i+=this.renderAttrs(n),0===n.nesting&&a.xhtmlOut&&(i+=" /");let r=!1;if(n.block&&(r=!0,1===n.nesting&&t+1<e.length)){const a=e[t+1];("inline"===a.type||a.hidden||-1===a.nesting&&a.tag===n.tag)&&(r=!1)}return i+=r?">\n":">",i},e_.prototype.renderInline=function(e,t,a){let n="";const i=this.rules;for(let r=0,o=e.length;r<o;r++){const o=e[r].type;void 0!==i[o]?n+=i[o](e,r,t,a,this):n+=this.renderToken(e,r,t)}return n},e_.prototype.renderInlineAsText=function(e,t,a){let n="";for(let i=0,r=e.length;i<r;i++)switch(e[i].type){case"text":case"html_inline":case"html_block":n+=e[i].content;break;case"image":n+=this.renderInlineAsText(e[i].children,t,a);break;case"softbreak":case"hardbreak":n+="\n"}return n},e_.prototype.render=function(e,t,a){let n="";const i=this.rules;for(let r=0,o=e.length;r<o;r++){const o=e[r].type;"inline"===o?n+=this.renderInline(e[r].children,t,a):void 0!==i[o]?n+=i[o](e,r,t,a,this):n+=this.renderToken(e,r,t,a)}return n},t_.prototype.__find__=function(e){for(let t=0;t<this.__rules__.length;t++)if(this.__rules__[t].name===e)return t;return-1},t_.prototype.__compile__=function(){const e=this,t=[""];e.__rules__.forEach((function(e){e.enabled&&e.alt.forEach((function(e){t.indexOf(e)<0&&t.push(e)}))})),e.__cache__={},t.forEach((function(t){e.__cache__[t]=[],e.__rules__.forEach((function(a){a.enabled&&(t&&a.alt.indexOf(t)<0||e.__cache__[t].push(a.fn))}))}))},t_.prototype.at=function(e,t,a){const n=this.__find__(e),i=a||{};if(-1===n)throw new Error("Parser rule not found: "+e);this.__rules__[n].fn=t,this.__rules__[n].alt=i.alt||[],this.__cache__=null},t_.prototype.before=function(e,t,a,n){const i=this.__find__(e),r=n||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i,0,{name:t,enabled:!0,fn:a,alt:r.alt||[]}),this.__cache__=null},t_.prototype.after=function(e,t,a,n){const i=this.__find__(e),r=n||{};if(-1===i)throw new Error("Parser rule not found: "+e);this.__rules__.splice(i+1,0,{name:t,enabled:!0,fn:a,alt:r.alt||[]}),this.__cache__=null},t_.prototype.push=function(e,t,a){const n=a||{};this.__rules__.push({name:e,enabled:!0,fn:t,alt:n.alt||[]}),this.__cache__=null},t_.prototype.enable=function(e,t){Array.isArray(e)||(e=[e]);const a=[];return e.forEach((function(e){const n=this.__find__(e);if(n<0){if(t)return;throw new Error("Rules manager: invalid rule name "+e)}this.__rules__[n].enabled=!0,a.push(e)}),this),this.__cache__=null,a},t_.prototype.enableOnly=function(e,t){Array.isArray(e)||(e=[e]),this.__rules__.forEach((function(e){e.enabled=!1})),this.enable(e,t)},t_.prototype.disable=function(e,t){Array.isArray(e)||(e=[e]);const a=[];return e.forEach((function(e){const n=this.__find__(e);if(n<0){if(t)return;throw new Error("Rules manager: invalid rule name "+e)}this.__rules__[n].enabled=!1,a.push(e)}),this),this.__cache__=null,a},t_.prototype.getRules=function(e){return null===this.__cache__&&this.__compile__(),this.__cache__[e]||[]},a_.prototype.attrIndex=function(e){if(!this.attrs)return-1;const t=this.attrs;for(let a=0,n=t.length;a<n;a++)if(t[a][0]===e)return a;return-1},a_.prototype.attrPush=function(e){this.attrs?this.attrs.push(e):this.attrs=[e]},a_.prototype.attrSet=function(e,t){const a=this.attrIndex(e),n=[e,t];a<0?this.attrPush(n):this.attrs[a]=n},a_.prototype.attrGet=function(e){const t=this.attrIndex(e);let a=null;return t>=0&&(a=this.attrs[t][1]),a},a_.prototype.attrJoin=function(e,t){const a=this.attrIndex(e);a<0?this.attrPush([e,t]):this.attrs[a][1]=this.attrs[a][1]+" "+t},n_.prototype.Token=a_;const i_=/\r\n?|\n/g,r_=/\0/g;function o_(e){return/^<a[>\s]/i.test(e)}function s_(e){return/^<\/a\s*>/i.test(e)}const l_=/\+-|\.\.|\?\?\?\?|!!!!|,,|--/,c_=/\((c|tm|r)\)/i,u_=/\((c|tm|r)\)/gi,d_={c:"©",r:"®",tm:"™"};function m_(e,t){return d_[t.toLowerCase()]}function h_(e){let t=0;for(let a=e.length-1;a>=0;a--){const n=e[a];"text"!==n.type||t||(n.content=n.content.replace(u_,m_)),"link_open"===n.type&&"auto"===n.info&&t--,"link_close"===n.type&&"auto"===n.info&&t++}}function p_(e){let t=0;for(let a=e.length-1;a>=0;a--){const n=e[a];"text"!==n.type||t||l_.test(n.content)&&(n.content=n.content.replace(/\+-/g,"±").replace(/\.{2,}/g,"…").replace(/([?!])…/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---(?=[^-]|$)/gm,"$1—").replace(/(^|\s)--(?=\s|$)/gm,"$1–").replace(/(^|[^-\s])--(?=[^-\s]|$)/gm,"$1–")),"link_open"===n.type&&"auto"===n.info&&t--,"link_close"===n.type&&"auto"===n.info&&t++}}const g_=/['"]/,f_=/['"]/g,y_="’";function b_(e,t,a){return e.slice(0,t)+a+e.slice(t+1)}function v_(e,t){let a;const n=[];for(let i=0;i<e.length;i++){const r=e[i],o=e[i].level;for(a=n.length-1;a>=0&&!(n[a].level<=o);a--);if(n.length=a+1,"text"!==r.type)continue;let s=r.content,l=0,c=s.length;e:for(;l<c;){f_.lastIndex=l;const u=f_.exec(s);if(!u)break;let d=!0,m=!0;l=u.index+1;const h="'"===u[0];let p=32;if(u.index-1>=0)p=s.charCodeAt(u.index-1);else for(a=i-1;a>=0&&("softbreak"!==e[a].type&&"hardbreak"!==e[a].type);a--)if(e[a].content){p=e[a].content.charCodeAt(e[a].content.length-1);break}let g=32;if(l<c)g=s.charCodeAt(l);else for(a=i+1;a<e.length&&("softbreak"!==e[a].type&&"hardbreak"!==e[a].type);a++)if(e[a].content){g=e[a].content.charCodeAt(0);break}const f=KE(p)||GE(String.fromCharCode(p)),y=KE(g)||GE(String.fromCharCode(g)),b=$E(p),v=$E(g);if(v?d=!1:y&&(b||f||(d=!1)),b?m=!1:f&&(v||y||(m=!1)),34===g&&'"'===u[0]&&p>=48&&p<=57&&(m=d=!1),d&&m&&(d=f,m=y),d||m){if(m)for(a=n.length-1;a>=0;a--){let d=n[a];if(n[a].level<o)break;if(d.single===h&&n[a].level===o){let o,m;d=n[a],h?(o=t.md.options.quotes[2],m=t.md.options.quotes[3]):(o=t.md.options.quotes[0],m=t.md.options.quotes[1]),r.content=b_(r.content,u.index,m),e[d.token].content=b_(e[d.token].content,d.pos,o),l+=m.length-1,d.token===i&&(l+=o.length-1),s=r.content,c=s.length,n.length=a;continue e}}d?n.push({token:i,pos:u.index,single:h,level:o}):m&&h&&(r.content=b_(r.content,u.index,y_))}else h&&(r.content=b_(r.content,u.index,y_))}}}const w_=[["normalize",function(e){let t;t=e.src.replace(i_,"\n"),t=t.replace(r_,"�"),e.src=t}],["block",function(e){let t;e.inlineMode?(t=new e.Token("inline","",0),t.content=e.src,t.map=[0,1],t.children=[],e.tokens.push(t)):e.md.block.parse(e.src,e.md,e.env,e.tokens)}],["inline",function(e){const t=e.tokens;for(let a=0,n=t.length;a<n;a++){const n=t[a];"inline"===n.type&&e.md.inline.parse(n.content,e.md,e.env,n.children)}}],["linkify",function(e){const t=e.tokens;if(e.md.options.linkify)for(let a=0,n=t.length;a<n;a++){if("inline"!==t[a].type||!e.md.linkify.pretest(t[a].content))continue;let n=t[a].children,i=0;for(let r=n.length-1;r>=0;r--){const o=n[r];if("link_close"!==o.type){if("html_inline"===o.type&&(o_(o.content)&&i>0&&i--,s_(o.content)&&i++),!(i>0)&&"text"===o.type&&e.md.linkify.test(o.content)){const i=o.content;let s=e.md.linkify.match(i);const l=[];let c=o.level,u=0;s.length>0&&0===s[0].index&&r>0&&"text_special"===n[r-1].type&&(s=s.slice(1));for(let t=0;t<s.length;t++){const a=s[t].url,n=e.md.normalizeLink(a);if(!e.md.validateLink(n))continue;let r=s[t].text;r=s[t].schema?"mailto:"!==s[t].schema||/^mailto:/i.test(r)?e.md.normalizeLinkText(r):e.md.normalizeLinkText("mailto:"+r).replace(/^mailto:/,""):e.md.normalizeLinkText("http://"+r).replace(/^http:\/\//,"");const o=s[t].index;if(o>u){const t=new e.Token("text","",0);t.content=i.slice(u,o),t.level=c,l.push(t)}const d=new e.Token("link_open","a",1);d.attrs=[["href",n]],d.level=c++,d.markup="linkify",d.info="auto",l.push(d);const m=new e.Token("text","",0);m.content=r,m.level=c,l.push(m);const h=new e.Token("link_close","a",-1);h.level=--c,h.markup="linkify",h.info="auto",l.push(h),u=s[t].lastIndex}if(u<i.length){const t=new e.Token("text","",0);t.content=i.slice(u),t.level=c,l.push(t)}t[a].children=n=ME(n,r,l)}}else for(r--;n[r].level!==o.level&&"link_open"!==n[r].type;)r--}}}],["replacements",function(e){let t;if(e.md.options.typographer)for(t=e.tokens.length-1;t>=0;t--)"inline"===e.tokens[t].type&&(c_.test(e.tokens[t].content)&&h_(e.tokens[t].children),l_.test(e.tokens[t].content)&&p_(e.tokens[t].children))}],["smartquotes",function(e){if(e.md.options.typographer)for(let t=e.tokens.length-1;t>=0;t--)"inline"===e.tokens[t].type&&g_.test(e.tokens[t].content)&&v_(e.tokens[t].children,e)}],["text_join",function(e){let t,a;const n=e.tokens,i=n.length;for(let e=0;e<i;e++){if("inline"!==n[e].type)continue;const i=n[e].children,r=i.length;for(t=0;t<r;t++)"text_special"===i[t].type&&(i[t].type="text");for(t=a=0;t<r;t++)"text"===i[t].type&&t+1<r&&"text"===i[t+1].type?i[t+1].content=i[t].content+i[t+1].content:(t!==a&&(i[a]=i[t]),a++);t!==a&&(i.length=a)}}]];function x_(){this.ruler=new t_;for(let e=0;e<w_.length;e++)this.ruler.push(w_[e][0],w_[e][1])}function k_(e,t,a,n){this.src=e,this.md=t,this.env=a,this.tokens=n,this.bMarks=[],this.eMarks=[],this.tShift=[],this.sCount=[],this.bsCount=[],this.blkIndent=0,this.line=0,this.lineMax=0,this.tight=!1,this.ddIndent=-1,this.listIndent=-1,this.parentType="root",this.level=0;const i=this.src;for(let e=0,t=0,a=0,n=0,r=i.length,o=!1;t<r;t++){const s=i.charCodeAt(t);if(!o){if(VE(s)){a++,9===s?n+=4-n%4:n++;continue}o=!0}10!==s&&t!==r-1||(10!==s&&t++,this.bMarks.push(e),this.eMarks.push(t),this.tShift.push(a),this.sCount.push(n),this.bsCount.push(0),o=!1,a=0,n=0,e=t+1)}this.bMarks.push(i.length),this.eMarks.push(i.length),this.tShift.push(0),this.sCount.push(0),this.bsCount.push(0),this.lineMax=this.bMarks.length-1}x_.prototype.process=function(e){const t=this.ruler.getRules("");for(let a=0,n=t.length;a<n;a++)t[a](e)},x_.prototype.State=n_,k_.prototype.push=function(e,t,a){const n=new a_(e,t,a);return n.block=!0,a<0&&this.level--,n.level=this.level,a>0&&this.level++,this.tokens.push(n),n},k_.prototype.isEmpty=function(e){return this.bMarks[e]+this.tShift[e]>=this.eMarks[e]},k_.prototype.skipEmptyLines=function(e){for(let t=this.lineMax;e<t&&!(this.bMarks[e]+this.tShift[e]<this.eMarks[e]);e++);return e},k_.prototype.skipSpaces=function(e){for(let t=this.src.length;e<t;e++){if(!VE(this.src.charCodeAt(e)))break}return e},k_.prototype.skipSpacesBack=function(e,t){if(e<=t)return e;for(;e>t;)if(!VE(this.src.charCodeAt(--e)))return e+1;return e},k_.prototype.skipChars=function(e,t){for(let a=this.src.length;e<a&&this.src.charCodeAt(e)===t;e++);return e},k_.prototype.skipCharsBack=function(e,t,a){if(e<=a)return e;for(;e>a;)if(t!==this.src.charCodeAt(--e))return e+1;return e},k_.prototype.getLines=function(e,t,a,n){if(e>=t)return"";const i=new Array(t-e);for(let r=0,o=e;o<t;o++,r++){let e=0;const s=this.bMarks[o];let l,c=s;for(l=o+1<t||n?this.eMarks[o]+1:this.eMarks[o];c<l&&e<a;){const t=this.src.charCodeAt(c);if(VE(t))9===t?e+=4-(e+this.bsCount[o])%4:e++;else{if(!(c-s<this.tShift[o]))break;e++}c++}i[r]=e>a?new Array(e-a+1).join(" ")+this.src.slice(c,l):this.src.slice(c,l)}return i.join("")},k_.prototype.Token=a_;function A_(e,t){const a=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];return e.src.slice(a,n)}function S_(e){const t=[],a=e.length;let n=0,i=e.charCodeAt(n),r=!1,o=0,s="";for(;n<a;)124===i&&(r?(s+=e.substring(o,n-1),o=n):(t.push(s+e.substring(o,n)),s="",o=n+1)),r=92===i,n++,i=e.charCodeAt(n);return t.push(s+e.substring(o)),t}function E_(e,t){const a=e.eMarks[t];let n=e.bMarks[t]+e.tShift[t];const i=e.src.charCodeAt(n++);if(42!==i&&45!==i&&43!==i)return-1;if(n<a){if(!VE(e.src.charCodeAt(n)))return-1}return n}function __(e,t){const a=e.bMarks[t]+e.tShift[t],n=e.eMarks[t];let i=a;if(i+1>=n)return-1;let r=e.src.charCodeAt(i++);if(r<48||r>57)return-1;for(;;){if(i>=n)return-1;if(r=e.src.charCodeAt(i++),!(r>=48&&r<=57)){if(41===r||46===r)break;return-1}if(i-a>=10)return-1}return i<n&&(r=e.src.charCodeAt(i),!VE(r))?-1:i}const C_="<[A-Za-z][A-Za-z0-9\\-]*(?:\\s+[a-zA-Z_:][a-zA-Z0-9:._-]*(?:\\s*=\\s*(?:[^\"'=<>`\\x00-\\x20]+|'[^']*'|\"[^\"]*\"))?)*\\s*\\/?>",T_="<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>",P_=new RegExp("^(?:"+C_+"|"+T_+"|\x3c!---?>|\x3c!--(?:[^-]|-[^-]|--[^>])*--\x3e|<[?][\\s\\S]*?[?]>|<![A-Za-z][^>]*>|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>)"),O_=new RegExp("^(?:"+C_+"|"+T_+")"),D_=[[/^<(script|pre|style|textarea)(?=(\s|>|$))/i,/<\/(script|pre|style|textarea)>/i,!0],[/^<!--/,/-->/,!0],[/^<\?/,/\?>/,!0],[/^<![A-Z]/,/>/,!0],[/^<!\[CDATA\[/,/\]\]>/,!0],[new RegExp("^</?("+["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"].join("|")+")(?=(\\s|/?>|$))","i"),/^$/,!0],[new RegExp(O_.source+"\\s*$"),/^$/,!1]];const M_=[["table",function(e,t,a,n){if(t+2>a)return!1;let i=t+1;if(e.sCount[i]<e.blkIndent)return!1;if(e.sCount[i]-e.blkIndent>=4)return!1;let r=e.bMarks[i]+e.tShift[i];if(r>=e.eMarks[i])return!1;const o=e.src.charCodeAt(r++);if(124!==o&&45!==o&&58!==o)return!1;if(r>=e.eMarks[i])return!1;const s=e.src.charCodeAt(r++);if(124!==s&&45!==s&&58!==s&&!VE(s))return!1;if(45===o&&VE(s))return!1;for(;r<e.eMarks[i];){const t=e.src.charCodeAt(r);if(124!==t&&45!==t&&58!==t&&!VE(t))return!1;r++}let l=A_(e,t+1),c=l.split("|");const u=[];for(let e=0;e<c.length;e++){const t=c[e].trim();if(!t){if(0===e||e===c.length-1)continue;return!1}if(!/^:?-+:?$/.test(t))return!1;58===t.charCodeAt(t.length-1)?u.push(58===t.charCodeAt(0)?"center":"right"):58===t.charCodeAt(0)?u.push("left"):u.push("")}if(l=A_(e,t).trim(),-1===l.indexOf("|"))return!1;if(e.sCount[t]-e.blkIndent>=4)return!1;c=S_(l),c.length&&""===c[0]&&c.shift(),c.length&&""===c[c.length-1]&&c.pop();const d=c.length;if(0===d||d!==u.length)return!1;if(n)return!0;const m=e.parentType;e.parentType="table";const h=e.md.block.ruler.getRules("blockquote"),p=[t,0];e.push("table_open","table",1).map=p,e.push("thead_open","thead",1).map=[t,t+1],e.push("tr_open","tr",1).map=[t,t+1];for(let t=0;t<c.length;t++){const a=e.push("th_open","th",1);u[t]&&(a.attrs=[["style","text-align:"+u[t]]]);const n=e.push("inline","",0);n.content=c[t].trim(),n.children=[],e.push("th_close","th",-1)}let g;e.push("tr_close","tr",-1),e.push("thead_close","thead",-1);let f=0;for(i=t+2;i<a&&!(e.sCount[i]<e.blkIndent);i++){let n=!1;for(let t=0,r=h.length;t<r;t++)if(h[t](e,i,a,!0)){n=!0;break}if(n)break;if(l=A_(e,i).trim(),!l)break;if(e.sCount[i]-e.blkIndent>=4)break;if(c=S_(l),c.length&&""===c[0]&&c.shift(),c.length&&""===c[c.length-1]&&c.pop(),f+=d-c.length,f>65536)break;if(i===t+2){e.push("tbody_open","tbody",1).map=g=[t+2,0]}e.push("tr_open","tr",1).map=[i,i+1];for(let t=0;t<d;t++){const a=e.push("td_open","td",1);u[t]&&(a.attrs=[["style","text-align:"+u[t]]]);const n=e.push("inline","",0);n.content=c[t]?c[t].trim():"",n.children=[],e.push("td_close","td",-1)}e.push("tr_close","tr",-1)}return g&&(e.push("tbody_close","tbody",-1),g[1]=i),e.push("table_close","table",-1),p[1]=i,e.parentType=m,e.line=i,!0},["paragraph","reference"]],["code",function(e,t,a){if(e.sCount[t]-e.blkIndent<4)return!1;let n=t+1,i=n;for(;n<a;)if(e.isEmpty(n))n++;else{if(!(e.sCount[n]-e.blkIndent>=4))break;n++,i=n}e.line=i;const r=e.push("code_block","code",0);return r.content=e.getLines(t,i,4+e.blkIndent,!1)+"\n",r.map=[t,e.line],!0}],["fence",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(i+3>r)return!1;const o=e.src.charCodeAt(i);if(126!==o&&96!==o)return!1;let s=i;i=e.skipChars(i,o);let l=i-s;if(l<3)return!1;const c=e.src.slice(s,i),u=e.src.slice(i,r);if(96===o&&u.indexOf(String.fromCharCode(o))>=0)return!1;if(n)return!0;let d=t,m=!1;for(;(d++,!(d>=a))&&(i=s=e.bMarks[d]+e.tShift[d],r=e.eMarks[d],!(i<r&&e.sCount[d]<e.blkIndent));)if(e.src.charCodeAt(i)===o&&!(e.sCount[d]-e.blkIndent>=4||(i=e.skipChars(i,o),i-s<l||(i=e.skipSpaces(i),i<r)))){m=!0;break}l=e.sCount[t],e.line=d+(m?1:0);const h=e.push("fence","code",0);return h.info=u,h.content=e.getLines(t+1,d,l,!0),h.markup=c,h.map=[t,e.line],!0},["paragraph","reference","blockquote","list"]],["blockquote",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];const o=e.lineMax;if(e.sCount[t]-e.blkIndent>=4)return!1;if(62!==e.src.charCodeAt(i))return!1;if(n)return!0;const s=[],l=[],c=[],u=[],d=e.md.block.ruler.getRules("blockquote"),m=e.parentType;e.parentType="blockquote";let h,p=!1;for(h=t;h<a;h++){const t=e.sCount[h]<e.blkIndent;if(i=e.bMarks[h]+e.tShift[h],r=e.eMarks[h],i>=r)break;if(62===e.src.charCodeAt(i++)&&!t){let t,a,n=e.sCount[h]+1;32===e.src.charCodeAt(i)?(i++,n++,a=!1,t=!0):9===e.src.charCodeAt(i)?(t=!0,(e.bsCount[h]+n)%4==3?(i++,n++,a=!1):a=!0):t=!1;let o=n;for(s.push(e.bMarks[h]),e.bMarks[h]=i;i<r;){const t=e.src.charCodeAt(i);if(!VE(t))break;9===t?o+=4-(o+e.bsCount[h]+(a?1:0))%4:o++,i++}p=i>=r,l.push(e.bsCount[h]),e.bsCount[h]=e.sCount[h]+1+(t?1:0),c.push(e.sCount[h]),e.sCount[h]=o-n,u.push(e.tShift[h]),e.tShift[h]=i-e.bMarks[h];continue}if(p)break;let n=!1;for(let t=0,i=d.length;t<i;t++)if(d[t](e,h,a,!0)){n=!0;break}if(n){e.lineMax=h,0!==e.blkIndent&&(s.push(e.bMarks[h]),l.push(e.bsCount[h]),u.push(e.tShift[h]),c.push(e.sCount[h]),e.sCount[h]-=e.blkIndent);break}s.push(e.bMarks[h]),l.push(e.bsCount[h]),u.push(e.tShift[h]),c.push(e.sCount[h]),e.sCount[h]=-1}const g=e.blkIndent;e.blkIndent=0;const f=e.push("blockquote_open","blockquote",1);f.markup=">";const y=[t,0];f.map=y,e.md.block.tokenize(e,t,h),e.push("blockquote_close","blockquote",-1).markup=">",e.lineMax=o,e.parentType=m,y[1]=e.line;for(let a=0;a<u.length;a++)e.bMarks[a+t]=s[a],e.tShift[a+t]=u[a],e.sCount[a+t]=c[a],e.bsCount[a+t]=l[a];return e.blkIndent=g,!0},["paragraph","reference","blockquote","list"]],["hr",function(e,t,a,n){const i=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let r=e.bMarks[t]+e.tShift[t];const o=e.src.charCodeAt(r++);if(42!==o&&45!==o&&95!==o)return!1;let s=1;for(;r<i;){const t=e.src.charCodeAt(r++);if(t!==o&&!VE(t))return!1;t===o&&s++}if(s<3)return!1;if(n)return!0;e.line=t+1;const l=e.push("hr","hr",0);return l.map=[t,e.line],l.markup=Array(s+1).join(String.fromCharCode(o)),!0},["paragraph","reference","blockquote","list"]],["list",function(e,t,a,n){let i,r,o,s,l=t,c=!0;if(e.sCount[l]-e.blkIndent>=4)return!1;if(e.listIndent>=0&&e.sCount[l]-e.listIndent>=4&&e.sCount[l]<e.blkIndent)return!1;let u,d,m,h=!1;if(n&&"paragraph"===e.parentType&&e.sCount[l]>=e.blkIndent&&(h=!0),(m=__(e,l))>=0){if(u=!0,o=e.bMarks[l]+e.tShift[l],d=Number(e.src.slice(o,m-1)),h&&1!==d)return!1}else{if(!((m=E_(e,l))>=0))return!1;u=!1}if(h&&e.skipSpaces(m)>=e.eMarks[l])return!1;if(n)return!0;const p=e.src.charCodeAt(m-1),g=e.tokens.length;u?(s=e.push("ordered_list_open","ol",1),1!==d&&(s.attrs=[["start",d]])):s=e.push("bullet_list_open","ul",1);const f=[l,0];s.map=f,s.markup=String.fromCharCode(p);let y=!1;const b=e.md.block.ruler.getRules("list"),v=e.parentType;for(e.parentType="list";l<a;){r=m,i=e.eMarks[l];const t=e.sCount[l]+m-(e.bMarks[l]+e.tShift[l]);let n=t;for(;r<i;){const t=e.src.charCodeAt(r);if(9===t)n+=4-(n+e.bsCount[l])%4;else{if(32!==t)break;n++}r++}const d=r;let h;h=d>=i?1:n-t,h>4&&(h=1);const g=t+h;s=e.push("list_item_open","li",1),s.markup=String.fromCharCode(p);const f=[l,0];s.map=f,u&&(s.info=e.src.slice(o,m-1));const v=e.tight,w=e.tShift[l],x=e.sCount[l],k=e.listIndent;if(e.listIndent=e.blkIndent,e.blkIndent=g,e.tight=!0,e.tShift[l]=d-e.bMarks[l],e.sCount[l]=n,d>=i&&e.isEmpty(l+1)?e.line=Math.min(e.line+2,a):e.md.block.tokenize(e,l,a,!0),e.tight&&!y||(c=!1),y=e.line-l>1&&e.isEmpty(e.line-1),e.blkIndent=e.listIndent,e.listIndent=k,e.tShift[l]=w,e.sCount[l]=x,e.tight=v,s=e.push("list_item_close","li",-1),s.markup=String.fromCharCode(p),l=e.line,f[1]=l,l>=a)break;if(e.sCount[l]<e.blkIndent)break;if(e.sCount[l]-e.blkIndent>=4)break;let A=!1;for(let t=0,n=b.length;t<n;t++)if(b[t](e,l,a,!0)){A=!0;break}if(A)break;if(u){if(m=__(e,l),m<0)break;o=e.bMarks[l]+e.tShift[l]}else if(m=E_(e,l),m<0)break;if(p!==e.src.charCodeAt(m-1))break}return s=u?e.push("ordered_list_close","ol",-1):e.push("bullet_list_close","ul",-1),s.markup=String.fromCharCode(p),f[1]=l,e.line=l,e.parentType=v,c&&function(e,t){const a=e.level+2;for(let n=t+2,i=e.tokens.length-2;n<i;n++)e.tokens[n].level===a&&"paragraph_open"===e.tokens[n].type&&(e.tokens[n+2].hidden=!0,e.tokens[n].hidden=!0,n+=2)}(e,g),!0},["paragraph","reference","blockquote"]],["reference",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t],o=t+1;if(e.sCount[t]-e.blkIndent>=4)return!1;if(91!==e.src.charCodeAt(i))return!1;function s(t){const a=e.lineMax;if(t>=a||e.isEmpty(t))return null;let n=!1;if(e.sCount[t]-e.blkIndent>3&&(n=!0),e.sCount[t]<0&&(n=!0),!n){const n=e.md.block.ruler.getRules("reference"),i=e.parentType;e.parentType="reference";let r=!1;for(let i=0,o=n.length;i<o;i++)if(n[i](e,t,a,!0)){r=!0;break}if(e.parentType=i,r)return null}const i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];return e.src.slice(i,r+1)}let l=e.src.slice(i,r+1);r=l.length;let c=-1;for(i=1;i<r;i++){const e=l.charCodeAt(i);if(91===e)return!1;if(93===e){c=i;break}if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(92===e&&(i++,i<r&&10===l.charCodeAt(i))){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}}if(c<0||58!==l.charCodeAt(c+1))return!1;for(i=c+2;i<r;i++){const e=l.charCodeAt(i);if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(!VE(e))break}const u=e.md.helpers.parseLinkDestination(l,i,r);if(!u.ok)return!1;const d=e.md.normalizeLink(u.str);if(!e.md.validateLink(d))return!1;i=u.pos;const m=i,h=o,p=i;for(;i<r;i++){const e=l.charCodeAt(i);if(10===e){const e=s(o);null!==e&&(l+=e,r=l.length,o++)}else if(!VE(e))break}let g,f=e.md.helpers.parseLinkTitle(l,i,r);for(;f.can_continue;){const t=s(o);if(null===t)break;l+=t,i=r,r=l.length,o++,f=e.md.helpers.parseLinkTitle(l,i,r,f)}for(i<r&&p!==i&&f.ok?(g=f.str,i=f.pos):(g="",i=m,o=h);i<r;){if(!VE(l.charCodeAt(i)))break;i++}if(i<r&&10!==l.charCodeAt(i)&&g)for(g="",i=m,o=h;i<r;){if(!VE(l.charCodeAt(i)))break;i++}if(i<r&&10!==l.charCodeAt(i))return!1;const y=ZE(l.slice(1,c));return!!y&&(n||(void 0===e.env.references&&(e.env.references={}),void 0===e.env.references[y]&&(e.env.references[y]={title:g,href:d}),e.line=o),!0)}],["html_block",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;if(!e.md.options.html)return!1;if(60!==e.src.charCodeAt(i))return!1;let o=e.src.slice(i,r),s=0;for(;s<D_.length&&!D_[s][0].test(o);s++);if(s===D_.length)return!1;if(n)return D_[s][2];let l=t+1;if(!D_[s][1].test(o))for(;l<a&&!(e.sCount[l]<e.blkIndent);l++)if(i=e.bMarks[l]+e.tShift[l],r=e.eMarks[l],o=e.src.slice(i,r),D_[s][1].test(o)){0!==o.length&&l++;break}e.line=l;const c=e.push("html_block","",0);return c.map=[t,l],c.content=e.getLines(t,l,e.blkIndent,!0),!0},["paragraph","reference","blockquote"]],["heading",function(e,t,a,n){let i=e.bMarks[t]+e.tShift[t],r=e.eMarks[t];if(e.sCount[t]-e.blkIndent>=4)return!1;let o=e.src.charCodeAt(i);if(35!==o||i>=r)return!1;let s=1;for(o=e.src.charCodeAt(++i);35===o&&i<r&&s<=6;)s++,o=e.src.charCodeAt(++i);if(s>6||i<r&&!VE(o))return!1;if(n)return!0;r=e.skipSpacesBack(r,i);const l=e.skipCharsBack(r,35,i);l>i&&VE(e.src.charCodeAt(l-1))&&(r=l),e.line=t+1;const c=e.push("heading_open","h"+String(s),1);c.markup="########".slice(0,s),c.map=[t,e.line];const u=e.push("inline","",0);return u.content=e.src.slice(i,r).trim(),u.map=[t,e.line],u.children=[],e.push("heading_close","h"+String(s),-1).markup="########".slice(0,s),!0},["paragraph","reference","blockquote"]],["lheading",function(e,t,a){const n=e.md.block.ruler.getRules("paragraph");if(e.sCount[t]-e.blkIndent>=4)return!1;const i=e.parentType;e.parentType="paragraph";let r,o=0,s=t+1;for(;s<a&&!e.isEmpty(s);s++){if(e.sCount[s]-e.blkIndent>3)continue;if(e.sCount[s]>=e.blkIndent){let t=e.bMarks[s]+e.tShift[s];const a=e.eMarks[s];if(t<a&&(r=e.src.charCodeAt(t),(45===r||61===r)&&(t=e.skipChars(t,r),t=e.skipSpaces(t),t>=a))){o=61===r?1:2;break}}if(e.sCount[s]<0)continue;let t=!1;for(let i=0,r=n.length;i<r;i++)if(n[i](e,s,a,!0)){t=!0;break}if(t)break}if(!o)return!1;const l=e.getLines(t,s,e.blkIndent,!1).trim();e.line=s+1;const c=e.push("heading_open","h"+String(o),1);c.markup=String.fromCharCode(r),c.map=[t,e.line];const u=e.push("inline","",0);return u.content=l,u.map=[t,e.line-1],u.children=[],e.push("heading_close","h"+String(o),-1).markup=String.fromCharCode(r),e.parentType=i,!0}],["paragraph",function(e,t,a){const n=e.md.block.ruler.getRules("paragraph"),i=e.parentType;let r=t+1;for(e.parentType="paragraph";r<a&&!e.isEmpty(r);r++){if(e.sCount[r]-e.blkIndent>3)continue;if(e.sCount[r]<0)continue;let t=!1;for(let i=0,o=n.length;i<o;i++)if(n[i](e,r,a,!0)){t=!0;break}if(t)break}const o=e.getLines(t,r,e.blkIndent,!1).trim();e.line=r,e.push("paragraph_open","p",1).map=[t,e.line];const s=e.push("inline","",0);return s.content=o,s.map=[t,e.line],s.children=[],e.push("paragraph_close","p",-1),e.parentType=i,!0}]];function I_(){this.ruler=new t_;for(let e=0;e<M_.length;e++)this.ruler.push(M_[e][0],M_[e][1],{alt:(M_[e][2]||[]).slice()})}function N_(e,t,a,n){this.src=e,this.env=a,this.md=t,this.tokens=n,this.tokens_meta=Array(n.length),this.pos=0,this.posMax=this.src.length,this.level=0,this.pending="",this.pendingLevel=0,this.cache={},this.delimiters=[],this._prev_delimiters=[],this.backticks={},this.backticksScanned=!1,this.linkLevel=0}function j_(e){switch(e){case 10:case 33:case 35:case 36:case 37:case 38:case 42:case 43:case 45:case 58:case 60:case 61:case 62:case 64:case 91:case 92:case 93:case 94:case 95:case 96:case 123:case 125:case 126:return!0;default:return!1}}I_.prototype.tokenize=function(e,t,a){const n=this.ruler.getRules(""),i=n.length,r=e.md.options.maxNesting;let o=t,s=!1;for(;o<a&&(e.line=o=e.skipEmptyLines(o),!(o>=a))&&!(e.sCount[o]<e.blkIndent);){if(e.level>=r){e.line=a;break}const t=e.line;let l=!1;for(let r=0;r<i;r++)if(l=n[r](e,o,a,!1),l){if(t>=e.line)throw new Error("block rule didn't increment state.line");break}if(!l)throw new Error("none of the block rules matched");e.tight=!s,e.isEmpty(e.line-1)&&(s=!0),o=e.line,o<a&&e.isEmpty(o)&&(s=!0,o++,e.line=o)}},I_.prototype.parse=function(e,t,a,n){if(!e)return;const i=new this.State(e,t,a,n);this.tokenize(i,i.line,i.lineMax)},I_.prototype.State=k_,N_.prototype.pushPending=function(){const e=new a_("text","",0);return e.content=this.pending,e.level=this.pendingLevel,this.tokens.push(e),this.pending="",e},N_.prototype.push=function(e,t,a){this.pending&&this.pushPending();const n=new a_(e,t,a);let i=null;return a<0&&(this.level--,this.delimiters=this._prev_delimiters.pop()),n.level=this.level,a>0&&(this.level++,this._prev_delimiters.push(this.delimiters),this.delimiters=[],i={delimiters:this.delimiters}),this.pendingLevel=this.level,this.tokens.push(n),this.tokens_meta.push(i),n},N_.prototype.scanDelims=function(e,t){const a=this.posMax,n=this.src.charCodeAt(e),i=e>0?this.src.charCodeAt(e-1):32;let r=e;for(;r<a&&this.src.charCodeAt(r)===n;)r++;const o=r-e,s=r<a?this.src.charCodeAt(r):32,l=KE(i)||GE(String.fromCharCode(i)),c=KE(s)||GE(String.fromCharCode(s)),u=$E(i),d=$E(s),m=!d&&(!c||u||l),h=!u&&(!l||d||c);return{can_open:m&&(t||!h||l),can_close:h&&(t||!m||c),length:o}},N_.prototype.Token=a_;const z_=/(?:^|[^a-z0-9.+-])([a-z][a-z0-9.+-]*)$/i;const R_=[];for(let e=0;e<256;e++)R_.push(0);function L_(e,t){let a;const n=[],i=t.length;for(let r=0;r<i;r++){const i=t[r];if(126!==i.marker)continue;if(-1===i.end)continue;const o=t[i.end];a=e.tokens[i.token],a.type="s_open",a.tag="s",a.nesting=1,a.markup="~~",a.content="",a=e.tokens[o.token],a.type="s_close",a.tag="s",a.nesting=-1,a.markup="~~",a.content="","text"===e.tokens[o.token-1].type&&"~"===e.tokens[o.token-1].content&&n.push(o.token-1)}for(;n.length;){const t=n.pop();let i=t+1;for(;i<e.tokens.length&&"s_close"===e.tokens[i].type;)i++;i--,t!==i&&(a=e.tokens[i],e.tokens[i]=e.tokens[t],e.tokens[t]=a)}}"\\!\"#$%&'()*+,./:;<=>?@[]^_`{|}~-".split("").forEach((function(e){R_[e.charCodeAt(0)]=1}));var F_={tokenize:function(e,t){const a=e.pos,n=e.src.charCodeAt(a);if(t)return!1;if(126!==n)return!1;const i=e.scanDelims(e.pos,!0);let r=i.length;const o=String.fromCharCode(n);if(r<2)return!1;let s;r%2&&(s=e.push("text","",0),s.content=o,r--);for(let t=0;t<r;t+=2)s=e.push("text","",0),s.content=o+o,e.delimiters.push({marker:n,length:0,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close});return e.pos+=i.length,!0},postProcess:function(e){const t=e.tokens_meta,a=e.tokens_meta.length;L_(e,e.delimiters);for(let n=0;n<a;n++)t[n]&&t[n].delimiters&&L_(e,t[n].delimiters)}};function B_(e,t){for(let a=t.length-1;a>=0;a--){const n=t[a];if(95!==n.marker&&42!==n.marker)continue;if(-1===n.end)continue;const i=t[n.end],r=a>0&&t[a-1].end===n.end+1&&t[a-1].marker===n.marker&&t[a-1].token===n.token-1&&t[n.end+1].token===i.token+1,o=String.fromCharCode(n.marker),s=e.tokens[n.token];s.type=r?"strong_open":"em_open",s.tag=r?"strong":"em",s.nesting=1,s.markup=r?o+o:o,s.content="";const l=e.tokens[i.token];l.type=r?"strong_close":"em_close",l.tag=r?"strong":"em",l.nesting=-1,l.markup=r?o+o:o,l.content="",r&&(e.tokens[t[a-1].token].content="",e.tokens[t[n.end+1].token].content="",a--)}}var H_={tokenize:function(e,t){const a=e.pos,n=e.src.charCodeAt(a);if(t)return!1;if(95!==n&&42!==n)return!1;const i=e.scanDelims(e.pos,42===n);for(let t=0;t<i.length;t++){e.push("text","",0).content=String.fromCharCode(n),e.delimiters.push({marker:n,length:i.length,token:e.tokens.length-1,end:-1,open:i.can_open,close:i.can_close})}return e.pos+=i.length,!0},postProcess:function(e){const t=e.tokens_meta,a=e.tokens_meta.length;B_(e,e.delimiters);for(let n=0;n<a;n++)t[n]&&t[n].delimiters&&B_(e,t[n].delimiters)}};const q_=/^([a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)$/,U_=/^([a-zA-Z][a-zA-Z0-9+.-]{1,31}):([^<>\x00-\x20]*)$/;const W_=/^&#((?:x[a-f0-9]{1,6}|[0-9]{1,7}));/i,V_=/^&([a-z][a-z0-9]{1,31});/i;function $_(e){const t={},a=e.length;if(!a)return;let n=0,i=-2;const r=[];for(let o=0;o<a;o++){const a=e[o];if(r.push(0),e[n].marker===a.marker&&i===a.token-1||(n=o),i=a.token,a.length=a.length||0,!a.close)continue;t.hasOwnProperty(a.marker)||(t[a.marker]=[-1,-1,-1,-1,-1,-1]);const s=t[a.marker][(a.open?3:0)+a.length%3];let l=n-r[n]-1,c=l;for(;l>s;l-=r[l]+1){const t=e[l];if(t.marker===a.marker&&(t.open&&t.end<0)){let n=!1;if((t.close||a.open)&&(t.length+a.length)%3==0&&(t.length%3==0&&a.length%3==0||(n=!0)),!n){const n=l>0&&!e[l-1].open?r[l-1]+1:0;r[o]=o-l+n,r[l]=n,a.open=!1,t.end=o,t.close=!1,c=-1,i=-2;break}}}-1!==c&&(t[a.marker][(a.open?3:0)+(a.length||0)%3]=c)}}const G_=[["text",function(e,t){let a=e.pos;for(;a<e.posMax&&!j_(e.src.charCodeAt(a));)a++;return a!==e.pos&&(t||(e.pending+=e.src.slice(e.pos,a)),e.pos=a,!0)}],["linkify",function(e,t){if(!e.md.options.linkify)return!1;if(e.linkLevel>0)return!1;const a=e.pos;if(a+3>e.posMax)return!1;if(58!==e.src.charCodeAt(a))return!1;if(47!==e.src.charCodeAt(a+1))return!1;if(47!==e.src.charCodeAt(a+2))return!1;const n=e.pending.match(z_);if(!n)return!1;const i=n[1],r=e.md.linkify.matchAtStart(e.src.slice(a-i.length));if(!r)return!1;let o=r.url;if(o.length<=i.length)return!1;o=o.replace(/\*+$/,"");const s=e.md.normalizeLink(o);if(!e.md.validateLink(s))return!1;if(!t){e.pending=e.pending.slice(0,-i.length);const t=e.push("link_open","a",1);t.attrs=[["href",s]],t.markup="linkify",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(o);const a=e.push("link_close","a",-1);a.markup="linkify",a.info="auto"}return e.pos+=o.length-i.length,!0}],["newline",function(e,t){let a=e.pos;if(10!==e.src.charCodeAt(a))return!1;const n=e.pending.length-1,i=e.posMax;if(!t)if(n>=0&&32===e.pending.charCodeAt(n))if(n>=1&&32===e.pending.charCodeAt(n-1)){let t=n-1;for(;t>=1&&32===e.pending.charCodeAt(t-1);)t--;e.pending=e.pending.slice(0,t),e.push("hardbreak","br",0)}else e.pending=e.pending.slice(0,-1),e.push("softbreak","br",0);else e.push("softbreak","br",0);for(a++;a<i&&VE(e.src.charCodeAt(a));)a++;return e.pos=a,!0}],["escape",function(e,t){let a=e.pos;const n=e.posMax;if(92!==e.src.charCodeAt(a))return!1;if(a++,a>=n)return!1;let i=e.src.charCodeAt(a);if(10===i){for(t||e.push("hardbreak","br",0),a++;a<n&&(i=e.src.charCodeAt(a),VE(i));)a++;return e.pos=a,!0}let r=e.src[a];if(i>=55296&&i<=56319&&a+1<n){const t=e.src.charCodeAt(a+1);t>=56320&&t<=57343&&(r+=e.src[a+1],a++)}const o="\\"+r;if(!t){const t=e.push("text_special","",0);i<256&&0!==R_[i]?t.content=r:t.content=o,t.markup=o,t.info="escape"}return e.pos=a+1,!0}],["backticks",function(e,t){let a=e.pos;if(96!==e.src.charCodeAt(a))return!1;const n=a;a++;const i=e.posMax;for(;a<i&&96===e.src.charCodeAt(a);)a++;const r=e.src.slice(n,a),o=r.length;if(e.backticksScanned&&(e.backticks[o]||0)<=n)return t||(e.pending+=r),e.pos+=o,!0;let s,l=a;for(;-1!==(s=e.src.indexOf("`",l));){for(l=s+1;l<i&&96===e.src.charCodeAt(l);)l++;const n=l-s;if(n===o){if(!t){const t=e.push("code_inline","code",0);t.markup=r,t.content=e.src.slice(a,s).replace(/\n/g," ").replace(/^ (.+) $/,"$1")}return e.pos=l,!0}e.backticks[n]=s}return e.backticksScanned=!0,t||(e.pending+=r),e.pos+=o,!0}],["strikethrough",F_.tokenize],["emphasis",H_.tokenize],["link",function(e,t){let a,n,i,r,o="",s="",l=e.pos,c=!0;if(91!==e.src.charCodeAt(e.pos))return!1;const u=e.pos,d=e.posMax,m=e.pos+1,h=e.md.helpers.parseLinkLabel(e,e.pos,!0);if(h<0)return!1;let p=h+1;if(p<d&&40===e.src.charCodeAt(p)){for(c=!1,p++;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);if(p>=d)return!1;if(l=p,i=e.md.helpers.parseLinkDestination(e.src,p,e.posMax),i.ok){for(o=e.md.normalizeLink(i.str),e.md.validateLink(o)?p=i.pos:o="",l=p;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);if(i=e.md.helpers.parseLinkTitle(e.src,p,e.posMax),p<d&&l!==p&&i.ok)for(s=i.str,p=i.pos;p<d&&(a=e.src.charCodeAt(p),VE(a)||10===a);p++);}(p>=d||41!==e.src.charCodeAt(p))&&(c=!0),p++}if(c){if(void 0===e.env.references)return!1;if(p<d&&91===e.src.charCodeAt(p)?(l=p+1,p=e.md.helpers.parseLinkLabel(e,p),p>=0?n=e.src.slice(l,p++):p=h+1):p=h+1,n||(n=e.src.slice(m,h)),r=e.env.references[ZE(n)],!r)return e.pos=u,!1;o=r.href,s=r.title}if(!t){e.pos=m,e.posMax=h;const t=[["href",o]];e.push("link_open","a",1).attrs=t,s&&t.push(["title",s]),e.linkLevel++,e.md.inline.tokenize(e),e.linkLevel--,e.push("link_close","a",-1)}return e.pos=p,e.posMax=d,!0}],["image",function(e,t){let a,n,i,r,o,s,l,c,u="";const d=e.pos,m=e.posMax;if(33!==e.src.charCodeAt(e.pos))return!1;if(91!==e.src.charCodeAt(e.pos+1))return!1;const h=e.pos+2,p=e.md.helpers.parseLinkLabel(e,e.pos+1,!1);if(p<0)return!1;if(r=p+1,r<m&&40===e.src.charCodeAt(r)){for(r++;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);if(r>=m)return!1;for(c=r,s=e.md.helpers.parseLinkDestination(e.src,r,e.posMax),s.ok&&(u=e.md.normalizeLink(s.str),e.md.validateLink(u)?r=s.pos:u=""),c=r;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);if(s=e.md.helpers.parseLinkTitle(e.src,r,e.posMax),r<m&&c!==r&&s.ok)for(l=s.str,r=s.pos;r<m&&(a=e.src.charCodeAt(r),VE(a)||10===a);r++);else l="";if(r>=m||41!==e.src.charCodeAt(r))return e.pos=d,!1;r++}else{if(void 0===e.env.references)return!1;if(r<m&&91===e.src.charCodeAt(r)?(c=r+1,r=e.md.helpers.parseLinkLabel(e,r),r>=0?i=e.src.slice(c,r++):r=p+1):r=p+1,i||(i=e.src.slice(h,p)),o=e.env.references[ZE(i)],!o)return e.pos=d,!1;u=o.href,l=o.title}if(!t){n=e.src.slice(h,p);const t=[];e.md.inline.parse(n,e.md,e.env,t);const a=e.push("image","img",0),i=[["src",u],["alt",""]];a.attrs=i,a.children=t,a.content=n,l&&i.push(["title",l])}return e.pos=r,e.posMax=m,!0}],["autolink",function(e,t){let a=e.pos;if(60!==e.src.charCodeAt(a))return!1;const n=e.pos,i=e.posMax;for(;;){if(++a>=i)return!1;const t=e.src.charCodeAt(a);if(60===t)return!1;if(62===t)break}const r=e.src.slice(n+1,a);if(U_.test(r)){const a=e.md.normalizeLink(r);if(!e.md.validateLink(a))return!1;if(!t){const t=e.push("link_open","a",1);t.attrs=[["href",a]],t.markup="autolink",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(r);const n=e.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return e.pos+=r.length+2,!0}if(q_.test(r)){const a=e.md.normalizeLink("mailto:"+r);if(!e.md.validateLink(a))return!1;if(!t){const t=e.push("link_open","a",1);t.attrs=[["href",a]],t.markup="autolink",t.info="auto";e.push("text","",0).content=e.md.normalizeLinkText(r);const n=e.push("link_close","a",-1);n.markup="autolink",n.info="auto"}return e.pos+=r.length+2,!0}return!1}],["html_inline",function(e,t){if(!e.md.options.html)return!1;const a=e.posMax,n=e.pos;if(60!==e.src.charCodeAt(n)||n+2>=a)return!1;const i=e.src.charCodeAt(n+1);if(33!==i&&63!==i&&47!==i&&!function(e){const t=32|e;return t>=97&&t<=122}(i))return!1;const r=e.src.slice(n).match(P_);if(!r)return!1;if(!t){const t=e.push("html_inline","",0);t.content=r[0],function(e){return/^<a[>\s]/i.test(e)}(t.content)&&e.linkLevel++,function(e){return/^<\/a\s*>/i.test(e)}(t.content)&&e.linkLevel--}return e.pos+=r[0].length,!0}],["entity",function(e,t){const a=e.pos,n=e.posMax;if(38!==e.src.charCodeAt(a))return!1;if(a+1>=n)return!1;if(35===e.src.charCodeAt(a+1)){const n=e.src.slice(a).match(W_);if(n){if(!t){const t="x"===n[1][0].toLowerCase()?parseInt(n[1].slice(1),16):parseInt(n[1],10),a=e.push("text_special","",0);a.content=IE(t)?NE(t):NE(65533),a.markup=n[0],a.info="entity"}return e.pos+=n[0].length,!0}}else{const n=e.src.slice(a).match(V_);if(n){const a=TE(n[0]);if(a!==n[0]){if(!t){const t=e.push("text_special","",0);t.content=a,t.markup=n[0],t.info="entity"}return e.pos+=n[0].length,!0}}}return!1}]],K_=[["balance_pairs",function(e){const t=e.tokens_meta,a=e.tokens_meta.length;$_(e.delimiters);for(let e=0;e<a;e++)t[e]&&t[e].delimiters&&$_(t[e].delimiters)}],["strikethrough",F_.postProcess],["emphasis",H_.postProcess],["fragments_join",function(e){let t,a,n=0;const i=e.tokens,r=e.tokens.length;for(t=a=0;t<r;t++)i[t].nesting<0&&n--,i[t].level=n,i[t].nesting>0&&n++,"text"===i[t].type&&t+1<r&&"text"===i[t+1].type?i[t+1].content=i[t].content+i[t+1].content:(t!==a&&(i[a]=i[t]),a++);t!==a&&(i.length=a)}]];function Z_(){this.ruler=new t_;for(let e=0;e<G_.length;e++)this.ruler.push(G_[e][0],G_[e][1]);this.ruler2=new t_;for(let e=0;e<K_.length;e++)this.ruler2.push(K_[e][0],K_[e][1])}function Y_(e){return Array.prototype.slice.call(arguments,1).forEach((function(t){t&&Object.keys(t).forEach((function(a){e[a]=t[a]}))})),e}function X_(e){return Object.prototype.toString.call(e)}function Q_(e){return"[object Function]"===X_(e)}function J_(e){return e.replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}Z_.prototype.skipToken=function(e){const t=e.pos,a=this.ruler.getRules(""),n=a.length,i=e.md.options.maxNesting,r=e.cache;if(void 0!==r[t])return void(e.pos=r[t]);let o=!1;if(e.level<i){for(let i=0;i<n;i++)if(e.level++,o=a[i](e,!0),e.level--,o){if(t>=e.pos)throw new Error("inline rule didn't increment state.pos");break}}else e.pos=e.posMax;o||e.pos++,r[t]=e.pos},Z_.prototype.tokenize=function(e){const t=this.ruler.getRules(""),a=t.length,n=e.posMax,i=e.md.options.maxNesting;for(;e.pos<n;){const r=e.pos;let o=!1;if(e.level<i)for(let n=0;n<a;n++)if(o=t[n](e,!1),o){if(r>=e.pos)throw new Error("inline rule didn't increment state.pos");break}if(o){if(e.pos>=n)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},Z_.prototype.parse=function(e,t,a,n){const i=new this.State(e,t,a,n);this.tokenize(i);const r=this.ruler2.getRules(""),o=r.length;for(let e=0;e<o;e++)r[e](i)},Z_.prototype.State=N_;const eC={fuzzyLink:!0,fuzzyEmail:!0,fuzzyIP:!1};const tC={"http:":{validate:function(e,t,a){const n=e.slice(t);return a.re.http||(a.re.http=new RegExp("^\\/\\/"+a.re.src_auth+a.re.src_host_port_strict+a.re.src_path,"i")),a.re.http.test(n)?n.match(a.re.http)[0].length:0}},"https:":"http:","ftp:":"http:","//":{validate:function(e,t,a){const n=e.slice(t);return a.re.no_http||(a.re.no_http=new RegExp("^"+a.re.src_auth+"(?:localhost|(?:(?:"+a.re.src_domain+")\\.)+"+a.re.src_domain_root+")"+a.re.src_port+a.re.src_host_terminator+a.re.src_path,"i")),a.re.no_http.test(n)?t>=3&&":"===e[t-3]||t>=3&&"/"===e[t-3]?0:n.match(a.re.no_http)[0].length:0}},"mailto:":{validate:function(e,t,a){const n=e.slice(t);return a.re.mailto||(a.re.mailto=new RegExp("^"+a.re.src_email_name+"@"+a.re.src_host_strict,"i")),a.re.mailto.test(n)?n.match(a.re.mailto)[0].length:0}}},aC="a[cdefgilmnoqrstuwxz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvwxyz]|d[ejkmoz]|e[cegrstu]|f[ijkmor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdeghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eosuw]|s[abcdeghijklmnortuvxyz]|t[cdfghjklmnortvwz]|u[agksyz]|v[aceginu]|w[fs]|y[et]|z[amw]",nC="biz|com|edu|gov|net|org|pro|web|xxx|aero|asia|coop|info|museum|name|shop|рф".split("|");function iC(e){const t=e.re=function(e){const t={};e=e||{},t.src_Any=sE.source,t.src_Cc=lE.source,t.src_Z=dE.source,t.src_P=cE.source,t.src_ZPCc=[t.src_Z,t.src_P,t.src_Cc].join("|"),t.src_ZCc=[t.src_Z,t.src_Cc].join("|");const a="[><|]";return t.src_pseudo_letter="(?:(?![><|]|"+t.src_ZPCc+")"+t.src_Any+")",t.src_ip4="(?:(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)",t.src_auth="(?:(?:(?!"+t.src_ZCc+"|[@/\\[\\]()]).)+@)?",t.src_port="(?::(?:6(?:[0-4]\\d{3}|5(?:[0-4]\\d{2}|5(?:[0-2]\\d|3[0-5])))|[1-5]?\\d{1,4}))?",t.src_host_terminator="(?=$|[><|]|"+t.src_ZPCc+")(?!"+(e["---"]?"-(?!--)|":"-|")+"_|:\\d|\\.-|\\.(?!$|"+t.src_ZPCc+"))",t.src_path="(?:[/?#](?:(?!"+t.src_ZCc+"|"+a+"|[()[\\]{}.,\"'?!\\-;]).|\\[(?:(?!"+t.src_ZCc+"|\\]).)*\\]|\\((?:(?!"+t.src_ZCc+"|[)]).)*\\)|\\{(?:(?!"+t.src_ZCc+'|[}]).)*\\}|\\"(?:(?!'+t.src_ZCc+'|["]).)+\\"|\\\'(?:(?!'+t.src_ZCc+"|[']).)+\\'|\\'(?="+t.src_pseudo_letter+"|[-])|\\.{2,}[a-zA-Z0-9%/&]|\\.(?!"+t.src_ZCc+"|[.]|$)|"+(e["---"]?"\\-(?!--(?:[^-]|$))(?:-*)|":"\\-+|")+",(?!"+t.src_ZCc+"|$)|;(?!"+t.src_ZCc+"|$)|\\!+(?!"+t.src_ZCc+"|[!]|$)|\\?(?!"+t.src_ZCc+"|[?]|$))+|\\/)?",t.src_email_name='[\\-;:&=\\+\\$,\\.a-zA-Z0-9_][\\-;:&=\\+\\$,\\"\\.a-zA-Z0-9_]*',t.src_xn="xn--[a-z0-9\\-]{1,59}",t.src_domain_root="(?:"+t.src_xn+"|"+t.src_pseudo_letter+"{1,63})",t.src_domain="(?:"+t.src_xn+"|(?:"+t.src_pseudo_letter+")|(?:"+t.src_pseudo_letter+"(?:-|"+t.src_pseudo_letter+"){0,61}"+t.src_pseudo_letter+"))",t.src_host="(?:(?:(?:(?:"+t.src_domain+")\\.)*"+t.src_domain+"))",t.tpl_host_fuzzy="(?:"+t.src_ip4+"|(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%)))",t.tpl_host_no_ip_fuzzy="(?:(?:(?:"+t.src_domain+")\\.)+(?:%TLDS%))",t.src_host_strict=t.src_host+t.src_host_terminator,t.tpl_host_fuzzy_strict=t.tpl_host_fuzzy+t.src_host_terminator,t.src_host_port_strict=t.src_host+t.src_port+t.src_host_terminator,t.tpl_host_port_fuzzy_strict=t.tpl_host_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_port_no_ip_fuzzy_strict=t.tpl_host_no_ip_fuzzy+t.src_port+t.src_host_terminator,t.tpl_host_fuzzy_test="localhost|www\\.|\\.\\d{1,3}\\.|(?:\\.(?:%TLDS%)(?:"+t.src_ZPCc+"|>|$))",t.tpl_email_fuzzy='(^|[><|]|"|\\(|'+t.src_ZCc+")("+t.src_email_name+"@"+t.tpl_host_fuzzy_strict+")",t.tpl_link_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_fuzzy_strict+t.src_path+")",t.tpl_link_no_ip_fuzzy="(^|(?![.:/\\-_@])(?:[$+<=>^`||]|"+t.src_ZPCc+"))((?![$+<=>^`||])"+t.tpl_host_port_no_ip_fuzzy_strict+t.src_path+")",t}(e.__opts__),a=e.__tlds__.slice();function n(e){return e.replace("%TLDS%",t.src_tlds)}e.onCompile(),e.__tlds_replaced__||a.push(aC),a.push(t.src_xn),t.src_tlds=a.join("|"),t.email_fuzzy=RegExp(n(t.tpl_email_fuzzy),"i"),t.link_fuzzy=RegExp(n(t.tpl_link_fuzzy),"i"),t.link_no_ip_fuzzy=RegExp(n(t.tpl_link_no_ip_fuzzy),"i"),t.host_fuzzy_test=RegExp(n(t.tpl_host_fuzzy_test),"i");const i=[];function r(e,t){throw new Error('(LinkifyIt) Invalid schema "'+e+'": '+t)}e.__compiled__={},Object.keys(e.__schemas__).forEach((function(t){const a=e.__schemas__[t];if(null===a)return;const n={validate:null,link:null};if(e.__compiled__[t]=n,function(e){return"[object Object]"===X_(e)}(a))return!function(e){return"[object RegExp]"===X_(e)}(a.validate)?Q_(a.validate)?n.validate=a.validate:r(t,a):n.validate=function(e){return function(t,a){const n=t.slice(a);return e.test(n)?n.match(e)[0].length:0}}(a.validate),void(Q_(a.normalize)?n.normalize=a.normalize:a.normalize?r(t,a):n.normalize=function(e,t){t.normalize(e)});!function(e){return"[object String]"===X_(e)}(a)?r(t,a):i.push(t)})),i.forEach((function(t){e.__compiled__[e.__schemas__[t]]&&(e.__compiled__[t].validate=e.__compiled__[e.__schemas__[t]].validate,e.__compiled__[t].normalize=e.__compiled__[e.__schemas__[t]].normalize)})),e.__compiled__[""]={validate:null,normalize:function(e,t){t.normalize(e)}};const o=Object.keys(e.__compiled__).filter((function(t){return t.length>0&&e.__compiled__[t]})).map(J_).join("|");e.re.schema_test=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+o+")","i"),e.re.schema_search=RegExp("(^|(?!_)(?:[><|]|"+t.src_ZPCc+"))("+o+")","ig"),e.re.schema_at_start=RegExp("^"+e.re.schema_search.source,"i"),e.re.pretest=RegExp("("+e.re.schema_test.source+")|("+e.re.host_fuzzy_test.source+")|@","i"),function(e){e.__index__=-1,e.__text_cache__=""}(e)}function rC(e,t){const a=e.__index__,n=e.__last_index__,i=e.__text_cache__.slice(a,n);this.schema=e.__schema__.toLowerCase(),this.index=a+t,this.lastIndex=n+t,this.raw=i,this.text=i,this.url=i}function oC(e,t){const a=new rC(e,t);return e.__compiled__[a.schema].normalize(a,e),a}function sC(e,t){if(!(this instanceof sC))return new sC(e,t);t||function(e){return Object.keys(e||{}).reduce((function(e,t){return e||eC.hasOwnProperty(t)}),!1)}(e)&&(t=e,e={}),this.__opts__=Y_({},eC,t),this.__index__=-1,this.__last_index__=-1,this.__schema__="",this.__text_cache__="",this.__schemas__=Y_({},tC,e),this.__compiled__={},this.__tlds__=nC,this.__tlds_replaced__=!1,this.re={},iC(this)}sC.prototype.add=function(e,t){return this.__schemas__[e]=t,iC(this),this},sC.prototype.set=function(e){return this.__opts__=Y_(this.__opts__,e),this},sC.prototype.test=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return!1;let t,a,n,i,r,o,s,l,c;if(this.re.schema_test.test(e))for(s=this.re.schema_search,s.lastIndex=0;null!==(t=s.exec(e));)if(i=this.testSchemaAt(e,t[2],s.lastIndex),i){this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+i;break}return this.__opts__.fuzzyLink&&this.__compiled__["http:"]&&(l=e.search(this.re.host_fuzzy_test),l>=0&&(this.__index__<0||l<this.__index__)&&null!==(a=e.match(this.__opts__.fuzzyIP?this.re.link_fuzzy:this.re.link_no_ip_fuzzy))&&(r=a.index+a[1].length,(this.__index__<0||r<this.__index__)&&(this.__schema__="",this.__index__=r,this.__last_index__=a.index+a[0].length))),this.__opts__.fuzzyEmail&&this.__compiled__["mailto:"]&&(c=e.indexOf("@"),c>=0&&null!==(n=e.match(this.re.email_fuzzy))&&(r=n.index+n[1].length,o=n.index+n[0].length,(this.__index__<0||r<this.__index__||r===this.__index__&&o>this.__last_index__)&&(this.__schema__="mailto:",this.__index__=r,this.__last_index__=o))),this.__index__>=0},sC.prototype.pretest=function(e){return this.re.pretest.test(e)},sC.prototype.testSchemaAt=function(e,t,a){return this.__compiled__[t.toLowerCase()]?this.__compiled__[t.toLowerCase()].validate(e,a,this):0},sC.prototype.match=function(e){const t=[];let a=0;this.__index__>=0&&this.__text_cache__===e&&(t.push(oC(this,a)),a=this.__last_index__);let n=a?e.slice(a):e;for(;this.test(n);)t.push(oC(this,a)),n=n.slice(this.__last_index__),a+=this.__last_index__;return t.length?t:null},sC.prototype.matchAtStart=function(e){if(this.__text_cache__=e,this.__index__=-1,!e.length)return null;const t=this.re.schema_at_start.exec(e);if(!t)return null;const a=this.testSchemaAt(e,t[2],t[0].length);return a?(this.__schema__=t[2],this.__index__=t.index+t[1].length,this.__last_index__=t.index+t[0].length+a,oC(this,0)):null},sC.prototype.tlds=function(e,t){return e=Array.isArray(e)?e:[e],t?(this.__tlds__=this.__tlds__.concat(e).sort().filter((function(e,t,a){return e!==a[t-1]})).reverse(),iC(this),this):(this.__tlds__=e.slice(),this.__tlds_replaced__=!0,iC(this),this)},sC.prototype.normalize=function(e){e.schema||(e.url="http://"+e.url),"mailto:"!==e.schema||/^mailto:/i.test(e.url)||(e.url="mailto:"+e.url)},sC.prototype.onCompile=function(){};const lC=2147483647,cC=36,uC=/^xn--/,dC=/[^\0-\x7F]/,mC=/[\x2E\u3002\uFF0E\uFF61]/g,hC={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},pC=Math.floor,gC=String.fromCharCode;function fC(e){throw new RangeError(hC[e])}function yC(e,t){const a=e.split("@");let n="";a.length>1&&(n=a[0]+"@",e=a[1]);const i=function(e,t){const a=[];let n=e.length;for(;n--;)a[n]=t(e[n]);return a}((e=e.replace(mC,".")).split("."),t).join(".");return n+i}function bC(e){const t=[];let a=0;const n=e.length;for(;a<n;){const i=e.charCodeAt(a++);if(i>=55296&&i<=56319&&a<n){const n=e.charCodeAt(a++);56320==(64512&n)?t.push(((1023&i)<<10)+(1023&n)+65536):(t.push(i),a--)}else t.push(i)}return t}const vC=function(e,t){return e+22+75*(e<26)-((0!=t)<<5)},wC=function(e,t,a){let n=0;for(e=a?pC(e/700):e>>1,e+=pC(e/t);e>455;n+=cC)e=pC(e/35);return pC(n+36*e/(e+38))},xC=function(e){const t=[],a=e.length;let n=0,i=128,r=72,o=e.lastIndexOf("-");o<0&&(o=0);for(let a=0;a<o;++a)e.charCodeAt(a)>=128&&fC("not-basic"),t.push(e.charCodeAt(a));for(let l=o>0?o+1:0;l<a;){const o=n;for(let t=1,i=cC;;i+=cC){l>=a&&fC("invalid-input");const o=(s=e.charCodeAt(l++))>=48&&s<58?s-48+26:s>=65&&s<91?s-65:s>=97&&s<123?s-97:cC;o>=cC&&fC("invalid-input"),o>pC((lC-n)/t)&&fC("overflow"),n+=o*t;const c=i<=r?1:i>=r+26?26:i-r;if(o<c)break;const u=cC-c;t>pC(lC/u)&&fC("overflow"),t*=u}const c=t.length+1;r=wC(n-o,c,0==o),pC(n/c)>lC-i&&fC("overflow"),i+=pC(n/c),n%=c,t.splice(n++,0,i)}var s;return String.fromCodePoint(...t)},kC=function(e){const t=[],a=(e=bC(e)).length;let n=128,i=0,r=72;for(const a of e)a<128&&t.push(gC(a));const o=t.length;let s=o;for(o&&t.push("-");s<a;){let a=lC;for(const t of e)t>=n&&t<a&&(a=t);const l=s+1;a-n>pC((lC-i)/l)&&fC("overflow"),i+=(a-n)*l,n=a;for(const a of e)if(a<n&&++i>lC&&fC("overflow"),a===n){let e=i;for(let a=cC;;a+=cC){const n=a<=r?1:a>=r+26?26:a-r;if(e<n)break;const i=e-n,o=cC-n;t.push(gC(vC(n+i%o,0))),e=pC(i/o)}t.push(gC(vC(e,0))),r=wC(i,l,s===o),i=0,++s}++i,++n}return t.join("")},AC={version:"2.3.1",ucs2:{decode:bC,encode:e=>String.fromCodePoint(...e)},decode:xC,encode:kC,toASCII:function(e){return yC(e,(function(e){return dC.test(e)?"xn--"+kC(e):e}))},toUnicode:function(e){return yC(e,(function(e){return uC.test(e)?xC(e.slice(4).toLowerCase()):e}))}};const SC={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:100},components:{core:{},block:{},inline:{}}},zero:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["paragraph"]},inline:{rules:["text"],rules2:["balance_pairs","fragments_join"]}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkify:!1,typographer:!1,quotes:"“”‘’",highlight:null,maxNesting:20},components:{core:{rules:["normalize","block","inline","text_join"]},block:{rules:["blockquote","code","fence","heading","hr","html_block","lheading","list","reference","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","html_inline","image","link","newline","text"],rules2:["balance_pairs","emphasis","fragments_join"]}}}},EC=/^(vbscript|javascript|file|data):/,_C=/^data:image\/(gif|png|jpeg|webp);/;function CC(e){const t=e.trim().toLowerCase();return!EC.test(t)||_C.test(t)}const TC=["http:","https:","mailto:"];function PC(e){const t=iE(e,!0);if(t.hostname&&(!t.protocol||TC.indexOf(t.protocol)>=0))try{t.hostname=AC.toASCII(t.hostname)}catch(e){}return WS(VS(t))}function OC(e){const t=iE(e,!0);if(t.hostname&&(!t.protocol||TC.indexOf(t.protocol)>=0))try{t.hostname=AC.toUnicode(t.hostname)}catch(e){}return qS(VS(t),qS.defaultChars+"%")}function DC(e,t){if(!(this instanceof DC))return new DC(e,t);t||PE(e)||(t=e||{},e="default"),this.inline=new Z_,this.block=new I_,this.core=new x_,this.renderer=new e_,this.linkify=new sC,this.validateLink=CC,this.normalizeLink=PC,this.normalizeLinkText=OC,this.utils=XE,this.helpers=DE({},QE),this.options={},this.configure(e),t&&this.set(t)}DC.prototype.set=function(e){return DE(this.options,e),this},DC.prototype.configure=function(e){const t=this;if(PE(e)){const t=e;if(!(e=SC[t]))throw new Error('Wrong `markdown-it` preset "'+t+'", check name')}if(!e)throw new Error("Wrong `markdown-it` preset, can't be empty");return e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach((function(a){e.components[a].rules&&t[a].ruler.enableOnly(e.components[a].rules),e.components[a].rules2&&t[a].ruler2.enableOnly(e.components[a].rules2)})),this},DC.prototype.enable=function(e,t){let a=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){a=a.concat(this[t].ruler.enable(e,!0))}),this),a=a.concat(this.inline.ruler2.enable(e,!0));const n=e.filter((function(e){return a.indexOf(e)<0}));if(n.length&&!t)throw new Error("MarkdownIt. Failed to enable unknown rule(s): "+n);return this},DC.prototype.disable=function(e,t){let a=[];Array.isArray(e)||(e=[e]),["core","block","inline"].forEach((function(t){a=a.concat(this[t].ruler.disable(e,!0))}),this),a=a.concat(this.inline.ruler2.disable(e,!0));const n=e.filter((function(e){return a.indexOf(e)<0}));if(n.length&&!t)throw new Error("MarkdownIt. Failed to disable unknown rule(s): "+n);return this},DC.prototype.use=function(e){const t=[this].concat(Array.prototype.slice.call(arguments,1));return e.apply(e,t),this},DC.prototype.parse=function(e,t){if("string"!=typeof e)throw new Error("Input data should be a String");const a=new this.core.State(e,this,t);return this.core.process(a),a.tokens},DC.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},DC.prototype.parseInline=function(e,t){const a=new this.core.State(e,this,t);return a.inlineMode=!0,this.core.process(a),a.tokens},DC.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var MC=Object.defineProperty,IC=Object.defineProperties,NC=Object.getOwnPropertyDescriptor,jC=Object.getOwnPropertyDescriptors,zC=Object.getOwnPropertyNames,RC=Object.getOwnPropertySymbols,LC=Object.prototype.hasOwnProperty,FC=Object.prototype.propertyIsEnumerable,BC=(e,t,a)=>t in e?MC(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,HC=(e,t)=>{for(var a in t||(t={}))LC.call(t,a)&&BC(e,a,t[a]);if(RC)for(var a of RC(t))FC.call(t,a)&&BC(e,a,t[a]);return e},qC=(e,t)=>IC(e,jC(t)),UC={};((e,t)=>{for(var a in t)MC(e,a,{get:t[a],enumerable:!0})})(UC,{default:()=>XC});var WC,VC=(WC=UC,((e,t,a,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let i of zC(t))LC.call(e,i)||i===a||MC(e,i,{get:()=>t[i],enumerable:!(n=NC(t,i))||n.enumerable});return e})(MC({},"__esModule",{value:!0}),WC));function $C(e,t,a,n,i){try{return t.highlight(n,{language:""!==i?i:"plaintext",ignoreIllegals:a}).value}catch(t){return e.utils.escapeHtml(n)}}function GC(e,t,a,n,i){if(""!==i)return $C(e,t,a,n,i);try{return t.highlightAuto(n).value}catch(t){return e.utils.escapeHtml(n)}}function KC(e){return function(...t){return e(...t).replace('<code class="','<code class="hljs ').replace("<code>",'<code class="hljs">')}}function ZC(e){var t,a;for(const n of e.tokens)if("inline"===n.type&&null!=n.children)for(const[i,r]of n.children.entries()){if("code_inline"!==r.type)continue;const o=n.children[i+1];if(null==o)continue;const s=/^{:?\.([^}]+)}/.exec(o.content);if(null==s)continue;const l=s[1];o.content=o.content.slice(s[0].length);let c=null!=(t=r.attrGet("class"))?t:"";c+=`${null!=(a=e.md.options.langPrefix)?a:"language-"}${l}`,r.attrSet("class",c),r.meta=qC(HC({},r.meta),{highlightLanguage:l})}}function YC(e,t,a,n,i){var r,o;const s=e[t];if(null==a.highlight)throw new Error("`options.highlight` was null, this is not supposed to happen");const l=a.highlight(s.content,null!=(o=null==(r=s.meta)?void 0:r.highlightLanguage)?o:"","");return`<code${i.renderAttrs(s)}>${l}</code>`}function XC(e,t){const a=HC(HC({},XC.defaults),t);if(null==a.hljs)throw new Error("Please pass a highlight.js instance for the required `hljs` option.");null!=a.register&&function(e,t){for(const[a,n]of Object.entries(t))e.registerLanguage(a,n)}(a.hljs,a.register),e.options.highlight=(a.auto?GC:$C).bind(null,e,a.hljs,a.ignoreIllegals),null!=e.renderer.rules.fence&&(e.renderer.rules.fence=KC(e.renderer.rules.fence)),a.code&&null!=e.renderer.rules.code_block&&(e.renderer.rules.code_block=KC(e.renderer.rules.code_block)),a.inline&&(e.core.ruler.before("linkify","inline_code_language",ZC),e.renderer.rules.code_inline=KC(YC))}XC.defaults={auto:!1,code:!1,inline:!1,ignoreIllegals:!1};var QC=Gt(VC.default);function JC(e){return e instanceof Map?e.clear=e.delete=e.set=function(){throw new Error("map is read-only")}:e instanceof Set&&(e.add=e.clear=e.delete=function(){throw new Error("set is read-only")}),Object.freeze(e),Object.getOwnPropertyNames(e).forEach((t=>{const a=e[t],n=typeof a;"object"!==n&&"function"!==n||Object.isFrozen(a)||JC(a)})),e}let eT=class{constructor(e){void 0===e.data&&(e.data={}),this.data=e.data,this.isMatchIgnored=!1}ignoreMatch(){this.isMatchIgnored=!0}};function tT(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")}function aT(e,...t){const a=Object.create(null);for(const t in e)a[t]=e[t];return t.forEach((function(e){for(const t in e)a[t]=e[t]})),a}const nT=e=>!!e.scope;class iT{constructor(e,t){this.buffer="",this.classPrefix=t.classPrefix,e.walk(this)}addText(e){this.buffer+=tT(e)}openNode(e){if(!nT(e))return;const t=((e,{prefix:t})=>{if(e.startsWith("language:"))return e.replace("language:","language-");if(e.includes(".")){const a=e.split(".");return[`${t}${a.shift()}`,...a.map(((e,t)=>`${e}${"_".repeat(t+1)}`))].join(" ")}return`${t}${e}`})(e.scope,{prefix:this.classPrefix});this.span(t)}closeNode(e){nT(e)&&(this.buffer+="</span>")}value(){return this.buffer}span(e){this.buffer+=`<span class="${e}">`}}const rT=(e={})=>{const t={children:[]};return Object.assign(t,e),t};class oT{constructor(){this.rootNode=rT(),this.stack=[this.rootNode]}get top(){return this.stack[this.stack.length-1]}get root(){return this.rootNode}add(e){this.top.children.push(e)}openNode(e){const t=rT({scope:e});this.add(t),this.stack.push(t)}closeNode(){if(this.stack.length>1)return this.stack.pop()}closeAllNodes(){for(;this.closeNode(););}toJSON(){return JSON.stringify(this.rootNode,null,4)}walk(e){return this.constructor._walk(e,this.rootNode)}static _walk(e,t){return"string"==typeof t?e.addText(t):t.children&&(e.openNode(t),t.children.forEach((t=>this._walk(e,t))),e.closeNode(t)),e}static _collapse(e){"string"!=typeof e&&e.children&&(e.children.every((e=>"string"==typeof e))?e.children=[e.children.join("")]:e.children.forEach((e=>{oT._collapse(e)})))}}class sT extends oT{constructor(e){super(),this.options=e}addText(e){""!==e&&this.add(e)}startScope(e){this.openNode(e)}endScope(){this.closeNode()}__addSublanguage(e,t){const a=e.root;t&&(a.scope=`language:${t}`),this.add(a)}toHTML(){return new iT(this,this.options).value()}finalize(){return this.closeAllNodes(),!0}}function lT(e){return e?"string"==typeof e?e:e.source:null}function cT(e){return mT("(?=",e,")")}function uT(e){return mT("(?:",e,")*")}function dT(e){return mT("(?:",e,")?")}function mT(...e){const t=e.map((e=>lT(e))).join("");return t}function hT(...e){const t=function(e){const t=e[e.length-1];return"object"==typeof t&&t.constructor===Object?(e.splice(e.length-1,1),t):{}}(e),a="("+(t.capture?"":"?:")+e.map((e=>lT(e))).join("|")+")";return a}function pT(e){return new RegExp(e.toString()+"|").exec("").length-1}const gT=/\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;function fT(e,{joinWith:t}){let a=0;return e.map((e=>{a+=1;const t=a;let n=lT(e),i="";for(;n.length>0;){const e=gT.exec(n);if(!e){i+=n;break}i+=n.substring(0,e.index),n=n.substring(e.index+e[0].length),"\\"===e[0][0]&&e[1]?i+="\\"+String(Number(e[1])+t):(i+=e[0],"("===e[0]&&a++)}return i})).map((e=>`(${e})`)).join(t)}const yT="[a-zA-Z]\\w*",bT="[a-zA-Z_]\\w*",vT="\\b\\d+(\\.\\d+)?",wT="(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",xT="\\b(0b[01]+)",kT={begin:"\\\\[\\s\\S]",relevance:0},AT={scope:"string",begin:"'",end:"'",illegal:"\\n",contains:[kT]},ST={scope:"string",begin:'"',end:'"',illegal:"\\n",contains:[kT]},ET=function(e,t,a={}){const n=aT({scope:"comment",begin:e,end:t,contains:[]},a);n.contains.push({scope:"doctag",begin:"[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",end:/(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,excludeBegin:!0,relevance:0});const i=hT("I","a","is","so","us","to","at","if","in","it","on",/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,/[A-Za-z]+[-][a-z]+/,/[A-Za-z][a-z]{2,}/);return n.contains.push({begin:mT(/[ ]+/,"(",i,/[.]?[:]?([.][ ]|[ ])/,"){3}")}),n},_T=ET("//","$"),CT=ET("/\\*","\\*/"),TT=ET("#","$"),PT={scope:"number",begin:vT,relevance:0},OT={scope:"number",begin:wT,relevance:0},DT={scope:"number",begin:xT,relevance:0},MT={scope:"regexp",begin:/\/(?=[^/\n]*\/)/,end:/\/[gimuy]*/,contains:[kT,{begin:/\[/,end:/\]/,relevance:0,contains:[kT]}]},IT={scope:"title",begin:yT,relevance:0},NT={scope:"title",begin:bT,relevance:0},jT={begin:"\\.\\s*"+bT,relevance:0};var zT=Object.freeze({__proto__:null,APOS_STRING_MODE:AT,BACKSLASH_ESCAPE:kT,BINARY_NUMBER_MODE:DT,BINARY_NUMBER_RE:xT,COMMENT:ET,C_BLOCK_COMMENT_MODE:CT,C_LINE_COMMENT_MODE:_T,C_NUMBER_MODE:OT,C_NUMBER_RE:wT,END_SAME_AS_BEGIN:function(e){return Object.assign(e,{"on:begin":(e,t)=>{t.data._beginMatch=e[1]},"on:end":(e,t)=>{t.data._beginMatch!==e[1]&&t.ignoreMatch()}})},HASH_COMMENT_MODE:TT,IDENT_RE:yT,MATCH_NOTHING_RE:/\b\B/,METHOD_GUARD:jT,NUMBER_MODE:PT,NUMBER_RE:vT,PHRASAL_WORDS_MODE:{begin:/\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/},QUOTE_STRING_MODE:ST,REGEXP_MODE:MT,RE_STARTERS_RE:"!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",SHEBANG:(e={})=>{const t=/^#![ ]*\//;return e.binary&&(e.begin=mT(t,/.*\b/,e.binary,/\b.*/)),aT({scope:"meta",begin:t,end:/$/,relevance:0,"on:begin":(e,t)=>{0!==e.index&&t.ignoreMatch()}},e)},TITLE_MODE:IT,UNDERSCORE_IDENT_RE:bT,UNDERSCORE_TITLE_MODE:NT});function RT(e,t){"."===e.input[e.index-1]&&t.ignoreMatch()}function LT(e,t){void 0!==e.className&&(e.scope=e.className,delete e.className)}function FT(e,t){t&&e.beginKeywords&&(e.begin="\\b("+e.beginKeywords.split(" ").join("|")+")(?!\\.)(?=\\b|\\s)",e.__beforeBegin=RT,e.keywords=e.keywords||e.beginKeywords,delete e.beginKeywords,void 0===e.relevance&&(e.relevance=0))}function BT(e,t){Array.isArray(e.illegal)&&(e.illegal=hT(...e.illegal))}function HT(e,t){if(e.match){if(e.begin||e.end)throw new Error("begin & end are not supported with match");e.begin=e.match,delete e.match}}function qT(e,t){void 0===e.relevance&&(e.relevance=1)}const UT=(e,t)=>{if(!e.beforeMatch)return;if(e.starts)throw new Error("beforeMatch cannot be used with starts");const a=Object.assign({},e);Object.keys(e).forEach((t=>{delete e[t]})),e.keywords=a.keywords,e.begin=mT(a.beforeMatch,cT(a.begin)),e.starts={relevance:0,contains:[Object.assign(a,{endsParent:!0})]},e.relevance=0,delete a.beforeMatch},WT=["of","and","for","in","not","or","if","then","parent","list","value"],VT="keyword";function $T(e,t,a=VT){const n=Object.create(null);return"string"==typeof e?i(a,e.split(" ")):Array.isArray(e)?i(a,e):Object.keys(e).forEach((function(a){Object.assign(n,$T(e[a],t,a))})),n;function i(e,a){t&&(a=a.map((e=>e.toLowerCase()))),a.forEach((function(t){const a=t.split("|");n[a[0]]=[e,GT(a[0],a[1])]}))}}function GT(e,t){return t?Number(t):function(e){return WT.includes(e.toLowerCase())}(e)?0:1}const KT={},ZT=e=>{console.error(e)},YT=(e,...t)=>{console.log(`WARN: ${e}`,...t)},XT=(e,t)=>{KT[`${e}/${t}`]||(console.log(`Deprecated as of ${e}. ${t}`),KT[`${e}/${t}`]=!0)},QT=new Error;function JT(e,t,{key:a}){let n=0;const i=e[a],r={},o={};for(let e=1;e<=t.length;e++)o[e+n]=i[e],r[e+n]=!0,n+=pT(t[e-1]);e[a]=o,e[a]._emit=r,e[a]._multi=!0}function eP(e){!function(e){e.scope&&"object"==typeof e.scope&&null!==e.scope&&(e.beginScope=e.scope,delete e.scope)}(e),"string"==typeof e.beginScope&&(e.beginScope={_wrap:e.beginScope}),"string"==typeof e.endScope&&(e.endScope={_wrap:e.endScope}),function(e){if(Array.isArray(e.begin)){if(e.skip||e.excludeBegin||e.returnBegin)throw ZT("skip, excludeBegin, returnBegin not compatible with beginScope: {}"),QT;if("object"!=typeof e.beginScope||null===e.beginScope)throw ZT("beginScope must be object"),QT;JT(e,e.begin,{key:"beginScope"}),e.begin=fT(e.begin,{joinWith:""})}}(e),function(e){if(Array.isArray(e.end)){if(e.skip||e.excludeEnd||e.returnEnd)throw ZT("skip, excludeEnd, returnEnd not compatible with endScope: {}"),QT;if("object"!=typeof e.endScope||null===e.endScope)throw ZT("endScope must be object"),QT;JT(e,e.end,{key:"endScope"}),e.end=fT(e.end,{joinWith:""})}}(e)}function tP(e){function t(t,a){return new RegExp(lT(t),"m"+(e.case_insensitive?"i":"")+(e.unicodeRegex?"u":"")+(a?"g":""))}class a{constructor(){this.matchIndexes={},this.regexes=[],this.matchAt=1,this.position=0}addRule(e,t){t.position=this.position++,this.matchIndexes[this.matchAt]=t,this.regexes.push([t,e]),this.matchAt+=pT(e)+1}compile(){0===this.regexes.length&&(this.exec=()=>null);const e=this.regexes.map((e=>e[1]));this.matcherRe=t(fT(e,{joinWith:"|"}),!0),this.lastIndex=0}exec(e){this.matcherRe.lastIndex=this.lastIndex;const t=this.matcherRe.exec(e);if(!t)return null;const a=t.findIndex(((e,t)=>t>0&&void 0!==e)),n=this.matchIndexes[a];return t.splice(0,a),Object.assign(t,n)}}class n{constructor(){this.rules=[],this.multiRegexes=[],this.count=0,this.lastIndex=0,this.regexIndex=0}getMatcher(e){if(this.multiRegexes[e])return this.multiRegexes[e];const t=new a;return this.rules.slice(e).forEach((([e,a])=>t.addRule(e,a))),t.compile(),this.multiRegexes[e]=t,t}resumingScanAtSamePosition(){return 0!==this.regexIndex}considerAll(){this.regexIndex=0}addRule(e,t){this.rules.push([e,t]),"begin"===t.type&&this.count++}exec(e){const t=this.getMatcher(this.regexIndex);t.lastIndex=this.lastIndex;let a=t.exec(e);if(this.resumingScanAtSamePosition())if(a&&a.index===this.lastIndex);else{const t=this.getMatcher(0);t.lastIndex=this.lastIndex+1,a=t.exec(e)}return a&&(this.regexIndex+=a.position+1,this.regexIndex===this.count&&this.considerAll()),a}}if(e.compilerExtensions||(e.compilerExtensions=[]),e.contains&&e.contains.includes("self"))throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");return e.classNameAliases=aT(e.classNameAliases||{}),function a(i,r){const o=i;if(i.isCompiled)return o;[LT,HT,eP,UT].forEach((e=>e(i,r))),e.compilerExtensions.forEach((e=>e(i,r))),i.__beforeBegin=null,[FT,BT,qT].forEach((e=>e(i,r))),i.isCompiled=!0;let s=null;return"object"==typeof i.keywords&&i.keywords.$pattern&&(i.keywords=Object.assign({},i.keywords),s=i.keywords.$pattern,delete i.keywords.$pattern),s=s||/\w+/,i.keywords&&(i.keywords=$T(i.keywords,e.case_insensitive)),o.keywordPatternRe=t(s,!0),r&&(i.begin||(i.begin=/\B|\b/),o.beginRe=t(o.begin),i.end||i.endsWithParent||(i.end=/\B|\b/),i.end&&(o.endRe=t(o.end)),o.terminatorEnd=lT(o.end)||"",i.endsWithParent&&r.terminatorEnd&&(o.terminatorEnd+=(i.end?"|":"")+r.terminatorEnd)),i.illegal&&(o.illegalRe=t(i.illegal)),i.contains||(i.contains=[]),i.contains=[].concat(...i.contains.map((function(e){return function(e){e.variants&&!e.cachedVariants&&(e.cachedVariants=e.variants.map((function(t){return aT(e,{variants:null},t)})));if(e.cachedVariants)return e.cachedVariants;if(aP(e))return aT(e,{starts:e.starts?aT(e.starts):null});if(Object.isFrozen(e))return aT(e);return e}("self"===e?i:e)}))),i.contains.forEach((function(e){a(e,o)})),i.starts&&a(i.starts,r),o.matcher=function(e){const t=new n;return e.contains.forEach((e=>t.addRule(e.begin,{rule:e,type:"begin"}))),e.terminatorEnd&&t.addRule(e.terminatorEnd,{type:"end"}),e.illegal&&t.addRule(e.illegal,{type:"illegal"}),t}(o),o}(e)}function aP(e){return!!e&&(e.endsWithParent||aP(e.starts))}class nP extends Error{constructor(e,t){super(e),this.name="HTMLInjectionError",this.html=t}}const iP=tT,rP=aT,oP=Symbol("nomatch"),sP=function(e){const t=Object.create(null),a=Object.create(null),n=[];let i=!0;const r="Could not find the language '{}', did you forget to load/include a language module?",o={disableAutodetect:!0,name:"Plain text",contains:[]};let s={ignoreUnescapedHTML:!1,throwUnescapedHTML:!1,noHighlightRe:/^(no-?highlight)$/i,languageDetectRe:/\blang(?:uage)?-([\w-]+)\b/i,classPrefix:"hljs-",cssSelector:"pre code",languages:null,__emitter:sT};function l(e){return s.noHighlightRe.test(e)}function c(e,t,a){let n="",i="";"object"==typeof t?(n=e,a=t.ignoreIllegals,i=t.language):(XT("10.7.0","highlight(lang, code, ...args) has been deprecated."),XT("10.7.0","Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277"),i=e,n=t),void 0===a&&(a=!0);const r={code:n,language:i};b("before:highlight",r);const o=r.result?r.result:u(r.language,r.code,a);return o.code=r.code,b("after:highlight",o),o}function u(e,a,n,o){const l=Object.create(null);function c(){if(!E.keywords)return void C.addText(T);let e=0;E.keywordPatternRe.lastIndex=0;let t=E.keywordPatternRe.exec(T),a="";for(;t;){a+=T.substring(e,t.index);const i=k.case_insensitive?t[0].toLowerCase():t[0],r=(n=i,E.keywords[n]);if(r){const[e,n]=r;if(C.addText(a),a="",l[i]=(l[i]||0)+1,l[i]<=7&&(P+=n),e.startsWith("_"))a+=t[0];else{const a=k.classNameAliases[e]||e;h(t[0],a)}}else a+=t[0];e=E.keywordPatternRe.lastIndex,t=E.keywordPatternRe.exec(T)}var n;a+=T.substring(e),C.addText(a)}function m(){null!=E.subLanguage?function(){if(""===T)return;let e=null;if("string"==typeof E.subLanguage){if(!t[E.subLanguage])return void C.addText(T);e=u(E.subLanguage,T,!0,_[E.subLanguage]),_[E.subLanguage]=e._top}else e=d(T,E.subLanguage.length?E.subLanguage:null);E.relevance>0&&(P+=e.relevance),C.__addSublanguage(e._emitter,e.language)}():c(),T=""}function h(e,t){""!==e&&(C.startScope(t),C.addText(e),C.endScope())}function p(e,t){let a=1;const n=t.length-1;for(;a<=n;){if(!e._emit[a]){a++;continue}const n=k.classNameAliases[e[a]]||e[a],i=t[a];n?h(i,n):(T=i,c(),T=""),a++}}function f(e,t){return e.scope&&"string"==typeof e.scope&&C.openNode(k.classNameAliases[e.scope]||e.scope),e.beginScope&&(e.beginScope._wrap?(h(T,k.classNameAliases[e.beginScope._wrap]||e.beginScope._wrap),T=""):e.beginScope._multi&&(p(e.beginScope,t),T="")),E=Object.create(e,{parent:{value:E}}),E}function y(e,t,a){let n=function(e,t){const a=e&&e.exec(t);return a&&0===a.index}(e.endRe,a);if(n){if(e["on:end"]){const a=new eT(e);e["on:end"](t,a),a.isMatchIgnored&&(n=!1)}if(n){for(;e.endsParent&&e.parent;)e=e.parent;return e}}if(e.endsWithParent)return y(e.parent,t,a)}function b(e){return 0===E.matcher.regexIndex?(T+=e[0],1):(M=!0,0)}function v(e){const t=e[0],n=a.substring(e.index),i=y(E,e,n);if(!i)return oP;const r=E;E.endScope&&E.endScope._wrap?(m(),h(t,E.endScope._wrap)):E.endScope&&E.endScope._multi?(m(),p(E.endScope,e)):r.skip?T+=t:(r.returnEnd||r.excludeEnd||(T+=t),m(),r.excludeEnd&&(T=t));do{E.scope&&C.closeNode(),E.skip||E.subLanguage||(P+=E.relevance),E=E.parent}while(E!==i.parent);return i.starts&&f(i.starts,e),r.returnEnd?0:t.length}let w={};function x(t,r){const o=r&&r[0];if(T+=t,null==o)return m(),0;if("begin"===w.type&&"end"===r.type&&w.index===r.index&&""===o){if(T+=a.slice(r.index,r.index+1),!i){const t=new Error(`0 width match regex (${e})`);throw t.languageName=e,t.badRule=w.rule,t}return 1}if(w=r,"begin"===r.type)return function(e){const t=e[0],a=e.rule,n=new eT(a),i=[a.__beforeBegin,a["on:begin"]];for(const a of i)if(a&&(a(e,n),n.isMatchIgnored))return b(t);return a.skip?T+=t:(a.excludeBegin&&(T+=t),m(),a.returnBegin||a.excludeBegin||(T=t)),f(a,e),a.returnBegin?0:t.length}(r);if("illegal"===r.type&&!n){const e=new Error('Illegal lexeme "'+o+'" for mode "'+(E.scope||"<unnamed>")+'"');throw e.mode=E,e}if("end"===r.type){const e=v(r);if(e!==oP)return e}if("illegal"===r.type&&""===o)return 1;if(D>1e5&&D>3*r.index){throw new Error("potential infinite loop, way more iterations than matches")}return T+=o,o.length}const k=g(e);if(!k)throw ZT(r.replace("{}",e)),new Error('Unknown language: "'+e+'"');const A=tP(k);let S="",E=o||A;const _={},C=new s.__emitter(s);!function(){const e=[];for(let t=E;t!==k;t=t.parent)t.scope&&e.unshift(t.scope);e.forEach((e=>C.openNode(e)))}();let T="",P=0,O=0,D=0,M=!1;try{if(k.__emitTokens)k.__emitTokens(a,C);else{for(E.matcher.considerAll();;){D++,M?M=!1:E.matcher.considerAll(),E.matcher.lastIndex=O;const e=E.matcher.exec(a);if(!e)break;const t=x(a.substring(O,e.index),e);O=e.index+t}x(a.substring(O))}return C.finalize(),S=C.toHTML(),{language:e,value:S,relevance:P,illegal:!1,_emitter:C,_top:E}}catch(t){if(t.message&&t.message.includes("Illegal"))return{language:e,value:iP(a),illegal:!0,relevance:0,_illegalBy:{message:t.message,index:O,context:a.slice(O-100,O+100),mode:t.mode,resultSoFar:S},_emitter:C};if(i)return{language:e,value:iP(a),illegal:!1,relevance:0,errorRaised:t,_emitter:C,_top:E};throw t}}function d(e,a){a=a||s.languages||Object.keys(t);const n=function(e){const t={value:iP(e),illegal:!1,relevance:0,_top:o,_emitter:new s.__emitter(s)};return t._emitter.addText(e),t}(e),i=a.filter(g).filter(y).map((t=>u(t,e,!1)));i.unshift(n);const r=i.sort(((e,t)=>{if(e.relevance!==t.relevance)return t.relevance-e.relevance;if(e.language&&t.language){if(g(e.language).supersetOf===t.language)return 1;if(g(t.language).supersetOf===e.language)return-1}return 0})),[l,c]=r,d=l;return d.secondBest=c,d}function m(e){let t=null;const n=function(e){let t=e.className+" ";t+=e.parentNode?e.parentNode.className:"";const a=s.languageDetectRe.exec(t);if(a){const t=g(a[1]);return t||(YT(r.replace("{}",a[1])),YT("Falling back to no-highlight mode for this block.",e)),t?a[1]:"no-highlight"}return t.split(/\s+/).find((e=>l(e)||g(e)))}(e);if(l(n))return;if(b("before:highlightElement",{el:e,language:n}),e.dataset.highlighted)return void console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.",e);if(e.children.length>0&&(s.ignoreUnescapedHTML||(console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk."),console.warn("https://github.com/highlightjs/highlight.js/wiki/security"),console.warn("The element with unescaped HTML:"),console.warn(e)),s.throwUnescapedHTML)){throw new nP("One of your code blocks includes unescaped HTML.",e.innerHTML)}t=e;const i=t.textContent,o=n?c(i,{language:n,ignoreIllegals:!0}):d(i);e.innerHTML=o.value,e.dataset.highlighted="yes",function(e,t,n){const i=t&&a[t]||n;e.classList.add("hljs"),e.classList.add(`language-${i}`)}(e,n,o.language),e.result={language:o.language,re:o.relevance,relevance:o.relevance},o.secondBest&&(e.secondBest={language:o.secondBest.language,relevance:o.secondBest.relevance}),b("after:highlightElement",{el:e,result:o,text:i})}let h=!1;function p(){if("loading"===document.readyState)return void(h=!0);document.querySelectorAll(s.cssSelector).forEach(m)}function g(e){return e=(e||"").toLowerCase(),t[e]||t[a[e]]}function f(e,{languageName:t}){"string"==typeof e&&(e=[e]),e.forEach((e=>{a[e.toLowerCase()]=t}))}function y(e){const t=g(e);return t&&!t.disableAutodetect}function b(e,t){const a=e;n.forEach((function(e){e[a]&&e[a](t)}))}"undefined"!=typeof window&&window.addEventListener&&window.addEventListener("DOMContentLoaded",(function(){h&&p()}),!1),Object.assign(e,{highlight:c,highlightAuto:d,highlightAll:p,highlightElement:m,highlightBlock:function(e){return XT("10.7.0","highlightBlock will be removed entirely in v12.0"),XT("10.7.0","Please use highlightElement now."),m(e)},configure:function(e){s=rP(s,e)},initHighlighting:()=>{p(),XT("10.6.0","initHighlighting() deprecated. Use highlightAll() now.")},initHighlightingOnLoad:function(){p(),XT("10.6.0","initHighlightingOnLoad() deprecated. Use highlightAll() now.")},registerLanguage:function(a,n){let r=null;try{r=n(e)}catch(e){if(ZT("Language definition for '{}' could not be registered.".replace("{}",a)),!i)throw e;ZT(e),r=o}r.name||(r.name=a),t[a]=r,r.rawDefinition=n.bind(null,e),r.aliases&&f(r.aliases,{languageName:a})},unregisterLanguage:function(e){delete t[e];for(const t of Object.keys(a))a[t]===e&&delete a[t]},listLanguages:function(){return Object.keys(t)},getLanguage:g,registerAliases:f,autoDetection:y,inherit:rP,addPlugin:function(e){!function(e){e["before:highlightBlock"]&&!e["before:highlightElement"]&&(e["before:highlightElement"]=t=>{e["before:highlightBlock"](Object.assign({block:t.el},t))}),e["after:highlightBlock"]&&!e["after:highlightElement"]&&(e["after:highlightElement"]=t=>{e["after:highlightBlock"](Object.assign({block:t.el},t))})}(e),n.push(e)},removePlugin:function(e){const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}),e.debugMode=function(){i=!1},e.safeMode=function(){i=!0},e.versionString="11.10.0",e.regex={concat:mT,lookahead:cT,either:hT,optional:dT,anyNumberOfTimes:uT};for(const e in zT)"object"==typeof zT[e]&&JC(zT[e]);return Object.assign(e,zT),e},lP=sP({});lP.newInstance=()=>sP({});var cP=lP;lP.HighlightJS=lP,lP.default=lP;var uP=Gt(cP);const dP="[A-Za-z$_][0-9A-Za-z$_]*",mP=["as","in","of","if","for","while","finally","var","new","function","do","return","void","else","break","catch","instanceof","with","throw","case","default","try","switch","continue","typeof","delete","let","yield","const","class","debugger","async","await","static","import","from","export","extends"],hP=["true","false","null","undefined","NaN","Infinity"],pP=["Object","Function","Boolean","Symbol","Math","Date","Number","BigInt","String","RegExp","Array","Float32Array","Float64Array","Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Int32Array","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array","Set","Map","WeakSet","WeakMap","ArrayBuffer","SharedArrayBuffer","Atomics","DataView","JSON","Promise","Generator","GeneratorFunction","AsyncFunction","Reflect","Proxy","Intl","WebAssembly"],gP=["Error","EvalError","InternalError","RangeError","ReferenceError","SyntaxError","TypeError","URIError"],fP=["setInterval","setTimeout","clearInterval","clearTimeout","require","exports","eval","isFinite","isNaN","parseFloat","parseInt","decodeURI","decodeURIComponent","encodeURI","encodeURIComponent","escape","unescape"],yP=["arguments","this","super","console","window","document","localStorage","sessionStorage","module","global"],bP=[].concat(fP,pP,gP);var vP={},wP={},xP={};Object.defineProperty(xP,"__esModule",{value:!0}),xP.default=function(e){var t,a,n=e.match(EP),i=n&&n[1]?n[1].toLowerCase():"";switch(i){case kP:var r=PP(e);if(!_P.test(e))null===(t=null==(s=r.querySelector(AP))?void 0:s.parentNode)||void 0===t||t.removeChild(s);if(!CP.test(e))null===(a=null==(s=r.querySelector(SP))?void 0:s.parentNode)||void 0===a||a.removeChild(s);return r.querySelectorAll(kP);case AP:case SP:var o=TP(e).querySelectorAll(i);return CP.test(e)&&_P.test(e)?o[0].parentNode.childNodes:o;default:return IP?IP(e):(s=TP(e,SP).querySelector(SP)).childNodes;var s}};var kP="html",AP="head",SP="body",EP=/<([a-zA-Z]+[0-9]?)/,_P=/<head[^]*>/i,CP=/<body[^]*>/i,TP=function(e,t){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},PP=function(e,t){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")},OP="object"==typeof window&&window.DOMParser;if("function"==typeof OP){var DP=new OP;TP=PP=function(e,t){return t&&(e="<".concat(t,">").concat(e,"</").concat(t,">")),DP.parseFromString(e,"text/html")}}if("object"==typeof document&&document.implementation){var MP=document.implementation.createHTMLDocument();TP=function(e,t){if(t){var a=MP.documentElement.querySelector(t);return a&&(a.innerHTML=e),MP}return MP.documentElement.innerHTML=e,MP}}var IP,NP="object"==typeof document&&document.createElement("template");NP&&NP.content&&(IP=function(e){return NP.innerHTML=e,NP.content.childNodes});var jP,zP,RP={},LP={},FP={};jP=FP,Object.defineProperty(jP,"__esModule",{value:!0}),jP.Doctype=jP.CDATA=jP.Tag=jP.Style=jP.Script=jP.Comment=jP.Directive=jP.Text=jP.Root=jP.isTag=jP.ElementType=void 0,function(e){e.Root="root",e.Text="text",e.Directive="directive",e.Comment="comment",e.Script="script",e.Style="style",e.Tag="tag",e.CDATA="cdata",e.Doctype="doctype"}(zP=jP.ElementType||(jP.ElementType={})),jP.isTag=function(e){return e.type===zP.Tag||e.type===zP.Script||e.type===zP.Style},jP.Root=zP.Root,jP.Text=zP.Text,jP.Directive=zP.Directive,jP.Comment=zP.Comment,jP.Script=zP.Script,jP.Style=zP.Style,jP.Tag=zP.Tag,jP.CDATA=zP.CDATA,jP.Doctype=zP.Doctype;var BP,HP={},qP=$t&&$t.__extends||(BP=function(e,t){return BP=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])},BP(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function a(){this.constructor=e}BP(e,t),e.prototype=null===t?Object.create(t):(a.prototype=t.prototype,new a)}),UP=$t&&$t.__assign||function(){return UP=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var i in t=arguments[a])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},UP.apply(this,arguments)};Object.defineProperty(HP,"__esModule",{value:!0}),HP.cloneNode=HP.hasChildren=HP.isDocument=HP.isDirective=HP.isComment=HP.isText=HP.isCDATA=HP.isTag=HP.Element=HP.Document=HP.CDATA=HP.NodeWithChildren=HP.ProcessingInstruction=HP.Comment=HP.Text=HP.DataNode=HP.Node=void 0;var WP=FP,VP=function(){function e(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(e){return void 0===e&&(e=!1),oO(this,e)},e}();HP.Node=VP;var $P=function(e){function t(t){var a=e.call(this)||this;return a.data=t,a}return qP(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(VP);HP.DataNode=$P;var GP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Text,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),t}($P);HP.Text=GP;var KP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Comment,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),t}($P);HP.Comment=KP;var ZP=function(e){function t(t,a){var n=e.call(this,a)||this;return n.name=t,n.type=WP.ElementType.Directive,n}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),t}($P);HP.ProcessingInstruction=ZP;var YP=function(e){function t(t){var a=e.call(this)||this;return a.children=t,a}return qP(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return null!==(e=this.children[0])&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(VP);HP.NodeWithChildren=YP;var XP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.CDATA,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),t}(YP);HP.CDATA=XP;var QP=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=WP.ElementType.Root,t}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),t}(YP);HP.Document=QP;var JP=function(e){function t(t,a,n,i){void 0===n&&(n=[]),void 0===i&&(i="script"===t?WP.ElementType.Script:"style"===t?WP.ElementType.Style:WP.ElementType.Tag);var r=e.call(this,n)||this;return r.name=t,r.attribs=a,r.type=i,r}return qP(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map((function(t){var a,n;return{name:t,value:e.attribs[t],namespace:null===(a=e["x-attribsNamespace"])||void 0===a?void 0:a[t],prefix:null===(n=e["x-attribsPrefix"])||void 0===n?void 0:n[t]}}))},enumerable:!1,configurable:!0}),t}(YP);function eO(e){return(0,WP.isTag)(e)}function tO(e){return e.type===WP.ElementType.CDATA}function aO(e){return e.type===WP.ElementType.Text}function nO(e){return e.type===WP.ElementType.Comment}function iO(e){return e.type===WP.ElementType.Directive}function rO(e){return e.type===WP.ElementType.Root}function oO(e,t){var a;if(void 0===t&&(t=!1),aO(e))a=new GP(e.data);else if(nO(e))a=new KP(e.data);else if(eO(e)){var n=t?sO(e.children):[],i=new JP(e.name,UP({},e.attribs),n);n.forEach((function(e){return e.parent=i})),null!=e.namespace&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]=UP({},e["x-attribsNamespace"])),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]=UP({},e["x-attribsPrefix"])),a=i}else if(tO(e)){n=t?sO(e.children):[];var r=new XP(n);n.forEach((function(e){return e.parent=r})),a=r}else if(rO(e)){n=t?sO(e.children):[];var o=new QP(n);n.forEach((function(e){return e.parent=o})),e["x-mode"]&&(o["x-mode"]=e["x-mode"]),a=o}else{if(!iO(e))throw new Error("Not implemented yet: ".concat(e.type));var s=new ZP(e.name,e.data);null!=e["x-name"]&&(s["x-name"]=e["x-name"],s["x-publicId"]=e["x-publicId"],s["x-systemId"]=e["x-systemId"]),a=s}return a.startIndex=e.startIndex,a.endIndex=e.endIndex,null!=e.sourceCodeLocation&&(a.sourceCodeLocation=e.sourceCodeLocation),a}function sO(e){for(var t=e.map((function(e){return oO(e,!0)})),a=1;a<t.length;a++)t[a].prev=t[a-1],t[a-1].next=t[a];return t}HP.Element=JP,HP.isTag=eO,HP.isCDATA=tO,HP.isText=aO,HP.isComment=nO,HP.isDirective=iO,HP.isDocument=rO,HP.hasChildren=function(e){return Object.prototype.hasOwnProperty.call(e,"children")},HP.cloneNode=oO,function(e){var t=$t&&$t.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var i=Object.getOwnPropertyDescriptor(t,a);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,i)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),a=$t&&$t.__exportStar||function(e,a){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(a,n)||t(a,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var n=FP,i=HP;a(HP,e);var r={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function e(e,t,a){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,"function"==typeof t&&(a=t,t=r),"object"==typeof e&&(t=e,e=void 0),this.callback=null!=e?e:null,this.options=null!=t?t:r,this.elementCB=null!=a?a:null}return e.prototype.onparserinit=function(e){this.parser=e},e.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},e.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},e.prototype.onerror=function(e){this.handleCallback(e)},e.prototype.onclosetag=function(){this.lastNode=null;var e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)},e.prototype.onopentag=function(e,t){var a=this.options.xmlMode?n.ElementType.Tag:void 0,r=new i.Element(e,t,void 0,a);this.addNode(r),this.tagStack.push(r)},e.prototype.ontext=function(e){var t=this.lastNode;if(t&&t.type===n.ElementType.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{var a=new i.Text(e);this.addNode(a),this.lastNode=a}},e.prototype.oncomment=function(e){if(this.lastNode&&this.lastNode.type===n.ElementType.Comment)this.lastNode.data+=e;else{var t=new i.Comment(e);this.addNode(t),this.lastNode=t}},e.prototype.oncommentend=function(){this.lastNode=null},e.prototype.oncdatastart=function(){var e=new i.Text(""),t=new i.CDATA([e]);this.addNode(t),e.parent=t,this.lastNode=e},e.prototype.oncdataend=function(){this.lastNode=null},e.prototype.onprocessinginstruction=function(e,t){var a=new i.ProcessingInstruction(e,t);this.addNode(a)},e.prototype.handleCallback=function(e){if("function"==typeof this.callback)this.callback(e,this.dom);else if(e)throw e},e.prototype.addNode=function(e){var t=this.tagStack[this.tagStack.length-1],a=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),a&&(e.prev=a,a.next=e),e.parent=t,this.lastNode=null},e}();e.DomHandler=o,e.default=o}(LP);var lO={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES=void 0,e.CASE_SENSITIVE_TAG_NAMES=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],e.CASE_SENSITIVE_TAG_NAMES_MAP=e.CASE_SENSITIVE_TAG_NAMES.reduce((function(e,t){return e[t.toLowerCase()]=t,e}),{})}(lO),Object.defineProperty(RP,"__esModule",{value:!0}),RP.formatAttributes=dO,RP.formatDOM=function e(t,a,n){void 0===a&&(a=null);for(var i,r=[],o=0,s=t.length;o<s;o++){var l=t[o];switch(l.nodeType){case 1:var c=mO(l.nodeName);(i=new cO.Element(c,dO(l.attributes))).children=e("template"===c?l.content.childNodes:l.childNodes,i);break;case 3:i=new cO.Text(l.nodeValue);break;case 8:i=new cO.Comment(l.nodeValue);break;default:continue}var u=r[o-1]||null;u&&(u.next=i),i.parent=a,i.prev=u,i.next=null,r.push(i)}n&&((i=new cO.ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n)).next=r[0]||null,i.parent=a,r.unshift(i),r[1]&&(r[1].prev=r[0]));return r};var cO=LP,uO=lO;function dO(e){for(var t={},a=0,n=e.length;a<n;a++){var i=e[a];t[i.name]=i.value}return t}function mO(e){var t=function(e){return uO.CASE_SENSITIVE_TAG_NAMES_MAP[e]}(e=e.toLowerCase());return t||e}var hO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(wP,"__esModule",{value:!0}),wP.default=function(e){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];var t=e.match(fO),a=t?t[1]:void 0;return(0,gO.formatDOM)((0,pO.default)(e),null,a)};var pO=hO(xP),gO=RP,fO=/<(![a-zA-Z\s]+)>/;var yO={},bO={},vO={};vO.SAME=0;vO.CAMELCASE=1,vO.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1};function wO(e,t,a,n,i,r,o){this.acceptsBooleans=2===t||3===t||4===t,this.attributeName=n,this.attributeNamespace=i,this.mustUseProperty=a,this.propertyName=e,this.type=t,this.sanitizeURL=r,this.removeEmptyString=o}const xO={};["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"].forEach((e=>{xO[e]=new wO(e,0,!1,e,null,!1,!1)})),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach((([e,t])=>{xO[e]=new wO(e,1,!1,t,null,!1,!1)})),["contentEditable","draggable","spellCheck","value"].forEach((e=>{xO[e]=new wO(e,2,!1,e.toLowerCase(),null,!1,!1)})),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach((e=>{xO[e]=new wO(e,2,!1,e,null,!1,!1)})),["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach((e=>{xO[e]=new wO(e,3,!1,e.toLowerCase(),null,!1,!1)})),["checked","multiple","muted","selected"].forEach((e=>{xO[e]=new wO(e,3,!0,e,null,!1,!1)})),["capture","download"].forEach((e=>{xO[e]=new wO(e,4,!1,e,null,!1,!1)})),["cols","rows","size","span"].forEach((e=>{xO[e]=new wO(e,6,!1,e,null,!1,!1)})),["rowSpan","start"].forEach((e=>{xO[e]=new wO(e,5,!1,e.toLowerCase(),null,!1,!1)}));const kO=/[\-\:]([a-z])/g,AO=e=>e[1].toUpperCase();["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,null,!1,!1)})),["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)})),["xml:base","xml:lang","xml:space"].forEach((e=>{const t=e.replace(kO,AO);xO[t]=new wO(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)})),["tabIndex","crossOrigin"].forEach((e=>{xO[e]=new wO(e,1,!1,e.toLowerCase(),null,!1,!1)}));xO.xlinkHref=new wO("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach((e=>{xO[e]=new wO(e,1,!1,e.toLowerCase(),null,!0,!0)}));const{CAMELCASE:SO,SAME:EO,possibleStandardNames:_O}=vO,CO=RegExp.prototype.test.bind(new RegExp("^(data|aria)-[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$")),TO=Object.keys(_O).reduce(((e,t)=>{const a=_O[t];return a===EO?e[t]=t:a===SO?e[t.toLowerCase()]=t:e[t]=a,e}),{});bO.BOOLEAN=3,bO.BOOLEANISH_STRING=2,bO.NUMERIC=5,bO.OVERLOADED_BOOLEAN=4,bO.POSITIVE_NUMERIC=6,bO.RESERVED=0,bO.STRING=1,bO.getPropertyInfo=function(e){return xO.hasOwnProperty(e)?xO[e]:null},bO.isCustomAttribute=CO,bO.possibleStandardNames=TO;var PO={},OO={},DO=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,MO=/\n/g,IO=/^\s*/,NO=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,jO=/^:\s*/,zO=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,RO=/^[;\s]*/,LO=/^\s+|\s+$/g,FO="";function BO(e){return e?e.replace(LO,FO):FO}var HO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(OO,"__esModule",{value:!0});var qO=HO((function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var a=1,n=1;function i(e){var t=e.match(MO);t&&(a+=t.length);var i=e.lastIndexOf("\n");n=~i?e.length-i:n+e.length}function r(){var e={line:a,column:n};return function(t){return t.position=new o(e),c(),t}}function o(e){this.start=e,this.end={line:a,column:n},this.source=t.source}function s(i){var r=new Error(t.source+":"+a+":"+n+": "+i);if(r.reason=i,r.filename=t.source,r.line=a,r.column=n,r.source=e,!t.silent)throw r}function l(t){var a=t.exec(e);if(a){var n=a[0];return i(n),e=e.slice(n.length),a}}function c(){l(IO)}function u(e){var t;for(e=e||[];t=d();)!1!==t&&e.push(t);return e}function d(){var t=r();if("/"==e.charAt(0)&&"*"==e.charAt(1)){for(var a=2;FO!=e.charAt(a)&&("*"!=e.charAt(a)||"/"!=e.charAt(a+1));)++a;if(a+=2,FO===e.charAt(a-1))return s("End of comment missing");var o=e.slice(2,a-2);return n+=2,i(o),e=e.slice(a),n+=2,t({type:"comment",comment:o})}}function m(){var e=r(),t=l(NO);if(t){if(d(),!l(jO))return s("property missing ':'");var a=l(zO),n=e({type:"declaration",property:BO(t[0].replace(DO,FO)),value:a?BO(a[0].replace(DO,FO)):FO});return l(RO),n}}return o.prototype.content=e,c(),function(){var e,t=[];for(u(t);e=m();)!1!==e&&(t.push(e),u(t));return t}()}));OO.default=function(e,t){var a=null;if(!e||"string"!=typeof e)return a;var n=(0,qO.default)(e),i="function"==typeof t;return n.forEach((function(e){if("declaration"===e.type){var n=e.property,r=e.value;i?t(n,r,e):r&&((a=a||{})[n]=r)}})),a};var UO={};Object.defineProperty(UO,"__esModule",{value:!0}),UO.camelCase=void 0;var WO=/^--[a-zA-Z0-9-]+$/,VO=/-([a-z])/g,$O=/^[^-]+$/,GO=/^-(webkit|moz|ms|o|khtml)-/,KO=/^-(ms)-/,ZO=function(e,t){return t.toUpperCase()},YO=function(e,t){return"".concat(t,"-")};UO.camelCase=function(e,t){return void 0===t&&(t={}),function(e){return!e||$O.test(e)||WO.test(e)}(e)?e:(e=e.toLowerCase(),(e=t.reactCompat?e.replace(KO,YO):e.replace(GO,YO)).replace(VO,ZO))};var XO=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},QO=XO(OO),JO=UO;function eD(e,t){var a={};return e&&"string"==typeof e?((0,QO.default)(e,(function(e,n){e&&n&&(a[(0,JO.camelCase)(e,t)]=n)})),a):a}eD.default=eD;var tD=eD;!function(e){var a=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.returnFirstArg=e.canTextBeChildOfNode=e.ELEMENTS_WITH_NO_TEXT_CHILDREN=e.PRESERVE_CUSTOM_ATTRIBUTES=void 0,e.isCustomComponent=function(e,t){if(!e.includes("-"))return Boolean(t&&"string"==typeof t.is);if(r.has(e))return!1;return!0},e.setStyleProp=function(e,t){if("string"!=typeof e)return;if(!e.trim())return void(t.style={});try{t.style=(0,i.default)(e,o)}catch(e){t.style={}}};var n=t,i=a(tD),r=new Set(["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"]);var o={reactCompat:!0};e.PRESERVE_CUSTOM_ATTRIBUTES=Number(n.version.split(".")[0])>=16,e.ELEMENTS_WITH_NO_TEXT_CHILDREN=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);e.canTextBeChildOfNode=function(t){return!e.ELEMENTS_WITH_NO_TEXT_CHILDREN.has(t.name)};e.returnFirstArg=function(e){return e}}(PO),Object.defineProperty(yO,"__esModule",{value:!0}),yO.default=function(e,t){void 0===e&&(e={});var a={},n=Boolean(e.type&&oD[e.type]);for(var i in e){var r=e[i];if((0,aD.isCustomAttribute)(i))a[i]=r;else{var o=i.toLowerCase(),s=sD(o);if(s){var l=(0,aD.getPropertyInfo)(s);switch(iD.includes(s)&&rD.includes(t)&&!n&&(s=sD("default"+o)),a[s]=r,l&&l.type){case aD.BOOLEAN:a[s]=!0;break;case aD.OVERLOADED_BOOLEAN:""===r&&(a[s]=!0)}}else nD.PRESERVE_CUSTOM_ATTRIBUTES&&(a[i]=r)}}return(0,nD.setStyleProp)(e.style,a),a};var aD=bO,nD=PO,iD=["checked","value"],rD=["input","select","textarea"],oD={reset:!0,submit:!0};function sD(e){return aD.possibleStandardNames[e]}var lD={},cD=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(lD,"__esModule",{value:!0}),lD.default=function e(t,a){void 0===a&&(a={});for(var n=[],i="function"==typeof a.replace,r=a.transform||mD.returnFirstArg,o=a.library||hD,s=o.cloneElement,l=o.createElement,c=o.isValidElement,u=t.length,d=0;d<u;d++){var m=t[d];if(i){var h=a.replace(m,d);if(c(h)){u>1&&(h=s(h,{key:h.key||d})),n.push(r(h,m,d));continue}}if("text"!==m.type){var p=m,g={};pD(p)?((0,mD.setStyleProp)(p.attribs.style,p.attribs),g=p.attribs):p.attribs&&(g=(0,dD.default)(p.attribs,p.name));var f=void 0;switch(m.type){case"script":case"style":m.children[0]&&(g.dangerouslySetInnerHTML={__html:m.children[0].data});break;case"tag":"textarea"===m.name&&m.children[0]?g.defaultValue=m.children[0].data:m.children&&m.children.length&&(f=e(m.children,a));break;default:continue}u>1&&(g.key=d),n.push(r(l(m.name,g,f),m,d))}else{var y=!m.data.trim().length;if(y&&m.parent&&!(0,mD.canTextBeChildOfNode)(m.parent))continue;if(a.trim&&y)continue;n.push(r(m.data,m,d))}}return 1===n.length?n[0]:n};var uD=t,dD=cD(yO),mD=PO,hD={cloneElement:uD.cloneElement,createElement:uD.createElement,isValidElement:uD.isValidElement};function pD(e){return mD.PRESERVE_CUSTOM_ATTRIBUTES&&"tag"===e.type&&(0,mD.isCustomComponent)(e.name,e.attribs)}var gD={},fD={},yD=$t&&$t.__extends||function(){var e=function(t,a){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])},e(t,a)};return function(t,a){if("function"!=typeof a&&null!==a)throw new TypeError("Class extends value "+String(a)+" is not a constructor or null");function n(){this.constructor=t}e(t,a),t.prototype=null===a?Object.create(a):(n.prototype=a.prototype,new n)}}(),bD=$t&&$t.__assign||function(){return bD=Object.assign||function(e){for(var t,a=1,n=arguments.length;a<n;a++)for(var i in t=arguments[a])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},bD.apply(this,arguments)};Object.defineProperty(fD,"__esModule",{value:!0}),fD.cloneNode=fD.hasChildren=fD.isDocument=fD.isDirective=fD.isComment=fD.isText=fD.isCDATA=fD.isTag=fD.Element=fD.Document=fD.CDATA=fD.NodeWithChildren=fD.ProcessingInstruction=fD.Comment=fD.Text=fD.DataNode=fD.Node=void 0;var vD=FP,wD=function(){function e(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(e.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),e.prototype.cloneNode=function(e){return void 0===e&&(e=!1),jD(this,e)},e}();fD.Node=wD;var xD=function(e){function t(t){var a=e.call(this)||this;return a.data=t,a}return yD(t,e),Object.defineProperty(t.prototype,"nodeValue",{get:function(){return this.data},set:function(e){this.data=e},enumerable:!1,configurable:!0}),t}(wD);fD.DataNode=xD;var kD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Text,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 3},enumerable:!1,configurable:!0}),t}(xD);fD.Text=kD;var AD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Comment,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 8},enumerable:!1,configurable:!0}),t}(xD);fD.Comment=AD;var SD=function(e){function t(t,a){var n=e.call(this,a)||this;return n.name=t,n.type=vD.ElementType.Directive,n}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),t}(xD);fD.ProcessingInstruction=SD;var ED=function(e){function t(t){var a=e.call(this)||this;return a.children=t,a}return yD(t,e),Object.defineProperty(t.prototype,"firstChild",{get:function(){var e;return null!==(e=this.children[0])&&void 0!==e?e:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"childNodes",{get:function(){return this.children},set:function(e){this.children=e},enumerable:!1,configurable:!0}),t}(wD);fD.NodeWithChildren=ED;var _D=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.CDATA,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 4},enumerable:!1,configurable:!0}),t}(ED);fD.CDATA=_D;var CD=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.type=vD.ElementType.Root,t}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 9},enumerable:!1,configurable:!0}),t}(ED);fD.Document=CD;var TD=function(e){function t(t,a,n,i){void 0===n&&(n=[]),void 0===i&&(i="script"===t?vD.ElementType.Script:"style"===t?vD.ElementType.Style:vD.ElementType.Tag);var r=e.call(this,n)||this;return r.name=t,r.attribs=a,r.type=i,r}return yD(t,e),Object.defineProperty(t.prototype,"nodeType",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tagName",{get:function(){return this.name},set:function(e){this.name=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attributes",{get:function(){var e=this;return Object.keys(this.attribs).map((function(t){var a,n;return{name:t,value:e.attribs[t],namespace:null===(a=e["x-attribsNamespace"])||void 0===a?void 0:a[t],prefix:null===(n=e["x-attribsPrefix"])||void 0===n?void 0:n[t]}}))},enumerable:!1,configurable:!0}),t}(ED);function PD(e){return(0,vD.isTag)(e)}function OD(e){return e.type===vD.ElementType.CDATA}function DD(e){return e.type===vD.ElementType.Text}function MD(e){return e.type===vD.ElementType.Comment}function ID(e){return e.type===vD.ElementType.Directive}function ND(e){return e.type===vD.ElementType.Root}function jD(e,t){var a;if(void 0===t&&(t=!1),DD(e))a=new kD(e.data);else if(MD(e))a=new AD(e.data);else if(PD(e)){var n=t?zD(e.children):[],i=new TD(e.name,bD({},e.attribs),n);n.forEach((function(e){return e.parent=i})),null!=e.namespace&&(i.namespace=e.namespace),e["x-attribsNamespace"]&&(i["x-attribsNamespace"]=bD({},e["x-attribsNamespace"])),e["x-attribsPrefix"]&&(i["x-attribsPrefix"]=bD({},e["x-attribsPrefix"])),a=i}else if(OD(e)){n=t?zD(e.children):[];var r=new _D(n);n.forEach((function(e){return e.parent=r})),a=r}else if(ND(e)){n=t?zD(e.children):[];var o=new CD(n);n.forEach((function(e){return e.parent=o})),e["x-mode"]&&(o["x-mode"]=e["x-mode"]),a=o}else{if(!ID(e))throw new Error("Not implemented yet: ".concat(e.type));var s=new SD(e.name,e.data);null!=e["x-name"]&&(s["x-name"]=e["x-name"],s["x-publicId"]=e["x-publicId"],s["x-systemId"]=e["x-systemId"]),a=s}return a.startIndex=e.startIndex,a.endIndex=e.endIndex,null!=e.sourceCodeLocation&&(a.sourceCodeLocation=e.sourceCodeLocation),a}function zD(e){for(var t=e.map((function(e){return jD(e,!0)})),a=1;a<t.length;a++)t[a].prev=t[a-1],t[a-1].next=t[a];return t}fD.Element=TD,fD.isTag=PD,fD.isCDATA=OD,fD.isText=DD,fD.isComment=MD,fD.isDirective=ID,fD.isDocument=ND,fD.hasChildren=function(e){return Object.prototype.hasOwnProperty.call(e,"children")},fD.cloneNode=jD,function(e){var t=$t&&$t.__createBinding||(Object.create?function(e,t,a,n){void 0===n&&(n=a);var i=Object.getOwnPropertyDescriptor(t,a);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[a]}}),Object.defineProperty(e,n,i)}:function(e,t,a,n){void 0===n&&(n=a),e[n]=t[a]}),a=$t&&$t.__exportStar||function(e,a){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(a,n)||t(a,e,n)};Object.defineProperty(e,"__esModule",{value:!0}),e.DomHandler=void 0;var n=FP,i=fD;a(fD,e);var r={withStartIndices:!1,withEndIndices:!1,xmlMode:!1},o=function(){function e(e,t,a){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,"function"==typeof t&&(a=t,t=r),"object"==typeof e&&(t=e,e=void 0),this.callback=null!=e?e:null,this.options=null!=t?t:r,this.elementCB=null!=a?a:null}return e.prototype.onparserinit=function(e){this.parser=e},e.prototype.onreset=function(){this.dom=[],this.root=new i.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},e.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},e.prototype.onerror=function(e){this.handleCallback(e)},e.prototype.onclosetag=function(){this.lastNode=null;var e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)},e.prototype.onopentag=function(e,t){var a=this.options.xmlMode?n.ElementType.Tag:void 0,r=new i.Element(e,t,void 0,a);this.addNode(r),this.tagStack.push(r)},e.prototype.ontext=function(e){var t=this.lastNode;if(t&&t.type===n.ElementType.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{var a=new i.Text(e);this.addNode(a),this.lastNode=a}},e.prototype.oncomment=function(e){if(this.lastNode&&this.lastNode.type===n.ElementType.Comment)this.lastNode.data+=e;else{var t=new i.Comment(e);this.addNode(t),this.lastNode=t}},e.prototype.oncommentend=function(){this.lastNode=null},e.prototype.oncdatastart=function(){var e=new i.Text(""),t=new i.CDATA([e]);this.addNode(t),e.parent=t,this.lastNode=e},e.prototype.oncdataend=function(){this.lastNode=null},e.prototype.onprocessinginstruction=function(e,t){var a=new i.ProcessingInstruction(e,t);this.addNode(a)},e.prototype.handleCallback=function(e){if("function"==typeof this.callback)this.callback(e,this.dom);else if(e)throw e},e.prototype.addNode=function(e){var t=this.tagStack[this.tagStack.length-1],a=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),a&&(e.prev=a,a.next=e),e.parent=t,this.lastNode=null},e}();e.DomHandler=o,e.default=o}(gD),function(e){var t=$t&&$t.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.htmlToDOM=e.domToReact=e.attributesToProps=e.Text=e.ProcessingInstruction=e.Element=e.Comment=void 0,e.default=function(e,t){if("string"!=typeof e)throw new TypeError("First argument must be a string");if(!e)return[];return(0,i.default)((0,a.default)(e,(null==t?void 0:t.htmlparser2)||o),t)};var a=t(wP);e.htmlToDOM=a.default;var n=t(yO);e.attributesToProps=n.default;var i=t(lD);e.domToReact=i.default;var r=gD;Object.defineProperty(e,"Comment",{enumerable:!0,get:function(){return r.Comment}}),Object.defineProperty(e,"Element",{enumerable:!0,get:function(){return r.Element}}),Object.defineProperty(e,"ProcessingInstruction",{enumerable:!0,get:function(){return r.ProcessingInstruction}}),Object.defineProperty(e,"Text",{enumerable:!0,get:function(){return r.Text}});var o={lowerCaseAttributeNames:!1}}(vP);var RD=Gt(vP),LD=RD.default||RD;A("pre code.hljs {\n display: block;\n overflow-x: auto;\n padding: 1em\n}\ncode.hljs {\n padding: 3px 5px\n}\n/*\n\nAtom One Dark by Daniel Gamage\nOriginal One Dark Syntax theme from https://github.com/atom/one-dark-syntax\n\nbase: #282c34\nmono-1: #abb2bf\nmono-2: #818896\nmono-3: #5c6370\nhue-1: #56b6c2\nhue-2: #61aeee\nhue-3: #c678dd\nhue-4: #98c379\nhue-5: #e06c75\nhue-5-2: #be5046\nhue-6: #d19a66\nhue-6-2: #e6c07b\n\n*/\n.hljs {\n color: #abb2bf;\n background: #282c34\n}\n.hljs-comment,\n.hljs-quote {\n color: #5c6370;\n font-style: italic\n}\n.hljs-doctag,\n.hljs-keyword,\n.hljs-formula {\n color: #c678dd\n}\n.hljs-section,\n.hljs-name,\n.hljs-selector-tag,\n.hljs-deletion,\n.hljs-subst {\n color: #e06c75\n}\n.hljs-literal {\n color: #56b6c2\n}\n.hljs-string,\n.hljs-regexp,\n.hljs-addition,\n.hljs-attribute,\n.hljs-meta .hljs-string {\n color: #98c379\n}\n.hljs-attr,\n.hljs-variable,\n.hljs-template-variable,\n.hljs-type,\n.hljs-selector-class,\n.hljs-selector-attr,\n.hljs-selector-pseudo,\n.hljs-number {\n color: #d19a66\n}\n.hljs-symbol,\n.hljs-bullet,\n.hljs-link,\n.hljs-meta,\n.hljs-selector-id,\n.hljs-title {\n color: #61aeee\n}\n.hljs-built_in,\n.hljs-title.class_,\n.hljs-class .hljs-title {\n color: #e6c07b\n}\n.hljs-emphasis {\n font-style: italic\n}\n.hljs-strong {\n font-weight: bold\n}\n.hljs-link {\n text-decoration: underline\n}");A(".mdhui-chat {\n background: var(--mdhui-background-color-0);\n font-size: 0.88em;\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n min-height: 150px;\n}\n\n.mdhui-chat .mdhui-chat-log {\n overflow: hidden;\n flex: 1 1 0%;\n}\n\n.mdhui-chat .mdhui-chat-messages-scroll-wrapper {\n overflow-y: auto;\n height: 100%;\n}\n\n.mdhui-chat .mdhui-chat-messages {\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n min-height: 100%;\n width: 100%;\n}\n\n.mdhui-chat p,\n.mdhui-chat ul {\n margin: .25rem 0;\n word-break: break-word;\n}\n\n.mdhui-chat input,\n.mdhui-chat button {\n min-height: var(--mdhui-touch);\n min-width: var(--mdhui-touch);\n border: 0;\n}\n\n.mdhui-chat .mdhui-chat-send-button {\n position: absolute;\n right: 4px;\n cursor: pointer;\n text-align: center;\n}\n\n.mdhui-chat .mdhui-chat-send-button:disabled {\n cursor: default;\n color: var(--mdhui-text-color-3);\n}\n\n.mdhui-chat input {\n flex: 1;\n font-size: 1em;\n color: var(--mdhui-text-color-1);\n padding: var(--mdhui-padding-md) var(--mdhui-touch) var(--mdhui-padding-md) var(--mdhui-padding-md);\n box-sizing: border-box;\n outline-offset: -1px;\n background: var(--mdhui-background-color-0);\n}\n\n.mdhui-chat .mdhui-chat-input-group {\n position: relative;\n display: flex;\n align-items: center;\n width: 100%;\n background: #fff;\n border-top: 1px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-chat .mdhui-chat-message,\n.mdhui-chat .mdhui-chat-message-loading {\n padding: var(--mdhui-padding-xxs) var(--mdhui-padding-md);\n position: relative;\n}\n\n.mdhui-chat .mdhui-chat-received-message-row {\n display: flex;\n flex-direction: row;\n align-items: flex-start;\n}\n\n.mdhui-chat .mdhui-chat-sent-message-row {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n padding-right: var(--mdhui-padding-md);\n}\n\n.mdhui-chat .mdhui-chat-sent-message {\n background: var(--mdhui-background-color-1);\n max-width: 70%;\n padding: var(--mdhui-padding-xs) var(--mdhui-padding-sm);\n border-radius: var(--mdhui-card-border-radius);\n}\n\n.mdhui-chat .mdhui-chat-message .svg-inline--fa,\n.mdhui-chat .mdhui-chat-message-loading .svg-inline--fa {\n color: var(--mdhui-text-color-3);\n margin-top: .35rem;\n margin-right: .25rem;\n}\n\n.mdhui-chat .mdhui-chat-message-loading .svg-inline--fa {\n font-weight: 700;\n}\n\n.mdhui-chat input:focus-visible {\n outline: 1px solid var(--mdhui-color-primary);\n}\n\n.mdhui-chat .mdhui-chat-suggestions {\n display: flex;\n justify-content: center;\n padding: 0 var(--mdhui-padding-xxs);\n}\n\n.mdhui-chat .mdhui-chat-suggestion {\n padding: var(--mdhui-padding-xs) var(--mdhui-padding-sm);\n margin: var(--mdhui-padding-xs) var(--mdhui-padding-xxs);\n border-radius: var(--mdhui-card-border-radius);\n background: var(--mdhui-background-color-1);\n cursor: pointer;\n}\n"),uP.registerLanguage("javascript",(function(e){const t=e.regex,a=dP,n="<>",i="</>",r={begin:/<[A-Za-z0-9\\._:-]+/,end:/\/[A-Za-z0-9\\._:-]+>|\/>/,isTrulyOpeningTag:(e,t)=>{const a=e[0].length+e.index,n=e.input[a];if("<"===n||","===n)return void t.ignoreMatch();let i;">"===n&&(((e,{after:t})=>{const a="</"+e[0].slice(1);return-1!==e.input.indexOf(a,t)})(e,{after:a})||t.ignoreMatch());const r=e.input.substring(a);((i=r.match(/^\s*=/))||(i=r.match(/^\s+extends\s+/))&&0===i.index)&&t.ignoreMatch()}},o={$pattern:dP,keyword:mP,literal:hP,built_in:bP,"variable.language":yP},s="[0-9](_?[0-9])*",l=`\\.(${s})`,c="0|[1-9](_?[0-9])*|0[0-7]*[89][0-9]*",u={className:"number",variants:[{begin:`(\\b(${c})((${l})|\\.)?|(${l}))[eE][+-]?(${s})\\b`},{begin:`\\b(${c})\\b((${l})\\b|\\.)?|(${l})\\b`},{begin:"\\b(0|[1-9](_?[0-9])*)n\\b"},{begin:"\\b0[xX][0-9a-fA-F](_?[0-9a-fA-F])*n?\\b"},{begin:"\\b0[bB][0-1](_?[0-1])*n?\\b"},{begin:"\\b0[oO][0-7](_?[0-7])*n?\\b"},{begin:"\\b0[0-7]+n?\\b"}],relevance:0},d={className:"subst",begin:"\\$\\{",end:"\\}",keywords:o,contains:[]},m={begin:".?html`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"xml"}},h={begin:".?css`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"css"}},p={begin:".?gql`",end:"",starts:{end:"`",returnEnd:!1,contains:[e.BACKSLASH_ESCAPE,d],subLanguage:"graphql"}},g={className:"string",begin:"`",end:"`",contains:[e.BACKSLASH_ESCAPE,d]},f={className:"comment",variants:[e.COMMENT(/\/\*\*(?!\/)/,"\\*/",{relevance:0,contains:[{begin:"(?=@[A-Za-z]+)",relevance:0,contains:[{className:"doctag",begin:"@[A-Za-z]+"},{className:"type",begin:"\\{",end:"\\}",excludeEnd:!0,excludeBegin:!0,relevance:0},{className:"variable",begin:a+"(?=\\s*(-)|$)",endsParent:!0,relevance:0},{begin:/(?=[^\n])\s/,relevance:0}]}]}),e.C_BLOCK_COMMENT_MODE,e.C_LINE_COMMENT_MODE]},y=[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,p,g,{match:/\$\d+/},u];d.contains=y.concat({begin:/\{/,end:/\}/,keywords:o,contains:["self"].concat(y)});const b=[].concat(f,d.contains),v=b.concat([{begin:/(\s*)\(/,end:/\)/,keywords:o,contains:["self"].concat(b)}]),w={className:"params",begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v},x={variants:[{match:[/class/,/\s+/,a,/\s+/,/extends/,/\s+/,t.concat(a,"(",t.concat(/\./,a),")*")],scope:{1:"keyword",3:"title.class",5:"keyword",7:"title.class.inherited"}},{match:[/class/,/\s+/,a],scope:{1:"keyword",3:"title.class"}}]},k={relevance:0,match:t.either(/\bJSON/,/\b[A-Z][a-z]+([A-Z][a-z]*|\d)*/,/\b[A-Z]{2,}([A-Z][a-z]+|\d)+([A-Z][a-z]*)*/,/\b[A-Z]{2,}[a-z]+([A-Z][a-z]+|\d)*([A-Z][a-z]*)*/),className:"title.class",keywords:{_:[...pP,...gP]}},A={variants:[{match:[/function/,/\s+/,a,/(?=\s*\()/]},{match:[/function/,/\s*(?=\()/]}],className:{1:"keyword",3:"title.function"},label:"func.def",contains:[w],illegal:/%/},S={match:t.concat(/\b/,function(e){return t.concat("(?!",e.join("|"),")")}([...fP,"super","import"].map((e=>`${e}\\s*\\(`))),a,t.lookahead(/\s*\(/)),className:"title.function",relevance:0},E={begin:t.concat(/\./,t.lookahead(t.concat(a,/(?![0-9A-Za-z$_(])/))),end:a,excludeBegin:!0,keywords:"prototype",className:"property",relevance:0},_={match:[/get|set/,/\s+/,a,/(?=\()/],className:{1:"keyword",3:"title.function"},contains:[{begin:/\(\)/},w]},C="(\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)|"+e.UNDERSCORE_IDENT_RE+")\\s*=>",T={match:[/const|var|let/,/\s+/,a,/\s*/,/=\s*/,/(async\s*)?/,t.lookahead(C)],keywords:"async",className:{1:"keyword",3:"title.function"},contains:[w]};return{name:"JavaScript",aliases:["js","jsx","mjs","cjs"],keywords:o,exports:{PARAMS_CONTAINS:v,CLASS_REFERENCE:k},illegal:/#(?![$_A-z])/,contains:[e.SHEBANG({label:"shebang",binary:"node",relevance:5}),{label:"use_strict",className:"meta",relevance:10,begin:/^\s*['"]use (strict|asm)['"]/},e.APOS_STRING_MODE,e.QUOTE_STRING_MODE,m,h,p,g,f,{match:/\$\d+/},u,k,{className:"attr",begin:a+t.lookahead(":"),relevance:0},T,{begin:"("+e.RE_STARTERS_RE+"|\\b(case|return|throw)\\b)\\s*",keywords:"return throw case",relevance:0,contains:[f,e.REGEXP_MODE,{className:"function",begin:C,returnBegin:!0,end:"\\s*=>",contains:[{className:"params",variants:[{begin:e.UNDERSCORE_IDENT_RE,relevance:0},{className:null,begin:/\(\s*\)/,skip:!0},{begin:/(\s*)\(/,end:/\)/,excludeBegin:!0,excludeEnd:!0,keywords:o,contains:v}]}]},{begin:/,/,relevance:0},{match:/\s+/,relevance:0},{variants:[{begin:n,end:i},{match:/<[A-Za-z0-9\\._:-]+\s*\/>/},{begin:r.begin,"on:begin":r.isTrulyOpeningTag,end:r.end}],subLanguage:"xml",contains:[{begin:r.begin,end:r.end,skip:!0,contains:["self"]}]}]},A,{beginKeywords:"while if switch catch for"},{begin:"\\b(?!function)"+e.UNDERSCORE_IDENT_RE+"\\([^()]*(\\([^()]*(\\([^()]*\\)[^()]*)*\\)[^()]*)*\\)\\s*\\{",returnBegin:!0,label:"func.def",contains:[w,e.inherit(e.TITLE_MODE,{begin:a,className:"title.function"})]},{match:/\.\.\./,relevance:0},E,{match:"\\$"+a,relevance:0},{match:[/\bconstructor(?=\s*\()/],className:{1:"title.function"},contains:[w]},S,{relevance:0,match:/\b[A-Z][A-Z_0-9]+\b/,className:"variable.constant"},x,_,{match:/\$[(.]/}]}}));const FD=new DC({breaks:!0}).use(QC,{inline:!0,hljs:uP});function BD(e){const[a,n]=c(""),i=s(null);l((()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)}),[e.messages]);const r=async function(){let t=a;e.onSendMessage(t),n("")};return t.createElement("div",{className:"mdhui-chat",ref:e.innerRef},t.createElement("div",{className:"mdhui-chat-log"},t.createElement("div",{className:"mdhui-chat-messages-scroll-wrapper",ref:i},t.createElement("div",{className:"mdhui-chat-messages"},e.messages.map(((e,a)=>"sent"===e.type?t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-sent-message-row"},t.createElement("div",{className:"mdhui-chat-sent-message"},LD(FD.render(e.content)))):"received-image"===e.type?t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-received-message-row"},t.createElement("img",{src:e.content,className:e.cssClass})):t.createElement("div",{key:a,className:"mdhui-chat-message mdhui-chat-received-message-row"},e.icon,t.createElement("div",{className:"mdhui-chat-received-message"+(e.cssClass?" "+e.cssClass:"")},LD(FD.render(e.content)))))),e.loading&&t.createElement("div",{className:"mdhui-chat-message-loading"},t.createElement(je,{icon:Ee,spin:!0}),e.loading)))),e.suggestions&&e.onSuggestionSelected&&t.createElement("div",{className:"mdhui-chat-suggestions"},e.suggestions.map((a=>t.createElement("div",{key:a,className:"mdhui-chat-suggestion",onClick:()=>e.onSuggestionSelected?.(a)},a)))),t.createElement("div",{className:"mdhui-chat-input"},t.createElement("div",{className:"mdhui-chat-input-group"},t.createElement("input",{type:"text",value:a,onChange:e=>n(e.target.value),onKeyDown:t=>{!e.inputDisabled&&a&&"Enter"===t.key&&r()}}),t.createElement(S,{onClick:r,className:"mdhui-chat-send-button",disabled:e.inputDisabled||!a},t.createElement(je,{icon:De})))))}function HD(e){const a="Month"===e.intervalType?{months:1}:"Day"===e.intervalType?{days:1}:"6Month"===e.intervalType?{months:6}:{weeks:1};var n=un(e.intervalStart,a),i=!1,r=new Date;e.intervalStart<=r&&r<n&&(i=!0);let o=["mdhui-date-range-navigator"];return"rounded"==e.variant&&o.push("mdhui-date-range-navigator-rounded"),e.sticky&&o.push("mdhui-date-range-navigator-sticky"),e.className&&o.push(e.className),t.createElement("div",{ref:e.innerRef,className:o.join(" ")},t.createElement("div",{className:"mdhui-date-range-navigator-inner"},t.createElement(S,{title:"Previous",className:"navigator-button navigate-previous",onClick:()=>{return t=Ur(e.intervalStart,a),void e.onIntervalChange(t,un(t,a));var t}},t.createElement(je,{icon:ke})),yl(e.intervalType,e.intervalStart),!i&&t.createElement(S,{title:"Next",className:"navigator-button navigate-next",onClick:()=>{return t=un(e.intervalStart,a),void e.onIntervalChange(t,un(t,a));var t}},t.createElement(je,{icon:Ae}))))}A(".mdhui-card .mdhui-date-range-navigator:first-child {\n border-radius: var(--mdhui-card-border-radius) var(--mdhui-card-border-radius) 0px 0px;\n}\n\n.mdhui-date-range-navigator {\n padding: 16px;\n text-align: center;\n font-weight: bold;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n background: var(--mdhui-background-color-0);\n z-index: 1;\n position: relative;\n}\n\n.mdhui-date-range-navigator.mdhui-date-range-navigator-sticky {\n position: sticky;\n position: -webkit-sticky;\n top: 0;\n padding-top: calc(16px + env(safe-area-inset-top, 0px));\n}\n\n.mdhui-date-range-navigator .navigator-button {\n position: absolute;\n top: 0;\n padding: 16px;\n color: var(--mdhui-color-primary);\n height: 100%;\n}\n\n.mdhui-date-range-navigator .navigate-previous {\n left: 0;\n}\n\n.mdhui-date-range-navigator .navigate-next {\n right: 0;\n}\n\n.mdhui-date-range-navigator-rounded {\n padding: 16px;\n border: none;\n background: var(--mdhui-background-color-1);\n}\n\n.mdhui-date-range-navigator-rounded .mdhui-date-range-navigator-inner {\n line-height: 40px;\n border-radius: 32px;\n background: var(--mdhui-background-color-2);\n position: relative;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button {\n padding: 0;\n width: 36px;\n height: 36px;\n background: var(--mdhui-background-color-0);\n color: var(--mdhui-color-primary);\n border-radius: 31px;\n cursor: pointer;\n position: absolute;\n top: 2px;\n line-height: 36px;\n display: flex;\n align-items: center;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button.navigate-previous {\n left: 2px;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button.navigate-next {\n right: 2px;\n}\n\n.mdhui-date-range-navigator-rounded .navigator-button svg {\n margin: 0 auto;\n}\n\n.mdhui-navigation-bar .mdhui-date-range-navigator-rounded {\n margin: 0;\n}");const qD=o(null);function UD(e){let a=e.initialIntervalStart||_u();"Week"===e.intervalType&&(a=Eu(e.weekStartsOn)),"Day"===e.intervalType&&(a=vn(new Date));const[n,i]=c(null),r=s();return r.current=n,l((()=>{i({intervalType:e.intervalType,intervalStart:a,update:e=>{i({...r.current,...e})}})}),[e.intervalType,e.weekStartsOn]),n?t.createElement("div",{ref:e.innerRef},t.createElement(qD.Provider,{value:n},!e.useCustomNavigator&&t.createElement(HD,{sticky:e.sticky,intervalType:e.intervalType,intervalStart:n.intervalStart,onIntervalChange:e=>i({...n,intervalStart:e}),variant:e.variant}),e.children)):null}function WD(e){let a=`h${e.order||1}`,n=["mdhui-title"];e.className&&n.push(e.className);let i=r(Ka),o=ze(i?.colorScheme,e.color);"top"===e.imageAlignment&&n.push("mdhui-title-image-top"),e.defaultMargin&&n.push("mdhui-title-default-margin");let s=null;if(e.image&&e.autosizeImage){switch(s=24,e.order){case 1:s=40;break;case 2:s=30;break;case 3:s=24;break;case 4:s=20;break;case 5:s=16;break;case 6:s=12}"top"==e.imageAlignment&&(s*=2)}return t.createElement("div",{className:n.join(" "),ref:e.innerRef},e.image&&t.createElement("div",{className:"mdhui-title-image "+(e.autosizeImage?"mdhui-title-image-autosize":""),style:{width:s+"px"}},e.image),t.createElement(a,{style:{...e.style,color:o}},e.children),e.accessory)}function VD(){}function $D(e){let a=r(qD);return a||(a={intervalStart:vn(new Date),intervalType:"Day",update:VD}),t.createElement(WD,{defaultMargin:e.defaultMargin,order:e.order||3,color:e.color,style:e.style,innerRef:e.innerRef},yl(a.intervalType,a.intervalStart,"long"))}A(".mdhui-title {\n display: flex;\n align-items: center;\n gap: var(--mdhui-padding-md);\n}\n\n.mdhui-title.mdhui-title-default-margin {\n margin: var(--mdhui-padding-md);\n}\n\n.mdhui-title.mdhui-title-image-top {\n display: block;\n}\n\n.mdhui-title .mdhui-title-image\n{\n display: flex;\n}\n\n.mdhui-title .mdhui-title-image-autosize img {\n width: 100%;\n}\n\n.mdhui-title h1,\n.mdhui-title h2,\n.mdhui-title h3,\n.mdhui-title h4,\n.mdhui-title h5,\n.mdhui-title h6 {\n margin: 0;\n padding: 0;\n flex-grow: 1;\n}\n\n\n.mdhui-title.mdhui-title-image-top h1,\n.mdhui-title.mdhui-title-image-top h2,\n.mdhui-title.mdhui-title-image-top h3,\n.mdhui-title.mdhui-title-image-top h4,\n.mdhui-title.mdhui-title-image-top h5,\n.mdhui-title.mdhui-title-image-top h6 {\n margin-top: var(--mdhui-padding-md);\n}\n\n.mdhui-title h1 {\n font-size: 2em;\n}\n\n.mdhui-title h2 {\n font-size: 1.5em;\n}\n\n.mdhui-title h3 {\n font-size: 1.17em;\n}\n\n.mdhui-title h4 {\n font-size: 1em;\n}\n\n.mdhui-title h5 {\n font-size: 0.83em;\n}\n\n.mdhui-title h6 {\n font-size: 0.67em;\n}");function GD(e){for(var a=100/e.primaryColors.length,n="conic-gradient(",i=0,r=0;r<e.primaryColors.length;r++)n=n+e.primaryColors[r]+" "+i+"%, ",i+=a,n=n+e.primaryColors[r]+" "+i+"%",r!=e.primaryColors.length-1&&(n+=", ");var o={background:n+=")"};let s=["mdhui-day-tracker-symbol"];return e.className&&s.push(e.className),"large"==e.size&&s.push("mdhui-day-tracker-symbol-large"),t.createElement("div",{ref:e.innerRef,className:s.join(" ")},t.createElement("div",{className:"day-circle",style:o},e.secondaryColors.slice(0,3).map(((e,a)=>t.createElement("div",{key:a,className:"secondary-color",style:{background:e}}))),e.secondaryColors.length>3&&t.createElement("div",{className:"more-items"},"+")))}A(".mdhui-day-tracker-symbol {\n padding: 10px;\n}\n\n.mdhui-day-tracker-symbol .day-circle {\n font-size: 12px;\n height: 30px;\n width: 30px;\n display: inline-block;\n border-radius: 17px;\n line-height: 30px;\n background: var(--mdhui-background-color-2);\n position: relative;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color {\n position: absolute;\n width: 8px;\n height: 8px;\n border-radius: 50%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:first-child {\n left: 36.6%;\n top: -33.33%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:nth-child(2) {\n left: 0%;\n top: -23.333%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .secondary-color:nth-child(3) {\n left: 73%;\n top: -23.333%;\n}\n\n.mdhui-day-tracker-symbol .day-circle .more-items {\n position: absolute;\n left: 30px;\n top: 0px;\n font-size: 10px;\n height: 8px;\n width: 7px;\n line-height: 6px;\n}\n\n.mdhui-day-tracker-symbol.mdhui-day-tracker-symbol-large {\n transform: scale(2);\n padding-top: 34px;\n padding-bottom: 22px;\n}");function KD(e){const a=r(Ka),n=[...Array(e.tickCount).keys()];let i=e.value;void 0!==i&&i<0&&(i=0),void 0!==i&&i>=e.tickCount&&(i=e.tickCount-1);let o=e.sliderColor?ze(a.colorScheme,e.sliderColor):"var(--mdhui-color-primary)",s=i?`calc((((100% - 16px) / ${e.tickCount-1}) * ${i}) + 8px)`:"0%",l={background:`linear-gradient(to right, ${o} 0%, ${o} ${s}, var(--mdhui-background-color-2) ${s}, var(--mdhui-background-color-2) 100%)`},c={gridTemplateColumns:n.slice(0,-1).map((e=>"1fr")).join(" ")};const u=t=>{e.onChange&&e.onChange(t)};return t.createElement("div",{className:"mdhui-discrete-scale",ref:e.innerRef},t.createElement("div",{className:"mdhui-discrete-scale-slider",style:l}," "),t.createElement("div",{className:"mdhui-discrete-scale-ticks",style:c},n.slice(0,-1).map(((a,n)=>t.createElement("div",{key:n,className:"mdhui-discrete-scale-ticks-section"},t.createElement(S,{className:"mdhui-discrete-scale-ticks-section-button",onClick:()=>u(a),style:{left:0===n?"-10px":"-50%",width:0===n?"calc(50% + 10px)":"100%"}},t.createElement("div",{className:"mdhui-discrete-scale-ticks-section-marker",style:{background:a===i?o:"transparent",left:0===n?"-1px":"calc(50% - 11px)"}}," ")),n===e.tickCount-2&&t.createElement(S,{className:"mdhui-discrete-scale-ticks-section-button",onClick:()=>u(a+1),style:{left:"calc(50% + 2px)",width:"calc(50% + 10px)"}},t.createElement("div",{className:"mdhui-discrete-scale-ticks-section-marker",style:{background:a+1===i?o:"transparent",right:"1px"}}," ")))))),t.createElement("div",{className:"mdhui-discrete-scale-labels"},t.createElement("div",{className:"mdhui-discrete-scale-labels-min"},e.minLabel),void 0!==e.value&&t.createElement(S,{onClick:()=>{e.onChange&&e.onChange(void 0)}},t.createElement("div",{className:"mdhui-discrete-scale-clear-button",style:{color:o}},so("clear"))),void 0===e.value&&t.createElement(t.Fragment,null," "),t.createElement("div",{className:"mdhui-discrete-scale-labels-max"},e.maxLabel)))}A(".mdhui-discrete-scale {\n padding: 16px;\n}\n\n.mdhui-discrete-scale-slider {\n height: 10px;\n border: 1px solid var(--mdhui-border-color-2);\n border-radius: 5px;\n margin-bottom: 4px;\n}\n\n.mdhui-discrete-scale-ticks {\n padding: 0 8px;\n display: grid;\n align-items: center;\n margin-bottom: 8px;\n}\n\n.mdhui-discrete-scale-ticks-section {\n position: relative;\n height: 5px;\n border-right: 2px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-discrete-scale-ticks-section:first-child {\n border-left: 2px solid var(--mdhui-border-color-1);\n}\n\n.mdhui-discrete-scale-ticks-section-button.mdhui-unstyled-button {\n position: absolute;\n top: -20px;\n height: 20px;\n}\n\n.mdhui-discrete-scale-ticks-section-marker {\n position: absolute;\n top: 0;\n height: 20px;\n width: 20px;\n border-radius: 10px;\n}\n\n.mdhui-discrete-scale-labels {\n display: grid;\n grid-template-columns: 1fr auto 1fr;\n align-items: center;\n font-size: 0.8em;\n color: var(--mdhui-text-color-2);\n}\n\n.mdhui-discrete-scale-clear-button {\n text-align: center;\n text-decoration: underline;\n}\n\n.mdhui-discrete-scale-labels-max {\n text-align: right;\n}");function ZD(){return t.createElement("div",{className:"mdhui-divider"})}A(".mdhui-divider {\n height: 0x;\n border-bottom: solid 1px var(--mdhui-border-color-0);\n}");var YD;function XD(e){const a=e.axis.xIncrement,n=e.axis.yRange.values[0],i=e.axis.yRange.values[1],r=i-n,o=e.dumbbell?.class??YD["mdhui-dumbbell-in-range"],s=YD[o],l=[s],c=[s],u={left:e.index*a+"%"},d=e.dumbbell&&e.dumbbell.dataPoint?e.dumbbell.dataPoint.dataSet1.values:[],m=e.dumbbell&&e.dumbbell.dataPoint?e.dumbbell.dataPoint.dataSet2.values:[],h=d.length>1?d[1]:d[0],p=m.length>1?m[1]:m[0],g=p===m[0],f=d[0]-n,y=D(f+4.5,r);var b=`${y}%`;const v=d[0]<n,w=h<n;var x=h-d[0];!w&&v?(l.push("mdhui-dumbbell-partial-out-of-range-pill"),l.push("mdhui-dumbbell-bottom-lower-out-of-range"),x=h-n,b="10px"):l.push("mdhui-dumbbell-pill");const k=M(`${x}px`,b),A=p>i,S=m[0]>i;var E=0,_=D(E=g&&S?i-9:m[0]-n,r),C=0;g||(C=(p>i?i+11:p)-E);const T=g?{bottom:`${_}%`}:M(`${C}px`,`${_}%`);!S&&A?(c.push("mdhui-dumbbell-partial-out-of-range-pill"),c.push("mdhui-dumbbell-top-upper-out-of-range")):c.push("mdhui-dumbbell-pill");var P=D((S?i-n:E)-(w||d[0]<0?0:f),r);const O={height:`${P=P>100?100:P}%`,bottom:w||f<=0?"10px":`${y}%`,left:"5px"};function D(e,t){return e/t*100}function M(e,t){return{height:e,bottom:t}}return t.createElement("div",{className:"mdhui-dumbbell",style:u},e.dumbbell?.dataPoint&&t.createElement(t.Fragment,null,S&&t.createElement("div",{className:"mdhui-dumbbell-full-out-of-range-pill mdhui-dumbbell-top-upper-out-of-range"}),!S&&t.createElement("div",{className:c.join(" "),style:T}),t.createElement("div",{className:`mdhui-dumbbell-line ${s}`,style:O}),w&&t.createElement("div",{className:"mdhui-dumbbell-full-out-of-range-pill mdhui-dumbbell-bottom-lower-out-of-range"}),!w&&t.createElement("div",{className:l.join(" "),style:k})),t.createElement("div",{className:"mdhui-dumbbell-x-axis mdhui-dumbbell-axis-text",key:`xAxis${e.index+1}`},e.dumbbell?.xValue))}function QD(e){const a=e.axis.yRange.values[0],n=e.axis.yRange.values[1]-a;return t.createElement("div",{className:"mdhui-dumbbell-visualization"},t.createElement("div",{className:"mdhui-dumbbell-chart"},e.dumbbells.map(((a,n)=>t.createElement(XD,{key:`mdhui-dumbbell-${n}`,dumbbell:a,axis:e.axis,index:n+1}))),function(){const a=n/e.axis.yIncrement,i=[];for(var r=e.axis.yRange.values[0],o={bottom:"0%"},s=0;s<a+1;s++){var l=`yAxis${s+1}`,c=r;let u=["mdhui-dumbbell-axis-text"];s!=a&&0!=s||u.push("mdhui-dumbbell-axis-text-hidden"),i.push(t.createElement("div",{className:"mdhui-dumbbell-y-axis",style:o,key:l},t.createElement("div",{className:u.join(" ")},c))),r+=e.axis.yIncrement,o={bottom:(s+1)*e.axis.yIncrement/n*100+"%"}}return i}()))}A(".mdhui-dumbbell-visualization {\n padding-top: var(--mdhui-padding-sm);\n padding-bottom: var(--mdhui-padding-md);\n overflow: hidden;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart{\n height: 200px;\n width: 100%;\n position: relative;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell-y-axis{\n position: absolute;\n flex-flow: nowrap;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n width: 100%;\n border-top-width: 1px;\n border-top-style: solid;\n border-top-color: var(--mdhui-border-color-0);\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-x-axis{\n position: absolute;\n bottom: -15px;\n margin-left: -2.5px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-axis-text{\n color: var(--mdhui-text-color-4);\n font-size: 10px;\n font-style: normal;\n font-weight: 700;\n line-height: normal;\n display: flex;\n justify-content: right;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart \n.mdhui-dumbbell-y-axis \n.mdhui-dumbbell-axis-text{\n margin-right: 15px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell-y-axis .mdhui-dumbbell-axis-text-hidden{\n visibility: hidden;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell{\n bottom: 0px;\n height: 100%;\n position: absolute;\n }\n\n .mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n .mdhui-dumbbell-pill{\n position: absolute;\n width: 9px;\n border-radius: 25px;\n border-style: solid;\n border-width: 2px;\n z-index: 1;\n min-height: 9px;\n min-width: 9px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-full-out-of-range-pill{\n background-color: var(--mdhui-color-danger);\n border-color:var(--mdhui-color-danger);\n position: absolute;\n width: 9px;\n height: 9px;\n border-style: solid;\n border-width: 2px;\n z-index: 1;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-partial-out-of-range-pill{\n position: absolute;\n z-index: 1;\n width: 9px;\n border-style: solid;\n border-width: 2px;\n min-height: 9px;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-top-upper-out-of-range{\n border-bottom-left-radius: 25px;\n border-bottom-right-radius: 25px; \n bottom: 100%;\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-bottom-lower-out-of-range{\n border-top-left-radius: 25px;\n border-top-right-radius: 25px; \n border-bottom: 0;\n bottom: 10px; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-bottom{\n bottom: 10px; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-top{\n bottom: 100%; \n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-line {\n position: absolute;\n border-left-style: solid;\n border-left-width: 2px;\n width: 1px;\n z-index: 1;\n }\n\n .mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n .mdhui-dumbbell-in-range {\n background-color: var(--mdhui-color-primary);\n border-color: var(--mdhui-color-primary);\n}\n\n.mdhui-dumbbell-visualization .mdhui-dumbbell-chart .mdhui-dumbbell \n.mdhui-dumbbell-out-of-range {\n background-color: var(--mdhui-color-danger);\n border-color: var(--mdhui-color-danger);\n}"),function(e){e[e["mdhui-dumbbell-in-range"]=0]="mdhui-dumbbell-in-range",e[e["mdhui-dumbbell-out-of-range"]=1]="mdhui-dumbbell-out-of-range"}(YD||(YD={}));A(".mdhui-face\n{\n width: 40px;\n height: 40px;\n display: inline-block;\n border-radius: 50%;\n overflow: hidden;\n position: relative;\n}\n\n .mdhui-face img\n {\n width: 100%;\n height: 100%;\n opacity: .7;\n display: block;\n }\n\n .mdhui-face.mdhui-face-selected\n {\n background: #eec04c;\n }");var JD="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c224c-29.824%2c0-58.232%2c12.632-77.96%2c34.664c-2.944%2c3.296-2.664%2c8.344%2c0.624%2c11.296c1.52%2c1.368%2c3.432%2c2.04%2c5.336%2c2.04 c2.192%2c0%2c4.384-0.896%2c5.96-2.664C134.656%2c250.688%2c158.728%2c240%2c184%2c240c25.28%2c0%2c49.352%2c10.688%2c66.04%2c29.336 c2.944%2c3.296%2c8.008%2c3.568%2c11.296%2c0.624c3.288-2.944%2c3.568-8%2c0.624-11.296C242.24%2c236.64%2c213.832%2c224%2c184%2c224z'/%3e %3cpath d='M184%2c0C82.536%2c0%2c0%2c82.544%2c0%2c184s82.536%2c184%2c184%2c184s184-82.544%2c184-184S285.464%2c0%2c184%2c0z M184%2c352 c-92.632%2c0-168-75.36-168-168S91.368%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.632%2c352%2c184%2c352z'/%3e %3cpath d='M280%2c128c-4.424%2c0-8%2c3.584-8%2c8c0%2c13.232-10.768%2c24-24%2c24s-24-10.768-24-24c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8 c0%2c22.056%2c17.944%2c40%2c40%2c40c22.056%2c0%2c40-17.944%2c40-40C288%2c131.584%2c284.424%2c128%2c280%2c128z'/%3e %3cpath d='M160%2c136c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8c0%2c13.232-10.768%2c24-24%2c24s-24-10.768-24-24c0-4.416-3.576-8-8-8s-8%2c3.584-8%2c8 c0%2c22.056%2c17.944%2c40%2c40%2c40C142.056%2c176%2c160%2c158.056%2c160%2c136z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",eM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184c101.464%2c0%2c184-82.544%2c184-184S285.464%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16c92.632%2c0%2c168%2c75.36%2c168%2c168S276.632%2c352%2c184%2c352z'/%3e %3cpath d='M144%2c152c0-13.232-10.768-24-24-24s-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24S144%2c165.232%2c144%2c152z M112%2c152c0-4.408%2c3.592-8%2c8-8 s8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8S112%2c156.408%2c112%2c152z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.416%2c0-8-3.592-8-8s3.584-8%2c8-8c4.416%2c0%2c8%2c3.592%2c8%2c8S252.416%2c160%2c248%2c160z'/%3e %3cpath d='M184%2c224c-29.824%2c0-58.24%2c12.632-77.96%2c34.664c-2.944%2c3.296-2.664%2c8.352%2c0.624%2c11.296 c3.296%2c2.952%2c8.352%2c2.664%2c11.296-0.624C134.648%2c250.688%2c158.72%2c240%2c184%2c240c25.28%2c0%2c49.352%2c10.688%2c66.04%2c29.336 c1.576%2c1.768%2c3.768%2c2.664%2c5.96%2c2.664c1.896%2c0%2c3.816-0.672%2c5.336-2.04c3.288-2.944%2c3.568-8%2c0.624-11.296 C242.24%2c236.64%2c213.832%2c224%2c184%2c224z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",tM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M120%2c176c13.232%2c0%2c24-10.768%2c24-24s-10.768-24-24-24s-24%2c10.768-24%2c24S106.768%2c176%2c120%2c176z M120%2c144 c4.408%2c0%2c8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8s-8-3.592-8-8S115.592%2c144%2c120%2c144z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.408%2c0-8-3.592-8-8s3.592-8%2c8-8c4.408%2c0%2c8%2c3.592%2c8%2c8S252.408%2c160%2c248%2c160z'/%3e %3cpath d='M264%2c224H104c-4.416%2c0-8%2c3.584-8%2c8c0%2c4.416%2c3.584%2c8%2c8%2c8h160c4.416%2c0%2c8-3.584%2c8-8C272%2c227.584%2c268.416%2c224%2c264%2c224z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",aM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M144%2c152c0-13.232-10.768-24-24-24s-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24S144%2c165.232%2c144%2c152z M112%2c152c0-4.408%2c3.592-8%2c8-8 s8%2c3.592%2c8%2c8s-3.592%2c8-8%2c8S112%2c156.408%2c112%2c152z'/%3e %3cpath d='M248%2c128c-13.232%2c0-24%2c10.768-24%2c24s10.768%2c24%2c24%2c24s24-10.768%2c24-24S261.232%2c128%2c248%2c128z M248%2c160 c-4.408%2c0-8-3.592-8-8s3.592-8%2c8-8c4.408%2c0%2c8%2c3.592%2c8%2c8S252.408%2c160%2c248%2c160z'/%3e %3cpath d='M261.336%2c226.04c-3.296-2.952-8.36-2.664-11.296%2c0.624C233.352%2c245.312%2c209.288%2c256%2c184%2c256 c-25.28%2c0-49.352-10.688-66.04-29.336c-2.952-3.288-8-3.576-11.296-0.624c-3.296%2c2.944-3.568%2c8-0.624%2c11.296 C125.76%2c259.368%2c154.176%2c272%2c184%2c272c29.832%2c0%2c58.248-12.64%2c77.96-34.664C264.904%2c234.04%2c264.624%2c228.984%2c261.336%2c226.04z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e",nM="data:image/svg+xml,%3c%3fxml version='1.0' encoding='iso-8859-1'%3f%3e%3c!-- Generator: Adobe Illustrator 19.0.0%2c SVG Export Plug-In . SVG Version: 6.00 Build 0) --%3e%3csvg version='1.1' id='Capa_1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' x='0px' y='0px' viewBox='0 0 368 368' style='enable-background:new 0 0 368 368%3b' xml:space='preserve'%3e%3cg%3e %3cg%3e %3cg%3e %3cpath d='M261.336%2c226.04c-3.296-2.952-8.36-2.664-11.296%2c0.624C233.352%2c245.312%2c209.288%2c256%2c184%2c256 c-25.28%2c0-49.352-10.688-66.04-29.336c-2.952-3.288-8-3.576-11.296-0.624c-3.296%2c2.944-3.568%2c8-0.624%2c11.296 C125.76%2c259.368%2c154.176%2c272%2c184%2c272c29.832%2c0%2c58.248-12.64%2c77.96-34.664C264.904%2c234.04%2c264.624%2c228.984%2c261.336%2c226.04z'/%3e %3cpath d='M184%2c0C82.544%2c0%2c0%2c82.544%2c0%2c184s82.544%2c184%2c184%2c184s184-82.544%2c184-184S285.456%2c0%2c184%2c0z M184%2c352 c-92.64%2c0-168-75.36-168-168S91.36%2c16%2c184%2c16s168%2c75.36%2c168%2c168S276.64%2c352%2c184%2c352z'/%3e %3cpath d='M248%2c128c-22.056%2c0-40%2c17.944-40%2c40c0%2c4.416%2c3.584%2c8%2c8%2c8c4.416%2c0%2c8-3.584%2c8-8c0-13.232%2c10.768-24%2c24-24s24%2c10.768%2c24%2c24 c0%2c4.416%2c3.584%2c8%2c8%2c8c4.416%2c0%2c8-3.584%2c8-8C288%2c145.944%2c270.056%2c128%2c248%2c128z'/%3e %3cpath d='M144%2c168c0%2c4.416%2c3.584%2c8%2c8%2c8s8-3.584%2c8-8c0-22.056-17.944-40-40-40c-22.056%2c0-40%2c17.944-40%2c40c0%2c4.416%2c3.584%2c8%2c8%2c8 s8-3.584%2c8-8c0-13.232%2c10.768-24%2c24-24S144%2c154.768%2c144%2c168z'/%3e %3c/g%3e %3c/g%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3cg%3e%3c/g%3e%3c/svg%3e";function iM(e){let a={};"dark"!=r(Ka).colorScheme||e.selected||(a.filter="invert(1)");var n="mdhui-face";function i(){return 1==e.faceValue?JD:2==e.faceValue?eM:3==e.faceValue?tM:4==e.faceValue?aM:5==e.faceValue?nM:void 0}e.selected&&(n+=" mdhui-face-selected"),e.className&&(n+=" "+e.className);const o=e.faceValue?so(`face-value-${e.faceValue}`):"";return e.onClick?t.createElement(S,{innerRef:e.innerRef,className:n,onClick:e.onClick,"aria-label":o},t.createElement("img",{src:i(),style:a,alt:o}),t.createElement(LS,null)):t.createElement("div",{className:n},t.createElement("img",{src:i(),style:a,alt:o}),t.createElement(LS,null))}function rM(e){let a,n,i,r,o,s;if(e.glucoseReadings&&e.glucoseReadings.length>0){let t=e.glucoseReadings.map((e=>e.value));a=Math.min(...t),n=Math.max(...t),i=t.reduce(((e,t)=>e+t),0)/t.length}e.steps&&e.steps.length>0&&(r=e.steps.reduce(((e,t)=>e+t.value),0)),e.sleepMinutes&&(o=Math.floor(e.sleepMinutes/60),s=Math.floor(e.sleepMinutes%60));let l=60*(o||0)+(s||0);return t.createElement("div",{className:"mdhui-glucose-stats",ref:e.innerRef},t.createElement(oM,{loading:e.loading,label:so("minimal"===e.variant?"glucose-stats-range-label-minimal":"glucose-stats-range-label"),icon:"minimal"===e.variant?void 0:he,iconColor:"#d36540",value:a&&n?`${El(a)} - ${El(n)} mg/dL`:void 0,invert:"minimal"===e.variant}),t.createElement(oM,{loading:e.loading,label:so("minimal"===e.variant?"glucose-stats-avg-label-minimal":"glucose-stats-avg-label"),icon:"minimal"===e.variant?void 0:he,iconColor:"#d36540",value:i?`${El(i)} mg/dL`:void 0,invert:"minimal"===e.variant}),"minimal"!==e.variant&&t.createElement(t.Fragment,null,t.createElement(oM,{loading:e.loading,label:so("glucose-stats-steps-label"),icon:_e,iconColor:"#f5b722",value:r?`${El(r)}`:void 0}),t.createElement(oM,{loading:e.loading,label:so("glucose-stats-sleep-label"),icon:me,iconColor:"#8287bb",value:o||s?_l(l):void 0})))}function oM(e){return t.createElement("div",{className:"mdhui-glucose-stat"},!e.invert&&t.createElement("div",{className:"mdhui-glucose-stat-label"},e.label),e.loading&&t.createElement(NS,null),!e.loading&&e.value&&t.createElement("div",{className:"mdhui-glucose-stat-value"},e.icon&&t.createElement(je,{icon:e.icon,color:e.iconColor})," ",e.value),!e.loading&&!e.value&&t.createElement("div",{className:"mdhui-glucose-stat-value-not-available"},"--"),e.invert&&t.createElement("div",{className:"mdhui-glucose-stat-label"},e.label))}A(".mdhui-glucose-stats {\n display: grid;\n grid-template-columns: 1fr 1fr;\n align-items: center;\n grid-column-gap: 16px;\n grid-row-gap: 16px;\n padding: 16px;\n}\n\n.mdhui-glucose-stats .mdhui-loading-indicator {\n padding: 0;\n text-align: left;\n}\n\n.mdhui-glucose-stat-label {\n text-transform: uppercase;\n font-size: 0.65em;\n margin-bottom: 4px;\n}\n\n.mdhui-glucose-stat-value {\n font-size: 0.95em;\n font-weight: bold;\n color: var(--mdhui-text-color-0);\n margin-bottom: 1px;\n}\n\n.mdhui-glucose-stat-value-not-available {\n font-size: 0.95em;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n margin-bottom: 1px;\n}");A(".mdhui-grid {\n display: flex;\n gap: var(--mdhui-padding-md);\n flex-wrap: wrap;\n}\n\n.mdhui-grid.mdhui-grid-default-margin {\n margin: var(--mdhui-padding-md);\n}\n\n.mdhui-grid .mdhui-grid-column {\n flex-grow: 0;\n flex-shrink: 0;\n}\n\n.mdhui-grid .mdhui-grid-column.mdhui-card {\n margin: 0;\n}\n\n.mdhui-grid .mdhui-grid-column:empty {\n display: none;\n}");const sM=o({gap:16});function lM(e){let a=["mdhui-grid"];e.className&&a.push(e.className),e.defaultMargin&&a.push("mdhui-grid-default-margin");const n={...e.style},i=e.gap||0===e.gap?e.gap:16;return n.gap=`${i}px`,t.createElement(sM.Provider,{value:{gap:i}},t.createElement("div",{ref:e.innerRef,className:a.join(" "),style:n},e.children))}lM.Column=function(e){if(!e.children)return null;const a=`calc(${e.span/12*100}% - ${t.useContext(sM).gap}px)`,n={...e.style,width:a};return"card"===e.variant?t.createElement(FS,{innerRef:e.innerRef,className:"mdhui-grid-column",style:n},e.children):t.createElement("div",{ref:e.innerRef,className:"mdhui-grid-column",style:n},e.children)};function cM(e){const a=r(Ka);let n=0;e.entries.forEach((function(e){e.value>n&&(n=e.value)}));var i=[...e.entries].sort(((e,t)=>t.value-e.value||(e.label>t.label?1:t.label>e.label?-1:0)));return t.createElement("div",{ref:e.innerRef,className:"mdhui-histogram "+(e.className||"")},i.map(((i,r)=>t.createElement("div",{className:"mdhui-histogram-entry"+(i.onSelect?" mdhui-histogram-entry-clickable":""),key:r,onClick:()=>i.onSelect?.()},t.createElement("div",{className:"mdhui-histogram-entry-bar-wrapper"},t.createElement("div",{className:"mdhui-histogram-entry-bar",style:{background:i.color,width:i.value/n*100+"%"}},t.createElement(LS,null)),t.createElement("div",{className:"mdhui-histogram-entry-value",style:{width:8*n.toString().length+"px"}},i.value)),t.createElement("div",{className:"mdhui-histogram-entry-label",style:i.onSelect&&e.linkColor?{color:ze(a.colorScheme,e.linkColor)}:void 0},i.label)))))}A(".mdhui-histogram\n{\n padding: 16px;\n}\n\n .mdhui-histogram .mdhui-histogram-entry\n {\n padding-top: 8px;\n font-size: 15px;\n }\n\n .mdhui-histogram .mdhui-histogram-entry.mdhui-histogram-entry-clickable\n {\n cursor: pointer;\n }\n\n .mdhui-histogram .mdhui-histogram-entry.mdhui-histogram-entry-clickable .mdhui-histogram-entry-label\n {\n text-decoration: underline;\n color: var(--mdhui-color-primary);\n }\n\n .mdhui-histogram .mdhui-histogram-entry-bar-wrapper\n {\n display: flex;\n }\n\n .mdhui-histogram .mdhui-histogram-entry-bar\n {\n position: relative;\n height: 16px;\n border-radius: 8px;\n }\n\n .mdhui-histogram .mdhui-histogram-entry-value\n {\n padding-left: 4px;\n line-height: 16px;\n font-size: 12px;\n font-weight: bold;\n }\n");function uM(e){const a=r(Ka),n=e.configuration.shouldHighlight(e.data),i=n?e.configuration.iconColor??"var(--mdhui-color-primary)":{lightMode:"#ccc",darkMode:"#555"},o=n?e.configuration.iconTextColor??"var(--mdhui-background-color-0)":"var(--mdhui-background-color-0)",s=ze(a.colorScheme,i),l=ze(a.colorScheme,o),c=["mdhui-insights-badge"];"xsmall"===e.variant&&c.push("mdhui-insights-badge-xsmall"),n&&c.push("mdhui-insights-badge-highlighted");const u={background:s,borderColor:s,...n&&e.configuration.customHighlightStyling};return t.createElement("div",{className:c.join(" "),style:u,ref:e.innerRef},e.configuration.icon?t.createElement(je,{className:"mdhui-insights-badge-icon",icon:e.configuration.icon,style:{color:l}}):t.createElement("div",{className:"mdhui-insights-badge-label"},e.configuration.identifier.substring(0,1).toUpperCase()))}A(".mdhui-insights-badge {\n width: 32px;\n height: 32px;\n border: 1px solid var(--mdhui-border-color-1);\n border-radius: 50%;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 18px;\n}\n\n.mdhui-insights-badge.mdhui-insights-badge-xsmall {\n width: 16px;\n height: 16px;\n font-size: 10px;\n}\n\n.mdhui-insights-badge .mdhui-insights-badge-icon {\n color: var(--mdhui-background-color-0);\n}\n\n.mdhui-insights-badge .mdhui-insights-badge-label {\n color: var(--mdhui-text-color-2);\n line-height: 40px;\n}\n\n.mdhui-insights-badge.mdhui-insights-badge-highlighted .mdhui-insights-badge-label {\n color: var(--mdhui-text-color-1);\n}");A(".mdhui-insights-calendar .mdhui-calendar {\n padding-bottom: 8px;\n}\n\n.mdhui-insights-calendar .mdhui-week-calendar {\n border-top: none;\n border-bottom: none;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day {\n margin: 8px 0 0;\n height: 100%;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: flex-start;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-label {\n font-size: 14px;\n font-weight: bold;\n color: var(--mdhui-text-color-2);\n text-align: center;\n margin-bottom: 16px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-footer {\n margin: 24px 2px 0;\n}\n\n.mdhui-insights-calendar .mdhui-insights-week-calendar-day-badges {\n margin-bottom: 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 2px;\n flex-wrap: wrap;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-footer {\n border-top: 1px solid var(--mdhui-border-color-1);\n position: relative;\n min-height: 38px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend {\n padding: 8px 40px 8px;\n width: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 12px;\n flex-wrap: wrap;\n box-sizing: border-box;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry {\n display: flex;\n align-items: center;\n gap: 4px;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry-color {\n height: 16px;\n width: 16px;\n border-radius: 50%;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-legend-entry-label {\n font-size: 0.7em;\n color: var(--mdhui-text-color-2);\n font-weight: bold;\n}\n\n.mdhui-insights-calendar .mdhui-insights-calendar-loading-indicator.mdhui-loading-indicator {\n position: absolute;\n bottom: 8px;\n right: 16px;\n padding: 0;\n}");var dM={prefix:"far",iconName:"lightbulb",icon:[384,512,[128161],"f0eb","M297.2 248.9C311.6 228.3 320 203.2 320 176c0-70.7-57.3-128-128-128S64 105.3 64 176c0 27.2 8.4 52.3 22.8 72.9c3.7 5.3 8.1 11.3 12.8 17.7l0 0c12.9 17.7 28.3 38.9 39.8 59.8c10.4 19 15.7 38.8 18.3 57.5H109c-2.2-12-5.9-23.7-11.8-34.5c-9.9-18-22.2-34.9-34.5-51.8l0 0 0 0c-5.2-7.1-10.4-14.2-15.4-21.4C27.6 247.9 16 213.3 16 176C16 78.8 94.8 0 192 0s176 78.8 176 176c0 37.3-11.6 71.9-31.4 100.3c-5 7.2-10.2 14.3-15.4 21.4l0 0 0 0c-12.3 16.8-24.6 33.7-34.5 51.8c-5.9 10.8-9.6 22.5-11.8 34.5H226.4c2.6-18.7 7.9-38.6 18.3-57.5c11.5-20.9 26.9-42.1 39.8-59.8l0 0 0 0 0 0c4.7-6.4 9-12.4 12.7-17.7zM192 128c-26.5 0-48 21.5-48 48c0 8.8-7.2 16-16 16s-16-7.2-16-16c0-44.2 35.8-80 80-80c8.8 0 16 7.2 16 16s-7.2 16-16 16zm0 384c-44.2 0-80-35.8-80-80V416H272v16c0 44.2-35.8 80-80 80z"]},mM={prefix:"far",iconName:"circle-check",icon:[512,512,[61533,"check-circle"],"f058","M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209c9.4-9.4 9.4-24.6 0-33.9s-24.6-9.4-33.9 0l-111 111-47-47c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l64 64c9.4 9.4 24.6 9.4 33.9 0L369 209z"]},hM={prefix:"far",iconName:"circle",icon:[512,512,[128308,128309,128992,128993,128994,128995,128996,9679,9898,9899,11044,61708,61915],"f111","M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256z"]},pM={prefix:"far",iconName:"sun",icon:[512,512,[9728],"f185","M375.7 19.7c-1.5-8-6.9-14.7-14.4-17.8s-16.1-2.2-22.8 2.4L256 61.1 173.5 4.2c-6.7-4.6-15.3-5.5-22.8-2.4s-12.9 9.8-14.4 17.8l-18.1 98.5L19.7 136.3c-8 1.5-14.7 6.9-17.8 14.4s-2.2 16.1 2.4 22.8L61.1 256 4.2 338.5c-4.6 6.7-5.5 15.3-2.4 22.8s9.8 13 17.8 14.4l98.5 18.1 18.1 98.5c1.5 8 6.9 14.7 14.4 17.8s16.1 2.2 22.8-2.4L256 450.9l82.5 56.9c6.7 4.6 15.3 5.5 22.8 2.4s12.9-9.8 14.4-17.8l18.1-98.5 98.5-18.1c8-1.5 14.7-6.9 17.8-14.4s2.2-16.1-2.4-22.8L450.9 256l56.9-82.5c4.6-6.7 5.5-15.3 2.4-22.8s-9.8-12.9-17.8-14.4l-98.5-18.1L375.7 19.7zM269.6 110l65.6-45.2 14.4 78.3c1.8 9.8 9.5 17.5 19.3 19.3l78.3 14.4L402 242.4c-5.7 8.2-5.7 19 0 27.2l45.2 65.6-78.3 14.4c-9.8 1.8-17.5 9.5-19.3 19.3l-14.4 78.3L269.6 402c-8.2-5.7-19-5.7-27.2 0l-65.6 45.2-14.4-78.3c-1.8-9.8-9.5-17.5-19.3-19.3L64.8 335.2 110 269.6c5.7-8.2 5.7-19 0-27.2L64.8 176.8l78.3-14.4c9.8-1.8 17.5-9.5 19.3-19.3l14.4-78.3L242.4 110c8.2 5.7 19 5.7 27.2 0zM256 368a112 112 0 1 0 0-224 112 112 0 1 0 0 224zM192 256a64 64 0 1 1 128 0 64 64 0 1 1 -128 0z"]};class gM extends of{constructor(e){super({...e,content:""}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.id=e.id}_getType(){return"remove"}get _printableFields(){return{...super._printableFields,id:this.id}}}const fM=(e,t)=>{const a=[...new Set(t?.map((e=>{if("string"==typeof e)return e;const t=new e({});if(!("_getType"in t)||"function"!=typeof t._getType)throw new Error("Invalid type provided.");return t._getType()})))],n=e._getType();return a.some((e=>e===n))};function yM(e,t={}){const{includeNames:a,excludeNames:n,includeTypes:i,excludeTypes:r,includeIds:o,excludeIds:s}=t,l=[];for(const t of e)n&&t.name&&n.includes(t.name)||r&&fM(t,r)||s&&t.id&&s.includes(t.id)||(i||o||a?(a&&t.name&&a.some((e=>e===t.name))||i&&fM(t,i)||o&&t.id&&o.some((e=>e===t.id)))&&l.push(t):l.push(t));return l}function bM(e){if(!e.length)return[];const t=[];for(const a of e){const e=a,n=t.pop();if(n)if("tool"===e._getType()||e._getType()!==n._getType())t.push(n,e);else{const a=If(n),i=If(e),r=a.concat(i);"string"==typeof a.content&&"string"==typeof i.content&&(r.content=`${a.content}\n${i.content}`),t.push(AM(r))}else t.push(e)}return t}async function vM(e,t){const{maxTokens:a,tokenCounter:n,strategy:i="last",allowPartial:r=!1,endOn:o,startOn:s,includeSystem:l=!1,textSplitter:c}=t;if(s&&"first"===i)throw new Error("`startOn` should only be specified if `strategy` is 'last'.");if(l&&"first"===i)throw new Error("`includeSystem` should only be specified if `strategy` is 'last'.");let u;u="getNumTokens"in n?async e=>(await Promise.all(e.map((e=>n.getNumTokens(e.content))))).reduce(((e,t)=>e+t),0):async e=>n(e);let d=SM;if(c&&(d="splitText"in c?c.splitText:async e=>c(e)),"first"===i)return wM(e,{maxTokens:a,tokenCounter:u,textSplitter:d,partialStrategy:r?"first":void 0,endOn:o});if("last"===i)return async function(e,t){const{allowPartial:a=!1,includeSystem:n=!1,endOn:i,startOn:r,...o}=t;if(i){const t=Array.isArray(i)?i:[i];for(;e&&!fM(e[e.length-1],t);)e.pop()}const s=n&&"system"===e[0]._getType();let l=s?e.slice(0,1).concat(e.slice(1).reverse()):e.reverse();return l=await wM(l,{...o,partialStrategy:a?"last":void 0,endOn:r}),s?[l[0],...l.slice(1).reverse()]:l.reverse()}(e,{maxTokens:a,tokenCounter:u,textSplitter:d,allowPartial:r,includeSystem:l,startOn:s,endOn:o});throw new Error(`Unrecognized strategy: '${i}'. Must be one of 'first' or 'last'.`)}async function wM(e,t){const{maxTokens:a,tokenCounter:n,textSplitter:i,partialStrategy:r,endOn:o}=t;let s=[...e],l=0;for(let e=0;e<s.length;e+=1){const t=e>0?s.slice(0,-e):s;if(await n(t)<=a){l=s.length-e;break}}if(l<s.length-1&&r){let e=!1;if(Array.isArray(s[l].content)){const t=s[l];if("string"==typeof t.content)throw new Error("Expected content to be an array.");const i=t.content.length,o="last"===r?[...t.content].reverse():t.content;for(let c=1;c<=i;c+=1){const i="first"===r?o.slice(0,c):o.slice(-c),u=Object.fromEntries(Object.entries(t).filter((([e])=>"type"!==e&&!e.startsWith("lc_")))),d=kM(t._getType(),{...u,content:i}),m=[...s.slice(0,l),d];if(!(await n(m)<=a))break;s=m,l+=1,e=!0}e&&"last"===r&&(t.content=[...o].reverse())}if(!e){const e=s[l];let t;if(Array.isArray(e.content)&&e.content.some((e=>"string"==typeof e||"text"===e.type))){const a=e.content.find((e=>"text"===e.type&&e.text));t=a?.text}else"string"==typeof e.content&&(t=e.content);if(t){const o=await i(t),c=o.length;"last"===r&&o.reverse();for(let t=0;t<c-1;t+=1)if(o.pop(),e.content=o.join(""),await n([...s.slice(0,l),e])<=a){"last"===r&&(e.content=[...o].reverse().join("")),s=[...s.slice(0,l),e],l+=1;break}}}}if(o){const e=Array.isArray(o)?o:[o];for(;l>0&&!fM(s[l-1],e);)l-=1}return s.slice(0,l)}const xM={human:{message:Sf,messageChunk:Ef},ai:{message:ff,messageChunk:vf},system:{message:_f,messageChunk:Cf},tool:{message:pf,messageChunk:gf},function:{message:kf,messageChunk:Af},generic:{message:wf,messageChunk:xf},remove:{message:gM,messageChunk:gM}};function kM(e,t,a){let n;switch(e){case"human":n=new Sf(t);break;case"ai":n=new ff(t);break;case"system":n=new _f(t);break;case"tool":if(!("tool_call_id"in t))throw new Error("Can not convert ToolMessage to ToolMessageChunk if 'tool_call_id' field is not defined.");n=new pf(t);break;case"function":if(!t.name)throw new Error("FunctionMessage must have a 'name' field");n=new kf(t);break;case"generic":if(!("role"in t))throw new Error("Can not convert ChatMessage to ChatMessageChunk if 'role' field is not defined.");n=new wf(t);break;default:throw new Error(`Unrecognized message type ${e}`)}if(n)return n;throw new Error(`Unrecognized message type ${e}`)}function AM(e){const t=e._getType();let a;const n=Object.fromEntries(Object.entries(e).filter((([e])=>!["type","tool_call_chunks"].includes(e)&&!e.startsWith("lc_"))));if(t in xM&&(a=kM(t,n)),!a)throw new Error(`Unrecognized message chunk class ${t}. Supported classes are ${Object.keys(xM)}`);return a}function SM(e){const t=e.split("\n");return Promise.resolve([...t.slice(0,-1).map((e=>`${e}\n`)),t[t.length-1]])}var EM=Object.freeze({__proto__:null,AIMessage:ff,AIMessageChunk:vf,BaseMessage:of,BaseMessageChunk:uf,ChatMessage:wf,ChatMessageChunk:xf,FunctionMessage:kf,FunctionMessageChunk:Af,HumanMessage:Sf,HumanMessageChunk:Ef,RemoveMessage:gM,SystemMessage:_f,SystemMessageChunk:Cf,ToolMessage:pf,ToolMessageChunk:gf,_isMessageFieldWithRole:df,_mergeDicts:sf,_mergeLists:lf,_mergeObj:cf,_mergeStatus:rf,coerceMessageLikeToMessage:Of,convertToChunk:If,defaultTextSplitter:SM,filterMessages:function(e,t){return Array.isArray(e)?yM(e,t):pA.from((t=>yM(t,e)))},getBufferString:Df,isAIMessage:yf,isAIMessageChunk:bf,isBaseMessage:mf,isBaseMessageChunk:hf,isChatMessage:function(e){return"generic"===e._getType()},isChatMessageChunk:function(e){return"generic"===e._getType()},isFunctionMessage:function(e){return"function"===e._getType()},isFunctionMessageChunk:function(e){return"function"===e._getType()},isHumanMessage:function(e){return"human"===e.getType()},isHumanMessageChunk:function(e){return"human"===e.getType()},isOpenAIToolCallArray:function(e){return Array.isArray(e)&&e.every((e=>"number"==typeof e.index))},isSystemMessage:function(e){return"system"===e._getType()},isSystemMessageChunk:function(e){return"system"===e._getType()},isToolMessage:function(e){return"tool"===e._getType()},isToolMessageChunk:function(e){return"tool"===e._getType()},mapChatMessagesToStoredMessages:function(e){return e.map((e=>e.toDict()))},mapStoredMessageToChatMessage:Mf,mapStoredMessagesToChatMessages:function(e){return e.map(Mf)},mergeContent:nf,mergeMessageRuns:function(e){return Array.isArray(e)?bM(e):pA.from(bM)},trimMessages:function(e,t){if(Array.isArray(e)){const a=e;if(!t)throw new Error("Options parameter is required when providing messages.");return vM(a,t)}{const t=e;return pA.from((e=>vM(e,t)))}}});const _M="4.68.1";let CM,TM,PM,OM,DM,MM,IM,NM,jM,zM=!1;class RM{constructor(e){this.body=e}get[Symbol.toStringTag](){return"MultipartBody"}}CM||function(e,t={auto:!1}){if(zM)throw new Error(`you must \`import 'openai/shims/${e.kind}'\` before importing anything else from openai`);if(CM)throw new Error(`can't \`import 'openai/shims/${e.kind}'\` after \`import 'openai/shims/${CM}'\``);zM=t.auto,CM=e.kind,TM=e.fetch,PM=e.FormData,OM=e.File,DM=e.ReadableStream,MM=e.getMultipartRequestOptions,IM=e.getDefaultAgent,NM=e.fileFromPath,jM=e.isFsReadStream}(function({manuallyImported:e}={}){const t=e?"You may need to use polyfills":"Add one of these imports before your first `import … from 'openai'`:\n- `import 'openai/shims/node'` (if you're running on Node)\n- `import 'openai/shims/web'` (otherwise)\n";let a,n,i,r;try{a=fetch,n=Request,i=Response,r=Headers}catch(e){throw new Error(`this environment is missing the following Web Fetch API type: ${e.message}. ${t}`)}return{kind:"web",fetch:a,Request:n,Response:i,Headers:r,FormData:"undefined"!=typeof FormData?FormData:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'FormData' is undefined. ${t}`)}},Blob:"undefined"!=typeof Blob?Blob:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'Blob' is undefined. ${t}`)}},File:"undefined"!=typeof File?File:class{constructor(){throw new Error(`file uploads aren't supported in this environment yet as 'File' is undefined. ${t}`)}},ReadableStream:"undefined"!=typeof ReadableStream?ReadableStream:class{constructor(){throw new Error(`streaming isn't supported in this environment yet as 'ReadableStream' is undefined. ${t}`)}},getMultipartRequestOptions:async(e,t)=>({...t,body:new RM(e)}),getDefaultAgent:e=>{},fileFromPath:()=>{throw new Error("The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/openai/openai-node#file-uploads")},isFsReadStream:e=>!1}}(),{auto:!0});class LM{constructor(){this.buffer=[],this.trailingCR=!1}decode(e){let t=this.decodeText(e);if(this.trailingCR&&(t="\r"+t,this.trailingCR=!1),t.endsWith("\r")&&(this.trailingCR=!0,t=t.slice(0,-1)),!t)return[];const a=LM.NEWLINE_CHARS.has(t[t.length-1]||"");let n=t.split(LM.NEWLINE_REGEXP);return a&&n.pop(),1!==n.length||a?(this.buffer.length>0&&(n=[this.buffer.join("")+n[0],...n.slice(1)],this.buffer=[]),a||(this.buffer=[n.pop()||""]),n):(this.buffer.push(n[0]),[])}decodeText(e){if(null==e)return"";if("string"==typeof e)return e;if("undefined"!=typeof Buffer){if(e instanceof Buffer)return e.toString();if(e instanceof Uint8Array)return Buffer.from(e).toString();throw new OI(`Unexpected: received non-Uint8Array (${e.constructor.name}) stream chunk in an environment with a global "Buffer" defined, which this library assumes to be Node. Please report this error.`)}if("undefined"!=typeof TextDecoder){if(e instanceof Uint8Array||e instanceof ArrayBuffer)return this.textDecoder??(this.textDecoder=new TextDecoder("utf8")),this.textDecoder.decode(e);throw new OI(`Unexpected: received non-Uint8Array/ArrayBuffer (${e.constructor.name}) in a web platform. Please report this error.`)}throw new OI("Unexpected: neither Buffer nor TextDecoder are available as globals. Please report this error.")}flush(){if(!this.buffer.length&&!this.trailingCR)return[];const e=[this.buffer.join("")];return this.buffer=[],this.trailingCR=!1,e}}LM.NEWLINE_CHARS=new Set(["\n","\r"]),LM.NEWLINE_REGEXP=/\r\n|[\n\r]/g;class FM{constructor(e,t){this.iterator=e,this.controller=t}static fromSSEResponse(e,t){let a=!1;return new FM((async function*(){if(a)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let n=!1;try{for await(const a of async function*(e,t){if(!e.body)throw t.abort(),new OI("Attempted to iterate over a response with no body");const a=new HM,n=new LM,i=qM(e.body);for await(const e of async function*(e){let t=new Uint8Array;for await(const a of e){if(null==a)continue;const e=a instanceof ArrayBuffer?new Uint8Array(a):"string"==typeof a?(new TextEncoder).encode(a):a;let n,i=new Uint8Array(t.length+e.length);for(i.set(t),i.set(e,t.length),t=i;-1!==(n=BM(t));)yield t.slice(0,n),t=t.slice(n)}t.length>0&&(yield t)}(i))for(const t of n.decode(e)){const e=a.decode(t);e&&(yield e)}for(const e of n.flush()){const t=a.decode(e);t&&(yield t)}}(e,t))if(!n)if(a.data.startsWith("[DONE]"))n=!0;else if(null===a.event){let e;try{e=JSON.parse(a.data)}catch(e){throw console.error("Could not parse message into JSON:",a.data),console.error("From chunk:",a.raw),e}if(e&&e.error)throw new DI(void 0,e.error,void 0,void 0);yield e}else{let e;try{e=JSON.parse(a.data)}catch(e){throw console.error("Could not parse message into JSON:",a.data),console.error("From chunk:",a.raw),e}if("error"==a.event)throw new DI(void 0,e.error,e.message,void 0);yield{event:a.event,data:e}}n=!0}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}finally{n||t.abort()}}),t)}static fromReadableStream(e,t){let a=!1;return new FM((async function*(){if(a)throw new Error("Cannot iterate over a consumed stream, use `.tee()` to split the stream.");a=!0;let n=!1;try{for await(const t of async function*(){const t=new LM,a=qM(e);for await(const e of a)for(const a of t.decode(e))yield a;for(const e of t.flush())yield e}())n||t&&(yield JSON.parse(t));n=!0}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;throw e}finally{n||t.abort()}}),t)}[Symbol.asyncIterator](){return this.iterator()}tee(){const e=[],t=[],a=this.iterator(),n=n=>({next:()=>{if(0===n.length){const n=a.next();e.push(n),t.push(n)}return n.shift()}});return[new FM((()=>n(e)),this.controller),new FM((()=>n(t)),this.controller)]}toReadableStream(){const e=this;let t;const a=new TextEncoder;return new DM({async start(){t=e[Symbol.asyncIterator]()},async pull(e){try{const{value:n,done:i}=await t.next();if(i)return e.close();const r=a.encode(JSON.stringify(n)+"\n");e.enqueue(r)}catch(t){e.error(t)}},async cancel(){await(t.return?.())}})}}function BM(e){for(let t=0;t<e.length-2;t++){if(10===e[t]&&10===e[t+1])return t+2;if(13===e[t]&&13===e[t+1])return t+2;if(13===e[t]&&10===e[t+1]&&t+3<e.length&&13===e[t+2]&&10===e[t+3])return t+4}return-1}class HM{constructor(){this.event=null,this.data=[],this.chunks=[]}decode(e){if(e.endsWith("\r")&&(e=e.substring(0,e.length-1)),!e){if(!this.event&&!this.data.length)return null;const e={event:this.event,data:this.data.join("\n"),raw:this.chunks};return this.event=null,this.data=[],this.chunks=[],e}if(this.chunks.push(e),e.startsWith(":"))return null;let[t,a,n]=function(e,t){const a=e.indexOf(t);if(-1!==a)return[e.substring(0,a),t,e.substring(a+t.length)];return[e,"",""]}(e,":");return n.startsWith(" ")&&(n=n.substring(1)),"event"===t?this.event=n:"data"===t&&this.data.push(n),null}}function qM(e){if(e[Symbol.asyncIterator])return e;const t=e.getReader();return{async next(){try{const e=await t.read();return e?.done&&t.releaseLock(),e}catch(e){throw t.releaseLock(),e}},async return(){const e=t.cancel();return t.releaseLock(),await e,{done:!0,value:void 0}},[Symbol.asyncIterator](){return this}}}const UM=e=>null!=e&&"object"==typeof e&&"string"==typeof e.url&&"function"==typeof e.blob,WM=e=>null!=e&&"object"==typeof e&&"string"==typeof e.name&&"number"==typeof e.lastModified&&VM(e),VM=e=>null!=e&&"object"==typeof e&&"number"==typeof e.size&&"string"==typeof e.type&&"function"==typeof e.text&&"function"==typeof e.slice&&"function"==typeof e.arrayBuffer;async function $M(e,t,a){if(e=await e,WM(e))return e;if(UM(e)){const n=await e.blob();t||(t=new URL(e.url).pathname.split(/[\\/]/).pop()??"unknown_file");const i=VM(n)?[await n.arrayBuffer()]:[n];return new OM(i,t,a)}const n=await async function(e){let t=[];if("string"==typeof e||ArrayBuffer.isView(e)||e instanceof ArrayBuffer)t.push(e);else if(VM(e))t.push(await e.arrayBuffer());else{if(!KM(e))throw new Error(`Unexpected data type: ${typeof e}; constructor: ${e?.constructor?.name}; props: ${function(e){const t=Object.getOwnPropertyNames(e);return`[${t.map((e=>`"${e}"`)).join(", ")}]`}(e)}`);for await(const a of e)t.push(a)}return t}(e);if(t||(t=function(e){return GM(e.name)||GM(e.filename)||GM(e.path)?.split(/[\\/]/).pop()}(e)??"unknown_file"),!a?.type){const e=n[0]?.type;"string"==typeof e&&(a={...a,type:e})}return new OM(n,t,a)}const GM=e=>"string"==typeof e?e:"undefined"!=typeof Buffer&&e instanceof Buffer?String(e):void 0,KM=e=>null!=e&&"object"==typeof e&&"function"==typeof e[Symbol.asyncIterator],ZM=e=>e&&"object"==typeof e&&e.body&&"MultipartBody"===e[Symbol.toStringTag],YM=async e=>{const t=await XM(e.body);return MM(t,e)},XM=async e=>{const t=new PM;return await Promise.all(Object.entries(e||{}).map((([e,a])=>QM(t,e,a)))),t},QM=async(e,t,a)=>{if(void 0!==a){if(null==a)throw new TypeError(`Received null for "${t}"; to pass null in FormData, you must use the string 'null'`);if("string"==typeof a||"number"==typeof a||"boolean"==typeof a)e.append(t,String(a));else if((e=>WM(e)||UM(e)||jM(e))(a)){const n=await $M(a);e.append(t,n)}else if(Array.isArray(a))await Promise.all(a.map((a=>QM(e,t+"[]",a))));else{if("object"!=typeof a)throw new TypeError(`Invalid value given to form, expected a string, number, boolean, object, Array, File or Blob but got ${a} instead`);await Promise.all(Object.entries(a).map((([a,n])=>QM(e,`${t}[${a}]`,n))))}}};var JM,eI=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},tI=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};async function aI(e){const{response:t}=e;if(e.options.stream)return _I("response",t.status,t.url,t.headers,t.body),e.options.__streamClass?e.options.__streamClass.fromSSEResponse(t,e.controller):FM.fromSSEResponse(t,e.controller);if(204===t.status)return null;if(e.options.__binaryResponse)return t;const a=t.headers.get("content-type");if(a?.includes("application/json")||a?.includes("application/vnd.api+json")){const e=await t.json();return _I("response",t.status,t.url,t.headers,e),nI(e,t)}const n=await t.text();return _I("response",t.status,t.url,t.headers,n),n}function nI(e,t){return!e||"object"!=typeof e||Array.isArray(e)?e:Object.defineProperty(e,"_request_id",{value:t.headers.get("x-request-id"),enumerable:!1})}class iI extends Promise{constructor(e,t=aI){super((e=>{e(null)})),this.responsePromise=e,this.parseResponse=t}_thenUnwrap(e){return new iI(this.responsePromise,(async t=>nI(e(await this.parseResponse(t),t),t.response)))}asResponse(){return this.responsePromise.then((e=>e.response))}async withResponse(){const[e,t]=await Promise.all([this.parse(),this.asResponse()]);return{data:e,response:t,request_id:t.headers.get("x-request-id")}}parse(){return this.parsedPromise||(this.parsedPromise=this.responsePromise.then(this.parseResponse)),this.parsedPromise}then(e,t){return this.parse().then(e,t)}catch(e){return this.parse().catch(e)}finally(e){return this.parse().finally(e)}}class rI{constructor({baseURL:e,maxRetries:t=2,timeout:a=6e5,httpAgent:n,fetch:i}){this.baseURL=e,this.maxRetries=wI("maxRetries",t),this.timeout=wI("timeout",a),this.httpAgent=n,this.fetch=i??TM}authHeaders(e){return{}}defaultHeaders(e){return{Accept:"application/json","Content-Type":"application/json","User-Agent":this.getUserAgent(),...gI(),...this.authHeaders(e)}}validateHeaders(e,t){}defaultIdempotencyKey(){return`stainless-node-retry-${CI()}`}get(e,t){return this.methodRequest("get",e,t)}post(e,t){return this.methodRequest("post",e,t)}patch(e,t){return this.methodRequest("patch",e,t)}put(e,t){return this.methodRequest("put",e,t)}delete(e,t){return this.methodRequest("delete",e,t)}methodRequest(e,t,a){return this.request(Promise.resolve(a).then((async a=>{const n=a&&VM(a?.body)?new DataView(await a.body.arrayBuffer()):a?.body instanceof DataView?a.body:a?.body instanceof ArrayBuffer?new DataView(a.body):a&&ArrayBuffer.isView(a?.body)?new DataView(a.body.buffer):a?.body;return{method:e,path:t,...a,body:n}})))}getAPIList(e,t,a){return this.requestAPIList(t,{method:"get",path:e,...a})}calculateContentLength(e){if("string"==typeof e){if("undefined"!=typeof Buffer)return Buffer.byteLength(e,"utf8").toString();if("undefined"!=typeof TextEncoder){return(new TextEncoder).encode(e).length.toString()}}else if(ArrayBuffer.isView(e))return e.byteLength.toString();return null}buildRequest(e,{retryCount:t=0}={}){const{method:a,path:n,query:i,headers:r={}}=e,o=ArrayBuffer.isView(e.body)||e.__binaryRequest&&"string"==typeof e.body?e.body:ZM(e.body)?e.body.body:e.body?JSON.stringify(e.body,null,2):null,s=this.calculateContentLength(o),l=this.buildURL(n,i);"timeout"in e&&wI("timeout",e.timeout);const c=e.timeout??this.timeout,u=e.httpAgent??this.httpAgent??IM(l),d=c+1e3;"number"==typeof u?.options?.timeout&&d>(u.options.timeout??0)&&(u.options.timeout=d),this.idempotencyHeader&&"get"!==a&&(e.idempotencyKey||(e.idempotencyKey=this.defaultIdempotencyKey()),r[this.idempotencyHeader]=e.idempotencyKey);return{req:{method:a,...o&&{body:o},headers:this.buildHeaders({options:e,headers:r,contentLength:s,retryCount:t}),...u&&{agent:u},signal:e.signal??null},url:l,timeout:c}}buildHeaders({options:e,headers:t,contentLength:a,retryCount:n}){const i={};a&&(i["content-length"]=a);const r=this.defaultHeaders(e);return EI(i,r),EI(i,t),ZM(e.body)&&"node"!==CM&&delete i["content-type"],void 0===TI(r,"x-stainless-retry-count")&&void 0===TI(t,"x-stainless-retry-count")&&(i["x-stainless-retry-count"]=String(n)),this.validateHeaders(i,t),i}async prepareOptions(e){}async prepareRequest(e,{url:t,options:a}){}parseHeaders(e){return e?Symbol.iterator in e?Object.fromEntries(Array.from(e).map((e=>[...e]))):{...e}:{}}makeStatusError(e,t,a,n){return DI.generate(e,t,a,n)}request(e,t=null){return new iI(this.makeRequest(e,t))}async makeRequest(e,t){const a=await e,n=a.maxRetries??this.maxRetries;null==t&&(t=n),await this.prepareOptions(a);const{req:i,url:r,timeout:o}=this.buildRequest(a,{retryCount:n-t});if(await this.prepareRequest(i,{url:r,options:a}),_I("request",r,a,i.headers),a.signal?.aborted)throw new MI;const s=new AbortController,l=await this.fetchWithTimeout(r,i,o,s).catch(xI);if(l instanceof Error){if(a.signal?.aborted)throw new MI;if(t)return this.retryRequest(a,t);if("AbortError"===l.name)throw new NI;throw new II({cause:l})}const c=lI(l.headers);if(!l.ok){if(t&&this.shouldRetry(l)){return _I(`response (error; ${`retrying, ${t} attempts remaining`})`,l.status,r,c),this.retryRequest(a,t,c)}const e=await l.text().catch((e=>xI(e).message)),n=fI(e),i=n?void 0:e;_I(`response (error; ${t?"(error; no more retries left)":"(error; not retryable)"})`,l.status,r,c,i);throw this.makeStatusError(l.status,n,i,c)}return{response:l,options:a,controller:s}}requestAPIList(e,t){const a=this.makeRequest(t,null);return new sI(this,a,e)}buildURL(e,t){const a=bI(e)?new URL(e):new URL(this.baseURL+(this.baseURL.endsWith("/")&&e.startsWith("/")?e.slice(1):e)),n=this.defaultQuery();return AI(n)||(t={...n,...t}),"object"==typeof t&&t&&!Array.isArray(t)&&(a.search=this.stringifyQuery(t)),a.toString()}stringifyQuery(e){return Object.entries(e).filter((([e,t])=>void 0!==t)).map((([e,t])=>{if("string"==typeof t||"number"==typeof t||"boolean"==typeof t)return`${encodeURIComponent(e)}=${encodeURIComponent(t)}`;if(null===t)return`${encodeURIComponent(e)}=`;throw new OI(`Cannot stringify type ${typeof t}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`)})).join("&")}async fetchWithTimeout(e,t,a,n){const{signal:i,...r}=t||{};i&&i.addEventListener("abort",(()=>n.abort()));const o=setTimeout((()=>n.abort()),a);return this.getRequestClient().fetch.call(void 0,e,{signal:n.signal,...r}).finally((()=>{clearTimeout(o)}))}getRequestClient(){return{fetch:this.fetch}}shouldRetry(e){const t=e.headers.get("x-should-retry");return"true"===t||"false"!==t&&(408===e.status||(409===e.status||(429===e.status||e.status>=500)))}async retryRequest(e,t,a){let n;const i=a?.["retry-after-ms"];if(i){const e=parseFloat(i);Number.isNaN(e)||(n=e)}const r=a?.["retry-after"];if(r&&!n){const e=parseFloat(r);n=Number.isNaN(e)?Date.parse(r)-Date.now():1e3*e}if(!(n&&0<=n&&n<6e4)){const a=e.maxRetries??this.maxRetries;n=this.calculateDefaultRetryTimeoutMillis(t,a)}return await vI(n),this.makeRequest(e,t-1)}calculateDefaultRetryTimeoutMillis(e,t){const a=t-e;return Math.min(.5*Math.pow(2,a),8)*(1-.25*Math.random())*1e3}getUserAgent(){return`${this.constructor.name}/JS ${_M}`}}class oI{constructor(e,t,a,n){JM.set(this,void 0),eI(this,JM,e,"f"),this.options=n,this.response=t,this.body=a}hasNextPage(){return!!this.getPaginatedItems().length&&null!=this.nextPageInfo()}async getNextPage(){const e=this.nextPageInfo();if(!e)throw new OI("No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.");const t={...this.options};if("params"in e&&"object"==typeof t.query)t.query={...t.query,...e.params};else if("url"in e){const a=[...Object.entries(t.query||{}),...e.url.searchParams.entries()];for(const[t,n]of a)e.url.searchParams.set(t,n);t.query=void 0,t.path=e.url.toString()}return await tI(this,JM,"f").requestAPIList(this.constructor,t)}async*iterPages(){let e=this;for(yield e;e.hasNextPage();)e=await e.getNextPage(),yield e}async*[(JM=new WeakMap,Symbol.asyncIterator)](){for await(const e of this.iterPages())for(const t of e.getPaginatedItems())yield t}}class sI extends iI{constructor(e,t,a){super(t,(async t=>new a(e,t.response,await aI(t),t.options)))}async*[Symbol.asyncIterator](){const e=await(this);for await(const t of e)yield t}}const lI=e=>new Proxy(Object.fromEntries(e.entries()),{get(e,t){const a=t.toString();return e[a.toLowerCase()]||e[a]}}),cI={method:!0,path:!0,query:!0,body:!0,headers:!0,maxRetries:!0,stream:!0,timeout:!0,httpAgent:!0,signal:!0,idempotencyKey:!0,__binaryRequest:!0,__binaryResponse:!0,__streamClass:!0},uI=e=>"object"==typeof e&&null!==e&&!AI(e)&&Object.keys(e).every((e=>SI(cI,e))),dI=()=>{if("undefined"!=typeof Deno&&null!=Deno.build)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":hI(Deno.build.os),"X-Stainless-Arch":mI(Deno.build.arch),"X-Stainless-Runtime":"deno","X-Stainless-Runtime-Version":"string"==typeof Deno.version?Deno.version:Deno.version?.deno??"unknown"};if("undefined"!=typeof EdgeRuntime)return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":`other:${EdgeRuntime}`,"X-Stainless-Runtime":"edge","X-Stainless-Runtime-Version":process.version};if("[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0))return{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":hI(process.platform),"X-Stainless-Arch":mI(process.arch),"X-Stainless-Runtime":"node","X-Stainless-Runtime-Version":process.version};const e=function(){if("undefined"==typeof navigator||!navigator)return null;const e=[{key:"edge",pattern:/Edge(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/MSIE(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"ie",pattern:/Trident(?:.*rv\:(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"chrome",pattern:/Chrome(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"firefox",pattern:/Firefox(?:\W+(\d+)\.(\d+)(?:\.(\d+))?)?/},{key:"safari",pattern:/(?:Version\W+(\d+)\.(\d+)(?:\.(\d+))?)?(?:\W+Mobile\S*)?\W+Safari/}];for(const{key:t,pattern:a}of e){const e=a.exec(navigator.userAgent);if(e){return{browser:t,version:`${e[1]||0}.${e[2]||0}.${e[3]||0}`}}}return null}();return e?{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":`browser:${e.browser}`,"X-Stainless-Runtime-Version":e.version}:{"X-Stainless-Lang":"js","X-Stainless-Package-Version":_M,"X-Stainless-OS":"Unknown","X-Stainless-Arch":"unknown","X-Stainless-Runtime":"unknown","X-Stainless-Runtime-Version":"unknown"}};const mI=e=>"x32"===e?"x32":"x86_64"===e||"x64"===e?"x64":"arm"===e?"arm":"aarch64"===e||"arm64"===e?"arm64":e?`other:${e}`:"unknown",hI=e=>(e=e.toLowerCase()).includes("ios")?"iOS":"android"===e?"Android":"darwin"===e?"MacOS":"win32"===e?"Windows":"freebsd"===e?"FreeBSD":"openbsd"===e?"OpenBSD":"linux"===e?"Linux":e?`Other:${e}`:"Unknown";let pI;const gI=()=>pI??(pI=dI()),fI=e=>{try{return JSON.parse(e)}catch(e){return}},yI=new RegExp("^(?:[a-z]+:)?//","i"),bI=e=>yI.test(e),vI=e=>new Promise((t=>setTimeout(t,e))),wI=(e,t)=>{if("number"!=typeof t||!Number.isInteger(t))throw new OI(`${e} must be an integer`);if(t<0)throw new OI(`${e} must be a positive integer`);return t},xI=e=>{if(e instanceof Error)return e;if("object"==typeof e&&null!==e)try{return new Error(JSON.stringify(e))}catch{}return new Error(e)},kI=e=>"undefined"!=typeof process?process.env?.[e]?.trim()??void 0:"undefined"!=typeof Deno?Deno.env?.get?.(e)?.trim():void 0;function AI(e){if(!e)return!0;for(const t in e)return!1;return!0}function SI(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function EI(e,t){for(const a in t){if(!SI(t,a))continue;const n=a.toLowerCase();if(!n)continue;const i=t[a];null===i?delete e[n]:void 0!==i&&(e[n]=i)}}function _I(e,...t){"undefined"!=typeof process&&"true"===process?.env?.DEBUG&&console.log(`OpenAI:DEBUG:${e}`,...t)}const CI=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),TI=(e,t)=>{const a=t.toLowerCase();if((e=>"function"==typeof e?.get)(e)){const n=t[0]?.toUpperCase()+t.substring(1).replace(/([^\w])(\w)/g,((e,t,a)=>t+a.toUpperCase()));for(const i of[t,a,t.toUpperCase(),n]){const t=e.get(i);if(t)return t}}for(const[n,i]of Object.entries(e))if(n.toLowerCase()===a)return Array.isArray(i)?(i.length<=1||console.warn(`Received ${i.length} entries for the ${t} header, using the first entry.`),i[0]):i};function PI(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)}let OI=class extends Error{},DI=class e extends OI{constructor(t,a,n,i){super(`${e.makeMessage(t,a,n)}`),this.status=t,this.headers=i,this.request_id=i?.["x-request-id"];const r=a;this.error=r,this.code=r?.code,this.param=r?.param,this.type=r?.type}static makeMessage(e,t,a){const n=t?.message?"string"==typeof t.message?t.message:JSON.stringify(t.message):t?JSON.stringify(t):a;return e&&n?`${e} ${n}`:e?`${e} status code (no body)`:n||"(no status code or body)"}static generate(t,a,n,i){if(!t)return new II({message:n,cause:xI(a)});const r=a?.error;return 400===t?new jI(t,r,n,i):401===t?new zI(t,r,n,i):403===t?new RI(t,r,n,i):404===t?new LI(t,r,n,i):409===t?new FI(t,r,n,i):422===t?new BI(t,r,n,i):429===t?new HI(t,r,n,i):t>=500?new qI(t,r,n,i):new e(t,r,n,i)}},MI=class extends DI{constructor({message:e}={}){super(void 0,void 0,e||"Request was aborted.",void 0),this.status=void 0}},II=class extends DI{constructor({message:e,cause:t}){super(void 0,void 0,e||"Connection error.",void 0),this.status=void 0,t&&(this.cause=t)}},NI=class extends II{constructor({message:e}={}){super({message:e??"Request timed out."})}},jI=class extends DI{constructor(){super(...arguments),this.status=400}},zI=class extends DI{constructor(){super(...arguments),this.status=401}},RI=class extends DI{constructor(){super(...arguments),this.status=403}},LI=class extends DI{constructor(){super(...arguments),this.status=404}},FI=class extends DI{constructor(){super(...arguments),this.status=409}},BI=class extends DI{constructor(){super(...arguments),this.status=422}},HI=class extends DI{constructor(){super(...arguments),this.status=429}},qI=class extends DI{};class UI extends OI{constructor(){super("Could not parse response content as the length limit was reached")}}class WI extends OI{constructor(){super("Could not parse response content as the request was rejected by the content filter")}}var VI=Object.freeze({__proto__:null,APIConnectionError:II,APIConnectionTimeoutError:NI,APIError:DI,APIUserAbortError:MI,AuthenticationError:zI,BadRequestError:jI,ConflictError:FI,ContentFilterFinishReasonError:WI,InternalServerError:qI,LengthFinishReasonError:UI,NotFoundError:LI,OpenAIError:OI,PermissionDeniedError:RI,RateLimitError:HI,UnprocessableEntityError:BI});const $I="RFC3986",GI={RFC1738:e=>String(e).replace(/%20/g,"+"),RFC3986:e=>String(e)},KI=Array.isArray,ZI=(()=>{const e=[];for(let t=0;t<256;++t)e.push("%"+((t<16?"0":"")+t.toString(16)).toUpperCase());return e})(),YI=1024;function XI(e,t){if(KI(e)){const a=[];for(let n=0;n<e.length;n+=1)a.push(t(e[n]));return a}return t(e)}const QI=Object.prototype.hasOwnProperty,JI={brackets:e=>String(e)+"[]",comma:"comma",indices:(e,t)=>String(e)+"["+t+"]",repeat:e=>String(e)},eN=Array.isArray,tN=Array.prototype.push,aN=function(e,t){tN.apply(e,eN(t)?t:[t])},nN=Date.prototype.toISOString,iN={addQueryPrefix:!1,allowDots:!1,allowEmptyArrays:!1,arrayFormat:"indices",charset:"utf-8",charsetSentinel:!1,delimiter:"&",encode:!0,encodeDotInKeys:!1,encoder:(e,t,a,n,i)=>{if(0===e.length)return e;let r=e;if("symbol"==typeof e?r=Symbol.prototype.toString.call(e):"string"!=typeof e&&(r=String(e)),"iso-8859-1"===a)return escape(r).replace(/%u[0-9a-f]{4}/gi,(function(e){return"%26%23"+parseInt(e.slice(2),16)+"%3B"}));let o="";for(let e=0;e<r.length;e+=YI){const t=r.length>=YI?r.slice(e,e+YI):r,a=[];for(let e=0;e<t.length;++e){let n=t.charCodeAt(e);45===n||46===n||95===n||126===n||n>=48&&n<=57||n>=65&&n<=90||n>=97&&n<=122||"RFC1738"===i&&(40===n||41===n)?a[a.length]=t.charAt(e):n<128?a[a.length]=ZI[n]:n<2048?a[a.length]=ZI[192|n>>6]+ZI[128|63&n]:n<55296||n>=57344?a[a.length]=ZI[224|n>>12]+ZI[128|n>>6&63]+ZI[128|63&n]:(e+=1,n=65536+((1023&n)<<10|1023&t.charCodeAt(e)),a[a.length]=ZI[240|n>>18]+ZI[128|n>>12&63]+ZI[128|n>>6&63]+ZI[128|63&n])}o+=a.join("")}return o},encodeValuesOnly:!1,format:$I,formatter:GI[$I],indices:!1,serializeDate:e=>nN.call(e),skipNulls:!1,strictNullHandling:!1};const rN={};function oN(e,t,a,n,i,r,o,s,l,c,u,d,m,h,p,g,f,y){let b=e,v=y,w=0,x=!1;for(;void 0!==(v=v.get(rN))&&!x;){const t=v.get(e);if(w+=1,void 0!==t){if(t===w)throw new RangeError("Cyclic object value");x=!0}void 0===v.get(rN)&&(w=0)}if("function"==typeof c?b=c(t,b):b instanceof Date?b=m?.(b):"comma"===a&&eN(b)&&(b=XI(b,(function(e){return e instanceof Date?m?.(e):e}))),null===b){if(r)return l&&!g?l(t,iN.encoder,f,"key",h):t;b=""}if("string"==typeof(k=b)||"number"==typeof k||"boolean"==typeof k||"symbol"==typeof k||"bigint"==typeof k||function(e){return!(!e||"object"!=typeof e||!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e)))}(b)){if(l){const e=g?t:l(t,iN.encoder,f,"key",h);return[p?.(e)+"="+p?.(l(b,iN.encoder,f,"value",h))]}return[p?.(t)+"="+p?.(String(b))]}var k;const A=[];if(void 0===b)return A;let S;if("comma"===a&&eN(b))g&&l&&(b=XI(b,l)),S=[{value:b.length>0?b.join(",")||null:void 0}];else if(eN(c))S=c;else{const e=Object.keys(b);S=u?e.sort(u):e}const E=s?String(t).replace(/\./g,"%2E"):String(t),_=n&&eN(b)&&1===b.length?E+"[]":E;if(i&&eN(b)&&0===b.length)return _+"[]";for(let t=0;t<S.length;++t){const v=S[t],x="object"==typeof v&&void 0!==v.value?v.value:b[v];if(o&&null===x)continue;const k=d&&s?v.replace(/\./g,"%2E"):v,E=eN(b)?"function"==typeof a?a(_,k):_:_+(d?"."+k:"["+k+"]");y.set(e,w);const C=new WeakMap;C.set(rN,y),aN(A,oN(x,E,a,n,i,r,o,s,"comma"===a&&g&&eN(b)?null:l,c,u,d,m,h,p,g,f,C))}return A}function sN(e,t={}){let a=e;const n=function(e=iN){if(void 0!==e.allowEmptyArrays&&"boolean"!=typeof e.allowEmptyArrays)throw new TypeError("`allowEmptyArrays` option can only be `true` or `false`, when provided");if(void 0!==e.encodeDotInKeys&&"boolean"!=typeof e.encodeDotInKeys)throw new TypeError("`encodeDotInKeys` option can only be `true` or `false`, when provided");if(null!==e.encoder&&void 0!==e.encoder&&"function"!=typeof e.encoder)throw new TypeError("Encoder has to be a function.");const t=e.charset||iN.charset;if(void 0!==e.charset&&"utf-8"!==e.charset&&"iso-8859-1"!==e.charset)throw new TypeError("The charset option must be either utf-8, iso-8859-1, or undefined");let a=$I;if(void 0!==e.format){if(!QI.call(GI,e.format))throw new TypeError("Unknown format option provided.");a=e.format}const n=GI[a];let i,r=iN.filter;if(("function"==typeof e.filter||eN(e.filter))&&(r=e.filter),i=e.arrayFormat&&e.arrayFormat in JI?e.arrayFormat:"indices"in e?e.indices?"indices":"repeat":iN.arrayFormat,"commaRoundTrip"in e&&"boolean"!=typeof e.commaRoundTrip)throw new TypeError("`commaRoundTrip` must be a boolean, or absent");const o=void 0===e.allowDots?1==!!e.encodeDotInKeys||iN.allowDots:!!e.allowDots;return{addQueryPrefix:"boolean"==typeof e.addQueryPrefix?e.addQueryPrefix:iN.addQueryPrefix,allowDots:o,allowEmptyArrays:"boolean"==typeof e.allowEmptyArrays?!!e.allowEmptyArrays:iN.allowEmptyArrays,arrayFormat:i,charset:t,charsetSentinel:"boolean"==typeof e.charsetSentinel?e.charsetSentinel:iN.charsetSentinel,commaRoundTrip:!!e.commaRoundTrip,delimiter:void 0===e.delimiter?iN.delimiter:e.delimiter,encode:"boolean"==typeof e.encode?e.encode:iN.encode,encodeDotInKeys:"boolean"==typeof e.encodeDotInKeys?e.encodeDotInKeys:iN.encodeDotInKeys,encoder:"function"==typeof e.encoder?e.encoder:iN.encoder,encodeValuesOnly:"boolean"==typeof e.encodeValuesOnly?e.encodeValuesOnly:iN.encodeValuesOnly,filter:r,format:a,formatter:n,serializeDate:"function"==typeof e.serializeDate?e.serializeDate:iN.serializeDate,skipNulls:"boolean"==typeof e.skipNulls?e.skipNulls:iN.skipNulls,sort:"function"==typeof e.sort?e.sort:null,strictNullHandling:"boolean"==typeof e.strictNullHandling?e.strictNullHandling:iN.strictNullHandling}}(t);let i,r;"function"==typeof n.filter?(r=n.filter,a=r("",a)):eN(n.filter)&&(r=n.filter,i=r);const o=[];if("object"!=typeof a||null===a)return"";const s=JI[n.arrayFormat],l="comma"===s&&n.commaRoundTrip;i||(i=Object.keys(a)),n.sort&&i.sort(n.sort);const c=new WeakMap;for(let e=0;e<i.length;++e){const t=i[e];n.skipNulls&&null===a[t]||aN(o,oN(a[t],t,s,l,n.allowEmptyArrays,n.strictNullHandling,n.skipNulls,n.encodeDotInKeys,n.encode?n.encoder:null,n.filter,n.sort,n.allowDots,n.serializeDate,n.format,n.formatter,n.encodeValuesOnly,n.charset,c))}const u=o.join(n.delimiter);let d=!0===n.addQueryPrefix?"?":"";return n.charsetSentinel&&("iso-8859-1"===n.charset?d+="utf8=%26%2310003%3B&":d+="utf8=%E2%9C%93&"),u.length>0?d+u:""}let lN=class extends oI{constructor(e,t,a,n){super(e,t,a,n),this.data=a.data||[],this.object=a.object}getPaginatedItems(){return this.data??[]}nextPageParams(){return null}nextPageInfo(){return null}};class cN extends oI{constructor(e,t,a,n){super(e,t,a,n),this.data=a.data||[]}getPaginatedItems(){return this.data??[]}nextPageParams(){const e=this.nextPageInfo();if(!e)return null;if("params"in e)return e.params;const t=Object.fromEntries(e.url.searchParams);return Object.keys(t).length?t:null}nextPageInfo(){const e=this.getPaginatedItems();if(!e.length)return null;const t=e[e.length-1]?.id;return t?{params:{after:t}}:null}}class uN{constructor(e){this._client=e}}let dN=class extends uN{create(e,t){return this._client.post("/chat/completions",{body:e,...t,stream:e.stream??!1})}};dN||(dN={});let mN=class extends uN{constructor(){super(...arguments),this.completions=new dN(this._client)}};(mN||(mN={})).Completions=dN;class hN extends uN{create(e,t){return this._client.post("/audio/speech",{body:e,...t,__binaryResponse:!0})}}hN||(hN={});class pN extends uN{create(e,t){return this._client.post("/audio/transcriptions",YM({body:e,...t}))}}pN||(pN={});class gN extends uN{create(e,t){return this._client.post("/audio/translations",YM({body:e,...t}))}}gN||(gN={});class fN extends uN{constructor(){super(...arguments),this.transcriptions=new pN(this._client),this.translations=new gN(this._client),this.speech=new hN(this._client)}}!function(e){e.Transcriptions=pN,e.Translations=gN,e.Speech=hN}(fN||(fN={}));class yN extends uN{create(e,t){return this._client.post("/batches",{body:e,...t})}retrieve(e,t){return this._client.get(`/batches/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/batches",bN,{query:e,...t})}cancel(e,t){return this._client.post(`/batches/${e}/cancel`,t)}}class bN extends cN{}!function(e){e.BatchesPage=bN}(yN||(yN={}));class vN extends uN{create(e,t){return this._client.post("/assistants",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/assistants/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/assistants",wN,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/assistants/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class wN extends cN{}function xN(e){return"function"==typeof e.parse}!function(e){e.AssistantsPage=wN}(vN||(vN={}));const kN=e=>"assistant"===e?.role,AN=e=>"function"===e?.role,SN=e=>"tool"===e?.role;var EN,_N,CN,TN,PN,ON,DN,MN,IN,NN,jN,zN,RN,LN=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},FN=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};class BN{constructor(){EN.add(this),this.controller=new AbortController,_N.set(this,void 0),CN.set(this,(()=>{})),TN.set(this,(()=>{})),PN.set(this,void 0),ON.set(this,(()=>{})),DN.set(this,(()=>{})),MN.set(this,{}),IN.set(this,!1),NN.set(this,!1),jN.set(this,!1),zN.set(this,!1),LN(this,_N,new Promise(((e,t)=>{LN(this,CN,e,"f"),LN(this,TN,t,"f")})),"f"),LN(this,PN,new Promise(((e,t)=>{LN(this,ON,e,"f"),LN(this,DN,t,"f")})),"f"),FN(this,_N,"f").catch((()=>{})),FN(this,PN,"f").catch((()=>{}))}_run(e){setTimeout((()=>{e().then((()=>{this._emitFinal(),this._emit("end")}),FN(this,EN,"m",RN).bind(this))}),0)}_connected(){this.ended||(FN(this,CN,"f").call(this),this._emit("connect"))}get ended(){return FN(this,IN,"f")}get errored(){return FN(this,NN,"f")}get aborted(){return FN(this,jN,"f")}abort(){this.controller.abort()}on(e,t){return(FN(this,MN,"f")[e]||(FN(this,MN,"f")[e]=[])).push({listener:t}),this}off(e,t){const a=FN(this,MN,"f")[e];if(!a)return this;const n=a.findIndex((e=>e.listener===t));return n>=0&&a.splice(n,1),this}once(e,t){return(FN(this,MN,"f")[e]||(FN(this,MN,"f")[e]=[])).push({listener:t,once:!0}),this}emitted(e){return new Promise(((t,a)=>{LN(this,zN,!0,"f"),"error"!==e&&this.once("error",a),this.once(e,t)}))}async done(){LN(this,zN,!0,"f"),await FN(this,PN,"f")}_emit(e,...t){if(FN(this,IN,"f"))return;"end"===e&&(LN(this,IN,!0,"f"),FN(this,ON,"f").call(this));const a=FN(this,MN,"f")[e];if(a&&(FN(this,MN,"f")[e]=a.filter((e=>!e.once)),a.forEach((({listener:e})=>e(...t)))),"abort"===e){const e=t[0];return FN(this,zN,"f")||a?.length||Promise.reject(e),FN(this,TN,"f").call(this,e),FN(this,DN,"f").call(this,e),void this._emit("end")}if("error"===e){const e=t[0];FN(this,zN,"f")||a?.length||Promise.reject(e),FN(this,TN,"f").call(this,e),FN(this,DN,"f").call(this,e),this._emit("end")}}_emitFinal(){}}function HN(e){return"auto-parseable-response-format"===e?.$brand}function qN(e){return"auto-parseable-tool"===e?.$brand}function UN(e,t){const a=e.choices.map((e=>{if("length"===e.finish_reason)throw new UI;if("content_filter"===e.finish_reason)throw new WI;return{...e,message:{...e.message,tool_calls:e.message.tool_calls?.map((e=>function(e,t){const a=e.tools?.find((e=>e.function?.name===t.function.name));return{...t,function:{...t.function,parsed_arguments:qN(a)?a.$parseRaw(t.function.arguments):a?.function.strict?JSON.parse(t.function.arguments):null}}}(t,e)))??[],parsed:e.message.content&&!e.message.refusal?WN(t,e.message.content):null}}}));return{...e,choices:a}}function WN(e,t){if("json_schema"!==e.response_format?.type)return null;if("json_schema"===e.response_format?.type){if("$parseRaw"in e.response_format){return e.response_format.$parseRaw(t)}return JSON.parse(t)}return null}function VN(e,t){if(!e)return!1;const a=e.tools?.find((e=>e.function?.name===t.function.name));return qN(a)||a?.function.strict||!1}function $N(e){return!!HN(e.response_format)||(e.tools?.some((e=>qN(e)||"function"===e.type&&!0===e.function.strict))??!1)}_N=new WeakMap,CN=new WeakMap,TN=new WeakMap,PN=new WeakMap,ON=new WeakMap,DN=new WeakMap,MN=new WeakMap,IN=new WeakMap,NN=new WeakMap,jN=new WeakMap,zN=new WeakMap,EN=new WeakSet,RN=function(e){if(LN(this,NN,!0,"f"),e instanceof Error&&"AbortError"===e.name&&(e=new MI),e instanceof MI)return LN(this,jN,!0,"f"),this._emit("abort",e);if(e instanceof OI)return this._emit("error",e);if(e instanceof Error){const t=new OI(e.message);return t.cause=e,this._emit("error",t)}return this._emit("error",new OI(String(e)))};var GN,KN,ZN,YN,XN,QN,JN,ej,tj=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};const aj=10;class nj extends BN{constructor(){super(...arguments),GN.add(this),this._chatCompletions=[],this.messages=[]}_addChatCompletion(e){this._chatCompletions.push(e),this._emit("chatCompletion",e);const t=e.choices[0]?.message;return t&&this._addMessage(t),e}_addMessage(e,t=!0){if("content"in e||(e.content=null),this.messages.push(e),t)if(this._emit("message",e),(AN(e)||SN(e))&&e.content)this._emit("functionCallResult",e.content);else if(kN(e)&&e.function_call)this._emit("functionCall",e.function_call);else if(kN(e)&&e.tool_calls)for(const t of e.tool_calls)"function"===t.type&&this._emit("functionCall",t.function)}async finalChatCompletion(){await this.done();const e=this._chatCompletions[this._chatCompletions.length-1];if(!e)throw new OI("stream ended without producing a ChatCompletion");return e}async finalContent(){return await this.done(),tj(this,GN,"m",KN).call(this)}async finalMessage(){return await this.done(),tj(this,GN,"m",ZN).call(this)}async finalFunctionCall(){return await this.done(),tj(this,GN,"m",YN).call(this)}async finalFunctionCallResult(){return await this.done(),tj(this,GN,"m",XN).call(this)}async totalUsage(){return await this.done(),tj(this,GN,"m",QN).call(this)}allChatCompletions(){return[...this._chatCompletions]}_emitFinal(){const e=this._chatCompletions[this._chatCompletions.length-1];e&&this._emit("finalChatCompletion",e);const t=tj(this,GN,"m",ZN).call(this);t&&this._emit("finalMessage",t);const a=tj(this,GN,"m",KN).call(this);a&&this._emit("finalContent",a);const n=tj(this,GN,"m",YN).call(this);n&&this._emit("finalFunctionCall",n);const i=tj(this,GN,"m",XN).call(this);null!=i&&this._emit("finalFunctionCallResult",i),this._chatCompletions.some((e=>e.usage))&&this._emit("totalUsage",tj(this,GN,"m",QN).call(this))}async _createChatCompletion(e,t,a){const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort()))),tj(this,GN,"m",JN).call(this,t);const i=await e.chat.completions.create({...t,stream:!1},{...a,signal:this.controller.signal});return this._connected(),this._addChatCompletion(UN(i,t))}async _runChatCompletion(e,t,a){for(const e of t.messages)this._addMessage(e,!1);return await this._createChatCompletion(e,t,a)}async _runFunctions(e,t,a){const n="function",{function_call:i="auto",stream:r,...o}=t,s="string"!=typeof i&&i?.name,{maxChatCompletions:l=aj}=a||{},c={};for(const e of t.functions)c[e.name||e.function.name]=e;const u=t.functions.map((e=>({name:e.name||e.function.name,parameters:e.parameters,description:e.description})));for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){const t=await this._createChatCompletion(e,{...o,function_call:i,functions:u,messages:[...this.messages]},a),r=t.choices[0]?.message;if(!r)throw new OI("missing message in ChatCompletion response");if(!r.function_call)return;const{name:l,arguments:d}=r.function_call,m=c[l];if(!m){const e=`Invalid function_call: ${JSON.stringify(l)}. Available options are: ${u.map((e=>JSON.stringify(e.name))).join(", ")}. Please try again`;this._addMessage({role:n,name:l,content:e});continue}if(s&&s!==l){const e=`Invalid function_call: ${JSON.stringify(l)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:n,name:l,content:e});continue}let h;try{h=xN(m)?await m.parse(d):d}catch(e){this._addMessage({role:n,name:l,content:e instanceof Error?e.message:String(e)});continue}const p=await m.function(h,this),g=tj(this,GN,"m",ej).call(this,p);if(this._addMessage({role:n,name:l,content:g}),s)return}}async _runTools(e,t,a){const n="tool",{tool_choice:i="auto",stream:r,...o}=t,s="string"!=typeof i&&i?.function?.name,{maxChatCompletions:l=aj}=a||{},c=t.tools.map((e=>{if(qN(e)){if(!e.$callback)throw new OI("Tool given to `.runTools()` that does not have an associated function");return{type:"function",function:{function:e.$callback,name:e.function.name,description:e.function.description||"",parameters:e.function.parameters,parse:e.$parseRaw,strict:!0}}}return e})),u={};for(const e of c)"function"===e.type&&(u[e.function.name||e.function.function.name]=e.function);const d="tools"in t?c.map((e=>"function"===e.type?{type:"function",function:{name:e.function.name||e.function.function.name,parameters:e.function.parameters,description:e.function.description,strict:e.function.strict}}:e)):void 0;for(const e of t.messages)this._addMessage(e,!1);for(let t=0;t<l;++t){const t=await this._createChatCompletion(e,{...o,tool_choice:i,tools:d,messages:[...this.messages]},a),r=t.choices[0]?.message;if(!r)throw new OI("missing message in ChatCompletion response");if(!r.tool_calls?.length)return;for(const e of r.tool_calls){if("function"!==e.type)continue;const t=e.id,{name:a,arguments:i}=e.function,r=u[a];if(!r){const e=`Invalid tool_call: ${JSON.stringify(a)}. Available options are: ${Object.keys(u).map((e=>JSON.stringify(e))).join(", ")}. Please try again`;this._addMessage({role:n,tool_call_id:t,content:e});continue}if(s&&s!==a){const e=`Invalid tool_call: ${JSON.stringify(a)}. ${JSON.stringify(s)} requested. Please try again`;this._addMessage({role:n,tool_call_id:t,content:e});continue}let o;try{o=xN(r)?await r.parse(i):i}catch(e){const a=e instanceof Error?e.message:String(e);this._addMessage({role:n,tool_call_id:t,content:a});continue}const l=await r.function(o,this),c=tj(this,GN,"m",ej).call(this,l);if(this._addMessage({role:n,tool_call_id:t,content:c}),s)return}}}}GN=new WeakSet,KN=function(){return tj(this,GN,"m",ZN).call(this).content??null},ZN=function(){let e=this.messages.length;for(;e-- >0;){const t=this.messages[e];if(kN(t)){const{function_call:e,...a}=t,n={...a,content:t.content??null,refusal:t.refusal??null};return e&&(n.function_call=e),n}}throw new OI("stream ended without producing a ChatCompletionMessage with role=assistant")},YN=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(kN(t)&&t?.function_call)return t.function_call;if(kN(t)&&t?.tool_calls?.length)return t.tool_calls.at(-1)?.function}},XN=function(){for(let e=this.messages.length-1;e>=0;e--){const t=this.messages[e];if(AN(t)&&null!=t.content)return t.content;if(SN(t)&&null!=t.content&&"string"==typeof t.content&&this.messages.some((e=>"assistant"===e.role&&e.tool_calls?.some((e=>"function"===e.type&&e.id===t.tool_call_id)))))return t.content}},QN=function(){const e={completion_tokens:0,prompt_tokens:0,total_tokens:0};for(const{usage:t}of this._chatCompletions)t&&(e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens);return e},JN=function(e){if(null!=e.n&&e.n>1)throw new OI("ChatCompletion convenience helpers only support n=1 at this time. To use n>1, please use chat.completions.create() directly.")},ej=function(e){return"string"==typeof e?e:void 0===e?"undefined":JSON.stringify(e)};class ij extends nj{static runFunctions(e,t,a){const n=new ij,i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run((()=>n._runFunctions(e,t,i))),n}static runTools(e,t,a){const n=new ij,i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run((()=>n._runTools(e,t,i))),n}_addMessage(e,t=!0){super._addMessage(e,t),kN(e)&&e.content&&this._emit("content",e.content)}}const rj=1,oj=2,sj=4,lj=8,cj=16,uj=32,dj=64,mj=128,hj=256,pj=511;class gj extends Error{}class fj extends Error{}const yj=(e,t)=>{const a=e.length;let n=0;const i=e=>{throw new gj(`${e} at position ${n}`)},r=e=>{throw new fj(`${e} at position ${n}`)},o=()=>(d(),n>=a&&i("Unexpected end of input"),'"'===e[n]?s():"{"===e[n]?l():"["===e[n]?c():"null"===e.substring(n,n+4)||cj&t&&a-n<4&&"null".startsWith(e.substring(n))?(n+=4,null):"true"===e.substring(n,n+4)||uj&t&&a-n<4&&"true".startsWith(e.substring(n))?(n+=4,!0):"false"===e.substring(n,n+5)||uj&t&&a-n<5&&"false".startsWith(e.substring(n))?(n+=5,!1):"Infinity"===e.substring(n,n+8)||mj&t&&a-n<8&&"Infinity".startsWith(e.substring(n))?(n+=8,1/0):"-Infinity"===e.substring(n,n+9)||hj&t&&1<a-n&&a-n<9&&"-Infinity".startsWith(e.substring(n))?(n+=9,-1/0):"NaN"===e.substring(n,n+3)||dj&t&&a-n<3&&"NaN".startsWith(e.substring(n))?(n+=3,NaN):u()),s=()=>{const o=n;let s=!1;for(n++;n<a&&('"'!==e[n]||s&&"\\"===e[n-1]);)s="\\"===e[n]&&!s,n++;if('"'==e.charAt(n))try{return JSON.parse(e.substring(o,++n-Number(s)))}catch(e){r(String(e))}else if(rj&t)try{return JSON.parse(e.substring(o,n-Number(s))+'"')}catch(t){return JSON.parse(e.substring(o,e.lastIndexOf("\\"))+'"')}i("Unterminated string literal")},l=()=>{n++,d();const r={};try{for(;"}"!==e[n];){if(d(),n>=a&&lj&t)return r;const i=s();d(),n++;try{const e=o();Object.defineProperty(r,i,{value:e,writable:!0,enumerable:!0,configurable:!0})}catch(e){if(lj&t)return r;throw e}d(),","===e[n]&&n++}}catch(e){if(lj&t)return r;i("Expected '}' at end of object")}return n++,r},c=()=>{n++;const a=[];try{for(;"]"!==e[n];)a.push(o()),d(),","===e[n]&&n++}catch(e){if(sj&t)return a;i("Expected ']' at end of array")}return n++,a},u=()=>{if(0===n){"-"===e&&oj&t&&i("Not sure what '-' is");try{return JSON.parse(e)}catch(a){if(oj&t)try{return"."===e[e.length-1]?JSON.parse(e.substring(0,e.lastIndexOf("."))):JSON.parse(e.substring(0,e.lastIndexOf("e")))}catch(e){}r(String(a))}}const o=n;for("-"===e[n]&&n++;e[n]&&!",]}".includes(e[n]);)n++;n!=a||oj&t||i("Unterminated number literal");try{return JSON.parse(e.substring(o,n))}catch(a){"-"===e.substring(o,n)&&oj&t&&i("Not sure what '-' is");try{return JSON.parse(e.substring(o,e.lastIndexOf("e")))}catch(e){r(String(e))}}},d=()=>{for(;n<a&&" \n\r\t".includes(e[n]);)n++};return o()},bj=e=>function(e,t=pj){if("string"!=typeof e)throw new TypeError("expecting str, got "+typeof e);if(!e.trim())throw new Error(`${e} is empty`);return yj(e.trim(),t)}(e,pj^oj);var vj,wj,xj,kj,Aj,Sj,Ej,_j,Cj,Tj,Pj,Oj,Dj=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a},Mj=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)};class Ij extends nj{constructor(e){super(),vj.add(this),wj.set(this,void 0),xj.set(this,void 0),kj.set(this,void 0),Dj(this,wj,e,"f"),Dj(this,xj,[],"f")}get currentChatCompletionSnapshot(){return Mj(this,kj,"f")}static fromReadableStream(e){const t=new Ij(null);return t._run((()=>t._fromReadableStream(e))),t}static createChatCompletion(e,t,a){const n=new Ij(t);return n._run((()=>n._runChatCompletion(e,{...t,stream:!0},{...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"stream"}}))),n}async _createChatCompletion(e,t,a){super._createChatCompletion;const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort()))),Mj(this,vj,"m",Aj).call(this);const i=await e.chat.completions.create({...t,stream:!0},{...a,signal:this.controller.signal});this._connected();for await(const e of i)Mj(this,vj,"m",Ej).call(this,e);if(i.controller.signal?.aborted)throw new MI;return this._addChatCompletion(Mj(this,vj,"m",Tj).call(this))}async _fromReadableStream(e,t){const a=t?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",(()=>this.controller.abort()))),Mj(this,vj,"m",Aj).call(this),this._connected();const n=FM.fromReadableStream(e,this.controller);let i;for await(const e of n)i&&i!==e.id&&this._addChatCompletion(Mj(this,vj,"m",Tj).call(this)),Mj(this,vj,"m",Ej).call(this,e),i=e.id;if(n.controller.signal?.aborted)throw new MI;return this._addChatCompletion(Mj(this,vj,"m",Tj).call(this))}[(wj=new WeakMap,xj=new WeakMap,kj=new WeakMap,vj=new WeakSet,Aj=function(){this.ended||Dj(this,kj,void 0,"f")},Sj=function(e){let t=Mj(this,xj,"f")[e.index];return t||(t={content_done:!1,refusal_done:!1,logprobs_content_done:!1,logprobs_refusal_done:!1,done_tool_calls:new Set,current_tool_call_index:null},Mj(this,xj,"f")[e.index]=t,t)},Ej=function(e){if(this.ended)return;const t=Mj(this,vj,"m",Oj).call(this,e);this._emit("chunk",e,t);for(const a of e.choices){const e=t.choices[a.index];null!=a.delta.content&&"assistant"===e.message?.role&&e.message?.content&&(this._emit("content",a.delta.content,e.message.content),this._emit("content.delta",{delta:a.delta.content,snapshot:e.message.content,parsed:e.message.parsed})),null!=a.delta.refusal&&"assistant"===e.message?.role&&e.message?.refusal&&this._emit("refusal.delta",{delta:a.delta.refusal,snapshot:e.message.refusal}),null!=a.logprobs?.content&&"assistant"===e.message?.role&&this._emit("logprobs.content.delta",{content:a.logprobs?.content,snapshot:e.logprobs?.content??[]}),null!=a.logprobs?.refusal&&"assistant"===e.message?.role&&this._emit("logprobs.refusal.delta",{refusal:a.logprobs?.refusal,snapshot:e.logprobs?.refusal??[]});const n=Mj(this,vj,"m",Sj).call(this,e);e.finish_reason&&(Mj(this,vj,"m",Cj).call(this,e),null!=n.current_tool_call_index&&Mj(this,vj,"m",_j).call(this,e,n.current_tool_call_index));for(const t of a.delta.tool_calls??[])n.current_tool_call_index!==t.index&&(Mj(this,vj,"m",Cj).call(this,e),null!=n.current_tool_call_index&&Mj(this,vj,"m",_j).call(this,e,n.current_tool_call_index)),n.current_tool_call_index=t.index;for(const t of a.delta.tool_calls??[]){const a=e.message.tool_calls?.[t.index];a?.type&&("function"===a?.type&&this._emit("tool_calls.function.arguments.delta",{name:a.function?.name,index:t.index,arguments:a.function.arguments,parsed_arguments:a.function.parsed_arguments,arguments_delta:t.function?.arguments??""}))}}},_j=function(e,t){if(Mj(this,vj,"m",Sj).call(this,e).done_tool_calls.has(t))return;const a=e.message.tool_calls?.[t];if(!a)throw new Error("no tool call snapshot");if(!a.type)throw new Error("tool call snapshot missing `type`");if("function"===a.type){const e=Mj(this,wj,"f")?.tools?.find((e=>"function"===e.type&&e.function.name===a.function.name));this._emit("tool_calls.function.arguments.done",{name:a.function.name,index:t,arguments:a.function.arguments,parsed_arguments:qN(e)?e.$parseRaw(a.function.arguments):e?.function.strict?JSON.parse(a.function.arguments):null})}else a.type},Cj=function(e){const t=Mj(this,vj,"m",Sj).call(this,e);if(e.message.content&&!t.content_done){t.content_done=!0;const a=Mj(this,vj,"m",Pj).call(this);this._emit("content.done",{content:e.message.content,parsed:a?a.$parseRaw(e.message.content):null})}e.message.refusal&&!t.refusal_done&&(t.refusal_done=!0,this._emit("refusal.done",{refusal:e.message.refusal})),e.logprobs?.content&&!t.logprobs_content_done&&(t.logprobs_content_done=!0,this._emit("logprobs.content.done",{content:e.logprobs.content})),e.logprobs?.refusal&&!t.logprobs_refusal_done&&(t.logprobs_refusal_done=!0,this._emit("logprobs.refusal.done",{refusal:e.logprobs.refusal}))},Tj=function(){if(this.ended)throw new OI("stream has ended, this shouldn't happen");const e=Mj(this,kj,"f");if(!e)throw new OI("request ended without sending any chunks");return Dj(this,kj,void 0,"f"),Dj(this,xj,[],"f"),function(e,t){const{id:a,choices:n,created:i,model:r,system_fingerprint:o,...s}=e,l={...s,id:a,choices:n.map((({message:t,finish_reason:a,index:n,logprobs:i,...r})=>{if(!a)throw new OI(`missing finish_reason for choice ${n}`);const{content:o=null,function_call:s,tool_calls:l,...c}=t,u=t.role;if(!u)throw new OI(`missing role for choice ${n}`);if(s){const{arguments:e,name:l}=s;if(null==e)throw new OI(`missing function_call.arguments for choice ${n}`);if(!l)throw new OI(`missing function_call.name for choice ${n}`);return{...r,message:{content:o,function_call:{arguments:e,name:l},role:u,refusal:t.refusal??null},finish_reason:a,index:n,logprobs:i}}return l?{...r,index:n,finish_reason:a,logprobs:i,message:{...c,role:u,content:o,refusal:t.refusal??null,tool_calls:l.map(((t,a)=>{const{function:i,type:r,id:o,...s}=t,{arguments:l,name:c,...u}=i||{};if(null==o)throw new OI(`missing choices[${n}].tool_calls[${a}].id\n${Nj(e)}`);if(null==r)throw new OI(`missing choices[${n}].tool_calls[${a}].type\n${Nj(e)}`);if(null==c)throw new OI(`missing choices[${n}].tool_calls[${a}].function.name\n${Nj(e)}`);if(null==l)throw new OI(`missing choices[${n}].tool_calls[${a}].function.arguments\n${Nj(e)}`);return{...s,id:o,type:r,function:{...u,name:c,arguments:l}}}))}}:{...r,message:{...c,content:o,role:u,refusal:t.refusal??null},finish_reason:a,index:n,logprobs:i}})),created:i,model:r,object:"chat.completion",...o?{system_fingerprint:o}:{}};return function(e,t){return t&&$N(t)?UN(e,t):{...e,choices:e.choices.map((e=>({...e,message:{...e.message,parsed:null,tool_calls:e.message.tool_calls??[]}})))}}(l,t)}(e,Mj(this,wj,"f"))},Pj=function(){const e=Mj(this,wj,"f")?.response_format;return HN(e)?e:null},Oj=function(e){var t,a,n,i;let r=Mj(this,kj,"f");const{choices:o,...s}=e;r?Object.assign(r,s):r=Dj(this,kj,{...s,choices:[]},"f");for(const{delta:o,finish_reason:s,index:l,logprobs:c=null,...u}of e.choices){let e=r.choices[l];if(e||(e=r.choices[l]={finish_reason:s,index:l,message:{},logprobs:c,...u}),c)if(e.logprobs){const{content:n,refusal:i,...r}=c;Object.assign(e.logprobs,r),n&&((t=e.logprobs).content??(t.content=[]),e.logprobs.content.push(...n)),i&&((a=e.logprobs).refusal??(a.refusal=[]),e.logprobs.refusal.push(...i))}else e.logprobs=Object.assign({},c);if(s&&(e.finish_reason=s,Mj(this,wj,"f")&&$N(Mj(this,wj,"f")))){if("length"===s)throw new UI;if("content_filter"===s)throw new WI}if(Object.assign(e,u),!o)continue;const{content:d,refusal:m,function_call:h,role:p,tool_calls:g,...f}=o;if(Object.assign(e.message,f),m&&(e.message.refusal=(e.message.refusal||"")+m),p&&(e.message.role=p),h&&(e.message.function_call?(h.name&&(e.message.function_call.name=h.name),h.arguments&&((n=e.message.function_call).arguments??(n.arguments=""),e.message.function_call.arguments+=h.arguments)):e.message.function_call=h),d&&(e.message.content=(e.message.content||"")+d,!e.message.refusal&&Mj(this,vj,"m",Pj).call(this)&&(e.message.parsed=bj(e.message.content))),g){e.message.tool_calls||(e.message.tool_calls=[]);for(const{index:t,id:a,type:n,function:r,...o}of g){const s=(i=e.message.tool_calls)[t]??(i[t]={});Object.assign(s,o),a&&(s.id=a),n&&(s.type=n),r&&(s.function??(s.function={name:r.name??"",arguments:""})),r?.name&&(s.function.name=r.name),r?.arguments&&(s.function.arguments+=r.arguments,VN(Mj(this,wj,"f"),s)&&(s.function.parsed_arguments=bj(s.function.arguments)))}}}return r},Symbol.asyncIterator)](){const e=[],t=[];let a=!1;return this.on("chunk",(a=>{const n=t.shift();n?n.resolve(a):e.push(a)})),this.on("end",(()=>{a=!0;for(const e of t)e.resolve(void 0);t.length=0})),this.on("abort",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),this.on("error",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),{next:async()=>{if(!e.length)return a?{value:void 0,done:!0}:new Promise(((e,a)=>t.push({resolve:e,reject:a}))).then((e=>e?{value:e,done:!1}:{value:void 0,done:!0}));return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}toReadableStream(){return new FM(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}}function Nj(e){return JSON.stringify(e)}class jj extends Ij{static fromReadableStream(e){const t=new jj(null);return t._run((()=>t._fromReadableStream(e))),t}static runFunctions(e,t,a){const n=new jj(null),i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runFunctions"}};return n._run((()=>n._runFunctions(e,t,i))),n}static runTools(e,t,a){const n=new jj(t),i={...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"runTools"}};return n._run((()=>n._runTools(e,t,i))),n}}let zj=class extends uN{parse(e,t){return function(e){for(const t of e??[]){if("function"!==t.type)throw new OI(`Currently only \`function\` tool types support auto-parsing; Received \`${t.type}\``);if(!0!==t.function.strict)throw new OI(`The \`${t.function.name}\` tool is not marked with \`strict: true\`. Only strict function tools can be auto-parsed`)}}(e.tools),this._client.chat.completions.create(e,{...t,headers:{...t?.headers,"X-Stainless-Helper-Method":"beta.chat.completions.parse"}})._thenUnwrap((t=>UN(t,e)))}runFunctions(e,t){return e.stream?jj.runFunctions(this._client,e,t):ij.runFunctions(this._client,e,t)}runTools(e,t){return e.stream?jj.runTools(this._client,e,t):ij.runTools(this._client,e,t)}stream(e,t){return Ij.createChatCompletion(this._client,e,t)}};class Rj extends uN{constructor(){super(...arguments),this.completions=new zj(this._client)}}!function(e){e.Completions=zj}(Rj||(Rj={}));var Lj,Fj,Bj,Hj,qj,Uj,Wj,Vj,$j,Gj,Kj,Zj,Yj,Xj,Qj,Jj,ez,tz,az,nz,iz,rz,oz=function(e,t,a,n){if("a"===a&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?n:"a"===a?n.call(e):n?n.value:t.get(e)},sz=function(e,t,a,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(e,a):i?i.value=a:t.set(e,a),a};class lz extends BN{constructor(){super(...arguments),Lj.add(this),Fj.set(this,[]),Bj.set(this,{}),Hj.set(this,{}),qj.set(this,void 0),Uj.set(this,void 0),Wj.set(this,void 0),Vj.set(this,void 0),$j.set(this,void 0),Gj.set(this,void 0),Kj.set(this,void 0),Zj.set(this,void 0),Yj.set(this,void 0)}[(Fj=new WeakMap,Bj=new WeakMap,Hj=new WeakMap,qj=new WeakMap,Uj=new WeakMap,Wj=new WeakMap,Vj=new WeakMap,$j=new WeakMap,Gj=new WeakMap,Kj=new WeakMap,Zj=new WeakMap,Yj=new WeakMap,Lj=new WeakSet,Symbol.asyncIterator)](){const e=[],t=[];let a=!1;return this.on("event",(a=>{const n=t.shift();n?n.resolve(a):e.push(a)})),this.on("end",(()=>{a=!0;for(const e of t)e.resolve(void 0);t.length=0})),this.on("abort",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),this.on("error",(e=>{a=!0;for(const a of t)a.reject(e);t.length=0})),{next:async()=>{if(!e.length)return a?{value:void 0,done:!0}:new Promise(((e,a)=>t.push({resolve:e,reject:a}))).then((e=>e?{value:e,done:!1}:{value:void 0,done:!0}));return{value:e.shift(),done:!1}},return:async()=>(this.abort(),{value:void 0,done:!0})}}static fromReadableStream(e){const t=new lz;return t._run((()=>t._fromReadableStream(e))),t}async _fromReadableStream(e,t){const a=t?.signal;a&&(a.aborted&&this.controller.abort(),a.addEventListener("abort",(()=>this.controller.abort()))),this._connected();const n=FM.fromReadableStream(e,this.controller);for await(const e of n)oz(this,Lj,"m",Xj).call(this,e);if(n.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}toReadableStream(){return new FM(this[Symbol.asyncIterator].bind(this),this.controller).toReadableStream()}static createToolAssistantStream(e,t,a,n,i){const r=new lz;return r._run((()=>r._runToolAssistantStream(e,t,a,n,{...i,headers:{...i?.headers,"X-Stainless-Helper-Method":"stream"}}))),r}async _createToolAssistantStream(e,t,a,n,i){const r=i?.signal;r&&(r.aborted&&this.controller.abort(),r.addEventListener("abort",(()=>this.controller.abort())));const o={...n,stream:!0},s=await e.submitToolOutputs(t,a,o,{...i,signal:this.controller.signal});this._connected();for await(const e of s)oz(this,Lj,"m",Xj).call(this,e);if(s.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}static createThreadAssistantStream(e,t,a){const n=new lz;return n._run((()=>n._threadAssistantStream(e,t,{...a,headers:{...a?.headers,"X-Stainless-Helper-Method":"stream"}}))),n}static createAssistantStream(e,t,a,n){const i=new lz;return i._run((()=>i._runAssistantStream(e,t,a,{...n,headers:{...n?.headers,"X-Stainless-Helper-Method":"stream"}}))),i}currentEvent(){return oz(this,Kj,"f")}currentRun(){return oz(this,Zj,"f")}currentMessageSnapshot(){return oz(this,qj,"f")}currentRunStepSnapshot(){return oz(this,Yj,"f")}async finalRunSteps(){return await this.done(),Object.values(oz(this,Bj,"f"))}async finalMessages(){return await this.done(),Object.values(oz(this,Hj,"f"))}async finalRun(){if(await this.done(),!oz(this,Uj,"f"))throw Error("Final run was not received.");return oz(this,Uj,"f")}async _createThreadAssistantStream(e,t,a){const n=a?.signal;n&&(n.aborted&&this.controller.abort(),n.addEventListener("abort",(()=>this.controller.abort())));const i={...t,stream:!0},r=await e.createAndRun(i,{...a,signal:this.controller.signal});this._connected();for await(const e of r)oz(this,Lj,"m",Xj).call(this,e);if(r.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}async _createAssistantStream(e,t,a,n){const i=n?.signal;i&&(i.aborted&&this.controller.abort(),i.addEventListener("abort",(()=>this.controller.abort())));const r={...a,stream:!0},o=await e.create(t,r,{...n,signal:this.controller.signal});this._connected();for await(const e of o)oz(this,Lj,"m",Xj).call(this,e);if(o.controller.signal?.aborted)throw new MI;return this._addRun(oz(this,Lj,"m",Qj).call(this))}static accumulateDelta(e,t){for(const[a,n]of Object.entries(t)){if(!e.hasOwnProperty(a)){e[a]=n;continue}let t=e[a];if(null!=t)if("index"!==a&&"type"!==a){if("string"==typeof t&&"string"==typeof n)t+=n;else if("number"==typeof t&&"number"==typeof n)t+=n;else{if(!PI(t)||!PI(n)){if(Array.isArray(t)&&Array.isArray(n)){if(t.every((e=>"string"==typeof e||"number"==typeof e))){t.push(...n);continue}for(const e of n){if(!PI(e))throw new Error(`Expected array delta entry to be an object but got: ${e}`);const a=e.index;if(null==a)throw console.error(e),new Error("Expected array delta entry to have an `index` property");if("number"!=typeof a)throw new Error(`Expected array delta entry \`index\` property to be a number but got ${a}`);const n=t[a];null==n?t.push(e):t[a]=this.accumulateDelta(n,e)}continue}throw Error(`Unhandled record type: ${a}, deltaValue: ${n}, accValue: ${t}`)}t=this.accumulateDelta(t,n)}e[a]=t}else e[a]=n;else e[a]=n}return e}_addRun(e){return e}async _threadAssistantStream(e,t,a){return await this._createThreadAssistantStream(t,e,a)}async _runAssistantStream(e,t,a,n){return await this._createAssistantStream(t,e,a,n)}async _runToolAssistantStream(e,t,a,n,i){return await this._createToolAssistantStream(a,e,t,n,i)}}Xj=function(e){if(!this.ended)switch(sz(this,Kj,e,"f"),oz(this,Lj,"m",tz).call(this,e),e.event){case"thread.created":break;case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":case"thread.run.requires_action":case"thread.run.completed":case"thread.run.failed":case"thread.run.cancelling":case"thread.run.cancelled":case"thread.run.expired":oz(this,Lj,"m",rz).call(this,e);break;case"thread.run.step.created":case"thread.run.step.in_progress":case"thread.run.step.delta":case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":oz(this,Lj,"m",ez).call(this,e);break;case"thread.message.created":case"thread.message.in_progress":case"thread.message.delta":case"thread.message.completed":case"thread.message.incomplete":oz(this,Lj,"m",Jj).call(this,e);break;case"error":throw new Error("Encountered an error event in event processing - errors should be processed earlier")}},Qj=function(){if(this.ended)throw new OI("stream has ended, this shouldn't happen");if(!oz(this,Uj,"f"))throw Error("Final run has not been received");return oz(this,Uj,"f")},Jj=function(e){const[t,a]=oz(this,Lj,"m",nz).call(this,e,oz(this,qj,"f"));sz(this,qj,t,"f"),oz(this,Hj,"f")[t.id]=t;for(const e of a){const a=t.content[e.index];"text"==a?.type&&this._emit("textCreated",a.text)}switch(e.event){case"thread.message.created":this._emit("messageCreated",e.data);break;case"thread.message.in_progress":break;case"thread.message.delta":if(this._emit("messageDelta",e.data.delta,t),e.data.delta.content)for(const a of e.data.delta.content){if("text"==a.type&&a.text){let e=a.text,n=t.content[a.index];if(!n||"text"!=n.type)throw Error("The snapshot associated with this text delta is not text or missing");this._emit("textDelta",e,n.text)}if(a.index!=oz(this,Wj,"f")){if(oz(this,Vj,"f"))switch(oz(this,Vj,"f").type){case"text":this._emit("textDone",oz(this,Vj,"f").text,oz(this,qj,"f"));break;case"image_file":this._emit("imageFileDone",oz(this,Vj,"f").image_file,oz(this,qj,"f"))}sz(this,Wj,a.index,"f")}sz(this,Vj,t.content[a.index],"f")}break;case"thread.message.completed":case"thread.message.incomplete":if(void 0!==oz(this,Wj,"f")){const t=e.data.content[oz(this,Wj,"f")];if(t)switch(t.type){case"image_file":this._emit("imageFileDone",t.image_file,oz(this,qj,"f"));break;case"text":this._emit("textDone",t.text,oz(this,qj,"f"))}}oz(this,qj,"f")&&this._emit("messageDone",e.data),sz(this,qj,void 0,"f")}},ez=function(e){const t=oz(this,Lj,"m",az).call(this,e);switch(sz(this,Yj,t,"f"),e.event){case"thread.run.step.created":this._emit("runStepCreated",e.data);break;case"thread.run.step.delta":const a=e.data.delta;if(a.step_details&&"tool_calls"==a.step_details.type&&a.step_details.tool_calls&&"tool_calls"==t.step_details.type)for(const e of a.step_details.tool_calls)e.index==oz(this,$j,"f")?this._emit("toolCallDelta",e,t.step_details.tool_calls[e.index]):(oz(this,Gj,"f")&&this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,$j,e.index,"f"),sz(this,Gj,t.step_details.tool_calls[e.index],"f"),oz(this,Gj,"f")&&this._emit("toolCallCreated",oz(this,Gj,"f")));this._emit("runStepDelta",e.data.delta,t);break;case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":sz(this,Yj,void 0,"f");"tool_calls"==e.data.step_details.type&&oz(this,Gj,"f")&&(this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,Gj,void 0,"f")),this._emit("runStepDone",e.data,t)}},tz=function(e){oz(this,Fj,"f").push(e),this._emit("event",e)},az=function(e){switch(e.event){case"thread.run.step.created":return oz(this,Bj,"f")[e.data.id]=e.data,e.data;case"thread.run.step.delta":let t=oz(this,Bj,"f")[e.data.id];if(!t)throw Error("Received a RunStepDelta before creation of a snapshot");let a=e.data;if(a.delta){const n=lz.accumulateDelta(t,a.delta);oz(this,Bj,"f")[e.data.id]=n}return oz(this,Bj,"f")[e.data.id];case"thread.run.step.completed":case"thread.run.step.failed":case"thread.run.step.cancelled":case"thread.run.step.expired":case"thread.run.step.in_progress":oz(this,Bj,"f")[e.data.id]=e.data}if(oz(this,Bj,"f")[e.data.id])return oz(this,Bj,"f")[e.data.id];throw new Error("No snapshot available")},nz=function(e,t){let a=[];switch(e.event){case"thread.message.created":return[e.data,a];case"thread.message.delta":if(!t)throw Error("Received a delta with no existing snapshot (there should be one from message creation)");let n=e.data;if(n.delta.content)for(const e of n.delta.content)if(e.index in t.content){let a=t.content[e.index];t.content[e.index]=oz(this,Lj,"m",iz).call(this,e,a)}else t.content[e.index]=e,a.push(e);return[t,a];case"thread.message.in_progress":case"thread.message.completed":case"thread.message.incomplete":if(t)return[t,a];throw Error("Received thread message event with no existing snapshot")}throw Error("Tried to accumulate a non-message event")},iz=function(e,t){return lz.accumulateDelta(t,e)},rz=function(e){switch(sz(this,Zj,e.data,"f"),e.event){case"thread.run.created":case"thread.run.queued":case"thread.run.in_progress":break;case"thread.run.requires_action":case"thread.run.cancelled":case"thread.run.failed":case"thread.run.completed":case"thread.run.expired":sz(this,Uj,e.data,"f"),oz(this,Gj,"f")&&(this._emit("toolCallDone",oz(this,Gj,"f")),sz(this,Gj,void 0,"f"))}};class cz extends uN{create(e,t,a){return this._client.post(`/threads/${e}/messages`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/threads/${e}/messages/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}update(e,t,a,n){return this._client.post(`/threads/${e}/messages/${t}`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/messages`,uz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t,a){return this._client.delete(`/threads/${e}/messages/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}}class uz extends cN{}!function(e){e.MessagesPage=uz}(cz||(cz={}));class dz extends uN{retrieve(e,t,a,n={},i){return uI(n)?this.retrieve(e,t,a,{},n):this._client.get(`/threads/${e}/runs/${t}/steps/${a}`,{query:n,...i,headers:{"OpenAI-Beta":"assistants=v2",...i?.headers}})}list(e,t,a={},n){return uI(a)?this.list(e,t,{},a):this._client.getAPIList(`/threads/${e}/runs/${t}/steps`,mz,{query:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}}class mz extends cN{}!function(e){e.RunStepsPage=mz}(dz||(dz={}));class hz extends uN{constructor(){super(...arguments),this.steps=new dz(this._client)}create(e,t,a){const{include:n,...i}=t;return this._client.post(`/threads/${e}/runs`,{query:{include:n},body:i,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers},stream:t.stream??!1})}retrieve(e,t,a){return this._client.get(`/threads/${e}/runs/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}update(e,t,a,n){return this._client.post(`/threads/${e}/runs/${t}`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/threads/${e}/runs`,pz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}cancel(e,t,a){return this._client.post(`/threads/${e}/runs/${t}/cancel`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t,a);return await this.poll(e,n.id,a)}createAndStream(e,t,a){return lz.createAssistantStream(e,this._client.beta.threads.runs,t,a)}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const{data:i,response:r}=await this.retrieve(e,t,{...a,headers:{...a?.headers,...n}}).withResponse();switch(i.status){case"queued":case"in_progress":case"cancelling":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=r.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"requires_action":case"incomplete":case"cancelled":case"completed":case"failed":case"expired":return i}}}stream(e,t,a){return lz.createAssistantStream(e,this._client.beta.threads.runs,t,a)}submitToolOutputs(e,t,a,n){return this._client.post(`/threads/${e}/runs/${t}/submit_tool_outputs`,{body:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers},stream:a.stream??!1})}async submitToolOutputsAndPoll(e,t,a,n){const i=await this.submitToolOutputs(e,t,a,n);return await this.poll(e,i.id,n)}submitToolOutputsStream(e,t,a,n){return lz.createToolAssistantStream(e,t,this._client.beta.threads.runs,a,n)}}class pz extends cN{}!function(e){e.RunsPage=pz,e.Steps=dz,e.RunStepsPage=mz}(hz||(hz={}));class gz extends uN{constructor(){super(...arguments),this.runs=new hz(this._client),this.messages=new cz(this._client)}create(e={},t){return uI(e)?this.create({},e):this._client.post("/threads",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/threads/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t){return this._client.delete(`/threads/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}createAndRun(e,t){return this._client.post("/threads/runs",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers},stream:e.stream??!1})}async createAndRunPoll(e,t){const a=await this.createAndRun(e,t);return await this.runs.poll(a.thread_id,a.id,t)}createAndRunStream(e,t){return lz.createThreadAssistantStream(e,this._client.beta.threads,t)}}!function(e){e.Runs=hz,e.RunsPage=pz,e.Messages=cz,e.MessagesPage=uz}(gz||(gz={}));let fz=class extends uN{create(e,t,a){return this._client.post(`/vector_stores/${e}/files`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/vector_stores/${e}/files/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/vector_stores/${e}/files`,yz,{query:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}del(e,t,a){return this._client.delete(`/vector_stores/${e}/files/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t,a);return await this.poll(e,n.id,a)}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const i=await this.retrieve(e,t,{...a,headers:n}).withResponse(),r=i.data;switch(r.status){case"in_progress":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=i.response.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"failed":case"completed":return r}}}async upload(e,t,a){const n=await this._client.files.create({file:t,purpose:"assistants"},a);return this.create(e,{file_id:n.id},a)}async uploadAndPoll(e,t,a){const n=await this.upload(e,t,a);return await this.poll(e,n.id,a)}};class yz extends cN{}(fz||(fz={})).VectorStoreFilesPage=yz;class bz extends uN{create(e,t,a){return this._client.post(`/vector_stores/${e}/file_batches`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}retrieve(e,t,a){return this._client.get(`/vector_stores/${e}/file_batches/${t}`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}cancel(e,t,a){return this._client.post(`/vector_stores/${e}/file_batches/${t}/cancel`,{...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}async createAndPoll(e,t,a){const n=await this.create(e,t);return await this.poll(e,n.id,a)}listFiles(e,t,a={},n){return uI(a)?this.listFiles(e,t,{},a):this._client.getAPIList(`/vector_stores/${e}/file_batches/${t}/files`,yz,{query:a,...n,headers:{"OpenAI-Beta":"assistants=v2",...n?.headers}})}async poll(e,t,a){const n={...a?.headers,"X-Stainless-Poll-Helper":"true"};for(a?.pollIntervalMs&&(n["X-Stainless-Custom-Poll-Interval"]=a.pollIntervalMs.toString());;){const{data:i,response:r}=await this.retrieve(e,t,{...a,headers:n}).withResponse();switch(i.status){case"in_progress":let e=5e3;if(a?.pollIntervalMs)e=a.pollIntervalMs;else{const t=r.headers.get("openai-poll-after-ms");if(t){const a=parseInt(t);isNaN(a)||(e=a)}}await vI(e);break;case"failed":case"cancelled":case"completed":return i}}}async uploadAndPoll(e,{files:t,fileIds:a=[]},n){if(null==t||0==t.length)throw new Error("No `files` provided to process. If you've already uploaded files you should use `.createAndPoll()` instead");const i=n?.maxConcurrency??5,r=Math.min(i,t.length),o=this._client,s=t.values(),l=[...a];const c=Array(r).fill(s).map((async function(e){for(let t of e){const e=await o.files.create({file:t,purpose:"assistants"},n);l.push(e.id)}}));return await(async e=>{const t=await Promise.allSettled(e),a=t.filter((e=>"rejected"===e.status));if(a.length){for(const e of a)console.error(e.reason);throw new Error(`${a.length} promise(s) failed - see the above errors`)}const n=[];for(const e of t)"fulfilled"===e.status&&n.push(e.value);return n})(c),await this.createAndPoll(e,{file_ids:l})}}bz||(bz={});class vz extends uN{constructor(){super(...arguments),this.files=new fz(this._client),this.fileBatches=new bz(this._client)}create(e,t){return this._client.post("/vector_stores",{body:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}retrieve(e,t){return this._client.get(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}update(e,t,a){return this._client.post(`/vector_stores/${e}`,{body:t,...a,headers:{"OpenAI-Beta":"assistants=v2",...a?.headers}})}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/vector_stores",wz,{query:e,...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}del(e,t){return this._client.delete(`/vector_stores/${e}`,{...t,headers:{"OpenAI-Beta":"assistants=v2",...t?.headers}})}}class wz extends cN{}!function(e){e.VectorStoresPage=wz,e.Files=fz,e.VectorStoreFilesPage=yz,e.FileBatches=bz}(vz||(vz={}));class xz extends uN{constructor(){super(...arguments),this.vectorStores=new vz(this._client),this.chat=new Rj(this._client),this.assistants=new vN(this._client),this.threads=new gz(this._client)}}!function(e){e.VectorStores=vz,e.VectorStoresPage=wz,e.Chat=Rj,e.Assistants=vN,e.AssistantsPage=wN,e.Threads=gz}(xz||(xz={}));class kz extends uN{create(e,t){return this._client.post("/completions",{body:e,...t,stream:e.stream??!1})}}kz||(kz={});let Az=class extends uN{create(e,t){return this._client.post("/embeddings",{body:e,...t})}};Az||(Az={});class Sz extends uN{create(e,t){return this._client.post("/files",YM({body:e,...t}))}retrieve(e,t){return this._client.get(`/files/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/files",Ez,{query:e,...t})}del(e,t){return this._client.delete(`/files/${e}`,t)}content(e,t){return this._client.get(`/files/${e}/content`,{...t,__binaryResponse:!0})}retrieveContent(e,t){return this._client.get(`/files/${e}/content`,{...t,headers:{Accept:"application/json",...t?.headers}})}async waitForProcessing(e,{pollInterval:t=5e3,maxWait:a=18e5}={}){const n=new Set(["processed","error","deleted"]),i=Date.now();let r=await this.retrieve(e);for(;!r.status||!n.has(r.status);)if(await vI(t),r=await this.retrieve(e),Date.now()-i>a)throw new NI({message:`Giving up on waiting for file ${e} to finish processing after ${a} milliseconds.`});return r}}class Ez extends lN{}!function(e){e.FileObjectsPage=Ez}(Sz||(Sz={}));class _z extends uN{list(e,t={},a){return uI(t)?this.list(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/checkpoints`,Cz,{query:t,...a})}}class Cz extends cN{}!function(e){e.FineTuningJobCheckpointsPage=Cz}(_z||(_z={}));class Tz extends uN{constructor(){super(...arguments),this.checkpoints=new _z(this._client)}create(e,t){return this._client.post("/fine_tuning/jobs",{body:e,...t})}retrieve(e,t){return this._client.get(`/fine_tuning/jobs/${e}`,t)}list(e={},t){return uI(e)?this.list({},e):this._client.getAPIList("/fine_tuning/jobs",Pz,{query:e,...t})}cancel(e,t){return this._client.post(`/fine_tuning/jobs/${e}/cancel`,t)}listEvents(e,t={},a){return uI(t)?this.listEvents(e,{},t):this._client.getAPIList(`/fine_tuning/jobs/${e}/events`,Oz,{query:t,...a})}}class Pz extends cN{}class Oz extends cN{}!function(e){e.FineTuningJobsPage=Pz,e.FineTuningJobEventsPage=Oz,e.Checkpoints=_z,e.FineTuningJobCheckpointsPage=Cz}(Tz||(Tz={}));class Dz extends uN{constructor(){super(...arguments),this.jobs=new Tz(this._client)}}!function(e){e.Jobs=Tz,e.FineTuningJobsPage=Pz,e.FineTuningJobEventsPage=Oz}(Dz||(Dz={}));class Mz extends uN{createVariation(e,t){return this._client.post("/images/variations",YM({body:e,...t}))}edit(e,t){return this._client.post("/images/edits",YM({body:e,...t}))}generate(e,t){return this._client.post("/images/generations",{body:e,...t})}}Mz||(Mz={});class Iz extends uN{retrieve(e,t){return this._client.get(`/models/${e}`,t)}list(e){return this._client.getAPIList("/models",Nz,e)}del(e,t){return this._client.delete(`/models/${e}`,t)}}class Nz extends lN{}!function(e){e.ModelsPage=Nz}(Iz||(Iz={}));class jz extends uN{create(e,t){return this._client.post("/moderations",{body:e,...t})}}jz||(jz={});class zz extends uN{create(e,t,a){return this._client.post(`/uploads/${e}/parts`,YM({body:t,...a}))}}zz||(zz={});class Rz extends uN{constructor(){super(...arguments),this.parts=new zz(this._client)}create(e,t){return this._client.post("/uploads",{body:e,...t})}cancel(e,t){return this._client.post(`/uploads/${e}/cancel`,t)}complete(e,t,a){return this._client.post(`/uploads/${e}/complete`,{body:t,...a})}}var Lz;!function(e){e.Parts=zz}(Rz||(Rz={}));let Fz=class extends rI{constructor({baseURL:e=kI("OPENAI_BASE_URL"),apiKey:t=kI("OPENAI_API_KEY"),organization:a=kI("OPENAI_ORG_ID")??null,project:n=kI("OPENAI_PROJECT_ID")??null,...i}={}){if(void 0===t)throw new OI("The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'My API Key' }).");const r={apiKey:t,organization:a,project:n,...i,baseURL:e||"https://api.openai.com/v1"};if(!r.dangerouslyAllowBrowser&&"undefined"!=typeof window&&void 0!==window.document&&"undefined"!=typeof navigator)throw new OI("It looks like you're running in a browser-like environment.\n\nThis is disabled by default, as it risks exposing your secret API credentials to attackers.\nIf you understand the risks and have appropriate mitigations in place,\nyou can set the `dangerouslyAllowBrowser` option to `true`, e.g.,\n\nnew OpenAI({ apiKey, dangerouslyAllowBrowser: true });\n\nhttps://help.openai.com/en/articles/5112595-best-practices-for-api-key-safety\n");super({baseURL:r.baseURL,timeout:r.timeout??6e5,httpAgent:r.httpAgent,maxRetries:r.maxRetries,fetch:r.fetch}),this.completions=new kz(this),this.chat=new mN(this),this.embeddings=new Az(this),this.files=new Sz(this),this.images=new Mz(this),this.audio=new fN(this),this.moderations=new jz(this),this.models=new Iz(this),this.fineTuning=new Dz(this),this.beta=new xz(this),this.batches=new yN(this),this.uploads=new Rz(this),this._options=r,this.apiKey=t,this.organization=a,this.project=n}defaultQuery(){return this._options.defaultQuery}defaultHeaders(e){return{...super.defaultHeaders(e),"OpenAI-Organization":this.organization,"OpenAI-Project":this.project,...this._options.defaultHeaders}}authHeaders(e){return{Authorization:`Bearer ${this.apiKey}`}}stringifyQuery(e){return sN(e,{arrayFormat:"brackets"})}};Lz=Fz,Fz.OpenAI=Lz,Fz.DEFAULT_TIMEOUT=6e5,Fz.OpenAIError=OI,Fz.APIError=DI,Fz.APIConnectionError=II,Fz.APIConnectionTimeoutError=NI,Fz.APIUserAbortError=MI,Fz.NotFoundError=LI,Fz.ConflictError=FI,Fz.RateLimitError=HI,Fz.BadRequestError=jI,Fz.AuthenticationError=zI,Fz.InternalServerError=qI,Fz.PermissionDeniedError=RI,Fz.UnprocessableEntityError=BI,Fz.toFile=$M,Fz.fileFromPath=NM;const{OpenAIError:Bz,APIError:Hz,APIConnectionError:qz,APIConnectionTimeoutError:Uz,APIUserAbortError:Wz,NotFoundError:Vz,ConflictError:$z,RateLimitError:Gz,BadRequestError:Kz,AuthenticationError:Zz,InternalServerError:Yz,PermissionDeniedError:Xz,UnprocessableEntityError:Qz}=VI;var Jz;(Jz=Fz||(Fz={})).Page=lN,Jz.CursorPage=cN,Jz.Completions=kz,Jz.Chat=mN,Jz.Embeddings=Az,Jz.Files=Sz,Jz.FileObjectsPage=Ez,Jz.Images=Mz,Jz.Audio=fN,Jz.Moderations=jz,Jz.Models=Iz,Jz.ModelsPage=Nz,Jz.FineTuning=Dz,Jz.Beta=xz,Jz.Batches=yN,Jz.BatchesPage=bN,Jz.Uploads=Rz;class eR extends sA{static lc_name(){return"RunnablePassthrough"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"func",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),e&&(this.func=e.func)}async invoke(e,t){const a=vk(t);return this.func&&await this.func(e,a),this._callWithConfig((e=>Promise.resolve(e)),e,a)}async*transform(e,t){const a=vk(t);let n,i=!0;for await(const t of this._transformStreamWithConfig(e,(e=>e),a))if(yield t,i)if(void 0===n)n=t;else try{n=Qx(n,t)}catch{n=void 0,i=!1}this.func&&void 0!==n&&await this.func(n,a)}static assign(e){return new yA(new mA({steps:e}))}}class tR extends SA{constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","chat_models",this._llmType()]})}_separateRunnableConfigFromCallOptionsCompat(e){const[t,a]=super._separateRunnableConfigFromCallOptions(e);return a.signal=t.signal,[t,a]}async invoke(e,t){const a=tR._convertInputToPromptValue(e);return(await this.generatePrompt([a],t,t?.callbacks)).generations[0][0].message}async*_streamResponseChunks(e,t,a){throw new Error("Not implemented.")}async*_streamIterator(e,t){if(this._streamResponseChunks===tR.prototype._streamResponseChunks)yield this.invoke(e,t);else{const a=tR._convertInputToPromptValue(e).toChatMessages(),[n,i]=this._separateRunnableConfigFromCallOptionsCompat(t),r={...n.metadata,...this.getLsParams(i)},o=await Nw.configure(n.callbacks,this.callbacks,n.tags,this.tags,r,this.metadata,{verbose:this.verbose}),s={options:i,invocation_params:this?.invocationParams(i),batch_size:1},l=await(o?.handleChatModelStart(this.toJSON(),[a],n.runId,void 0,s,void 0,void 0,n.runName));let c,u;try{for await(const e of this._streamResponseChunks(a,i,l?.[0])){if(null==e.message.id){const t=l?.at(0)?.runId;null!=t&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata},yield e.message,c=c?c.concat(e):e,bf(e.message)&&void 0!==e.message.usage_metadata&&(u={tokenUsage:{promptTokens:e.message.usage_metadata.input_tokens,completionTokens:e.message.usage_metadata.output_tokens,totalTokens:e.message.usage_metadata.total_tokens}})}}catch(e){throw await Promise.all((l??[]).map((t=>t?.handleLLMError(e)))),e}await Promise.all((l??[]).map((e=>e?.handleLLMEnd({generations:[[c]],llmOutput:u}))))}}getLsParams(e){return{ls_model_type:"chat",ls_stop:e.stop}}async _generateUncached(e,t,a){const n=e.map((e=>e.map(Of))),i={...a.metadata,...this.getLsParams(t)},r=await Nw.configure(a.callbacks,this.callbacks,a.tags,this.tags,i,this.metadata,{verbose:this.verbose}),o={options:t,invocation_params:this?.invocationParams(t),batch_size:1},s=await(r?.handleChatModelStart(this.toJSON(),n,a.runId,void 0,o,void 0,void 0,a.runName)),l=[],c=[];if(!!s?.[0].handlers.find((e=>pk(e)||ik(e)))&&1===n.length&&this._streamResponseChunks!==tR.prototype._streamResponseChunks)try{const e=await this._streamResponseChunks(n[0],t,s?.[0]);let a,i;for await(const t of e){if(null==t.message.id){const e=s?.at(0)?.runId;null!=e&&t.message._updateId(`run-${e}`)}a=void 0===a?t:Qx(a,t),bf(t.message)&&void 0!==t.message.usage_metadata&&(i={tokenUsage:{promptTokens:t.message.usage_metadata.input_tokens,completionTokens:t.message.usage_metadata.output_tokens,totalTokens:t.message.usage_metadata.total_tokens}})}if(void 0===a)throw new Error("Received empty response from chat model call.");l.push([a]),await(s?.[0].handleLLMEnd({generations:l,llmOutput:i}))}catch(e){throw await(s?.[0].handleLLMError(e)),e}else{const e=await Promise.allSettled(n.map(((e,a)=>this._generate(e,{...t,promptIndex:a},s?.[a]))));await Promise.all(e.map((async(e,t)=>{if("fulfilled"===e.status){const a=e.value;for(const e of a.generations){if(null==e.message.id){const t=s?.at(0)?.runId;null!=t&&e.message._updateId(`run-${t}`)}e.message.response_metadata={...e.generationInfo,...e.message.response_metadata}}return 1===a.generations.length&&(a.generations[0].message.response_metadata={...a.llmOutput,...a.generations[0].message.response_metadata}),l[t]=a.generations,c[t]=a.llmOutput,s?.[t]?.handleLLMEnd({generations:[a.generations],llmOutput:a.llmOutput})}return await(s?.[t]?.handleLLMError(e.reason)),Promise.reject(e.reason)})))}const u={generations:l,llmOutput:c.length?this._combineLLMOutput?.(...c):void 0};return Object.defineProperty(u,ck,{value:s?{runIds:s?.map((e=>e.runId))}:void 0,configurable:!0}),u}async _generateCached({messages:e,cache:t,llmStringKey:a,parsedOptions:n,handledOptions:i}){const r=e.map((e=>e.map(Of))),o={...i.metadata,...this.getLsParams(n)},s=await Nw.configure(i.callbacks,this.callbacks,i.tags,this.tags,o,this.metadata,{verbose:this.verbose}),l={options:n,invocation_params:this?.invocationParams(n),batch_size:1,cached:!0},c=await(s?.handleChatModelStart(this.toJSON(),r,i.runId,void 0,l,void 0,void 0,i.runName)),u=[],d=await Promise.allSettled(r.map((async(e,n)=>{const i=tR._convertInputToPromptValue(e).toString(),r=await t.lookup(i,a);return null==r&&u.push(n),r}))),m=d.map(((e,t)=>({result:e,runManager:c?.[t]}))).filter((({result:e})=>"fulfilled"===e.status&&null!=e.value||"rejected"===e.status)),h=[];await Promise.all(m.map((async({result:e,runManager:t},a)=>{if("fulfilled"===e.status){const n=e.value;return h[a]=n,n.length&&await(t?.handleLLMNewToken(n[0].text)),t?.handleLLMEnd({generations:[n]})}return await(t?.handleLLMError(e.reason)),Promise.reject(e.reason)})));const p={generations:h,missingPromptIndices:u};return Object.defineProperty(p,ck,{value:c?{runIds:c?.map((e=>e.runId))}:void 0,configurable:!0}),p}async generate(e,t,a){let n;n=Array.isArray(t)?{stop:t}:t;const i=e.map((e=>e.map(Of))),[r,o]=this._separateRunnableConfigFromCallOptionsCompat(n);if(r.callbacks=r.callbacks??a,!this.cache)return this._generateUncached(i,o,r);const{cache:s}=this,l=this._getSerializedCacheKeyParametersForCall(o),{generations:c,missingPromptIndices:u}=await this._generateCached({messages:i,cache:s,llmStringKey:l,parsedOptions:o,handledOptions:r});let d={};if(u.length>0){const e=await this._generateUncached(u.map((e=>i[e])),o,r);await Promise.all(e.generations.map((async(e,t)=>{const a=u[t];c[a]=e;const n=tR._convertInputToPromptValue(i[a]).toString();return s.update(n,l,e)}))),d=e.llmOutput??{}}return{generations:c,llmOutput:d}}invocationParams(e){return{}}_modelType(){return"base_chat_model"}serialize(){return{...this.invocationParams(),_type:this._llmType(),_model:this._modelType()}}async generatePrompt(e,t,a){const n=e.map((e=>e.toChatMessages()));return this.generate(n,t,a)}async call(e,t,a){return(await this.generate([e.map(Of)],t,a)).generations[0][0].message}async callPrompt(e,t,a){const n=e.toChatMessages();return this.call(n,t,a)}async predictMessages(e,t,a){return this.call(e,t,a)}async predict(e,t,a){const n=new Sf(e),i=await this.call([n],t,a);if("string"!=typeof i.content)throw new Error("Cannot use predict when output is not a string.");return i.content}withStructuredOutput(e,t){if("function"!=typeof this.bindTools)throw new Error('Chat model must implement ".bindTools()" to use withStructuredOutput.');const a=e,n=t?.name,i=a.description??"A function available to call.",r=t?.method,o=t?.includeRaw;if("jsonMode"===r)throw new Error('Base withStructuredOutput implementation only supports "functionCalling" as a method.');let s,l=n??"extract";_A(a)?s=[{type:"function",function:{name:l,description:i,parameters:Gk(a)}}]:("name"in a&&(l=a.name),s=[{type:"function",function:{name:l,description:i,parameters:a}}]);const c=this.bindTools(s),u=pA.from((e=>{if(!e.tool_calls||0===e.tool_calls.length)throw new Error("No tool calls found in the response.");const t=e.tool_calls.find((e=>e.name===l));if(!t)throw new Error(`No tool call found with name ${l}.`);return t.args}));if(!o)return c.pipe(u).withConfig({runName:"StructuredOutput"});const d=eR.assign({parsed:(e,t)=>u.invoke(e.raw,t)}),m=eR.assign({parsed:()=>null}),h=d.withFallbacks({fallbacks:[m]});return dA.from([{raw:c},h]).withConfig({runName:"StructuredOutputRunnable"})}}var aR=Object.freeze({__proto__:null,BaseChatModel:tR,SimpleChatModel:class extends tR{async _generate(e,t,a){const n=await this._call(e,t,a),i=new ff(n);if("string"!=typeof i.content)throw new Error("Cannot generate with a simple chat model when output is not a string.");return{generations:[{text:i.content,message:i}]}}},createChatMessageChunkEncoderStream:function(){const e=new TextEncoder;return new TransformStream({transform(t,a){a.enqueue(e.encode("string"==typeof t.content?t.content:JSON.stringify(t.content)))}})}});var nR=Object.freeze({__proto__:null,RouterRunnable:class extends sA{static lc_name(){return"RouterRunnable"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"runnables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnables=e.runnables}async invoke(e,t){const{key:a,input:n}=e,i=this.runnables[a];if(void 0===i)throw new Error(`No runnable associated with key "${a}".`);return i.invoke(n,vk(t))}async batch(e,t,a){const n=e.map((e=>e.key)),i=e.map((e=>e.input)),r=n.find((e=>void 0===this.runnables[e]));if(void 0!==r)throw new Error("One or more keys do not have a corresponding runnable.");const o=n.map((e=>this.runnables[e])),s=this._getOptionsList(t??{},e.length),l=s[0]?.maxConcurrency??a?.maxConcurrency,c=l&&l>0?l:e.length,u=[];for(let e=0;e<i.length;e+=c){const t=i.slice(e,e+c).map(((e,t)=>o[t].invoke(e,s[t]))),a=await Promise.all(t);u.push(a)}return u.flat()}async stream(e,t){const{key:a,input:n}=e,i=this.runnables[a];if(void 0===i)throw new Error(`No runnable associated with key "${a}".`);return i.stream(n,t)}},Runnable:sA,RunnableAssign:yA,RunnableBinding:lA,RunnableBranch:class extends sA{static lc_name(){return"RunnableBranch"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","runnables"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"default",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"branches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.branches=e.branches,this.default=e.default}static from(e){if(e.length<1)throw new Error("RunnableBranch requires at least one branch");return new this({branches:e.slice(0,-1).map((([e,t])=>[fA(e),fA(t)])),default:fA(e[e.length-1])})}async _invoke(e,t,a){let n;for(let i=0;i<this.branches.length;i+=1){const[r,o]=this.branches[i];if(await r.invoke(e,wk(t,{callbacks:a?.getChild(`condition:${i+1}`)}))){n=await o.invoke(e,wk(t,{callbacks:a?.getChild(`branch:${i+1}`)}));break}}return n||(n=await this.default.invoke(e,wk(t,{callbacks:a?.getChild("branch:default")}))),n}async invoke(e,t={}){return this._callWithConfig(this._invoke,e,t)}async*_streamIterator(e,t){const a=await fk(t),n=await(a?.handleChainStart(this.toJSON(),oA(e,"input"),t?.runId,void 0,void 0,void 0,t?.runName));let i,r,o=!0;try{for(let a=0;a<this.branches.length;a+=1){const[s,l]=this.branches[a];if(await s.invoke(e,wk(t,{callbacks:n?.getChild(`condition:${a+1}`)}))){r=await l.stream(e,wk(t,{callbacks:n?.getChild(`branch:${a+1}`)}));for await(const e of r)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch(e){i=void 0,o=!1}break}}if(void 0===r){r=await this.default.stream(e,wk(t,{callbacks:n?.getChild("branch:default")}));for await(const e of r)if(yield e,o)if(void 0===i)i=e;else try{i=Qx(i,e)}catch(e){i=void 0,o=!1}}}catch(e){throw await(n?.handleChainError(e)),e}await(n?.handleChainEnd(i??{}))}},RunnableEach:cA,RunnableLambda:pA,RunnableMap:mA,RunnableParallel:class extends mA{},RunnablePassthrough:eR,RunnablePick:bA,RunnableRetry:uA,RunnableSequence:dA,RunnableToolLike:vA,RunnableWithFallbacks:gA,RunnableWithMessageHistory:class extends lA{constructor(e){let t=pA.from(((e,t)=>this._enterHistory(e,t??{}))).withConfig({runName:"loadHistory"});const a=e.historyMessagesKey??e.inputMessagesKey;a&&(t=eR.assign({[a]:t}).withConfig({runName:"insertHistory"}));const n=t.pipe(e.runnable.withListeners({onEnd:(e,t)=>this._exitHistory(e,t??{})})).withConfig({runName:"RunnableWithMessageHistory"}),i=e.config??{};super({...e,config:i,bound:n}),Object.defineProperty(this,"runnable",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"historyMessagesKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getMessageHistory",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.runnable=e.runnable,this.getMessageHistory=e.getMessageHistory,this.inputMessagesKey=e.inputMessagesKey,this.outputMessagesKey=e.outputMessagesKey,this.historyMessagesKey=e.historyMessagesKey}_getInputMessages(e){let t;if("object"!=typeof e||Array.isArray(e)||mf(e))t=e;else{let a;a=this.inputMessagesKey?this.inputMessagesKey:1===Object.keys(e).length?Object.keys(e)[0]:"input",t=Array.isArray(e[a])&&Array.isArray(e[a][0])?e[a][0]:e[a]}if("string"==typeof t)return[new Sf(t)];if(Array.isArray(t))return t;if(mf(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages.\nGot ${JSON.stringify(t,null,2)}`)}_getOutputMessages(e){let t;if(Array.isArray(e)||mf(e)||"string"==typeof e)t=e;else{let a;a=void 0!==this.outputMessagesKey?this.outputMessagesKey:1===Object.keys(e).length?Object.keys(e)[0]:"output",t=void 0!==e.generations?e.generations[0][0].message:e[a]}if("string"==typeof t)return[new ff(t)];if(Array.isArray(t))return t;if(mf(t))return[t];throw new Error(`Expected a string, BaseMessage, or array of BaseMessages. Received: ${JSON.stringify(t,null,2)}`)}async _enterHistory(e,t){const a=t?.configurable?.messageHistory,n=await a.getMessages();return void 0===this.historyMessagesKey?n.concat(this._getInputMessages(e)):n}async _exitHistory(e,t){const a=t.configurable?.messageHistory;let n;n=Array.isArray(e.inputs)&&Array.isArray(e.inputs[0])?e.inputs[0]:e.inputs;let i=this._getInputMessages(n);if(void 0===this.historyMessagesKey){const e=await a.getMessages();i=i.slice(e.length)}const r=e.outputs;if(!r)throw new Error(`Output values from 'Run' undefined. Run: ${JSON.stringify(e,null,2)}`);const o=this._getOutputMessages(r);await a.addMessages([...i,...o])}async _mergeConfig(...e){const t=await super._mergeConfig(...e);if(!t.configurable||!t.configurable.sessionId){const e={[this.inputMessagesKey??"input"]:"foo"},t={configurable:{sessionId:"123"}};throw new Error(`sessionId is required. Pass it in as part of the config argument to .invoke() or .stream()\neg. chain.invoke(${JSON.stringify(e)}, ${JSON.stringify(t)})`)}const{sessionId:a}=t.configurable;return t.configurable.messageHistory=await this.getMessageHistory(a),t}},_coerceToRunnable:fA,ensureConfig:vk,getCallbackManagerForConfig:fk,mergeConfigs:yk,patchConfig:wk});class iR extends sA{parseResultWithPrompt(e,t,a){return this.parseResult(e,a)}_baseMessageToString(e){return"string"==typeof e.content?e.content:this._baseMessageContentToString(e.content)}_baseMessageContentToString(e){return JSON.stringify(e)}async invoke(e,t){return"string"==typeof e?this._callWithConfig((async(e,t)=>this.parseResult([{text:e}],t?.callbacks)),e,{...t,runType:"parser"}):this._callWithConfig((async(e,t)=>this.parseResult([{message:e,text:this._baseMessageToString(e)}],t?.callbacks)),e,{...t,runType:"parser"})}}class rR extends iR{parseResult(e,t){return this.parse(e[0].text,t)}async parseWithPrompt(e,t,a){return this.parse(e,a)}_type(){throw new Error("_type not implemented")}}class oR extends Error{constructor(e,t,a,n=!1){if(super(e),Object.defineProperty(this,"llmOutput",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"observation",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"sendToLLM",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.llmOutput=t,this.observation=a,this.sendToLLM=n,n&&(void 0===a||void 0===t))throw new Error("Arguments 'observation' & 'llmOutput' are required if 'sendToLlm' is true");Qg(this,"OUTPUT_PARSING_FAILURE")}}function sR(e,t){const a=typeof e;if(a!==typeof t)return!1;if(Array.isArray(e)){if(!Array.isArray(t))return!1;const a=e.length;if(a!==t.length)return!1;for(let n=0;n<a;n++)if(!sR(e[n],t[n]))return!1;return!0}if("object"===a){if(!e||!t)return e===t;const a=Object.keys(e),n=Object.keys(t);if(a.length!==n.length)return!1;for(const n of a)if(!sR(e[n],t[n]))return!1;return!0}return e===t}function lR(e){return encodeURI(function(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}(e))}const cR={prefixItems:!0,items:!0,allOf:!0,anyOf:!0,oneOf:!0},uR={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependentSchemas:!0},dR={id:!0,$id:!0,$ref:!0,$schema:!0,$anchor:!0,$vocabulary:!0,$comment:!0,default:!0,enum:!0,const:!0,required:!0,type:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};let mR="undefined"!=typeof self&&self.location&&"null"!==self.location.origin?new URL(self.location.origin+self.location.pathname+location.search):new URL("https://github.com/cfworker");function hR(e,t=Object.create(null),a=mR,n=""){if(e&&"object"==typeof e&&!Array.isArray(e)){const i=e.$id||e.id;if(i){const r=new URL(i,a.href);r.hash.length>1?t[r.href]=e:(r.hash="",""===n?a=r:hR(e,t,a))}}else if(!0!==e&&!1!==e)return t;const i=a.href+(n?"#"+n:"");if(void 0!==t[i])throw new Error(`Duplicate schema URI "${i}".`);if(t[i]=e,!0===e||!1===e)return t;if(void 0===e.__absolute_uri__&&Object.defineProperty(e,"__absolute_uri__",{enumerable:!1,value:i}),e.$ref&&void 0===e.__absolute_ref__){const t=new URL(e.$ref,a.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_ref__",{enumerable:!1,value:t.href})}if(e.$recursiveRef&&void 0===e.__absolute_recursive_ref__){const t=new URL(e.$recursiveRef,a.href);t.hash=t.hash,Object.defineProperty(e,"__absolute_recursive_ref__",{enumerable:!1,value:t.href})}if(e.$anchor){t[new URL("#"+e.$anchor,a.href).href]=e}for(let i in e){if(dR[i])continue;const r=`${n}/${lR(i)}`,o=e[i];if(Array.isArray(o)){if(cR[i]){const e=o.length;for(let n=0;n<e;n++)hR(o[n],t,a,`${r}/${n}`)}}else if(uR[i])for(let e in o)hR(o[e],t,a,`${r}/${lR(e)}`);else hR(o,t,a,r)}return t}const pR=/^(\d\d\d\d)-(\d\d)-(\d\d)$/,gR=[0,31,28,31,30,31,30,31,31,30,31,30,31],fR=/^(\d\d):(\d\d):(\d\d)(\.\d+)?(z|[+-]\d\d(?::?\d\d)?)?$/i,yR=/^(?=.{1,253}\.?$)[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\.[a-z0-9](?:[-0-9a-z]{0,61}[0-9a-z])?)*\.?$/i,bR=/^(?:[a-z][a-z0-9+\-.]*:)?(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'"()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'"()*+,;=:@]|%[0-9a-f]{2})*)*)?(?:\?(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'"()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i,vR=/^(?:(?:[^\x00-\x20"'<>%\\^`{|}]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?::[1-9][0-9]{0,3}|\*)?)*\})*$/i,wR=/^(?:(?:https?|ftp):\/\/)(?:\S+(?::\S*)?@)?(?:(?!10(?:\.\d{1,3}){3})(?!127(?:\.\d{1,3}){3})(?!169\.254(?:\.\d{1,3}){2})(?!192\.168(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)(?:\.(?:[a-z\u{00a1}-\u{ffff}0-9]+-?)*[a-z\u{00a1}-\u{ffff}0-9]+)*(?:\.(?:[a-z\u{00a1}-\u{ffff}]{2,})))(?::\d{2,5})?(?:\/[^\s]*)?$/iu,xR=/^(?:urn:uuid:)?[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i,kR=/^(?:\/(?:[^~/]|~0|~1)*)*$/,AR=/^#(?:\/(?:[a-z0-9_\-.!$&'()*+,;:=@]|%[0-9a-f]{2}|~0|~1)*)*$/i,SR=/^(?:0|[1-9][0-9]*)(?:#|(?:\/(?:[^~/]|~0|~1)*)*)$/,ER=/^\d\d\d\d-[0-1]\d-[0-3]\d$/,_R=/^(?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)?$/i,CR=/^\d\d\d\d-[0-1]\d-[0-3]\d[t\s](?:[0-2]\d:[0-5]\d:[0-5]\d|23:59:60)(?:\.\d+)?(?:z|[+-]\d\d(?::?\d\d)?)$/i,TR=/^(?:(?:[a-z][a-z0-9+-.]*:)?\/?\/)?(?:[^\\\s#][^\s#]*)?(?:#[^\\\s]*)?$/i,PR=/^(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)$/,OR=/^((([0-9a-f]{1,4}:){7}([0-9a-f]{1,4}|:))|(([0-9a-f]{1,4}:){6}(:[0-9a-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){5}(((:[0-9a-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9a-f]{1,4}:){4}(((:[0-9a-f]{1,4}){1,3})|((:[0-9a-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){3}(((:[0-9a-f]{1,4}){1,4})|((:[0-9a-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){2}(((:[0-9a-f]{1,4}){1,5})|((:[0-9a-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9a-f]{1,4}:){1}(((:[0-9a-f]{1,4}){1,6})|((:[0-9a-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9a-f]{1,4}){1,7})|((:[0-9a-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))$/i;function DR(e){return e.test.bind(e)}const MR={date:NR,time:jR.bind(void 0,!1),"date-time":function(e){const t=e.split(zR);return 2==t.length&&NR(t[0])&&jR(!0,t[1])},duration:e=>e.length>1&&e.length<80&&(/^P\d+([.,]\d+)?W$/.test(e)||/^P[\dYMDTHS]*(\d[.,]\d+)?[YMDHS]$/.test(e)&&/^P([.,\d]+Y)?([.,\d]+M)?([.,\d]+D)?(T([.,\d]+H)?([.,\d]+M)?([.,\d]+S)?)?$/.test(e)),uri:function(e){return RR.test(e)&&LR.test(e)},"uri-reference":DR(bR),"uri-template":DR(vR),url:DR(wR),email:e=>{if('"'===e[0])return!1;const[t,a,...n]=e.split("@");return!(!t||!a||0!==n.length||t.length>64||a.length>253)&&("."!==t[0]&&!t.endsWith(".")&&!t.includes("..")&&(!(!/^[a-z0-9.-]+$/i.test(a)||!/^[a-z0-9.!#$%&'*+/=?^_`{|}~-]+$/i.test(t))&&a.split(".").every((e=>/^[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?$/i.test(e)))))},hostname:DR(yR),ipv4:DR(PR),ipv6:DR(OR),regex:function(e){if(FR.test(e))return!1;try{return new RegExp(e),!0}catch(e){return!1}},uuid:DR(xR),"json-pointer":DR(kR),"json-pointer-uri-fragment":DR(AR),"relative-json-pointer":DR(SR)},IR={...MR,date:DR(ER),time:DR(_R),"date-time":DR(CR),"uri-reference":DR(TR)};function NR(e){const t=e.match(pR);if(!t)return!1;const a=+t[1],n=+t[2],i=+t[3];return n>=1&&n<=12&&i>=1&&i<=(2==n&&function(e){return e%4==0&&(e%100!=0||e%400==0)}(a)?29:gR[n])}function jR(e,t){const a=t.match(fR);if(!a)return!1;const n=+a[1],i=+a[2],r=+a[3],o=!!a[5];return(n<=23&&i<=59&&r<=59||23==n&&59==i&&60==r)&&(!e||o)}const zR=/t|\s/i;const RR=/\/|:/,LR=/^(?:[a-z][a-z0-9+\-.]*:)(?:\/?\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:(?:[0-9a-f]{1,4}:){6}|::(?:[0-9a-f]{1,4}:){5}|(?:[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){4}|(?:(?:[0-9a-f]{1,4}:){0,1}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){3}|(?:(?:[0-9a-f]{1,4}:){0,2}[0-9a-f]{1,4})?::(?:[0-9a-f]{1,4}:){2}|(?:(?:[0-9a-f]{1,4}:){0,3}[0-9a-f]{1,4})?::[0-9a-f]{1,4}:|(?:(?:[0-9a-f]{1,4}:){0,4}[0-9a-f]{1,4})?::)(?:[0-9a-f]{1,4}:[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?))|(?:(?:[0-9a-f]{1,4}:){0,5}[0-9a-f]{1,4})?::[0-9a-f]{1,4}|(?:(?:[0-9a-f]{1,4}:){0,6}[0-9a-f]{1,4})?::)|[Vv][0-9a-f]+\.[a-z0-9\-._~!$&'()*+,;=:]+)\]|(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)|(?:[a-z0-9\-._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[a-z0-9\-._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)(?:\?(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[a-z0-9\-._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;const FR=/[^\\]\\Z/;function BR(e,t,a="2019-09",n=hR(t),i=!0,r=null,o="#",s="#",l=Object.create(null)){if(!0===t)return{valid:!0,errors:[]};if(!1===t)return{valid:!1,errors:[{instanceLocation:o,keyword:"false",keywordLocation:o,error:"False boolean schema."}]};const c=typeof e;let u;switch(c){case"boolean":case"number":case"string":u=c;break;case"object":u=null===e?"null":Array.isArray(e)?"array":"object";break;default:throw new Error(`Instances of "${c}" type are not supported.`)}const{$ref:d,$recursiveRef:m,$recursiveAnchor:h,type:p,const:g,enum:f,required:y,not:b,anyOf:v,allOf:w,oneOf:x,if:k,then:A,else:S,format:E,properties:_,patternProperties:C,additionalProperties:T,unevaluatedProperties:P,minProperties:O,maxProperties:D,propertyNames:M,dependentRequired:I,dependentSchemas:N,dependencies:j,prefixItems:z,items:R,additionalItems:L,unevaluatedItems:F,contains:B,minContains:H,maxContains:q,minItems:U,maxItems:W,uniqueItems:V,minimum:$,maximum:G,exclusiveMinimum:K,exclusiveMaximum:Z,multipleOf:Y,minLength:X,maxLength:Q,pattern:J,__absolute_ref__:ee,__absolute_recursive_ref__:te}=t,ae=[];if(!0===h&&null===r&&(r=t),"#"===m){const c=null===r?n[te]:r,u=`${s}/$recursiveRef`,d=BR(e,null===r?t:r,a,n,i,c,o,u,l);d.valid||ae.push({instanceLocation:o,keyword:"$recursiveRef",keywordLocation:u,error:"A subschema had errors."},...d.errors)}if(void 0!==d){const t=n[ee||d];if(void 0===t){let e=`Unresolved $ref "${d}".`;throw ee&&ee!==d&&(e+=` Absolute URI "${ee}".`),e+=`\nKnown schemas:\n- ${Object.keys(n).join("\n- ")}`,new Error(e)}const c=`${s}/$ref`,u=BR(e,t,a,n,i,r,o,c,l);if(u.valid||ae.push({instanceLocation:o,keyword:"$ref",keywordLocation:c,error:"A subschema had errors."},...u.errors),"4"===a||"7"===a)return{valid:0===ae.length,errors:ae}}if(Array.isArray(p)){let t=p.length,a=!1;for(let n=0;n<t;n++)if(u===p[n]||"integer"===p[n]&&"number"===u&&e%1==0&&e==e){a=!0;break}a||ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p.join('", "')}".`})}else"integer"===p?("number"!==u||e%1||e!=e)&&ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p}".`}):void 0!==p&&u!==p&&ae.push({instanceLocation:o,keyword:"type",keywordLocation:`${s}/type`,error:`Instance type "${u}" is invalid. Expected "${p}".`});if(void 0!==g&&("object"===u||"array"===u?sR(e,g)||ae.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`}):e!==g&&ae.push({instanceLocation:o,keyword:"const",keywordLocation:`${s}/const`,error:`Instance does not match ${JSON.stringify(g)}.`})),void 0!==f&&("object"===u||"array"===u?f.some((t=>sR(e,t)))||ae.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(f)}.`}):f.some((t=>e===t))||ae.push({instanceLocation:o,keyword:"enum",keywordLocation:`${s}/enum`,error:`Instance does not match any of ${JSON.stringify(f)}.`})),void 0!==b){const t=`${s}/not`;BR(e,b,a,n,i,r,o,t).valid&&ae.push({instanceLocation:o,keyword:"not",keywordLocation:t,error:'Instance matched "not" schema.'})}let ne=[];if(void 0!==v){const t=`${s}/anyOf`,c=ae.length;let u=!1;for(let s=0;s<v.length;s++){const c=v[s],d=Object.create(l),m=BR(e,c,a,n,i,!0===h?r:null,o,`${t}/${s}`,d);ae.push(...m.errors),u=u||m.valid,m.valid&&ne.push(d)}u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"anyOf",keywordLocation:t,error:"Instance does not match any subschemas."})}if(void 0!==w){const t=`${s}/allOf`,c=ae.length;let u=!0;for(let s=0;s<w.length;s++){const c=w[s],d=Object.create(l),m=BR(e,c,a,n,i,!0===h?r:null,o,`${t}/${s}`,d);ae.push(...m.errors),u=u&&m.valid,m.valid&&ne.push(d)}u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"allOf",keywordLocation:t,error:"Instance does not match every subschema."})}if(void 0!==x){const t=`${s}/oneOf`,c=ae.length,u=x.filter(((s,c)=>{const u=Object.create(l),d=BR(e,s,a,n,i,!0===h?r:null,o,`${t}/${c}`,u);return ae.push(...d.errors),d.valid&&ne.push(u),d.valid})).length;1===u?ae.length=c:ae.splice(c,0,{instanceLocation:o,keyword:"oneOf",keywordLocation:t,error:`Instance does not match exactly one subschema (${u} matches).`})}if("object"!==u&&"array"!==u||Object.assign(l,...ne),void 0!==k){const t=`${s}/if`;if(BR(e,k,a,n,i,r,o,t,l).valid){if(void 0!==A){const c=BR(e,A,a,n,i,r,o,`${s}/then`,l);c.valid||ae.push({instanceLocation:o,keyword:"if",keywordLocation:t,error:'Instance does not match "then" schema.'},...c.errors)}}else if(void 0!==S){const c=BR(e,S,a,n,i,r,o,`${s}/else`,l);c.valid||ae.push({instanceLocation:o,keyword:"if",keywordLocation:t,error:'Instance does not match "else" schema.'},...c.errors)}}if("object"===u){if(void 0!==y)for(const t of y)t in e||ae.push({instanceLocation:o,keyword:"required",keywordLocation:`${s}/required`,error:`Instance does not have required property "${t}".`});const t=Object.keys(e);if(void 0!==O&&t.length<O&&ae.push({instanceLocation:o,keyword:"minProperties",keywordLocation:`${s}/minProperties`,error:`Instance does not have at least ${O} properties.`}),void 0!==D&&t.length>D&&ae.push({instanceLocation:o,keyword:"maxProperties",keywordLocation:`${s}/maxProperties`,error:`Instance does not have at least ${D} properties.`}),void 0!==M){const t=`${s}/propertyNames`;for(const s in e){const e=`${o}/${lR(s)}`,l=BR(s,M,a,n,i,r,e,t);l.valid||ae.push({instanceLocation:o,keyword:"propertyNames",keywordLocation:t,error:`Property name "${s}" does not match schema.`},...l.errors)}}if(void 0!==I){const t=`${s}/dependantRequired`;for(const a in I)if(a in e){const n=I[a];for(const i of n)i in e||ae.push({instanceLocation:o,keyword:"dependentRequired",keywordLocation:t,error:`Instance has "${a}" but does not have "${i}".`})}}if(void 0!==N)for(const t in N){const c=`${s}/dependentSchemas`;if(t in e){const s=BR(e,N[t],a,n,i,r,o,`${c}/${lR(t)}`,l);s.valid||ae.push({instanceLocation:o,keyword:"dependentSchemas",keywordLocation:c,error:`Instance has "${t}" but does not match dependant schema.`},...s.errors)}}if(void 0!==j){const t=`${s}/dependencies`;for(const s in j)if(s in e){const l=j[s];if(Array.isArray(l))for(const a of l)a in e||ae.push({instanceLocation:o,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not have "${a}".`});else{const c=BR(e,l,a,n,i,r,o,`${t}/${lR(s)}`);c.valid||ae.push({instanceLocation:o,keyword:"dependencies",keywordLocation:t,error:`Instance has "${s}" but does not match dependant schema.`},...c.errors)}}}const c=Object.create(null);let u=!1;if(void 0!==_){const t=`${s}/properties`;for(const s in _){if(!(s in e))continue;const d=`${o}/${lR(s)}`,m=BR(e[s],_[s],a,n,i,r,d,`${t}/${lR(s)}`);if(m.valid)l[s]=c[s]=!0;else if(u=i,ae.push({instanceLocation:o,keyword:"properties",keywordLocation:t,error:`Property "${s}" does not match schema.`},...m.errors),u)break}}if(!u&&void 0!==C){const t=`${s}/patternProperties`;for(const s in C){const d=new RegExp(s),m=C[s];for(const h in e){if(!d.test(h))continue;const p=`${o}/${lR(h)}`,g=BR(e[h],m,a,n,i,r,p,`${t}/${lR(s)}`);g.valid?l[h]=c[h]=!0:(u=i,ae.push({instanceLocation:o,keyword:"patternProperties",keywordLocation:t,error:`Property "${h}" matches pattern "${s}" but does not match associated schema.`},...g.errors))}}}if(u||void 0===T){if(!u&&void 0!==P){const t=`${s}/unevaluatedProperties`;for(const s in e)if(!l[s]){const c=`${o}/${lR(s)}`,u=BR(e[s],P,a,n,i,r,c,t);u.valid?l[s]=!0:ae.push({instanceLocation:o,keyword:"unevaluatedProperties",keywordLocation:t,error:`Property "${s}" does not match unevaluated properties schema.`},...u.errors)}}}else{const t=`${s}/additionalProperties`;for(const s in e){if(c[s])continue;const d=`${o}/${lR(s)}`,m=BR(e[s],T,a,n,i,r,d,t);m.valid?l[s]=!0:(u=i,ae.push({instanceLocation:o,keyword:"additionalProperties",keywordLocation:t,error:`Property "${s}" does not match additional properties schema.`},...m.errors))}}}else if("array"===u){void 0!==W&&e.length>W&&ae.push({instanceLocation:o,keyword:"maxItems",keywordLocation:`${s}/maxItems`,error:`Array has too many items (${e.length} > ${W}).`}),void 0!==U&&e.length<U&&ae.push({instanceLocation:o,keyword:"minItems",keywordLocation:`${s}/minItems`,error:`Array has too few items (${e.length} < ${U}).`});const t=e.length;let c=0,u=!1;if(void 0!==z){const d=`${s}/prefixItems`,m=Math.min(z.length,t);for(;c<m;c++){const t=BR(e[c],z[c],a,n,i,r,`${o}/${c}`,`${d}/${c}`);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"prefixItems",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}}if(void 0!==R){const d=`${s}/items`;if(Array.isArray(R)){const s=Math.min(R.length,t);for(;c<s;c++){const t=BR(e[c],R[c],a,n,i,r,`${o}/${c}`,`${d}/${c}`);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}}else for(;c<t;c++){const t=BR(e[c],R,a,n,i,r,`${o}/${c}`,d);if(l[c]=!0,!t.valid&&(u=i,ae.push({instanceLocation:o,keyword:"items",keywordLocation:d,error:"Items did not match schema."},...t.errors),u))break}if(!u&&void 0!==L){const d=`${s}/additionalItems`;for(;c<t;c++){const t=BR(e[c],L,a,n,i,r,`${o}/${c}`,d);l[c]=!0,t.valid||(u=i,ae.push({instanceLocation:o,keyword:"additionalItems",keywordLocation:d,error:"Items did not match additional items schema."},...t.errors))}}}if(void 0!==B)if(0===t&&void 0===H)ae.push({instanceLocation:o,keyword:"contains",keywordLocation:`${s}/contains`,error:"Array is empty. It must contain at least one item matching the schema."});else if(void 0!==H&&t<H)ae.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array has less items (${t}) than minContains (${H}).`});else{const c=`${s}/contains`,u=ae.length;let d=0;for(let s=0;s<t;s++){const t=BR(e[s],B,a,n,i,r,`${o}/${s}`,c);t.valid?(l[s]=!0,d++):ae.push(...t.errors)}d>=(H||0)&&(ae.length=u),void 0===H&&void 0===q&&0===d?ae.splice(u,0,{instanceLocation:o,keyword:"contains",keywordLocation:c,error:"Array does not contain item matching schema."}):void 0!==H&&d<H?ae.push({instanceLocation:o,keyword:"minContains",keywordLocation:`${s}/minContains`,error:`Array must contain at least ${H} items matching schema. Only ${d} items were found.`}):void 0!==q&&d>q&&ae.push({instanceLocation:o,keyword:"maxContains",keywordLocation:`${s}/maxContains`,error:`Array may contain at most ${q} items matching schema. ${d} items were found.`})}if(!u&&void 0!==F){const u=`${s}/unevaluatedItems`;for(;c<t;c++){if(l[c])continue;const t=BR(e[c],F,a,n,i,r,`${o}/${c}`,u);l[c]=!0,t.valid||ae.push({instanceLocation:o,keyword:"unevaluatedItems",keywordLocation:u,error:"Items did not match unevaluated items schema."},...t.errors)}}if(V)for(let a=0;a<t;a++){const n=e[a],i="object"==typeof n&&null!==n;for(let r=0;r<t;r++){if(a===r)continue;const t=e[r];(n===t||i&&("object"==typeof t&&null!==t)&&sR(n,t))&&(ae.push({instanceLocation:o,keyword:"uniqueItems",keywordLocation:`${s}/uniqueItems`,error:`Duplicate items at indexes ${a} and ${r}.`}),a=Number.MAX_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER)}}}else if("number"===u){if("4"===a?(void 0!==$&&(!0===K&&e<=$||e<$)&&ae.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${K?"or equal to ":""} ${$}.`}),void 0!==G&&(!0===Z&&e>=G||e>G)&&ae.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${Z?"or equal to ":""} ${G}.`})):(void 0!==$&&e<$&&ae.push({instanceLocation:o,keyword:"minimum",keywordLocation:`${s}/minimum`,error:`${e} is less than ${$}.`}),void 0!==G&&e>G&&ae.push({instanceLocation:o,keyword:"maximum",keywordLocation:`${s}/maximum`,error:`${e} is greater than ${G}.`}),void 0!==K&&e<=K&&ae.push({instanceLocation:o,keyword:"exclusiveMinimum",keywordLocation:`${s}/exclusiveMinimum`,error:`${e} is less than ${K}.`}),void 0!==Z&&e>=Z&&ae.push({instanceLocation:o,keyword:"exclusiveMaximum",keywordLocation:`${s}/exclusiveMaximum`,error:`${e} is greater than or equal to ${Z}.`})),void 0!==Y){const t=e%Y;Math.abs(0-t)>=1.1920929e-7&&Math.abs(Y-t)>=1.1920929e-7&&ae.push({instanceLocation:o,keyword:"multipleOf",keywordLocation:`${s}/multipleOf`,error:`${e} is not a multiple of ${Y}.`})}}else if("string"===u){const t=void 0===X&&void 0===Q?0:function(e){let t,a=0,n=e.length,i=0;for(;i<n;)a++,t=e.charCodeAt(i++),t>=55296&&t<=56319&&i<n&&(t=e.charCodeAt(i),56320==(64512&t)&&i++);return a}(e);void 0!==X&&t<X&&ae.push({instanceLocation:o,keyword:"minLength",keywordLocation:`${s}/minLength`,error:`String is too short (${t} < ${X}).`}),void 0!==Q&&t>Q&&ae.push({instanceLocation:o,keyword:"maxLength",keywordLocation:`${s}/maxLength`,error:`String is too long (${t} > ${Q}).`}),void 0===J||new RegExp(J).test(e)||ae.push({instanceLocation:o,keyword:"pattern",keywordLocation:`${s}/pattern`,error:"String does not match pattern."}),void 0!==E&&IR[E]&&!IR[E](e)&&ae.push({instanceLocation:o,keyword:"format",keywordLocation:`${s}/format`,error:`String does not match format "${E}".`})}return{valid:0===ae.length,errors:ae}}class HR extends rR{async*_transform(e){for await(const t of e)"string"==typeof t?yield this.parseResult([{text:t}]):yield this.parseResult([{message:t,text:this._baseMessageToString(t)}])}async*transform(e,t){yield*this._transformStreamWithConfig(e,this._transform.bind(this),{...t,runType:"parser"})}}class qR extends HR{constructor(e){super(e),Object.defineProperty(this,"diff",{enumerable:!0,configurable:!0,writable:!0,value:!1}),this.diff=e?.diff??this.diff}async*_transform(e){let t,a;for await(const n of e){if("string"!=typeof n&&"string"!=typeof n.content)throw new Error("Cannot handle non-string output.");let e;if(hf(n)){if("string"!=typeof n.content)throw new Error("Cannot handle non-string message output.");e=new dk({message:n,text:n.content})}else if(mf(n)){if("string"!=typeof n.content)throw new Error("Cannot handle non-string message output.");e=new dk({message:If(n),text:n.content})}else e=new uk({text:n});a=void 0===a?e:a.concat(e);const i=await this.parsePartialResult([a]);null==i||sR(i,t)||(this.diff?yield this._diff(t,i):yield i,t=i)}}getFormatInstructions(){return""}}class UR extends HR{constructor(){super(...arguments),Object.defineProperty(this,"re",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}async*_transform(e){let t="";for await(const a of e)if(t+="string"==typeof a?a:a.content,this.re){const e=[...t.matchAll(this.re)];if(e.length>1){let a=0;for(const t of e.slice(0,-1))yield[t[1]],a+=(t.index??0)+t[0].length;t=t.slice(a)}}else{const e=await this.parse(t);if(e.length>1){for(const t of e.slice(0,-1))yield[t];t=e[e.length-1]}}for(const e of await this.parse(t))yield[e]}}class WR extends rR{static lc_name(){return"StructuredOutputParser"}toJSON(){return this.toJSONNotImplemented()}constructor(e){super(e),Object.defineProperty(this,"schema",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","output_parsers","structured"]})}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const t=jp.object(Object.fromEntries(Object.entries(e).map((([e,t])=>[e,jp.string().describe(t)]))));return new this(t)}getFormatInstructions(){return`You must format your output as a JSON value that adheres to a given "JSON Schema" instance.\n\n"JSON Schema" is a declarative language that allows you to annotate and validate JSON documents.\n\nFor example, the example "JSON Schema" instance {{"properties": {{"foo": {{"description": "a list of test words", "type": "array", "items": {{"type": "string"}}}}}}, "required": ["foo"]}}}}\nwould match an object with one required property, "foo". The "type" property specifies "foo" must be an "array", and the "description" property semantically describes it as "a list of test words". The items within "foo" must be strings.\nThus, the object {{"foo": ["bar", "baz"]}} is a well-formatted instance of this example "JSON Schema". The object {{"properties": {{"foo": ["bar", "baz"]}}}} is not well-formatted.\n\nYour output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!\n\nHere is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:\n\`\`\`json\n${JSON.stringify(Gk(this.schema))}\n\`\`\`\n`}async parse(e){try{const t=(e.includes("```")?e.trim().split(/```(?:json)?/)[1]:e.trim()).replace(/"([^"\\]*(\\.[^"\\]*)*)"/g,((e,t)=>`"${t.replace(/\n/g,"\\n")}"`)).replace(/\n/g,"");return await this.schema.parseAsync(JSON.parse(t))}catch(t){throw new oR(`Failed to parse. Text: "${e}". Error: ${t}`,e)}}}class VR extends WR{static lc_name(){return"JsonMarkdownStructuredOutputParser"}getFormatInstructions(e){const t=e?.interpolationDepth??1;if(t<1)throw new Error("f string interpolation depth must be at least 1");return`Return a markdown code snippet with a JSON object formatted to look like:\n\`\`\`json\n${this._schemaToInstruction(Gk(this.schema)).replaceAll("{","{".repeat(t)).replaceAll("}","}".repeat(t))}\n\`\`\``}_schemaToInstruction(e,t=2){const a=e;if("type"in a){let e,n=!1;if(Array.isArray(a.type)){const t=a.type.findIndex((e=>"null"===e));-1!==t&&(n=!0,a.type.splice(t,1)),e=a.type.join(" | ")}else e=a.type;if("object"===a.type&&a.properties){const e=a.description?` // ${a.description}`:"",n=Object.entries(a.properties).map((([e,n])=>{const i=a.required?.includes(e)?"":" (optional)";return`${" ".repeat(t)}"${e}": ${this._schemaToInstruction(n,t+2)}${i}`})).join("\n");return`{\n${n}\n${" ".repeat(t-2)}}${e}`}if("array"===a.type&&a.items){const e=a.description?` // ${a.description}`:"";return`array[\n${" ".repeat(t)}${this._schemaToInstruction(a.items,t+2)}\n${" ".repeat(t-2)}] ${e}`}const i=n?" (nullable)":"";return`${e}${a.description?` // ${a.description}`:""}${i}`}if("anyOf"in a)return a.anyOf.map((e=>this._schemaToInstruction(e,t))).join(`\n${" ".repeat(t-2)}`);throw new Error("unsupported schema type")}static fromZodSchema(e){return new this(e)}static fromNamesAndDescriptions(e){const t=jp.object(Object.fromEntries(Object.entries(e).map((([e,t])=>[e,jp.string().describe(t)]))));return new this(t)}}var $R=Object.freeze({__proto__:null,applyPatch:Fx,compare:Ux});class GR extends qR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0})}static lc_name(){return"JsonOutputParser"}_diff(e,t){if(t)return e?Ux(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return tf(e[0].text)}async parse(e){return tf(e,JSON.parse)}getFormatInstructions(){return""}}const KR=function(){const e={parser:function(e,t){return new a(e,t)}};e.SAXParser=a,e.SAXStream=r,e.createStream=function(e,t){return new r(e,t)},e.MAX_BUFFER_LENGTH=65536;const t=["comment","sgmlDecl","textNode","tagName","doctype","procInstName","procInstBody","entity","attribName","attribValue","cdata","script"];function a(n,i){if(!(this instanceof a))return new a(n,i);var r=this;!function(e){for(var a=0,n=t.length;a<n;a++)e[t[a]]=""}(r),r.q=r.c="",r.bufferCheckPosition=e.MAX_BUFFER_LENGTH,r.opt=i||{},r.opt.lowercase=r.opt.lowercase||r.opt.lowercasetags,r.looseCase=r.opt.lowercase?"toLowerCase":"toUpperCase",r.tags=[],r.closed=r.closedRoot=r.sawRoot=!1,r.tag=r.error=null,r.strict=!!n,r.noscript=!(!n&&!r.opt.noscript),r.state=w.BEGIN,r.strictEntities=r.opt.strictEntities,r.ENTITIES=r.strictEntities?Object.create(e.XML_ENTITIES):Object.create(e.ENTITIES),r.attribList=[],r.opt.xmlns&&(r.ns=Object.create(u)),r.trackPosition=!1!==r.opt.position,r.trackPosition&&(r.position=r.line=r.column=0),k(r,"onready")}e.EVENTS=["text","processinginstruction","sgmldeclaration","doctype","comment","opentagstart","attribute","opentag","closetag","opencdata","cdata","closecdata","error","end","ready","script","opennamespace","closenamespace"],Object.create||(Object.create=function(e){function t(){}return t.prototype=e,new t}),Object.keys||(Object.keys=function(e){var t=[];for(var a in e)e.hasOwnProperty(a)&&t.push(a);return t}),a.prototype={end:function(){C(this)},write:function(a){var n=this;if(this.error)throw this.error;if(n.closed)return _(n,"Cannot write after close. Assign an onready handler.");if(null===a)return C(n);"object"==typeof a&&(a=a.toString());var i=0,r="";for(;r=z(a,i++),n.c=r,r;)switch(n.trackPosition&&(n.position++,"\n"===r?(n.line++,n.column=0):n.column++),n.state){case w.BEGIN:if(n.state=w.BEGIN_WHITESPACE,"\ufeff"===r)continue;j(n,r);continue;case w.BEGIN_WHITESPACE:j(n,r);continue;case w.TEXT:if(n.sawRoot&&!n.closedRoot){for(var l=i-1;r&&"<"!==r&&"&"!==r;)(r=z(a,i++))&&n.trackPosition&&(n.position++,"\n"===r?(n.line++,n.column=0):n.column++);n.textNode+=a.substring(l,i-1)}"<"!==r||n.sawRoot&&n.closedRoot&&!n.strict?(g(r)||n.sawRoot&&!n.closedRoot||T(n,"Text data outside of root node."),"&"===r?n.state=w.TEXT_ENTITY:n.textNode+=r):(n.state=w.OPEN_WAKA,n.startTagPosition=n.position);continue;case w.SCRIPT:"<"===r?n.state=w.SCRIPT_ENDING:n.script+=r;continue;case w.SCRIPT_ENDING:"/"===r?n.state=w.CLOSE_TAG:(n.script+="<"+r,n.state=w.SCRIPT);continue;case w.OPEN_WAKA:if("!"===r)n.state=w.SGML_DECL,n.sgmlDecl="";else if(g(r));else if(b(d,r))n.state=w.OPEN_TAG,n.tagName=r;else if("/"===r)n.state=w.CLOSE_TAG,n.tagName="";else if("?"===r)n.state=w.PROC_INST,n.procInstName=n.procInstBody="";else{if(T(n,"Unencoded <"),n.startTagPosition+1<n.position){var c=n.position-n.startTagPosition;r=new Array(c).join(" ")+r}n.textNode+="<"+r,n.state=w.TEXT}continue;case w.SGML_DECL:(n.sgmlDecl+r).toUpperCase()===o?(A(n,"onopencdata"),n.state=w.CDATA,n.sgmlDecl="",n.cdata=""):n.sgmlDecl+r==="--"?(n.state=w.COMMENT,n.comment="",n.sgmlDecl=""):(n.sgmlDecl+r).toUpperCase()===s?(n.state=w.DOCTYPE,(n.doctype||n.sawRoot)&&T(n,"Inappropriately located doctype declaration"),n.doctype="",n.sgmlDecl=""):">"===r?(A(n,"onsgmldeclaration",n.sgmlDecl),n.sgmlDecl="",n.state=w.TEXT):f(r)?(n.state=w.SGML_DECL_QUOTED,n.sgmlDecl+=r):n.sgmlDecl+=r;continue;case w.SGML_DECL_QUOTED:r===n.q&&(n.state=w.SGML_DECL,n.q=""),n.sgmlDecl+=r;continue;case w.DOCTYPE:">"===r?(n.state=w.TEXT,A(n,"ondoctype",n.doctype),n.doctype=!0):(n.doctype+=r,"["===r?n.state=w.DOCTYPE_DTD:f(r)&&(n.state=w.DOCTYPE_QUOTED,n.q=r));continue;case w.DOCTYPE_QUOTED:n.doctype+=r,r===n.q&&(n.q="",n.state=w.DOCTYPE);continue;case w.DOCTYPE_DTD:n.doctype+=r,"]"===r?n.state=w.DOCTYPE:f(r)&&(n.state=w.DOCTYPE_DTD_QUOTED,n.q=r);continue;case w.DOCTYPE_DTD_QUOTED:n.doctype+=r,r===n.q&&(n.state=w.DOCTYPE_DTD,n.q="");continue;case w.COMMENT:"-"===r?n.state=w.COMMENT_ENDING:n.comment+=r;continue;case w.COMMENT_ENDING:"-"===r?(n.state=w.COMMENT_ENDED,n.comment=E(n.opt,n.comment),n.comment&&A(n,"oncomment",n.comment),n.comment=""):(n.comment+="-"+r,n.state=w.COMMENT);continue;case w.COMMENT_ENDED:">"!==r?(T(n,"Malformed comment"),n.comment+="--"+r,n.state=w.COMMENT):n.state=w.TEXT;continue;case w.CDATA:"]"===r?n.state=w.CDATA_ENDING:n.cdata+=r;continue;case w.CDATA_ENDING:"]"===r?n.state=w.CDATA_ENDING_2:(n.cdata+="]"+r,n.state=w.CDATA);continue;case w.CDATA_ENDING_2:">"===r?(n.cdata&&A(n,"oncdata",n.cdata),A(n,"onclosecdata"),n.cdata="",n.state=w.TEXT):"]"===r?n.cdata+="]":(n.cdata+="]]"+r,n.state=w.CDATA);continue;case w.PROC_INST:"?"===r?n.state=w.PROC_INST_ENDING:g(r)?n.state=w.PROC_INST_BODY:n.procInstName+=r;continue;case w.PROC_INST_BODY:if(!n.procInstBody&&g(r))continue;"?"===r?n.state=w.PROC_INST_ENDING:n.procInstBody+=r;continue;case w.PROC_INST_ENDING:">"===r?(A(n,"onprocessinginstruction",{name:n.procInstName,body:n.procInstBody}),n.procInstName=n.procInstBody="",n.state=w.TEXT):(n.procInstBody+="?"+r,n.state=w.PROC_INST_BODY);continue;case w.OPEN_TAG:b(m,r)?n.tagName+=r:(P(n),">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:(g(r)||T(n,"Invalid character in tag name"),n.state=w.ATTRIB));continue;case w.OPEN_TAG_SLASH:">"===r?(M(n,!0),I(n)):(T(n,"Forward-slash in opening tag not followed by >"),n.state=w.ATTRIB);continue;case w.ATTRIB:if(g(r))continue;">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:b(d,r)?(n.attribName=r,n.attribValue="",n.state=w.ATTRIB_NAME):T(n,"Invalid attribute name");continue;case w.ATTRIB_NAME:"="===r?n.state=w.ATTRIB_VALUE:">"===r?(T(n,"Attribute without value"),n.attribValue=n.attribName,D(n),M(n)):g(r)?n.state=w.ATTRIB_NAME_SAW_WHITE:b(m,r)?n.attribName+=r:T(n,"Invalid attribute name");continue;case w.ATTRIB_NAME_SAW_WHITE:if("="===r)n.state=w.ATTRIB_VALUE;else{if(g(r))continue;T(n,"Attribute without value"),n.tag.attributes[n.attribName]="",n.attribValue="",A(n,"onattribute",{name:n.attribName,value:""}),n.attribName="",">"===r?M(n):b(d,r)?(n.attribName=r,n.state=w.ATTRIB_NAME):(T(n,"Invalid attribute name"),n.state=w.ATTRIB)}continue;case w.ATTRIB_VALUE:if(g(r))continue;f(r)?(n.q=r,n.state=w.ATTRIB_VALUE_QUOTED):(T(n,"Unquoted attribute value"),n.state=w.ATTRIB_VALUE_UNQUOTED,n.attribValue=r);continue;case w.ATTRIB_VALUE_QUOTED:if(r!==n.q){"&"===r?n.state=w.ATTRIB_VALUE_ENTITY_Q:n.attribValue+=r;continue}D(n),n.q="",n.state=w.ATTRIB_VALUE_CLOSED;continue;case w.ATTRIB_VALUE_CLOSED:g(r)?n.state=w.ATTRIB:">"===r?M(n):"/"===r?n.state=w.OPEN_TAG_SLASH:b(d,r)?(T(n,"No whitespace between attributes"),n.attribName=r,n.attribValue="",n.state=w.ATTRIB_NAME):T(n,"Invalid attribute name");continue;case w.ATTRIB_VALUE_UNQUOTED:if(!y(r)){"&"===r?n.state=w.ATTRIB_VALUE_ENTITY_U:n.attribValue+=r;continue}D(n),">"===r?M(n):n.state=w.ATTRIB;continue;case w.CLOSE_TAG:if(n.tagName)">"===r?I(n):b(m,r)?n.tagName+=r:n.script?(n.script+="</"+n.tagName,n.tagName="",n.state=w.SCRIPT):(g(r)||T(n,"Invalid tagname in closing tag"),n.state=w.CLOSE_TAG_SAW_WHITE);else{if(g(r))continue;v(d,r)?n.script?(n.script+="</"+r,n.state=w.SCRIPT):T(n,"Invalid tagname in closing tag."):n.tagName=r}continue;case w.CLOSE_TAG_SAW_WHITE:if(g(r))continue;">"===r?I(n):T(n,"Invalid characters in closing tag");continue;case w.TEXT_ENTITY:case w.ATTRIB_VALUE_ENTITY_Q:case w.ATTRIB_VALUE_ENTITY_U:var u,x;switch(n.state){case w.TEXT_ENTITY:u=w.TEXT,x="textNode";break;case w.ATTRIB_VALUE_ENTITY_Q:u=w.ATTRIB_VALUE_QUOTED,x="attribValue";break;case w.ATTRIB_VALUE_ENTITY_U:u=w.ATTRIB_VALUE_UNQUOTED,x="attribValue"}if(";"===r)if(n.opt.unparsedEntities){var k=N(n);n.entity="",n.state=u,n.write(k)}else n[x]+=N(n),n.entity="",n.state=u;else b(n.entity.length?p:h,r)?n.entity+=r:(T(n,"Invalid character in entity name"),n[x]+="&"+n.entity+r,n.entity="",n.state=u);continue;default:throw new Error(n,"Unknown state: "+n.state)}n.position>=n.bufferCheckPosition&&function(a){for(var n=Math.max(e.MAX_BUFFER_LENGTH,10),i=0,r=0,o=t.length;r<o;r++){var s=a[t[r]].length;if(s>n)switch(t[r]){case"textNode":S(a);break;case"cdata":A(a,"oncdata",a.cdata),a.cdata="";break;case"script":A(a,"onscript",a.script),a.script="";break;default:_(a,"Max buffer length exceeded: "+t[r])}i=Math.max(i,s)}var l=e.MAX_BUFFER_LENGTH-i;a.bufferCheckPosition=l+a.position}(n);return n}
415
415
  /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */,resume:function(){return this.error=null,this},close:function(){return this.write(null)},flush:function(){var e;S(e=this),""!==e.cdata&&(A(e,"oncdata",e.cdata),e.cdata=""),""!==e.script&&(A(e,"onscript",e.script),e.script="")}};var n=ReadableStream;n||(n=function(){});var i=e.EVENTS.filter((function(e){return"error"!==e&&"end"!==e}));function r(e,t){if(!(this instanceof r))return new r(e,t);n.apply(this),this._parser=new a(e,t),this.writable=!0,this.readable=!0;var o=this;this._parser.onend=function(){o.emit("end")},this._parser.onerror=function(e){o.emit("error",e),o._parser.error=null},this._decoder=null,i.forEach((function(e){Object.defineProperty(o,"on"+e,{get:function(){return o._parser["on"+e]},set:function(t){if(!t)return o.removeAllListeners(e),o._parser["on"+e]=t,t;o.on(e,t)},enumerable:!0,configurable:!1})}))}r.prototype=Object.create(n.prototype,{constructor:{value:r}}),r.prototype.write=function(e){return this._parser.write(e.toString()),this.emit("data",e),!0},r.prototype.end=function(e){return e&&e.length&&this.write(e),this._parser.end(),!0},r.prototype.on=function(e,t){var a=this;return a._parser["on"+e]||-1===i.indexOf(e)||(a._parser["on"+e]=function(){var t=1===arguments.length?[arguments[0]]:Array.apply(null,arguments);t.splice(0,0,e),a.emit.apply(a,t)}),n.prototype.on.call(a,e,t)};var o="[CDATA[",s="DOCTYPE",l="http://www.w3.org/XML/1998/namespace",c="http://www.w3.org/2000/xmlns/",u={xml:l,xmlns:c},d=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,m=/[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/,h=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/,p=/[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;function g(e){return" "===e||"\n"===e||"\r"===e||"\t"===e}function f(e){return'"'===e||"'"===e}function y(e){return">"===e||g(e)}function b(e,t){return e.test(t)}function v(e,t){return!b(e,t)}var w=0;for(var x in e.STATE={BEGIN:w++,BEGIN_WHITESPACE:w++,TEXT:w++,TEXT_ENTITY:w++,OPEN_WAKA:w++,SGML_DECL:w++,SGML_DECL_QUOTED:w++,DOCTYPE:w++,DOCTYPE_QUOTED:w++,DOCTYPE_DTD:w++,DOCTYPE_DTD_QUOTED:w++,COMMENT_STARTING:w++,COMMENT:w++,COMMENT_ENDING:w++,COMMENT_ENDED:w++,CDATA:w++,CDATA_ENDING:w++,CDATA_ENDING_2:w++,PROC_INST:w++,PROC_INST_BODY:w++,PROC_INST_ENDING:w++,OPEN_TAG:w++,OPEN_TAG_SLASH:w++,ATTRIB:w++,ATTRIB_NAME:w++,ATTRIB_NAME_SAW_WHITE:w++,ATTRIB_VALUE:w++,ATTRIB_VALUE_QUOTED:w++,ATTRIB_VALUE_CLOSED:w++,ATTRIB_VALUE_UNQUOTED:w++,ATTRIB_VALUE_ENTITY_Q:w++,ATTRIB_VALUE_ENTITY_U:w++,CLOSE_TAG:w++,CLOSE_TAG_SAW_WHITE:w++,SCRIPT:w++,SCRIPT_ENDING:w++},e.XML_ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'"},e.ENTITIES={amp:"&",gt:">",lt:"<",quot:'"',apos:"'",AElig:198,Aacute:193,Acirc:194,Agrave:192,Aring:197,Atilde:195,Auml:196,Ccedil:199,ETH:208,Eacute:201,Ecirc:202,Egrave:200,Euml:203,Iacute:205,Icirc:206,Igrave:204,Iuml:207,Ntilde:209,Oacute:211,Ocirc:212,Ograve:210,Oslash:216,Otilde:213,Ouml:214,THORN:222,Uacute:218,Ucirc:219,Ugrave:217,Uuml:220,Yacute:221,aacute:225,acirc:226,aelig:230,agrave:224,aring:229,atilde:227,auml:228,ccedil:231,eacute:233,ecirc:234,egrave:232,eth:240,euml:235,iacute:237,icirc:238,igrave:236,iuml:239,ntilde:241,oacute:243,ocirc:244,ograve:242,oslash:248,otilde:245,ouml:246,szlig:223,thorn:254,uacute:250,ucirc:251,ugrave:249,uuml:252,yacute:253,yuml:255,copy:169,reg:174,nbsp:160,iexcl:161,cent:162,pound:163,curren:164,yen:165,brvbar:166,sect:167,uml:168,ordf:170,laquo:171,not:172,shy:173,macr:175,deg:176,plusmn:177,sup1:185,sup2:178,sup3:179,acute:180,micro:181,para:182,middot:183,cedil:184,ordm:186,raquo:187,frac14:188,frac12:189,frac34:190,iquest:191,times:215,divide:247,OElig:338,oelig:339,Scaron:352,scaron:353,Yuml:376,fnof:402,circ:710,tilde:732,Alpha:913,Beta:914,Gamma:915,Delta:916,Epsilon:917,Zeta:918,Eta:919,Theta:920,Iota:921,Kappa:922,Lambda:923,Mu:924,Nu:925,Xi:926,Omicron:927,Pi:928,Rho:929,Sigma:931,Tau:932,Upsilon:933,Phi:934,Chi:935,Psi:936,Omega:937,alpha:945,beta:946,gamma:947,delta:948,epsilon:949,zeta:950,eta:951,theta:952,iota:953,kappa:954,lambda:955,mu:956,nu:957,xi:958,omicron:959,pi:960,rho:961,sigmaf:962,sigma:963,tau:964,upsilon:965,phi:966,chi:967,psi:968,omega:969,thetasym:977,upsih:978,piv:982,ensp:8194,emsp:8195,thinsp:8201,zwnj:8204,zwj:8205,lrm:8206,rlm:8207,ndash:8211,mdash:8212,lsquo:8216,rsquo:8217,sbquo:8218,ldquo:8220,rdquo:8221,bdquo:8222,dagger:8224,Dagger:8225,bull:8226,hellip:8230,permil:8240,prime:8242,Prime:8243,lsaquo:8249,rsaquo:8250,oline:8254,frasl:8260,euro:8364,image:8465,weierp:8472,real:8476,trade:8482,alefsym:8501,larr:8592,uarr:8593,rarr:8594,darr:8595,harr:8596,crarr:8629,lArr:8656,uArr:8657,rArr:8658,dArr:8659,hArr:8660,forall:8704,part:8706,exist:8707,empty:8709,nabla:8711,isin:8712,notin:8713,ni:8715,prod:8719,sum:8721,minus:8722,lowast:8727,radic:8730,prop:8733,infin:8734,ang:8736,and:8743,or:8744,cap:8745,cup:8746,int:8747,there4:8756,sim:8764,cong:8773,asymp:8776,ne:8800,equiv:8801,le:8804,ge:8805,sub:8834,sup:8835,nsub:8836,sube:8838,supe:8839,oplus:8853,otimes:8855,perp:8869,sdot:8901,lceil:8968,rceil:8969,lfloor:8970,rfloor:8971,lang:9001,rang:9002,loz:9674,spades:9824,clubs:9827,hearts:9829,diams:9830},Object.keys(e.ENTITIES).forEach((function(t){var a=e.ENTITIES[t],n="number"==typeof a?String.fromCharCode(a):a;e.ENTITIES[t]=n})),e.STATE)e.STATE[e.STATE[x]]=x;function k(e,t,a){e[t]&&e[t](a)}function A(e,t,a){e.textNode&&S(e),k(e,t,a)}function S(e){e.textNode=E(e.opt,e.textNode),e.textNode&&k(e,"ontext",e.textNode),e.textNode=""}function E(e,t){return e.trim&&(t=t.trim()),e.normalize&&(t=t.replace(/\s+/g," ")),t}function _(e,t){return S(e),e.trackPosition&&(t+="\nLine: "+e.line+"\nColumn: "+e.column+"\nChar: "+e.c),t=new Error(t),e.error=t,k(e,"onerror",t),e}function C(e){return e.sawRoot&&!e.closedRoot&&T(e,"Unclosed root tag"),e.state!==w.BEGIN&&e.state!==w.BEGIN_WHITESPACE&&e.state!==w.TEXT&&_(e,"Unexpected end"),S(e),e.c="",e.closed=!0,k(e,"onend"),a.call(e,e.strict,e.opt),e}function T(e,t){if("object"!=typeof e||!(e instanceof a))throw new Error("bad call to strictFail");e.strict&&_(e,t)}function P(e){e.strict||(e.tagName=e.tagName[e.looseCase]());var t=e.tags[e.tags.length-1]||e,a=e.tag={name:e.tagName,attributes:{}};e.opt.xmlns&&(a.ns=t.ns),e.attribList.length=0,A(e,"onopentagstart",a)}function O(e,t){var a=e.indexOf(":")<0?["",e]:e.split(":"),n=a[0],i=a[1];return t&&"xmlns"===e&&(n="xmlns",i=""),{prefix:n,local:i}}function D(e){if(e.strict||(e.attribName=e.attribName[e.looseCase]()),-1!==e.attribList.indexOf(e.attribName)||e.tag.attributes.hasOwnProperty(e.attribName))e.attribName=e.attribValue="";else{if(e.opt.xmlns){var t=O(e.attribName,!0),a=t.prefix,n=t.local;if("xmlns"===a)if("xml"===n&&e.attribValue!==l)T(e,"xml: prefix must be bound to "+l+"\nActual: "+e.attribValue);else if("xmlns"===n&&e.attribValue!==c)T(e,"xmlns: prefix must be bound to "+c+"\nActual: "+e.attribValue);else{var i=e.tag,r=e.tags[e.tags.length-1]||e;i.ns===r.ns&&(i.ns=Object.create(r.ns)),i.ns[n]=e.attribValue}e.attribList.push([e.attribName,e.attribValue])}else e.tag.attributes[e.attribName]=e.attribValue,A(e,"onattribute",{name:e.attribName,value:e.attribValue});e.attribName=e.attribValue=""}}function M(e,t){if(e.opt.xmlns){var a=e.tag,n=O(e.tagName);a.prefix=n.prefix,a.local=n.local,a.uri=a.ns[n.prefix]||"",a.prefix&&!a.uri&&(T(e,"Unbound namespace prefix: "+JSON.stringify(e.tagName)),a.uri=n.prefix);var i=e.tags[e.tags.length-1]||e;a.ns&&i.ns!==a.ns&&Object.keys(a.ns).forEach((function(t){A(e,"onopennamespace",{prefix:t,uri:a.ns[t]})}));for(var r=0,o=e.attribList.length;r<o;r++){var s=e.attribList[r],l=s[0],c=s[1],u=O(l,!0),d=u.prefix,m=u.local,h=""===d?"":a.ns[d]||"",p={name:l,value:c,prefix:d,local:m,uri:h};d&&"xmlns"!==d&&!h&&(T(e,"Unbound namespace prefix: "+JSON.stringify(d)),p.uri=d),e.tag.attributes[l]=p,A(e,"onattribute",p)}e.attribList.length=0}e.tag.isSelfClosing=!!t,e.sawRoot=!0,e.tags.push(e.tag),A(e,"onopentag",e.tag),t||(e.noscript||"script"!==e.tagName.toLowerCase()?e.state=w.TEXT:e.state=w.SCRIPT,e.tag=null,e.tagName=""),e.attribName=e.attribValue="",e.attribList.length=0}function I(e){if(!e.tagName)return T(e,"Weird empty close tag."),e.textNode+="</>",void(e.state=w.TEXT);if(e.script){if("script"!==e.tagName)return e.script+="</"+e.tagName+">",e.tagName="",void(e.state=w.SCRIPT);A(e,"onscript",e.script),e.script=""}var t=e.tags.length,a=e.tagName;e.strict||(a=a[e.looseCase]());for(var n=a;t--;){if(e.tags[t].name===n)break;T(e,"Unexpected close tag")}if(t<0)return T(e,"Unmatched closing tag: "+e.tagName),e.textNode+="</"+e.tagName+">",void(e.state=w.TEXT);e.tagName=a;for(var i=e.tags.length;i-- >t;){var r=e.tag=e.tags.pop();e.tagName=e.tag.name,A(e,"onclosetag",e.tagName);var o={};for(var s in r.ns)o[s]=r.ns[s];var l=e.tags[e.tags.length-1]||e;e.opt.xmlns&&r.ns!==l.ns&&Object.keys(r.ns).forEach((function(t){var a=r.ns[t];A(e,"onclosenamespace",{prefix:t,uri:a})}))}0===t&&(e.closedRoot=!0),e.tagName=e.attribValue=e.attribName="",e.attribList.length=0,e.state=w.TEXT}function N(e){var t,a=e.entity,n=a.toLowerCase(),i="";return e.ENTITIES[a]?e.ENTITIES[a]:e.ENTITIES[n]?e.ENTITIES[n]:("#"===(a=n).charAt(0)&&("x"===a.charAt(1)?(a=a.slice(2),i=(t=parseInt(a,16)).toString(16)):(a=a.slice(1),i=(t=parseInt(a,10)).toString(10))),a=a.replace(/^0+/,""),isNaN(t)||i.toLowerCase()!==a?(T(e,"Invalid character entity"),"&"+e.entity+";"):String.fromCodePoint(t))}function j(e,t){"<"===t?(e.state=w.OPEN_WAKA,e.startTagPosition=e.position):g(t)||(T(e,"Non-whitespace before first tag."),e.textNode=t,e.state=w.TEXT)}function z(e,t){var a="";return t<e.length&&(a=e.charAt(t)),a}return w=e.STATE,String.fromCodePoint||function(){var e=String.fromCharCode,t=Math.floor,a=function(){var a,n,i=[],r=-1,o=arguments.length;if(!o)return"";for(var s="";++r<o;){var l=Number(arguments[r]);if(!isFinite(l)||l<0||l>1114111||t(l)!==l)throw RangeError("Invalid code point: "+l);l<=65535?i.push(l):(a=55296+((l-=65536)>>10),n=l%1024+56320,i.push(a,n)),(r+1===o||i.length>16384)&&(s+=e.apply(null,i),i.length=0)}return s};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:a,configurable:!0,writable:!0}):String.fromCodePoint=a}(),e},ZR=KR(),YR='The output should be formatted as a XML file.\n1. Output should conform to the tags below. \n2. If tags are not given, make them on your own.\n3. Remember to always open and close all the tags.\n\nAs an example, for the tags ["foo", "bar", "baz"]:\n1. String "<foo>\n <bar>\n <baz></baz>\n </bar>\n</foo>" is a well-formatted instance of the schema. \n2. String "<foo>\n <bar>\n </foo>" is a badly-formatted instance.\n3. String "<foo>\n <tag>\n </tag>\n</foo>" is a badly-formatted instance.\n\nHere are the output tags:\n```\n{tags}\n```';const XR=e=>e.split("\n").map((e=>e.replace(/^\s+/,""))).join("\n").trim(),QR=e=>{if(0===Object.keys(e).length)return{};const t={};return e.children.length>0?(t[e.name]=e.children.map(QR),t):(t[e.name]=e.text??void 0,t)};function JR(e){const t=XR(e),a=ZR.parser(!0);let n={};const i=[];a.onopentag=e=>{const t={name:e.name,attributes:e.attributes,children:[],text:"",isSelfClosing:e.isSelfClosing};if(i.length>0){i[i.length-1].children.push(t)}else n=t;e.isSelfClosing||i.push(t)},a.onclosetag=()=>{if(i.length>0){const e=i.pop();0===i.length&&e&&(n=e)}},a.ontext=e=>{if(i.length>0){i[i.length-1].text+=e}},a.onattribute=e=>{if(i.length>0){i[i.length-1].attributes[e.name]=e.value}};const r=/```(xml)?(.*)```/s.exec(t),o=r?r[2]:t;return a.write(o).close(),n&&"?xml"===n.name&&(n=n.children[0]),QR(n)}var eL=Object.freeze({__proto__:null,AsymmetricStructuredOutputParser:class extends rR{constructor({inputSchema:e}){super(...arguments),Object.defineProperty(this,"structuredInputParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.structuredInputParser=new VR(e)}async parse(e){let t;try{t=await this.structuredInputParser.parse(e)}catch(t){throw new oR(`Failed to parse. Text: "${e}". Error: ${t}`,e)}return this.outputProcessor(t)}getFormatInstructions(){return this.structuredInputParser.getFormatInstructions()}},BaseCumulativeTransformOutputParser:qR,BaseLLMOutputParser:iR,BaseOutputParser:rR,BaseTransformOutputParser:HR,BytesOutputParser:class extends HR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","bytes"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"textEncoder",{enumerable:!0,configurable:!0,writable:!0,value:new TextEncoder})}static lc_name(){return"BytesOutputParser"}parse(e){return Promise.resolve(this.textEncoder.encode(e))}getFormatInstructions(){return""}},CommaSeparatedListOutputParser:class extends UR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","list"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0})}static lc_name(){return"CommaSeparatedListOutputParser"}async parse(e){try{return e.trim().split(",").map((e=>e.trim()))}catch(t){throw new oR(`Could not parse output: ${e}`,e)}}getFormatInstructions(){return"Your response should be a list of comma separated values, eg: `foo, bar, baz`"}},CustomListOutputParser:class extends UR{constructor({length:e,separator:t}){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","list"]}),Object.defineProperty(this,"length",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"separator",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.length=e,this.separator=t||","}async parse(e){try{const t=e.trim().split(this.separator).map((e=>e.trim()));if(void 0!==this.length&&t.length!==this.length)throw new oR(`Incorrect number of items. Expected ${this.length}, got ${t.length}.`);return t}catch(t){if(Object.getPrototypeOf(t)===oR.prototype)throw t;throw new oR(`Could not parse output: ${e}`)}}getFormatInstructions(){return`Your response should be a list of ${void 0===this.length?"":`${this.length} `}items separated by "${this.separator}" (eg: \`foo${this.separator} bar${this.separator} baz\`)`}},JsonMarkdownStructuredOutputParser:VR,JsonOutputParser:GR,ListOutputParser:UR,MarkdownListOutputParser:class extends UR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","list"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"re",{enumerable:!0,configurable:!0,writable:!0,value:/^\s*[-*]\s([^\n]+)$/gm})}static lc_name(){return"NumberedListOutputParser"}getFormatInstructions(){return"Your response should be a numbered list with each item on a new line. For example: \n\n1. foo\n\n2. bar\n\n3. baz"}async parse(e){return[...e.matchAll(this.re)??[]].map((e=>e[1]))}},NumberedListOutputParser:class extends UR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","list"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"re",{enumerable:!0,configurable:!0,writable:!0,value:/\d+\.\s([^\n]+)/g})}static lc_name(){return"NumberedListOutputParser"}getFormatInstructions(){return"Your response should be a numbered list with each item on a new line. For example: \n\n1. foo\n\n2. bar\n\n3. baz"}async parse(e){return[...e.matchAll(this.re)??[]].map((e=>e[1]))}},OutputParserException:oR,StringOutputParser:class extends HR{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers","string"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0})}static lc_name(){return"StrOutputParser"}parse(e){return Promise.resolve(e)}getFormatInstructions(){return""}_textContentToString(e){return e.text}_imageUrlContentToString(e){throw new Error('Cannot coerce a multimodal "image_url" message part into a string.')}_messageContentComplexToString(e){switch(e.type){case"text":case"text_delta":if("text"in e)return this._textContentToString(e);break;case"image_url":if("image_url"in e)return this._imageUrlContentToString(e);break;default:throw new Error(`Cannot coerce "${e.type}" message part into a string.`)}throw new Error(`Invalid content type: ${e.type}`)}_baseMessageContentToString(e){return e.reduce(((e,t)=>e+this._messageContentComplexToString(t)),"")}},StructuredOutputParser:WR,XMLOutputParser:class extends qR{constructor(e){super(e),Object.defineProperty(this,"tags",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","output_parsers"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),this.tags=e?.tags}static lc_name(){return"XMLOutputParser"}_diff(e,t){if(t)return e?Ux(e,t):[{op:"replace",path:"",value:t}]}async parsePartialResult(e){return JR(e[0].text)}async parse(e){return JR(e)}getFormatInstructions(){return!!(this.tags&&this.tags.length>0)?YR.replace("{tags}",this.tags?.join(", ")??""):YR}},XML_FORMAT_INSTRUCTIONS:YR,parseJsonMarkdown:tf,parsePartialJson:af,parseXMLMarkdown:JR});function tL(e,t){if(void 0===e.function)return;let a;if(t?.partial)try{a=af(e.function.arguments??"{}")}catch(e){return}else try{a=JSON.parse(e.function.arguments)}catch(t){throw new oR([`Function "${e.function.name}" arguments:`,"",e.function.arguments,"","are not valid JSON.",`Error: ${t.message}`].join("\n"))}const n={name:e.function.name,args:a,type:"tool_call"};return t?.returnId&&(n.id=e.id),n}function aL(e){if(void 0===e.id)throw new Error('All OpenAI tool calls must have an "id" field.');return{id:e.id,type:"function",function:{name:e.name,arguments:JSON.stringify(e.args)}}}function nL(e,t){return{name:e.function?.name,args:e.function?.arguments,id:e.id,error:t,type:"invalid_tool_call"}}class iL extends qR{static lc_name(){return"JsonOutputToolsParser"}constructor(e){super(e),Object.defineProperty(this,"returnId",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","output_parsers","openai_tools"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),this.returnId=e?.returnId??this.returnId}_diff(){throw new Error("Not supported.")}async parse(){throw new Error("Not implemented.")}async parseResult(e){return await this.parsePartialResult(e,!1)}async parsePartialResult(e,t=!0){const a=e[0].message;let n;if(yf(a)&&a.tool_calls?.length)n=a.tool_calls.map((e=>{const{id:t,...a}=e;return this.returnId?{id:t,...a}:a}));else if(void 0!==a.additional_kwargs.tool_calls){n=JSON.parse(JSON.stringify(a.additional_kwargs.tool_calls)).map((e=>tL(e,{returnId:this.returnId,partial:t})))}if(!n)return[];const i=[];for(const e of n)if(void 0!==e){const t={type:e.name,args:e.args,id:e.id};i.push(t)}return i}}class rL extends iL{static lc_name(){return"JsonOutputKeyToolsParser"}constructor(e){super(e),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","output_parsers","openai_tools"]}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"returnId",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"keyName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"returnSingle",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"zodSchema",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.keyName=e.keyName,this.returnSingle=e.returnSingle??this.returnSingle,this.zodSchema=e.zodSchema}async _validateResult(e){if(void 0===this.zodSchema)return e;const t=await this.zodSchema.safeParseAsync(e);if(t.success)return t.data;throw new oR(`Failed to parse. Text: "${JSON.stringify(e,null,2)}". Error: ${JSON.stringify(t.error.errors)}`,JSON.stringify(e,null,2))}async parsePartialResult(e){const t=(await super.parsePartialResult(e)).filter((e=>e.type===this.keyName));let a=t;if(t.length)return this.returnId||(a=t.map((e=>e.args))),this.returnSingle?a[0]:a}async parseResult(e){const t=(await super.parsePartialResult(e,!1)).filter((e=>e.type===this.keyName));let a=t;if(!t.length)return;if(this.returnId||(a=t.map((e=>e.args))),this.returnSingle)return this._validateResult(a[0]);const n=await Promise.all(a.map((e=>this._validateResult(e))));return n}}const oL=Symbol("Let zodToJsonSchema decide on which parser to use"),sL={name:void 0,$refStrategy:"root",effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",nullableStrategy:"from-target",removeAdditionalStrategy:"passthrough",definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},lL=e=>"_def"in e?e._def:e;const cL=e=>{const t=(e=>"string"==typeof e?{...sL,basePath:["#"],definitions:{},name:e}:{...sL,basePath:["#"],definitions:{},...e})(e),a=void 0!==t.name?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:a,propertyPath:void 0,seenRefs:new Set,seen:new Map(Object.entries(t.definitions).map((([e,a])=>[lL(a),{def:lL(a),path:[...t.basePath,t.definitionPath,e],jsonSchema:void 0}])))}};function uL(e,t,a,n){n?.errorMessages&&a&&(e.errorMessage={...e.errorMessage,[t]:a})}function dL(e,t,a,n,i){e[t]=a,uL(e,t,n,i)}function mL(e,t,a){const n=a??t.dateStrategy;if(Array.isArray(n))return{anyOf:n.map(((a,n)=>mL(e,t,a)))};switch(n){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return hL(e,t)}}const hL=(e,t)=>{const a={type:"integer",format:"unix-time"};if("openApi3"===t.target)return a;for(const n of e.checks)switch(n.kind){case"min":dL(a,"minimum",n.value,n.message,t);break;case"max":dL(a,"maximum",n.value,n.message,t)}return a};let pL;const gL={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>(void 0===pL&&(pL=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),pL),uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/};function fL(e,t){const a={type:"string"};function n(e){return"escape"===t.patternStrategy?yL(e):e}if(e.checks)for(const i of e.checks)switch(i.kind){case"min":dL(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t);break;case"max":dL(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"email":switch(t.emailStrategy){case"format:email":bL(a,"email",i.message,t);break;case"format:idn-email":bL(a,"idn-email",i.message,t);break;case"pattern:zod":vL(a,gL.email,i.message,t)}break;case"url":bL(a,"uri",i.message,t);break;case"uuid":bL(a,"uuid",i.message,t);break;case"regex":vL(a,i.regex,i.message,t);break;case"cuid":vL(a,gL.cuid,i.message,t);break;case"cuid2":vL(a,gL.cuid2,i.message,t);break;case"startsWith":vL(a,RegExp(`^${n(i.value)}`),i.message,t);break;case"endsWith":vL(a,RegExp(`${n(i.value)}$`),i.message,t);break;case"datetime":bL(a,"date-time",i.message,t);break;case"date":bL(a,"date",i.message,t);break;case"time":bL(a,"time",i.message,t);break;case"duration":bL(a,"duration",i.message,t);break;case"length":dL(a,"minLength","number"==typeof a.minLength?Math.max(a.minLength,i.value):i.value,i.message,t),dL(a,"maxLength","number"==typeof a.maxLength?Math.min(a.maxLength,i.value):i.value,i.message,t);break;case"includes":vL(a,RegExp(n(i.value)),i.message,t);break;case"ip":"v6"!==i.version&&bL(a,"ipv4",i.message,t),"v4"!==i.version&&bL(a,"ipv6",i.message,t);break;case"emoji":vL(a,gL.emoji,i.message,t);break;case"ulid":vL(a,gL.ulid,i.message,t);break;case"base64":switch(t.base64Strategy){case"format:binary":bL(a,"binary",i.message,t);break;case"contentEncoding:base64":dL(a,"contentEncoding","base64",i.message,t);break;case"pattern:zod":vL(a,gL.base64,i.message,t)}break;case"nanoid":vL(a,gL.nanoid,i.message,t)}return a}const yL=e=>Array.from(e).map((e=>/[a-zA-Z0-9]/.test(e)?e:`\\${e}`)).join(""),bL=(e,t,a,n)=>{e.format||e.anyOf?.some((e=>e.format))?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format,...e.errorMessage&&n.errorMessages&&{errorMessage:{format:e.errorMessage.format}}}),delete e.format,e.errorMessage&&(delete e.errorMessage.format,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.anyOf.push({format:t,...a&&n.errorMessages&&{errorMessage:{format:a}}})):dL(e,"format",t,a,n)},vL=(e,t,a,n)=>{e.pattern||e.allOf?.some((e=>e.pattern))?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern,...e.errorMessage&&n.errorMessages&&{errorMessage:{pattern:e.errorMessage.pattern}}}),delete e.pattern,e.errorMessage&&(delete e.errorMessage.pattern,0===Object.keys(e.errorMessage).length&&delete e.errorMessage)),e.allOf.push({pattern:wL(t,n),...a&&n.errorMessages&&{errorMessage:{pattern:a}}})):dL(e,"pattern",wL(t,n),a,n)},wL=(e,t)=>{const a="function"==typeof e?e():e;if(!t.applyRegexFlags||!a.flags)return a.source;const n=a.flags.includes("i"),i=a.flags.includes("m"),r=a.flags.includes("s"),o=n?a.source.toLowerCase():a.source;let s="",l=!1,c=!1,u=!1;for(let e=0;e<o.length;e++)if(l)s+=o[e],l=!1;else{if(n)if(c){if(o[e].match(/[a-z]/)){u?(s+=o[e],s+=`${o[e-2]}-${o[e]}`.toUpperCase(),u=!1):"-"===o[e+1]&&o[e+2]?.match(/[a-z]/)?(s+=o[e],u=!0):s+=`${o[e]}${o[e].toUpperCase()}`;continue}}else if(o[e].match(/[a-z]/)){s+=`[${o[e]}${o[e].toUpperCase()}]`;continue}if(i){if("^"===o[e]){s+="(^|(?<=[\r\n]))";continue}if("$"===o[e]){s+="($|(?=[\r\n]))";continue}}r&&"."===o[e]?s+=c?`${o[e]}\r\n`:`[${o[e]}\r\n]`:(s+=o[e],"\\"===o[e]?l=!0:c&&"]"===o[e]?c=!1:c||"["!==o[e]||(c=!0))}try{new RegExp(s)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),a.source}return s};function xL(e,t){if("openApi3"===t.target&&e.keyType?._def.typeName===Qh.ZodEnum)return{type:"object",required:e.keyType._def.values,properties:e.keyType._def.values.reduce(((a,n)=>({...a,[n]:EL(e.valueType._def,{...t,currentPath:[...t.currentPath,"properties",n]})??{}})),{}),additionalProperties:!1};const a={type:"object",additionalProperties:EL(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??{}};if("openApi3"===t.target)return a;if(e.keyType?._def.typeName===Qh.ZodString&&e.keyType._def.checks?.length){const n=Object.entries(fL(e.keyType._def,t)).reduce(((e,[t,a])=>"type"===t?e:{...e,[t]:a}),{});return{...a,propertyNames:n}}return e.keyType?._def.typeName===Qh.ZodEnum?{...a,propertyNames:{enum:e.keyType._def.values}}:a}const kL={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};const AL=(e,t)=>{const a=(e.options instanceof Map?Array.from(e.options.values()):e.options).map(((e,a)=>EL(e._def,{...t,currentPath:[...t.currentPath,"anyOf",`${a}`]}))).filter((e=>!!e&&(!t.strictUnions||"object"==typeof e&&Object.keys(e).length>0)));return a.length?{anyOf:a}:void 0};function SL(e,t){return"strict"===t.removeAdditionalStrategy?"ZodNever"===e.catchall._def.typeName?"strict"!==e.unknownKeys:EL(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0:"ZodNever"===e.catchall._def.typeName?"passthrough"===e.unknownKeys:EL(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]})??!0}function EL(e,t,a=!1){const n=t.seen.get(e);if(t.override){const i=t.override?.(e,t,n,a);if(i!==oL)return i}if(n&&!a){const e=_L(n,t);if(void 0!==e)return"$ref"in e&&t.seenRefs.add(e.$ref),e}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const r=TL(e,e.typeName,t,a);return r&&PL(e,t,r),i.jsonSchema=r,r}const _L=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"extract-to-root":const a=e.path.slice(t.basePath.length+1).join("_");return a!==t.name&&"duplicate-ref"===t.nameStrategy&&(t.definitions[a]=e.def),{$ref:[...t.basePath,t.definitionPath,a].join("/")};case"relative":return{$ref:CL(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every(((e,a)=>t.currentPath[a]===e))?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),{}):"seen"===t.$refStrategy?{}:void 0}},CL=(e,t)=>{let a=0;for(;a<e.length&&a<t.length&&e[a]===t[a];a++);return[(e.length-a).toString(),...t.slice(a)].join("/")},TL=(e,t,a,n)=>{switch(t){case Qh.ZodString:return fL(e,a);case Qh.ZodNumber:return function(e,t){const a={type:"number"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"int":a.type="integer",uL(a,"type",n.message,t);break;case"min":"jsonSchema7"===t.target?n.inclusive?dL(a,"minimum",n.value,n.message,t):dL(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),dL(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?dL(a,"maximum",n.value,n.message,t):dL(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),dL(a,"maximum",n.value,n.message,t));break;case"multipleOf":dL(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodObject:return function(e,t){const a={type:"object",...Object.entries(e.shape()).reduce(((e,[a,n])=>{if(void 0===n||void 0===n._def)return e;const i=EL(n._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});return void 0===i?e:{properties:{...e.properties,[a]:i},required:n.isOptional()&&!t.openaiStrictMode?e.required:[...e.required,a]}}),{properties:{},required:[]}),additionalProperties:SL(e,t)};return a.required.length||delete a.required,a}(e,a);case Qh.ZodBigInt:return function(e,t){const a={type:"integer",format:"int64"};if(!e.checks)return a;for(const n of e.checks)switch(n.kind){case"min":"jsonSchema7"===t.target?n.inclusive?dL(a,"minimum",n.value,n.message,t):dL(a,"exclusiveMinimum",n.value,n.message,t):(n.inclusive||(a.exclusiveMinimum=!0),dL(a,"minimum",n.value,n.message,t));break;case"max":"jsonSchema7"===t.target?n.inclusive?dL(a,"maximum",n.value,n.message,t):dL(a,"exclusiveMaximum",n.value,n.message,t):(n.inclusive||(a.exclusiveMaximum=!0),dL(a,"maximum",n.value,n.message,t));break;case"multipleOf":dL(a,"multipleOf",n.value,n.message,t)}return a}(e,a);case Qh.ZodBoolean:return{type:"boolean"};case Qh.ZodDate:return mL(e,a);case Qh.ZodUndefined:return{not:{}};case Qh.ZodNull:return function(e){return"openApi3"===e.target?{enum:["null"],nullable:!0}:{type:"null"}}(a);case Qh.ZodArray:return function(e,t){const a={type:"array"};return e.type?._def?.typeName!==Qh.ZodAny&&(a.items=EL(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&dL(a,"minItems",e.minLength.value,e.minLength.message,t),e.maxLength&&dL(a,"maxItems",e.maxLength.value,e.maxLength.message,t),e.exactLength&&(dL(a,"minItems",e.exactLength.value,e.exactLength.message,t),dL(a,"maxItems",e.exactLength.value,e.exactLength.message,t)),a}(e,a);case Qh.ZodUnion:case Qh.ZodDiscriminatedUnion:return function(e,t){if("openApi3"===t.target)return AL(e,t);const a=e.options instanceof Map?Array.from(e.options.values()):e.options;if(a.every((e=>e._def.typeName in kL&&(!e._def.checks||!e._def.checks.length)))){const e=a.reduce(((e,t)=>{const a=kL[t._def.typeName];return a&&!e.includes(a)?[...e,a]:e}),[]);return{type:e.length>1?e:e[0]}}if(a.every((e=>"ZodLiteral"===e._def.typeName&&!e.description))){const e=a.reduce(((e,t)=>{const a=typeof t._def.value;switch(a){case"string":case"number":case"boolean":return[...e,a];case"bigint":return[...e,"integer"];case"object":if(null===t._def.value)return[...e,"null"];default:return e}}),[]);if(e.length===a.length){const t=e.filter(((e,t,a)=>a.indexOf(e)===t));return{type:t.length>1?t:t[0],enum:a.reduce(((e,t)=>e.includes(t._def.value)?e:[...e,t._def.value]),[])}}}else if(a.every((e=>"ZodEnum"===e._def.typeName)))return{type:"string",enum:a.reduce(((e,t)=>[...e,...t._def.values.filter((t=>!e.includes(t)))]),[])};return AL(e,t)}(e,a);case Qh.ZodIntersection:return function(e,t){const a=[EL(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),EL(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter((e=>!!e));let n="jsonSchema2019-09"===t.target?{unevaluatedProperties:!1}:void 0;const i=[];return a.forEach((e=>{if((e=>(!("type"in e)||"string"!==e.type)&&"allOf"in e)(e))i.push(...e.allOf),void 0===e.unevaluatedProperties&&(n=void 0);else{let t=e;if("additionalProperties"in e&&!1===e.additionalProperties){const{additionalProperties:a,...n}=e;t=n}else n=void 0;i.push(t)}})),i.length?{allOf:i,...n}:void 0}(e,a);case Qh.ZodTuple:return function(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map(((e,a)=>EL(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[]),additionalItems:EL(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map(((e,a)=>EL(e._def,{...t,currentPath:[...t.currentPath,"items",`${a}`]}))).reduce(((e,t)=>void 0===t?e:[...e,t]),[])}}(e,a);case Qh.ZodRecord:return xL(e,a);case Qh.ZodLiteral:return function(e,t){const a=typeof e.value;return"bigint"!==a&&"number"!==a&&"boolean"!==a&&"string"!==a?{type:Array.isArray(e.value)?"array":"object"}:"openApi3"===t.target?{type:"bigint"===a?"integer":a,enum:[e.value]}:{type:"bigint"===a?"integer":a,const:e.value}}(e,a);case Qh.ZodEnum:return function(e){return{type:"string",enum:[...e.values]}}(e);case Qh.ZodNativeEnum:return function(e){const t=e.values,a=Object.keys(e.values).filter((e=>"number"!=typeof t[t[e]])),n=a.map((e=>t[e])),i=Array.from(new Set(n.map((e=>typeof e))));return{type:1===i.length?"string"===i[0]?"string":"number":["string","number"],enum:n}}(e);case Qh.ZodNullable:return function(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return"openApi3"===t.target||"property"===t.nullableStrategy?{type:kL[e.innerType._def.typeName],nullable:!0}:{type:[kL[e.innerType._def.typeName],"null"]};if("openApi3"===t.target){const a=EL(e.innerType._def,{...t,currentPath:[...t.currentPath]});return a&&"$ref"in a?{allOf:[a],nullable:!0}:a&&{...a,nullable:!0}}const a=EL(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return a&&{anyOf:[a,{type:"null"}]}}(e,a);case Qh.ZodOptional:return((e,t)=>{if(t.currentPath.toString()===t.propertyPath?.toString())return EL(e.innerType._def,t);const a=EL(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return a?{anyOf:[{not:{}},a]}:{}})(e,a);case Qh.ZodMap:return function(e,t){return"record"===t.mapStrategy?xL(e,t):{type:"array",maxItems:125,items:{type:"array",items:[EL(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||{},EL(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||{}],minItems:2,maxItems:2}}}(e,a);case Qh.ZodSet:return function(e,t){const a={type:"array",uniqueItems:!0,items:EL(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&dL(a,"minItems",e.minSize.value,e.minSize.message,t),e.maxSize&&dL(a,"maxItems",e.maxSize.value,e.maxSize.message,t),a}(e,a);case Qh.ZodLazy:return EL(e.getter()._def,a);case Qh.ZodPromise:return function(e,t){return EL(e.type._def,t)}(e,a);case Qh.ZodNaN:case Qh.ZodNever:return{not:{}};case Qh.ZodEffects:return function(e,t,a){return"input"===t.effectStrategy?EL(e.schema._def,t,a):{}}(e,a,n);case Qh.ZodAny:case Qh.ZodUnknown:return{};case Qh.ZodDefault:return function(e,t){return{...EL(e.innerType._def,t),default:e.defaultValue()}}(e,a);case Qh.ZodBranded:return function(e,t){return EL(e.type._def,t)}(e,a);case Qh.ZodReadonly:case Qh.ZodCatch:return((e,t)=>EL(e.innerType._def,t))(e,a);case Qh.ZodPipeline:return((e,t)=>{if("input"===t.pipeStrategy)return EL(e.in._def,t);if("output"===t.pipeStrategy)return EL(e.out._def,t);const a=EL(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]});return{allOf:[a,EL(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",a?"1":"0"]})].filter((e=>void 0!==e))}})(e,a);case Qh.ZodFunction:case Qh.ZodVoid:case Qh.ZodSymbol:default:return}},PL=(e,t,a)=>(e.description&&(a.description=e.description,t.markdownDescription&&(a.markdownDescription=e.description)),a),OL=(e,t)=>{const a=cL(t),n="string"==typeof t?t:"title"===t?.nameStrategy?void 0:t?.name,i=EL(e._def,void 0===n?a:{...a,currentPath:[...a.basePath,a.definitionPath,n]},!1)??{},r="object"==typeof t&&void 0!==t.name&&"title"===t.nameStrategy?t.name:void 0;void 0!==r&&(i.title=r);const o=(()=>{if(function(e){if(!e)return!0;for(const t in e)return!1;return!0}(a.definitions))return;const e={},t=new Set;for(let n=0;n<500;n++){const n=Object.entries(a.definitions).filter((([e])=>!t.has(e)));if(0===n.length)break;for(const[i,r]of n)e[i]=EL(lL(r),{...a,currentPath:[...a.basePath,a.definitionPath,i]},!0)??{},t.add(i)}return e})(),s=void 0===n?o?{...i,[a.definitionPath]:o}:i:"duplicate-ref"===a.nameStrategy?{...i,...o||a.seenRefs.size?{[a.definitionPath]:{...o,...a.seenRefs.size?{[n]:i}:void 0}}:void 0}:{$ref:[..."relative"===a.$refStrategy?[]:a.basePath,a.definitionPath,n].join("/"),[a.definitionPath]:{...o,[n]:i}};return"jsonSchema7"===a.target?s.$schema="http://json-schema.org/draft-07/schema#":"jsonSchema2019-09"===a.target&&(s.$schema="https://json-schema.org/draft/2019-09/schema#"),s};function DL(e,t){return OL(e,{openaiStrictMode:!0,name:t.name,nameStrategy:"duplicate-ref",$refStrategy:"extract-to-root",nullableStrategy:"property"})}function ML(e,t,a){return function(e,t){const a={...e};return Object.defineProperties(a,{$brand:{value:"auto-parseable-response-format",enumerable:!1},$parseRaw:{value:t,enumerable:!1}}),a}({type:"json_schema",json_schema:{...a,name:t,strict:!0,schema:DL(e,{name:t})}},(t=>e.parse(JSON.parse(t))))}function IL(e){return function(e,{parser:t,callback:a}){const n={...e};return Object.defineProperties(n,{$brand:{value:"auto-parseable-tool",enumerable:!1},$parseRaw:{value:t,enumerable:!1},$callback:{value:a,enumerable:!1}}),n}({type:"function",function:{name:e.name,parameters:DL(e.parameters,{name:e.name}),strict:!0,...e.description?{description:e.description}:void 0}},{callback:e.function,parser:t=>e.parameters.parse(JSON.parse(t))})}function NL(e,t){const a="number"==typeof t?void 0:t;return{name:e.name,description:e.description,parameters:Gk(e.schema),...void 0!==a?.strict?{strict:a.strict}:{}}}function jL(e,t){const a="number"==typeof t?void 0:t;let n;return n=FL(e)?{type:"function",function:NL(e)}:e,void 0!==a?.strict&&(n.function.strict=a.strict),n}function zL(e){return void 0!==e&&Array.isArray(e.lc_namespace)}function RL(e){return void 0!==e&&sA.isRunnable(e)&&"lc_name"in e.constructor&&"function"==typeof e.constructor.lc_name&&"RunnableToolLike"===e.constructor.lc_name()}function LL(e){return!!e&&"object"==typeof e&&"name"in e&&"schema"in e&&_A(e.schema)}function FL(e){return LL(e)||RL(e)||zL(e)}var BL=Object.freeze({__proto__:null,convertToOpenAIFunction:NL,convertToOpenAITool:jL,isLangChainTool:FL,isRunnableToolLike:RL,isStructuredTool:zL,isStructuredToolParams:LL});function HL(e,t){return e.lc_error_code=t,e.message=`${e.message}\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${t}/\n`,e}function qL(e){let t;return e.constructor.name===Uz.name?(t=new Error(e.message),t.name="TimeoutError"):e.constructor.name===Wz.name?(t=new Error(e.message),t.name="AbortError"):t=400===e.status&&e.message.includes("tool_calls")?HL(e,"INVALID_TOOL_RESULTS"):401===e.status?HL(e,"MODEL_AUTHENTICATION"):429===e.status?HL(e,"MODEL_RATE_LIMIT"):404===e.status?HL(e,"MODEL_NOT_FOUND"):e,t}function UL(e,t){const a=[];for(const[n,i]of Object.entries(e.properties??{}))i.description&&t<2&&a.push(`// ${i.description}`),e.required?.includes(n)?a.push(`${n}: ${WL(i,t)},`):a.push(`${n}?: ${WL(i,t)},`);return a.map((e=>" ".repeat(t)+e)).join("\n")}function WL(e,t){if(void 0!==(a=e).anyOf&&Array.isArray(a.anyOf))return e.anyOf.map((e=>WL(e,t))).join(" | ");var a;switch(e.type){case"string":return e.enum?e.enum.map((e=>`"${e}"`)).join(" | "):"string";case"number":case"integer":return e.enum?e.enum.map((e=>`${e}`)).join(" | "):"number";case"boolean":return"boolean";case"null":return"null";case"object":return["{",UL(e,t+2),"}"].join("\n");case"array":return e.items?`${WL(e.items,t)}[]`:"any[]";default:return""}}function VL(e){const t=e._getType();switch(t){case"system":return"system";case"ai":return"assistant";case"human":return"user";case"function":return"function";case"tool":return"tool";case"generic":if(!wf.isInstance(e))throw new Error("Invalid generic chat message");return function(e){return"system"!==e.role&&"assistant"!==e.role&&"user"!==e.role&&"function"!==e.role&&"tool"!==e.role&&console.warn(`Unknown message role: ${e.role}`),e.role}(e);default:throw new Error(`Unknown message type: ${t}`)}}function $L(e,t,a){const n=e.tool_calls;if("assistant"===e.role){const i=[],r=[];for(const e of n??[])try{i.push(tL(e,{returnId:!0}))}catch(t){r.push(nL(e,t.message))}const o={function_call:e.function_call,tool_calls:n};let s;return void 0!==a&&(o.__raw_response=t),t.system_fingerprint&&(s={usage:{...t.usage},system_fingerprint:t.system_fingerprint}),e.audio&&(o.audio=e.audio),new ff({content:e.content||"",tool_calls:i,invalid_tool_calls:r,additional_kwargs:o,response_metadata:s,id:t.id})}return new wf(e.content||"",e.role??"unknown")}function GL(e,t,a,n){const i=e.role??a,r=e.content??"";let o;o=e.function_call?{function_call:e.function_call}:e.tool_calls?{tool_calls:e.tool_calls}:{},n&&(o.__raw_response=t),e.audio&&(o.audio={...e.audio,index:t.choices[0].index});const s={usage:{...t.usage}};if("user"===i)return new Ef({content:r,response_metadata:s});if("assistant"===i){const a=[];if(Array.isArray(e.tool_calls))for(const t of e.tool_calls)a.push({name:t.function?.name,args:t.function?.arguments,id:t.id,index:t.index,type:"tool_call_chunk"});return new vf({content:r,tool_call_chunks:a,additional_kwargs:o,id:t.id,response_metadata:s})}return"system"===i?new Cf({content:r,response_metadata:s}):"function"===i?new Af({content:r,additional_kwargs:o,name:e.name,response_metadata:s}):"tool"===i?new gf({content:r,additional_kwargs:o,tool_call_id:e.tool_call_id,response_metadata:s}):new xf({content:r,role:i,response_metadata:s})}function KL(e){return e.flatMap((e=>{const t={role:VL(e),content:e.content};if(null!=e.name&&(t.name=e.name),null!=e.additional_kwargs.function_call&&(t.function_call=e.additional_kwargs.function_call,t.content=null),yf(e)&&e.tool_calls?.length?(t.tool_calls=e.tool_calls.map(aL),t.content=null):(null!=e.additional_kwargs.tool_calls&&(t.tool_calls=e.additional_kwargs.tool_calls),null!=e.tool_call_id&&(t.tool_call_id=e.tool_call_id)),e.additional_kwargs.audio&&"object"==typeof e.additional_kwargs.audio&&"id"in e.additional_kwargs.audio){return[t,{role:"assistant",audio:{id:e.additional_kwargs.audio.id}}]}return t}))}function ZL(e,t){return kA(e)?void 0!==t?.strict?{...e,function:{...e.function,strict:t.strict}}:e:function(e,t){let a;if(FL(e)){const n=IL({name:e.name,parameters:e.schema,description:e.description});a=n.function.parameters?{type:n.type,function:{name:n.function.name,description:n.function.description,parameters:n.function.parameters,...void 0!==t?.strict?{strict:t.strict}:{}}}:{type:"function",function:NL(e,t)}}else a=e;return void 0!==t?.strict&&(a.function.strict=t.strict),a}(e,t)}class YL extends tR{static lc_name(){return"ChatOpenAI"}get callKeys(){return[...super.callKeys,"options","function_call","functions","tools","tool_choice","promptIndex","response_format","seed"]}get lc_secrets(){return{openAIApiKey:"OPENAI_API_KEY",apiKey:"OPENAI_API_KEY",azureOpenAIApiKey:"AZURE_OPENAI_API_KEY",organization:"OPENAI_ORGANIZATION"}}get lc_aliases(){return{modelName:"model",openAIApiKey:"openai_api_key",apiKey:"openai_api_key",azureOpenAIApiVersion:"azure_openai_api_version",azureOpenAIApiKey:"azure_openai_api_key",azureOpenAIApiInstanceName:"azure_openai_api_instance_name",azureOpenAIApiDeploymentName:"azure_openai_api_deployment_name"}}constructor(e,t){if(super(e??{}),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"temperature",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"topP",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"frequencyPenalty",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"presencePenalty",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"n",{enumerable:!0,configurable:!0,writable:!0,value:1}),Object.defineProperty(this,"logitBias",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"modelName",{enumerable:!0,configurable:!0,writable:!0,value:"gpt-3.5-turbo"}),Object.defineProperty(this,"model",{enumerable:!0,configurable:!0,writable:!0,value:"gpt-3.5-turbo"}),Object.defineProperty(this,"modelKwargs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stop",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"stopSequences",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"user",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"streaming",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"streamUsage",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"maxTokens",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"logprobs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"topLogprobs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"openAIApiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIApiVersion",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIApiKey",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureADTokenProvider",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIApiInstanceName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIApiDeploymentName",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIBasePath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"azureOpenAIEndpoint",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"organization",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"__includeRawResponse",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"client",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientConfig",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"supportsStrictToolCalling",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"audio",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"modalities",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.openAIApiKey=e?.apiKey??e?.openAIApiKey??e?.configuration?.apiKey??Ng("OPENAI_API_KEY"),this.apiKey=this.openAIApiKey,this.azureOpenAIApiKey=e?.azureOpenAIApiKey??Ng("AZURE_OPENAI_API_KEY"),this.azureADTokenProvider=e?.azureADTokenProvider??void 0,!this.azureOpenAIApiKey&&!this.apiKey&&!this.azureADTokenProvider)throw new Error("OpenAI or Azure OpenAI API key or Token Provider not found");if(this.azureOpenAIApiInstanceName=e?.azureOpenAIApiInstanceName??Ng("AZURE_OPENAI_API_INSTANCE_NAME"),this.azureOpenAIApiDeploymentName=e?.azureOpenAIApiDeploymentName??Ng("AZURE_OPENAI_API_DEPLOYMENT_NAME"),this.azureOpenAIApiVersion=e?.azureOpenAIApiVersion??Ng("AZURE_OPENAI_API_VERSION"),this.azureOpenAIBasePath=e?.azureOpenAIBasePath??Ng("AZURE_OPENAI_BASE_PATH"),this.organization=e?.configuration?.organization??Ng("OPENAI_ORGANIZATION"),this.azureOpenAIEndpoint=e?.azureOpenAIEndpoint??Ng("AZURE_OPENAI_ENDPOINT"),this.modelName=e?.model??e?.modelName??this.model,this.model=this.modelName,this.modelKwargs=e?.modelKwargs??{},this.timeout=e?.timeout,this.temperature=e?.temperature??this.temperature,this.topP=e?.topP??this.topP,this.frequencyPenalty=e?.frequencyPenalty??this.frequencyPenalty,this.presencePenalty=e?.presencePenalty??this.presencePenalty,this.maxTokens=e?.maxTokens,this.logprobs=e?.logprobs,this.topLogprobs=e?.topLogprobs,this.n=e?.n??this.n,this.logitBias=e?.logitBias,this.stop=e?.stopSequences??e?.stop,this.stopSequences=this?.stop,this.user=e?.user,this.__includeRawResponse=e?.__includeRawResponse,this.audio=e?.audio,this.modalities=e?.modalities,this.azureOpenAIApiKey||this.azureADTokenProvider){if(!this.azureOpenAIApiInstanceName&&!this.azureOpenAIBasePath&&!this.azureOpenAIEndpoint)throw new Error("Azure OpenAI API instance name not found");if(!this.azureOpenAIApiDeploymentName&&this.azureOpenAIBasePath){const e=this.azureOpenAIBasePath.split("/openai/deployments/");if(2===e.length){const[,t]=e;this.azureOpenAIApiDeploymentName=t}}if(!this.azureOpenAIApiDeploymentName)throw new Error("Azure OpenAI API deployment name not found");if(!this.azureOpenAIApiVersion)throw new Error("Azure OpenAI API version not found");this.apiKey=this.apiKey??"",this.streamUsage=!1}this.streaming=e?.streaming??!1,this.streamUsage=e?.streamUsage??this.streamUsage,this.clientConfig={apiKey:this.apiKey,organization:this.organization,baseURL:t?.basePath??e?.configuration?.basePath,dangerouslyAllowBrowser:!0,defaultHeaders:t?.baseOptions?.headers??e?.configuration?.baseOptions?.headers,defaultQuery:t?.baseOptions?.params??e?.configuration?.baseOptions?.params,...t,...e?.configuration},void 0!==e?.supportsStrictToolCalling&&(this.supportsStrictToolCalling=e.supportsStrictToolCalling)}getLsParams(e){const t=this.invocationParams(e);return{ls_provider:"openai",ls_model_name:this.model,ls_model_type:"chat",ls_temperature:t.temperature??void 0,ls_max_tokens:t.max_tokens??void 0,ls_stop:e.stop}}bindTools(e,t){let a;return void 0!==t?.strict?a=t.strict:void 0!==this.supportsStrictToolCalling&&(a=this.supportsStrictToolCalling),this.bind({tools:e.map((e=>ZL(e,{strict:a}))),...t})}createResponseFormat(e){return e&&"json_schema"===e.type&&e.json_schema.schema&&XL(e.json_schema.schema)?ML(e.json_schema.schema,e.json_schema.name,{description:e.json_schema.description}):e}invocationParams(e,t){let a;void 0!==e?.strict?a=e.strict:void 0!==this.supportsStrictToolCalling&&(a=this.supportsStrictToolCalling);let n={};void 0!==e?.stream_options?n={stream_options:e.stream_options}:this.streamUsage&&(this.streaming||t?.streaming)&&(n={stream_options:{include_usage:!0}});const i={model:this.model,temperature:this.temperature,top_p:this.topP,frequency_penalty:this.frequencyPenalty,presence_penalty:this.presencePenalty,max_tokens:-1===this.maxTokens?void 0:this.maxTokens,logprobs:this.logprobs,top_logprobs:this.topLogprobs,n:this.n,logit_bias:this.logitBias,stop:e?.stop??this.stopSequences,user:this.user,stream:this.streaming,functions:e?.functions,function_call:e?.function_call,tools:e?.tools?.length?e.tools.map((e=>ZL(e,{strict:a}))):void 0,tool_choice:(r=e?.tool_choice,r?"any"===r||"required"===r?"required":"auto"===r?"auto":"none"===r?"none":"string"==typeof r?{type:"function",function:{name:r}}:r:void 0),response_format:this.createResponseFormat(e?.response_format),seed:e?.seed,...n,parallel_tool_calls:e?.parallel_tool_calls,...this.audio||e?.audio?{audio:this.audio||e?.audio}:{},...this.modalities||e?.modalities?{modalities:this.modalities||e?.modalities}:{},...this.modelKwargs};var r;return i}_identifyingParams(){return{model_name:this.model,...this.invocationParams(),...this.clientConfig}}async*_streamResponseChunks(e,t,a){if(this.model.includes("o1-")){console.warn("[WARNING]: OpenAI o1 models do not yet support token-level streaming. Streaming will yield single chunk.");const n=If((await this._generate(e,t,a)).generations[0].message);return void(yield new dk({message:n,text:"string"==typeof n.content?n.content:""}))}const n=KL(e),i={...this.invocationParams(t,{streaming:!0}),messages:n,stream:!0};let r;const o=await this.completionWithRetry(i,t);let s;for await(const e of o){const n=e?.choices?.[0];if(e.usage&&(s=e.usage),!n)continue;const{delta:i}=n;if(!i)continue;const o=GL(i,e,r,this.__includeRawResponse);r=i.role??r;const l={prompt:t.promptIndex??0,completion:n.index??0};if("string"!=typeof o.content){console.log("[WARNING]: Received non-string content from OpenAI. This is currently not supported.");continue}const c={...l};null!=n.finish_reason&&(c.finish_reason=n.finish_reason,c.system_fingerprint=e.system_fingerprint),this.logprobs&&(c.logprobs=n.logprobs);const u=new dk({message:o,text:o.content,generationInfo:c});yield u,await(a?.handleLLMNewToken(u.text??"",l,void 0,void 0,void 0,{chunk:u}))}if(s){const e={...null!==s.prompt_tokens_details?.audio_tokens&&{audio:s.prompt_tokens_details?.audio_tokens},...null!==s.prompt_tokens_details?.cached_tokens&&{cache_read:s.prompt_tokens_details?.cached_tokens}},t={...null!==s.completion_tokens_details?.audio_tokens&&{audio:s.completion_tokens_details?.audio_tokens},...null!==s.completion_tokens_details?.reasoning_tokens&&{reasoning:s.completion_tokens_details?.reasoning_tokens}},a=new dk({message:new vf({content:"",response_metadata:{usage:{...s}},usage_metadata:{input_tokens:s.prompt_tokens,output_tokens:s.completion_tokens,total_tokens:s.total_tokens,...Object.keys(e).length>0&&{input_token_details:e},...Object.keys(t).length>0&&{output_token_details:t}}}),text:""});yield a}if(t.signal?.aborted)throw new Error("AbortError")}identifyingParams(){return this._identifyingParams()}async _generate(e,t,a){const n={},i=this.invocationParams(t),r=KL(e);if(i.stream){const i=this._streamResponseChunks(e,t,a),r={};for await(const e of i){e.message.response_metadata={...e.generationInfo,...e.message.response_metadata};const t=e.generationInfo?.completion??0;void 0===r[t]?r[t]=e:r[t]=r[t].concat(e)}const o=Object.entries(r).sort((([e],[t])=>parseInt(e,10)-parseInt(t,10))).map((([e,t])=>t)),{functions:s,function_call:l}=this.invocationParams(t),c=await this.getEstimatedTokenCountFromPrompt(e,s,l),u=await this.getNumTokensFromGenerations(o);return n.input_tokens=c,n.output_tokens=u,n.total_tokens=c+u,{generations:o,llmOutput:{estimatedTokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}{let e;e=t.response_format&&"json_schema"===t.response_format.type?await this.betaParsedCompletionWithRetry({...i,stream:!1,messages:r},{signal:t?.signal,...t?.options}):await this.completionWithRetry({...i,stream:!1,messages:r},{signal:t?.signal,...t?.options});const{completion_tokens:a,prompt_tokens:o,total_tokens:s,prompt_tokens_details:l,completion_tokens_details:c}=e?.usage??{};a&&(n.output_tokens=(n.output_tokens??0)+a),o&&(n.input_tokens=(n.input_tokens??0)+o),s&&(n.total_tokens=(n.total_tokens??0)+s),null===l?.audio_tokens&&null===l?.cached_tokens||(n.input_token_details={...null!==l?.audio_tokens&&{audio:l?.audio_tokens},...null!==l?.cached_tokens&&{cache_read:l?.cached_tokens}}),null===c?.audio_tokens&&null===c?.reasoning_tokens||(n.output_token_details={...null!==c?.audio_tokens&&{audio:c?.audio_tokens},...null!==c?.reasoning_tokens&&{reasoning:c?.reasoning_tokens}});const u=[];for(const t of e?.choices??[]){const a={text:t.message?.content??"",message:$L(t.message??{role:"assistant"},e,this.__includeRawResponse)};a.generationInfo={...t.finish_reason?{finish_reason:t.finish_reason}:{},...t.logprobs?{logprobs:t.logprobs}:{}},yf(a.message)&&(a.message.usage_metadata=n),a.message=new ff({...a.message}),u.push(a)}return{generations:u,llmOutput:{tokenUsage:{promptTokens:n.input_tokens,completionTokens:n.output_tokens,totalTokens:n.total_tokens}}}}}async getEstimatedTokenCountFromPrompt(e,t,a){let n=(await this.getNumTokensFromMessages(e)).totalCount;if(t&&"auto"!==a){const e=function(e){const t=["namespace functions {",""];for(const a of e)a.description&&t.push(`// ${a.description}`),Object.keys(a.parameters.properties??{}).length>0?(t.push(`type ${a.name} = (_: {`),t.push(UL(a.parameters,0)),t.push("}) => any;")):t.push(`type ${a.name} = () => any;`),t.push("");return t.push("} // namespace functions"),t.join("\n")}(t);n+=await this.getNumTokens(e),n+=9}return t&&e.find((e=>"system"===e._getType()))&&(n-=4),"none"===a?n+=1:"object"==typeof a&&(n+=await this.getNumTokens(a.name)+4),n}async getNumTokensFromGenerations(e){return(await Promise.all(e.map((async e=>e.message.additional_kwargs?.function_call?(await this.getNumTokensFromMessages([e.message])).countPerMessage[0]:await this.getNumTokens(e.message.content))))).reduce(((e,t)=>e+t),0)}async getNumTokensFromMessages(e){let t=0,a=0,n=0;"gpt-3.5-turbo-0301"===this.model?(a=4,n=-1):(a=3,n=1);const i=await Promise.all(e.map((async e=>{const i=await this.getNumTokens(e.content),r=await this.getNumTokens(VL(e)),o=void 0!==e.name?n+await this.getNumTokens(e.name):0;let s=i+a+r+o;const l=e;if("function"===l._getType()&&(s-=2),l.additional_kwargs?.function_call&&(s+=3),l?.additional_kwargs.function_call?.name&&(s+=await this.getNumTokens(l.additional_kwargs.function_call?.name)),l.additional_kwargs.function_call?.arguments)try{s+=await this.getNumTokens(JSON.stringify(JSON.parse(l.additional_kwargs.function_call?.arguments)))}catch(e){console.error("Error parsing function arguments",e,JSON.stringify(l.additional_kwargs.function_call)),s+=await this.getNumTokens(l.additional_kwargs.function_call?.arguments)}return t+=s,s})));return t+=3,{totalCount:t,countPerMessage:i}}async completionWithRetry(e,t){const a=this._getClientOptions(t);return this.caller.call((async()=>{try{return await this.client.chat.completions.create(e,a)}catch(e){throw qL(e)}}))}async betaParsedCompletionWithRetry(e,t){const a=this._getClientOptions(t);return this.caller.call((async()=>{try{return await this.client.beta.chat.completions.parse(e,a)}catch(e){throw qL(e)}}))}_getClientOptions(e){if(!this.client){const e=function(e){const{azureOpenAIApiDeploymentName:t,azureOpenAIApiInstanceName:a,azureOpenAIApiKey:n,azureOpenAIBasePath:i,baseURL:r,azureADTokenProvider:o,azureOpenAIEndpoint:s}=e;if((n||o)&&i&&t)return`${i}/${t}`;if((n||o)&&s&&t)return`${s}/openai/deployments/${t}`;if(n||o){if(!a)throw new Error("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");if(!t)throw new Error("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");return`https://${a}.openai.azure.com/openai/deployments/${t}`}return r}({azureOpenAIApiDeploymentName:this.azureOpenAIApiDeploymentName,azureOpenAIApiInstanceName:this.azureOpenAIApiInstanceName,azureOpenAIApiKey:this.azureOpenAIApiKey,azureOpenAIBasePath:this.azureOpenAIBasePath,baseURL:this.clientConfig.baseURL,azureOpenAIEndpoint:this.azureOpenAIEndpoint}),t={...this.clientConfig,baseURL:e,timeout:this.timeout,maxRetries:0};t.baseURL||delete t.baseURL,this.client=new Fz(t)}const t={...this.clientConfig,...e};return this.azureOpenAIApiKey&&(t.headers={"api-key":this.azureOpenAIApiKey,...t.headers},t.query={"api-version":this.azureOpenAIApiVersion,...t.query}),t}_llmType(){return"openai"}_combineLLMOutput(...e){return e.reduce(((e,t)=>(t&&t.tokenUsage&&(e.tokenUsage.completionTokens+=t.tokenUsage.completionTokens??0,e.tokenUsage.promptTokens+=t.tokenUsage.promptTokens??0,e.tokenUsage.totalTokens+=t.tokenUsage.totalTokens??0),e)),{tokenUsage:{completionTokens:0,promptTokens:0,totalTokens:0}})}withStructuredOutput(e,t){let a,n,i,r,o,s;if(!function(e){return void 0!==e&&"object"==typeof e.schema}(e)?(a=e,n=t?.name,i=t?.method,r=t?.includeRaw):(a=e.schema,n=e.name,i=e.method,r=e.includeRaw),void 0!==t?.strict&&"jsonMode"===i)throw new Error("Argument `strict` is only supported for `method` = 'function_calling'");if("jsonMode"===i)o=this.bind({response_format:{type:"json_object"}}),s=XL(a)?WR.fromZodSchema(a):new GR;else if("jsonSchema"===i)o=this.bind({response_format:{type:"json_schema",json_schema:{name:n??"extract",description:a.description,schema:a,strict:t?.strict}}}),s=XL(a)?WR.fromZodSchema(a):new GR;else{let e=n??"extract";if(XL(a)){const n=Gk(a);o=this.bind({tools:[{type:"function",function:{name:e,description:n.description,parameters:n}}],tool_choice:{type:"function",function:{name:e}},...void 0!==t?.strict?{strict:t.strict}:{}}),s=new rL({returnSingle:!0,keyName:e,zodSchema:a})}else{let n;"string"==typeof a.name&&"object"==typeof a.parameters&&null!=a.parameters?(n=a,e=a.name):(e=a.title??e,n={name:e,description:a.description??"",parameters:a}),o=this.bind({tools:[{type:"function",function:n}],tool_choice:{type:"function",function:{name:e}},...void 0!==t?.strict?{strict:t.strict}:{}}),s=new rL({returnSingle:!0,keyName:e})}}if(!r)return o.pipe(s);const l=eR.assign({parsed:(e,t)=>s.invoke(e.raw,t)}),c=eR.assign({parsed:()=>null}),u=l.withFallbacks({fallbacks:[c]});return dA.from([{raw:o},u])}}function XL(e){return"function"==typeof e?.parse}class QL extends SA{constructor({concurrency:e,...t}){super(e?{maxConcurrency:e,...t}:t),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","llms",this._llmType()]})}async invoke(e,t){const a=QL._convertInputToPromptValue(e);return(await this.generatePrompt([a],t,t?.callbacks)).generations[0][0].text}async*_streamResponseChunks(e,t,a){throw new Error("Not implemented.")}_separateRunnableConfigFromCallOptionsCompat(e){const[t,a]=super._separateRunnableConfigFromCallOptions(e);return a.signal=t.signal,[t,a]}async*_streamIterator(e,t){if(this._streamResponseChunks===QL.prototype._streamResponseChunks)yield this.invoke(e,t);else{const a=QL._convertInputToPromptValue(e),[n,i]=this._separateRunnableConfigFromCallOptionsCompat(t),r=await Nw.configure(n.callbacks,this.callbacks,n.tags,this.tags,n.metadata,this.metadata,{verbose:this.verbose}),o={options:i,invocation_params:this?.invocationParams(i),batch_size:1},s=await(r?.handleLLMStart(this.toJSON(),[a.toString()],n.runId,void 0,o,void 0,void 0,n.runName));let l=new uk({text:""});try{for await(const e of this._streamResponseChunks(a.toString(),i,s?.[0]))l=l?l.concat(e):e,"string"==typeof e.text&&(yield e.text)}catch(e){throw await Promise.all((s??[]).map((t=>t?.handleLLMError(e)))),e}await Promise.all((s??[]).map((e=>e?.handleLLMEnd({generations:[[l]]}))))}}async generatePrompt(e,t,a){const n=e.map((e=>e.toString()));return this.generate(n,t,a)}invocationParams(e){return{}}_flattenLLMResult(e){const t=[];for(let a=0;a<e.generations.length;a+=1){const n=e.generations[a];if(0===a)t.push({generations:[n],llmOutput:e.llmOutput});else{const a=e.llmOutput?{...e.llmOutput,tokenUsage:{}}:void 0;t.push({generations:[n],llmOutput:a})}}return t}async _generateUncached(e,t,a){const n=await Nw.configure(a.callbacks,this.callbacks,a.tags,this.tags,a.metadata,this.metadata,{verbose:this.verbose}),i={options:t,invocation_params:this?.invocationParams(t),batch_size:e.length},r=await(n?.handleLLMStart(this.toJSON(),e,a.runId,void 0,i,void 0,void 0,a?.runName));let o;if(!!r?.[0].handlers.find((e=>pk(e)||ik(e)))&&1===e.length&&this._streamResponseChunks!==QL.prototype._streamResponseChunks)try{const a=await this._streamResponseChunks(e[0],t,r?.[0]);let n;for await(const e of a)n=void 0===n?e:Qx(n,e);if(void 0===n)throw new Error("Received empty response from chat model call.");o={generations:[[n]],llmOutput:{}},await(r?.[0].handleLLMEnd(o))}catch(e){throw await(r?.[0].handleLLMError(e)),e}else{try{o=await this._generate(e,t,r?.[0])}catch(e){throw await Promise.all((r??[]).map((t=>t?.handleLLMError(e)))),e}const a=this._flattenLLMResult(o);await Promise.all((r??[]).map(((e,t)=>e?.handleLLMEnd(a[t]))))}const s=r?.map((e=>e.runId))||void 0;return Object.defineProperty(o,ck,{value:s?{runIds:s}:void 0,configurable:!0}),o}async _generateCached({prompts:e,cache:t,llmStringKey:a,parsedOptions:n,handledOptions:i,runId:r}){const o=await Nw.configure(i.callbacks,this.callbacks,i.tags,this.tags,i.metadata,this.metadata,{verbose:this.verbose}),s={options:n,invocation_params:this?.invocationParams(n),batch_size:e.length,cached:!0},l=await(o?.handleLLMStart(this.toJSON(),e,r,void 0,s,void 0,void 0,i?.runName)),c=[],u=await Promise.allSettled(e.map((async(e,n)=>{const i=await t.lookup(e,a);return null==i&&c.push(n),i}))),d=u.map(((e,t)=>({result:e,runManager:l?.[t]}))).filter((({result:e})=>"fulfilled"===e.status&&null!=e.value||"rejected"===e.status)),m=[];await Promise.all(d.map((async({result:e,runManager:t},a)=>{if("fulfilled"===e.status){const n=e.value;return m[a]=n,n.length&&await(t?.handleLLMNewToken(n[0].text)),t?.handleLLMEnd({generations:[n]})}return await(t?.handleLLMError(e.reason)),Promise.reject(e.reason)})));const h={generations:m,missingPromptIndices:c};return Object.defineProperty(h,ck,{value:l?{runIds:l?.map((e=>e.runId))}:void 0,configurable:!0}),h}async generate(e,t,a){if(!Array.isArray(e))throw new Error("Argument 'prompts' is expected to be a string[]");let n;n=Array.isArray(t)?{stop:t}:t;const[i,r]=this._separateRunnableConfigFromCallOptionsCompat(n);if(i.callbacks=i.callbacks??a,!this.cache)return this._generateUncached(e,r,i);const{cache:o}=this,s=this._getSerializedCacheKeyParametersForCall(r),{generations:l,missingPromptIndices:c}=await this._generateCached({prompts:e,cache:o,llmStringKey:s,parsedOptions:r,handledOptions:i,runId:i.runId});let u={};if(c.length>0){const t=await this._generateUncached(c.map((t=>e[t])),r,i);await Promise.all(t.generations.map((async(t,a)=>{const n=c[a];return l[n]=t,o.update(e[n],s,t)}))),u=t.llmOutput??{}}return{generations:l,llmOutput:u}}async call(e,t,a){const{generations:n}=await this.generate([e],t,a);return n[0][0].text}async predict(e,t,a){return this.call(e,t,a)}async predictMessages(e,t,a){const n=Df(e),i=await this.call(n,t,a);return new ff(i)}_identifyingParams(){return{}}serialize(){return{...this._identifyingParams(),_type:this._llmType(),_model:this._modelType()}}_modelType(){return"base_llm"}}class JL extends QL{async _generate(e,t,a){const n=await Promise.all(e.map(((e,n)=>this._call(e,{...t,promptIndex:n},a).then((e=>[{text:e}])))));return{generations:n}}}var eF=Object.freeze({__proto__:null,BaseLLM:QL,LLM:JL});var tF=Object.freeze({__proto__:null,chunkArray:(e,t)=>e.reduce(((e,a,n)=>{const i=Math.floor(n/t),r=e[i]||[];return e[i]=r.concat([a]),e}),[])});class aF{constructor(e){Object.defineProperty(this,"caller",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.caller=new ix(e??{})}}var nF=Object.freeze({__proto__:null,Embeddings:aF});class iF extends Error{constructor(e,t){let a=e??"";t?.lc_error_code&&(a=`${a}\n\nTroubleshooting URL: https://js.langchain.com/docs/troubleshooting/errors/${t.lc_error_code}/\n`),super(a),Object.defineProperty(this,"lc_error_code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.lc_error_code=t?.lc_error_code}}class rF extends iF{constructor(e,t){super(e,t),this.name="GraphRecursionError"}static get unminifiable_name(){return"GraphRecursionError"}}class oF extends iF{constructor(e,t){super(e,t),this.name="GraphValueError"}static get unminifiable_name(){return"GraphValueError"}}class sF extends iF{constructor(e,t){super(JSON.stringify(e,null,2),t),Object.defineProperty(this,"interrupts",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name="GraphInterrupt",this.interrupts=e??[]}static get unminifiable_name(){return"GraphInterrupt"}}class lF extends sF{constructor(e,t){super([{value:e,when:"during"}],t),this.name="NodeInterrupt"}static get unminifiable_name(){return"NodeInterrupt"}}function cF(e){return void 0!==e&&[sF.unminifiable_name,lF.unminifiable_name].includes(e.name)}class uF extends iF{constructor(e,t){super(e,t),this.name="EmptyInputError"}static get unminifiable_name(){return"EmptyInputError"}}class dF extends iF{constructor(e,t){super(e,t),this.name="EmptyChannelError"}static get unminifiable_name(){return"EmptyChannelError"}}class mF extends iF{constructor(e,t){super(e,t),this.name="InvalidUpdateError"}static get unminifiable_name(){return"InvalidUpdateError"}}class hF extends iF{constructor(e,t){super(e,t),this.name="MultipleSubgraphError"}static get unminifiable_name(){return"MultipleSubgraphError"}}const pF=()=>(void 0===globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]&&(globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]=new Set),globalThis[Symbol.for("LG_CHECKPOINT_SEEN_NS_SET")]);function gF(e){return ig({clockseq:e})}function fF(e,t){const a=t.replace(/-/g,"").match(/.{2}/g).map((e=>parseInt(e,16)));return eg(e,new Uint8Array(a))}const yF=[];var bF=Object.freeze({__proto__:null});class vF extends Sg{async addMessages(e){for(const t of e)await this.addMessage(t)}}class wF extends Sg{addUserMessage(e){return this.addMessage(new Sf(e))}addAIChatMessage(e){return this.addMessage(new ff(e))}addAIMessage(e){return this.addMessage(new ff(e))}async addMessages(e){for(const t of e)await this.addMessage(t)}clear(){throw new Error("Not implemented.")}}var xF=Object.freeze({__proto__:null,BaseChatMessageHistory:vF,BaseListChatMessageHistory:wF,InMemoryChatMessageHistory:class extends wF{constructor(e){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain","stores","message","in_memory"]}),Object.defineProperty(this,"messages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.messages=e??[]}async getMessages(){return this.messages}async addMessage(e){this.messages.push(e)}async clear(){this.messages=[]}}});let kF=class{constructor(e){Object.defineProperty(this,"pageContent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metadata",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.pageContent=void 0!==e.pageContent?e.pageContent.toString():"",this.metadata=e.metadata??{},this.id=e.id}};class AF extends sA{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","documents","transformers"]})}invoke(e,t){return this.transformDocuments(e)}}var SF=Object.freeze({__proto__:null,BaseDocumentTransformer:AF,Document:kF,MappingDocumentTransformer:class extends AF{async transformDocuments(e){const t=[];for(const a of e){const e=await this._transformDocument(a);t.push(e)}return t}}});class EF extends Sg{constructor(){super(...arguments),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","example_selectors","base"]})}}class _F{async getPromptAsync(e,t){return this.getPrompt(e).partial(t?.partialVariables??{})}}function CF(e){return e.split(/\n| /).length}class TF extends EF{constructor(e){super(e),Object.defineProperty(this,"examples",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"examplePrompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"getTextLength",{enumerable:!0,configurable:!0,writable:!0,value:CF}),Object.defineProperty(this,"maxLength",{enumerable:!0,configurable:!0,writable:!0,value:2048}),Object.defineProperty(this,"exampleTextLengths",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.examplePrompt=e.examplePrompt,this.maxLength=e.maxLength??2048,this.getTextLength=e.getTextLength??CF}async addExample(e){this.examples.push(e);const t=await this.examplePrompt.format(e);this.exampleTextLengths.push(this.getTextLength(t))}async calculateExampleTextLengths(e,t){if(e.length>0)return e;const{examples:a,examplePrompt:n}=t;return(await Promise.all(a.map((e=>n.format(e))))).map((e=>this.getTextLength(e)))}async selectExamples(e){const t=Object.values(e).join(" ");let a=this.maxLength-this.getTextLength(t),n=0;const i=[];for(;a>0&&n<this.examples.length;){const e=a-this.exampleTextLengths[n];if(e<0)break;i.push(this.examples[n]),a=e,n+=1}return i}static async fromExamples(e,t){const a=new TF(t);return await Promise.all(e.map((e=>a.addExample(e)))),a}}function PF(e){return Object.keys(e).sort().map((t=>e[t]))}class OF extends EF{constructor(e){if(super(e),Object.defineProperty(this,"vectorStoreRetriever",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleKeys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKeys",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.exampleKeys=e.exampleKeys,this.inputKeys=e.inputKeys,void 0!==e.vectorStore)this.vectorStoreRetriever=e.vectorStore.asRetriever({k:e.k??4,filter:e.filter});else{if(!e.vectorStoreRetriever)throw new Error('You must specify one of "vectorStore" and "vectorStoreRetriever".');this.vectorStoreRetriever=e.vectorStoreRetriever}}async addExample(e){const t=PF((this.inputKeys??Object.keys(e)).reduce(((t,a)=>({...t,[a]:e[a]})),{})).join(" ");await this.vectorStoreRetriever.addDocuments([new kF({pageContent:t,metadata:e})])}async selectExamples(e){const t=PF((this.inputKeys??Object.keys(e)).reduce(((t,a)=>({...t,[a]:e[a]})),{})).join(" "),a=(await this.vectorStoreRetriever.invoke(t)).map((e=>e.metadata));return this.exampleKeys?a.map((e=>this.exampleKeys.reduce(((t,a)=>({...t,[a]:e[a]})),{}))):a}static async fromExamples(e,t,a,n={}){const i=n.inputKeys??null,r=e.map((e=>PF(i?i.reduce(((t,a)=>({...t,[a]:e[a]})),{}):e).join(" "))),o=await a.fromTexts(r,e,t,n);return new OF({vectorStore:o,k:n.k??4,exampleKeys:n.exampleKeys,inputKeys:n.inputKeys})}}var DF=Object.freeze({__proto__:null,BaseExampleSelector:EF,BasePromptSelector:_F,ConditionalPromptSelector:class extends _F{constructor(e,t=[]){super(),Object.defineProperty(this,"defaultPrompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"conditionals",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.defaultPrompt=e,this.conditionals=t}getPrompt(e){for(const[t,a]of this.conditionals)if(t(e))return a;return this.defaultPrompt}},LengthBasedExampleSelector:TF,SemanticSimilarityExampleSelector:OF,isChatModel:function(e){return"base_chat_model"===e._modelType()},isLLM:function(e){return"base_llm"===e._modelType()}});const MF=(e,t)=>{if(void 0!==t)return e[t];const a=Object.keys(e);return 1===a.length?e[a[0]]:void 0};var IF=Object.freeze({__proto__:null,BaseMemory:class{},getInputValue:(e,t)=>{const a=MF(e,t);if(!a){const t=Object.keys(e);throw new Error(`input values have ${t.length} keys, you must specify an input key or pass only 1 key as input`)}return a},getOutputValue:(e,t)=>{const a=MF(e,t);if(!a&&""!==a){const t=Object.keys(e);throw new Error(`output values have ${t.length} keys, you must specify an output key or pass only 1 key as output`)}return a},getPromptInputKey:function(e,t){const a=Object.keys(e).filter((e=>!t.includes(e)&&"stop"!==e));if(1!==a.length)throw new Error(`One input key expected, but got ${a.length}`);return a[0]}});class NF extends sA{get lc_attributes(){return{partialVariables:void 0}}constructor(e){super(e),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"lc_namespace",{enumerable:!0,configurable:!0,writable:!0,value:["langchain_core","prompts",this._getPromptType()]}),Object.defineProperty(this,"inputVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"outputParser",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"partialVariables",{enumerable:!0,configurable:!0,writable:!0,value:void 0});const{inputVariables:t}=e;if(t.includes("stop"))throw new Error("Cannot have an input variable named 'stop', as it is used internally, please rename.");Object.assign(this,e)}async mergePartialAndUserVariables(e){const t=this.partialVariables??{},a={};for(const[e,n]of Object.entries(t))a[e]="string"==typeof n?n:await n();return{...a,...e}}async invoke(e,t){return this._callWithConfig((e=>this.formatPromptValue(e)),e,{...t,runType:"prompt"})}serialize(){throw new Error("Use .toJSON() instead")}static async deserialize(e){switch(e._type){case"prompt":{const{PromptTemplate:t}=await Promise.resolve().then((function(){return mB}));return t.deserialize(e)}case void 0:{const{PromptTemplate:t}=await Promise.resolve().then((function(){return mB}));return t.deserialize({...e,_type:"prompt"})}case"few_shot":{const{FewShotPromptTemplate:t}=await Promise.resolve().then((function(){return TB}));return t.deserialize(e)}default:throw new Error(`Invalid prompt type in config: ${e._type}`)}}}class jF extends NF{async formatPromptValue(e){const t=await this.format(e);return new Qw(t)}}
416
416
  /*!
417
417
  * mustache.js - Logic-less {{mustache}} templates with JavaScript