@arcgis/portal-components 5.1.0-next.84 → 5.1.0-next.86
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/{LNCTAKOH.js → I4ZGLRAS.js} +4 -4
- package/dist/cdn/MFMTJNSM.js +2 -0
- package/dist/cdn/WRH4C2YQ.js +2 -0
- package/dist/cdn/assets/portal-replacement-item-redirect/t9n/messages.en.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/chunks/fieldAddDelete.js +27 -27
- package/dist/components/arcgis-portal-ai-assistant/customElement.js +22 -33
- package/dist/components/arcgis-portal-replacement-item-redirect/customElement.d.ts +2 -0
- package/dist/components/arcgis-portal-replacement-item-redirect/customElement.js +41 -38
- package/dist/docs/api.json +1 -1
- package/dist/docs/docs.json +1 -1
- package/dist/docs/web-types.json +1 -1
- package/package.json +3 -3
- package/dist/cdn/IVVOF5BB.js +0 -2
- package/dist/cdn/SFYRYZJS.js +0 -2
|
@@ -101,9 +101,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
101
101
|
${e}</tr>
|
|
102
102
|
`}tablecell(e){let r=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+r+`</${n}>
|
|
103
103
|
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${oe(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:r,tokens:n}){let o=this.parser.parseInline(n),t=up(e);if(t===null)return o;e=t;let i='<a href="'+e+'"';return r&&(i+=' title="'+oe(r)+'"'),i+=">"+o+"</a>",i}image({href:e,title:r,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));let t=up(e);if(t===null)return oe(n);e=t;let i=`<img src="${e}" alt="${oe(n)}"`;return r&&(i+=` title="${oe(r)}"`),i+=">",i}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):"escaped"in e&&e.escaped?e.text:oe(e.text)}},su=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},ee=class Hs{options;renderer;textRenderer;constructor(r){this.options=r||Oe,this.options.renderer=this.options.renderer||new Vn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new su}static parse(r,n){return new Hs(n).parse(r)}static parseInline(r,n){return new Hs(n).parseInline(r)}parse(r){this.renderer.parser=this;let n="";for(let o=0;o<r.length;o++){let t=r[o];if(this.options.extensions?.renderers?.[t.type]){let a=t,c=this.options.extensions.renderers[a.type].call({parser:this},a);if(c!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=c||"";continue}}let i=t;switch(i.type){case"space":{n+=this.renderer.space(i);break}case"hr":{n+=this.renderer.hr(i);break}case"heading":{n+=this.renderer.heading(i);break}case"code":{n+=this.renderer.code(i);break}case"table":{n+=this.renderer.table(i);break}case"blockquote":{n+=this.renderer.blockquote(i);break}case"list":{n+=this.renderer.list(i);break}case"checkbox":{n+=this.renderer.checkbox(i);break}case"html":{n+=this.renderer.html(i);break}case"def":{n+=this.renderer.def(i);break}case"paragraph":{n+=this.renderer.paragraph(i);break}case"text":{n+=this.renderer.text(i);break}default:{let a='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw new Error(a)}}}return n}parseInline(r,n=this.renderer){this.renderer.parser=this;let o="";for(let t=0;t<r.length;t++){let i=r[t];if(this.options.extensions?.renderers?.[i.type]){let c=this.options.extensions.renderers[i.type].call({parser:this},i);if(c!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){o+=c||"";continue}}let a=i;switch(a.type){case"escape":{o+=n.text(a);break}case"html":{o+=n.html(a);break}case"link":{o+=n.link(a);break}case"image":{o+=n.image(a);break}case"checkbox":{o+=n.checkbox(a);break}case"strong":{o+=n.strong(a);break}case"em":{o+=n.em(a);break}case"codespan":{o+=n.codespan(a);break}case"br":{o+=n.br(a);break}case"del":{o+=n.del(a);break}case"text":{o+=n.text(a);break}default:{let c='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(c),"";throw new Error(c)}}}return o}},Gt=class{options;block;constructor(e){this.options=e||Oe}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?H.lex:H.lexInline}provideParser(e=this.block){return e?ee.parse:ee.parseInline}},uh=class{defaults=eu();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=ee;Renderer=Vn;TextRenderer=su;Lexer=H;Tokenizer=Jn;Hooks=Gt;constructor(...e){this.use(...e)}walkTokens(e,r){let n=[];for(let o of e)switch(n=n.concat(r.call(this,o)),o.type){case"table":{let t=o;for(let i of t.header)n=n.concat(this.walkTokens(i.tokens,r));for(let i of t.rows)for(let a of i)n=n.concat(this.walkTokens(a.tokens,r));break}case"list":{let t=o;n=n.concat(this.walkTokens(t.items,r));break}default:{let t=o;this.defaults.extensions?.childTokens?.[t.type]?this.defaults.extensions.childTokens[t.type].forEach(i=>{let a=t[i].flat(1/0);n=n.concat(this.walkTokens(a,r))}):t.tokens&&(n=n.concat(this.walkTokens(t.tokens,r)))}}return n}use(...e){let r=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach(t=>{if(!t.name)throw new Error("extension name required");if("renderer"in t){let i=r.renderers[t.name];i?r.renderers[t.name]=function(...a){let c=t.renderer.apply(this,a);return c===!1&&(c=i.apply(this,a)),c}:r.renderers[t.name]=t.renderer}if("tokenizer"in t){if(!t.level||t.level!=="block"&&t.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=r[t.level];i?i.unshift(t.tokenizer):r[t.level]=[t.tokenizer],t.start&&(t.level==="block"?r.startBlock?r.startBlock.push(t.start):r.startBlock=[t.start]:t.level==="inline"&&(r.startInline?r.startInline.push(t.start):r.startInline=[t.start]))}"childTokens"in t&&t.childTokens&&(r.childTokens[t.name]=t.childTokens)}),o.extensions=r),n.renderer){let t=this.defaults.renderer||new Vn(this.defaults);for(let i in n.renderer){if(!(i in t))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let a=i,c=n.renderer[a],u=t[a];t[a]=(...s)=>{let l=c.apply(t,s);return l===!1&&(l=u.apply(t,s)),l||""}}o.renderer=t}if(n.tokenizer){let t=this.defaults.tokenizer||new Jn(this.defaults);for(let i in n.tokenizer){if(!(i in t))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let a=i,c=n.tokenizer[a],u=t[a];t[a]=(...s)=>{let l=c.apply(t,s);return l===!1&&(l=u.apply(t,s)),l}}o.tokenizer=t}if(n.hooks){let t=this.defaults.hooks||new Gt;for(let i in n.hooks){if(!(i in t))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let a=i,c=n.hooks[a],u=t[a];Gt.passThroughHooks.has(i)?t[a]=s=>{if(this.defaults.async&&Gt.passThroughHooksRespectAsync.has(i))return(async()=>{let p=await c.call(t,s);return u.call(t,p)})();let l=c.call(t,s);return u.call(t,l)}:t[a]=(...s)=>{if(this.defaults.async)return(async()=>{let p=await c.apply(t,s);return p===!1&&(p=await u.apply(t,s)),p})();let l=c.apply(t,s);return l===!1&&(l=u.apply(t,s)),l}}o.hooks=t}if(n.walkTokens){let t=this.defaults.walkTokens,i=n.walkTokens;o.walkTokens=function(a){let c=[];return c.push(i.call(this,a)),t&&(c=c.concat(t.call(this,a))),c}}this.defaults={...this.defaults,...o}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,r){return H.lex(e,r??this.defaults)}parser(e,r){return ee.parse(e,r??this.defaults)}parseMarkdown(e){return(r,n)=>{let o={...n},t={...this.defaults,...o},i=this.onError(!!t.silent,!!t.async);if(this.defaults.async===!0&&o.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof r>"u"||r===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof r!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(t.hooks&&(t.hooks.options=t,t.hooks.block=e),t.async)return(async()=>{let a=t.hooks?await t.hooks.preprocess(r):r,c=await(t.hooks?await t.hooks.provideLexer(e):e?H.lex:H.lexInline)(a,t),u=t.hooks?await t.hooks.processAllTokens(c):c;t.walkTokens&&await Promise.all(this.walkTokens(u,t.walkTokens));let s=await(t.hooks?await t.hooks.provideParser(e):e?ee.parse:ee.parseInline)(u,t);return t.hooks?await t.hooks.postprocess(s):s})().catch(i);try{t.hooks&&(r=t.hooks.preprocess(r));let a=(t.hooks?t.hooks.provideLexer(e):e?H.lex:H.lexInline)(r,t);t.hooks&&(a=t.hooks.processAllTokens(a)),t.walkTokens&&this.walkTokens(a,t.walkTokens);let c=(t.hooks?t.hooks.provideParser(e):e?ee.parse:ee.parseInline)(a,t);return t.hooks&&(c=t.hooks.postprocess(c)),c}catch(a){return i(a)}}}onError(e,r){return n=>{if(n.message+=`
|
|
104
|
-
Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+oe(n.message+"",!0)+"</pre>";return r?Promise.resolve(o):o}if(r)return Promise.reject(n);throw n}}},Ze=new uh;function j(e,r){return Ze.parse(e,r)}j.options=j.setOptions=function(e){return Ze.setOptions(e),j.defaults=Ze.defaults,mp(j.defaults),j};j.getDefaults=eu;j.defaults=Oe;j.use=function(...e){return Ze.use(...e),j.defaults=Ze.defaults,mp(j.defaults),j};j.walkTokens=function(e,r){return Ze.walkTokens(e,r)};j.parseInline=Ze.parseInline;j.Parser=ee;j.parser=ee.parse;j.Renderer=Vn;j.TextRenderer=su;j.Lexer=H;j.lexer=H.lex;j.Tokenizer=Jn;j.Hooks=Gt;j.parse=j;var Rx=j.options,Lx=j.setOptions,Cx=j.use,Fx=j.walkTokens,Jx=j.parseInline;var Vx=ee.parse,Mx=H.lex;var lu="http://127.0.0.1:9015",mh=`${lu}/v1/turn/stream`;function fh(e){return`${lu}/v1/users/${encodeURIComponent(e)}/threads`}function gh(e){return`${lu}/v1/threads/${encodeURIComponent(e)}/messages`}var hh=["user","analytics","navigation","documentation","clarify","plan"],vh=b.object({threadId:b.string(),threadSummary:b.string(),lastActivityAt:b.string()}),$h=b.object({username:b.string(),threads:b.array(vh)}),xh=b.object({id:b.string(),type:b.enum(hh),content:b.string()}),_h=b.object({threadId:b.string(),threadSummary:b.string(),messages:b.array(xh)});async function bh(e,r){let n=await fetch(fh(e),{signal:r});if(!n.ok)throw new Error(`Thread list request failed with status ${n.status}.`);let o=$h.safeParse(await n.json());if(!o.success)throw new Error("Thread list response is invalid.");return o.data}async function Ip(e,r){let n=await fetch(gh(e),{signal:r});if(!n.ok)throw new Error(`Thread messages request failed with status ${n.status}.`);let o=await n.json(),t=_h.safeParse(o);if(!t.success)throw new Error("Thread messages response is invalid.");return t.data}function Pp(e){return e.type==="user"?{id:e.id,role:"user",content:e.content}:{id:e.id,role:"assistant",content:e.content,data:e.type==="navigation"?{type:"navigation",summary:e.content}:{type:"analytics",summary:e.content,generatedFollowUpQuestions:[]}}}async function yh(e){try{let r=(await bh(e.username)).threads,n=r[0]?.threadId;if(!n)return{result:null};let o=await Ip(n);return{result:{threads:r,firstThreadInfo:{threadId:n,messages:o.messages.map(Pp)}}}}catch(r){return console.error("Failed to initialize assistant thread state.",r),{error:{code:"unhandledError"}}}}var kh=Object.defineProperty,wh=Object.getOwnPropertyDescriptor,pt=(e,r,n,o)=>{for(var t=o>1?void 0:o?wh(r,n):r,i=e.length-1,a;i>=0;i--)(a=e[i])&&(t=(o?a(r,n,t):a(t))||t);return o&&t&&kh(r,n,t),t},ye=class extends lh{constructor(e){super(e),this.isLoading=!1,this.activeThreadId=null,this.messages=null,this.threads=[]}async load(){await this.initializeThreadMessages()}async initializeThreadMessages(){this.isLoading=!0;let e=await yh(this.user),{error:r,result:n}=e;if(r){console.error("Failed to initialize assistant threads.",r),this.isLoading=!1;return}if(!n){this.activeThreadId=null,this.threads=[],this.isLoading=!1;return}let{threads:o,firstThreadInfo:t}=n;this.threads=[...o].sort((i,a)=>new Date(a.lastActivityAt).getTime()-new Date(i.lastActivityAt).getTime()),this.activeThreadId=t.threadId,console.log("this.activeThreadId:",this.activeThreadId),this.messages=t.messages,this.isLoading=!1}async changeThread(e){if(!e){this.activeThreadId=null,this.messages=null;return}if(this.isLoading=!0,!this.threads.find(r=>r.threadId===e)){console.warn(`Thread with id ${e} not found.`),this.isLoading=!1;return}this.activeThreadId=e;try{let r=await Ip(e);this.messages=r?.messages.map(Pp)||null}catch(r){console.error(`Failed to fetch messages for thread ${e}.`,r),this.messages=null}finally{this.isLoading=!1}}setActiveThreadId(e){this.activeThreadId=e}addMessageToActiveThread(e){this.messages=[...this.messages||[],e]}};pt([qt()],ye.prototype,"user",2);pt([qt()],ye.prototype,"isLoading",2);pt([qt()],ye.prototype,"activeThreadId",2);pt([qt()],ye.prototype,"messages",2);pt([qt()],ye.prototype,"threads",2);ye=pt([dh("AiAssistantThreadController")],ye);function zh(e){if(!e)return"";try{return j.parse(e,{async:!1,breaks:!0})}catch{return e}}function Sh(e){if(e.data.type!=="navigation")return null;let r=e.data.relevantLinks||[];return!e.data.suggestedLink&&!r.length?null:J`<div class="msg-nav-links">${e.data.suggestedLink&&J`<div class="msg-link-row"><calcite-link .href=${e.data.suggestedLink} target=_blank icon-start=launch>${kp(e.data.suggestedLink,"Suggested")}</calcite-link></div>`||""}${r.length>0&&J`<ul class="msg-links-list">${Qn(r,n=>`${n}-${index}`,(n,o)=>J`<li><calcite-link .href=${n} target=_blank icon-start=launch>${kp(n,"Relevant")}</calcite-link></li>`)}</ul>`||""}</div>`}function Ih(e,r){if(e.data.type!=="analytics")return null;let n=e.data.generatedFollowUpQuestions||[];return!n.length||!r?null:J`<div class="msg-follow-ups">${Qn(n,o=>o,o=>J`<calcite-button appearance=outline-fill kind=brand round scale=s width=full @click=${()=>r(o)}>${o}</calcite-button>`)}</div>`}function Ph(e){let{message:r,user:n,onFollowUpQuestionClick:o}=e,t=r.role==="user",i=r.role==="assistant",a=r.content,c=zh(a);return J`<div class=${Yt({"bubble-row":!0,"bubble-row__user":t,"bubble-row__assistant":i})} role=listitem aria-label=${`${r.role} message`}><div class=${Yt(Xn("avatar",t&&"avatar__user",i&&"avatar__assistant"))}>${t?J`<calcite-avatar .username=${n.username??"User"} .thumbnail=${n.thumbnailUrl||void 0} .userId=${n.id} .fullName=${n.fullName||void 0}></calcite-avatar>`:J`<calcite-chip .icon=${i?"effects":"information-letter"} label appearance=outline-fill .kind=${i?"brand":"neutral"}></calcite-chip>`}</div><div class=${Yt(Xn("msg",t&&"msg__user",i&&"msg__assistant"))}><div class="msg-text">${hu(c)}</div>${i?Sh(r):null}${i?Ih(r,o):null}</div></div>`}function kp(e,r){try{let n=new URL(e);return r==="Suggested"?`${r}: ${n.hostname}`:n.hostname}catch{return r}}var jh=Gn`.bubble-row{display:flex;flex-direction:column;gap:.5rem}.bubble-row__user{flex-direction:row-reverse;padding-left:1.5rem}.avatar__user{align-self:flex-end}calcite-avatar{overflow:clip}.msg{display:flex;flex-direction:column;gap:.75rem}.msg-follow-ups{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.5rem;width:100%;max-width:100%}.suggested-nav{display:flex;flex-direction:column;gap:.5rem}.suggested-nav>*{width:fit-content}.msg-text{word-break:break-word}.msg-text>p{margin:0}.msg__user{padding:.5rem .75rem;border-radius:16px 16px 0;background-color:var(--calcite-color-surface-highlight)}.action-results{display:flex;flex-direction:column;gap:.5rem}.action-results>p{margin:0}.action-results>ul{display:flex;flex-direction:column;gap:.5rem}`,Th=Gn`:host{border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;height:-moz-fit-content;height:fit-content;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:host([expanded]){height:100%}.panel__body{display:flex;flex-direction:column;height:100%}.chat-container{overflow:auto;display:flex;flex-grow:1;padding-left:1.25rem;padding-right:1.25rem}.chat-container__inner{display:flex;flex-direction:column;gap:.75rem;width:100%;padding-top:1.25rem;padding-bottom:1.25rem}.thinking-container__header{position:relative;height:2rem;width:2rem}.loader{position:absolute;top:0;left:0;height:100%;width:100%;--calcite-loader-progress-color-inline: var(--calcite-color-brand)}.avatar__user{align-self:flex-end}calcite-avatar{overflow:clip}.thinking-container{display:flex;flex-direction:column;gap:.5rem;.thinking-text{animation:pulse 2s infinite ease-in-out}}@keyframes pulse{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.spacer{visibility:hidden;height:1.25rem;width:100%}.welcome-message{padding:1.75rem .75rem .75rem;display:flex;flex-direction:column;align-items:center;gap:1rem}.welcome{font-size:2rem;font-weight:500;margin:0}.welcome-text{font-size:1.25rem;font-weight:500;margin:0;text-align:center}@media(prefers-reduced-motion:reduce){.hit{transition:none}.chat{scroll-behavior:auto}}.dialog{--calcite-dialog-content-space: 0;--calcite-dialog-size-x: 1080px}.stage{height:100%;overflow:hidden;--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));background-color:var(--calcite-color-background)}@media screen and (min-width:1080px){.stage{height:min(700px,60vh)}}`;function Uh(e,r,n,o){let t=e?.id||"",i=ph.findCredential(e.url)?.token??"",a=window.location.origin||window.location.href.replace(/#.*$/u,""),c=r?.username||e?.user?.username||"";return{threadId:n,userMessage:o,portalId:t,token:i,tokenReferrer:a,username:c}}var Zh=b.enum(["analytics","navigation"]),jp=b.object({type:b.literal("analytics"),summary:b.string(),generatedFollowUpQuestions:b.array(b.string())}),Tp=b.object({type:b.literal("navigation"),summary:b.string(),suggestedLink:b.string().nullable().optional(),relevantLinks:b.array(b.string()).optional()}),Up=b.discriminatedUnion("type",[jp,Tp]),Oh=b.object({type:b.string(),summary:b.string()}),Dh=b.object({type:b.literal("analytics"),summary:b.string(),generatedFollowUpQuestions:b.unknown().transform(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r.trim()):[])}),Nh=b.object({type:b.literal("navigation"),summary:b.string(),suggested_link:b.unknown().optional().transform(e=>typeof e=="string"&&e?e:void 0),relevant_links:b.unknown().optional().transform(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r):[])});function Eh(e,r="Unexpected assistant response type."){throw new Error(`${r} Received: ${String(e)}`)}function du(e){let r=Oh.safeParse(e);if(!r.success)throw new Error("Assistant response must include type and summary fields.");let n=Zh.safeParse(r.data.type);if(!n.success)throw new Error("Assistant response type must be either analytics or navigation.");let o=n.data;switch(o){case"analytics":{let t=Dh.parse(e);return jp.parse({type:"analytics",summary:t.summary,generatedFollowUpQuestions:t.generatedFollowUpQuestions})}case"navigation":{let t=Nh.parse(e);return Tp.parse({type:"navigation",summary:t.summary,suggestedLink:t.suggested_link,relevantLinks:t.relevant_links})}default:return Eh(o)}}var Ah=["thinking","routing","running-analytic","running-navigation","summarizing","saving-state","completed","error"],Rh=["thinking","routing","running-analytic","running-navigation","summarizing","saving-state"];b.enum(Ah);var Zp=b.enum(Rh),Op=b.object({status:Zp,threadId:b.string()}),Lh=b.object({status:b.literal("completed"),threadId:b.string(),response:Up}),Ch=b.object({status:b.literal("error"),threadId:b.string(),errorCode:b.string(),message:b.string().nullable().optional()}),Dp=b.discriminatedUnion("status",[Lh,Ch,Op]);b.object({event:b.literal("runtime"),data:Dp});var Fh=b.object({kind:b.literal("progress"),status:Zp,payload:Op,threadId:b.string()}),Jh=b.object({kind:b.literal("complete"),status:b.literal("completed"),data:Up,threadId:b.string()}),wp=b.discriminatedUnion("kind",[Jh,Fh]),Vh=b.object({event:b.literal("runtime"),data:b.unknown()});function Mh(e){return e.replace(/\r\n?/gu,`
|
|
105
|
-
`)}function zp(e,r=!1){let n=
|
|
104
|
+
Please report this to https://github.com/markedjs/marked.`,e){let o="<p>An error occurred:</p><pre>"+oe(n.message+"",!0)+"</pre>";return r?Promise.resolve(o):o}if(r)return Promise.reject(n);throw n}}},Ze=new uh;function j(e,r){return Ze.parse(e,r)}j.options=j.setOptions=function(e){return Ze.setOptions(e),j.defaults=Ze.defaults,mp(j.defaults),j};j.getDefaults=eu;j.defaults=Oe;j.use=function(...e){return Ze.use(...e),j.defaults=Ze.defaults,mp(j.defaults),j};j.walkTokens=function(e,r){return Ze.walkTokens(e,r)};j.parseInline=Ze.parseInline;j.Parser=ee;j.parser=ee.parse;j.Renderer=Vn;j.TextRenderer=su;j.Lexer=H;j.lexer=H.lex;j.Tokenizer=Jn;j.Hooks=Gt;j.parse=j;var Ax=j.options,Rx=j.setOptions,Lx=j.use,Cx=j.walkTokens,Fx=j.parseInline;var Jx=ee.parse,Vx=H.lex;var lu="http://127.0.0.1:9015",mh=`${lu}/v1/turn/stream`;function fh(e){return`${lu}/v1/users/${encodeURIComponent(e)}/threads`}function gh(e){return`${lu}/v1/threads/${encodeURIComponent(e)}/messages`}var hh=["user","analytics","navigation","documentation","clarify","plan"],vh=b.object({threadId:b.string(),threadSummary:b.string(),lastActivityAt:b.string()}),$h=b.object({username:b.string(),threads:b.array(vh)}),xh=b.object({id:b.string(),type:b.enum(hh),content:b.string()}),_h=b.object({threadId:b.string(),threadSummary:b.string(),messages:b.array(xh)});async function bh(e,r){let n=await fetch(fh(e),{signal:r});if(!n.ok)throw new Error(`Thread list request failed with status ${n.status}.`);let o=$h.safeParse(await n.json());if(!o.success)throw new Error("Thread list response is invalid.");return o.data}async function Ip(e,r){let n=await fetch(gh(e),{signal:r});if(!n.ok)throw new Error(`Thread messages request failed with status ${n.status}.`);let o=await n.json(),t=_h.safeParse(o);if(!t.success)throw new Error("Thread messages response is invalid.");return t.data}function Pp(e){return e.type==="user"?{id:e.id,role:"user",content:e.content}:{id:e.id,role:"assistant",content:e.content,data:e.type==="navigation"?{type:"navigation",summary:e.content}:{type:"analytics",summary:e.content,generatedFollowUpQuestions:[]}}}async function yh(e){try{let r=(await bh(e.username)).threads,n=r[0]?.threadId;if(!n)return{result:null};let o=await Ip(n);return{result:{threads:r,firstThreadInfo:{threadId:n,messages:o.messages.map(Pp)}}}}catch(r){return console.error("Failed to initialize assistant thread state.",r),{error:{code:"unhandledError"}}}}var kh=Object.defineProperty,wh=Object.getOwnPropertyDescriptor,pt=(e,r,n,o)=>{for(var t=o>1?void 0:o?wh(r,n):r,i=e.length-1,a;i>=0;i--)(a=e[i])&&(t=(o?a(r,n,t):a(t))||t);return o&&t&&kh(r,n,t),t},ye=class extends lh{constructor(e){super(e),this.isLoading=!1,this.activeThreadId=null,this.messages=null,this.threads=[]}async load(){await this.initializeThreadMessages()}async initializeThreadMessages(){this.isLoading=!0;let e=await yh(this.user),{error:r,result:n}=e;if(r){console.error("Failed to initialize assistant threads.",r),this.isLoading=!1;return}if(!n){this.activeThreadId=null,this.threads=[],this.isLoading=!1;return}let{threads:o,firstThreadInfo:t}=n;this.threads=[...o].sort((i,a)=>new Date(a.lastActivityAt).getTime()-new Date(i.lastActivityAt).getTime()),this.activeThreadId=t.threadId,console.log("this.activeThreadId:",this.activeThreadId),this.messages=t.messages,this.isLoading=!1}async changeThread(e){if(!e){this.activeThreadId=null,this.messages=null;return}if(this.isLoading=!0,!this.threads.find(r=>r.threadId===e)){console.warn(`Thread with id ${e} not found.`),this.isLoading=!1;return}this.activeThreadId=e;try{let r=await Ip(e);this.messages=r?.messages.map(Pp)||null}catch(r){console.error(`Failed to fetch messages for thread ${e}.`,r),this.messages=null}finally{this.isLoading=!1}}setActiveThreadId(e){this.activeThreadId=e}addMessageToActiveThread(e){this.messages=[...this.messages||[],e]}};pt([qt()],ye.prototype,"user",2);pt([qt()],ye.prototype,"isLoading",2);pt([qt()],ye.prototype,"activeThreadId",2);pt([qt()],ye.prototype,"messages",2);pt([qt()],ye.prototype,"threads",2);ye=pt([dh("AiAssistantThreadController")],ye);function zh(e){if(!e)return"";try{return j.parse(e,{async:!1,breaks:!0})}catch{return e}}function Sh(e){if(e.data.type!=="navigation")return null;let r=e.data.relevantLinks||[];return!e.data.suggestedLink&&!r.length?null:J`<div class="msg-nav-links">${e.data.suggestedLink&&J`<div class="msg-link-row"><calcite-link .href=${e.data.suggestedLink} target=_blank icon-start=launch>${kp(e.data.suggestedLink,"Suggested")}</calcite-link></div>`||""}${r.length>0&&J`<ul class="msg-links-list">${Qn(r,n=>`${n}-${index}`,(n,o)=>J`<li><calcite-link .href=${n} target=_blank icon-start=launch>${kp(n,"Relevant")}</calcite-link></li>`)}</ul>`||""}</div>`}function Ih(e,r){if(e.data.type!=="analytics")return null;let n=e.data.generatedFollowUpQuestions||[];return!n.length||!r?null:J`<div class="msg-follow-ups">${Qn(n,o=>o,o=>J`<calcite-button appearance=outline-fill kind=brand round scale=s width=full @click=${()=>r(o)}>${o}</calcite-button>`)}</div>`}function Ph(e){let{message:r,user:n,onFollowUpQuestionClick:o}=e,t=r.role==="user",i=r.role==="assistant",a=r.content,c=zh(a);return J`<div class=${Yt({"bubble-row":!0,"bubble-row__user":t,"bubble-row__assistant":i})} role=listitem aria-label=${`${r.role} message`}><div class=${Yt(Xn("avatar",t&&"avatar__user",i&&"avatar__assistant"))}>${t?J`<calcite-avatar .username=${n.username??"User"} .thumbnail=${n.thumbnailUrl||void 0} .userId=${n.id} .fullName=${n.fullName||void 0}></calcite-avatar>`:J`<calcite-chip .icon=${i?"effects":"information-letter"} label appearance=outline-fill .kind=${i?"brand":"neutral"}></calcite-chip>`}</div><div class=${Yt(Xn("msg",t&&"msg__user",i&&"msg__assistant"))}><div class="msg-text">${hu(c)}</div>${i?Sh(r):null}${i?Ih(r,o):null}</div></div>`}function kp(e,r){try{let n=new URL(e);return r==="Suggested"?`${r}: ${n.hostname}`:n.hostname}catch{return r}}var jh=Gn`.bubble-row{display:flex;flex-direction:column;gap:.5rem}.bubble-row__user{flex-direction:row-reverse;padding-left:1.5rem}.avatar__user{align-self:flex-end}calcite-avatar{overflow:clip}.msg{display:flex;flex-direction:column;gap:.75rem}.msg-follow-ups{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:.5rem;width:100%;max-width:100%}.suggested-nav{display:flex;flex-direction:column;gap:.5rem}.suggested-nav>*{width:fit-content}.msg-text{word-break:break-word}.msg-text>p{margin:0}.msg__user{padding:.5rem .75rem;border-radius:16px 16px 0;background-color:var(--calcite-color-surface-highlight)}.action-results{display:flex;flex-direction:column;gap:.5rem}.action-results>p{margin:0}.action-results>ul{display:flex;flex-direction:column;gap:.5rem}`,Th=Gn`:host{border-width:1px;border-style:solid;border-color:var(--calcite-color-border-3);display:block;height:-moz-fit-content;height:fit-content;width:100%;--tw-shadow: 0 1px 6px -1px rgba(0, 0, 0, .16), 0 1px 2px -1px rgba(0, 0, 0, .08);--tw-shadow-colored: 0 1px 6px -1px var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}:host([expanded]){height:100%}.panel__body{display:flex;flex-direction:column;height:100%}.chat-container{overflow:auto;display:flex;flex-grow:1;padding-left:1.25rem;padding-right:1.25rem}.chat-container__inner{display:flex;flex-direction:column;gap:.75rem;width:100%;padding-top:1.25rem;padding-bottom:1.25rem}.thinking-container__header{position:relative;height:2rem;width:2rem}.loader{position:absolute;top:0;left:0;height:100%;width:100%;--calcite-loader-progress-color-inline: var(--calcite-color-brand)}.avatar__user{align-self:flex-end}calcite-avatar{overflow:clip}.thinking-container{display:flex;flex-direction:column;gap:.5rem;.thinking-text{animation:pulse 2s infinite ease-in-out}}@keyframes pulse{0%{opacity:.5}50%{opacity:1}to{opacity:.5}}.spacer{visibility:hidden;height:1.25rem;width:100%}.welcome-message{padding:1.75rem .75rem .75rem;display:flex;flex-direction:column;align-items:center;gap:1rem}.welcome{font-size:2rem;font-weight:500;margin:0}.welcome-text{font-size:1.25rem;font-weight:500;margin:0;text-align:center}@media(prefers-reduced-motion:reduce){.hit{transition:none}.chat{scroll-behavior:auto}}.dialog{--calcite-dialog-content-space: 0;--calcite-dialog-size-x: 1080px}.stage{height:100%;overflow:hidden;--tw-translate-x: 0px;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));background-color:var(--calcite-color-background)}@media screen and (min-width:1080px){.stage{height:min(700px,60vh)}}`;function Uh(e,r,n,o){let t=e?.id||"",i=ph.findCredential(e.url)?.token??"",a=window.location.origin||window.location.href.replace(/#.*$/u,""),c=r?.username||e?.user?.username||"";return{threadId:n,userMessage:o,portalId:t,token:i,tokenReferrer:a,username:c}}var Zh=b.enum(["analytics","navigation"]),jp=b.object({type:b.literal("analytics"),summary:b.string(),generatedFollowUpQuestions:b.array(b.string())}),Tp=b.object({type:b.literal("navigation"),summary:b.string(),suggestedLink:b.string().nullable().optional(),relevantLinks:b.array(b.string()).optional()}),Up=b.discriminatedUnion("type",[jp,Tp]),Oh=b.object({type:b.string(),summary:b.string()}),Dh=b.object({type:b.literal("analytics"),summary:b.string(),generatedFollowUpQuestions:b.unknown().transform(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r.trim()):[])}),Nh=b.object({type:b.literal("navigation"),summary:b.string(),suggested_link:b.unknown().optional().transform(e=>typeof e=="string"&&e?e:void 0),relevant_links:b.unknown().optional().transform(e=>Array.isArray(e)?e.filter(r=>typeof r=="string"&&!!r):[])});function Eh(e,r="Unexpected assistant response type."){throw new Error(`${r} Received: ${String(e)}`)}function du(e){let r=Oh.safeParse(e);if(!r.success)throw new Error("Assistant response must include type and summary fields.");let n=Zh.safeParse(r.data.type);if(!n.success)throw new Error("Assistant response type must be either analytics or navigation.");let o=n.data;switch(o){case"analytics":{let t=Dh.parse(e);return jp.parse({type:"analytics",summary:t.summary,generatedFollowUpQuestions:t.generatedFollowUpQuestions})}case"navigation":{let t=Nh.parse(e);return Tp.parse({type:"navigation",summary:t.summary,suggestedLink:t.suggested_link,relevantLinks:t.relevant_links})}default:return Eh(o)}}var Ah=["thinking","routing","running-analytic","running-navigation","summarizing","saving-state"],Zp=b.enum(Ah),Op=b.object({status:Zp,threadId:b.string()}),Rh=b.object({status:b.literal("completed"),threadId:b.string(),response:Up}),Lh=b.object({status:b.literal("error"),threadId:b.string(),errorCode:b.string(),message:b.string().nullable().optional()}),Dp=b.discriminatedUnion("status",[Rh,Lh,Op]);b.object({event:b.literal("runtime"),data:Dp});var Ch=b.object({kind:b.literal("progress"),status:Zp,payload:Op,threadId:b.string()}),Fh=b.object({kind:b.literal("complete"),status:b.literal("completed"),data:Up,threadId:b.string()}),wp=b.discriminatedUnion("kind",[Fh,Ch]),Jh=b.object({event:b.literal("runtime"),data:b.unknown()});function Vh(e){return e.replace(/\r\n?/gu,`
|
|
105
|
+
`)}function zp(e,r=!1){let n=Vh(e).split(`
|
|
106
106
|
|
|
107
|
-
`),o=r?"":n.pop()??"";return{blocks:n.map(t=>t.trim()).filter(Boolean),remainder:o}}function
|
|
107
|
+
`),o=r?"":n.pop()??"";return{blocks:n.map(t=>t.trim()).filter(Boolean),remainder:o}}function Mh(e){let r=Dp.safeParse(e);return r.success?r.data.status==="completed"?{...r.data,response:du(r.data.response)}:r.data:null}function Sp(e){let r=e.trim();if(!r)return null;let n="message",o=[];for(let c of r.split(`
|
|
108
108
|
`)){let u=c.trimEnd();if(!(!u||u.startsWith(":"))){if(u.startsWith("event:")){n=u.slice(6).trim();continue}u.startsWith("data:")&&o.push(u.slice(5).trimStart())}}if(n!=="runtime"||!o.length)return null;let t=JSON.parse(o.join(`
|
|
109
|
-
`)),i=
|
|
109
|
+
`)),i=Jh.safeParse(t),a=Mh(i.success?i.data.data:t);if(!a)throw new Error("Assistant stream event is invalid.");return{event:"runtime",data:a}}async function*Bh(e){let r=new TextDecoder,n="";for await(let o of e){n+=r.decode(o,{stream:!0});let t=zp(n);n=t.remainder;for(let i of t.blocks){let a=Sp(i);a&&(yield a)}}if(n+=r.decode(),n.trim()){let o=zp(n,!0);for(let t of o.blocks){let i=Sp(t);i&&(yield i)}}}function Gh(e){let r=e.data;if(r.status==="error")throw new Error(r.message??"Assistant stream reported an error.");return r.status==="completed"?wp.parse({kind:"complete",status:"completed",data:du(r.response),threadId:r.threadId}):wp.parse({kind:"progress",status:r.status,payload:r,threadId:r.threadId})}async function Wh({portal:e,user:r,userMessage:n,threadId:o,onStatus:t,signal:i}){try{let a=Uh(e,r,o,n),c=await fetch(mh,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:a.threadId,userMessage:a.userMessage,portalId:a.portalId,username:a.username,token:a.token,tokenReferrer:a.tokenReferrer}),signal:i});if(!c.ok)return console.error(`Assistant stream request failed with status ${c.status}.`),{error:{code:"unhandledError"}};if(!c.body)return console.error("Assistant stream response body is missing."),{error:{code:"unhandledError"}};let u,s=a.threadId;for await(let l of Bh(c.body)){let p=Gh(l);if(p.kind==="progress"){t?.(p.status,p.payload),p.threadId&&(s=p.threadId);continue}t?.(p.status,void 0),u=p.data,p.threadId&&(s=p.threadId)}return u===void 0?(console.error("Assistant stream ended without completed event data."),{error:{code:"unhandledError"}}):s?{result:{data:du(u),threadId:s}}:(console.error("Assistant response is missing threadId."),{error:{code:"unhandledError"}})}catch(a){return console.error("Failed to send message to assistant stream.",a),{error:{code:"unhandledError"}}}}var uu=class extends pu{constructor(){super(...arguments),this.t9n=gu({blocking:!0}),this.composerEl=qn(),this.chatAnchorEl=qn(),this.refocusInput=async()=>{await this.updateComplete,this.composerEl.value?.focusTextArea()},this.setPanelAttribute=()=>{this.isPanelExpanded?this.el.setAttribute("expanded",String(this.isPanelExpanded)):this.el.removeAttribute("expanded")},this.togglePanel=()=>{let r=!this.isPanelExpanded;this.isPanelExpanded=r,this.arcgisAiAssistantPanelToggle.emit(r),this.setPanelAttribute()},this.getStatusLabel=r=>{let{t9n:{status:n}}=this;switch(r){case"thinking":return n.thinking;case"routing":return n.routing;case"running-analytic":return n.runningAnalytic;case"running-navigation":return n.runningNavigation;case"summarizing":return n.summarizing;case"saving-state":return n.savingState;case"completed":return n.completed;case"error":return this.t9n.streamErrorOccurred;default:return n.waitingForResponse}},this.onSend=async r=>{let{threadController:n}=this,o=r.trim();if(!o||this.isSending||!n)return;await this.composerEl.value?.stopListening(),this.arcgisInputSend.emit({text:o}),n.addMessageToActiveThread({id:Qt(),role:"user",content:o}),this.scrollToBottom(),this.isSending=!0,this.isThinking=!0,this.streamStatus=this.t9n.status.waitingForResponse;let{portal:t,user:i}=this,a=await Wh({portal:t,user:i,userMessage:o,threadId:n.activeThreadId||void 0,onStatus:s=>{this.streamStatus=this.getStatusLabel(s)}}),{error:c,result:u}=a;c||!u?(console.error(this.t9n.errorSendingTurn,c),n.addMessageToActiveThread({id:Qt(),role:"system",content:this.t9n.somethingWentWrong})):(n.setActiveThreadId(u.threadId),n.addMessageToActiveThread({id:Qt(),role:"assistant",content:u.data.summary,data:u.data})),this.scrollToBottom(),this.isSending=!1,this.isThinking=!1,this.streamStatus=null,this.refocusInput()},this.initializeThreadModel=async()=>{let r=new ye({user:this.user});await r.load(),this.threadController=r},this.threadController=null,this.isSending=!1,this.isThinking=!1,this.streamStatus=null,this.isPanelExpanded=!1,this.isSidePanelOpen=!1,this.autoDestroyDisabled=!1,this.defaultClosed=!1,this.openEntitiesInNewTab=!1,this.arcgisAiAssistantPanelToggle=Wn(),this.arcgisInputSend=Wn()}static{this.properties={threadController:16,isSending:16,isThinking:16,streamStatus:16,isPanelExpanded:16,isSidePanelOpen:16,autoDestroyDisabled:5,portal:0,user:0,config:0,defaultClosed:5,openEntitiesInNewTab:5}}static{this.styles=[Th,jh]}connectedCallback(){super.connectedCallback(),this.isPanelExpanded=!this.defaultClosed}async load(){this.setPanelAttribute()}willUpdate(r){r.has("user")&&this.initializeThreadModel()}scrollToBottom(r=!0){let n=this.chatAnchorEl.value;n&&this.updateComplete.then(()=>{n.scrollIntoView({behavior:r?"smooth":"auto",block:"end"})})}renderWelcomeMessage(){let{t9n:r}=this;return J`<div class="welcome-message"><p class="welcome">${r.welcome}</p><calcite-chip appearance=solid kind=inverse icon=effects .label=${r.welcome}></calcite-chip><p class="welcome-text">${r.welcomeText}</p></div>`}render(){let{isPanelExpanded:r,threadController:n,isThinking:o,streamStatus:t,t9n:i,isSidePanelOpen:a}=this,c=n?.messages;return J`<calcite-panel icon=effects collapsible .collapsed=${!r} collapse-direction=up .heading=${i.heading} @calcitePanelToggle=${this.togglePanel}><calcite-button slot=header-actions-start .iconStart=${a?"x":"hamburger"} appearance=transparent kind=neutral .label=${i.openPanel} @click=${()=>this.isSidePanelOpen=!this.isSidePanelOpen}></calcite-button>${a&&J`<calcite-scrim style=${mu({"--calcite-scrim-background":"rgba(0, 0, 0, 0.5)"})} @click=${()=>this.isSidePanelOpen=!1}></calcite-scrim><arcgis-portal-ai-assistant-side-panel .threads=${n?.threads||[]} .activeThreadId=${n?.activeThreadId??null} .t9n=${i} @arcgisThreadSelect=${async({detail:{threadId:u}})=>{await this.threadController?.changeThread(u),this.isSidePanelOpen=!1,this.scrollToBottom(!1)}} @arcgisSidePanelClose=${()=>this.isSidePanelOpen=!1}></arcgis-portal-ai-assistant-side-panel>`||""}<div class="panel__body"><div class="chat-container"><div class="chat-container__inner">${c?.length?c.map(u=>Ph({message:u,user:this.user,onFollowUpQuestionClick:this.onSend})):this.renderWelcomeMessage()}${o&&J`<div class="thinking-container"><div class="thinking-container__header"><calcite-loader .label=${t??i.status.waitingForResponse} inline scale=l class="loader"></calcite-loader><calcite-chip icon=effects .label=${i.status.thinking} appearance=outline kind=neutral></calcite-chip></div><div class="thinking-text">${t}</div></div>`||""}<div class="spacer" ${Kn(this.chatAnchorEl)}></div></div></div><div slot=footer><arcgis-portal-ai-assistant-composer .portal=${this.portal} .user=${this.user} .t9n=${this.t9n} .isLoading=${this.isSending||n?.isLoading} @arcgisInputSend=${({detail:u})=>{this.onSend(u.text)}} ${Kn(this.composerEl)}></arcgis-portal-ai-assistant-composer></div></div></calcite-panel>`}};fu("arcgis-portal-ai-assistant",uu);return uu},"core/Accessor","core/accessorSupport/decorators","identity/IdentityManager")
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import a from"./UXUVTFIJ.js";import"./S2PHM4WZ.js";import{a as I}from"./MUGCPKN6.js";import{a as y}from"./UNK7CMDL.js";import"./KKLD7GP6.js";import{I as u,J as h,K as f,N as g,Q as v,R as b,i as m,k as l,v as d}from"./3XZ4NJNW.js";export default $arcgis.t(([k,{i:w}])=>{var C=m`.thumbnail-container{width:100%}.replacement-container{margin:.5rem}.replacement-message{margin-bottom:.5rem}.replacement-card__title{margin-bottom:.25rem}`,M=["3DInsetMap","3DScene","3DViz","AttachmentViewer","CapacityAnalysis","Cascade","Compare","Compare/Configure","Compare/Multiviewer","Compare/Search","Compare/SideBySideViewer_Configure","Compare/storytelling_compare","Compare/storytelling_sidepanel","Compare/storytelling_tabbed","Compare3d","CompareAnalysis","CompareMaps","CrowdsourceManager","CrowdsourcePolling","CrowdsourceReporter","Directions","Edit","Editor","Elevations","ElevationsProfile","Embed","Filter","FilterGallery","GeoForm","GeoList","GeoTour","HeaderFooter","Identify","ImageInterpretation","ImageMask","ImageVisit","ImageryViewer","ImpactSummary","InformationLookup","InteractiveFilter","InteractiveLegend","LayerShowcase","Legend","LiveMaps","LocalPerspective","MapAndAppGallery","MapCarousel","MapJournal","MapSeries","Shortlist","MapTools","MapTour","Media","MinimalGallery","Minimalist","MobileViewer","Nearby","OnePane","Panels","PanelsLegend","Profile","PublicGallery","PublicInformation","ServiceLookup","SimpleMapViewer","SimpleViewer","SocialMedia","Solutions/s2.html?app=apps2/FindEditFilter","Solutions/s2.html?app=apps2/Finder","Solutions/s2.html","StoryMapBasic","StorytellingSwipe","StorytellingTextLegend","Styler","SummaryViewer","Time","TimeAware","TwoPane","View","Viewer","ZoneLookup"],S=i=>{if(!i)return!1;let e=M.some(t=>{let a=t.includes(".html"),r=`/apps/${t}${a?"":"/"}`;return decodeURIComponent(i.url)?.includes(r)});return i.type==="Web Mapping Application"&&!!i.url&&e};function T(i){let e=["Cascade","MapTour","MapJournal","MapSeries","Shortlist","StoryMapCrowdsource","SwipeSpyglass","Story Map"];return i.type==="Web Mapping Application"&&(P(e,i)||A(i))}function A(i){return["Cascade","MapTour","MapJournal","MapSeries","Shortlist","StoryMapCrowdsource","StorytellingSwipe"].some(e=>{let t=`/apps/${e}/index.html`;return decodeURIComponent(i.url)?.includes(t)})}function P(i,e){return i?.some(t=>e?.typeKeywords?.includes(t))}function $(i){let e=x(i);return b(`assets/portal-item-thumbnail/${e}`)}function x(i){let e=i.type?.toLowerCase(),t=i.typeKeywords||[];switch(e){case"web mapping application":return"webapp.avif";case"mobile application":return"mobileapp.avif";case"notebook code snippets":case"notebook code snippet library":return"notebookcodesnippets.avif";case"notebook":return"notebook.avif";case"style":return t.includes("Dictionary")?"dictionarystyle.avif":"style.avif";case"feature service":return t.includes("Location Tracking View")?"locationtrackingservice.avif":t.includes("IndoorPositioningDataService")?"indoor-positioning-data-service.avif":"default.avif";case"pro presentation":return"pro-presentation.avif";case"reality mapping project":return"realitymappingproject.avif";case"raster function template":return"rasterfunctiontemplate.avif";case"workforce project":return"workforceproject.avif";case"hub initiative":return"hubinitiative.avif";case"hub page":return"hubpage.avif";case"hub site application":case"site application":return"hubsite.avif";case"hub event":return"hubevent.avif";case"hub project":return"hubproject.avif";case"dashboard":return t.includes("ArcGIS Dashboards")?"dashboards.avif":"opsdashboard.avif";case"geoprocessing service":return t.includes("Notebook Web Tool")?"notebookwebtool.avif":"webtool.avif";case"web scene":case"scene service":return"scene.avif";case"ortho mapping project":return"orthomappingproject.avif";case"ortho mapping template":return"orthomappingtemplate.avif";case"insights theme":return"insightstheme.avif";case"insights workbook package":return"insightsworkbookpackage.avif";case"solution":return"solution.avif";case"mobile scene package":return"mobilescenepackage.avif";case"deep learning package":return"deeplearningpackage.avif";case"big data analytic":return"bigdataanalytic.avif";case"real time analytic":return"realtimeanalytic.avif";case"feed":return"feed.avif";case"excalibur imagery project":return"excaliburimageryproject.avif";case"storymap":return t?.includes("storymapcollection")?"storymapcollection.avif":"storymap.avif";case"survey123 add in":return"survey123addin.avif";case"mission":return"mission.avif";case"mission template":return"missiontemplate.avif";case"quickcapture project":return"quickcaptureproject.avif";case"pro report":return"proreport.avif";case"pro package":return"propackage.avif";case"pro report template":return"proreporttemplate.avif";case"urban model":return"urbanmodel.avif";case"urban project":return"urbanproject.avif";case"web experience":return"webexperience.avif";case"web experience template":return"webexperiencetemplate.avif";case"experience builder widget":return"experiencebuilderwidget.avif";case"experience builder widget package":return"experiencebuilderwidgetpackage.avif";case"workflow":return"workflow.avif";case"insights script":return"insightsscript.avif";case"kernel gateway connection":return"kernelgatewayconnection.avif";case"hub initiative template":return"hubinitiativetemplate.avif";case"image service":return t?.includes("Tile Imagery")?"tiledimagerylayer.avif":"imagerylayer.avif";case"mission report":return"missionreport.avif";case"administrative report":return"administrativereport.avif";case"storymap theme":return"storymaptheme.avif";case"knowledge graph":return"knowledgegraph.avif";case"knowledge graph layer":return"knowledgegraphlayer.avif";case"knowledge studio project":return"knowledgestudio.avif";case"earth configuration":return"earthconfiguration.avif";case"link chart":return"linkchart.avif";case"investigation":return"investigation.avif";case"apache parquet":return"apacheparquet.avif";case"curated collection":return"curatedcollection.avif";case"video service":return"mediaservice.avif";case"geodata service":return"geodataservice.avif";case"suitability model":return"suitabilitymodel.avif";case"esri classifier definition":return"classifierdefinition.avif";case"esri spectral library":return"spectrallibrary.avif";case"deep learning studio project":return"deeplearningstudioproject.avif";case"esri classification schema":return"classificationschema.avif";case"insights data engineering workbook":return"dataengineeringworkbook.avif";case"insights data engineering model":return"dataengineeringmodel.avif";case"discussion":return"discussion.avif";case"api key":return"apikey.avif";case"data pipeline":return"datapipeline.avif";case"analysis model":return"analysismodel.avif";case"service connection":return"serviceconnection.avif";case"xr experience":return"xrexperience.avif";case"3dtiles service":return t?.includes("GaussianSplat")?"gaussiansplatlayer.avif":"default.avif";default:return"default.avif"}}function U(i,e,t){let{restUrl:a}=i,r=j(i),n=r?`token=${r}`:"",c=`${a}/content/items/${e.id}`;if(e.thumbnail){let o=e.thumbnailUrl;if(o){let s=new URL(o);return s.searchParams.append("w","400"),s.href}return`${c}/info/${e.thumbnail}?w=400${r?"&":""}${n}`}else if(e.type==="Image")return`${c}/data?${n}`;return $(e)}function j(i){return i?.credential?.token||i?.token||i?.user?.credential?.token||i?.portalUser?.token||""}function L({portal:i,usePortalHostname:e}){let{customBaseUrl:t,portalHostname:a,urlKey:r}=i,{protocol:n}=window.location,c=!e&&r?`${r}.${t}`:a;return`${n}//${c}`}var R=5e3,p=class extends f{constructor(){super(...arguments),this.replacementId=null,this.replacementItemInRecycleBin=!1,this.hasInaccessibleReplacementItem=!1,this.thumbnailUrl=null,this.timer=void 0,this.t9n=y({blocking:!0}),this.primaryActionRef=u(),this.getItemDetailsUrl=({portal:e,itemId:t,redirect:a})=>{let r=L({portal:e,usePortalHostname:!this.user});return r?`${`${r}/home`}/item.html?id=${t}${a?"&performRedirectAction=true":""}`:""},this.performRedirectAction=()=>{window.open(this.getItemDetailsUrl({portal:this.portal,itemId:this.replacementId,redirect:!0}),"_self")},this.viewItemDetailsPage=()=>{window.open(this.getItemDetailsUrl({portal:this.portal,itemId:this.replacementId??this.itemId}),this.canRedirect?"_self":"_blank")},this.item=null,this.replacementItem=null,this.redirectAction=null,this.canRedirect=!1,this.redirectCancelled=!1,this.open=!1,this.redirectTimeRemaining=R/1e3,this.arcgisPortalReplacementItemFetch=d()}static{this.properties={item:16,replacementItem:16,redirectAction:16,canRedirect:16,redirectCancelled:16,open:16,redirectTimeRemaining:16,itemId:1,portal:0,user:0}}static{this.styles=C}async setFocus(){this.primaryActionRef.value?.setFocus()}willUpdate(e){(e.has("itemId")||e.has("portal")||e.has("user"))&&(this.user??=this.portal?.user??null,this.initItem())}setupTimer({onComplete:e}){typeof this.timer=="number"&&clearInterval(this.timer),this.redirectTimeRemaining=R/1e3,this.timer=setInterval(()=>{if(this.redirectTimeRemaining<=0){clearInterval(this.timer),this.timer=void 0,e();return}this.redirectTimeRemaining-=1},1e3)}cancelTimer({onCancel:e}={}){e?.(),clearInterval(this.timer)}handleClose(){this.cancelTimer(),this.itemId="",this.item=null,this.open=!1}cancelRedirect(){this.cancelTimer(),this.redirectCancelled=!0}isItemRetired(e){return S(e)||T(e)}async initItem(){if(!this.itemId)return;let{itemId:e,portal:t,performRedirectAction:a}=this,r=new k({id:e,portal:t});this.item=await r?.load();let n=await w(e,t,{relationshipType:"ReplacementItem2Item",direction:"reverse"},!0),c=n.data?.relatedItems?.[0];this.replacementItemInRecycleBin=c?.inRecycleBin;let o=c?.id,s=!this.replacementItemInRecycleBin&&o?new k({id:o,portal:t}):null;await s?.load(),this.replacementItem=s,this.hasInaccessibleReplacementItem=this.replacementItemInRecycleBin||!s&&n.data?.aggregations?.total?.count>0&&n.data?.relatedItems?.length===0,this.arcgisPortalReplacementItemFetch.emit({replacementItem:this.hasInaccessibleReplacementItem?{}:s||null}),this.replacementItem=s,this.thumbnailUrl=U(t,s??this.item),this.canRedirect=!!s&&this.isItemRetired(r),this.replacementId=s?.id||null,this.canRedirect&&this.setupTimer({onComplete:()=>a()}),this.open=!0}getReplacementHeading(){let{t9n:e,hasInaccessibleReplacementItem:t,canRedirect:a}=this;return t?e.replacementUnavailable:a?e.redirectToReplacement:this.isItemRetired(this.item)&&!this.replacementItem?e.retiredTitle:e.replacementAvailable}getReplacementMessage(){let{t9n:e,hasInaccessibleReplacementItem:t,canRedirect:a}=this;return t?e.retiredReplacementUnavailable:a?e.deprecatedHasReplacement:this.isItemRetired(this.item)&&!this.replacementItem?e.retired:e.deprecatedHasReplacement}getRedirectActionMessage(){let{t9n:e,canRedirect:t,redirectTimeRemaining:a,redirectCancelled:r}=this;return r?e.redirectToReplacement:t?e.redirect.replace("${seconds}",`${a}`):e.moreDetails}renderCard(e){let{canRedirect:t,t9n:a}=this;return l`<calcite-card thumbnail-position=inline-start><img slot=thumbnail class="thumbnail" src=${(this.thumbnailUrl||void 0)??g} @error=${async()=>this.thumbnailUrl=$(e)}><span slot=heading class="replacement-card__title">${e.title}</span><span slot=description>${a.ownedBy?.replace("${owner}",e.owner||"")||""}</span>${t&&l`<calcite-link slot=footer-start icon-end=launch icon-flip-rtl=end .href=${this.getItemDetailsUrl({portal:this.portal,itemId:this.replacementId})} target=_blank>${a.moreDetails}</calcite-link>`||""}</calcite-card>`}render(){let{open:e,t9n:t,item:a,replacementItem:r,canRedirect:n,redirectCancelled:c}=this;if(!(!a||!this.isItemRetired(a)))return l`<calcite-dialog modal .open=${e} width=s kind=info outside-close-disabled escape-disabled close-disabled .heading=${this.getReplacementHeading()} @calciteDialogClose=${()=>this.handleClose()}><div class="replacement-container"><div class="replacement-message">${I(this.getReplacementMessage()?.replace("${itemTitle}",this.item?.title||""))}</div>${this.renderCard(n?r:a)}</div>${n&&!c&&l`<calcite-button slot=footer-end appearance=outline-fill kind=neutral @click=${()=>{this.cancelRedirect()}}>${t.cancelRedirection}</calcite-button>`||""}<calcite-button slot=footer-end @click=${()=>{this.cancelTimer(),n?this.performRedirectAction():this.viewItemDetailsPage()}} .iconEnd=${n?void 0:"launch"} icon-flip-rtl=end ${h(this.primaryActionRef)}>${this.getRedirectActionMessage()}</calcite-button></calcite-dialog>`}};v("arcgis-portal-replacement-item-redirect",p);return p},"portal/PortalItem",a)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import a from"./UXUVTFIJ.js";import{a as T}from"./S2PHM4WZ.js";import{b as W}from"./VAQDGK3W.js";import{a as q}from"./UNK7CMDL.js";import"./KKLD7GP6.js";import{I as C,J as P,K as J,O as A,Q as B,i as R,k as y,o as N,q as S,r as j,v as E}from"./3XZ4NJNW.js";export default $arcgis.t(([le,Ie,ve,Fe,x,de,I,pe,fe,L,Z,$,ee,{a:G,b:z,c:V,d:U,e:_,f:H,g:K,h:Q,i:X,j:Y}])=>{var k=(i=>(i.expression="expression/",i))(k||{});function F(i){return i!=null}function te(i,e,t){let s=e.fieldName;if(s.includes(k.expression)){let r=t.get(s);return r?.title?r.title:s}else return ee.supportsFieldConfiguration(i)&&i.getFieldConfiguration(s)?i.getFieldAlias(s)||s:e.label||s}function se(i,e,t){let s="";if(/^raster.(?:item|service)pixelvalue/iu.test(i))s="number";else if(e.has(i)){let r=e.get(i);s=r.type?r.type.toLowerCase():""}else if(t.has(i)){let r=t.get(i);s=r.returnType?r.returnType.toLowerCase():""}else s="number";return s}async function ie(i){return new Map((await me(i)).filter(e=>e.visible).map(e=>[e.name,e]))}function re(i){let e=new Map;return i?.expressionInfos&&i.expressionInfos.forEach(t=>{let s=`${k.expression}${t.name}`;e.set(s,t)}),e}async function me(i){return await new Promise((e,t)=>{switch(i.type){case"feature":case"ogc-feature":case"stream":e(i.fields);break;case"sublayer":{let s=i,r=s?.layer;r?.portalItem&&r.url.includes("https://demographics")&&r.url.includes(".arcgis.com")?r.portalItem?.fetchData().then(a=>{if(a?.thematicGroup){let o=new Map(s.fields.map(n=>[n.name,n])),c=a.thematicGroup.fieldNames,p=[];c.forEach(n=>{o.has(n)&&p.push(o.get(n))}),e(p)}else e(s.fields)}).catch(a=>{t(new Error(a))}):e(s.fields);break}case"imagery":case"imagery-tile":case"wcs":e(i.rasterFields);break;default:e("fields"in i?i.fields??[]:[])}})}function d(i,e){return!i||!e?!1:i.toLocaleLowerCase()===e.toLocaleLowerCase()}async function ae(i,e,t,s){if(!t)return!1;let r=["feature","oriented-imagery"].includes(e.type),a=s?.item??e.portalItem,o=e.sourceJSON;if(!r||!a||!a.portal.user||!U(a)||V(a)||_(a)||H(o)||a.portal.isPortal&&z(a)||["oid","global-id","geometry"].includes(t.type)||await ue(e,t.name,s))return!1;let c=e.sourceJSON.geometryProperties,p=c?.shapeLengthFieldName,n=c?.shapeAreaFieldName;if(d(p,t.name)||d(n,t.name))return!1;let l=e.editFieldsInfo;if(l&&(d(l.creationDateField,t.name)||d(l.creatorField,t.name)||d(l.editDateField,t.name)||d(l.editorField,t.name))||d(e.objectIdField,t.name)||d(e.displayField,t.name)||d(e.typeIdField,t.name)||d(e.subtypeField,t.name)||e.timeInfo&&(d(e.timeInfo.startField,t.name)||d(e.timeInfo.endField,t.name)||d(e.timeInfo.trackIdField,t.name)))return!1;if(!s?.ignoreLayerRenderer&&e.featureReduction){let f=new Set;if(await I.collectFeatureReductionFields(f,e,e.featureReduction),Array.from(f).some(b=>d(b,t.name)))return!1}if(!s?.ignoreLayerRenderer&&(await I.getRendererFields(e.renderer,e.fieldsIndex)).some(f=>d(f,t.name)))return!1;if(!s?.ignoreLayerLabelingInfo){let f=e.labelingInfo?.map(b=>b.labelExpressionInfo?.expression);if(f&&((await I.getExpressionFields(e,f)).some(b=>d(b,t.name))||await oe(e,t,"layer")))return!1}if(!s?.ignoreLayerDefinitionExpression&&e.definitionExpression&&(await $.parseWhereClause(e.definitionExpression,e.fieldsIndex)).fieldNames.some(f=>d(f,t.name))||await ge(e,t,s)||await ye(e,t))return!1;if(await be(e,t))return await Promise.resolve(!1);if(await we(e,t))return await Promise.resolve(!1);if(he(i,e,t)||e.relationships?.map(f=>f.keyField)?.some(f=>d(f,t.name)))return!1;let u=G(a,a.portal.user),v=s?.userItemInfo?.userGroups??await K(e)??[],g=s?.userItemInfo?.itemGroups??await Q(e)??[],w=Y(v,g);if(!u&&!w)return!1;let m=s?.userItemInfo?.relatedItems??await X(a.id,a.portal,{relationshipType:"Service2Service"});return!(m?.data?.relatedItems&&m.data.relatedItems.some(f=>["WMTS","Map Service","Vector Tile Service"].includes(f.type)))}async function ue(i,e,t){let s=`${i.url}/${i.layerId}/fieldGroups`;try{let r=t?.userItemInfo&&"fieldGroups"in t.userItemInfo?t.userItemInfo.fieldGroups:(await Z(s,{query:{f:"json"},responseType:"json"}))?.data?.fieldGroups;return r?r.some(a=>a.fields.some(o=>d(o,e))):!1}catch{return!1}}function he(i,e,t){if(!i)return!1;let s=i.map?.applicationProperties?.viewing?.search;if(s){let r=s.layers?.find(a=>a.id===e.id);if(r){let a=r?.field?.name;if(a)return d(a,t.name)}}return!1}async function oe(i,e,t){let s=t==="layer"?i.labelingInfo?.filter(o=>F(o.where)):i.sourceJSON?.drawingInfo?.labelingInfo?.filter(o=>F(o.where));if(!s?.length)return!1;let r=[...await Promise.all(s.map(async o=>await $.parseWhereClause(o.where,i.fieldsIndex)))],a=!1;for(let o=0;o<r.length;o++){let c=r[o].fieldNames?.some(p=>d(p,e.name));if(!a&&c){a=!0;break}}return await Promise.resolve(a)}async function ge(i,e,t){let s=i.portalItem;if(!s)return!1;let r=`${T(s.portal)}content/items/${s.id}/data`,a=(t?.userItemInfo?.itemData??await Z(r,{query:{f:"json"},responseType:"json"}))?.data;if(!a)return!1;if(a?.layers){let o=a.layers.find(l=>l.id===i.layerId),c=o?.layerDefinition?.drawingInfo?.renderer,p=o?.layerDefinition?.featureReduction,n=o?.layerDefinition?.definitionExpression;if(!c&&!p&&!n)return!1;if(!t?.ignoreItemRenderer&&c){let l=L.fromJSON(c);if((await I.getRendererFields(l,i.fieldsIndex)).some(u=>d(u,e.name)))return!0}if(!t?.ignoreItemFeatureReduction&&p&&await ne(i,e,p)||n&&(await $.parseWhereClause(n,i.fieldsIndex)).fieldNames.some(l=>d(l,e.name)))return!0}return!1}async function ye(i,e){let t=i.sourceJSON,s=t?.drawingInfo?.renderer,r=t?.featureReduction;if(!s&&!r)return!1;if(s){let a=L.fromJSON(s);if((await I.getRendererFields(a,i.fieldsIndex)).some(o=>d(o,e.name)))return!0}return!!(r&&await ne(i,e,r))}async function be(i,e){let t=i.sourceJSON?.drawingInfo?.labelingInfo;if(!t)return await Promise.resolve(!1);let s=t?.map(r=>r.labelExpressionInfo?.expression);if(s){if((await I.getExpressionFields(i,s)).some(r=>d(r,e.name)))return await Promise.resolve(!0);if(await oe(i,e,"service"))return await Promise.resolve(!0)}return await Promise.resolve(!1)}async function we(i,e){let t=i.sourceJSON?.definitionQuery;return t?(await $.parseWhereClause(t,i.fieldsIndex)).fieldNames.some(s=>d(s,e.name))?await Promise.resolve(!0):await Promise.resolve(!1):await Promise.resolve(!1)}async function ne(i,e,t){let s=t.type==="binning"?pe.fromJSON(t):fe.fromJSON(t),r=new Set;return await I.collectFeatureReductionFields(r,i,s),!!Array.from(r).some(a=>d(a,e.name))}var h=new Map;h.set("oid","key");h.set("guid","key");h.set("global-id","key");h.set("blob","binary");h.set("integer","integer");h.set("small-integer","integer");h.set("big-integer","integer");h.set("single","number");h.set("double","number");h.set("long","number");h.set("number","number");h.set("date","date-time");h.set("date-only","calendar");h.set("time-only","clock");h.set("timestamp-offset","time-zone");h.set("string","string");var Ne=({fieldType:i})=>y`<calcite-icon scale=s .icon=${h.get(i)}></calcite-icon>`,Ee=R`.dialog{--calcite-dialog-max-size-y: 60%}.dialog-content-wrapper{position:relative;min-height:100px}.hide-overflow{overflow:hidden}.field-icons{padding:0 var(--calcite-spacing-lg);display:flex;align-items:center}.warning{border-bottom:var(--calcite-border-width-sm) solid var(--calcite-color-border-3);margin-bottom:var(--calcite-spacing-md)}.warning-message{font-size:var(--calcite-font-size--1);font-weight:var(--calcite-font-weight-bold)}.loader-container{position:absolute;height:100%;width:100%;top:0;right:0;display:none;z-index:40;overflow:hidden;background:#fffffff2;padding:0}.active{display:flex;flex-direction:column;align-items:center;justify-content:center}.loader{padding:0}.loader-text{font-weight:var(--calcite-font-weight-medium);text-align:center;margin-right:6.25rem;margin-left:6.25rem}`,O=class extends J{constructor(){super(...arguments),this.arcadeExpMap=new Map,this.cancelNode=C(),this.dialogNode=C(),this.layerFields=[],this.layerFieldsMap=new Map,this.messages=q({blocking:!0}),this.deleteInProgress=!1,this.fieldsAreDeletable=!1,this._propWatcherTask=new W(this,{task:async([e,t])=>{let s=F(e)&&F(t);if(F(e)||N("error",this,S("layer")),F(t)||N("error",this,S("fieldNames")),!s)throw new Error("Required properties are missing");this._propWatcherTask.autoRun=!1,await this.processProps()},args:()=>[this.layer,this.fieldNames]}),this.arcgisBeforeModalClose=E(),this.arcgisClose=E(),this.arcgisBeforeDelete=E(),this.arcgisFieldsDeleted=E()}static{this.properties={config:0,fieldNames:0,layer:0,mapView:0,options:0}}static{this.styles=Ee}async processProps(){let{layer:e,mapView:t,fieldNames:s}=this;if(!e||!s){this.fieldsAreDeletable=!1;return}e.loaded||await e.load(),this.layerFields=e.fields.filter(a=>s.includes(a.name));let r=s.some(a=>!e.fields.find(o=>o.name===a));if(!this.layerFields?.length||r)this.fieldsAreDeletable=!1;else{let a=await Promise.all(this.layerFields.map(async o=>await ae(t,e,o,this.options)));if(this.fieldsAreDeletable=a.every(o=>o),!this.fieldsAreDeletable)return}if(this.layerFieldsMap=await ie(e),this.options?.ignorePopupTemplate||(this.arcadeExpMap=re(e.popupTemplate)),this.portal=e.portalItem?.portal??this.options?.portal,this.item=e.portalItem??this.options?.item,!this.item){this.fieldsAreDeletable=!1;return}await Fe.getCredential(this.item.url.replace("rest/services","rest/admin/services"))}getFieldLabel(e){let{layer:t,arcadeExpMap:s}=this;if(this.options?.ignorePopupTemplate)return this.getFieldDisplayNameFromLayerFields(e);{let r=(t.popupTemplate??t.createPopupTemplate()).fieldInfos?.find(a=>a.fieldName===e);return r?te(t,r,s):this.getFieldDisplayNameFromLayerFields(e)}}getFieldDisplayNameFromLayerFields(e){let{layer:t}=this,s=this.layerFieldsMap.get(e);return de.supportsFieldConfiguration(t)?t.getFieldAlias(e):s.alias??s.name}async deleteFields(){let{layer:e,fieldNames:t}=this,s=`${e.url.replace("/rest/services","/rest/admin/services")}/${e.layerId}/deleteFromDefinition`,r={fields:t.map(o=>({name:o}))},a={deleteFromDefinition:JSON.stringify(r)};await x(s,{query:{...a,f:"json",async:!1},method:"post",responseType:"json"}).then(async o=>{if(o.data?.success){let c=`${e.url}/${e.layerId}`;t.forEach(n=>{e.type==="feature"&&e.floorInfo?.floorField===n&&(e.floorInfo=null)});let p=await x(c,{query:{f:"json"},responseType:"json"});if(p){let n=p.data;this.currentLayerInfo=p.data,n&&(this.updateTypesAndTemplatesOnLayer(),t.forEach(l=>{n.templates?.length?n.templates.forEach(u=>delete u.prototype.attributes[l]):n.types?.forEach(u=>{u.templates.forEach(v=>delete v.prototype.attributes[l])})}),this.updateFeatureService(n))}else this.handleError()}},()=>this.handleError())}updateTypesAndTemplatesOnLayer(){let{currentLayerInfo:e}=this,t=e;if(t.templates?.length){let s=this.updateTemplatesList(t.templates);t.templates=s}else if(t.types){let s=t.types;t.types=[],s.forEach(r=>{r.templates=this.updateTemplatesList(r.templates),this.addType(t,r)})}}updateTemplatesList(e){let{currentLayerInfo:t,messages:s}=this,r=[];return(e??[]).forEach(a=>{let o=new Ie;o.description=a.description??"",o.name=a.name||s.newFeature,o.drawingTool=a.drawingTool||"point";let c={};t.fields.forEach(n=>{let l=!1;for(let u=0;u<a.prototype.attributes.length;u++)if(a.prototype.attributes[u]===n.name){l=!0,c[n.name]=a.prototype.attributes[n.name];break}!l&&n.editable&&(c[n.name]=n.defaultValue||null)});let p=new ve({attributes:c});o.prototype=p,r.push(o)}),r}addType(e,t){e.types?e.types.some(s=>s.id===t.id)||e.types.push(t):e.types=[t]}async updateFeatureService(e){let{layer:t,fieldNames:s}=this,r={templates:e.templates,types:e.types},a=`${t.url.replace("/rest/services","/rest/admin/services")}/${t.layerId}/updateDefinition`,o={f:"json",updateDefinition:JSON.stringify(r)};await x(a,{query:{...o,f:"json"},method:"post",responseType:"json"}).then(async c=>{if(c.data?.success){let p=`${T(this.portal)}content/items/${this.item.id}/data`;if(this.options?.ignorePopupTemplate||s.forEach(n=>{t.popupTemplate?.fieldInfos&&(t.popupTemplate.fieldInfos=t.popupTemplate.fieldInfos.filter(l=>l.fieldName!==n)),t.popupTemplate?.content?.forEach((l,u)=>{l.type==="fields"&&l.fieldInfos&&((t.popupTemplate?.content)[u].fieldInfos=(t.popupTemplate?.content)[u].fieldInfos?.filter(v=>v.fieldName!==n))})}),t.attributeTableTemplate){let n=t.attributeTableTemplate.clone();n.elements=n.elements.filter(l=>!(l.type==="field"&&s.includes(l.fieldName))),n.orderByFields=n.orderByFields.filter(l=>!s.includes(l.field)),t.attributeTableTemplate=n}if(t.fieldConfigurations?.length){let n=le.clone(t.fieldConfigurations).filter(l=>!s.includes(l.name));t.fieldConfigurations=n}await x(p,{query:{f:"json"},responseType:"json"}).then(async n=>{let l=n.data;if(l?.layers||l?.tables){let u=t.isTable,v=u?l.tables:l.layers,g=v?.find(w=>w.id===t.layerId);if(s.forEach(w=>{g?.attributeTableInfo?.attributeTableElements&&(g.attributeTableInfo.attributeTableElements=g.attributeTableInfo.attributeTableElements.map(m=>{if(m.type==="field")return m.fieldName===w?void 0:m;if(m.type==="group"&&Array.isArray(m.attributeTableElements)){let f=m.attributeTableElements.filter(b=>!(b.type==="field"&&b.fieldName===w));return f.length?{...m,attributeTableElements:f}:void 0}return m}).filter(Boolean),g.attributeTableInfo.orderByFields=g.attributeTableInfo.orderByFields.filter(m=>m.field!==w))}),g?.layerDefinition?.fieldConfigurations&&(g.layerDefinition.fieldConfigurations=g.layerDefinition.fieldConfigurations.filter(w=>!s.includes(w.name))),g?.popupInfo){s.forEach(b=>{g.popupInfo.fieldInfos=g.popupInfo.fieldInfos.filter(D=>D.fieldName!==b),g.popupInfo.popupElements?.forEach((D,M)=>{D.type==="fields"&&D.fieldInfos&&(g.popupInfo.popupElements[M].fieldInfos=g.popupInfo.popupElements[M].fieldInfos.filter(ce=>ce.fieldName!==b))})});let w=`${T(this.portal)}content/users/${this.item.owner}/items/${this.item.id}/update`,m={};u?(m.tables=v,l.layers&&(m.layers=l.layers)):(m.layers=v,l.tables&&(m.tables=l.tables));let f={f:"json",text:JSON.stringify(m)};await x(w,{query:{...f},method:"post",responseType:"json"}).then(b=>{b.data?.success?this.handleSuccess():this.handleError()},()=>this.handleError())}else this.handleSuccess()}else n.httpStatus===200&&(!n.data||JSON.stringify(n.data)==="{}")?this.handleSuccess():this.handleError()},()=>this.handleError())}},()=>this.handleError())}handleSuccess(){this.arcgisFieldsDeleted.emit(),this.dialogNode?.value&&(this.dialogNode.value.open=!1),this.options?.handleCloseOnConsumer?this.arcgisBeforeModalClose.emit("success"):this.displaySuccessAlert()}handleError(e){this.dialogNode?.value&&(this.dialogNode.value.open=!1),e?this.options?.handleCloseOnConsumer?this.arcgisBeforeModalClose.emit("read-only-error"):this.displayReadOnlyErrorAlert():this.options?.handleCloseOnConsumer?this.arcgisBeforeModalClose.emit("error"):this.displayErrorAlert()}displaySuccessAlert(){let{messages:e,fieldNames:t}=this;this.successAlertNode&&(this.successAlertNode.parentElement?.removeChild(this.successAlertNode),this.successAlertNode=void 0),this.successAlertNode=A(y`<calcite-alert .label=${t.length===1?e.fieldDeleted:e.fieldsDeleted} kind=success icon=check-circle auto-close open><div slot=message>${t.length===1?e.fieldDeleted:e.fieldsDeleted}</div></calcite-alert>`),document.body.append(this.successAlertNode)}displayErrorAlert(){let{messages:e}=this;this.errorAlertNode&&(this.errorAlertNode.parentElement?.removeChild(this.errorAlertNode),this.errorAlertNode=void 0),this.errorAlertNode=A(y`<calcite-alert .label=${e.fieldDeletionUnsuccessful} kind=danger icon=exclamation-mark-triangle auto-close open><div slot=message>${e.fieldDeletionUnsuccessful}</div></calcite-alert>`),document.body.append(this.errorAlertNode)}displayReadOnlyErrorAlert(){let{messages:e,portal:t}=this;this.errorAlertNode&&(this.errorAlertNode.parentElement?.removeChild(this.errorAlertNode),this.errorAlertNode=void 0),this.errorAlertNode=A(y`<calcite-alert .label=${e.fieldDeletionUnsuccessful} kind=danger icon=exclamation-mark-triangle auto-close auto-close-duration=slow open><div slot=title>${e.error}</div><div slot=message>${t.isPortal?e.readOnlyErrorMessageEnterprise:e.readOnlyErrorMessage}</div>${!t.isPortal&&y`<calcite-link slot=link target=_blank href=https://status.arcgis.com>${e.healthDashboard}</calcite-link>`||""}</calcite-alert>`),document.body.append(this.errorAlertNode)}render(){let{messages:e,fieldsAreDeletable:t,fieldNames:s,deleteInProgress:r}=this;return this._propWatcherTask.render({complete:()=>(t||(s?.length?s?.length===1?N("error",this,"Field cannot be deleted"):N("error",this,"One or more fields cannot be deleted"):N("error",this,j("fieldNames"))),y`<calcite-dialog class="dialog" width=s open modal outside-close-disabled escape-disabled @calciteDialogClose=${()=>this.arcgisClose.emit()} .heading=${s?.length===1?e.deleteField:e.deleteFields} ${P(this.dialogNode)}>${t?y`<div class=${`dialog-content-wrapper ${r?"hide-overflow":""}`}>${this.renderDeleteLoader()}<calcite-label>${s.length===1?e.deletePrompt:e.deleteMultiplePrompt}</calcite-label>${this.renderFieldsPreview()}</div>${this.renderCancelButton()}${this.renderDeleteButton()}`:this.renderError()}</calcite-dialog>`)})}renderError(){let{messages:e}=this;return y`<div class="loader-container active"><div class="loader-text">${e.errorOccurred}</div></div>`}renderDeleteLoader(){let{messages:e,fieldNames:t,deleteInProgress:s}=this;return y`<div class=${`loader-container ${s?"active":""}`}><calcite-loader class="loader" .label=${t.length===1?e.deletingField:e.deletingFields} .hidden=${!s}></calcite-loader><div class="loader-text">${t.length===1?e.deletingField:e.deletingFields}</div></div>`}renderFieldsPreview(){let{fieldNames:e,layerFields:t,layerFieldsMap:s,arcadeExpMap:r,messages:a}=this;return y`<calcite-list .label=${a.fields}>${e.map(o=>{let c=t.find(p=>p.name===o);return y`<calcite-list-item .label=${this.getFieldLabel(o)} .description=${`{${o}}`} .value=${o} .disabled=${!c.editable}><div slot=actions-end class="field-icons">${Ne({fieldType:se(o,s,r)})}</div></calcite-list-item>`})}</calcite-list>`}renderCancelButton(){let{messages:e}=this;return y`<calcite-button @click=${()=>this.dialogNode.value.open=!1} slot=footer-end appearance=outline ${P(this.cancelNode)}>${e.cancel}</calcite-button>`}renderDeleteButton(){let{messages:e,fieldNames:t}=this;return y`<calcite-button kind=danger slot=footer-end @click=${async s=>{let{portal:r}=this;s.currentTarget.disabled=!0,this.cancelNode.value.disabled=!0,this.dialogNode.value.closeDisabled=!0,r.sourceJSON?.isReadOnly?this.handleError(!0):(this.deleteInProgress=!0,this.requestUpdate(),this.arcgisBeforeDelete.emit(),await this.deleteFields())}}>${t.length===1?e.deleteField:e.deleteFieldsWithNumber.replace("${number}",`${t.length}`)}</calcite-button>`}};B("arcgis-portal-field-delete",O);return O},"core/lang","layers/support/FeatureTemplate","Graphic","identity/IdentityManager","request","applications/PortalApp/layerUtils","layers/support/fieldUtils","layers/support/FeatureReductionBinning","layers/support/FeatureReductionCluster","renderers/support/jsonUtils","request","core/sql","applications/PortalApp/layerUtils",a)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"replacementAvailable":"Replacement available","replacementUnavailable":"Replacement unavailable","redirectToReplacement":"Redirect to replacement","retiredTitle":"Retired","cancel":"Cancel","ownedBy":"Owned by: ${owner}","redirect":"Redirecting in ${seconds}s...","deprecatedHasReplacement":"<strong>${itemTitle}</strong> has been replaced by the following:","retired":"<strong>${itemTitle}</strong> has been retired.","retiredReplacementUnavailable":"<strong>${itemTitle}</strong> has been retired. You do not have access to its replacement.","moreDetails":"More details"}
|
|
1
|
+
{"replacementAvailable":"Replacement available","replacementUnavailable":"Replacement unavailable","redirectToReplacement":"Redirect to replacement","retiredTitle":"Retired","cancel":"Cancel","cancelRedirection":"Cancel redirection","ownedBy":"Owned by: ${owner}","redirect":"Redirecting in ${seconds}s...","deprecatedHasReplacement":"<strong>${itemTitle}</strong> has been replaced by the following:","retired":"<strong>${itemTitle}</strong> has been retired.","retiredReplacementUnavailable":"<strong>${itemTitle}</strong> has been retired. You do not have access to its replacement.","moreDetails":"More details"}
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{P as t,z as e}from"./3XZ4NJNW.js";var a=e(t,{"arcgis-portal-ai-assistant":[()=>import("./
|
|
2
|
+
import{P as t,z as e}from"./3XZ4NJNW.js";var a=e(t,{"arcgis-portal-ai-assistant":[()=>import("./I4ZGLRAS.js"),"autoDestroyDisabled,config:,defaultClosed,openEntitiesInNewTab,portal:,t9n:,user:"],"arcgis-portal-ai-assistant-composer":[()=>import("./VI6KZSVE.js"),"isLoading,portal:,t9n:,user:;focusTextArea,stopListening"],"arcgis-portal-ai-assistant-side-panel":[()=>import("./KGBCXUHG.js"),"activeThreadId,t9n:,threads:"],"arcgis-portal-classification-banner":[()=>import("./GDNNFUB4.js"),"autoDestroyDisabled,messages:,missingExistingClassification,portalItem:,validationErrors,variant;destroy"],"arcgis-portal-classification-config":[()=>import("./4CENJHJO.js"),"autoDestroyDisabled,messages:,portalItem:,status,valid,values;destroy,resetForm,validateForm"],"arcgis-portal-classification-favorite":[()=>import("./NWUVXMPQ.js"),"attributeExpressionResults:,classificationValue:,favoriteClassifications:,messages:,portalItem:,resetFavoriteClassification:,selectedFavoriteClassificationName,updateClassificationData:"],"arcgis-portal-classification-form-element":[()=>import("./NTDYM2RH.js"),"attribute:,attributeKey,isRequiredErrors:,messages:,renderingInfo:,value:"],"arcgis-portal-extent-picker":[()=>import("./YJB3RZMI.js"),"active,contentOnly,extentService,extentValue:,isArea,itemId,messages:,portal:;;getExtent"],"arcgis-portal-extent-picker-coord-field":[()=>import("./WR6GOULY.js"),"errorMessage,inputId,label,max,min,relatedErrorMessage,validateRelated:,value;;checkRelatedField,isValid,setFocus"],"arcgis-portal-field-delete":[()=>import("./WRH4C2YQ.js"),"config:,fieldNames:,layer:,mapView:,messages:,options:"],"arcgis-portal-mentionable-text-area":[()=>import("./OI4PPW4B.js"),"disabled,maxLength,placeholder,popoverListLabel,popoverPlacement,portal:,readOnly,rows,scale,starters:,user:,value;closePopover,focusTextArea,selectItem"],"arcgis-portal-replacement-item-redirect":[()=>import("./MFMTJNSM.js"),"itemId,portal:,t9n:,user:;setFocus"],"arcgis-portal-user-avatar":[()=>import("./6XC5HMRA.js"),"checkOnline,description,heading,hideAvatar,messages:,portal:,scale,showName,underline,user:,username,wrap"],"arcgis-portal-voice-input":[()=>import("./MCI6R5AJ.js"),"language;clearText,startListening,stopListening"]});a({resourcesUrl:import.meta.url});var i=new CSSStyleSheet;i.replaceSync("@layer{:not([hydrated]):is(arcgis-portal-ai-assistant,arcgis-portal-classification-banner,arcgis-portal-classification-config,arcgis-portal-classification-favorite,arcgis-portal-classification-form-element,arcgis-portal-extent-picker,arcgis-portal-field-delete,arcgis-portal-mentionable-text-area,arcgis-portal-replacement-item-redirect,arcgis-portal-user-avatar,arcgis-portal-voice-input){visibility:hidden}}");document.adoptedStyleSheets=[...document.adoptedStyleSheets,i];window.$arcgis||Object.defineProperty(window,"$arcgis",{configurable:!1,enumerable:!0,writable:!1,value:{}}),((a,r)=>{a.t=(c,...x)=>Promise.all(x.map(x=>x.then?x:(!a?.forceESM&&a?.import||(x=>import(x+".js").then(m=>m.default??m)))("@arcgis/core/"+x))).then(c);r.p=a.t(([m])=>{r.t=m.trackAccess;r.o=m.createObservable;r.c=m.createTrackingTarget;r.r=m.runTracked},"applications/Components/reactiveUtils")})($arcgis,t)
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
import * as p from "@arcgis/core/layers/support/fieldUtils.js";
|
|
3
3
|
import Q from "@arcgis/core/layers/support/FeatureReductionBinning.js";
|
|
4
4
|
import q from "@arcgis/core/layers/support/FeatureReductionCluster.js";
|
|
5
|
-
import * as
|
|
6
|
-
import
|
|
5
|
+
import * as x from "@arcgis/core/renderers/support/jsonUtils.js";
|
|
6
|
+
import R from "@arcgis/core/request.js";
|
|
7
7
|
import * as L from "@arcgis/core/core/sql.js";
|
|
8
8
|
import * as H from "@arcgis/core/applications/PortalApp/layerUtils.js";
|
|
9
|
-
import { i as J, a as N, l as T, b as
|
|
9
|
+
import { i as J, a as N, l as T, b as P, c as z, u as G, g as E, d as D, e as V, f as k } from "./item.js";
|
|
10
10
|
import { g as K } from "./portal.js";
|
|
11
|
-
var O = /* @__PURE__ */ ((r) => (r.expression = "expression/", r
|
|
11
|
+
var O = /* @__PURE__ */ ((r) => (r.expression = "expression/", r))(O || {});
|
|
12
12
|
function b(r) {
|
|
13
13
|
return r != null;
|
|
14
14
|
}
|
|
@@ -38,7 +38,7 @@ async function be(r) {
|
|
|
38
38
|
(await X(r)).filter((e) => e.visible).map((e) => [e.name, e])
|
|
39
39
|
);
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function xe(r) {
|
|
42
42
|
const e = /* @__PURE__ */ new Map();
|
|
43
43
|
return r?.expressionInfos && r.expressionInfos.forEach((i) => {
|
|
44
44
|
const t = `${O.expression}${i.name}`;
|
|
@@ -59,8 +59,8 @@ async function X(r) {
|
|
|
59
59
|
if (n?.thematicGroup) {
|
|
60
60
|
const a = new Map(
|
|
61
61
|
t.fields.map((l) => [l.name, l])
|
|
62
|
-
),
|
|
63
|
-
|
|
62
|
+
), d = n.thematicGroup.fieldNames, c = [];
|
|
63
|
+
d.forEach((l) => {
|
|
64
64
|
a.has(l) && c.push(a.get(l));
|
|
65
65
|
}), e(c);
|
|
66
66
|
} else
|
|
@@ -83,14 +83,14 @@ async function X(r) {
|
|
|
83
83
|
function o(r, e) {
|
|
84
84
|
return !r || !e ? !1 : r.toLocaleLowerCase() === e.toLocaleLowerCase();
|
|
85
85
|
}
|
|
86
|
-
async function
|
|
86
|
+
async function Re(r) {
|
|
87
87
|
const e = ["feature", "oriented-imagery"].includes(r.type), i = r?.portalItem, t = r.sourceJSON;
|
|
88
88
|
if (!e || !i)
|
|
89
89
|
return !1;
|
|
90
90
|
const s = i.portal;
|
|
91
|
-
if (!s?.user || N(i) || !J(i) || T(i) ||
|
|
91
|
+
if (!s?.user || N(i) || !J(i) || T(i) || P(t))
|
|
92
92
|
return !1;
|
|
93
|
-
const l =
|
|
93
|
+
const l = G(i, s.user), I = await E(r) ?? [], F = await D(r) ?? [], u = V(I, F);
|
|
94
94
|
if (!l && !u)
|
|
95
95
|
return !1;
|
|
96
96
|
const S = await k(i.id, s, {
|
|
@@ -104,7 +104,7 @@ async function Je(r, e, i, t) {
|
|
|
104
104
|
if (!i)
|
|
105
105
|
return !1;
|
|
106
106
|
const s = ["feature", "oriented-imagery"].includes(e.type), n = t?.item ?? e.portalItem, a = e.sourceJSON;
|
|
107
|
-
if (!s || !n || !n.portal.user || !J(n) || N(n) || T(n) ||
|
|
107
|
+
if (!s || !n || !n.portal.user || !J(n) || N(n) || T(n) || P(a) || n.portal.isPortal && z(n) || ["oid", "global-id", "geometry"].includes(i.type) || await Y(e, i.name, t))
|
|
108
108
|
return !1;
|
|
109
109
|
const w = e.sourceJSON.geometryProperties, g = w?.shapeLengthFieldName, U = w?.shapeAreaFieldName;
|
|
110
110
|
if (o(g, i.name) || o(U, i.name))
|
|
@@ -113,12 +113,12 @@ async function Je(r, e, i, t) {
|
|
|
113
113
|
if (y && (o(y.creationDateField, i.name) || o(y.creatorField, i.name) || o(y.editDateField, i.name) || o(y.editorField, i.name)) || o(e.objectIdField, i.name) || o(e.displayField, i.name) || o(e.typeIdField, i.name) || o(e.subtypeField, i.name) || e.timeInfo && (o(e.timeInfo.startField, i.name) || o(e.timeInfo.endField, i.name) || o(e.timeInfo.trackIdField, i.name)))
|
|
114
114
|
return !1;
|
|
115
115
|
if (!t?.ignoreLayerRenderer && e.featureReduction) {
|
|
116
|
-
const
|
|
116
|
+
const f = /* @__PURE__ */ new Set();
|
|
117
117
|
if (await p.collectFeatureReductionFields(
|
|
118
|
-
|
|
118
|
+
f,
|
|
119
119
|
e,
|
|
120
120
|
e.featureReduction
|
|
121
|
-
), Array.from(
|
|
121
|
+
), Array.from(f).some(
|
|
122
122
|
(h) => o(h, i.name)
|
|
123
123
|
))
|
|
124
124
|
return !1;
|
|
@@ -126,10 +126,10 @@ async function Je(r, e, i, t) {
|
|
|
126
126
|
if (!t?.ignoreLayerRenderer && (await p.getRendererFields(e.renderer, e.fieldsIndex)).some((h) => o(h, i.name)))
|
|
127
127
|
return !1;
|
|
128
128
|
if (!t?.ignoreLayerLabelingInfo) {
|
|
129
|
-
const
|
|
129
|
+
const f = e.labelingInfo?.map(
|
|
130
130
|
(m) => m.labelExpressionInfo?.expression
|
|
131
131
|
);
|
|
132
|
-
if (
|
|
132
|
+
if (f && ((await p.getExpressionFields(e, f)).some(($) => o($, i.name)) || await A(e, i, "layer")))
|
|
133
133
|
return !1;
|
|
134
134
|
}
|
|
135
135
|
if (!t?.ignoreLayerDefinitionExpression && e.definitionExpression && (await L.parseWhereClause(e.definitionExpression, e.fieldsIndex)).fieldNames.some((h) => o(h, i.name)) || await _(e, i, t) || await ee(e, i))
|
|
@@ -138,9 +138,9 @@ async function Je(r, e, i, t) {
|
|
|
138
138
|
return await Promise.resolve(!1);
|
|
139
139
|
if (await ie(e, i))
|
|
140
140
|
return await Promise.resolve(!1);
|
|
141
|
-
if (Z(r, e, i) || e.relationships?.map((
|
|
141
|
+
if (Z(r, e, i) || e.relationships?.map((f) => f.keyField)?.some((f) => o(f, i.name)))
|
|
142
142
|
return !1;
|
|
143
|
-
const M =
|
|
143
|
+
const M = G(n, n.portal.user), j = t?.userItemInfo?.userGroups ?? await E(e) ?? [], W = t?.userItemInfo?.itemGroups ?? await D(e) ?? [], B = V(j, W);
|
|
144
144
|
if (!M && !B)
|
|
145
145
|
return !1;
|
|
146
146
|
const v = t?.userItemInfo?.relatedItems ?? await k(n.id, n.portal, {
|
|
@@ -153,12 +153,12 @@ async function Je(r, e, i, t) {
|
|
|
153
153
|
async function Y(r, e, i) {
|
|
154
154
|
const t = `${r.url}/${r.layerId}/fieldGroups`;
|
|
155
155
|
try {
|
|
156
|
-
const s = i?.userItemInfo && "fieldGroups" in i.userItemInfo ? i.userItemInfo.fieldGroups : (await
|
|
156
|
+
const s = i?.userItemInfo && "fieldGroups" in i.userItemInfo ? i.userItemInfo.fieldGroups : (await R(t, {
|
|
157
157
|
query: { f: "json" },
|
|
158
158
|
responseType: "json"
|
|
159
159
|
}))?.data?.fieldGroups;
|
|
160
160
|
return s ? s.some(
|
|
161
|
-
(a) => a.fields.some((
|
|
161
|
+
(a) => a.fields.some((d) => o(d, e))
|
|
162
162
|
) : !1;
|
|
163
163
|
} catch {
|
|
164
164
|
return !1;
|
|
@@ -191,8 +191,8 @@ async function A(r, e, i) {
|
|
|
191
191
|
];
|
|
192
192
|
let n = !1;
|
|
193
193
|
for (let a = 0; a < s.length; a++) {
|
|
194
|
-
const
|
|
195
|
-
if (!n &&
|
|
194
|
+
const d = s[a].fieldNames?.some((c) => o(c, e.name));
|
|
195
|
+
if (!n && d) {
|
|
196
196
|
n = !0;
|
|
197
197
|
break;
|
|
198
198
|
}
|
|
@@ -203,7 +203,7 @@ async function _(r, e, i) {
|
|
|
203
203
|
const t = r.portalItem;
|
|
204
204
|
if (!t)
|
|
205
205
|
return !1;
|
|
206
|
-
const s = `${K(t.portal)}content/items/${t.id}/data`, a = (i?.userItemInfo?.itemData ?? await
|
|
206
|
+
const s = `${K(t.portal)}content/items/${t.id}/data`, a = (i?.userItemInfo?.itemData ?? await R(s, {
|
|
207
207
|
query: { f: "json" },
|
|
208
208
|
responseType: "json"
|
|
209
209
|
}))?.data;
|
|
@@ -214,7 +214,7 @@ async function _(r, e, i) {
|
|
|
214
214
|
if (!l && !I && !F)
|
|
215
215
|
return !1;
|
|
216
216
|
if (!i?.ignoreItemRenderer && l) {
|
|
217
|
-
const u =
|
|
217
|
+
const u = x.fromJSON(l);
|
|
218
218
|
if ((await p.getRendererFields(u, r.fieldsIndex)).some((g) => o(g, e.name)))
|
|
219
219
|
return !0;
|
|
220
220
|
}
|
|
@@ -228,7 +228,7 @@ async function ee(r, e) {
|
|
|
228
228
|
if (!t && !s)
|
|
229
229
|
return !1;
|
|
230
230
|
if (t) {
|
|
231
|
-
const n =
|
|
231
|
+
const n = x.fromJSON(t);
|
|
232
232
|
if ((await p.getRendererFields(n, r.fieldsIndex)).some((c) => o(c, e.name)))
|
|
233
233
|
return !0;
|
|
234
234
|
}
|
|
@@ -265,8 +265,8 @@ async function C(r, e, i) {
|
|
|
265
265
|
}
|
|
266
266
|
export {
|
|
267
267
|
Je as a,
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
xe as b,
|
|
269
|
+
Re as c,
|
|
270
270
|
Oe as d,
|
|
271
271
|
ve as e,
|
|
272
272
|
be as g,
|
|
@@ -278,72 +278,61 @@ function y(t) {
|
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
const we = [
|
|
281
|
-
"thinking",
|
|
282
|
-
"routing",
|
|
283
|
-
"running-analytic",
|
|
284
|
-
"running-navigation",
|
|
285
|
-
"summarizing",
|
|
286
|
-
"saving-state",
|
|
287
|
-
"completed",
|
|
288
|
-
"error"
|
|
289
|
-
], ye = [
|
|
290
281
|
"thinking",
|
|
291
282
|
"routing",
|
|
292
283
|
"running-analytic",
|
|
293
284
|
"running-navigation",
|
|
294
285
|
"summarizing",
|
|
295
286
|
"saving-state"
|
|
296
|
-
]
|
|
297
|
-
a.enum(we);
|
|
298
|
-
const U = a.enum(ye), j = a.object({
|
|
287
|
+
], U = a.enum(we), j = a.object({
|
|
299
288
|
status: U,
|
|
300
289
|
threadId: a.string()
|
|
301
|
-
}),
|
|
290
|
+
}), ye = a.object({
|
|
302
291
|
status: a.literal("completed"),
|
|
303
292
|
threadId: a.string(),
|
|
304
293
|
response: M
|
|
305
|
-
}),
|
|
294
|
+
}), be = a.object({
|
|
306
295
|
status: a.literal("error"),
|
|
307
296
|
threadId: a.string(),
|
|
308
297
|
errorCode: a.string(),
|
|
309
298
|
message: a.string().nullable().optional()
|
|
310
299
|
}), D = a.discriminatedUnion("status", [
|
|
300
|
+
ye,
|
|
311
301
|
be,
|
|
312
|
-
ke,
|
|
313
302
|
j
|
|
314
303
|
]);
|
|
315
304
|
a.object({
|
|
316
305
|
event: a.literal("runtime"),
|
|
317
306
|
data: D
|
|
318
307
|
});
|
|
319
|
-
const
|
|
308
|
+
const ke = a.object({
|
|
320
309
|
kind: a.literal("progress"),
|
|
321
310
|
status: U,
|
|
322
311
|
payload: j,
|
|
323
312
|
threadId: a.string()
|
|
324
|
-
}),
|
|
313
|
+
}), xe = a.object({
|
|
325
314
|
kind: a.literal("complete"),
|
|
326
315
|
status: a.literal("completed"),
|
|
327
316
|
data: M,
|
|
328
317
|
threadId: a.string()
|
|
329
318
|
}), $ = a.discriminatedUnion("kind", [
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
]),
|
|
319
|
+
xe,
|
|
320
|
+
ke
|
|
321
|
+
]), Se = a.object({
|
|
333
322
|
event: a.literal("runtime"),
|
|
334
323
|
data: a.unknown()
|
|
335
324
|
});
|
|
336
|
-
function
|
|
325
|
+
function Te(t) {
|
|
337
326
|
return t.replace(/\r\n?/gu, `
|
|
338
327
|
`);
|
|
339
328
|
}
|
|
340
329
|
function E(t, e = !1) {
|
|
341
|
-
const n =
|
|
330
|
+
const n = Te(t).split(`
|
|
342
331
|
|
|
343
332
|
`), r = e ? "" : n.pop() ?? "";
|
|
344
333
|
return { blocks: n.map((o) => o.trim()).filter(Boolean), remainder: r };
|
|
345
334
|
}
|
|
346
|
-
function
|
|
335
|
+
function $e(t) {
|
|
347
336
|
const e = D.safeParse(t);
|
|
348
337
|
return e.success ? e.data.status === "completed" ? {
|
|
349
338
|
...e.data,
|
|
@@ -370,12 +359,12 @@ function A(t) {
|
|
|
370
359
|
if (s !== "runtime" || !n.length)
|
|
371
360
|
return null;
|
|
372
361
|
const r = JSON.parse(n.join(`
|
|
373
|
-
`)), i =
|
|
362
|
+
`)), i = Se.safeParse(r), o = $e(i.success ? i.data.data : r);
|
|
374
363
|
if (!o)
|
|
375
364
|
throw new Error("Assistant stream event is invalid.");
|
|
376
365
|
return { event: "runtime", data: o };
|
|
377
366
|
}
|
|
378
|
-
async function*
|
|
367
|
+
async function* Ee(t) {
|
|
379
368
|
const e = new TextDecoder();
|
|
380
369
|
let s = "";
|
|
381
370
|
for await (const n of t) {
|
|
@@ -395,7 +384,7 @@ async function* Ae(t) {
|
|
|
395
384
|
}
|
|
396
385
|
}
|
|
397
386
|
}
|
|
398
|
-
function
|
|
387
|
+
function Ae(t) {
|
|
399
388
|
const e = t.data;
|
|
400
389
|
if (e.status === "error")
|
|
401
390
|
throw new Error(e.message ?? "Assistant stream reported an error.");
|
|
@@ -411,7 +400,7 @@ function Ie(t) {
|
|
|
411
400
|
threadId: e.threadId
|
|
412
401
|
});
|
|
413
402
|
}
|
|
414
|
-
async function
|
|
403
|
+
async function Ie({
|
|
415
404
|
portal: t,
|
|
416
405
|
user: e,
|
|
417
406
|
userMessage: s,
|
|
@@ -440,8 +429,8 @@ async function Pe({
|
|
|
440
429
|
if (!c.body)
|
|
441
430
|
return console.error("Assistant stream response body is missing."), { error: { code: "unhandledError" } };
|
|
442
431
|
let l, p = o.threadId;
|
|
443
|
-
for await (const z of
|
|
444
|
-
const u =
|
|
432
|
+
for await (const z of Ee(c.body)) {
|
|
433
|
+
const u = Ae(z);
|
|
445
434
|
if (u.kind === "progress") {
|
|
446
435
|
r?.(u.status, u.payload), u.threadId && (p = u.threadId);
|
|
447
436
|
continue;
|
|
@@ -453,7 +442,7 @@ async function Pe({
|
|
|
453
442
|
return console.error("Failed to send message to assistant stream.", o), { error: { code: "unhandledError" } };
|
|
454
443
|
}
|
|
455
444
|
}
|
|
456
|
-
class
|
|
445
|
+
class Pe extends F {
|
|
457
446
|
constructor() {
|
|
458
447
|
super(...arguments), this.t9n = B({ blocking: !0 }), this.composerEl = k(), this.chatAnchorEl = k(), this.refocusInput = async () => {
|
|
459
448
|
await this.updateComplete, this.composerEl.value?.focusTextArea();
|
|
@@ -489,7 +478,7 @@ class _e extends F {
|
|
|
489
478
|
if (!n || this.isSending || !s)
|
|
490
479
|
return;
|
|
491
480
|
await this.composerEl.value?.stopListening(), this.arcgisInputSend.emit({ text: n }), s.addMessageToActiveThread({ id: v(), role: "user", content: n }), this.scrollToBottom(), this.isSending = !0, this.isThinking = !0, this.streamStatus = this.t9n.status.waitingForResponse;
|
|
492
|
-
const { portal: r, user: i } = this, o = await
|
|
481
|
+
const { portal: r, user: i } = this, o = await Ie({
|
|
493
482
|
portal: r,
|
|
494
483
|
user: i,
|
|
495
484
|
userMessage: n,
|
|
@@ -547,7 +536,7 @@ class _e extends F {
|
|
|
547
536
|
}} ${x(this.composerEl)}></arcgis-portal-ai-assistant-composer></div></div></calcite-panel>`;
|
|
548
537
|
}
|
|
549
538
|
}
|
|
550
|
-
O("arcgis-portal-ai-assistant",
|
|
539
|
+
O("arcgis-portal-ai-assistant", Pe);
|
|
551
540
|
export {
|
|
552
|
-
|
|
541
|
+
Pe as ArcgisPortalAiAssistant
|
|
553
542
|
};
|
|
@@ -25,6 +25,7 @@ export abstract class ArcgisPortalReplacementItemRedirect extends LitElement {
|
|
|
25
25
|
redirectToReplacement: string;
|
|
26
26
|
retiredTitle: string;
|
|
27
27
|
cancel: string;
|
|
28
|
+
cancelRedirection: string;
|
|
28
29
|
ownedBy: string;
|
|
29
30
|
redirect: string;
|
|
30
31
|
deprecatedHasReplacement: string;
|
|
@@ -37,6 +38,7 @@ export abstract class ArcgisPortalReplacementItemRedirect extends LitElement {
|
|
|
37
38
|
redirectToReplacement: string;
|
|
38
39
|
retiredTitle: string;
|
|
39
40
|
cancel: string;
|
|
41
|
+
cancelRedirection: string;
|
|
40
42
|
ownedBy: string;
|
|
41
43
|
redirect: string;
|
|
42
44
|
deprecatedHasReplacement: string;
|