@arcgis/ai-components 5.1.0-next.60 → 5.1.0-next.62
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/{VDUOWASW.js → 344C2EEF.js} +17 -3
- package/dist/cdn/5RA2JKQ5.js +3 -0
- package/dist/cdn/6IDESYBP.js +2 -0
- package/dist/cdn/{LNIUXPX7.js → AAEEDEN7.js} +67 -67
- package/dist/cdn/{3JJ2FKJ4.js → B4DEC7PH.js} +1 -1
- package/dist/cdn/{ZOOIBXUA.js → DLTK3ENO.js} +1 -1
- package/dist/cdn/E4J4SWHB.js +2 -0
- package/dist/cdn/{XKTKSULE.js → H3DVSYQV.js} +1 -1
- package/dist/cdn/{63RJS4ZW.js → IUMTWQJI.js} +1 -1
- package/dist/cdn/{AVQKKIKL.js → KVH3PDVW.js} +1 -1
- package/dist/cdn/MP7AEALE.js +2 -0
- package/dist/cdn/{L5TVHUCT.js → NXIQDF7N.js} +1 -1
- package/dist/cdn/{5HPWBCKJ.js → O5QYUL5C.js} +1 -1
- package/dist/cdn/{Z6ZNHTPJ.js → RBFFW5ZM.js} +27 -27
- package/dist/cdn/SOPNKXO5.js +2 -0
- package/dist/cdn/{5BADCY6B.js → TTLSUI5H.js} +1 -1
- package/dist/cdn/{FARA7SPN.js → UX7NRZPV.js} +1 -1
- package/dist/cdn/VJGA26MX.js +2 -0
- package/dist/cdn/X34ZV777.js +225 -0
- package/dist/cdn/{GRUIRS5W.js → YGW7TUNX.js} +1 -1
- package/dist/cdn/assets/assistant-chat-card/t9n/messages.en.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/cdn/main.css +1 -1
- package/dist/components/arcgis-assistant/customElement.d.ts +4 -0
- package/dist/components/arcgis-assistant/customElement.js +30 -30
- package/dist/components/arcgis-assistant-chat/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat/customElement.js +7 -7
- package/dist/components/arcgis-assistant-chat-card/customElement.d.ts +6 -0
- package/dist/components/arcgis-assistant-chat-card/customElement.js +101 -25
- package/dist/components/arcgis-assistant-chat-entry/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-chat-entry/customElement.js +129 -33
- package/dist/components/arcgis-assistant-chat-entry/index.js +1 -0
- package/dist/components/arcgis-assistant-chat-entry-speech-input/customElement.d.ts +26 -0
- package/dist/components/arcgis-assistant-chat-entry-speech-input/customElement.js +437 -0
- package/dist/components/arcgis-assistant-chat-entry-speech-input/index.js +2 -0
- package/dist/components/arcgis-assistant-chat-entry-speech-input/support/types.d.ts +15 -0
- package/dist/components/arcgis-assistant-shell/customElement.d.ts +2 -0
- package/dist/components/arcgis-assistant-shell/customElement.js +6 -6
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/vscode.html-custom-data.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/index.d.ts +10 -8
- package/dist/loader.js +6 -7
- package/dist/types/lumina.d.ts +16 -15
- package/dist/types/preact.d.ts +17 -17
- package/dist/types/react.d.ts +18 -19
- package/dist/types/stencil.d.ts +16 -15
- package/package.json +6 -6
- package/dist/cdn/6T2EIYO4.js +0 -59
- package/dist/cdn/B7LZV76W.js +0 -2
- package/dist/cdn/BTK65AMF.js +0 -2
- package/dist/cdn/EP54VHGN.js +0 -2
- package/dist/cdn/GHAVT5EV.js +0 -2
- package/dist/cdn/HN2HMAMX.js +0 -28
- package/dist/cdn/TX5YYQZP.js +0 -2
- package/dist/cdn/UASXQEPJ.js +0 -3
- package/dist/cdn/VIXYCCHV.js +0 -275
- package/dist/cdn/X7WF7TCS.js +0 -2
- package/dist/cdn/ZLYDPB4L.js +0 -2
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.d.ts +0 -8
- package/dist/components/arcgis-assistant-layer-filter-agent/customElement.js +0 -26
- package/dist/components/arcgis-assistant-layer-filter-agent/index.js +0 -1
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.d.ts +0 -8
- package/dist/components/arcgis-assistant-layer-query-agent/customElement.js +0 -26
- package/dist/components/arcgis-assistant-layer-query-agent/index.d.ts +0 -1
- package/dist/components/arcgis-assistant-layer-query-agent/index.js +0 -1
- /package/dist/components/{arcgis-assistant-layer-filter-agent → arcgis-assistant-chat-entry-speech-input}/index.d.ts +0 -0
|
@@ -27,11 +27,15 @@ Validator: Before producing output, verify every field used exists in the listed
|
|
|
27
27
|
|
|
28
28
|
## Input
|
|
29
29
|
|
|
30
|
-
Use the most recent relevant user question from the chat history.
|
|
30
|
+
Use the most recent relevant user question from the chat history.
|
|
31
31
|
|
|
32
|
-
###
|
|
32
|
+
### Fresh WHERE clause rule
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Start with a fresh WHERE clause for each new question. Do not inherit filters from previous questions UNLESS the user explicitly references previous results (see "Referencing Previously Identified Features" below).
|
|
35
|
+
|
|
36
|
+
### Rules for generating WHERE clause SQL expressions:
|
|
37
|
+
|
|
38
|
+
- Use only the field's **\`name\`** in the output expression.
|
|
35
39
|
- Use metadata (\`alias\`, \`description\`, \`statistics\`) only to help understand the user's meaning \u2014 not in the syntax.
|
|
36
40
|
- Use field \`type\` to choose appropriate operators:
|
|
37
41
|
- **String** \u2192 \`LIKE '%value%'\`, \`=\`, \`IN (...)\` (prefer \`LIKE\` over \`=\`)
|
|
@@ -43,6 +47,16 @@ Use the most recent relevant user question from the chat history. The question w
|
|
|
43
47
|
- **Range domain fields** \u2192 Use the listed min/max as valid bounds for comparisons.
|
|
44
48
|
- If no meaningful layer filter can be generated, do not call a tool.
|
|
45
49
|
|
|
50
|
+
## Referencing Previously Identified Features
|
|
51
|
+
|
|
52
|
+
This is an exception to the "fresh WHERE clause" rule above.
|
|
53
|
+
|
|
54
|
+
When the user uses words like "these", "those", "them", "the same ones" referring to features from a previous turn:
|
|
55
|
+
|
|
56
|
+
- If the previous query used useCurrentExtent: true \u2192 use useCurrentExtent: true with where: "1=1"
|
|
57
|
+
- If the previous assistant response mentions specific objectIds or feature IDs \u2192 use {{objectIdField}} IN (id1, id2, ...) to scope to those features
|
|
58
|
+
- If neither is available, use the same WHERE clause and layer from the previous query turn to re-select the same features
|
|
59
|
+
|
|
46
60
|
### Mixed Questions
|
|
47
61
|
|
|
48
62
|
If a question has both aggregate and display components (e.g., "How many wells have depth > 100? Show them"):
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{a as v,b as y}from"./UGJXHTYH.js";import{a as b}from"./H3DVSYQV.js";import"./YGW7TUNX.js";import{g as p,h as s,n as g,t as u,u as _,v as m,z as f}from"./WRENCTR3.js";import"./CFDTXKJ6.js";export default $arcgis.t(([{watch:x},k,{property:$,subclass:w}])=>{var L=p`:host{display:block;container-type:inline-size}.assistant-chat-card__prompt-container{display:flex;align-items:center;gap:var(--calcite-spacing-md);background:color-mix(in srgb,var(--calcite-color-brand) 25%,transparent);color:var(--calcite-color-text-1);padding:var(--calcite-spacing-md);border-radius:var(--calcite-border-radius);width:fit-content;margin-left:auto;justify-content:flex-end}.assistant-chat-card__prompt-avatar{display:flex;align-items:center;justify-content:center}.assistant-chat-card__content-container{display:flex;flex:1;flex-direction:column;width:100%}.assistant-chat-card__response-container{display:flex;flex-direction:column;align-items:flex-start;gap:var(--calcite-spacing-sm);width:100%;text-align:left}.assistant-chat-card__response-icon{padding:var(--calcite-spacing-sm);border-radius:var(--calcite-spacing-xl);background:var(--calcite-color-brand);color:var(--calcite-color-foreground-1)}.assistant-chat-card__footer{display:flex;width:100%;justify-content:space-between;padding:0 var(--calcite-spacing-xxs)}.assistant-chat-card__feedback-actions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xxs)}.assistant-chat-card__log-container{padding:0 var(--calcite-spacing-sm);border-radius:var(--calcite-border-radius);margin-bottom:var(--calcite-spacing-sm)}.assistant-chat-card__log{margin:0;background-color:var(--calcite-color-foreground-1);width:100%;max-height:300px;overflow:auto}.assistant-chat-card__log-entry{margin-left:var(--calcite-spacing-sm);padding:var(--calcite-spacing-xxs) var(--calcite-spacing-lg);border-left:1px solid var(--calcite-color-border-1)}.assistant-chat-card__footer-start,.assistant-chat-card__footer-end{display:flex;gap:var(--calcite-spacing-xxs)}@container (min-width: 480px){.assistant-chat-card__prompt-container,.assistant-chat-card__response-container{max-width:80%}}`,A=Object.defineProperty,E=Object.getOwnPropertyDescriptor,h=(a,t,i,n)=>{for(var o=n>1?void 0:n?E(t,i):t,e=a.length-1,c;e>=0;e--)(c=a[e])&&(o=(n?c(t,i,o):c(o))||o);return n&&o&&A(t,i,o),o};function l(){return typeof window>"u"?null:window}var r=class extends k{constructor(){super(...arguments),this._utterance=null,this.state="idle",this.supported=r.isSupported()}destroy(){this.stop(),super.destroy()}start(a){let t=a.trim(),i=l(),n=i?.SpeechSynthesisUtterance,o=i?.speechSynthesis;if(this._set("supported",r.isSupported(i)),!t||!n||!o)return;this.stop();let e=new n(t);e.rate=.9,e.pitch=1.1,e.volume=1,e.onend=()=>{this._utterance===e&&this._reset()},e.onerror=()=>{this._utterance===e&&this._reset()};try{o.speak(e),this._utterance=e,this._set("state","playing")}catch{e.onend=null,e.onerror=null,this._reset()}}stop(){let a=l(),t=a?.speechSynthesis;if(this._set("supported",r.isSupported(a)),t)try{(t.speaking||t.pending)&&t.cancel()}catch{}this._reset()}toggle(a){if(this.state==="playing"){this.stop();return}this.start(a)}static isSupported(a=l()){return!!a?.speechSynthesis&&typeof a.SpeechSynthesisUtterance=="function"}_reset(){this._utterance&&(this._utterance.onend=null,this._utterance.onerror=null),this._utterance=null,this._set("state","idle")}};h([$({readOnly:!0})],r.prototype,"state",2);h([$({readOnly:!0})],r.prototype,"supported",2);r=h([w("ReadAloudController")],r);var d=class extends m{constructor(){super(...arguments),this._messages=b({blocking:!0}),this._endRef=u(),this._readAloudController=new r,this._showLog=!1,this.loading=!1,this.feedbackEnabled=!1,this.logEnabled=!1,this.copyEnabled=!1,this.readAloudEnabled=!1,this.arcgisFeedback=g()}static{this.properties={_showLog:16,_role:16,_content:16,_log:16,_error:16,_feedback:16,loading:5,messageRole:1,feedbackEnabled:5,logEnabled:5,copyEnabled:5,readAloudEnabled:5,content:1,loadingMessage:1,log:0,error:1,user:1,message:0}}static{this.styles=L}get _role(){return this.message?.role??this.messageRole}get _content(){return this.message?.content??this.content}get _log(){return(this.message?.role==="assistant"?this.message?.log:void 0)??this.log}get _error(){return(this.message?.role==="assistant"?this.message?.error:void 0)??this.error}get _feedback(){return this.message?.role==="assistant"?this.message?.feedback?.positive:void 0}loaded(){this.manager.onLifecycle(()=>[x(()=>this._showLog,()=>this._scrollToEnd()),x(()=>this._readAloudController.state,()=>this.requestUpdate(),{initial:!0})])}disconnectedCallback(){super.disconnectedCallback(),this._readAloudController.destroy()}_scrollToEnd(){requestAnimationFrame(()=>{this._endRef.value?.scrollIntoView({behavior:"smooth",block:"end"})})}_handleFeedback(t){this.message?.role==="assistant"&&(this.message.feedback=this.message.feedback?.positive===t?void 0:{positive:t},this.arcgisFeedback.emit(this.message),this.requestUpdate())}_toggleReadAloud(){this._readAloudController.toggle(this._content??"")}_renderLog(){return this._log&&this._showLog&&this.logEnabled?s`<div class="assistant-chat-card__log-container"><div class="assistant-chat-card__log"><calcite-accordion appearance=transparent icon-position=start icon-type=chevron scale=s>${this._log.map(t=>{let i=t.includes(`
|
|
3
|
+
`)||t.length>70;return s`<calcite-accordion-item .heading=${i?`${t.substring(0,70)}...`:t} .expanded=${i}><div class="assistant-chat-card__log-entry">${i?v(y(t)):null}</div></calcite-accordion-item>`})}</calcite-accordion></div></div>`:null}_renderThumbsUpButton(){return s`<calcite-action id=action-thumbs-up icon=thumbs-up scale=s .active=${this._feedback===!0} @click=${()=>this._handleFeedback(!0)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-up overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsUpLabel}</span></calcite-tooltip>`}_renderThumbsDownButton(){return s`<calcite-action id=action-thumbs-down icon=thumbs-down scale=s .active=${this._feedback===!1} @click=${()=>this._handleFeedback(!1)} text></calcite-action><calcite-tooltip reference-element=action-thumbs-down overlay-positioning=fixed placement=bottom><span>${this._messages.thumbsDownLabel}</span></calcite-tooltip>`}_renderFeedback(){return this.feedbackEnabled&&!this._error?s`<div class="assistant-chat-card__feedback-actions">${this._renderThumbsUpButton()}${this._renderThumbsDownButton()}</div>`:null}_renderCopyButton(){return!this._error&&this.copyEnabled?s`<calcite-action id=action-copy icon=copy-to-clipboard scale=s @click=${async()=>{try{this._content&&await navigator.clipboard.writeText(this._content)}catch(t){console.error("Failed to copy text to clipboard:",t)}}} text></calcite-action><calcite-tooltip reference-element=action-copy overlay-positioning=fixed placement=bottom><span>${this._messages.copyButtonLabel}</span></calcite-tooltip>`:null}_renderLogButton(){return this._log&&this.logEnabled?s`<calcite-action id=action-log icon=access-string-results scale=s @click=${()=>this._showLog=!this._showLog} .text=${this._messages.logButtonLabel} .active=${this._showLog}></calcite-action><calcite-tooltip reference-element=action-log overlay-positioning=fixed placement=bottom><span>${this._messages.logButtonLabel}</span></calcite-tooltip>`:null}_renderReadAloudButton(){return this.readAloudEnabled&&!this._error&&this._content?.trim()&&this._readAloudController.supported?s`<calcite-action id=action-read-aloud .icon=${this._readAloudController.state==="playing"?"sound-off":"sound"} scale=s .active=${this._readAloudController.state==="playing"} @click=${()=>this._toggleReadAloud()} text></calcite-action><calcite-tooltip reference-element=action-read-aloud overlay-positioning=fixed placement=bottom><span>${this._readAloudController.state==="playing"?this._messages.stopReadingButtonLabel:this._messages.readAloudButtonLabel}</span></calcite-tooltip>`:null}_renderFooter(){return this.loading?null:s`<div class="assistant-chat-card__footer"><div class="assistant-chat-card__footer-start">${this._renderCopyButton()}${this._renderLogButton()}${this._renderReadAloudButton()}<slot name=footer-actions-start></slot></div><div class="assistant-chat-card__footer-end"><slot name=footer-actions-end></slot>${this._renderFeedback()}</div></div>`}render(){return this._role==="user"?s`<div class="assistant-chat-card__prompt-container"><div>${this._content}</div><div class="assistant-chat-card__prompt-avatar"><calcite-avatar .fullName=${this.user} scale=s></calcite-avatar></div></div>`:s`<div class="assistant-chat-card__response-container"><calcite-icon icon=effects class="assistant-chat-card__response-icon" scale=s></calcite-icon><div class="assistant-chat-card__content-container"><arcgis-assistant-chat-card-content .loading=${this.loading} .loadingMessage=${this.loadingMessage} .type=${this._error?"error":"text"} .content=${this._error??this._content}></arcgis-assistant-chat-card-content>${this._renderLog()}${this._renderFooter()}</div><div ${_(this._endRef)}></div></div>`}};f("arcgis-assistant-chat-card",d);return d},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators")
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import a from"./AAEEDEN7.js";import{a as k}from"./H3DVSYQV.js";import{a as C}from"./KVH3PDVW.js";import"./YGW7TUNX.js";import{g as v,h,l as _,n as o,t as u,u as m,v as f,z as E}from"./WRENCTR3.js";import"./CFDTXKJ6.js";export default $arcgis.t(([I,{whenOnce:S,watch:L,when:P},O,A,{property:p,subclass:M},{x:w}])=>{var x=v`:host{display:block;width:var(--arcgis-internal-panel-width, 100%);height:var(--arcgis-internal-expand-max-height, 100%)}`,R=Object.defineProperty,z=Object.getOwnPropertyDescriptor,l=(c,t,e,i)=>{for(var s=i>1?void 0:i?z(t,e):t,r=c.length-1,n;r>=0;r--)(n=c[r])&&(s=(i?n(t,e,s):n(s))||s);return i&&s&&R(t,e,s),s},a=class extends A{constructor(c){super(c),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 S(()=>!this.view.updating),this._set("orchestrator",await w.init({agents:[...this.agents],view:this.view??void 0})),this.addHandles([L(()=>[this.view,this.agents],()=>void this._initialize())])}clearChatHistory(){this.orchestrator?.newConversation()}async*ask(c,t){if(!this.orchestrator)throw new Error("Orchestrator not initialized yet.");this._set("processing",!0),this._set("processingStep","");let e=[];try{let i=this.orchestrator.ask(c);for await(let s of i){let r=s.runId;if(t?.aborted){yield{type:"cancelled",runId:r};break}switch(s.type){case"trace":{this._set("processingStep",s.data.text),e.push(s.data.text);break}case"completed":{if(!s.result.content.length){yield{type:"completed",error:"Could not process the request.",log:e,runId:r};return}let n=s.result.content;this._set("processingStep",""),yield{type:"completed",response:n,log:e,runId:r};return}case"interrupt":{let{kind:n,message:d,metadata:b}=s.interrupt,g=Array.isArray(b)?[...b]:[],$=(()=>{switch(n){case"booleanChoice":return{type:"boolean-choice",message:d,options:g};case"singleSelection":return{type:"single-select",message:d,options:g};case"multipleSelection":return{type:"multi-select",message:d,options:g};case"textInput":return{type:"text-input",message:d};default:return{type:n,message:d,options:g}}})();this._set("processingStep","Waiting for user input..."),yield{type:"interrupt",payload:$,runId:r};break}case"cancelled":{yield{type:"cancelled",runId:r};return}case"error":{yield{type:"completed",error:s.error.message,log:e,runId:r};return}default:{console.warn("Unknown event type:",s);break}}}}catch(i){console.warn("Error during message processing:",i),yield{type:"completed",error:"An error occurred during message processing.",log:e,runId:"error"};return}finally{this._set("processing",!1)}}};l([p({readOnly:!0})],a.prototype,"orchestrator",2);l([p()],a.prototype,"agents",2);l([p()],a.prototype,"portal",2);l([p()],a.prototype,"view",2);l([p({readOnly:!0})],a.prototype,"loading",2);l([p({readOnly:!0})],a.prototype,"processing",2);l([p({readOnly:!0})],a.prototype,"processingStep",2);a=l([M("OrchestratorController")],a);var H="Embeddings resource 'embeddings-v01.json' not found in the webmap portal item.",j="Embeddings not found for this web map.",F="https://developers.arcgis.com/javascript/latest/agentic-apps/ai-webmap-setup/#embeddings",y=class extends f{constructor(){super(...arguments),this._messages=k({blocking:!0}),this.#t=u(),this.#e=u(),this.#s=null,this.#o=new Map,this.#r=O.getDefault(),this.#i=t=>{t.stopPropagation(),this.arcgisInterruptCancel.emit(),this.orchestrator?.cancelInterrupt(),this._interrupt=null},this.#a=t=>{t.stopPropagation();let e=t.detail;this.arcgisInterruptSubmit.emit(e),this.orchestrator?.resumeInterrupt(e),this._interrupt=null},this.#n=t=>{t.stopPropagation(),this.keepSuggestedPrompts||(this.suggestedPrompts=[]);let e=t.detail;this.arcgisSubmit.emit(e),this.submitMessage(e)},this.#l=t=>{if(t.stopPropagation(),this.arcgisCancel.emit(),this._interrupt){this.orchestrator?.cancelInterrupt(),this._interrupt=null;return}this.#s?.abort()},this.#c=t=>{t.stopPropagation();let e=t.detail;this.arcgisFeedback.emit(e)},this._orchestratorController=null,this._interrupt=null,this._error=null,this.messages=new I([]),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=o(),this.arcgisError=o(),this.arcgisFeedback=o(),this.arcgisInterrupt=o(),this.arcgisInterruptCancel=o(),this.arcgisInterruptSubmit=o(),this.arcgisReady=o(),this.arcgisSubmit=o()}static{this.properties={_orchestratorController:16,_interrupt:16,_error:16,_user:16,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=x}#t;#e;#s;#o;#r;#i;#a;#n;#l;#c;async#h(){try{let t=C(this.el,this.referenceElement);await t?.componentOnReady();let e=[...this.#o.values()];return e.length?(this._orchestratorController=new a({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 orchestrator(){return this._orchestratorController?.orchestrator}async clearChatHistory(){this._reset(),this._orchestratorController?.clearChatHistory()}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,log:s.log,error:s.error,id:r});break;case"interrupt":this._interrupt={...s.payload,id:r};break;case"cancelled":this.messages.push({role:"assistant",error:"Request cancelled.",id:r});break}}}load(){this.manager.onLifecycle(this._reset.bind(this))}loaded(){this.manager.onLifecycle(()=>{this.#t.value?.addEventListener("arcgisSubmit",this.#n),this.#t.value?.addEventListener("arcgisCancel",this.#l),this.#t.value?.addEventListener("arcgisFeedback",this.#c);let t=P(()=>!!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}),this._interrupt&&this.arcgisInterrupt.emit(this._interrupt)});return queueMicrotask(()=>{this.#h().then(e=>{e?this.arcgisReady.emit():this._error&&this.arcgisError.emit(new Error(this._error))})}),()=>{t.remove(),this.#e.value?.removeEventListener("arcgisSubmit",this.#a),this.#e.value?.removeEventListener("arcgisCancel",this.#i),this.#t.value?.removeEventListener("arcgisSubmit",this.#n),this.#t.value?.removeEventListener("arcgisCancel",this.#l),this.#t.value?.removeEventListener("arcgisFeedback",this.#c),this._orchestratorController?.destroy(),this._orchestratorController=null}})}_reset(){this.#s?.abort(),this._interrupt=null,this.messages.removeAll(),this._error=null}_renderErrorNotice(){return this._error?h`<calcite-notice closable slot=entry-message open kind=danger icon width=full>${this._error===H?h`<div slot=message>${j}</div><calcite-link slot=link .href=${F} target=_blank title="Learn about web map embeddings">Read more</calcite-link>`:h`<div slot=message>${this._error}</div>`}</calcite-notice>`:null}render(){return h`<arcgis-assistant-shell .loading=${!this._orchestratorController&&!this._error||this._orchestratorController?.loading} .heading=${this.heading??this._messages.assistantLabel} .description=${this.description} .entryMessage=${this.entryMessage} .entryMessageClosed=${this.messages.length>0} .awaitingResponse=${this._orchestratorController?.processing} .suggestedPrompts=${this.suggestedPrompts} .messages=${this.messages} .voiceInputEnabled=${this.voiceInputEnabled} ${m(this.#t)}>${this._renderErrorNotice()}${this._interrupt?h`<arcgis-assistant-interrupt slot=entry-message .type=${this._interrupt.type} .message=${this._interrupt.message} .options=${this._interrupt.options} ${m(this.#e)}></arcgis-assistant-interrupt>`:null}<arcgis-assistant-chat .loading=${this._orchestratorController?.processing} .loadingMessage=${this._orchestratorController?.processingStep||""} .messages=${this.messages} .user=${this._user} .feedbackEnabled=${this.feedbackEnabled} .logEnabled=${this.logEnabled} .copyEnabled=${this.copyEnabled} .readAloudEnabled=${this.readAloudEnabled}><slot></slot></arcgis-assistant-chat><slot name=header-actions-end slot=header-actions-end></slot>${this.entryMessage?null:h`<slot name=entry-message slot=entry-message></slot>`}<slot name=entry-actions-start slot=entry-actions-start></slot><slot name=footer-content slot=footer-content></slot></arcgis-assistant-shell>`}};E("arcgis-assistant",y);return y},"core/Collection","core/reactiveUtils","portal/Portal","core/Accessor","core/accessorSupport/decorators",a)
|