@arcgis/coding-components 5.2.0-next.136 → 5.2.0-next.137

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.
Files changed (45) hide show
  1. package/dist/cdn/7GVCXLAE.js +2 -0
  2. package/dist/cdn/{WHOYO2EQ.js → BPCBI4SE.js} +3 -3
  3. package/dist/cdn/EQDKZIAP.js +2 -0
  4. package/dist/cdn/GDTEFKCP.js +2 -0
  5. package/dist/cdn/GJ4W3JPG.js +2 -0
  6. package/dist/cdn/J7TSCCXO.js +6 -0
  7. package/dist/cdn/JFO2HVZ6.js +2 -0
  8. package/dist/cdn/JGRWZYW5.js +3 -0
  9. package/dist/cdn/N56B3UDM.js +2 -0
  10. package/dist/cdn/{FFLWFFHU.js → OMJLVFHT.js} +1 -1
  11. package/dist/cdn/{YJ4WRZOI.js → ZJCPZ5ZN.js} +1 -1
  12. package/dist/cdn/assets/arcade-debugger-output/t9n/messages.en.json +1 -1
  13. package/dist/cdn/assets/code-editor/sql-expr.worker.js +4585 -4421
  14. package/dist/cdn/index.js +1 -1
  15. package/dist/chunks/arcade-defaults.js +95 -102
  16. package/dist/chunks/setup-monaco-theme.js +34 -67
  17. package/dist/chunks/sql-expr-mode.js +73 -61
  18. package/dist/chunks/sql-expr-service-accessors.js +35 -2
  19. package/dist/components/arcgis-arcade-coding-assistant/customElement.js +22 -23
  20. package/dist/components/arcgis-arcade-debugger-output/customElement.js +8 -8
  21. package/dist/components/arcgis-arcade-editor/customElement.d.ts +12 -1
  22. package/dist/components/arcgis-arcade-editor/customElement.js +104 -104
  23. package/dist/components/arcgis-code-editor/customElement.js +12 -11
  24. package/dist/components/arcgis-code-viewer/customElement.js +2 -1
  25. package/dist/components/arcgis-sql-expression-editor/customElement.d.ts +2 -0
  26. package/dist/components/arcgis-sql-expression-editor/customElement.js +13 -7
  27. package/dist/components/types.d.ts +11 -0
  28. package/dist/docs/api.json +1 -1
  29. package/dist/docs/docs.json +1 -1
  30. package/dist/docs/vscode.html-custom-data.json +1 -1
  31. package/dist/docs/web-types.json +1 -1
  32. package/dist/loader.js +6 -6
  33. package/dist/types/lumina.d.ts +1 -1
  34. package/dist/types/preact.d.ts +1 -1
  35. package/dist/types/react.d.ts +1 -1
  36. package/dist/types/stencil.d.ts +1 -1
  37. package/package.json +7 -7
  38. package/dist/cdn/DBAL7LSK.js +0 -2
  39. package/dist/cdn/EDJMOEXG.js +0 -2
  40. package/dist/cdn/FQWGIGBG.js +0 -2
  41. package/dist/cdn/M4ASZPOM.js +0 -2
  42. package/dist/cdn/SQQXRZAR.js +0 -2
  43. package/dist/cdn/XMKMX4RT.js +0 -2
  44. package/dist/cdn/XUI74PBQ.js +0 -2
  45. package/dist/cdn/YCA4A2EF.js +0 -6
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import h from"./AI6346MJ.js";import g from"./D5GWRYT7.js";import f from"./J7TSCCXO.js";import e from"./SXM2EQHN.js";import d from"./H5EGZU2S.js";import{f as j}from"./ZLV7T4YS.js";import b from"./7Z6G332Z.js";import"./MZMKV7FA.js";import a from"./ZUCC43DN.js";import{a as W}from"./G4VQ7X3L.js";import{a as H}from"./A3TU47C5.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import{a as Z,b as ee,c as D}from"./UHQN4ZKV.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import{a as Y}from"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import{E as T,F as I,G as q,H as y,K as G,L as V,h as z,j as c,l as C,n as R,t as U}from"./O6XP7VU2.js";import{b as l}from"./BFPEJYVB.js";import{El as Q,wl as L,xl as M,zl as F}from"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([{watch:v},P,{property:r,subclass:A},{a:X,d:b,i:S,j:w},{b:O},,,f,{a:J},{a:te,b:se}])=>{var ae=z`: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:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}.bottom-action-bar.is-collapsed{border-bottom:0}.bottom-action-bar{display:flex;.bottom-action-bar__actions{flex:1 1 auto;min-inline-size:0}}`,ne=Object.defineProperty,oe=Object.getOwnPropertyDescriptor,m=(s,e,t,i)=>{for(var a=i>1?void 0:i?oe(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(a=(i?o(e,t,a):o(a))||a);return i&&a&&ne(e,t,a),a},ie=100,h=class extends P{constructor(s){super(s),this.collectionItems=[],this.errorMessage="",this.expanded=!1,this.requestId=0,this.status="idle",this.visibleChildCount=ie}};m([r()],h.prototype,"collectionItems",2);m([r()],h.prototype,"errorMessage",2);m([r()],h.prototype,"expanded",2);m([r()],h.prototype,"requestId",2);m([r()],h.prototype,"schemaValue",2);m([r()],h.prototype,"status",2);m([r()],h.prototype,"visibleChildCount",2);h=m([A("ArcadeDebuggerLazyTreeNodeState")],h);var B=class extends P{constructor(s){super(s),this.generation=0,this.nodes=new Map}reset(){this.generation+=1,this.destroyNodes()}ensureNode(s,e=!1,t){let i=this.nodes.get(s);if(i)return i;let a=new h;return a.expanded=e,this.nodes.set(s,a),e&&t&&this.loadNode(s,t),a}setExpanded(s,e,t){let i=this.ensureNode(s,e,t);if(i.expanded===e){e&&t&&this.loadNode(s,t);return}i.expanded=e,e&&t&&this.loadNode(s,t)}showMore(s,e){let t=this.ensureNode(s);t.visibleChildCount>=e||(t.visibleChildCount=Math.min(e,t.visibleChildCount+ie))}loadNode(s,e){switch(e.kind){case"collection":this.runLoad(s,e.load,(t,i)=>{t.collectionItems=i});return;case"schema":this.runLoad(s,e.load,(t,i)=>{t.schemaValue=i});return}}runLoad(s,e,t){let i=this.nodes.get(s);if(!i||i.status==="loading"||i.status==="loaded")return;let a=this.generation,n=i.requestId+1;i.requestId=n,i.status="loading",i.errorMessage="",i.schemaValue=void 0,i.collectionItems=[],e().then(o=>{let u=this.nodes.get(s);!u||this.generation!==a||u.requestId!==n||(t(u,o),u.status="loaded")}).catch(()=>{let o=this.nodes.get(s);!o||this.generation!==a||o.requestId!==n||(o.status="error")})}destroyNodes(){for(let s of this.nodes.values())s.destroy();this.nodes.clear()}};B=m([A("ArcadeDebuggerLazyTreeState")],B);var re=Object.defineProperty,ce=Object.getOwnPropertyDescriptor,d=(s,e,t,i)=>{for(var a=i>1?void 0:i?ce(e,t):e,n=s.length-1,o;n>=0;n--)(o=s[n])&&(a=(i?o(e,t,a):o(a))||a);return i&&a&&re(e,t,a),a},_=class extends P{constructor(s){super(s),this.phase="idle",this.sessionId=0,this.consoleLogs=[],this.hasExecuted=!1}get isExecuting(){return this.phase==="running"||this.phase==="debug-running"||this.phase==="debug-paused"}get isDebugging(){return this.phase==="debug-running"||this.phase==="debug-paused"}get isPaused(){return this.phase==="debug-paused"}get runResult(){return this.result?.resultType==="run"?this.result.result:void 0}get resultForLegacyRenderer(){return this.result?.resultType==="debug"?void 0:this.result?.result}get debugResult(){return this.result?.resultType==="debug"?this.result.result:void 0}get executionTiming(){return this.result?.resultType==="error"?void 0:this.result?.timing}addConsoleLog(s){this.consoleLogs=[...this.consoleLogs,s]}};d([r()],_.prototype,"phase",2);d([r()],_.prototype,"mode",2);d([r()],_.prototype,"sessionId",2);d([r()],_.prototype,"result",2);d([r()],_.prototype,"consoleLogs",2);d([r()],_.prototype,"hasExecuted",2);_=d([A("ArcadeDebuggerExecutionModel")],_);var $=class extends P{constructor(s){super(s),this.editorBreakpoints=[],this.executionBreakpoints=[]}setBreakpoints(s,e){s==="editor"?this.editorBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i):this.executionBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i)}toggleBreakpoint(s,e){let t=new Set(s==="editor"?this.editorBreakpoints:this.executionBreakpoints);t.has(e)?t.delete(e):t.add(e),this.setBreakpoints(s,t)}clearBreakpoints(s){s==="editor"?this.editorBreakpoints=[]:this.executionBreakpoints=[]}syncExecutionBreakpointsFromEditor(){this.executionBreakpoints=this.editorBreakpoints}};d([r()],$.prototype,"editorBreakpoints",2);d([r()],$.prototype,"executionBreakpoints",2);$=d([A("ArcadeDebuggerSessionModel")],$);var E=class extends P{constructor(s){super(s),this.openedPanel="output",this.showPanel=!1}};d([r()],E.prototype,"openedPanel",2);d([r()],E.prototype,"showPanel",2);E=d([A("ArcadeDebuggerUiModel")],E);var k=class extends P{constructor(s){super(s)}get line(){return this.pausedState?.line}clearPausedState(){this.lastPausedState=this.pausedState,this.pausedState=void 0}reset(){this.pausedState=void 0,this.lastPausedState=void 0}setPausedState(s){this.pausedState=s,this.lastPausedState=s}};d([r()],k.prototype,"pausedState",2);d([r()],k.prototype,"lastPausedState",2);k=d([A("ArcadeDebuggerPausedFrameModel")],k);var g=class extends P{constructor(s){super(s),this.execution=new _,this.lazyTreeState=new B,this.pausedFrame=new k,this.previewTabsState=new O,this.session=new $,this.ui=new E}get editorBreakpoints(){return this.session.editorBreakpoints}get debuggerBreakpoints(){return this.isPaused?this.session.executionBreakpoints.map(s=>({line:s})):this.session.editorBreakpoints.map(s=>({line:s}))}get executionBreakpoints(){return this.session.executionBreakpoints}get consoleLogs(){return this.execution.consoleLogs}get debug(){if(!(!this.pausedFrame.pausedState&&!this.pausedFrame.lastPausedState))return{pausedState:this.pausedFrame.pausedState,lastPausedState:this.pausedFrame.lastPausedState}}get debugResult(){return this.execution.debugResult}get executionTiming(){return this.execution.executionTiming}get debuggerLine(){return this.pausedFrame.pausedState?.line}get executionState(){return this.pausedFrame.pausedState}get hasExecuted(){return this.execution.hasExecuted}get isDebugging(){return this.execution.isDebugging}get isExecuting(){return this.execution.isExecuting}get isPaused(){return this.execution.isPaused}get mode(){return this.execution.mode}get openedPanel(){return this.ui.openedPanel}get outputRenderer(){if(this.execution.result)return this.execution.result.resultType==="debug"?"debugger":"legacy"}get phase(){return this.execution.phase}get result(){return this.execution.result}get runResult(){return this.execution.runResult}get resultForLegacyRenderer(){return this.execution.resultForLegacyRenderer}get sessionId(){return this.execution.sessionId}get showPanel(){return this.ui.showPanel}addConsoleLog(s){this.execution.addConsoleLog(s)}clearBreakpoints(s){this.session.clearBreakpoints(s)}clearForMissingTestData(){this.cancelExecution({hidePanel:!0}),this.execution.hasExecuted=!1,this.execution.result=void 0}closePanel(){this.ui.showPanel=!1}completeDebug(s,e){this.execution.mode="debug",this.execution.result={resultType:"debug",result:s,...e?{timing:e}:{}},this.execution.phase="completed",this.ui.openedPanel="output",this.pausedFrame.reset(),this.resetTransientDebuggerState()}completeRun(s,e={}){this.execution.mode="run",!e.useDebugRenderer&&S(s)?this.execution.result={resultType:"run",result:s}:e.useDebugRenderer&&!S(s)&&(this.execution.result={resultType:"debug",result:s,...e.timing?{timing:e.timing}:{}}),this.execution.phase="completed",this.pausedFrame.reset(),this.ui.openedPanel="output",this.resetTransientDebuggerState()}continueDebug(){let s=this.pausedFrame.pausedState?.continue;s&&(this.execution.phase="debug-running",this.pausedFrame.clearPausedState(),s.resolve())}disableDebugger(){this.cancelExecution({hidePanel:!0}),this.clearBreakpoints("execution"),this.clearBreakpoints("editor")}fail(s){this.execution.result={resultType:"error",result:s},this.execution.phase="completed",this.pausedFrame.reset(),this.ui.openedPanel="output",this.resetTransientDebuggerState()}pauseDebug(s){let e=this.pausedFrame.pausedState??this.pausedFrame.lastPausedState;this.syncPausedState(e,s),this.pausedFrame.setPausedState(s),this.execution.phase="debug-paused"}reset(){this.execution.phase="idle",this.execution.mode=void 0,this.execution.result=void 0,this.execution.consoleLogs=[],this.execution.hasExecuted=!1,this.execution.sessionId=0,this.ui.openedPanel="output",this.ui.showPanel=!1,this.pausedFrame.reset(),this.clearBreakpoints("execution"),this.clearBreakpoints("editor"),this.replaceTransientDebuggerState()}resetDebug(){this.cancelExecution({hidePanel:!1}),this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="debug-console"}disconnect(){this.cancelExecution({hidePanel:!0})}setBreakpoints(s){this.session.setBreakpoints("editor",s)}setPanel(s){this.execution.hasExecuted&&(this.ui.openedPanel=s,this.ui.showPanel=!0)}startDebug(){return this.execution.mode="debug",this.execution.phase="debug-running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.session.syncExecutionBreakpointsFromEditor(),this.execution.consoleLogs=[],this.ui.openedPanel="debug-console",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}startRun(){return this.execution.mode="run",this.execution.phase="running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="output",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}cancelExecution({hidePanel:s=!0,invalidateSession:e=!0}={}){let t=this.pausedFrame.pausedState?.continue;e&&(this.execution.sessionId+=1),this.execution.phase=this.execution.hasExecuted?"completed":"idle",this.pausedFrame.reset(),this.resetTransientDebuggerState(),s&&(this.ui.showPanel=!1),this.ui.openedPanel==="debug-console"&&(this.ui.openedPanel="output"),t?.resolve()}syncPausedState(s,e){this.lazyTreeState.reset(),s&&e&&s!==e&&this.previewTabsState.invalidateAll(),this.pausedLine=e?.line}toggleBreakpoint(s){this.session.toggleBreakpoint("editor",s)}togglePanel(s){if(this.execution.hasExecuted){if(s==null){this.ui.showPanel=!this.ui.showPanel;return}if(this.ui.openedPanel===s&&this.ui.showPanel){this.ui.showPanel=!1;return}this.setPanel(s)}}resetTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState.reset(),this.previewTabsState.clear()}replaceTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState=new B,this.previewTabsState=new O}};d([r()],g.prototype,"execution",2);d([r()],g.prototype,"lazyTreeState",2);d([r()],g.prototype,"pausedLine",2);d([r()],g.prototype,"pausedFrame",2);d([r()],g.prototype,"previewTabsState",2);d([r()],g.prototype,"session",2);d([r()],g.prototype,"ui",2);g=d([A("ArcadeDebuggerStore")],g);var N=class{#e;#a;#t;constructor(e,t=w){this.#e=e,this.#a=t}start(e){this.cancel({hidePanel:!1});let t=e.mode==="debug"?this.#e.startDebug():this.#e.startRun();setTimeout(()=>{this.#s(t)&&this.#o(e,t)},0)}cancel({hidePanel:e=!0}={}){this.#t?.abort(),this.#t=void 0,this.#e.isExecuting&&this.#e.cancelExecution({hidePanel:e})}async#o(e,t){let i;try{let{externalExecutor:a}=e;i=a?await this.#c({...e,externalExecutor:a},t):await this.#r(e,t)}catch(a){let n=a instanceof Error?a.message:String(a);i={type:"failure",error:b(n,a)}}this.#d(t,i)}async#r(e,t){if(!e.testData)return{type:"failure",error:b("Missing test data")};let i=await e.editorProfile;if(!i)return{type:"failure",error:b("Missing editor profile")};let a=await this.#a(i.definition,e.script,e.testData,{mode:e.mode,console:n=>this.#i(t,n),breakpoints:e.mode==="debug"?e.breakpoints:void 0,onDebugPause:e.mode==="debug"?(n,o)=>this.#n(t,n,o):void 0});return e.mode==="debug"?S(a)?{type:"failure",error:this.#u(a)}:{type:"debug",value:a}:S(a)?{type:"legacy-run",result:a}:{type:"failure",error:b("Unexpected debug result")}}async#c(e,t){let{externalExecutor:i}=e,a=new AbortController;this.#t=a;try{if(e.mode==="debug"){let o=await i.execute({mode:"debug",script:e.script,console:u=>this.#i(t,u),signal:a.signal,breakpoints:e.breakpoints,onDebugPause:(u,x)=>this.#n(t,u,x)});return{type:"debug",value:o.result,timing:o.timing}}let n=await i.execute({mode:"run",script:e.script,console:o=>this.#i(t,o),signal:a.signal});return{type:"run",value:n.result,timing:n.timing}}catch(n){let o=n instanceof Error?n.message:String(n);return{type:"failure",error:b(o,n)}}finally{this.#t===a&&(this.#t=void 0)}}#i(e,t){this.#s(e)&&this.#e.addConsoleLog(t)}async#n(e,t,i){if(!this.#s(e)||!this.#e.isDebugging)return;let a=Promise.withResolvers();return this.#e.pauseDebug({line:t.line,result:i,continue:a}),await a.promise}#d(e,t){if(this.#s(e))switch(t.type){case"debug":this.#e.completeDebug(t.value,t.timing);return;case"failure":this.#e.fail(t.error);return;case"legacy-run":this.#e.completeRun(t.result);return;case"run":this.#e.completeRun(t.value,{useDebugRenderer:!0,timing:t.timing})}}#u(e){return e.type==="error"?b(e.value,e.error):b("Unexpected legacy result")}#s(e){return e===this.#e.sessionId}},de={glyphMargin:!0,lineNumbersMinChars:1},K=class extends q{constructor(){super(...arguments),this._codeEditorElt=T(),this._arcadeAssistantElt=T(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this._focusContinueActionOnPause=!1,this._debuggerState=new g,this._executionCoordinator=new N(this._debuggerState),this.messages=W(),this._modelId=U(),this._openArcadeHelp=()=>{window.open(X,"Arcade Help")},this._decorations=void 0,this._monacoEditor=H(Y),this._editorOptions={},this._toggleSidePanel=e=>{e.currentTarget instanceof HTMLElement&&this._setOpenedSidePanel(e.currentTarget.dataset.panelName??"none")},this._closeSidePanel=()=>{this._setOpenedSidePanel("none")},this._updateBreakpointsDecorations=()=>{let e=this.editorInstance;if(!e)return;let t=this._debuggerState.editorBreakpoints.map(i=>({range:new F(i,1,i,1),options:{isWholeLine:!0,glyphMarginClassName:"arcgis-code-editor__breakpoint-glyph",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}));this._decorations?.clear(),this._decorations=e.createDecorationsCollection(t)},this._clearDebuggerDecorations=()=>{this._decorations?.clear(),this._decorations=void 0,this._debuggerPausedLineDecoration?.clear(),this._debuggerPausedLineDecoration=void 0},this._debuggerPausedLineDecoration=void 0,this._preparingArcade=!1,this._arcadeAssistantRemoteState={shouldRender:!1},this._diagnostics=[],this.enableDebugger=!1,this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.disableAssistant=!1,this.arcgisDiagnosticsChange=R({bubbles:!1}),this.arcgisScriptChange=R({bubbles:!1})}static{this.properties={_apiLibrary:16,_editorProfile:16,_preparingArcade:16,_arcadeAssistantRemoteState:16,_diagnostics:16,editorInstance:32,editorOptions:0,enableDebugger:5,hideDocumentationActions:5,hideSideBar:5,messageOverrides:0,openedSidePanel:3,profile:0,script:1,sideActionBarExpanded:7,snippets:0,suggestions:0,testData:0,customPanels:0,disableAssistant:5,arcadeAssistant:0,externalExecutor:0,docsConfig:0}}static{this.styles=[ae]}get _canExecute(){return!!(this.testData||this.externalExecutor)}get _usesBottomExecutionDrawer(){return this._canExecute&&(this.enableDebugger||!!this.externalExecutor)}get editorInstance(){return this._codeEditorElt.value?.editorInstance}get editorOptions(){return{...de,...this._editorOptions}}set editorOptions(e){this._editorOptions=e??{}}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,i=await w(e.definition,t,this.testData,{mode:"run"});return S(i)?i:{type:"error",value:"Unexpected result",error:null}}async testRun(){try{let e=this._codeEditorElt.value?.value??this.script;if(this.externalExecutor){let{result:n}=await this.externalExecutor.execute({mode:"run",script:e,console:()=>{},signal:new AbortController().signal});return n}let t=this.testData;if(!t)throw new Error("Missing test data");await this._componentReadyDefer.promise;let i=await this._editorProfilePromise;if(!i)throw new Error("Missing editor profile");let a=await w(i.definition,e,t,{mode:"debug"});if(S(a))throw a.type==="error"&&a.error instanceof Error?a.error:new Error(a.type==="error"?a.value:"Unexpected Arcade result");return a}catch(e){let t=e instanceof Error?e.message:String(e);return b(t,e)}}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async openArcadeAssistant(e){if(!this._arcadeAssistantRemoteState.shouldRender)return!1;if(this.openedSidePanel="arcade-assistant",await this.updateComplete,!this._canPromptWithArcadeAssistant())return!0;let t=this._arcadeAssistantElt.value;return e?.prompt&&await t?.openPrompt(e.prompt),!0}async load(){let e=V("./assets");te(e),await this._updateDataModelDeps(),this.manager.onLifecycle(()=>(this.hasUpdated&&this._connectMonacoCustomizations().catch(l(this)),()=>{for(this._askAiBindingKey&&(D(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);this._disposables.length;)this._disposables.pop()?.dispose();this._executionCoordinator.cancel(),this._connectMonacoCustomizationsPromise=void 0,this._executeScriptAction=void 0,this._executeDebugScriptAction=void 0,this._hasDebuggerBreakpointsContextKey=void 0,this._focusContinueActionOnPause=!1,this._clearDebuggerDecorations(),this._debuggerState.disconnect()}))}willUpdate(e){(e.has("messages")||e.has("profile"))&&this._updateDataModelDeps(),(e.has("testData")||e.has("externalExecutor"))&&this._executionContextChanged(),e.has("enableDebugger")&&(this.enableDebugger||this._debuggerState.disableDebugger(),this._syncExecuteDebugScriptAction()),e.has("snippets")&&f.updateApiContextForModel(this._modelId,{snippets:this.snippets}),(e.has("arcadeAssistant")||e.has("disableAssistant"))&&this._updateArcadeAssistantRemoteState()}async loaded(){await this._connectMonacoCustomizations(),this._componentReadyDefer.resolve()}_setOpenedSidePanel(e){this.openedSidePanel=e===this.openedSidePanel?"none":e}async _connectMonacoCustomizations(){if(this._connectMonacoCustomizationsPromise)return await this._connectMonacoCustomizationsPromise;this._connectMonacoCustomizationsPromise=(async()=>{if(!this.isConnected)return;let e=await se();this._disposables.push(e.onDiagnosticsChange(p=>{this._preparingArcade||(this._diagnostics=p.diagnostics,this.arcgisDiagnosticsChange.emit(p.diagnostics))})),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),this._syncAskAiAction();let t=v(()=>this._debuggerState.editorBreakpoints,()=>{this._updateBreakpointsDecorations(),this._updateDebuggerBreakpointContextKey()},{sync:!0}),i=v(()=>this._debuggerState.debuggerLine,()=>this._updateDebuggerPausedLineDecoration(),{sync:!0}),a=v(()=>this._debuggerState.isPaused,()=>{!this._debuggerState.isPaused||!this._focusContinueActionOnPause||(this._focusContinueActionOnPause=!1,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isConnected&&this._debuggerState.isPaused&&this.el.shadowRoot?.querySelector("#debugger-continue-action")?.setFocus()})}))},{sync:!0}),n=v(()=>this._debuggerState.isDebugging,()=>{this._debuggerState.isDebugging||(this._focusContinueActionOnPause=!1)},{sync:!0}),o=v(()=>this._debuggerState.consoleLogs.length,()=>this.requestUpdate(),{sync:!0});this._disposables.push({dispose:()=>t.remove()},{dispose:()=>i.remove()},{dispose:()=>a.remove()},{dispose:()=>n.remove()},{dispose:()=>o.remove()}),this._updateDebuggerBreakpointContextKey();let u=this.editorInstance?.onMouseDown(p=>this._onEditorMouseDown(p));u&&this._disposables.push(u);let x=this.editorInstance?.onDidChangeModelContent(p=>this._onEditorModelContentChange(p));x&&this._disposables.push(x),this._updateBreakpointsDecorations(),this._updateDebuggerPausedLineDecoration()})();try{await this._connectMonacoCustomizationsPromise}finally{this._connectMonacoCustomizationsPromise=void 0}}_onEditorMouseDown(e){if(!this.enableDebugger||![this._monacoEditor.MouseTargetType.GUTTER_GLYPH_MARGIN].includes(e.target.type)||e.target.element?.classList.contains("codicon-gutter-lightbulb"))return;let t=e.target.position?.lineNumber;t&&this._debuggerState.toggleBreakpoint(t)}_onEditorModelContentChange(e){if(!this.enableDebugger||!this._debuggerState.editorBreakpoints.length||e.isFlush)return;let t=j(this._debuggerState.editorBreakpoints,e.changes);t.length===this._debuggerState.editorBreakpoints.length&&t.every((i,a)=>i===this._debuggerState.editorBreakpoints[a])||this._debuggerState.setBreakpoints(t)}_updateDebuggerPausedLineDecoration(){let e=this.editorInstance;if(!e)return;this._debuggerPausedLineDecoration?.clear();let t=this._debuggerState.debuggerLine;t!=null?this._debuggerPausedLineDecoration=e.createDecorationsCollection([{range:new F(t,1,t,1),options:{isWholeLine:!0,className:"arcgis-code-editor__debugger-paused-line",glyphMarginClassName:"arcgis-code-editor__debugger-paused-glyph",marginClassName:"arcgis-code-editor__debugger-paused-line arcgis-code-editor__debugger-paused-margin",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}]):this._debuggerPausedLineDecoration=void 0}_continueDebugSession(){this._debuggerState.continueDebug()}_stopDebugSession(){this._executionCoordinator.cancel({hidePanel:!1})}_resetDebugSession(){this._debuggerState.resetDebug(),this._executeScript("debug").catch(l(this))}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}_executionContextChanged(){this._canExecute||(this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this._executeDebugScriptAction&&(this._disposeSafely(this._executeDebugScriptAction),this._executeDebugScriptAction=void 0)),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),!this.testData&&this.enableDebugger&&this._debuggerState.clearForMissingTestData(),this._debuggerState.openedPanel==="debug-console"&&!this.enableDebugger&&this._debuggerState.closePanel(),this._executionCoordinator.cancel({hidePanel:!1}),this._debuggerState.showPanel&&this._executeScript("run").catch(l(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await f.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=f.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await f.getApiLibraryForModel(this._modelId)}_setExecutionPanel(e){this._debuggerState.setPanel(e)}async _executeScript(e,t=!1){let i=this.testData,a=this.externalExecutor;!this._codeEditorElt.value||!i&&!a||(this._focusContinueActionOnPause=e==="debug"&&t,this._executionCoordinator.start({mode:e,script:this._codeEditorElt.value?.value??this.script,testData:i,editorProfile:this._editorProfilePromise,externalExecutor:a,breakpoints:this._debuggerState.debuggerBreakpoints}))}_toggleShowExecutionPanel(){this._debuggerState.togglePanel()}_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(l(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(l(this))}_onResultPanelChange(e){let t=e.currentTarget;this._debuggerState.setPanel(t.openedResultPanel)}_onExecutionPanelClose(){this._debuggerState.closePanel()}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[L.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this._canExecute&&this._executeScript("run").catch(l(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e)),this._syncExecuteDebugScriptAction()}_syncExecuteDebugScriptAction(){if(!this._canExecute||!this.enableDebugger){this._executeDebugScriptAction&&(this._disposeSafely(this._executeDebugScriptAction),this._executeDebugScriptAction=void 0);return}if(this._executeDebugScriptAction)return;let e=this.editorInstance?.addAction({id:"run-debug-script",label:this.messages.runanddebug??"Run and debug",precondition:"arcgisArcadeDebuggerHasBreakpoints",keybindings:[M.CtrlCmd|M.Shift|L.F5],contextMenuGroupId:"code",contextMenuOrder:2,run:()=>this._runAndDebug()});this._hasDebuggerBreakpointsContextKey??=this.editorInstance?.createContextKey("arcgisArcadeDebuggerHasBreakpoints",this._debuggerState.editorBreakpoints.length>0),this._updateDebuggerBreakpointContextKey(),e&&(this._executeDebugScriptAction=e,this._disposables.push(e))}_updateDebuggerBreakpointContextKey(){this._hasDebuggerBreakpointsContextKey?.set(this._debuggerState.editorBreakpoints.length>0)}_runAndDebug(){!this._canExecute||!this.enableDebugger||!this._debuggerState.editorBreakpoints.length||this._executeScript("debug",!0).catch(l(this))}_getAskAiBindingKey(){return Q.parse(this._modelId).toString()}_canRenderAskAiCodeActions(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.codeActions:!1}_canPromptWithArcadeAssistant(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.prompting:!1}_getAskAiCodeActions(e){if(!this._canRenderAskAiCodeActions())return[];if(!e.markers.length)return[];let t=this.messages.askarcadeassistant??"Ask Arcade Assistant",i=this._getAskAiBindingKey();return[{title:t,kind:Z,diagnostics:e.markers,isPreferred:!1,isAI:!1,command:{id:ee,title:t,arguments:[i,this.messages.askarcadeassistantprompt??"Fix the errors in my script"]}}]}_syncAskAiAction(){if(!this.editorInstance)return;let e=this._getAskAiBindingKey();if(!this._arcadeAssistantRemoteState.shouldRender){this._askAiBindingKey&&(D(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);return}this._askAiBindingKey&&this._askAiBindingKey!==e&&D(this._askAiBindingKey,void 0),D(e,{provideCodeActions:({context:t})=>this._getAskAiCodeActions(t),run:t=>{this.openArcadeAssistant({prompt:t??this.messages.askarcadeassistantprompt??"Fix the errors in my script"}).catch(l(this))}}),this._askAiBindingKey=e}_disposeSafely(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1),e.dispose()}async _updateArcadeAssistantRemoteState(){let e=this.arcadeAssistant;this.disableAssistant?this._arcadeAssistantRemoteState={shouldRender:!1}:this._arcadeAssistantRemoteState=await J(e??{}),this._syncAskAiAction()}renderMainActionBar(){return this._usesBottomExecutionDrawer||!this._canExecute?null:c`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-toggle-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=${()=>{this._executeScript("run").catch(l(this))}}></calcite-action>${this._debuggerState.result?c`<calcite-action .text=${this.messages.lastresults??""} .active=${this._debuggerState.showPanel} text-enabled icon=access-string-results icon-flip-rtl scale=s @click=${this._toggleShowExecutionPanel}></calcite-action>`:null}</calcite-action-group></calcite-action-bar>`}renderMainPanel(){return c`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${f.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${I(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:t,icon:i,active:a,panelName:n,iconFlipRtl:o=!1,onClick:u=this._toggleSidePanel}){return c`<calcite-action id=${e??C} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${i} .active=${a} @click=${u} data-panel-name=${n??C} .iconFlipRtl=${o}></calcite-action>${!this.sideActionBarExpanded&&c`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:c`<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,_arcadeAssistantRemoteState:t}=this;return c`<arcgis-language-api-panel slot=side-panel class=${y(e==="api"?"":"hidden")} .loading=${this._preparingArcade} .apiLibrary=${this._apiLibrary} .hideDocumentationActions=${this.hideDocumentationActions} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none .closed=${e!=="api"}></arcgis-language-api-panel><arcgis-editor-variables slot=side-panel class=${y(e==="variables"?"":"hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e!=="variables"} .messageOverrides=${{profileempty:this.messages.profileempty,profilevariables:this.messages.profilevariables}}></arcgis-editor-variables>${this.suggestions?.length&&c`<arcgis-arcade-suggestions slot=side-panel class=${y(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${t?.shouldRender&&c`<arcgis-arcade-coding-assistant slot=side-panel class=${y(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._closeSidePanel} .portalUrl=${t.portalUrl} .serviceUrl=${"serviceUrl"in t?t.serviceUrl:void 0} .helpBase=${t.helpBase} .promptingEnabled=${this._canPromptWithArcadeAssistant()} .feedbackServiceUrl=${t.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant?.appVersion} .disableQuestionAnswerLogging=${this.arcadeAssistant?.disableQuestionAnswerLogging} .diagnostics=${this._diagnostics} .isDevEnv=${"isDevEnv"in t?t.isDevEnv:!1} .docsConfig=${this.docsConfig} ${I(this._arcadeAssistantElt)}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(i=>c`<calcite-flow slot=side-panel class=${y(e===i.id?"":"hidden")}>${i?.useFlows?i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el}):c`<calcite-flow-item .heading=${i.name} heading-level=2 closable .closed=${e!==i.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${i.description}>${i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el})}</calcite-flow-item>`}</calcite-flow>`)}`}renderResultsPanel(){if(this._usesBottomExecutionDrawer)return this.renderBottomExecutionBody();if(!this._debuggerState.showPanel)return null;let e=this._debuggerState.openedPanel==="debug-console"?"output":this._debuggerState.openedPanel;return c`<arcgis-arcade-results slot=results-panel .openedResultPanel=${e} .loading=${this._debuggerState.isExecuting} .result=${this._debuggerState.resultForLegacyRenderer} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`}renderBottomExecutionBody(){let{showPanel:e,openedPanel:t,debugResult:i,isExecuting:a}=this._debuggerState;if(!e)return null;let n=t==="debug-console"?"output":t;return this.enableDebugger&&t==="debug-console"?c`<arcgis-arcade-debugger-console slot=results-panel .modelId=${this._modelId} .debuggerStore=${this._debuggerState}></arcgis-arcade-debugger-console>`:t==="output"&&i?c`<arcgis-arcade-debugger-output slot=results-panel .debuggerStore=${this._debuggerState} .result=${i}></arcgis-arcade-debugger-output>`:c`<arcgis-arcade-results slot=results-panel class="bottom-results" .openedResultPanel=${n} .loading=${t==="console"&&this._debuggerState.isPaused?!1:a} .result=${this._debuggerState.resultForLegacyRenderer} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} hide-header @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange}></arcgis-arcade-results>`}renderBottomActionBar(){if(!this._usesBottomExecutionDrawer)return null;let{showPanel:e,hasExecuted:t,openedPanel:i,isDebugging:a,isPaused:n,isExecuting:o}=this._debuggerState,u=this.messages.continue??"Continue",x=this.messages.reset??"Reset",p=this.messages.stop??"Stop";return c`<div slot=bottom-action-bar class=${`main-action-bar bottom-action-bar ${e?"":"is-collapsed"}`}><calcite-action-bar class="bottom-action-bar__actions" layout=horizontal scale=s expand-toggle-disabled expanded><calcite-action-group scale=s>${this.enableDebugger&&a?c`<calcite-action id=debugger-continue-action .text=${u} icon=forward scale=s .disabled=${!n} @click=${this._continueDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-continue-action placement=top><span>${u}</span></calcite-tooltip><calcite-action id=debugger-reset-action .text=${x} icon=reset scale=s @click=${this._resetDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-reset-action placement=top><span>${x}</span></calcite-tooltip><calcite-action id=debugger-stop-action .text=${p} icon=circle-stop scale=s @click=${this._stopDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-stop-action placement=top><span>${p}</span></calcite-tooltip>`:c`<calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade||o} @click=${()=>{this._executeScript("run").catch(l(this))}}></calcite-action>${this.enableDebugger&&c`<calcite-action .disabled=${this._debuggerState.editorBreakpoints.length===0} .text=${this.messages.runanddebug??"Run and Debug"} text-enabled icon=debug-script scale=s .loading=${this._preparingArcade||o} @click=${this._runAndDebug}></calcite-action>`||""}`}</calcite-action-group>${t?c`<calcite-action-group scale=s><calcite-action .active=${i==="output"&&e} .text=${this.messages.output??"Output"} text-enabled scale=s icon=list-show-all icon-flip-rtl @click=${()=>this._setExecutionPanel("output")}></calcite-action><calcite-action .active=${i==="console"&&e} .text=${this.messages.console??"Console"} text-enabled scale=s icon=console icon-flip-rtl @click=${()=>this._setExecutionPanel("console")}></calcite-action><calcite-action .active=${i==="log"&&e} .text=${this.messages.log??"Log"} text-enabled scale=s icon=list icon-flip-rtl @click=${()=>this._setExecutionPanel("log")} .disabled=${this.enableDebugger&&this._debuggerState.mode==="debug"}></calcite-action>${this.enableDebugger&&c`<calcite-action .active=${i==="debug-console"&&e} .text=${this.messages.debugconsole??"Debug console"} text-enabled scale=s icon=debug .disabled=${this._debuggerState.mode!=="debug"} @click=${()=>this._setExecutionPanel("debug-console")}></calcite-action>`||""}</calcite-action-group>`:null}</calcite-action-bar>${e?c`<calcite-action .text=${this.messages.collapse??"Collapse"} scale=s icon=chevrons-down icon-flip-rtl @click=${this._onExecutionPanelClose} slot=actions-end></calcite-action>`:null}</div>`}render(){return c`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderBottomActionBar()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};G("arcgis-arcade-editor",K);return K},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators",a,b,d,e,f,g,h)
@@ -1,4 +1,4 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{a as N}from"./IO6Q3255.js";import e from"./D5GWRYT7.js";import c from"./YCA4A2EF.js";import b from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import{d as se,e as oe}from"./ZLV7T4YS.js";import{d as ne}from"./MZMKV7FA.js";import{a as ie}from"./G4VQ7X3L.js";import"./A3TU47C5.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import{E as X,F as K,G as Z,H as ee,I as E,K as te,h as j,j as d,k as H,l as R,t as G,w as J,x as Y,y as W}from"./O6XP7VU2.js";import{a as w}from"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([Se,re,Te,ce,le,{getDeclaredVoxelMembers:Ae,getDeclaredPixelMembers:Ce},Ie,{property:b,subclass:Ee},{G:F,w:ae,x:V},,q,{b:P}])=>{var C=class extends W{constructor(e){if(super(e),this.it=R,e.type!==J.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===R||e==null)return this._t=void 0,this.it=e;if(e===H)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};C.directiveName="unsafeHTML",C.resultType=1;var I=Y(C);var Me=j`: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-dialog{--calcite-dialog-content-space: initial;--calcite-dialog-size-y: initial}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}`,k=class extends Error{constructor({message:e,code:t,subCode:a,details:o,source:n}){super(e),this.name="ArcadeAssistantError",this.code=t,this.subCode=a,this.details=o,this.source=n}};function de(i){if(!i)return;let e=i.indexOf('{"error":');if(e!==-1)try{let t=i.slice(e),a=JSON.parse(t);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Re(i){let{baseUrl:e,skillId:t,message:a,authToken:o,previousConversationId:n,context:r}=i,p=t?`${e}/skills/${t}/chat`:`${e}/chat`,c=[],s={message:a,context:r};n&&(s.conversation_id=n);let u;try{u=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(s),responseType:"json"})}catch(v){let f=v,$=f.details?.rawResponse||f.message||String(v),x=de($);throw x?new k(x):v}let l=u.data;c.push(l);let h=l.conversationId,S=l.inquiryId;async function T(){let v=l.sequenceNumber,f=0,$=100;for(;f<$;){await new Promise(A=>setTimeout(A,1e3));let x=Ve(h,v,S),L;try{L=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(x),responseType:"json"})}catch(A){let B=A,ke=B.details?.rawResponse||B.message||String(A),Q=de(ke);throw Q?new k(Q):A}let y=L.data;if(y.context?.kind==="ArcgisErrorAsContext"&&y.context.error)throw new k({message:y.context.error.message||"ArcGIS Assistant error",code:y.context.error.code,subCode:y.context.error.subCode,details:y.context.error.details,source:"polling-response"});if(c.push(y),v=y.sequenceNumber,f++,!y.hasMore)break}if(f===$)throw new k({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let M=120*1e3;return await Promise.race([T(),new Promise((v,f)=>setTimeout(()=>f(new k({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),M))]),c}function Ve(i,e,t){return{conversationId:i,inquiryId:t,ackSequenceNumber:e}}function Fe(i){return i.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":i.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":i.message}var qe=({notices:i})=>i.length?d`<div class="border-block-end">${N(i,e=>e.id??e.title,e=>d`<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&&d`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&d`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Pe=i=>{let e=i.value.length,t=72,a=180,o=i.offsetWidth,n=Math.max(1,Math.floor(o/8)),r=Math.ceil(e/n),p=t+(r-2)*24;i.style.setProperty("--calcite-text-area-min-height",`${Math.min(p,a)}px`)},Ne=({promptValidationMessage:i,errorMessage:e,contextTooBig:t,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:o,setErrorMessage:n,messages:r})=>{let p=[];if(i&&p.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:i,closable:!0}),e&&p.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),t&&!a){let c=r.contextreduced??"Context reduced",s=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.";p.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:s,closable:!0,onClose:()=>o(!0)})}return p};function _e({messages:i}){return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta??"Beta"}>${i.beta??"Beta"}</calcite-chip>`}function De({popoverContent:i,messages:e}){return d`<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">${i}</div></calcite-popover>`}function Ue({errorMessage:i,slot:e}){return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??E}>${i}</calcite-input-message></div>`}function Oe({active:i,setActive:e,messages:t}){return d`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${t.expressionapplied??"Expression applied"}><div slot=message>${t.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function ze({context:i,messages:e}){return i?d`<div class="gaps">${i.profileId&&d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function Le({isDisabled:i,isReadOnly:e,setQuestion:t,setIsViewingResult:a,textAreaRef:o,question:n,errorMessage:r,setErrorMessage:p,promptValidationMessage:c,setPromptValidationMessage:s,submitQuestion:u,messages:l,mode:h,assistantRef:S,context:T,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:v}){let f=T?.contextTooLarge??!1,$=Ne({promptValidationMessage:c,errorMessage:r,contextTooBig:f,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:v,setErrorMessage:p,messages:l});return d`<div class="text-area-wrapper">${qe({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${i||e} class=${ee($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${l.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${x=>{Pe(x.target),t(x.target.value)}} ${K(o)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${T&&ze({context:T,messages:l})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${i} @click=${async()=>{a(!1),t("")}} .label=${l.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">${l.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${i} @click=${async()=>{a(!1),t("")}} class="hidden-below-380" scale=s>${l.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-below-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} id=small-submit-button @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-above-380" .label=${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var Be="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function je({setOpen:i,messages:e,feedback:t,learnMoreUrl:a,setFeedback:o,onSubmit:n}){return t.active?d`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${()=>i(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${t.text} @calciteTextAreaInput=${r=>o({...t,text:r.target.value})} .disabled=${t.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=${t.termsAccepted} @calciteCheckboxChange=${r=>{o({...t,termsAccepted:r.target.checked})}} .disabled=${t.submitting}></calcite-checkbox><span>${I((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=${Be} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${I((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=${()=>i(!1)} .disabled=${t.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!t.termsAccepted||t.submitting} .loading=${t.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function pe({promptingEnabled:i,messages:e,slot:t,helpTopicUrl:a}){return d`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${t??E} 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>${i?d`<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>${I((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>`:d`<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 He({messages:i,onProceed:e,onExit:t,helpTopicUrl:a}){return d`<calcite-dialog close-disabled placement=top .heading=${i.welcome??"Welcome to the new assistant experience"} slot=dialogs open width=s scale=s id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${i.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${I((i.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">${i.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ge({messages:i,suggestions:e,onSuggestionClick:t}){return d`<calcite-block .heading=${i.promptsuggestions} expanded expandable id=suggestion-block scale=s><div class="suggestions">${e.map(a=>d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${()=>t?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var ue=200;function me({hidden:i=!1,expanded:e=!1,messages:t,cards:a,heading:o,collapsible:n=!1,showEffectsIcon:r=!1,onCopyCode:p,standalone:c}){return d`<calcite-block .hidden=${i} id=result-block .heading=${o??t.besteffort??"Here is the assistant's best effort"} .expanded=${e} .expandable=${n}>${r&&d`<calcite-chip .label=${t.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${t.assistantresponses??"Assistant responses"}>${N(a,s=>s.conversationId,s=>d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${s.priorPrompt.length>ue?`${s.priorPrompt.slice(0,ue)}...`:s.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} @click=${u=>{let l=u.currentTarget;navigator.clipboard.writeText(s.priorPrompt).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${s.message&&c&&d`<div class="response-error-container">${Ue({errorMessage:s.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${t.responsecontext??"Response Context"} scale=s>${s.message&&!c&&d`<calcite-tooltip .referenceElement=${`response-chip-${s.conversationId}-error`} placement=top-start>${s.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${s.conversationId}-error`} .label=${t.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${Je({card:s,messages:t})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${s.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=${()=>s.onAddToEditor("replace")} scale=s icon-start=file-code round .label=${t.replaceineditor??"Replace code in editor"} .id=${`replace-in-editor-button-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`replace-in-editor-button-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start>${t.replaceineditor??"Replace code in editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>s.onAddToEditor("replace")} scale=s icon-start=file-code round>${t.replaceineditor??"Replace code in editor"}</calcite-button><calcite-button round icon-start=plus kind=neutral scale=s @click=${()=>s.onAddToEditor("add")} class="response-secondary-action-button" .id=${`add-to-editor-button-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`add-to-editor-button-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.addtoeditor??"Add to editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${u=>{let l=u.currentTarget;p(s.code).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${s.onThumbsUp} .id=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${s.onThumbsDown} .id=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var Je=({card:i,messages:e})=>{let t=G(),a=`response-chip-profile-${i.conversationId}-${t}`,o=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId);return d`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${o}</calcite-tooltip><calcite-chip .label=${i.profileId} scale=s appearance=outline icon=map-information id=${a??E}>${i.profileId}</calcite-chip>`},he=i=>i.type==="featureSet";function $e(i){return i&&i!=="dataCatalogDatastore"?i:void 0}var _=i=>{if(!ae(i))return[];let e=[];return i.relationships?.forEach(t=>{e.push(t.toJSON())}),e},D=i=>i.length>0?{relationships:i}:{},Ye=i=>ne(i).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),U=i=>i?{fields:Ye(i)}:{fields:[]};async function ge(i){let e=await i.loadSource(),t=V(e)&&e.isTable,a=_(e);return{name:i.name,type:"featureSet",isTable:t,...U(e?.fields),...D(a)}}async function xe(i){switch(i.type){case"feature":{let t=await i.loadSource(),a=_(t);return{name:i.name,type:i.type,...U(t?.fields),...D(a)}}case"featureSet":{let t=await i.loadSource(),a=V(t)&&t.isTable;return{name:i.name,type:"featureSet",...a?{isTable:a}:{},...U(t?.fields),...D(_(t))}}case"featureSetCollection":{let t=await i.loadSource(),a=t?.layers.filter(he)??[],o=t?.tables.filter(he)??[],n=await Promise.all(a.map(ge)),r=await Promise.all(o.map(ge));return{name:i.name,type:"featureSetCollection",layers:n,tables:r}}case"dictionary":{let t=await Promise.all(i.dictionaryVariables.filter(F).map(xe));return{name:i.name,type:"dictionary",attributes:t}}case"pixel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"pixel"};let a=await Ce(t);return{name:i.name,type:"pixel",members:a.map(be)}}case"voxel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"voxel"};let a=await Ae(t);return{name:i.name,type:"voxel",members:a.map(be)}}case"array":let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:i.name,type:i.type}}}function be(i){if(i.type==="array"){let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}}}return{name:i.name,type:i.type}}async function We(i){return{variables:await Promise.all(i.variables.filter(F).map(xe))}}var Xe=1e5;function Ke(i){let e=new TextEncoder().encode(i).length;return Math.ceil(e/3.5)}function O(i){return Ke(JSON.stringify(i))}function Ze(i){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),t=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(t)};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:i.variables.map(t)}}function et(i){let e=i.variables,t=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],o=a?[a]:[];return{context:{variables:o},wasReduced:t!==o.length,reducedToVariableName:a?.name}}function tt(i){return O(i)>Xe}var it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,g=(i,e,t,a)=>{for(var o=a>1?void 0:a?at(e,t):e,n=i.length-1,r;n>=0;n--)(r=i[n])&&(o=(a?r(e,t,o):r(o))||o);return a&&o&&it(e,t,o),o},m=class extends Ie{constructor(i){super(i),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};g([b()],m.prototype,"viewMode",2);g([b()],m.prototype,"confirmationActive",2);g([b()],m.prototype,"contextReducedNoticeDismissed",2);g([b()],m.prototype,"splashActive",2);g([b()],m.prototype,"isSubmitting",2);g([b()],m.prototype,"errorMessage",2);g([b()],m.prototype,"promptValidationMessage",2);g([b()],m.prototype,"question",2);g([b()],m.prototype,"history",2);g([b()],m.prototype,"feedback",2);g([b()],m.prototype,"context",2);m=g([Ee("ArcadeAssistantViewState")],m);var st="arcade_generation",ot="ArcadeCodeRequest",fe="visualization",ve="ArcadeAssistant",nt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras","extras2","conversation_id","privacy_statement"],ye=[],we=!0,z=class extends Z{constructor(){super(...arguments),this.textAreaRef=X(),this.messages=ie(),this._feedbackService=void 0,this.viewState=new m,this.handleFeedbackButton=(e,t)=>{this.updateViewState({feedback:{active:!0,value:e,item:t,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 t=!1,a;if(this.viewState.feedback.item.isCurrentResult&&this.viewState.viewMode==="result"){let h=this.viewState.context??await this.getProfileAndMetadata(this.getModel()?.uri??""),S=this.viewState.feedback.item.contextSnapshot;a={...h,editor_code:S?.editor_code??"",diagnostics:S?.diagnostics,runtime:S?.runtime??P()},t=!0}else a=this.viewState.feedback.item.contextSnapshot;let o=ce.applicationName;!o&&!this.appVersion&&w("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:n,text:r,termsAccepted:p,item:{question:c,formattedScript:s,conversationId:u}}=this.viewState.feedback,l={user_evaluation:n,your_comments:r||void 0,question:c??"",answer:this.encodeForFeedback(s),useragent:navigator.userAgent,_source:ve,version:this.appVersion||o||"NOT_SET",context:a?JSON.stringify({...a,editor_code:this.encodeForFeedback(a.editor_code),isSnapshot:!t}):"",extras:a?.profileId??"",extras2:this.isDevEnv?"dev":"",conversation_id:u??"",privacy_statement:p?"I_agree":""};try{await e.applyEdits({addFeatures:[new le({attributes:l})]})}catch(h){w("error",this,"Error submitting feedback.",{detail:{error:h}})}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.promptingEnabled=!1,this.closed=!1,this.isDevEnv=!1,this.disableQuestionAnswerLogging=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,promptingEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,isDevEnv:5,appVersion:1,diagnostics:0,disableQuestionAnswerLogging:5}}static{this.styles=Me}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/understand-arcade-assistant.htm`}async openPrompt(e){if(this.closed=!1,!this.promptingEnabled)return;e&&this.updateViewState({question:e,viewMode:"prompt"});let t=this.textAreaRef.value;t&&t.setFocus()}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:ye,splashActive:we})}loaded(){let e=async()=>{let t=this.getModel();if(!t){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(t.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};this.manager.onLifecycle(()=>{e();let t=q.onModelContextDidChange(async()=>{e().catch(a=>{w("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{t.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),ye=this.viewState.history,we=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let t=Ze(e.metadata);return{...e,metadata:t,estimatedTokens:O(t)}}withEditorState(e,t){return{...e,editor_code:t?.getValue()??this.getModel()?.getValue()??"",diagnostics:this.diagnostics,runtime:P()}}encodeForFeedback(e){return encodeURIComponent(e??"")}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,t)=>(!t.script||(e.push({priorPrompt:t.question,code:t.formattedScript||t.error||"",profileId:t.profile??fe,onAddToEditor:a=>{se(this.editorRef.editorInstance,t.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",t),onThumbsDown:()=>this.handleFeedbackButton("bad",t),conversationId:t.conversationId??"",message:t.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 t=nt.filter(a=>!e.fields.some(o=>o.name===a));if(t.length>0){w("error",this,`Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}async logInteractionToFeedbackService(e){if(this.disableQuestionAnswerLogging||!e.question)return;let t;try{t=await this.ensureFeedbackService()}catch(r){w("error",this,"Error initializing feedback service for interaction logging.",{detail:{error:r}});return}if(!t)return;let a=ce.applicationName,o=e.contextSnapshot,n={question:e.question,answer:this.encodeForFeedback(e.answer),useragent:navigator.userAgent,_source:ve,version:this.appVersion||a||"NOT_SET",context:o?JSON.stringify({...o,isSnapshot:!0}):"",extras:o?.profileId??"",extras2:this.isDevEnv?"dev":"",conversation_id:e.conversationId??"",privacy_statement:""};try{await t.applyEdits({addFeatures:[new le({attributes:n})]})}catch(r){w("error",this,"Error logging arcade assistant question/answer interaction.",{detail:{error:r}})}}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(!this.viewState.question)return;let e=this.viewState.question;this.updateViewState({isSubmitting:!0,errorMessage:void 0});let t,a;try{let o=this.getModel();if(!o||!this.serviceUrl)return;let n=this.viewState.context??await this.getProfileAndMetadata(o.uri),r=this.withEditorState(n,o);t=this.createFeedbackContextSnapshot(r);let p=await this.getToken(),c=await Re({baseUrl:this.serviceUrl,skillId:st,message:e,authToken:p,context:{kind:ot,context:{profile_id:r.profileId,metadata:[r.metadata],editor_code:r.editor_code,runtime:r.runtime,...r.diagnostics?.length?{diagnostics:r.diagnostics}:{}}}});a=c?.[0]?.conversationId;let s=c.find(u=>u.context?.kind==="ArcadeCodeResponse");if(!s){await this.logInteractionToFeedbackService({question:e,answer:"No ArcadeCodeResponse returned.",contextSnapshot:t,conversationId:a});return}if(s.context?.kind==="ArcadeCodeResponse"){let u=this.createFeedbackContextSnapshot(r),l=oe(s?.context?.arcadeCode?.code??"");this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:l,error:void 0,question:e,profile:n.profileId,conversationId:s.conversationId,isCurrentResult:!0,contextSnapshot:u,...s.message?{message:s.message}:{}},...this.viewState.history.map(h=>({...h,isCurrentResult:!1}))],viewMode:"result",errorMessage:void 0}),await this.logInteractionToFeedbackService({question:e,answer:l,contextSnapshot:t,conversationId:s.conversationId})}}catch(o){let n=o instanceof Error&&o.name==="ArcadeAssistantError"?Fe(o)||this.messages.erroroccurred||"An error occurred.":this.messages.erroroccurred||"An error occurred.";this.updateViewState({errorMessage:n}),await this.logInteractionToFeedbackService({question:e,answer:n,contextSnapshot:t,conversationId:a}),w("error",this,"Error submitting question",{detail:{error:o}})}finally{this.updateViewState({isSubmitting:!1})}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let t=fe,a=q.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let o=this.editorRef.profile;o&&"id"in o&&(t=o.id);let n=a?await We(a):{variables:[]},r=tt(n),p=r?et(n):void 0,c=p?p.context:n,s=O(c);return{profileId:t,metadata:c,contextTooLarge:r,reducedToVariableName:p?.reducedToVariableName,estimatedTokens:s}}onCopyCode(e){let t=e?`${this.disclaimerComment}
4
- ${e}`:"";return navigator.clipboard.writeText(t)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",t=this.getHistoryCards();return this.promptingEnabled?d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&d`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${De({messages:this.messages,popoverContent:pe({promptingEnabled:this.promptingEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&He({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:a=>this.closePanel?.(a)})||""}${Oe({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${Le({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&&Ge({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>${me({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:t.length?[t[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${me({expanded:!e,messages:this.messages,collapsible:!0,cards:e?t.slice(1):t,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?je({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>`:d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${pe({slot:"content-top",messages:this.messages,promptingEnabled:this.promptingEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};te("arcgis-arcade-coding-assistant",z);return z},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,e)
2
+ import{a as N}from"./IO6Q3255.js";import e from"./D5GWRYT7.js";import c from"./J7TSCCXO.js";import b from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import{d as se,e as oe}from"./ZLV7T4YS.js";import{d as ne}from"./MZMKV7FA.js";import{a as ie}from"./G4VQ7X3L.js";import"./A3TU47C5.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import{E as X,F as K,G as Z,H as ee,I as E,K as te,h as j,j as d,k as H,l as R,t as G,w as J,x as Y,y as W}from"./O6XP7VU2.js";import{a as w}from"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([Se,re,Te,ce,le,{getDeclaredVoxelMembers:Ce,getDeclaredPixelMembers:Ae},Ie,{property:b,subclass:Ee},{G:F,w:ae,x:V},,q,{b:P}])=>{var A=class extends W{constructor(e){if(super(e),this.it=R,e.type!==J.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===R||e==null)return this._t=void 0,this.it=e;if(e===H)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 t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};A.directiveName="unsafeHTML",A.resultType=1;var I=Y(A);var Me=j`: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-dialog{--calcite-dialog-content-space: initial;--calcite-dialog-size-y: initial}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}`,k=class extends Error{constructor({message:e,code:t,subCode:a,details:o,source:n}){super(e),this.name="ArcadeAssistantError",this.code=t,this.subCode=a,this.details=o,this.source=n}};function de(i){if(!i)return;let e=i.indexOf('{"error":');if(e!==-1)try{let t=i.slice(e),a=JSON.parse(t);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Re(i){let{baseUrl:e,skillId:t,message:a,authToken:o,previousConversationId:n,context:r}=i,p=t?`${e}/skills/${t}/chat`:`${e}/chat`,c=[],s={message:a,context:r};n&&(s.conversation_id=n);let u;try{u=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(s),responseType:"json"})}catch(v){let f=v,$=f.details?.rawResponse||f.message||String(v),x=de($);throw x?new k(x):v}let l=u.data;c.push(l);let h=l.conversationId,S=l.inquiryId;async function T(){let v=l.sequenceNumber,f=0,$=100;for(;f<$;){await new Promise(C=>setTimeout(C,1e3));let x=Ve(h,v,S),L;try{L=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(x),responseType:"json"})}catch(C){let B=C,ke=B.details?.rawResponse||B.message||String(C),Q=de(ke);throw Q?new k(Q):C}let y=L.data;if(y.context?.kind==="ArcgisErrorAsContext"&&y.context.error)throw new k({message:y.context.error.message||"ArcGIS Assistant error",code:y.context.error.code,subCode:y.context.error.subCode,details:y.context.error.details,source:"polling-response"});if(c.push(y),v=y.sequenceNumber,f++,!y.hasMore)break}if(f===$)throw new k({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let M=120*1e3;return await Promise.race([T(),new Promise((v,f)=>setTimeout(()=>f(new k({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),M))]),c}function Ve(i,e,t){return{conversationId:i,inquiryId:t,ackSequenceNumber:e}}function Fe(i){return i.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":i.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":i.message}var qe=({notices:i})=>i.length?d`<div class="border-block-end">${N(i,e=>e.id??e.title,e=>d`<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&&d`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&d`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Pe=i=>{let e=i.value.length,t=72,a=180,o=i.offsetWidth,n=Math.max(1,Math.floor(o/8)),r=Math.ceil(e/n),p=t+(r-2)*24;i.style.setProperty("--calcite-text-area-min-height",`${Math.min(p,a)}px`)},Ne=({promptValidationMessage:i,errorMessage:e,contextTooBig:t,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:o,setErrorMessage:n,messages:r})=>{let p=[];if(i&&p.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:i,closable:!0}),e&&p.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),t&&!a){let c=r.contextreduced??"Context reduced",s=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.";p.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:s,closable:!0,onClose:()=>o(!0)})}return p};function _e({messages:i}){return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta??"Beta"}>${i.beta??"Beta"}</calcite-chip>`}function De({popoverContent:i,messages:e}){return d`<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">${i}</div></calcite-popover>`}function Ue({errorMessage:i,slot:e}){return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??E}>${i}</calcite-input-message></div>`}function ze({active:i,setActive:e,messages:t}){return d`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${t.expressionapplied??"Expression applied"}><div slot=message>${t.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function Oe({context:i,messages:e}){return i?d`<div class="gaps">${i.profileId&&d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function Le({isDisabled:i,isReadOnly:e,setQuestion:t,setIsViewingResult:a,textAreaRef:o,question:n,errorMessage:r,setErrorMessage:p,promptValidationMessage:c,setPromptValidationMessage:s,submitQuestion:u,messages:l,mode:h,assistantRef:S,context:T,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:v}){let f=T?.contextTooLarge??!1,$=Ne({promptValidationMessage:c,errorMessage:r,contextTooBig:f,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:v,setErrorMessage:p,messages:l});return d`<div class="text-area-wrapper">${qe({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${i||e} class=${ee($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${l.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${x=>{Pe(x.target),t(x.target.value)}} ${K(o)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${T&&Oe({context:T,messages:l})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${i} @click=${async()=>{a(!1),t("")}} .label=${l.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">${l.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${i} @click=${async()=>{a(!1),t("")}} class="hidden-below-380" scale=s>${l.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-below-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} id=small-submit-button @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-above-380" .label=${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var Be="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function je({setOpen:i,messages:e,feedback:t,learnMoreUrl:a,setFeedback:o,onSubmit:n}){return t.active?d`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${()=>i(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${t.text} @calciteTextAreaInput=${r=>o({...t,text:r.target.value})} .disabled=${t.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=${t.termsAccepted} @calciteCheckboxChange=${r=>{o({...t,termsAccepted:r.target.checked})}} .disabled=${t.submitting}></calcite-checkbox><span>${I((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=${Be} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${I((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=${()=>i(!1)} .disabled=${t.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!t.termsAccepted||t.submitting} .loading=${t.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function pe({promptingEnabled:i,messages:e,slot:t,helpTopicUrl:a}){return d`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${t??E} 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>${i?d`<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>${I((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>`:d`<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 He({messages:i,onProceed:e,onExit:t,helpTopicUrl:a}){return d`<calcite-dialog close-disabled placement=top .heading=${i.welcome??"Welcome to the new assistant experience"} slot=dialogs open width=s scale=s id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${i.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${I((i.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">${i.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ge({messages:i,suggestions:e,onSuggestionClick:t}){return d`<calcite-block .heading=${i.promptsuggestions} expanded expandable id=suggestion-block scale=s><div class="suggestions">${e.map(a=>d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${()=>t?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var ue=200;function me({hidden:i=!1,expanded:e=!1,messages:t,cards:a,heading:o,collapsible:n=!1,showEffectsIcon:r=!1,onCopyCode:p,standalone:c}){return d`<calcite-block .hidden=${i} id=result-block .heading=${o??t.besteffort??"Here is the assistant's best effort"} .expanded=${e} .expandable=${n}>${r&&d`<calcite-chip .label=${t.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${t.assistantresponses??"Assistant responses"}>${N(a,s=>s.conversationId,s=>d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${s.priorPrompt.length>ue?`${s.priorPrompt.slice(0,ue)}...`:s.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} @click=${u=>{let l=u.currentTarget;navigator.clipboard.writeText(s.priorPrompt).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${s.message&&c&&d`<div class="response-error-container">${Ue({errorMessage:s.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${t.responsecontext??"Response Context"} scale=s>${s.message&&!c&&d`<calcite-tooltip .referenceElement=${`response-chip-${s.conversationId}-error`} placement=top-start>${s.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${s.conversationId}-error`} .label=${t.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${Je({card:s,messages:t})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${s.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=${()=>s.onAddToEditor("replace")} scale=s icon-start=file-code round .label=${t.replaceineditor??"Replace code in editor"} .id=${`replace-in-editor-button-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`replace-in-editor-button-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start>${t.replaceineditor??"Replace code in editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>s.onAddToEditor("replace")} scale=s icon-start=file-code round>${t.replaceineditor??"Replace code in editor"}</calcite-button><calcite-button round icon-start=plus kind=neutral scale=s @click=${()=>s.onAddToEditor("add")} class="response-secondary-action-button" .id=${`add-to-editor-button-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`add-to-editor-button-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.addtoeditor??"Add to editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${u=>{let l=u.currentTarget;p(s.code).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${s.onThumbsUp} .id=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${s.onThumbsDown} .id=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var Je=({card:i,messages:e})=>{let t=G(),a=`response-chip-profile-${i.conversationId}-${t}`,o=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId);return d`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${o}</calcite-tooltip><calcite-chip .label=${i.profileId} scale=s appearance=outline icon=map-information id=${a??E}>${i.profileId}</calcite-chip>`},he=i=>i.type==="featureSet";function $e(i){return i&&i!=="dataCatalogDatastore"?i:void 0}var _=i=>{if(!ae(i))return[];let e=[];return i.relationships?.forEach(t=>{e.push(t.toJSON())}),e},D=i=>i.length>0?{relationships:i}:{},Ye=i=>ne(i).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),U=i=>i?{fields:Ye(i)}:{fields:[]};async function ge(i){let e=await i.loadSource(),t=V(e)&&e.isTable,a=_(e);return{name:i.name,type:"featureSet",isTable:t,...U(e?.fields),...D(a)}}async function xe(i){switch(i.type){case"feature":{let t=await i.loadSource(),a=_(t);return{name:i.name,type:i.type,...U(t?.fields),...D(a)}}case"featureSet":{let t=await i.loadSource(),a=V(t)&&t.isTable;return{name:i.name,type:"featureSet",...a?{isTable:a}:{},...U(t?.fields),...D(_(t))}}case"featureSetCollection":{let t=await i.loadSource(),a=t?.layers.filter(he)??[],o=t?.tables.filter(he)??[],n=await Promise.all(a.map(ge)),r=await Promise.all(o.map(ge));return{name:i.name,type:"featureSetCollection",layers:n,tables:r}}case"dictionary":{let t=await Promise.all(i.dictionaryVariables.filter(F).map(xe));return{name:i.name,type:"dictionary",attributes:t}}case"pixel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"pixel"};let a=await Ae(t);return{name:i.name,type:"pixel",members:a.map(be)}}case"voxel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"voxel"};let a=await Ce(t);return{name:i.name,type:"voxel",members:a.map(be)}}case"array":let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:i.name,type:i.type}}}function be(i){if(i.type==="array"){let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}}}return{name:i.name,type:i.type}}async function We(i){return{variables:await Promise.all(i.variables.filter(F).map(xe))}}var Xe=1e5;function Ke(i){let e=new TextEncoder().encode(i).length;return Math.ceil(e/3.5)}function z(i){return Ke(JSON.stringify(i))}function Ze(i){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),t=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(t)};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:i.variables.map(t)}}function et(i){let e=i.variables,t=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],o=a?[a]:[];return{context:{variables:o},wasReduced:t!==o.length,reducedToVariableName:a?.name}}function tt(i){return z(i)>Xe}var it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,g=(i,e,t,a)=>{for(var o=a>1?void 0:a?at(e,t):e,n=i.length-1,r;n>=0;n--)(r=i[n])&&(o=(a?r(e,t,o):r(o))||o);return a&&o&&it(e,t,o),o},m=class extends Ie{constructor(i){super(i),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};g([b()],m.prototype,"viewMode",2);g([b()],m.prototype,"confirmationActive",2);g([b()],m.prototype,"contextReducedNoticeDismissed",2);g([b()],m.prototype,"splashActive",2);g([b()],m.prototype,"isSubmitting",2);g([b()],m.prototype,"errorMessage",2);g([b()],m.prototype,"promptValidationMessage",2);g([b()],m.prototype,"question",2);g([b()],m.prototype,"history",2);g([b()],m.prototype,"feedback",2);g([b()],m.prototype,"context",2);m=g([Ee("ArcadeAssistantViewState")],m);var st="arcade-assistant-reference-doc",ot="arcade_generation",nt="ArcadeCodeRequest",fe="visualization",ve="ArcadeAssistant",rt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras","extras2","conversation_id","privacy_statement"],ye=[],we=!0,O=class extends Z{constructor(){super(...arguments),this.textAreaRef=X(),this.messages=ie(),this._feedbackService=void 0,this.viewState=new m,this.handleFeedbackButton=(e,t)=>{this.updateViewState({feedback:{active:!0,value:e,item:t,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 t=!1,a;if(this.viewState.feedback.item.isCurrentResult&&this.viewState.viewMode==="result"){let h=this.viewState.context??await this.getProfileAndMetadata(this.getModel()?.uri??""),S=this.viewState.feedback.item.contextSnapshot;a={...h,editor_code:S?.editor_code??"",diagnostics:S?.diagnostics,runtime:S?.runtime??P()},t=!0}else a=this.viewState.feedback.item.contextSnapshot;let o=ce.applicationName;!o&&!this.appVersion&&w("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:n,text:r,termsAccepted:p,item:{question:c,formattedScript:s,conversationId:u}}=this.viewState.feedback,l={user_evaluation:n,your_comments:r||void 0,question:c??"",answer:this.encodeForFeedback(s),useragent:navigator.userAgent,_source:ve,version:this.appVersion||o||"NOT_SET",context:a?JSON.stringify({...a,editor_code:this.encodeForFeedback(a.editor_code),isSnapshot:!t}):"",extras:a?.profileId??"",extras2:this.isDevEnv?"dev":"",conversation_id:u??"",privacy_statement:p?"I_agree":""};try{await e.applyEdits({addFeatures:[new le({attributes:l})]})}catch(h){w("error",this,"Error submitting feedback.",{detail:{error:h}})}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.promptingEnabled=!1,this.closed=!1,this.isDevEnv=!1,this.disableQuestionAnswerLogging=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,promptingEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,isDevEnv:5,appVersion:1,diagnostics:0,docsConfig:0,disableQuestionAnswerLogging:5}}static{this.styles=Me}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
3
+ // ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get helpTopicUrl(){return this.docsConfig?.links[st]||`${this.helpBase||"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}async openPrompt(e){if(this.closed=!1,!this.promptingEnabled)return;e&&this.updateViewState({question:e,viewMode:"prompt"});let t=this.textAreaRef.value;t&&t.setFocus()}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:ye,splashActive:we})}loaded(){let e=async()=>{let t=this.getModel();if(!t){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(t.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};this.manager.onLifecycle(()=>{e();let t=q.onModelContextDidChange(async()=>{e().catch(a=>{w("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{t.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),ye=this.viewState.history,we=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let t=Ze(e.metadata);return{...e,metadata:t,estimatedTokens:z(t)}}withEditorState(e,t){return{...e,editor_code:t?.getValue()??this.getModel()?.getValue()??"",diagnostics:this.diagnostics,runtime:P()}}encodeForFeedback(e){return encodeURIComponent(e??"")}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,t)=>(!t.script||(e.push({priorPrompt:t.question,code:t.formattedScript||t.error||"",profileId:t.profile??fe,onAddToEditor:a=>{se(this.editorRef.editorInstance,t.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",t),onThumbsDown:()=>this.handleFeedbackButton("bad",t),conversationId:t.conversationId??"",message:t.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 t=rt.filter(a=>!e.fields.some(o=>o.name===a));if(t.length>0){w("error",this,`Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}async logInteractionToFeedbackService(e){if(this.disableQuestionAnswerLogging||!e.question)return;let t;try{t=await this.ensureFeedbackService()}catch(r){w("error",this,"Error initializing feedback service for interaction logging.",{detail:{error:r}});return}if(!t)return;let a=ce.applicationName,o=e.contextSnapshot,n={question:e.question,answer:this.encodeForFeedback(e.answer),useragent:navigator.userAgent,_source:ve,version:this.appVersion||a||"NOT_SET",context:o?JSON.stringify({...o,isSnapshot:!0}):"",extras:o?.profileId??"",extras2:this.isDevEnv?"dev":"",conversation_id:e.conversationId??"",privacy_statement:""};try{await t.applyEdits({addFeatures:[new le({attributes:n})]})}catch(r){w("error",this,"Error logging arcade assistant question/answer interaction.",{detail:{error:r}})}}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(!this.viewState.question)return;let e=this.viewState.question;this.updateViewState({isSubmitting:!0,errorMessage:void 0});let t,a;try{let o=this.getModel();if(!o||!this.serviceUrl)return;let n=this.viewState.context??await this.getProfileAndMetadata(o.uri),r=this.withEditorState(n,o);t=this.createFeedbackContextSnapshot(r);let p=await this.getToken(),c=await Re({baseUrl:this.serviceUrl,skillId:ot,message:e,authToken:p,context:{kind:nt,context:{profile_id:r.profileId,metadata:[r.metadata],editor_code:r.editor_code,runtime:r.runtime,...r.diagnostics?.length?{diagnostics:r.diagnostics}:{}}}});a=c?.[0]?.conversationId;let s=c.find(u=>u.context?.kind==="ArcadeCodeResponse");if(!s){await this.logInteractionToFeedbackService({question:e,answer:"No ArcadeCodeResponse returned.",contextSnapshot:t,conversationId:a});return}if(s.context?.kind==="ArcadeCodeResponse"){let u=this.createFeedbackContextSnapshot(r),l=oe(s?.context?.arcadeCode?.code??"");this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:l,error:void 0,question:e,profile:n.profileId,conversationId:s.conversationId,isCurrentResult:!0,contextSnapshot:u,...s.message?{message:s.message}:{}},...this.viewState.history.map(h=>({...h,isCurrentResult:!1}))],viewMode:"result",errorMessage:void 0}),await this.logInteractionToFeedbackService({question:e,answer:l,contextSnapshot:t,conversationId:s.conversationId})}}catch(o){let n=o instanceof Error&&o.name==="ArcadeAssistantError"?Fe(o)||this.messages.erroroccurred||"An error occurred.":this.messages.erroroccurred||"An error occurred.";this.updateViewState({errorMessage:n}),await this.logInteractionToFeedbackService({question:e,answer:n,contextSnapshot:t,conversationId:a}),w("error",this,"Error submitting question",{detail:{error:o}})}finally{this.updateViewState({isSubmitting:!1})}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let t=fe,a=q.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let o=this.editorRef.profile;o&&"id"in o&&(t=o.id);let n=a?await We(a):{variables:[]},r=tt(n),p=r?et(n):void 0,c=p?p.context:n,s=z(c);return{profileId:t,metadata:c,contextTooLarge:r,reducedToVariableName:p?.reducedToVariableName,estimatedTokens:s}}onCopyCode(e){let t=e?`${this.disclaimerComment}
4
+ ${e}`:"";return navigator.clipboard.writeText(t)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",t=this.getHistoryCards();return this.promptingEnabled?d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&d`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${De({messages:this.messages,popoverContent:pe({promptingEnabled:this.promptingEnabled,messages:this.messages,helpTopicUrl:this.helpTopicUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&He({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.helpTopicUrl,onExit:a=>this.closePanel?.(a)})||""}${ze({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${Le({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&&Ge({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>${me({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:t.length?[t[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${me({expanded:!e,messages:this.messages,collapsible:!0,cards:e?t.slice(1):t,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?je({setOpen:this.handleFeedbackSheetClose,messages:this.messages,onSubmit:this.handleFeedbackSubmit,feedback:this.viewState.feedback,setFeedback:this.setFeedbackState,learnMoreUrl:this.helpTopicUrl}):null}</calcite-shell></calcite-flow-item></calcite-flow>`:d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${pe({slot:"content-top",messages:this.messages,promptingEnabled:this.promptingEnabled,helpTopicUrl:this.helpTopicUrl})}</calcite-flow-item></calcite-flow>`}};te("arcgis-arcade-coding-assistant",O);return O},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,e)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import i from"./JFO2HVZ6.js";import f from"./N56B3UDM.js";import e from"./SXM2EQHN.js";import b from"./H5EGZU2S.js";import"./ZLV7T4YS.js";import"./MZMKV7FA.js";import{a as _}from"./G4VQ7X3L.js";import"./A3TU47C5.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import{E as l,F as h,G as p,H as r,K as g,h as c,j as t,n as o,t as d}from"./O6XP7VU2.js";import{b as a}from"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([,,{a:s,c:f},{b:m}])=>{var u=c`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}`,n=class extends p{constructor(){super(...arguments),this._codeEditorElt=l(),this._disposables=[],this.messages=_(),this._modelId=d(),this._preparing=!1,this.sideActionBarExpanded=!1,this.script="",this.hideSideBar=!1,this.hideDescriptionsInFieldsPanel=!1,this.arcgisDiagnosticsChange=o({bubbles:!1}),this.arcgisScriptChange=o({bubbles:!1})}static{this.properties={_activeAction:16,_apiLibrary:16,_editorProfile:16,_preparing:16,sideActionBarExpanded:16,profile:0,script:1,hideSideBar:5,messageOverrides:0,hideDescriptionsInFieldsPanel:5}}static{this.styles=[u]}async setFocus(){await this._codeEditorElt.value?.setFocus()}async formatExpression(){await f(s.languageId);let i=this._codeEditorElt.value?.editorInstance?.getAction("editor.action.formatDocument");i&&await i.run()}async load(){await this._updateEditorProfile().catch(a(this))}willUpdate(i){(i.has("messages")||i.has("profile"))&&this._updateDataModelDeps()}async loaded(){let i=await m();this._disposables.push(i.onDiagnosticsChange(e=>!this._preparing&&this.arcgisDiagnosticsChange.emit(e.diagnostics)))}disconnectedCallback(){for(super.disconnectedCallback();this._disposables.length;)this._disposables.pop()?.dispose()}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}async _updateEditorProfile(){this._preparing=!0;try{await s.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale}),this._editorProfile=s.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._preparing=!1}}_setActiveAction(i){if(this._activeAction===i){this._activeAction=void 0;return}this._activeAction=i}_handleActionClick(i){let e=i.currentTarget;this._setActiveAction(e.dataset.panelName)}_insertAsSnippet(i){this._codeEditorElt.value?.insertSnippet(i.detail).catch(a(this))}_insertAsText(i){this._codeEditorElt.value?.insertText(i.detail.replaceAll('"',"'")).catch(a(this))}async _updateApiLibrary(){this._apiLibrary=await s.getApiLibraryForModel(this._modelId)}_onCodeEditorValueChange(i){i.stopPropagation(),this.script=i.detail,this.arcgisScriptChange.emit(i.detail)}_getFeatureSetVariable(){let i,e=s.getEditorProfileForModel(this._modelId);return e?.variables?.length&&e?.variables?.[0]?.type!=="featureSet"?a(this)("Encountered unexpected editor profile"):i=e?.variables?.[0],i}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}render(){let i=this._getFeatureSetVariable();return t`<arcgis-code-editor-shell><arcgis-code-editor slot=editor language=arcgis-sql-expression .modelId=${this._modelId} .value=${this.script??""} @arcgisValueChange=${this._onCodeEditorValueChange} ${h(this._codeEditorElt)}></arcgis-code-editor>${!this.hideSideBar&&i&&t`<arcgis-editor-variables slot=side-panel .variable=${i} .hideDescriptions=${this.hideDescriptionsInFieldsPanel} .closed=${this._activeAction!=="fields"} class=${r(this._activeAction==="fields"?"":"hidden")} .loading=${this._preparing} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${()=>this._setActiveAction(void 0)} data-panel-name=none .messageOverrides=${{profileempty:this.messages.profileempty}}></arcgis-editor-variables>`||""}${!this.hideSideBar&&t`<arcgis-language-api-panel slot=side-panel class=${r(this._activeAction==="functions"?"":"hidden")} .closed=${this._activeAction!=="functions"} @arcgisInternalItemSelected=${this._insertAsSnippet} @arcgisInternalClosePanel=${()=>this._setActiveAction(void 0)} .loading=${this._preparing} .apiLibrary=${this._apiLibrary} data-panel-name=none hide-documentation-actions .languageId=${s.languageId}></arcgis-language-api-panel>`||""}${!this.hideSideBar&&t`<calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}>${i&&t`<calcite-action id=fields-action .text=${this.messages.fields??"Fields"} icon=profile-variables .active=${this._activeAction==="fields"} data-panel-name=fields @click=${e=>this._handleActionClick(e)}></calcite-action>`||""}${i&&!this.sideActionBarExpanded&&t`<calcite-tooltip reference-element=fields-action><span>${this.messages.fields??"Fields"}</span></calcite-tooltip>`||""}<calcite-action id=functions-action .text=${this.messages.functions??"Functions"} icon=function .active=${this._activeAction==="functions"} data-panel-name=functions @click=${e=>this._handleActionClick(e)}></calcite-action>${!this.sideActionBarExpanded&&t`<calcite-tooltip reference-element=functions-action><span>${this.messages.functions??"Functions"}</span></calcite-tooltip>`||""}</calcite-action-bar>`||""}</arcgis-code-editor-shell>`}};g("arcgis-sql-expression-editor",n);return n},b,e,f,i)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import f from"./MO22NTSF.js";import e from"./EIKXKAAA.js";import"./5HKDO4SX.js";import b from"./ZUCC43DN.js";import{a as d}from"./G4VQ7X3L.js";import"./A3TU47C5.js";import{b as n,d as u}from"./C5WMGZYX.js";import"./J4I4EROF.js";import{G as o,K as c,h as l,j as a}from"./O6XP7VU2.js";import"./BFPEJYVB.js";import"./H6RQVSYM.js";export default $arcgis.t(([,{a:s,h:r,i:m,j:p},{c:h,f:g,g:f,h:b,i:v}])=>{var y=l`:host{display:flex;flex-direction:column;width:100%;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-2);--calcite-block-padding: var(--calcite-spacing-sm);overflow:auto;calcite-flow{height:100%}.disabled-state-text{font-size:var(--calcite-font-size-sm);color:var(--calcite-color-text-3);font-style:italic;display:block;margin:var(--calcite-spacing-md)}[class*=result-value-]{line-height:1.25rem}}`;function x(t,e){return h(t)||b(t)||f(t)||g(t)?e??"Output":t.arcadeType}var i=class extends o{constructor(){super(...arguments),this.messages=d()}static{this.properties={debuggerStore:0,result:0}}static{this.styles=[y,p,m()]}load(){this.manager.onLifecycle(()=>{let e=n(this.el,["class"],this.updateTheme.bind(this));return this.updateTheme(),()=>e()})}willUpdate(e){e.has("result")&&this.result&&this.debuggerStore?.lazyTreeState.reset()}updateTheme(){u(this.el)==="dark"?this.elementInternals.states.add(r):this.elementInternals.states.delete(r)}render(){if(!this.result)return a`<span class="disabled-state-text">${this.messages.nooutput??"No output available."}</span>`;let e=this.debuggerStore?.lazyTreeState;return e?a`<calcite-tree .scale=${s.scale} @calciteTreeSelect=${s.oncalciteTreeSelect} .lines=${s.lines} .selectionMode=${s.selectionMode}>${v({expanded:!0,name:x(this.result,this.messages.output),value:this.result,messages:this.messages,path:this.result.arcadeType,lazyTreeState:e})}</calcite-tree>`:a`<span class="disabled-state-text">${this.messages.nooutput??"No output available."}</span>`}};c("arcgis-arcade-debugger-output",i);return i},b,e,f)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import{a as O,c as u,d as k}from"./DSXNVNHP.js";import i from"./JGRWZYW5.js";import h from"./N56B3UDM.js";import"./5HKDO4SX.js";import e from"./AI6346MJ.js";import d from"./J7TSCCXO.js";import c from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import"./ZLV7T4YS.js";import"./MZMKV7FA.js";import{a as E}from"./A3TU47C5.js";import{b as T,d as w}from"./C5WMGZYX.js";import{a as S}from"./J4I4EROF.js";import"./LEFE3FVL.js";import{a as C}from"./XEK22IDA.js";import{a as N}from"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import{G as v,K as b,L as y,h as g,i as f,j as n}from"./O6XP7VU2.js";import{b as _}from"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([,,,{a:L},{c:c,e:m}])=>{var x=Symbol(),l=class{get taskComplete(){return this.t||(this.i===1?this.t=new Promise(((t,e)=>{this.o=t,this.h=e})):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){this.p=0,this.i=0,(this._=t).addController(this);let i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??M,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=this.T?.())}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;let t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){let t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){let e,s;t??=this.T(),this.O=t,this.i===1?this.q?.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask((()=>this._.requestUpdate())):this._.requestUpdate();let i=++this.p;this.q=new AbortController;let r=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(d){r=!0,s=d}if(this.p===i){if(e===x)this.i=0;else{if(r===!1){try{this.k?.(e)}catch{}this.i=2,this.o?.(e)}else{try{this.A?.(s)}catch{}this.i=3,this.h?.(s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){this.i===1&&this.q?.abort(t)}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){switch(this.i){case 0:return t.initial?.();case 1:return t.pending?.();case 2:return t.complete?.(this.value);case 3:return t.error?.(this.error);default:throw Error("Unexpected status: "+this.i)}}},M=(h,t)=>h===t||h.length===t.length&&h.every(((e,s)=>!f(e,t[s])));var $=g`:host{display:block}.arcgis-code-viewer-container{display:flex;align-items:stretch;background-color:var(--calcite-color-foreground-2)}.arcgis-code-viewer__gutter{display:flex;min-width:var(--calcite-spacing-md);padding:0 var(--calcite-spacing-xs) 0 var(--calcite-spacing-sm);border-inline-end:1px solid var(--calcite-color-border-3);color:var(--calcite-color-text-3);font-size:var(--calcite-font-size--2);font-family:var(--calcite-font-family-code);user-select:none;justify-items:center;font-variant-numeric:tabular-nums}.arcgis-code-viewer__line-number{display:flex;align-items:center}pre.arcgis-code-viewer{display:flex;direction:ltr;overflow-x:auto;margin:0;padding:var(--calcite-spacing-sm);white-space:pre-line;code{font-size:var(--calcite-font-size--2);font-family:var(--calcite-font-family-code)}}:host([round]){.arcgis-code-viewer-container{border-radius:var(--calcite-corner-radius-round)}}`,p=class extends v{constructor(){super(...arguments),this._monacoEditor=E(N),this.#e=Promise.withResolvers(),this.#t="",this._slotContentObservers=[],this._onDefaultSlotChange=async t=>{S(t)||(this._codeFromSlot="");let e=t.target instanceof HTMLSlotElement?t.target:null,s=e?this._computeSlotText(e):"";e&&this._observeAssignedSlotNodes(e),s!==this._codeFromSlot&&(this._codeFromSlot=s),this.#e.resolve()},this._colorizeTask=new l(this,{task:async([t,e],{signal:s})=>{if(await this.#e.promise,s.aborted)return this.#t;if(await c(e),s.aborted)return this.#t;let i=await O(t,e);return s.aborted?this.#t:(this.#t=i,i)},args:()=>[this._codeFromSlot,this.language]}),this._codeFromSlot="",this.language="arcade",this.round=!1,this.lineNumbers="off"}static{this.properties={_codeFromSlot:16,language:1,round:7,lineNumbers:1}}static{this.styles=$}#e;#t;async load(){L(y("./assets")),await m(this.language),await c(this.language),this._applyColorizeStyles(u()),this.manager.onLifecycle(()=>(this._themeObserver=T(this.el,["class"],()=>this.updateTheme()),this._themeChangedListener=k(()=>{this._applyColorizeStyles(u())}),this.updateTheme(),()=>{this._themeObserver?.(),this._themeObserver=void 0,this._themeChangedListener?.dispose(),this._themeChangedListener=void 0}))}loaded(){this.el.hasChildNodes()||this.#e.resolve()}willUpdate(t){t.has("language")&&m(this.language).then(()=>c(this.language)).catch(_(this))}disconnectedCallback(){super.disconnectedCallback(),this._disposeSlotObservers()}_disposeSlotObservers(){this._slotContentObservers.length&&(this._slotContentObservers.forEach(t=>t.disconnect()),this._slotContentObservers=[])}_observeAssignedSlotNodes(t){this._disposeSlotObservers();let e=t.assignedNodes({flatten:!0});if(!e.length)return;let s=new Set;for(let o of e)o.nodeType===Node.ELEMENT_NODE?s.add(o):o.nodeType===Node.TEXT_NODE&&o.parentElement&&s.add(o.parentElement);let i={characterData:!0,childList:!0,subtree:!0},r=C(()=>{let o=this._computeSlotText(t);o!==this._codeFromSlot&&(this._codeFromSlot=o)},100),d=o=>{if(o.some(a=>a.type==="childList")){let a=this._computeSlotText(t);a!==this._codeFromSlot&&(this._codeFromSlot=a);return}r()};s.forEach(o=>{let a=new MutationObserver(d);a.observe(o,i),this._slotContentObservers.push(a)})}_computeSlotText(t){let e=t.assignedNodes({flatten:!0}).filter(s=>s.nodeType!==Node.COMMENT_NODE);if(this.language==="html"&&e.length){let s=e.find(r=>r.nodeType===Node.ELEMENT_NODE&&r.tagName==="TEMPLATE");if(s)return(s.innerHTML??"").trim();let i=e.map(r=>r.nodeType===Node.ELEMENT_NODE?r.outerHTML:r.nodeType===Node.TEXT_NODE?r.textContent??"":"").join("").trim();return i}return e.map(s=>s.textContent??"").join("").trim()}updateTheme(){let t=w(this.el)==="light"?"vs":"vs-dark";t!==this._currentTheme&&(this._currentTheme=t,this._monacoEditor.setTheme(t))}_applyColorizeStyles(t){if(!this._colorizeSheet){this._colorizeSheet=new CSSStyleSheet;let e=this.renderRoot;e.adoptedStyleSheets=[...e.adoptedStyleSheets,this._colorizeSheet]}this._colorizeSheet.replaceSync(t)}_showLineNumbers(){return typeof this.lineNumbers=="function"||this.lineNumbers==="on"}_getLineNumberLabel(t){return typeof this.lineNumbers=="function"?this.lineNumbers(t):`${t}`}_getRenderedLineNumbers(){if(!this._showLineNumbers())return[];let t=Math.max(this._codeFromSlot.split(/\r\n|\r|\n/u).length,1);return Array.from({length:t},(e,s)=>this._getLineNumberLabel(s+1))}render(){let t=this._getRenderedLineNumbers();return n`<div class=${`arcgis-code-viewer-container${t.length?" arcgis-code-viewer-container--with-line-numbers":""}`}><slot @slotchange=${this._onDefaultSlotChange} style="display:none" aria-hidden=true></slot>${t.length?n`<div class="arcgis-code-viewer__gutter" aria-hidden=true>${t.map(e=>n`<span class="arcgis-code-viewer__line-number">${e}</span>`)}</div>`:null}<pre class="arcgis-code-viewer" aria-label=${`${this.language} code snippet`}>${this._colorizeTask.render({error:()=>null,pending:()=>n`<code class=${`language-${this.language}`}></code>`,complete:e=>n`<code class=${`language-${this.language}`} .innerHTML=${e??""}></code>`})}</pre></div>`}};b("arcgis-code-viewer",p);return p},a,c,d,e,h,i)
@@ -0,0 +1,6 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import b from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import{h as v,i as T}from"./C5WMGZYX.js";import{b as f,c,d as p}from"./LEFE3FVL.js";import{L as m}from"./O6XP7VU2.js";export default $arcgis.t(([{getDeclaredPixelMembers:$},{G:w,f:M,g:F,h:k,i:P,j:A,n:b},{k:I,l:L,m:V,o:C,p:D}])=>{async function K(e){let{apiVersion:r,bundles:t,hiddenApiItems:n}=e.toEditorProfileDefinition(),s=await j(e.dictionaryVariables.filter(w));return{apiVersion:r,bundles:t,variables:s,hiddenApiItems:n?.map(o=>o.toLowerCase())}}async function j(e,r=f.Variable){return await Promise.all(e.map(async t=>{switch(t.type){case"dictionary":return await O(t,r);case"pixel":return await B(t,r);case"voxel":case"feature":return await q(t,r);default:return _(t,r)}}))}function _(e,r){let{name:t,type:n}=e,s=e.getDescription(),o=r===f.Field?I(t,!1):t;return{name:t,description:s,type:n,completion:{label:t,detail:t,insertText:o,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:r,documentation:{kind:"markdown",value:s}}}}async function q(e,r){let t=await e.loadSource(),{name:n}=e,s=e.getDescription(),o={label:n,detail:n,insertText:n,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:r},a={name:n,description:s,type:"dictionary",properties:[],completion:o};if(!t)return a;let[i,l]=L(t.fields,s,{includeAliases:!0});return a.properties=i,o.documentation={kind:"markdown",value:l},a}async function B(e,r){let t=await e.loadSource(),n=e.toProfileVariableDefinition();if(n.type!=="pixel")throw new Error("Incorrect definition passed to pixel variable");let{name:s}=e,o=e.getDescription(),a={label:s,detail:s,insertText:s,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:r},i={name:s,description:o,type:"dictionary",properties:[],completion:a};if(!t||!n.definition)return i;let l=await $(t),[d,u]=V(l,o);return i.properties=d,a.documentation={kind:"markdown",value:u},i}async function O(e,r){let{name:t,dictionaryVariables:n}=e,s=e.getDescription(),o=n.reduce((a,i)=>{a!==""&&(a+=`
3
+
4
+ `),a+=`**${i.name}**
5
+ ${i.type}`;let l=i.getDescription();return l&&(a+=`
6
+ ${l}`),a},s);return{name:t,description:s,type:"dictionary",properties:await j(n.filter(w),f.Field),completion:{label:t,detail:t,insertText:t,insertTextMode:p.asIs,insertTextFormat:c.PlainText,kind:r,documentation:{kind:"markdown",value:o}}}}async function h(e="en"){let r=E.get(e);if(r)return r;if(!v.has(e))return await h("en");try{let t=await fetch(m(`./assets/arcade-language/profiles/arcade-profiles.t9n.${e}.json`));return t.ok?z(e,await t.json()):e==="en"?null:await h("en")}catch{return null}}var E=new Map;function z(e,r){let t=new Map;return r.forEach(n=>{t.set(n.id,n)}),E.set(e,t),t}async function G(e,r="en"){return(await h(r))?.get(e)??null}function H(e){return!!e&&typeof e=="object"&&"additionalVariables"in e&&Array.isArray(e.additionalVariables)}function J(e){return e?.map(r=>g(r))}function g(e){switch(e.type){case"dictionary":return{...e,type:e.type,properties:J(e.properties)};case"array":return{...e,type:e.type};default:return{...e,type:e.type}}}async function N(e,r="en"){if(!b(e))return;let t=await G(e.id,r);if(!t)return;let n=e.definitions,s=new Map(Object.entries(n).map(([a,i])=>[a.toLowerCase(),i])),o={bundles:[...t.bundles],variables:[],hiddenApiItems:e.hiddenApiItems?.map(a=>a.toLowerCase())};return t.variables.forEach(a=>{if(e.disabledVariables?.includes(a.name))return;let i=s.get(a.name.toLowerCase());switch(a.type){case"dictionary":return o.variables.push(g({...a,type:a.type,properties:Array.isArray(i)?[...i]:a.properties}));case"feature":return M(i)?o.variables.push({...a,type:"feature",definition:i}):void 0;case"pixel":return k(i)?o.variables.push({...a,type:a.type,definition:i}):void 0;case"voxel":return F(i)?o.variables.push({...a,type:a.type,definition:i}):void 0;case"featureSet":return P(i)?o.variables.push({...a,type:a.type,definition:i}):void 0;case"featureSetCollection":return A(i)?o.variables.push({...a,type:a.type,definition:i}):void 0;default:return o.variables.push(g(a))}}),H(e)&&o.variables.push(...e.additionalVariables??[]),o}var Q=["catalog-footprint","catalog","csv","feature","geojson","knowledge-graph-sublayer","oriented-imagery","subtype-group","subtype-sublayer","wfs","parquet"];function R(e){return!!e&&typeof e=="object"&&"type"in e&&typeof e.type=="string"&&Q.includes(e.type)}var U={filterFsCollectionLayersFromMap:e=>R(e)},x=class extends D{#e=new Map;constructor(){super("arcade",{apiPath:"./assets/arcade-language/api",apiPrefix:"arcade-api.t9n."})}async setProfileForModel(r,t,n={locale:"en"}){let s=this._getApiKey(r),o=(this.#e.get(s)||Promise.resolve()).then(async()=>{let i=t,l=b(i)?await N(i,n.locale):i,d=await T(n.locale,m("./assets/editor-profile/t9n"),"messages.");if(!d)throw new Error(`Failed to load the language bundle for ${n.locale}`);this.disposeForModel(r);let u=new C(l,d,n.locale,U);this._modelToProfileMap.set(s,u);let S=await K(u);this.updateApiContextForModel(r,{locale:n.locale,profile:S,snippets:n.snippets})}),a=o.finally(()=>{this.#e.get(s)===a&&this.#e.delete(s)});return this.#e.set(s,a),await o}},y=new x,ae={setProfileForModel:y.setProfileForModel.bind(y),getApiLibraryForModel:y.getApiLibraryForModel.bind(y)};return y},"applications/Components/arcadeEditorUtils",a,b)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import a from"./N56B3UDM.js";import{a as f}from"./XEK22IDA.js";import{a as h}from"./NKGAHXNJ.js";import{b as g}from"./BFPEJYVB.js";import{Hl as u,vl as T}from"./XCISKBJD.js";export default $arcgis.t(([{a:l,f:N}])=>{var E=Promise.withResolvers(),p=class{constructor(e){this._defaults=e,this._worker=null,this._client=null,this._configChangeListener=this._defaults.onDidChange(()=>this.stopWorker())}dispose(){this._configChangeListener.dispose(),this.stopWorker()}stopWorker(){this._worker&&(this._worker.dispose(),this._worker=null,E=Promise.withResolvers()),this._client=null}static async waitForWorker(){return await E.promise}async _getClientProxy(){let e=await h();if(!this._client){let{languageId:t}=this._defaults,o=window.MonacoEnvironment?.getWorker;if(!o)throw new Error("MonacoEnvironment.getWorker is not configured. Call setupMonacoEnvironment(...) before creating SQL Expression workers.");this._worker=e.createWebWorker({worker:o("SqlExprWorker",t),host:this._defaults.workerHost}),E.resolve(this._worker),this._client=this._worker.getProxy()}return await this._client}async getLanguageServiceWorker(...e){let t=await this._getClientProxy();return await this._worker?.withSyncedResources(e),t}},M=["AND","AS","BOTH","CASE","CAST","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","DATE","DAY","DOY","DOW","ELSE","END","ESCAPE","FALSE","FLOAT","FOR","FROM","HOUR","IN","INT","INTEGER","INTERVAL","LEADING","LIKE","MINUTE","MONTH","POSITION","REAL","SECOND","SMALLINT","THEN","TIME","TIMESTAMP","TIMEZONE_HOUR","TIMEZONE_MINUTE","TO","TRAILING","TRIM","TRUE","VARCHAR","WEEK","WHEN","WITH","YEAR","ZONE"],b=["AND","BETWEEN","LIKE","NOT","OR","IS","NULL"],D=["CAST","EXTRACT","CURRENT_DATE","CURRENT_TIME","CURRENT_TIMESTAMP","CURRENT_USER","ABS","ACOS","ASIN","ATAN","CEILING","COS","FLOOR","LOG","LOG10","MOD","NULLIF","POWER","ROUND","SIGN","SIN","TAN","TRUNCATE","CHAR_LENGTH","COALESCE","CONCAT","LOWER","POSITION","SUBSTRING","TRIM","UPPER"],O={comments:{lineComment:"--",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}]},x={defaultToken:"",tokenPostfix:".arcgis",ignoreCase:!0,brackets:[{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],keywords:M,operators:b,builtinFunctions:D,builtinVariables:[],tokenizer:{root:[{include:"@comments"},{include:"@whitespace"},{include:"@numbers"},{include:"@strings"},{include:"@complexIdentifiers"},{include:"@scopes"},[/[;,.]/,"delimiter"],[/[()]/,"@brackets"],[/[\w@#$]+/,{cases:{"@operators":"operator","@builtinVariables":"predefined","@builtinFunctions":"predefined","@keywords":"keyword","@default":"identifier"}}],[/[<>=!%&+\-*/|~^]/,"operator"]],whitespace:[[/\s+/,"white"]],comments:[[/--+.*/,"comment"],[/\/\*/,{token:"comment.quote",next:"@comment"}]],comment:[[/[^*/]+/,"comment"],[/\*\//,{token:"comment.quote",next:"@pop"}],[/./,"comment"]],numbers:[[/0[xX][0-9a-fA-F]*/,"number"],[/[$][+-]*\d*(\.\d*)?/,"number"],[/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/,"number"]],strings:[[/N'/,{token:"string",next:"@string"}],[/'/,{token:"string",next:"@string"}]],string:[[/[^']+/,"string"],[/''/,"string"],[/'/,{token:"string",next:"@pop"}]],complexIdentifiers:[[/"/,{token:"identifier.quote",next:"@quotedIdentifier"}]],quotedIdentifier:[[/[^"]+/,"identifier"],[/""/,"identifier"],[/"/,{token:"identifier.quote",next:"@pop"}]],scopes:[[/(BEGIN|CASE)\b/i,{token:"keyword.block"}],[/END\b/i,{token:"keyword.block"}],[/WHEN\b/i,{token:"keyword.choice"}],[/THEN\b/i,{token:"keyword.choice"}]]}},_=class{constructor(e,t){this._worker=e,this._defaults=t}async provideCompletionItems(e,t){try{let o=await this._worker(e.uri),a=e.getWordUntilPosition(t),r={startLineNumber:t.lineNumber,endLineNumber:t.lineNumber,startColumn:a.startColumn,endColumn:a.endColumn},c=this._defaults.getApiContextForModel(e.uri);return await o.doComplete(e.uri.toString(),r,t,c)}catch(o){return g("SqlExprCompletionProvider")(o),{suggestions:[]}}}},w=class{constructor(e){this._worker=e}async provideDocumentFormattingEdits(e){let t=await this._worker(e.uri),o=(await h()).tokenize(e.getValue(),e.getLanguageId());return await t.doFormat(e.uri.toString(),o)}},k=class{constructor(e,t,{defaults:o,diagnosticService:a}){this._languageId=e,this._worker=t,this._disposables=[],this._modelListeners=new Map,this._diagnosticsService=a,this._defaults=o,h().then(r=>{let c=i=>{let s=i.getLanguageId();if(s!==this._languageId)return;let d=f(()=>{this._doValidate(i,s).catch(L=>{throw L})}),A=i.onDidChangeContent(d),R=i.onDidChangeAttached(d);this._modelListeners.set(i.uri.toString(),[A,R]),this._doValidate(i,s).catch(g("SqlExprDiagnosticsAdapter"))},m=i=>{let s=i.uri.toString();r.setModelMarkers(i,this._languageId,[]);let d=this._modelListeners.get(s);if(d){for(;d.length;)d.pop()?.dispose();this._modelListeners.delete(s)}};this._disposables.push(r.onDidCreateModel(c)),this._disposables.push(r.onWillDisposeModel(i=>m(i))),this._disposables.push(r.onDidChangeModelLanguage(i=>{m(i.model),c(i.model)})),this._disposables.push(o.onDidChange(()=>{r.getModels().forEach(i=>{i.getLanguageId()===this._languageId&&(m(i),c(i))})})),this._disposables.push(o.onModelContextDidChange(i=>{r.getModels().forEach(s=>{s.getLanguageId()===this._languageId&&s.uri.toString()===i&&this._doValidate(s,this._languageId).catch(g("SqlExprDiagnosticsAdapter"))})})),this._disposables.push({dispose:()=>{this._modelListeners.forEach(i=>i.forEach(s=>s.dispose())),this._modelListeners.clear()}}),r.getModels().forEach(c)})}async _doValidate(e,t){let o=await h();if(e.isAttachedToEditor())try{let a=await this._worker(e.uri),r=this._defaults.getApiContextForModel(e.uri),c=await a.doValidation(e.uri.toString(),r);this._diagnosticsService.fireDiagnosticsChange(e.uri,c),o.setModelMarkers(e,t,c)}catch(a){g("SqlExprDiagnosticsAdapter")(a)}}},C;async function Y(...n){return await p.waitForWorker(),await new Promise((e,t)=>{if(!C){t(new Error("sql expression worker not registered!"));return}e(C(...n))})}var I=class{constructor(){this._onDiagnosticsChange=new T}get onDiagnosticsChange(){return this._onDiagnosticsChange.event}fireDiagnosticsChange(e,t){this._onDiagnosticsChange.fire({uri:e,diagnostics:t})}},S=new I;async function $(){return await N(),S}function z(n){let e=new p(n),t=async(...a)=>await e.getLanguageServiceWorker(...a);C=t,u.setMonarchTokensProvider(l.languageId,x),u.setLanguageConfiguration(l.languageId,O);let o=new _(t,l);u.registerCompletionItemProvider(l.languageId,o),u.registerDocumentFormattingEditProvider(l.languageId,new w(t)),new k(n.languageId,t,{defaults:n,diagnosticService:S})}return{a:Y,b:$,c:z}},a)
@@ -0,0 +1,3 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import c from"./N56B3UDM.js";import{a as m}from"./5HKDO4SX.js";import b from"./AI6346MJ.js";import a from"./J7TSCCXO.js";import{a as d}from"./NKGAHXNJ.js";import{Hl as t}from"./XCISKBJD.js";export default $arcgis.t(([o,{c:p},{a:a,b:n,d:i,f:c}])=>{t.register({id:o.languageId,aliases:["Arcade","arcade"],extensions:[".arc"],mimetypes:["application/arcade"]});t.onLanguage(o.languageId,i(o.languageId,()=>{p().then(e=>{e.setupMode(o),n(o.languageId)}).catch(e=>{throw e})}));t.register({id:a.languageId,aliases:["EsiSqlExpression","sql-expression"],extensions:[".sql-expression"],mimetypes:["application/sql-expression"]});t.onLanguage(a.languageId,i(a.languageId,()=>{c().then(e=>{e.setupMode(a),n(a.languageId)}).catch(e=>{throw e})}));u();function u(){d().then(e=>{["light","dark"].forEach(s=>{let g=s==="light"?"vs":"vs-dark",r=m[`${s}-theme`];e.defineTheme(g,{base:g,inherit:!0,rules:[{token:"comment.arcgis",foreground:r.comment},{token:"constant.arcgis",foreground:r.constant},{token:"keyword.arcgis",foreground:r.keyword},{token:"identifier.arcgis",foreground:r.identifier},{token:"number.arcgis",foreground:r.number},{token:"string.arcgis",foreground:r.string},{token:"operator.arcgis",foreground:r.operator},{token:"predefined.arcgis",foreground:r.predefined},{token:"date.arcgis",foreground:r.date}],colors:{}})})})}
3
+ },a,b,c)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
+ import c from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import{i as m}from"./C5WMGZYX.js";import{b as h,c as g,d as b}from"./LEFE3FVL.js";import{a as F}from"./NKGAHXNJ.js";import{L as f}from"./O6XP7VU2.js";import{El as w}from"./XCISKBJD.js";export default $arcgis.t(([{i:y,n:l},{l:M,o:v,p:P}])=>{var E={allowAllRootBinaryOperators:!1,requiresPredicateRootNode:!1},x={"field-calculation":E,"where-clause":{allowAllRootBinaryOperators:!0,requiresPredicateRootNode:!0,allowGeometryFields:!0}};function S(e){return e&&e in x?x[e]:void 0}var R=e=>{let t=e.variables[0],r=t?.type==="featureSet"?V(t):void 0,{apiVersion:i,bundles:s,hiddenApiItems:a}=e.toEditorProfileDefinition();return{apiVersion:i,bundles:s,variables:r?[r]:[],hiddenApiItems:a?.map(o=>o.toLowerCase())}};function V(e){let{name:t}=e,r=e.getDescription(),{definition:i}=e.toProfileVariableDefinition(),s={label:t,detail:t,insertText:t,insertTextMode:b.asIs,insertTextFormat:g.PlainText,kind:h.Field},a={name:t,description:r,type:"dictionary",properties:[],completion:s};if(!i||!("fields"in i))return a;let[o,n]=M(i.fields,r,{includeAliases:!1,supportGeometryFields:!0});return a.properties=o,s.documentation={kind:"markdown",value:n},a}var A=[{name:"$layer",type:"featureSet",description:"The layer being calculated."}],$={"field-calculation":{id:"field-calculation",variables:A},"where-clause":{id:"where-clause",variables:A}};function k(e){return $[e]??null}function C(e){if(!l(e))return;let t=k(e.id);if(!t)return;let r={variables:[],hiddenApiItems:e.hiddenApiItems?.map(i=>i.toLowerCase())};return t.variables.forEach(i=>{if(e.disabledVariables?.includes(i.name))return;let s=e.definitions[i.name];if(i.type==="featureSet")return y(s)?r.variables.push({...i,type:i.type,definition:s}):void 0;throw Error(`sdkVariable type not supported (yet) type: ${i.type}`)}),r}var q="arcgis-sql-expression",p=class extends P{constructor(){super(q,{apiPath:"./assets/sql-language/api",apiPrefix:"sql-api.t9n."}),this._languageId=q,this._layerMap=new Map}updateFeatureLayerForModel(t,r){let i=this._getApiKey(t);this._layerMap.set(i,r)}getFeatureLayerForModel(t){let r=this._getApiKey(t);return this._layerMap.get(r)}async setProfileForModel(t,r,i={locale:"en"}){let s=l(r)?S(r.id):void 0;l(r)&&(r=C(r));let a=await m(i.locale,f("./assets/editor-profile/t9n"),"messages.");if(!a)throw new Error(`Failed to load the language bundle for ${i.locale}`);this.disposeForModel(t);let o=this._getApiKey(t),n=new v(r,a,i.locale,s);this._modelToProfileMap.set(o,n);let L=R(n);this.updateApiContextForModel(t,{locale:i.locale,profile:L,...s?{profilePolicy:s}:{}});let u=r?.variables?.find(_=>_.name==="$layer");u&&this.updateFeatureLayerForModel(t,u.definition)}},d=new p,U={setProfileForModel:d.setProfileForModel.bind(d),getApiLibraryForModel:d.getApiLibraryForModel.bind(d)};var D=["arcade","arcgis-sql-expression","sql-layer-sql-server","sql-layer-postgres","sql-layer-bigquery"],c=new Set,T=new Map;function I(e){let t=T.get(e);return t||(t=Promise.withResolvers(),T.set(e,t)),t}function J(e){I(e).resolve()}function Q(e){return D.includes(e)?I(e).promise:Promise.resolve()}function W(e,t){return()=>{c.has(e)||c.add(e),t()}}async function X(e){c.has(e)||(await F()).createModel("",e,w.parse("")).dispose()}async function Y(){return await import("./OMJLVFHT.js").then(m=>m.default)}return{a:d,b:J,c:Q,d:W,e:X,f:Y}},a,c)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import d from"./SQQXRZAR.js";import c from"./XUI74PBQ.js";import b from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import"./ZLV7T4YS.js";import"./MZMKV7FA.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import"./O6XP7VU2.js";import"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([,,,{a:a,b:b,c:c}])=>{return{getSqlExprDiagnosticService:b,getSqlExprWorker:a,setupMode:c}},a,b,c,d)
2
+ import d from"./JFO2HVZ6.js";import c from"./N56B3UDM.js";import b from"./SXM2EQHN.js";import a from"./H5EGZU2S.js";import"./ZLV7T4YS.js";import"./MZMKV7FA.js";import"./C5WMGZYX.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./NKGAHXNJ.js";import"./XWEX2VS6.js";import"./3G26WBEK.js";import"./O6XP7VU2.js";import"./BFPEJYVB.js";import"./XCISKBJD.js";import"./H6RQVSYM.js";export default $arcgis.t(([,,,{a:a,b:b,c:c}])=>{return{getSqlExprDiagnosticService:b,getSqlExprWorker:a,setupMode:c}},a,b,c,d)