@arcgis/coding-components 5.1.0-next.5 → 5.1.0-next.7
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/{QTZWZ5B5.js → YUYP77Z2.js} +1 -1
- package/dist/cdn/assets/code-editor/sql-expr.worker.js +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-arcade-coding-assistant/customElement.js +46 -46
- package/dist/components/arcgis-arcade-editor/customElement.d.ts +5 -1
- 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 +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{a as oe}from"./ZYS253RG.js";import"./MP6Z45SA.js";import b from"./MKAM2LVE.js";import"./P5D2YYFD.js";import a from"./X2LBWSH3.js";import{d as ce}from"./IFNCCZ7O.js";import{c as ne,d as re}from"./QWLPT7LO.js";import"./NKCYMRE4.js";import"./BQLG62QR.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{A as X,B as Z,C as U,D as ee,E as te,F as ie,G as ae,H as O,J as se,h as W,j as p,k as P,l as _,s as K,v as N,w as q,x as D,y as I,z as k}from"./EMMNZESW.js";import{a as T}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([Se,pe,Te,Ae,Ce,{getDeclaredVoxelMembers:Ie,getDeclaredPixelMembers:Me},Ee,{property:w,subclass:Re},{g:le,h:F},z])=>{var de=(t,e,i)=>{let a=new Map;for(let s=e;s<=i;s++)a.set(t[s],s);return a},L=q(class extends D{constructor(t){if(super(t),t.type!==N.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,i){let a;i===void 0?i=e:e!==void 0&&(a=e);let s=[],n=[],l=0;for(let d of t)s[l]=a?a(d,l):l,n[l]=i(d,l),l++;return{values:n,keys:s}}render(t,e,i){return this.dt(t,e,i).values}update(t,[e,i,a]){let s=Z(t),{values:n,keys:l}=this.dt(e,i,a);if(!Array.isArray(s))return this.ut=l,n;let d=this.ut??=[],c=[],o,g,r=0,u=s.length-1,m=0,h=n.length-1;for(;r<=u&&m<=h;)if(s[r]===null)r++;else if(s[u]===null)u--;else if(d[r]===l[m])c[m]=k(s[r],n[m]),r++,m++;else if(d[u]===l[h])c[h]=k(s[u],n[h]),u--,h--;else if(d[r]===l[h])c[h]=k(s[r],n[h]),I(t,c[h+1],s[r]),r++,h--;else if(d[u]===l[m])c[m]=k(s[u],n[m]),I(t,s[r],s[u]),u--,m++;else if(o===void 0&&(o=de(l,m,h),g=de(d,r,u)),o.has(d[r]))if(o.has(d[u])){let f=g.get(l[m]),S=f!==void 0?s[f]:null;if(S===null){let v=I(t,s[r]);k(v,n[m]),c[m]=v}else c[m]=k(S,n[m]),I(t,s[r],S),s[f]=null;m++}else U(s[u]),u--;else U(s[r]),r++;for(;m<=h;){let f=I(t,c[h+1]);k(f,n[m]),c[m++]=f}for(;r<=u;){let f=s[r++];f!==null&&U(f)}return this.ut=l,X(t,c),P}});var R=class extends D{constructor(e){if(super(e),this.it=_,e.type!==N.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===P)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let i=[e];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}};R.directiveName="unsafeHTML",R.resultType=1;var V=q(R);var Ve=W`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,A=class extends Error{constructor({message:e,code:i,subCode:a,details:s,source:n}){super(e),this.name="ArcadeAssistantError",this.code=i,this.subCode=a,this.details=s,this.source=n}};function ue(t){if(!t)return;let e=t.indexOf('{"error":');if(e!==-1)try{let i=t.slice(e),a=JSON.parse(i);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Pe(t){let{baseUrl:e,skillId:i,message:a,authToken:s,previousConversationId:n,context:l}=t,d=i?`${e}/skills/${i}/chat`:`${e}/chat`,c=[],o={message:a,context:l};n&&(o.conversation_id=n);let g;try{g=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(o),responseType:"json"})}catch(v){let $=v,C=$.details?.rawResponse||$.message||String(v),M=ue(C);throw M?new A(M):v}let r=g.data;c.push(r);let u=r.conversationId,m=r.inquiryId,h=r.sequenceNumber;async function f(){let v=0,$=100;for(;v<$;){await new Promise(E=>setTimeout(E,1e3));let C=Ne(u,h,m),M;try{M=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(C),responseType:"json"})}catch(E){let J=E,ke=J.details?.rawResponse||J.message||String(E),Y=ue(ke);throw Y?new A(Y):E}let x=M.data;if(x.context?.kind==="ArcgisErrorAsContext"&&x.context.error)throw new A({message:x.context.error.message||"ArcGIS Assistant error",code:x.context.error.code,subCode:x.context.error.subCode,details:x.context.error.details,source:"polling-response"});if(c.push(x),h=x.sequenceNumber,v++,!x.hasMore)break}if(v===$)throw new A({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let S=120*1e3;return await Promise.race([f(),new Promise((v,$)=>setTimeout(()=>$(new A({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),S))]),c}function Ne(t,e,i){return{conversationId:t,inquiryId:i,ackSequenceNumber:e}}function qe(t){return t.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":t.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":t.message}var De=({notices:t})=>t.length?p`<div class="border-block-end">${L(t,e=>e.id??e.title,e=>p`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&p`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&p`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Ue=t=>{let e=t.value.length,i=72,a=180,s=t.offsetWidth,n=Math.max(1,Math.floor(s/8)),l=Math.ceil(e/n),d=i+(l-2)*24;t.style.setProperty("--calcite-text-area-min-height",`${Math.min(d,a)}px`)},Oe=({promptValidationMessage:t,errorMessage:e,contextTooBig:i,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:s,setErrorMessage:n,messages:l})=>{let d=[];if(t&&d.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:t,closable:!0}),e&&d.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),i&&!a){let c=l.contextreduced??"Context reduced",o=l.contextreducedmessage??"The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";d.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:o,closable:!0,onClose:()=>s(!0)})}return d};function _e({messages:t}){return p`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta??"Beta"}>${t.beta??"Beta"}</calcite-chip>`}function Fe({popoverContent:t,messages:e}){return p`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer??"Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${t}</div></calcite-popover>`}function ze({errorMessage:t,slot:e}){return p`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??O}>${t}</calcite-input-message></div>`}function Le({active:t,setActive:e,messages:i}){return p`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${i.expressionapplied??"Expression applied"}><div slot=message>${i.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function Be({context:t,messages:e}){return t?p`<div class="gaps">${t.profileId&&p`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function je({isDisabled:t,isReadOnly:e,setQuestion:i,setIsViewingResult:a,textAreaRef:s,question:n,errorMessage:l,setErrorMessage:d,promptValidationMessage:c,setPromptValidationMessage:o,submitQuestion:g,messages:r,mode:u,assistantRef:m,context:h,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S}){let v=h?.contextTooLarge??!1,$=Oe({promptValidationMessage:c,errorMessage:l,contextTooBig:v,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S,setErrorMessage:d,messages:r});return p`<div class="text-area-wrapper">${De({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${t||e} class=${ae($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${r.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${C=>{Ue(C.target),i(C.target.value)}} ${te(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${h&&Be({context:h,messages:r})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async()=>{a(!1),i("")}} .label=${r.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${r.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async()=>{a(!1),i("")}} class="hidden-below-380" scale=s>${r.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-below-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-above-380" .label=${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}></calcite-button></div></div></div></calcite-text-area></div>`}var He="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function Ge({setOpen:t,messages:e,feedback:i,learnMoreUrl:a,setFeedback:s,onSubmit:n}){return i.active?p`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${()=>t(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${l=>s({...i,text:l.target.value})} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo??"Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${l=>{s({...i,termsAccepted:l.target.checked})}} .disabled=${i.submitting}></calcite-checkbox><span>${V((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Qe} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${He} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${V((e.feedbackhelps??"Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}",`<calcite-link href=${a} target="_blank">${e.learnmore??"Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${()=>t(!1)} .disabled=${i.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted||i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function me({assistantsEnabled:t,messages:e,slot:i,helpTopicUrl:a}){return p`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${i??O} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing??"Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new??"New"} kind=brand scale=s>${e.new??"New"}</calcite-chip></div>${t?p`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${V((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${a} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:p`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function Je({messages:t,onProceed:e,onExit:i,helpTopicUrl:a}){return p`<calcite-dialog close-disabled placement=top .heading=${t.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${V((t.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${a} target="_blank">${t.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ye({messages:t,suggestions:e,onSuggestionClick:i}){return p`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(a=>p`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${()=>i?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var he=200;function ge({hidden:t=!1,expanded:e=!1,messages:i,cards:a,heading:s,collapsible:n=!1,showEffectsIcon:l=!1,onCopyCode:d,standalone:c}){return p`<calcite-block .hidden=${t} id=result-block .heading=${s??i.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${l&&p`<calcite-chip .label=${i.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${i.assistantresponses??"Assistant responses"}>${L(a,o=>o.conversationId,o=>p`<calcite-card><div slot=heading><div class="prior-prompt"><span>${o.priorPrompt.length>he?`${o.priorPrompt.slice(0,he)}...`:o.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} @click=${g=>{let r=g.currentTarget;navigator.clipboard.writeText(o.priorPrompt).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${o.message&&c&&p`<div class="response-error-container">${ze({errorMessage:o.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext??"Response Context"} scale=s>${o.message&&!c&&p`<calcite-tooltip .referenceElement=${`response-chip-${o.conversationId}-error`} placement=top-start>${o.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${o.conversationId}-error`} .label=${i.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${We({card:o,messages:i})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${o.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start>${i.addtoeditor??"Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor??"Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${()=>o.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.replaceineditor??"Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${g=>{let r=g.currentTarget;d(o.code).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${o.onThumbsUp} .id=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${o.onThumbsDown} .id=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var We=({card:t,messages:e})=>{let i=K(),a=`response-chip-profile-${t.conversationId}-${i}`,s=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId);return p`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${a??O}>${t.profileId}</calcite-chip>`},be=t=>t.type==="featureSet",B=t=>{if(!le(t))return[];let e=[];return t.relationships?.forEach(i=>{e.push(i.toJSON())}),e},j=t=>t.length>0?{relationships:t}:{},Ke=t=>ce(t).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),H=t=>t?{fields:Ke(t)}:{fields:[]};async function fe(t){let e=await t.loadSource(),i=F(e)&&e.isTable,a=B(e);return{name:t.name,type:"featureSet",isTable:i,...H(e?.fields),...j(a)}}async function xe(t){switch(t.type){case"feature":{let e=await t.loadSource(),i=B(e);return{name:t.name,type:t.type,...H(e?.fields),...j(i)}}case"featureSet":{let e=await t.loadSource(),i=F(e)&&e.isTable;return{name:t.name,type:"featureSet",...i?{isTable:i}:{},...H(e?.fields),...j(B(e))}}case"featureSetCollection":{let e=await t.loadSource(),i=e?.layers.filter(be)??[],a=e?.tables.filter(be)??[],s=await Promise.all(i.map(fe)),n=await Promise.all(a.map(fe));return{name:t.name,type:"featureSetCollection",layers:s,tables:n}}case"dictionary":{let e=await Promise.all(t.dictionaryVariables.map(xe));return{name:t.name,type:"dictionary",attributes:e}}case"pixel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"pixel"};let i=await Me(e);return{name:t.name,type:"pixel",members:i.map(ve)}}case"voxel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"voxel"};let i=await Ie(e);return{name:t.name,type:"voxel",members:i.map(ve)}}case"array":return{name:t.name,type:"array",elementType:t.elementType.type};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:t.name,type:t.type}}}function ve(t){return t.type==="array"?{name:t.name,type:"array",elementType:t.elementType.type}:{name:t.name,type:t.type}}async function Xe(t){return{variables:await Promise.all(t.variables.map(xe))}}var Ze=1e5;function et(t){let e=new TextEncoder().encode(t).length;return Math.ceil(e/3.5)}function Q(t){return et(JSON.stringify(t))}function tt(t){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),i=a=>{switch(a.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:a.name,type:a.type,..."isTable"in a&&a.isTable?{isTable:a.isTable}:{},..."relationships"in a?{relationships:a.relationships}:{}};case"featureSetCollection":return{name:a.name,type:"featureSetCollection",layers:a.layers.map(e),tables:a.tables.map(e)};case"dictionary":return{name:a.name,type:"dictionary",attributes:a.attributes.map(i)};case"pixel":case"voxel":return{name:a.name,type:a.type};case"array":return{name:a.name,type:"array",...a.elementType?{elementType:a.elementType}:{}};default:return a}};return{variables:t.variables.map(i)}}function it(t){let e=t.variables,i=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],s=a?[a]:[];return{context:{variables:s},wasReduced:i!==s.length,reducedToVariableName:a?.name}}function at(t){return Q(t)>Ze}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,y=(t,e,i,a)=>{for(var s=a>1?void 0:a?ot(e,i):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(s=(a?l(e,i,s):l(s))||s);return a&&s&&st(e,i,s),s},b=class extends Ee{constructor(t){super(t),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};y([w()],b.prototype,"viewMode",2);y([w()],b.prototype,"confirmationActive",2);y([w()],b.prototype,"contextReducedNoticeDismissed",2);y([w()],b.prototype,"splashActive",2);y([w()],b.prototype,"isSubmitting",2);y([w()],b.prototype,"errorMessage",2);y([w()],b.prototype,"promptValidationMessage",2);y([w()],b.prototype,"question",2);y([w()],b.prototype,"history",2);y([w()],b.prototype,"feedback",2);y([w()],b.prototype,"context",2);b=y([Re("ArcadeAssistantViewState")],b);var nt="arcade_generation",rt="ArcadeCodeRequest",ye="visualization",ct="ArcadeAssistant",lt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras"],we=[],$e=!0,G=class extends ie{constructor(){super(...arguments),this.textAreaRef=ee(),this.messages=oe(),this._feedbackService=void 0,this.viewState=new b,this.handleFeedbackButton=(e,i)=>{this.updateViewState({feedback:{active:!0,value:e,item:i,termsAccepted:!1,text:"",submitting:!1}})},this.handleFeedbackSheetClose=()=>{this.updateViewState({feedback:{active:!1}})},this.handleFeedbackSubmit=async()=>{if(!this.viewState.feedback.active)return;this.updateViewState({feedback:{...this.viewState.feedback,submitting:!0}});let e=await this.ensureFeedbackService();if(!e){this.handleFeedbackSheetClose();return}let i=this.viewState.feedback.item.contextSnapshot,a=Ae.applicationName;!a&&!this.appVersion&&T("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:s,text:n,termsAccepted:l,item:{question:d,formattedScript:c,conversationId:o}}=this.viewState.feedback,g={user_evaluation:s,your_comments:n||void 0,question:d??"",answer:encodeURIComponent(c??""),useragent:navigator.userAgent,_source:ct,version:this.appVersion||a||"NOT_SET",context:i?JSON.stringify(i):"",extras:i?.profileId??"",conversation_id:o??"",privacy_statement:l?"I_agree":""};try{await e.applyEdits({addFeatures:[new Ce({attributes:g})]})}catch(r){T("error",this,"Error submitting feedback.",{detail:{error:r}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.assistantsEnabled=!1,this.closed=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,assistantsEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1}}static{this.styles=Ve}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
|
|
2
|
+
import{a as oe}from"./ZYS253RG.js";import"./MP6Z45SA.js";import b from"./MKAM2LVE.js";import"./P5D2YYFD.js";import a from"./X2LBWSH3.js";import{d as ce}from"./IFNCCZ7O.js";import{c as ne,d as re}from"./QWLPT7LO.js";import"./NKCYMRE4.js";import"./BQLG62QR.js";import"./WMLTLTIE.js";import"./UYBZWFE5.js";import{A as X,B as Z,C as U,D as ee,E as te,F as ie,G as ae,H as O,J as se,h as W,j as p,k as P,l as _,s as K,v as N,w as q,x as D,y as I,z as k}from"./EMMNZESW.js";import{a as T}from"./BCUUVBXH.js";import"./YLN7EMJC.js";import"./GHSEU7VA.js";import"./4OSKRQ5X.js";import"./NG7S6FUK.js";import"./3TTFCHAA.js";export default $arcgis.t(([Se,pe,Te,Ae,Ce,{getDeclaredVoxelMembers:Ie,getDeclaredPixelMembers:Me},Ee,{property:w,subclass:Re},{g:le,h:F},z])=>{var de=(t,e,i)=>{let a=new Map;for(let s=e;s<=i;s++)a.set(t[s],s);return a},L=q(class extends D{constructor(t){if(super(t),t.type!==N.CHILD)throw Error("repeat() can only be used in text expressions")}dt(t,e,i){let a;i===void 0?i=e:e!==void 0&&(a=e);let s=[],n=[],l=0;for(let d of t)s[l]=a?a(d,l):l,n[l]=i(d,l),l++;return{values:n,keys:s}}render(t,e,i){return this.dt(t,e,i).values}update(t,[e,i,a]){let s=Z(t),{values:n,keys:l}=this.dt(e,i,a);if(!Array.isArray(s))return this.ut=l,n;let d=this.ut??=[],c=[],o,g,r=0,u=s.length-1,m=0,h=n.length-1;for(;r<=u&&m<=h;)if(s[r]===null)r++;else if(s[u]===null)u--;else if(d[r]===l[m])c[m]=k(s[r],n[m]),r++,m++;else if(d[u]===l[h])c[h]=k(s[u],n[h]),u--,h--;else if(d[r]===l[h])c[h]=k(s[r],n[h]),I(t,c[h+1],s[r]),r++,h--;else if(d[u]===l[m])c[m]=k(s[u],n[m]),I(t,s[r],s[u]),u--,m++;else if(o===void 0&&(o=de(l,m,h),g=de(d,r,u)),o.has(d[r]))if(o.has(d[u])){let f=g.get(l[m]),S=f!==void 0?s[f]:null;if(S===null){let v=I(t,s[r]);k(v,n[m]),c[m]=v}else c[m]=k(S,n[m]),I(t,s[r],S),s[f]=null;m++}else U(s[u]),u--;else U(s[r]),r++;for(;m<=h;){let f=I(t,c[h+1]);k(f,n[m]),c[m++]=f}for(;r<=u;){let f=s[r++];f!==null&&U(f)}return this.ut=l,X(t,c),P}});var R=class extends D{constructor(e){if(super(e),this.it=_,e.type!==N.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===_||e==null)return this._t=void 0,this.it=e;if(e===P)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;let i=[e];return i.raw=i,this._t={_$litType$:this.constructor.resultType,strings:i,values:[]}}};R.directiveName="unsafeHTML",R.resultType=1;var V=q(R);var Ve=W`:host(:not([closed])){container-type:size;--calcite-block-border-color: var(--calcite-color-transparent);box-sizing:border-box;.submission-actions-wrapper{display:flex;flex-direction:column;width:100%;gap:.75rem}.submission-actions{display:flex;flex-direction:row;gap:.5rem;justify-content:space-between}@container (max-width: 380px){.hidden-below-380{display:none}}@container (min-width: 380px){.hidden-above-380{display:none}}.gaps{display:flex;gap:.25rem}.align-inline-end{margin-inline-start:auto}.context-popover p{padding:0 .5rem;font-size:var(--calcite-font-size-sm)}.feedback-content{padding:var(--calcite-spacing-sm);display:flex;flex-direction:column;max-height:75cqb;overflow-y:auto;>*{margin-block-end:.5rem}>*:last-child,.terms-label{margin-block-end:0}calcite-text-area{--calcite-text-area-min-height: 4rem}calcite-notice{margin-block-start:0}}.feedback-sheet{--calcite-sheet-height: auto;--calcite-sheet-max-height: 100%;--calcite-sheet-min-height: auto}.feedback-footer{display:flex;justify-content:flex-end;gap:.5rem;width:100%}calcite-chip[slot=header-actions-end]{align-self:center;margin-inline-end:.5rem}calcite-flow-item calcite-shell{background:transparent}calcite-block{width:100%;max-width:100%;align-self:flex-end;background-color:transparent;margin-block:0}calcite-sheet{--calcite-sheet-scrim-background: rgba(200, 200, 200, .5)}calcite-list-item calcite-button{margin-inline-end:.25rem}calcite-flow-item calcite-shell calcite-notice{margin-block:1rem}calcite-block[open]:last-of-type{border-block-end:0}.text-area-wrapper{display:flex;border-radius:var(--calcite-corner-radius-round);margin:.75rem;overflow:hidden;--calcite-color-border-input: transparent;position:sticky;box-shadow:var(--calcite-shadow-sm);flex:none;flex-direction:column}calcite-text-area{height:auto;overflow:hidden;--calcite-font-weight-normal: 500;font-weight:500;line-height:1.2}calcite-flow{height:100%}calcite-popover calcite-list{--calcite-list-background-color: transparent;--calcite-input-border-color: transparent}calcite-popover calcite-list calcite-filter{--calcite-spacing-sm: 0}.contained-popover-or-tooltip{--calcite-popover-max-size-x: 100%;--calcite-tooltip-max-size-x: 100%}.info-heading{font-size:var(--calcite-font-size-0);color:var(--calcite-color-text-1);margin:0}.info-heading-row{display:flex;align-items:center;gap:var(--calcite-spacing-sm);flex-wrap:wrap}.unstyled-h3{margin:unset;font-size:var(--calcite-font-size-md)}.unstyled-shell{position:unset;inset:unset;display:unset;block-size:unset;inline-size:unset}.suggestion-button{font-weight:var(--calcite-font-weight-medium)}.suggestions{display:flex;flex-direction:row;gap:var(--calcite-spacing-xs);flex-wrap:wrap}.info-block{max-width:450px}#result-block{calcite-card-group{--calcite-card-group-gap: 1.25rem}calcite-card{--calcite-card-corner-radius: var(--calcite-corner-radius-round);--calcite-card-border-color: transparent;width:100%}.positioned-code-content{display:flex;flex-direction:row;gap:.5rem;padding:.5rem}calcite-card [slot=heading] calcite-chip{margin-block-start:.25rem}.code-response-wrapper{position:relative;background:var(--calcite-color-foreground-2);border-radius:var(--calcite-corner-radius-round);margin-top:-1.5rem}.prior-prompt{display:flex;flex-direction:row;padding:0;overflow-y:hidden;overflow-x:auto;margin:.25rem 0 .75rem;align-items:center;max-width:100%;span{overflow-x:auto;overflow-y:hidden}}.copy-feedback{display:none}.copy-prompt-button{align-self:flex-start;margin-inline-start:auto}.response-secondary-action-button[data-copied]+.copy-feedback,.copy-prompt-button[data-copied]+.copy-feedback{display:block;span{padding:.75rem 1rem;font-size:var(--calcite-font-size--2);line-height:1.375;color:var(--calcite-color-text--2);font-weight:var(--calcite-font-weight-medium)}}.copy-prompt-button[data-copied]~.copy-tooltip,.response-secondary-action-button[data-copied]~.copy-tooltip{display:none}code{white-space:pre;font-size:12px;margin:0;overflow-x:auto;font-family:Fira Mono,Consolas,Menlo,monospace;display:block;max-height:12rem;position:relative;padding:.5rem}.response-secondary-action-button{margin-left:.5rem}.add-to-editor-button{--calcite-internal-button-border-color: unset}}.collapsible-code{padding:.5rem}.collapsible-code summary{cursor:pointer;font-weight:500;color:var(--calcite-color-brand);outline:none;padding:.25rem 0}.collapsible-code[open] summary{color:var(--calcite-color-text-2)}.response-error-container{padding:.5rem;background:color-mix(in srgb,var(--calcite-color-status-warning) 10%,transparent);border-radius:var(--calcite-corner-radius-round);margin:1rem 0;font-size:var(--calcite-font-size--2);--calcite-input-message-icon-color: var(--calcite-color-status-warning)}.response-error-chip{--calcite-internal-chip-background-color: var(--calcite-color-status-warning);--calcite-chip-icon-color: var(--calcite-color-foreground-1);--calcite-chip-border-color: var(--calcite-color-transparent)}.feedback-actions{gap:unset}.contained{max-width:100%;max-height:100%;max-width:100cqi;max-height:75cqb;overflow-y:auto}.submission-notice{--calcite-notice-border-color: transparent;margin-block:0;width:100%;--calcite-font-size-relative-base: var(--calcite-font-size--2)}.border-block-end{border-block-end:1px solid var(--calcite-color-border-3)}.round-top{border-radius:var(--calcite-corner-radius-round) var(--calcite-corner-radius-round) 0 0}}:host([closed]){display:none}`,A=class extends Error{constructor({message:e,code:i,subCode:a,details:s,source:n}){super(e),this.name="ArcadeAssistantError",this.code=i,this.subCode=a,this.details=s,this.source=n}};function ue(t){if(!t)return;let e=t.indexOf('{"error":');if(e!==-1)try{let i=t.slice(e),a=JSON.parse(i);if(a&&typeof a=="object"&&a.error)return a.error}catch{return}}async function Pe(t){let{baseUrl:e,skillId:i,message:a,authToken:s,previousConversationId:n,context:l}=t,d=i?`${e}/skills/${i}/chat`:`${e}/chat`,c=[],o={message:a,context:l};n&&(o.conversation_id=n);let g;try{g=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(o),responseType:"json"})}catch(v){let $=v,C=$.details?.rawResponse||$.message||String(v),M=ue(C);throw M?new A(M):v}let r=g.data;c.push(r);let u=r.conversationId,m=r.inquiryId,h=r.sequenceNumber;async function f(){let v=0,$=100;for(;v<$;){await new Promise(E=>setTimeout(E,1e3));let C=Ne(u,h,m),M;try{M=await pe(d,{method:"post",headers:{"Content-Type":"application/json",token:s},body:JSON.stringify(C),responseType:"json"})}catch(E){let J=E,ke=J.details?.rawResponse||J.message||String(E),Y=ue(ke);throw Y?new A(Y):E}let x=M.data;if(x.context?.kind==="ArcgisErrorAsContext"&&x.context.error)throw new A({message:x.context.error.message||"ArcGIS Assistant error",code:x.context.error.code,subCode:x.context.error.subCode,details:x.context.error.details,source:"polling-response"});if(c.push(x),h=x.sequenceNumber,v++,!x.hasMore)break}if(v===$)throw new A({message:"Request timed out",code:"TIMEOUT",source:"polling"})}let S=120*1e3;return await Promise.race([f(),new Promise((v,$)=>setTimeout(()=>$(new A({message:"Request timed out",code:"TIMEOUT",source:"hard-timeout"})),S))]),c}function Ne(t,e,i){return{conversationId:t,inquiryId:i,ackSequenceNumber:e}}function qe(t){return t.message.match(/Error in prompt shield/u)?"I'm having trouble with this request. Try again by rephrasing the question.":t.code==="TIMEOUT"?"Request timed out. Try again by re-asking the same question or rephrasing it.":t.message}var De=({notices:t})=>t.length?p`<div class="border-block-end">${L(t,e=>e.id??e.title,e=>p`<calcite-notice class="submission-notice" .icon=${e.icon} .kind=${e.kind} scale=s open .closable=${e.closable} @calciteNoticeClose=${()=>e.onClose?.()}><div slot=title>${e.title}</div>${e.message&&p`<div slot=message>${e.message}</div>`||""}${e.actionLinkMessage&&e.onAction&&p`<calcite-link slot=link @click=${()=>e.onAction?.()}>${e.actionLinkMessage}</calcite-link>`||""}</calcite-notice>`)}</div>`:null,Ue=t=>{let e=t.value.length,i=72,a=180,s=t.offsetWidth,n=Math.max(1,Math.floor(s/8)),l=Math.ceil(e/n),d=i+(l-2)*24;t.style.setProperty("--calcite-text-area-min-height",`${Math.min(d,a)}px`)},Oe=({promptValidationMessage:t,errorMessage:e,contextTooBig:i,contextReducedNoticeDismissed:a,setContextReducedNoticeDismissed:s,setErrorMessage:n,messages:l})=>{let d=[];if(t&&d.push({id:"prompt-validation",kind:"danger",icon:"exclamation-mark-triangle",title:t,closable:!0}),e&&d.push({id:"assistant-error",kind:"danger",icon:"exclamation-mark-triangle",title:e,closable:!0,onClose:()=>n(void 0)}),i&&!a){let c=l.contextreduced??"Context reduced",o=l.contextreducedmessage??"The editor profile is too large for the assistant. It has been reduced in the assistant in order to ensure a successful request.";d.push({id:"context-reduced",kind:"warning",icon:"exclamation-mark-triangle",title:c,message:o,closable:!0,onClose:()=>s(!0)})}return d};function _e({messages:t}){return p`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta??"Beta"}>${t.beta??"Beta"}</calcite-chip>`}function Fe({popoverContent:t,messages:e}){return p`<calcite-action icon=information slot=header-actions-end id=legal-disclaimer text></calcite-action><calcite-popover reference-element=legal-disclaimer .label=${e.legaldisclaimer??"Legal disclaimer"} placement=bottom auto-close focus-trap-disabled><div class="contained">${t}</div></calcite-popover>`}function ze({errorMessage:t,slot:e}){return p`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e??O}>${t}</calcite-input-message></div>`}function Le({active:t,setActive:e,messages:i}){return p`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${()=>e(!1)} .label=${i.expressionapplied??"Expression applied"}><div slot=message>${i.expressionapplied??"Expression applied to editor."}</div></calcite-alert>`}function Be({context:t,messages:e}){return t?p`<div class="gaps">${t.profileId&&p`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>`||""}</div>`:null}function je({isDisabled:t,isReadOnly:e,setQuestion:i,setIsViewingResult:a,textAreaRef:s,question:n,errorMessage:l,setErrorMessage:d,promptValidationMessage:c,setPromptValidationMessage:o,submitQuestion:g,messages:r,mode:u,assistantRef:m,context:h,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S}){let v=h?.contextTooLarge??!1,$=Oe({promptValidationMessage:c,errorMessage:l,contextTooBig:v,contextReducedNoticeDismissed:f,setContextReducedNoticeDismissed:S,setErrorMessage:d,messages:r});return p`<div class="text-area-wrapper">${De({notices:$})}<calcite-text-area scale=s resize=vertical .readOnly=${t||e} class=${ae($.length?"submission-text-area":"submission-text-area round-top")} .placeholder=${r.askaquestion??`Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${C=>{Ue(C.target),i(C.target.value)}} ${te(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${h&&Be({context:h,messages:r})||""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async()=>{a(!1),i("")}} .label=${r.startover??"Start Over"} class="hidden-above-380" id=small-start-over-button></calcite-button><calcite-tooltip reference-element=small-start-over-button placement=top-start class="hidden-above-380">${r.startover??"Start Over"}</calcite-tooltip><calcite-button round kind=neutral .hidden=${u!=="refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async()=>{a(!1),i("")}} class="hidden-below-380" scale=s>${r.startover??"Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-below-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} id=small-submit-button @click=${async()=>{if(d(""),!n){o(r.enteraprompt??"Please enter a prompt");return}o(void 0),await g()}} class="hidden-above-380" .label=${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${u==="prompt"?r.ask??"Generate":r.refine??"Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`}var He="https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement",Qe="https://www.esri.com/en-us/privacy/privacy-statements";function Ge({setOpen:t,messages:e,feedback:i,learnMoreUrl:a,setFeedback:s,onSubmit:n}){return i.active?p`<calcite-sheet class="feedback-sheet" .label=${e.feedback??"Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${()=>t(!1)}><calcite-panel .heading=${e.submitfeedback??"Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${l=>s({...i,text:l.target.value})} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo??"Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${l=>{s({...i,termsAccepted:l.target.checked})}} .disabled=${i.submitting}></calcite-checkbox><span>${V((e.agreement??"I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}",`<calcite-link href=${Qe} target="_blank">${e.esriprivacystatement??"Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}",`<calcite-link href=${He} target="_blank">${e.supplement??"Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${V((e.feedbackhelps??"Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}",`<calcite-link href=${a} target="_blank">${e.learnmore??"Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${()=>t(!1)} .disabled=${i.submitting}>${e.cancel??"Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted||i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit??"Submit"}</calcite-button></div></calcite-panel></calcite-sheet>`:null}function me({assistantsEnabled:t,messages:e,slot:i,helpTopicUrl:a}){return p`<calcite-block .label=${e.assistantinformation??"Assistant information"} slot=${i??O} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing??"Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new??"New"} kind=brand scale=s>${e.new??"New"}</calcite-chip></div>${t?p`<p>${e.capabilities??"The assistant uses artificial intelligence to generate Arcade expressions."}</p><p>${e.keepinmind??"Keep in mind the following:"}<ul><li>${e.beconsise??"Be concise, but also clear in your request"}</li><li>${e.avoidambiguity??"Avoid ambiguity and vagueness"}</li><li>${e.moredetails??"you do not need to use exact field names in your instructions, but more detail is generally better"}</li></ul>${V((e.seedocumentation??"Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}",`<calcite-link href=${a} target="_blank">${e.documentation??"documentation"}</calcite-link>`))}</p>`:p`<p>${e.useofassistant??"The assistant uses artificial intelligence to generate Arcade expressions. To enable Arcade Assistant (beta), the following must be true:"}</p><ul><li>${e.enabledinorg??"AI assistants are enabled in the organization settings"}</li><li>${e.enabledbetaapps??"Beta apps and capabilities are not blocked"}</li><li>${e.enabledroleprivilege??"Your role privilege allows you to use AI assistants"}</li></ul>`}</calcite-block>`}function Je({messages:t,onProceed:e,onExit:i,helpTopicUrl:a}){return p`<calcite-dialog close-disabled placement=top .heading=${t.welcome??"Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted??"Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect??"AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${V((t.pleasereadhelp??"Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}",`<calcite-link href=${a} target="_blank">${t.helptopic??"help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed??"Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit??"Exit"}</calcite-button></calcite-dialog>`}function Ye({messages:t,suggestions:e,onSuggestionClick:i}){return p`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map(a=>p`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${()=>i?.(a)}>${a}</calcite-button>`)}</div></calcite-block>`}var he=200;function ge({hidden:t=!1,expanded:e=!1,messages:i,cards:a,heading:s,collapsible:n=!1,showEffectsIcon:l=!1,onCopyCode:d,standalone:c}){return p`<calcite-block .hidden=${t} id=result-block .heading=${s??i.besteffort??"Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${l&&p`<calcite-chip .label=${i.assistantresponses??"Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>`||""}<calcite-card-group .label=${i.assistantresponses??"Assistant responses"}>${L(a,o=>o.conversationId,o=>p`<calcite-card><div slot=heading><div class="prior-prompt"><span>${o.priorPrompt.length>he?`${o.priorPrompt.slice(0,he)}...`:o.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} @click=${g=>{let r=g.currentTarget;navigator.clipboard.writeText(o.priorPrompt).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard??"Copy prompt to clipboard"}</calcite-tooltip></div>${o.message&&c&&p`<div class="response-error-container">${ze({errorMessage:o.message})}</div>`||""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext??"Response Context"} scale=s>${o.message&&!c&&p`<calcite-tooltip .referenceElement=${`response-chip-${o.conversationId}-error`} placement=top-start>${o.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${o.conversationId}-error`} .label=${i.error??"Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>`||""}${We({card:o,messages:i})}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${o.code}</arcgis-code-viewer></details></div></div><div slot=footer-start class="feedback-actions"><calcite-button class="add-to-editor-button hidden-above-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor??"Add to editor"} .id=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start>${i.addtoeditor??"Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${()=>o.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor??"Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${()=>o.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.replaceineditor??"Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${g=>{let r=g.currentTarget;d(o.code).then(()=>{r.setAttribute("data-copied","true"),setTimeout(()=>r.removeAttribute("data-copied"),1500)})}} class="response-secondary-action-button" .id=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully??"copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully??"copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard??"Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup??"Thumbs up"} scale=s icon=thumbs-up @click=${o.onThumbsUp} .id=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.helpful??"Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown??"Thumbs down"} scale=s icon=thumbs-down @click=${o.onThumbsDown} .id=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${o.conversationId}-${c?"standalone":"list"}`} placement=top-start><span>${i.unhelpful??"Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`}var We=({card:t,messages:e})=>{let i=K(),a=`response-chip-profile-${t.conversationId}-${i}`,s=(e.profilecontextlabel??"Profile context: {profileId}").replace("{profileId}",t.profileId);return p`<calcite-tooltip .referenceElement=${a} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${a??O}>${t.profileId}</calcite-chip>`},be=t=>t.type==="featureSet",B=t=>{if(!le(t))return[];let e=[];return t.relationships?.forEach(i=>{e.push(i.toJSON())}),e},j=t=>t.length>0?{relationships:t}:{},Ke=t=>ce(t).map(e=>({alias:e.alias,name:e.name,type:e.type,...e.domain?{domain:e.domain}:{}})),H=t=>t?{fields:Ke(t)}:{fields:[]};async function fe(t){let e=await t.loadSource(),i=F(e)&&e.isTable,a=B(e);return{name:t.name,type:"featureSet",isTable:i,...H(e?.fields),...j(a)}}async function xe(t){switch(t.type){case"feature":{let e=await t.loadSource(),i=B(e);return{name:t.name,type:t.type,...H(e?.fields),...j(i)}}case"featureSet":{let e=await t.loadSource(),i=F(e)&&e.isTable;return{name:t.name,type:"featureSet",...i?{isTable:i}:{},...H(e?.fields),...j(B(e))}}case"featureSetCollection":{let e=await t.loadSource(),i=e?.layers.filter(be)??[],a=e?.tables.filter(be)??[],s=await Promise.all(i.map(fe)),n=await Promise.all(a.map(fe));return{name:t.name,type:"featureSetCollection",layers:s,tables:n}}case"dictionary":{let e=await Promise.all(t.dictionaryVariables.map(xe));return{name:t.name,type:"dictionary",attributes:e}}case"pixel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"pixel"};let i=await Me(e);return{name:t.name,type:"pixel",members:i.map(ve)}}case"voxel":{let e=await t.loadSource();if(!e)return{name:t.name,type:"voxel"};let i=await Ie(e);return{name:t.name,type:"voxel",members:i.map(ve)}}case"array":return{name:t.name,type:"array",elementType:t.elementType.type};case"number":case"text":case"boolean":case"date":case"knowledgeGraph":case"dateOnly":case"geometry":case"time":return{name:t.name,type:t.type}}}function ve(t){return t.type==="array"?{name:t.name,type:"array",elementType:t.elementType.type}:{name:t.name,type:t.type}}async function Xe(t){return{variables:await Promise.all(t.variables.map(xe))}}var Ze=1e5;function et(t){let e=new TextEncoder().encode(t).length;return Math.ceil(e/3.5)}function Q(t){return et(JSON.stringify(t))}function tt(t){let e=a=>({name:a.name,type:a.type,...a.isTable?{isTable:a.isTable}:{},...a.relationships?{relationships:a.relationships}:{}}),i=a=>{switch(a.type){case"feature":case"featureSet":case"knowledgeGraph":return{name:a.name,type:a.type,..."isTable"in a&&a.isTable?{isTable:a.isTable}:{},..."relationships"in a?{relationships:a.relationships}:{}};case"featureSetCollection":return{name:a.name,type:"featureSetCollection",layers:a.layers.map(e),tables:a.tables.map(e)};case"dictionary":return{name:a.name,type:"dictionary",attributes:a.attributes.map(i)};case"pixel":case"voxel":return{name:a.name,type:a.type};case"array":return{name:a.name,type:"array",...a.elementType?{elementType:a.elementType}:{}};default:return a}};return{variables:t.variables.map(i)}}function it(t){let e=t.variables,i=e.length,a=e.find(n=>n.name==="$feature")??e.find(n=>n.type==="feature")??e[0],s=a?[a]:[];return{context:{variables:s},wasReduced:i!==s.length,reducedToVariableName:a?.name}}function at(t){return Q(t)>Ze}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,y=(t,e,i,a)=>{for(var s=a>1?void 0:a?ot(e,i):e,n=t.length-1,l;n>=0;n--)(l=t[n])&&(s=(a?l(e,i,s):l(s))||s);return a&&s&&st(e,i,s),s},b=class extends Ee{constructor(t){super(t),this.viewMode="prompt",this.confirmationActive=!1,this.contextReducedNoticeDismissed=!1,this.splashActive=!0,this.isSubmitting=!1,this.question="",this.history=[],this.feedback={active:!1}}};y([w()],b.prototype,"viewMode",2);y([w()],b.prototype,"confirmationActive",2);y([w()],b.prototype,"contextReducedNoticeDismissed",2);y([w()],b.prototype,"splashActive",2);y([w()],b.prototype,"isSubmitting",2);y([w()],b.prototype,"errorMessage",2);y([w()],b.prototype,"promptValidationMessage",2);y([w()],b.prototype,"question",2);y([w()],b.prototype,"history",2);y([w()],b.prototype,"feedback",2);y([w()],b.prototype,"context",2);b=y([Re("ArcadeAssistantViewState")],b);var nt="arcade_generation",rt="ArcadeCodeRequest",ye="visualization",ct="ArcadeAssistant",lt=["your_comments","user_evaluation","question","answer","useragent","_source","version","context","extras"],we=[],$e=!0,G=class extends ie{constructor(){super(...arguments),this.textAreaRef=ee(),this.messages=oe(),this._feedbackService=void 0,this.viewState=new b,this.handleFeedbackButton=(e,i)=>{this.updateViewState({feedback:{active:!0,value:e,item:i,termsAccepted:!1,text:"",submitting:!1}})},this.handleFeedbackSheetClose=()=>{this.updateViewState({feedback:{active:!1}})},this.handleFeedbackSubmit=async()=>{if(!this.viewState.feedback.active)return;this.updateViewState({feedback:{...this.viewState.feedback,submitting:!0}});let e=await this.ensureFeedbackService();if(!e){this.handleFeedbackSheetClose();return}let i=this.viewState.feedback.item.contextSnapshot,a=Ae.applicationName;!a&&!this.appVersion&&T("warn",this,"esriConfig.applicationName is not set. Consider setting it to help identify the application version in feedback.");let{value:s,text:n,termsAccepted:l,item:{question:d,formattedScript:c,conversationId:o}}=this.viewState.feedback,g={user_evaluation:s,your_comments:n||void 0,question:d??"",answer:encodeURIComponent(c??""),useragent:navigator.userAgent,_source:ct,version:this.appVersion||a||"NOT_SET",context:i?JSON.stringify(i):"",extras:i?.profileId??"",conversation_id:o??"",privacy_statement:l?"I_agree":""};try{await e.applyEdits({addFeatures:[new Ce({attributes:g})]})}catch(r){T("error",this,"Error submitting feedback.",{detail:{error:r}})}this.handleFeedbackSheetClose()},this.handleClose=e=>{this.closed=!0,this.closePanel?.(e)},this.setQuestionState=e=>{this.updateViewState({question:e,promptValidationMessage:void 0})},this.setFeedbackState=e=>{this.updateViewState({feedback:e})},this.onSuggestionClick=e=>{this.textAreaRef.value&&(this.textAreaRef.value.value=e,this.textAreaRef.value.setFocus(),this.setQuestionState(e))},this.helpBase="",this.assistantsEnabled=!1,this.closed=!1}static{this.properties={closePanel:0,insertText:0,helpBase:1,assistantsEnabled:5,portalUrl:1,serviceUrl:1,closed:7,editorRef:0,feedbackServiceUrl:1,appVersion:1}}static{this.styles=Ve}get disclaimerComment(){return`// ${this.messages.disclaimercomment}
|
|
3
3
|
// ${this.messages.disclaimerpt2??"AI-generated content may be inaccurate. Review before using."}`}get assistantOverviewDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/understand-arcade-assistant.htm`}get usingTheAssitantDocUrl(){return`${this.helpBase??"https://doc.arcgis.com/en/arcgis-online/"}create-maps/use-arcade-assistant.htm`}async destroy(){}connectedCallback(){super.connectedCallback(),this.updateViewState({history:we,splashActive:$e})}load(){let e=async()=>{let i=this.getModel();if(!i){this.updateViewState({context:void 0});return}let a=await this.getProfileAndMetadata(i.uri);this.updateViewState({context:a,contextReducedNoticeDismissed:a.contextTooLarge?!1:this.viewState.contextReducedNoticeDismissed})};e().catch(i=>{T("error",this,"Error setting initial context.",{detail:{error:i}})}),this.manager.onLifecycle(()=>{let i=z.onModelContextDidChange(async()=>{e().catch(a=>{T("error",this,"Error setting context.",{detail:{error:a}})})});return{remove:()=>{i.dispose()}}})}disconnectedCallback(){super.disconnectedCallback(),we=this.viewState.history,$e=this.viewState.splashActive,this.copySuccessTimer&&(clearTimeout(this.copySuccessTimer),this.copySuccessTimer=void 0)}createFeedbackContextSnapshot(e){let i=tt(e.metadata);return{...e,metadata:i,estimatedTokens:Q(i)}}updateViewState(e){this.viewState.set(e)}getHistoryCards(){return this.viewState.history.reduce((e,i)=>(!i.script||(e.push({priorPrompt:i.question,code:i.formattedScript||i.error||"",profileId:i.profile??ye,onAddToEditor:a=>{ne(this.editorRef.editorInstance,i.formattedScript??"",a,this.disclaimerComment)},onThumbsUp:()=>this.handleFeedbackButton("good",i),onThumbsDown:()=>this.handleFeedbackButton("bad",i),conversationId:i.conversationId??"",message:i.message}),this.viewState.viewMode),e),[])}async ensureFeedbackService(){if(this._feedbackService)return this._feedbackService;if(!this.feedbackServiceUrl)return;let e=new Te({url:this.feedbackServiceUrl});await e.load();let i=lt.filter(a=>!e.fields.some(s=>s.name===a));if(i.length>0){T("error",this,`Missing the following fields in feedback service: ${i.join(", ")}. Feedback will not be logged.`);return}return this._feedbackService=e,e}getModel(){return this.editorRef.editorInstance?.getModel()}async submitQuestion(){if(this.viewState.question){this.updateViewState({isSubmitting:!0,errorMessage:void 0});try{let e=await this.getToken(),i=this.getModel();if(!i)return;let a=this.viewState.context??await this.getProfileAndMetadata(i.uri),s=(await Pe({baseUrl:this.serviceUrl,skillId:nt,message:this.viewState.question,authToken:e,context:{kind:rt,context:{profile_id:a.profileId,metadata:[a.metadata]}}})).find(n=>n.context?.kind==="ArcadeCodeResponse");if(!s)return;if(s.context?.kind==="ArcadeCodeResponse"){let n=this.createFeedbackContextSnapshot(a);this.updateViewState({history:[{script:s?.context?.arcadeCode?.code,formattedScript:re(s?.context?.arcadeCode?.code??""),error:void 0,question:this.viewState.question,profile:a.profileId,conversationId:s.conversationId,contextSnapshot:n,...s.message?{message:s.message}:{}},...this.viewState.history],viewMode:"result",errorMessage:void 0})}}catch(e){e instanceof Error&&e.name==="ArcadeAssistantError"?this.updateViewState({errorMessage:qe(e)||this.messages.erroroccurred||"An error occurred."}):this.updateViewState({errorMessage:this.messages.erroroccurred||"An error occurred."}),T("error",this,"Error submitting question",{detail:{error:e}})}finally{this.updateViewState({isSubmitting:!1})}}}async getToken(){let{token:e}=await Se.getCredential(this.portalUrl);return e}async getProfileAndMetadata(e){let i=ye,a=z.getEditorProfileForModel(e);a?.loaded||await a?.loadSource();let s=this.editorRef.profile;s&&"id"in s&&(i=s.id);let n=a?await Xe(a):{variables:[]},l=at(n),d=l?it(n):void 0,c=d?d.context:n,o=Q(c);return{profileId:i,metadata:c,contextTooLarge:l,reducedToVariableName:d?.reducedToVariableName,estimatedTokens:o}}onCopyCode(e){let i=e?`${this.disclaimerComment}
|
|
4
4
|
${e}`:"";return navigator.clipboard.writeText(i)}render(){if(this.closed)return null;let e=this.viewState.viewMode==="result",i=this.getHistoryCards();return this.assistantsEnabled?p`<calcite-flow><calcite-flow-item closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${this.viewState.splashActive&&p`<calcite-scrim></calcite-scrim>`||""}${_e({messages:this.messages})}${Fe({messages:this.messages,popoverContent:me({assistantsEnabled:this.assistantsEnabled,messages:this.messages,helpTopicUrl:this.usingTheAssitantDocUrl})})}<calcite-shell class="unstyled-shell">${this.viewState.splashActive&&Je({messages:this.messages,onProceed:()=>{this.updateViewState({splashActive:!1})},helpTopicUrl:this.assistantOverviewDocUrl,onExit:a=>this.closePanel?.(a)})||""}${Le({active:this.viewState.confirmationActive,setActive:a=>this.updateViewState({confirmationActive:a}),messages:this.messages})}${je({isDisabled:this.viewState.isSubmitting,isReadOnly:!1,setQuestion:this.setQuestionState,setIsViewingResult:a=>this.updateViewState({viewMode:a?"result":"prompt"}),mode:e?"refine":"prompt",textAreaRef:this.textAreaRef,question:this.viewState.question,errorMessage:this.viewState.errorMessage,setErrorMessage:a=>this.updateViewState({errorMessage:a}),promptValidationMessage:this.viewState.promptValidationMessage,setPromptValidationMessage:a=>this.updateViewState({promptValidationMessage:a}),submitQuestion:this.submitQuestion.bind(this),assistantRef:this.el,messages:this.messages,context:this.viewState.context,contextReducedNoticeDismissed:this.viewState.contextReducedNoticeDismissed,setContextReducedNoticeDismissed:a=>this.updateViewState({contextReducedNoticeDismissed:a})})}<calcite-block-group .label=${this.messages.interactiveblocks??"interactive blocks"}>${!e&&!this.viewState.isSubmitting&&Ye({messages:this.messages,suggestions:[this.messages.prompsuggestion1??"",this.messages.prompsuggestion2??""],onSuggestionClick:this.onSuggestionClick})||""}<calcite-block .hidden=${!this.viewState.isSubmitting} .heading=${this.messages.generatingresponse??"Generating response..."}></calcite-block>${ge({expanded:e,messages:this.messages,collapsible:!0,showEffectsIcon:!0,cards:i.length?[i[0]]:[],heading:this.messages.besteffort??"Here's the assistant's best effort",hidden:this.viewState.isSubmitting||!e,onCopyCode:this.onCopyCode.bind(this),standalone:!0})}${ge({expanded:!e,messages:this.messages,collapsible:!0,cards:e?i.slice(1):i,heading:this.messages.recentprompts??"Recent prompts",hidden:this.viewState.isSubmitting||this.viewState.history.length===0,onCopyCode:this.onCopyCode.bind(this)})}</calcite-block-group>${this.viewState.feedback.active?Ge({setOpen:this.handleFeedbackSheetClose,messages:this.messages,onSubmit:this.handleFeedbackSubmit,feedback:this.viewState.feedback,setFeedback:this.setFeedbackState,learnMoreUrl:this.assistantOverviewDocUrl}):null}</calcite-shell></calcite-flow-item></calcite-flow>`:p`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant??"Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${me({slot:"content-top",messages:this.messages,assistantsEnabled:this.assistantsEnabled,helpTopicUrl:this.usingTheAssitantDocUrl})}</calcite-flow-item></calcite-flow>`}};se("arcgis-arcade-coding-assistant",G);return G},"identity/IdentityManager","request","layers/FeatureLayer","config","Graphic","applications/Components/arcadeEditorUtils","core/Accessor","core/accessorSupport/decorators",a,b)
|
|
@@ -18238,7 +18238,7 @@ function se(t, e, r, n) {
|
|
|
18238
18238
|
const fr = { apiKey: void 0, apiKeys: { scopes: [] }, applicationName: "", applicationUrl: globalThis.location?.href, assetsPath: "", fontsUrl: "https://static.arcgis.com/fonts", geometryServiceUrl: "https://utility.arcgisonline.com/arcgis/rest/services/Geometry/GeometryServer", geoRSSServiceUrl: "https://utility.arcgis.com/sharing/rss", kmlServiceUrl: "https://utility.arcgis.com/sharing/kml", userPrivilegesApplied: !0, portalUrl: "https://www.arcgis.com", respectPrefersReducedMotion: !0, routeServiceUrl: "https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World", workers: { loaderConfig: { has: {}, paths: {}, map: {}, packages: [] } }, request: { crossOriginNoCorsDomains: null, httpsDomains: ["arcgis.com", "arcgisonline.com", "esrikr.com", "premiumservices.blackbridge.com", "esripremium.accuweather.com", "gbm.digitalglobe.com", "firstlook.digitalglobe.com", "msi.digitalglobe.com"], interceptors: [], internalInterceptors: [], maxUrlLength: 2e3, priority: "high", proxyRules: [], proxyUrl: null, timeout: 62e3, trustedServers: [], useIdentity: !0 }, log: { interceptors: [], level: null } };
|
|
18239
18239
|
if (globalThis.esriConfig && (q4(fr, globalThis.esriConfig, !0), delete fr.has), !fr.assetsPath) {
|
|
18240
18240
|
{
|
|
18241
|
-
const t = "5.0.0-next.
|
|
18241
|
+
const t = "5.0.0-next.115";
|
|
18242
18242
|
fr.assetsPath = `https://cdn.jsdelivr.net/npm/@arcgis/core@${t}/assets`;
|
|
18243
18243
|
}
|
|
18244
18244
|
fr.defaultAssetsPath = fr.assetsPath;
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./
|
|
2
|
+
import{I as s,u as e}from"./EMMNZESW.js";import"./BCUUVBXH.js";import"./3TTFCHAA.js";var i=e(s,{"arcgis-arcade-coding-assistant":[()=>import("./YUYP77Z2.js"),"appVersion,assistantsEnabled,closed,closePanel:,editorRef:,feedbackServiceUrl,helpBase,insertText:,portalUrl,serviceUrl;destroy"],"arcgis-arcade-editor":[()=>import("./2LBCAP4J.js"),"arcadeAssistant:,customPanels:,editorInstance:,editorOptions:,hideDocumentationActions,hideSideBar,messages:,openedSidePanel,profile:,script,sideActionBarExpanded,snippets:,suggestions:,testData:;getTestResult,setFocus"],"arcgis-arcade-results":[()=>import("./D2RP5367.js"),"calciteModeDark,consoleLogs:,loading,openedResultPanel,result:"],"arcgis-arcade-suggestions":[()=>import("./44MLHT3A.js"),"closed,suggestions:"],"arcgis-code-editor":[()=>import("./3FUUECYI.js"),"editorInstance:,editorOptions:,language,modelId,value;insertSnippet,insertText,setFocus"],"arcgis-code-editor-shell":[()=>import("./3C7TCPV5.js")],"arcgis-code-viewer":[()=>import("./6U5PWF5V.js"),"language,round"],"arcgis-editor-variables":[()=>import("./DTZPALJA.js"),"closed,loading,modelId,variable:"],"arcgis-language-api-panel":[()=>import("./H75CMJQP.js"),"apiLibrary:,closed,hideDocumentationActions,languageId,loading"],"arcgis-sql-expression-editor":[()=>import("./Q7MXMDGS.js"),"hideSideBar,messages:,profile:,script;setFocus"]});i({resourcesUrl:import.meta.url});var t=new CSSStyleSheet;t.replaceSync("@layer{:not([hydrated]):is(arcgis-arcade-editor,arcgis-code-editor,arcgis-code-editor-shell,arcgis-code-viewer,arcgis-sql-expression-editor){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,t];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,s)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
2
|
import { c as Z } from "../../chunks/runtime.js";
|
|
3
|
-
import { css as ee, html as
|
|
3
|
+
import { css as ee, html as d } from "lit";
|
|
4
4
|
import { nothing as V, safeClassMap as te, LitElement as ie } from "@arcgis/lumina";
|
|
5
5
|
import { ref as oe, createRef as ae } from "lit/directives/ref.js";
|
|
6
6
|
import se from "@arcgis/core/identity/IdentityManager.js";
|
|
@@ -67,10 +67,10 @@ async function we(t) {
|
|
|
67
67
|
const g = b, $ = g.details?.rawResponse || g.message || String(b), k = U($);
|
|
68
68
|
throw k ? new C(k) : b;
|
|
69
69
|
}
|
|
70
|
-
const
|
|
71
|
-
c.push(
|
|
72
|
-
const y =
|
|
73
|
-
let w =
|
|
70
|
+
const l = h.data;
|
|
71
|
+
c.push(l);
|
|
72
|
+
const y = l.conversationId, q = l.inquiryId;
|
|
73
|
+
let w = l.sequenceNumber;
|
|
74
74
|
async function T() {
|
|
75
75
|
let b = 0;
|
|
76
76
|
const g = 100;
|
|
@@ -138,7 +138,7 @@ function $e(t, e, i) {
|
|
|
138
138
|
function xe(t) {
|
|
139
139
|
return t.message.match(/Error in prompt shield/u) ? "I'm having trouble with this request. Try again by rephrasing the question." : t.code === "TIMEOUT" ? "Request timed out. Try again by re-asking the same question or rephrasing it." : t.message;
|
|
140
140
|
}
|
|
141
|
-
const ke = ({ notices: t }) => t.length ?
|
|
141
|
+
const ke = ({ notices: t }) => t.length ? d`<div class="border-block-end">${Q(t, (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, Se = (t) => {
|
|
142
142
|
const e = t.value.length, i = 72, o = 180, s = t.offsetWidth, r = Math.max(1, Math.floor(s / 8)), p = Math.ceil(e / r), c = i + (p - 2) * 24;
|
|
143
143
|
t.style.setProperty("--calcite-text-area-min-height", `${Math.min(c, o)}px`);
|
|
144
144
|
}, Ce = ({ promptValidationMessage: t, errorMessage: e, contextTooBig: i, contextReducedNoticeDismissed: o, setContextReducedNoticeDismissed: s, setErrorMessage: n, messages: r }) => {
|
|
@@ -171,21 +171,21 @@ const ke = ({ notices: t }) => t.length ? l`<div class="border-block-end">${Q(t,
|
|
|
171
171
|
return p;
|
|
172
172
|
};
|
|
173
173
|
function Ae({ messages: t }) {
|
|
174
|
-
return
|
|
174
|
+
return d`<calcite-chip slot=header-actions-end scale=s appearance=outline-fill .label=${t.beta ?? "Beta"}>${t.beta ?? "Beta"}</calcite-chip>`;
|
|
175
175
|
}
|
|
176
176
|
function Te({ popoverContent: t, messages: e }) {
|
|
177
|
-
return
|
|
177
|
+
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">${t}</div></calcite-popover>`;
|
|
178
178
|
}
|
|
179
179
|
function Ie({ errorMessage: t, slot: e }) {
|
|
180
|
-
return
|
|
180
|
+
return d`<div class="error-display"><calcite-input-message id=error-message status=invalid icon=exclamation-mark-triangle scale=m slot=${e ?? V}>${t}</calcite-input-message></div>`;
|
|
181
181
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
182
|
+
function Re({ active: t, setActive: e, messages: i }) {
|
|
183
|
+
return d`<calcite-alert slot=alerts .open=${t} placement=bottom kind=success icon=check-circle-f auto-close @calciteAlertClose=${() => e(!1)} .label=${i.expressionapplied ?? "Expression applied"}><div slot=message>${i.expressionapplied ?? "Expression applied to editor."}</div></calcite-alert>`;
|
|
184
184
|
}
|
|
185
|
-
function
|
|
186
|
-
return t ?
|
|
185
|
+
function Ee({ context: t, messages: e }) {
|
|
186
|
+
return t ? d`<div class="gaps">${t.profileId && d`<calcite-popover auto-close placement=top .label=${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)} reference-element=profile-context-button class="context-popover contained-popover-or-tooltip"><p>${(e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId)}</p></calcite-popover><calcite-button round kind=neutral icon-start=map-information id=profile-context-button scale=s></calcite-button>` || ""}</div>` : null;
|
|
187
187
|
}
|
|
188
|
-
function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult: o, textAreaRef: s, question: n, errorMessage: r, setErrorMessage: p, promptValidationMessage: c, setPromptValidationMessage: a, submitQuestion: h, messages:
|
|
188
|
+
function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult: o, textAreaRef: s, question: n, errorMessage: r, setErrorMessage: p, promptValidationMessage: c, setPromptValidationMessage: a, submitQuestion: h, messages: l, mode: y, assistantRef: q, context: w, contextReducedNoticeDismissed: T, setContextReducedNoticeDismissed: I }) {
|
|
189
189
|
const b = w?.contextTooLarge ?? !1, g = Ce({
|
|
190
190
|
promptValidationMessage: c,
|
|
191
191
|
errorMessage: r,
|
|
@@ -193,92 +193,92 @@ function Me({ isDisabled: t, isReadOnly: e, setQuestion: i, setIsViewingResult:
|
|
|
193
193
|
contextReducedNoticeDismissed: T,
|
|
194
194
|
setContextReducedNoticeDismissed: I,
|
|
195
195
|
setErrorMessage: p,
|
|
196
|
-
messages:
|
|
196
|
+
messages: l
|
|
197
197
|
});
|
|
198
|
-
return
|
|
198
|
+
return d`<div class="text-area-wrapper">${ke({ notices: g })}<calcite-text-area scale=s resize=vertical .readOnly=${t || e} class=${te(g.length ? "submission-text-area" : "submission-text-area round-top")} .placeholder=${l.askaquestion ?? `Specify the calculation or logic you need in an Arcade expression. (e.g., 'Return "Yes" if value > 10')`} .value=${n} @calciteTextAreaInput=${($) => {
|
|
199
199
|
Se($.target), i($.target.value);
|
|
200
|
-
}} ${oe(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${w &&
|
|
200
|
+
}} ${oe(s)}><div class="submission-actions-wrapper" slot=footer-start><div class="submission-actions">${w && Ee({ context: w, messages: l }) || ""}<div class="align-inline-end gaps"><calcite-button round kind=neutral .hidden=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid scale=s .disabled=${t} @click=${async () => {
|
|
201
201
|
o(!1), i("");
|
|
202
|
-
}} .label=${
|
|
202
|
+
}} .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=${y !== "refine"} icon-start=arrow-left icon-flip-rtl=both appearance=solid .disabled=${t} @click=${async () => {
|
|
203
203
|
o(!1), i("");
|
|
204
|
-
}} class="hidden-below-380" scale=s>${
|
|
204
|
+
}} class="hidden-below-380" scale=s>${l.startover ?? "Start Over"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} @click=${async () => {
|
|
205
205
|
if (p(""), !n) {
|
|
206
|
-
a(
|
|
206
|
+
a(l.enteraprompt ?? "Please enter a prompt");
|
|
207
207
|
return;
|
|
208
208
|
}
|
|
209
209
|
a(void 0), await h();
|
|
210
|
-
}} class="hidden-below-380">${y === "prompt" ?
|
|
210
|
+
}} class="hidden-below-380">${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-button><calcite-button round scale=s icon-end=effects appearance=solid .loading=${t} .disabled=${t} id=small-submit-button @click=${async () => {
|
|
211
211
|
if (p(""), !n) {
|
|
212
|
-
a(
|
|
212
|
+
a(l.enteraprompt ?? "Please enter a prompt");
|
|
213
213
|
return;
|
|
214
214
|
}
|
|
215
215
|
a(void 0), await h();
|
|
216
|
-
}} class="hidden-above-380" .label=${y === "prompt" ?
|
|
216
|
+
}} class="hidden-above-380" .label=${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}></calcite-button><calcite-tooltip reference-element=small-submit-button placement=top-start class="hidden-above-380">${y === "prompt" ? l.ask ?? "Generate" : l.refine ?? "Refine"}</calcite-tooltip></div></div></div></calcite-text-area></div>`;
|
|
217
217
|
}
|
|
218
218
|
const Pe = "https://www.esri.com/en-us/privacy/privacy-statements/privacy-supplement", Ve = "https://www.esri.com/en-us/privacy/privacy-statements";
|
|
219
219
|
function qe({ setOpen: t, messages: e, feedback: i, learnMoreUrl: o, setFeedback: s, onSubmit: n }) {
|
|
220
|
-
return i.active ?
|
|
220
|
+
return i.active ? d`<calcite-sheet class="feedback-sheet" .label=${e.feedback ?? "Feedback"} slot=sheets display-mode=float position=block-end .open=${i.active} @calciteSheetClose=${() => t(!1)}><calcite-panel .heading=${e.submitfeedback ?? "Submit feedback to Esri"} scale=s><div class="feedback-content"><calcite-text-area scale=s resize=vertical .value=${i.text} @calciteTextAreaInput=${(r) => s({ ...i, text: r.target.value })} .disabled=${i.submitting} .placeholder=${e.donotincludepersonalinfo ?? "Do not include personal or sensitive information"} rows=3></calcite-text-area><calcite-label layout=inline scale=s class="terms-label"><calcite-checkbox scale=l .checked=${i.termsAccepted} @calciteCheckboxChange=${(r) => {
|
|
221
221
|
s({ ...i, termsAccepted: r.target.checked });
|
|
222
222
|
}} .disabled=${i.submitting}></calcite-checkbox><span>${A((e.agreement ?? "I agree to the {EsriPrivacyStatement} (and {Supplement}).").replace("{EsriPrivacyStatement}", `<calcite-link href=${Ve} target="_blank">${e.esriprivacystatement ?? "Esri Privacy Statement"}</calcite-link>`).replace("{Supplement}", `<calcite-link href=${Pe} target="_blank">${e.supplement ?? "Supplement"}</calcite-link>`))}</span></calcite-label><calcite-notice scale=s open closable><span slot=message>${A((e.feedbackhelps ?? "Your feedback will be used to improve Esri products and services. {LearnMore} about how this data is used.").replace("{LearnMore}", `<calcite-link href=${o} target="_blank">${e.learnmore ?? "Learn more"}</calcite-link>`))}</span></calcite-notice></div><div slot=footer class="feedback-footer"><calcite-button kind=neutral appearance=outline @click=${() => t(!1)} .disabled=${i.submitting}>${e.cancel ?? "Cancel"}</calcite-button><calcite-button @click=${n} .disabled=${!i.termsAccepted || i.submitting} .loading=${i.submitting} data-testid=submit-feedback-button>${e.submit ?? "Submit"}</calcite-button></div></calcite-panel></calcite-sheet>` : null;
|
|
223
223
|
}
|
|
224
224
|
function O({ assistantsEnabled: t, messages: e, slot: i, helpTopicUrl: o }) {
|
|
225
|
-
return
|
|
225
|
+
return d`<calcite-block .label=${e.assistantinformation ?? "Assistant information"} slot=${i ?? V} expanded class="info-block" scale=s><div class="info-heading-row"><h1 class="info-heading">${e.introducing ?? "Introducing Arcade Assistant (beta)"}</h1><calcite-chip .label=${e.new ?? "New"} kind=brand scale=s>${e.new ?? "New"}</calcite-chip></div>${t ? 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>${A((e.seedocumentation ?? "Please see the {documentation} for more information, including limitations and additional resources.").replace("{documentation}", `<calcite-link href=${o} target="_blank">${e.documentation ?? "documentation"}</calcite-link>`))}</p>` : 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>`;
|
|
226
226
|
}
|
|
227
227
|
function Fe({ messages: t, onProceed: e, onExit: i, helpTopicUrl: o }) {
|
|
228
|
-
return
|
|
228
|
+
return d`<calcite-dialog close-disabled placement=top .heading=${t.welcome ?? "Welcome to the new assistant experience"} slot=dialogs open width-scale=m id=welcome-dialog><h3 class="unstyled-h3">${t.beforeyougetstarted ?? "Before you get started be aware:"}</h3><ul><li>${t.maybeincorrect ?? "AI generated code may occasionally be incorrect or biased. Review carefully."}</li><li>${A((t.pleasereadhelp ?? "Read the Arcade Assistant (beta) {helpTopic} to get started and learn details on security, privacy and limitations.").replace("{helpTopic}", `<calcite-link href=${o} target="_blank">${t.helptopic ?? "help topic"}</calcite-link>`))}</li></ul><calcite-button id=welcome-proceed slot=footer-end @click=${e}>${t.proceed ?? "Proceed"}</calcite-button><calcite-button id=welcome-decline slot=footer-start @click=${i} kind=neutral>${t.exit ?? "Exit"}</calcite-button></calcite-dialog>`;
|
|
229
229
|
}
|
|
230
230
|
function De({ messages: t, suggestions: e, onSuggestionClick: i }) {
|
|
231
|
-
return
|
|
231
|
+
return d`<calcite-block .heading=${t.promptsuggestions} expanded collapsible id=suggestion-block scale=s><div class="suggestions">${e.map((o) => d`<calcite-button round scale=s appearance=outline-fill kind=neutral .label=${t.promptsuggestion} class="suggestion-button" @click=${() => i?.(o)}>${o}</calcite-button>`)}</div></calcite-block>`;
|
|
232
232
|
}
|
|
233
233
|
const z = 200;
|
|
234
234
|
function L({ hidden: t = !1, expanded: e = !1, messages: i, cards: o, heading: s, collapsible: n = !1, showEffectsIcon: r = !1, onCopyCode: p, standalone: c }) {
|
|
235
|
-
return
|
|
236
|
-
const
|
|
235
|
+
return d`<calcite-block .hidden=${t} id=result-block .heading=${s ?? i.besteffort ?? "Here is the assistant's best effort"} .expanded=${e} .collapsible=${n}>${r && d`<calcite-chip .label=${i.assistantresponses ?? "Assistant responses"} slot=content-start icon=effects scale=m class="suggestion-chips"></calcite-chip>` || ""}<calcite-card-group .label=${i.assistantresponses ?? "Assistant responses"}>${Q(o, (a) => a.conversationId, (a) => d`<calcite-card><div slot=heading><div class="prior-prompt"><span>${a.priorPrompt.length > z ? `${a.priorPrompt.slice(0, z)}...` : a.priorPrompt}</span><calcite-action icon=duplicate scale=s slot=actions-end class="copy-prompt-button" text .id=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} @click=${(h) => {
|
|
236
|
+
const l = h.currentTarget;
|
|
237
237
|
navigator.clipboard.writeText(a.priorPrompt).then(() => {
|
|
238
|
-
|
|
238
|
+
l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
|
|
239
239
|
});
|
|
240
|
-
}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && c &&
|
|
241
|
-
const
|
|
240
|
+
}}></calcite-action><calcite-popover .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-prompt-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copyprompttoclipboard ?? "Copy prompt to clipboard"}</calcite-tooltip></div>${a.message && c && d`<div class="response-error-container">${Ie({ errorMessage: a.message })}</div>` || ""}</div><div><div class="code-response-wrapper"><div class="positioned-code-content"><calcite-chip-group .label=${i.responsecontext ?? "Response Context"} scale=s>${a.message && !c && d`<calcite-tooltip .referenceElement=${`response-chip-${a.conversationId}-error`} placement=top-start>${a.message}</calcite-tooltip><calcite-chip .id=${`response-chip-${a.conversationId}-error`} .label=${i.error ?? "Error"} scale=s appearance=outline icon=exclamation-mark-triangle-f class="response-error-chip"></calcite-chip>` || ""}${Ne({ card: a, messages: i })}</calcite-chip-group></div><details class="collapsible-code" open><summary>Code response</summary><arcgis-code-viewer language=arcade round>${a.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=${() => a.onAddToEditor("add")} scale=s icon-start=plus round .label=${i.addtoeditor ?? "Add to editor"} .id=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip class="hidden-above-380" .referenceElement=${`add-to-editor-button-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start>${i.addtoeditor ?? "Add to editor"}</calcite-tooltip><calcite-button class="add-to-editor-button hidden-below-380" @click=${() => a.onAddToEditor("add")} scale=s icon-start=plus round>${i.addtoeditor ?? "Add to editor"}</calcite-button><calcite-button round icon-start=file-code kind=neutral scale=s @click=${() => a.onAddToEditor("replace")} class="response-secondary-action-button" .id=${`replace-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-tooltip .referenceElement=${`replace-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.replaceineditor ?? "Replace all code in editor"}</span></calcite-tooltip><calcite-button round icon-start=copy-to-clipboard kind=neutral scale=s @click=${(h) => {
|
|
241
|
+
const l = h.currentTarget;
|
|
242
242
|
p(a.code).then(() => {
|
|
243
|
-
|
|
243
|
+
l.setAttribute("data-copied", "true"), setTimeout(() => l.removeAttribute("data-copied"), 1500);
|
|
244
244
|
});
|
|
245
245
|
}} class="response-secondary-action-button" .id=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-button><calcite-popover .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-feedback" .label=${i.copiedsuccessfully ?? "copied successfully"} open trigger-disabled><span>${i.copiedsuccessfully ?? "copied successfully"}</span></calcite-popover><calcite-tooltip .referenceElement=${`copy-response-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start class="copy-tooltip">${i.copytoclipboard ?? "Copy code to clipboard"}</calcite-tooltip></div><div slot=footer-end class="feedback-actions"><calcite-action .text=${i.thumbsup ?? "Thumbs up"} scale=s icon=thumbs-up @click=${a.onThumbsUp} .id=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-up-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.helpful ?? "Helpful"}</span></calcite-tooltip><calcite-action .text=${i.thumbsdown ?? "Thumbs down"} scale=s icon=thumbs-down @click=${a.onThumbsDown} .id=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`}></calcite-action><calcite-tooltip .referenceElement=${`thumbs-down-${a.conversationId}-${c ? "standalone" : "list"}`} placement=top-start><span>${i.unhelpful ?? "Unhelpful"}</span></calcite-tooltip></div></calcite-card>`)}</calcite-card-group></calcite-block>`;
|
|
246
246
|
}
|
|
247
247
|
const Ne = ({ card: t, messages: e }) => {
|
|
248
248
|
const i = le(), o = `response-chip-profile-${t.conversationId}-${i}`, s = (e.profilecontextlabel ?? "Profile context: {profileId}").replace("{profileId}", t.profileId);
|
|
249
|
-
return
|
|
250
|
-
}, B = (t) => t.type === "featureSet",
|
|
249
|
+
return d`<calcite-tooltip .referenceElement=${o} placement=top-start class="contained-popover-or-tooltip">${s}</calcite-tooltip><calcite-chip .label=${t.profileId} scale=s appearance=outline icon=map-information id=${o ?? V}>${t.profileId}</calcite-chip>`;
|
|
250
|
+
}, B = (t) => t.type === "featureSet", R = (t) => {
|
|
251
251
|
if (!be(t))
|
|
252
252
|
return [];
|
|
253
253
|
const e = [];
|
|
254
254
|
return t.relationships?.forEach((i) => {
|
|
255
255
|
e.push(i.toJSON());
|
|
256
256
|
}), e;
|
|
257
|
-
},
|
|
257
|
+
}, E = (t) => t.length > 0 ? { relationships: t } : {}, _e = (t) => fe(t).map((e) => ({
|
|
258
258
|
alias: e.alias,
|
|
259
259
|
name: e.name,
|
|
260
260
|
type: e.type,
|
|
261
261
|
...e.domain ? { domain: e.domain } : {}
|
|
262
262
|
})), M = (t) => t ? { fields: _e(t) } : { fields: [] };
|
|
263
263
|
async function j(t) {
|
|
264
|
-
const e = await t.loadSource(), i = Y(e) && e.isTable, o =
|
|
264
|
+
const e = await t.loadSource(), i = Y(e) && e.isTable, o = R(e);
|
|
265
265
|
return {
|
|
266
266
|
name: t.name,
|
|
267
267
|
type: "featureSet",
|
|
268
268
|
isTable: i,
|
|
269
269
|
...M(e?.fields),
|
|
270
|
-
...
|
|
270
|
+
...E(o)
|
|
271
271
|
};
|
|
272
272
|
}
|
|
273
273
|
async function K(t) {
|
|
274
274
|
switch (t.type) {
|
|
275
275
|
case "feature": {
|
|
276
|
-
const e = await t.loadSource(), i =
|
|
276
|
+
const e = await t.loadSource(), i = R(e);
|
|
277
277
|
return {
|
|
278
278
|
name: t.name,
|
|
279
279
|
type: t.type,
|
|
280
280
|
...M(e?.fields),
|
|
281
|
-
...
|
|
281
|
+
...E(i)
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
case "featureSet": {
|
|
@@ -288,7 +288,7 @@ async function K(t) {
|
|
|
288
288
|
type: "featureSet",
|
|
289
289
|
...i ? { isTable: i } : {},
|
|
290
290
|
...M(e?.fields),
|
|
291
|
-
...R(
|
|
291
|
+
...E(R(e))
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
294
|
case "featureSetCollection": {
|
|
@@ -539,8 +539,8 @@ class Ke extends ie {
|
|
|
539
539
|
};
|
|
540
540
|
try {
|
|
541
541
|
await e.applyEdits({ addFeatures: [new ue({ attributes: h })] });
|
|
542
|
-
} catch (
|
|
543
|
-
x("error", this, "Error submitting feedback.", { detail: { error:
|
|
542
|
+
} catch (l) {
|
|
543
|
+
x("error", this, "Error submitting feedback.", { detail: { error: l } });
|
|
544
544
|
}
|
|
545
545
|
this.handleFeedbackSheetClose();
|
|
546
546
|
}, this.handleClose = (e) => {
|
|
@@ -724,9 +724,9 @@ ${e}` : "";
|
|
|
724
724
|
if (this.closed)
|
|
725
725
|
return null;
|
|
726
726
|
const e = this.viewState.viewMode === "result", i = this.getHistoryCards();
|
|
727
|
-
return this.assistantsEnabled ?
|
|
727
|
+
return this.assistantsEnabled ? 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>` || ""}${Ae({ messages: this.messages })}${Te({ messages: this.messages, popoverContent: O({ assistantsEnabled: this.assistantsEnabled, messages: this.messages, helpTopicUrl: this.usingTheAssitantDocUrl }) })}<calcite-shell class="unstyled-shell">${this.viewState.splashActive && Fe({ messages: this.messages, onProceed: () => {
|
|
728
728
|
this.updateViewState({ splashActive: !1 });
|
|
729
|
-
}, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${
|
|
729
|
+
}, helpTopicUrl: this.assistantOverviewDocUrl, onExit: (o) => this.closePanel?.(o) }) || ""}${Re({ active: this.viewState.confirmationActive, setActive: (o) => this.updateViewState({ confirmationActive: o }), messages: this.messages })}${Me({ isDisabled: this.viewState.isSubmitting, isReadOnly: !1, setQuestion: this.setQuestionState, setIsViewingResult: (o) => this.updateViewState({ viewMode: o ? "result" : "prompt" }), mode: e ? "refine" : "prompt", textAreaRef: this.textAreaRef, question: this.viewState.question, errorMessage: this.viewState.errorMessage, setErrorMessage: (o) => this.updateViewState({ errorMessage: o }), promptValidationMessage: this.viewState.promptValidationMessage, setPromptValidationMessage: (o) => this.updateViewState({ promptValidationMessage: o }), submitQuestion: this.submitQuestion.bind(this), assistantRef: this.el, messages: this.messages, context: this.viewState.context, contextReducedNoticeDismissed: this.viewState.contextReducedNoticeDismissed, setContextReducedNoticeDismissed: (o) => this.updateViewState({ contextReducedNoticeDismissed: o }) })}<calcite-block-group .label=${this.messages.interactiveblocks ?? "interactive blocks"}>${!e && !this.viewState.isSubmitting && De({ 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>${L({
|
|
730
730
|
expanded: e,
|
|
731
731
|
messages: this.messages,
|
|
732
732
|
collapsible: !0,
|
|
@@ -751,7 +751,7 @@ ${e}` : "";
|
|
|
751
751
|
heading: this.messages.recentprompts ?? "Recent prompts",
|
|
752
752
|
hidden: this.viewState.isSubmitting || this.viewState.history.length === 0,
|
|
753
753
|
onCopyCode: this.onCopyCode.bind(this)
|
|
754
|
-
})}</calcite-block-group>${this.viewState.feedback.active ? qe({ setOpen: this.handleFeedbackSheetClose, messages: this.messages, onSubmit: this.handleFeedbackSubmit, feedback: this.viewState.feedback, setFeedback: this.setFeedbackState, learnMoreUrl: this.assistantOverviewDocUrl }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` :
|
|
754
|
+
})}</calcite-block-group>${this.viewState.feedback.active ? qe({ setOpen: this.handleFeedbackSheetClose, messages: this.messages, onSubmit: this.handleFeedbackSubmit, feedback: this.viewState.feedback, setFeedback: this.setFeedbackState, learnMoreUrl: this.assistantOverviewDocUrl }) : null}</calcite-shell></calcite-flow-item></calcite-flow>` : d`<calcite-flow><calcite-flow-item .selected=${!e} closable heading-level=2 .heading=${this.messages.arcadeassistant ?? "Arcade assistant"} @calciteFlowItemClose=${this.handleClose}>${O({ slot: "content-top", messages: this.messages, assistantsEnabled: this.assistantsEnabled, helpTopicUrl: this.usingTheAssitantDocUrl })}</calcite-flow-item></calcite-flow>`;
|
|
755
755
|
}
|
|
756
756
|
}
|
|
757
757
|
Z("arcgis-arcade-coding-assistant", Ke);
|
|
@@ -31,7 +31,11 @@ import type { T9nMeta } from "@arcgis/lumina/controllers";
|
|
|
31
31
|
* - Support for many [languages and directionality](https://developers.arcgis.com/javascript/latest/localization/)
|
|
32
32
|
*/
|
|
33
33
|
export abstract class ArcgisArcadeEditor<T extends WithCustomPanels = object> extends LitElement {
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* enables and configures the arcade assistant
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
35
39
|
accessor arcadeAssistant: ArcadeAssistantConfig | undefined;
|
|
36
40
|
/**
|
|
37
41
|
* Custom panels to be displayed in the side panel.
|