@arcgis/coding-components 5.1.0-next.88 → 5.1.0-next.89

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 (91) hide show
  1. package/dist/cdn/3VRELPEF.js +2 -0
  2. package/dist/cdn/4B64NBIM.js +2 -0
  3. package/dist/cdn/5DAIGIIS.js +2 -0
  4. package/dist/cdn/6EKA3H3N.js +2 -0
  5. package/dist/cdn/6G5URSC7.js +2 -0
  6. package/dist/cdn/{BVNLUX5A.js → 6HL5GBWZ.js} +1 -1
  7. package/dist/cdn/7B33SKQD.js +2 -0
  8. package/dist/cdn/{GJMI6M3I.js → BA546EMZ.js} +1 -1
  9. package/dist/cdn/{2PRSVBDA.js → BKBBI4SA.js} +1 -1
  10. package/dist/cdn/BQISDYES.js +2 -0
  11. package/dist/cdn/E3TJIEWT.js +2 -0
  12. package/dist/cdn/FEYQMPLI.js +2 -0
  13. package/dist/cdn/GLJQQLP2.js +2 -0
  14. package/dist/cdn/{4I7VT4LW.js → I22MLDO4.js} +1 -1
  15. package/dist/cdn/ID3QICBM.js +4 -0
  16. package/dist/cdn/IIER7Z56.js +2 -0
  17. package/dist/cdn/{LWXQURWG.js → ILQJDTTW.js} +1 -1
  18. package/dist/cdn/JIBWBXDI.js +3 -0
  19. package/dist/cdn/{KEROXLGY.js → JT3FBAVQ.js} +1 -1
  20. package/dist/cdn/KA5TX72B.js +64 -0
  21. package/dist/cdn/MC6EICRD.js +2 -0
  22. package/dist/cdn/MJ7MJPGA.js +2 -0
  23. package/dist/cdn/MTIHPCIF.js +2 -0
  24. package/dist/cdn/N75AXIUZ.js +2 -0
  25. package/dist/cdn/NEIT2PGG.js +2 -0
  26. package/dist/cdn/{N7KYUPBV.js → NK5J27LM.js} +1 -1
  27. package/dist/cdn/NKJUJKFG.js +2 -0
  28. package/dist/cdn/NZDJGAT2.js +2 -0
  29. package/dist/cdn/{JHVMGSI2.js → OI3DH7N2.js} +1 -1
  30. package/dist/cdn/QMNQFBIA.js +4 -0
  31. package/dist/cdn/{INPMAY4D.js → SM3MA3KP.js} +1 -1
  32. package/dist/cdn/SMAQD57G.js +2 -0
  33. package/dist/cdn/{6XDEGPYR.js → UOQZCTHQ.js} +1 -1
  34. package/dist/cdn/{QOX2FNYP.js → VA6SZILK.js} +1 -1
  35. package/dist/cdn/VKNLGQFU.js +2 -0
  36. package/dist/cdn/{YLJUOSJJ.js → XBM4ZDJT.js} +1 -1
  37. package/dist/cdn/YVF4PPDB.js +2 -0
  38. package/dist/cdn/assets/arcade-debugger-console/t9n/messages.en.json +1 -0
  39. package/dist/cdn/assets/arcade-debugger-output/t9n/messages.en.json +1 -0
  40. package/dist/cdn/assets/arcade-editor/t9n/messages.en.json +1 -1
  41. package/dist/cdn/index.js +1 -1
  42. package/dist/chunks/ArcadeDebuggerPreviewTabsState.js +178 -0
  43. package/dist/chunks/arcade-executor.js +76 -67
  44. package/dist/chunks/arcade-service-accessors.js +2 -2
  45. package/dist/chunks/colorize.js +9 -9
  46. package/dist/chunks/debugger-value-components.js +275 -0
  47. package/dist/chunks/debugger-value-styles.js +171 -0
  48. package/dist/chunks/functional.js +83 -0
  49. package/dist/chunks/setup-monaco-theme.js +1 -1
  50. package/dist/chunks/utilities.js +44 -34
  51. package/dist/components/arcgis-arcade-debugger-console/customElement.js +201 -0
  52. package/dist/components/arcgis-arcade-debugger-console/index.js +11 -0
  53. package/dist/components/arcgis-arcade-debugger-output/customElement.js +42 -0
  54. package/dist/components/arcgis-arcade-debugger-output/index.js +5 -0
  55. package/dist/components/arcgis-arcade-editor/customElement.d.ts +34 -1
  56. package/dist/components/arcgis-arcade-editor/customElement.js +639 -111
  57. package/dist/components/arcgis-arcade-editor/index.js +2 -0
  58. package/dist/components/arcgis-arcade-results/customElement.js +52 -155
  59. package/dist/components/arcgis-code-editor/customElement.js +1 -1
  60. package/dist/components/arcgis-code-editor-shell/customElement.d.ts +2 -1
  61. package/dist/components/arcgis-code-editor-shell/customElement.js +17 -8
  62. package/dist/components/arcgis-code-viewer/customElement.d.ts +28 -1
  63. package/dist/components/arcgis-code-viewer/customElement.js +65 -52
  64. package/dist/docs/api.json +1 -1
  65. package/dist/docs/docs.json +1 -1
  66. package/dist/docs/vscode.html-custom-data.json +1 -1
  67. package/dist/docs/web-types.json +1 -1
  68. package/dist/loader.js +5 -3
  69. package/dist/types/lumina.d.ts +2 -2
  70. package/dist/types/preact.d.ts +2 -2
  71. package/dist/types/react.d.ts +2 -2
  72. package/dist/types/stencil.d.ts +2 -2
  73. package/dist/utils/arcade-executor.d.ts +2 -1
  74. package/package.json +5 -5
  75. package/dist/cdn/3GNGWLOI.js +0 -2
  76. package/dist/cdn/3UZ3JCYW.js +0 -4
  77. package/dist/cdn/43A7UCSS.js +0 -2
  78. package/dist/cdn/4Y64BGY2.js +0 -2
  79. package/dist/cdn/BGQRJR32.js +0 -2
  80. package/dist/cdn/CPJ4MNMY.js +0 -2
  81. package/dist/cdn/G2Z2DNVW.js +0 -2
  82. package/dist/cdn/ISAWP6I3.js +0 -2
  83. package/dist/cdn/IVNVT7UT.js +0 -2
  84. package/dist/cdn/KD7MZWFX.js +0 -2
  85. package/dist/cdn/MSV4QVR2.js +0 -2
  86. package/dist/cdn/PX32GRG7.js +0 -2
  87. package/dist/cdn/QRXX4WHP.js +0 -3
  88. package/dist/cdn/T4G2IY4F.js +0 -2
  89. package/dist/cdn/TTOHS2DV.js +0 -11
  90. package/dist/cdn/VUYXKN7I.js +0 -2
  91. package/dist/cdn/YMEY2NOQ.js +0 -4
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import a from"./KA5TX72B.js";import{H as z,j as l,p as A,q as E}from"./SM3MA3KP.js";export default $arcgis.t(([{a:b}])=>{var O=/^[$A-Z_a-z][$\w]*$/u;function I(e){return e.replaceAll("\\","\\\\").replaceAll('"','\\"')}function U(e){return O.test(e)}function B(e){return typeof e=="number"?`[${e}]`:e.startsWith("name:")?`[name="${I(e.slice(5))}"]`:e.startsWith("id:")?`[id="${I(e.slice(3))}"]`:U(e)?`.${e}`:`["${I(e)}"]`}function R(e,t){if(e[t]!=='"')return;let i="",a=t+1;for(;a<e.length;){let m=e[a];if(m==="\\"){if(a+=1,a>=e.length)return;i+=e[a],a+=1;continue}if(m==='"')return{value:i,nextIndex:a+1};i+=m,a+=1}}function H(e){if(!e)return;let t=0,i=[];for(;t<e.length&&/[$A-Z_a-z0-9]/u.test(e[t]);)t+=1;let a=e.slice(0,t);if(!a)return;for(;t<e.length;){let p=e[t];if(p==="."){t+=1;let c=t;for(;t<e.length&&/[$\w]/u.test(e[t]);)t+=1;if(c===t)return;i.push(e.slice(c,t));continue}if(p!=="[")return;if(t+=1,/\d/u.test(e[t]??"")){let c=t;for(;t<e.length&&/\d/u.test(e[t]);)t+=1;if(e[t]!=="]")return;i.push(e.slice(c,t)),t+=1;continue}let v=e.startsWith("name=",t)?"name":e.startsWith("id=",t)?"id":void 0;if(v){let c=R(e,t+v.length+1);if(!c||e[c.nextIndex]!=="]")return;i.push(`${v}:${c.value}`),t=c.nextIndex+1;continue}let u=R(e,t);if(!u||e[u.nextIndex]!=="]")return;i.push(u.value),t=u.nextIndex+1}let[m,...s]=i;if(m)return{scopeName:a,rootName:m,pathSegments:s}}function ue(e,t){return`${e}${B(t)}`}function M(e,t){return e?`${e}.${t}`:String(t)}function k(e,t){if(e)return`${e}${B(t)}`}function de(e){return H(e)}function V(e,t){return typeof t=="number"?`${e}[${t}]`:`${e}.${t}`}function J(e){return e.name?`name:${e.name}`:`id:${e.id}`}function K(e){return Object.entries(e).filter(([t])=>t!=="featureSet")}function Q(e,t){if(t){let i=t.featureSet;return{kind:"feature-set",displayValue:i.arcadeType,featureSetValue:i,loadRequest:{kind:"schema",load:()=>i.schema()},mergedCollectionItem:t}}return e.type==="feature-set"?{kind:"feature-set",displayValue:e.arcadeType,featureSetValue:e,loadRequest:{kind:"schema",load:()=>e.schema()}}:e.type==="feature-set-collection"?{kind:"collection",collectionValue:e,displayValue:e.arcadeType,loadRequest:{kind:"collection",load:()=>e.load()}}:null}function x(e){return l`<calcite-tree slot=children .lines=${b.lines} .selectionMode=${b.selectionMode} .scale=${b.scale} @calciteTreeSelect=${b.oncalciteTreeSelect}>${e}</calcite-tree>`}function F({lazyTreeState:e,nodePath:t,mergedCollectionItem:i,expanded:a=!1,isMetadata:m=!1,messages:s,name:p,value:v,loadPreview:u,previewLabel:c,previewSourcePath:y,previewLoading:f=!1}){let o=Q(v,i);if(!o)return null;let n=e.ensureNode(t,a,o.loadRequest),g=o.kind==="feature-set"?o.featureSetValue:void 0,$=c??String(p),w=y??t,C=!!(u&&$&&g&&typeof g.querySample=="function"),d=r=>{r.target===r.currentTarget&&e.setExpanded(t,!0,o.loadRequest)},h=r=>{r.target===r.currentTarget&&e.setExpanded(t,!1,o.loadRequest)},S=r=>{r.stopPropagation(),!(!u||!$||!g)&&u({label:$,sourcePath:w,value:g})},N=()=>l`<calcite-tree-item disabled><div class="tree-item-label"><span class="constant-value">${n.errorMessage||(s.loaderror??"Unable to load data.")}</span></div></calcite-tree-item>`,G=()=>o.kind!=="feature-set"||!n.schemaValue?null:T({name:"schema",value:n.schemaValue,messages:s,path:V(t,"schema"),lazyTreeState:e}),Z=()=>o.kind!=="feature-set"||!o.mergedCollectionItem?[]:K(o.mergedCollectionItem).map(([r,P])=>T({name:r,value:X(P),messages:s,path:V(t,r),lazyTreeState:e})),_=()=>{if(o.kind!=="feature-set")return null;if(!n.expanded||n.status==="loading")return x();let r=[];if(n.status==="error")r.push(N());else{r.push(...Z());let P=G();P&&r.push(P)}return r.length?x(r):x()},j=()=>o.kind!=="collection"?null:!n.expanded||n.status==="loading"?x():x(l`${n.status==="error"?N():null}${n.status==="loaded"?n.collectionItems.map(r=>F({name:r.name||r.id,mergedCollectionItem:r,messages:s,nodePath:V(t,r.id),lazyTreeState:e,value:r.featureSet,loadPreview:u,previewLabel:M(c,r.name||r.id),previewSourcePath:k(w,J(r)),previewLoading:f})):null}`),D=()=>o.kind==="collection"?j():_();return l`<calcite-tree-item .expanded=${n.expanded} @calciteTreeItemExpand=${d} @calciteTreeItemCollapse=${h}><div class="tree-item-label">${L({name:p,isMetadata:m})}<bdi>${o.displayValue}</bdi></div>${n.status==="loading"?l`<calcite-loader slot=actions-end scale=s inline type=indeterminate .label=${s.loading??"Loading"} .text=${s.loading??"Loading"}></calcite-loader>`:null}${C?l`<calcite-action slot=actions-end scale=s class="load-action" .text=${s.loadpreview??"Load preview"} text-enabled icon=play icon-flip-rtl .disabled=${f} @click=${S}></calcite-action>`:null}${D()}</calcite-tree-item>`}function X(e){if(e==null)return{type:"primitive",arcadeType:"",value:null};switch(typeof e){case"boolean":return{type:"primitive",arcadeType:"Boolean",value:e};case"number":return{type:"primitive",arcadeType:"Number",value:e};case"string":return{type:"primitive",arcadeType:"String",value:e};default:return{type:"primitive",arcadeType:"String",value:String(e)}}}var q="tree-item-metadata";function L({name:e,isMetadata:t=!1}){let i=t?`dictionary-property ${q}`:"dictionary-property",a=t?q:void 0;return l`<bdi class=${z(i)}>${e}</bdi><bdi class=${z(a)}>:&nbsp;</bdi>`}function Y({lazyTreeState:e,path:t,expanded:i=!1,value:a,subtree:m,messages:s,onLoadPreview:p,previewLabel:v,previewSourcePath:u,previewLoading:c=!1}){let y=d=>l`<calcite-tree slot=${"children"} .lines=${b.lines} .selectionMode=${b.selectionMode} .scale=${b.scale} @calciteTreeSelect=${b.oncalciteTreeSelect}>${d}</calcite-tree>`;if(!i)return y();let f=e.ensureNode(t,i),o=d=>f.visibleChildCount>=d?null:l`<calcite-tree-item @click=${h=>{h.stopPropagation(),e.showMore(t,d)}}><div class="tree-item-label"><span class=${z(q)}>${s.showmore??"Show more"}</span></div></calcite-tree-item>`,n=a.expand();if(Array.isArray(n)){let d=n.slice(0,f.visibleChildCount);return y(l`${d.map((h,S)=>T({name:S,value:h,messages:s,path:`${t}[${S}]`,lazyTreeState:e,onLoadPreview:p,previewLabel:M(v,S),previewSourcePath:k(u,S),previewLoading:c}))}${o(n.length)}${T({name:"length",value:{arcadeType:"Number",type:"primitive",value:n.length},isMetadata:!0,messages:s,path:`${t}.length`,lazyTreeState:e})}`)}let g=a.arcadeType==="Feature"?n.get("Geometry()"):void 0,$=Math.min(f.visibleChildCount,g?n.size-1:n.size),w=[];for(let[d,h]of n.entries())if(!(d==="Geometry()"&&a.arcadeType==="Feature")){if(w.length>=$)break;w.push([d,h])}let C=!!(g&&f.visibleChildCount>w.length);return y(l`${w.map(([d,h])=>T({name:d,value:h,messages:s,path:`${t}.${d}`,lazyTreeState:e,onLoadPreview:p,previewLabel:M(v,d),previewSourcePath:k(u,d),previewLoading:c}))}${C?T({name:"geometry",value:g,messages:s,path:`${t}.geometry`,lazyTreeState:e,onLoadPreview:p,previewLabel:M(v,"geometry"),previewSourcePath:k(u,"geometry"),previewLoading:c}):null}${o(n.size)}`)}function ee(e){return"expand"in e}function te(e){return e.type==="simple"}function ae(e){return e.type==="primitive"}function ie(e){return e.type==="feature-set"}function ne(e){return e.type==="feature-set-collection"}function re(e){return ie(e)||ne(e)}function T({lazyTreeState:e,path:t,name:i,value:a,messages:m,expanded:s,isMetadata:p=!1,onLoadPreview:v,previewLabel:u,previewSourcePath:c,previewLoading:y=!1}){if(a===void 0)return null;if(a===null)return l`<calcite-tree-item .expanded=${s}><div class="tree-item-label">${L({name:i,isMetadata:p})}<bdi class="constant-value">null</bdi></div></calcite-tree-item>`;if(ee(a)){let f=e.ensureNode(t,s),o=$=>{$.target===$.currentTarget&&e.setExpanded(t,!0)},n=$=>{$.target===$.currentTarget&&e.setExpanded(t,!1)},g=typeof a.arcadeType=="string"?a.arcadeType:"unknown";return l`<calcite-tree-item .expanded=${f.expanded} @calciteTreeItemExpand=${o} @calciteTreeItemCollapse=${n}><div class="tree-item-label">${L({name:i,isMetadata:p})}<bdi>${A(g)}</bdi></div>${Y({expanded:f.expanded,value:a,subtree:!0,messages:m,path:t,lazyTreeState:e,onLoadPreview:v,previewLabel:u,previewSourcePath:c,previewLoading:y})}</calcite-tree-item>`}return re(a)?F({name:i,value:a,nodePath:t,lazyTreeState:e,messages:m,expanded:s,isMetadata:p,loadPreview:v,previewLabel:u,previewSourcePath:c,previewLoading:y}):te(a)?l`<calcite-tree-item .expanded=${s}><div class="tree-item-label">${L({name:i,isMetadata:p})}${W({value:a})}</div></calcite-tree-item>`:ae(a)?l`<calcite-tree-item .expanded=${s}><div class="tree-item-label">${L({name:i,isMetadata:p})}${W({value:a})}</div></calcite-tree-item>`:null}var W=({value:e})=>{switch(e.type){case"primitive":if(e.value===null)return l`<bdi class="constant-value">null</bdi>`;switch(e.arcadeType){case"String":return l`<bdi class="string-value">${E(String(e.value))}</bdi>`;case"Number":return l`<bdi class="number-value">${String(e.value)}</bdi>`;case"Boolean":return l`<bdi class="constant-value">${String(e.value)}</bdi>`;default:return null}case"simple":return l`<bdi class="date-value">${e.render()}</bdi>`;case"minimal":return l`<bdi class="constant-value">${e.arcadeType}</bdi>`;default:return null}};return{a:ue,b:de,c:ee,d:te,e:ae,f:ie,g:ne,h:T,i:W}},a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ function y(e){return g(e)||m(e)}function f(e){return h(e).filter(t=>t.nodeType===Node.TEXT_NODE).map(t=>t.textContent).join("").trim()}function m(e){return f(e).length>0}function h(e){return e.currentTarget.assignedNodes({flatten:!0})}function g(e){return E(e).length>0}function E(e,t){return p(e.target,t)}function p(e,t){let n=e.assignedElements({flatten:!0});return t?n.filter(s=>s.matches(t)):n}var C=(...e)=>{let t=[];for(let s=0;s<e.length;++s){let o=e[s];if(typeof o=="string")t.push(o);else if(Array.isArray(o))t.push.apply(t,o);else if(typeof o=="object")for(let r in o)o[r]&&t.push(r)}let n=t.join(" ");return t.length=0,n},b=(e,t)=>{let n=e;for(;n;){if(n===t)return!0;if(!n.parentNode)return!1;n.parentNode instanceof ShadowRoot?n=n.parentNode.host:n=n.parentNode}return!1},T=(e,t,n)=>{let s=v(t).subscribe;return s(o=>{o.some(i=>b(e,i.target))&&n()})},a={},v=e=>{let t=e.join(","),n=a[t];if(n!==void 0)return n;let s=new Set,o=new MutationObserver(i=>s.forEach(d=>d(i)));globalThis.document&&o.observe(document.documentElement,{attributes:!0,attributeFilter:e,subtree:!0});let r={subscribe:i=>(s.add(i),()=>{s.delete(i),s.size===0&&(o.disconnect(),a[t]=void 0)})};return a[t]=r,r},l=(e,t)=>{let n=e;for(;n;){let s=n.closest?.(t);if(s)return s;let o=n.getRootNode?.();if(o===globalThis.document)return;n=o?.host}};function w(e){let t=l(e,".calcite-mode-dark, .calcite-mode-light, .calcite-mode-auto");return t?.classList.contains("calcite-mode-dark")||t?.classList.contains("calcite-mode-auto")&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}var A=(e,t,n)=>l(e,`[${t}]`)?.getAttribute(t)??n,R=async e=>{e!=null&&(u(e)?await e.setFocus():e.focus())},u=e=>typeof e.setFocus=="function",x=(e,t)=>{if(e?.shadowRoot){if(e.hasAttribute("hydrated")||e.hasAttribute("calcite-hydrated")){c(e,t);return}Promise.resolve(e.componentOnReady?.()).then(()=>c(e,t))}},N=e=>e.nodeType===Node.ELEMENT_NODE,c=(e,t="")=>{if(!N(e))return!1;if(e.matches(t))return u(e)&&setTimeout(()=>{e.setFocus()},0),!0;for(let s of e.children)if(c(s,t))return!0;let n=e.shadowRoot;if(n){for(let s of n.children)if(c(s,t))return!0}return!1};export{y as a,C as b,T as c,l as d,w as e,A as f,R as g,x as h};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./2PRSVBDA.js";import b from"./YLJUOSJJ.js";import{a as m}from"./HPZZVB4X.js";import a from"./4I7VT4LW.js";import{a as t}from"./ER2MKLVA.js";import{Zk as d,al as n}from"./LLPQEURF.js";export default $arcgis.t(([{a:s,b:p},a,{c:c}])=>{var k=["arcade","arcgis-sql-expression","sql-layer-sql-server","sql-layer-postgres","sql-layer-bigquery"],i=new Set,u=new Map;function l(e){let r=u.get(e);return r||(r=Promise.withResolvers(),u.set(e,r)),r}function f(e){l(e).resolve()}function T(e){return k.includes(e)?l(e).promise:Promise.resolve()}function h(e,r){return()=>{i.has(e)||i.add(e),r()}}async function U(e){i.has(e)||(await t()).createModel("",e,d.parse("")).dispose()}n.register({id:a.languageId,aliases:["Arcade","arcade"],extensions:[".arc"],mimetypes:["application/arcade"]});n.onLanguage(a.languageId,h(a.languageId,()=>{c().then(e=>{e.setupMode(a),f(a.languageId)}).catch(e=>{throw e})}));n.register({id:s.languageId,aliases:["EsiSqlExpression","sql-expression"],extensions:[".sql-expression"],mimetypes:["application/sql-expression"]});n.onLanguage(s.languageId,h(s.languageId,()=>{p().then(e=>{e.setupMode(s),f(s.languageId)}).catch(e=>{throw e})}));q();function q(){t().then(e=>{["light","dark"].forEach(r=>{let g=r==="light"?"vs":"vs-dark",o=m[`${r}-theme`];e.defineTheme(g,{base:g,inherit:!0,rules:[{token:"comment.arcgis",foreground:o.comment},{token:"constant.arcgis",foreground:o.constant},{token:"keyword.arcgis",foreground:o.keyword},{token:"identifier.arcgis",foreground:o.identifier},{token:"number.arcgis",foreground:o.number},{token:"string.arcgis",foreground:o.string},{token:"operator.arcgis",foreground:o.operator},{token:"predefined.arcgis",foreground:o.predefined},{token:"date.arcgis",foreground:o.date}],colors:{}})})})}return{a:f,b:T,c:h,d:U}},a,b,c)
2
+ import e from"./I22MLDO4.js";import b from"./BKBBI4SA.js";import a from"./XBM4ZDJT.js";import{a as t}from"./ER2MKLVA.js";import{a as c}from"./HPZZVB4X.js";import{Zk as d,al as n}from"./LLPQEURF.js";export default $arcgis.t(([s,{c:m},{a:a,b:p}])=>{var k=["arcade","arcgis-sql-expression","sql-layer-sql-server","sql-layer-postgres","sql-layer-bigquery"],i=new Set,u=new Map;function l(e){let r=u.get(e);return r||(r=Promise.withResolvers(),u.set(e,r)),r}function f(e){l(e).resolve()}function T(e){return k.includes(e)?l(e).promise:Promise.resolve()}function h(e,r){return()=>{i.has(e)||i.add(e),r()}}async function U(e){i.has(e)||(await t()).createModel("",e,d.parse("")).dispose()}n.register({id:s.languageId,aliases:["Arcade","arcade"],extensions:[".arc"],mimetypes:["application/arcade"]});n.onLanguage(s.languageId,h(s.languageId,()=>{m().then(e=>{e.setupMode(s),f(s.languageId)}).catch(e=>{throw e})}));n.register({id:a.languageId,aliases:["EsiSqlExpression","sql-expression"],extensions:[".sql-expression"],mimetypes:["application/sql-expression"]});n.onLanguage(a.languageId,h(a.languageId,()=>{p().then(e=>{e.setupMode(a),f(a.languageId)}).catch(e=>{throw e})}));q();function q(){t().then(e=>{["light","dark"].forEach(r=>{let g=r==="light"?"vs":"vs-dark",o=c[`${r}-theme`];e.defineTheme(g,{base:g,inherit:!0,rules:[{token:"comment.arcgis",foreground:o.comment},{token:"constant.arcgis",foreground:o.constant},{token:"keyword.arcgis",foreground:o.keyword},{token:"identifier.arcgis",foreground:o.identifier},{token:"number.arcgis",foreground:o.number},{token:"string.arcgis",foreground:o.string},{token:"operator.arcgis",foreground:o.operator},{token:"predefined.arcgis",foreground:o.predefined},{token:"date.arcgis",foreground:o.date}],colors:{}})})})}return{a:f,b:T,c:h,d:U}},a,b,e)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import j from"./VA6SZILK.js";import i from"./I22MLDO4.js";import f from"./UOQZCTHQ.js";import b from"./ZHZFKZA7.js";import"./QMNQFBIA.js";import"./OSG5CFY4.js";import"./ER2MKLVA.js";import"./MP6Z45SA.js";import"./IFNCCZ7O.js";import{a as _}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import"./6G5URSC7.js";import"./6C52UOYL.js";import{E as l,F as h,G as p,H as r,K as g,h as c,j as e,n as o,t as d}from"./SM3MA3KP.js";import{b as a}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([,,{a:s},{b:m}])=>{var f=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.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}}static{this.styles=[f]}async setFocus(){await this._codeEditorElt.value?.setFocus()}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(t=>!this._preparing&&this.arcgisDiagnosticsChange.emit(t.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 t=i.target;this._setActiveAction(t.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,t=s.getEditorProfileForModel(this._modelId);return t?.variables?.length&&t?.variables?.[0]?.type!=="featureSet"?a(this)("Encountered unexpected editor profile"):i=t?.variables?.[0],i}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}render(){let i=this._getFeatureSetVariable();return e`<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&&e`<arcgis-editor-variables slot=side-panel .variable=${i} .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&&e`<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&&e`<calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}>${i&&e`<calcite-action id=fields-action .text=${this.messages.fields??"Fields"} icon=profile-variables .active=${this._activeAction==="fields"} data-panel-name=fields @click=${this._handleActionClick}></calcite-action>`||""}${i&&!this.sideActionBarExpanded&&e`<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=${this._handleActionClick}></calcite-action>${!this.sideActionBarExpanded&&e`<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,f,i,j)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{b as r}from"./CPJ4MNMY.js";import{K as o}from"./INPMAY4D.js";var s=r(o);export{s as a};
2
+ import{b as r}from"./MJ7MJPGA.js";import{L as o}from"./SM3MA3KP.js";var s=r(o);export{s as a};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{Ok as i,aj as l}from"./LLPQEURF.js";export default $arcgis.t(([d])=>{function m(){return!!window.MonacoEnvironment?.getWorker}var c="",f=new Map,u=!1;async function p(t,r,e){if(e)return r?r():new Worker(t);let s=window.location.origin;if(new URL(t,window.location.href).origin!==s){let o=await d(t,{responseType:"text"});return new Worker(URL.createObjectURL(new Blob([o.data],{type:"text/javascript"})),{type:"module"})}return new Worker(t,{type:"module"})}function E(t){if(m())return;g(),c=t;let r=`${c}/code-editor`,e={arcade:`${r}/arcade.worker.js`,"arcgis-sql-expression":`${r}/sql-expr.worker.js`,"sql-layer-sql-server":`${r}/sql-layer.worker.js`,"sql-layer-postgres":`${r}/sql-layer.worker.js`,"sql-layer-bigquery":`${r}/sql-layer.worker.js`,html:`${r}/html.worker.js`,css:`${r}/css.worker.js`,typescript:`${r}/ts.worker.js`,json:`${r}/json.worker.js`,default:`${r}/editor.worker.js`},s={arcade:{url:e.arcade},"arcgis-sql-expression":{url:e["arcgis-sql-expression"]},"sql-layer-sql-server":{url:e["sql-layer-sql-server"]},"sql-layer-postgres":{url:e["sql-layer-postgres"]},"sql-layer-bigquery":{url:e["sql-layer-bigquery"]},html:{url:e.html},css:{url:e.css},typescript:{url:e.typescript},javascript:{url:e.typescript},json:{url:e.json},default:{url:e.default}};window.MonacoEnvironment={getWorker:async(o,a)=>{let n=f.get(a);if(n)return await p(n,void 0,u);let{url:y,localWorker:q}=s[a]||s.default;return await p(y,q,u)}}}var w=!1;function g(){w||(i.get(l),w=!0)}async function L(){return(await j()).getArcadeDiagnosticService()}async function j(){return await import("./LWXQURWG.js")}return{a:E,b:L,c:j}},"request")
2
+ import{Ok as i,aj as l}from"./LLPQEURF.js";export default $arcgis.t(([d])=>{function m(){return!!window.MonacoEnvironment?.getWorker}var c="",f=new Map,u=!1;async function p(t,r,e){if(e)return r?r():new Worker(t);let s=window.location.origin;if(new URL(t,window.location.href).origin!==s){let o=await d(t,{responseType:"text"});return new Worker(URL.createObjectURL(new Blob([o.data],{type:"text/javascript"})),{type:"module"})}return new Worker(t,{type:"module"})}function E(t){if(m())return;g(),c=t;let r=`${c}/code-editor`,e={arcade:`${r}/arcade.worker.js`,"arcgis-sql-expression":`${r}/sql-expr.worker.js`,"sql-layer-sql-server":`${r}/sql-layer.worker.js`,"sql-layer-postgres":`${r}/sql-layer.worker.js`,"sql-layer-bigquery":`${r}/sql-layer.worker.js`,html:`${r}/html.worker.js`,css:`${r}/css.worker.js`,typescript:`${r}/ts.worker.js`,json:`${r}/json.worker.js`,default:`${r}/editor.worker.js`},s={arcade:{url:e.arcade},"arcgis-sql-expression":{url:e["arcgis-sql-expression"]},"sql-layer-sql-server":{url:e["sql-layer-sql-server"]},"sql-layer-postgres":{url:e["sql-layer-postgres"]},"sql-layer-bigquery":{url:e["sql-layer-bigquery"]},html:{url:e.html},css:{url:e.css},typescript:{url:e.typescript},javascript:{url:e.typescript},json:{url:e.json},default:{url:e.default}};window.MonacoEnvironment={getWorker:async(o,a)=>{let n=f.get(a);if(n)return await p(n,void 0,u);let{url:y,localWorker:q}=s[a]||s.default;return await p(y,q,u)}}}var w=!1;function g(){w||(i.get(l),w=!0)}async function L(){return(await j()).getArcadeDiagnosticService()}async function j(){return await import("./ILQJDTTW.js")}return{a:E,b:L,c:j}},"request")
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{b,c as r,d as _}from"./SMAQD57G.js";import{a as v}from"./NYL3WO6Q.js";import{a as f}from"./QMNQFBIA.js";import"./OSG5CFY4.js";import"./ER2MKLVA.js";import{a as p}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import{g as h,h as m}from"./6G5URSC7.js";import"./6C52UOYL.js";import{F as c,G as d,K as u,h as g,j as s,l,n as a}from"./SM3MA3KP.js";import"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";function S(o){return!Array.isArray(o)||!o.length?!1:Array.isArray(o[0].suggestions)}var $=g`:host{background-color:var(--calcite-color-foreground-1);.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.sticky{position:sticky;top:0;z-index:10}calcite-flow{height:100%}calcite-block{p:first-of-type{margin-top:0}code{font-family:var(--calcite-code-family)}pre{direction:ltr;overflow-x:auto;background-color:var(--calcite-color-foreground-2);padding:var(--calcite-spacing-sm);code{font-size:var(--calcite-font-size--2)}}}calcite-list-item-group{background-color:var(--calcite-color-foreground-2)}calcite-flow{[slot=footer]{word-break:break-word}}}`,n=class extends d{constructor(){super(...arguments),this._beforeBack=async()=>{this._selectedSuggestion=void 0},this.messages=p(),this._colorizeStyle="",this._filterValue="",this.closed=!1,this.arcgisInternalClosePanel=a({bubbles:!1,composed:!1}),this.arcgisInternalItemSelected=a({bubbles:!1,composed:!1})}static{this.properties={_colorizeStyle:16,_filterValue:16,_selectedSuggestion:16,suggestions:0,closed:5}}static{this.styles=$}load(){this._colorizeStyle=r(),this._themeChangedListener=_(()=>this._colorizeStyle=r())}willUpdate(e){e.has("suggestions")&&this.suggestionsPropChanged()}disconnectedCallback(){super.disconnectedCallback(),this._flowObserver?.disconnect(),this._themeChangedListener?.dispose()}suggestionsPropChanged(){this._selectedSuggestion=void 0}flowFocusHandler(e){if(!e){this._flowObserver?.disconnect(),this._flowObserver=void 0;return}this._flowObserver||(this._flowObserver=new MutationObserver(()=>{m(e.querySelector("calcite-flow-item:last-child"),"calcite-input")}),this._flowObserver.observe(e,{attributes:!0,attributeFilter:["id"],childList:!0}))}_updateFilterValue(e){this._filterValue=e.currentTarget?.value??""}_emitItemSelected(e,t){let i=e;(!i.key||i.key==="Enter")&&(e.preventDefault(),this.arcgisInternalItemSelected.emit(t.code))}_showSuggestionDetail(e,t){e.stopPropagation(),this._selectedSuggestion=t}_emitClose(){this.arcgisInternalClosePanel.emit()}_colorizeCode(e){e!==void 0&&b(e,this._selectedSuggestion.code,"arcade")}renderSuggestionGroups(){return this.suggestions===void 0?null:S(this.suggestions)?this.suggestions.map(e=>s`<calcite-list-item-group .heading=${e.label}>${this.renderSuggestionListItems(e.suggestions)}</calcite-list-item-group>`):this.renderSuggestionListItems(this.suggestions)}renderSuggestionListItems(e){return e=f(e,"label",this._filterValue),e.length?e.map(t=>s`<calcite-list-item .label=${t.label} .description=${t.description} @calciteListItemSelect=${i=>this._emitItemSelected(i,t)} @keydown=${i=>this._emitItemSelected(i,t)} data-item=${t??l}><calcite-action slot=actions-end .text=${this.messages.expand??""} scale=s icon=chevron-right icon-flip-rtl @click=${i=>this._showSuggestionDetail(i,t)} data-item=${t??l}></calcite-action></calcite-list-item>`):s`<div class="notice-container">${this.messages.noitems}</div>`}renderSuggestionFlowItem(){let e=this._selectedSuggestion;return e?s`<calcite-flow-item heading-level=2 .heading=${this.messages.suggestions} closable @calciteFlowItemClose=${this._emitClose} .beforeBack=${this._beforeBack} selected><calcite-button width=half slot=footer appearance=outline kind=brand icon-start=code scale=s @click=${t=>this._emitItemSelected(t,e)} data-item=${e??l} ${c(h)}>${this.messages.insert}</calcite-button><calcite-block open .heading=${e.label} .description=${e.description}><div .innerHTML=${v(e.documentation)??""}></div><pre><code ${c(this._colorizeCode)}></code></pre></calcite-block></calcite-flow-item>`:null}render(){return this.closed?null:s`<style>${this._colorizeStyle}</style><calcite-flow ${c(this.flowFocusHandler)}><calcite-flow-item heading-level=2 .heading=${this.messages.suggestions} closable @calciteFlowItemClose=${this._emitClose} .selected=${!this._selectedSuggestion}><calcite-input .value=${this._filterValue} icon=magnifying-glass clearable @calciteInputInput=${this._updateFilterValue} class="sticky" scale=m></calcite-input><calcite-list .label=${this.messages.suggestions??"Suggestions"}>${this.renderSuggestionGroups()}</calcite-list></calcite-flow-item>${this.renderSuggestionFlowItem()}</calcite-flow>`}};u("arcgis-arcade-suggestions",n);export{n as ArcgisArcadeSuggestions};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import d from"./VA6SZILK.js";import c from"./I22MLDO4.js";import b from"./UOQZCTHQ.js";import a from"./ZHZFKZA7.js";import"./QMNQFBIA.js";import"./OSG5CFY4.js";import"./ER2MKLVA.js";import"./MP6Z45SA.js";import"./IFNCCZ7O.js";import"./MTIHPCIF.js";import"./6G5URSC7.js";import"./6C52UOYL.js";import"./SM3MA3KP.js";import"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([,,,{a:a,b:b,c:c}])=>{return{getSqlExprDiagnosticService:b,getSqlExprWorker:a,setupMode:c}},a,b,c,d)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import a from"./ZHZFKZA7.js";import{a as v}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import{d as u,g as p}from"./6G5URSC7.js";import{F as f,G as g,K as b,h as d,j as i,n as r,r as m}from"./SM3MA3KP.js";import{a as h}from"./BCUUVBXH.js";import"./3TTFCHAA.js";export default $arcgis.t(([{C:o,D:n,E:_,F:w}])=>{var $=d`:host{background-color:var(--calcite-color-foreground-1);.notice-container{margin:var(--calcite-spacing-xxs);padding:var(--calcite-spacing-sm);background-color:var(--calcite-color-foreground-1)}.sticky{position:sticky;top:0;z-index:10}calcite-flow{height:100%}calcite-list-item-group{background-color:var(--calcite-color-foreground-2);word-break:break-word}}`;function I(l){l.key==="Enter"&&l.stopPropagation()}var c=class extends g{constructor(){super(...arguments),this._beforeBack=async()=>{this.removeLastPanelRenderer(),this._filterValue=""},this.messages=v(),this._filterValue="",this._flowItemRenderers=[],this._rootPresentation="profile",this._mutationCounter=1,this.loading=!1,this.closed=!1,this.arcgisInternalClosePanel=r({bubbles:!1,composed:!1}),this.arcgisInternalItemSelected=r({bubbles:!1})}static{this.properties={_filterValue:16,_flowItemRenderers:16,_rootPresentation:16,_mutationCounter:16,loading:5,modelId:1,closed:5,variable:0,heading:1,messageOverrides:0}}static{this.styles=$}load(){this._variableChanged()}willUpdate(e){e.has("modelId")&&(this._flowItemRenderers=[]),e.has("variable")&&this._variableChanged()}disconnectedCallback(){super.disconnectedCallback(),this._flowObserver?.disconnect()}_variableChanged(){if(!this.variable||o(this.variable)){this._rootPresentation="profile";return}this._rootPresentation=this.variable.type==="featureSet"?"featureSetRoot":"collectionRoot"}addPanelRenderer(e){this._flowItemRenderers=[...this._flowItemRenderers,e]}removeLastPanelRenderer(){this._flowItemRenderers=this._flowItemRenderers.slice(0,-1)}_isRootPresentation(e){return this._rootPresentation===e}flowFocusHandler(e){if(!e){this._flowObserver?.disconnect(),this._flowObserver=void 0;return}this._flowObserver||(this._flowObserver=new MutationObserver(()=>{p(u(e.querySelector("calcite-flow-item:last-child")??e,"calcite-input"))}),this._flowObserver.observe(e,{attributes:!0,attributeFilter:["id"],childList:!0}))}_updateFilterValue(e){this._filterValue=e.currentTarget.value}_emitClose(){this.arcgisInternalClosePanel.emit()}_backToTop(){this._flowItemRenderers=[]}_emitItemSelected(e,t){if(t.nonInteractive)return;let s=e;(!s.key||s.key==="Enter")&&(e.preventDefault(),this.arcgisInternalItemSelected.emit(t.snippet))}_showCollectionPanel(e,t){e.stopPropagation(),this.addPanelRenderer(s=>this.renderCollectionBasedVariable(t,!1,s))}_getHeadingForCollection(e,t=!1){if(!e)return"";if(t){if(this.heading)return this.heading;if(o(this.variable))return this.variable.definition?.label??this.messages.profilevariables??"Profile variables";if(this._isRootPresentation("featureSetRoot"))return this.messages.fields??"Fields";if(this._isRootPresentation("collectionRoot"))return this.messages.tables??"Tables"}return n(e)||w(e)?this.messages.fields??"Fields":this.messages.profilevariables??"Profile variables"}_getDescriptionForCollection(e){return e?n(e)?e.variables[0]?.getLabel()??"":_(e)?e.datastoreInfo?.name??e.getDescription()??"":e.breadcrumb:""}renderCollectionBasedVariable(e,t=!1,s=!1){if(!e)return null;let a=this.loading;return!a&&!e.loaded&&(e.loadSource().then(()=>setTimeout(()=>{this._mutationCounter+=1})).catch(()=>{h("error",this,"Error loading collection"),a=!1}),a=!0),i`<calcite-flow-item heading-level=2 .heading=${this._getHeadingForCollection(e,t)} .description=${this._getDescriptionForCollection(e)} .beforeBack=${this._beforeBack} closable @calciteFlowItemClose=${this._emitClose} .selected=${s}><calcite-action slot=header-actions-end .text=${this.messages.backtotop??""} scale=m .hidden=${t||this._isRootPresentation("featureSetRoot")} icon=chevrons-left icon-flip-rtl @click=${this._backToTop}></calcite-action><calcite-input .value=${this._filterValue} icon=magnifying-glass clearable @calciteInputInput=${this._updateFilterValue} class="sticky" scale=m .label=${this.messages.filterthevariablesbyname??""} name=variable-filter></calcite-input>${a?i`<calcite-loader scale=s type=indeterminate .label=${this.messages.loading??""}></calcite-loader>`:i`<calcite-list .label=${this.messages.profilevariables??"Profile variables"}>${this.renderEditorVariables(e)}</calcite-list>`}</calcite-flow-item>`}renderEditorVariables(e){let t=m(this._filterValue),s=e.variables.filter(a=>a.passFilter(t));return s.length?s.map(a=>this.renderEditorVariable(a)):i`<div class="notice-container">${this.messages.noitems}</div>`}renderEditorVariable(e){return e.type==="group"?this._isRootPresentation("featureSetRoot")&&e.isHeader?i`<calcite-list-item-group .heading=${e.getLabel()}></calcite-list-item-group>`:this._isRootPresentation("featureSetRoot")&&e._label?.code==="fields"?this.renderEditorVariables(e):i`<calcite-list-item-group .heading=${e.getLabel()}>${this.renderEditorVariables(e)}</calcite-list-item-group>`:i`<calcite-list-item .label=${e.getLabel()} .description=${e.getDescription()} @calciteListItemSelect=${t=>this._emitItemSelected(t,e)} @keydown=${t=>this._emitItemSelected(t,e)}>${e.isCollection?i`<calcite-action slot=actions-end .text=${this.messages.expand??""} scale=s icon=chevron-right icon-flip-rtl @click=${t=>this._showCollectionPanel(t,e)} @keydown=${I}></calcite-action>`:null}${e.icon?i`<calcite-icon .icon=${e.icon} scale=s slot=content-start></calcite-icon>`:null}</calcite-list-item>`}render(){return this.closed?null:this.loading&&!this.variable?i`<calcite-flow><calcite-flow-item heading-level=2 .heading=${this.heading??this.messages.profilevariables} closable @calciteFlowItemClose=${this._emitClose}><calcite-loader scale=s type=indeterminate .label=${this.messages.loading??""}></calcite-loader></calcite-flow-item></calcite-flow>`:!this.loading&&(!this.variable||this.variable?.loaded&&!this.variable?.variables.length)?i`<calcite-flow><calcite-flow-item heading-level=2 .heading=${this.heading??this.messages.profilevariables} closable @calciteFlowItemClose=${this._emitClose}><div class="notice-container">${this.messages.profileempty}</div></calcite-flow-item></calcite-flow>`:i`<calcite-flow ${f(this.flowFocusHandler)}>${this.renderCollectionBasedVariable(this.variable,!0,this._flowItemRenderers.length===0)}${this._flowItemRenderers.map((e,t,s)=>e(t===s.length-1))}</calcite-flow>`}};b("arcgis-editor-variables",c);return c},a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ export default $arcgis.t(([{createArcadeDebugExecutor:C,createArcadeExecutor:b},w])=>{var _="https://developers.arcgis.com/arcade/",q=100,D=100;function R(e){return!!e&&typeof e=="object"&&"declaredRootClass"in e&&typeof e.declaredRootClass=="string"&&e.declaredRootClass==="esri.arcade.featureset.support.FeatureSet"}function j(e){return!!e&&typeof e=="object"&&"arcadeDeclaredClass"in e&&typeof e.arcadeDeclaredClass=="string"&&e.arcadeDeclaredClass==="esri.arcade.Feature"}function A(e){return!!e&&typeof e=="object"&&"declaredClass"in e&&typeof e.declaredClass=="string"&&e.declaredClass==="esri.arcade.Dictionary"}function h(e){return!!e&&typeof e=="object"&&"declaredClass"in e&&typeof e.declaredClass=="string"&&e.declaredClass.startsWith("esri.geometry.")}function x(e){return!!e&&typeof e=="object"&&"declaredClass"in e&&typeof e.declaredClass=="string"&&e.declaredClass.startsWith("esri.rest.knowledgeGraph.KnowledgeGraph")}function k(e){return!!e&&typeof e=="object"&&"declaredClass"in e&&typeof e.declaredClass=="string"&&e.declaredClass==="esri.arcade.Portal"}function S(e){return!!e&&typeof e=="object"&&"declaredClass"in e&&typeof e.declaredClass=="string"&&e.declaredClass==="esri.arcade.Attachment"}function F(e){return!!e&&typeof e=="object"&&"declaredRootClass"in e&&typeof e.declaredRootClass=="string"&&e.declaredRootClass==="esri.arcade.arcadedate"}function T(e){return!!e&&typeof e=="object"&&"declaredRootClass"in e&&typeof e.declaredRootClass=="string"&&e.declaredRootClass==="esri.core.sql.dateonly"}function Z(e){return!!e&&typeof e=="object"&&"declaredRootClass"in e&&typeof e.declaredRootClass=="string"&&e.declaredRootClass==="esri.core.sql.timeonly"}function E(e){return!!e&&typeof e=="object"&&"arcadeDeclaredClass"in e&&typeof e.arcadeDeclaredClass=="string"&&e.arcadeDeclaredClass==="esri.arcade.Pixel"}function P(e){return!!e&&typeof e=="object"&&"length"in e&&typeof e.length=="function"&&"get"in e&&typeof e.get=="function"&&"toArray"in e&&typeof e.toArray=="function"&&"_elements"in e&&Array.isArray(e._elements)}function G(e){return e==null?{type:"null"}:Array.isArray(e)?{type:"array",value:e}:P(e)?{type:"array",value:e.toArray()}:e instanceof Date?{type:"date",value:e}:typeof e=="string"?{type:"text",value:e}:typeof e=="number"?{type:"number",value:e}:typeof e=="boolean"?{type:"boolean",value:e}:typeof e!="object"?{type:"unknown"}:F(e)?{type:"date",value:e}:T(e)?{type:"dateOnly",value:e}:Z(e)?{type:"time",value:e}:S(e)?{type:"attachment",value:e}:k(e)?{type:"portal",value:e}:R(e)?{type:"featureSet",value:e,features:[],iterator:null}:j(e)?{type:"feature",value:e}:E(e)?{type:"pixel",value:e}:A(e)?{type:"dictionary",value:e}:h(e)?{type:"geometry",value:e}:x(e)?{type:"knowledgeGraph",value:e}:{type:"unknown"}}function B(e,a="en"){return e.value instanceof Date?new Intl.DateTimeFormat(a,{dateStyle:"medium",timeStyle:"long"}).format(e.value):e.value.toDateTime().setLocale(a).toFormat(e.value.isUnknownTimeZone?"FF":"FF ZZZZZ")}function K(e){return e.value.toString()}function L(e){return e.value.toString()}async function I(e,a="system"){let t=G(e);return t.type!=="featureSet"||(await t.value.load(),t.iterator=t.value.iterator({aborted:!1}),t.features=await t.iterator.nextBatchAsArcadeFeatures(D,a)??[]),t}function V(e){return"compilationTime"in e||"executionTime"in e||"timeStamp"in e}async function W(e,a,t,r={}){let l=new Date,i=r.mode??"run";r.console??=()=>{};try{let o=performance.now(),n=a??"",c={variables:e?.variables??[]},y=i==="debug"?await C(n,c,{services:{debugger:r.onDebugPause?{pause:r.onDebugPause}:void 0},breakpoints:r.breakpoints}):await b(n,c),u=performance.now(),{profileVariableInstances:f,spatialReference:m,timeZone:d,services:g}=t,v={spatialReference:new w({wkid:m?.wkid??3857}),timeZone:d,console:r.console,services:g,rawOutput:!0},p=await y.executeAsync(f,v);if(i==="debug")return p;let s=await I(p,d);return s.timeStamp=l,s.compilationTime=u-o,s.executionTime=performance.now()-u,s}catch(o){let n="Unknown Error";return o instanceof Error&&(n=o.message),{type:"error",value:n,error:o,timeStamp:l,compilationTime:0,executionTime:0}}}return{a:_,b:q,c:D,d:G,e:B,f:K,g:L,h:V,i:W}},"arcade","geometry/SpatialReference")
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import c from"./6XDEGPYR.js";import a from"./ZHZFKZA7.js";import{b as y,c as h,d as b}from"./OSG5CFY4.js";import{h as u}from"./T4G2IY4F.js";import{K as f}from"./INPMAY4D.js";export default $arcgis.t(([{i:m,n:d},{l:g,o:F,p:M}])=>{var A=o=>{let t=o.variables[0],i=t?.type==="featureSet"?w(t):void 0,{apiVersion:e,bundles:a,hiddenApiItems:r}=o.toEditorProfileDefinition();return{apiVersion:e,bundles:a,variables:i?[i]:[],hiddenApiItems:r?.map(s=>s.toLowerCase())}};function w(o){let{name:t}=o,i=o.getDescription(),{definition:e}=o.toProfileVariableDefinition(),a={label:t,detail:t,insertText:t,insertTextMode:b.asIs,insertTextFormat:h.PlainText,kind:y.Field},r={name:t,description:i,type:"dictionary",properties:[],completion:a};if(!e||!("fields"in e))return r;let[s,l]=g(e.fields,i);return r.properties=s,a.documentation={kind:"markdown",value:l},r}var I={id:"field-calculation",variables:[{name:"$layer",type:"featureSet",description:"The layer being calculated."}]};function P(){return I}function T(o){if(!d(o))return;let t=P();if(!t)return;let i={variables:[],hiddenApiItems:o.hiddenApiItems?.map(e=>e.toLowerCase())};return t.variables.forEach(e=>{if(o.disabledVariables?.includes(e.name))return;let a=o.definitions[e.name];if(e.type==="featureSet")return m(a)?i.variables.push({...e,type:e.type,definition:a}):void 0;throw Error(`sdkVariable type not supported (yet) type: ${e.type}`)}),i}var x="arcgis-sql-expression",p=class extends M{constructor(){super(x,{apiPath:"./assets/sql-language/api",apiPrefix:"sql-api.t9n."}),this._languageId=x,this._layerMap=new Map}updateFeatureLayerForModel(t,i){let e=this._getApiKey(t);this._layerMap.set(e,i)}getFeatureLayerForModel(t){let i=this._getApiKey(t);return this._layerMap.get(i)}async setProfileForModel(t,i,e={locale:"en"}){d(i)&&(i=T(i));let a=await u(e.locale,f("./assets/editor-profile/t9n"),"messages.");if(!a)throw new Error(`Failed to load the language bundle for ${e.locale}`);this.disposeForModel(t);let r=this._getApiKey(t),s=new F(i,a);this._modelToProfileMap.set(r,s);let l=A(s);this.updateApiContextForModel(t,{locale:e.locale,profile:l});let c=i?.variables?.find(v=>v.name==="$layer");c&&this.updateFeatureLayerForModel(t,c.definition)}},n=new p,C={setProfileForModel:n.setProfileForModel.bind(n),getApiLibraryForModel:n.getApiLibraryForModel.bind(n)};async function S(){return await import("./ISAWP6I3.js").then(m=>m.default)}return{a:n,b:S}},a,c)
2
+ import c from"./UOQZCTHQ.js";import a from"./ZHZFKZA7.js";import{b as y,c as h,d as b}from"./OSG5CFY4.js";import{b as u}from"./MTIHPCIF.js";import{L as f}from"./SM3MA3KP.js";export default $arcgis.t(([{i:m,n:d},{l:g,o:F,p:M}])=>{var A=o=>{let t=o.variables[0],i=t?.type==="featureSet"?w(t):void 0,{apiVersion:e,bundles:a,hiddenApiItems:r}=o.toEditorProfileDefinition();return{apiVersion:e,bundles:a,variables:i?[i]:[],hiddenApiItems:r?.map(s=>s.toLowerCase())}};function w(o){let{name:t}=o,i=o.getDescription(),{definition:e}=o.toProfileVariableDefinition(),a={label:t,detail:t,insertText:t,insertTextMode:b.asIs,insertTextFormat:h.PlainText,kind:y.Field},r={name:t,description:i,type:"dictionary",properties:[],completion:a};if(!e||!("fields"in e))return r;let[s,l]=g(e.fields,i);return r.properties=s,a.documentation={kind:"markdown",value:l},r}var I={id:"field-calculation",variables:[{name:"$layer",type:"featureSet",description:"The layer being calculated."}]};function P(){return I}function T(o){if(!d(o))return;let t=P();if(!t)return;let i={variables:[],hiddenApiItems:o.hiddenApiItems?.map(e=>e.toLowerCase())};return t.variables.forEach(e=>{if(o.disabledVariables?.includes(e.name))return;let a=o.definitions[e.name];if(e.type==="featureSet")return m(a)?i.variables.push({...e,type:e.type,definition:a}):void 0;throw Error(`sdkVariable type not supported (yet) type: ${e.type}`)}),i}var x="arcgis-sql-expression",p=class extends M{constructor(){super(x,{apiPath:"./assets/sql-language/api",apiPrefix:"sql-api.t9n."}),this._languageId=x,this._layerMap=new Map}updateFeatureLayerForModel(t,i){let e=this._getApiKey(t);this._layerMap.set(e,i)}getFeatureLayerForModel(t){let i=this._getApiKey(t);return this._layerMap.get(i)}async setProfileForModel(t,i,e={locale:"en"}){d(i)&&(i=T(i));let a=await u(e.locale,f("./assets/editor-profile/t9n"),"messages.");if(!a)throw new Error(`Failed to load the language bundle for ${e.locale}`);this.disposeForModel(t);let r=this._getApiKey(t),s=new F(i,a);this._modelToProfileMap.set(r,s);let l=A(s);this.updateApiContextForModel(t,{locale:e.locale,profile:l});let c=i?.variables?.find(v=>v.name==="$layer");c&&this.updateFeatureLayerForModel(t,c.definition)}},n=new p,C={setProfileForModel:n.setProfileForModel.bind(n),getApiLibraryForModel:n.getApiLibraryForModel.bind(n)};async function S(){return await import("./E3TJIEWT.js").then(m=>m.default)}return{a:n,b:S}},a,c)
@@ -0,0 +1,4 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{a as F}from"./NZDJGAT2.js";import c from"./XBM4ZDJT.js";import b from"./UOQZCTHQ.js";import a from"./ZHZFKZA7.js";import{c as ie,d as se}from"./QMNQFBIA.js";import"./OSG5CFY4.js";import"./ER2MKLVA.js";import"./MP6Z45SA.js";import{d as oe}from"./IFNCCZ7O.js";import{a as te}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import"./6G5URSC7.js";import"./6C52UOYL.js";import{E as W,F as K,G as X,H as Z,I,K as ee,h as Q,j as l,k as j,l as R,t as H,w as G,x as J,y as Y}from"./SM3MA3KP.js";import{a as w}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([xe,ne,Se,re,ce,{getDeclaredVoxelMembers:Te,getDeclaredPixelMembers:Ae},Ce,{property:g,subclass:Ie},{G:q,w:ae,x:V},,N])=>{var A=class extends Y{constructor(e){if(super(e),this.it=R,e.type!==G.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===j)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 C=J(A);var Me=Q`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,$=class extends Error{constructor({message:e,code:t,subCode:i,details:o,source:n}){super(e),this.name="ArcadeAssistantError",this.code=t,this.subCode=i,this.details=o,this.source=n}};function le(a){if(!a)return;let e=a.indexOf('{"error":');if(e!==-1)try{let t=a.slice(e),i=JSON.parse(t);if(i&&typeof i=="object"&&i.error)return i.error}catch{return}}async function Ee(a){let{baseUrl:e,skillId:t,message:i,authToken:o,previousConversationId:n,context:c}=a,p=t?`${e}/skills/${t}/chat`:`${e}/chat`,r=[],s={message:i,context:c};n&&(s.conversation_id=n);let u;try{u=await ne(p,{method:"post",headers:{"Content-Type":"application/json",token:o},body:JSON.stringify(s),responseType:"json"})}catch(b){let f=b,x=f.details?.rawResponse||f.message||String(b),S=le(x);throw S?new $(S):b}let d=u.data;r.push(d);let v=d.conversationId,z=d.inquiryId,k=d.sequenceNumber;async function M(){let b=0,f=100;for(;b<f;){await new Promise(T=>setTimeout(T,1e3));let x=Re(v,k,z),S;try{S=await ne(p,{method:"post",headers:{"Content-Type":"application/json",token:o},body:JSON.stringify(x),responseType:"json"})}catch(T){let L=T,ke=L.details?.rawResponse||L.message||String(T),B=le(ke);throw B?new $(B):T}let y=S.data;if(y.context?.kind==="ArcgisErrorAsContext"&&y.context.error)throw new $({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(r.push(y),k=y.sequenceNumber,b++,!y.hasMore)break}if(b===f)throw new $({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let E=120*1e3;return await Promise.race([M(),new Promise((b,f)=>setTimeout(()=>f(new $({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),E))]),r}function Re(a,e,t){return{conversationId:a,inquiryId:t,ackSequenceNumber:e}}function Ve(a){return a.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":a.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":a.message}var qe=({notices:a})=>a.length?l`<div class="border-block-end">${F(a,e=>e.id??e.title,e=>l`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&l`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&l`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Ne=a=>{let e=a.value.length,t=72,i=180,o=a.offsetWidth,n=Math.max(1,Math.floor(o/8)),c=Math.ceil(e/n),p=t+(c-2)*24;a.style.setProperty("--calcite-text-area-min-height",`${Math.min(p,i)}px`)},Fe=({promptValidationMessage:a,errorMessage:e,contextTooBig:t,contextReducedNoticeDismissed:i,setContextReducedNoticeDismissed:o,setErrorMessage:n,messages:c})=>{let p=[];if(a&&p.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:a,closable:!0}),e&&p.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),t&&!i){let r=c.contextreduced??"Context reduced",s=c.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:r,message:s,closable:!0,onClose:()=>o(!0)})}return p};function Pe({messages:a}){return l`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${a.beta??"Beta"}>${a.beta??"Beta"}</calcite-chip>`}function De({popoverContent:a,messages:e}){return l`<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">${a}</div></calcite-popover>`}function _e({errorMessage:a,slot:e}){return l`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??I}>${a}</calcite-input-message></div>`}function Ue({active:a,setActive:e,messages:t}){return l`<calcite-alert slot=alerts .open=${a} 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:a,messages:e}){return a?l`<div class="gaps">${a.profileId&&l`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",a.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",a.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function ze({isDisabled:a,isReadOnly:e,setQuestion:t,setIsViewingResult:i,textAreaRef:o,question:n,errorMessage:c,setErrorMessage:p,promptValidationMessage:r,setPromptValidationMessage:s,submitQuestion:u,messages:d,mode:v,assistantRef:z,context:k,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:E}){let b=k?.contextTooLarge??!1,f=Fe({promptValidationMessage:r,errorMessage:c,contextTooBig:b,contextReducedNoticeDismissed:M,setContextReducedNoticeDismissed:E,setErrorMessage:p,messages:d});return l`<div class="text-area-wrapper">${qe({notices:f})}<calcite-text-area scale=s resize=vertical .readOnly=${a||e} class=${Z(f.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${d.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${x=>{Ne(x.target),t(x.target.value)}} ${K(o)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${k&&Oe({context:k,messages:d})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${v!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${a} @click=${async()=>{i(!1),t("")}} .label=${d.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${d.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${v!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${a} @click=${async()=>{i(!1),t("")}} class="hidden-below-380" scale=s>${d.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${a} .disabled=${a} @click=${async()=>{if(p(""),!n){s(d.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-below-380">${v==="prompt"?d.ask??"Generate":d.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${a} .disabled=${a} id=small-submit-button @click=${async()=>{if(p(""),!n){s(d.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-above-380" .label=${v==="prompt"?d.ask??"Generate":d.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${v==="prompt"?d.ask??"Generate":d.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var Le="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Be="https://www.esri.com/en-us/privacy/privacy-statements";function Qe({setOpen:a,messages:e,feedback:t,learnMoreUrl:i,setFeedback:o,onSubmit:n}){return t.active?l`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${()=>a(!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=${c=>o({...t,text:c.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=${c=>{o({...t,termsAccepted:c.target.checked})}} .disabled=${t.submitting}></calcite-checkbox><span>${C((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Be} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${Le} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${C((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=${i} 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=${()=>a(!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 de({assistantsEnabled:a,messages:e,slot:t,helpTopicUrl:i}){return l`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${t??I} 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>${a?l`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${C((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${i} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:l`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function je({messages:a,onProceed:e,onExit:t,helpTopicUrl:i}){return l`<calcite-dialog close-disabled placement=top .heading=${a.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${a.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${a.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${C((a.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${i} target="_blank">${a.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${a.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${a.exit??"Exit"}</calcite-button></calcite-dialog>`}function He({messages:a,suggestions:e,onSuggestionClick:t}){return l`<calcite-block .heading=${a.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(i=>l`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${a.promptsuggestion} class="suggestion-button" @click=${()=>t?.(i)}>${i}</calcite-button>`)}</div></calcite-block>`}var pe=200;function ue({hidden:a=!1,expanded:e=!1,messages:t,cards:i,heading:o,collapsible:n=!1,showEffectsIcon:c=!1,onCopyCode:p,standalone:r}){return l`<calcite-block .hidden=${a} id=result-block .heading=${o??t.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${c&&l`<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"}>${F(i,s=>s.conversationId,s=>l`<calcite-card><div slot=heading><div class="prior-prompt"><span>${s.priorPrompt.length>pe?`${s.priorPrompt.slice(0,pe)}...`:s.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${s.conversationId}-${r?"standalone":"list"}`} @click=${u=>{let d=u.currentTarget;navigator.clipboard.writeText(s.priorPrompt).then(()=>{d.setAttribute("data-copied","true"),setTimeout(()=>d.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${s.conversationId}-${r?"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}-${r?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${s.message&&r&&l`<div class="response-error-container">${_e({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&&!r&&l`<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>`||""}${Ge({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("add")} scale=s icon-start=plus round .label=${t.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${s.conversationId}-${r?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${s.conversationId}-${r?"standalone":"list"}`} placement=top-start>${t.addtoeditor??"Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>s.onAddToEditor("add")} scale=s icon-start=plus round>${t.addtoeditor??"Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${()=>s.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${s.conversationId}-${r?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${s.conversationId}-${r?"standalone":"list"}`} placement=top-start><span>${t.replaceineditor??"Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${u=>{let d=u.currentTarget;p(s.code).then(()=>{d.setAttribute("data-copied","true"),setTimeout(()=>d.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${s.conversationId}-${r?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${s.conversationId}-${r?"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}-${r?"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}-${r?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${s.conversationId}-${r?"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}-${r?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${s.conversationId}-${r?"standalone":"list"}`} placement=top-start><span>${t.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var Ge=({card:a,messages:e})=>{let t=H(),i=`response-chip-profile-${a.conversationId}-${t}`,o=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",a.profileId);return l`<calcite-tooltip .referenceElement=${i} placement=top-start class="contained-popover-or-tooltip">${o}</calcite-tooltip><calcite-chip .label=${a.profileId} scale=s appearance=outline icon=map-information id=${i??I}>${a.profileId}</calcite-chip>`},me=a=>a.type==="featureSet";function we(a){return a&&a!=="dataCatalogDatastore"?a:void 0}var P=a=>{if(!ae(a))return[];let e=[];return a.relationships?.forEach(t=>{e.push(t.toJSON())}),e},D=a=>a.length>0?{relationships:a}:{},Je=a=>oe(a).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),_=a=>a?{fields:Je(a)}:{fields:[]};async function he(a){let e=await a.loadSource(),t=V(e)&&e.isTable,i=P(e);return{name:a.name,type:"featureSet",isTable:t,..._(e?.fields),...D(i)}}async function $e(a){switch(a.type){case"feature":{let t=await a.loadSource(),i=P(t);return{name:a.name,type:a.type,..._(t?.fields),...D(i)}}case"featureSet":{let t=await a.loadSource(),i=V(t)&&t.isTable;return{name:a.name,type:"featureSet",...i?{isTable:i}:{},..._(t?.fields),...D(P(t))}}case"featureSetCollection":{let t=await a.loadSource(),i=t?.layers.filter(me)??[],o=t?.tables.filter(me)??[],n=await Promise.all(i.map(he)),c=await Promise.all(o.map(he));return{name:a.name,type:"featureSetCollection",layers:n,tables:c}}case"dictionary":{let t=await Promise.all(a.dictionaryVariables.filter(q).map($e));return{name:a.name,type:"dictionary",attributes:t}}case"pixel":{let t=await a.loadSource();if(!t)return{name:a.name,type:"pixel"};let i=await Ae(t);return{name:a.name,type:"pixel",members:i.map(ge)}}case"voxel":{let t=await a.loadSource();if(!t)return{name:a.name,type:"voxel"};let i=await Te(t);return{name:a.name,type:"voxel",members:i.map(ge)}}case"array":let e=we(a.elementType.type);return{name:a.name,type:"array",...e?{elementType:e}:{}};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:a.name,type:a.type}}}function ge(a){if(a.type==="array"){let e=we(a.elementType.type);return{name:a.name,type:"array",...e?{elementType:e}:{}}}return{name:a.name,type:a.type}}async function Ye(a){return{variables:await Promise.all(a.variables.filter(q).map($e))}}var We=1e5;function Ke(a){let e=new TextEncoder().encode(a).length;return Math.ceil(e/3.5)}function U(a){return Ke(JSON.stringify(a))}function Xe(a){let e=i=>({name:i.name,type:i.type,...i.isTable?{isTable:i.isTable}:{},...i.relationships?{relationships:i.relationships}:{}}),t=i=>{switch(i.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:i.name,type:i.type,..."isTable"in i&&i.isTable?{isTable:i.isTable}:{},..."relationships"in i?{relationships:i.relationships}:{}};case"featureSetCollection":return{name:i.name,type:"featureSetCollection",layers:i.layers.map(e),tables:i.tables.map(e)};case"dictionary":return{name:i.name,type:"dictionary",attributes:i.attributes.map(t)};case"pixel":case"voxel":return{name:i.name,type:i.type};case"array":return{name:i.name,type:"array",...i.elementType?{elementType:i.elementType}:{}};default:return i}};return{variables:a.variables.map(t)}}function Ze(a){let e=a.variables,t=e.length,i=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],o=i?[i]:[];return{context:{variables:o},wasReduced:t!==o.length,reducedToVariableName:i?.name}}function et(a){return U(a)>We}var tt=Object.defineProperty,at=Object.getOwnPropertyDescriptor,h=(a,e,t,i)=>{for(var o=i>1?void 0:i?at(e,t):e,n=a.length-1,c;n>=0;n--)(c=a[n])&&(o=(i?c(e,t,o):c(o))||o);return i&&o&&tt(e,t,o),o},m=class extends Ce{constructor(a){super(a),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};h([g()],m.prototype,"viewMode",2);h([g()],m.prototype,"confirmationActive",2);h([g()],m.prototype,"contextReducedNoticeDismissed",2);h([g()],m.prototype,"splashActive",2);h([g()],m.prototype,"isSubmitting",2);h([g()],m.prototype,"errorMessage",2);h([g()],m.prototype,"promptValidationMessage",2);h([g()],m.prototype,"question",2);h([g()],m.prototype,"history",2);h([g()],m.prototype,"feedback",2);h([g()],m.prototype,"context",2);m=h([Ie("ArcadeAssistantViewState")],m);var it="arcade_generation",st="ArcadeCodeRequest",be="visualization",fe="ArcadeAssistant",ot=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras","conversation_id","privacy_statement"],ve=[],ye=!0,O=class extends X{constructor(){super(...arguments),this.textAreaRef=W(),this.messages=te(),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,i;this.viewState.feedback.item.conversationId===this.viewState.history[0]?.conversationId&&this.viewState.viewMode==="result"?(i=this.viewState.context,t=!0):i=this.viewState.feedback.item.contextSnapshot;let o=re.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:c,termsAccepted:p,item:{question:r,formattedScript:s,conversationId:u}}=this.viewState.feedback,d={user_evaluation:n,your_comments:c||void 0,question:r??"",answer:this.encodeAnswerForFeedback(s),useragent:navigator.userAgent,_source:fe,version:this.appVersion||o||"NOT_SET",context:i?JSON.stringify({...i,isSnapshot:!t}):"",extras:i?.profileId??"",conversation_id:u??"",privacy_statement:p?"I_agree":""};try{await e.applyEdits({addFeatures:[new ce({attributes:d})]})}catch(v){w("error",this,"Error submitting feedback.",{detail:{error:v}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.assistantsEnabled=!1,this.closed=!1,this.disableQuestionAnswerLogging=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,assistantsEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1,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 destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:ve,splashActive:ye})}load(){let e=async()=>{let t=this.getModel();if(!t){this.updateViewState({context:void 0});return}let i=await this.getProfileAndMetadata(t.uri);this.updateViewState({context:i,contextReducedNoticeDismissed:i.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(t=>{w("error",this,"Error setting initial context.",{detail:{error:t}})}),this.manager.onLifecycle(()=>{let t=N.onModelContextDidChange(async()=>{e().catch(i=>{w("error",this,"Error setting context.",{detail:{error:i}})})});return{remove:()=>{t.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),ve=this.viewState.history,ye=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let t=Xe(e.metadata);return{...e,metadata:t,estimatedTokens:U(t)}}encodeAnswerForFeedback(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??be,onAddToEditor:i=>{ie(this.editorRef.editorInstance,t.formattedScript??"",i,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 Se({url:this.feedbackServiceUrl});await e.load();let t=ot.filter(i=>!e.fields.some(o=>o.name===i));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(c){w("error",this,"Error initializing feedback service for interaction logging.",{detail:{error:c}});return}if(!t)return;let i=re.applicationName,o=e.contextSnapshot,n={question:e.question,answer:this.encodeAnswerForFeedback(e.answer),useragent:navigator.userAgent,_source:fe,version:this.appVersion||i||"NOT_SET",context:o?JSON.stringify({...o,isSnapshot:!0}):"",extras:o?.profileId??"",conversation_id:e.conversationId??"",privacy_statement:""};try{await t.applyEdits({addFeatures:[new ce({attributes:n})]})}catch(c){w("error",this,"Error logging arcade assistant question/answer interaction.",{detail:{error:c}})}}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,i;try{let o=this.getModel();if(!o||!this.serviceUrl)return;let n=this.viewState.context??await this.getProfileAndMetadata(o.uri);t=this.createFeedbackContextSnapshot(n);let c=await this.getToken(),p=await Ee({baseUrl:this.serviceUrl,skillId:it,message:e,authToken:c,context:{kind:st,context:{profile_id:n.profileId,metadata:[n.metadata]}}});i=p?.[0]?.conversationId;let r=p.find(s=>s.context?.kind==="ArcadeCodeResponse");if(!r){await this.logInteractionToFeedbackService({question:e,answer:"No ArcadeCodeResponse returned.",contextSnapshot:t,conversationId:i});return}if(r.context?.kind==="ArcadeCodeResponse"){let s=this.createFeedbackContextSnapshot(n),u=se(r?.context?.arcadeCode?.code??"");this.updateViewState({history:[{script:r?.context?.arcadeCode?.code,formattedScript:u,error:void 0,question:e,profile:n.profileId,conversationId:r.conversationId,contextSnapshot:s,...r.message?{message:r.message}:{}},...this.viewState.history],viewMode:"result",errorMessage:void 0}),await this.logInteractionToFeedbackService({question:e,answer:u,contextSnapshot:t,conversationId:r.conversationId})}}catch(o){let n=o instanceof Error&&o.name==="ArcadeAssistantError"?Ve(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:i}),w("error",this,"Error submitting question",{detail:{error:o}})}finally{this.updateViewState({isSubmitting:!1})}}async getToken(){let{token:e}=await xe.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let t=be,i=N.getEditorProfileForModel(e);i?.loaded||await i?.loadSource();let o=this.editorRef.profile;o&&"id"in o&&(t=o.id);let n=i?await Ye(i):{variables:[]},c=et(n),p=c?Ze(n):void 0,r=p?p.context:n,s=U(r);return{profileId:t,metadata:r,contextTooLarge:c,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.assistantsEnabled?l`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&l`<calcite-scrim></calcite-scrim>`||""}${Pe({messages:this.messages})}${De({messages:this.messages,popoverContent:de({assistantsEnabled:this.assistantsEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&je({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:i=>this.closePanel?.(i)})||""}${Ue({active:this.viewState.confirmationActive,setActive:i=>this.updateViewState({confirmationActive:i}),messages:this.messages})}${ze({isDisabled:this.viewState.isSubmitting,isReadOnly:!1,setQuestion:this.setQuestionState,setIsViewingResult:i=>this.updateViewState({viewMode:i?"result":"prompt"}),mode:e?"refine":"prompt",textAreaRef:this.textAreaRef,question:this.viewState.question,errorMessage:this.viewState.errorMessage,setErrorMessage:i=>this.updateViewState({errorMessage:i}),promptValidationMessage:this.viewState.promptValidationMessage,setPromptValidationMessage:i=>this.updateViewState({promptValidationMessage:i}),submitQuestion:this.submitQuestion.bind(this),assistantRef:this.el,messages:this.messages,context:this.viewState.context,contextReducedNoticeDismissed:this.viewState.contextReducedNoticeDismissed,setContextReducedNoticeDismissed:i=>this.updateViewState({contextReducedNoticeDismissed:i})})}<calcite-block-group .label=${this.messages.interactiveblocks??"interactive blocks"}>${!e&&!this.viewState.isSubmitting&&He({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>${ue({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})}${ue({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?Qe({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>`:l`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${de({slot:"content-top",messages:this.messages,assistantsEnabled:this.assistantsEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};ee("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)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import f from"./BKBBI4SA.js";import e from"./XBM4ZDJT.js";import d from"./UOQZCTHQ.js";import c from"./ZHZFKZA7.js";import{e as J}from"./QMNQFBIA.js";import b from"./4B64NBIM.js";import"./OSG5CFY4.js";import{a as ee}from"./ER2MKLVA.js";import"./IFNCCZ7O.js";import a from"./GLJQQLP2.js";import{a as Y}from"./BA546EMZ.js";import{a as K}from"./MJ7MJPGA.js";import"./MTIHPCIF.js";import"./6G5URSC7.js";import"./6C52UOYL.js";import{E as V,F as H,G as Q,H as x,K as W,L as X,h as j,j as l,l as I,n as L,t as G}from"./SM3MA3KP.js";import{a as q,b as u}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import{Rk as Z,Uk as T}from"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([ne,{watch:F},m,{property:o,subclass:S},{a:te,h:y,i:B},{b:M},,,P,{a:se,b:ie}])=>{var ce=j`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}.main-action-bar{calcite-action-group{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action{padding-inline-end:var(--calcite-spacing-sm)}calcite-action-group calcite-action:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}calcite-action-group:last-child{border-inline-end-width:0px}calcite-action-group:not(:first-child){padding-inline-start:var(--calcite-spacing-sm)}}.bottom-action-bar.is-collapsed{border-bottom:0}`,ae="https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0",p=(t,e)=>q(t,"Arcade Assistant",e),le=t=>{let{aiAssistantsEnabled:e}=t;return e===void 0?(p("warn","`areAiAssistantsEnabled` is not defined in the organizations settings."),!1):e},de=t=>!(!t||!("id"in t)),ue=async t=>(await ne.getCredential(t,{oAuthPopupConfirmation:!1})).token,he=async t=>{try{return!!await ne.checkSignInStatus(t)}catch{return p("warn","User is not signed in."),!1}};async function ge({portalUrl:t,profile:e}){if(!de(e))return p("warn","Addon initialization failed. Reason: unsupported profile."),{shouldRender:!1};let s=t.replace(/\/sharing\/rest(\/.*)?$/iu,"").replace(/\/$/u,"");if(!await he(s))return{shouldRender:!1};let i=await ue(t),a=`${s}/sharing/rest/portals/self?f=json&token=${i}`,r=`${s}/sharing/rest/portals/self/settings?f=json&token=${i}`,n=`${s}/sharing/rest/portals/self/signinSettings?f=json&token=${i}`,d=await Promise.allSettled([fetch(a,{credentials:"include"}).then($=>$.json()),fetch(r,{credentials:"include"}).then($=>$.json()),fetch(n,{credentials:"include"}).then($=>$.json())]),[f,C,R]=d,A=f.status==="fulfilled"?f.value:(p("warn",`Failed to fetch selfUrl. Reason: ${f.reason}.`),{}),O=C.status==="fulfilled"?C.value:(p("warn",`Failed to fetch settingsUrl. Reason: ${C.reason}.`),{}),re=R.status==="fulfilled"?R.value:(p("warn",`Failed to fetch signinSettingsUrl. Reason: ${R.reason}.`),{});if(A.isPortal)return{shouldRender:!1};let U=A.helpBase||"";if(!O)return p("warn","Settings response is not available."),{shouldRender:!1};let k=le(O);re.blockBetaApps===!0&&(p("warn","Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."),k=!1),A?.user?.privileges?.includes("portal:user:useAIAssistants")||(p("warn","User does not have the required privileges to use AI Assistants."),k=!1);let z=A?.helperServices?.aiAssistantServices?.url;return z?{shouldRender:!0,serviceUrl:z,helpBase:U,assistantsEnabled:k,feedbackServiceUrl:ae}:{shouldRender:!0,assistantsEnabled:!1,helpBase:U,feedbackServiceUrl:ae}}var pe=Object.defineProperty,be=Object.getOwnPropertyDescriptor,_=(t,e,s,i)=>{for(var a=i>1?void 0:i?be(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&pe(e,s,a),a},oe=100,h=class extends m{constructor(t){super(t),this.collectionItems=[],this.errorMessage="",this.expanded=!1,this.requestId=0,this.status="idle",this.visibleChildCount=oe}};_([o()],h.prototype,"collectionItems",2);_([o()],h.prototype,"errorMessage",2);_([o()],h.prototype,"expanded",2);_([o()],h.prototype,"requestId",2);_([o()],h.prototype,"schemaValue",2);_([o()],h.prototype,"status",2);_([o()],h.prototype,"visibleChildCount",2);h=_([S("ArcadeDebuggerLazyTreeNodeState")],h);var w=class extends m{constructor(t){super(t),this.generation=0,this.nodes=new Map}reset(){this.generation+=1,this.destroyNodes()}ensureNode(t,e=!1,s){let i=this.nodes.get(t);if(i)return i;let a=new h;return a.expanded=e,this.nodes.set(t,a),e&&s&&this.loadNode(t,s),a}setExpanded(t,e,s){let i=this.ensureNode(t,e,s);if(i.expanded===e){e&&s&&this.loadNode(t,s);return}i.expanded=e,e&&s&&this.loadNode(t,s)}showMore(t,e){let s=this.ensureNode(t);s.visibleChildCount>=e||(s.visibleChildCount=Math.min(e,s.visibleChildCount+oe))}loadNode(t,e){switch(e.kind){case"collection":this.runLoad(t,e.load,(s,i)=>{s.collectionItems=i});return;case"schema":this.runLoad(t,e.load,(s,i)=>{s.schemaValue=i});return}}runLoad(t,e,s){let i=this.nodes.get(t);if(!i||i.status==="loading"||i.status==="loaded")return;let a=this.generation,r=i.requestId+1;i.requestId=r,i.status="loading",i.errorMessage="",i.schemaValue=void 0,i.collectionItems=[],e().then(n=>{let d=this.nodes.get(t);!d||this.generation!==a||d.requestId!==r||(s(d,n),d.status="loaded")}).catch(()=>{let n=this.nodes.get(t);!n||this.generation!==a||n.requestId!==r||(n.status="error")})}destroyNodes(){for(let t of this.nodes.values())t.destroy();this.nodes.clear()}};w=_([S("ArcadeDebuggerLazyTreeState")],w);var _e=Object.defineProperty,me=Object.getOwnPropertyDescriptor,c=(t,e,s,i)=>{for(var a=i>1?void 0:i?me(e,s):e,r=t.length-1,n;r>=0;r--)(n=t[r])&&(a=(i?n(e,s,a):n(a))||a);return i&&a&&_e(e,s,a),a},b=class extends m{constructor(t){super(t),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 debugResult(){return this.result?.resultType==="debug"?this.result.result:void 0}addConsoleLog(t){this.consoleLogs=[...this.consoleLogs,t]}};c([o()],b.prototype,"phase",2);c([o()],b.prototype,"mode",2);c([o()],b.prototype,"sessionId",2);c([o()],b.prototype,"result",2);c([o()],b.prototype,"consoleLogs",2);c([o()],b.prototype,"hasExecuted",2);b=c([S("ArcadeDebuggerExecutionModel")],b);var E=class extends m{constructor(t){super(t),this.breakpoints=[]}setBreakpoints(t){this.breakpoints=Array.from(new Set(t)).sort((e,s)=>e-s)}toggleBreakpoint(t){let e=new Set(this.breakpoints);e.has(t)?e.delete(t):e.add(t),this.setBreakpoints(e)}clearBreakpoints(){this.breakpoints=[]}};c([o()],E.prototype,"breakpoints",2);E=c([S("ArcadeDebuggerSessionModel")],E);var v=class extends m{constructor(t){super(t),this.openedPanel="output",this.showPanel=!1}};c([o()],v.prototype,"openedPanel",2);c([o()],v.prototype,"showPanel",2);v=c([S("ArcadeDebuggerUiModel")],v);var D=class extends m{constructor(t){super(t)}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(t){this.pausedState=t,this.lastPausedState=t}};c([o()],D.prototype,"pausedState",2);c([o()],D.prototype,"lastPausedState",2);D=c([S("ArcadeDebuggerPausedFrameModel")],D);var g=class extends m{constructor(t){super(t),this.execution=new b,this.lazyTreeState=new w,this.pausedFrame=new D,this.previewTabsState=new M,this.session=new E,this.ui=new v}get breakpoints(){return this.session.breakpoints}get debuggerBreakpoints(){return this.session.breakpoints.map(t=>({line:t}))}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 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 sessionId(){return this.execution.sessionId}get showPanel(){return this.ui.showPanel}addConsoleLog(t){this.execution.addConsoleLog(t)}clearBreakpoints(){this.session.clearBreakpoints()}clearForMissingTestData(){this.stopDebug({hidePanel:!0}),this.execution.hasExecuted=!1,this.execution.result=void 0}closePanel(){this.ui.showPanel=!1}completeDebug(t){this.execution.mode="debug",this.execution.result={resultType:"debug",result:t},this.execution.phase="completed",this.ui.openedPanel="output",this.pausedFrame.reset(),this.resetTransientDebuggerState()}completeRun(t){this.execution.mode="run",this.execution.result={resultType:"run",result:t},this.execution.phase="completed",this.pausedFrame.reset(),this.resetTransientDebuggerState()}continueDebug(){let t=this.pausedFrame.pausedState?.continue;t&&(this.execution.phase="debug-running",this.pausedFrame.clearPausedState(),t.resolve())}disableDebugger(){this.stopDebug({hidePanel:!0}),this.clearBreakpoints()}fail(t){this.completeRun(t)}pauseDebug(t){let e=this.pausedFrame.pausedState??this.pausedFrame.lastPausedState;this.syncPausedState(e,t),this.pausedFrame.setPausedState(t),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.session.clearBreakpoints(),this.replaceTransientDebuggerState()}resetDebug(){this.stopDebug({hidePanel:!1}),this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="debug-console"}disconnect(){this.stopDebug({hidePanel:!0})}setBreakpoints(t){this.session.setBreakpoints(t)}setPanel(t){this.execution.hasExecuted&&(this.ui.openedPanel=t,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.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}stopDebug({hidePanel:t=!0,invalidateSession:e=!0}={}){let s=this.pausedFrame.pausedState?.continue;e&&(this.execution.sessionId+=1),this.execution.phase=this.execution.hasExecuted?"completed":"idle",this.pausedFrame.reset(),this.resetTransientDebuggerState(),t&&(this.ui.showPanel=!1),this.ui.openedPanel==="debug-console"&&(this.ui.openedPanel="output"),s?.resolve()}syncPausedState(t,e){this.lazyTreeState.reset(),t&&e&&t!==e&&this.previewTabsState.invalidateAll(),this.pausedLine=e?.line}toggleBreakpoint(t){this.session.toggleBreakpoint(t)}togglePanel(t){if(this.execution.hasExecuted){if(t==null){this.ui.showPanel=!this.ui.showPanel;return}if(this.ui.openedPanel===t&&this.ui.showPanel){this.ui.showPanel=!1;return}this.setPanel(t)}}resetTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState.reset(),this.previewTabsState.clear()}replaceTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState=new w,this.previewTabsState=new M}};c([o()],g.prototype,"execution",2);c([o()],g.prototype,"lazyTreeState",2);c([o()],g.prototype,"pausedLine",2);c([o()],g.prototype,"pausedFrame",2);c([o()],g.prototype,"previewTabsState",2);c([o()],g.prototype,"session",2);c([o()],g.prototype,"ui",2);g=c([S("ArcadeDebuggerStore")],g);var Se={glyphMargin:!0,lineNumbersMinChars:1},N=class extends Q{constructor(){super(...arguments),this._codeEditorElt=V(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this._debuggerState=new g,this.messages=Y(),this._modelId=G(),this._openArcadeHelp=()=>{window.open(te,"Arcade Help")},this._decorations=void 0,this._monacoEditor=K(ee),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 s=this._debuggerState.breakpoints.map(i=>({range:new T(i,1,i,1),options:{isWholeLine:!0,glyphMarginClassName:"arcgis-code-editor__breakpoint-glyph"}}));this._decorations?.clear(),this._decorations=e.createDecorationsCollection(s)},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.enableDebugger=!1,this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.arcgisDiagnosticsChange=L({bubbles:!1}),this.arcgisScriptChange=L({bubbles:!1})}static{this.properties={_apiLibrary:16,_editorProfile:16,_preparingArcade:16,_arcadeAssistantRemoteState: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,arcadeAssistant:0}}static{this.styles=[ce]}get _usesBottomExecutionDrawer(){return this.enableDebugger&&!!this.testData}get editorInstance(){return this._codeEditorElt.value?.editorInstance}get editorOptions(){return{...Se,...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 s=this._codeEditorElt.value?.value,i=await B(e.definition,s,this.testData,{mode:"run"});return y(i)?i:{type:"error",value:"Unexpected debug result",error:null}}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async load(){let e=X("./assets");se(e),await this._updateDataModelDeps(),await this._updateArcadeAssistantRemoteState(),this.manager.onLifecycle(()=>(this.hasUpdated&&this._connectMonacoCustomizations().catch(u(this)),()=>{for(;this._disposables.length;)this._disposables.pop()?.dispose();this._connectMonacoCustomizationsPromise=void 0,this._executeScriptAction=void 0,this._clearDebuggerDecorations(),this._debuggerState.disconnect()}))}willUpdate(e){(e.has("messages")||e.has("profile"))&&this._updateDataModelDeps(),e.has("testData")&&this._testDataChanged(),e.has("enableDebugger")&&!this.enableDebugger&&this._debuggerState.disableDebugger(),e.has("snippets")&&P.updateApiContextForModel(this._modelId,{snippets:this.snippets}),e.has("arcadeAssistant")&&this._updateArcadeAssistantRemoteState()}async loaded(){this._componentReadyDefer.resolve(),await this._updateApiLibrary(),await this._connectMonacoCustomizations(),await this._codeEditorElt.value?.setFocus()}_setOpenedSidePanel(e){this.openedSidePanel=e===this.openedSidePanel?"none":e}async _connectMonacoCustomizations(){if(this._disposables.length||this._connectMonacoCustomizationsPromise)return await this._connectMonacoCustomizationsPromise;this._connectMonacoCustomizationsPromise=(async()=>{if(await this.updateComplete,!this.isConnected||this._disposables.length)return;let e=await ie();if(!this.isConnected||this._disposables.length)return;this._disposables.push(e.onDiagnosticsChange(d=>!this._preparingArcade&&this.arcgisDiagnosticsChange.emit(d.diagnostics))),this.testData&&!this._executeScriptAction&&this._addExecuteScriptAction();let s=F(()=>this._debuggerState.breakpoints,()=>this._updateBreakpointsDecorations(),{sync:!0}),i=F(()=>this._debuggerState.debuggerLine,()=>this._updateDebuggerPausedLineDecoration(),{sync:!0}),a=F(()=>this._debuggerState.consoleLogs.length,()=>this.requestUpdate(),{sync:!0});this._disposables.push({dispose:()=>s.remove()},{dispose:()=>i.remove()},{dispose:()=>a.remove()});let r=this.editorInstance?.onMouseDown(d=>this._onEditorMouseDown(d));r&&this._disposables.push(r);let n=this.editorInstance?.onDidChangeModelContent(d=>this._onEditorModelContentChange(d));n&&this._disposables.push(n),this._updateBreakpointsDecorations(),this._updateDebuggerPausedLineDecoration()})();try{await this._connectMonacoCustomizationsPromise}finally{this._connectMonacoCustomizationsPromise=void 0}}_onEditorMouseDown(e){if(!this.enableDebugger||![this._monacoEditor.MouseTargetType.GUTTER_GLYPH_MARGIN,this._monacoEditor.MouseTargetType.GUTTER_LINE_NUMBERS,this._monacoEditor.MouseTargetType.GUTTER_LINE_DECORATIONS].includes(e.target.type))return;let s=e.target.position?.lineNumber;s&&this._debuggerState.toggleBreakpoint(s)}_onEditorModelContentChange(e){if(!this.enableDebugger||!this._debuggerState.breakpoints.length||e.isFlush)return;let s=J(this._debuggerState.breakpoints,e.changes);s.length===this._debuggerState.breakpoints.length&&s.every((i,a)=>i===this._debuggerState.breakpoints[a])||this._debuggerState.setBreakpoints(s)}_updateDebuggerPausedLineDecoration(){let e=this.editorInstance;if(!e)return;this._debuggerPausedLineDecoration?.clear();let s=this._debuggerState.debuggerLine;s!=null?this._debuggerPausedLineDecoration=e.createDecorationsCollection([{range:new T(s,1,s,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"}}]):this._debuggerPausedLineDecoration=void 0}_continueDebugSession(){this._debuggerState.continueDebug()}_stopDebugSession({hideExecutionPanel:e=!0}={}){this._debuggerState.stopDebug({hidePanel:e})}_resetDebugSession(){this._debuggerState.resetDebug(),this._executeScript("debug").catch(u(this))}async _handleDebugPause(e,s,i){if(!this._debuggerState.isDebugging||e!==this._debuggerState.sessionId)return;let a=Promise.withResolvers();return this._debuggerState.pauseDebug({line:s.line,result:i,continue:a}),await a.promise}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}_testDataChanged(){!this.testData&&this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this.testData&&!this._executeScriptAction&&this._addExecuteScriptAction(),!this.testData&&this.enableDebugger&&this._debuggerState.clearForMissingTestData(),this._debuggerState.showPanel&&this._executeScript("run").catch(u(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await P.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=P.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await P.getApiLibraryForModel(this._modelId)}_setExecutionPanel(e){this._debuggerState.togglePanel(e)}async _executeScript(e){let s=this.testData;if(!this._codeEditorElt.value||!s)return;let i=e==="debug"?this._debuggerState.startDebug():this._debuggerState.startRun(),a=await this._editorProfilePromise;if(!a){this._debuggerState.fail({type:"error",value:"Missing editor profile",error:null});return}setTimeout(()=>{(async()=>{let r=this._codeEditorElt.value?.value,n={mode:e,console:f=>this._debuggerState.addConsoleLog(f),breakpoints:e==="debug"?this._debuggerState.debuggerBreakpoints:void 0};e==="debug"&&(n.onDebugPause=this._handleDebugPause.bind(this,i));let d=await B(a.definition,r,s,n);if(i===this._debuggerState.sessionId){if(e==="debug"){if(y(d)){this._debuggerState.fail(d);return}this._debuggerState.completeDebug(d);return}y(d)?this._debuggerState.completeRun(d):this._debuggerState.fail({type:"error",value:"Unexpected debug result",error:null})}})()},0)}_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(u(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(u(this))}_onResultPanelChange(e){let s=e.currentTarget;this._debuggerState.setPanel(s.openedResultPanel)}_onExecutionPanelClose(){this._debuggerState.closePanel()}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[Z.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this.testData&&this._executeScript("run").catch(u(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e))}_disposeSafely(e){let s=this._disposables.indexOf(e);s!==-1&&this._disposables.splice(s,1),e.dispose()}async _updateArcadeAssistantRemoteState(){this.arcadeAssistant&&(this._arcadeAssistantRemoteState=await ge({...this.arcadeAssistant,profile:this.profile}))}renderMainActionBar(){return this.enableDebugger||!this.testData?null:l`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${()=>{this._executeScript("run").catch(u(this))}}></calcite-action>${this._debuggerState.result?l`<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 l`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${P.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${H(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:s,icon:i,active:a,panelName:r,iconFlipRtl:n=!1,onClick:d=this._toggleSidePanel}){return l`<calcite-action id=${e??I} .text=${s} .textEnabled=${this.sideActionBarExpanded} .icon=${i} .active=${a} @click=${d} data-panel-name=${r??I} .iconFlipRtl=${n}></calcite-action>${!this.sideActionBarExpanded&&l`<calcite-tooltip .referenceElement=${e}><span>${s}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:l`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({id:"profile-variables-action",label:this.messages.profilevariables??"",icon:"profile-variables",active:this.openedSidePanel==="variables",panelName:"variables"})}${this.renderAction({id:"function-action",label:this.messages.constantsandfunctions??"",icon:"function",active:this.openedSidePanel==="api",panelName:"api"})}${this.suggestions?.length?this.renderAction({id:"suggestions-action",label:this.messages.suggestions??"",icon:"lightbulb",active:this.openedSidePanel==="suggestions",panelName:"suggestions"}):null}${this._arcadeAssistantRemoteState.shouldRender&&this.renderAction({id:"arcade-assistant-action",label:this.messages.arcadeassistant??"Arcade assistant",icon:"effects",active:this.openedSidePanel==="arcade-assistant",panelName:"arcade-assistant"})||""}${this.customPanels?.map(e=>e.enabled===!1?null:this.renderAction({id:e.id,label:e.name,icon:e.icon,active:this.openedSidePanel===e.id,panelName:e.id}))}${this.hideDocumentationActions?null:this.renderAction({id:"developer-website-action",label:this.messages.help??"",icon:"question",active:!1,panelName:"none",iconFlipRtl:this.messages._lang==="ar",onClick:this._openArcadeHelp})}</calcite-action-group></calcite-action-bar>`}renderSidePanel(){if(this.hideSideBar)return null;let{openedSidePanel:e}=this;return l`<arcgis-language-api-panel slot=side-panel class=${x(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=${x(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}}></arcgis-editor-variables>${this.suggestions?.length&&l`<arcgis-arcade-suggestions slot=side-panel class=${x(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${this.arcadeAssistant&&this._arcadeAssistantRemoteState.shouldRender&&l`<arcgis-arcade-coding-assistant slot=side-panel class=${x(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._closeSidePanel} .portalUrl=${this.arcadeAssistant.portalUrl} .serviceUrl=${"serviceUrl"in this._arcadeAssistantRemoteState?this._arcadeAssistantRemoteState.serviceUrl:void 0} .helpBase=${this._arcadeAssistantRemoteState.helpBase} .assistantsEnabled=${this._arcadeAssistantRemoteState.assistantsEnabled} .feedbackServiceUrl=${this._arcadeAssistantRemoteState.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant.appVersion} .disableQuestionAnswerLogging=${this.arcadeAssistant.disableQuestionAnswerLogging}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(s=>l`<calcite-flow slot=side-panel class=${x(e===s.id?"":"hidden")}>${s?.useFlows?s.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==s.id,editorRef:this.el}):l`<calcite-flow-item .heading=${s.name} heading-level=2 closable .closed=${e!==s.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${s.description}>${s.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==s.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 l`<arcgis-arcade-results slot=results-panel .openedResultPanel=${e} .loading=${this._debuggerState.isExecuting} .result=${this._debuggerState.runResult} .consoleLogs=${this._debuggerState.consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`}renderBottomExecutionBody(){let{showPanel:e,openedPanel:s,debugResult:i,isExecuting:a,mode:r}=this._debuggerState;return e?s==="debug-console"?l`<arcgis-arcade-debugger-console slot=results-panel .modelId=${this._modelId} .debuggerStore=${this._debuggerState}></arcgis-arcade-debugger-console>`:s==="output"&&r==="debug"?l`<arcgis-arcade-debugger-output slot=results-panel .debuggerStore=${this._debuggerState} .result=${i}></arcgis-arcade-debugger-output>`:l`<arcgis-arcade-results slot=results-panel class="bottom-results" .openedResultPanel=${s} .loading=${s==="console"&&this._debuggerState.isPaused?!1:a} .result=${this._debuggerState.runResult} .consoleLogs=${this._debuggerState.consoleLogs} hide-header @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange}></arcgis-arcade-results>`:null}renderBottomActionBar(){if(!this._usesBottomExecutionDrawer)return null;let{showPanel:e,hasExecuted:s,openedPanel:i,isDebugging:a,isPaused:r,isExecuting:n}=this._debuggerState;return l`<calcite-action-bar slot=bottom-action-bar class=${`main-action-bar bottom-action-bar ${e?"":"is-collapsed"}`} layout=horizontal scale=s expand-disabled><calcite-action-group scale=s>${a?l`<calcite-action .text=${this.messages.continue??"Continue"} icon=forward scale=s .disabled=${!r} @click=${this._continueDebugSession}></calcite-action><calcite-action .text=${this.messages.reset??"Reset"} icon=reset scale=s @click=${this._resetDebugSession}></calcite-action><calcite-action .text=${this.messages.stop??"Stop"} icon=circle-stop scale=s @click=${()=>this._stopDebugSession()}></calcite-action>`:l`<calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("run").catch(u(this))}}></calcite-action><calcite-action .text=${this.messages.runanddebug??"Run and Debug"} text-enabled icon=debug-script scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("debug").catch(u(this))}}></calcite-action>`}</calcite-action-group>${s?l`<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")}></calcite-action><calcite-action .active=${i==="debug-console"&&e} .text=${this.messages.debugconsole??"Debug Console"} text-enabled scale=s icon=debug-script icon-flip-rtl .disabled=${this._debuggerState.mode!=="debug"} @click=${()=>this._setExecutionPanel("debug-console")}></calcite-action></calcite-action-group>`:null}${e?l`<calcite-action-group scale=s><calcite-action .text=${this.messages.close??"Close"} scale=s icon=x icon-flip-rtl @click=${this._onExecutionPanelClose}></calcite-action></calcite-action-group>`:null}</calcite-action-bar>`}render(){return l`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderBottomActionBar()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};W("arcgis-arcade-editor",N);return N},"identity/IdentityManager","core/reactiveUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,d,e,f)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{a as F}from"./MP6Z45SA.js";import{a as w}from"./ER2MKLVA.js";import{a as m,b as i,c as E,g as M}from"./OSG5CFY4.js";import"./6C52UOYL.js";import{b as f}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import{Qk as L,Uk as x,Xk as p,al as g}from"./LLPQEURF.js";import"./3TTFCHAA.js";var $=["<=",">=","==","!=","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","=","+=","-=","*=","**=","/=","%="],P={wordPattern:/(-?\d*\.\d\w*)|([^`~!#%\^&\*\(\)\-=\+\[\{\]\}\\\|;:'",\.<>\/\?\s]+)/gu,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]},{open:"`",close:"`",notIn:["string","comment"]}],autoCloseBefore:";:.,=}])` \n ",folding:{markers:{start:/^\s*\/\/\s*#?region\b/u,end:/^\s*\/\/\s*#?endregion\b/u}},indentationRules:{decreaseIndentPattern:/^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/u,increaseIndentPattern:/^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/u}},W={defaultToken:"invalid",tokenPostfix:".arcgis",ignoreCase:!0,keywords:M,operators:$,constants:["true","false","null"],symbols:/[=><!~?:&|+\-*\/\^%]+/u,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/u,digits:/\d+(_+\d+)*/u,octaldigits:/[0-7]+(_+[0-7]+)*/u,binarydigits:/[0-1]+(_+[0-1]+)*/u,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/u,regexpctl:/[(){}\[\]\$\^|\-*+?\.]/u,regexpesc:/\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/u,tokenizer:{root:[[/[{}]/u,"delimiter.bracket"],{include:"common"}],common:[[/import(?=\s)/u,{token:"keyword",next:"@import"}],[/for(?=\s)/u,{token:"keyword",next:"@forLoopInit"}],[/[a-z_$][\w$]*/u,{cases:{"@constants":"constant","@keywords":"keyword","@default":"identifier"}}],{include:"@whitespace"},[/\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/u,{token:"regexp",bracket:"@open",next:"@regexp"}],[/[()\[\]]/u,"@brackets"],[/[<>](?!@symbols)/u,"@brackets"],[/@symbols/u,{cases:{"@operators":"delimiter","@default":""}}],[/(@digits)[eE]([\-+]?(@digits))?/u,"number"],[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/u,"number"],[/0[xX](@hexdigits)/u,"number"],[/0[oO]?(@octaldigits)/u,"number"],[/0[bB](@binarydigits)/u,"number"],[/(@digits)/u,"number"],[/[;,.]/u,"delimiter"],[/"([^"\\]|\\.)*$/u,"string.invalid"],[/'([^'\\]|\\.)*$/u,"string.invalid"],[/"/u,"string","@string_double"],[/'/u,"string","@string_single"],[/`/u,"string","@string_backtick"]],import:[[/import(?=\s)/u,{token:"keyword"}],{include:"@whitespace"},[/[a-z_$][\w$]*/u,"identifier"],{include:"@whitespace"},[/from(?=\s)/u,{token:"keyword",next:"@popall"}]],forLoopInit:[{include:"@whitespace"},[/\(/u,{token:"@brackets",next:"@forLoopVar"}],[/.*/u,"","@pop"]],forLoopVar:[{include:"@whitespace"},[/var(?=\s)/u,"keyword","@forLoopVarName"],[/[a-z_$][\w$]*/u,"identifier","@forLoopCheckInOf"],[/\)/u,{token:"@brackets",next:"@popall"}]],forLoopVarName:[{include:"@whitespace"},[/[a-z_$][\w$]*/u,"identifier","@forLoopCheckInOf"],[/\)/u,{token:"@brackets",next:"@popall"}]],forLoopCheckInOf:[{include:"@whitespace"},[/in(?=\s)/u,"keyword","@popall"],[/of(?=\s)/u,"keyword","@popall"],[/[a-z_$][\w$]*/u,"identifier"],[/\)/u,{token:"@brackets",next:"@popall"}]],whitespace:[[/[ \t\r\n]+/u,""],[/\/\*/u,"comment","@comment"],[/\/\/.*$/u,"comment"]],comment:[[/[^\/*]+/u,"comment"],[/\*\//u,"comment","@pop"],[/[\/*]/u,"comment"]],regexp:[[/(\{)(\d+(?:,\d*)?)(\})/u,["regexp.escape.control","regexp.escape.control","regexp.escape.control"]],[/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/u,["regexp.escape.control",{token:"regexp.escape.control",next:"@regexrange"}]],[/(\()(\?:|\?=|\?!)/u,["regexp.escape.control","regexp.escape.control"]],[/[()]/u,"regexp.escape.control"],[/@regexpctl/u,"regexp.escape.control"],[/[^\\\/]/u,"regexp"],[/@regexpesc/u,"regexp.escape"],[/\\\./u,"regexp.invalid"],[/(\/)([gimsuy]*)/u,[{token:"regexp",bracket:"@close",next:"@pop"},"keyword.other"]]],regexrange:[[/-/u,"regexp.escape.control"],[/\^/u,"regexp.invalid"],[/@regexpesc/u,"regexp.escape"],[/[^\]]/u,"regexp"],[/\]/u,{token:"regexp.escape.control",next:"@pop",bracket:"@close"}]],string_double:[[/[^\\"]+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/"/u,"string","@pop"]],string_single:[[/[^\\']+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/'/u,"string","@pop"]],string_backtick:[[/\$\{/u,{token:"delimiter.bracket",next:"@bracketCounting"}],[/[^\\`$]+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/`/u,"string","@pop"]],bracketCounting:[[/\{/u,"delimiter.bracket","@bracketCounting"],[/\}/u,"delimiter.bracket","@pop"],{include:"common"}]}},b=class{constructor(e,n,{defaults:o,diagnosticsService:d}){this._languageId=e,this._worker=n,this._disposables=[],this._modelListeners=new Map,this._diagnosticsService=d,this._defaults=o,w().then(c=>{let u=s=>{let r=s.getLanguageId();if(r!==this._languageId)return;let a=F(()=>{this._doValidate(s,r).catch(D=>{throw D})}),A=s.onDidChangeContent(a),S=s.onDidChangeAttached(a);this._modelListeners.set(s.uri.toString(),[A,S]),this._doValidate(s,r).catch(f("DiagnosticsAdapter"))},l=s=>{let r=s.uri.toString();c.setModelMarkers(s,this._languageId,[]);let a=this._modelListeners.get(r);if(a){for(;a.length;)a.pop()?.dispose();this._modelListeners.delete(r)}};this._disposables.push(c.onDidCreateModel(u)),this._disposables.push(c.onWillDisposeModel(s=>{l(s)})),this._disposables.push(c.onDidChangeModelLanguage(s=>{l(s.model),u(s.model)})),this._disposables.push(o.onDidChange(()=>{c.getModels().forEach(s=>{s.getLanguageId()===this._languageId&&(l(s),u(s))})})),this._disposables.push(o.onModelContextDidChange(s=>{c.getModels().forEach(r=>{r.getLanguageId()===this._languageId&&r.uri.toString()===s&&this._doValidate(r,this._languageId).catch(f("DiagnosticsAdapter"))})})),this._disposables.push({dispose:()=>{this._modelListeners.forEach(s=>s.forEach(r=>r.dispose())),this._modelListeners.clear()}}),c.getModels().forEach(u)})}dispose(){this._disposables.forEach(e=>e.dispose()),this._disposables=[]}async _doValidate(e,n){if(e.isAttachedToEditor())try{let o=await w(),d=await this._worker(e.uri),c=this._defaults.getApiContextForModel(e.uri),u=await d.doValidation(e.uri.toString(),c),l=u.map(s=>R(e.uri,s));this._diagnosticsService.fireDiagnosticsChange(e.uri,u),o.setModelMarkers(e,n,l)}catch(o){f("DiagnosticsAdapter")(o)}}};function V(t){switch(t){case m.Error:return p.Error;case m.Warning:return p.Warning;case m.Information:return p.Info;case m.Hint:return p.Hint;default:return p.Info}}function R(t,e){return{severity:V(e.severity),startLineNumber:e.range.start.line+1,startColumn:e.range.start.character+1,endLineNumber:e.range.end.line+1,endColumn:e.range.end.character+1,message:e.message}}function K(t){return{character:t.column-1,line:t.lineNumber-1}}function h(t){return new x(t.start.line+1,t.start.character+1,t.end.line+1,t.end.character+1)}function N(t){return{range:h(t.range),text:t.newText}}function z(t){return typeof t.insert<"u"&&typeof t.replace<"u"}function O(t){let e=g.CompletionItemKind;switch(t){case i.Text:return e.Text;case i.Method:return e.Method;case i.Function:return e.Function;case i.Constructor:return e.Constructor;case i.Field:return e.Field;case i.Variable:return e.Variable;case i.Class:return e.Class;case i.Interface:return e.Interface;case i.Module:return e.Module;case i.Property:return e.Property;case i.Unit:return e.Unit;case i.Value:return e.Value;case i.Enum:return e.Enum;case i.Keyword:return e.Keyword;case i.Snippet:return e.Snippet;case i.Color:return e.Color;case i.File:return e.File;case i.Reference:return e.Reference;case i.Folder:return e.Folder;case i.EnumMember:return e.EnumMember;case i.Constant:return e.Constant;case i.Struct:return e.Struct;case i.Event:return e.Event;case i.Operator:return e.Operator;case i.TypeParameter:return e.TypeParameter;default:return e.Property}}var C=class{constructor(e,n){this._worker=e,this._defaults=n,this.triggerCharacters=[".","("]}async provideCompletionItems(e,n){let o=await this._worker(e.uri),d=this._defaults.getApiContextForModel(e.uri),c=await o.doComplete(e.uri.toString(),K(n),d),u=e.getWordUntilPosition(n),l=new x(n.lineNumber,u.startColumn,n.lineNumber,u.endColumn),s=c.items.map(r=>{let a={label:r.label,insertText:r.insertText||r.label,sortText:r.sortText,filterText:r.filterText,detail:r.detail,range:l,kind:O(r.kind)};return r.textEdit&&(z(r.textEdit)?a.range={insert:h(r.textEdit.insert),replace:h(r.textEdit.replace)}:a.range=h(r.textEdit.range),a.insertText=r.textEdit.newText),r.additionalTextEdits&&(a.additionalTextEdits=r.additionalTextEdits.map(N)),r.insertTextFormat===E.Snippet&&(a.insertTextRules=g.CompletionItemInsertTextRule.InsertAsSnippet),r.documentation&&(typeof r.documentation=="string"?a.documentation=r.documentation:a.documentation={supportThemeIcons:!1,value:r.documentation.value,supportHtml:!0}),a});return{incomplete:c.isIncomplete,suggestions:s}}},y=class{constructor(e,n){this._worker=e,this._defaults=n}async provideDocumentFormattingEdits(e){let n=await this._worker(e.uri),o=this._defaults.getApiContextForModel(e.uri.toString());return(await n.doFormat(e.uri.toString(),o)).map(d=>({range:h(d.range),text:d.newText}))}},_=Promise.withResolvers(),k=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,_=Promise.withResolvers()),this._client=null}static async waitForWorker(){return await _.promise}async _getClientProxy(){let e=await w();if(!this._client){let{languageId:n}=this._defaults,o=window.MonacoEnvironment?.getWorker;if(!o)throw new Error("MonacoEnvironment.getWorker is not configured. Call setupMonacoEnvironment(...) before creating Arcade workers.");this._worker=e.createWebWorker({worker:o("ArcadeWorker",n),host:this._defaults.workerHost}),_.resolve(this._worker),this._client=this._worker.getProxy()}return await this._client}async getLanguageServiceWorker(...e){let n=await this._getClientProxy();return await this._worker?.withSyncedResources(e),n}},I;async function re(...t){return await k.waitForWorker(),await new Promise((e,n)=>{if(!I){n(new Error("Arcade not registered!"));return}e(I(...t))})}var v=class{constructor(){this._onDiagnosticsChange=new L}get onDiagnosticsChange(){return this._onDiagnosticsChange.event}fireDiagnosticsChange(e,n){this._onDiagnosticsChange.fire({uri:e,diagnostics:n})}},T=new v;function ne(){return T}function se(t){let e=new k(t),n=async(...o)=>await e.getLanguageServiceWorker(...o);I=n,g.setMonarchTokensProvider(t.languageId,W),g.setLanguageConfiguration(t.languageId,P),g.registerCompletionItemProvider(t.languageId,new C(n,t)),g.registerDocumentFormattingEditProvider(t.languageId,new y(n,t)),new b(t.languageId,n,{defaults:t,diagnosticsService:T})}export{ne as getArcadeDiagnosticService,re as getArcadeWorker,se as setupMode};
2
+ import{a as m,b as i,c as E,g as M}from"./OSG5CFY4.js";import{a as w}from"./ER2MKLVA.js";import{a as F}from"./MP6Z45SA.js";import"./6C52UOYL.js";import{b as f}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import{Qk as L,Uk as x,Xk as p,al as g}from"./LLPQEURF.js";import"./3TTFCHAA.js";var $=["<=",">=","==","!=","+","-","*","/","%","++","--","<<",">>",">>>","&","|","^","!","~","&&","||","=","+=","-=","*=","**=","/=","%="],P={wordPattern:/(-?\d*\.\d\w*)|([^`~!#%\^&\*\(\)\-=\+\[\{\]\}\\\|;:'",\.<>\/\?\s]+)/gu,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]},{open:"`",close:"`",notIn:["string","comment"]}],autoCloseBefore:";:.,=}])` \n ",folding:{markers:{start:/^\s*\/\/\s*#?region\b/u,end:/^\s*\/\/\s*#?endregion\b/u}},indentationRules:{decreaseIndentPattern:/^((?!.*?\/\*).*\*\/)?\s*[\}\]\)].*$/u,increaseIndentPattern:/^((?!\/\/).)*(\{[^}"'`]*|\([^)"'`]*|\[[^\]"'`]*)$/u}},W={defaultToken:"invalid",tokenPostfix:".arcgis",ignoreCase:!0,keywords:M,operators:$,constants:["true","false","null"],symbols:/[=><!~?:&|+\-*\/\^%]+/u,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/u,digits:/\d+(_+\d+)*/u,octaldigits:/[0-7]+(_+[0-7]+)*/u,binarydigits:/[0-1]+(_+[0-1]+)*/u,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/u,regexpctl:/[(){}\[\]\$\^|\-*+?\.]/u,regexpesc:/\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/u,tokenizer:{root:[[/[{}]/u,"delimiter.bracket"],{include:"common"}],common:[[/import(?=\s)/u,{token:"keyword",next:"@import"}],[/for(?=\s)/u,{token:"keyword",next:"@forLoopInit"}],[/[a-z_$][\w$]*/u,{cases:{"@constants":"constant","@keywords":"keyword","@default":"identifier"}}],{include:"@whitespace"},[/\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/u,{token:"regexp",bracket:"@open",next:"@regexp"}],[/[()\[\]]/u,"@brackets"],[/[<>](?!@symbols)/u,"@brackets"],[/@symbols/u,{cases:{"@operators":"delimiter","@default":""}}],[/(@digits)[eE]([\-+]?(@digits))?/u,"number"],[/(@digits)\.(@digits)([eE][\-+]?(@digits))?/u,"number"],[/0[xX](@hexdigits)/u,"number"],[/0[oO]?(@octaldigits)/u,"number"],[/0[bB](@binarydigits)/u,"number"],[/(@digits)/u,"number"],[/[;,.]/u,"delimiter"],[/"([^"\\]|\\.)*$/u,"string.invalid"],[/'([^'\\]|\\.)*$/u,"string.invalid"],[/"/u,"string","@string_double"],[/'/u,"string","@string_single"],[/`/u,"string","@string_backtick"]],import:[[/import(?=\s)/u,{token:"keyword"}],{include:"@whitespace"},[/[a-z_$][\w$]*/u,"identifier"],{include:"@whitespace"},[/from(?=\s)/u,{token:"keyword",next:"@popall"}]],forLoopInit:[{include:"@whitespace"},[/\(/u,{token:"@brackets",next:"@forLoopVar"}],[/.*/u,"","@pop"]],forLoopVar:[{include:"@whitespace"},[/var(?=\s)/u,"keyword","@forLoopVarName"],[/[a-z_$][\w$]*/u,"identifier","@forLoopCheckInOf"],[/\)/u,{token:"@brackets",next:"@popall"}]],forLoopVarName:[{include:"@whitespace"},[/[a-z_$][\w$]*/u,"identifier","@forLoopCheckInOf"],[/\)/u,{token:"@brackets",next:"@popall"}]],forLoopCheckInOf:[{include:"@whitespace"},[/in(?=\s)/u,"keyword","@popall"],[/of(?=\s)/u,"keyword","@popall"],[/[a-z_$][\w$]*/u,"identifier"],[/\)/u,{token:"@brackets",next:"@popall"}]],whitespace:[[/[ \t\r\n]+/u,""],[/\/\*/u,"comment","@comment"],[/\/\/.*$/u,"comment"]],comment:[[/[^\/*]+/u,"comment"],[/\*\//u,"comment","@pop"],[/[\/*]/u,"comment"]],regexp:[[/(\{)(\d+(?:,\d*)?)(\})/u,["regexp.escape.control","regexp.escape.control","regexp.escape.control"]],[/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/u,["regexp.escape.control",{token:"regexp.escape.control",next:"@regexrange"}]],[/(\()(\?:|\?=|\?!)/u,["regexp.escape.control","regexp.escape.control"]],[/[()]/u,"regexp.escape.control"],[/@regexpctl/u,"regexp.escape.control"],[/[^\\\/]/u,"regexp"],[/@regexpesc/u,"regexp.escape"],[/\\\./u,"regexp.invalid"],[/(\/)([gimsuy]*)/u,[{token:"regexp",bracket:"@close",next:"@pop"},"keyword.other"]]],regexrange:[[/-/u,"regexp.escape.control"],[/\^/u,"regexp.invalid"],[/@regexpesc/u,"regexp.escape"],[/[^\]]/u,"regexp"],[/\]/u,{token:"regexp.escape.control",next:"@pop",bracket:"@close"}]],string_double:[[/[^\\"]+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/"/u,"string","@pop"]],string_single:[[/[^\\']+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/'/u,"string","@pop"]],string_backtick:[[/\$\{/u,{token:"delimiter.bracket",next:"@bracketCounting"}],[/[^\\`$]+/u,"string"],[/@escapes/u,"string.escape"],[/\\./u,"string.escape.invalid"],[/`/u,"string","@pop"]],bracketCounting:[[/\{/u,"delimiter.bracket","@bracketCounting"],[/\}/u,"delimiter.bracket","@pop"],{include:"common"}]}},b=class{constructor(e,n,{defaults:o,diagnosticsService:d}){this._languageId=e,this._worker=n,this._disposables=[],this._modelListeners=new Map,this._diagnosticsService=d,this._defaults=o,w().then(c=>{let u=s=>{let r=s.getLanguageId();if(r!==this._languageId)return;let a=F(()=>{this._doValidate(s,r).catch(D=>{throw D})}),A=s.onDidChangeContent(a),S=s.onDidChangeAttached(a);this._modelListeners.set(s.uri.toString(),[A,S]),this._doValidate(s,r).catch(f("DiagnosticsAdapter"))},l=s=>{let r=s.uri.toString();c.setModelMarkers(s,this._languageId,[]);let a=this._modelListeners.get(r);if(a){for(;a.length;)a.pop()?.dispose();this._modelListeners.delete(r)}};this._disposables.push(c.onDidCreateModel(u)),this._disposables.push(c.onWillDisposeModel(s=>{l(s)})),this._disposables.push(c.onDidChangeModelLanguage(s=>{l(s.model),u(s.model)})),this._disposables.push(o.onDidChange(()=>{c.getModels().forEach(s=>{s.getLanguageId()===this._languageId&&(l(s),u(s))})})),this._disposables.push(o.onModelContextDidChange(s=>{c.getModels().forEach(r=>{r.getLanguageId()===this._languageId&&r.uri.toString()===s&&this._doValidate(r,this._languageId).catch(f("DiagnosticsAdapter"))})})),this._disposables.push({dispose:()=>{this._modelListeners.forEach(s=>s.forEach(r=>r.dispose())),this._modelListeners.clear()}}),c.getModels().forEach(u)})}dispose(){this._disposables.forEach(e=>e.dispose()),this._disposables=[]}async _doValidate(e,n){if(e.isAttachedToEditor())try{let o=await w(),d=await this._worker(e.uri),c=this._defaults.getApiContextForModel(e.uri),u=await d.doValidation(e.uri.toString(),c),l=u.map(s=>R(e.uri,s));this._diagnosticsService.fireDiagnosticsChange(e.uri,u),o.setModelMarkers(e,n,l)}catch(o){f("DiagnosticsAdapter")(o)}}};function V(t){switch(t){case m.Error:return p.Error;case m.Warning:return p.Warning;case m.Information:return p.Info;case m.Hint:return p.Hint;default:return p.Info}}function R(t,e){return{severity:V(e.severity),startLineNumber:e.range.start.line+1,startColumn:e.range.start.character+1,endLineNumber:e.range.end.line+1,endColumn:e.range.end.character+1,message:e.message}}function K(t){return{character:t.column-1,line:t.lineNumber-1}}function h(t){return new x(t.start.line+1,t.start.character+1,t.end.line+1,t.end.character+1)}function N(t){return{range:h(t.range),text:t.newText}}function z(t){return typeof t.insert<"u"&&typeof t.replace<"u"}function O(t){let e=g.CompletionItemKind;switch(t){case i.Text:return e.Text;case i.Method:return e.Method;case i.Function:return e.Function;case i.Constructor:return e.Constructor;case i.Field:return e.Field;case i.Variable:return e.Variable;case i.Class:return e.Class;case i.Interface:return e.Interface;case i.Module:return e.Module;case i.Property:return e.Property;case i.Unit:return e.Unit;case i.Value:return e.Value;case i.Enum:return e.Enum;case i.Keyword:return e.Keyword;case i.Snippet:return e.Snippet;case i.Color:return e.Color;case i.File:return e.File;case i.Reference:return e.Reference;case i.Folder:return e.Folder;case i.EnumMember:return e.EnumMember;case i.Constant:return e.Constant;case i.Struct:return e.Struct;case i.Event:return e.Event;case i.Operator:return e.Operator;case i.TypeParameter:return e.TypeParameter;default:return e.Property}}var C=class{constructor(e,n){this._worker=e,this._defaults=n,this.triggerCharacters=[".","("]}async provideCompletionItems(e,n){let o=await this._worker(e.uri),d=this._defaults.getApiContextForModel(e.uri),c=await o.doComplete(e.uri.toString(),K(n),d),u=e.getWordUntilPosition(n),l=new x(n.lineNumber,u.startColumn,n.lineNumber,u.endColumn),s=c.items.map(r=>{let a={label:r.label,insertText:r.insertText||r.label,sortText:r.sortText,filterText:r.filterText,detail:r.detail,range:l,kind:O(r.kind)};return r.textEdit&&(z(r.textEdit)?a.range={insert:h(r.textEdit.insert),replace:h(r.textEdit.replace)}:a.range=h(r.textEdit.range),a.insertText=r.textEdit.newText),r.additionalTextEdits&&(a.additionalTextEdits=r.additionalTextEdits.map(N)),r.insertTextFormat===E.Snippet&&(a.insertTextRules=g.CompletionItemInsertTextRule.InsertAsSnippet),r.documentation&&(typeof r.documentation=="string"?a.documentation=r.documentation:a.documentation={supportThemeIcons:!1,value:r.documentation.value,supportHtml:!0}),a});return{incomplete:c.isIncomplete,suggestions:s}}},y=class{constructor(e,n){this._worker=e,this._defaults=n}async provideDocumentFormattingEdits(e){let n=await this._worker(e.uri),o=this._defaults.getApiContextForModel(e.uri.toString());return(await n.doFormat(e.uri.toString(),o)).map(d=>({range:h(d.range),text:d.newText}))}},_=Promise.withResolvers(),k=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,_=Promise.withResolvers()),this._client=null}static async waitForWorker(){return await _.promise}async _getClientProxy(){let e=await w();if(!this._client){let{languageId:n}=this._defaults,o=window.MonacoEnvironment?.getWorker;if(!o)throw new Error("MonacoEnvironment.getWorker is not configured. Call setupMonacoEnvironment(...) before creating Arcade workers.");this._worker=e.createWebWorker({worker:o("ArcadeWorker",n),host:this._defaults.workerHost}),_.resolve(this._worker),this._client=this._worker.getProxy()}return await this._client}async getLanguageServiceWorker(...e){let n=await this._getClientProxy();return await this._worker?.withSyncedResources(e),n}},I;async function re(...t){return await k.waitForWorker(),await new Promise((e,n)=>{if(!I){n(new Error("Arcade not registered!"));return}e(I(...t))})}var v=class{constructor(){this._onDiagnosticsChange=new L}get onDiagnosticsChange(){return this._onDiagnosticsChange.event}fireDiagnosticsChange(e,n){this._onDiagnosticsChange.fire({uri:e,diagnostics:n})}},T=new v;function ne(){return T}function se(t){let e=new k(t),n=async(...o)=>await e.getLanguageServiceWorker(...o);I=n,g.setMonarchTokensProvider(t.languageId,W),g.setLanguageConfiguration(t.languageId,P),g.registerCompletionItemProvider(t.languageId,new C(n,t)),g.registerDocumentFormattingEditProvider(t.languageId,new y(n,t)),new b(t.languageId,n,{defaults:t,diagnosticsService:T})}export{ne as getArcadeDiagnosticService,re as getArcadeWorker,se as setupMode};
@@ -0,0 +1,3 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{b as I}from"./OI3DH7N2.js";import e from"./JT3FBAVQ.js";import d from"./UOQZCTHQ.js";import c from"./ZHZFKZA7.js";import{c as E}from"./QMNQFBIA.js";import"./OSG5CFY4.js";import"./ER2MKLVA.js";import"./MP6Z45SA.js";import"./IFNCCZ7O.js";import{a as u}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import"./6G5URSC7.js";import"./6C52UOYL.js";import{E as g,F as m,G as _,H as b,K as f,h as p,j as o,n as r,t as h}from"./SM3MA3KP.js";import{b as a}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([,,,,,,,{E:l},{c:d},{a:S,b:v,c:$,d:y}])=>{var x=p`:host{height:100%}calcite-tooltip:not([calcite-hydrated])>*{display:none}`,n=class extends _{constructor(){super(...arguments),this._codeEditorElt=g(),this._disposables=[],this._modelId=h(),this.messages=u(),this._preparing=!1,this._resolvedLanguage=d,this.sideActionBarExpanded=!1,this.script="",this.hideSideBar=!1,this.openedSidePanel="none",this.arcgisDiagnosticsChange=r({bubbles:!1}),this.arcgisScriptChange=r({bubbles:!1})}static{this.properties={_editorProfile:16,_preparing:16,_resolvedLanguage:16,sideActionBarExpanded:16,profile:0,script:1,hideSideBar:5,messageOverrides:0,openedSidePanel:3,editorOptions:0,editorInstance:32}}static{this.styles=[x]}get editorInstance(){return this._codeEditorElt.value?.editorInstance}async setFocus(){await this._codeEditorElt.value?.setFocus()}async load(){await this._updateDataModelDeps().catch(a(this))}willUpdate(e){e.has("profile")&&this._updateDataModelDeps().catch(a(this))}async loaded(){let e=I();this._disposables.push(e.onDiagnosticsChange(t=>{t.uri.toString()===this._modelId&&!this._preparing&&this.arcgisDiagnosticsChange.emit(t.diagnostics)}))}disconnectedCallback(){for(super.disconnectedCallback();this._disposables.length;)this._disposables.pop()?.dispose();y().forEach(e=>e.disposeForModel(this._modelId))}async _updateDataModelDeps(){this._preparing=!0;try{let e=await S(this.profile);e!==this._resolvedLanguage&&($(this._resolvedLanguage)?.disposeForModel(this._modelId),this._resolvedLanguage=e);let t=v(this._resolvedLanguage);await t.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale}),this._editorProfile=t.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0,this._resolvedLanguage=d}finally{this._preparing=!1}}_toggleSideActionBarExpanded(){this.sideActionBarExpanded=!this.sideActionBarExpanded}_toggleSidePanel(e){this.openedSidePanel=this.openedSidePanel===e?"none":e,this.openedSidePanel==="none"&&this._codeEditorElt.value?.setFocus().catch(a(this))}_onCodeEditorValueChange(e){e.stopPropagation(),this.script=e.detail,this.arcgisScriptChange.emit(e.detail)}async _onItemSelected(e){e.stopPropagation();let t=this._getSelectedTableVariable(e.detail);if(!t){this._codeEditorElt.value?.insertText(e.detail).catch(a(this));return}await t.loadSource();let i,c=t.fieldInfos.filter(s=>s.type==="geometry"&&!i?(i=s.name,!0):s.type!=="geometry").map(s=>s.name).filter(Boolean),P=`select ${c.length?c.join(", "):"*"} from ${t.snippet};`;E(this._codeEditorElt.value?.editorInstance,P,"replace","")}_getTablesVariable(){return this._editorProfile?.variables.find(l)}_getSelectedTableVariable(e){let t=this._getTablesVariable();if(l(t))return t.tableVariables.find(i=>i.snippet===e)}render(){let e=this._getTablesVariable(),t=String(this.messages.placeholderexample??"Example: {sqlQueryExample}").replace("{sqlQueryExample}","select field1, field2 from db.dataset;"),i=`${this.messages.placeholder??"Start filtering data using SQL query syntax"}
3
+ ${t}`;return o`<arcgis-code-editor-shell><arcgis-code-editor slot=editor .language=${this._resolvedLanguage} .modelId=${this._modelId} .value=${this.script??""} @arcgisValueChange=${this._onCodeEditorValueChange} .editorOptions=${{placeholder:i,...this.editorOptions}} ${m(this._codeEditorElt)}></arcgis-code-editor>${!this.hideSideBar&&o`<arcgis-editor-variables slot=side-panel .variable=${e} .heading=${this.messages.tables??"Tables"} .messageOverrides=${{profileempty:this.messages.profileempty}} .closed=${this.openedSidePanel!=="variables"} class=${b(this.openedSidePanel==="variables"?"":"hidden")} .loading=${this._preparing} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._onItemSelected} @arcgisInternalClosePanel=${()=>{this.openedSidePanel="none"}} data-panel-name=none></arcgis-editor-variables><calcite-action-bar slot=side-action-bar .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action id=tables-action .text=${this.messages.tables??"Tables"} icon=table .active=${this.openedSidePanel==="variables"} data-panel-name=variables @click=${()=>this._toggleSidePanel("variables")}></calcite-action>${!this.sideActionBarExpanded&&o`<calcite-tooltip reference-element=tables-action><span>${this.messages.tables??"Tables"}</span></calcite-tooltip>`||""}</calcite-action-bar>`||""}</arcgis-code-editor-shell>`}};f("arcgis-sql-layer-editor",n);return n},"portal/PortalItem","WebMap","WebScene","layers/FeatureLayer","applications/Components/arcadeEditorUtils","core/Error","portal/Portal",c,d,e)
@@ -1,5 +1,5 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import b from"./6XDEGPYR.js";import a from"./ZHZFKZA7.js";import{h as P}from"./T4G2IY4F.js";import{K as I}from"./INPMAY4D.js";export default $arcgis.t(([N,{B:S},{a:q,d:F,e:T,f:g,g:h,h:C,i:$,j:x,n:L,o:_,p:D}])=>{function b(t){for(let e of t){if(e instanceof L)return e;if(e.isCollection&&"variables"in e){let n=b(e.variables.filter(a=>a.type!=="group"));if(n)return n}}}function A(t,e){return`${t}:${e}`}function V(t){if(t){for(let e of t)if(e.type==="dataCatalogDatastore")return e.definition}}async function B(t){let e=new N({url:t.portal.url});return await e.load(),new q({itemId:t.id,serviceUrl:t.serviceUrl,portal:e})}async function E(t){return S(t)?await B(t):t}function K(t,e,n){let a=`**${t}**`;return e.type&&(a+=`
2
+ import b from"./UOQZCTHQ.js";import a from"./ZHZFKZA7.js";import{b as P}from"./MTIHPCIF.js";import{L as I}from"./SM3MA3KP.js";export default $arcgis.t(([N,{B:S},{a:q,d:F,e:T,f:g,g:h,h:C,i:$,j:x,n:L,o:_,p:D}])=>{function b(t){for(let e of t){if(e instanceof L)return e;if(e.isCollection&&"variables"in e){let n=b(e.variables.filter(a=>a.type!=="group"));if(n)return n}}}function A(t,e){return`${t}:${e}`}function V(t){if(t){for(let e of t)if(e.type==="dataCatalogDatastore")return e.definition}}async function B(t){let e=new N({url:t.portal.url});return await e.load(),new q({itemId:t.id,serviceUrl:t.serviceUrl,portal:e})}async function E(t){return S(t)?await B(t):t}function K(t,e,n){let a=`**${t}**`;return e.type&&(a+=`
3
3
  ${e.type}`),n&&(a+=`
4
4
  Datastore: ${n}`),{value:a}}function z(t,e){let n=`**${t.name}**`;return t.serverType&&(n+=`
5
5
  ${t.serverType}`),n+=`
@@ -0,0 +1,64 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{a as u}from"./HPZZVB4X.js";import a from"./GLJQQLP2.js";import{b as o}from"./6G5URSC7.js";import{H as i,I as m,g as p,h as l,j as t,p as v,q as r}from"./SM3MA3KP.js";export default $arcgis.t(([{e:d,f:y,g:g}])=>{var s={lines:!0,selectionMode:"none",scale:"s",oncalciteTreeSelect:e=>e.currentTarget.selectedItems.forEach(a=>a.selected=!1)},$="tree-item-metadata",f=({name:e,isMetadata:a=!1})=>t`<span class=${i(o("dictionary-property",a&&$))}>${e}</span><span class=${i(o(a&&$))}>:&nbsp;</span>`,M=({obj:e,subtree:a})=>t`<calcite-tree slot=${"children"} .lines=${s.lines} .selectionMode=${s.selectionMode} .scale=${s.scale} @calciteTreeSelect=${s.oncalciteTreeSelect}><calcite-tree-item class="string-value">${JSON.stringify(e,void 0,2)}</calcite-tree-item></calcite-tree>`,N=({value:e,subtree:a=!1})=>t`<calcite-tree slot=${(a?"children":void 0)??m} .lines=${s.lines} .selectionMode=${s.selectionMode} .scale=${s.scale} @calciteTreeSelect=${s.oncalciteTreeSelect}><calcite-tree-item><div class="tree-item-label">${f({name:"type"})}${v(e.type)}</div></calcite-tree-item><calcite-tree-item><div class="tree-item-label">${f({name:"value"})}<span class="string-value">${JSON.stringify(e,void 0,2)}</span></div></calcite-tree-item></calcite-tree>`,D=({type:e,value:a})=>{switch(e){case"unknown":case"Unknown":return t`<span class="constant-value">${e}</span>`;case"null":case"Null":return t`<span class="constant-value">null</span>`;case"text":case"String":case"Text":return t`<span class="string-value">${r(a)}</span>`;case"number":case"Number":return t`<span class="number-value">${a}</span>`;case"boolean":case"Boolean":return t`<span class="constant-value">${a}</span>`;case"date":case"Date":return t`<span class="date-value">${a}</span>`;case"dateOnly":case"DateOnly":return t`<span class="string-value">${r(a)}</span>`;case"time":case"Time":return t`<span class="string-value">${r(a)}</span>`;case"":return t`<span class="string-value">null</span>`;default:return null}},h=["boolean","date","dateOnly","null","number","text","time","unknown","Boolean","Date","DateOnly","Null","Number","Text","Time","Unknown","String",""],E=e=>h.includes(e.type);function j(e){switch(e.type){case"null":case"unknown":return{type:e.type,value:e.type};case"number":return{type:e.type,value:String(e.value)};case"boolean":return{type:e.type,value:String(e.value)};case"text":return{type:e.type,value:e.value};case"date":return{type:e.type,value:d(e)};case"dateOnly":return{type:e.type,value:y(e)};case"time":return{type:e.type,value:g(e)}}}var S="calcite-mode-dark";function C(){let e=`:host {
3
+ `,a=u["light-theme"];Object.entries(a).forEach(([c,n])=>{e+=` --arcgis-editor-${c}: ${n};
4
+ `}),e+=`}
5
+ `,e+=`:host(:state(${S})),
6
+ `,e+=`:host([calcite-mode-dark]) {
7
+ `;let b=u["dark-theme"];return Object.entries(b).forEach(([c,n])=>{e+=`
8
+ --arcgis-editor-${c}: ${n};`}),e+=`
9
+ }
10
+ `,l`
11
+ ${p(e)}
12
+ `}var B=l`
13
+ .xs {
14
+ font-size: var(--calcite-font-size-xs);
15
+ color: var(--calcite-color-text-2);
16
+ }
17
+
18
+ .breakpoint-code {
19
+ font-size: var(--calcite-font-size--2);
20
+ }
21
+
22
+ [class*="result-value-"] {
23
+ font-size: var(--calcite-font-size--2);
24
+ background-color: var(--calcite-color-foreground-1);
25
+ }
26
+
27
+ .tree-item-label,
28
+ .number-value,
29
+ .string-value,
30
+ .boolean-value {
31
+ font-family: var(--calcite-code-family);
32
+ }
33
+
34
+ .tree-item-label,
35
+ .value-type {
36
+ color: var(--calcite-color-text-2);
37
+ font-weight: var(--calcite-font-weight-normal);
38
+ }
39
+
40
+ .tree-item-metadata {
41
+ opacity: 0.7;
42
+ }
43
+
44
+ .dictionary-property {
45
+ color: var(--arcgis-editor-identifier);
46
+ }
47
+
48
+ .number-value {
49
+ color: var(--arcgis-editor-number);
50
+ }
51
+
52
+ .string-value {
53
+ color: var(--arcgis-editor-string);
54
+ white-space: pre-wrap;
55
+ }
56
+
57
+ .constant-value {
58
+ color: var(--arcgis-editor-constant);
59
+ }
60
+
61
+ .date-value {
62
+ color: var(--arcgis-editor-date);
63
+ }
64
+ `;return{a:s,b:f,c:M,d:N,e:D,f:E,g:j,h:S,i:C,j:B}},a)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import d from"./6EKA3H3N.js";import b from"./KA5TX72B.js";import"./HPZZVB4X.js";import a from"./GLJQQLP2.js";import{a as u}from"./BA546EMZ.js";import"./MJ7MJPGA.js";import"./MTIHPCIF.js";import{c,e as n}from"./6G5URSC7.js";import{G as l,K as o,h as i,j as s}from"./SM3MA3KP.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";export default $arcgis.t(([,{a:t,h:a,i:d,j:m},{h:p}])=>{var h=i`: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)}.ltr-container{direction:ltr}[class*=result-value-]{line-height:1.25rem}}`,r=class extends l{constructor(){super(...arguments),this.messages=u()}static{this.properties={debuggerStore:0,result:0}}static{this.styles=[h,m,d()]}load(){this.manager.onLifecycle(()=>{let e=c(this.el,["class"],this.updateTheme.bind(this));return this.updateTheme(),()=>e()})}willUpdate(e){e.has("result")&&this.result&&this.debuggerStore?.lazyTreeState.reset()}updateTheme(){n(this.el)==="dark"?this.elementInternals.states.add(a):this.elementInternals.states.delete(a)}render(){if(!this.result)return s`<span class="disabled-state-text">${this.messages.nooutput??"No output available."}</span>`;let e=this.debuggerStore?.lazyTreeState;return e?s`<calcite-tree .scale=${t.scale} @calciteTreeSelect=${t.oncalciteTreeSelect} .lines=${t.lines} .selectionMode=${t.selectionMode}>${p({expanded:!0,name:this.result.arcadeType,value:this.result,messages:this.messages,path:this.result.arcadeType,lazyTreeState:e})}</calcite-tree>`:s`<span class="disabled-state-text">${this.messages.nooutput??"No output available."}</span>`}};o("arcgis-arcade-debugger-output",r);return r},a,b,d)
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{c as P,e as O}from"./MTIHPCIF.js";import{a as b,b as y,c as u,d as m,e as E,f as x,m as f,o as C}from"./SM3MA3KP.js";var w=e=>(...n)=>{let t=m(),o=new e(...n),s=o.exports;u(t.at(-1));let r=o.component.manager;r.W(o,s),o.watchExports(r.W.bind(r,o)),E(o);let a=[o.component,...t].reverse();return f(a,i=>i===void 0?void 0:A(o,i,s),s)},A=(e,{host:n,key:t,isReactive:o},s)=>{let r=n,a=r[t]!==e.exports,i=r[t]!==s,c=s!==e.exports;if(a&&!i&&c&&(r[t]=e.exports),n===e.component){if(o){let p=e.component.manager;i&&p.W(e,r[t]),e.onUpdate(h=>{if(h.has(t)){let g=r[t];g!==e.exports&&p.W(e,g)}})}e.O=o?void 0:t}let d=e.component.constructor.elementProperties.get(t)?.readOnly;e.watchExports(()=>{r[t]!==e.exports&&(d?x(()=>{r[t]=e.exports}):r[t]=e.exports)})};var L=e=>D(void 0,e);var v=class extends C{constructor(n,t){super(n);let o=this.exports;try{y(this.component);let s=t(this.component,this),r=this.exports!==o;if(b(s)){r||this.setProvisionalExports(s);let a=s.then(i=>{this.exports=i,super.catchUpLifecycle()}).catch(i=>{this.P.reject(i)});this.onLoad(async()=>await a)}else(!r||s!==void 0)&&(this.exports=s),queueMicrotask(()=>super.catchUpLifecycle())}catch(s){this.P.reject(s)}}catchUpLifecycle(){}},D=w(v);var G=L;var $=e=>(n={})=>L((t,o)=>{let s=P(t.el),r={_lang:s.lang,_t9nLocale:s.t9nLocale,_loading:!0},a=t;o.onLifecycle(()=>O(t.el,()=>e("./assets"),({t9nLocale:c,t9nStrings:l,lang:d})=>{let p={...l,_lang:d,_t9nLocale:c,_loading:!1};o.exports=p;let h=l.componentLabel;typeof h=="string"&&"label"in t&&t.label==null&&(t.label??=h),i(a.messageOverrides)},n.name));let i=c=>{let l=o.exports,d=l._original??l,p=_(d,c);c&&(p._original=d),o.exports=p};return"messageOverrides"in a&&o.onUpdate(c=>{c.has("messageOverrides")&&i(a.messageOverrides)}),n.blocking?(o.setProvisionalExports(r,!1),o.ready):r}),_=(e,n)=>{if(!n)return e;let t={...e};return Object.entries(n).forEach(([o,s])=>{e[o]!==void 0&&(typeof s=="object"?t[o]=_(e[o],s):t[o]=s??e[o])}),t};export{G as a,$ as b};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{c as g,f as u}from"./6G5URSC7.js";import{a as c}from"./BCUUVBXH.js";var f="ar,bg,bs,ca,cs,da,de,el,en,es,et,fi,fr,he,hr,hu,id,it,ja,ko,lt,lv,nl,nb,no,pl,pt-BR,pt-PT,ro,ru,sk,sl,sr,sv,th,tr,uk,vi,zh-CN,zh-HK,zh-TW".split(","),L=new Set(f),i="en",$={pt:"pt-BR",nb:"no",nn:"no",zh:"zh-CN"},b=async(n,o,r="")=>{let e=`${o}/${r}`,t=`${e}${n}.json`;return l[t]??(l[t]=p(n,e)),await l[t]},l={},p=async(n,o)=>{let r=`${o}${n}.json`;try{let e=await fetch(r);if(e.ok)return await e.json()}catch(e){return c("error","intl",`An unknown error occurred while fetching localization strings at ${r}`,{detail:{error:e}}),{}}return n===i?{}:await p(i,o)},k=n=>{let o=u(n,"lang",globalThis.navigator?.language||i);return{lang:o,t9nLocale:h(o)}},h=n=>{let[o,r]=n.split("-"),e=o.toLowerCase(),t=e;return r&&(t=`${e}-${r.toUpperCase()}`),t=$[t]??t,L.has(t)?t:r?h(e):i},C=(n,o,r,e)=>{let t,s=()=>v(n,o(),e).then(a=>{(t?.lang!==a.lang||t.t9nLocale!==a.t9nLocale||t.t9nStrings!==a.t9nStrings)&&r(a),t=a}).catch(a=>{c("error","intl","Error updating component locale state",{detail:{error:a}})});return queueMicrotask(s),g(n,["lang"],s)},v=async(n,o,r=n.localName.split("-").slice(1).join("-"))=>{let{lang:e,t9nLocale:t}=k(n),s=`${o}/${r}/t9n`,d=r===null?{}:await b(t,s,"messages.");return{lang:e,t9nLocale:t,t9nStrings:d}};export{L as a,b,k as c,h as d,C as e};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import{a as O,c as u,d as k}from"./SMAQD57G.js";import i from"./6HL5GBWZ.js";import h from"./I22MLDO4.js";import e from"./BKBBI4SA.js";import d from"./XBM4ZDJT.js";import c from"./UOQZCTHQ.js";import a from"./ZHZFKZA7.js";import"./QMNQFBIA.js";import"./OSG5CFY4.js";import{a as N}from"./ER2MKLVA.js";import"./HPZZVB4X.js";import{a as C}from"./MP6Z45SA.js";import"./IFNCCZ7O.js";import{a as E}from"./MJ7MJPGA.js";import"./MTIHPCIF.js";import{a as S,c as T,e as w}from"./6G5URSC7.js";import"./6C52UOYL.js";import{G as v,K as b,L as y,h as g,i as f,j as n}from"./SM3MA3KP.js";import{b as _}from"./BCUUVBXH.js";import"./B3UMUBOI.js";import"./CF3TERM3.js";import"./Z5ZZ36DQ.js";import"./LLPQEURF.js";import"./3TTFCHAA.js";export default $arcgis.t(([,,,{a:L},,{b:c,d: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)