@esri/hub-web-components 0.0.7 → 0.0.9
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/{WRKUDBNV.js → 4A7FWUZG.js} +1 -1
- package/dist/cdn/{O2NZEVMJ.js → 4RA6ROL7.js} +2 -2
- package/dist/cdn/{SWTIJZQB.js → LZNPMUYS.js} +2 -2
- package/dist/cdn/{4ODXXJTI.js → N6XAUVU3.js} +3 -3
- package/dist/cdn/{U2LWF6QB.js → YIHEVBQL.js} +1 -1
- package/dist/cdn/YZNI5NYE.js +4 -0
- package/dist/cdn/{KSGVQKCZ.js → ZVSPHTOL.js} +1 -1
- package/dist/cdn/index.js +2 -2
- package/dist/chunks/chat-action.js +1 -1
- package/dist/chunks/runtime.js +1 -1
- package/dist/components/arcgis-chat-shell/customElement.js +1 -1
- package/dist/components/arcgis-chat-ui/components/chat-action/customElement.js +1 -1
- package/dist/components/arcgis-chat-ui/components/chat-response/customElement.js +1 -1
- package/dist/components/arcgis-chat-ui/components/chat-status/customElement.js +1 -1
- package/dist/components/arcgis-chat-ui/customElement.js +2 -2
- package/dist/components/arcgis-hub-ai-assistant/customElement.js +108 -106
- package/dist/components/arcgis-hub-ai-assistant/util/customElement.js +1 -1
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/dist/embed-config.js +1 -1
- package/dist/index.js +1 -1
- package/dist/loader.js +1 -1
- package/dist/util/configuration.d.ts +3 -0
- package/package.json +2 -2
- package/dist/cdn/WXE3ZTTR.js +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
4
|
-
import{c,g as $,h as d,i as f,j as A}from"./
|
|
3
|
+
v0.0.9 */
|
|
4
|
+
import{c,g as $,h as d,i as f,j as A}from"./ZVSPHTOL.js";var o=(t,e)=>{let s=t._$AN;if(s===void 0)return!1;for(let i of s)i._$AO?.(e,!1),o(i,e);return!0},n=t=>{let e,s;do{if((e=t._$AM)===void 0)break;s=e._$AN,s.delete(t),t=e}while(s?.size===0)},v=t=>{for(let e;e=t._$AM;t=e){let s=e._$AN;if(s===void 0)e._$AN=s=new Set;else if(s.has(t))break;s.add(t),m(e)}};function p(t){this._$AN!==void 0?(n(this),this._$AM=t,v(this)):this._$AM=t}function u(t,e=!1,s=0){let i=this._$AH,_=this._$AN;if(_!==void 0&&_.size!==0)if(e)if(Array.isArray(i))for(let h=s;h<i.length;h++)o(i[h],!1),n(i[h]);else i!=null&&(o(i,!1),n(i));else o(this,t)}var m=t=>{t.type==$.CHILD&&(t._$AP??=u,t._$AQ??=p)},r=class extends f{constructor(){super(...arguments),this._$AN=void 0}_$AT(e,s,i){super._$AT(e,s,i),v(this),this.isConnected=e._$AU}_$AO(e,s=!0){e!==this.isConnected&&(this.isConnected=e,e?this.reconnected?.():this.disconnected?.()),s&&(o(this,e),n(this))}setValue(e){if(A(this._$Ct))this._$Ct._$AI(e,this);else{let s=[...this._$Ct._$AH];s[this._$Ci]=e,this._$Ct._$AI(s,this,0)}}disconnected(){}reconnected(){}};var T=()=>new l,l=class{},a=new WeakMap,w=d(class extends r{render(t){return c}update(t,[e]){let s=e!==this.G;return s&&this.G!==void 0&&this.rt(void 0),(s||this.lt!==this.ct)&&(this.G=e,this.ht=t.options?.host,this.rt(this.ct=t.element)),c}rt(t){if(this.isConnected||(t=void 0),typeof this.G=="function"){let e=this.ht??globalThis,s=a.get(e);s===void 0&&(s=new WeakMap,a.set(e,s)),s.get(this.G)!==void 0&&this.G.call(this.ht,void 0),s.set(this.G,t),t!==void 0&&this.G.call(this.ht,t)}else this.G.value=t}get lt(){return typeof this.G=="function"?a.get(this.ht??globalThis)?.get(this.G):this.G?.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});export{T as a,w as b};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
4
|
-
import"./
|
|
3
|
+
v0.0.9 */
|
|
4
|
+
import"./4A7FWUZG.js";import{a as t,b as a}from"./4RA6ROL7.js";import{a as o,b as i,d as s,k as n,l as c,p as h}from"./ZVSPHTOL.js";var p=o`:host{display:flex;height:100%;.innerContent{word-wrap:break-word;height:100%}.hidden{display:none}.aboutPanel{padding:10px}.map-panel-outer{height:100%;display:flex;flex-direction:column}::slotted([slot="map"]){flex-grow:1}}`,e=class extends n{constructor(){super(...arguments),this._chatAction=t(),this._aboutAction=t(),this._contentPanel=t(),this._aboutPanel=t(),this.activePanelMode="chat",this.mapEnabled=!1,this.mapVisible=!1,this.aboutVisible=!1,this.map=void 0,this.featureTable=void 0,this.chatComponent=void 0,this.aboutContent=`
|
|
5
5
|
<div style="padding: 20px">
|
|
6
6
|
<h2>Disclaimer</h2>
|
|
7
7
|
<p>more info soon ...</p>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
4
|
-
import{d as q,g as z}from"./
|
|
3
|
+
v0.0.9 */
|
|
4
|
+
import{d as q,g as z}from"./YIHEVBQL.js";import{b as _}from"./4RA6ROL7.js";import{a as I,b as c,c as G,d as S,k as M,m as B,n as E,p as A}from"./ZVSPHTOL.js";export default $arcgis.t(([K,Q])=>{var p=class{source;flags;constructor(e,t=""){this.source=e.source,this.flags=t}setGroup(e,t){let i=typeof t=="string"?t:t.source;return i=i.replace(/(^|[^\[])\^/g,"$1"),this.source=this.source.replace(e,i),this}getRegexp(){return new RegExp(this.source,this.flags)}};var N=/[&<>"']/,O=/[&<>"']/g,U={"&":"&","<":"<",">":">",'"':""","'":"'"},T=/[<>"']|&(?!#?\w+;)/,W=/[<>"']|&(?!#?\w+;)/g;function Y(n,e){if(e){if(N.test(n))return n.replace(O,t=>U[t])}else if(T.test(n))return n.replace(W,t=>U[t]);return n}function V(n){return n.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,function(e,t){return t=t.toLowerCase(),t==="colon"?":":t.charAt(0)==="#"?t.charAt(1)==="x"?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""})}var l;(function(n){n[n.space=1]="space",n[n.text=2]="text",n[n.paragraph=3]="paragraph",n[n.heading=4]="heading",n[n.listStart=5]="listStart",n[n.listEnd=6]="listEnd",n[n.looseItemStart=7]="looseItemStart",n[n.looseItemEnd=8]="looseItemEnd",n[n.listItemStart=9]="listItemStart",n[n.listItemEnd=10]="listItemEnd",n[n.blockquoteStart=11]="blockquoteStart",n[n.blockquoteEnd=12]="blockquoteEnd",n[n.code=13]="code",n[n.table=14]="table",n[n.html=15]="html",n[n.hr=16]="hr"})(l||(l={}));var L=class{gfm=!0;tables=!0;breaks=!1;pedantic=!1;sanitize=!1;sanitizer;mangle=!0;smartLists=!1;silent=!1;highlight;langPrefix="lang-";smartypants=!1;headerPrefix="";renderer;xhtml=!1;escape=Y;unescape=V;isNoP};var y=class{options;constructor(e){this.options=e||x.options}code(e,t,i,s){if(this.options.highlight){let h=this.options.highlight(e,t);h!=null&&h!==e&&(i=!0,e=h)}let r=i?e:this.options.escape(e,!0);return t?`
|
|
5
5
|
<pre><code class="${this.options.langPrefix+this.options.escape(t,!0)}">${r}
|
|
6
6
|
</code></pre>
|
|
7
7
|
`:`
|
|
@@ -38,4 +38,4 @@ Please report this to https://github.com/ts-stack/markdown`,this.options.silent)
|
|
|
38
38
|
`)+s,b=a-1)),f=u||/\n\n(?!\s*$)/.test(m),b!==a-1&&(u=m.charAt(m.length-1)===`
|
|
39
39
|
`,f||(f=u)),this.tokens.push({type:f?l.looseItemStart:l.listItemStart}),this.getTokens(m,!1,i),this.tokens.push({type:l.listItemEnd})}this.tokens.push({type:l.listEnd});continue}if(r=this.rules.html.exec(s)){s=s.substring(r[0].length);let o=r[1],h=o==="pre"||o==="script"||o==="style";this.tokens.push({type:this.options.sanitize?l.paragraph:l.html,pre:!this.options.sanitizer&&h,text:r[0]});continue}if(t&&(r=this.rules.def.exec(s))){s=s.substring(r[0].length),this.links[r[1].toLowerCase()]={href:r[2],title:r[3]};continue}if(t&&this.hasRulesTables&&(r=this.rules.table.exec(s))){s=s.substring(r[0].length);let o={type:l.table,header:r[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:r[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:[]};for(let a=0;a<o.align.length;a++)/^ *-+: *$/.test(o.align[a])?o.align[a]="right":/^ *:-+: *$/.test(o.align[a])?o.align[a]="center":/^ *:-+ *$/.test(o.align[a])?o.align[a]="left":o.align[a]=null;let h=r[3].replace(/(?: *\| *)?\n$/,"").split(`
|
|
40
40
|
`);for(let a=0;a<h.length;a++)o.cells[a]=h[a].replace(/^ *\| *| *\| *$/g,"").split(/ *\| */);this.tokens.push(o);continue}if(this.staticThis.simpleRules.length){let o=this.staticThis.simpleRules;for(let h=0;h<o.length;h++)if(r=o[h].exec(s)){s=s.substring(r[0].length);let a="simpleRule"+(h+1);this.tokens.push({type:a,execArr:r});continue e}}if(t&&(r=this.rules.paragraph.exec(s))){s=s.substring(r[0].length),r[1].slice(-1)===`
|
|
41
|
-
`?this.tokens.push({type:l.paragraph,text:r[1].slice(0,-1)}):this.tokens.push({type:this.tokens.length>0?l.paragraph:l.text,text:r[1]});continue}if(r=this.rules.text.exec(s)){s=s.substring(r[0].length),this.tokens.push({type:l.text,text:r[0]});continue}if(s)throw new Error("Infinite loop on byte: "+s.charCodeAt(0)+`, near text '${s.slice(0,30)}...'`)}return{tokens:this.tokens,links:this.links}}};var J=n=>{let e=/https?:\/\/[^\s]+[^. ]/g;return n.replace(e,"<a href='$&' target='_new'>$&</a>")},F=n=>{if(!n)return"";let e=n.replace(/(?:\r\n|\r|\n|\\n)/g,"<br>");return e=e.replace(/(\\\")/g,"'"),e=e.replace(/(\")/g,""),e=e.replace(/AI: /g,""),e=x.parse(e),e.match(/href/)||(e=J(e)),e=e.replace(/<a href=/g,'<a target="_new" href='),e},Z=(n,e,t,i)=>{if(!e)return"";switch(!0){case e.includes("Site"):return t;case e.includes("Page"):return`https://${i}/pages/${n}`;case e.includes("Service"):return`https://${i}/maps/${n}`;case e.includes("Document"):return`https://${i}/documents/${n}`;default:return`https://${i}/content/${n}`}},D=({source:n,domain:e="hub.arcgis.com",showOutlinks:t=!0,addDataClick:i})=>{let s=Z(n.id,n.type,n.url,e);return c`<div class="thumbnail calcite-mode-light" style=${B({backgroundImage:`url(https://www.arcgis.com/sharing/rest/content/items/${n.id}/info/${n.thumbnail})`})}><calcite-button round icon-start=add-layer @click=${()=>{i()}} appearance=outline-fill>Add to Map</calcite-button></div><div class="bottom"><div class="title">${n.title}</div>${t&&s&&c`<div class="viewDetails"><a href=${s??G} target=_blank>${c`View Details <span>\u21F1</span>`}</a></div>`||""}</div>`};var v=({message:n,addDataClick:e,addLocationClick:t})=>{function i(a){return c`<calcite-accordion-item heading=Reasoning description="Explanation of the AI Assistant process" icon-start=automation><ol>${a.map(u=>c`<li>Tool: ${u.name}${Object.keys(u.parameters).map(d=>{let g=u.parameters[d];return d==="sources"&&Array.isArray(g)?g=g.map(f=>f.title).join(", "):d==="location"&&(g=g.name),c`<div>${d}: ${JSON.stringify(g)}</div>`})}</li>`)}</ol></calcite-accordion-item>`}function s(a){return c`<calcite-accordion-item description="Content to add to your context" heading=Sources icon-start=information expanded><div class="sources">${a.map(u=>c`<div class="wrapper source">${D({source:u,domain:"hub.arcgis.com",showOutlinks:!0,addDataClick:()=>{let d={type:"dataset",title:u.title,data:{id:u.id}};e?.(d)}})}</div>`)}</div></calcite-accordion-item>`}function r(a){return c`<calcite-accordion-item description="See the layers" heading=Map icon-start=map expanded><div>${a.name}</div><arcgis-map .center=${[a.longitude,a.latitude]} .zoom=${a.zoom??void 0} basemap=gray-vector @arcgisViewReadyChange=${o}><arcgis-zoom position=top-left></arcgis-zoom><arcgis-expand position=top-right><arcgis-layer-list></arcgis-layer-list></arcgis-expand></arcgis-map><calcite-button round icon-start=extent @click=${()=>t?.(a)}>Zoom To Location</calcite-button></calcite-accordion-item>`}function o(a){let u=a.target;u.map&&n.sources?.length&&n.sources.forEach(d=>{let g=new K({id:d.id});Q.fromPortalItem({portalItem:g}).then(f=>{u.map&&u.map.add(f)})})}let h=n.sources?.length??n.tools?.length??!!n.location;return c`<div class=${`message author-${n.author}`}><div class="response"><div class="text" .innerHTML=${F(n.text)??""}></div>${h&&c`<div class="actions"><link rel=stylesheet href=https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/light/main.css><calcite-accordion>${n.location&&r(n.location)||""}${(n.sources??[]).length>0&&s(n.sources??[])||""}${(n.tools??[]).length>0&&i(n.tools??[])||""}</calcite-accordion></div>`||""}</div></div>`};var H=({showSkeletonLoader:n,currentLoadingMessage:e})=>n?c`<div class="loader"><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="square-container"><div class="skeleton-loader square"></div><div class="skeleton-loader square"></div></div></div>`:c`<div class="status-message">${e}</div>`;var X=I`.actions{margin:.5em;background-color:#ffffff80;width:100%;border-radius:10px;.thumbnail{background-size:cover;background-position:center center;height:150px;width:100%;display:flex;align-items:center;justify-content:center;border-top-left-radius:10px;border-top-right-radius:10px}.viewDetails{font-size:smaller}.bottom{padding:10px}.title{margin-bottom:5px}.viewDetails span{transform:rotate(90deg);display:inline-block}calcite-accordion{width:100%}}.sources{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:1em;width:100%}.source{margin:.5em;border-radius:10px;width:200px}calcite-accordion-item[heading=Map]>*{margin-bottom:1rem}arcgis-map{display:block;height:400px}.text{margin:0 .5rem}.message{display:grid;grid-column-gap:1px;justify-content:start;grid-template-areas:"avatar text" ". feedback "}.message.removed{display:none}.response{display:block;grid-area:text;width:fit-content;padding:.75rem;font-size:1rem;line-height:1.375rem;text-align:left}.response p{margin-block-start:0;margin-block-end:0}.response a{color:#00a0ff}.response .actions{width:100%;display:flex;flex-wrap:wrap;box-sizing:border-box}.author-Human{justify-content:end;grid-template-areas:"text avatar" "feedback ."}.author-Human .response{background-color:var(--color-primary);color:#fff;border-radius:15px 0 15px 15px}.author-AI .response{border-radius:0 15px 15px;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-1)}.status-message{opacity:0;font-size:1em;transition:opacity 2s ease-in-out;font-size:1.2rem;text-justify:auto}@keyframes fadeIn{0%{opacity:0;transform:translateY(20px)}50%{opacity:1;transform:translateY(0)}to{opacity:0}}.status-message{animation:fadeIn 6s infinite}.loader{display:flex;flex-direction:column;gap:.5rem;background:#fff;padding:1rem;width:65%;border-radius:0 16px 16px}.skeleton-loader{background:#eee;background:linear-gradient(110deg,#ececec 8%,#f5f5f5 18%,#ececec 33%);border-radius:5px;background-size:200% 100%;animation:1.5s shine linear infinite;height:24px;width:100%}.square-container{display:flex;gap:1rem;flex-direction:row}.square{width:120px;height:120px}@keyframes shine{to{background-position-x:-200%}}:host{--color-primary: dodgerblue;display:flex;flex-direction:column;height:100%;.messages{flex:1;flex-grow:1;display:flex;padding:10px;overflow-y:auto;flex-direction:column;gap:1rem}form{margin:0 .5rem;.action-buttons{display:flex;justify-content:space-around}.action-buttons calcite-button{width:auto;flex-grow:1;margin:.5rem}}}#request-input{margin:0 .5rem;height:2rem}.actionsTitle{display:block;font-weight:700;font-size:1.2rem;text-align:left}#actions{display:flex;flex-flow:row wrap;justify-content:flex-start;gap:1rem;margin:1rem}`,k=(n=>(n.USER="Human",n.HUB="AI",n.SYSTEM="System",n))(k||{}),j=["Searching for relevant datasets...","Analyzing your query...","Finding location details...","Loading data for your request...","Filtering data...","Creating map...","Fetching the latest statistics..."],C=class extends M{constructor(){super(...arguments),this.loadingMessageIntervalMs=6e3,this.handleFormSubmit=e=>{e.preventDefault(),this.inputText.trim()&&this.submitUserMessage(this.inputText)},this.handleClearHistory=()=>{this.messages=[],this.conversationId=null,this.scrollToBottomAfterUpdate()},this.isLoading=!1,this.currentLoadingMessage=this.getRandomLoadingMessage(),this.messages=[],this.conversationId=null,this.botDescription="",this.botTitle="",this.defaultSuggestions=[],this.inputText="",this.getFinderResponse=async()=>[],this.arcgisAddDataClick=S(),this.arcgisLocationClick=S()}static{this.properties={isLoading:16,currentLoadingMessage:16,messages:16,devFeatureMessage:0,conversationId:1,botDescription:1,botTitle:1,defaultSuggestions:0,inputText:1,getFinderResponse:0}}static{this.styles=X}submitUserMessage(e){this.inputText="";let t=structuredClone(this.messages),i={author:k.USER,text:e,messageId:t.length+1};t.push(i),this.messages=t,this.scrollToBottomAfterUpdate(),this.handleDevFeatures(t,e)||this.handleUserMessage()}getRandomLoadingMessage(){return j[Math.floor(Math.random()*j.length)]}setMessagesContainer(e){this.messagesContainer=e}scrollToBottomAfterUpdate(){this.updateComplete.then(()=>{this.scrollToBottom()})}scrollToBottom(){this.messagesContainer&&this.messagesContainer.scrollTo({top:this.messagesContainer.scrollHeight,behavior:"smooth"})}handleInputTextChange(e){this.inputText=e.target.value}handleDevFeatures(e,t){if(t==="::trees"&&this.devFeatureMessage){let i={...this.devFeatureMessage,messageId:e.length+1};return e.push(i),this.messages=e,!0}return!1}handleChatError(e){this.setLoading(!1);let t={text:"Sorry, I encountered an error while processing your request. Please try again.",author:k.HUB,messageId:e.length+1};e.push(t),this.messages=e,this.scrollToBottomAfterUpdate()}setLoading(e){this.isLoading=e,e?(this.currentLoadingMessage=this.getRandomLoadingMessage(),this.loadingIntervalId=window.setInterval(()=>{this.currentLoadingMessage=this.getRandomLoadingMessage()},this.loadingMessageIntervalMs),this.scrollToBottomAfterUpdate()):this.loadingIntervalId&&(clearInterval(this.loadingIntervalId),this.loadingIntervalId=void 0)}async handleUserMessage(){let e=structuredClone(this.messages);try{this.setLoading(!0);let t=(await this.getFinderResponse(e[e.length-1].text,this.conversationId))[1];if(this.conversationId??=t.conversationId,z(t.context)){let i=t.context,s=Array.isArray(i.sources)&&i.sources.length>0?await q(i.sources):[],r={...i,sources:s,messageId:e.length+1,author:k.HUB};e[e.length-1].text==="trees"&&(this.devFeatureMessage=r),this.setLoading(!1),e.push(r),this.messages=e}else this.handleChatError(e);this.scrollToBottomAfterUpdate()}catch{this.handleChatError(e)}}renderSuggestions(e){return e.map(t=>c`<calcite-button round icon-start=${(typeof t=="string"?"effects":t.icon)??E} @click=${()=>this.submitUserMessage(typeof t=="string"?t:t.label)} .disabled=${this.isLoading} appearance=outline-fill>${typeof t=="string"?t:t.label}</calcite-button>`)}renderWelcomeMessages(){return c`${this.botTitle&&v({message:{author:k.HUB,text:`Welcome to the ${this.botTitle}`}})||""}${this.botDescription&&v({message:{author:k.HUB,text:this.botDescription}})||""}${v({message:{author:k.HUB,text:"How can I assist you today?"}})}`}renderForm(){return c`<form @submit=${this.handleFormSubmit}><calcite-input-text .disabled=${this.isLoading} id=request-input placeholder="What are you searching for...?" @calciteInputTextInput=${this.handleInputTextChange} .value=${this.inputText}></calcite-input-text><div class="action-buttons"><calcite-button appearance=outline icon-start=reset @click=${this.handleClearHistory} .disabled=${this.isLoading}>Clear History</calcite-button><calcite-button type=submit icon-start=send .disabled=${this.isLoading||!this.inputText.trim()}>Send</calcite-button></div></form>`}renderMessageContainer(){return c`<div class="messages" ${_(this.setMessagesContainer)}>${this.renderWelcomeMessages()}<div><div class="actionsTitle">Suggested prompts</div><div id=actions>${this.renderSuggestions(this.defaultSuggestions)}</div></div>${this.messages.map(e=>v({message:e,addDataClick:t=>this.arcgisAddDataClick.emit(t),addLocationClick:t=>this.arcgisLocationClick.emit(t)}))}${this.isLoading&&H({showSkeletonLoader:!1,currentLoadingMessage:this.currentLoadingMessage})||""}</div>`}render(){return c`${this.renderMessageContainer()}${this.renderForm()}`}};A("arcgis-chat-ui",C);return C},"portal/PortalItem","layers/Layer")
|
|
41
|
+
`?this.tokens.push({type:l.paragraph,text:r[1].slice(0,-1)}):this.tokens.push({type:this.tokens.length>0?l.paragraph:l.text,text:r[1]});continue}if(r=this.rules.text.exec(s)){s=s.substring(r[0].length),this.tokens.push({type:l.text,text:r[0]});continue}if(s)throw new Error("Infinite loop on byte: "+s.charCodeAt(0)+`, near text '${s.slice(0,30)}...'`)}return{tokens:this.tokens,links:this.links}}};var J=n=>{let e=/https?:\/\/[^\s]+[^. ]/g;return n.replace(e,"<a href='$&' target='_new'>$&</a>")},F=n=>{if(!n)return"";let e=n.replace(/(?:\r\n|\r|\n|\\n)/g,"<br>");return e=e.replace(/(\\\")/g,"'"),e=e.replace(/(\")/g,""),e=e.replace(/AI: /g,""),e=x.parse(e),e.match(/href/)||(e=J(e)),e=e.replace(/<a href=/g,'<a target="_new" href='),e},Z=(n,e,t,i)=>{if(!e)return"";switch(!0){case e.includes("Site"):return t;case e.includes("Page"):return`https://${i}/pages/${n}`;case e.includes("Service"):return`https://${i}/maps/${n}`;case e.includes("Document"):return`https://${i}/documents/${n}`;default:return`https://${i}/content/${n}`}},D=({source:n,domain:e="hub.arcgis.com",showOutlinks:t=!0,addDataClick:i})=>{let s=Z(n.id,n.type,n.url,e);return c`<div class="thumbnail calcite-mode-light" style=${B({backgroundImage:`url(https://www.arcgis.com/sharing/rest/content/items/${n.id}/info/${n.thumbnail})`})}><calcite-button round icon-start=add-layer @click=${()=>{i()}} appearance=outline-fill>Add to Map</calcite-button></div><div class="bottom"><div class="title">${n.title}</div>${t&&s&&c`<div class="viewDetails"><a href=${s??G} target=_blank>${c`View Details <span>\u21F1</span>`}</a></div>`||""}</div>`};var v=({message:n,addDataClick:e,addLocationClick:t})=>{function i(a){return c`<calcite-accordion-item heading=Reasoning description="Explanation of the AI Assistant process" icon-start=automation><ol>${a.map(u=>c`<li>Tool: ${u.name}${Object.keys(u.parameters).map(d=>{let g=u.parameters[d];return d==="sources"&&Array.isArray(g)?g=g.map(f=>f.title).join(", "):d==="location"&&(g=g.name),c`<div>${d}: ${JSON.stringify(g)}</div>`})}</li>`)}</ol></calcite-accordion-item>`}function s(a){return c`<calcite-accordion-item description="Content to add to your context" heading=Sources icon-start=information expanded><div class="sources">${a.map(u=>c`<div class="wrapper source">${D({source:u,domain:"hub.arcgis.com",showOutlinks:!0,addDataClick:()=>{let d={type:"dataset",title:u.title,data:{id:u.id}};e?.(d)}})}</div>`)}</div></calcite-accordion-item>`}function r(a){return c`<calcite-accordion-item description="See the layers" heading=Map icon-start=map expanded><div>${a.name}</div><arcgis-map .center=${[a.longitude,a.latitude]} .zoom=${a.zoom??void 0} basemap=gray-vector @arcgisViewReadyChange=${o}><arcgis-zoom position=top-left></arcgis-zoom><arcgis-expand position=top-right><arcgis-layer-list></arcgis-layer-list></arcgis-expand></arcgis-map><calcite-button round icon-start=extent @click=${()=>t?.(a)}>Zoom To Location</calcite-button></calcite-accordion-item>`}function o(a){let u=a.target;u.map&&n.sources?.length&&n.sources.forEach(d=>{let g=new K({id:d.id});Q.fromPortalItem({portalItem:g}).then(f=>{u.map&&u.map.add(f)})})}let h=n.sources?.length??n.tools?.length??!!n.location;return c`<div class=${`message author-${n.author}`}><div class="response"><div class="text" .innerHTML=${F(n.text)??""}></div>${h&&c`<div class="actions"><link rel=stylesheet href=https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/light/main.css><calcite-accordion>${n.location&&r(n.location)||""}${(n.sources??[]).length>0&&s(n.sources??[])||""}${(n.tools??[]).length>0&&i(n.tools??[])||""}</calcite-accordion></div>`||""}</div></div>`};var H=({showSkeletonLoader:n,currentLoadingMessage:e})=>n?c`<div class="loader"><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="square-container"><div class="skeleton-loader square"></div><div class="skeleton-loader square"></div></div></div>`:c`<div class="status-message">${e}</div>`;var X=I`.actions{margin:.5em;background-color:#ffffff80;width:100%;border-radius:10px;.thumbnail{background-size:cover;background-position:center center;height:150px;width:100%;display:flex;align-items:center;justify-content:center;border-top-left-radius:10px;border-top-right-radius:10px}.viewDetails{font-size:smaller}.bottom{padding:10px}.title{margin-bottom:5px}.viewDetails span{transform:rotate(90deg);display:inline-block}calcite-accordion{width:100%}}.sources{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:1em;width:100%}.source{margin:.5em;border-radius:10px;width:200px}calcite-accordion-item[heading=Map]>*{margin-bottom:1rem}arcgis-map{display:block;height:400px}.text{margin:0 .5rem}.message{display:grid;grid-column-gap:1px;justify-content:start;grid-template-areas:"avatar text" ". feedback "}.message.removed{display:none}.response{display:block;grid-area:text;width:fit-content;padding:.75rem;font-size:1rem;line-height:1.375rem;text-align:left}.response p{margin-block-start:0;margin-block-end:0}.response a{color:#00a0ff}.response .actions{width:100%;display:flex;flex-wrap:wrap;box-sizing:border-box}.author-Human{justify-content:end;grid-template-areas:"text avatar" "feedback ."}.author-Human .response{background-color:var(--color-primary);color:#fff;border-radius:15px 0 15px 15px}.author-AI .response{border-radius:0 15px 15px;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-1)}.status-message{opacity:0;font-size:1em;transition:opacity 2s ease-in-out;font-size:1.2rem;text-justify:auto}@keyframes fadeIn{0%{opacity:0;transform:translateY(20px)}50%{opacity:1;transform:translateY(0)}to{opacity:0}}.status-message{animation:fadeIn 6s infinite}.loader{display:flex;flex-direction:column;gap:.5rem;background:#fff;padding:1rem;width:65%;border-radius:0 16px 16px}.skeleton-loader{background:#eee;background:linear-gradient(110deg,#ececec 8%,#f5f5f5 18%,#ececec 33%);border-radius:5px;background-size:200% 100%;animation:1.5s shine linear infinite;height:24px;width:100%}.square-container{display:flex;gap:1rem;flex-direction:row}.square{width:120px;height:120px}@keyframes shine{to{background-position-x:-200%}}:host{--color-primary: dodgerblue;display:flex;flex-direction:column;height:100%;.messages{flex:1;flex-grow:1;display:flex;padding:10px;overflow-y:auto;flex-direction:column;gap:1rem}form{margin:0 .5rem;.action-buttons{display:flex;justify-content:space-around}.action-buttons calcite-button{width:auto;flex-grow:1;margin:.5rem}}}#request-input{margin:0 .5rem;height:2rem}.actionsTitle{display:block;font-weight:700;font-size:1.2rem;text-align:left}#actions{display:flex;flex-flow:row wrap;justify-content:flex-start;gap:1rem;margin:1rem}`,k=(n=>(n.USER="Human",n.HUB="AI",n.SYSTEM="System",n))(k||{}),j=["Searching for relevant datasets...","Analyzing your query...","Finding location details...","Loading data for your request...","Filtering data...","Creating map...","Fetching the latest statistics..."],C=class extends M{constructor(){super(...arguments),this.loadingMessageIntervalMs=6e3,this.handleFormSubmit=e=>{e.preventDefault(),this.inputText.trim()&&this.submitUserMessage(this.inputText)},this.handleClearHistory=()=>{this.messages=[],this.conversationId=null,this.scrollToBottomAfterUpdate()},this.isLoading=!1,this.currentLoadingMessage=this.getRandomLoadingMessage(),this.messages=[],this.conversationId=null,this.botDescription="",this.botTitle="",this.defaultSuggestions=[],this.inputText="",this.getFinderResponse=async()=>[],this.arcgisAddDataClick=S(),this.arcgisLocationClick=S()}static{this.properties={isLoading:16,currentLoadingMessage:16,messages:16,devFeatureMessage:0,conversationId:1,botDescription:1,botTitle:1,defaultSuggestions:0,inputText:1,getFinderResponse:0}}static{this.styles=X}submitUserMessage(e){this.inputText="";let t=structuredClone(this.messages),i={author:k.USER,text:e,messageId:t.length+1};t.push(i),this.messages=t,this.scrollToBottomAfterUpdate(),this.handleDevFeatures(t,e)||this.handleUserMessage()}getRandomLoadingMessage(){return j[Math.floor(Math.random()*j.length)]}setMessagesContainer(e){this.messagesContainer=e}scrollToBottomAfterUpdate(){this.updateComplete.then(()=>{this.scrollToBottom()})}scrollToBottom(){this.messagesContainer&&this.messagesContainer.scrollTo({top:this.messagesContainer.scrollHeight,behavior:"smooth"})}handleInputTextChange(e){this.inputText=e.target.value}handleDevFeatures(e,t){if(t==="::trees"&&this.devFeatureMessage){let i={...this.devFeatureMessage,messageId:e.length+1};return e.push(i),this.messages=e,!0}return!1}handleChatError(e){this.setLoading(!1);let t={text:"Sorry, I encountered an error while processing your request. Please try again.",author:k.HUB,messageId:e.length+1};e.push(t),this.messages=e,this.scrollToBottomAfterUpdate()}setLoading(e){this.isLoading=e,e?(this.currentLoadingMessage=this.getRandomLoadingMessage(),this.loadingIntervalId=window.setInterval(()=>{this.currentLoadingMessage=this.getRandomLoadingMessage()},this.loadingMessageIntervalMs),this.scrollToBottomAfterUpdate()):this.loadingIntervalId&&(clearInterval(this.loadingIntervalId),this.loadingIntervalId=void 0)}async handleUserMessage(){let e=structuredClone(this.messages);try{this.setLoading(!0);let t=(await this.getFinderResponse(e[e.length-1].text,this.conversationId))[1];if(this.conversationId??=t.conversationId,z(t.context)){let i=t.context,s=Array.isArray(i.sources)&&i.sources.length>0?await q(i.sources):[],r={...i,sources:s,messageId:e.length+1,author:k.HUB};e[e.length-1].text==="trees"&&(this.devFeatureMessage=r),this.setLoading(!1),e.push(r),this.messages=e}else this.handleChatError(e);this.scrollToBottomAfterUpdate()}catch{this.handleChatError(e)}}renderSuggestions(e){return e.map(t=>c`<calcite-button round icon-start=${(typeof t=="string"?"effects":t.icon)??E} @click=${()=>this.submitUserMessage(typeof t=="string"?t:t.label)} .disabled=${this.isLoading} appearance=outline-fill>${typeof t=="string"?t:t.label}</calcite-button>`)}renderWelcomeMessages(){return c`${this.botTitle&&v({message:{author:k.HUB,text:`Welcome to the ${this.botTitle} assistant.`}})||""}${this.botDescription&&v({message:{author:k.HUB,text:this.botDescription}})||""}${v({message:{author:k.HUB,text:"How can I assist you today?"}})}`}renderForm(){return c`<form @submit=${this.handleFormSubmit}><calcite-input-text .disabled=${this.isLoading} id=request-input placeholder="What are you searching for...?" @calciteInputTextInput=${this.handleInputTextChange} .value=${this.inputText}></calcite-input-text><div class="action-buttons"><calcite-button appearance=outline icon-start=reset @click=${this.handleClearHistory} .disabled=${this.isLoading}>Clear History</calcite-button><calcite-button type=submit icon-start=send .disabled=${this.isLoading||!this.inputText.trim()}>Send</calcite-button></div></form>`}renderMessageContainer(){return c`<div class="messages" ${_(this.setMessagesContainer)}>${this.renderWelcomeMessages()}<div><div class="actionsTitle">Suggested prompts</div><div id=actions>${this.renderSuggestions(this.defaultSuggestions)}</div></div>${this.messages.map(e=>v({message:e,addDataClick:t=>this.arcgisAddDataClick.emit(t),addLocationClick:t=>this.arcgisLocationClick.emit(t)}))}${this.isLoading&&H({showSkeletonLoader:!1,currentLoadingMessage:this.currentLoadingMessage})||""}</div>`}render(){return c`${this.renderMessageContainer()}${this.renderForm()}`}};A("arcgis-chat-ui",C);return C},"portal/PortalItem","layers/Layer")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
3
|
+
v0.0.9 */
|
|
4
4
|
function X(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r}function G(t){return Object.keys(t).some(e=>{let r=t[e];if(!r)return!1;switch(r&&r.toParam&&(r=r.toParam()),r.constructor.name){case"Array":return!1;case"Object":return!1;case"Date":return!1;case"Function":return!1;case"Boolean":return!1;case"String":return!1;case"Number":return!1;default:return!0}})}function F(t){let e={};return Object.keys(t).forEach(r=>{var n,o;let i=t[r];if(i&&i.toParam&&(i=i.toParam()),!i&&i!==0&&typeof i!="boolean"&&typeof i!="string")return;let s=i.constructor.name,c;switch(s){case"Array":let m=(o=(n=i[0])===null||n===void 0?void 0:n.constructor)===null||o===void 0?void 0:o.name;c=m==="Array"?i:m==="Object"?JSON.stringify(i):i.join(",");break;case"Object":c=JSON.stringify(i);break;case"Date":c=i.valueOf();break;case"Function":c=null;break;case"Boolean":c=i+"";break;default:c=i;break}(c||c===0||typeof c=="string"||Array.isArray(c))&&(e[r]=c)}),e}function O(t,e){return Array.isArray(e)&&e[0]&&Array.isArray(e[0])?e.map(r=>O(t,r)).join("&"):encodeURIComponent(t)+"="+encodeURIComponent(e)}function $(t){let e=F(t);return Object.keys(e).map(r=>O(r,e[r])).join("&")}var Z=globalThis.FormData,ve=globalThis.File,je=globalThis.Blob;function q(t,e){let r=G(t)||e,n=F(t);if(r){let o=new Z;return Object.keys(n).forEach(i=>{if(typeof Blob<"u"&&n[i]instanceof Blob){let s=n.fileName||n[i].name||i;o.append(i,n[i],s)}else o.append(i,n[i])}),o}else return $(t)}var T=class extends Error{constructor(e,r,n,o,i){super(e);let s=new.target.prototype;Object.setPrototypeOf(this,s),e=e||"UNKNOWN_ERROR",r=r||"UNKNOWN_ERROR_CODE",this.name="ArcGISRequestError",this.message=r==="UNKNOWN_ERROR_CODE"?e:`${r}: ${e}`,this.originalMessage=e,this.code=r,this.response=n,this.url=o,this.options=i}};function L(t){console&&console.warn&&console.warn.apply(console,[t])}function ee(){return Promise.resolve({fetch:globalThis.fetch,Headers:globalThis.Headers,Response:globalThis.Response,Request:globalThis.Request})}var J="@esri/arcgis-rest-js";function pe(){return globalThis.DEFAULT_ARCGIS_REQUEST_OPTIONS||{httpMethod:"POST",params:{f:"json"}}}var S=class extends T{constructor(e="AUTHENTICATION_ERROR",r="AUTHENTICATION_ERROR_CODE",n,o,i){super(e,r,n,o,i),this.name="ArcGISAuthError",this.message=r==="AUTHENTICATION_ERROR_CODE"?e:`${r}: ${e}`;let s=new.target.prototype;Object.setPrototypeOf(this,s)}retry(e,r=1){let n=0,o=(i,s)=>{n=n+1,e(this.url,this.options).then(c=>{let m=Object.assign(Object.assign({},this.options),{authentication:c});return te(this.url,m)}).then(c=>{i(c)}).catch(c=>{c.name==="ArcGISAuthError"&&n<r?o(i,s):c.name===this.name&&c.message===this.message&&n>=r?s(this):s(c)})};return new Promise((i,s)=>{o(i,s)})}};function de(t,e,r,n,o){if(t.code>=400){let{message:i,code:s}=t;throw new T(i,s,t,e,n)}if(t.error){let{message:i,code:s,messageCode:c}=t.error,m=c||s||"UNKNOWN_ERROR_CODE";throw s===498||s===499?o||new S(i,m,t,e,n):new T(i,m,t,e,n)}if(t.status==="failed"||t.status==="failure"){let i,s="UNKNOWN_ERROR_CODE";try{i=JSON.parse(t.statusMessage).message,s=JSON.parse(t.statusMessage).code}catch{i=t.statusMessage||t.message}throw new T(i,s,t,e,n)}return t}function te(t,e){let r=pe(),n=Object.assign(Object.assign(Object.assign({httpMethod:"POST"},r),e),{params:Object.assign(Object.assign({},r.params),e.params),headers:Object.assign(Object.assign({},r.headers),e.headers)}),{httpMethod:o,rawResponse:i}=n,s=Object.assign({f:"json"},n.params),c=null,m={method:o,signal:n.signal,credentials:n.credentials||"same-origin"};n.headers&&n.headers["X-Esri-Auth-Client-Id"]&&t.indexOf("/oauth2/platformSelf")>-1&&(m.credentials="include");let x;if(typeof n.authentication=="string"){let u=n.authentication;x={portal:"https://www.arcgis.com/sharing/rest",getToken:()=>Promise.resolve(u)},!n.authentication.startsWith("AAPK")&&!n.authentication.startsWith("AATK")&&!n.suppressWarnings&&!globalThis.ARCGIS_REST_JS_SUPPRESS_TOKEN_WARNING&&(L("Using an oAuth 2.0 access token directly in the token option is discouraged. Consider using ArcGISIdentityManager or Application session. See https://esriurl.com/arcgis-rest-js-direct-token-warning for more information."),globalThis.ARCGIS_REST_JS_SUPPRESS_TOKEN_WARNING=!0)}else x=n.authentication;let d=t;return(x?x.getToken(t).catch(u=>(u.url=t,u.options=n,c=u,Promise.resolve(""))):Promise.resolve("")).then(u=>{u.length&&(s.token=u),x&&x.getDomainCredentials&&(m.credentials=x.getDomainCredentials(t));let f={};if(m.method==="GET"){s.token&&n.hideToken&&typeof window>"u"&&(f["X-Esri-Authorization"]=`Bearer ${s.token}`,delete s.token);let p=$(s)===""?t:t+"?"+$(s);n.maxUrlLength&&p.length>n.maxUrlLength||s.token&&n.hideToken?(m.method="POST",u.length&&n.hideToken&&(s.token=u,delete f["X-Esri-Authorization"])):t=p}let w=new RegExp("/items/.+/updateResources").test(t);return m.method==="POST"&&(m.body=q(s,w)),m.headers=Object.assign(Object.assign({},f),n.headers),(typeof window>"u"||window&&typeof window.document>"u")&&!m.headers.referer&&(m.headers.referer=J),!G(s)&&!w&&(m.headers["Content-Type"]="application/x-www-form-urlencoded"),globalThis.fetch?globalThis.fetch(t,m):ee().then(({fetch:h})=>h(t,m))}).then(u=>{if(!u.ok)return u.json().then(f=>{let{status:w,statusText:h}=u,{message:p,details:k}=f.error,b=`${p}. ${k?k.join(" "):""}`.trim();throw new T(b,`HTTP ${w} ${h}`,f,t,n)}).catch(f=>{if(f.name==="ArcGISRequestError")throw f;let{status:w,statusText:h}=u;throw new T(h,`HTTP ${w}`,u,t,n)});if(i)return u;switch(s.f){case"json":return u.json();case"geojson":return u.json();case"html":return u.text();case"text":return u.text();default:return u.blob()}}).then(u=>{if((s.f==="json"||s.f==="geojson")&&!i){let f=de(u,d,s,n,c);if(c){let w=t.toLowerCase().split(/\/rest(\/admin)?\/services\//)[0];n.authentication.federatedServers[w]={token:[],expires:new Date(Date.now()+86400*1e3)},c=null}return f}else return u})}function a(t,e={params:{f:"json"}}){let{request:r}=e,n=X(e,["request"]);return r?r(t,n):te(t,n).catch(o=>o instanceof S&&e.authentication&&typeof e.authentication!="string"&&e.authentication.canRefresh&&e.authentication.refreshCredentials?o.retry(()=>e.authentication.refreshCredentials(),1):Promise.reject(o))}var E;(function(t){t.TOKEN_REFRESH_FAILED="TOKEN_REFRESH_FAILED",t.GENERATE_TOKEN_FOR_SERVER_FAILED="GENERATE_TOKEN_FOR_SERVER_FAILED",t.REFRESH_TOKEN_EXCHANGE_FAILED="REFRESH_TOKEN_EXCHANGE_FAILED",t.NOT_FEDERATED="NOT_FEDERATED",t.UNKNOWN_ERROR_CODE="UNKNOWN_ERROR_CODE"})(E||(E={}));var _=class extends Error{constructor(e="UNKNOWN_ERROR",r=E.UNKNOWN_ERROR_CODE,n,o,i){super(e);let s=new.target.prototype;Object.setPrototypeOf(this,s),this.name="ArcGISTokenRequestError",this.message=`${r}: ${e}`,this.originalMessage=e,this.code=r,this.response=n,this.url=o,this.options=i}};var N=class extends Error{constructor(){super("The user has denied your authorization request.");let r=new.target.prototype;Object.setPrototypeOf(this,r),this.name="ArcGISAccessDeniedError"}};function g(t){return typeof t!="string"||(t=t.trim(),t[t.length-1]==="/"&&(t=t.slice(0,-1))),t}function ge(t){let[e,r]=t.split("=");return{key:decodeURIComponent(e),value:decodeURIComponent(r)}}function re(t){return!t||t.length<=0?{}:t.replace(/^#/,"").replace(/^\?/,"").split("&").reduce((e,r)=>{let{key:n,value:o}=ge(r);return e[n]=o,e},{})}var ne;(function(t){t.ArcGISRequestError="ArcGISRequestError",t.ArcGISAuthError="ArcGISAuthError",t.ArcGISAccessDeniedError="ArcGISAccessDeniedError",t.ArcGISTokenRequestError="ArcGISTokenRequestError"})(ne||(ne={}));var oe=5*60*1e3;function j(t,e){let r=e;return r.rawResponse=!1,a(t,r).then(n=>{if("token"in n&&"expires"in n)return{token:n.token,username:e.params.username,expires:new Date(n.expires)};let o={token:n.access_token,username:n.username,expires:new Date(Date.now()+n.expires_in*1e3-oe),ssl:n.ssl===!0};return n.refresh_token&&(o.refreshToken=n.refresh_token),n.refresh_token_expires_in&&(o.refreshTokenExpires=new Date(Date.now()+n.refresh_token_expires_in*1e3-oe)),o})}var P=class{constructor(e){this.portal=e.portal?g(e.portal):"https://www.arcgis.com/sharing/rest",this._username=e.username}get username(){if(this._username)return this._username;if(this._user&&this._user.username)return this._user.username}getUsername(){return this.username?Promise.resolve(this.username):this.getUser().then(e=>e.username)}getUser(e){if(this._pendingUserRequest)return this._pendingUserRequest;if(this._user)return Promise.resolve(this._user);{let r=`${this.portal}/community/self`,n=Object.assign(Object.assign({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingUserRequest=a(r,n).then(o=>(this._user=o,this._pendingUserRequest=null,o)),this._pendingUserRequest}}clearCachedUserInfo(){this._user=null}};var H=/^https?:\/\/(\S+)\.arcgis\.com.+/;function ie(t){return H.test(t)}function xe(t){if(!H.test(t))return t;switch(K(t)){case"dev":return"https://devext.arcgis.com/sharing/rest";case"qa":return"https://qaext.arcgis.com/sharing/rest";default:return"https://www.arcgis.com/sharing/rest"}}function K(t){if(!H.test(t))return null;let r=t.match(H)[1].split(".").pop();return r.includes("dev")?"dev":r.includes("qa")?"qa":"production"}function se(t,e){let r=g(xe(e)).replace(/https?:\/\//,""),n=g(t).replace(/https?:\/\//,"");return new RegExp(n,"i").test(r)}function ae(t,e){let r=ie(t),n=ie(e),o=K(t),i=K(e);return!!(r&&n&&o===i)}function ce(t,e,r="https://www.arcgis.com/sharing/rest"){let n=`${r}/oauth2/validateAppAccess`;return a(n,{method:"POST",params:{f:"json",client_id:e,token:t}})}function ue(t){let e=`${g(t.portal||"https://www.arcgis.com/sharing/rest")}/oauth2/revokeToken/`,r=t.token,n=t.clientId;delete t.portal,delete t.clientId,delete t.token;let o=Object.assign(Object.assign({},t),{httpMethod:"POST",params:{client_id:n,auth_token:r}});return a(e,o).then(i=>{if(!i.success)throw new T("Unable to revoke token",500,i,e,o);return i})}function z(t,e=window){return!e&&window&&(e=window),e.btoa(String.fromCharCode.apply(null,t)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function le(t,e=window){if(!e&&window&&(e=window),t&&e.isSecureContext&&e.crypto&&e.crypto.subtle){let n=new e.TextEncoder().encode(t);return e.crypto.subtle.digest("SHA-256",n).then(o=>z(new Uint8Array(o),e))}return Promise.resolve(null)}function V(t){!t&&window&&(t=window);let e=t.crypto.getRandomValues(new Uint8Array(32));return z(e)}var I=class t extends P{constructor(e){if(super(e),this.clientId=e.clientId,this._refreshToken=e.refreshToken,this._refreshTokenExpires=e.refreshTokenExpires,this.password=e.password,this._token=e.token,this._tokenExpires=e.tokenExpires,this.portal=e.portal?g(e.portal):"https://www.arcgis.com/sharing/rest",this.ssl=e.ssl,this.provider=e.provider||"arcgis",this.tokenDuration=e.tokenDuration||20160,this.redirectUri=e.redirectUri,this.server=e.server,this.referer=e.referer,this.federatedServers={},this.trustedDomains=[],e.server){let r=this.getServerRootUrl(e.server);this.federatedServers[r]={token:e.token,expires:e.tokenExpires}}this._pendingTokenRequests={}}get token(){return this._token}get tokenExpires(){return this._tokenExpires}get refreshToken(){return this._refreshToken}get refreshTokenExpires(){return this._refreshTokenExpires}get canRefresh(){return!!(this.username&&this.password||this.clientId&&this.refreshToken&&this.redirectUri)}static beginOAuth2(e,r){!r&&window&&(r=window);let{portal:n,provider:o,clientId:i,expiration:s,redirectUri:c,popup:m,popupWindowFeatures:x,locale:d,params:u,style:f,pkce:w,state:h}=Object.assign({portal:"https://www.arcgis.com/sharing/rest",provider:"arcgis",expiration:20160,popup:!0,popupWindowFeatures:"height=400,width=600,menubar=no,location=yes,resizable=yes,scrollbars=yes,status=yes",locale:"",style:"",pkce:!0},e),p=h||V(r),k=`ARCGIS_REST_JS_AUTH_STATE_${i}`;r.localStorage.setItem(k,p);let b=`${g(n)}/oauth2/authorize`,A={client_id:i,response_type:w?"code":"token",expiration:s,redirect_uri:c,state:JSON.stringify({id:p,originalUrl:r.location.href}),locale:d,style:f};o!=="arcgis"&&(b=`${g(n)}/oauth2/social/authorize`,A.socialLoginProviderName=o,A.autoAccountCreateForSocial=!0);let W;if(w){let C=V(r),M=`ARCGIS_REST_JS_CODE_VERIFIER_${i}`;r.localStorage.setItem(M,C),W=le(C,r).then(function(y){A.code_challenge_method=y?"S256":"plain",A.code_challenge=y||C})}else W=Promise.resolve();return W.then(()=>{if(b=`${b}?${$(A)}`,u&&(b=`${b}&${$(u)}`),m)return new Promise((C,M)=>{r.addEventListener(`arcgis-rest-js-popup-auth-${i}`,y=>{if(y.detail.error==="access_denied"){let D=new N;return M(D),D}if(y.detail.errorMessage){let D=new S(y.detail.errorMessage,y.detail.error);return M(D),D}C(new t({clientId:i,portal:n,ssl:y.detail.ssl,token:y.detail.token,tokenExpires:y.detail.expires,username:y.detail.username,refreshToken:y.detail.refreshToken,refreshTokenExpires:y.detail.refreshTokenExpires,redirectUri:c}))},{once:!0}),r.open(b,"oauth-window",x),r.dispatchEvent(new CustomEvent("arcgis-rest-js-popup-auth-start"))});r.location.href=b})}static completeOAuth2(e,r){!r&&window&&(r=window);let{portal:n,clientId:o,popup:i,pkce:s,redirectUri:c}=Object.assign({portal:"https://www.arcgis.com/sharing/rest",popup:!0,pkce:!0},e),m=`ARCGIS_REST_JS_AUTH_STATE_${o}`,x=r.localStorage.getItem(m),d=re(s?r.location.search.replace(/^\?/,""):r.location.hash.replace(/^#/,"")),u=d&&d.state?JSON.parse(d.state):void 0;function f(h,p,k){if(r.localStorage.removeItem(m),i&&r.opener){r.opener.dispatchEvent(new CustomEvent(`arcgis-rest-js-popup-auth-${o}`,{detail:{error:p,errorMessage:h}})),r.close();return}return k&&r.history.replaceState(r.history.state,"",k),p==="access_denied"?Promise.reject(new N):Promise.reject(new S(h,p))}function w(h,p){if(r.localStorage.removeItem(m),i&&r.opener){r.opener.dispatchEvent(new CustomEvent(`arcgis-rest-js-popup-auth-${o}`,{detail:Object.assign({},h)})),r.close();return}return r.history.replaceState(r.history.state,"",p),new t({clientId:o,portal:n,ssl:h.ssl,token:h.token,tokenExpires:h.expires,username:h.username,refreshToken:h.refreshToken,refreshTokenExpires:h.refreshTokenExpires,redirectUri:c||location.href.replace(location.search,"")})}if(!x||!u)return f("No authentication state was found, call `ArcGISIdentityManager.beginOAuth2(...)` to start the authentication process.","no-auth-state");if(u.id!==x)return f("Saved client state did not match server sent state.","mismatched-auth-state");if(d.error){let h=d.error,p=d.error_description||"Unknown error";return f(p,h,u.originalUrl)}if(s&&d.code){let h=g(`${n}/oauth2/token/`),p=`ARCGIS_REST_JS_CODE_VERIFIER_${o}`,k=r.localStorage.getItem(p);return r.localStorage.removeItem(p),j(h,{httpMethod:"POST",params:{client_id:o,code_verifier:k,grant_type:"authorization_code",redirect_uri:c||location.href.replace(location.search,""),code:d.code}}).then(b=>w(Object.assign(Object.assign({},b),u),u.originalUrl)).catch(b=>f(b.originalMessage,b.code,u.originalUrl))}return!s&&d.access_token?Promise.resolve(w(Object.assign({token:d.access_token,expires:new Date(Date.now()+parseInt(d.expires_in,10)*1e3),ssl:d.ssl==="true",username:d.username},u),u.originalUrl)):f("Unknown error","oauth-error",u.originalUrl)}static fromParent(e,r){!r&&window&&(r=window);let n;return new Promise((o,i)=>{n=s=>{if(s.source===r.parent&&s.data)try{return o(t.parentMessageHandler(s))}catch(c){return i(c)}},r.addEventListener("message",n,!1),r.parent.postMessage({type:"arcgis:auth:requestCredential"},e)}).then(o=>(r.removeEventListener("message",n,!1),o))}static authorize(e,r){let{portal:n,clientId:o,expiration:i,redirectUri:s,state:c}=Object.assign({portal:"https://arcgis.com/sharing/rest",expiration:20160},e),m={client_id:o,expiration:i,response_type:"code",redirect_uri:s};c&&(m.state=c);let x=`${n}/oauth2/authorize?${$(m)}`;r.writeHead(301,{Location:x}),r.end()}static exchangeAuthorizationCode(e,r){let{portal:n,clientId:o,redirectUri:i}=Object.assign({portal:"https://www.arcgis.com/sharing/rest"},e);return j(`${n}/oauth2/token`,{params:{grant_type:"authorization_code",client_id:o,redirect_uri:i,code:r}}).then(s=>new t({clientId:o,portal:n,ssl:s.ssl,redirectUri:i,refreshToken:s.refreshToken,refreshTokenExpires:s.refreshTokenExpires,token:s.token,tokenExpires:s.expires,username:s.username})).catch(s=>{throw new _(s.message,E.REFRESH_TOKEN_EXCHANGE_FAILED,s.response,s.url,s.options)})}static deserialize(e){let r=JSON.parse(e);return new t({clientId:r.clientId,refreshToken:r.refreshToken,refreshTokenExpires:r.refreshTokenExpires?new Date(r.refreshTokenExpires):void 0,username:r.username,password:r.password,token:r.token,tokenExpires:r.tokenExpires?new Date(r.tokenExpires):void 0,portal:r.portal,ssl:r.ssl,tokenDuration:r.tokenDuration,redirectUri:r.redirectUri,server:r.server})}static fromCredential(e,r){let n=typeof e.ssl<"u"?e.ssl:!0,o=e.expires||Date.now()+72e5;return r.hasServer?new t({server:e.server,ssl:n,token:e.token,username:e.userId,tokenExpires:new Date(o)}):new t({portal:g(e.server.includes("sharing/rest")?e.server:e.server+"/sharing/rest"),ssl:n,token:e.token,username:e.userId,tokenExpires:new Date(o)})}static parentMessageHandler(e){if(e.data.type==="arcgis:auth:credential")return new t(e.data.credential);if(e.data.type==="arcgis:auth:error"){let r=new Error(e.data.error.message);throw r.name=e.data.error.name,r}else throw new Error("Unknown message type.")}static destroy(e){return ue({clientId:e.clientId,portal:e.portal,token:e.refreshToken||e.token})}static fromToken(e){let r=new t(e);return r.getUser().then(()=>r)}static signIn(e){let r=new t(e);return r.getUser().then(()=>r)}toCredential(){return{expires:this.tokenExpires.getTime(),server:this.server||this.portal,ssl:this.ssl,token:this.token,userId:this.username}}getPortal(e){if(this._pendingPortalRequest)return this._pendingPortalRequest;if(this._portalInfo)return Promise.resolve(this._portalInfo);{let r=`${this.portal}/portals/self`,n=Object.assign(Object.assign({httpMethod:"GET",authentication:this},e),{rawResponse:!1});return this._pendingPortalRequest=a(r,n).then(o=>(this._portalInfo=o,this._pendingPortalRequest=null,o)),this._pendingPortalRequest}}getToken(e,r){return ae(this.portal,e)?this.getFreshToken(r):new RegExp(this.portal,"i").test(e)?this.getFreshToken(r):this.getTokenForServer(e,r)}validateAppAccess(e){return this.getToken(this.portal).then(r=>ce(r,e))}toJSON(){return{clientId:this.clientId,refreshToken:this.refreshToken,refreshTokenExpires:this.refreshTokenExpires||void 0,username:this.username,password:this.password,token:this.token,tokenExpires:this.tokenExpires||void 0,portal:this.portal,ssl:this.ssl,tokenDuration:this.tokenDuration,redirectUri:this.redirectUri,server:this.server}}serialize(){return JSON.stringify(this)}enablePostMessageAuth(e,r){!r&&window&&(r=window),this._hostHandler=this.createPostMessageHandler(e),r.addEventListener("message",this._hostHandler,!1)}disablePostMessageAuth(e){!e&&window&&(e=window),e.removeEventListener("message",this._hostHandler,!1)}refreshCredentials(e){return this.clearCachedUserInfo(),this.username&&this.password?this.refreshWithUsernameAndPassword(e):this.clientId&&this.refreshToken?this.refreshWithRefreshToken():Promise.reject(new _("Unable to refresh token. No refresh token or password present.",E.TOKEN_REFRESH_FAILED))}getServerRootUrl(e){let[r]=g(e).split(/\/rest(\/admin)?\/services(?:\/|#|\?|$)/),[n,o,i]=r.match(/(https?:\/\/)(.+)/),[s,...c]=i.split("/");return`${o}${s.toLowerCase()}/${c.join("/")}`}getDomainCredentials(e){return!this.trustedDomains||!this.trustedDomains.length?"same-origin":(e=e.toLowerCase(),this.trustedDomains.some(r=>e.startsWith(r.toLowerCase()))?"include":"same-origin")}signOut(){return t.destroy(this)}createPostMessageHandler(e){return r=>{let n=e.indexOf(r.origin)>-1,o=r.data.type==="arcgis:auth:requestCredential",i=this.tokenExpires.getTime()>Date.now();if(n&&o){let s={};i?s={type:"arcgis:auth:credential",credential:this.toCredential()}:s={type:"arcgis:auth:error",error:{name:"tokenExpiredError",message:"Token was expired, and not returned to the child application"}},r.source.postMessage(s,r.origin)}}}getTokenForServer(e,r){let n=this.getServerRootUrl(e),o=this.federatedServers[n];return o&&o.expires&&o.expires.getTime()>Date.now()?Promise.resolve(o.token):this._pendingTokenRequests[n]?this._pendingTokenRequests[n]:(this._pendingTokenRequests[n]=this.fetchAuthorizedDomains().then(()=>a(`${n}/rest/info`,{credentials:this.getDomainCredentials(e)}).then(i=>{if(i.owningSystemUrl){if(se(i.owningSystemUrl,this.portal))return a(`${i.owningSystemUrl}/sharing/rest/info`,r);throw new _(`${e} is not federated with ${this.portal}.`,E.NOT_FEDERATED)}else{if(i.authInfo&&this.federatedServers[n]!==void 0)return Promise.resolve({authInfo:i.authInfo});throw new _(`${e} is not federated with any portal and is not explicitly trusted.`,E.NOT_FEDERATED)}}).then(i=>this.token&&this.tokenExpires.getTime()<Date.now()?this.server?this.refreshCredentials().then(()=>({token:this.token,expires:this.tokenExpires})):this.refreshCredentials().then(()=>this.generateTokenForServer(i.authInfo.tokenServicesUrl,n)):this.generateTokenForServer(i.authInfo.tokenServicesUrl,n)).then(i=>(this.federatedServers[n]=i,delete this._pendingTokenRequests[n],i.token))),this._pendingTokenRequests[n])}generateTokenForServer(e,r){return a(e,{params:{token:this.token,serverUrl:r,expiration:this.tokenDuration}}).then(n=>({token:n.token,expires:new Date(n.expires-1e3*60*5)})).catch(n=>{throw new _(n.message,E.GENERATE_TOKEN_FOR_SERVER_FAILED,n.response,n.url,n.options)})}getFreshToken(e){return this.token&&!this.tokenExpires?Promise.resolve(this.token):this.token&&this.tokenExpires&&this.tokenExpires.getTime()>Date.now()?Promise.resolve(this.token):(this._pendingTokenRequests[this.portal]||(this._pendingTokenRequests[this.portal]=this.refreshCredentials(e).then(()=>(this._pendingTokenRequests[this.portal]=null,this.token))),this._pendingTokenRequests[this.portal])}refreshWithUsernameAndPassword(e){let r={username:this.username,password:this.password,expiration:this.tokenDuration,client:"referer",referer:this.referer?this.referer:typeof window<"u"&&typeof window.document<"u"&&window.location&&window.location.origin?window.location.origin:J};return(this.server?a(`${this.getServerRootUrl(this.server)}/rest/info`).then(n=>a(n.authInfo.tokenServicesUrl,Object.assign({params:r},e))):a(`${this.portal}/generateToken`,Object.assign({params:r},e))).then(n=>(this.updateToken(n.token,new Date(n.expires)),this)).catch(n=>{throw new _(n.message,E.TOKEN_REFRESH_FAILED,n.response,n.url,n.options)})}refreshWithRefreshToken(e){if(this.refreshToken&&this.refreshTokenExpires&&this.refreshTokenExpires.getTime()-864e5<Date.now())return this.exchangeRefreshToken(e);let n=Object.assign({params:{client_id:this.clientId,refresh_token:this.refreshToken,grant_type:"refresh_token"}},e);return j(`${this.portal}/oauth2/token`,n).then(o=>this.updateToken(o.token,o.expires)).catch(o=>{throw new _(o.message,E.TOKEN_REFRESH_FAILED,o.response,o.url,o.options)})}updateToken(e,r){return this._token=e,this._tokenExpires=r,this}exchangeRefreshToken(e){let r=Object.assign({params:{client_id:this.clientId,refresh_token:this.refreshToken,redirect_uri:this.redirectUri,grant_type:"exchange_refresh_token"}},e);return j(`${this.portal}/oauth2/token`,r).then(n=>(this._token=n.token,this._tokenExpires=n.expires,this._refreshToken=n.refreshToken,this._refreshTokenExpires=n.refreshTokenExpires,this)).catch(n=>{throw new _(n.message,E.REFRESH_TOKEN_EXCHANGE_FAILED,n.response,n.url,n.options)})}fetchAuthorizedDomains(){return this.server||!this.portal?Promise.resolve(this):this.getPortal().then(e=>(e.authorizedCrossOriginDomains&&e.authorizedCrossOriginDomains.length&&(this.trustedDomains=e.authorizedCrossOriginDomains.filter(r=>!r.startsWith("http://")).map(r=>r.startsWith("https://")?r:`https://${r}`)),this))}};function v(t){return console.log("DEPRECATED:, 'UserSession' is deprecated. Use 'ArcGISIdentityManager' instead."),new I(t)}v.beginOAuth2=function(...t){return console.warn("DEPRECATED:, 'UserSession.beginOAuth2' is deprecated. Use 'ArcGISIdentityManager.beginOAuth2' instead."),I.beginOAuth2(...t)};v.completeOAuth2=function(...t){return console.warn("DEPRECATED:, 'UserSession.completeOAuth2()' is deprecated. Use 'ArcGISIdentityManager.completeOAuth2()' instead."),t.length<=1&&console.warn("WARNING:, 'UserSession.completeOAuth2()' is now async and returns a promise the resolves to an instance of `ArcGISIdentityManager`."),I.completeOAuth2(...t)};v.fromParent=function(...t){return console.warn("DEPRECATED:, 'UserSession.fromParent' is deprecated. Use 'ArcGISIdentityManager.fromParent' instead."),I.fromParent(...t)};v.authorize=function(...t){return console.warn("DEPRECATED:, 'UserSession.authorize' is deprecated. Use 'ArcGISIdentityManager.authorize' instead."),I.authorize(...t)};v.exchangeAuthorizationCode=function(...t){return console.warn("DEPRECATED:, 'UserSession.exchangeAuthorizationCode' is deprecated. Use 'ArcGISIdentityManager.exchangeAuthorizationCode' instead."),I.exchangeAuthorizationCode(...t)};v.fromCredential=function(...t){return console.log("DEPRECATED:, 'UserSession.fromCredential' is deprecated. Use 'ArcGISIdentityManager.fromCredential' instead."),console.warn("WARNING:, 'UserSession.fromCredential' now requires a `ServerInfo` object from the JS API as a second parameter."),I.fromCredential(...t)};v.deserialize=function(...t){return console.log("DEPRECATED:, 'UserSession.deserialize' is deprecated. Use 'ArcGISIdentityManager.deserialize' instead."),I.deserialize(...t)};var B;(function(t){t.Success="Succeeded",t.Failed="Failed",t.Waiting="Waiting",t.Cancelled="Cancelled",t.Cancelling="Cancelling",t.New="New",t.Executing="Executing",t.Submitted="Submitted",t.Failure="Failure",t.TimedOut="TimedOut",t.Error="Error",t.Status="Etatus",t.Unknown="Unknown"})(B||(B={}));function l(t={}){return t.portal?g(t.portal):t.authentication&&typeof t.authentication!="string"?t.authentication.portal:"https://www.arcgis.com/sharing/rest"}function me(t,e){let r=he(t,e),n=Object.assign({httpMethod:"GET"},e);return a(r,n)}var he=(t,e)=>`${typeof e=="string"?e:l(e)}/content/items/${t}`;function en(t,e){let r=`${he(t,e)}/data`,n=Object.assign({httpMethod:"GET",params:{}},e);return n.file&&(n.params.f=null),a(r,n).catch(o=>{if(!RegExp(/The string did not match the expected pattern|(Unexpected end of (JSON input|data at line 1 column 1))/i).test(o.message))throw o})}function on(t,e){let r=t||"self",n=`${l(e)}/portals/${r}/settings`,o=Object.assign({httpMethod:"GET"},e);return a(n,o)}var ra=async t=>await Promise.all(t.map(Ie)),Ie=async t=>{let e=structuredClone(t);try{let r=await me(t.id);return console.debug("Enriching source:",t.id,r),e.thumbnail=r.thumbnail,e.url=r.url,e.type=r.type,e}catch{console.error("Could not enrich:",t)}return e},na=t=>{if(!t)return[0,0];let e=t[0][0],r=t[0][1],n=t[1][0],o=(t[1][1]+r)/2;return[(n+e)/2,o]},oa=t=>{if(!t)return 5;let e=t[0][0],r=t[0][1],n=t[1][0],o=t[1][1],i=Math.abs(n-e),s=Math.abs(o-r),c=Math.log2(360/i),m=Math.log2(180/s);return Math.floor(Math.min(c,m))+2};function ia(t){return!!t&&typeof t=="object"&&"kind"in t&&t.kind==="FinderResponse"}export{me as a,en as b,on as c,ra as d,na as e,oa as f,ia as g};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
+
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
+
v0.0.9 */
|
|
4
|
+
import"./4A7FWUZG.js";import{a as k,b as E,c as R,e as U,f as C}from"./YIHEVBQL.js";import{a as A,b as u}from"./4RA6ROL7.js";import{a as S,b as d,d as v,f as x,k as $,p as T}from"./ZVSPHTOL.js";export default $arcgis.t(([V,q])=>{async function H(i){let{skillId:t,message:s,context:a,token:e,conversationId:n,apiUrl:c="https://api.example.com",pauseMs:_=1e3,retries:L=3}=i,g={Authorization:`Bearer ${e}`,Accept:"application/json","Content-Type":"application/json"},b=`${c}/skills/${t}/chat`,f={message:s,context:a};n&&(f.conversationId=n);try{let r=await fetch(b,{method:"POST",headers:g,body:JSON.stringify(f)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let o=await r.json(),P=n??o.conversationId,z=o.inquiryId,y=o.hasMore||o.message==null,w=o.sequenceNumber,h=[];o.message&&h.push(o);let I=0;for(;y&&I<L;){await new Promise(M=>setTimeout(M,_));let p=await fetch(b,{method:"POST",headers:g,body:JSON.stringify({conversationId:P,inquiryId:z,ackSequenceNumber:w})});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);let l=await p.json();l.message&&h.push(l),y=l.hasMore,l.message!=null&&(w+=1),I++}return h}catch(r){return console.error("Error during request:",r),[]}}async function j({message:i,context:t,token:s,conversationId:a,apiUrl:e="https://hub.arcgis.com/api/assistants/v1",pauseMs:n=1e3,retries:c=50}){return await H({skillId:"finder",message:i,context:t,token:s,conversationId:a??void 0,apiUrl:e,pauseMs:n,retries:c})}var F=S`@layer{arcgis-hub-ai-assistant{arcgis-feature-table{height:200px}}}`,D={language:"en",defaultSuggestions:["What can I do with this assistant?"],personality:"You are writing for a government websites readable by 8th graders."};async function O({portal:i,authentication:t}){try{let s=await R(void 0,{portal:i,authentication:t});return s.aiAssistantsEnabled===void 0||s.aiAssistantsEnabled&&!s.blockBetaApps?!0:(console.warn("AI Assistants are not enabled for this organization."),!1)}catch(s){return console.error("Error fetching organization assistant settings:",s),!1}}async function G(i,t,s){try{let[a,e]=await Promise.all([k(i,{authentication:t,portal:s}),E(i,{authentication:t,portal:s})]);return{...D,title:a.title,description:e.assistant?.description,extent:a.extent,personality:e.assistant?.personality,location:e.assistant?.location??"",defaultSuggestions:e.assistant?.examplePrompts??D.defaultSuggestions,context:"",hub:"",allowChat:!1,showHeader:!1,entityId:"",tools:[]}}catch(a){throw console.error("Error fetching configuration:",a),a}}var m=class extends ${constructor(){super(...arguments),this._featureTable=A(),this.handleArcGISDataClick=t=>{let s=t.detail.data.id,a=new q({id:s});V.fromPortalItem({portalItem:a}).then(e=>{this._mapRef?.map?.add(e),this._featureTable.value&&(this._featureTable.value.layer=e),this.mapLayers.push(s),this.arcgisAddLayer.emit(),this.mapVisible=!0}).catch(e=>{console.log("could not add layer:",e)})},this.handleArcGISLocationClick=t=>{let s=t.detail;s.longitude&&s.latitude&&s.zoom&&(this.mapVisible=!0,this._mapRef?.view.goTo({center:[s.longitude,s.latitude],zoom:s.zoom}))},this.assistantsEnabled=!1,this.mapEnabled=!1,this.mapVisible=!1,this.itemId=null,this.portalUrl="https://www.arcgis.com",this.apiUrl="/api/assistants/v1",this.botTitle="Hub AI Assistant",this.extent=[[-77.119,38.791],[-76.909,38.995]],this.mapLayers=[],this.mapShowTable=!1,this.mapBasemap="gray-vector",this.location="Washington, DC",this.hub="opendata.dc.gov",this.entityId=null,this.context=null,this.language=void 0,this.botDescription="Hub AI Assistant helps you find and use open data in your community.",this.defaultSuggestions=[],this.authentication=void 0,this.arcgisAddLayer=v()}static{this.properties={assistantsEnabled:16,_mapRef:16,mapEnabled:5,mapVisible:5,itemId:1,portalUrl:1,apiUrl:1,botTitle:1,extent:0,mapLayers:0,mapShowTable:5,mapBasemap:1,location:1,hub:1,entityId:1,context:1,language:1,botDescription:1,defaultSuggestions:0,authentication:0}}static{this.shadowRootOptions=x}static{this.styles=F}async load(){if(this.assistantsEnabled=await O({portal:`${this.portalUrl}/sharing/rest`,authentication:this.authentication}),this.itemId){let t=await G(this.itemId,this.authentication,`${this.portalUrl}/sharing/rest`);this.botTitle=t.title,this.botDescription=t.description?t.description:"",this.hub=t.hub,this.location=t.location,this.extent=t.extent,this.defaultSuggestions=t.defaultSuggestions}}async handleFinderResponse(t,s){let a=await j({message:t,conversationId:s,context:{kind:"FinderRequest",item:this.itemId??void 0},token:this.authentication?.token??"",apiUrl:this.apiUrl});if(a.length===0)throw new Error("Finder response is empty or invalid");return a}_setMapRef(t){this._mapRef=t}render(){return d`<link rel=stylesheet href=https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/light/main.css><arcgis-chat-shell .aboutContent=${this.botDescription} .mapEnabled=${this.mapEnabled} .mapVisible=${this.mapEnabled&&this.mapVisible} @arcgisUpdateMapVisibility=${t=>{this.mapVisible=t.detail}}><arcgis-chat-ui .botDescription=${this.botDescription} .botTitle=${this.botTitle} .defaultSuggestions=${this.defaultSuggestions} slot=leftPanel .getFinderResponse=${this.handleFinderResponse.bind(this)} @arcgisAddDataClick=${this.handleArcGISDataClick} @arcgisLocationClick=${this.handleArcGISLocationClick}></arcgis-chat-ui><arcgis-map slot=map .center=${U(this.extent)} .zoom=${C(this.extent)} .basemap=${this.mapBasemap} ${u(this._setMapRef)}><arcgis-zoom position=top-left></arcgis-zoom><arcgis-expand position=top-right><arcgis-layer-list></arcgis-layer-list></arcgis-expand><arcgis-search position=bottom-trailing></arcgis-search></arcgis-map>${this.mapShowTable&&d`<arcgis-feature-table .referenceElement=${this._mapRef} slot=featureTable ${u(this._featureTable)}></arcgis-feature-table>`||""}</arcgis-chat-shell>`}};T("arcgis-hub-ai-assistant",m);return m},"layers/Layer","portal/PortalItem")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
3
|
+
v0.0.9 */
|
|
4
4
|
var F=globalThis,K=F.ShadowRoot&&(F.ShadyCSS===void 0||F.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,lt=Symbol(),Tt=new WeakMap,M=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==lt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o,e=this.t;if(K&&t===void 0){let s=e!==void 0&&e.length===1;s&&(t=Tt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&Tt.set(e,t))}return t}toString(){return this.cssText}},Lt=o=>new M(typeof o=="string"?o:o+"",void 0,lt),ht=(o,...t)=>{let e=o.length===1?o[0]:t.reduce((s,n,r)=>s+(i=>{if(i._$cssResult$===!0)return i.cssText;if(typeof i=="number")return i;throw Error("Value passed to 'css' function must be a 'css' function result: "+i+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+o[r+1],o[0]);return new M(e,o,lt)},Pt=(o,t)=>{if(K)o.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(let e of t){let s=document.createElement("style"),n=F.litNonce;n!==void 0&&s.setAttribute("nonce",n),s.textContent=e.cssText,o.appendChild(s)}},dt=K?o=>o:o=>o instanceof CSSStyleSheet?(t=>{let e="";for(let s of t.cssRules)e+=s.cssText;return Lt(e)})(o):o;var pt=globalThis,J=pt.trustedTypes,Nt=J?J.createPolicy("lit-html",{createHTML:o=>o}):void 0,ft="$lit$",E=`lit$${Math.random().toFixed(9).slice(2)}$`,mt="?"+E,ue=`<${mt}>`,O=document,j=()=>O.createComment(""),z=o=>o===null||typeof o!="object"&&typeof o!="function",yt=Array.isArray,It=o=>yt(o)||typeof o?.[Symbol.iterator]=="function",ut=`[
|
|
5
5
|
\f\r]`,I=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Rt=/-->/g,kt=/>/g,w=RegExp(`>|${ut}(?:([^\\s"'>=/]+)(${ut}*=${ut}*(?:[^
|
|
6
6
|
\f\r"'\`<>=]|("|')|))|$)`,"g"),Dt=/'/g,Ut=/"/g,jt=/^(?:script|style|textarea|title)$/i,gt=o=>(t,...e)=>({_$litType$:o,strings:t,values:e}),ts=gt(1),es=gt(2),ss=gt(3),f=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),Mt=new WeakMap,x=O.createTreeWalker(O,129);function zt(o,t){if(!yt(o)||!o.hasOwnProperty("raw"))throw Error("invalid template strings array");return Nt!==void 0?Nt.createHTML(t):t}var Vt=(o,t)=>{let e=o.length-1,s=[],n,r=t===2?"<svg>":t===3?"<math>":"",i=I;for(let c=0;c<e;c++){let a=o[c],l,p,h=-1,m=0;for(;m<a.length&&(i.lastIndex=m,p=i.exec(a),p!==null);)m=i.lastIndex,i===I?p[1]==="!--"?i=Rt:p[1]!==void 0?i=kt:p[2]!==void 0?(jt.test(p[2])&&(n=RegExp("</"+p[2],"g")),i=w):p[3]!==void 0&&(i=w):i===w?p[0]===">"?(i=n??I,h=-1):p[1]===void 0?h=-2:(h=i.lastIndex-p[2].length,l=p[1],i=p[3]===void 0?w:p[3]==='"'?Ut:Dt):i===Ut||i===Dt?i=w:i===Rt||i===kt?i=I:(i=w,n=void 0);let y=i===w&&o[c+1].startsWith("/>")?" ":"";r+=i===I?a+ue:h>=0?(s.push(l),a.slice(0,h)+ft+a.slice(h)+E+y):a+E+(h===-2?c:y)}return[zt(o,r+(o[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]},V=class o{constructor({strings:t,_$litType$:e},s){let n;this.parts=[];let r=0,i=0,c=t.length-1,a=this.parts,[l,p]=Vt(t,e);if(this.el=o.createElement(l,s),x.currentNode=this.el.content,e===2||e===3){let h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(n=x.nextNode())!==null&&a.length<c;){if(n.nodeType===1){if(n.hasAttributes())for(let h of n.getAttributeNames())if(h.endsWith(ft)){let m=p[i++],y=n.getAttribute(h).split(E),g=/([.?@])?(.*)/.exec(m);a.push({type:1,index:r,name:g[2],strings:y,ctor:g[1]==="."?Z:g[1]==="?"?Q:g[1]==="@"?X:T}),n.removeAttribute(h)}else h.startsWith(E)&&(a.push({type:6,index:r}),n.removeAttribute(h));if(jt.test(n.tagName)){let h=n.textContent.split(E),m=h.length-1;if(m>0){n.textContent=J?J.emptyScript:"";for(let y=0;y<m;y++)n.append(h[y],j()),x.nextNode(),a.push({type:2,index:++r});n.append(h[m],j())}}}else if(n.nodeType===8)if(n.data===mt)a.push({type:2,index:r});else{let h=-1;for(;(h=n.data.indexOf(E,h+1))!==-1;)a.push({type:7,index:r}),h+=E.length-1}r++}}static createElement(t,e){let s=O.createElement("template");return s.innerHTML=t,s}};function S(o,t,e=o,s){if(t===f)return t;let n=s!==void 0?e._$Co?.[s]:e._$Cl,r=z(t)?void 0:t._$litDirective$;return n?.constructor!==r&&(n?._$AO?.(!1),r===void 0?n=void 0:(n=new r(o),n._$AT(o,e,s)),s!==void 0?(e._$Co??=[])[s]=n:e._$Cl=n),n!==void 0&&(t=S(o,n._$AS(o,t.values),n,s)),t}var Y=class{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){let{el:{content:e},parts:s}=this._$AD,n=(t?.creationScope??O).importNode(e,!0);x.currentNode=n;let r=x.nextNode(),i=0,c=0,a=s[0];for(;a!==void 0;){if(i===a.index){let l;a.type===2?l=new N(r,r.nextSibling,this,t):a.type===1?l=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(l=new tt(r,this,t)),this._$AV.push(l),a=s[++c]}i!==a?.index&&(r=x.nextNode(),i++)}return x.currentNode=O,n}p(t){let e=0;for(let s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}},N=class o{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,e,s,n){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=n,this._$Cv=n?.isConnected??!0}get parentNode(){let t=this._$AA.parentNode,e=this._$AM;return e!==void 0&&t?.nodeType===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=S(this,t,e),z(t)?t===d||t==null||t===""?(this._$AH!==d&&this._$AR(),this._$AH=d):t!==this._$AH&&t!==f&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):It(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==d&&z(this._$AH)?this._$AA.nextSibling.data=t:this.T(O.createTextNode(t)),this._$AH=t}$(t){let{values:e,_$litType$:s}=t,n=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=V.createElement(zt(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===n)this._$AH.p(e);else{let r=new Y(n,this),i=r.u(this.options);r.p(e),this.T(i),this._$AH=r}}_$AC(t){let e=Mt.get(t.strings);return e===void 0&&Mt.set(t.strings,e=new V(t)),e}k(t){yt(this._$AH)||(this._$AH=[],this._$AR());let e=this._$AH,s,n=0;for(let r of t)n===e.length?e.push(s=new o(this.O(j()),this.O(j()),this,this.options)):s=e[n],s._$AI(r),n++;n<e.length&&(this._$AR(s&&s._$AB.nextSibling,n),e.length=n)}_$AR(t=this._$AA.nextSibling,e){for(this._$AP?.(!1,!0,e);t&&t!==this._$AB;){let s=t.nextSibling;t.remove(),t=s}}setConnected(t){this._$AM===void 0&&(this._$Cv=t,this._$AP?.(t))}},T=class{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,n,r){this.type=1,this._$AH=d,this._$AN=void 0,this.element=t,this.name=e,this._$AM=n,this.options=r,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=d}_$AI(t,e=this,s,n){let r=this.strings,i=!1;if(r===void 0)t=S(this,t,e,0),i=!z(t)||t!==this._$AH&&t!==f,i&&(this._$AH=t);else{let c=t,a,l;for(t=r[0],a=0;a<r.length-1;a++)l=S(this,c[s+a],e,a),l===f&&(l=this._$AH[a]),i||=!z(l)||l!==this._$AH[a],l===d?t=d:t!==d&&(t+=(l??"")+r[a+1]),this._$AH[a]=l}i&&!n&&this.j(t)}j(t){t===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}},Z=class extends T{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===d?void 0:t}},Q=class extends T{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==d)}},X=class extends T{constructor(t,e,s,n,r){super(t,e,s,n,r),this.type=5}_$AI(t,e=this){if((t=S(this,t,e,0)??d)===f)return;let s=this._$AH,n=t===d&&s!==d||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,r=t!==d&&(s===d||n);n&&this.element.removeEventListener(this.name,this,s),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t)}},tt=class{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){S(this,t)}},Ht={M:ft,P:E,A:mt,C:1,L:Vt,R:Y,D:It,V:S,I:N,H:T,N:Q,U:X,B:Z,F:tt},pe=pt.litHtmlPolyfillSupport;pe?.(V,N),(pt.litHtmlVersions??=[]).push("3.3.0");var vt=(o,t,e)=>{let s=e?.renderBefore??t,n=s._$litPart$;if(n===void 0){let r=e?.renderBefore??null;s._$litPart$=n=new N(t.insertBefore(j(),r),r,void 0,e??{})}return n._$AI(o),n};var _=class{resolve(t){}reject(t){}constructor(){this.promise=new Promise((t,e)=>{this.resolve=t,this.reject=e})}};function u(o,t,...e){try{return o?.call(t,...e)}catch(s){console.error(s,o)}}async function H(o,t,...e){try{return await o?.call(t,...e)}catch(s){console.error(s,o)}}var et=o=>o.replace(fe,(t,e)=>`${e===0?"":"-"}${t.toLowerCase()}`),fe=/[A-Z]+(?![a-z])|[A-Z]/gu;function qt(o,t){let e=t>me?ye:t/ge,s=0,n=setInterval(()=>{s+=e,s>=t&&(clearInterval(n),o())},e);return n}var me=4e3,ye=2e3,ge=4;var{is:ve,defineProperty:_e,getOwnPropertyDescriptor:be,getOwnPropertyNames:Ee,getOwnPropertySymbols:Ce,getPrototypeOf:$e}=Object,ot=globalThis,Bt=ot.trustedTypes,Ae=Bt?Bt.emptyScript:"",we=ot.reactiveElementPolyfillSupport,q=(o,t)=>o,st={toAttribute(o,t){switch(t){case Boolean:o=o?Ae:null;break;case Object:case Array:o=o==null?o:JSON.stringify(o)}return o},fromAttribute(o,t){let e=o;switch(t){case Boolean:e=o!==null;break;case Number:e=o===null?null:Number(o);break;case Object:case Array:try{e=JSON.parse(o)}catch{e=null}}return e}},_t=(o,t)=>!ve(o,t),Wt={attribute:!0,type:String,converter:st,reflect:!1,useDefault:!1,hasChanged:_t};Symbol.metadata??=Symbol("metadata"),ot.litPropertyMetadata??=new WeakMap;var C=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Wt){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){let s=Symbol(),n=this.getPropertyDescriptor(t,s,e);n!==void 0&&_e(this.prototype,t,n)}}static getPropertyDescriptor(t,e,s){let{get:n,set:r}=be(this.prototype,t)??{get(){return this[e]},set(i){this[e]=i}};return{get:n,set(i){let c=n?.call(this);r?.call(this,i),this.requestUpdate(t,c,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Wt}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;let t=$e(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){let e=this.properties,s=[...Ee(e),...Ce(e)];for(let n of s)this.createProperty(n,e[n])}let t=this[Symbol.metadata];if(t!==null){let e=litPropertyMetadata.get(t);if(e!==void 0)for(let[s,n]of e)this.elementProperties.set(s,n)}this._$Eh=new Map;for(let[e,s]of this.elementProperties){let n=this._$Eu(e,s);n!==void 0&&this._$Eh.set(n,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){let e=[];if(Array.isArray(t)){let s=new Set(t.flat(1/0).reverse());for(let n of s)e.unshift(dt(n))}else t!==void 0&&e.push(dt(t));return e}static _$Eu(t,e){let s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(t=>this.enableUpdating=t),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(t=>t(this))}addController(t){(this._$EO??=new Set).add(t),this.renderRoot!==void 0&&this.isConnected&&t.hostConnected?.()}removeController(t){this._$EO?.delete(t)}_$E_(){let t=new Map,e=this.constructor.elementProperties;for(let s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){let t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Pt(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(t=>t.hostConnected?.())}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach(t=>t.hostDisconnected?.())}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){let s=this.constructor.elementProperties.get(t),n=this.constructor._$Eu(t,s);if(n!==void 0&&s.reflect===!0){let r=(s.converter?.toAttribute!==void 0?s.converter:st).toAttribute(e,s.type);this._$Em=t,r==null?this.removeAttribute(n):this.setAttribute(n,r),this._$Em=null}}_$AK(t,e){let s=this.constructor,n=s._$Eh.get(t);if(n!==void 0&&this._$Em!==n){let r=s.getPropertyOptions(n),i=typeof r.converter=="function"?{fromAttribute:r.converter}:r.converter?.fromAttribute!==void 0?r.converter:st;this._$Em=n,this[n]=i.fromAttribute(e,r.type)??this._$Ej?.get(n)??null,this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){let n=this.constructor,r=this[t];if(s??=n.getPropertyOptions(t),!((s.hasChanged??_t)(r,e)||s.useDefault&&s.reflect&&r===this._$Ej?.get(t)&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:n,wrapped:r},i){s&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,i??e??this[t]),r!==!0||i!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),n===!0&&this._$Em!==t&&(this._$Eq??=new Set).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}let t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(let[n,r]of this._$Ep)this[n]=r;this._$Ep=void 0}let s=this.constructor.elementProperties;if(s.size>0)for(let[n,r]of s){let{wrapped:i}=r,c=this[n];i!==!0||this._$AL.has(n)||c===void 0||this.C(n,void 0,r,c)}}let t=!1,e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),this._$EO?.forEach(s=>s.hostUpdate?.()),this.update(e)):this._$EM()}catch(s){throw t=!1,this._$EM(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){this._$EO?.forEach(e=>e.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&=this._$Eq.forEach(e=>this._$ET(e,this[e])),this._$EM()}updated(t){}firstUpdated(t){}};C.elementStyles=[],C.shadowRootOptions={mode:"open"},C[q("elementProperties")]=new Map,C[q("finalized")]=new Map,we?.({ReactiveElement:C}),(ot.reactiveElementVersions??=[]).push("2.1.0");var bt=globalThis,b=class extends C{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){let t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){let e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=vt(e,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return f}};b._$litElement$=!0,b.finalized=!0,bt.litElementHydrateSupport?.({LitElement:b});var xe=bt.litElementPolyfillSupport;xe?.({LitElement:b});(bt.litElementVersions??=[]).push("4.2.0");var nt=Symbol.for("controller");var Oe=o=>typeof o=="object"&&o!==null&&(nt in o||"hostConnected"in o||"hostDisconnected"in o||"hostUpdate"in o||"hostUpdated"in o);var B;function R(o){B!==o&&(B=o,queueMicrotask(()=>{B===o&&(B=void 0)}))}function W(o){return B}var L=[];function Se(o){if(o===void 0){L=[];return}let t=L.indexOf(o);L=t===-1?[...L,o]:L.slice(0,t+1),queueMicrotask(()=>{L=[]})}function Te(){return L}var Gt;function Le(){let o=Gt;return Gt=void 0,o}var Pe=async(o,t)=>{let e=Ct(o);if(e===void 0)return o;if(await e.ready,typeof t=="function"){let s=e.watchExports(n=>t(n,s))}return e.exports},Ne=async o=>{let t=Ct(o);return await t.ready,t},Ct=o=>{let e=W().manager._resolveExports(o);if(e!==void 0)return e;if(Oe(o))return o;let s=Le();if(s!==void 0)return s},Jt=!1,Yt=!1;function Re(o,t,e){let s=Object.keys(o),n=s.length;k===void 0&&queueMicrotask(rt),k??=new Map;let r=k.get(o);return r===void 0&&(r={callbacks:[],keyCount:n},k.set(o,r)),r.keyCount!==n&&(r.callbacks.forEach(i=>i(s)),r.callbacks=[],r.keyCount=n),r.callbacks.push(i=>{let c=l=>u(t,null,l),a=i[n];a===void 0?c(void 0):o[a]===e?c(a):c(void 0)}),e}var k;function rt(){k?.forEach(({callbacks:o},t)=>{let e=Object.keys(t);o.forEach(s=>s(e))}),k=void 0}function ke(o,t,e){let s=o.manager;return s._trackedValue!==d&&s._trackedValue!==e&&s._firePropTrackers(void 0,void 0),s._keyTrackers.length===0&&queueMicrotask(()=>s._firePropTrackers(void 0,void 0)),s._trackedValue=e,s._keyTrackers.push((n,r)=>u(t,void 0,e===r?n:void 0)),e}function De(o=[W(),...Te()],t,e){let s=Array.isArray(o)?o:[o],n=s.length+1,r=i=>{n-=1,i!==void 0&&(n=Math.min(n,0)),n===0&&t(i)};s.forEach(i=>Re(i,c=>r(c===void 0?void 0:{key:c,host:i,isReactive:!1}),e));for(let i of s)if("manager"in i&&typeof i.manager=="object"&&i.manager.component===i){ke(i,c=>r(c===void 0?void 0:{key:c,host:i,isReactive:!0}),e);break}return e}var Ue=(o="",t={},e=W())=>{let s={emit:n=>{o===""&&rt();let r=new CustomEvent(o,{detail:n,cancelable:!0,bubbles:!0,composed:!0,...t});return e.el.dispatchEvent(r),r}};return o===""&&De(void 0,n=>{o=n.key},s),s},Me=Ue.bind(null,""),Zt;Zt=nt;var Et=class{constructor(t){this._callbacks={hostConnected:[],hostDisconnected:[],hostLoad:[],hostLoaded:[],hostUpdate:[],hostUpdated:[],hostDestroy:[],hostLifecycle:[]},this._ready=new _,this._lifecycleCleanups=[],this.connectedCalled=!1,this._loadCalled=!1,this.loadedCalled=!1,this[Zt]=!0,this.ready=this._ready.promise,this._exports=Kt(this),this._exportWatchers=new Set;let e=t??W(new.target.name);this.component=e,this.component.addController(this),this.component.manager===void 0||(Se(this),queueMicrotask(()=>this.catchUpLifecycle()))}catchUpLifecycle(){let{manager:t}=this.component;t.connectedCalled&&!this.connectedCalled&&this.triggerConnected(),t._loadCalled&&this.triggerLoad().then(()=>{t.loadedCalled&&this.triggerLoaded()}).catch(console.error)}get exports(){return this._exports}set exports(t){let e=this._exports;e!==t&&(this._exports=t,this._exportWatchers.forEach(u),this.connectedCalled&&this.assignedProperty!==!1&&this.component.requestUpdate(this.assignedProperty,e)),this._ready.resolve(t)}setProvisionalExports(t,e=!0){this._exports=e?Kt(t):t,this._exportWatchers.forEach(u)}watchExports(t){let e=()=>t(this._exports);return this._exportWatchers.add(e),()=>void this._exportWatchers.delete(e)}get use(){return R(this.component),Pe}get useRef(){return R(this.component),Ne}get useRefSync(){return R(this.component),Ct}controllerRemoved(){this.component.el.isConnected&&this.triggerDisconnected(),this.triggerDestroy()}onConnected(t){this._callbacks.hostConnected.push(t)}onDisconnected(t){this._callbacks.hostDisconnected.push(t)}onLoad(t){this._callbacks.hostLoad.push(t)}onLoaded(t){this._callbacks.hostLoaded.push(t)}onUpdate(t){this._callbacks.hostUpdate.push(t)}onUpdated(t){this._callbacks.hostUpdated.push(t)}onDestroy(t){this._callbacks.hostDestroy.push(t)}onLifecycle(t){this._callbacks.hostLifecycle.push(t),this.connectedCalled&&this.component.el.isConnected&&this._callLifecycle(t)}triggerConnected(){let t=this;t.hostConnected&&u(t.hostConnected,t),this._callbacks.hostConnected.forEach(u),this.triggerLifecycle(),this.connectedCalled=!0}triggerDisconnected(){let t=this;t.hostDisconnected&&u(t.hostDisconnected,t),this._callbacks.hostDisconnected.forEach(u),this._lifecycleCleanups.forEach(u),this._lifecycleCleanups=[]}async triggerLoad(){if(this._loadCalled)return;this._loadCalled=!0;let t=this;t.hostLoad&&await H(t.hostLoad,t),this._callbacks.hostLoad.length>0&&await Promise.allSettled(this._callbacks.hostLoad.map(H)),this._ready.resolve(this._exports)}triggerLoaded(){if(this.loadedCalled)return;let t=this;t.hostLoaded&&u(t.hostLoaded,t),this._callbacks.hostLoaded.forEach(u),this.loadedCalled=!0}triggerUpdate(t){let e=this;e.hostUpdate&&u(e.hostUpdate,e,t),this._callbacks.hostUpdate.forEach(Ft,t)}triggerUpdated(t){let e=this;e.hostUpdated&&u(e.hostUpdated,e,t),this._callbacks.hostUpdated.forEach(Ft,t)}triggerDestroy(){let t=this;t.hostDestroy&&u(t.hostDestroy,t),this._callbacks.hostDestroy.forEach(u)}triggerLifecycle(){let t=this;t.hostLifecycle&&this._callLifecycle(()=>t.hostLifecycle()),this._callbacks.hostLifecycle.forEach(this._callLifecycle,this)}_callLifecycle(t){R(this.component);let e=u(t);(Array.isArray(e)?e:[e]).forEach(n=>{typeof n=="function"?this._lifecycleCleanups.push(n):typeof n=="object"&&typeof n.remove=="function"&&this._lifecycleCleanups.push(n.remove)})}};function Ft(o){u(o,void 0,this)}var Qt=Et;function Kt(o){if(typeof o!="object"&&typeof o!="function"||o===null)return o;let t=new Proxy(o,{get(e,s,n){if(!((s==="exports"||s==="_exports")&&s in e&&e[s]===t)&&(s in e||s in Promise.prototype||typeof s=="symbol"))return typeof e=="function"?e[s]:Reflect.get(e,s,n)},set:(e,s,n,r)=>Reflect.set(e,s,n,r)});return t}var Xt=";",it=",",te=":",$=(o=>(o[o.ATTRIBUTE=1]="ATTRIBUTE",o[o.REFLECT=2]="REFLECT",o[o.BOOLEAN=4]="BOOLEAN",o[o.NUMBER=8]="NUMBER",o[o.STATE=16]="STATE",o[o.READ_ONLY=32]="READ_ONLY",o[o.NO_ACCESSOR=64]="NO_ACCESSOR",o))($||{});function At(o){let t=o;for(;t=t.parentNode??t.host;)if(t?.constructor?.lumina){let e=t;return e.manager?.loadedCalled||e._offspring.push(o),e._postLoad.promise}return!1}var Ie=(o,t)=>function(s,n){if(!globalThis.customElements)return;let i=(n??s??{}).resourcesUrl;i&&o.setAssetPath(i),Object.entries(t).forEach(je)};function je([o,[t,e=""]]){if(customElements.get(o))return;let[s,n,r]=e.split(Xt),i=s?s?.split(it).map(ee):void 0,c=i?.map(([l])=>l),a=class extends $t{static{this.observedAttributes=i?.map(([,l])=>l).filter(l=>l!=="")}static{this._properties=c}static{this._asyncMethods=n?n?.split(it):void 0}static{this._syncMethods=r?.split(it)}static{this._name=o}constructor(){!a._loadPromise&&(a._loadPromise=t(),a._initializePrototype()),super()}};customElements.define(o,a)}var at=Object.defineProperty;function ee(o){let t=o.split(te);return t.length===1?[t[0],et(t[0])]:t}var ze=globalThis.HTMLElement??ee,$t=class extends ze{constructor(){super(),this._store={},this._pendingAttributes=[],this._postLoad=new _,this._postLoaded=new _,this._offspring=[],this._saveInstanceProperties();let t=this.constructor;t._LitConstructor?this._initializeComponent({a:t._LitConstructor}):t._loadPromise.then(qe).then(this._initializeComponent.bind(this)).catch(e=>{this._postLoaded.reject(e),setTimeout(()=>{throw e})})}static{this.lumina=!0}static _initializePrototype(){this._properties?.forEach(this._bindProp,this),this._asyncMethods?.forEach(this._bindAsync,this),this._syncMethods?.forEach(this._bindSync,this)}static _bindProp(t){at(this.prototype,t,{configurable:!0,enumerable:!0,get(){return this._store[t]},set(e){this._store[t]=e}})}static _bindAsync(t){at(this.prototype,t,{async value(...e){return this._litElement||await this._postLoaded.promise,await this._litElement[t](...e)},configurable:!0})}static _bindSync(t){at(this.prototype,t,{value(...e){return this._litElement[t](...e)},configurable:!0})}get manager(){return this._litElement?.manager}_saveInstanceProperties(){let t=this.constructor,e=this;t._properties?.forEach(s=>{Object.hasOwn(this,s)&&(this._store[s]=e[s],delete e[s])})}attributeChangedCallback(t,e,s){this._litElement?.attributeChangedCallback(t,e,s),this._litElement||this._pendingAttributes.push(t)}connectedCallback(){this._litElement?this._litElement.connectedCallback?.():queueMicrotask(()=>{this._ancestorLoad=At(this)})}disconnectedCallback(){this._litElement?.disconnectedCallback?.()}async componentOnReady(){return await this._postLoaded.promise,this}_initializeComponent(t){let e=this.constructor,s=e._name,n=this._store,r=Object.values(t).find(h=>h.tagName===s),i=`${s}--lazy`,c=r;for(;c&&!Object.hasOwn(c,"lumina");)c=Object.getPrototypeOf(c);He(c),!e._LitConstructor&&(e._LitConstructor=r,customElements.define(i,r)),r.lazy=this;let l=document.createElement(i);r.lazy=void 0,this._litElement=l,this._store=l,this._pendingAttributes.forEach(h=>{let m=this.getAttribute(h);l.attributeChangedCallback(h,null,m)}),Object.entries(n).forEach(Ve,l);let p=this.isConnected;(p||this._ancestorLoad)&&(l.connectedCallback?.(),p||l.disconnectedCallback())}addController(){}requestUpdate(){this._litElement?.requestUpdate()}};function Ve([o,t]){this[o]=t}function He(o){let t=o.prototype,e=Element.prototype;Object.hasOwn(t,"isConnected")||(t.setAttribute=function(n,r){e.setAttribute.call(this.el,n,r)},t.removeAttribute=function(n){e.removeAttribute.call(this.el,n)},at(t,"isConnected",{get(){return Reflect.get(e,"isConnected",this.el)}}))}var qe=async o=>await(o.default?.then(t=>typeof t=="function"?{a:t}:t)??o),wt={};var v={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},P=o=>(...t)=>({_$litDirective$:o,values:t}),A=class{constructor(t){}get _$AU(){return this._$AM._$AU}_$AT(t,e,s){this._$Ct=t,this._$AM=e,this._$Ci=s}_$AS(t,e){return this.update(t,e)}update(t,e){return this.render(...e)}};var ne=P(class extends A{constructor(o){if(super(o),o.type!==v.ATTRIBUTE||o.name!=="class"||o.strings?.length>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(o){return" "+Object.keys(o).filter(t=>o[t]).join(" ")+" "}update(o,[t]){if(this.st===void 0){this.st=new Set,o.strings!==void 0&&(this.nt=new Set(o.strings.join(" ").split(/\s/).filter(s=>s!=="")));for(let s in t)t[s]&&!this.nt?.has(s)&&this.st.add(s);return this.render(t)}let e=o.element.classList;for(let s of this.st)s in t||(e.remove(s),this.st.delete(s));for(let s in t){let n=!!t[s];n===this.st.has(s)||this.nt?.has(s)||(n?(e.add(s),this.st.add(s)):(e.remove(s),this.st.delete(s)))}return f}});var re="important",We=" !"+re,ie=P(class extends A{constructor(o){if(super(o),o.type!==v.ATTRIBUTE||o.name!=="style"||o.strings?.length>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(o){return Object.keys(o).reduce((t,e)=>{let s=o[e];return s==null?t:t+`${e=e.includes("-")?e:e.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`},"")}update(o,[t]){let{style:e}=o.element;if(this.ft===void 0)return this.ft=new Set(Object.keys(t)),this.render(t);for(let s of this.ft)t[s]==null&&(this.ft.delete(s),s.includes("-")?e.removeProperty(s):e[s]=null);for(let s in t){let n=t[s];if(n!=null){this.ft.add(s);let r=typeof n=="string"&&n.endsWith(We);s.includes("-")||r?e.setProperty(s,r?n.slice(0,-11):n,r?re:""):e[s]=n}}return f}});var{I:_o}=Ht;var ae=o=>o.strings===void 0;var Ge={},ce=(o,t=Ge)=>o._$AH=t;var Fe=P(class extends A{constructor(o){if(super(o),o.type!==v.PROPERTY&&o.type!==v.ATTRIBUTE&&o.type!==v.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!ae(o))throw Error("`live` bindings can only contain a single expression")}render(o){return o}update(o,[t]){if(t===f||t===d)return t;let e=o.element,s=o.name;if(o.type===v.PROPERTY){if(t===e[s])return f}else if(o.type===v.BOOLEAN_ATTRIBUTE){if(!!t===e.hasAttribute(s))return f}else if(o.type===v.ATTRIBUTE&&e.getAttribute(s)===t+"")return f;return ce(o),t}});var Ot=class extends Qt{constructor(t){super(t),this.destroyed=!1,this._enforceReadonly=!1,this._trackedValue=d,this._keyTrackers=[],this._accessorGetter={},this._accessorSetter={},this._exportsStore=new WeakMap,this.exports=void 0,this.hasDestroy=St in t&&typeof t.destroy=="function",b.prototype.addController.call(t,{hostConnected:()=>{if(this.destroyed){let e=t.el.localName;throw t.el.remove(),new Error(`The ${e} component has already been destroyed. It cannot be used again. If you meant to disconnect and reconnect a component without automatic destroy, set the ${St} prop.`)}this._autoDestroyTimeout!==void 0&&clearTimeout(this._autoDestroyTimeout),rt();for(let e of t._controllers)"triggerConnected"in e?e.triggerConnected():u(e.hostConnected,e)},hostDisconnected:()=>{for(let e of t._controllers)"triggerDisconnected"in e?e.triggerDisconnected():u(e.hostDisconnected,e);this.hasDestroy&&!this.destroyed&&this._setAutoDestroyTimeout()},hostUpdate:()=>{for(let e of t._controllers)"triggerUpdate"in e?e.triggerUpdate(this._changes):u(e.hostUpdate,e,this._changes)},hostUpdated:()=>{for(let e of t._controllers)"triggerUpdated"in e?e.triggerUpdated(this._changes):u(e.hostUpdated,e,this._changes);this._changes=void 0}}),t.constructor.elementProperties.forEach((e,s)=>{e.noAccessor||(this._accessorGetter[s]=le,this._accessorSetter[s]=le,this._getSetProxy(s,e.readOnly))}),queueMicrotask(()=>{this._enforceReadonly=!0}),R(t)}async destroy(){if(!this.destroyed){if(this.component.el.isConnected){this.hasDestroy=!1;try{this.component.el.remove()}finally{this.hasDestroy=!0}}this._autoDestroyTimeout=void 0,this.destroyed=!0;for(let t of this.component._controllers)"triggerDestroy"in t?t.triggerDestroy():u(t.hostDestroy,t);this.component._controllers.clear()}}_setAutoDestroyTimeout(){if(this._autoDestroyTimeout!==void 0&&clearTimeout(this._autoDestroyTimeout),!this.component.el.isConnected&&!this.component.autoDestroyDisabled){let t=()=>void this.component.destroy();this._autoDestroyTimeout=qt(t,Je)}}_firePropTrackers(t,e){let s=this._keyTrackers;this._trackedValue=d,this._keyTrackers=[],s.forEach(n=>n(t,e))}_getSetProxy(t,e){let s=this.component.constructor.prototype,n;do n=Object.getOwnPropertyDescriptor(s,t);while(!n&&(s=Object.getPrototypeOf(s)));if(!n)return;let r=n.get,i=n.set,c=ct in r,a=ct in i;if(c&&a)return;let l=!c,p=!a,h=l?function(){let g=r.call(this);return Jt?g:this.manager._accessorGetter[t](g,t)}:r,m=p?function(g){let G=r.call(this),D=g??void 0,U=this.manager;if(D!==G){if(e&&!Yt&&(U._enforceReadonly||U.connectedCalled))throw new Error(`Cannot assign to read-only property "${t}" of ${this.el.localName}. Trying to assign "${String(D)}"`);D=U._accessorSetter[t](D,G,t)}i.call(this,D),U._keyTrackers.length>0&&U?._firePropTrackers(t,g)}:i;l&&(h[ct]=!0),p&&(m[ct]=!0),Object.defineProperty(s,t,{...n,get:h,set:m})}_markExports(t,e){(typeof e=="object"&&e!==null||typeof e=="function")&&this._exportsStore.set(e,t)}_resolveExports(t){if(typeof t=="object"&&t!==null||typeof t=="function")return this._exportsStore.get(t)}},Je=1e3,St="autoDestroyDisabled",le=o=>o,ct=Symbol(),Ye=()=>{},he=class o extends b{constructor(){super(),this.el=this.constructor.lazy??this,this._controllers=new Set,this.manager=new Ot(this),this._postLoad=this.constructor.lazy?._postLoad??new _,this._offspring=this.constructor.lazy?._offspring??[],this._postLoaded=this.constructor.lazy?._postLoaded??new _,this._enableUpdating=this.enableUpdating,this.enableUpdating=Ye;let t=o.prototype.shouldUpdate;this.shouldUpdate!==t&&(this._originalShouldUpdate=this.shouldUpdate,this.shouldUpdate=t),!1}static finalizeStyles(t){let e=super.finalizeStyles(t),s=this.shadowRootOptions===wt;return this.runtime?.commonStyles===void 0||s?e:[this.runtime.commonStyles,...e]}static createProperty(t,e){let s=typeof e=="number"?e:Array.isArray(e)?e[0]:0,n=Array.isArray(e)?e[1]:void 0;super.createProperty(t,{attribute:s&$.ATTRIBUTE&&typeof t=="string"?et(t):!1,reflect:!!(s&$.REFLECT),type:s&$.BOOLEAN?Boolean:s&$.NUMBER?Number:void 0,state:!!(s&$.STATE),readOnly:!!(s&$.READ_ONLY),noAccessor:!!(s&$.NO_ACCESSOR),...n})}static{this.lumina=!0}connectedCallback(){if(this.el.hasAttribute("defer-hydration"))return;let t=!this.manager.connectedCalled;super.connectedCallback(),t&&queueMicrotask(()=>this._load().catch(e=>{this._postLoaded.reject(e),setTimeout(()=>{throw e})}))}createRenderRoot(){let t=this.el.shadowRoot,e=this.constructor,s=e.shadowRootOptions,r=t??(s===wt?this.el:this.el.attachShadow(s));if(t)return b.prototype.createRenderRoot.call(this),t;if(this.isConnected){let i=r.getRootNode();i.adoptedStyleSheets=[...i.adoptedStyleSheets,...e.elementStyles.map(c=>"styleSheet"in c?c.styleSheet:c)]}return r}async _load(){let t=this.el._ancestorLoad??At(this.el);t&&await t;let e=[];for(let n of this._controllers)"triggerLoad"in n?e.push(n.triggerLoad()):e.push(H(n.hostLoad,n));await Promise.all(e),await this.load?.(),this.manager.hasDestroy&&this.manager.onUpdate(n=>n.has(St)&&this.manager._setAutoDestroyTimeout()),this._enableUpdating(!0),this.performUpdate(),this._postLoad.resolve(),await Promise.resolve();let s=this._offspring.filter(n=>!n.manager?.loadedCalled);s.length&&await Promise.allSettled(s.map(async n=>await n.componentOnReady())),this._offspring.length=0,this.el.setAttribute(this.constructor.runtime.hydratedAttribute,"");for(let n of this._controllers)"triggerLoaded"in n?n.triggerLoaded():u(n.hostLoaded,n);this.loaded?.(),this._postLoaded.resolve()}shouldUpdate(t){return this.manager._changes=t,this._originalShouldUpdate?.(t)??!0}listen(t,e,s){let n=e?.bind(this)??e;this.manager.onLifecycle(()=>(this.el.addEventListener(t,n,s),()=>this.el.removeEventListener(t,n,s)))}listenOn(t,e,s,n){let r=s?.bind(this)??s;this.manager.onLifecycle(()=>(t.addEventListener(e,r,n),()=>t.removeEventListener(e,r,n)))}async componentOnReady(){return await this._postLoaded.promise,this}addController(t){this._controllers.add(t),!(nt in t)&&this.renderRoot&&this.el.isConnected&&t.hostConnected?.()}removeController(t){this._controllers.delete(t),t.controllerRemoved?.()}};function de(o){let t,e=n=>{t=new URL(n,globalThis.location?.href||void 0).href},s={...o,getAssetPath(n){let r=new URL(n,t);return r.origin!==globalThis.location?.origin?r.href:r.pathname},setAssetPath:e,customElement(n,r){r.runtime=s,r.tagName=n,customElements.get(n)||customElements.define(n,r)}};return e(o.defaultAssetPath),s}var qo=o=>typeof o=="object"&&o!=null?ne(o):o,Bo=o=>typeof o=="object"&&o!=null?ie(o):o;var Wo=d;var Ze=ht`:host{font-family:ui-sans-serif,system-ui,sans-serif}`,Qe=de({defaultAssetPath:"https://js.arcgis.com/0.0/hub-web-components/",hydratedAttribute:"hydrated",commonStyles:Ze}),{customElement:Jo,getAssetPath:Yo,setAssetPath:Zo}=Qe;export{ht as a,ts as b,d as c,Me as d,Ie as e,wt as f,v as g,P as h,A as i,ae as j,he as k,qo as l,Bo as m,Wo as n,Qe as o,Jo as p};
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
2
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.
|
|
4
|
-
import{e,o as t}from"./
|
|
3
|
+
v0.0.9 */
|
|
4
|
+
import{e,o as t}from"./ZVSPHTOL.js";var a=e(t,{"arcgis-chat-shell":[()=>import("./LZNPMUYS.js"),"aboutContent,aboutVisible,chatComponent:,featureTable:,map:,mapEnabled,mapVisible"],"arcgis-chat-ui":[()=>import("./N6XAUVU3.js"),"botDescription,botTitle,conversationId,defaultSuggestions:,devFeatureMessage:,getFinderResponse:,inputText;;submitUserMessage"],"arcgis-hub-ai-assistant":[()=>import("./YZNI5NYE.js"),"apiUrl,authentication:,botDescription,botTitle,context,defaultSuggestions:,entityId,extent:,hub,itemId,language,location,mapBasemap,mapEnabled,mapLayers:,mapShowTable,mapVisible,portalUrl"]});var s=new CSSStyleSheet;s.replaceSync("@layer{:not([hydrated]):is(arcgis-chat-shell,arcgis-chat-ui,arcgis-hub-ai-assistant){visibility:hidden}:root{--acme-components-text-color: #111}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,s];a({resourcesUrl:import.meta.url});window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a)=>{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)})($arcgis)
|
|
@@ -3,7 +3,7 @@ import { safeStyleMap as l } from "@arcgis/lumina";
|
|
|
3
3
|
import { Marked as i } from "@ts-stack/markdown";
|
|
4
4
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
5
5
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
6
|
-
v0.0.
|
|
6
|
+
v0.0.9 */
|
|
7
7
|
const p = (t) => {
|
|
8
8
|
const e = /https?:\/\/[^\s]+[^. ]/g;
|
|
9
9
|
return t.replace(e, "<a href='$&' target='_new'>$&</a>");
|
package/dist/chunks/runtime.js
CHANGED
|
@@ -2,7 +2,7 @@ import { css as s } from "@lit/reactive-element/css-tag.js";
|
|
|
2
2
|
import { makeRuntime as t } from "@arcgis/lumina";
|
|
3
3
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
4
4
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
5
|
-
v0.0.
|
|
5
|
+
v0.0.9 */
|
|
6
6
|
const e = s`:host{font-family:ui-sans-serif,system-ui,sans-serif}`, o = t({ defaultAssetPath: "https://js.arcgis.com/0.0/hub-web-components/", hydratedAttribute: "hydrated", commonStyles: e }), { customElement: r, getAssetPath: n, setAssetPath: i } = o;
|
|
7
7
|
export {
|
|
8
8
|
r as c,
|
|
@@ -5,7 +5,7 @@ import { css as c } from "@lit/reactive-element/css-tag.js";
|
|
|
5
5
|
import { createRef as t, ref as e } from "lit/directives/ref.js";
|
|
6
6
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
7
7
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
8
|
-
v0.0.
|
|
8
|
+
v0.0.9 */
|
|
9
9
|
const h = c`:host{display:flex;height:100%;.innerContent{word-wrap:break-word;height:100%}.hidden{display:none}.aboutPanel{padding:10px}.map-panel-outer{height:100%;display:flex;flex-direction:column}::slotted([slot="map"]){flex-grow:1}}`;
|
|
10
10
|
class p extends o {
|
|
11
11
|
constructor() {
|
|
@@ -3,7 +3,7 @@ import "@arcgis/lumina";
|
|
|
3
3
|
import { C as m } from "../../../../chunks/chat-action.js";
|
|
4
4
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
5
5
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
6
|
-
v0.0.
|
|
6
|
+
v0.0.9 */
|
|
7
7
|
export {
|
|
8
8
|
m as ChatAction
|
|
9
9
|
};
|
|
@@ -4,7 +4,7 @@ import f from "@arcgis/core/portal/PortalItem.js";
|
|
|
4
4
|
import g from "@arcgis/core/layers/Layer.js";
|
|
5
5
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
6
6
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
7
|
-
v0.0.
|
|
7
|
+
v0.0.9 */
|
|
8
8
|
const C = ({ message: t, addDataClick: n, addLocationClick: s }) => {
|
|
9
9
|
function d(i) {
|
|
10
10
|
return r`<calcite-accordion-item heading=Reasoning description="Explanation of the AI Assistant process" icon-start=automation><ol>${i.map((o) => r`<li>Tool: ${o.name}${Object.keys(o.parameters).map((a) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { html as e } from "lit-html";
|
|
2
2
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
4
|
-
v0.0.
|
|
4
|
+
v0.0.9 */
|
|
5
5
|
const l = ({ showSkeletonLoader: s, currentLoadingMessage: d }) => s ? e`<div class="loader"><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="skeleton-loader"></div><div class="square-container"><div class="skeleton-loader square"></div><div class="skeleton-loader square"></div></div></div>` : e`<div class="status-message">${d}</div>`;
|
|
6
6
|
export {
|
|
7
7
|
l as ChatStatus
|
|
@@ -8,7 +8,7 @@ import { ChatStatus as x } from "./components/chat-status/customElement.js";
|
|
|
8
8
|
import { isFinderResponseContext as b, enrichSources as y } from "../arcgis-hub-ai-assistant/util/customElement.js";
|
|
9
9
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
10
10
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
11
|
-
v0.0.
|
|
11
|
+
v0.0.9 */
|
|
12
12
|
const v = f`.actions{margin:.5em;background-color:#ffffff80;width:100%;border-radius:10px;.thumbnail{background-size:cover;background-position:center center;height:150px;width:100%;display:flex;align-items:center;justify-content:center;border-top-left-radius:10px;border-top-right-radius:10px}.viewDetails{font-size:smaller}.bottom{padding:10px}.title{margin-bottom:5px}.viewDetails span{transform:rotate(90deg);display:inline-block}calcite-accordion{width:100%}}.sources{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:1em;width:100%}.source{margin:.5em;border-radius:10px;width:200px}calcite-accordion-item[heading=Map]>*{margin-bottom:1rem}arcgis-map{display:block;height:400px}.text{margin:0 .5rem}.message{display:grid;grid-column-gap:1px;justify-content:start;grid-template-areas:"avatar text" ". feedback "}.message.removed{display:none}.response{display:block;grid-area:text;width:fit-content;padding:.75rem;font-size:1rem;line-height:1.375rem;text-align:left}.response p{margin-block-start:0;margin-block-end:0}.response a{color:#00a0ff}.response .actions{width:100%;display:flex;flex-wrap:wrap;box-sizing:border-box}.author-Human{justify-content:end;grid-template-areas:"text avatar" "feedback ."}.author-Human .response{background-color:var(--color-primary);color:#fff;border-radius:15px 0 15px 15px}.author-AI .response{border-radius:0 15px 15px;background-color:var(--calcite-color-foreground-1);color:var(--calcite-color-text-1)}.status-message{opacity:0;font-size:1em;transition:opacity 2s ease-in-out;font-size:1.2rem;text-justify:auto}@keyframes fadeIn{0%{opacity:0;transform:translateY(20px)}50%{opacity:1;transform:translateY(0)}to{opacity:0}}.status-message{animation:fadeIn 6s infinite}.loader{display:flex;flex-direction:column;gap:.5rem;background:#fff;padding:1rem;width:65%;border-radius:0 16px 16px}.skeleton-loader{background:#eee;background:linear-gradient(110deg,#ececec 8%,#f5f5f5 18%,#ececec 33%);border-radius:5px;background-size:200% 100%;animation:1.5s shine linear infinite;height:24px;width:100%}.square-container{display:flex;gap:1rem;flex-direction:row}.square{width:120px;height:120px}@keyframes shine{to{background-position-x:-200%}}:host{--color-primary: dodgerblue;display:flex;flex-direction:column;height:100%;.messages{flex:1;flex-grow:1;display:flex;padding:10px;overflow-y:auto;flex-direction:column;gap:1rem}form{margin:0 .5rem;.action-buttons{display:flex;justify-content:space-around}.action-buttons calcite-button{width:auto;flex-grow:1;margin:.5rem}}}#request-input{margin:0 .5rem;height:2rem}.actionsTitle{display:block;font-weight:700;font-size:1.2rem;text-align:left}#actions{display:flex;flex-flow:row wrap;justify-content:flex-start;gap:1rem;margin:1rem}`;
|
|
13
13
|
var i = /* @__PURE__ */ ((a) => (a.USER = "Human", a.HUB = "AI", a.SYSTEM = "System", a))(i || {});
|
|
14
14
|
const c = [
|
|
@@ -109,7 +109,7 @@ class I extends u {
|
|
|
109
109
|
return e.map((t) => r`<calcite-button round icon-start=${(typeof t == "string" ? "effects" : t.icon) ?? p} @click=${() => this.submitUserMessage(typeof t == "string" ? t : t.label)} .disabled=${this.isLoading} appearance=outline-fill>${typeof t == "string" ? t : t.label}</calcite-button>`);
|
|
110
110
|
}
|
|
111
111
|
renderWelcomeMessages() {
|
|
112
|
-
return r`${this.botTitle && n({ message: { author: i.HUB, text: `Welcome to the ${this.botTitle}
|
|
112
|
+
return r`${this.botTitle && n({ message: { author: i.HUB, text: `Welcome to the ${this.botTitle} assistant.` } }) || ""}${this.botDescription && n({ message: { author: i.HUB, text: this.botDescription } }) || ""}${n({ message: { author: i.HUB, text: "How can I assist you today?" } })}`;
|
|
113
113
|
}
|
|
114
114
|
renderForm() {
|
|
115
115
|
return r`<form @submit=${this.handleFormSubmit}><calcite-input-text .disabled=${this.isLoading} id=request-input placeholder="What are you searching for...?" @calciteInputTextInput=${this.handleInputTextChange} .value=${this.inputText}></calcite-input-text><div class="action-buttons"><calcite-button appearance=outline icon-start=reset @click=${this.handleClearHistory} .disabled=${this.isLoading}>Clear History</calcite-button><calcite-button type=submit icon-start=send .disabled=${this.isLoading || !this.inputText.trim()}>Send</calcite-button></div></form>`;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import { c as
|
|
1
|
+
import { c as T } from "../../chunks/runtime.js";
|
|
2
2
|
import { html as y } from "lit-html";
|
|
3
|
-
import { LitElement as
|
|
4
|
-
import { getLocationCenter as D, calculateZoom as
|
|
5
|
-
import { css as
|
|
6
|
-
import { getPortalSettings as
|
|
7
|
-
import { createRef as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
3
|
+
import { LitElement as E, createEvent as x, noShadowRoot as R } from "@arcgis/lumina";
|
|
4
|
+
import { getLocationCenter as D, calculateZoom as C } from "./util/customElement.js";
|
|
5
|
+
import { css as P } from "@lit/reactive-element/css-tag.js";
|
|
6
|
+
import { getPortalSettings as L, getItem as _, getItemData as z } from "@esri/arcgis-rest-portal";
|
|
7
|
+
import { createRef as U, ref as w } from "lit/directives/ref.js";
|
|
8
|
+
import M from "@arcgis/core/layers/Layer.js";
|
|
9
|
+
import V from "@arcgis/core/portal/PortalItem.js";
|
|
10
10
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
11
11
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
12
|
-
v0.0.
|
|
13
|
-
async function
|
|
12
|
+
v0.0.9 */
|
|
13
|
+
async function q(o) {
|
|
14
14
|
const {
|
|
15
15
|
skillId: t,
|
|
16
|
-
message:
|
|
17
|
-
context:
|
|
18
|
-
token:
|
|
19
|
-
conversationId:
|
|
16
|
+
message: e,
|
|
17
|
+
context: s,
|
|
18
|
+
token: i,
|
|
19
|
+
conversationId: a,
|
|
20
20
|
apiUrl: c = "https://api.example.com",
|
|
21
|
-
pauseMs:
|
|
22
|
-
retries:
|
|
23
|
-
} =
|
|
24
|
-
Authorization: `Bearer ${
|
|
21
|
+
pauseMs: S = 1e3,
|
|
22
|
+
retries: A = 3
|
|
23
|
+
} = o, d = {
|
|
24
|
+
Authorization: `Bearer ${i}`,
|
|
25
25
|
Accept: "application/json",
|
|
26
26
|
"Content-Type": "application/json"
|
|
27
|
-
}, u = `${c}/skills/${t}/chat`, m = { message:
|
|
28
|
-
|
|
27
|
+
}, u = `${c}/skills/${t}/chat`, m = { message: e, context: s };
|
|
28
|
+
a && (m.conversationId = a);
|
|
29
29
|
try {
|
|
30
30
|
const r = await fetch(u, {
|
|
31
31
|
method: "POST",
|
|
32
|
-
headers:
|
|
32
|
+
headers: d,
|
|
33
33
|
body: JSON.stringify(m)
|
|
34
34
|
});
|
|
35
35
|
if (!r.ok)
|
|
36
36
|
throw new Error(`HTTP error! status: ${r.status}`);
|
|
37
|
-
const n = await r.json(), k =
|
|
37
|
+
const n = await r.json(), k = a ?? n.conversationId, v = n.inquiryId;
|
|
38
38
|
let g = n.hasMore || n.message == null, f = n.sequenceNumber;
|
|
39
39
|
const h = [];
|
|
40
40
|
n.message && h.push(n);
|
|
41
41
|
let b = 0;
|
|
42
|
-
for (; g && b <
|
|
43
|
-
await new Promise((
|
|
44
|
-
const
|
|
42
|
+
for (; g && b < A; ) {
|
|
43
|
+
await new Promise(($) => setTimeout($, S));
|
|
44
|
+
const p = await fetch(u, {
|
|
45
45
|
method: "POST",
|
|
46
|
-
headers:
|
|
46
|
+
headers: d,
|
|
47
47
|
body: JSON.stringify({
|
|
48
48
|
conversationId: k,
|
|
49
49
|
inquiryId: v,
|
|
50
50
|
ackSequenceNumber: f
|
|
51
51
|
})
|
|
52
52
|
});
|
|
53
|
-
if (!
|
|
54
|
-
throw new Error(`HTTP error! status: ${
|
|
55
|
-
const l = await
|
|
53
|
+
if (!p.ok)
|
|
54
|
+
throw new Error(`HTTP error! status: ${p.status}`);
|
|
55
|
+
const l = await p.json();
|
|
56
56
|
l.message && h.push(l), g = l.hasMore, l.message != null && (f += 1), b++;
|
|
57
57
|
}
|
|
58
58
|
return h;
|
|
@@ -60,130 +60,132 @@ async function H(i) {
|
|
|
60
60
|
return console.error("Error during request:", r), [];
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
|
-
async function
|
|
64
|
-
message:
|
|
63
|
+
async function F({
|
|
64
|
+
message: o,
|
|
65
65
|
context: t,
|
|
66
|
-
token:
|
|
67
|
-
conversationId:
|
|
68
|
-
apiUrl:
|
|
69
|
-
pauseMs:
|
|
66
|
+
token: e,
|
|
67
|
+
conversationId: s,
|
|
68
|
+
apiUrl: i = "https://hub.arcgis.com/api/assistants/v1",
|
|
69
|
+
pauseMs: a = 1e3,
|
|
70
70
|
retries: c = 50
|
|
71
71
|
}) {
|
|
72
|
-
return await
|
|
72
|
+
return await q({
|
|
73
73
|
skillId: "finder",
|
|
74
|
-
message:
|
|
74
|
+
message: o,
|
|
75
75
|
context: t,
|
|
76
|
-
token:
|
|
77
|
-
conversationId:
|
|
78
|
-
apiUrl:
|
|
79
|
-
pauseMs:
|
|
76
|
+
token: e,
|
|
77
|
+
conversationId: s ?? void 0,
|
|
78
|
+
apiUrl: i,
|
|
79
|
+
pauseMs: a,
|
|
80
80
|
retries: c
|
|
81
81
|
});
|
|
82
82
|
}
|
|
83
|
-
const
|
|
83
|
+
const H = P`@layer{arcgis-hub-ai-assistant{arcgis-feature-table{height:200px}}}`, I = {
|
|
84
84
|
language: "en",
|
|
85
85
|
defaultSuggestions: ["What can I do with this assistant?"],
|
|
86
|
-
personality: "You are writing for a government websites readable by 8th graders."
|
|
87
|
-
feedbackFormUrl: "https://survey123.arcgis.com/share/5661d0a398e4416984c2008ebf02a701",
|
|
88
|
-
allowChat:
|
|
89
|
-
showHeader:
|
|
86
|
+
personality: "You are writing for a government websites readable by 8th graders."
|
|
87
|
+
// feedbackFormUrl: "https://survey123.arcgis.com/share/5661d0a398e4416984c2008ebf02a701",
|
|
88
|
+
// allowChat: false,
|
|
89
|
+
// showHeader: true,
|
|
90
90
|
};
|
|
91
91
|
async function O({
|
|
92
|
-
portal:
|
|
92
|
+
portal: o,
|
|
93
93
|
authentication: t
|
|
94
94
|
}) {
|
|
95
95
|
try {
|
|
96
|
-
const
|
|
97
|
-
portal:
|
|
96
|
+
const s = await L(void 0, {
|
|
97
|
+
portal: o,
|
|
98
98
|
authentication: t
|
|
99
99
|
});
|
|
100
|
-
return
|
|
101
|
-
} catch (
|
|
102
|
-
return console.error("Error fetching organization assistant settings:",
|
|
100
|
+
return s.aiAssistantsEnabled === void 0 || s.aiAssistantsEnabled && !s.blockBetaApps ? !0 : (console.warn("AI Assistants are not enabled for this organization."), !1);
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return console.error("Error fetching organization assistant settings:", e), !1;
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
-
function j(
|
|
106
|
-
return i.replace("http://", "").replace("https://", "").split(/[/?#]/u)[0];
|
|
107
|
-
}
|
|
108
|
-
async function B(i, t, s) {
|
|
105
|
+
async function j(o, t, e) {
|
|
109
106
|
try {
|
|
110
|
-
const [
|
|
111
|
-
|
|
107
|
+
const [s, i] = await Promise.all([
|
|
108
|
+
_(o, { authentication: t, portal: e }),
|
|
112
109
|
// , { authentication: state.context.hubRequestOptions.authentication }
|
|
113
|
-
|
|
110
|
+
z(o, { authentication: t, portal: e })
|
|
114
111
|
// , { authentication: state.context.hubRequestOptions.authentication }
|
|
115
112
|
]);
|
|
116
113
|
return {
|
|
117
|
-
...
|
|
118
|
-
title:
|
|
119
|
-
description:
|
|
120
|
-
extent:
|
|
121
|
-
context:
|
|
122
|
-
placeholder:
|
|
123
|
-
theme:
|
|
124
|
-
avatar:
|
|
125
|
-
language:
|
|
126
|
-
clientId:
|
|
127
|
-
personality:
|
|
128
|
-
feedbackFormUrl:
|
|
129
|
-
hub:
|
|
130
|
-
allowChat:
|
|
131
|
-
showHeader:
|
|
132
|
-
entityId:
|
|
133
|
-
location:
|
|
134
|
-
tools:
|
|
135
|
-
defaultSuggestions:
|
|
136
|
-
|
|
114
|
+
...I,
|
|
115
|
+
title: s.title,
|
|
116
|
+
description: i.assistant?.description,
|
|
117
|
+
extent: s.extent,
|
|
118
|
+
// context: item.accessInformation as string,
|
|
119
|
+
// placeholder: itemData.placeholder,
|
|
120
|
+
// theme: itemData.theme,
|
|
121
|
+
// avatar: itemData.avatar,
|
|
122
|
+
// language: itemData.language,
|
|
123
|
+
// clientId: itemData.clientId,
|
|
124
|
+
personality: i.assistant?.personality,
|
|
125
|
+
// feedbackFormUrl: itemData.feedbackFormUrl,
|
|
126
|
+
// hub: extractDomain(itemData.hub),
|
|
127
|
+
// allowChat: itemData.allowChat,
|
|
128
|
+
// showHeader: itemData.showHeader,
|
|
129
|
+
// entityId: itemData.entityId,
|
|
130
|
+
location: i.assistant?.location ?? "",
|
|
131
|
+
// tools: itemData.tools,
|
|
132
|
+
defaultSuggestions: i.assistant?.examplePrompts ?? I.defaultSuggestions,
|
|
133
|
+
context: "",
|
|
134
|
+
hub: "",
|
|
135
|
+
allowChat: !1,
|
|
136
|
+
showHeader: !1,
|
|
137
|
+
entityId: "",
|
|
138
|
+
tools: []
|
|
137
139
|
};
|
|
138
|
-
} catch (
|
|
139
|
-
throw console.error("Error fetching configuration:",
|
|
140
|
+
} catch (s) {
|
|
141
|
+
throw console.error("Error fetching configuration:", s), s;
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
|
-
class
|
|
144
|
+
class B extends E {
|
|
143
145
|
constructor() {
|
|
144
|
-
super(...arguments), this._featureTable =
|
|
145
|
-
const
|
|
146
|
-
id:
|
|
146
|
+
super(...arguments), this._featureTable = U(), this.handleArcGISDataClick = (t) => {
|
|
147
|
+
const s = t.detail.data.id, i = new V({
|
|
148
|
+
id: s
|
|
147
149
|
});
|
|
148
|
-
|
|
149
|
-
portalItem:
|
|
150
|
-
}).then((
|
|
151
|
-
this._mapRef?.map?.add(
|
|
152
|
-
}).catch((
|
|
153
|
-
console.log("could not add layer:",
|
|
150
|
+
M.fromPortalItem({
|
|
151
|
+
portalItem: i
|
|
152
|
+
}).then((a) => {
|
|
153
|
+
this._mapRef?.map?.add(a), this._featureTable.value && (this._featureTable.value.layer = a), this.mapLayers.push(s), this.arcgisAddLayer.emit(), this.mapVisible = !0;
|
|
154
|
+
}).catch((a) => {
|
|
155
|
+
console.log("could not add layer:", a);
|
|
154
156
|
});
|
|
155
157
|
}, this.handleArcGISLocationClick = (t) => {
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
+
const e = t.detail;
|
|
159
|
+
e.longitude && e.latitude && e.zoom && (this.mapVisible = !0, this._mapRef?.view.goTo({ center: [e.longitude, e.latitude], zoom: e.zoom }));
|
|
158
160
|
}, this.assistantsEnabled = !1, this.mapEnabled = !1, this.mapVisible = !1, this.itemId = null, this.portalUrl = "https://www.arcgis.com", this.apiUrl = "/api/assistants/v1", this.botTitle = "Hub AI Assistant", this.extent = [
|
|
159
161
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
160
162
|
[-77.119, 38.791],
|
|
161
163
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
162
164
|
[-76.909, 38.995]
|
|
163
|
-
], this.mapLayers = [], this.mapShowTable = !1, this.mapBasemap = "gray-vector", this.location = "Washington, DC", this.hub = "opendata.dc.gov", this.entityId = null, this.context = null, this.language = void 0, this.botDescription = "Hub AI Assistant helps you find and use open data in your community.", this.defaultSuggestions = [], this.authentication = void 0, this.arcgisAddLayer =
|
|
165
|
+
], this.mapLayers = [], this.mapShowTable = !1, this.mapBasemap = "gray-vector", this.location = "Washington, DC", this.hub = "opendata.dc.gov", this.entityId = null, this.context = null, this.language = void 0, this.botDescription = "Hub AI Assistant helps you find and use open data in your community.", this.defaultSuggestions = [], this.authentication = void 0, this.arcgisAddLayer = x();
|
|
164
166
|
}
|
|
165
167
|
static {
|
|
166
168
|
this.properties = { assistantsEnabled: 16, _mapRef: 16, mapEnabled: 5, mapVisible: 5, itemId: 1, portalUrl: 1, apiUrl: 1, botTitle: 1, extent: 0, mapLayers: 0, mapShowTable: 5, mapBasemap: 1, location: 1, hub: 1, entityId: 1, context: 1, language: 1, botDescription: 1, defaultSuggestions: 0, authentication: 0 };
|
|
167
169
|
}
|
|
168
170
|
static {
|
|
169
|
-
this.shadowRootOptions =
|
|
171
|
+
this.shadowRootOptions = R;
|
|
170
172
|
}
|
|
171
173
|
static {
|
|
172
|
-
this.styles =
|
|
174
|
+
this.styles = H;
|
|
173
175
|
}
|
|
174
176
|
async load() {
|
|
175
177
|
if (this.assistantsEnabled = await O({
|
|
176
178
|
portal: `${this.portalUrl}/sharing/rest`,
|
|
177
179
|
authentication: this.authentication
|
|
178
180
|
}), this.itemId) {
|
|
179
|
-
const t = await
|
|
180
|
-
|
|
181
|
+
const t = await j(this.itemId, this.authentication, `${this.portalUrl}/sharing/rest`);
|
|
182
|
+
this.botTitle = t.title, this.botDescription = t.description ? t.description : "", this.hub = t.hub, this.location = t.location, this.extent = t.extent, this.defaultSuggestions = t.defaultSuggestions;
|
|
181
183
|
}
|
|
182
184
|
}
|
|
183
|
-
async handleFinderResponse(t,
|
|
184
|
-
const
|
|
185
|
+
async handleFinderResponse(t, e) {
|
|
186
|
+
const s = await F({
|
|
185
187
|
message: t,
|
|
186
|
-
conversationId:
|
|
188
|
+
conversationId: e,
|
|
187
189
|
context: {
|
|
188
190
|
kind: "FinderRequest",
|
|
189
191
|
item: this.itemId ?? void 0
|
|
@@ -191,9 +193,9 @@ class G extends T {
|
|
|
191
193
|
token: this.authentication?.token ?? "",
|
|
192
194
|
apiUrl: this.apiUrl
|
|
193
195
|
});
|
|
194
|
-
if (
|
|
196
|
+
if (s.length === 0)
|
|
195
197
|
throw new Error("Finder response is empty or invalid");
|
|
196
|
-
return
|
|
198
|
+
return s;
|
|
197
199
|
}
|
|
198
200
|
_setMapRef(t) {
|
|
199
201
|
this._mapRef = t;
|
|
@@ -201,10 +203,10 @@ class G extends T {
|
|
|
201
203
|
render() {
|
|
202
204
|
return y`<link rel=stylesheet href=https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/light/main.css><arcgis-chat-shell .aboutContent=${this.botDescription} .mapEnabled=${this.mapEnabled} .mapVisible=${this.mapEnabled && this.mapVisible} @arcgisUpdateMapVisibility=${(t) => {
|
|
203
205
|
this.mapVisible = t.detail;
|
|
204
|
-
}}><arcgis-chat-ui .botDescription=${this.botDescription} .botTitle=${this.botTitle} .defaultSuggestions=${this.defaultSuggestions} slot=leftPanel .getFinderResponse=${this.handleFinderResponse.bind(this)} @arcgisAddDataClick=${this.handleArcGISDataClick} @arcgisLocationClick=${this.handleArcGISLocationClick}></arcgis-chat-ui><arcgis-map slot=map .center=${D(this.extent)} .zoom=${
|
|
206
|
+
}}><arcgis-chat-ui .botDescription=${this.botDescription} .botTitle=${this.botTitle} .defaultSuggestions=${this.defaultSuggestions} slot=leftPanel .getFinderResponse=${this.handleFinderResponse.bind(this)} @arcgisAddDataClick=${this.handleArcGISDataClick} @arcgisLocationClick=${this.handleArcGISLocationClick}></arcgis-chat-ui><arcgis-map slot=map .center=${D(this.extent)} .zoom=${C(this.extent)} .basemap=${this.mapBasemap} ${w(this._setMapRef)}><arcgis-zoom position=top-left></arcgis-zoom><arcgis-expand position=top-right><arcgis-layer-list></arcgis-layer-list></arcgis-expand><arcgis-search position=bottom-trailing></arcgis-search></arcgis-map>${this.mapShowTable && y`<arcgis-feature-table .referenceElement=${this._mapRef} slot=featureTable ${w(this._featureTable)}></arcgis-feature-table>` || ""}</arcgis-chat-shell>`;
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
|
-
|
|
209
|
+
T("arcgis-hub-ai-assistant", B);
|
|
208
210
|
export {
|
|
209
|
-
|
|
211
|
+
B as ArcGISHubAIAssistant
|
|
210
212
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getItem as u } from "@esri/arcgis-rest-portal";
|
|
2
2
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
4
|
-
v0.0.
|
|
4
|
+
v0.0.9 */
|
|
5
5
|
const m = async (o) => await Promise.all(o.map(h)), h = async (o) => {
|
|
6
6
|
const t = structuredClone(o);
|
|
7
7
|
try {
|
package/dist/docs/api.json
CHANGED
package/dist/docs/docs.json
CHANGED
package/dist/docs/web-types.json
CHANGED
package/dist/embed-config.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { g as e, s as a } from "./chunks/runtime.js";
|
|
2
2
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
4
|
-
v0.0.
|
|
4
|
+
v0.0.9 */
|
|
5
5
|
export {
|
|
6
6
|
e as getAssetPath,
|
|
7
7
|
a as setAssetPath
|
package/dist/loader.js
CHANGED
|
@@ -2,7 +2,7 @@ import { r as e } from "./chunks/runtime.js";
|
|
|
2
2
|
import { makeDefineCustomElements as t } from "@arcgis/lumina";
|
|
3
3
|
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
4
4
|
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
5
|
-
v0.0.
|
|
5
|
+
v0.0.9 */
|
|
6
6
|
const o = t(e, {
|
|
7
7
|
"arcgis-chat-shell": [() => import("./components/arcgis-chat-shell/customElement.js"), "aboutContent,aboutVisible,chatComponent:,featureTable:,map:,mapEnabled,mapVisible"],
|
|
8
8
|
"arcgis-chat-ui": [() => import("./components/arcgis-chat-ui/customElement.js"), "botDescription,botTitle,conversationId,defaultSuggestions:,devFeatureMessage:,getFinderResponse:,inputText;;submitUserMessage"],
|
|
@@ -10,6 +10,9 @@ export declare function getOrganizationAssistantsEnabled({ portal, authenticatio
|
|
|
10
10
|
portal: string;
|
|
11
11
|
authentication?: ArcGISIdentityManager | string;
|
|
12
12
|
}): Promise<boolean>;
|
|
13
|
+
/**
|
|
14
|
+
* Get just the domain name from a URL
|
|
15
|
+
*/
|
|
13
16
|
/**
|
|
14
17
|
* Fetch the configuration of an assistant from the ArcGIS Online item
|
|
15
18
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@esri/hub-web-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9",
|
|
4
|
+
"description": "A collection of web components to build web experiences with ArcGIS Hub.",
|
|
4
5
|
"publishConfig": {
|
|
5
6
|
"access": "public"
|
|
6
7
|
},
|
|
@@ -77,7 +78,6 @@
|
|
|
77
78
|
"dist/docs/vscode.html-custom-data.json"
|
|
78
79
|
],
|
|
79
80
|
"web-types": "dist/docs/web-types.json",
|
|
80
|
-
"description": "A new Lumina components project",
|
|
81
81
|
"scripts": {
|
|
82
82
|
"start": "vite",
|
|
83
83
|
"start-internal-storybook": "storybook dev -c .storybook/internal -p 6007 --quiet",
|
package/dist/cdn/WXE3ZTTR.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
/*! All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
2
|
-
See https://js.arcgis.com/0.0/esri/copyright.txt for details.
|
|
3
|
-
v0.0.7 */
|
|
4
|
-
import"./WRKUDBNV.js";import{a as T,b as E,c as U,e as R,f as C}from"./U2LWF6QB.js";import{a as A,b as u}from"./O2NZEVMJ.js";import{a as S,b as d,d as v,f as $,k,p as x}from"./KSGVQKCZ.js";export default $arcgis.t(([P,F])=>{async function M(i){let{skillId:t,message:e,context:s,token:a,conversationId:n,apiUrl:c="https://api.example.com",pauseMs:D=1e3,retries:_=3}=i,g={Authorization:`Bearer ${a}`,Accept:"application/json","Content-Type":"application/json"},b=`${c}/skills/${t}/chat`,f={message:e,context:s};n&&(f.conversationId=n);try{let r=await fetch(b,{method:"POST",headers:g,body:JSON.stringify(f)});if(!r.ok)throw new Error(`HTTP error! status: ${r.status}`);let o=await r.json(),L=n??o.conversationId,z=o.inquiryId,y=o.hasMore||o.message==null,w=o.sequenceNumber,h=[];o.message&&h.push(o);let I=0;for(;y&&I<_;){await new Promise(H=>setTimeout(H,D));let p=await fetch(b,{method:"POST",headers:g,body:JSON.stringify({conversationId:L,inquiryId:z,ackSequenceNumber:w})});if(!p.ok)throw new Error(`HTTP error! status: ${p.status}`);let l=await p.json();l.message&&h.push(l),y=l.hasMore,l.message!=null&&(w+=1),I++}return h}catch(r){return console.error("Error during request:",r),[]}}async function V({message:i,context:t,token:e,conversationId:s,apiUrl:a="https://hub.arcgis.com/api/assistants/v1",pauseMs:n=1e3,retries:c=50}){return await M({skillId:"finder",message:i,context:t,token:e,conversationId:s??void 0,apiUrl:a,pauseMs:n,retries:c})}var q=S`@layer{arcgis-hub-ai-assistant{arcgis-feature-table{height:200px}}}`,j={language:"en",defaultSuggestions:["What can I do with this assistant?"],personality:"You are writing for a government websites readable by 8th graders.",feedbackFormUrl:"https://survey123.arcgis.com/share/5661d0a398e4416984c2008ebf02a701",allowChat:!1,showHeader:!0};async function B({portal:i,authentication:t}){try{let e=await U(void 0,{portal:i,authentication:t});return console.log("orgSettingsData",e),e.aiAssistantsEnabled===void 0||e.aiAssistantsEnabled&&!e.blockBetaApps?!0:(console.warn("AI Assistants are not enabled for this organization."),!1)}catch(e){return console.error("Error fetching organization assistant settings:",e),!1}}function O(i){return i.replace("http://","").replace("https://","").split(/[/?#]/u)[0]}async function G(i,t,e){try{let[s,a]=await Promise.all([T(i,{authentication:t,portal:e}),E(i,{authentication:t,portal:e})]);return{...j,title:s.title,description:s.description,extent:s.extent,context:s.accessInformation,placeholder:a.placeholder,theme:a.theme,avatar:a.avatar,language:a.language,clientId:a.clientId,personality:a.personality,feedbackFormUrl:a.feedbackFormUrl,hub:O(a.hub),allowChat:a.allowChat,showHeader:a.showHeader,entityId:a.entityId,location:a.location,tools:a.tools,defaultSuggestions:a.defaultSuggestions,informationSources:a.informationSources??[a.entityId]}}catch(s){throw console.error("Error fetching configuration:",s),s}}var m=class extends k{constructor(){super(...arguments),this._featureTable=A(),this.handleArcGISDataClick=t=>{let e=t.detail.data.id,s=new F({id:e});P.fromPortalItem({portalItem:s}).then(a=>{this._mapRef?.map?.add(a),this._featureTable.value&&(this._featureTable.value.layer=a),this.mapLayers.push(e),this.arcgisAddLayer.emit(),this.mapVisible=!0}).catch(a=>{console.log("could not add layer:",a)})},this.handleArcGISLocationClick=t=>{let e=t.detail;e.longitude&&e.latitude&&e.zoom&&(this.mapVisible=!0,this._mapRef?.view.goTo({center:[e.longitude,e.latitude],zoom:e.zoom}))},this.assistantsEnabled=!1,this.mapEnabled=!1,this.mapVisible=!1,this.itemId=null,this.portalUrl="https://www.arcgis.com",this.apiUrl="/api/assistants/v1",this.botTitle="Hub AI Assistant",this.extent=[[-77.119,38.791],[-76.909,38.995]],this.mapLayers=[],this.mapShowTable=!1,this.mapBasemap="gray-vector",this.location="Washington, DC",this.hub="opendata.dc.gov",this.entityId=null,this.context=null,this.language=void 0,this.botDescription="Hub AI Assistant helps you find and use open data in your community.",this.defaultSuggestions=[],this.authentication=void 0,this.arcgisAddLayer=v()}static{this.properties={assistantsEnabled:16,_mapRef:16,mapEnabled:5,mapVisible:5,itemId:1,portalUrl:1,apiUrl:1,botTitle:1,extent:0,mapLayers:0,mapShowTable:5,mapBasemap:1,location:1,hub:1,entityId:1,context:1,language:1,botDescription:1,defaultSuggestions:0,authentication:0}}static{this.shadowRootOptions=$}static{this.styles=q}async load(){if(this.assistantsEnabled=await B({portal:`${this.portalUrl}/sharing/rest`,authentication:this.authentication}),this.itemId){let t=await G(this.itemId,this.authentication,`${this.portalUrl}/sharing/rest`);console.log("Hub AI Assistant configuration",t),this.botTitle=t.title,this.botDescription=t.description?t.description:"",this.hub=t.hub,this.extent=t.extent,this.defaultSuggestions=t.defaultSuggestions}}async handleFinderResponse(t,e){let s=await V({message:t,conversationId:e,context:{kind:"FinderRequest",item:this.itemId??void 0},token:this.authentication?.token??"",apiUrl:this.apiUrl});if(s.length===0)throw new Error("Finder response is empty or invalid");return s}_setMapRef(t){this._mapRef=t}render(){return d`<link rel=stylesheet href=https://js.arcgis.com/4.33/@arcgis/core/assets/esri/themes/light/main.css><arcgis-chat-shell .aboutContent=${this.botDescription} .mapEnabled=${this.mapEnabled} .mapVisible=${this.mapEnabled&&this.mapVisible} @arcgisUpdateMapVisibility=${t=>{this.mapVisible=t.detail}}><arcgis-chat-ui .botDescription=${this.botDescription} .botTitle=${this.botTitle} .defaultSuggestions=${this.defaultSuggestions} slot=leftPanel .getFinderResponse=${this.handleFinderResponse.bind(this)} @arcgisAddDataClick=${this.handleArcGISDataClick} @arcgisLocationClick=${this.handleArcGISLocationClick}></arcgis-chat-ui><arcgis-map slot=map .center=${R(this.extent)} .zoom=${C(this.extent)} .basemap=${this.mapBasemap} ${u(this._setMapRef)}><arcgis-zoom position=top-left></arcgis-zoom><arcgis-expand position=top-right><arcgis-layer-list></arcgis-layer-list></arcgis-expand><arcgis-search position=bottom-trailing></arcgis-search></arcgis-map>${this.mapShowTable&&d`<arcgis-feature-table .referenceElement=${this._mapRef} slot=featureTable ${u(this._featureTable)}></arcgis-feature-table>`||""}</arcgis-chat-shell>`}};x("arcgis-hub-ai-assistant",m);return m},"layers/Layer","portal/PortalItem")
|