@arcgis/portal-components 5.1.0-next.55 → 5.1.0-next.56
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/O5AQSFQM.js +65 -0
- package/dist/cdn/assets/portal-ai-assistant/t9n/messages.en.json +1 -1
- package/dist/cdn/index.js +1 -1
- package/dist/components/arcgis-portal-ai-assistant/customElement.d.ts +22 -4
- package/dist/components/arcgis-portal-ai-assistant/customElement.js +272 -125
- 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/LKSVLCAW.js +0 -60
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
+
import{a as fe}from"./CQYRDCAS.js";import{a as ge}from"./WZGUYBTB.js";import{a as de}from"./A6YUOK3J.js";import{b as U}from"./AJZHPBED.js";import{H as _,I as z,J as pe,K as q,P as ue,h as V,j as x,u as H,x as B}from"./GWHFVZ3O.js";export default $arcgis.t(([Rt])=>{function X(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var R=X();function $e(t){R=t}var S={exec:()=>null};function u(t,e=""){let s=typeof t=="string"?t:t.source,n={replace:(r,a)=>{let i=typeof a=="string"?a:a.source;return i=i.replace(m.caret,"$1"),s=s.replace(r,i),n},getRegex:()=>new RegExp(s,e)};return n}var Ze=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:t=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:t=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},Ne=/^(?:[ \t]*(?:\n|$))+/,je=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Qe=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,C=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Oe=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,J=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,ve=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,Se=u(ve).replace(/bull/g,J).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ve=u(ve).replace(/bull/g,J).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),K=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,He=/^[^\n]+/,Y=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Ue=u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Y).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ge=u(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,J).getRegex(),j="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",ee=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,We=u("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",ee).replace("tag",j).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Te=u(K).replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",j).getRegex(),Fe=u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Te).getRegex(),te={blockquote:Fe,code:je,def:Ue,fences:Qe,heading:Oe,hr:C,html:We,lheading:Se,list:Ge,newline:Ne,paragraph:Te,table:S,text:He},ke=u("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",j).getRegex(),Xe={...te,lheading:Ve,table:ke,paragraph:u(K).replace("hr",C).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ke).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",j).getRegex()},Je={...te,html:u(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",ee).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:S,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:u(K).replace("hr",C).replace("heading",` *#{1,6} *[^
|
|
3
|
+
]`).replace("lheading",Se).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Ke=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Ye=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Re=/^( {2,}|\\)\n(?!\s*$)/,et=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,A=/[\p{P}\p{S}]/u,Q=/[\s\p{P}\p{S}]/u,se=/[^\s\p{P}\p{S}]/u,tt=u(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Q).getRegex(),Ae=/(?!~)[\p{P}\p{S}]/u,st=/(?!~)[\s\p{P}\p{S}]/u,rt=/(?:[^\s\p{P}\p{S}]|~)/u,nt=u(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Ze?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ie=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,it=u(Ie,"u").replace(/punct/g,A).getRegex(),at=u(Ie,"u").replace(/punct/g,Ae).getRegex(),_e="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",lt=u(_e,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,Q).replace(/punct/g,A).getRegex(),ot=u(_e,"gu").replace(/notPunctSpace/g,rt).replace(/punctSpace/g,st).replace(/punct/g,Ae).getRegex(),ct=u("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,Q).replace(/punct/g,A).getRegex(),ht=u(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,A).getRegex(),pt="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ut=u(pt,"gu").replace(/notPunctSpace/g,se).replace(/punctSpace/g,Q).replace(/punct/g,A).getRegex(),dt=u(/\\(punct)/,"gu").replace(/punct/g,A).getRegex(),gt=u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ft=u(ee).replace("(?:-->|$)","-->").getRegex(),kt=u("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ft).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),D=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,mt=u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",D).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ze=u(/^!?\[(label)\]\[(ref)\]/).replace("label",D).replace("ref",Y).getRegex(),Ee=u(/^!?\[(ref)\](?:\[\])?/).replace("ref",Y).getRegex(),xt=u("reflink|nolink(?!\\()","g").replace("reflink",ze).replace("nolink",Ee).getRegex(),me=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,re={_backpedal:S,anyPunctuation:dt,autolink:gt,blockSkip:nt,br:Re,code:Ye,del:S,delLDelim:S,delRDelim:S,emStrongLDelim:it,emStrongRDelimAst:lt,emStrongRDelimUnd:ct,escape:Ke,link:mt,nolink:Ee,punctuation:tt,reflink:ze,reflinkSearch:xt,tag:kt,text:et,url:S},bt={...re,link:u(/^!?\[(label)\]\((.*?)\)/).replace("label",D).getRegex(),reflink:u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",D).getRegex()},G={...re,emStrongRDelimAst:ot,emStrongLDelim:at,delLDelim:ht,delRDelim:ut,url:u(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",me).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:u(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",me).getRegex()},wt={...G,br:u(Re).replace("{2,}","*").getRegex(),text:u(G.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},M={normal:te,gfm:Xe,pedantic:Je},E={normal:re,gfm:G,breaks:wt,pedantic:bt},yt={"&":"&","<":"<",">":">",'"':""","'":"'"},xe=t=>yt[t];function $(t,e){if(e){if(m.escapeTest.test(t))return t.replace(m.escapeReplace,xe)}else if(m.escapeTestNoEncode.test(t))return t.replace(m.escapeReplaceNoEncode,xe);return t}function be(t){try{t=encodeURI(t).replace(m.percentDecode,"%")}catch{return null}return t}function we(t,e){let s=t.replace(m.findPipe,(a,i,o)=>{let l=!1,h=i;for(;--h>=0&&o[h]==="\\";)l=!l;return l?"|":" |"}),n=s.split(m.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length<e;)n.push("");for(;r<n.length;r++)n[r]=n[r].trim().replace(m.slashPipe,"|");return n}function P(t,e,s){let n=t.length;if(n===0)return"";let r=0;for(;r<n;){let a=t.charAt(n-r-1);if(a===e&&!s)r++;else if(a!==e&&s)r++;else break}return t.slice(0,n-r)}function $t(t,e){if(t.indexOf(e[1])===-1)return-1;let s=0;for(let n=0;n<t.length;n++)if(t[n]==="\\")n++;else if(t[n]===e[0])s++;else if(t[n]===e[1]&&(s--,s<0))return n;return s>0?-2:-1}function vt(t,e=0){let s=e,n="";for(let r of t)if(r===" "){let a=4-s%4;n+=" ".repeat(a),s+=a}else n+=r,s++;return n}function ye(t,e,s,n,r){let a=e.href,i=e.title||null,o=t[1].replace(r.other.outputLinkReplace,"$1");n.state.inLink=!0;let l={type:t[0].charAt(0)==="!"?"image":"link",raw:s,href:a,title:i,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,l}function St(t,e,s){let n=t.match(s.other.indentCodeCompensation);if(n===null)return e;let r=n[1];return e.split(`
|
|
4
|
+
`).map(a=>{let i=a.match(s.other.beginningSpace);if(i===null)return a;let[o]=i;return o.length>=r.length?a.slice(r.length):a}).join(`
|
|
5
|
+
`)}var Z=class{options;rules;lexer;constructor(t){this.options=t||R}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let s=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?s:P(s,`
|
|
6
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let s=e[0],n=St(s,e[3]||"",this.rules);return{type:"code",raw:s,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:n}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let s=e[2].trim();if(this.rules.other.endingHash.test(s)){let n=P(s,"#");(this.options.pedantic||!n||this.rules.other.endingSpaceChar.test(n))&&(s=n.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:s,tokens:this.lexer.inline(s)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:P(e[0],`
|
|
7
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let s=P(e[0],`
|
|
8
|
+
`).split(`
|
|
9
|
+
`),n="",r="",a=[];for(;s.length>0;){let i=!1,o=[],l;for(l=0;l<s.length;l++)if(this.rules.other.blockquoteStart.test(s[l]))o.push(s[l]),i=!0;else if(!i)o.push(s[l]);else break;s=s.slice(l);let h=o.join(`
|
|
10
|
+
`),c=h.replace(this.rules.other.blockquoteSetextReplace,`
|
|
11
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");n=n?`${n}
|
|
12
|
+
${h}`:h,r=r?`${r}
|
|
13
|
+
${c}`:c;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,a,!0),this.lexer.state.top=p,s.length===0)break;let d=a.at(-1);if(d?.type==="code")break;if(d?.type==="blockquote"){let k=d,f=k.raw+`
|
|
14
|
+
`+s.join(`
|
|
15
|
+
`),v=this.blockquote(f);a[a.length-1]=v,n=n.substring(0,n.length-k.raw.length)+v.raw,r=r.substring(0,r.length-k.text.length)+v.text;break}else if(d?.type==="list"){let k=d,f=k.raw+`
|
|
16
|
+
`+s.join(`
|
|
17
|
+
`),v=this.list(f);a[a.length-1]=v,n=n.substring(0,n.length-d.raw.length)+v.raw,r=r.substring(0,r.length-k.raw.length)+v.raw,s=f.substring(a.at(-1).raw.length).split(`
|
|
18
|
+
`);continue}}return{type:"blockquote",raw:n,tokens:a,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let s=e[1].trim(),n=s.length>1,r={type:"list",raw:"",ordered:n,start:n?+s.slice(0,-1):"",loose:!1,items:[]};s=n?`\\d{1,9}\\${s.slice(-1)}`:`\\${s}`,this.options.pedantic&&(s=n?s:"[*+-]");let a=this.rules.other.listItemRegex(s),i=!1;for(;t;){let l=!1,h="",c="";if(!(e=a.exec(t))||this.rules.block.hr.test(t))break;h=e[0],t=t.substring(h.length);let p=vt(e[2].split(`
|
|
19
|
+
`,1)[0],e[1].length),d=t.split(`
|
|
20
|
+
`,1)[0],k=!p.trim(),f=0;if(this.options.pedantic?(f=2,c=p.trimStart()):k?f=e[1].length+1:(f=p.search(this.rules.other.nonSpaceChar),f=f>4?1:f,c=p.slice(f),f+=e[1].length),k&&this.rules.other.blankLine.test(d)&&(h+=d+`
|
|
21
|
+
`,t=t.substring(d.length+1),l=!0),!l){let v=this.rules.other.nextBulletRegex(f),oe=this.rules.other.hrRegex(f),ce=this.rules.other.fencesBeginRegex(f),he=this.rules.other.headingBeginRegex(f),Me=this.rules.other.htmlBeginRegex(f),De=this.rules.other.blockquoteBeginRegex(f);for(;t;){let O=t.split(`
|
|
22
|
+
`,1)[0],I;if(d=O,this.options.pedantic?(d=d.replace(this.rules.other.listReplaceNesting," "),I=d):I=d.replace(this.rules.other.tabCharGlobal," "),ce.test(d)||he.test(d)||Me.test(d)||De.test(d)||v.test(d)||oe.test(d))break;if(I.search(this.rules.other.nonSpaceChar)>=f||!d.trim())c+=`
|
|
23
|
+
`+I.slice(f);else{if(k||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ce.test(p)||he.test(p)||oe.test(p))break;c+=`
|
|
24
|
+
`+d}k=!d.trim(),h+=O+`
|
|
25
|
+
`,t=t.substring(O.length+1),p=I.slice(f)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(h)&&(i=!0)),r.items.push({type:"list_item",raw:h,task:!!this.options.gfm&&this.rules.other.listIsTask.test(c),loose:!1,text:c,tokens:[]}),r.raw+=h}let o=r.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let l of r.items){if(this.lexer.state.top=!1,l.tokens=this.lexer.blockTokens(l.text,[]),l.task){if(l.text=l.text.replace(this.rules.other.listReplaceTask,""),l.tokens[0]?.type==="text"||l.tokens[0]?.type==="paragraph"){l.tokens[0].raw=l.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),l.tokens[0].text=l.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let c=this.lexer.inlineQueue.length-1;c>=0;c--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[c].src)){this.lexer.inlineQueue[c].src=this.lexer.inlineQueue[c].src.replace(this.rules.other.listReplaceTask,"");break}}let h=this.rules.other.listTaskCheckbox.exec(l.raw);if(h){let c={type:"checkbox",raw:h[0]+" ",checked:h[0]!=="[ ]"};l.checked=c.checked,r.loose?l.tokens[0]&&["paragraph","text"].includes(l.tokens[0].type)&&"tokens"in l.tokens[0]&&l.tokens[0].tokens?(l.tokens[0].raw=c.raw+l.tokens[0].raw,l.tokens[0].text=c.raw+l.tokens[0].text,l.tokens[0].tokens.unshift(c)):l.tokens.unshift({type:"paragraph",raw:c.raw,text:c.raw,tokens:[c]}):l.tokens.unshift(c)}}if(!r.loose){let h=l.tokens.filter(p=>p.type==="space"),c=h.length>0&&h.some(p=>this.rules.other.anyLine.test(p.raw));r.loose=c}}if(r.loose)for(let l of r.items){l.loose=!0;for(let h of l.tokens)h.type==="text"&&(h.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let s=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),n=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:s,raw:e[0],href:n,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let s=we(e[1]),n=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
26
|
+
`):[],a={type:"table",raw:e[0],header:[],align:[],rows:[]};if(s.length===n.length){for(let i of n)this.rules.other.tableAlignRight.test(i)?a.align.push("right"):this.rules.other.tableAlignCenter.test(i)?a.align.push("center"):this.rules.other.tableAlignLeft.test(i)?a.align.push("left"):a.align.push(null);for(let i=0;i<s.length;i++)a.header.push({text:s[i],tokens:this.lexer.inline(s[i]),header:!0,align:a.align[i]});for(let i of r)a.rows.push(we(i,a.header.length).map((o,l)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:a.align[l]})));return a}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let s=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:s,tokens:this.lexer.inline(s)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let s=e[1].charAt(e[1].length-1)===`
|
|
27
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:s,tokens:this.lexer.inline(s)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let s=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(s)){if(!this.rules.other.endAngleBracket.test(s))return;let a=P(s.slice(0,-1),"\\");if((s.length-a.length)%2===0)return}else{let a=$t(e[2],"()");if(a===-2)return;if(a>-1){let i=(e[0].indexOf("!")===0?5:4)+e[1].length+a;e[2]=e[2].substring(0,a),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let n=e[2],r="";if(this.options.pedantic){let a=this.rules.other.pedanticHrefTitle.exec(n);a&&(n=a[1],r=a[3])}else r=e[3]?e[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(s)?n=n.slice(1):n=n.slice(1,-1)),ye(e,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let s;if((s=this.rules.inline.reflink.exec(t))||(s=this.rules.inline.nolink.exec(t))){let n=(s[2]||s[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[n.toLowerCase()];if(!r){let a=s[0].charAt(0);return{type:"text",raw:a,text:a}}return ye(s,r,s[0],this.lexer,this.rules)}}emStrong(t,e,s=""){let n=this.rules.inline.emStrongLDelim.exec(t);if(!(!n||!n[1]&&!n[2]&&!n[3]&&!n[4]||n[4]&&s.match(this.rules.other.unicodeAlphaNumeric))&&(!(n[1]||n[3])||!s||this.rules.inline.punctuation.exec(s))){let r=[...n[0]].length-1,a,i,o=r,l=0,h=n[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(h.lastIndex=0,e=e.slice(-1*t.length+r);(n=h.exec(e))!=null;){if(a=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!a)continue;if(i=[...a].length,n[3]||n[4]){o+=i;continue}else if((n[5]||n[6])&&r%3&&!((r+i)%3)){l+=i;continue}if(o-=i,o>0)continue;i=Math.min(i,i+o+l);let c=[...n[0]][0].length,p=t.slice(0,r+n.index+c+i);if(Math.min(r,i)%2){let k=p.slice(1,-1);return{type:"em",raw:p,text:k,tokens:this.lexer.inlineTokens(k)}}let d=p.slice(2,-2);return{type:"strong",raw:p,text:d,tokens:this.lexer.inlineTokens(d)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let s=e[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(s),r=this.rules.other.startingSpaceChar.test(s)&&this.rules.other.endingSpaceChar.test(s);return n&&r&&(s=s.substring(1,s.length-1)),{type:"codespan",raw:e[0],text:s}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,s=""){let n=this.rules.inline.delLDelim.exec(t);if(n&&(!n[1]||!s||this.rules.inline.punctuation.exec(s))){let r=[...n[0]].length-1,a,i,o=r,l=this.rules.inline.delRDelim;for(l.lastIndex=0,e=e.slice(-1*t.length+r);(n=l.exec(e))!=null;){if(a=n[1]||n[2]||n[3]||n[4]||n[5]||n[6],!a||(i=[...a].length,i!==r))continue;if(n[3]||n[4]){o+=i;continue}if(o-=i,o>0)continue;i=Math.min(i,i+o);let h=[...n[0]][0].length,c=t.slice(0,r+n.index+h+i),p=c.slice(r,-r);return{type:"del",raw:c,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let s,n;return e[2]==="@"?(s=e[1],n="mailto:"+s):(s=e[1],n=s),{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let s,n;if(e[2]==="@")s=e[0],n="mailto:"+s;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);s=e[0],e[1]==="www."?n="http://"+e[0]:n=e[0]}return{type:"link",raw:e[0],text:s,href:n,tokens:[{type:"text",raw:s,text:s}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let s=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:s}}}},w=class W{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||R,this.options.tokenizer=this.options.tokenizer||new Z,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let s={other:m,block:M.normal,inline:E.normal};this.options.pedantic?(s.block=M.pedantic,s.inline=E.pedantic):this.options.gfm&&(s.block=M.gfm,this.options.breaks?s.inline=E.breaks:s.inline=E.gfm),this.tokenizer.rules=s}static get rules(){return{block:M,inline:E}}static lex(e,s){return new W(s).lex(e)}static lexInline(e,s){return new W(s).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,`
|
|
28
|
+
`),this.blockTokens(e,this.tokens);for(let s=0;s<this.inlineQueue.length;s++){let n=this.inlineQueue[s];this.inlineTokens(n.src,n.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,s=[],n=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(m.tabCharGlobal," ").replace(m.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(i=>(r=i.call({lexer:this},e,s))?(e=e.substring(r.raw.length),s.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let i=s.at(-1);r.raw.length===1&&i!==void 0?i.raw+=`
|
|
29
|
+
`:s.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let i=s.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
30
|
+
`)?"":`
|
|
31
|
+
`)+r.raw,i.text+=`
|
|
32
|
+
`+r.text,this.inlineQueue.at(-1).src=i.text):s.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let i=s.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
33
|
+
`)?"":`
|
|
34
|
+
`)+r.raw,i.text+=`
|
|
35
|
+
`+r.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},s.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),s.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),s.push(r);continue}let a=e;if(this.options.extensions?.startBlock){let i=1/0,o=e.slice(1),l;this.options.extensions.startBlock.forEach(h=>{l=h.call({lexer:this},o),typeof l=="number"&&l>=0&&(i=Math.min(i,l))}),i<1/0&&i>=0&&(a=e.substring(0,i+1))}if(this.state.top&&(r=this.tokenizer.paragraph(a))){let i=s.at(-1);n&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(`
|
|
36
|
+
`)?"":`
|
|
37
|
+
`)+r.raw,i.text+=`
|
|
38
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):s.push(r),n=a.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let i=s.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
39
|
+
`)?"":`
|
|
40
|
+
`)+r.raw,i.text+=`
|
|
41
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):s.push(r);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw new Error(i)}}return this.state.top=!0,s}inline(e,s=[]){return this.inlineQueue.push({src:e,tokens:s}),s}inlineTokens(e,s=[]){this.tokenizer.lexer=this;let n=e,r=null;if(this.tokens.links){let l=Object.keys(this.tokens.links);if(l.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)l.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let a;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)a=r[2]?r[2].length:0,n=n.slice(0,r.index+a)+"["+"a".repeat(r[0].length-a-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,o="";for(;e;){i||(o=""),i=!1;let l;if(this.options.extensions?.inline?.some(c=>(l=c.call({lexer:this},e,s))?(e=e.substring(l.raw.length),s.push(l),!0):!1))continue;if(l=this.tokenizer.escape(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.tag(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.link(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(l.raw.length);let c=s.at(-1);l.type==="text"&&c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):s.push(l);continue}if(l=this.tokenizer.emStrong(e,n,o)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.codespan(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.br(e)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.del(e,n,o)){e=e.substring(l.raw.length),s.push(l);continue}if(l=this.tokenizer.autolink(e)){e=e.substring(l.raw.length),s.push(l);continue}if(!this.state.inLink&&(l=this.tokenizer.url(e))){e=e.substring(l.raw.length),s.push(l);continue}let h=e;if(this.options.extensions?.startInline){let c=1/0,p=e.slice(1),d;this.options.extensions.startInline.forEach(k=>{d=k.call({lexer:this},p),typeof d=="number"&&d>=0&&(c=Math.min(c,d))}),c<1/0&&c>=0&&(h=e.substring(0,c+1))}if(l=this.tokenizer.inlineText(h)){e=e.substring(l.raw.length),l.raw.slice(-1)!=="_"&&(o=l.raw.slice(-1)),i=!0;let c=s.at(-1);c?.type==="text"?(c.raw+=l.raw,c.text+=l.text):s.push(l);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return s}},N=class{options;parser;constructor(t){this.options=t||R}space(t){return""}code({text:t,lang:e,escaped:s}){let n=(e||"").match(m.notSpaceStart)?.[0],r=t.replace(m.endingNewline,"")+`
|
|
42
|
+
`;return n?'<pre><code class="language-'+$(n)+'">'+(s?r:$(r,!0))+`</code></pre>
|
|
43
|
+
`:"<pre><code>"+(s?r:$(r,!0))+`</code></pre>
|
|
44
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
45
|
+
${this.parser.parse(t)}</blockquote>
|
|
46
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
47
|
+
`}hr(t){return`<hr>
|
|
48
|
+
`}list(t){let e=t.ordered,s=t.start,n="";for(let i=0;i<t.items.length;i++){let o=t.items[i];n+=this.listitem(o)}let r=e?"ol":"ul",a=e&&s!==1?' start="'+s+'"':"";return"<"+r+a+`>
|
|
49
|
+
`+n+"</"+r+`>
|
|
50
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
51
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
52
|
+
`}table(t){let e="",s="";for(let r=0;r<t.header.length;r++)s+=this.tablecell(t.header[r]);e+=this.tablerow({text:s});let n="";for(let r=0;r<t.rows.length;r++){let a=t.rows[r];s="";for(let i=0;i<a.length;i++)s+=this.tablecell(a[i]);n+=this.tablerow({text:s})}return n&&(n=`<tbody>${n}</tbody>`),`<table>
|
|
53
|
+
<thead>
|
|
54
|
+
`+e+`</thead>
|
|
55
|
+
`+n+`</table>
|
|
56
|
+
`}tablerow({text:t}){return`<tr>
|
|
57
|
+
${t}</tr>
|
|
58
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),s=t.header?"th":"td";return(t.align?`<${s} align="${t.align}">`:`<${s}>`)+e+`</${s}>
|
|
59
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${$(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:s}){let n=this.parser.parseInline(s),r=be(t);if(r===null)return n;t=r;let a='<a href="'+t+'"';return e&&(a+=' title="'+$(e)+'"'),a+=">"+n+"</a>",a}image({href:t,title:e,text:s,tokens:n}){n&&(s=this.parser.parseInline(n,this.parser.textRenderer));let r=be(t);if(r===null)return $(s);t=r;let a=`<img src="${t}" alt="${$(s)}"`;return e&&(a+=` title="${$(e)}"`),a+=">",a}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):"escaped"in t&&t.escaped?t.text:$(t.text)}},ne=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},y=class F{options;renderer;textRenderer;constructor(e){this.options=e||R,this.options.renderer=this.options.renderer||new N,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ne}static parse(e,s){return new F(s).parse(e)}static parseInline(e,s){return new F(s).parseInline(e)}parse(e){this.renderer.parser=this;let s="";for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let i=r,o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){s+=o||"";continue}}let a=r;switch(a.type){case"space":{s+=this.renderer.space(a);break}case"hr":{s+=this.renderer.hr(a);break}case"heading":{s+=this.renderer.heading(a);break}case"code":{s+=this.renderer.code(a);break}case"table":{s+=this.renderer.table(a);break}case"blockquote":{s+=this.renderer.blockquote(a);break}case"list":{s+=this.renderer.list(a);break}case"checkbox":{s+=this.renderer.checkbox(a);break}case"html":{s+=this.renderer.html(a);break}case"def":{s+=this.renderer.def(a);break}case"paragraph":{s+=this.renderer.paragraph(a);break}case"text":{s+=this.renderer.text(a);break}default:{let i='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw new Error(i)}}}return s}parseInline(e,s=this.renderer){this.renderer.parser=this;let n="";for(let r=0;r<e.length;r++){let a=e[r];if(this.options.extensions?.renderers?.[a.type]){let o=this.options.extensions.renderers[a.type].call({parser:this},a);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(a.type)){n+=o||"";continue}}let i=a;switch(i.type){case"escape":{n+=s.text(i);break}case"html":{n+=s.html(i);break}case"link":{n+=s.link(i);break}case"image":{n+=s.image(i);break}case"checkbox":{n+=s.checkbox(i);break}case"strong":{n+=s.strong(i);break}case"em":{n+=s.em(i);break}case"codespan":{n+=s.codespan(i);break}case"br":{n+=s.br(i);break}case"del":{n+=s.del(i);break}case"text":{n+=s.text(i);break}default:{let o='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return n}},L=class{options;block;constructor(t){this.options=t||R}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(){return this.block?w.lex:w.lexInline}provideParser(){return this.block?y.parse:y.parseInline}},Tt=class{defaults=X();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=y;Renderer=N;TextRenderer=ne;Lexer=w;Tokenizer=Z;Hooks=L;constructor(...t){this.use(...t)}walkTokens(t,e){let s=[];for(let n of t)switch(s=s.concat(e.call(this,n)),n.type){case"table":{let r=n;for(let a of r.header)s=s.concat(this.walkTokens(a.tokens,e));for(let a of r.rows)for(let i of a)s=s.concat(this.walkTokens(i.tokens,e));break}case"list":{let r=n;s=s.concat(this.walkTokens(r.items,e));break}default:{let r=n;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(a=>{let i=r[a].flat(1/0);s=s.concat(this.walkTokens(i,e))}):r.tokens&&(s=s.concat(this.walkTokens(r.tokens,e)))}}return s}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach(s=>{let n={...s};if(n.async=this.defaults.async||n.async||!1,s.extensions&&(s.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let a=e.renderers[r.name];a?e.renderers[r.name]=function(...i){let o=r.renderer.apply(this,i);return o===!1&&(o=a.apply(this,i)),o}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let a=e[r.level];a?a.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),n.extensions=e),s.renderer){let r=this.defaults.renderer||new N(this.defaults);for(let a in s.renderer){if(!(a in r))throw new Error(`renderer '${a}' does not exist`);if(["options","parser"].includes(a))continue;let i=a,o=s.renderer[i],l=r[i];r[i]=(...h)=>{let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c||""}}n.renderer=r}if(s.tokenizer){let r=this.defaults.tokenizer||new Z(this.defaults);for(let a in s.tokenizer){if(!(a in r))throw new Error(`tokenizer '${a}' does not exist`);if(["options","rules","lexer"].includes(a))continue;let i=a,o=s.tokenizer[i],l=r[i];r[i]=(...h)=>{let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c}}n.tokenizer=r}if(s.hooks){let r=this.defaults.hooks||new L;for(let a in s.hooks){if(!(a in r))throw new Error(`hook '${a}' does not exist`);if(["options","block"].includes(a))continue;let i=a,o=s.hooks[i],l=r[i];L.passThroughHooks.has(a)?r[i]=h=>{if(this.defaults.async&&L.passThroughHooksRespectAsync.has(a))return(async()=>{let p=await o.call(r,h);return l.call(r,p)})();let c=o.call(r,h);return l.call(r,c)}:r[i]=(...h)=>{if(this.defaults.async)return(async()=>{let p=await o.apply(r,h);return p===!1&&(p=await l.apply(r,h)),p})();let c=o.apply(r,h);return c===!1&&(c=l.apply(r,h)),c}}n.hooks=r}if(s.walkTokens){let r=this.defaults.walkTokens,a=s.walkTokens;n.walkTokens=function(i){let o=[];return o.push(a.call(this,i)),r&&(o=o.concat(r.call(this,i))),o}}this.defaults={...this.defaults,...n}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return w.lex(t,e??this.defaults)}parser(t,e){return y.parse(t,e??this.defaults)}parseMarkdown(t){return(e,s)=>{let n={...s},r={...this.defaults,...n},a=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&n.async===!1)return a(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 e>"u"||e===null)return a(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return a(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(e):e,o=await(r.hooks?await r.hooks.provideLexer():t?w.lex:w.lexInline)(i,r),l=r.hooks?await r.hooks.processAllTokens(o):o;r.walkTokens&&await Promise.all(this.walkTokens(l,r.walkTokens));let h=await(r.hooks?await r.hooks.provideParser():t?y.parse:y.parseInline)(l,r);return r.hooks?await r.hooks.postprocess(h):h})().catch(a);try{r.hooks&&(e=r.hooks.preprocess(e));let i=(r.hooks?r.hooks.provideLexer():t?w.lex:w.lexInline)(e,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let o=(r.hooks?r.hooks.provideParser():t?y.parse:y.parseInline)(i,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(i){return a(i)}}}onError(t,e){return s=>{if(s.message+=`
|
|
60
|
+
Please report this to https://github.com/markedjs/marked.`,t){let n="<p>An error occurred:</p><pre>"+$(s.message+"",!0)+"</pre>";return e?Promise.resolve(n):n}if(e)return Promise.reject(s);throw s}}},T=new Tt;function g(t,e){return T.parse(t,e)}g.options=g.setOptions=function(t){return T.setOptions(t),g.defaults=T.defaults,$e(g.defaults),g};g.getDefaults=X;g.defaults=R;g.use=function(...t){return T.use(...t),g.defaults=T.defaults,$e(g.defaults),g};g.walkTokens=function(t,e){return T.walkTokens(t,e)};g.parseInline=T.parseInline;g.Parser=y;g.parser=y.parse;g.Renderer=N;g.TextRenderer=ne;g.Lexer=w;g.lexer=w.lex;g.Tokenizer=Z;g.Hooks=L;g.parse=g;var Yt=g.options,es=g.setOptions,ts=g.use,ss=g.walkTokens,rs=g.parseInline;var ns=y.parse,is=w.lex;function At(t){if(!t)return"";try{return g.parse(t,{async:!1,breaks:!0})}catch{return t}}function It(t){if(t.data.type!=="navigation")return null;let e=t.data.relevantLinks||[];return!t.data.suggestedLink&&!e.length?null:x`<div class="msg-nav-links">${t.data.suggestedLink&&x`<div class="msg-link-row"><calcite-link .href=${t.data.suggestedLink} target=_blank icon-start=launch>${Pe(t.data.suggestedLink,"Suggested")}</calcite-link></div>`||""}${e.length>0&&x`<ul class="msg-links-list">${ge(e,s=>`${s}-${index}`,(s,n)=>x`<li><calcite-link .href=${s} target=_blank icon-start=launch>${Pe(s,"Relevant")}</calcite-link></li>`)}</ul>`||""}</div>`}function _t(t){let{message:e,user:s}=t,n=e.role==="user",r=e.role==="assistant",a=e.role==="assistant"?e.data.summary:e.text,i=At(a);return x`<div class=${q({"bubble-row":!0,"bubble-row__user":n,"bubble-row__assistant":r})} role=listitem aria-label=${`${e.role} message`}><div class=${q(U("avatar",n&&"avatar__user",r&&"avatar__assistant"))}>${n?x`<calcite-avatar .username=${s.username??"User"} .thumbnail=${s.thumbnailUrl||void 0} .userId=${s.id} .fullName=${s.fullName||void 0}></calcite-avatar>`:x`<calcite-chip .icon=${r?"effects":"information-letter"} label appearance=outline-fill .kind=${r?"brand":"neutral"}></calcite-chip>`}</div><div class=${q(U("msg",n&&"msg__user",r&&"msg__assistant"))}><div class="msg-text">${fe(i)}</div>${r?It(e):null}</div></div>`}function Pe(t,e){try{let s=new URL(t);return e==="Suggested"?`${e}: ${s.hostname}`:s.hostname}catch{return e}}var zt=V`.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}.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}`;function b(t){return typeof t=="object"&&t!==null}var ae="http://127.0.0.1:9015",Et=`${ae}/v1/turn/stream`;function Pt(t){return`${ae}/v1/users/${encodeURIComponent(t)}/threads`}function Lt(t){return`${ae}/v1/threads/${encodeURIComponent(t)}/messages`}async function Ct(t,e){let s=await fetch(Pt(t),{signal:e});if(!s.ok)throw new Error(`Thread list request failed with status ${s.status}.`);let n=await s.json();if(!b(n))throw new Error("Thread list response is invalid.");let r=n.userId,a=qe(n.threads);if(typeof r!="string"||!a)throw new Error("Thread list response is invalid.");return{userId:r,threads:a.map(qt).filter(i=>i!==null)}}async function Bt(t,e){let s=await fetch(Lt(t),{signal:e});if(!s.ok)throw new Error(`Thread messages request failed with status ${s.status}.`);let n=await s.json();if(!b(n))throw new Error("Thread messages response is invalid.");let r=n.threadId,a=qe(n.messages);if(typeof r!="string"||!a)throw new Error("Thread messages response is invalid.");return{threadId:r,messages:a.map(Mt).filter(i=>i!==null)}}function qe(t){return Array.isArray(t)?t:null}function qt(t){if(!b(t))return null;let e=t.threadId,s=t.lastActivityAtMs;return typeof e!="string"||typeof s!="number"?null:{threadId:e,lastActivityAtMs:s}}function Mt(t){if(!b(t))return null;let e=t.id,s=t.role,n=t.content,r=t.type;if(typeof e!="string"||typeof s!="string"||typeof n!="string"||typeof r!="string")return null;let a=typeof t.checkpointNs=="string"?t.checkpointNs:void 0,i=typeof t.checkpointId=="string"?t.checkpointId:void 0;return{id:e,role:s,content:n,type:r,checkpointNs:a,checkpointId:i}}function Dt(t){return b(t)?typeof t.id=="string"&&typeof t.role=="string"&&typeof t.content=="string"&&typeof t.type=="string":!1}function Zt(t){return!b(t)||typeof t.userId!="string"||!Array.isArray(t.threads)?!1:t.threads.every(e=>b(e)&&typeof e.threadId=="string"&&typeof e.lastActivityAtMs=="number")}function Nt(t){return b(t)&&typeof t.threadId=="string"&&Array.isArray(t.messages)&&t.messages.every(Dt)}function jt(t){return t.role==="assistant"?{id:t.id,role:"assistant",data:{type:t.type==="navigation"?"navigation":"analytics",summary:t.content}}:t.role==="user"?{id:t.id,role:"user",text:t.content}:{id:t.id,role:"system",text:t.content}}function Qt(t){return typeof t!="object"||t===null||!("type"in t)||!("summary"in t)?!1:(t.type==="analytics"||t.type==="navigation")&&typeof t.summary=="string"}async function Ot(t){let e=t?.id||t?.username;if(!e)return null;let s=await Ct(e);if(!Zt(s))throw new Error("User threads response is invalid.");let n=s.threads[0]?.threadId;if(!n)return null;let r=await Bt(n);if(!Nt(r))throw new Error("Thread messages response is invalid.");return{threadId:n,messages:r.messages.map(jt)}}var Vt=V`: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)}.composer{background-color:var(--calcite-color-foreground-1);>*:has(*){border-width:0px;border-top-width:1px;border-style:solid;border-color:var(--calcite-color-border-3)}}.composer__input{padding:.75rem}.composer__footer{display:flex;align-items:center;justify-content:end;padding:.75rem;& p{margin:0}}.composer__actions{display:flex;gap:.5rem}.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%}@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 Ht(t,e,s,n){let r=t?.id||"",a=Rt.findCredential(t.url)?.token??"",i=window.location.origin||window.location.href.replace(/#.*$/u,""),o=e?.username||t?.user?.username||"";return{threadId:s,userMessage:n,portalId:r,token:a,tokenReferrer:i,username:o}}function le(t){if(!b(t)||typeof t.type!="string"||typeof t.summary!="string")throw new Error("Assistant response must include type and summary fields.");if(t.type!=="analytics"&&t.type!=="navigation")throw new Error("Assistant response type must be either analytics or navigation.");let e=t.type==="navigation"&&Array.isArray(t.relevant_links)?t.relevant_links.filter(n=>typeof n=="string"&&!!n):[],s=t.type==="navigation"&&typeof t.suggested_link=="string"&&t.suggested_link?t.suggested_link:void 0;return t.type==="analytics"?{type:"analytics",summary:t.summary}:{type:"navigation",summary:t.summary,suggestedLink:s,relevantLinks:e}}var Ut=["thinking","routing","running-analytic","running-navigation","summarizing","saving-state","completed","error"];function Gt(t){return typeof t=="string"&&Ut.includes(t)}function Wt(t){return b(t)?(t.type==="analytics"||t.type==="navigation")&&typeof t.summary=="string":!1}function Ft(t){return t.replace(/\r\n?/gu,`
|
|
61
|
+
`)}function Le(t,e=!1){let s=Ft(t).split(`
|
|
62
|
+
|
|
63
|
+
`),n=e?"":s.pop()??"";return{blocks:s.map(r=>r.trim()).filter(Boolean),remainder:n}}function Ce(t){if(!b(t))return null;let e=t.status;if(!Gt(e))return null;let s=t.threadId;if(typeof s!="string")return null;if(e==="completed"){let n=t.response;return Wt(n)?{status:"completed",threadId:s,response:le(n)}:null}return e==="error"?typeof t.errorCode!="string"?null:{status:e,threadId:s,errorCode:t.errorCode,message:typeof t.message=="string"||t.message===null?t.message:void 0}:{status:e,threadId:s}}function Be(t){let e=t.trim();if(!e)return null;let s="message",n=[];for(let i of e.split(`
|
|
64
|
+
`)){let o=i.trimEnd();if(!(!o||o.startsWith(":"))){if(o.startsWith("event:")){s=o.slice(6).trim();continue}o.startsWith("data:")&&n.push(o.slice(5).trimStart())}}if(s!=="runtime"||!n.length)return null;let r=JSON.parse(n.join(`
|
|
65
|
+
`)),a=null;if(b(r)&&r.event==="runtime"?a=Ce(r.data):a=Ce(r),!a)throw new Error("Assistant stream event is invalid.");return{event:"runtime",data:a}}async function*Xt(t){let e=new TextDecoder,s="";for await(let n of t){s+=e.decode(n,{stream:!0});let r=Le(s);s=r.remainder;for(let a of r.blocks){let i=Be(a);i&&(yield i)}}if(s+=e.decode(),s.trim()){let n=Le(s,!0);for(let r of n.blocks){let a=Be(r);a&&(yield a)}}}function Jt(t){let e=t.data;if(e.status==="error")throw new Error(e.message??"Assistant stream reported an error.");return e.status==="completed"?{kind:"complete",status:"completed",data:le(e.response),threadId:e.threadId}:{kind:"progress",status:e.status,payload:e,threadId:e.threadId}}async function Kt({portal:t,user:e,userMessage:s,threadId:n,onStatus:r,signal:a}){let i=Ht(t,e,n,s),o=await fetch(Et,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({threadId:i.threadId,userMessage:i.userMessage,portalId:i.portalId,username:i.username,token:i.token,tokenReferrer:i.tokenReferrer}),signal:a});if(!o.ok)throw new Error(`Assistant stream request failed with status ${o.status}.`);if(!o.body)throw new Error("Assistant stream response body is missing.");let l,h=i.threadId;for await(let c of Xt(o.body)){let p=Jt(c);if(p.kind==="progress"){r?.(p.status,p.payload),p.threadId&&(h=p.threadId);continue}r?.(p.status,void 0),l=p.data,p.threadId&&(h=p.threadId)}if(l===void 0)throw new Error("Assistant stream ended without completed event data.");if(!h)throw new Error("Assistant response is missing threadId.");return{data:le(l),threadId:h}}var ie=class extends pe{constructor(){super(...arguments),this.t9n=de({blocking:!0}),this.textAreaEl=_(),this.voiceInputEl=_(),this.formEl=_(),this.chatAnchorEl=_(),this.hasLoadedThreadMessages=!1,this.refocusInput=async()=>{await this.updateComplete,this.textAreaEl.value?.focusTextArea()},this.setPanelAttribute=()=>{this.isPanelExpanded?this.el.setAttribute("expanded",String(this.isPanelExpanded)):this.el.removeAttribute("expanded")},this.togglePanel=()=>{let e=!this.isPanelExpanded;this.isPanelExpanded=e,this.arcgisAiAssistantPanelToggle.emit(e),this.setPanelAttribute()},this.initializeThreadMessages=async()=>{if(!(this.hasLoadedThreadMessages||!(this.user?.id||this.user?.username))){this.hasLoadedThreadMessages=!0;try{let e=await Ot(this.user);if(!e?.threadId)return;this.threadId=e.threadId,this.messages=e.messages}catch(e){this.hasLoadedThreadMessages=!1,console.error("Failed to initialize assistant threads.",e)}}},this.getStatusLabel=e=>{let{t9n:{status:s}}=this;switch(e){case"thinking":return s.thinking;case"routing":return s.routing;case"running-analytic":return s.runningAnalytic;case"running-navigation":return s.runningNavigation;case"summarizing":return s.summarizing;case"saving-state":return s.savingState;case"completed":return s.completed;case"error":return this.t9n.streamErrorOccurred;default:return s.waitingForResponse}},this.onSend=async()=>{let e=this.inputText.trim();if(!(!e||this.isSending)){this.isListening&&await this.voiceInputEl.value?.stopListening(),this.arcgisAiAssistantSend.emit({text:e}),this.messages=[...this.messages,{id:B(),role:"user",text:e}],this.inputText="",this.isSending=!0,this.isThinking=!0,this.streamStatus=this.t9n.status.waitingForResponse;try{let{portal:s,user:n,threadId:r}=this,a=await Kt({portal:s,user:n,userMessage:e,threadId:r,onStatus:o=>{this.streamStatus=this.getStatusLabel(o)}});if(typeof a!="object"||a===null||!("data"in a)||!Qt(a.data))throw new Error("Assistant response is invalid.");let i="threadId"in a&&typeof a.threadId=="string"?a.threadId:void 0;i&&(this.threadId=i),this.messages=[...this.messages,{id:B(),role:"assistant",data:a.data}]}catch(s){console.error(this.t9n.errorSendingTurn,s),this.messages=[...this.messages,{id:B(),role:"system",text:this.t9n.somethingWentWrong,error:!0}]}finally{this.isSending=!1,this.isThinking=!1,this.streamStatus=null,this.refocusInput()}}},this.isSending=!1,this.isThinking=!1,this.streamStatus=null,this.messages=[],this.inputText="",this.showVoiceInput=!0,this.isListening=!1,this.isVoiceInputDisabled=!1,this.isPanelExpanded=!1,this.defaultClosed=!1,this.openEntitiesInNewTab=!1,this.arcgisAiAssistantPanelToggle=H(),this.arcgisAiAssistantSend=H()}static{this.properties={isSending:16,isThinking:16,streamStatus:16,messages:16,inputText:16,showVoiceInput:16,isListening:16,isVoiceInputDisabled:16,isPanelExpanded:16,threadId:16,portal:0,user:0,config:0,defaultClosed:5,openEntitiesInNewTab:5}}static{this.styles=[Vt,zt]}load(){this.setPanelAttribute(),this.initializeThreadMessages()}connectedCallback(){super.connectedCallback(),this.isPanelExpanded=!this.defaultClosed}willUpdate(e){e.has("user")&&this.initializeThreadMessages(),e.has("messages")&&requestAnimationFrame(()=>this.scrollToBottom(!0))}scrollToBottom(e=!0){let s=this.chatAnchorEl.value;s&&this.updateComplete.then(()=>{s.scrollIntoView({behavior:e?"smooth":"auto",block:"end"})})}renderBubble(e){return _t({message:e,user:this.user})}renderComposer(){let{onSend:e,showVoiceInput:s,isListening:n,isVoiceInputDisabled:r,isSending:a,formEl:i,inputText:o,portal:l,user:h,t9n:c}=this;return x`<form class="composer" @submit=${p=>{p.preventDefault(),e()}} ${z(this.formEl)}><div class="composer__input"><arcgis-portal-mentionable-text-area .popoverListLabel=${c.mentionEntities} .portal=${l} .user=${h} @arcgisUserMentionableTextAreaKeyDown=${({detail:p})=>{p.key==="Enter"&&!p.shiftKey&&(p.preventDefault(),i.value?.requestSubmit())}} .value=${o} .placeholder=${c.askMeAQuestionPlaceholder} @arcgisUserMentionableTextAreaChange=${p=>{this.inputText=p.detail??""}} .disabled=${a} rows=3 ${z(this.textAreaEl)}></arcgis-portal-mentionable-text-area></div><div class="composer__footer"><div class="composer__actions"><arcgis-portal-voice-input @arcgisVoiceInputStart=${()=>{this.isListening=!0,this.isVoiceInputDisabled=!1}} @arcgisVoiceInputStop=${()=>{this.isListening=!1,this.isVoiceInputDisabled=!1}} @arcgisVoiceInputError=${p=>{p.detail.errorCode==="not-supported"&&(this.showVoiceInput=!1)}} @arcgisVoiceInputInterimTranscription=${p=>{this.inputText=p.detail.text}} ${z(this.voiceInputEl)}></arcgis-portal-voice-input>${s&&x`<calcite-button icon-start=microphone .label=${c.voiceInput} round .disabled=${r||a} .appearance=${n?"solid":"outline-fill"} @click=${async()=>{this.isVoiceInputDisabled=!0;let p=this.voiceInputEl.value;n?await p?.stopListening():await p?.startListening()}}></calcite-button>`||""}<calcite-button type=submit appearance=solid round icon-start=send .disabled=${!this.inputText?.trim()||a} .label=${this.isSending?c.status.sending:c.send}></calcite-button></div></div></form>`}render(){let{isPanelExpanded:e,messages:s,isThinking:n,streamStatus:r,t9n:a}=this;return x`<calcite-panel icon=effects collapsible .collapsed=${!e} collapse-direction=up .heading=${a.heading} @calcitePanelToggle=${this.togglePanel}><div class="panel__body"><div class="chat-container"><div class="chat-container__inner">${s.map(i=>this.renderBubble(i))}${n&&x`<div class="thinking-container"><div class="thinking-container__header"><calcite-loader .label=${r??a.status.waitingForResponse} inline scale=l class="loader"></calcite-loader><calcite-chip icon=effects .label=${a.status.thinking} appearance=outline kind=neutral></calcite-chip></div><div class="thinking-text">${r}</div></div>`||""}<div class="spacer" ${z(this.chatAnchorEl)}></div></div></div><div slot=footer>${this.renderComposer()}</div></div></calcite-panel>`}};ue("arcgis-portal-ai-assistant",ie);return ie},"identity/IdentityManager")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"heading":"ArcGIS Portal Assistant","placeholder":"Ask a question or mention @people, #items, and $groups","askMeAQuestionPlaceholder":"Ask me a question...","emptyStateMessage":"Ask a question about your portal content to start the conversation.","entryMessage":"Responses are generated from a local assistant service and your current portal context.","send":"Send","
|
|
1
|
+
{"heading":"ArcGIS Portal Assistant","placeholder":"Ask a question or mention @people, #items, and $groups","askMeAQuestionPlaceholder":"Ask me a question...","emptyStateMessage":"Ask a question about your portal content to start the conversation.","entryMessage":"Responses are generated from a local assistant service and your current portal context.","send":"Send","stop":"Stop","session":"Session","missingContext":"Portal id, username, or token is unavailable.","requestFailed":"Assistant request failed.","thinking":"Thinking","searchHitsHeading":"Search Hits","foundHitsMessage":"Found {total} hits. Displaying top {top} results:","runAction":"Run Action","voiceInput":"Voice Input","somethingWentWrong":"Sorry, something went wrong.","streamErrorOccurred":"Stream error occurred","noFinalTurnDataReceived":"No final turn data received","errorSendingTurn":"Error sending turn:","genieNavigateEvent":"Genie navigate event:","mentionEntities":"Mention entities","status":{"sending":"Sending...","thinking":"Thinking...","waitingForResponse":"Waiting for response...","routing":"Routing...","runningAnalytic":"Analyzing...","runningNavigation":"Finding the suitable place to navigate...","summarizing":"Summarizing...","savingState":"Saving state...","completed":"Completed!"}}
|
package/dist/cdn/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{O as t,y as e}from"./GWHFVZ3O.js";var a=e(t,{"arcgis-portal-ai-assistant":[()=>import("./
|
|
2
|
+
import{O as t,y as e}from"./GWHFVZ3O.js";var a=e(t,{"arcgis-portal-ai-assistant":[()=>import("./O5AQSFQM.js"),"config:,defaultClosed,openEntitiesInNewTab,portal:,t9n:,user:"],"arcgis-portal-classification-banner":[()=>import("./EVOIJL6Z.js"),"autoDestroyDisabled,messages:,missingExistingClassification,portalItem:,validationErrors,variant;destroy"],"arcgis-portal-classification-config":[()=>import("./MEE5ZP4M.js"),"autoDestroyDisabled,messages:,portalItem:,status,valid,values;destroy,resetForm,validateForm"],"arcgis-portal-classification-favorite":[()=>import("./TZYWAETV.js"),"attributeExpressionResults:,classificationValue:,favoriteClassifications:,messages:,portalItem:,resetFavoriteClassification:,selectedFavoriteClassificationName,updateClassificationData:"],"arcgis-portal-classification-form-element":[()=>import("./DBENQABR.js"),"attribute:,attributeKey,isRequiredErrors:,messages:,renderingInfo:,value:"],"arcgis-portal-extent-picker":[()=>import("./RBDKEFSK.js"),"active,contentOnly,extentService,extentValue:,isArea,itemId,messages:,portal:;;getExtent"],"arcgis-portal-extent-picker-coord-field":[()=>import("./UVUVRFDE.js"),"errorMessage,inputId,label,max,min,relatedErrorMessage,validateRelated:,value;;checkRelatedField,isValid,setFocus"],"arcgis-portal-field-delete":[()=>import("./PA26Q7CJ.js"),"config:,fieldNames:,layer:,mapView:,messages:,options:"],"arcgis-portal-mentionable-text-area":[()=>import("./37ZQQP3E.js"),"disabled,maxLength,placeholder,popoverListLabel,popoverPlacement,portal:,readOnly,rows,scale,starters:,user:,value;closePopover,focusTextArea,selectItem"],"arcgis-portal-replacement-item-redirect":[()=>import("./JA7IJOC7.js"),"itemId,portal:,t9n:,user:;setFocus"],"arcgis-user-avatar":[()=>import("./JI4ITHDM.js"),"checkOnline,description,heading,messages:,portal:,scale,showAvatar,showName,underline,user:,username,wrap"],"arcgis-portal-voice-input":[()=>import("./YNYDJOWH.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-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)
|
|
@@ -24,10 +24,8 @@ export abstract class ArcgisPortalAiAssistant extends LitElement {
|
|
|
24
24
|
emptyStateMessage: string;
|
|
25
25
|
entryMessage: string;
|
|
26
26
|
send: string;
|
|
27
|
-
sending: string;
|
|
28
27
|
stop: string;
|
|
29
28
|
session: string;
|
|
30
|
-
waitingForResponse: string;
|
|
31
29
|
missingContext: string;
|
|
32
30
|
requestFailed: string;
|
|
33
31
|
thinking: string;
|
|
@@ -41,6 +39,17 @@ export abstract class ArcgisPortalAiAssistant extends LitElement {
|
|
|
41
39
|
errorSendingTurn: string;
|
|
42
40
|
genieNavigateEvent: string;
|
|
43
41
|
mentionEntities: string;
|
|
42
|
+
status: {
|
|
43
|
+
sending: string;
|
|
44
|
+
thinking: string;
|
|
45
|
+
waitingForResponse: string;
|
|
46
|
+
routing: string;
|
|
47
|
+
runningAnalytic: string;
|
|
48
|
+
runningNavigation: string;
|
|
49
|
+
summarizing: string;
|
|
50
|
+
savingState: string;
|
|
51
|
+
completed: string;
|
|
52
|
+
};
|
|
44
53
|
} & T9nMeta<{
|
|
45
54
|
heading: string;
|
|
46
55
|
placeholder: string;
|
|
@@ -48,10 +57,8 @@ export abstract class ArcgisPortalAiAssistant extends LitElement {
|
|
|
48
57
|
emptyStateMessage: string;
|
|
49
58
|
entryMessage: string;
|
|
50
59
|
send: string;
|
|
51
|
-
sending: string;
|
|
52
60
|
stop: string;
|
|
53
61
|
session: string;
|
|
54
|
-
waitingForResponse: string;
|
|
55
62
|
missingContext: string;
|
|
56
63
|
requestFailed: string;
|
|
57
64
|
thinking: string;
|
|
@@ -65,6 +72,17 @@ export abstract class ArcgisPortalAiAssistant extends LitElement {
|
|
|
65
72
|
errorSendingTurn: string;
|
|
66
73
|
genieNavigateEvent: string;
|
|
67
74
|
mentionEntities: string;
|
|
75
|
+
status: {
|
|
76
|
+
sending: string;
|
|
77
|
+
thinking: string;
|
|
78
|
+
waitingForResponse: string;
|
|
79
|
+
routing: string;
|
|
80
|
+
runningAnalytic: string;
|
|
81
|
+
runningNavigation: string;
|
|
82
|
+
summarizing: string;
|
|
83
|
+
savingState: string;
|
|
84
|
+
completed: string;
|
|
85
|
+
};
|
|
68
86
|
}>;
|
|
69
87
|
accessor user: PortalUser;
|
|
70
88
|
readonly arcgisAiAssistantPanelToggle: import("@arcgis/lumina").TargetedEvent<this, boolean>;
|