@arcgis/coding-components 5.1.0-next.0 → 5.1.0-next.2
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/GNJO6WNS.js +2 -0
- package/dist/cdn/{ASVCAO4G.js → HC6SQXXT.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +56 -51
- package/dist/components/arcgis-arcade-editor/customElement.js +65 -56
- 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/package.json +5 -5
- package/dist/cdn/6QWZ6LSH.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import d from"./4Y64BGY2.js";import c from"./BYO7RLJT.js";import{a as k}from"./ZYS253RG.js";import b from"./RXNRHK3U.js";import"./P5D2YYFD.js";import a from"./Z56TGOZF.js";import"./IFNCCZ7O.js";import"./3FSDLLYC.js";import"./NKCYMRE4.js";import"./3B6KNFHK.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{D as y,E as C,F as D,G as r,J as I,K as B,h as E,j as s,l as $,n as S,s as R}from"./EMMNZESW.js";import{a as w,b as o}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import{Rk as L}from"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([U,,l,{a:T,b:F},{a:M,h:b}])=>{var j=E`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}.main-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}`,z="https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0",a=(i,e)=>w(i,"Arcade Assistant",e),H=i=>{let{aiAssistantsEnabled:e}=i;return e===void 0?(a("warn","`areAiAssistantsEnabled` is not defined in the organizations settings."),!1):e},V=i=>!(!i||!("id"in i)),G=async i=>(await U.getCredential(i,{oAuthPopupConfirmation:!1})).token,q=async i=>{try{return!!await U.checkSignInStatus(i)}catch{return a("warn","User is not signed in."),!1}};async function X({portalUrl:i,profile:e}){if(!V(e))return a("warn","Addon initialization failed. Reason: unsupported profile."),{shouldRender:!1};let t=i.replace(/\/sharing\/rest(\/.*)?$/iu,"").replace(/\/$/u,"");if(!await q(t))return{shouldRender:!1};let n=await G(i),c=`${t}/sharing/rest/portals/self?f=json&token=${n}`,h=`${t}/sharing/rest/portals/self/settings?f=json&token=${n}`,p=`${t}/sharing/rest/portals/self/signinSettings?f=json&token=${n}`,u=await Promise.allSettled([fetch(c,{credentials:"include"}).then(d=>d.json()),fetch(h,{credentials:"include"}).then(d=>d.json()),fetch(p,{credentials:"include"}).then(d=>d.json())]),[g,_,m]=u,f=g.status==="fulfilled"?g.value:(a("warn",`Failed to fetch selfUrl. Reason: ${g.reason}.`),{}),x=_.status==="fulfilled"?_.value:(a("warn",`Failed to fetch settingsUrl. Reason: ${_.reason}.`),{}),N=m.status==="fulfilled"?m.value:(a("warn",`Failed to fetch signinSettingsUrl. Reason: ${m.reason}.`),{}),v=f?.helperServices?.aiAssistantServices?.url;if(!v)return a("warn","Service URL is not available in the portal self response."),{shouldRender:!1};let O=f.helpBase||"";if(!x)return a("warn","Settings response is not available."),{shouldRender:!1};let A=H(x);return N.blockBetaApps===!0&&(a("warn","Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."),A=!1),f?.user?.privileges?.includes("portal:user:useAIAssistants")||(a("warn","User does not have the required privileges to use AI Assistants."),A=!1),{shouldRender:!0,serviceUrl:v,helpBase:O,assistantsEnabled:A,feedbackServiceUrl:z}}var P=class extends D{constructor(){super(...arguments),this._codeEditorElt=y(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this.messages=k(),this._modelId=R(),this._openArcadeHelp=()=>void window.open(M,"Arcade Help"),this._toggleSidePanel=e=>{if(!e.target)return;let t=e.target?.dataset.panelName??"none";this.openedSidePanel=t===this.openedSidePanel?"none":t,this.openedSidePanel==="none"&&this._codeEditorElt.value?.setFocus().catch(o(this))},this._consoleLogs=[],this._executingScript=!1,this._preparingArcade=!1,this._resultPanel="output",this._showExecutionPanel=!1,this._arcadeAssistantRemoteState={shouldRender:!1},this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.arcgisDiagnosticsChange=S({bubbles:!1}),this.arcgisScriptChange=S({bubbles:!1})}static{this.properties={_apiLibrary:16,_consoleLogs:16,_editorProfile:16,_executingScript:16,_executionResult:16,_preparingArcade:16,_resultPanel:16,_showExecutionPanel:16,_arcadeAssistantRemoteState:16,editorInstance:32,editorOptions:0,hideDocumentationActions:5,hideSideBar:5,openedSidePanel:3,profile:0,script:1,sideActionBarExpanded:7,snippets:0,suggestions:0,testData:0,customPanels:0,arcadeAssistant:0}}static{this.styles=[j]}get editorInstance(){return this._codeEditorElt.value?.editorInstance}async getTestResult(){if(!this.testData)return{type:"error",value:"Missing test data",error:null};let e=await this._editorProfilePromise;if(!e)return{type:"error",value:"Missing editor profile",error:null};await this._componentReadyDefer.promise;let t=this._codeEditorElt.value?.value;return await b(e.definition,t,this.testData)}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async load(){let e=B("./assets");T(e),await this._updateDataModelDeps(),await this._updateArcadeAssistantRemoteState()}willUpdate(e){(e.has("messages")||e.has("profile"))&&this.hasUpdated&&this._updateDataModelDeps(),e.has("testData")&&this._testDataChanged(),e.has("snippets")&&l.updateApiContextForModel(this._modelId,{snippets:this.snippets}),e.has("arcadeAssistant")&&this._updateArcadeAssistantRemoteState()}async loaded(){this._componentReadyDefer.resolve(),await this._updateApiLibrary();let e=await F();this._disposables.push(e.onDiagnosticsChange(t=>!this._preparingArcade&&this.arcgisDiagnosticsChange.emit(t.diagnostics))),this.testData&&this._addExecuteScriptAction()}disconnectedCallback(){for(super.disconnectedCallback();this._disposables.length;)this._disposables.pop()?.dispose()}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}_testDataChanged(){!this.testData&&this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this.testData&&!this._executeScriptAction&&this._addExecuteScriptAction(),this._showExecutionPanel&&this._executeScript().catch(o(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await l.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=l.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await l.getApiLibraryForModel(this._modelId)}async _executeScript(){let e=this.testData;if(!this._codeEditorElt.value||!e)return;let t=await this._editorProfilePromise;if(!t){this._executionResult={type:"error",value:"Missing editor profile",error:null};return}this._showExecutionPanel=!0,this._executingScript=!0,this._consoleLogs=[],setTimeout(()=>void(async()=>{let n=this._codeEditorElt.value?.value;this._executionResult=await b(t.definition,n,e,c=>setTimeout(()=>this._consoleLogs=[...this._consoleLogs,c],0)),this._executingScript=!1})(),0)}_toggleShowExecutionPanel(){this._showExecutionPanel=!this._showExecutionPanel}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}_onCodeEditorValueChange(e){e.stopPropagation(),this.script=e.detail,this.arcgisScriptChange.emit(e.detail)}_insertAsSnippet(e){this._codeEditorElt.value?.insertSnippet(e.detail).catch(o(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(o(this))}_onResultPanelChange(e){let t=e.currentTarget;this._resultPanel=t.openedResultPanel}_onExecutionPanelClose(){this._showExecutionPanel=!1}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[L.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this.testData&&this._executeScript().catch(o(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e))}_disposeSafely(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1),e.dispose()}async _updateArcadeAssistantRemoteState(){this.arcadeAssistant&&(this._arcadeAssistantRemoteState=await X({...this.arcadeAssistant,profile:this.profile}))}renderMainActionBar(){return this.testData?s`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${()=>void this._executeScript().catch(o(this))}></calcite-action>${this._executionResult?s`<calcite-action .text=${this.messages.lastresults??""} .active=${this._showExecutionPanel} text-enabled icon=access-string-results icon-flip-rtl scale=s @click=${this._toggleShowExecutionPanel}></calcite-action>`:null}</calcite-action-group></calcite-action-bar>`:null}renderMainPanel(){return s`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${l.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${C(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:t,icon:n,active:c,panelName:h,iconFlipRtl:p=!1,onClick:u=this._toggleSidePanel}){return s`<calcite-action id=${e??$} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${n} .active=${c} @click=${u} data-panel-name=${h??$} .iconFlipRtl=${p}></calcite-action>${!this.sideActionBarExpanded&&s`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:s`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({id:"profile-variables-action",label:this.messages.profilevariables??"",icon:"profile-variables",active:this.openedSidePanel==="variables",panelName:"variables"})}${this.renderAction({id:"function-action",label:this.messages.constantsandfunctions??"",icon:"function",active:this.openedSidePanel==="api",panelName:"api"})}${this.suggestions?.length?this.renderAction({id:"suggestions-action",label:this.messages.suggestions??"",icon:"lightbulb",active:this.openedSidePanel==="suggestions",panelName:"suggestions"}):null}${this._arcadeAssistantRemoteState.shouldRender&&this.renderAction({id:"arcade-assistant-action",label:this.messages.arcadeassistant??"Arcade assistant",icon:"effects",active:this.openedSidePanel==="arcade-assistant",panelName:"arcade-assistant"})||""}${this.customPanels?.map(e=>e.enabled===!1?null:this.renderAction({id:e.id,label:e.name,icon:e.icon,active:this.openedSidePanel===e.id,panelName:e.id}))}${this.hideDocumentationActions?null:this.renderAction({id:"developer-website-action",label:this.messages.help??"",icon:"question",active:!1,panelName:"none",iconFlipRtl:this.messages._lang==="ar",onClick:this._openArcadeHelp})}</calcite-action-group></calcite-action-bar>`}renderSidePanel(){if(this.hideSideBar)return null;let{openedSidePanel:e}=this;return s`<arcgis-language-api-panel slot=side-panel class=${r(e==="api"?"":"hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .closed=${e!=="api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${r(e==="variables"?"":"hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e!=="variables"}></arcgis-editor-variables>${this.suggestions?.length&&s`<arcgis-arcade-suggestions slot=side-panel class=${r(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._toggleSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${this.arcadeAssistant&&this._arcadeAssistantRemoteState.shouldRender&&s`<arcgis-arcade-coding-assistant slot=side-panel class=${r(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._toggleSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${this._arcadeAssistantRemoteState.serviceUrl} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(t=>s`<calcite-flow slot=side-panel class=${r(e===t.id?"":"hidden")}>${t?.useFlows?t.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==t.id,editorRef:this.el}):s`<calcite-flow-item .heading=${t.name} heading-level=2 closable .closed=${e!==t.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${t.description}>${t.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==t.id,editorRef:this.el})}</calcite-flow-item>`}</calcite-flow>`)}`}renderResultsPanel(){return this._showExecutionPanel?s`<arcgis-arcade-results slot=results-panel .openedResultPanel=${this._resultPanel} .loading=${this._executingScript} .result=${this._executionResult} .consoleLogs=${this._consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`:null}render(){return s`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};I("arcgis-arcade-editor",P);return P},"identity/IdentityManager",a,b,c,d)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import{a as oe}from"./ZYS253RG.js";import"./MP6Z45SA.js";import b from"./RXNRHK3U.js";import"./P5D2YYFD.js";import a from"./Z56TGOZF.js";import{d as ce}from"./IFNCCZ7O.js";import{c as ne,d as re}from"./3FSDLLYC.js";import"./NKCYMRE4.js";import"./3B6KNFHK.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{A as X,B as Z,C as U,D as ee,E as te,F as ie,G as ae,H as O,J as se,h as W,j as p,k as P,l as _,s as K,v as N,w as q,x as D,y as I,z as k}from"./EMMNZESW.js";import{a as T}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([Se,pe,Te,Ae,Ce,{getDeclaredVoxelMembers:Ie,getDeclaredPixelMembers:Me},Ee,{property:w,subclass:Re},{g:le,h:F},z])=>{var de=(t,e,i)=>{let a=new Map;for(let s=e;s<=i;s++)a.set(t[s],s);return a},L=q(class extends D{constructor(t){if(super(t),t.type!==N.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,i){let a;i===void 0?i=e:e!==void 0&&(a=e);let s=[],n=[],l=0;for(let d of t)s[l]=a?a(d,l):l,n[l]=i(d,l),l++;return{values:n,keys:s}}render(t,e,i){return this.dt(t,e,i).values}update(t,[e,i,a]){let s=Z(t),{values:n,keys:l}=this.dt(e,i,a);if(!Array.isArray(s))return this.ut=l,n;let d=this.ut??=[],c=[],o,g,r=0,u=s.length-1,m=0,h=n.length-1;for(;r<=u&&m<=h;)if(s[r]===null)r++;else if(s[u]===null)u--;else if(d[r]===l[m])c[m]=k(s[r],n[m]),r++,m++;else if(d[u]===l[h])c[h]=k(s[u],n[h]),u--,h--;else if(d[r]===l[h])c[h]=k(s[r],n[h]),I(t,c[h+1],s[r]),r++,h--;else if(d[u]===l[m])c[m]=k(s[u],n[m]),I(t,s[r],s[u]),u--,m++;else if(o===void 0&&(o=de(l,m,h),g=de(d,r,u)),o.has(d[r]))if(o.has(d[u])){let f=g.get(l[m]),S=f!==void 0?s[f]:null;if(S===null){let v=I(t,s[r]);k(v,n[m]),c[m]=v}else c[m]=k(S,n[m]),I(t,s[r],S),s[f]=null;m++}else U(s[u]),u--;else U(s[r]),r++;for(;m<=h;){let f=I(t,c[h+1]);k(f,n[m]),c[m++]=f}for(;r<=u;){let f=s[r++];f!==null&&U(f)}return this.ut=l,X(t,c),P}});var R=class extends D{constructor(e){if(super(e),this.it=_,e.type!==N.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===P)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let i=[e];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}};R.directiveName="unsafeHTML",R.resultType=1;var V=q(R);var Ve=W`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,A=class extends Error{constructor({message:e,code:i,subCode:a,details:s,source:n}){super(e),this.name="ArcadeAssistantError",this.code=i,this.subCode=a,this.details=s,this.source=n}};function ue(t){if(!t)return;let e=t.indexOf('{"error":');if(e!==-1)try{let i=t.slice(e),a=JSON.parse(i);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Pe(t){let{baseUrl:e,skillId:i,message:a,authToken:s,previousConversationId:n,context:l}=t,d=i?`${e}/skills/${i}/chat`:`${e}/chat`,c=[],o={message:a,context:l};n&&(o.conversation_id=n);let g;try{g=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(o),responseType:"json"})}catch(v){let $=v,C=$.details?.rawResponse||$.message||String(v),M=ue(C);throw M?new A(M):v}let r=g.data;c.push(r);let u=r.conversationId,m=r.inquiryId,h=r.sequenceNumber;async function f(){let v=0,$=100;for(;v<$;){await new Promise(E=>setTimeout(E,1e3));let C=Ne(u,h,m),M;try{M=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(C),responseType:"json"})}catch(E){let J=E,ke=J.details?.rawResponse||J.message||String(E),Y=ue(ke);throw Y?new A(Y):E}let x=M.data;if(x.context?.kind==="ArcgisErrorAsContext"&&x.context.error)throw new A({message:x.context.error.message||"ArcGIS Assistant error",code:x.context.error.code,subCode:x.context.error.subCode,details:x.context.error.details,source:"polling-response"});if(c.push(x),h=x.sequenceNumber,v++,!x.hasMore)break}if(v===$)throw new A({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let S=120*1e3;return await Promise.race([f(),new Promise((v,$)=>setTimeout(()=>$(new A({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),S))]),c}function Ne(t,e,i){return{conversationId:t,inquiryId:i,ackSequenceNumber:e}}function qe(t){return t.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":t.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":t.message}var De=({notices:t})=>t.length?p`<div class="border-block-end">${L(t,e=>e.id??e.title,e=>p`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&p`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&p`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Ue=t=>{let e=t.value.length,i=72,a=180,s=t.offsetWidth,n=Math.max(1,Math.floor(s/8)),l=Math.ceil(e/n),d=i+(l-2)*24;t.style.setProperty("--calcite-text-area-min-height",`${Math.min(d,a)}px`)},Oe=({promptValidationMessage:t,errorMessage:e,contextTooBig:i,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:s,setErrorMessage:n,messages:l})=>{let d=[];if(t&&d.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:t,closable:!0}),e&&d.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),i&&!a){let c=l.contextreduced??"Context reduced",o=l.contextreducedmessage??"The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";d.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:o,closable:!0,onClose:()=>s(!0)})}return d};function _e({messages:t}){return p`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta??"Beta"}>${t.beta??"Beta"}</calcite-chip>`}function Fe({popoverContent:t,messages:e}){return p`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer??"Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${t}</div></calcite-popover>`}function ze({errorMessage:t,slot:e}){return p`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??O}>${t}</calcite-input-message></div>`}function Le({active:t,setActive:e,messages:i}){return p`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${i.expressionapplied??"Expression applied"}><div slot=message>${i.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function Be({context:t,messages:e}){return t?p`<div class="gaps">${t.profileId&&p`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function je({isDisabled:t,isReadOnly:e,setQuestion:i,setIsViewingResult:a,textAreaRef:s,question:n,errorMessage:l,setErrorMessage:d,promptValidationMessage:c,setPromptValidationMessage:o,submitQuestion:g,messages:r,mode:u,assistantRef:m,context:h,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S}){let v=h?.contextTooLarge??!1,$=Oe({promptValidationMessage:c,errorMessage:l,contextTooBig:v,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S,setErrorMessage:d,messages:r});return p`<div class="text-area-wrapper">${De({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${t||e} class=${ae($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${r.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${C=>{Ue(C.target),i(C.target.value)}} ${te(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${h&&Be({context:h,messages:r})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async()=>{a(!1),i("")}} .label=${r.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${r.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async()=>{a(!1),i("")}} class="hidden-below-380" scale=s>${r.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-below-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-above-380" .label=${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}></calcite-button></div></div></div></calcite-text-area></div>`}var He="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function Ge({setOpen:t,messages:e,feedback:i,learnMoreUrl:a,setFeedback:s,onSubmit:n}){return i.active?p`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${()=>t(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${l=>s({...i,text:l.target.value})} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo??"Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${l=>{s({...i,termsAccepted:l.target.checked})}} .disabled=${i.submitting}></calcite-checkbox><span>${V((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Qe} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${He} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${V((e.feedbackhelps??"Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}",`<calcite-link href=${a} target="_blank">${e.learnmore??"Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${()=>t(!1)} .disabled=${i.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted||i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function me({assistantsEnabled:t,messages:e,slot:i,helpTopicUrl:a}){return p`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${i??O} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing??"Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new??"New"} kind=brand scale=s>${e.new??"New"}</calcite-chip></div>${t?p`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${V((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${a} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:p`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function Je({messages:t,onProceed:e,onExit:i,helpTopicUrl:a}){return p`<calcite-dialog close-disabled placement=top .heading=${t.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${V((t.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${a} target="_blank">${t.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ye({messages:t,suggestions:e,onSuggestionClick:i}){return p`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(a=>p`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${()=>i?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var he=200;function ge({hidden:t=!1,expanded:e=!1,messages:i,cards:a,heading:s,collapsible:n=!1,showEffectsIcon:l=!1,onCopyCode:d,standalone:c}){return p`<calcite-block .hidden=${t} id=result-block .heading=${s??i.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${l&&p`<calcite-chip .label=${i.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${i.assistantresponses??"Assistant responses"}>${L(a,o=>o.conversationId,o=>p`<calcite-card><div slot=heading><div class="prior-prompt"><span>${o.priorPrompt.length>he?`${o.priorPrompt.slice(0,he)}...`:o.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} @click=${g=>{let r=g.currentTarget;navigator.clipboard.writeText(o.priorPrompt).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${o.message&&c&&p`<div class="response-error-container">${ze({errorMessage:o.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext??"Response Context"} scale=s>${o.message&&!c&&p`<calcite-tooltip .referenceElement=${`response-chip-${o.conversationId}-error`} placement=top-start>${o.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${o.conversationId}-error`} .label=${i.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${We({card:o,messages:i})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${o.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start>${i.addtoeditor??"Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor??"Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${()=>o.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.replaceineditor??"Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${g=>{let r=g.currentTarget;d(o.code).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${o.onThumbsUp} .id=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${o.onThumbsDown} .id=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var We=({card:t,messages:e})=>{let i=K(),a=`response-chip-profile-${t.conversationId}-${i}`,s=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId);return p`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${a??O}>${t.profileId}</calcite-chip>`},be=t=>t.type==="featureSet",B=t=>{if(!le(t))return[];let e=[];return t.relationships?.forEach(i=>{e.push(i.toJSON())}),e},j=t=>t.length>0?{relationships:t}:{},Ke=t=>ce(t).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),H=t=>t?{fields:Ke(t)}:{fields:[]};async function fe(t){let e=await t.loadSource(),i=F(e)&&e.isTable,a=B(e);return{name:t.name,type:"featureSet",isTable:i,...H(e?.fields),...j(a)}}async function xe(t){switch(t.type){case"feature":{let e=await t.loadSource(),i=B(e);return{name:t.name,type:t.type,...H(e?.fields),...j(i)}}case"featureSet":{let e=await t.loadSource(),i=F(e)&&e.isTable;return{name:t.name,type:"featureSet",...i?{isTable:i}:{},...H(e?.fields),...j(B(e))}}case"featureSetCollection":{let e=await t.loadSource(),i=e?.layers.filter(be)??[],a=e?.tables.filter(be)??[],s=await Promise.all(i.map(fe)),n=await Promise.all(a.map(fe));return{name:t.name,type:"featureSetCollection",layers:s,tables:n}}case"dictionary":{let e=await Promise.all(t.dictionaryVariables.map(xe));return{name:t.name,type:"dictionary",attributes:e}}case"pixel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"pixel"};let i=await Me(e);return{name:t.name,type:"pixel",members:i.map(ve)}}case"voxel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"voxel"};let i=await Ie(e);return{name:t.name,type:"voxel",members:i.map(ve)}}case"array":return{name:t.name,type:"array",elementType:t.elementType.type};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:t.name,type:t.type}}}function ve(t){return t.type==="array"?{name:t.name,type:"array",elementType:t.elementType.type}:{name:t.name,type:t.type}}async function Xe(t){return{variables:await Promise.all(t.variables.map(xe))}}var Ze=1e5;function et(t){let e=new TextEncoder().encode(t).length;return Math.ceil(e/3.5)}function Q(t){return et(JSON.stringify(t))}function tt(t){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),i=a=>{switch(a.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:a.name,type:a.type,..."isTable"in a&&a.isTable?{isTable:a.isTable}:{},..."relationships"in a?{relationships:a.relationships}:{}};case"featureSetCollection":return{name:a.name,type:"featureSetCollection",layers:a.layers.map(e),tables:a.tables.map(e)};case"dictionary":return{name:a.name,type:"dictionary",attributes:a.attributes.map(i)};case"pixel":case"voxel":return{name:a.name,type:a.type};case"array":return{name:a.name,type:"array",...a.elementType?{elementType:a.elementType}:{}};default:return a}};return{variables:t.variables.map(i)}}function it(t){let e=t.variables,i=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],s=a?[a]:[];return{context:{variables:s},wasReduced:i!==s.length,reducedToVariableName:a?.name}}function at(t){return Q(t)>Ze}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,y=(t,e,i,a)=>{for(var s=a>1?void 0:a?ot(e,i):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(s=(a?l(e,i,s):l(s))||s);return a&&s&&st(e,i,s),s},b=class extends Ee{constructor(t){super(t),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};y([w()],b.prototype,"viewMode",2);y([w()],b.prototype,"confirmationActive",2);y([w()],b.prototype,"contextReducedNoticeDismissed",2);y([w()],b.prototype,"splashActive",2);y([w()],b.prototype,"isSubmitting",2);y([w()],b.prototype,"errorMessage",2);y([w()],b.prototype,"promptValidationMessage",2);y([w()],b.prototype,"question",2);y([w()],b.prototype,"history",2);y([w()],b.prototype,"feedback",2);y([w()],b.prototype,"context",2);b=y([Re("ArcadeAssistantViewState")],b);var nt="arcade_generation",rt="ArcadeCodeRequest",ye="visualization",ct="ArcadeAssistant",lt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras"],we=[],$e=!0,G=class extends ie{constructor(){super(...arguments),this.textAreaRef=ee(),this.messages=oe(),this._feedbackService=void 0,this.viewState=new b,this.handleFeedbackButton=(e,i)=>{this.updateViewState({feedback:{active:!0,value:e,item:i,termsAccepted:!1,text:"",submitting:!1}})},this.handleFeedbackSheetClose=()=>{this.updateViewState({feedback:{active:!1}})},this.handleFeedbackSubmit=async()=>{if(!this.viewState.feedback.active)return;this.updateViewState({feedback:{...this.viewState.feedback,submitting:!0}});let e=await this.ensureFeedbackService();if(!e){this.handleFeedbackSheetClose();return}let i=this.viewState.feedback.item.contextSnapshot,a=Ae.applicationName;!a&&!this.appVersion&&T("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:s,text:n,termsAccepted:l,item:{question:d,formattedScript:c,conversationId:o}}=this.viewState.feedback,g={user_evaluation:s,your_comments:n||void 0,question:d??"",answer:encodeURIComponent(c??""),useragent:navigator.userAgent,_source:ct,version:this.appVersion||a||"NOT_SET",context:i?JSON.stringify(i):"",extras:i?.profileId??"",conversation_id:o??"",privacy_statement:l?"I_agree":""};try{await e.applyEdits({addFeatures:[new Ce({attributes:g})]})}catch(r){T("error",this,"Error submitting feedback.",{detail:{error:r}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.assistantsEnabled=!1,this.closed=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,assistantsEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1}}static{this.styles=Ve}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
|
|
3
|
-
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:we,splashActive:$e})}load(){let e=async()=>{let i=this.getModel();if(!i){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(i.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(i=>{T("error",this,"Error setting initial context.",{detail:{error:i}})}),this.manager.onLifecycle(()=>
|
|
3
|
+
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:we,splashActive:$e})}load(){let e=async()=>{let i=this.getModel();if(!i){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(i.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(i=>{T("error",this,"Error setting initial context.",{detail:{error:i}})}),this.manager.onLifecycle(()=>{let i=z.onModelContextDidChange(async()=>{e().catch(a=>{T("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{i.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),we=this.viewState.history,$e=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let i=tt(e.metadata);return{...e,metadata:i,estimatedTokens:Q(i)}}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,i)=>(!i.script||(e.push({priorPrompt:i.question,code:i.formattedScript||i.error||"",profileId:i.profile??ye,onAddToEditor:a=>{ne(this.editorRef.editorInstance,i.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",i),onThumbsDown:()=>this.handleFeedbackButton("bad",i),conversationId:i.conversationId??"",message:i.message}),this.viewState.viewMode),e),[])}async ensureFeedbackService(){if(this._feedbackService)return this._feedbackService;if(!this.feedbackServiceUrl)return;let e=new Te({url:this.feedbackServiceUrl});await e.load();let i=lt.filter(a=>!e.fields.some(s=>s.name===a));if(i.length>0){T("error",this,`Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(this.viewState.question){this.updateViewState({isSubmitting:!0,errorMessage:void 0});try{let e=await this.getToken(),i=this.getModel();if(!i)return;let a=this.viewState.context??await this.getProfileAndMetadata(i.uri),s=(await Pe({baseUrl:this.serviceUrl,skillId:nt,message:this.viewState.question,authToken:e,context:{kind:rt,context:{profile_id:a.profileId,metadata:[a.metadata]}}})).find(n=>n.context?.kind==="ArcadeCodeResponse");if(!s)return;if(s.context?.kind==="ArcadeCodeResponse"){let n=this.createFeedbackContextSnapshot(a);this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:re(s?.context?.arcadeCode?.code??""),error:void 0,question:this.viewState.question,profile:a.profileId,conversationId:s.conversationId,contextSnapshot:n,...s.message?{message:s.message}:{}},...this.viewState.history],viewMode:"result",errorMessage:void 0})}}catch(e){e instanceof Error&&e.name==="ArcadeAssistantError"?this.updateViewState({errorMessage:qe(e)||this.messages.erroroccurred||"An error occurred."}):this.updateViewState({errorMessage:this.messages.erroroccurred||"An error occurred."}),T("error",this,"Error submitting question",{detail:{error:e}})}finally{this.updateViewState({isSubmitting:!1})}}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let i=ye,a=z.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let s=this.editorRef.profile;s&&"id"in s&&(i=s.id);let n=a?await Xe(a):{variables:[]},l=at(n),d=l?it(n):void 0,c=d?d.context:n,o=Q(c);return{profileId:i,metadata:c,contextTooLarge:l,reducedToVariableName:d?.reducedToVariableName,estimatedTokens:o}}onCopyCode(e){let i=e?`${this.disclaimerComment}
|
|
4
4
|
${e}`:"";return navigator.clipboard.writeText(i)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",i=this.getHistoryCards();return this.assistantsEnabled?p`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&p`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${Fe({messages:this.messages,popoverContent:me({assistantsEnabled:this.assistantsEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&Je({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:a=>this.closePanel?.(a)})||""}${Le({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${je({isDisabled:this.viewState.isSubmitting,isReadOnly:!1,setQuestion:this.setQuestionState,setIsViewingResult:a=>this.updateViewState({viewMode:a?"result":"prompt"}),mode:e?"refine":"prompt",textAreaRef:this.textAreaRef,question:this.viewState.question,errorMessage:this.viewState.errorMessage,setErrorMessage:a=>this.updateViewState({errorMessage:a}),promptValidationMessage:this.viewState.promptValidationMessage,setPromptValidationMessage:a=>this.updateViewState({promptValidationMessage:a}),submitQuestion:this.submitQuestion.bind(this),assistantRef:this.el,messages:this.messages,context:this.viewState.context,contextReducedNoticeDismissed:this.viewState.contextReducedNoticeDismissed,setContextReducedNoticeDismissed:a=>this.updateViewState({contextReducedNoticeDismissed:a})})}<calcite-block-group .label=${this.messages.interactiveblocks??"interactive blocks"}>${!e&&!this.viewState.isSubmitting&&Ye({messages:this.messages,suggestions:[this.messages.prompsuggestion1??"",this.messages.prompsuggestion2??""],onSuggestionClick:this.onSuggestionClick})||""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse??"Generating response..."}></calcite-block>${ge({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:i.length?[i[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${ge({expanded:!e,messages:this.messages,collapsible:!0,cards:e?i.slice(1):i,heading:this.messages.recentprompts??"Recent prompts",hidden:this.viewState.isSubmitting||this.viewState.history.length===0,onCopyCode:this.onCopyCode.bind(this)})}</calcite-block-group>${this.viewState.feedback.active?Ge({setOpen:this.handleFeedbackSheetClose,messages:this.messages,onSubmit:this.handleFeedbackSubmit,feedback:this.viewState.feedback,setFeedback:this.setFeedbackState,learnMoreUrl:this.assistantOverviewDocUrl}):null}</calcite-shell></calcite-flow-item></calcite-flow>`:p`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${me({slot:"content-top",messages:this.messages,assistantsEnabled:this.assistantsEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};se("arcgis-arcade-coding-assistant",G);return G},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b)
|
|
@@ -18238,7 +18238,7 @@ function se(t, e, r, n) {
|
|
|
18238
18238
|
const fr = { apiKey: void 0, apiKeys: { scopes: [] }, applicationName: "", applicationUrl: globalThis.location?.href, assetsPath: "", fontsUrl: "https://static.arcgis.com/fonts", geometryServiceUrl: "https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer", geoRSSServiceUrl: "https://utility.arcgis.com/sharing/rss", kmlServiceUrl: "https://utility.arcgis.com/sharing/kml", userPrivilegesApplied: !0, portalUrl: "https://www.arcgis.com", respectPrefersReducedMotion: !0, routeServiceUrl: "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World", workers: { loaderConfig: { has: {}, paths: {}, map: {}, packages: [] } }, request: { crossOriginNoCorsDomains: null, httpsDomains: ["arcgis.com", "arcgisonline.com", "esrikr.com", "premiumservices.blackbridge.com", "esripremium.accuweather.com", "gbm.digitalglobe.com", "firstlook.digitalglobe.com", "msi.digitalglobe.com"], interceptors: [], internalInterceptors: [], maxUrlLength: 2e3, priority: "high", proxyRules: [], proxyUrl: null, timeout: 62e3, trustedServers: [], useIdentity: !0 }, log: { interceptors: [], level: null } };
|
|
18239
18239
|
if (globalThis.esriConfig && (q4(fr, globalThis.esriConfig, !0), delete fr.has), !fr.assetsPath) {
|
|
18240
18240
|
{
|
|
18241
|
-
const t = "5.0.0-next.
|
|
18241
|
+
const t = "5.0.0-next.111";
|
|
18242
18242
|
fr.assetsPath = `https://cdn.jsdelivr.net/npm/@arcgis/core@${t}/assets`;
|
|
18243
18243
|
}
|
|
18244
18244
|
fr.defaultAssetsPath = fr.assetsPath;
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./
|
|
2
|
+
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./HC6SQXXT.js"),"appVersion,assistantsEnabled,closed,closePanel:,editorRef:,feedbackServiceUrl,helpBase,insertText:,portalUrl,serviceUrl;destroy"],"arcgis-arcade-editor":[()=>import("./GNJO6WNS.js"),"arcadeAssistant:,customPanels:,editorInstance:,editorOptions:,hideDocumentationActions,hideSideBar,messages:,openedSidePanel,profile:,script,sideActionBarExpanded,snippets:,suggestions:,testData:;getTestResult,setFocus"],"arcgis-arcade-results":[()=>import("./D2RP5367.js"),"calciteModeDark,consoleLogs:,loading,openedResultPanel,result:"],"arcgis-arcade-suggestions":[()=>import("./UNTQC5M2.js"),"closed,suggestions:"],"arcgis-code-editor":[()=>import("./N2FN7LBN.js"),"editorInstance:,editorOptions:,language,modelId,value;insertSnippet,insertText,setFocus"],"arcgis-code-editor-shell":[()=>import("./3C7TCPV5.js")],"arcgis-code-viewer":[()=>import("./EPMYM35I.js"),"language,round"],"arcgis-editor-variables":[()=>import("./DTZPALJA.js"),"closed,loading,modelId,variable:"],"arcgis-language-api-panel":[()=>import("./NZY7KXAF.js"),"apiLibrary:,closed,hideDocumentationActions,languageId,loading"],"arcgis-sql-expression-editor":[()=>import("./QXQAIN3R.js"),"hideSideBar,messages:,profile:,script;setFocus"]});i({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-arcade-editor,arcgis-code-editor,arcgis-code-editor-shell,arcgis-code-viewer,arcgis-sql-expression-editor){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,s)
|
|
@@ -27,10 +27,10 @@ class C extends Error {
|
|
|
27
27
|
message: e,
|
|
28
28
|
code: i,
|
|
29
29
|
subCode: o,
|
|
30
|
-
details:
|
|
31
|
-
source:
|
|
30
|
+
details: s,
|
|
31
|
+
source: n
|
|
32
32
|
}) {
|
|
33
|
-
super(e), this.name = "ArcadeAssistantError", this.code = i, this.subCode = o, this.details =
|
|
33
|
+
super(e), this.name = "ArcadeAssistantError", this.code = i, this.subCode = o, this.details = s, this.source = n;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
function U(t) {
|
|
@@ -47,18 +47,18 @@ function U(t) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
async function we(t) {
|
|
50
|
-
const { baseUrl: e, skillId: i, message: o, authToken:
|
|
50
|
+
const { baseUrl: e, skillId: i, message: o, authToken: s, previousConversationId: n, context: r } = t, p = i ? `${e}/skills/${i}/chat` : `${e}/chat`, c = [], a = {
|
|
51
51
|
message: o,
|
|
52
52
|
context: r
|
|
53
53
|
};
|
|
54
|
-
|
|
54
|
+
n && (a.conversation_id = n);
|
|
55
55
|
let h;
|
|
56
56
|
try {
|
|
57
57
|
h = await _(p, {
|
|
58
58
|
method: "post",
|
|
59
59
|
headers: {
|
|
60
60
|
"Content-Type": "application/json",
|
|
61
|
-
token:
|
|
61
|
+
token: s
|
|
62
62
|
},
|
|
63
63
|
body: JSON.stringify(a),
|
|
64
64
|
responseType: "json"
|
|
@@ -83,7 +83,7 @@ async function we(t) {
|
|
|
83
83
|
method: "post",
|
|
84
84
|
headers: {
|
|
85
85
|
"Content-Type": "application/json",
|
|
86
|
-
token:
|
|
86
|
+
token: s
|
|
87
87
|
},
|
|
88
88
|
body: JSON.stringify($),
|
|
89
89
|
responseType: "json"
|
|
@@ -139,9 +139,9 @@ function xe(t) {
|
|
|
139
139
|
return t.message.match(/Error in prompt shield/u) ? "I'm having trouble with this request. Try again by rephrasing the question." : t.code === "TIMEOUT" ? "Request timed out. Try again by re-asking the same question or rephrasing it." : t.message;
|
|
140
140
|
}
|
|
141
141
|
const ke = ({ notices: t }) => t.length ? l`<div class="border-block-end">${Q(t, (e) => e.id ?? e.title, (e) => l`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${() => e.onClose?.()}><div slot=title>${e.title}</div>${e.message && l`<div slot=message>${e.message}</div>` || ""}${e.actionLinkMessage && e.onAction && l`<calcite-link slot=link @click=${() => e.onAction?.()}>${e.actionLinkMessage}</calcite-link>` || ""}</calcite-notice>`)}</div>` : null, Se = (t) => {
|
|
142
|
-
const e = t.value.length, i = 72, o = 180,
|
|
142
|
+
const e = t.value.length, i = 72, o = 180, s = t.offsetWidth, r = Math.max(1, Math.floor(s / 8)), p = Math.ceil(e / r), c = i + (p - 2) * 24;
|
|
143
143
|
t.style.setProperty("--calcite-text-area-min-height", `${Math.min(c, o)}px`);
|
|
144
|
-
}, Ce = ({ promptValidationMessage: t, errorMessage: e, contextTooBig: i, contextReducedNoticeDismissed: o, setContextReducedNoticeDismissed:
|
|
144
|
+
}, Ce = ({ promptValidationMessage: t, errorMessage: e, contextTooBig: i, contextReducedNoticeDismissed: o, setContextReducedNoticeDismissed: s, setErrorMessage: n, messages: r }) => {
|
|
145
145
|
const p = [];
|
|
146
146
|
if (t && p.push({
|
|
147
147
|
id: "prompt-validation",
|
|
@@ -155,7 +155,7 @@ const ke = ({ notices: t }) => t.length ? l`<div class="border-block-end">${Q(t,
|
|
|
155
155
|
icon: "exclamation-mark-triangle",
|
|
156
156
|
title: e,
|
|
157
157
|
closable: !0,
|
|
158
|
-
onClose: () =>
|
|
158
|
+
onClose: () => n(void 0)
|
|
159
159
|
}), i && !o) {
|
|
160
160
|
const c = r.contextreduced ?? "Context reduced", a = r.contextreducedmessage ?? "The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";
|
|
161
161
|
p.push({
|
|
@@ -165,7 +165,7 @@ const ke = ({ notices: t }) => t.length ? l`<div class="border-block-end">${Q(t,
|
|
|
165
165
|
title: c,
|
|
166
166
|
message: a,
|
|
167
167
|
closable: !0,
|
|
168
|
-
onClose: () =>
|
|
168
|
+
onClose: () => s(!0)
|
|
169
169
|
});
|
|
170
170
|
}
|
|
171
171
|
return p;
|
|
@@ -185,7 +185,7 @@ function Ee({ active: t, setActive: e, messages: i }) {
|
|
|
185
185
|
function Re({ context: t, messages: e }) {
|
|
186
186
|
return t ? l`<div class="gaps">${t.profileId && l`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>` || ""}</div>` : null;
|
|
187
187
|
}
|
|
188
|
-
function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult: o, textAreaRef:
|
|
188
|
+
function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult: o, textAreaRef: s, question: n, errorMessage: r, setErrorMessage: p, promptValidationMessage: c, setPromptValidationMessage: a, submitQuestion: h, messages: d, mode: y, assistantRef: q, context: w, contextReducedNoticeDismissed: T, setContextReducedNoticeDismissed: I }) {
|
|
189
189
|
const b = w?.contextTooLarge ?? !1, g = Ce({
|
|
190
190
|
promptValidationMessage: c,
|
|
191
191
|
errorMessage: r,
|
|
@@ -195,20 +195,20 @@ function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult:
|
|
|
195
195
|
setErrorMessage: p,
|
|
196
196
|
messages: d
|
|
197
197
|
});
|
|
198
|
-
return l`<div class="text-area-wrapper">${ke({ notices: g })}<calcite-text-area scale=s resize=vertical .readOnly=${t || e} class=${te(g.length ? "submission-text-area" : "submission-text-area round-top")} .placeholder=${d.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${
|
|
198
|
+
return l`<div class="text-area-wrapper">${ke({ notices: g })}<calcite-text-area scale=s resize=vertical .readOnly=${t || e} class=${te(g.length ? "submission-text-area" : "submission-text-area round-top")} .placeholder=${d.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${($) => {
|
|
199
199
|
Se($.target), i($.target.value);
|
|
200
|
-
}} ${oe(
|
|
200
|
+
}} ${oe(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${w && Re({ context: w, messages: d }) || ""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async () => {
|
|
201
201
|
o(!1), i("");
|
|
202
202
|
}} .label=${d.startover ?? "Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${d.startover ?? "Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async () => {
|
|
203
203
|
o(!1), i("");
|
|
204
204
|
}} class="hidden-below-380" scale=s>${d.startover ?? "Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async () => {
|
|
205
|
-
if (p(""), !
|
|
205
|
+
if (p(""), !n) {
|
|
206
206
|
a(d.enteraprompt ?? "Please enter a prompt");
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
a(void 0), await h();
|
|
210
210
|
}} class="hidden-below-380">${y === "prompt" ? d.ask ?? "Generate" : d.refine ?? "Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async () => {
|
|
211
|
-
if (p(""), !
|
|
211
|
+
if (p(""), !n) {
|
|
212
212
|
a(d.enteraprompt ?? "Please enter a prompt");
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
@@ -216,10 +216,10 @@ function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult:
|
|
|
216
216
|
}} class="hidden-above-380" .label=${y === "prompt" ? d.ask ?? "Generate" : d.refine ?? "Refine"}></calcite-button></div></div></div></calcite-text-area></div>`;
|
|
217
217
|
}
|
|
218
218
|
const Pe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement", Ve = "https://www.esri.com/en-us/privacy/privacy-statements";
|
|
219
|
-
function qe({ setOpen: t, messages: e, feedback: i, learnMoreUrl: o, setFeedback:
|
|
220
|
-
return i.active ? l`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${() => t(!1)}><calcite-panel .heading=${e.submitfeedback ?? "Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${(r) =>
|
|
221
|
-
|
|
222
|
-
}} .disabled=${i.submitting}></calcite-checkbox><span>${A((e.agreement ?? "I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}", `<calcite-link href=${Ve} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${Pe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${A((e.feedbackhelps ?? "Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}", `<calcite-link href=${o} target="_blank">${e.learnmore ?? "Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${() => t(!1)} .disabled=${i.submitting}>${e.cancel ?? "Cancel"}</calcite-button><calcite-button @click=${
|
|
219
|
+
function qe({ setOpen: t, messages: e, feedback: i, learnMoreUrl: o, setFeedback: s, onSubmit: n }) {
|
|
220
|
+
return i.active ? l`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${() => t(!1)}><calcite-panel .heading=${e.submitfeedback ?? "Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${(r) => s({ ...i, text: r.target.value })} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo ?? "Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${(r) => {
|
|
221
|
+
s({ ...i, termsAccepted: r.target.checked });
|
|
222
|
+
}} .disabled=${i.submitting}></calcite-checkbox><span>${A((e.agreement ?? "I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}", `<calcite-link href=${Ve} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${Pe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${A((e.feedbackhelps ?? "Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}", `<calcite-link href=${o} target="_blank">${e.learnmore ?? "Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${() => t(!1)} .disabled=${i.submitting}>${e.cancel ?? "Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted || i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit ?? "Submit"}</calcite-button></div></calcite-panel></calcite-sheet>` : null;
|
|
223
223
|
}
|
|
224
224
|
function O({ assistantsEnabled: t, messages: e, slot: i, helpTopicUrl: o }) {
|
|
225
225
|
return l`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${i ?? V} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing ?? "Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new ?? "New"} kind=brand scale=s>${e.new ?? "New"}</calcite-chip></div>${t ? l`<p>${e.capabilities ?? "The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind ?? "Keep in mind the following:"}<ul><li>${e.beconsise ?? "Be concise, but also clear in your request"}</li><li>${e.avoidambiguity ?? "Avoid ambiguity and vagueness"}</li><li>${e.moredetails ?? "you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${A((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${o} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : l`<p>${e.useofassistant ?? "The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg ?? "AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps ?? "Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege ?? "Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`;
|
|
@@ -231,8 +231,8 @@ function De({ messages: t, suggestions: e, onSuggestionClick: i }) {
|
|
|
231
231
|
return l`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map((o) => l`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${() => i?.(o)}>${o}</calcite-button>`)}</div></calcite-block>`;
|
|
232
232
|
}
|
|
233
233
|
const z = 200;
|
|
234
|
-
function L({ hidden: t = !1, expanded: e = !1, messages: i, cards: o, heading:
|
|
235
|
-
return l`<calcite-block .hidden=${t} id=result-block .heading=${
|
|
234
|
+
function L({ hidden: t = !1, expanded: e = !1, messages: i, cards: o, heading: s, collapsible: n = !1, showEffectsIcon: r = !1, onCopyCode: p, standalone: c }) {
|
|
235
|
+
return l`<calcite-block .hidden=${t} id=result-block .heading=${s ?? i.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${r && l`<calcite-chip .label=${i.assistantresponses ?? "Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${i.assistantresponses ?? "Assistant responses"}>${Q(o, (a) => a.conversationId, (a) => l`<calcite-card><div slot=heading><div class="prior-prompt"><span>${a.priorPrompt.length > z ? `${a.priorPrompt.slice(0, z)}...` : a.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} @click=${(h) => {
|
|
236
236
|
const d = h.currentTarget;
|
|
237
237
|
navigator.clipboard.writeText(a.priorPrompt).then(() => {
|
|
238
238
|
d.setAttribute("data-copied", "true"), setTimeout(() => d.removeAttribute("data-copied"), 1500);
|
|
@@ -245,8 +245,8 @@ function L({ hidden: t = !1, expanded: e = !1, messages: i, cards: o, heading: n
|
|
|
245
245
|
}} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard ?? "Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup ?? "Thumbs up"} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown ?? "Thumbs down"} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
|
|
246
246
|
}
|
|
247
247
|
const Ne = ({ card: t, messages: e }) => {
|
|
248
|
-
const i = le(), o = `response-chip-profile-${t.conversationId}-${i}`,
|
|
249
|
-
return l`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${
|
|
248
|
+
const i = le(), o = `response-chip-profile-${t.conversationId}-${i}`, s = (e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId);
|
|
249
|
+
return l`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${o ?? V}>${t.profileId}</calcite-chip>`;
|
|
250
250
|
}, B = (t) => t.type === "featureSet", E = (t) => {
|
|
251
251
|
if (!be(t))
|
|
252
252
|
return [];
|
|
@@ -292,12 +292,12 @@ async function K(t) {
|
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
case "featureSetCollection": {
|
|
295
|
-
const e = await t.loadSource(), i = e?.layers.filter(B) ?? [], o = e?.tables.filter(B) ?? [],
|
|
295
|
+
const e = await t.loadSource(), i = e?.layers.filter(B) ?? [], o = e?.tables.filter(B) ?? [], s = await Promise.all(i.map(j)), n = await Promise.all(o.map(j));
|
|
296
296
|
return {
|
|
297
297
|
name: t.name,
|
|
298
298
|
type: "featureSetCollection",
|
|
299
|
-
layers:
|
|
300
|
-
tables:
|
|
299
|
+
layers: s,
|
|
300
|
+
tables: n
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
303
|
case "dictionary": {
|
|
@@ -431,10 +431,10 @@ function Le(t) {
|
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
433
|
function Be(t) {
|
|
434
|
-
const e = t.variables, i = e.length, o = e.find((
|
|
434
|
+
const e = t.variables, i = e.length, o = e.find((n) => n.name === "$feature") ?? e.find((n) => n.type === "feature") ?? e[0], s = o ? [o] : [];
|
|
435
435
|
return {
|
|
436
|
-
context: { variables:
|
|
437
|
-
wasReduced: i !==
|
|
436
|
+
context: { variables: s },
|
|
437
|
+
wasReduced: i !== s.length,
|
|
438
438
|
reducedToVariableName: o?.name
|
|
439
439
|
};
|
|
440
440
|
}
|
|
@@ -442,9 +442,9 @@ function je(t) {
|
|
|
442
442
|
return P(t) > Oe;
|
|
443
443
|
}
|
|
444
444
|
var He = Object.defineProperty, Ge = Object.getOwnPropertyDescriptor, m = (t, e, i, o) => {
|
|
445
|
-
for (var
|
|
446
|
-
(r = t[
|
|
447
|
-
return o &&
|
|
445
|
+
for (var s = o > 1 ? void 0 : o ? Ge(e, i) : e, n = t.length - 1, r; n >= 0; n--)
|
|
446
|
+
(r = t[n]) && (s = (o ? r(e, i, s) : r(s)) || s);
|
|
447
|
+
return o && s && He(e, i, s), s;
|
|
448
448
|
};
|
|
449
449
|
let u = class extends ge {
|
|
450
450
|
constructor(t) {
|
|
@@ -518,9 +518,9 @@ class Ke extends ie {
|
|
|
518
518
|
}
|
|
519
519
|
const i = this.viewState.feedback.item.contextSnapshot, o = pe.applicationName;
|
|
520
520
|
!o && !this.appVersion && x("warn", this, "esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");
|
|
521
|
-
const { value:
|
|
522
|
-
user_evaluation:
|
|
523
|
-
your_comments:
|
|
521
|
+
const { value: s, text: n, termsAccepted: r, item: { question: p, formattedScript: c, conversationId: a } } = this.viewState.feedback, h = {
|
|
522
|
+
user_evaluation: s,
|
|
523
|
+
your_comments: n || void 0,
|
|
524
524
|
question: p ?? "",
|
|
525
525
|
/**
|
|
526
526
|
* The answer may contain invalid or partial HTML, which causes the feature service's HTML sanitizer to strip or reject it.
|
|
@@ -589,11 +589,16 @@ class Ke extends ie {
|
|
|
589
589
|
};
|
|
590
590
|
e().catch((i) => {
|
|
591
591
|
x("error", this, "Error setting initial context.", { detail: { error: i } });
|
|
592
|
-
}), this.manager.onLifecycle(() =>
|
|
593
|
-
|
|
594
|
-
|
|
592
|
+
}), this.manager.onLifecycle(() => {
|
|
593
|
+
const i = N.onModelContextDidChange(async () => {
|
|
594
|
+
e().catch((s) => {
|
|
595
|
+
x("error", this, "Error setting context.", { detail: { error: s } });
|
|
596
|
+
});
|
|
595
597
|
});
|
|
596
|
-
|
|
598
|
+
return { remove: () => {
|
|
599
|
+
i.dispose();
|
|
600
|
+
} };
|
|
601
|
+
});
|
|
597
602
|
}
|
|
598
603
|
disconnectedCallback() {
|
|
599
604
|
super.disconnectedCallback(), J = this.viewState.history, W = this.viewState.splashActive, this.copySuccessTimer && (clearTimeout(this.copySuccessTimer), this.copySuccessTimer = void 0);
|
|
@@ -630,7 +635,7 @@ class Ke extends ie {
|
|
|
630
635
|
return;
|
|
631
636
|
const e = new de({ url: this.feedbackServiceUrl });
|
|
632
637
|
await e.load();
|
|
633
|
-
const i = Ye.filter((o) => !e.fields.some((
|
|
638
|
+
const i = Ye.filter((o) => !e.fields.some((s) => s.name === o));
|
|
634
639
|
if (i.length > 0) {
|
|
635
640
|
x("error", this, `Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);
|
|
636
641
|
return;
|
|
@@ -647,7 +652,7 @@ class Ke extends ie {
|
|
|
647
652
|
const e = await this.getToken(), i = this.getModel();
|
|
648
653
|
if (!i)
|
|
649
654
|
return;
|
|
650
|
-
const o = this.viewState.context ?? await this.getProfileAndMetadata(i.uri),
|
|
655
|
+
const o = this.viewState.context ?? await this.getProfileAndMetadata(i.uri), n = (await we({
|
|
651
656
|
baseUrl: this.serviceUrl,
|
|
652
657
|
skillId: Je,
|
|
653
658
|
message: this.viewState.question,
|
|
@@ -660,21 +665,21 @@ class Ke extends ie {
|
|
|
660
665
|
}
|
|
661
666
|
}
|
|
662
667
|
})).find((r) => r.context?.kind === "ArcadeCodeResponse");
|
|
663
|
-
if (!
|
|
668
|
+
if (!n)
|
|
664
669
|
return;
|
|
665
|
-
if (
|
|
670
|
+
if (n.context?.kind === "ArcadeCodeResponse") {
|
|
666
671
|
const r = this.createFeedbackContextSnapshot(o);
|
|
667
672
|
this.updateViewState({
|
|
668
673
|
history: [
|
|
669
674
|
{
|
|
670
|
-
script:
|
|
671
|
-
formattedScript: re(
|
|
675
|
+
script: n?.context?.arcadeCode?.code,
|
|
676
|
+
formattedScript: re(n?.context?.arcadeCode?.code ?? ""),
|
|
672
677
|
error: void 0,
|
|
673
678
|
question: this.viewState.question,
|
|
674
679
|
profile: o.profileId,
|
|
675
|
-
conversationId:
|
|
680
|
+
conversationId: n.conversationId,
|
|
676
681
|
contextSnapshot: r,
|
|
677
|
-
...
|
|
682
|
+
...n.message ? { message: n.message } : {}
|
|
678
683
|
},
|
|
679
684
|
...this.viewState.history
|
|
680
685
|
],
|
|
@@ -699,9 +704,9 @@ class Ke extends ie {
|
|
|
699
704
|
let i = G;
|
|
700
705
|
const o = N.getEditorProfileForModel(e);
|
|
701
706
|
o?.loaded || await o?.loadSource();
|
|
702
|
-
const
|
|
703
|
-
|
|
704
|
-
const
|
|
707
|
+
const s = this.editorRef.profile;
|
|
708
|
+
s && "id" in s && (i = s.id);
|
|
709
|
+
const n = o ? await Ue(o) : { variables: [] }, r = je(n), p = r ? Be(n) : void 0, a = p ? p.context : n, h = P(a);
|
|
705
710
|
return {
|
|
706
711
|
profileId: i,
|
|
707
712
|
metadata: a,
|