@arcgis/ai-components 5.1.0-next.101 → 5.1.0-next.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/{GER6EQYH.js → 25OJ5FXG.js} +1 -1
- package/dist/cdn/{5L7OZ37N.js → 2GGXJKQD.js} +1 -1
- package/dist/cdn/{457RLS3H.js → 5RPWGEUQ.js} +1 -1
- package/dist/cdn/5X5GJH2L.js +5 -0
- package/dist/cdn/{SZBOIYZZ.js → 7M7EPP5U.js} +1 -1
- package/dist/cdn/L6A7BGIF.js +281 -0
- package/dist/cdn/{D7WNBUVK.js → LOXY54T6.js} +1 -1
- package/dist/cdn/{ARCP5UZY.js → RUG4CKQX.js} +1 -1
- package/dist/cdn/{WNDUCHXU.js → TSIUD5CY.js} +1 -1
- package/dist/cdn/{YW52XJMM.js → XHPF5TWW.js} +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +7 -7
- package/dist/cdn/6ALN3KMA.js +0 -269
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as _,b as f}from"./EUNEQNYC.js";import{a as C}from"./O62HTIOD.js";import"./3QC3BRZP.js";import b from"./D7WNBUVK.js";import"./YW52XJMM.js";import{a as P}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as E,h as a,l as $,n,t as y,u as v,v as k,w as m,y as S}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([R,{whenOnce:O,watch:M,when:A},V,q,{property:d,subclass:z},{f:I}])=>{var j=E`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}`,H=Object.defineProperty,N=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?N(t,e):t,r=g.length-1,o;r>=0;r--)(o=g[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&H(t,e,s),s},l=class extends q{constructor(g){super(g),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await O(()=>!this.view.updating),this._set("orchestrator",await I.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([M(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(g,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[],i;try{let s=this.orchestrator.ask(g);for await(let r of s){let o=r.runId;if(t?.aborted){yield{type:"cancelled",runId:o};break}switch(r.type){case"trace":{this._set("processingStep",r.data.text),e.push(r.data.text);break}case"completed":{let c=r.result,p=!!c.content.length,b=!!i?.length;if(!p&&!b){yield{type:"completed",error:"Could not process the request.",log:e,runId:o};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:o};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:b}=r.interrupt,u=Array.isArray(b)?b.filter(L=>typeof L=="string"):[],x=(()=>{switch(c){case"booleanChoice":return{type:"boolean-choice",message:p,options:u};case"singleSelection":return{type:"single-select",message:p,options:u};case"multipleSelection":return{type:"multi-select",message:p,options:u};case"textInput":return{type:"text-input",message:p};default:return{type:c,message:p,options:u}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:x,runId:o};break}case"cancelled":{yield{type:"cancelled",runId:o};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:o};return}default:{console.warn("Unknown event type:",r);break}}}}catch(s){console.warn("Error during message processing:",s),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};h([d({readOnly:!0})],l.prototype,"orchestrator",2);h([d()],l.prototype,"agents",2);h([d()],l.prototype,"portal",2);h([d()],l.prototype,"view",2);h([d({readOnly:!0})],l.prototype,"loading",2);h([d({readOnly:!0})],l.prototype,"processing",2);h([d({readOnly:!0})],l.prototype,"processingStep",2);l=h([z("OrchestratorController")],l);var D="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",B="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",w=class extends k{constructor(){super(...arguments),this._messages=C({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=V.getDefault(),this.#i=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#a=t=>{t.stopPropagation();let e=t.detail;this.submitInterrupt(e)},this.#l=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this._inputValue="",this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#c=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#h=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this.#g=t=>{t.stopPropagation();let e=t.detail;this._inputValue=e.prompt,this.arcgisPromptSelect.emit(e)},this.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new R([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=n(),this.arcgisError=n(),this.arcgisFeedback=n(),this.arcgisInterrupt=n(),this.arcgisInterruptCancel=n(),this.arcgisInterruptSubmit=n(),this.arcgisPromptSelect=n(),this.arcgisReady=n(),this.arcgisSubmit=n(),this.arcgisSlottableRequest=n({bubbles:!1,composed:!1})}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_inputValue:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=j}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;#p;async#d(){try{let t=P(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new l({agents:e,portal:this.#r,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",$(this)(t),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#o.set(t.agent.id,t)}async submitMessage(t){let e=t.trim();if(!e||(this.messages.push({id:Date.now().toString(),role:"user",content:e}),!this._orchestratorController))return;let i=this._orchestratorController.ask(e,this.#s?.signal);for await(let s of i){let r=s.runId;switch(s.type){case"completed":this.messages.push({role:"assistant",content:s.response,blocks:s.blocks,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#g),this.#t.value?.addEventListener("arcgisSubmit",this.#l),this.#t.value?.addEventListener("arcgisCancel",this.#c),this.#t.value?.addEventListener("arcgisFeedback",this.#h);let t=A(()=>!!this._interrupt&&!!this.#e.value,()=>{let e=this.#e.value;e.removeEventListener("arcgisSubmit",this.#a),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#a,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>{this.#d().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#g),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#l),this.#t.value?.removeEventListener("arcgisCancel",this.#c),this.#t.value?.removeEventListener("arcgisFeedback",this.#h),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue=""}_renderEntryMessage(){return this._interrupt?a`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#e)}></arcgis-assistant-interrupt></slot>`:this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:a`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:a`<slot name=entry-message></slot>`}_renderErrorNotice(){return this._error?a`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===D?a`<div slot=message>${B}</div><calcite-link slot=link .href=${F} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:a`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?a`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}render(){return a`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?a`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p}><slot name=${_(t.id)??m} slot=${_(t.id)??m}>${t?.error?a`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${t.error}</div></calcite-notice>`:a`<arcgis-assistant-message-text .content=${t?.content}></arcgis-assistant-message-text>`}</slot>${t.blocks?.map((e,i)=>a`<slot name=${f(t.id,i)??m} slot=${f(t.id,i)??m}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:a`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} @click=${()=>{this.#n.value?.submitMessage()}} round>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};S("arcgis-assistant",w);return w},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",b)
|
|
2
|
+
import{a as _,b as f}from"./EUNEQNYC.js";import{a as C}from"./O62HTIOD.js";import"./3QC3BRZP.js";import b from"./LOXY54T6.js";import"./XHPF5TWW.js";import{a as P}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as E,h as a,l as $,n,t as y,u as v,v as k,w as m,y as S}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([R,{whenOnce:O,watch:M,when:A},V,q,{property:d,subclass:z},{f:I}])=>{var j=E`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}.footer-container{display:flex;flex-direction:column;flex:1 1 0;gap:var(--calcite-spacing-md)}.content-container{display:flex;flex-direction:column;flex:1 1 0;min-height:0;position:relative;overflow:auto}.suggested-prompts-container{display:flex;justify-content:center;width:100%}.suggested-prompts{display:block;padding:var(--calcite-spacing-md);max-width:100%;box-sizing:border-box}.error-notice{padding:var(--calcite-spacing-sm)}`,H=Object.defineProperty,N=Object.getOwnPropertyDescriptor,h=(g,t,e,i)=>{for(var s=i>1?void 0:i?N(t,e):t,r=g.length-1,o;r>=0;r--)(o=g[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&H(t,e,s),s},l=class extends q{constructor(g){super(g),this.view=null,this.loading=!1,this.processing=!1,this.processingStep=""}async load(){this._set("loading",!0);try{await this._initialize()}finally{this._set("loading",!1)}}destroy(){this.orchestrator?.dispose(),super.destroy()}async _initialize(){this.removeHandles(),await Promise.all([this.portal.load(),this.view?.when()]),this.view&&await O(()=>!this.view.updating),this._set("orchestrator",await I.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([M(()=>[this.view,this.agents],()=>{this._initialize()})])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(g,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[],i;try{let s=this.orchestrator.ask(g);for await(let r of s){let o=r.runId;if(t?.aborted){yield{type:"cancelled",runId:o};break}switch(r.type){case"trace":{this._set("processingStep",r.data.text),e.push(r.data.text);break}case"completed":{let c=r.result,p=!!c.content.length,b=!!i?.length;if(!p&&!b){yield{type:"completed",error:"Could not process the request.",log:e,runId:o};return}let u=c.content;this._set("processingStep",""),yield{type:"completed",response:u,blocks:i,log:e,runId:o};return}case"ux-suggestion":{let c=r.suggestion;i=i?[...i,c]:[c];break}case"interrupt":{let{kind:c,message:p,metadata:b}=r.interrupt,u=Array.isArray(b)?b.filter(L=>typeof L=="string"):[],x=(()=>{switch(c){case"booleanChoice":return{type:"boolean-choice",message:p,options:u};case"singleSelection":return{type:"single-select",message:p,options:u};case"multipleSelection":return{type:"multi-select",message:p,options:u};case"textInput":return{type:"text-input",message:p};default:return{type:c,message:p,options:u}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:x,runId:o};break}case"cancelled":{yield{type:"cancelled",runId:o};return}case"error":{yield{type:"completed",error:r.error.message,log:e,runId:o};return}default:{console.warn("Unknown event type:",r);break}}}}catch(s){console.warn("Error during message processing:",s),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};h([d({readOnly:!0})],l.prototype,"orchestrator",2);h([d()],l.prototype,"agents",2);h([d()],l.prototype,"portal",2);h([d()],l.prototype,"view",2);h([d({readOnly:!0})],l.prototype,"loading",2);h([d({readOnly:!0})],l.prototype,"processing",2);h([d({readOnly:!0})],l.prototype,"processingStep",2);l=h([z("OrchestratorController")],l);var D="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",B="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",w=class extends k{constructor(){super(...arguments),this._messages=C({blocking:!0}),this.#t=y(),this.#n=y(),this.#e=y(),this.#s=null,this.#o=new Map,this.#r=V.getDefault(),this.#i=t=>{t.stopPropagation(),this.cancelInterrupt()},this.#a=t=>{t.stopPropagation();let e=t.detail;this.submitInterrupt(e)},this.#l=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this._inputValue="",this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#c=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#h=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this.#g=t=>{t.stopPropagation();let e=t.detail;this._inputValue=e.prompt,this.arcgisPromptSelect.emit(e)},this.#p=t=>{this.arcgisSlottableRequest.emit(t.detail)},this._orchestratorController=null,this._interrupt=null,this._error=null,this._inputValue="",this.messages=new R([]),this.referenceElement=null,this.suggestedPrompts=[],this.feedbackEnabled=!1,this.keepSuggestedPrompts=!1,this.logEnabled=!1,this.copyEnabled=!1,this.voiceInputEnabled=!1,this.readAloudEnabled=!1,this.arcgisCancel=n(),this.arcgisError=n(),this.arcgisFeedback=n(),this.arcgisInterrupt=n(),this.arcgisInterruptCancel=n(),this.arcgisInterruptSubmit=n(),this.arcgisPromptSelect=n(),this.arcgisReady=n(),this.arcgisSubmit=n(),this.arcgisSlottableRequest=n({bubbles:!1,composed:!1})}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_inputValue:16,_user:16,awaitingResponse:32,awaitingResponseStep:32,interrupt:32,messages:0,orchestrator:32,entryMessage:1,heading:1,description:1,referenceElement:1,suggestedPrompts:0,feedbackEnabled:5,keepSuggestedPrompts:5,logEnabled:5,copyEnabled:5,voiceInputEnabled:5,readAloudEnabled:5}}static{this.styles=j}#t;#n;#e;#s;#o;#r;#i;#a;#l;#c;#h;#g;#p;async#d(){try{let t=P(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new l({agents:e,portal:this.#r,view:t?.view}),await this._orchestratorController.load(),!0):(this._error="No agents found.",!1)}catch(t){return this._error=t?.message??"Error initializing orchestrator.",$(this)(t),!1}}get _user(){return this.#r?.user?.fullName||this.#r?.user?.username}get awaitingResponse(){return this._orchestratorController?.processing??!1}get awaitingResponseStep(){return this._orchestratorController?.processingStep??""}get interrupt(){return this._interrupt}get orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}cancelInterrupt(){this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null}register(t){this.#o.set(t.agent.id,t)}async submitMessage(t){let e=t.trim();if(!e||(this.messages.push({id:Date.now().toString(),role:"user",content:e}),!this._orchestratorController))return;let i=this._orchestratorController.ask(e,this.#s?.signal);for await(let s of i){let r=s.runId;switch(s.type){case"completed":this.messages.push({role:"assistant",content:s.response,blocks:s.blocks,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r},this.arcgisInterrupt.emit(this._interrupt);break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}submitInterrupt(t){this.arcgisInterruptSubmit.emit(t),this.orchestrator?.resumeInterrupt(t),this._interrupt=null}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisPromptSelect",this.#g),this.#t.value?.addEventListener("arcgisSubmit",this.#l),this.#t.value?.addEventListener("arcgisCancel",this.#c),this.#t.value?.addEventListener("arcgisFeedback",this.#h);let t=A(()=>!!this._interrupt&&!!this.#e.value,()=>{let e=this.#e.value;e.removeEventListener("arcgisSubmit",this.#a),e.removeEventListener("arcgisCancel",this.#i),e.addEventListener("arcgisSubmit",this.#a,{once:!0}),e.addEventListener("arcgisCancel",this.#i,{once:!0})});return queueMicrotask(()=>{this.#d().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#t.value?.removeEventListener("arcgisPromptSelect",this.#g),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#l),this.#t.value?.removeEventListener("arcgisCancel",this.#c),this.#t.value?.removeEventListener("arcgisFeedback",this.#h),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null,this._inputValue=""}_renderEntryMessage(){return this._interrupt?a`<slot name=interrupt><arcgis-assistant-interrupt .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${v(this.#e)}></arcgis-assistant-interrupt></slot>`:this._error?this._renderErrorNotice():this.entryMessage?this.messages.length>0?null:a`<calcite-notice open kind=info closable icon width=full><div slot=message>${this.entryMessage}</div></calcite-notice>`:a`<slot name=entry-message></slot>`}_renderErrorNotice(){return this._error?a`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===D?a`<div slot=message>${B}</div><calcite-link slot=link .href=${F} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:a`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}_renderSuggestedPrompts(){return this.suggestedPrompts?.length?a`<div class="suggested-prompts-container"><arcgis-assistant-suggested-prompts class="suggested-prompts" .prompts=${this.suggestedPrompts}></arcgis-assistant-suggested-prompts></div>`:null}render(){return a`<calcite-panel .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} ${v(this.#t)}><slot name=header-actions-start slot=header-actions-start></slot><slot name=header-actions-end slot=header-actions-end></slot><div class="content-container"><arcgis-assistant-chat .loading=${this.awaitingResponse} .messages=${this.messages}><slot name=message-starter slot=message-starter></slot><slot name=messages slot=messages>${this.messages.map(t=>t.role==="assistant"?a`<arcgis-assistant-message .message=${t} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled} @arcgisSlottableRequest=${this.#p}><slot name=${_(t.id)??m} slot=${_(t.id)??m}>${t?.error?a`<calcite-notice class="error-notice" open icon kind=warning width=full><div slot=message>${t.error}</div></calcite-notice>`:a`<arcgis-assistant-message-text .content=${t?.content}></arcgis-assistant-message-text>`}</slot>${t.blocks?.map((e,i)=>a`<slot name=${f(t.id,i)??m} slot=${f(t.id,i)??m}><arcgis-assistant-message-block .block=${e}></arcgis-assistant-message-block></slot>`)}</arcgis-assistant-message>`:a`<arcgis-assistant-user-message .message=${t} .user=${this._user}></arcgis-assistant-user-message>`)}</slot><slot name=message-loading slot=message-loading><arcgis-assistant-message-loading .loading=${this.awaitingResponse} .loadingMessage=${this.awaitingResponseStep}></arcgis-assistant-message-loading></slot></arcgis-assistant-chat></div>${this._renderSuggestedPrompts()}<div class="footer-container" slot=footer>${this._renderEntryMessage()}<slot name=chat-entry><arcgis-assistant-chat-entry .awaitingResponse=${this.awaitingResponse} .inputValue=${this._inputValue} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${v(this.#n)}><slot name=entry-actions-start slot=entry-actions-start></slot><slot name=entry-actions-end slot=entry-actions-end><calcite-button .iconStart=${this.awaitingResponse?"circle-stop":"send"} @click=${()=>{this.#n.value?.submitMessage()}} round>${this.awaitingResponse?this._messages.stopButtonLabel:this._messages.askButtonLabel}</calcite-button></slot></arcgis-assistant-chat-entry></slot><slot name=footer-content></slot></div></calcite-panel>`}};S("arcgis-assistant",w);return w},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",b)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import c from"./
|
|
2
|
+
import c from"./L6A7BGIF.js";import b from"./LOXY54T6.js";import"./XHPF5TWW.js";import{a as r,c as a}from"./B4DEC7PH.js";import"./KVH3PDVW.js";import"./YGW7TUNX.js";import{v as s,y as e}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";export default $arcgis.t(([,{d:i}])=>{var t=class extends s{constructor(){super(...arguments),this.agent=i}static{this.properties={referenceElement:1}}#t;getContext(){if(!this.#t)throw new Error("arcgis-assistant-help-agent requires a mapView");return{mapView:this.#t}}load(){this.#t=r(this,"arcgis-assistant-help-agent"),a(this)}};e("arcgis-assistant-help-agent",t);return t},b,c)
|
|
@@ -18,7 +18,7 @@ Right ${t}`)}}var Lt=class GS extends ze{static isInstance(t){if(!super.isInstan
|
|
|
18
18
|
Please upgrade your packages to versions that set`,"message tool calls. e.g., `pnpm install @langchain/anthropic`,","pnpm install @langchain/openai`, etc."].join(" "));try{if(r!=null&&i===void 0){let[n,a]=_c(r);t.tool_calls=n??[],t.invalid_tool_calls=a??[]}else t.tool_calls=t.tool_calls??[],t.invalid_tool_calls=t.invalid_tool_calls??[]}catch{t.tool_calls=[],t.invalid_tool_calls=[]}if(t.response_metadata!==void 0&&"output_version"in t.response_metadata&&t.response_metadata.output_version==="v1"&&(t.contentBlocks=t.content,t.content=void 0),t.contentBlocks!==void 0){t.tool_calls&&t.contentBlocks.push(...t.tool_calls.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})));let n=t.contentBlocks.filter(a=>a.type==="tool_call").filter(a=>!t.tool_calls?.some(o=>o.id===a.id&&o.name===a.name));n.length>0&&(t.tool_calls=n.map(a=>({type:"tool_call",id:a.id,name:a.name,args:a.args})))}}super(t),typeof t!="string"&&(this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls),this.usage_metadata=t.usage_metadata}static lc_name(){return"AIMessage"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=yh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls){let t=this.tool_calls.filter(r=>!e.some(i=>i.id===r.id&&i.name===r.name));e.push(...t.map(r=>({type:"tool_call",id:r.id,name:r.name,args:r.args})))}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};function jo(e){return e._getType()==="ai"}function vc(e){return e._getType()==="ai"}var mt=class extends Lt{type="ai";tool_calls=[];invalid_tool_calls=[];tool_call_chunks=[];usage_metadata;constructor(e){let t;if(typeof e=="string"||Array.isArray(e))t={content:e,tool_calls:[],invalid_tool_calls:[],tool_call_chunks:[]};else if(e.tool_call_chunks===void 0||e.tool_call_chunks.length===0)t={...e,tool_calls:e.tool_calls??[],invalid_tool_calls:[],tool_call_chunks:[],usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0};else{let r=zl(e.tool_call_chunks??[]);t={...e,tool_call_chunks:r.tool_call_chunks,tool_calls:r.tool_calls,invalid_tool_calls:r.invalid_tool_calls,usage_metadata:e.usage_metadata!==void 0?e.usage_metadata:void 0}}super(t),this.tool_call_chunks=t.tool_call_chunks??this.tool_call_chunks,this.tool_calls=t.tool_calls??this.tool_calls,this.invalid_tool_calls=t.invalid_tool_calls??this.invalid_tool_calls,this.usage_metadata=t.usage_metadata}get lc_aliases(){return{...super.lc_aliases,tool_calls:"tool_calls",invalid_tool_calls:"invalid_tool_calls",tool_call_chunks:"tool_call_chunks",usage_metadata:"usage_metadata"}}static lc_name(){return"AIMessageChunk"}get contentBlocks(){if(this.response_metadata&&"output_version"in this.response_metadata&&this.response_metadata.output_version==="v1")return this.content;if(this.response_metadata&&"model_provider"in this.response_metadata&&typeof this.response_metadata.model_provider=="string"){let t=yh(this.response_metadata.model_provider);if(t)return t.translateContent(this)}let e=super.contentBlocks;if(this.tool_calls&&typeof this.content!="string"){let t=this.content.filter(r=>r.type==="tool_call").map(r=>r.id);for(let r of this.tool_calls)r.id&&!t.includes(r.id)&&e.push({...r,type:"tool_call",id:r.id,name:r.name,args:r.args})}return e}get _printableFields(){return{...super._printableFields,tool_calls:this.tool_calls,tool_call_chunks:this.tool_call_chunks,invalid_tool_calls:this.invalid_tool_calls,usage_metadata:this.usage_metadata}}concat(e){let t={content:Ct(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:jl(this.response_metadata,e.response_metadata),tool_call_chunks:[],tool_calls:[],id:this.id??e.id};if(this.tool_call_chunks!==void 0||e.tool_call_chunks!==void 0){let i=ki(this.tool_call_chunks,e.tool_call_chunks);i!==void 0&&i.length>0&&(t.tool_call_chunks=i)}if(this.tool_calls!==void 0||e.tool_calls!==void 0){let i=ki(this.tool_calls,e.tool_calls);i!==void 0&&i.length>0&&(t.tool_calls=i)}(this.usage_metadata!==void 0||e.usage_metadata!==void 0)&&(t.usage_metadata=Mo(this.usage_metadata,e.usage_metadata));let r=this.constructor;return new r(t)}static isInstance(e){return super.isInstance(e)&&e.type==="ai"}};var Wr=class dk extends ze{static lc_name(){return"ChatMessage"}type="generic";role;static _chatMessageClass(){return dk}constructor(t,r){(typeof t=="string"||Array.isArray(t))&&(t={content:t,role:r}),super(t),this.role=t.role}static isInstance(t){return super.isInstance(t)&&t.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}},va=class extends Lt{static lc_name(){return"ChatMessageChunk"}type="generic";role;constructor(e,t){(typeof e=="string"||Array.isArray(e))&&(e={content:e,role:t}),super(e),this.role=e.role}concat(e){let t=this.constructor;return new t({content:Ct(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),role:this.role,id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="generic"}get _printableFields(){return{...super._printableFields,role:this.role}}};function pk(e){return e._getType()==="generic"}function fk(e){return e._getType()==="generic"}var ba=class extends ze{static lc_name(){return"FunctionMessage"}type="function";name;constructor(e){super(e),this.name=e.name}},wa=class extends Lt{static lc_name(){return"FunctionMessageChunk"}type="function";concat(e){let t=this.constructor;return new t({content:Ct(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),name:this.name??"",id:this.id??e.id})}};function mk(e){return e._getType()==="function"}function hk(e){return e._getType()==="function"}var Ye=class extends ze{static lc_name(){return"HumanMessage"}type="human";constructor(e){super(e)}static isInstance(e){return super.isInstance(e)&&e.type==="human"}},xa=class extends Lt{static lc_name(){return"HumanMessageChunk"}type="human";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Ct(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="human"}};function gk(e){return e.getType()==="human"}function _k(e){return e.getType()==="human"}var qr=class extends ze{type="remove";id;constructor(e){super({...e,content:[]}),this.id=e.id}get _printableFields(){return{...super._printableFields,id:this.id}}static isInstance(e){return super.isInstance(e)&&e.type==="remove"}};var Bt=class Dl extends ze{static lc_name(){return"SystemMessage"}type="system";constructor(t){super(t)}concat(t){if(typeof t=="string")return new Dl({content:Ct(this.content,t),additional_kwargs:this.additional_kwargs,response_metadata:this.response_metadata,id:this.id,name:this.name});if(Dl.isInstance(t))return new Dl({content:Ct(this.content,t.content),additional_kwargs:{...this.additional_kwargs,...t.additional_kwargs},response_metadata:{...this.response_metadata,...t.response_metadata},id:this.id??t.id,name:this.name??t.name});throw new Error("Unexpected chunk type for system message")}static isInstance(t){return super.isInstance(t)&&t.type==="system"}},Qn=class extends Lt{static lc_name(){return"SystemMessageChunk"}type="system";constructor(e){super(e)}concat(e){let t=this.constructor;return new t({content:Ct(this.content,e.content),additional_kwargs:He(this.additional_kwargs,e.additional_kwargs),response_metadata:He(this.response_metadata,e.response_metadata),id:this.id??e.id})}static isInstance(e){return super.isInstance(e)&&e.type==="system"}};function yk(e){return e._getType()==="system"}function vk(e){return e._getType()==="system"}var bk=e=>e();function n4(e){return $i(e)?e:typeof e.id=="string"&&e.type==="function"&&typeof e.function=="object"&&e.function!==null&&"arguments"in e.function&&typeof e.function.arguments=="string"&&"name"in e.function&&typeof e.function.name=="string"?{id:e.id,args:JSON.parse(e.function.arguments),name:e.function.name,type:"tool_call"}:e}function i4(e){return typeof e=="object"&&e!=null&&e.lc===1&&Array.isArray(e.id)&&e.kwargs!=null&&typeof e.kwargs=="object"}function vh(e){let t,r;if(i4(e)){let i=e.id.at(-1);i==="HumanMessage"||i==="HumanMessageChunk"?t="user":i==="AIMessage"||i==="AIMessageChunk"?t="assistant":i==="SystemMessage"||i==="SystemMessageChunk"?t="system":i==="FunctionMessage"||i==="FunctionMessageChunk"?t="function":i==="ToolMessage"||i==="ToolMessageChunk"?t="tool":t="unknown",r=e.kwargs}else{let{type:i,...n}=e;t=i,r=n}if(t==="human"||t==="user")return new Ye(r);if(t==="ai"||t==="assistant"){let{tool_calls:i,...n}=r;if(!Array.isArray(i))return new Ie(r);let a=i.map(n4);return new Ie({...n,tool_calls:a})}else{if(t==="system")return new Bt(r);if(t==="developer")return new Bt({...r,additional_kwargs:{...r.additional_kwargs,__openai_role__:"developer"}});if(t==="tool"&&"tool_call_id"in r)return new Ft({...r,content:r.content,tool_call_id:r.tool_call_id,name:r.name});if(t==="remove"&&"id"in r&&typeof r.id=="string")return new qr({...r,id:r.id});throw Xn(new Error(`Unable to coerce message from array: only human, AI, system, developer, or tool message coercion is currently supported.
|
|
19
19
|
|
|
20
20
|
Received: ${JSON.stringify(e,null,2)}`),"MESSAGE_COERCION_FAILURE")}}function xt(e){if(typeof e=="string")return new Ye(e);if(Je(e))return e;if(Array.isArray(e)){let[t,r]=e;return vh({type:t,content:r})}else if(Ml(e)){let{role:t,...r}=e;return vh({...r,type:t})}else return vh(e)}function a4(e){if(typeof e=="string")return e;switch(e.type){case"text":return e.text??"";case"text-plain":return e.text??"[text-plain file]";case"image":case"image_url":return"[image]";case"audio":case"input_audio":return"[audio]";case"video":return"[video]";case"file":return"[file]";case"reasoning":case"tool_call":case"tool_call_chunk":case"invalid_tool_call":case"server_tool_call":case"server_tool_call_chunk":case"server_tool_call_result":case"non_standard":return"";default:return e.type?`[${e.type}]`:""}}function zo(e,t="Human",r="AI"){let i=[];for(let n of e){let a;if(n.type==="human")a=t;else if(n.type==="ai")a=r;else if(n.type==="system")a="System";else if(n.type==="tool")a="Tool";else if(n.type==="generic")a=n.role;else throw new Error(`Got unsupported message type: ${n.type}`);let o=n.name?`${n.name}, `:"",s=typeof n.content=="string"?n.content:Array.isArray(n.content)?n.content.map(a4).filter(Boolean).join(""):"",c=`${a}: ${o}${s}`;if(n.type==="ai"){let u=n;u.tool_calls&&u.tool_calls.length>0?c+=JSON.stringify(u.tool_calls):u.additional_kwargs&&"function_call"in u.additional_kwargs&&(c+=JSON.stringify(u.additional_kwargs.function_call))}i.push(c)}return i.join(`
|
|
21
|
-
`)}function o4(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function bc(e){let t=o4(e);switch(t.type){case"human":return new Ye(t.data);case"ai":return new Ie(t.data);case"system":return new Bt(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new ba(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new Ft(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new Wr(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function wk(e){return e.map(bc)}function xk(e){return e.map(t=>t.toDict())}function Sa(e){let t=e._getType();if(t==="human")return new xa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new mt({...r})}else{if(t==="system")return new Qn({...e});if(t==="function")return new wa({...e});if(Wr.isInstance(e))return new va({...e});throw new Error("Unknown message type.")}}function zl(e){let t=e.reduce((n,a)=>{let o=n.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?n[o].push(a):n.push([a]),n},[]),r=[],i=[];for(let n of t){let a=null,o=n[0]?.name??"",s=n.map(l=>l.args||"").join("").trim(),c=s.length?s:"{}",u=n[0]?.id;try{if(a=kn(c),!u||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:o,args:a,id:u,type:"tool_call"})}catch{i.push({name:o,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var Sk=I({BaseCache:()=>$k,InMemoryCache:()=>bh,defaultHashKeyEncoder:()=>kk,deserializeStoredGeneration:()=>s4,serializeGeneration:()=>c4}),kk=(...e)=>Oo(e.join("_"));function s4(e){return e.message!==void 0?{text:e.text,message:bc(e.message)}:{text:e.text}}function c4(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var $k=class{keyEncoder=kk;makeDefaultKeyEncoder(e){this.keyEncoder=e}},u4=new Map,bh=class Ek extends $k{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new Ek(u4)}};var Ik=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function l4(e){return typeof e=="string"&&Ik.test(e)}var Ei=l4;function d4(e){if(!Ei(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var wh=d4;var St=[];for(let e=0;e<256;++e)St.push((e+256).toString(16).slice(1));function Do(e,t=0){return(St[e[t+0]]+St[e[t+1]]+St[e[t+2]]+St[e[t+3]]+"-"+St[e[t+4]]+St[e[t+5]]+"-"+St[e[t+6]]+St[e[t+7]]+"-"+St[e[t+8]]+St[e[t+9]]+"-"+St[e[t+10]]+St[e[t+11]]+St[e[t+12]]+St[e[t+13]]+St[e[t+14]]+St[e[t+15]]).toLowerCase()}var xh,p4=new Uint8Array(16);function Uo(){if(!xh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");xh=crypto.getRandomValues.bind(crypto)}return xh(p4)}function f4(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Tk="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ck="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Sh(e,t,r,i,n,a){let o=typeof r=="string"?f4(r):r,s=typeof i=="string"?wh(i):i;if(typeof i=="string"&&(i=wh(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){a=a||0;for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Do(c)}var m4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kh={randomUUID:m4};function h4(e,t,r){if(kh.randomUUID&&!t&&!e)return kh.randomUUID();e=e||{};let i=e.random??e.rng?.()??Uo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Do(i)}var $h=h4;function g4(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Eh(e,t){return e<<t|e>>>32-t}function _4(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/Math.pow(2,32),o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Eh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],p=r[3],f=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),v=Eh(u,5)+g4(g,l,d,p)+f+t[g]+c[m]>>>0;f=p,p=d,d=Eh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+p>>>0,r[4]=r[4]+f>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Ok=_4;function Ih(e,t,r,i){return Sh(80,Ok,e,t,r,i)}Ih.DNS=Tk;Ih.URL=Ck;var Ul=Ih;var Th={};function y4(e,t,r){let i;if(e)i=Ak(e.random??e.rng?.()??Uo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Uo();v4(Th,n,a),i=Ak(a,Th.msecs,Th.seq,t,r)}return t??Do(i)}function v4(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Ak(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Or=y4;var Pk=I({BaseCallbackHandler:()=>Xr,callbackHandlerPrefersStreaming:()=>wc,isBaseCallbackHandler:()=>Ch}),w4=class{};function wc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}var Xr=class extends w4{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Co(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Ut("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return at.prototype.toJSON.call(this)}toJSONNotImplemented(){return at.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Xr{name=Or();constructor(){super(),Object.assign(this,e)}}return new t}},Ch=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var Nk=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function x4(e){return typeof e=="string"&&Nk.test(e)}var xc=x4;function S4(e){if(!xc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Ll=S4;var kt=[];for(let e=0;e<256;++e)kt.push((e+256).toString(16).slice(1));function Lo(e,t=0){return(kt[e[t+0]]+kt[e[t+1]]+kt[e[t+2]]+kt[e[t+3]]+"-"+kt[e[t+4]]+kt[e[t+5]]+"-"+kt[e[t+6]]+kt[e[t+7]]+"-"+kt[e[t+8]]+kt[e[t+9]]+"-"+kt[e[t+10]]+kt[e[t+11]]+kt[e[t+12]]+kt[e[t+13]]+kt[e[t+14]]+kt[e[t+15]]).toLowerCase()}var k4=new Uint8Array(16);function Fo(){return crypto.getRandomValues(k4)}function $4(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():E4(e,t,r)}function E4(e,t,r){e=e||{};let i=e.random??e.rng?.()??Fo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Lo(i)}var ka=$4;function I4(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Oh(e,t){return e<<t|e>>>32-t}function T4(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Oh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],p=r[3],f=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),v=Oh(u,5)+I4(g,l,d,p)+f+t[g]+c[m]>>>0;f=p,p=d,d=Oh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+p>>>0,r[4]=r[4]+f>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Rk=T4;function C4(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Ah="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ph="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Nh(e,t,r,i,n,a){let o=typeof r=="string"?C4(r):r,s=typeof i=="string"?Ll(i):i;if(typeof i=="string"&&(i=Ll(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Lo(c)}function Rh(e,t,r,i){return Nh(80,Rk,e,t,r,i)}Rh.DNS=Ah;Rh.URL=Ph;var Mh=Rh;var jh={};function O4(e,t,r){let i;if(e)i=Mk(e.random??e.rng?.()??Fo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Fo();A4(jh,n,a),i=Mk(a,jh.msecs,jh.seq,t,r)}return t??Lo(i)}function A4(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Mk(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Bo=O4;var jk="gen_ai.operation.name",zk="gen_ai.system",zh="gen_ai.request.model",Dk="gen_ai.response.model",Dh="gen_ai.usage.input_tokens",Uh="gen_ai.usage.output_tokens",Lh="gen_ai.usage.total_tokens",Uk="gen_ai.request.max_tokens",Lk="gen_ai.request.temperature",Fk="gen_ai.request.top_p",Bk="gen_ai.request.frequency_penalty",Zk="gen_ai.request.presence_penalty",Vk="gen_ai.response.finish_reasons",Gk="gen_ai.prompt",Hk="gen_ai.completion",Jk="gen_ai.request.extra_query",Kk="gen_ai.request.extra_body",Wk="gen_ai.serialized.name",qk="gen_ai.serialized.signature",Xk="gen_ai.serialized.doc",Yk="gen_ai.response.id",Qk="gen_ai.response.service_tier",e$="gen_ai.response.system_fingerprint",t$="gen_ai.usage.input_token_details",r$="gen_ai.usage.output_token_details",n$="langsmith.trace.session_id",i$="langsmith.trace.session_name",a$="langsmith.span.kind",o$="langsmith.trace.name",s$="langsmith.metadata",Fh="langsmith.span.tags";var c$="langsmith.request.streaming",u$="langsmith.request.headers";var R4=(...e)=>fetch(...e),M4,l$=Symbol.for("ls:fetch_implementation");var d$=()=>globalThis[l$]===void 0?!0:M4??!1,p$=e=>async(...t)=>{if(e||Me("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[l$]??R4)(...t);return(e||Me("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Sc=()=>Me("PROJECT")??gr("LANGCHAIN_SESSION")??"default";var f$={};function $a(e){f$[e]||(console.warn(e),f$[e]=!0)}var N=e=>BigInt(e),_$=N("0x9E3779B1"),y$=N("0x85EBCA77"),j4=N("0xC2B2AE3D"),Ii=N("0x9E3779B185EBCA87"),Ea=N("0xC2B2AE3D27D4EB4F"),v$=N("0x165667B19E3779F9"),Gh=N("0x85EBCA77C2B2AE63"),z4=N("0x27D4EB2F165667C5"),D4=N("0x165667919E3779F9"),U4=N("0x9FB21C651E98DF25");function L4(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var $n=L4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Vo=(N(1)<<N(128))-N(1),me=(N(1)<<N(64))-N(1),Vl=(N(1)<<N(32))-N(1),ei=64,b$=ei/8,F4=8,Fl=4;function De(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Ve(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Zo(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function Bh(e,t=0){return e[t]}var B4=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),Z4=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),V4=(e,t)=>(e&Vl)*(t&Vl)&me,Go=e=>{if(!e)throw new Error("Assert failed")};function G4(e,t){return(e<<t|e>>N(32)-t)&Vl}function w$(e,t,r){for(let i=0;i<b$;i++){let n=Ve(t,i*8),a=n^Ve(r,i*8);e[i^1]+=n,e[i]+=V4(a,a>>N(32))}return e}function m$(e,t,r,i){for(let n=0;n<i;n++)w$(e,De(t,n*ei),De(r,n*8));return e}function H4(e,t){for(let r=0;r<b$;r++){let i=Ve(t,r*8),n=e[r];n=Zh(n,N(47)),n^=i,n*=_$,e[r]=n&me}return e}function Bl(e,t){return x$(e[0]^Ve(t,0),e[1]^Ve(t,F4))}function h$(e,t,r){let i=r;return i+=Bl(e.slice(0),De(t,0*Fl)),i+=Bl(e.slice(2),De(t,4*Fl)),i+=Bl(e.slice(4),De(t,8*Fl)),i+=Bl(e.slice(6),De(t,12*Fl)),En(i&me)}function J4(e,t,r,i,n){let a=Math.floor((r.byteLength-ei)/8),o=ei*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=m$(e,De(t,c*o),r,a),e=n(e,De(r,r.byteLength-ei));{let c=Math.floor((t.byteLength-1-o*s)/ei);e=m$(e,De(t,s*o),r,c),e=i(e,De(t,t.byteLength-ei),De(r,r.byteLength-ei-7))}return e}function K4(e,t,r){let i=new BigUint64Array([j4,Ii,Ea,v$,Gh,y$,z4,_$]);Go(e.length>128),i=J4(i,e,t,w$,H4),Go(i.length*8==64);{let n=h$(i,De(t,11),N(e.byteLength)*Ii&me);return h$(i,De(t,t.byteLength-ei-11),~(N(e.byteLength)*Ea)&me)<<N(64)|n}}function x$(e,t){let r=e*t&Vo;return r&me^r>>N(64)}function g$(e,t,r){return x$((Ve(e,0)^Ve(t,0)+r)&me,(Ve(e,8)^Ve(t,8)-r)&me)}function Zl(e,t,r,i,n){let a=e&me,o=e>>N(64)&me;return a+=g$(t,i,n),a^=Ve(r,0)+Ve(r,8),a&=me,o+=g$(r,De(i,16),n),o^=Ve(t,0)+Ve(t,8),o&=me,o<<N(64)|a}function En(e){return e^=e>>N(37),e*=D4,e&=me,e^=e>>N(32),e}function Gl(e){return e^=e>>N(33),e*=Ea,e&=me,e^=e>>N(29),e*=v$,e&=me,e^=e>>N(32),e}function W4(e,t,r){let i=e.byteLength;Go(i>0&&i<=3);let n=N(Bh(e,i-1))|N(i<<8)|N(Bh(e,0)<<16)|N(Bh(e,i>>1)<<24),a=(N(Zo(t,0))^N(Zo(t,4)))+r,o=(n^a)&me,s=(N(Zo(t,8))^N(Zo(t,12)))-r,c=(G4(Z4(n),N(13))^s)&me;return(Gl(c)&me)<<N(64)|Gl(o)}function Zh(e,t){return e^e>>t}function q4(e,t,r){let i=e.byteLength;Go(i>=4&&i<=8);{let n=Zo(e,0),a=Zo(e,i-4),o=N(n)|N(a)<<N(32),s=(Ve(t,16)^Ve(t,24))+r&me,u=(o^s)*(Ii+(N(i)<<N(2)))&Vo;return u+=(u&me)<<N(65),u&=Vo,u^=u>>N(67),Zh(Zh(u&me,N(35))*U4&me,N(28))|En(u>>N(64))<<N(64)}}function X4(e,t,r){let i=e.byteLength;Go(i>=9&&i<=16);{let n=(Ve(t,32)^Ve(t,40))+r&me,a=(Ve(t,48)^Ve(t,56))-r&me,o=Ve(e),s=Ve(e,i-8),c=(o^s^n)*Ii,u=(c&me)+(N(i-1)<<N(54));c=c&(Vo^me)|u,s^=a,c+=s+(s&Vl)*(y$-N(1))<<N(64),c&=Vo,c^=B4(c>>N(64));let l=(c&me)*Ea;return l+=(c>>N(64))*Ea<<N(64),l&=Vo,En(l&me)|En(l>>N(64))<<N(64)}}function Y4(e,t){let r=e.byteLength;return Go(r<=16),r>8?X4(e,$n,t):r>=4?q4(e,$n,t):r>0?W4(e,$n,t):Gl(t^Ve($n,64)^Ve($n,72))|Gl(t^Ve($n,80)^Ve($n,88))<<N(64)}function Vh(e){return~e+N(1)&me}function Q4(e,t,r){let i=N(e.byteLength)*Ii&me,n=N(e.byteLength-1)/N(32);for(;n>=0;){let s=Number(n);i=Zl(i,De(e,16*s),De(e,e.byteLength-16*(s+1)),De(t,32*s),r),n--}let a=i+(i>>N(64))&me;a=En(a);let o=(i&me)*Ii+(i>>N(64))*Gh+(N(e.byteLength)-r&me)*Ea;return o&=me,o=Vh(En(o)),a|o<<N(64)}function eM(e,t,r){let i=N(e.byteLength)*Ii&me;for(let o=32;o<160;o+=32)i=Zl(i,De(e,o-32),De(e,o-16),De(t,o-32),r);i=En(i&me)|En(i>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)i=Zl(i,De(e,o-32),De(e,o-16),De(t,3+o-160),r);i=Zl(i,De(e,e.byteLength-16),De(e,e.byteLength-32),De(t,103),Vh(r));let n=i+(i>>N(64))&me;n=En(n);let a=(i&me)*Ii+(i>>N(64))*Gh+(N(e.byteLength)-r&me)*Ea;return a&=me,a=Vh(En(a)),n|a<<N(64)}function S$(e,t=N(0)){let r=e.byteLength;return r<=16?Y4(e,t):r<=128?Q4(e,$n,t):r<=240?eM(e,$n,t):K4(e,$n,t)}function k$(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&me,n=e>>N(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var $$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function le(e,t){if(!$$.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Hl(e){let t=typeof e=="string"?Date.parse(e):e;return Bo({msecs:t,seq:0})}function tM(e){if(!$$.test(e))return null;let t=e[14];return parseInt(t,16)}function rM(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function nM(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var iM=new TextEncoder;function aM(e){let t=iM.encode(e),r=S$(t);return k$(r)}function kc(e,t){let r=`${e}:${t}`,i=aM(r),n=new Uint8Array(16);if(tM(e)===7){let o=rM(e);n.set(o.slice(0,6),0)}else{let o=Date.now();n[0]=o/1099511627776&255,n[1]=o/4294967296&255,n[2]=o/16777216&255,n[3]=o/65536&255,n[4]=o/256&255,n[5]=o&255}return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),nM(n)}var $c={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function E$(e){}async function I$(e,t){}async function T$(e){return[]}async function C$(e){return{size:0}}function Jl(e){return!1}function O$(e){return""}function sM(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Kl=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let i=$c.dirname(t);Jl(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw Jl(n)&&void 0,a}}load(t){if(!Jl(t))return 0;let r;try{let a=O$(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:n};this.cache.set(a,s),i+=1}return i}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,i]of this.cache.entries())sM(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},Wl=new Kl;var ql="0.5.25";var Tn,cM=()=>typeof window<"u"&&typeof window.document<"u",uM=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",lM=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),N$=()=>typeof Deno<"u",dM=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!N$(),Kh=()=>Tn||(typeof Bun<"u"?Tn="bun":cM()?Tn="browser":dM()?Tn="node":uM()?Tn="webworker":lM()?Tn="jsdom":N$()?Tn="deno":Tn="other",Tn),Hh;function Xl(){if(Hh===void 0){let e=Kh(),t=fM();Hh={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:ql,...t}}return Hh}function Wh(){let e=pM(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!i.toLowerCase().includes("key")&&!i.toLowerCase().includes("secret")&&!i.toLowerCase().includes("token")&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function pM(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function gr(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Me(e){return gr(`LANGSMITH_${e}`)||gr(`LANGCHAIN_${e}`)}var Jh;function fM(){if(Jh!==void 0)return Jh;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let i=gr(r);i!==void 0&&(t[r]=i)}return Jh=t,t}function A$(){return gr("OTEL_ENABLED")==="true"||Me("OTEL_ENABLED")==="true"}var P$=new Set(["langsmith","otel"]);function Yl(e){if(e!==void 0)return e;let t=Me("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!P$.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...P$].sort().join(", ")}`);return A$()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return A$()?"otel":"langsmith"}var Yh=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&Yl()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},Qh=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new Yh})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},eg=class{active(){return{}}with(t,r){return r()}},qh=Symbol.for("ls:otel_trace"),Xh=Symbol.for("ls:otel_context"),R$=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),mM=new Qh,hM=new eg,tg=class{getTraceInstance(){return globalThis[qh]??mM}getContextInstance(){return globalThis[Xh]??hM}initializeGlobalInstances(t){globalThis[qh]===void 0&&(globalThis[qh]=t.trace),globalThis[Xh]===void 0&&(globalThis[Xh]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[R$]=t}getDefaultOTLPTracerComponents(){return globalThis[R$]??void 0}},rg=new tg;function Ql(){return rg.getTraceInstance()}function M$(){return rg.getContextInstance()}function j$(){return rg.getDefaultOTLPTracerComponents()}var gM={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function _M(e){return gM[e]||e}var ed=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&Ql().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(a$,r.run_type);let s=_M(r.run_type||"chain");t.setAttribute(jk,s)}"name"in r&&r.name&&t.setAttribute(o$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(n$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(i$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(zh,n),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(Dh,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(Uh,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(Lh,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${s$}.${s}`,String(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(Fh,o.join(", ")):o&&t.setAttribute(Fh,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(Wk,String(s.name)),s.signature&&t.setAttribute(qk,String(s.signature)),s.doc&&t.setAttribute(Xk,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let a=n.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?i="anthropic":a.includes("bedrock")?i="aws.bedrock":a.includes("azure")&&a.includes("openai")?i="az.ai.openai":a.includes("azure")&&a.includes("inference")?i="az.ai.inference":a.includes("cohere")?i="cohere":a.includes("deepseek")?i="deepseek":a.includes("gemini")?i="gemini":a.includes("groq")?i="groq":a.includes("watson")||a.includes("ibm")?i="ibm.watsonx.ai":a.includes("mistral")?i="mistral_ai":a.includes("gpt")||a.includes("openai")?i="openai":a.includes("perplexity")||a.includes("sonar")?i="perplexity":a.includes("vertex")?i="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(i="xai")}t.setAttribute(zk,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(Uk,i.max_tokens),i.temperature!==void 0&&t.setAttribute(Lk,i.temperature),i.top_p!==void 0&&t.setAttribute(Fk,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(Bk,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute(Zk,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(zh,i.model),i.stream!==void 0&&t.setAttribute(c$,i.stream),i.extra_headers&&t.setAttribute(u$,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(Jk,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(Kk,JSON.stringify(i.extra_body))),t.setAttribute(Gk,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(Dh,n[0]),t.setAttribute(Uh,n[1]),t.setAttribute(Lh,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(Dk,String(i.model)),i.id&&t.setAttribute(Yk,i.id),i.choices&&Array.isArray(i.choices)){let a=i.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(Vk,a.join(", "))}if(i.service_tier&&t.setAttribute(Qk,i.service_tier),i.system_fingerprint&&t.setAttribute(e$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;a.input_token_details&&t.setAttribute(t$,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(r$,JSON.stringify(a.output_token_details))}}t.setAttribute(Hk,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let o of i){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let n=t.generations||[];if(!Array.isArray(n))return null;let a=Array.isArray(n[0])?n.flat():n;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var yM=Object.prototype.toString,vM=e=>yM.call(e)==="[object Error]",bM=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function ng(e){if(!(e&&vM(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:bM.has(r)}function wM(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function td(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var ig=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function xM(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function z$(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function SM({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof ig)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),z$(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=z$(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!ng(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=xM(r,n),p=Math.min(d,l);return p>0&&await new Promise((f,m)=>{let g=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",g),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",g),f()},p);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",g,{once:!0})}),n.signal?.throwIfAborted(),!0}async function ag(e,t={}){if(t={...t},wM(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,td("factor",t.factor,{min:0,allowInfinity:!1}),td("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),td("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),td("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await SM({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var sd=da(od(),1),J$="default"in sd.default?sd.default.default:sd.default;var PM=[408,425,429,500,502,503,504],Ic=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new J$({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let a=this.onFailedResponseHook,o=this.queue.add(()=>ag(()=>r(...i).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let u="response"in s?s.response:void 0;if(a&&await a(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!PM.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function pg(e){return typeof e?._getType=="function"}function fg(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function ud(e){return`Invalid prompt identifier format: "${e}". Expected one of:
|
|
21
|
+
`)}function o4(e){if(e.data!==void 0)return e;{let t=e;return{type:t.type,data:{content:t.text,role:t.role,name:void 0,tool_call_id:void 0}}}}function bc(e){let t=o4(e);switch(t.type){case"human":return new Ye(t.data);case"ai":return new Ie(t.data);case"system":return new Bt(t.data);case"function":if(t.data.name===void 0)throw new Error("Name must be defined for function messages");return new ba(t.data);case"tool":if(t.data.tool_call_id===void 0)throw new Error("Tool call ID must be defined for tool messages");return new Ft(t.data);case"generic":if(t.data.role===void 0)throw new Error("Role must be defined for chat messages");return new Wr(t.data);default:throw new Error(`Got unexpected type: ${t.type}`)}}function wk(e){return e.map(bc)}function xk(e){return e.map(t=>t.toDict())}function Sa(e){let t=e._getType();if(t==="human")return new xa({...e});if(t==="ai"){let r={...e};return"tool_calls"in r&&(r={...r,tool_call_chunks:r.tool_calls?.map(i=>({...i,type:"tool_call_chunk",index:void 0,args:JSON.stringify(i.args)}))}),new mt({...r})}else{if(t==="system")return new Qn({...e});if(t==="function")return new wa({...e});if(Wr.isInstance(e))return new va({...e});throw new Error("Unknown message type.")}}function zl(e){let t=e.reduce((n,a)=>{let o=n.findIndex(([s])=>"id"in a&&a.id&&"index"in a&&a.index!==void 0?a.id===s.id&&a.index===s.index:"id"in a&&a.id?a.id===s.id:"index"in a&&a.index!==void 0?a.index===s.index:!1);return o!==-1?n[o].push(a):n.push([a]),n},[]),r=[],i=[];for(let n of t){let a=null,o=n[0]?.name??"",s=n.map(l=>l.args||"").join("").trim(),c=s.length?s:"{}",u=n[0]?.id;try{if(a=kn(c),!u||a===null||typeof a!="object"||Array.isArray(a))throw new Error("Malformed tool call chunk args.");r.push({name:o,args:a,id:u,type:"tool_call"})}catch{i.push({name:o,args:c,id:u,error:"Malformed args.",type:"invalid_tool_call"})}}return{tool_call_chunks:e,tool_calls:r,invalid_tool_calls:i}}var Sk=I({BaseCache:()=>$k,InMemoryCache:()=>bh,defaultHashKeyEncoder:()=>kk,deserializeStoredGeneration:()=>s4,serializeGeneration:()=>c4}),kk=(...e)=>Oo(e.join("_"));function s4(e){return e.message!==void 0?{text:e.text,message:bc(e.message)}:{text:e.text}}function c4(e){let t={text:e.text};return e.message!==void 0&&(t.message=e.message.toDict()),t}var $k=class{keyEncoder=kk;makeDefaultKeyEncoder(e){this.keyEncoder=e}},u4=new Map,bh=class Ek extends $k{cache;constructor(t){super(),this.cache=t??new Map}lookup(t,r){return Promise.resolve(this.cache.get(this.keyEncoder(t,r))??null)}async update(t,r,i){this.cache.set(this.keyEncoder(t,r),i)}static global(){return new Ek(u4)}};var Ik=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function l4(e){return typeof e=="string"&&Ik.test(e)}var Ei=l4;function d4(e){if(!Ei(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var wh=d4;var St=[];for(let e=0;e<256;++e)St.push((e+256).toString(16).slice(1));function Do(e,t=0){return(St[e[t+0]]+St[e[t+1]]+St[e[t+2]]+St[e[t+3]]+"-"+St[e[t+4]]+St[e[t+5]]+"-"+St[e[t+6]]+St[e[t+7]]+"-"+St[e[t+8]]+St[e[t+9]]+"-"+St[e[t+10]]+St[e[t+11]]+St[e[t+12]]+St[e[t+13]]+St[e[t+14]]+St[e[t+15]]).toLowerCase()}var xh,p4=new Uint8Array(16);function Uo(){if(!xh){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");xh=crypto.getRandomValues.bind(crypto)}return xh(p4)}function f4(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Tk="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ck="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Sh(e,t,r,i,n,a){let o=typeof r=="string"?f4(r):r,s=typeof i=="string"?wh(i):i;if(typeof i=="string"&&(i=wh(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a=a||0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Do(c)}var m4=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),kh={randomUUID:m4};function h4(e,t,r){if(kh.randomUUID&&!t&&!e)return kh.randomUUID();e=e||{};let i=e.random??e.rng?.()??Uo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Do(i)}var $h=h4;function g4(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Eh(e,t){return e<<t|e>>>32-t}function _4(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/Math.pow(2,32),o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Eh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],p=r[3],f=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),v=Eh(u,5)+g4(g,l,d,p)+f+t[g]+c[m]>>>0;f=p,p=d,d=Eh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+p>>>0,r[4]=r[4]+f>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Ok=_4;function Ih(e,t,r,i){return Sh(80,Ok,e,t,r,i)}Ih.DNS=Tk;Ih.URL=Ck;var Ul=Ih;var Th={};function y4(e,t,r){let i;if(e)i=Ak(e.random??e.rng?.()??Uo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Uo();v4(Th,n,a),i=Ak(a,Th.msecs,Th.seq,t,r)}return t??Do(i)}function v4(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Ak(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Or=y4;var Pk=I({BaseCallbackHandler:()=>Xr,callbackHandlerPrefersStreaming:()=>wc,isBaseCallbackHandler:()=>Ch}),w4=class{};function wc(e){return"lc_prefer_streaming"in e&&e.lc_prefer_streaming}var Xr=class extends w4{lc_serializable=!1;get lc_namespace(){return["langchain_core","callbacks",this.name]}get lc_secrets(){}get lc_attributes(){}get lc_aliases(){}get lc_serializable_keys(){}static lc_name(){return this.name}get lc_id(){return[...this.lc_namespace,Co(this.constructor)]}lc_kwargs;ignoreLLM=!1;ignoreChain=!1;ignoreAgent=!1;ignoreRetriever=!1;ignoreCustomEvent=!1;raiseError=!1;awaitHandlers=Ut("LANGCHAIN_CALLBACKS_BACKGROUND")==="false";constructor(e){super(),this.lc_kwargs=e||{},e&&(this.ignoreLLM=e.ignoreLLM??this.ignoreLLM,this.ignoreChain=e.ignoreChain??this.ignoreChain,this.ignoreAgent=e.ignoreAgent??this.ignoreAgent,this.ignoreRetriever=e.ignoreRetriever??this.ignoreRetriever,this.ignoreCustomEvent=e.ignoreCustomEvent??this.ignoreCustomEvent,this.raiseError=e.raiseError??this.raiseError,this.awaitHandlers=this.raiseError||(e._awaitHandler??this.awaitHandlers))}copy(){return new this.constructor(this)}toJSON(){return at.prototype.toJSON.call(this)}toJSONNotImplemented(){return at.prototype.toJSONNotImplemented.call(this)}static fromMethods(e){class t extends Xr{name=Or();constructor(){super(),Object.assign(this,e)}}return new t}},Ch=e=>{let t=e;return t!==void 0&&typeof t.copy=="function"&&typeof t.name=="string"&&typeof t.awaitHandlers=="boolean"};var Nk=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;function x4(e){return typeof e=="string"&&Nk.test(e)}var xc=x4;function S4(e){if(!xc(e))throw TypeError("Invalid UUID");let t;return Uint8Array.of((t=parseInt(e.slice(0,8),16))>>>24,t>>>16&255,t>>>8&255,t&255,(t=parseInt(e.slice(9,13),16))>>>8,t&255,(t=parseInt(e.slice(14,18),16))>>>8,t&255,(t=parseInt(e.slice(19,23),16))>>>8,t&255,(t=parseInt(e.slice(24,36),16))/1099511627776&255,t/4294967296&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255)}var Ll=S4;var kt=[];for(let e=0;e<256;++e)kt.push((e+256).toString(16).slice(1));function Lo(e,t=0){return(kt[e[t+0]]+kt[e[t+1]]+kt[e[t+2]]+kt[e[t+3]]+"-"+kt[e[t+4]]+kt[e[t+5]]+"-"+kt[e[t+6]]+kt[e[t+7]]+"-"+kt[e[t+8]]+kt[e[t+9]]+"-"+kt[e[t+10]]+kt[e[t+11]]+kt[e[t+12]]+kt[e[t+13]]+kt[e[t+14]]+kt[e[t+15]]).toLowerCase()}var k4=new Uint8Array(16);function Fo(){return crypto.getRandomValues(k4)}function $4(e,t,r){return!t&&!e&&crypto.randomUUID?crypto.randomUUID():E4(e,t,r)}function E4(e,t,r){e=e||{};let i=e.random??e.rng?.()??Fo();if(i.length<16)throw new Error("Random bytes length must be >= 16");if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(r=r||0,r<0||r+16>t.length)throw new RangeError(`UUID byte range ${r}:${r+15} is out of buffer bounds`);for(let n=0;n<16;++n)t[r+n]=i[n];return t}return Lo(i)}var ka=$4;function I4(e,t,r,i){switch(e){case 0:return t&r^~t&i;case 1:return t^r^i;case 2:return t&r^t&i^r&i;case 3:return t^r^i}}function Oh(e,t){return e<<t|e>>>32-t}function T4(e){let t=[1518500249,1859775393,2400959708,3395469782],r=[1732584193,4023233417,2562383102,271733878,3285377520],i=new Uint8Array(e.length+1);i.set(e),i[e.length]=128,e=i;let n=e.length/4+2,a=Math.ceil(n/16),o=new Array(a);for(let s=0;s<a;++s){let c=new Uint32Array(16);for(let u=0;u<16;++u)c[u]=e[s*64+u*4]<<24|e[s*64+u*4+1]<<16|e[s*64+u*4+2]<<8|e[s*64+u*4+3];o[s]=c}o[a-1][14]=(e.length-1)*8/2**32,o[a-1][14]=Math.floor(o[a-1][14]),o[a-1][15]=(e.length-1)*8&4294967295;for(let s=0;s<a;++s){let c=new Uint32Array(80);for(let m=0;m<16;++m)c[m]=o[s][m];for(let m=16;m<80;++m)c[m]=Oh(c[m-3]^c[m-8]^c[m-14]^c[m-16],1);let u=r[0],l=r[1],d=r[2],p=r[3],f=r[4];for(let m=0;m<80;++m){let g=Math.floor(m/20),v=Oh(u,5)+I4(g,l,d,p)+f+t[g]+c[m]>>>0;f=p,p=d,d=Oh(l,30)>>>0,l=u,u=v}r[0]=r[0]+u>>>0,r[1]=r[1]+l>>>0,r[2]=r[2]+d>>>0,r[3]=r[3]+p>>>0,r[4]=r[4]+f>>>0}return Uint8Array.of(r[0]>>24,r[0]>>16,r[0]>>8,r[0],r[1]>>24,r[1]>>16,r[1]>>8,r[1],r[2]>>24,r[2]>>16,r[2]>>8,r[2],r[3]>>24,r[3]>>16,r[3]>>8,r[3],r[4]>>24,r[4]>>16,r[4]>>8,r[4])}var Rk=T4;function C4(e){e=unescape(encodeURIComponent(e));let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r)t[r]=e.charCodeAt(r);return t}var Ah="6ba7b810-9dad-11d1-80b4-00c04fd430c8",Ph="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function Nh(e,t,r,i,n,a){let o=typeof r=="string"?C4(r):r,s=typeof i=="string"?Ll(i):i;if(typeof i=="string"&&(i=Ll(i)),i?.length!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let c=new Uint8Array(16+o.length);if(c.set(s),c.set(o,s.length),c=t(c),c[6]=c[6]&15|e,c[8]=c[8]&63|128,n){if(a??=0,a<0||a+16>n.length)throw new RangeError(`UUID byte range ${a}:${a+15} is out of buffer bounds`);for(let u=0;u<16;++u)n[a+u]=c[u];return n}return Lo(c)}function Rh(e,t,r,i){return Nh(80,Rk,e,t,r,i)}Rh.DNS=Ah;Rh.URL=Ph;var Mh=Rh;var jh={};function O4(e,t,r){let i;if(e)i=Mk(e.random??e.rng?.()??Fo(),e.msecs,e.seq,t,r);else{let n=Date.now(),a=Fo();A4(jh,n,a),i=Mk(a,jh.msecs,jh.seq,t,r)}return t??Lo(i)}function A4(e,t,r){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=r[6]<<23|r[7]<<16|r[8]<<8|r[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function Mk(e,t,r,i,n=0){if(e.length<16)throw new Error("Random bytes length must be >= 16");if(!i)i=new Uint8Array(16),n=0;else if(n<0||n+16>i.length)throw new RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);return t??=Date.now(),r??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],i[n++]=t/1099511627776&255,i[n++]=t/4294967296&255,i[n++]=t/16777216&255,i[n++]=t/65536&255,i[n++]=t/256&255,i[n++]=t&255,i[n++]=112|r>>>28&15,i[n++]=r>>>20&255,i[n++]=128|r>>>14&63,i[n++]=r>>>6&255,i[n++]=r<<2&255|e[10]&3,i[n++]=e[11],i[n++]=e[12],i[n++]=e[13],i[n++]=e[14],i[n++]=e[15],i}var Bo=O4;var jk="gen_ai.operation.name",zk="gen_ai.system",zh="gen_ai.request.model",Dk="gen_ai.response.model",Dh="gen_ai.usage.input_tokens",Uh="gen_ai.usage.output_tokens",Lh="gen_ai.usage.total_tokens",Uk="gen_ai.request.max_tokens",Lk="gen_ai.request.temperature",Fk="gen_ai.request.top_p",Bk="gen_ai.request.frequency_penalty",Zk="gen_ai.request.presence_penalty",Vk="gen_ai.response.finish_reasons",Gk="gen_ai.prompt",Hk="gen_ai.completion",Jk="gen_ai.request.extra_query",Kk="gen_ai.request.extra_body",Wk="gen_ai.serialized.name",qk="gen_ai.serialized.signature",Xk="gen_ai.serialized.doc",Yk="gen_ai.response.id",Qk="gen_ai.response.service_tier",e$="gen_ai.response.system_fingerprint",t$="gen_ai.usage.input_token_details",r$="gen_ai.usage.output_token_details",n$="langsmith.trace.session_id",i$="langsmith.trace.session_name",a$="langsmith.span.kind",o$="langsmith.trace.name",s$="langsmith.metadata",Fh="langsmith.span.tags";var c$="langsmith.request.streaming",u$="langsmith.request.headers";var R4=(...e)=>fetch(...e),M4,l$=Symbol.for("ls:fetch_implementation");var d$=()=>globalThis[l$]===void 0?!0:M4??!1,p$=e=>async(...t)=>{if(e||Me("DEBUG")==="true"){let[i,n]=t;console.log(`\u2192 ${n?.method||"GET"} ${i}`)}let r=await(globalThis[l$]??R4)(...t);return(e||Me("DEBUG")==="true")&&console.log(`\u2190 ${r.status} ${r.statusText} ${r.url}`),r};var Sc=()=>Me("PROJECT")??gr("LANGCHAIN_SESSION")??"default";var f$={};function $a(e){f$[e]||(console.warn(e),f$[e]=!0)}var N=e=>BigInt(e),_$=N("0x9E3779B1"),y$=N("0x85EBCA77"),j4=N("0xC2B2AE3D"),Ii=N("0x9E3779B185EBCA87"),Ea=N("0xC2B2AE3D27D4EB4F"),v$=N("0x165667B19E3779F9"),Gh=N("0x85EBCA77C2B2AE63"),z4=N("0x27D4EB2F165667C5"),D4=N("0x165667919E3779F9"),U4=N("0x9FB21C651E98DF25");function L4(e){let t=new Uint8Array(e.length/2);for(let r=0;r<e.length;r+=2)t[r/2]=parseInt(e.substring(r,r+2),16);return t}var $n=L4("b8fe6c3923a44bbe7c01812cf721ad1cded46de9839097db7240a4a4b7b3671fcb79e64eccc0e578825ad07dccff7221b8084674f743248ee03590e6813a264c3c2852bb91c300cb88d0658b1b532ea371644897a20df94e3819ef46a9deacd8a8fa763fe39c343ff9dcbbc7c70b4f1d8a51e04bcdb45931c89f7ec9d9787364eac5ac8334d3ebc3c581a0fffa1363eb170ddd51b7f0da49d316552629d4689e2b16be587d47a1fc8ff8b8d17ad031ce45cb3a8f95160428afd7fbcabb4b407e"),Vo=(N(1)<<N(128))-N(1),me=(N(1)<<N(64))-N(1),Vl=(N(1)<<N(32))-N(1),ei=64,b$=ei/8,F4=8,Fl=4;function De(e,t=0){return new Uint8Array(e.buffer,e.byteOffset+t,e.length-t)}function Ve(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getBigUint64(0,!0)}function Zo(e,t=0){return new DataView(e.buffer,e.byteOffset+t).getUint32(0,!0)}function Bh(e,t=0){return e[t]}var B4=e=>(e&N(255))<<N(56)|(e&N(65280))<<N(40)|(e&N(16711680))<<N(24)|(e&N(4278190080))<<N(8)|(e&N(0xff00000000))>>N(8)|(e&N(0xff0000000000))>>N(24)|(e&N(0xff000000000000))>>N(40)|(e&N(0xff00000000000000))>>N(56),Z4=e=>(e=(e&N(65535))<<N(16)|(e&N(4294901760))>>N(16),e=(e&N(16711935))<<N(8)|(e&N(4278255360))>>N(8),e),V4=(e,t)=>(e&Vl)*(t&Vl)&me,Go=e=>{if(!e)throw new Error("Assert failed")};function G4(e,t){return(e<<t|e>>N(32)-t)&Vl}function w$(e,t,r){for(let i=0;i<b$;i++){let n=Ve(t,i*8),a=n^Ve(r,i*8);e[i^1]+=n,e[i]+=V4(a,a>>N(32))}return e}function m$(e,t,r,i){for(let n=0;n<i;n++)w$(e,De(t,n*ei),De(r,n*8));return e}function H4(e,t){for(let r=0;r<b$;r++){let i=Ve(t,r*8),n=e[r];n=Zh(n,N(47)),n^=i,n*=_$,e[r]=n&me}return e}function Bl(e,t){return x$(e[0]^Ve(t,0),e[1]^Ve(t,F4))}function h$(e,t,r){let i=r;return i+=Bl(e.slice(0),De(t,0*Fl)),i+=Bl(e.slice(2),De(t,4*Fl)),i+=Bl(e.slice(4),De(t,8*Fl)),i+=Bl(e.slice(6),De(t,12*Fl)),En(i&me)}function J4(e,t,r,i,n){let a=Math.floor((r.byteLength-ei)/8),o=ei*a,s=Math.floor((t.byteLength-1)/o);for(let c=0;c<s;c++)e=m$(e,De(t,c*o),r,a),e=n(e,De(r,r.byteLength-ei));{let c=Math.floor((t.byteLength-1-o*s)/ei);e=m$(e,De(t,s*o),r,c),e=i(e,De(t,t.byteLength-ei),De(r,r.byteLength-ei-7))}return e}function K4(e,t,r){let i=new BigUint64Array([j4,Ii,Ea,v$,Gh,y$,z4,_$]);Go(e.length>128),i=J4(i,e,t,w$,H4),Go(i.length*8==64);{let n=h$(i,De(t,11),N(e.byteLength)*Ii&me);return h$(i,De(t,t.byteLength-ei-11),~(N(e.byteLength)*Ea)&me)<<N(64)|n}}function x$(e,t){let r=e*t&Vo;return r&me^r>>N(64)}function g$(e,t,r){return x$((Ve(e,0)^Ve(t,0)+r)&me,(Ve(e,8)^Ve(t,8)-r)&me)}function Zl(e,t,r,i,n){let a=e&me,o=e>>N(64)&me;return a+=g$(t,i,n),a^=Ve(r,0)+Ve(r,8),a&=me,o+=g$(r,De(i,16),n),o^=Ve(t,0)+Ve(t,8),o&=me,o<<N(64)|a}function En(e){return e^=e>>N(37),e*=D4,e&=me,e^=e>>N(32),e}function Gl(e){return e^=e>>N(33),e*=Ea,e&=me,e^=e>>N(29),e*=v$,e&=me,e^=e>>N(32),e}function W4(e,t,r){let i=e.byteLength;Go(i>0&&i<=3);let n=N(Bh(e,i-1))|N(i<<8)|N(Bh(e,0)<<16)|N(Bh(e,i>>1)<<24),a=(N(Zo(t,0))^N(Zo(t,4)))+r,o=(n^a)&me,s=(N(Zo(t,8))^N(Zo(t,12)))-r,c=(G4(Z4(n),N(13))^s)&me;return(Gl(c)&me)<<N(64)|Gl(o)}function Zh(e,t){return e^e>>t}function q4(e,t,r){let i=e.byteLength;Go(i>=4&&i<=8);{let n=Zo(e,0),a=Zo(e,i-4),o=N(n)|N(a)<<N(32),s=(Ve(t,16)^Ve(t,24))+r&me,u=(o^s)*(Ii+(N(i)<<N(2)))&Vo;return u+=(u&me)<<N(65),u&=Vo,u^=u>>N(67),Zh(Zh(u&me,N(35))*U4&me,N(28))|En(u>>N(64))<<N(64)}}function X4(e,t,r){let i=e.byteLength;Go(i>=9&&i<=16);{let n=(Ve(t,32)^Ve(t,40))+r&me,a=(Ve(t,48)^Ve(t,56))-r&me,o=Ve(e),s=Ve(e,i-8),c=(o^s^n)*Ii,u=(c&me)+(N(i-1)<<N(54));c=c&(Vo^me)|u,s^=a,c+=s+(s&Vl)*(y$-N(1))<<N(64),c&=Vo,c^=B4(c>>N(64));let l=(c&me)*Ea;return l+=(c>>N(64))*Ea<<N(64),l&=Vo,En(l&me)|En(l>>N(64))<<N(64)}}function Y4(e,t){let r=e.byteLength;return Go(r<=16),r>8?X4(e,$n,t):r>=4?q4(e,$n,t):r>0?W4(e,$n,t):Gl(t^Ve($n,64)^Ve($n,72))|Gl(t^Ve($n,80)^Ve($n,88))<<N(64)}function Vh(e){return~e+N(1)&me}function Q4(e,t,r){let i=N(e.byteLength)*Ii&me,n=N(e.byteLength-1)/N(32);for(;n>=0;){let s=Number(n);i=Zl(i,De(e,16*s),De(e,e.byteLength-16*(s+1)),De(t,32*s),r),n--}let a=i+(i>>N(64))&me;a=En(a);let o=(i&me)*Ii+(i>>N(64))*Gh+(N(e.byteLength)-r&me)*Ea;return o&=me,o=Vh(En(o)),a|o<<N(64)}function eM(e,t,r){let i=N(e.byteLength)*Ii&me;for(let o=32;o<160;o+=32)i=Zl(i,De(e,o-32),De(e,o-16),De(t,o-32),r);i=En(i&me)|En(i>>N(64))<<N(64);for(let o=160;o<=e.byteLength;o+=32)i=Zl(i,De(e,o-32),De(e,o-16),De(t,3+o-160),r);i=Zl(i,De(e,e.byteLength-16),De(e,e.byteLength-32),De(t,103),Vh(r));let n=i+(i>>N(64))&me;n=En(n);let a=(i&me)*Ii+(i>>N(64))*Gh+(N(e.byteLength)-r&me)*Ea;return a&=me,a=Vh(En(a)),n|a<<N(64)}function S$(e,t=N(0)){let r=e.byteLength;return r<=16?Y4(e,t):r<=128?Q4(e,$n,t):r<=240?eM(e,$n,t):K4(e,$n,t)}function k$(e){let t=new Uint8Array(16),r=new DataView(t.buffer),i=e&me,n=e>>N(64);return r.setBigUint64(0,n,!1),r.setBigUint64(8,i,!1),t}var $$=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function le(e,t){if(!$$.test(e)){let r=t!==void 0?`Invalid UUID for ${t}: ${e}`:`Invalid UUID: ${e}`;throw new Error(r)}return e}function Hl(e){let t=typeof e=="string"?Date.parse(e):e;return Bo({msecs:t,seq:0})}function tM(e){if(!$$.test(e))return null;let t=e[14];return parseInt(t,16)}function rM(e){let t=e.replace(/-/g,""),r=new Uint8Array(16);for(let i=0;i<16;i++)r[i]=parseInt(t.slice(i*2,i*2+2),16);return r}function nM(e){let t=Array.from(e).map(r=>r.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var iM=new TextEncoder;function aM(e){let t=iM.encode(e),r=S$(t);return k$(r)}function kc(e,t){let r=`${e}:${t}`,i=aM(r),n=new Uint8Array(16);if(tM(e)===7){let o=rM(e);n.set(o.slice(0,6),0)}else{let o=Date.now();n[0]=o/1099511627776&255,n[1]=o/4294967296&255,n[2]=o/16777216&255,n[3]=o/65536&255,n[4]=o/256&255,n[5]=o&255}return n[6]=112|i[0]&15,n[7]=i[1],n[8]=128|i[2]&63,n.set(i.slice(3,10),9),nM(n)}var $c={join:(...e)=>e.join("/"),dirname:e=>e.split("/").slice(0,-1).join("/")};async function E$(e){}async function I$(e,t){}async function T$(e){return[]}async function C$(e){return{size:0}}function Jl(e){return!1}function O$(e){return""}function sM(e,t){return t===null?!1:Date.now()-e.createdAt>t*1e3}var Kl=class{constructor(t={}){Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"ttlSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshIntervalSeconds",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"refreshTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_metrics",{enumerable:!0,configurable:!0,writable:!0,value:{hits:0,misses:0,refreshes:0,refreshErrors:0}}),this.configure(t)}get metrics(){return{...this._metrics}}get totalRequests(){return this._metrics.hits+this._metrics.misses}get hitRate(){let t=this.totalRequests;return t>0?this._metrics.hits/t:0}resetMetrics(){this._metrics={hits:0,misses:0,refreshes:0,refreshErrors:0}}get(t,r){if(this.maxSize===0)return;let i=this.cache.get(t);if(!i){this._metrics.misses+=1;return}return this.cache.delete(t),this.cache.set(t,{...i,refreshFunc:r}),this._metrics.hits+=1,i.value}set(t,r,i){if(this.maxSize===0)return;if(this.refreshTimer===void 0&&this.startRefreshLoop(),!this.cache.has(t)&&this.cache.size>=this.maxSize){let a=this.cache.keys().next().value;a!==void 0&&this.cache.delete(a)}let n={value:r,createdAt:Date.now(),refreshFunc:i};this.cache.delete(t),this.cache.set(t,n)}invalidate(t){this.cache.delete(t)}clear(){this.cache.clear()}get size(){return this.cache.size}stop(){this.refreshTimer&&(clearInterval(this.refreshTimer),this.refreshTimer=void 0)}dump(t){let r={};for(let[a,o]of this.cache.entries())r[a]=o.value;let i=$c.dirname(t);Jl(i)||void 0;let n=`${t}.tmp`;try{JSON.stringify({entries:r},null,2)}catch(a){throw Jl(n)&&void 0,a}}load(t){if(!Jl(t))return 0;let r;try{let a=O$(t);r=JSON.parse(a).entries??null}catch{return 0}if(!r)return 0;let i=0,n=Date.now();for(let[a,o]of Object.entries(r)){if(this.cache.size>=this.maxSize)break;let s={value:o,createdAt:n};this.cache.set(a,s),i+=1}return i}startRefreshLoop(){this.stop(),this.ttlSeconds!==null&&(this.refreshTimer=setInterval(()=>{this.refreshStaleEntries().catch(t=>{console.warn("Unexpected error in cache refresh loop:",t)})},this.refreshIntervalSeconds*1e3),this.refreshTimer.unref&&this.refreshTimer.unref())}getStaleEntries(){let t=[];for(let[r,i]of this.cache.entries())sM(i,this.ttlSeconds)&&t.push([r,i]);return t}async refreshStaleEntries(){let t=this.getStaleEntries();if(t.length!==0){for(let[r,i]of t)if(i.refreshFunc!==void 0)try{let n=await i.refreshFunc();this.set(r,n,i.refreshFunc),this._metrics.refreshes+=1}catch(n){this._metrics.refreshErrors+=1,console.warn(`Failed to refresh cache entry ${r}:`,n)}}}configure(t){this.stop(),this.refreshIntervalSeconds=t.refreshIntervalSeconds??60,this.maxSize=t.maxSize??100,this.ttlSeconds=t.ttlSeconds??300}},Wl=new Kl;var ql="0.5.25";var Tn,cM=()=>typeof window<"u"&&typeof window.document<"u",uM=()=>typeof globalThis=="object"&&globalThis.constructor&&globalThis.constructor.name==="DedicatedWorkerGlobalScope",lM=()=>typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&navigator.userAgent.includes("jsdom"),N$=()=>typeof Deno<"u",dM=()=>typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"&&!N$(),Kh=()=>Tn||(typeof Bun<"u"?Tn="bun":cM()?Tn="browser":dM()?Tn="node":uM()?Tn="webworker":lM()?Tn="jsdom":N$()?Tn="deno":Tn="other",Tn),Hh;function Xl(){if(Hh===void 0){let e=Kh(),t=fM();Hh={library:"langsmith",runtime:e,sdk:"langsmith-js",sdk_version:ql,...t}}return Hh}function Wh(){let e=pM(),t={},r=["LANGCHAIN_API_KEY","LANGCHAIN_ENDPOINT","LANGCHAIN_TRACING_V2","LANGCHAIN_PROJECT","LANGCHAIN_SESSION","LANGSMITH_API_KEY","LANGSMITH_ENDPOINT","LANGSMITH_TRACING_V2","LANGSMITH_PROJECT","LANGSMITH_SESSION"];for(let[i,n]of Object.entries(e))typeof n=="string"&&!r.includes(i)&&!i.toLowerCase().includes("key")&&!i.toLowerCase().includes("secret")&&!i.toLowerCase().includes("token")&&(i==="LANGCHAIN_REVISION_ID"?t.revision_id=n:t[i]=n);return t}function pM(){let e={};try{if(typeof process<"u"&&process.env)for(let[t,r]of Object.entries(process.env))(t.startsWith("LANGCHAIN_")||t.startsWith("LANGSMITH_"))&&r!=null&&((t.toLowerCase().includes("key")||t.toLowerCase().includes("secret")||t.toLowerCase().includes("token"))&&typeof r=="string"?e[t]=r.slice(0,2)+"*".repeat(r.length-4)+r.slice(-2):e[t]=r)}catch{}return e}function gr(e){try{return typeof process<"u"?process.env?.[e]:void 0}catch{return}}function Me(e){return gr(`LANGSMITH_${e}`)||gr(`LANGCHAIN_${e}`)}var Jh;function fM(){if(Jh!==void 0)return Jh;let e=["VERCEL_GIT_COMMIT_SHA","NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA","COMMIT_REF","RENDER_GIT_COMMIT","CI_COMMIT_SHA","CIRCLE_SHA1","CF_PAGES_COMMIT_SHA","REACT_APP_GIT_SHA","SOURCE_VERSION","GITHUB_SHA","TRAVIS_COMMIT","GIT_COMMIT","BUILD_VCS_NUMBER","bamboo_planRepository_revision","Build.SourceVersion","BITBUCKET_COMMIT","DRONE_COMMIT_SHA","SEMAPHORE_GIT_SHA","BUILDKITE_COMMIT"],t={};for(let r of e){let i=gr(r);i!==void 0&&(t[r]=i)}return Jh=t,t}function A$(){return gr("OTEL_ENABLED")==="true"||Me("OTEL_ENABLED")==="true"}var P$=new Set(["langsmith","otel"]);function Yl(e){if(e!==void 0)return e;let t=Me("TRACING_MODE");if(t!==void 0&&t!==""){let r=t.toLowerCase();if(!P$.has(r))throw new Error(`Invalid LANGSMITH_TRACING_MODE=${JSON.stringify(t)}. Must be one of: ${[...P$].sort().join(", ")}`);return A$()&&console.warn("Both LANGSMITH_TRACING_MODE and the legacy OTEL_ENABLED / LANGSMITH_OTEL_ENABLED env vars are set. LANGSMITH_TRACING_MODE takes precedence."),r}return A$()?"otel":"langsmith"}var Yh=class{constructor(){Object.defineProperty(this,"hasWarned",{enumerable:!0,configurable:!0,writable:!0,value:!1})}startActiveSpan(t,...r){!this.hasWarned&&Yl()==="otel"&&(console.warn('OTel tracing mode is active (via LANGSMITH_TRACING_MODE, OTEL_ENABLED, or LANGSMITH_OTEL_ENABLED), but the required OTEL instances have not been initialized. Please add:\n```\nimport { initializeOTEL } from "langsmith/experimental/otel/setup";\ninitializeOTEL();\n```\nat the beginning of your code.'),this.hasWarned=!0);let i;if(r.length===1&&typeof r[0]=="function"?i=r[0]:r.length===2&&typeof r[1]=="function"?i=r[1]:r.length===3&&typeof r[2]=="function"&&(i=r[2]),typeof i=="function")return i()}},Qh=class{constructor(){Object.defineProperty(this,"mockTracer",{enumerable:!0,configurable:!0,writable:!0,value:new Yh})}getTracer(t,r){return this.mockTracer}getActiveSpan(){}setSpan(t,r){return t}getSpan(t){}setSpanContext(t,r){return t}getTracerProvider(){}setGlobalTracerProvider(t){return!1}},eg=class{active(){return{}}with(t,r){return r()}},qh=Symbol.for("ls:otel_trace"),Xh=Symbol.for("ls:otel_context"),R$=Symbol.for("ls:otel_get_default_otlp_tracer_provider"),mM=new Qh,hM=new eg,tg=class{getTraceInstance(){return globalThis[qh]??mM}getContextInstance(){return globalThis[Xh]??hM}initializeGlobalInstances(t){globalThis[qh]===void 0&&(globalThis[qh]=t.trace),globalThis[Xh]===void 0&&(globalThis[Xh]=t.context)}setDefaultOTLPTracerComponents(t){globalThis[R$]=t}getDefaultOTLPTracerComponents(){return globalThis[R$]??void 0}},rg=new tg;function Ql(){return rg.getTraceInstance()}function M$(){return rg.getContextInstance()}function j$(){return rg.getDefaultOTLPTracerComponents()}var gM={llm:"chat",tool:"execute_tool",retriever:"embeddings",embedding:"embeddings",prompt:"chat"};function _M(e){return gM[e]||e}var ed=class{constructor(){Object.defineProperty(this,"spans",{enumerable:!0,configurable:!0,writable:!0,value:new Map})}exportBatch(t,r){for(let i of t)try{if(!i.run)continue;if(i.operation==="post"){let n=this.createSpanForRun(i,i.run,r.get(i.id));n&&!i.run.end_time&&this.spans.set(i.id,n)}else this.updateSpanForRun(i,i.run)}catch(n){console.error(`Error processing operation ${i.id}:`,n)}}createSpanForRun(t,r,i){let n=i&&Ql().getSpan(i);if(n)try{return this.finishSpanSetup(n,r,t)}catch(a){console.error(`Failed to create span for run ${t.id}:`,a);return}}finishSpanSetup(t,r,i){return this.setSpanAttributes(t,r,i),r.error?(t.setStatus({code:2}),t.recordException(new Error(r.error))):t.setStatus({code:1}),r.end_time&&t.end(new Date(r.end_time)),t}updateSpanForRun(t,r){try{let i=this.spans.get(t.id);if(!i){console.debug(`No span found for run ${t.id} during update`);return}this.setSpanAttributes(i,r,t),r.error?(i.setStatus({code:2}),i.recordException(new Error(r.error))):i.setStatus({code:1});let n=r.end_time;n&&(i.end(new Date(n)),this.spans.delete(t.id))}catch(i){console.error(`Failed to update span for run ${t.id}:`,i)}}extractModelName(t){if(t.extra?.metadata){let r=t.extra.metadata;if(r.ls_model_name)return r.ls_model_name;if(r.invocation_params){let i=r.invocation_params;if(i.model)return i.model;if(i.model_name)return i.model_name}}}setSpanAttributes(t,r,i){if("run_type"in r&&r.run_type){t.setAttribute(a$,r.run_type);let s=_M(r.run_type||"chain");t.setAttribute(jk,s)}"name"in r&&r.name&&t.setAttribute(o$,r.name),"session_id"in r&&r.session_id&&t.setAttribute(n$,r.session_id),"session_name"in r&&r.session_name&&t.setAttribute(i$,r.session_name),this.setGenAiSystem(t,r);let n=this.extractModelName(r);n&&t.setAttribute(zh,n),"prompt_tokens"in r&&typeof r.prompt_tokens=="number"&&t.setAttribute(Dh,r.prompt_tokens),"completion_tokens"in r&&typeof r.completion_tokens=="number"&&t.setAttribute(Uh,r.completion_tokens),"total_tokens"in r&&typeof r.total_tokens=="number"&&t.setAttribute(Lh,r.total_tokens),this.setInvocationParameters(t,r);let a=r.extra?.metadata||{};for(let[s,c]of Object.entries(a))c!=null&&t.setAttribute(`${s$}.${s}`,String(c));let o=r.tags;if(o&&Array.isArray(o)?t.setAttribute(Fh,o.join(", ")):o&&t.setAttribute(Fh,String(o)),"serialized"in r&&typeof r.serialized=="object"){let s=r.serialized;s.name&&t.setAttribute(Wk,String(s.name)),s.signature&&t.setAttribute(qk,String(s.signature)),s.doc&&t.setAttribute(Xk,String(s.doc))}this.setIOAttributes(t,i)}setGenAiSystem(t,r){let i="langchain",n=this.extractModelName(r);if(n){let a=n.toLowerCase();a.includes("anthropic")||a.startsWith("claude")?i="anthropic":a.includes("bedrock")?i="aws.bedrock":a.includes("azure")&&a.includes("openai")?i="az.ai.openai":a.includes("azure")&&a.includes("inference")?i="az.ai.inference":a.includes("cohere")?i="cohere":a.includes("deepseek")?i="deepseek":a.includes("gemini")?i="gemini":a.includes("groq")?i="groq":a.includes("watson")||a.includes("ibm")?i="ibm.watsonx.ai":a.includes("mistral")?i="mistral_ai":a.includes("gpt")||a.includes("openai")?i="openai":a.includes("perplexity")||a.includes("sonar")?i="perplexity":a.includes("vertex")?i="vertex_ai":(a.includes("xai")||a.includes("grok"))&&(i="xai")}t.setAttribute(zk,i)}setInvocationParameters(t,r){if(!r.extra?.metadata?.invocation_params)return;let i=r.extra.metadata.invocation_params;i.max_tokens!==void 0&&t.setAttribute(Uk,i.max_tokens),i.temperature!==void 0&&t.setAttribute(Lk,i.temperature),i.top_p!==void 0&&t.setAttribute(Fk,i.top_p),i.frequency_penalty!==void 0&&t.setAttribute(Bk,i.frequency_penalty),i.presence_penalty!==void 0&&t.setAttribute(Zk,i.presence_penalty)}setIOAttributes(t,r){if(r.run.inputs)try{let i=r.run.inputs;typeof i=="object"&&i!==null&&(i.model&&Array.isArray(i.messages)&&t.setAttribute(zh,i.model),i.stream!==void 0&&t.setAttribute(c$,i.stream),i.extra_headers&&t.setAttribute(u$,JSON.stringify(i.extra_headers)),i.extra_query&&t.setAttribute(Jk,JSON.stringify(i.extra_query)),i.extra_body&&t.setAttribute(Kk,JSON.stringify(i.extra_body))),t.setAttribute(Gk,JSON.stringify(i))}catch(i){console.debug(`Failed to process inputs for run ${r.id}`,i)}if(r.run.outputs)try{let i=r.run.outputs,n=this.getUnifiedRunTokens(i);if(n&&(t.setAttribute(Dh,n[0]),t.setAttribute(Uh,n[1]),t.setAttribute(Lh,n[0]+n[1])),i&&typeof i=="object"){if(i.model&&t.setAttribute(Dk,String(i.model)),i.id&&t.setAttribute(Yk,i.id),i.choices&&Array.isArray(i.choices)){let a=i.choices.map(o=>o.finish_reason).filter(o=>o).map(String);a.length>0&&t.setAttribute(Vk,a.join(", "))}if(i.service_tier&&t.setAttribute(Qk,i.service_tier),i.system_fingerprint&&t.setAttribute(e$,i.system_fingerprint),i.usage_metadata&&typeof i.usage_metadata=="object"){let a=i.usage_metadata;a.input_token_details&&t.setAttribute(t$,JSON.stringify(a.input_token_details)),a.output_token_details&&t.setAttribute(r$,JSON.stringify(a.output_token_details))}}t.setAttribute(Hk,JSON.stringify(i))}catch(i){console.debug(`Failed to process outputs for run ${r.id}`,i)}}getUnifiedRunTokens(t){if(!t)return null;let r=this.extractUnifiedRunTokens(t.usage_metadata);if(r)return r;let i=Object.keys(t);for(let o of i){let s=t[o];if(!(!s||typeof s!="object")&&(r=this.extractUnifiedRunTokens(s.usage_metadata),r||s.lc===1&&s.kwargs&&typeof s.kwargs=="object"&&(r=this.extractUnifiedRunTokens(s.kwargs.usage_metadata),r)))return r}let n=t.generations||[];if(!Array.isArray(n))return null;let a=Array.isArray(n[0])?n.flat():n;for(let o of a)if(typeof o=="object"&&o.message&&typeof o.message=="object"&&o.message.kwargs&&typeof o.message.kwargs=="object"&&(r=this.extractUnifiedRunTokens(o.message.kwargs.usage_metadata),r))return r;return null}extractUnifiedRunTokens(t){return!t||typeof t!="object"||typeof t.input_tokens!="number"||typeof t.output_tokens!="number"?null:[t.input_tokens,t.output_tokens]}};var yM=Object.prototype.toString,vM=e=>yM.call(e)==="[object Error]",bM=new Set(["network error","Failed to fetch","NetworkError when attempting to fetch resource.","The Internet connection appears to be offline.","Network request failed","fetch failed","terminated"," A network error occurred.","Network connection lost"]);function ng(e){if(!(e&&vM(e)&&e.name==="TypeError"&&typeof e.message=="string"))return!1;let{message:r,stack:i}=e;return r==="Load failed"?i===void 0||"__sentry_captured__"in e:r.startsWith("error sending request for url")?!0:bM.has(r)}function wM(e){if(typeof e=="number"){if(e<0)throw new TypeError("Expected `retries` to be a non-negative number.");if(Number.isNaN(e))throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.")}else if(e!==void 0)throw new TypeError("Expected `retries` to be a number or Infinity.")}function td(e,t,{min:r=0,allowInfinity:i=!1}={}){if(t!==void 0){if(typeof t!="number"||Number.isNaN(t))throw new TypeError(`Expected \`${e}\` to be a number${i?" or Infinity":""}.`);if(!i&&!Number.isFinite(t))throw new TypeError(`Expected \`${e}\` to be a finite number.`);if(t<r)throw new TypeError(`Expected \`${e}\` to be \u2265 ${r}.`)}}var ig=class extends Error{constructor(t){super(),t instanceof Error?(this.originalError=t,{message:t}=t):(this.originalError=new Error(t),this.originalError.stack=this.stack),this.name="AbortError",this.message=t}};function xM(e,t){let r=Math.max(1,e+1),i=t.randomize?Math.random()+1:1,n=Math.round(i*t.minTimeout*t.factor**(r-1));return n=Math.min(n,t.maxTimeout),n}function z$(e,t){return Number.isFinite(t)?t-(performance.now()-e):t}async function SM({error:e,attemptNumber:t,retriesConsumed:r,startTime:i,options:n}){let a=e instanceof Error?e:new TypeError(`Non-error was thrown: "${e}". You should only throw errors.`);if(a instanceof ig)throw a.originalError;let o=Number.isFinite(n.retries)?Math.max(0,n.retries-r):n.retries,s=n.maxRetryTime??Number.POSITIVE_INFINITY,c=Object.freeze({error:a,attemptNumber:t,retriesLeft:o,retriesConsumed:r});if(await n.onFailedAttempt(c),z$(i,s)<=0)throw a;let u=await n.shouldConsumeRetry(c),l=z$(i,s);if(l<=0||o<=0)throw a;if(a instanceof TypeError&&!ng(a)){if(u)throw a;return n.signal?.throwIfAborted(),!1}if(!await n.shouldRetry(c))throw a;if(!u)return n.signal?.throwIfAborted(),!1;let d=xM(r,n),p=Math.min(d,l);return p>0&&await new Promise((f,m)=>{let g=()=>{clearTimeout(v),n.signal?.removeEventListener("abort",g),m(n.signal.reason)},v=setTimeout(()=>{n.signal?.removeEventListener("abort",g),f()},p);n.unref&&v.unref?.(),n.signal?.addEventListener("abort",g,{once:!0})}),n.signal?.throwIfAborted(),!0}async function ag(e,t={}){if(t={...t},wM(t.retries),Object.hasOwn(t,"forever"))throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");t.retries??=10,t.factor??=2,t.minTimeout??=1e3,t.maxTimeout??=Number.POSITIVE_INFINITY,t.maxRetryTime??=Number.POSITIVE_INFINITY,t.randomize??=!1,t.onFailedAttempt??=()=>{},t.shouldRetry??=()=>!0,t.shouldConsumeRetry??=()=>!0,td("factor",t.factor,{min:0,allowInfinity:!1}),td("minTimeout",t.minTimeout,{min:0,allowInfinity:!1}),td("maxTimeout",t.maxTimeout,{min:0,allowInfinity:!0}),td("maxRetryTime",t.maxRetryTime,{min:0,allowInfinity:!0}),t.factor>0||(t.factor=1),t.signal?.throwIfAborted();let r=0,i=0,n=performance.now();for(;!Number.isFinite(t.retries)||i<=t.retries;){r++;try{t.signal?.throwIfAborted();let a=await e(r);return t.signal?.throwIfAborted(),a}catch(a){await SM({error:a,attemptNumber:r,retriesConsumed:i,startTime:n,options:t})&&i++}}throw new Error("Retry attempts exhausted without throwing an error.")}var sd=da(od(),1),J$="default"in sd.default?sd.default.default:sd.default;var PM=[408,425,429,500,502,503,504],Ic=class{constructor(t){Object.defineProperty(this,"maxConcurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxRetries",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"maxQueueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFailedResponseHook",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"queueSizeBytes",{enumerable:!0,configurable:!0,writable:!0,value:0}),this.maxConcurrency=t.maxConcurrency??1/0,this.maxRetries=t.maxRetries??6,this.maxQueueSizeBytes=t.maxQueueSizeBytes,this.queue=new J$({concurrency:this.maxConcurrency}),this.onFailedResponseHook=t?.onFailedResponseHook}call(t,...r){return this.callWithOptions({},t,...r)}callWithOptions(t,r,...i){let n=t.sizeBytes??0;if(this.maxQueueSizeBytes!==void 0&&n>0&&this.queueSizeBytes+n>this.maxQueueSizeBytes)return Promise.reject(new Error(`Queue size limit (${this.maxQueueSizeBytes} bytes) exceeded. Current queue size: ${this.queueSizeBytes} bytes, attempted addition: ${n} bytes.`));n>0&&(this.queueSizeBytes+=n);let a=this.onFailedResponseHook,o=this.queue.add(()=>ag(()=>r(...i).catch(s=>{throw s instanceof Error?s:new Error(s)}),{async onFailedAttempt({error:s}){if(typeof s!="object"||s==null)throw s;let c="message"in s&&typeof s.message=="string"?s.message:void 0;if(c?.startsWith("Cancel")||c?.startsWith("TimeoutError")||c?.startsWith("AbortError")||"name"in s&&s.name==="TimeoutError"||"code"in s&&s.code==="ECONNABORTED")throw s;let u="response"in s?s.response:void 0;if(a&&await a(u))return;let l=u?.status??("status"in s?s.status:void 0);if(l!=null&&(typeof l=="number"||typeof l=="string")&&!PM.includes(+l))throw s},retries:this.maxRetries,randomize:!0}),{throwOnTimeout:!0});return n>0&&(o=o.finally(()=>{this.queueSizeBytes-=n})),t.signal?Promise.race([o,new Promise((s,c)=>{t.signal?.addEventListener("abort",()=>{c(new Error("AbortError"))})})]):o}};function pg(e){return typeof e?._getType=="function"}function fg(e){let t={type:e._getType(),data:{content:e.content}};return e?.additional_kwargs&&Object.keys(e.additional_kwargs).length>0&&(t.data.additional_kwargs={...e.additional_kwargs}),t}function ud(e){return`Invalid prompt identifier format: "${e}". Expected one of:
|
|
22
22
|
- "prompt-name" (for private prompts)
|
|
23
23
|
- "owner/prompt-name" (for prompts with explicit owner)
|
|
24
24
|
- "prompt-name:commit-hash" (with commit reference)
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{p as s,x as e}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";var a=s(e,{"arcgis-assistant":[()=>import("./
|
|
2
|
+
import{p as s,x as e}from"./DSEMD4M2.js";import"./CFDTXKJ6.js";var a=s(e,{"arcgis-assistant":[()=>import("./RUG4CKQX.js"),"_messages:,awaitingResponse:,awaitingResponseStep:,copyEnabled,description,entryMessage,feedbackEnabled,heading,interrupt:,keepSuggestedPrompts,logEnabled,messages:,orchestrator:,readAloudEnabled,referenceElement,suggestedPrompts:,voiceInputEnabled;clearChatHistory,submitMessage;cancelInterrupt,register,submitInterrupt"],"arcgis-assistant-agent":[()=>import("./ZPNJGIAF.js"),"agent:,context:;getContext"],"arcgis-assistant-data-exploration-agent":[()=>import("./7M7EPP5U.js"),"referenceElement;;getContext"],"arcgis-assistant-help-agent":[()=>import("./TSIUD5CY.js"),"referenceElement;;getContext"],"arcgis-assistant-layer-styling-agent":[()=>import("./25OJ5FXG.js"),"referenceElement;;getContext"],"arcgis-assistant-navigation-agent":[()=>import("./2GGXJKQD.js"),"referenceElement;;getContext"],"arcgis-assistant-chat":[()=>import("./2YEKZADB.js"),"loading,messages:"],"arcgis-assistant-chat-entry":[()=>import("./YNJYG2RG.js"),"_messages:,awaitingResponse,entryPlaceholder,inputValue,keyboardShortcutsDisabled,messages:,status,voiceInputEnabled;submitMessage"],"arcgis-assistant-interrupt":[()=>import("./ZLO73NU6.js"),"_messages:,message,options:,type"],"arcgis-assistant-message":[()=>import("./G4SVCCJH.js"),"copyEnabled,feedbackEnabled,footerDisabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-block":[()=>import("./5JBT3YNY.js"),"block:"],"arcgis-assistant-message-feedback":[()=>import("./Q5D5LJS5.js"),"_messages:,feedbackEnabled,message:"],"arcgis-assistant-message-footer":[()=>import("./UK6CP7BR.js"),"_messages:,copyEnabled,feedbackEnabled,logEnabled,message:,readAloudEnabled"],"arcgis-assistant-message-loading":[()=>import("./Z3DVGFEE.js"),"loading,loadingMessage"],"arcgis-assistant-message-log":[()=>import("./PTGKT5P6.js"),"log:,logEnabled,showLog"],"arcgis-assistant-message-read-aloud":[()=>import("./R5FWFRWW.js"),"_messages:,message:,readAloudEnabled"],"arcgis-assistant-message-text":[()=>import("./Y3AUHNRX.js"),"content"],"arcgis-assistant-speech-input":[()=>import("./TRDKA5Y6.js"),"awaitingResponse,inputValue,language,mode;;clearDraftSession"],"arcgis-assistant-suggested-prompts":[()=>import("./LXFCO34K.js"),"_messages:,label,prompts:"],"arcgis-assistant-user-message":[()=>import("./WBRZZ4FB.js"),"content,message:,user"]});a({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-assistant,arcgis-assistant-agent,arcgis-assistant-data-exploration-agent,arcgis-assistant-help-agent,arcgis-assistant-layer-styling-agent,arcgis-assistant-navigation-agent,arcgis-assistant-chat,arcgis-assistant-chat-entry,arcgis-assistant-interrupt,arcgis-assistant-message-block,arcgis-assistant-message-feedback,arcgis-assistant-message-footer,arcgis-assistant-message-loading,arcgis-assistant-message-log,arcgis-assistant-message-read-aloud,arcgis-assistant-message-text,arcgis-assistant-speech-input,arcgis-assistant-suggested-prompts,arcgis-assistant-user-message){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,e)
|