@arcgis/coding-components 5.2.0-next.97 → 5.2.0-next.99
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/FPSCELQQ.js +4 -0
- package/dist/cdn/{6W3EJ7HM.js → PU5GFLJW.js} +1 -1
- package/dist/cdn/WLWSPMNE.js +2 -0
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/utils.js +60 -58
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +17 -17
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +6 -6
- package/dist/cdn/BOXPGZVW.js +0 -4
- package/dist/cdn/SS6P7ONZ.js +0 -2
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{a as _}from"./5KM3AKLY.js";import e from"./WLWSPMNE.js";import c from"./WBN7AYGG.js";import b from"./MXOZNCTB.js";import{c as se,d as oe}from"./7VS5GHCL.js";import a from"./H5EGZU2S.js";import{d as ne}from"./MZMKV7FA.js";import{a as ie}from"./SGH4ISZJ.js";import"./CNEKU4E5.js";import"./BHSILWSL.js";import"./J4I4EROF.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import"./CMRUQ3BN.js";import"./UFF53OEH.js";import"./NHREAORV.js";import{F as X,G as K,H as Z,I as ee,J as M,L as te,h as j,j as d,k as H,l as V,t as G,x as J,y as Y,z as W}from"./7CO7POPG.js";import{a as w}from"./BFPEJYVB.js";import"./DSQ2DQQL.js";import"./H6RQVSYM.js";export default $arcgis.t(([Se,re,Te,ce,le,{getDeclaredVoxelMembers:Ae,getDeclaredPixelMembers:Ce},Ie,{property:b,subclass:Me},{G:q,w:ae,x:F},,P,{b:N}])=>{var C=class extends W{constructor(e){if(super(e),this.it=V,e.type!==J.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===V||e==null)return this._t=void 0,this.it=e;if(e===H)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}};C.directiveName="unsafeHTML",C.resultType=1;var I=Y(C);var Ee=j`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-dialog{--calcite-dialog-content-space: initial;--calcite-dialog-size-y: initial}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,$=class extends Error{constructor({message:e,code:t,subCode:a,details:o,source:n}){super(e),this.name="ArcadeAssistantError",this.code=t,this.subCode=a,this.details=o,this.source=n}};function de(i){if(!i)return;let e=i.indexOf('{"error":');if(e!==-1)try{let t=i.slice(e),a=JSON.parse(t);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Re(i){let{baseUrl:e,skillId:t,message:a,authToken:o,previousConversationId:n,context:r}=i,p=t?`${e}/skills/${t}/chat`:`${e}/chat`,c=[],s={message:a,context:r};n&&(s.conversation_id=n);let u;try{u=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(s),responseType:"json"})}catch(f){let v=f,S=v.details?.rawResponse||v.message||String(f),T=de(S);throw T?new $(T):f}let l=u.data;c.push(l);let h=l.conversationId,k=l.inquiryId,x=l.sequenceNumber;async function E(){let f=0,v=100;for(;f<v;){await new Promise(A=>setTimeout(A,1e3));let S=Ve(h,x,k),T;try{T=await re(p,{method:"post",headers:{"Content-Type":"application/json","X-Esri-Authorization":`Bearer ${o}`},body:JSON.stringify(S),responseType:"json"})}catch(A){let B=A,xe=B.details?.rawResponse||B.message||String(A),Q=de(xe);throw Q?new $(Q):A}let y=T.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(c.push(y),x=y.sequenceNumber,f++,!y.hasMore)break}if(f===v)throw new $({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let R=120*1e3;return await Promise.race([E(),new Promise((f,v)=>setTimeout(()=>v(new $({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),R))]),c}function Ve(i,e,t){return{conversationId:i,inquiryId:t,ackSequenceNumber:e}}function Fe(i){return i.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":i.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":i.message}var qe=({notices:i})=>i.length?d`<div class="border-block-end">${_(i,e=>e.id??e.title,e=>d`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&d`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&d`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Pe=i=>{let e=i.value.length,t=72,a=180,o=i.offsetWidth,n=Math.max(1,Math.floor(o/8)),r=Math.ceil(e/n),p=t+(r-2)*24;i.style.setProperty("--calcite-text-area-min-height",`${Math.min(p,a)}px`)},Ne=({promptValidationMessage:i,errorMessage:e,contextTooBig:t,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:o,setErrorMessage:n,messages:r})=>{let p=[];if(i&&p.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:i,closable:!0}),e&&p.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),t&&!a){let c=r.contextreduced??"Context reduced",s=r.contextreducedmessage??"The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";p.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:s,closable:!0,onClose:()=>o(!0)})}return p};function _e({messages:i}){return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${i.beta??"Beta"}>${i.beta??"Beta"}</calcite-chip>`}function De({popoverContent:i,messages:e}){return d`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer??"Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${i}</div></calcite-popover>`}function Ue({errorMessage:i,slot:e}){return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??M}>${i}</calcite-input-message></div>`}function Oe({active:i,setActive:e,messages:t}){return d`<calcite-alert slot=alerts .open=${i} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${t.expressionapplied??"Expression applied"}><div slot=message>${t.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function ze({context:i,messages:e}){return i?d`<div class="gaps">${i.profileId&&d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function Le({isDisabled:i,isReadOnly:e,setQuestion:t,setIsViewingResult:a,textAreaRef:o,question:n,errorMessage:r,setErrorMessage:p,promptValidationMessage:c,setPromptValidationMessage:s,submitQuestion:u,messages:l,mode:h,assistantRef:k,context:x,contextReducedNoticeDismissed:E,setContextReducedNoticeDismissed:R}){let f=x?.contextTooLarge??!1,v=Ne({promptValidationMessage:c,errorMessage:r,contextTooBig:f,contextReducedNoticeDismissed:E,setContextReducedNoticeDismissed:R,setErrorMessage:p,messages:l});return d`<div class="text-area-wrapper">${qe({notices:v})}<calcite-text-area scale=s resize=vertical .readOnly=${i||e} class=${ee(v.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${l.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${S=>{Pe(S.target),t(S.target.value)}} ${K(o)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${x&&ze({context:x,messages:l})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${i} @click=${async()=>{a(!1),t("")}} .label=${l.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${l.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${h!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${i} @click=${async()=>{a(!1),t("")}} class="hidden-below-380" scale=s>${l.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-below-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${i} .disabled=${i} id=small-submit-button @click=${async()=>{if(p(""),!n){s(l.enteraprompt??"Please enter a prompt");return}s(void 0),await u()}} class="hidden-above-380" .label=${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${h==="prompt"?l.ask??"Generate":l.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var Be="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function je({setOpen:i,messages:e,feedback:t,learnMoreUrl:a,setFeedback:o,onSubmit:n}){return t.active?d`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${t.active} @calciteSheetClose=${()=>i(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${t.text} @calciteTextAreaInput=${r=>o({...t,text:r.target.value})} .disabled=${t.submitting} .placeholder=${e.donotincludepersonalinfo??"Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${t.termsAccepted} @calciteCheckboxChange=${r=>{o({...t,termsAccepted:r.target.checked})}} .disabled=${t.submitting}></calcite-checkbox><span>${I((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Qe} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${Be} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${I((e.feedbackhelps??"Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}",`<calcite-link href=${a} target="_blank">${e.learnmore??"Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${()=>i(!1)} .disabled=${t.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!t.termsAccepted||t.submitting} .loading=${t.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function pe({promptingEnabled:i,messages:e,slot:t,helpTopicUrl:a}){return d`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${t??M} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing??"Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new??"New"} kind=brand scale=s>${e.new??"New"}</calcite-chip></div>${i?d`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${I((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${a} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:d`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function He({messages:i,onProceed:e,onExit:t,helpTopicUrl:a}){return d`<calcite-dialog close-disabled placement=top .heading=${i.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${i.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${i.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${I((i.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${a} target="_blank">${i.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${i.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${t} kind=neutral>${i.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ge({messages:i,suggestions:e,onSuggestionClick:t}){return d`<calcite-block .heading=${i.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(a=>d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${i.promptsuggestion} class="suggestion-button" @click=${()=>t?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var ue=200;function me({hidden:i=!1,expanded:e=!1,messages:t,cards:a,heading:o,collapsible:n=!1,showEffectsIcon:r=!1,onCopyCode:p,standalone:c}){return d`<calcite-block .hidden=${i} id=result-block .heading=${o??t.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${r&&d`<calcite-chip .label=${t.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${t.assistantresponses??"Assistant responses"}>${_(a,s=>s.conversationId,s=>d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${s.priorPrompt.length>ue?`${s.priorPrompt.slice(0,ue)}...`:s.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} @click=${u=>{let l=u.currentTarget;navigator.clipboard.writeText(s.priorPrompt).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${s.message&&c&&d`<div class="response-error-container">${Ue({errorMessage:s.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${t.responsecontext??"Response Context"} scale=s>${s.message&&!c&&d`<calcite-tooltip .referenceElement=${`response-chip-${s.conversationId}-error`} placement=top-start>${s.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${s.conversationId}-error`} .label=${t.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${Je({card:s,messages:t})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${s.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${()=>s.onAddToEditor("add")} scale=s icon-start=plus round .label=${t.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${s.conversationId}-${c?"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}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${s.conversationId}-${c?"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 l=u.currentTarget;p(s.code).then(()=>{l.setAttribute("data-copied","true"),setTimeout(()=>l.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${t.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${t.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${t.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${t.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${s.onThumbsUp} .id=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${t.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${s.onThumbsDown} .id=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${s.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${t.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var Je=({card:i,messages:e})=>{let t=G(),a=`response-chip-profile-${i.conversationId}-${t}`,o=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",i.profileId);return d`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${o}</calcite-tooltip><calcite-chip .label=${i.profileId} scale=s appearance=outline icon=map-information id=${a??M}>${i.profileId}</calcite-chip>`},he=i=>i.type==="featureSet";function $e(i){return i&&i!=="dataCatalogDatastore"?i:void 0}var D=i=>{if(!ae(i))return[];let e=[];return i.relationships?.forEach(t=>{e.push(t.toJSON())}),e},U=i=>i.length>0?{relationships:i}:{},Ye=i=>ne(i).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),O=i=>i?{fields:Ye(i)}:{fields:[]};async function ge(i){let e=await i.loadSource(),t=F(e)&&e.isTable,a=D(e);return{name:i.name,type:"featureSet",isTable:t,...O(e?.fields),...U(a)}}async function ke(i){switch(i.type){case"feature":{let t=await i.loadSource(),a=D(t);return{name:i.name,type:i.type,...O(t?.fields),...U(a)}}case"featureSet":{let t=await i.loadSource(),a=F(t)&&t.isTable;return{name:i.name,type:"featureSet",...a?{isTable:a}:{},...O(t?.fields),...U(D(t))}}case"featureSetCollection":{let t=await i.loadSource(),a=t?.layers.filter(he)??[],o=t?.tables.filter(he)??[],n=await Promise.all(a.map(ge)),r=await Promise.all(o.map(ge));return{name:i.name,type:"featureSetCollection",layers:n,tables:r}}case"dictionary":{let t=await Promise.all(i.dictionaryVariables.filter(q).map(ke));return{name:i.name,type:"dictionary",attributes:t}}case"pixel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"pixel"};let a=await Ce(t);return{name:i.name,type:"pixel",members:a.map(be)}}case"voxel":{let t=await i.loadSource();if(!t)return{name:i.name,type:"voxel"};let a=await Ae(t);return{name:i.name,type:"voxel",members:a.map(be)}}case"array":let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:i.name,type:i.type}}}function be(i){if(i.type==="array"){let e=$e(i.elementType.type);return{name:i.name,type:"array",...e?{elementType:e}:{}}}return{name:i.name,type:i.type}}async function We(i){return{variables:await Promise.all(i.variables.filter(q).map(ke))}}var Xe=1e5;function Ke(i){let e=new TextEncoder().encode(i).length;return Math.ceil(e/3.5)}function z(i){return Ke(JSON.stringify(i))}function Ze(i){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),t=a=>{switch(a.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:a.name,type:a.type,..."isTable"in a&&a.isTable?{isTable:a.isTable}:{},..."relationships"in a?{relationships:a.relationships}:{}};case"featureSetCollection":return{name:a.name,type:"featureSetCollection",layers:a.layers.map(e),tables:a.tables.map(e)};case"dictionary":return{name:a.name,type:"dictionary",attributes:a.attributes.map(t)};case"pixel":case"voxel":return{name:a.name,type:a.type};case"array":return{name:a.name,type:"array",...a.elementType?{elementType:a.elementType}:{}};default:return a}};return{variables:i.variables.map(t)}}function et(i){let e=i.variables,t=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],o=a?[a]:[];return{context:{variables:o},wasReduced:t!==o.length,reducedToVariableName:a?.name}}function tt(i){return z(i)>Xe}var it=Object.defineProperty,at=Object.getOwnPropertyDescriptor,g=(i,e,t,a)=>{for(var o=a>1?void 0:a?at(e,t):e,n=i.length-1,r;n>=0;n--)(r=i[n])&&(o=(a?r(e,t,o):r(o))||o);return a&&o&&it(e,t,o),o},m=class extends Ie{constructor(i){super(i),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};g([b()],m.prototype,"viewMode",2);g([b()],m.prototype,"confirmationActive",2);g([b()],m.prototype,"contextReducedNoticeDismissed",2);g([b()],m.prototype,"splashActive",2);g([b()],m.prototype,"isSubmitting",2);g([b()],m.prototype,"errorMessage",2);g([b()],m.prototype,"promptValidationMessage",2);g([b()],m.prototype,"question",2);g([b()],m.prototype,"history",2);g([b()],m.prototype,"feedback",2);g([b()],m.prototype,"context",2);m=g([Me("ArcadeAssistantViewState")],m);var st="arcade_generation",ot="ArcadeCodeRequest",fe="visualization",ve="ArcadeAssistant",nt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras","conversation_id","privacy_statement"],ye=[],we=!0,L=class extends Z{constructor(){super(...arguments),this.textAreaRef=X(),this.messages=ie(),this._feedbackService=void 0,this.viewState=new m,this.handleFeedbackButton=(e,t)=>{this.updateViewState({feedback:{active:!0,value:e,item:t,termsAccepted:!1,text:"",submitting:!1}})},this.handleFeedbackSheetClose=()=>{this.updateViewState({feedback:{active:!1}})},this.handleFeedbackSubmit=async()=>{if(!this.viewState.feedback.active)return;this.updateViewState({feedback:{...this.viewState.feedback,submitting:!0}});let e=await this.ensureFeedbackService();if(!e){this.handleFeedbackSheetClose();return}let t=!1,a;if(this.viewState.feedback.item.isCurrentResult&&this.viewState.viewMode==="result"){let h=this.viewState.context??await this.getProfileAndMetadata(this.getModel()?.uri??""),k=this.viewState.feedback.item.contextSnapshot;a={...h,editor_code:k?.editor_code??"",diagnostics:k?.diagnostics,runtime:k?.runtime??N()},t=!0}else a=this.viewState.feedback.item.contextSnapshot;let o=ce.applicationName;!o&&!this.appVersion&&w("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:n,text:r,termsAccepted:p,item:{question:c,formattedScript:s,conversationId:u}}=this.viewState.feedback,l={user_evaluation:n,your_comments:r||void 0,question:c??"",answer:this.encodeForFeedback(s),useragent:navigator.userAgent,_source:ve,version:this.appVersion||o||"NOT_SET",context:a?JSON.stringify({...a,editor_code:this.encodeForFeedback(a.editor_code),isSnapshot:!t}):"",extras:a?.profileId??"",conversation_id:u??"",privacy_statement:p?"I_agree":""};try{await e.applyEdits({addFeatures:[new le({attributes:l})]})}catch(h){w("error",this,"Error submitting feedback.",{detail:{error:h}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.promptingEnabled=!1,this.closed=!1,this.disableQuestionAnswerLogging=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,promptingEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1,diagnostics:0,disableQuestionAnswerLogging:5}}static{this.styles=Ee}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
|
|
3
|
+
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}async openPrompt(e){if(this.closed=!1,!this.promptingEnabled)return;e&&this.updateViewState({question:e,viewMode:"prompt"});let t=this.textAreaRef.value;t&&t.setFocus()}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:ye,splashActive:we})}loaded(){let e=async()=>{let t=this.getModel();if(!t){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(t.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};this.manager.onLifecycle(()=>{e();let t=P.onModelContextDidChange(async()=>{e().catch(a=>{w("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{t.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),ye=this.viewState.history,we=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let t=Ze(e.metadata);return{...e,metadata:t,estimatedTokens:z(t)}}withEditorState(e,t){return{...e,editor_code:t?.getValue()??this.getModel()?.getValue()??"",diagnostics:this.diagnostics,runtime:N()}}encodeForFeedback(e){return encodeURIComponent(e??"")}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,t)=>(!t.script||(e.push({priorPrompt:t.question,code:t.formattedScript||t.error||"",profileId:t.profile??fe,onAddToEditor:a=>{se(this.editorRef.editorInstance,t.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",t),onThumbsDown:()=>this.handleFeedbackButton("bad",t),conversationId:t.conversationId??"",message:t.message}),this.viewState.viewMode),e),[])}async ensureFeedbackService(){if(this._feedbackService)return this._feedbackService;if(!this.feedbackServiceUrl)return;let e=new Te({url:this.feedbackServiceUrl});await e.load();let t=nt.filter(a=>!e.fields.some(o=>o.name===a));if(t.length>0){w("error",this,`Missing the following fields in feedback service: ${t.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}async logInteractionToFeedbackService(e){if(this.disableQuestionAnswerLogging||!e.question)return;let t;try{t=await this.ensureFeedbackService()}catch(r){w("error",this,"Error initializing feedback service for interaction logging.",{detail:{error:r}});return}if(!t)return;let a=ce.applicationName,o=e.contextSnapshot,n={question:e.question,answer:this.encodeForFeedback(e.answer),useragent:navigator.userAgent,_source:ve,version:this.appVersion||a||"NOT_SET",context:o?JSON.stringify({...o,isSnapshot:!0}):"",extras:o?.profileId??"",conversation_id:e.conversationId??"",privacy_statement:""};try{await t.applyEdits({addFeatures:[new le({attributes:n})]})}catch(r){w("error",this,"Error logging arcade assistant question/answer interaction.",{detail:{error:r}})}}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(!this.viewState.question)return;let e=this.viewState.question;this.updateViewState({isSubmitting:!0,errorMessage:void 0});let t,a;try{let o=this.getModel();if(!o||!this.serviceUrl)return;let n=this.viewState.context??await this.getProfileAndMetadata(o.uri),r=this.withEditorState(n,o);t=this.createFeedbackContextSnapshot(r);let p=await this.getToken(),c=await Re({baseUrl:this.serviceUrl,skillId:st,message:e,authToken:p,context:{kind:ot,context:{profile_id:r.profileId,metadata:[r.metadata],editor_code:r.editor_code,runtime:r.runtime,...r.diagnostics?.length?{diagnostics:r.diagnostics}:{}}}});a=c?.[0]?.conversationId;let s=c.find(u=>u.context?.kind==="ArcadeCodeResponse");if(!s){await this.logInteractionToFeedbackService({question:e,answer:"No ArcadeCodeResponse returned.",contextSnapshot:t,conversationId:a});return}if(s.context?.kind==="ArcadeCodeResponse"){let u=this.createFeedbackContextSnapshot(r),l=oe(s?.context?.arcadeCode?.code??"");this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:l,error:void 0,question:e,profile:n.profileId,conversationId:s.conversationId,isCurrentResult:!0,contextSnapshot:u,...s.message?{message:s.message}:{}},...this.viewState.history.map(h=>({...h,isCurrentResult:!1}))],viewMode:"result",errorMessage:void 0}),await this.logInteractionToFeedbackService({question:e,answer:l,contextSnapshot:t,conversationId:s.conversationId})}}catch(o){let n=o instanceof Error&&o.name==="ArcadeAssistantError"?Fe(o)||this.messages.erroroccurred||"An error occurred.":this.messages.erroroccurred||"An error occurred.";this.updateViewState({errorMessage:n}),await this.logInteractionToFeedbackService({question:e,answer:n,contextSnapshot:t,conversationId:a}),w("error",this,"Error submitting question",{detail:{error:o}})}finally{this.updateViewState({isSubmitting:!1})}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let t=fe,a=P.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let o=this.editorRef.profile;o&&"id"in o&&(t=o.id);let n=a?await We(a):{variables:[]},r=tt(n),p=r?et(n):void 0,c=p?p.context:n,s=z(c);return{profileId:t,metadata:c,contextTooLarge:r,reducedToVariableName:p?.reducedToVariableName,estimatedTokens:s}}onCopyCode(e){let t=e?`${this.disclaimerComment}
|
|
4
|
+
${e}`:"";return navigator.clipboard.writeText(t)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",t=this.getHistoryCards();return this.promptingEnabled?d`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&d`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${De({messages:this.messages,popoverContent:pe({promptingEnabled:this.promptingEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&He({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:a=>this.closePanel?.(a)})||""}${Oe({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${Le({isDisabled:this.viewState.isSubmitting,isReadOnly:!1,setQuestion:this.setQuestionState,setIsViewingResult:a=>this.updateViewState({viewMode:a?"result":"prompt"}),mode:e?"refine":"prompt",textAreaRef:this.textAreaRef,question:this.viewState.question,errorMessage:this.viewState.errorMessage,setErrorMessage:a=>this.updateViewState({errorMessage:a}),promptValidationMessage:this.viewState.promptValidationMessage,setPromptValidationMessage:a=>this.updateViewState({promptValidationMessage:a}),submitQuestion:this.submitQuestion.bind(this),assistantRef:this.el,messages:this.messages,context:this.viewState.context,contextReducedNoticeDismissed:this.viewState.contextReducedNoticeDismissed,setContextReducedNoticeDismissed:a=>this.updateViewState({contextReducedNoticeDismissed:a})})}<calcite-block-group .label=${this.messages.interactiveblocks??"interactive blocks"}>${!e&&!this.viewState.isSubmitting&&Ge({messages:this.messages,suggestions:[this.messages.prompsuggestion1??"",this.messages.prompsuggestion2??""],onSuggestionClick:this.onSuggestionClick})||""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse??"Generating response..."}></calcite-block>${me({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:t.length?[t[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${me({expanded:!e,messages:this.messages,collapsible:!0,cards:e?t.slice(1):t,heading:this.messages.recentprompts??"Recent prompts",hidden:this.viewState.isSubmitting||this.viewState.history.length===0,onCopyCode:this.onCopyCode.bind(this)})}</calcite-block-group>${this.viewState.feedback.active?je({setOpen:this.handleFeedbackSheetClose,messages:this.messages,onSubmit:this.handleFeedbackSubmit,feedback:this.viewState.feedback,setFeedback:this.setFeedbackState,learnMoreUrl:this.assistantOverviewDocUrl}):null}</calcite-shell></calcite-flow-item></calcite-flow>`:d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${pe({slot:"content-top",messages:this.messages,promptingEnabled:this.promptingEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};te("arcgis-arcade-coding-assistant",L);return L},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,e)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import i from"./DFRZVVZZ.js";import g from"./SS6P7ONZ.js";import f from"./WBN7AYGG.js";import e from"./MXOZNCTB.js";import{e as q}from"./7VS5GHCL.js";import c from"./H5EGZU2S.js";import b from"./7Z6G332Z.js";import"./MZMKV7FA.js";import a from"./2WB7S5TQ.js";import{a as W}from"./SGH4ISZJ.js";import{a as U}from"./CNEKU4E5.js";import"./BHSILWSL.js";import"./J4I4EROF.js";import{a as Y,b as J,c as y}from"./CLPF64WZ.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import{a as H}from"./CMRUQ3BN.js";import"./UFF53OEH.js";import"./NHREAORV.js";import{F as B,G as C,H as O,I as P,L as z,M as K,h as F,j as d,l as k,n as w,t as N}from"./7CO7POPG.js";import{b as h}from"./BFPEJYVB.js";import{ml as V,pl as R,ul as G}from"./DSQ2DQQL.js";import"./H6RQVSYM.js";export default $arcgis.t(([{watch:L},x,{property:c,subclass:S},{a:Q,h:f,i:T},{b:I},,,A,{a:j},{a:X,b:Z}])=>{var te=F`: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}.bottom-action-bar{display:flex;.bottom-action-bar__actions{flex:1 1 auto;min-inline-size:0}}`,se=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,m=(s,e,t,i)=>{for(var a=i>1?void 0:i?ie(e,t):e,r=s.length-1,n;r>=0;r--)(n=s[r])&&(a=(i?n(e,t,a):n(a))||a);return i&&a&&se(e,t,a),a},ee=100,g=class extends x{constructor(s){super(s),this.collectionItems=[],this.errorMessage="",this.expanded=!1,this.requestId=0,this.status="idle",this.visibleChildCount=ee}};m([c()],g.prototype,"collectionItems",2);m([c()],g.prototype,"errorMessage",2);m([c()],g.prototype,"expanded",2);m([c()],g.prototype,"requestId",2);m([c()],g.prototype,"schemaValue",2);m([c()],g.prototype,"status",2);m([c()],g.prototype,"visibleChildCount",2);g=m([S("ArcadeDebuggerLazyTreeNodeState")],g);var D=class extends x{constructor(s){super(s),this.generation=0,this.nodes=new Map}reset(){this.generation+=1,this.destroyNodes()}ensureNode(s,e=!1,t){let i=this.nodes.get(s);if(i)return i;let a=new g;return a.expanded=e,this.nodes.set(s,a),e&&t&&this.loadNode(s,t),a}setExpanded(s,e,t){let i=this.ensureNode(s,e,t);if(i.expanded===e){e&&t&&this.loadNode(s,t);return}i.expanded=e,e&&t&&this.loadNode(s,t)}showMore(s,e){let t=this.ensureNode(s);t.visibleChildCount>=e||(t.visibleChildCount=Math.min(e,t.visibleChildCount+ee))}loadNode(s,e){switch(e.kind){case"collection":this.runLoad(s,e.load,(t,i)=>{t.collectionItems=i});return;case"schema":this.runLoad(s,e.load,(t,i)=>{t.schemaValue=i});return}}runLoad(s,e,t){let i=this.nodes.get(s);if(!i||i.status==="loading"||i.status==="loaded")return;let a=this.generation,r=i.requestId+1;i.requestId=r,i.status="loading",i.errorMessage="",i.schemaValue=void 0,i.collectionItems=[],e().then(n=>{let o=this.nodes.get(s);!o||this.generation!==a||o.requestId!==r||(t(o,n),o.status="loaded")}).catch(()=>{let n=this.nodes.get(s);!n||this.generation!==a||n.requestId!==r||(n.status="error")})}destroyNodes(){for(let s of this.nodes.values())s.destroy();this.nodes.clear()}};D=m([S("ArcadeDebuggerLazyTreeState")],D);var ae=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,l=(s,e,t,i)=>{for(var a=i>1?void 0:i?ne(e,t):e,r=s.length-1,n;r>=0;r--)(n=s[r])&&(a=(i?n(e,t,a):n(a))||a);return i&&a&&ae(e,t,a),a},b=class extends x{constructor(s){super(s),this.phase="idle",this.sessionId=0,this.consoleLogs=[],this.hasExecuted=!1}get isExecuting(){return this.phase==="running"||this.phase==="debug-running"||this.phase==="debug-paused"}get isDebugging(){return this.phase==="debug-running"||this.phase==="debug-paused"}get isPaused(){return this.phase==="debug-paused"}get runResult(){return this.result?.resultType==="run"?this.result.result:void 0}get debugResult(){return this.result?.resultType==="debug"?this.result.result:void 0}get executionTiming(){return this.result?.timing}addConsoleLog(s){this.consoleLogs=[...this.consoleLogs,s]}};l([c()],b.prototype,"phase",2);l([c()],b.prototype,"mode",2);l([c()],b.prototype,"sessionId",2);l([c()],b.prototype,"result",2);l([c()],b.prototype,"consoleLogs",2);l([c()],b.prototype,"hasExecuted",2);b=l([S("ArcadeDebuggerExecutionModel")],b);var $=class extends x{constructor(s){super(s),this.editorBreakpoints=[],this.executionBreakpoints=[]}setBreakpoints(s,e){s==="editor"?this.editorBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i):this.executionBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i)}toggleBreakpoint(s,e){let t=new Set(s==="editor"?this.editorBreakpoints:this.executionBreakpoints);t.has(e)?t.delete(e):t.add(e),this.setBreakpoints(s,t)}clearBreakpoints(s){s==="editor"?this.editorBreakpoints=[]:this.executionBreakpoints=[]}syncExecutionBreakpointsFromEditor(){this.executionBreakpoints=this.editorBreakpoints}};l([c()],$.prototype,"editorBreakpoints",2);l([c()],$.prototype,"executionBreakpoints",2);$=l([S("ArcadeDebuggerSessionModel")],$);var E=class extends x{constructor(s){super(s),this.openedPanel="output",this.showPanel=!1}};l([c()],E.prototype,"openedPanel",2);l([c()],E.prototype,"showPanel",2);E=l([S("ArcadeDebuggerUiModel")],E);var v=class extends x{constructor(s){super(s)}get line(){return this.pausedState?.line}clearPausedState(){this.lastPausedState=this.pausedState,this.pausedState=void 0}reset(){this.pausedState=void 0,this.lastPausedState=void 0}setPausedState(s){this.pausedState=s,this.lastPausedState=s}};l([c()],v.prototype,"pausedState",2);l([c()],v.prototype,"lastPausedState",2);v=l([S("ArcadeDebuggerPausedFrameModel")],v);var p=class extends x{constructor(s){super(s),this.execution=new b,this.lazyTreeState=new D,this.pausedFrame=new v,this.previewTabsState=new I,this.session=new $,this.ui=new E}get editorBreakpoints(){return this.session.editorBreakpoints}get debuggerBreakpoints(){return this.isPaused?this.session.executionBreakpoints.map(s=>({line:s})):this.session.editorBreakpoints.map(s=>({line:s}))}get executionBreakpoints(){return this.session.executionBreakpoints}get consoleLogs(){return this.execution.consoleLogs}get debug(){if(!(!this.pausedFrame.pausedState&&!this.pausedFrame.lastPausedState))return{pausedState:this.pausedFrame.pausedState,lastPausedState:this.pausedFrame.lastPausedState}}get debugResult(){return this.execution.debugResult}get executionTiming(){return this.execution.executionTiming}get debuggerLine(){return this.pausedFrame.pausedState?.line}get executionState(){return this.pausedFrame.pausedState}get hasExecuted(){return this.execution.hasExecuted}get isDebugging(){return this.execution.isDebugging}get isExecuting(){return this.execution.isExecuting}get isPaused(){return this.execution.isPaused}get mode(){return this.execution.mode}get openedPanel(){return this.ui.openedPanel}get outputRenderer(){if(this.execution.result)return this.execution.result.resultType==="debug"?"debugger":"legacy"}get phase(){return this.execution.phase}get result(){return this.execution.result}get runResult(){return this.execution.runResult}get sessionId(){return this.execution.sessionId}get showPanel(){return this.ui.showPanel}addConsoleLog(s){this.execution.addConsoleLog(s)}clearBreakpoints(s){this.session.clearBreakpoints(s)}clearForMissingTestData(){this.stopDebug({hidePanel:!0}),this.execution.hasExecuted=!1,this.execution.result=void 0}closePanel(){this.ui.showPanel=!1}completeDebug(s,e){this.execution.mode="debug",this.execution.result={resultType:"debug",result:s,...e?{timing:e}:{}},this.execution.phase="completed",this.ui.openedPanel="output",this.pausedFrame.reset(),this.resetTransientDebuggerState()}completeRun(s,e={}){this.execution.mode="run",!e.useDebugRenderer&&f(s)?this.execution.result={resultType:"run",result:s}:e.useDebugRenderer&&!f(s)&&(this.execution.result={resultType:"debug",result:s,...e.timing?{timing:e.timing}:{}}),this.execution.phase="completed",this.pausedFrame.reset(),this.ui.openedPanel="output",this.resetTransientDebuggerState()}continueDebug(){let s=this.pausedFrame.pausedState?.continue;s&&(this.execution.phase="debug-running",this.pausedFrame.clearPausedState(),s.resolve())}disableDebugger(){this.stopDebug({hidePanel:!0}),this.clearBreakpoints("execution"),this.clearBreakpoints("editor")}fail(s){this.completeRun(s)}pauseDebug(s){let e=this.pausedFrame.pausedState??this.pausedFrame.lastPausedState;this.syncPausedState(e,s),this.pausedFrame.setPausedState(s),this.execution.phase="debug-paused"}reset(){this.execution.phase="idle",this.execution.mode=void 0,this.execution.result=void 0,this.execution.consoleLogs=[],this.execution.hasExecuted=!1,this.execution.sessionId=0,this.ui.openedPanel="output",this.ui.showPanel=!1,this.pausedFrame.reset(),this.clearBreakpoints("execution"),this.clearBreakpoints("editor"),this.replaceTransientDebuggerState()}resetDebug(){this.stopDebug({hidePanel:!1}),this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="debug-console"}disconnect(){this.stopDebug({hidePanel:!0})}setBreakpoints(s){this.session.setBreakpoints("editor",s)}setPanel(s){this.execution.hasExecuted&&(this.ui.openedPanel=s,this.ui.showPanel=!0)}startDebug(){return this.execution.mode="debug",this.execution.phase="debug-running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.session.syncExecutionBreakpointsFromEditor(),this.execution.consoleLogs=[],this.ui.openedPanel="debug-console",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}startRun(){return this.execution.mode="run",this.execution.phase="running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="output",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}stopDebug({hidePanel:s=!0,invalidateSession:e=!0}={}){let t=this.pausedFrame.pausedState?.continue;e&&(this.execution.sessionId+=1),this.execution.phase=this.execution.hasExecuted?"completed":"idle",this.pausedFrame.reset(),this.resetTransientDebuggerState(),s&&(this.ui.showPanel=!1),this.ui.openedPanel==="debug-console"&&(this.ui.openedPanel="output"),t?.resolve()}syncPausedState(s,e){this.lazyTreeState.reset(),s&&e&&s!==e&&this.previewTabsState.invalidateAll(),this.pausedLine=e?.line}toggleBreakpoint(s){this.session.toggleBreakpoint("editor",s)}togglePanel(s){if(this.execution.hasExecuted){if(s==null){this.ui.showPanel=!this.ui.showPanel;return}if(this.ui.openedPanel===s&&this.ui.showPanel){this.ui.showPanel=!1;return}this.setPanel(s)}}resetTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState.reset(),this.previewTabsState.clear()}replaceTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState=new D,this.previewTabsState=new I}};l([c()],p.prototype,"execution",2);l([c()],p.prototype,"lazyTreeState",2);l([c()],p.prototype,"pausedLine",2);l([c()],p.prototype,"pausedFrame",2);l([c()],p.prototype,"previewTabsState",2);l([c()],p.prototype,"session",2);l([c()],p.prototype,"ui",2);p=l([S("ArcadeDebuggerStore")],p);var oe={glyphMargin:!0,lineNumbersMinChars:1},M=class extends O{constructor(){super(...arguments),this._codeEditorElt=B(),this._arcadeAssistantElt=B(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this._debuggerState=new p,this.messages=W(),this._modelId=N(),this._openArcadeHelp=()=>{window.open(Q,"Arcade Help")},this._decorations=void 0,this._monacoEditor=U(H),this._editorOptions={},this._toggleSidePanel=e=>{e.currentTarget instanceof HTMLElement&&this._setOpenedSidePanel(e.currentTarget.dataset.panelName??"none")},this._closeSidePanel=()=>{this._setOpenedSidePanel("none")},this._updateBreakpointsDecorations=()=>{let e=this.editorInstance;if(!e)return;let t=this._debuggerState.editorBreakpoints.map(i=>({range:new R(i,1,i,1),options:{isWholeLine:!0,glyphMarginClassName:"arcgis-code-editor__breakpoint-glyph",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}));this._decorations?.clear(),this._decorations=e.createDecorationsCollection(t)},this._clearDebuggerDecorations=()=>{this._decorations?.clear(),this._decorations=void 0,this._debuggerPausedLineDecoration?.clear(),this._debuggerPausedLineDecoration=void 0},this._debuggerPausedLineDecoration=void 0,this._preparingArcade=!1,this._arcadeAssistantRemoteState={shouldRender:!1},this._diagnostics=[],this.enableDebugger=!1,this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.disableAssistant=!1,this.arcgisDiagnosticsChange=w({bubbles:!1}),this.arcgisScriptChange=w({bubbles:!1})}static{this.properties={_apiLibrary:16,_editorProfile:16,_preparingArcade:16,_arcadeAssistantRemoteState:16,_diagnostics:16,editorInstance:32,editorOptions:0,enableDebugger:5,hideDocumentationActions:5,hideSideBar:5,messageOverrides:0,openedSidePanel:3,profile:0,script:1,sideActionBarExpanded:7,snippets:0,suggestions:0,testData:0,customPanels:0,disableAssistant:5,arcadeAssistant:0,externalExecutor:0}}static{this.styles=[te]}get _canExecute(){return!!(this.testData||this.externalExecutor)}get _usesBottomExecutionDrawer(){return this._canExecute&&(this.enableDebugger||!!this.externalExecutor)}get editorInstance(){return this._codeEditorElt.value?.editorInstance}get editorOptions(){return{...oe,...this._editorOptions}}set editorOptions(e){this._editorOptions=e??{}}async getTestResult(){if(!this.testData)return{type:"error",value:"Missing test data",error:null};let e=await this._editorProfilePromise;if(!e)return{type:"error",value:"Missing editor profile",error:null};await this._componentReadyDefer.promise;let t=this._codeEditorElt.value?.value,i=await T(e.definition,t,this.testData,{mode:"run"});return f(i)?i:{type:"error",value:"Unexpected debug result",error:null}}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async openArcadeAssistant(e){if(!this._arcadeAssistantRemoteState.shouldRender)return!1;if(this.openedSidePanel="arcade-assistant",await this.updateComplete,!this._canPromptWithArcadeAssistant())return!0;let t=this._arcadeAssistantElt.value;return e?.prompt&&await t?.openPrompt(e.prompt),!0}async load(){let e=K("./assets");X(e),await this._updateDataModelDeps(),this.manager.onLifecycle(()=>(this.hasUpdated&&this._connectMonacoCustomizations().catch(h(this)),()=>{for(this._askAiBindingKey&&(y(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);this._disposables.length;)this._disposables.pop()?.dispose();this._abortExternalExecution(),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")||e.has("externalExecutor"))&&this._executionContextChanged(),e.has("enableDebugger")&&!this.enableDebugger&&this._debuggerState.disableDebugger(),e.has("snippets")&&A.updateApiContextForModel(this._modelId,{snippets:this.snippets}),(e.has("arcadeAssistant")||e.has("disableAssistant"))&&this._updateArcadeAssistantRemoteState()}async loaded(){await this._connectMonacoCustomizations(),this._componentReadyDefer.resolve()}_setOpenedSidePanel(e){this.openedSidePanel=e===this.openedSidePanel?"none":e}async _connectMonacoCustomizations(){if(this._connectMonacoCustomizationsPromise)return await this._connectMonacoCustomizationsPromise;this._connectMonacoCustomizationsPromise=(async()=>{if(!this.isConnected)return;let e=await Z();this._disposables.push(e.onDiagnosticsChange(o=>{this._preparingArcade||(this._diagnostics=o.diagnostics,this.arcgisDiagnosticsChange.emit(o.diagnostics))})),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),this._syncAskAiAction();let t=L(()=>this._debuggerState.editorBreakpoints,()=>this._updateBreakpointsDecorations(),{sync:!0}),i=L(()=>this._debuggerState.debuggerLine,()=>this._updateDebuggerPausedLineDecoration(),{sync:!0}),a=L(()=>this._debuggerState.consoleLogs.length,()=>this.requestUpdate(),{sync:!0});this._disposables.push({dispose:()=>t.remove()},{dispose:()=>i.remove()},{dispose:()=>a.remove()});let r=this.editorInstance?.onMouseDown(o=>this._onEditorMouseDown(o));r&&this._disposables.push(r);let n=this.editorInstance?.onDidChangeModelContent(o=>this._onEditorModelContentChange(o));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].includes(e.target.type)||e.target.element?.classList.contains("codicon-gutter-lightbulb"))return;let t=e.target.position?.lineNumber;t&&this._debuggerState.toggleBreakpoint(t)}_onEditorModelContentChange(e){if(!this.enableDebugger||!this._debuggerState.editorBreakpoints.length||e.isFlush)return;let t=q(this._debuggerState.editorBreakpoints,e.changes);t.length===this._debuggerState.editorBreakpoints.length&&t.every((i,a)=>i===this._debuggerState.editorBreakpoints[a])||this._debuggerState.setBreakpoints(t)}_updateDebuggerPausedLineDecoration(){let e=this.editorInstance;if(!e)return;this._debuggerPausedLineDecoration?.clear();let t=this._debuggerState.debuggerLine;t!=null?this._debuggerPausedLineDecoration=e.createDecorationsCollection([{range:new R(t,1,t,1),options:{isWholeLine:!0,className:"arcgis-code-editor__debugger-paused-line",glyphMarginClassName:"arcgis-code-editor__debugger-paused-glyph",marginClassName:"arcgis-code-editor__debugger-paused-line arcgis-code-editor__debugger-paused-margin",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}]):this._debuggerPausedLineDecoration=void 0}_continueDebugSession(){this._debuggerState.continueDebug()}_abortExternalExecution(){this._externalExecutionAbortController?.abort(),this._externalExecutionAbortController=void 0}_stopDebugSession(){this._abortExternalExecution(),this._debuggerState.stopDebug({hidePanel:!1})}_resetDebugSession(){this._abortExternalExecution(),this._debuggerState.resetDebug(),this._executeScript("debug").catch(h(this))}async _handleDebugPause(e,t,i){if(!this._debuggerState.isDebugging||e!==this._debuggerState.sessionId)return;let a=Promise.withResolvers();return this._debuggerState.pauseDebug({line:t.line,result:i,continue:a}),await a.promise}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}async _executeWithExternalExecutor(e,t,i){if(!this.externalExecutor)return{type:"error",value:"Missing external executor",error:null};let a=new AbortController;this._abortExternalExecution(),this._externalExecutionAbortController=a;let r=i.console??(()=>{});try{if(e==="debug"){let{breakpoints:n,onDebugPause:o}=i;if(!n||!o)throw new Error("Missing debug execution options");return await this.externalExecutor.execute({mode:"debug",script:t,console:r,signal:a.signal,breakpoints:n,onDebugPause:o})}return await this.externalExecutor.execute({mode:"run",script:t,console:r,signal:a.signal})}catch(n){return{type:"error",value:(n instanceof Error?n:new Error(String(n))).message??"Execution failed",error:n instanceof Error?n:new Error(String(n)),compilationTime:0,executionTime:0,timeStamp:new Date}}finally{this._externalExecutionAbortController===a&&(this._externalExecutionAbortController=void 0)}}_executionContextChanged(){!this._canExecute&&this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),!this.testData&&this.enableDebugger&&this._debuggerState.clearForMissingTestData(),this._debuggerState.openedPanel==="debug-console"&&!this.enableDebugger&&this._debuggerState.closePanel(),this._debuggerState.showPanel&&this._executeScript("run").catch(h(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await A.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=A.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await A.getApiLibraryForModel(this._modelId)}_setExecutionPanel(e){this._debuggerState.setPanel(e)}async _executeScript(e){let t=this.testData,i=this.externalExecutor;if(!this._codeEditorElt.value||!t&&!i)return;let a=e==="debug"?this._debuggerState.startDebug():this._debuggerState.startRun();setTimeout(()=>{(async()=>{let r=this._codeEditorElt.value?.value??this.script,n={mode:e,console:u=>this._debuggerState.addConsoleLog(u),breakpoints:e==="debug"?this._debuggerState.debuggerBreakpoints:void 0};e==="debug"&&(n.onDebugPause=this._handleDebugPause.bind(this,a));let o,_;if(i){let u=await this._executeWithExternalExecutor(e,r,n);"result"in u?(o=u.result,_=u.timing):o=u}else if(t){let u=await this._editorProfilePromise;if(!u){this._debuggerState.fail({type:"error",value:"Missing editor profile",error:null});return}o=await T(u.definition,r,t,n)}else return;if(a===this._debuggerState.sessionId){if(e==="debug"){if(f(o)){this._debuggerState.fail(o);return}this._debuggerState.completeDebug(o,_);return}if(f(o))this._debuggerState.completeRun(o);else if(i){if(!_){this._debuggerState.fail({type:"error",value:"Missing execution timing",error:null});return}this._debuggerState.completeRun(o,{useDebugRenderer:!0,timing:_})}else 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(h(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(h(this))}_onResultPanelChange(e){let t=e.currentTarget;this._debuggerState.setPanel(t.openedResultPanel)}_onExecutionPanelClose(){this._debuggerState.closePanel()}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[V.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this._canExecute&&this._executeScript("run").catch(h(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e))}_getAskAiBindingKey(){return G.parse(this._modelId).toString()}_canRenderAskAiCodeActions(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.codeActions:!1}_canPromptWithArcadeAssistant(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.prompting:!1}_getAskAiCodeActions(e){if(!this._canRenderAskAiCodeActions())return[];if(!e.markers.length)return[];let t=this.messages.askarcadeassistant??"Ask Arcade Assistant",i=this._getAskAiBindingKey();return[{title:t,kind:Y,diagnostics:e.markers,isPreferred:!1,isAI:!1,command:{id:J,title:t,arguments:[i,this.messages.askarcadeassistantprompt??"Fix the errors in my script"]}}]}_syncAskAiAction(){if(!this.editorInstance)return;let e=this._getAskAiBindingKey();if(!this._arcadeAssistantRemoteState.shouldRender){this._askAiBindingKey&&(y(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);return}this._askAiBindingKey&&this._askAiBindingKey!==e&&y(this._askAiBindingKey,void 0),y(e,{provideCodeActions:({context:t})=>this._getAskAiCodeActions(t),run:t=>{this.openArcadeAssistant({prompt:t??this.messages.askarcadeassistantprompt??"Fix the errors in my script"}).catch(h(this))}}),this._askAiBindingKey=e}_disposeSafely(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1),e.dispose()}async _updateArcadeAssistantRemoteState(){let e=this.arcadeAssistant;this.disableAssistant?this._arcadeAssistantRemoteState={shouldRender:!1}:this._arcadeAssistantRemoteState=await j(e??{}),this._syncAskAiAction()}renderMainActionBar(){return this._usesBottomExecutionDrawer||!this._canExecute?null:d`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-toggle-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${()=>{this._executeScript("run").catch(h(this))}}></calcite-action>${this._debuggerState.result?d`<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 d`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${A.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${C(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:t,icon:i,active:a,panelName:r,iconFlipRtl:n=!1,onClick:o=this._toggleSidePanel}){return d`<calcite-action id=${e??k} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${i} .active=${a} @click=${o} data-panel-name=${r??k} .iconFlipRtl=${n}></calcite-action>${!this.sideActionBarExpanded&&d`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:d`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({id:"profile-variables-action",label:this.messages.profilevariables??"",icon:"profile-variables",active:this.openedSidePanel==="variables",panelName:"variables"})}${this.renderAction({id:"function-action",label:this.messages.constantsandfunctions??"",icon:"function",active:this.openedSidePanel==="api",panelName:"api"})}${this.suggestions?.length?this.renderAction({id:"suggestions-action",label:this.messages.suggestions??"",icon:"lightbulb",active:this.openedSidePanel==="suggestions",panelName:"suggestions"}):null}${this._arcadeAssistantRemoteState.shouldRender&&this.renderAction({id:"arcade-assistant-action",label:this.messages.arcadeassistant??"Arcade assistant",icon:"effects",active:this.openedSidePanel==="arcade-assistant",panelName:"arcade-assistant"})||""}${this.customPanels?.map(e=>e.enabled===!1?null:this.renderAction({id:e.id,label:e.name,icon:e.icon,active:this.openedSidePanel===e.id,panelName:e.id}))}${this.hideDocumentationActions?null:this.renderAction({id:"developer-website-action",label:this.messages.help??"",icon:"question",active:!1,panelName:"none",iconFlipRtl:this.messages._lang==="ar",onClick:this._openArcadeHelp})}</calcite-action-group></calcite-action-bar>`}renderSidePanel(){if(this.hideSideBar)return null;let{openedSidePanel:e,_arcadeAssistantRemoteState:t}=this;return d`<arcgis-language-api-panel slot=side-panel class=${P(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=${P(e==="variables"?"":"hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e!=="variables"} .messageOverrides=${{profileempty:this.messages.profileempty,profilevariables:this.messages.profilevariables}}></arcgis-editor-variables>${this.suggestions?.length&&d`<arcgis-arcade-suggestions slot=side-panel class=${P(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${t?.shouldRender&&d`<arcgis-arcade-coding-assistant slot=side-panel class=${P(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._closeSidePanel} .portalUrl=${t.portalUrl} .serviceUrl=${"serviceUrl"in t?t.serviceUrl:void 0} .helpBase=${t.helpBase} .promptingEnabled=${this._canPromptWithArcadeAssistant()} .feedbackServiceUrl=${t.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant?.appVersion} .disableQuestionAnswerLogging=${this.arcadeAssistant?.disableQuestionAnswerLogging} .diagnostics=${this._diagnostics} ${C(this._arcadeAssistantElt)}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(i=>d`<calcite-flow slot=side-panel class=${P(e===i.id?"":"hidden")}>${i?.useFlows?i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el}):d`<calcite-flow-item .heading=${i.name} heading-level=2 closable .closed=${e!==i.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${i.description}>${i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el})}</calcite-flow-item>`}</calcite-flow>`)}`}renderResultsPanel(){if(this._usesBottomExecutionDrawer)return this.renderBottomExecutionBody();if(!this._debuggerState.showPanel)return null;let e=this._debuggerState.openedPanel==="debug-console"?"output":this._debuggerState.openedPanel;return d`<arcgis-arcade-results slot=results-panel .openedResultPanel=${e} .loading=${this._debuggerState.isExecuting} .result=${this._debuggerState.runResult} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`}renderBottomExecutionBody(){let{showPanel:e,openedPanel:t,debugResult:i,isExecuting:a,mode:r}=this._debuggerState;if(!e)return null;let n=t==="debug-console"?"output":t;return this.enableDebugger&&t==="debug-console"?d`<arcgis-arcade-debugger-console slot=results-panel .modelId=${this._modelId} .debuggerStore=${this._debuggerState}></arcgis-arcade-debugger-console>`:t==="output"&&(r==="debug"||i)?d`<arcgis-arcade-debugger-output .outputTitle=${this.messages.output} slot=results-panel .debuggerStore=${this._debuggerState} .result=${i}></arcgis-arcade-debugger-output>`:d`<arcgis-arcade-results slot=results-panel class="bottom-results" .openedResultPanel=${n} .loading=${t==="console"&&this._debuggerState.isPaused?!1:a} .result=${this._debuggerState.runResult} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} hide-header @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange}></arcgis-arcade-results>`}renderBottomActionBar(){if(!this._usesBottomExecutionDrawer)return null;let{showPanel:e,hasExecuted:t,openedPanel:i,isDebugging:a,isPaused:r,isExecuting:n}=this._debuggerState,o=this.messages.continue??"Continue",_=this.messages.reset??"Reset",u=this.messages.stop??"Stop";return d`<div slot=bottom-action-bar class=${`main-action-bar bottom-action-bar ${e?"":"is-collapsed"}`}><calcite-action-bar class="bottom-action-bar__actions" layout=horizontal scale=s expand-toggle-disabled expanded><calcite-action-group scale=s>${this.enableDebugger&&a?d`<calcite-action id=debugger-continue-action .text=${o} icon=forward scale=s .disabled=${!r} @click=${this._continueDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-continue-action placement=top><span>${o}</span></calcite-tooltip><calcite-action id=debugger-reset-action .text=${_} icon=reset scale=s @click=${this._resetDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-reset-action placement=top><span>${_}</span></calcite-tooltip><calcite-action id=debugger-stop-action .text=${u} icon=circle-stop scale=s @click=${this._stopDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-stop-action placement=top><span>${u}</span></calcite-tooltip>`:d`<calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("run").catch(h(this))}}></calcite-action>${this.enableDebugger&&d`<calcite-action .disabled=${this._debuggerState.editorBreakpoints.length===0} .text=${this.messages.runanddebug??"Run and Debug"} text-enabled icon=debug-script scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("debug").catch(h(this))}}></calcite-action>`||""}`}</calcite-action-group>${t?d`<calcite-action-group scale=s><calcite-action .active=${i==="output"&&e} .text=${this.messages.output??"Output"} text-enabled scale=s icon=list-show-all icon-flip-rtl @click=${()=>this._setExecutionPanel("output")}></calcite-action><calcite-action .active=${i==="console"&&e} .text=${this.messages.console??"Console"} text-enabled scale=s icon=console icon-flip-rtl @click=${()=>this._setExecutionPanel("console")}></calcite-action><calcite-action .active=${i==="log"&&e} .text=${this.messages.log??"Log"} text-enabled scale=s icon=list icon-flip-rtl @click=${()=>this._setExecutionPanel("log")} .disabled=${this.enableDebugger&&this._debuggerState.mode==="debug"}></calcite-action>${this.enableDebugger&&d`<calcite-action .active=${i==="debug-console"&&e} .text=${this.messages.debugconsole??"Debug Console"} text-enabled scale=s icon=debug-script .disabled=${this._debuggerState.mode!=="debug"} @click=${()=>this._setExecutionPanel("debug-console")}></calcite-action>`||""}</calcite-action-group>`:null}</calcite-action-bar>${e?d`<calcite-action .text=${this.messages.close??"Close"} scale=s icon=x icon-flip-rtl @click=${this._onExecutionPanelClose} slot=actions-end></calcite-action>`:null}</div>`}render(){return d`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderBottomActionBar()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};z("arcgis-arcade-editor",M);return M},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,e,f,g,i)
|
|
2
|
+
import i from"./DFRZVVZZ.js";import g from"./WLWSPMNE.js";import f from"./WBN7AYGG.js";import e from"./MXOZNCTB.js";import{e as q}from"./7VS5GHCL.js";import c from"./H5EGZU2S.js";import b from"./7Z6G332Z.js";import"./MZMKV7FA.js";import a from"./2WB7S5TQ.js";import{a as W}from"./SGH4ISZJ.js";import{a as U}from"./CNEKU4E5.js";import"./BHSILWSL.js";import"./J4I4EROF.js";import{a as Y,b as J,c as y}from"./CLPF64WZ.js";import"./LEFE3FVL.js";import"./XEK22IDA.js";import{a as H}from"./CMRUQ3BN.js";import"./UFF53OEH.js";import"./NHREAORV.js";import{F as B,G as C,H as O,I as P,L as z,M as K,h as F,j as d,l as k,n as w,t as N}from"./7CO7POPG.js";import{b as h}from"./BFPEJYVB.js";import{ml as V,pl as R,ul as G}from"./DSQ2DQQL.js";import"./H6RQVSYM.js";export default $arcgis.t(([{watch:L},x,{property:c,subclass:S},{a:Q,h:f,i:T},{b:I},,,A,{a:j},{a:X,b:Z}])=>{var te=F`: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}.bottom-action-bar{display:flex;.bottom-action-bar__actions{flex:1 1 auto;min-inline-size:0}}`,se=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,m=(s,e,t,i)=>{for(var a=i>1?void 0:i?ie(e,t):e,r=s.length-1,n;r>=0;r--)(n=s[r])&&(a=(i?n(e,t,a):n(a))||a);return i&&a&&se(e,t,a),a},ee=100,g=class extends x{constructor(s){super(s),this.collectionItems=[],this.errorMessage="",this.expanded=!1,this.requestId=0,this.status="idle",this.visibleChildCount=ee}};m([c()],g.prototype,"collectionItems",2);m([c()],g.prototype,"errorMessage",2);m([c()],g.prototype,"expanded",2);m([c()],g.prototype,"requestId",2);m([c()],g.prototype,"schemaValue",2);m([c()],g.prototype,"status",2);m([c()],g.prototype,"visibleChildCount",2);g=m([S("ArcadeDebuggerLazyTreeNodeState")],g);var D=class extends x{constructor(s){super(s),this.generation=0,this.nodes=new Map}reset(){this.generation+=1,this.destroyNodes()}ensureNode(s,e=!1,t){let i=this.nodes.get(s);if(i)return i;let a=new g;return a.expanded=e,this.nodes.set(s,a),e&&t&&this.loadNode(s,t),a}setExpanded(s,e,t){let i=this.ensureNode(s,e,t);if(i.expanded===e){e&&t&&this.loadNode(s,t);return}i.expanded=e,e&&t&&this.loadNode(s,t)}showMore(s,e){let t=this.ensureNode(s);t.visibleChildCount>=e||(t.visibleChildCount=Math.min(e,t.visibleChildCount+ee))}loadNode(s,e){switch(e.kind){case"collection":this.runLoad(s,e.load,(t,i)=>{t.collectionItems=i});return;case"schema":this.runLoad(s,e.load,(t,i)=>{t.schemaValue=i});return}}runLoad(s,e,t){let i=this.nodes.get(s);if(!i||i.status==="loading"||i.status==="loaded")return;let a=this.generation,r=i.requestId+1;i.requestId=r,i.status="loading",i.errorMessage="",i.schemaValue=void 0,i.collectionItems=[],e().then(n=>{let o=this.nodes.get(s);!o||this.generation!==a||o.requestId!==r||(t(o,n),o.status="loaded")}).catch(()=>{let n=this.nodes.get(s);!n||this.generation!==a||n.requestId!==r||(n.status="error")})}destroyNodes(){for(let s of this.nodes.values())s.destroy();this.nodes.clear()}};D=m([S("ArcadeDebuggerLazyTreeState")],D);var ae=Object.defineProperty,ne=Object.getOwnPropertyDescriptor,l=(s,e,t,i)=>{for(var a=i>1?void 0:i?ne(e,t):e,r=s.length-1,n;r>=0;r--)(n=s[r])&&(a=(i?n(e,t,a):n(a))||a);return i&&a&&ae(e,t,a),a},b=class extends x{constructor(s){super(s),this.phase="idle",this.sessionId=0,this.consoleLogs=[],this.hasExecuted=!1}get isExecuting(){return this.phase==="running"||this.phase==="debug-running"||this.phase==="debug-paused"}get isDebugging(){return this.phase==="debug-running"||this.phase==="debug-paused"}get isPaused(){return this.phase==="debug-paused"}get runResult(){return this.result?.resultType==="run"?this.result.result:void 0}get debugResult(){return this.result?.resultType==="debug"?this.result.result:void 0}get executionTiming(){return this.result?.timing}addConsoleLog(s){this.consoleLogs=[...this.consoleLogs,s]}};l([c()],b.prototype,"phase",2);l([c()],b.prototype,"mode",2);l([c()],b.prototype,"sessionId",2);l([c()],b.prototype,"result",2);l([c()],b.prototype,"consoleLogs",2);l([c()],b.prototype,"hasExecuted",2);b=l([S("ArcadeDebuggerExecutionModel")],b);var $=class extends x{constructor(s){super(s),this.editorBreakpoints=[],this.executionBreakpoints=[]}setBreakpoints(s,e){s==="editor"?this.editorBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i):this.executionBreakpoints=Array.from(new Set(e)).sort((t,i)=>t-i)}toggleBreakpoint(s,e){let t=new Set(s==="editor"?this.editorBreakpoints:this.executionBreakpoints);t.has(e)?t.delete(e):t.add(e),this.setBreakpoints(s,t)}clearBreakpoints(s){s==="editor"?this.editorBreakpoints=[]:this.executionBreakpoints=[]}syncExecutionBreakpointsFromEditor(){this.executionBreakpoints=this.editorBreakpoints}};l([c()],$.prototype,"editorBreakpoints",2);l([c()],$.prototype,"executionBreakpoints",2);$=l([S("ArcadeDebuggerSessionModel")],$);var E=class extends x{constructor(s){super(s),this.openedPanel="output",this.showPanel=!1}};l([c()],E.prototype,"openedPanel",2);l([c()],E.prototype,"showPanel",2);E=l([S("ArcadeDebuggerUiModel")],E);var v=class extends x{constructor(s){super(s)}get line(){return this.pausedState?.line}clearPausedState(){this.lastPausedState=this.pausedState,this.pausedState=void 0}reset(){this.pausedState=void 0,this.lastPausedState=void 0}setPausedState(s){this.pausedState=s,this.lastPausedState=s}};l([c()],v.prototype,"pausedState",2);l([c()],v.prototype,"lastPausedState",2);v=l([S("ArcadeDebuggerPausedFrameModel")],v);var p=class extends x{constructor(s){super(s),this.execution=new b,this.lazyTreeState=new D,this.pausedFrame=new v,this.previewTabsState=new I,this.session=new $,this.ui=new E}get editorBreakpoints(){return this.session.editorBreakpoints}get debuggerBreakpoints(){return this.isPaused?this.session.executionBreakpoints.map(s=>({line:s})):this.session.editorBreakpoints.map(s=>({line:s}))}get executionBreakpoints(){return this.session.executionBreakpoints}get consoleLogs(){return this.execution.consoleLogs}get debug(){if(!(!this.pausedFrame.pausedState&&!this.pausedFrame.lastPausedState))return{pausedState:this.pausedFrame.pausedState,lastPausedState:this.pausedFrame.lastPausedState}}get debugResult(){return this.execution.debugResult}get executionTiming(){return this.execution.executionTiming}get debuggerLine(){return this.pausedFrame.pausedState?.line}get executionState(){return this.pausedFrame.pausedState}get hasExecuted(){return this.execution.hasExecuted}get isDebugging(){return this.execution.isDebugging}get isExecuting(){return this.execution.isExecuting}get isPaused(){return this.execution.isPaused}get mode(){return this.execution.mode}get openedPanel(){return this.ui.openedPanel}get outputRenderer(){if(this.execution.result)return this.execution.result.resultType==="debug"?"debugger":"legacy"}get phase(){return this.execution.phase}get result(){return this.execution.result}get runResult(){return this.execution.runResult}get sessionId(){return this.execution.sessionId}get showPanel(){return this.ui.showPanel}addConsoleLog(s){this.execution.addConsoleLog(s)}clearBreakpoints(s){this.session.clearBreakpoints(s)}clearForMissingTestData(){this.stopDebug({hidePanel:!0}),this.execution.hasExecuted=!1,this.execution.result=void 0}closePanel(){this.ui.showPanel=!1}completeDebug(s,e){this.execution.mode="debug",this.execution.result={resultType:"debug",result:s,...e?{timing:e}:{}},this.execution.phase="completed",this.ui.openedPanel="output",this.pausedFrame.reset(),this.resetTransientDebuggerState()}completeRun(s,e={}){this.execution.mode="run",!e.useDebugRenderer&&f(s)?this.execution.result={resultType:"run",result:s}:e.useDebugRenderer&&!f(s)&&(this.execution.result={resultType:"debug",result:s,...e.timing?{timing:e.timing}:{}}),this.execution.phase="completed",this.pausedFrame.reset(),this.ui.openedPanel="output",this.resetTransientDebuggerState()}continueDebug(){let s=this.pausedFrame.pausedState?.continue;s&&(this.execution.phase="debug-running",this.pausedFrame.clearPausedState(),s.resolve())}disableDebugger(){this.stopDebug({hidePanel:!0}),this.clearBreakpoints("execution"),this.clearBreakpoints("editor")}fail(s){this.completeRun(s)}pauseDebug(s){let e=this.pausedFrame.pausedState??this.pausedFrame.lastPausedState;this.syncPausedState(e,s),this.pausedFrame.setPausedState(s),this.execution.phase="debug-paused"}reset(){this.execution.phase="idle",this.execution.mode=void 0,this.execution.result=void 0,this.execution.consoleLogs=[],this.execution.hasExecuted=!1,this.execution.sessionId=0,this.ui.openedPanel="output",this.ui.showPanel=!1,this.pausedFrame.reset(),this.clearBreakpoints("execution"),this.clearBreakpoints("editor"),this.replaceTransientDebuggerState()}resetDebug(){this.stopDebug({hidePanel:!1}),this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="debug-console"}disconnect(){this.stopDebug({hidePanel:!0})}setBreakpoints(s){this.session.setBreakpoints("editor",s)}setPanel(s){this.execution.hasExecuted&&(this.ui.openedPanel=s,this.ui.showPanel=!0)}startDebug(){return this.execution.mode="debug",this.execution.phase="debug-running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.session.syncExecutionBreakpointsFromEditor(),this.execution.consoleLogs=[],this.ui.openedPanel="debug-console",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}startRun(){return this.execution.mode="run",this.execution.phase="running",this.execution.hasExecuted=!0,this.execution.result=void 0,this.execution.consoleLogs=[],this.ui.openedPanel="output",this.ui.showPanel=!0,this.execution.sessionId+=1,this.pausedFrame.reset(),this.replaceTransientDebuggerState(),this.execution.sessionId}stopDebug({hidePanel:s=!0,invalidateSession:e=!0}={}){let t=this.pausedFrame.pausedState?.continue;e&&(this.execution.sessionId+=1),this.execution.phase=this.execution.hasExecuted?"completed":"idle",this.pausedFrame.reset(),this.resetTransientDebuggerState(),s&&(this.ui.showPanel=!1),this.ui.openedPanel==="debug-console"&&(this.ui.openedPanel="output"),t?.resolve()}syncPausedState(s,e){this.lazyTreeState.reset(),s&&e&&s!==e&&this.previewTabsState.invalidateAll(),this.pausedLine=e?.line}toggleBreakpoint(s){this.session.toggleBreakpoint("editor",s)}togglePanel(s){if(this.execution.hasExecuted){if(s==null){this.ui.showPanel=!this.ui.showPanel;return}if(this.ui.openedPanel===s&&this.ui.showPanel){this.ui.showPanel=!1;return}this.setPanel(s)}}resetTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState.reset(),this.previewTabsState.clear()}replaceTransientDebuggerState(){this.pausedLine=void 0,this.lazyTreeState=new D,this.previewTabsState=new I}};l([c()],p.prototype,"execution",2);l([c()],p.prototype,"lazyTreeState",2);l([c()],p.prototype,"pausedLine",2);l([c()],p.prototype,"pausedFrame",2);l([c()],p.prototype,"previewTabsState",2);l([c()],p.prototype,"session",2);l([c()],p.prototype,"ui",2);p=l([S("ArcadeDebuggerStore")],p);var oe={glyphMargin:!0,lineNumbersMinChars:1},M=class extends O{constructor(){super(...arguments),this._codeEditorElt=B(),this._arcadeAssistantElt=B(),this._componentReadyDefer=Promise.withResolvers(),this._disposables=[],this._editorProfilePromise=Promise.resolve(void 0),this._debuggerState=new p,this.messages=W(),this._modelId=N(),this._openArcadeHelp=()=>{window.open(Q,"Arcade Help")},this._decorations=void 0,this._monacoEditor=U(H),this._editorOptions={},this._toggleSidePanel=e=>{e.currentTarget instanceof HTMLElement&&this._setOpenedSidePanel(e.currentTarget.dataset.panelName??"none")},this._closeSidePanel=()=>{this._setOpenedSidePanel("none")},this._updateBreakpointsDecorations=()=>{let e=this.editorInstance;if(!e)return;let t=this._debuggerState.editorBreakpoints.map(i=>({range:new R(i,1,i,1),options:{isWholeLine:!0,glyphMarginClassName:"arcgis-code-editor__breakpoint-glyph",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}));this._decorations?.clear(),this._decorations=e.createDecorationsCollection(t)},this._clearDebuggerDecorations=()=>{this._decorations?.clear(),this._decorations=void 0,this._debuggerPausedLineDecoration?.clear(),this._debuggerPausedLineDecoration=void 0},this._debuggerPausedLineDecoration=void 0,this._preparingArcade=!1,this._arcadeAssistantRemoteState={shouldRender:!1},this._diagnostics=[],this.enableDebugger=!1,this.hideDocumentationActions=!1,this.hideSideBar=!1,this.openedSidePanel="none",this.script="",this.sideActionBarExpanded=!1,this.disableAssistant=!1,this.arcgisDiagnosticsChange=w({bubbles:!1}),this.arcgisScriptChange=w({bubbles:!1})}static{this.properties={_apiLibrary:16,_editorProfile:16,_preparingArcade:16,_arcadeAssistantRemoteState:16,_diagnostics:16,editorInstance:32,editorOptions:0,enableDebugger:5,hideDocumentationActions:5,hideSideBar:5,messageOverrides:0,openedSidePanel:3,profile:0,script:1,sideActionBarExpanded:7,snippets:0,suggestions:0,testData:0,customPanels:0,disableAssistant:5,arcadeAssistant:0,externalExecutor:0}}static{this.styles=[te]}get _canExecute(){return!!(this.testData||this.externalExecutor)}get _usesBottomExecutionDrawer(){return this._canExecute&&(this.enableDebugger||!!this.externalExecutor)}get editorInstance(){return this._codeEditorElt.value?.editorInstance}get editorOptions(){return{...oe,...this._editorOptions}}set editorOptions(e){this._editorOptions=e??{}}async getTestResult(){if(!this.testData)return{type:"error",value:"Missing test data",error:null};let e=await this._editorProfilePromise;if(!e)return{type:"error",value:"Missing editor profile",error:null};await this._componentReadyDefer.promise;let t=this._codeEditorElt.value?.value,i=await T(e.definition,t,this.testData,{mode:"run"});return f(i)?i:{type:"error",value:"Unexpected debug result",error:null}}async setFocus(){await this._componentReadyDefer.promise,await this._codeEditorElt.value?.setFocus()}async openArcadeAssistant(e){if(!this._arcadeAssistantRemoteState.shouldRender)return!1;if(this.openedSidePanel="arcade-assistant",await this.updateComplete,!this._canPromptWithArcadeAssistant())return!0;let t=this._arcadeAssistantElt.value;return e?.prompt&&await t?.openPrompt(e.prompt),!0}async load(){let e=K("./assets");X(e),await this._updateDataModelDeps(),this.manager.onLifecycle(()=>(this.hasUpdated&&this._connectMonacoCustomizations().catch(h(this)),()=>{for(this._askAiBindingKey&&(y(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);this._disposables.length;)this._disposables.pop()?.dispose();this._abortExternalExecution(),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")||e.has("externalExecutor"))&&this._executionContextChanged(),e.has("enableDebugger")&&!this.enableDebugger&&this._debuggerState.disableDebugger(),e.has("snippets")&&A.updateApiContextForModel(this._modelId,{snippets:this.snippets}),(e.has("arcadeAssistant")||e.has("disableAssistant"))&&this._updateArcadeAssistantRemoteState()}async loaded(){await this._connectMonacoCustomizations(),this._componentReadyDefer.resolve()}_setOpenedSidePanel(e){this.openedSidePanel=e===this.openedSidePanel?"none":e}async _connectMonacoCustomizations(){if(this._connectMonacoCustomizationsPromise)return await this._connectMonacoCustomizationsPromise;this._connectMonacoCustomizationsPromise=(async()=>{if(!this.isConnected)return;let e=await Z();this._disposables.push(e.onDiagnosticsChange(o=>{this._preparingArcade||(this._diagnostics=o.diagnostics,this.arcgisDiagnosticsChange.emit(o.diagnostics))})),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),this._syncAskAiAction();let t=L(()=>this._debuggerState.editorBreakpoints,()=>this._updateBreakpointsDecorations(),{sync:!0}),i=L(()=>this._debuggerState.debuggerLine,()=>this._updateDebuggerPausedLineDecoration(),{sync:!0}),a=L(()=>this._debuggerState.consoleLogs.length,()=>this.requestUpdate(),{sync:!0});this._disposables.push({dispose:()=>t.remove()},{dispose:()=>i.remove()},{dispose:()=>a.remove()});let r=this.editorInstance?.onMouseDown(o=>this._onEditorMouseDown(o));r&&this._disposables.push(r);let n=this.editorInstance?.onDidChangeModelContent(o=>this._onEditorModelContentChange(o));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].includes(e.target.type)||e.target.element?.classList.contains("codicon-gutter-lightbulb"))return;let t=e.target.position?.lineNumber;t&&this._debuggerState.toggleBreakpoint(t)}_onEditorModelContentChange(e){if(!this.enableDebugger||!this._debuggerState.editorBreakpoints.length||e.isFlush)return;let t=q(this._debuggerState.editorBreakpoints,e.changes);t.length===this._debuggerState.editorBreakpoints.length&&t.every((i,a)=>i===this._debuggerState.editorBreakpoints[a])||this._debuggerState.setBreakpoints(t)}_updateDebuggerPausedLineDecoration(){let e=this.editorInstance;if(!e)return;this._debuggerPausedLineDecoration?.clear();let t=this._debuggerState.debuggerLine;t!=null?this._debuggerPausedLineDecoration=e.createDecorationsCollection([{range:new R(t,1,t,1),options:{isWholeLine:!0,className:"arcgis-code-editor__debugger-paused-line",glyphMarginClassName:"arcgis-code-editor__debugger-paused-glyph",marginClassName:"arcgis-code-editor__debugger-paused-line arcgis-code-editor__debugger-paused-margin",stickiness:this._monacoEditor.TrackedRangeStickiness.NeverGrowsWhenTypingAtEdges}}]):this._debuggerPausedLineDecoration=void 0}_continueDebugSession(){this._debuggerState.continueDebug()}_abortExternalExecution(){this._externalExecutionAbortController?.abort(),this._externalExecutionAbortController=void 0}_stopDebugSession(){this._abortExternalExecution(),this._debuggerState.stopDebug({hidePanel:!1})}_resetDebugSession(){this._abortExternalExecution(),this._debuggerState.resetDebug(),this._executeScript("debug").catch(h(this))}async _handleDebugPause(e,t,i){if(!this._debuggerState.isDebugging||e!==this._debuggerState.sessionId)return;let a=Promise.withResolvers();return this._debuggerState.pauseDebug({line:t.line,result:i,continue:a}),await a.promise}async _updateDataModelDeps(){await this._updateEditorProfile(),await this._updateApiLibrary()}async _executeWithExternalExecutor(e,t,i){if(!this.externalExecutor)return{type:"error",value:"Missing external executor",error:null};let a=new AbortController;this._abortExternalExecution(),this._externalExecutionAbortController=a;let r=i.console??(()=>{});try{if(e==="debug"){let{breakpoints:n,onDebugPause:o}=i;if(!n||!o)throw new Error("Missing debug execution options");return await this.externalExecutor.execute({mode:"debug",script:t,console:r,signal:a.signal,breakpoints:n,onDebugPause:o})}return await this.externalExecutor.execute({mode:"run",script:t,console:r,signal:a.signal})}catch(n){return{type:"error",value:(n instanceof Error?n:new Error(String(n))).message??"Execution failed",error:n instanceof Error?n:new Error(String(n)),compilationTime:0,executionTime:0,timeStamp:new Date}}finally{this._externalExecutionAbortController===a&&(this._externalExecutionAbortController=void 0)}}_executionContextChanged(){!this._canExecute&&this._executeScriptAction&&(this._disposeSafely(this._executeScriptAction),this._executeScriptAction=void 0),this._canExecute&&!this._executeScriptAction&&this._addExecuteScriptAction(),!this.testData&&this.enableDebugger&&this._debuggerState.clearForMissingTestData(),this._debuggerState.openedPanel==="debug-console"&&!this.enableDebugger&&this._debuggerState.closePanel(),this._debuggerState.showPanel&&this._executeScript("run").catch(h(this))}async _updateEditorProfile(){this._preparingArcade=!0;try{await A.setProfileForModel(this._modelId,this.profile,{locale:this.messages._t9nLocale,snippets:this.snippets}),this._editorProfile=A.getEditorProfileForModel(this._modelId)}catch{this._editorProfile=void 0}finally{this._editorProfilePromise=Promise.resolve(this._editorProfile),this._preparingArcade=!1}}async _updateApiLibrary(){this._apiLibrary=await A.getApiLibraryForModel(this._modelId)}_setExecutionPanel(e){this._debuggerState.setPanel(e)}async _executeScript(e){let t=this.testData,i=this.externalExecutor;if(!this._codeEditorElt.value||!t&&!i)return;let a=e==="debug"?this._debuggerState.startDebug():this._debuggerState.startRun();setTimeout(()=>{(async()=>{let r=this._codeEditorElt.value?.value??this.script,n={mode:e,console:u=>this._debuggerState.addConsoleLog(u),breakpoints:e==="debug"?this._debuggerState.debuggerBreakpoints:void 0};e==="debug"&&(n.onDebugPause=this._handleDebugPause.bind(this,a));let o,_;if(i){let u=await this._executeWithExternalExecutor(e,r,n);"result"in u?(o=u.result,_=u.timing):o=u}else if(t){let u=await this._editorProfilePromise;if(!u){this._debuggerState.fail({type:"error",value:"Missing editor profile",error:null});return}o=await T(u.definition,r,t,n)}else return;if(a===this._debuggerState.sessionId){if(e==="debug"){if(f(o)){this._debuggerState.fail(o);return}this._debuggerState.completeDebug(o,_);return}if(f(o))this._debuggerState.completeRun(o);else if(i){if(!_){this._debuggerState.fail({type:"error",value:"Missing execution timing",error:null});return}this._debuggerState.completeRun(o,{useDebugRenderer:!0,timing:_})}else 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(h(this))}_insertAsText(e){this._insertText(e.detail)}_insertText(e){this._codeEditorElt.value?.insertText(e).catch(h(this))}_onResultPanelChange(e){let t=e.currentTarget;this._debuggerState.setPanel(t.openedResultPanel)}_onExecutionPanelClose(){this._debuggerState.closePanel()}_addExecuteScriptAction(){let e=this.editorInstance?.addAction({id:"run-script",label:"Run Arcade Expression",keybindings:[V.F5],contextMenuGroupId:"code",contextMenuOrder:1,run:()=>{this._canExecute&&this._executeScript("run").catch(h(this))}});e&&(this._executeScriptAction=e,this._disposables.push(e))}_getAskAiBindingKey(){return G.parse(this._modelId).toString()}_canRenderAskAiCodeActions(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.codeActions:!1}_canPromptWithArcadeAssistant(){let e=this._arcadeAssistantRemoteState;return e.shouldRender?e.availableFeatures.prompting:!1}_getAskAiCodeActions(e){if(!this._canRenderAskAiCodeActions())return[];if(!e.markers.length)return[];let t=this.messages.askarcadeassistant??"Ask Arcade Assistant",i=this._getAskAiBindingKey();return[{title:t,kind:Y,diagnostics:e.markers,isPreferred:!1,isAI:!1,command:{id:J,title:t,arguments:[i,this.messages.askarcadeassistantprompt??"Fix the errors in my script"]}}]}_syncAskAiAction(){if(!this.editorInstance)return;let e=this._getAskAiBindingKey();if(!this._arcadeAssistantRemoteState.shouldRender){this._askAiBindingKey&&(y(this._askAiBindingKey,void 0),this._askAiBindingKey=void 0);return}this._askAiBindingKey&&this._askAiBindingKey!==e&&y(this._askAiBindingKey,void 0),y(e,{provideCodeActions:({context:t})=>this._getAskAiCodeActions(t),run:t=>{this.openArcadeAssistant({prompt:t??this.messages.askarcadeassistantprompt??"Fix the errors in my script"}).catch(h(this))}}),this._askAiBindingKey=e}_disposeSafely(e){let t=this._disposables.indexOf(e);t!==-1&&this._disposables.splice(t,1),e.dispose()}async _updateArcadeAssistantRemoteState(){let e=this.arcadeAssistant;this.disableAssistant?this._arcadeAssistantRemoteState={shouldRender:!1}:this._arcadeAssistantRemoteState=await j(e??{}),this._syncAskAiAction()}renderMainActionBar(){return this._usesBottomExecutionDrawer||!this._canExecute?null:d`<calcite-action-bar class="main-action-bar" layout=horizontal scale=s expanded expand-toggle-disabled slot=top-action-bar><calcite-action-group scale=s><calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade} @click=${()=>{this._executeScript("run").catch(h(this))}}></calcite-action>${this._debuggerState.result?d`<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 d`<arcgis-code-editor slot=editor .editorOptions=${this.editorOptions} .language=${A.languageId} .value=${this.script??""} .modelId=${this._modelId} @arcgisValueChange=${this._onCodeEditorValueChange} ${C(this._codeEditorElt)}></arcgis-code-editor>`}renderAction({id:e,label:t,icon:i,active:a,panelName:r,iconFlipRtl:n=!1,onClick:o=this._toggleSidePanel}){return d`<calcite-action id=${e??k} .text=${t} .textEnabled=${this.sideActionBarExpanded} .icon=${i} .active=${a} @click=${o} data-panel-name=${r??k} .iconFlipRtl=${n}></calcite-action>${!this.sideActionBarExpanded&&d`<calcite-tooltip .referenceElement=${e}><span>${t}</span></calcite-tooltip>`||""}`}renderSideActionBar(){return this.hideSideBar?null:d`<calcite-action-bar slot=side-action-bar class="side-action-bar" .expanded=${this.sideActionBarExpanded} position=end @calciteActionBarToggle=${this._toggleSideActionBarExpanded}><calcite-action-group>${this.renderAction({id:"profile-variables-action",label:this.messages.profilevariables??"",icon:"profile-variables",active:this.openedSidePanel==="variables",panelName:"variables"})}${this.renderAction({id:"function-action",label:this.messages.constantsandfunctions??"",icon:"function",active:this.openedSidePanel==="api",panelName:"api"})}${this.suggestions?.length?this.renderAction({id:"suggestions-action",label:this.messages.suggestions??"",icon:"lightbulb",active:this.openedSidePanel==="suggestions",panelName:"suggestions"}):null}${this._arcadeAssistantRemoteState.shouldRender&&this.renderAction({id:"arcade-assistant-action",label:this.messages.arcadeassistant??"Arcade assistant",icon:"effects",active:this.openedSidePanel==="arcade-assistant",panelName:"arcade-assistant"})||""}${this.customPanels?.map(e=>e.enabled===!1?null:this.renderAction({id:e.id,label:e.name,icon:e.icon,active:this.openedSidePanel===e.id,panelName:e.id}))}${this.hideDocumentationActions?null:this.renderAction({id:"developer-website-action",label:this.messages.help??"",icon:"question",active:!1,panelName:"none",iconFlipRtl:this.messages._lang==="ar",onClick:this._openArcadeHelp})}</calcite-action-group></calcite-action-bar>`}renderSidePanel(){if(this.hideSideBar)return null;let{openedSidePanel:e,_arcadeAssistantRemoteState:t}=this;return d`<arcgis-language-api-panel slot=side-panel class=${P(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=${P(e==="variables"?"":"hidden")} .loading=${this._preparingArcade} .modelId=${this._modelId} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none .variable=${this._editorProfile} .closed=${e!=="variables"} .messageOverrides=${{profileempty:this.messages.profileempty,profilevariables:this.messages.profilevariables}}></arcgis-editor-variables>${this.suggestions?.length&&d`<arcgis-arcade-suggestions slot=side-panel class=${P(e==="suggestions"?"":"hidden")} .closed=${e!=="suggestions"} .suggestions=${this.suggestions} @arcgisInternalItemSelected=${this._insertAsText} @arcgisInternalClosePanel=${this._closeSidePanel} data-panel-name=none></arcgis-arcade-suggestions>`||""}${t?.shouldRender&&d`<arcgis-arcade-coding-assistant slot=side-panel class=${P(e==="arcade-assistant"?"":"hidden")} .closed=${e!=="arcade-assistant"} .insertText=${this._insertText.bind(this)} .closePanel=${this._closeSidePanel} .portalUrl=${t.portalUrl} .serviceUrl=${"serviceUrl"in t?t.serviceUrl:void 0} .helpBase=${t.helpBase} .promptingEnabled=${this._canPromptWithArcadeAssistant()} .feedbackServiceUrl=${t.feedbackServiceUrl} .editorRef=${this.el} .appVersion=${this.arcadeAssistant?.appVersion} .disableQuestionAnswerLogging=${this.arcadeAssistant?.disableQuestionAnswerLogging} .diagnostics=${this._diagnostics} ${C(this._arcadeAssistantElt)}></arcgis-arcade-coding-assistant>`||""}${this.customPanels?.map(i=>d`<calcite-flow slot=side-panel class=${P(e===i.id?"":"hidden")}>${i?.useFlows?i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el}):d`<calcite-flow-item .heading=${i.name} heading-level=2 closable .closed=${e!==i.id} @calciteFlowItemClose=${this._toggleSidePanel} .description=${i.description}>${i.renderer?.({closePanel:this._toggleSidePanel,insertText:this._insertText.bind(this),closed:e!==i.id,editorRef:this.el})}</calcite-flow-item>`}</calcite-flow>`)}`}renderResultsPanel(){if(this._usesBottomExecutionDrawer)return this.renderBottomExecutionBody();if(!this._debuggerState.showPanel)return null;let e=this._debuggerState.openedPanel==="debug-console"?"output":this._debuggerState.openedPanel;return d`<arcgis-arcade-results slot=results-panel .openedResultPanel=${e} .loading=${this._debuggerState.isExecuting} .result=${this._debuggerState.runResult} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange} @arcgisInternalClosePanel=${this._onExecutionPanelClose}></arcgis-arcade-results>`}renderBottomExecutionBody(){let{showPanel:e,openedPanel:t,debugResult:i,isExecuting:a,mode:r}=this._debuggerState;if(!e)return null;let n=t==="debug-console"?"output":t;return this.enableDebugger&&t==="debug-console"?d`<arcgis-arcade-debugger-console slot=results-panel .modelId=${this._modelId} .debuggerStore=${this._debuggerState}></arcgis-arcade-debugger-console>`:t==="output"&&(r==="debug"||i)?d`<arcgis-arcade-debugger-output .outputTitle=${this.messages.output} slot=results-panel .debuggerStore=${this._debuggerState} .result=${i}></arcgis-arcade-debugger-output>`:d`<arcgis-arcade-results slot=results-panel class="bottom-results" .openedResultPanel=${n} .loading=${t==="console"&&this._debuggerState.isPaused?!1:a} .result=${this._debuggerState.runResult} .executionTiming=${this._debuggerState.executionTiming} .consoleLogs=${this._debuggerState.consoleLogs} hide-header @arcgisInternalOpenedResultPanelChange=${this._onResultPanelChange}></arcgis-arcade-results>`}renderBottomActionBar(){if(!this._usesBottomExecutionDrawer)return null;let{showPanel:e,hasExecuted:t,openedPanel:i,isDebugging:a,isPaused:r,isExecuting:n}=this._debuggerState,o=this.messages.continue??"Continue",_=this.messages.reset??"Reset",u=this.messages.stop??"Stop";return d`<div slot=bottom-action-bar class=${`main-action-bar bottom-action-bar ${e?"":"is-collapsed"}`}><calcite-action-bar class="bottom-action-bar__actions" layout=horizontal scale=s expand-toggle-disabled expanded><calcite-action-group scale=s>${this.enableDebugger&&a?d`<calcite-action id=debugger-continue-action .text=${o} icon=forward scale=s .disabled=${!r} @click=${this._continueDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-continue-action placement=top><span>${o}</span></calcite-tooltip><calcite-action id=debugger-reset-action .text=${_} icon=reset scale=s @click=${this._resetDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-reset-action placement=top><span>${_}</span></calcite-tooltip><calcite-action id=debugger-stop-action .text=${u} icon=circle-stop scale=s @click=${this._stopDebugSession}></calcite-action><calcite-tooltip reference-element=debugger-stop-action placement=top><span>${u}</span></calcite-tooltip>`:d`<calcite-action .text=${this.messages.run??""} text-enabled icon=play scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("run").catch(h(this))}}></calcite-action>${this.enableDebugger&&d`<calcite-action .disabled=${this._debuggerState.editorBreakpoints.length===0} .text=${this.messages.runanddebug??"Run and Debug"} text-enabled icon=debug-script scale=s .loading=${this._preparingArcade||n} @click=${()=>{this._executeScript("debug").catch(h(this))}}></calcite-action>`||""}`}</calcite-action-group>${t?d`<calcite-action-group scale=s><calcite-action .active=${i==="output"&&e} .text=${this.messages.output??"Output"} text-enabled scale=s icon=list-show-all icon-flip-rtl @click=${()=>this._setExecutionPanel("output")}></calcite-action><calcite-action .active=${i==="console"&&e} .text=${this.messages.console??"Console"} text-enabled scale=s icon=console icon-flip-rtl @click=${()=>this._setExecutionPanel("console")}></calcite-action><calcite-action .active=${i==="log"&&e} .text=${this.messages.log??"Log"} text-enabled scale=s icon=list icon-flip-rtl @click=${()=>this._setExecutionPanel("log")} .disabled=${this.enableDebugger&&this._debuggerState.mode==="debug"}></calcite-action>${this.enableDebugger&&d`<calcite-action .active=${i==="debug-console"&&e} .text=${this.messages.debugconsole??"Debug Console"} text-enabled scale=s icon=debug-script .disabled=${this._debuggerState.mode!=="debug"} @click=${()=>this._setExecutionPanel("debug-console")}></calcite-action>`||""}</calcite-action-group>`:null}</calcite-action-bar>${e?d`<calcite-action .text=${this.messages.close??"Close"} scale=s icon=x icon-flip-rtl @click=${this._onExecutionPanelClose} slot=actions-end></calcite-action>`:null}</div>`}render(){return d`<arcgis-code-editor-shell>${this.renderMainActionBar()}${this.renderMainPanel()}${this.renderBottomActionBar()}${this.renderResultsPanel()}${this.renderSidePanel()}${this.renderSideActionBar()}</arcgis-code-editor-shell>`}};z("arcgis-arcade-editor",M);return M},"core/reactiveUtils","core/Accessor","core/accessorSupport/decorators",a,b,c,e,f,g,i)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
+
import{u as h}from"./7CO7POPG.js";import{a as b}from"./BFPEJYVB.js";export default $arcgis.t(([R,{version:B},I,m])=>{var U="https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0",a=(e,s)=>{b(e,"Arcade Assistant",s)},u=["orgAiAssistantsEnabled","betaAppsAllowed","serviceUrlAvailable","userHasUseAiAssistantsPrivilege"],S=u,w=(e,s)=>s.every(t=>e[t]===!0),P=e=>{let{aiConfig:s}=e;return s?.aiForOrg?.enabled===!0&&s?.aiForOrg?.aiCapabilities?.aiAssistants?.enabled===!0};async function E({portalUrl:e}){e&&a("warn","The arcadeAssistant property is deprecated. Set esriConfig.portalUrl instead of arcadeAssistant.portalUrl.");let s=e||R.portalUrl;if(!s)return a("warn","Arcade Assistant initialization failed. Reason: missing portal url."),{shouldRender:!1};let t=new I({url:s,authMode:"no-prompt"});if(await t.load().catch(r=>(a("warn",`Failed to load portal. Reason: ${r}.`),{shouldRender:!1})),!t.user)return a("warn","User is not signed in."),{shouldRender:!1};let i=t.sourceJSON,n=i?.isPortal===!0;if(n&&!$(i.enterpriseVersion))return{shouldRender:!1};let{restUrl:o}=t,C=`${o}/portals/self/settings`,N=m(C,{query:{f:"json"}}).then(r=>r.data).catch(r=>(a("warn",`Failed to fetch settingsUrl. Reason: ${r}.`),{})),l=n,F=l?m(`${o}/portals/self/aiServer/status`,{query:{f:"json"}}).then(r=>r.data).catch(r=>(a("warn",`Failed to fetch aiServerStatusUrl. Reason: ${r}.`),{})):Promise.resolve({}),[d,p]=await Promise.all([N,F]);if(l&&!p?.success)return{shouldRender:!1};let A=i.helpBase||"";if(!d)return a("warn","Settings response is not available."),{shouldRender:!1};let c={orgAiAssistantsEnabled:P(d),betaAppsAllowed:d.blockBetaApps!==!0,serviceUrlAvailable:!!i?.helperServices?.aiAssistantServices?.url,userHasUseAiAssistantsPrivilege:["portal:user:useAIAssistants","portal:user:useAI"].some(r=>i?.user?.privileges?.includes(r)),aiServerConfigured:p?.aiCapabilities?.aiAssistants?.configured===!0};c.betaAppsAllowed||a("warn","Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."),c.userHasUseAiAssistantsPrivilege||a("warn","User does not have the required privileges to use AI Assistants.");let y=l?[...S,"aiServerConfigured"]:S,k=l?[...u,"aiServerConfigured"]:u,f=w(c,y),v=w(c,k),g=i?.helperServices?.aiAssistantServices?.url;return g?{shouldRender:!0,portalUrl:s,availableFeatures:{codeActions:f,prompting:v},serviceUrl:g,helpBase:A,feedbackServiceUrl:U}:{shouldRender:!0,portalUrl:s,availableFeatures:{codeActions:f,prompting:v},helpBase:A,feedbackServiceUrl:U}}function $(e){let s=h(e),[t,i="0"]=s.split("."),n=Number.parseInt(t,10),o=Number.parseInt(i,10);return Number.isNaN(n)||Number.isNaN(o)?!1:n>12||n===12&&o>=2}function H(e){return e.toLowerCase().includes("pro")}function _(){let e=R?.applicationName;return H(e)?e.toLowerCase():`jsSdk_${B}`}return{a:E,b:_}},"config","kernel","portal/Portal","request")
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{K as s,w as e}from"./7CO7POPG.js";import"./BFPEJYVB.js";import"./H6RQVSYM.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./
|
|
2
|
+
import{K as s,w as e}from"./7CO7POPG.js";import"./BFPEJYVB.js";import"./H6RQVSYM.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./FPSCELQQ.js"),"appVersion,closed,closePanel:,diagnostics:,disableQuestionAnswerLogging,editorRef:,feedbackServiceUrl,helpBase,insertText:,portalUrl,promptingEnabled,serviceUrl;destroy,openPrompt"],"arcgis-arcade-debugger-console":[()=>import("./WYXCUCXU.js"),"debuggerStore:,modelId"],"arcgis-arcade-debugger-output":[()=>import("./EU5ETQGL.js"),"debuggerStore:,outputTitle,result:"],"arcgis-arcade-editor":[()=>import("./PU5GFLJW.js"),"arcadeAssistant:,customPanels:,disableAssistant,editorInstance:,editorOptions:,enableDebugger,externalExecutor:,hideDocumentationActions,hideSideBar,messageOverrides:,messages:,openedSidePanel,profile:,script,sideActionBarExpanded,snippets:,suggestions:,testData:;getTestResult,openArcadeAssistant,setFocus"],"arcgis-arcade-results":[()=>import("./XC2AMQB3.js"),"consoleLogs:,executionTiming:,hideHeader,loading,openedResultPanel,result:"],"arcgis-arcade-suggestions":[()=>import("./SRHUAAB4.js"),"closed,suggestions:"],"arcgis-code-editor":[()=>import("./YMZOK6SL.js"),"editorInstance:,editorOptions:,language,modelId,value;insertSnippet,insertText,setFocus"],"arcgis-code-editor-shell":[()=>import("./YKJS4OIT.js")],"arcgis-code-viewer":[()=>import("./32JFHGOY.js"),"language,lineNumbers,round"],"arcgis-editor-variables":[()=>import("./NE7AQ3M2.js"),"closed,heading,hideDescriptions,loading,messageOverrides:,modelId,variable:"],"arcgis-language-api-panel":[()=>import("./RO677XRH.js"),"apiLibrary:,closed,hideDocumentationActions,languageId,loading"],"arcgis-sql-expression-editor":[()=>import("./5BDVHLU3.js"),"hideDescriptionsInFieldsPanel,hideSideBar,messageOverrides:,messages:,profile:,script;setFocus"],"arcgis-sql-layer-editor":[()=>import("./46HXMXDY.js"),"editorInstance:,editorOptions:,hideSideBar,messageOverrides:,messages:,openedSidePanel,profile:,script;setFocus"]});i({resourcesUrl:import.meta.url});var r=new CSSStyleSheet;r.replaceSync("@layer{:not([hydrated]):is(arcgis-arcade-editor,arcgis-code-editor,arcgis-code-editor-shell,arcgis-code-viewer,arcgis-sql-expression-editor,arcgis-sql-layer-editor){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,r];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,s)
|
package/dist/chunks/utils.js
CHANGED
|
@@ -1,93 +1,95 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import
|
|
3
|
-
import { version as
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
import U from "@arcgis/core/config.js";
|
|
3
|
+
import { version as q } from "@arcgis/core/kernel.js";
|
|
4
|
+
import { log as F } from "@arcgis/toolkit/log";
|
|
5
|
+
import { getMinorVersion as I } from "@arcgis/toolkit/string";
|
|
6
|
+
import y from "@arcgis/core/portal/Portal.js";
|
|
7
|
+
import b from "@arcgis/core/request.js";
|
|
8
|
+
const h = "https://services6.arcgis.com/HXHga6CfMLMBOlBX/ArcGIS/rest/services/survey123_6e349a50b4504ca6b6107216d568db5f_form/FeatureServer/0", a = (e, s) => {
|
|
9
|
+
F(e, "Arcade Assistant", s);
|
|
10
|
+
}, u = [
|
|
10
11
|
"orgAiAssistantsEnabled",
|
|
11
12
|
"betaAppsAllowed",
|
|
12
13
|
"serviceUrlAvailable",
|
|
13
14
|
"userHasUseAiAssistantsPrivilege"
|
|
14
|
-
],
|
|
15
|
-
const {
|
|
16
|
-
return s ===
|
|
17
|
-
}, P = async (e) => (await w.getCredential(e, { oAuthPopupConfirmation: !1 })).token, B = async (e) => {
|
|
18
|
-
try {
|
|
19
|
-
return !!await w.checkSignInStatus(e);
|
|
20
|
-
} catch {
|
|
21
|
-
return t("warn", "User is not signed in."), !1;
|
|
22
|
-
}
|
|
15
|
+
], R = u, S = (e, s) => s.every((i) => e[i] === !0), B = (e) => {
|
|
16
|
+
const { aiConfig: s } = e;
|
|
17
|
+
return s?.aiForOrg?.enabled === !0 && s?.aiForOrg?.aiCapabilities?.aiAssistants?.enabled === !0;
|
|
23
18
|
};
|
|
24
|
-
async function
|
|
19
|
+
async function z({
|
|
25
20
|
portalUrl: e
|
|
26
21
|
}) {
|
|
27
|
-
e &&
|
|
22
|
+
e && a(
|
|
28
23
|
"warn",
|
|
29
24
|
"The arcadeAssistant property is deprecated. Set esriConfig.portalUrl instead of arcadeAssistant.portalUrl."
|
|
30
25
|
);
|
|
31
|
-
const s = e ||
|
|
26
|
+
const s = e || U.portalUrl;
|
|
32
27
|
if (!s)
|
|
33
|
-
return
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
28
|
+
return a("warn", "Arcade Assistant initialization failed. Reason: missing portal url."), { shouldRender: !1 };
|
|
29
|
+
const i = new y({ url: s, authMode: "no-prompt" });
|
|
30
|
+
if (await i.load().catch((r) => (a("warn", `Failed to load portal. Reason: ${r}.`), { shouldRender: !1 })), !!!i.user)
|
|
31
|
+
return a("warn", "User is not signed in."), { shouldRender: !1 };
|
|
32
|
+
const t = i.sourceJSON, n = t?.isPortal === !0;
|
|
33
|
+
if (n && !$(t.enterpriseVersion))
|
|
36
34
|
return { shouldRender: !1 };
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const { restUrl: p } = i, w = `${p}/portals/self/settings`, C = b(w, {
|
|
36
|
+
query: { f: "json" }
|
|
37
|
+
}).then((r) => r.data).catch((r) => (a("warn", `Failed to fetch settingsUrl. Reason: ${r}.`), {})), o = n, P = o ? b(`${p}/portals/self/aiServer/status`, { query: { f: "json" } }).then((r) => r.data).catch((r) => (a("warn", `Failed to fetch aiServerStatusUrl. Reason: ${r}.`), {})) : Promise.resolve({}), [c, f] = await Promise.all([
|
|
38
|
+
C,
|
|
39
|
+
P
|
|
40
|
+
]);
|
|
41
|
+
if (o && !f?.success)
|
|
43
42
|
return { shouldRender: !1 };
|
|
44
|
-
const
|
|
45
|
-
if (!
|
|
46
|
-
return
|
|
43
|
+
const A = t.helpBase || "";
|
|
44
|
+
if (!c)
|
|
45
|
+
return a("warn", "Settings response is not available."), { shouldRender: !1 };
|
|
47
46
|
const l = {
|
|
48
|
-
orgAiAssistantsEnabled:
|
|
49
|
-
betaAppsAllowed:
|
|
50
|
-
serviceUrlAvailable: !!
|
|
51
|
-
userHasUseAiAssistantsPrivilege:
|
|
47
|
+
orgAiAssistantsEnabled: B(c),
|
|
48
|
+
betaAppsAllowed: c.blockBetaApps !== !0,
|
|
49
|
+
serviceUrlAvailable: !!t?.helperServices?.aiAssistantServices?.url,
|
|
50
|
+
userHasUseAiAssistantsPrivilege: ["portal:user:useAIAssistants", "portal:user:useAI"].some(
|
|
51
|
+
(r) => t?.user?.privileges?.includes(r)
|
|
52
|
+
),
|
|
53
|
+
aiServerConfigured: f?.aiCapabilities?.aiAssistants?.configured === !0
|
|
52
54
|
};
|
|
53
|
-
l.betaAppsAllowed ||
|
|
55
|
+
l.betaAppsAllowed || a(
|
|
54
56
|
"warn",
|
|
55
57
|
"Arcade Assistant is blocked by the organization settings. To enable it, do not block beta apps in the organization settings."
|
|
56
|
-
), l.userHasUseAiAssistantsPrivilege ||
|
|
57
|
-
const
|
|
58
|
-
return
|
|
58
|
+
), l.userHasUseAiAssistantsPrivilege || a("warn", "User does not have the required privileges to use AI Assistants.");
|
|
59
|
+
const k = o ? [...R, "aiServerConfigured"] : R, N = o ? [...u, "aiServerConfigured"] : u, g = S(l, k), m = S(l, N), v = t?.helperServices?.aiAssistantServices?.url;
|
|
60
|
+
return v ? {
|
|
59
61
|
shouldRender: !0,
|
|
60
62
|
portalUrl: s,
|
|
61
63
|
availableFeatures: {
|
|
62
|
-
codeActions:
|
|
63
|
-
prompting:
|
|
64
|
+
codeActions: g,
|
|
65
|
+
prompting: m
|
|
64
66
|
},
|
|
65
|
-
serviceUrl:
|
|
66
|
-
helpBase:
|
|
67
|
-
feedbackServiceUrl:
|
|
67
|
+
serviceUrl: v,
|
|
68
|
+
helpBase: A,
|
|
69
|
+
feedbackServiceUrl: h
|
|
68
70
|
} : {
|
|
69
71
|
shouldRender: !0,
|
|
70
72
|
portalUrl: s,
|
|
71
73
|
availableFeatures: {
|
|
72
|
-
codeActions:
|
|
73
|
-
prompting:
|
|
74
|
+
codeActions: g,
|
|
75
|
+
prompting: m
|
|
74
76
|
},
|
|
75
|
-
helpBase:
|
|
76
|
-
feedbackServiceUrl:
|
|
77
|
+
helpBase: A,
|
|
78
|
+
feedbackServiceUrl: h
|
|
77
79
|
};
|
|
78
80
|
}
|
|
79
|
-
function
|
|
80
|
-
const s =
|
|
81
|
-
return Number.isNaN(
|
|
81
|
+
function $(e) {
|
|
82
|
+
const s = I(e), [i, d = "0"] = s.split("."), t = Number.parseInt(i, 10), n = Number.parseInt(d, 10);
|
|
83
|
+
return Number.isNaN(t) || Number.isNaN(n) ? !1 : t > 12 || t === 12 && n >= 2;
|
|
82
84
|
}
|
|
83
|
-
function
|
|
85
|
+
function E(e) {
|
|
84
86
|
return e.toLowerCase().includes("pro");
|
|
85
87
|
}
|
|
86
|
-
function
|
|
87
|
-
const e =
|
|
88
|
-
return
|
|
88
|
+
function L() {
|
|
89
|
+
const e = U?.applicationName;
|
|
90
|
+
return E(e) ? e.toLowerCase() : `jsSdk_${q}`;
|
|
89
91
|
}
|
|
90
92
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
L as a,
|
|
94
|
+
z as g
|
|
93
95
|
};
|