@maggioli-rd/aicore-agent-chat 1.3.0 → 2.0.0
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/README.md +15 -14
- package/dist/aicore-agent-chat.js +141 -48
- package/dist/aicore-agent-chat.js.map +1 -1
- package/dist/bundle/a2ui-C-LAbJcp.js +87 -0
- package/dist/bundle/backstage-Bfl3Tyo5.js +86 -0
- package/dist/chunks/{a2ui-BLaPxJ9N.js → a2ui-Da_YceSP.js} +4 -4
- package/dist/chunks/{a2ui-BLaPxJ9N.js.map → a2ui-Da_YceSP.js.map} +1 -1
- package/dist/chunks/backstage-TkKENlNl.js +1008 -0
- package/dist/chunks/backstage-TkKENlNl.js.map +1 -0
- package/dist/chunks/{core-Db3hnKpM.js → core-4PRAI1Mt.js} +60 -5
- package/dist/chunks/core-4PRAI1Mt.js.map +1 -0
- package/dist/chunks/{rich-C2iN_5zh.js → rich-CdNA4NuG.js} +4 -4
- package/dist/chunks/rich-CdNA4NuG.js.map +1 -0
- package/dist/chunks/{src-Blgo9nVC.js → src-PkQozp4M.js} +369 -82
- package/dist/chunks/src-PkQozp4M.js.map +1 -0
- package/dist/chunks/{vega-BkX1Fjq6.js → vega-B07F6TI4.js} +2 -2
- package/dist/chunks/{vega-BkX1Fjq6.js.map → vega-B07F6TI4.js.map} +1 -1
- package/dist/core.js +1 -1
- package/dist/define.js +3 -3
- package/dist/index.js +3 -3
- package/dist/types/core/session.d.ts +31 -0
- package/dist/types/element/backstage/index.d.ts +10 -0
- package/dist/types/element/backstage/log.d.ts +13 -0
- package/dist/types/element/backstage/map.d.ts +12 -0
- package/dist/types/element/backstage/timing.d.ts +51 -0
- package/dist/types/element/i18n.d.ts +48 -4
- package/dist/types/element/icons.d.ts +3 -0
- package/dist/types/element/index.d.ts +15 -5
- package/dist/types/element/rich/index.d.ts +6 -0
- package/dist/types/element/styles.d.ts +1 -1
- package/dist/types/element/team.d.ts +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jsx.d.ts +1 -1
- package/package.json +2 -2
- package/dist/bundle/a2ui-C3GhjTrJ.js +0 -113
- package/dist/chunks/core-Db3hnKpM.js.map +0 -1
- package/dist/chunks/rich-C2iN_5zh.js.map +0 -1
- package/dist/chunks/src-Blgo9nVC.js.map +0 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var t=class extends Error{status;kind;errorCode;requestId;retryAfter;authDescription;constructor(e,t){super(e.message||`HTTP ${e.status}`),this.name=`AicoreError`,this.status=e.status,this.errorCode=e.errorCode,this.requestId=e.requestId,this.retryAfter=e.retryAfter,this.authDescription=e.authDescription,this.kind=t??r(e)}},n=/* @__PURE__ */ new Set([`tenant_required`,`tenant_not_allowed`,`tenant_not_registered`]);function r({status:e,errorCode:t}){return e===0?`network`:t&&n.has(t)?`tenant_refused`:e===401?`auth_required`:e===403?`forbidden`:e===404?`not_found`:e===409?`busy`:e===423?`locked`:e===429?`rate_limited`:`http`}function i(e){return e instanceof t?e:new t({status:0,message:String(e)})}function a(e,t){return e instanceof DOMException&&e.name===`AbortError`||t?.aborted===!0}function o(e){if(!e)return{};let t=t=>RegExp(`${t}="([^"]*)"`).exec(e)?.[1];return{error:t(`error`),description:t(`error_description`)}}function s(e){return e.status===401&&o(e.headers.get(`WWW-Authenticate`)).error===`invalid_token`}async function c(n){let r=n.headers.get(`Retry-After`)?.trim(),i={status:n.status,message:``,requestId:n.headers.get(`X-Request-Id`)??void 0,retryAfter:r&&/^\d+$/.test(r)?Number(r):void 0,authDescription:o(n.headers.get(`WWW-Authenticate`)).description};try{let t=await n.json();if(e(t)){let e=[];typeof t.message==`string`&&t.message&&e.push(t.message),typeof t.detail==`string`&&t.detail&&e.push(t.detail),i.message=[...new Set(e)].join(`: `),typeof t.error_code==`string`&&(i.errorCode=t.error_code),typeof t.request_id==`string`&&(i.requestId=t.request_id)}}catch{}return new t(i)}var l=class{#e=``;#t=``;#n=[];#r;#i=!1;push(e){let t=e;this.#i&&t.startsWith(`
|
|
2
2
|
`)&&(t=t.slice(1)),this.#i=!1,this.#e+=t;let n=[],r=/\r\n|\r|\n/g,i=0,a;for(;(a=r.exec(this.#e))!==null;){if(a[0]===`\r`&&a.index===this.#e.length-1){this.#i=!0;let e=this.#a(this.#e.slice(i,a.index));e&&n.push(e),i=this.#e.length;break}let e=this.#a(this.#e.slice(i,a.index));e&&n.push(e),i=a.index+a[0].length}return this.#e=this.#e.slice(i),n}end(){this.#e=``,this.#s()}#a(e){if(e===``)return this.#o();if(e.startsWith(`:`))return null;let t=e.indexOf(`:`),n=t>=0?e.slice(0,t):e,r=t>=0?e.slice(t+1):``;return r.startsWith(` `)&&(r=r.slice(1)),n===`event`?this.#t=r:n===`data`?this.#n.push(r):n===`id`&&!r.includes(`\0`)&&(this.#r=r),null}#o(){if(this.#n.length===0&&this.#t===``)return this.#s(),null;let e={event:this.#t||`message`,data:this.#n.join(`
|
|
3
|
-
`)};return this.#r!==void 0&&(e.id=this.#r),this.#s(),e}#s(){this.#t=``,this.#n=[],this.#r=void 0}};async function*u(e){let t=e.getReader(),n=new TextDecoder,r=new l;try{for(;;){let{done:e,value:i}=await t.read(),a=e?n.decode():n.decode(i,{stream:!0});if(yield*r.push(a),e)break}r.end()}finally{await t.cancel().catch(()=>t.releaseLock())}}function d(e){try{return e.data?JSON.parse(e.data):{}}catch{return{raw:e.data}}}var f=3e4;function p(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}function m(t){let n=t.split(`.`)[1];if(!n)return null;try{let t=JSON.parse(p(n));return e(t)?t:null}catch{return null}}function h(e){let t=m(e)?.exp;return typeof t==`number`?t*1e3:null}var ee=class{#e;#t;#n=null;#r=0;#i=null;#a=!1;#o=0;constructor(e,t=Date.now){this.#e=e,this.#t=t}get(){return this.#n&&this.#t()<this.#r-3e4?Promise.resolve(this.#n):this.#s(!1)}refresh(){return this.#n=null,this.#r=0,this.#s(!0)}clear(){this.#n=null,this.#r=0,this.#i=null,this.#a=!1,this.#o++}#s(e){if(this.#i&&(this.#a||!e))return this.#i;let n=++this.#o,r=Promise.resolve().then(()=>this.#e({retry:e})).then(e=>{if(!e)throw new t({status:401,message:`No token available for the user`},`auth_required`);return n===this.#o&&(this.#n=e,this.#r=h(e)??0),e}).finally(()=>{this.#i===r&&(this.#i=null,this.#a=!1)});return this.#i=r,this.#a=e,r}},g={text:``,result:null,sources:[],activity:null,title:null,error:null,finished:!1},_=t=>e(t)?t:{};function te(e,t,n){let r=_(n),i=e=>{let t=r[e];return typeof t==`string`&&t?t:void 0};switch(t){case`token`:return typeof r.text==`string`?{...e,text:e.text+r.text}:e;case`truncate`:return{...e,text:``};case`result`:return{...e,result:r.payload??null};case`context`:return{...e,sources:Array.isArray(r.context)?r.context:[]};case`title`:return{...e,title:i(`title`)??e.title};case`nop`:return i(`message`)?{...e,activity:i(`message`)}:e;case`error`:{let t=i(`error_code`),n=i(`detail`),a=i(`trace_id`);return{...e,error:{code:typeof r.code==`number`?r.code:500,...i(`message`)?{message:i(`message`)}:{},...t?{errorCode:t}:{},...n?{detail:n}:{},...a?{traceId:a}:{}}}}case`done`:return{...e,finished:!0,activity:null};default:return e}}function ne({text:e,result:t}){return e||t==null?e:typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===1&&`text`in t&&typeof t.text==`string`?t.text:"```json\n"+JSON.stringify(t,null,2)+"\n```"}function
|
|
4
|
-
`)}var y={conversation:`aicore-conversation`,turn:`aicore-turn`,error:`aicore-error`,authRequired:`aicore-auth-required`,tenantRefused:`aicore-tenant-refused`},re=3,b=1e3,x=`100`;function ie(e){let t=e.trim().replace(/\/+$/,``);return t.endsWith(`/api/v1`)?t:`${t}/api/v1`}function ae(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var oe=e=>e instanceof t&&(e.status===0||e.status>=502);function S(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})})}var C=class extends EventTarget{apiBase;tenant;#e;#t;#n;#r;#i;#a=null;constructor(e){super(),this.apiBase=ie(e.baseUrl),this.tenant=e.tenant??null,this.#e=new ee(e.getToken),this.#t=e.fetch??globalThis.fetch.bind(globalThis),this.#n=e.onRequest,this.#r=e.onIdentityChange}clearToken(){this.#e.clear()}async checkIdentity(){try{await this.#l(!1)}catch{}}#o(e,t,n){let r=new Headers({Accept:t.accept??`application/json`,Authorization:`Bearer ${e}`});return this.tenant&&r.set(`X-Tenant`,this.tenant),t.body!==void 0&&r.set(`Content-Type`,`application/json`),n&&r.set(`Idempotency-Key`,n),t.lastEventId&&r.set(`Last-Event-ID`,t.lastEventId),{method:t.method??`GET`,headers:r,body:t.form??(t.body===void 0?void 0:JSON.stringify(t.body)),credentials:`omit`,cache:`no-store`,signal:t.signal}}async#s(e,n,r){let i=performance.now(),o;try{o=await this.#t(this.apiBase+e,n)}catch(o){throw a(o,n.signal??void 0)?o:(this.#c(n,e,0,i,r),new t({status:0,message:`AI-CORE unreachable`}))}return this.#c(n,e,o.status,i,r,o),o}#c(e,t,n,r,i,a){this.#n?.({method:e.method??`GET`,path:t,status:n,requestId:a?.headers.get(`X-Request-Id`)??void 0,durationMs:Math.round(performance.now()-r),retriedWithFreshToken:i})}async#l(e){let n;try{n=await(e?this.#e.refresh():this.#e.get())}catch(e){throw e instanceof t?e:new t({status:0,message:`No token available: ${e instanceof Error?e.message:String(e)}`},`auth_required`)}let r=m(n)?.sub,i=typeof r==`string`&&r!==``?r:null,a=this.#i!==void 0&&(i===null||this.#i===null?n!==this.#a:i!==this.#i);return this.#i=i,this.#a=n,a&&this.#r?.(),n}async#u(e,t={}){let n=t.idempotent?ae():void 0;try{let r=await this.#l(!1),i=await this.#s(e,this.#o(r,t,n),!1);if(s(i)&&(r=await this.#l(!0),i=await this.#s(e,this.#o(r,t,n),!0)),!i.ok)throw await c(i);return i}catch(e){if(a(e,t.signal))throw e;let n=i(e);throw t.report!==!1&&this.#f(n),n}}async#d(e,t){return await(await this.#u(e,t)).json()}#f(e){this.dispatchEvent(new CustomEvent(y.error,{detail:e})),e.kind===`auth_required`&&this.dispatchEvent(new CustomEvent(y.authRequired,{detail:e})),e.kind===`tenant_refused`&&this.dispatchEvent(new CustomEvent(y.tenantRefused,{detail:e}))}listAgents(e){let t=new URLSearchParams({limit:x});return e&&t.set(`cursor`,e),this.#d(`/agents?${t.toString()}`)}getAgent(e){return this.#d(`/agents/${encodeURIComponent(e)}`)}listConversations(e,t){let n=new URLSearchParams({id_agent:e,limit:`50`});return t&&n.set(`cursor`,t),this.#d(`/conversations?${n.toString()}`)}async openConversation(e){let t=await this.#d(`/agents/${encodeURIComponent(e)}/conversations`,{method:`POST`,idempotent:!0});return this.dispatchEvent(new CustomEvent(y.conversation,{detail:{idConv:t.id_conv,idAgent:e}})),t}async history(e){let t=[],n=null;do{let r=new URLSearchParams({limit:x});n&&r.set(`cursor`,n);let i=await this.#d(`/conversations/${encodeURIComponent(e)}/messages?${r.toString()}`);t.push(...i.items),n=i.next_cursor}while(n);return t}renameConversation(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,body:{title:t}})}async deleteConversation(e){await this.#u(`/conversations/${encodeURIComponent(e)}`,{method:`DELETE`})}sendMessage(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t,idempotent:!0})}uploadFile(e,t){let n=new FormData;return n.append(`file`,t,t.name),this.#d(`/conversations/${encodeURIComponent(e)}/files`,{method:`POST`,form:n})}listFiles(e){return this.#d(`/conversations/${encodeURIComponent(e)}/files`)}async deleteFile(e,t){await this.#u(`/conversations/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`DELETE`})}async sendFeedback(e,t,n,r){await this.#u(`/conversations/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}/feedback`,{method:`PUT`,body:r?{rating:n,text:r}:{rating:n}})}async*streamTurn(e,n,r){let i=`/conversations/${encodeURIComponent(e)}/stream?id_query=${encodeURIComponent(n)}`,o,s=0;for(let e=!1;;e=!0){let n=o,c=null;try{c=await this.#u(i,{signal:r,accept:`text/event-stream`,lastEventId:o,report:!1})}catch(t){if(a(t,r))return;if(!e||!oe(t))throw t}if(c?.body)try{for await(let e of u(c.body))if(e.id!==void 0&&(o=e.id),yield{kind:e.event,data:d(e),id:e.id},e.event===`done`)return}catch(e){if(a(e,r))return}if(o!==n&&(s=0),++s>re)throw new t({status:0,message:`Connection lost while streaming`});if(await S(b*2**(s-1),r),r?.aborted)return}}async ask(e){let n=e.idConv??(await this.openConversation(e.idAgent)).id_conv;e.onConversation?.(n);let{id_query:r}=await this.sendMessage(n,e.request),i=g,a=!1;try{for await(let t of this.streamTurn(n,r,e.signal))i=te(i,t.kind,t.data),e.onUpdate?.(i,t)}catch(e){if(e instanceof t&&e.status===410)a=!0;else throw e instanceof t&&this.#f(e),e}return(a||i.error?.code===410)&&(i=await this.#p(n,r)),this.dispatchEvent(new CustomEvent(y.turn,{detail:{idConv:n,idQuery:r,turn:i}})),{idConv:n,idQuery:r,turn:i}}async#p(e,t){let n=(await this.history(e)).find(e=>e.role===`assistant`&&e.id_query===t);return{...g,text:n?.content??``,sources:n?.sources??[],finished:!0}}};function se(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ce=se();function le(e){ce=e}var w={exec:()=>null};function T(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function E(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(D.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ue=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),de=`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)`,D={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,textIndentedContinuation:/^(?:\n(?: {4}| {0,3}\t)[ \t]*[^ \t\n][^\n]*)+/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)(\t[ \t]*)/gm,blockquoteFenceOpen:/^ {0,3}(`{3,}(?=[^`]*$)|~{3,})/,blockquoteFenceClose:/^ {0,3}(`{3,}|~{3,})[ \t]*$/,blockquoteListItemStart:/^ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|$)/,nestedBlockMarker:/^ {0,3}(?:(?:[*+-]|\d{1,9}[.)])(?: |$)|> ?)/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableHeader:RegExp(de+`(?:\\n|$)`),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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:T(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:T(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:T(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:T(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:T(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:T(e=>RegExp(`^ {0,${e}}(?:</?(?:${_e})(?:[ \\t]+|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:T(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},fe=/^(?:[ \t]*(?:\n|$))+/,pe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,me=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*)[ \t]*(?=\n|$)|$)/,he=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ge=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,O=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_e=`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`,ve=E(` {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,_e).getRegex(),ye=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,be=E(ye).replace(/bull/g,O).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/\|table/g,``).replace(/html/g,ve).getRegex(),xe=E(ye).replace(/bull/g,O).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).replace(/html/g,ve).getRegex(),Se=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ce=/^[^\n]+/,we=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Te=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<(?:\\.|[^\n<>\\])*>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,we).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),k=E(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,O).getRegex(),Ee=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,A=E(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*?[ \\t]*/?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Ee).replace(`tag`,_e).replace(`attribute`,/[ \t]+[a-zA-Z:_][\w.:-]*(?:[ \t]*=[ \t]*"[^"\n]*"|[ \t]*=[ \t]*'[^'\n]*'|[ \t]*=[ \t]*[^\s"'=<>`]+)?/).getRegex(),De=e=>E(Se).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,ve).getRegex(),j=De(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Oe=De(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ke=/ {0,3}> ?(?:(?!blank)(paragraph)|[^\n]*)(?:\n|$)/,M={blockquote:E(/^(first)(?:next)*/).replace(`first`,E(ke).replace(`blank`,/[ \t]*(?:\n|$)| {4}/).getRegex()).replace(`next`,E(ke).replace(`blank`,/[ \t]*(?:\n|$)/).getRegex()).replace(/paragraph/g,Oe).getRegex(),code:pe,def:Te,fences:me,heading:ge,hr:he,html:A,lheading:be,list:k,newline:fe,paragraph:j,table:w,text:Ce},Ae=E(de+`(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,ve).getRegex(),je={...M,lheading:xe,table:Ae,paragraph:E(Se).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,D.tableHeader).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,ve).getRegex()},Me={...M,html:E(`^ *(?: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:w,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(Se).replace(`hr`,he).replace(`heading`,` *#{1,6} *[^
|
|
5
|
-
]`).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).replace(`lheading`,be).getRegex()},Ne=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
|
|
3
|
+
`)};return this.#r!==void 0&&(e.id=this.#r),this.#s(),e}#s(){this.#t=``,this.#n=[],this.#r=void 0}};async function*u(e){let t=e.getReader(),n=new TextDecoder,r=new l;try{for(;;){let{done:e,value:i}=await t.read(),a=e?n.decode():n.decode(i,{stream:!0});if(yield*r.push(a),e)break}r.end()}finally{await t.cancel().catch(()=>t.releaseLock())}}function d(e){try{return e.data?JSON.parse(e.data):{}}catch{return{raw:e.data}}}var f=3e4;function p(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=t+`=`.repeat((4-t.length%4)%4),r=atob(n),i=Uint8Array.from(r,e=>e.charCodeAt(0));return new TextDecoder().decode(i)}function m(t){let n=t.split(`.`)[1];if(!n)return null;try{let t=JSON.parse(p(n));return e(t)?t:null}catch{return null}}function h(e){let t=m(e)?.exp;return typeof t==`number`?t*1e3:null}var ee=class{#e;#t;#n=null;#r=0;#i=null;#a=!1;#o=0;constructor(e,t=Date.now){this.#e=e,this.#t=t}get(){return this.#n&&this.#t()<this.#r-3e4?Promise.resolve(this.#n):this.#s(!1)}refresh(){return this.#n=null,this.#r=0,this.#s(!0)}clear(){this.#n=null,this.#r=0,this.#i=null,this.#a=!1,this.#o++}#s(e){if(this.#i&&(this.#a||!e))return this.#i;let n=++this.#o,r=Promise.resolve().then(()=>this.#e({retry:e})).then(e=>{if(!e)throw new t({status:401,message:`No token available for the user`},`auth_required`);return n===this.#o&&(this.#n=e,this.#r=h(e)??0),e}).finally(()=>{this.#i===r&&(this.#i=null,this.#a=!1)});return this.#i=r,this.#a=e,r}},g={text:``,result:null,sources:[],activity:null,title:null,error:null,finished:!1},_=t=>e(t)?t:{};function te(e,t,n){let r=_(n),i=e=>{let t=r[e];return typeof t==`string`&&t?t:void 0};switch(t){case`token`:return typeof r.text==`string`?{...e,text:e.text+r.text}:e;case`truncate`:return{...e,text:``};case`result`:return{...e,result:r.payload??null};case`context`:return{...e,sources:Array.isArray(r.context)?r.context:[]};case`title`:return{...e,title:i(`title`)??e.title};case`nop`:return i(`message`)?{...e,activity:i(`message`)}:e;case`error`:{let t=i(`error_code`),n=i(`detail`),a=i(`trace_id`);return{...e,error:{code:typeof r.code==`number`?r.code:500,...i(`message`)?{message:i(`message`)}:{},...t?{errorCode:t}:{},...n?{detail:n}:{},...a?{traceId:a}:{}}}}case`done`:return{...e,finished:!0,activity:null};default:return e}}function ne({text:e,result:t}){return e||t==null?e:typeof t==`object`&&!Array.isArray(t)&&Object.keys(t).length===1&&`text`in t&&typeof t.text==`string`?t.text:"```json\n"+JSON.stringify(t,null,2)+"\n```"}function re({message:e,detail:t,traceId:n},r={}){let{failed:i=`The agent could not answer.`,trace:a=e=>`Trace ${e}`}=r,o=[e??i];return t&&o.push(t),n&&!e?.includes(n)&&o.push(a(n)),o.join(`
|
|
4
|
+
`)}var v={conversation:`aicore-conversation`,turn:`aicore-turn`,error:`aicore-error`,authRequired:`aicore-auth-required`,tenantRefused:`aicore-tenant-refused`},ie=3,y=1e3,b=`100`;function ae(e){let t=e.trim().replace(/\/+$/,``);return t.endsWith(`/api/v1`)?t:`${t}/api/v1`}function oe(){if(typeof crypto.randomUUID==`function`)return crypto.randomUUID();let e=crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16));e[6]=(e[6]??0)&15|64,e[8]=(e[8]??0)&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var se=e=>e instanceof t&&(e.status===0||e.status>=502);function x(e,t){return new Promise(n=>{if(t?.aborted)return n();let r=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(r),n()},{once:!0})})}var S=class extends EventTarget{apiBase;tenant;#e;#t;#n;#r;#i;#a=null;constructor(e){super(),this.apiBase=ae(e.baseUrl),this.tenant=e.tenant??null,this.#e=new ee(e.getToken),this.#t=e.fetch??globalThis.fetch.bind(globalThis),this.#n=e.onRequest,this.#r=e.onIdentityChange}clearToken(){this.#e.clear()}async checkIdentity(){try{await this.#l(!1)}catch{}}#o(e,t,n){let r=new Headers({Accept:t.accept??`application/json`,Authorization:`Bearer ${e}`});return this.tenant&&r.set(`X-Tenant`,this.tenant),t.body!==void 0&&r.set(`Content-Type`,`application/json`),n&&r.set(`Idempotency-Key`,n),t.lastEventId&&r.set(`Last-Event-ID`,t.lastEventId),{method:t.method??`GET`,headers:r,body:t.form??(t.body===void 0?void 0:JSON.stringify(t.body)),credentials:`omit`,cache:`no-store`,signal:t.signal}}async#s(e,n,r){let i=performance.now(),o;try{o=await this.#t(this.apiBase+e,n)}catch(o){throw a(o,n.signal??void 0)?o:(this.#c(n,e,0,i,r),new t({status:0,message:`AI-CORE unreachable`}))}return this.#c(n,e,o.status,i,r,o),o}#c(e,t,n,r,i,a){this.#n?.({method:e.method??`GET`,path:t,status:n,requestId:a?.headers.get(`X-Request-Id`)??void 0,durationMs:Math.round(performance.now()-r),retriedWithFreshToken:i})}async#l(e){let n;try{n=await(e?this.#e.refresh():this.#e.get())}catch(e){throw e instanceof t?e:new t({status:0,message:`No token available: ${e instanceof Error?e.message:String(e)}`},`auth_required`)}let r=m(n)?.sub,i=typeof r==`string`&&r!==``?r:null,a=this.#i!==void 0&&(i===null||this.#i===null?n!==this.#a:i!==this.#i);return this.#i=i,this.#a=n,a&&this.#r?.(),n}async#u(e,t={}){let n=t.idempotent?oe():void 0;try{let r=await this.#l(!1),i=await this.#s(e,this.#o(r,t,n),!1);if(s(i)&&(r=await this.#l(!0),i=await this.#s(e,this.#o(r,t,n),!0)),!i.ok)throw await c(i);return i}catch(e){if(a(e,t.signal))throw e;let n=i(e);throw t.report!==!1&&this.#f(n),n}}async#d(e,t){return await(await this.#u(e,t)).json()}#f(e){this.dispatchEvent(new CustomEvent(v.error,{detail:e})),e.kind===`auth_required`&&this.dispatchEvent(new CustomEvent(v.authRequired,{detail:e})),e.kind===`tenant_refused`&&this.dispatchEvent(new CustomEvent(v.tenantRefused,{detail:e}))}listAgents(e){let t=new URLSearchParams({limit:b});return e&&t.set(`cursor`,e),this.#d(`/agents?${t.toString()}`)}getAgent(e){return this.#d(`/agents/${encodeURIComponent(e)}`)}listConversations(e,t){let n=new URLSearchParams({id_agent:e,limit:`50`});return t&&n.set(`cursor`,t),this.#d(`/conversations?${n.toString()}`)}async openConversation(e){let t=await this.#d(`/agents/${encodeURIComponent(e)}/conversations`,{method:`POST`,idempotent:!0});return this.dispatchEvent(new CustomEvent(v.conversation,{detail:{idConv:t.id_conv,idAgent:e}})),t}async history(e){let t=[],n=null;do{let r=new URLSearchParams({limit:b});n&&r.set(`cursor`,n);let i=await this.#d(`/conversations/${encodeURIComponent(e)}/messages?${r.toString()}`);t.push(...i.items),n=i.next_cursor}while(n);return t}renameConversation(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,body:{title:t}})}async deleteConversation(e){await this.#u(`/conversations/${encodeURIComponent(e)}`,{method:`DELETE`})}sendMessage(e,t){return this.#d(`/conversations/${encodeURIComponent(e)}/messages`,{method:`POST`,body:t,idempotent:!0})}uploadFile(e,t){let n=new FormData;return n.append(`file`,t,t.name),this.#d(`/conversations/${encodeURIComponent(e)}/files`,{method:`POST`,form:n})}listFiles(e){return this.#d(`/conversations/${encodeURIComponent(e)}/files`)}async deleteFile(e,t){await this.#u(`/conversations/${encodeURIComponent(e)}/files/${encodeURIComponent(t)}`,{method:`DELETE`})}async sendFeedback(e,t,n,r){await this.#u(`/conversations/${encodeURIComponent(e)}/messages/${encodeURIComponent(t)}/feedback`,{method:`PUT`,body:r?{rating:n,text:r}:{rating:n}})}async*streamTurn(e,n,r){let i=`/conversations/${encodeURIComponent(e)}/stream?id_query=${encodeURIComponent(n)}`,o,s=0;for(let e=!1;;e=!0){let n=o,c=null;try{c=await this.#u(i,{signal:r,accept:`text/event-stream`,lastEventId:o,report:!1})}catch(t){if(a(t,r))return;if(!e||!se(t))throw t}if(c?.body)try{for await(let e of u(c.body))if(e.id!==void 0&&(o=e.id),yield{kind:e.event,data:d(e),id:e.id},e.event===`done`)return}catch(e){if(a(e,r))return}if(o!==n&&(s=0),++s>ie)throw new t({status:0,message:`Connection lost while streaming`});if(await x(y*2**(s-1),r),r?.aborted)return}}async ask(e){let n=e.idConv??(await this.openConversation(e.idAgent)).id_conv;e.onConversation?.(n);let{id_query:r}=await this.sendMessage(n,e.request),i=g,a=!1;try{for await(let t of this.streamTurn(n,r,e.signal))i=te(i,t.kind,t.data),e.onUpdate?.(i,t)}catch(e){if(e instanceof t&&e.status===410)a=!0;else throw e instanceof t&&this.#f(e),e}return(a||i.error?.code===410)&&(i=await this.#p(n,r)),this.dispatchEvent(new CustomEvent(v.turn,{detail:{idConv:n,idQuery:r,turn:i}})),{idConv:n,idQuery:r,turn:i}}async#p(e,t){let n=(await this.history(e)).find(e=>e.role===`assistant`&&e.id_query===t);return{...g,text:n?.content??``,sources:n?.sources??[],finished:!0}}};function ce(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var C=ce();function le(e){C=e}var w={exec:()=>null};function T(e){let t=[];return n=>{let r=Math.max(0,Math.min(3,n-1)),i=t[r];return i||(i=e(r),t[r]=i),i}}function E(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(D.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ue=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),de=`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)`,D={codeRemoveIndent:/^(?: {0,3}\t| {1,4})/gm,listInterruptsParagraph:/^ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,endingSpaceTabChar:/[ \t]$/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,leadingSpaceTab:/^[ \t]+/,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,textIndentedContinuation:/^(?:\n(?: {4}| {0,3}\t)[ \t]*[^ \t\n][^\n]*)+/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)(\t[ \t]*)/gm,blockquoteFenceOpen:/^ {0,3}(`{3,}(?=[^`]*$)|~{3,})/,blockquoteFenceClose:/^ {0,3}(`{3,}|~{3,})[ \t]*$/,blockquoteListItemStart:/^ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|$)/,nestedBlockMarker:/^ {0,3}(?:(?:[*+-]|\d{1,9}[.)])(?: |$)|> ?)/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableHeader:RegExp(de+`(?:\\n|$)`),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,numericCharacterReference:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));/,numericCharacterReferenceOrAmpersand:/&#(?:(\d{1,7})|[Xx]([A-Fa-f0-9]{1,6}));|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,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:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:T(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:T(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:T(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:T(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:T(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:T(e=>RegExp(`^ {0,${e}}(?:</?(?:${_e})(?:[ \\t]+|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:T(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},fe=/^(?:[ \t]*(?:\n|$))+/,pe=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,me=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*)[ \t]*(?=\n|$)|$)/,he=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ge=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,O=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_e=`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`,ve=E(` {0,3}(?:</?(?:tag)(?:[ \\t]+|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,_e).getRegex(),ye=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,be=E(ye).replace(/bull/g,O).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/\|table/g,``).replace(/html/g,ve).getRegex(),xe=E(ye).replace(/bull/g,O).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}(?:\s|$)/).replace(/hr/g,/ {0,3}(?:(?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).replace(/html/g,ve).getRegex(),Se=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,Ce=/^[^\n]+/,we=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Te=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<(?:\\.|[^\n<>\\])*>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,we).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),k=E(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,O).getRegex(),Ee=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,A=E(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n*|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>[^\\n]*\\n*|$)|<![A-Z][\\s\\S]*?(?:>[^\\n]*\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>[^\\n]*\\n*|$)|</?(tag)(?:[ \\t]+|\\n|/?>|$)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!(?:script|pre|style|textarea)(?![a-z0-9-]))([a-z][a-z0-9-]*)(?:attribute)*?[ \\t]*/?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Ee).replace(`tag`,_e).replace(`attribute`,/[ \t]+[a-zA-Z:_][\w.:-]*(?:[ \t]*=[ \t]*"[^"\n]*"|[ \t]*=[ \t]*'[^'\n]*'|[ \t]*=[ \t]*[^\s"'=<>`]+)?/).getRegex(),De=e=>E(Se).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,e).replace(`html`,ve).getRegex(),j=De(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Oe=De(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),ke=/ {0,3}> ?(?:(?!blank)(paragraph)|[^\n]*)(?:\n|$)/,M={blockquote:E(/^(first)(?:next)*/).replace(`first`,E(ke).replace(`blank`,/[ \t]*(?:\n|$)| {4}/).getRegex()).replace(`next`,E(ke).replace(`blank`,/[ \t]*(?:\n|$)/).getRegex()).replace(/paragraph/g,Oe).getRegex(),code:pe,def:Te,fences:me,heading:ge,hr:he,html:A,lheading:be,list:k,newline:fe,paragraph:j,table:w,text:Ce},Ae=E(de+`(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]`).replace(`html`,ve).getRegex(),je={...M,lheading:xe,table:Ae,paragraph:E(Se).replace(`hr`,he).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,D.tableHeader).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,ve).getRegex()},Me={...M,html:E(`^ *(?: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:w,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(Se).replace(`hr`,he).replace(`heading`,` *#{1,6} *[^
|
|
5
|
+
]`).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).replace(`lheading`,be).getRegex()},Ne=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Pe=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Fe=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,Ie=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,N=/[\p{P}\p{S}]/u,Le=/[\s\p{P}\p{S}]/u,Re=/[^\s\p{P}\p{S}]/u,ze=E(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Le).getRegex(),Be=/[\p{Pi}\p{Ps}"']/u,Ve=/(?!~)[\p{P}\p{S}]/u,He=/(?!~)[\s\p{P}\p{S}]/u,Ue=/(?:[^\s\p{P}\p{S}]|~)/u,We=E(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,ue?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),Ge=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Ke=E(Ge,`u`).replace(/punct/g,N).getRegex(),qe=E(Ge,`u`).replace(/punct/g,Ve).getRegex(),Je=E(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,Be).replace(/punct/g,N).getRegex(),Ye=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Xe=E(Ye,`gu`).replace(/notPunctSpace/g,Re).replace(/punctSpace/g,Le).replace(/punct/g,N).getRegex(),Ze=E(Ye,`gu`).replace(/notPunctSpace/g,Ue).replace(/punctSpace/g,He).replace(/punct/g,Ve).getRegex(),Qe=E(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Re).replace(/punctSpace/g,Le).replace(/punct/g,N).getRegex(),$e=E(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Re).replace(/punctSpace/g,Le).replace(/punct/g,N).getRegex(),et=E(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Re).replace(/punctSpace/g,Le).replace(/punct/g,N).getRegex(),tt=E(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,N).getRegex(),nt=E(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,Re).replace(/punctSpace/g,Le).replace(/punct/g,N).getRegex(),rt=E(/\\(punct)/,`gu`).replace(/punct/g,N).getRegex(),it=E(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,N).getRegex(),P=E(/^<(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(),at=E(Ee).replace(`(?:-->|$)`,`-->`).getRegex(),ot=E(`^comment|^</[a-zA-Z][a-zA-Z0-9-]*\\s*>|^<[a-zA-Z][a-zA-Z0-9-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,at).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),st=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,ct=E(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,st).getRegex(),lt=/\\[^ \t\n\x00-\x1f]|\\(?=[ \t\n])|[^ \t\n\x00-\x1f\\()]/,ut=E(/\((?:char)*\)/).replace(`char`,lt).getRegex(),dt=E(/\((?:char|p1)*\)/).replace(`char`,lt).replace(`p1`,ut).getRegex(),ft=E(/\((?:char|p2)*\)/).replace(`char`,lt).replace(`p2`,dt).getRegex(),pt=E(/(?!<)(?:char|p3)+/).replace(`char`,lt).replace(`p3`,ft).getRegex(),mt=E(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,ct).replace(`href`,E(/<(?:\\.|[^\n<>\\])*>|bareHref|(?=\))/).replace(`bareHref`,pt).getRegex()).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),ht=E(/^!?\[(label)\]\[(ref)\]/).replace(`label`,ct).replace(`ref`,we).getRegex(),gt=E(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,we).getRegex(),F=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,_t=E(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,st).getRegex(),vt=E(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,E(/^!?\[(label)\]\[(ref)\]/).replace(`label`,_t).replace(`ref`,F).getRegex()).replace(`nolink`,E(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,F).getRegex()).getRegex(),yt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,bt=E(/(?:mailto:email|xmpp:email(?:\/[A-Za-z0-9@.]+)?)/).replace(/email/g,/[A-Za-z0-9._+-]+@[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),xt={_backpedal:w,anyPunctuation:rt,anyPunctuationOutsideCode:it,autolink:P,blockSkip:We,br:Fe,code:Pe,del:w,delLDelim:w,delRDelim:w,emStrongLDelim:Ke,emStrongRDelimAst:Xe,emStrongRDelimUnd:$e,escape:Ne,link:mt,nolink:gt,punctuation:ze,reflink:ht,reflinkSearch:vt,tag:ot,text:Ie,url:w},St={...xt,emStrongLDelim:Je,emStrongRDelimAst:Qe,emStrongRDelimUnd:et,link:E(/^!?\[(label)\]\((.*?)\)/).replace(`label`,ct).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,ct).getRegex()},Ct={...xt,emStrongRDelimAst:Ze,emStrongLDelim:qe,delLDelim:tt,delRDelim:nt,url:E(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,bt).replace(`protocol`,yt).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![\w-])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:E(/^(?:[A-Za-z0-9.+-]+(?=@)|[^a-zA-Z0-9](?=emailProtocol)|(`+|~+|[^`~])(?:(?=[`~])|(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|wwwStart|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9](?=emailProtocol)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))))/).replace(`protocol`,yt).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,ue?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},wt={...Ct,br:E(Fe).replace(`{2,}`,`*`).getRegex(),text:E(Ct.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Tt={normal:M,gfm:je,pedantic:Me},Et={normal:xt,gfm:Ct,breaks:wt,pedantic:St},Dt={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Ot=e=>Dt[e];function I(e,t){if(t){if(D.escapeTest.test(e))return e.replace(D.escapeReplace,Ot)}else if(D.escapeTestNoEncode.test(e))return e.replace(D.escapeReplaceNoEncode,Ot);return e}function kt(e){return D.numericCharacterReference.test(e)?e.replace(D.numericCharacterReferenceOrAmpersand,(e,t,n)=>{if(t===void 0&&n===void 0)return`&`;let r=t===void 0?Number.parseInt(n,16):Number.parseInt(t,10);return r===0||r>1114111||r>=55296&&r<=57343?`�`:r===38?`&`:String.fromCodePoint(r)}):e}function At(e){try{e=encodeURI(e).replace(D.percentDecode,`%`)}catch{return null}return e}function jt(e,t){let n=e.replace(D.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(D.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t){if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``)}for(;r<n.length;r++)n[r]=n[r].trim().replace(D.slashPipe,`|`);return n}function L(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function Mt(e){let t=e.split(`
|
|
6
6
|
`),n=t.length-1;for(;n>=0&&D.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
7
|
-
`)}function
|
|
7
|
+
`)}function Nt(e){return e.trim().replace(D.multipleSpaceGlobal,` `).toLowerCase().toUpperCase().toLowerCase()}function Pt(e,t){if(e.indexOf(t[0])===-1&&e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}var Ft=/* @__PURE__ */ new WeakMap;function It(e){let t={"*":-1,_:-1},n=-1,r=e.length;for(let i=0;i<r;i++){let a=e[i];if(a!==`*`&&a!==`_`&&a!==`~`)continue;let o=i===0?`
|
|
8
8
|
`:e[i-1],s=i+1;for(;s<r&&e[s]===a;)s++;o!==` `&&o!==` `&&o!==`
|
|
9
|
-
`&&o!==`\r`&&o!==`\f`&&(a===`~`?n=i:t[a]=i),i=s-1}return{maskedSrc:e,lastPossibleEmStrongCloserIndex:t,lastPossibleDelCloserIndex:n}}function
|
|
10
|
-
`)}function
|
|
9
|
+
`&&o!==`\r`&&o!==`\f`&&(a===`~`?n=i:t[a]=i),i=s-1}return{maskedSrc:e,lastPossibleEmStrongCloserIndex:t,lastPossibleDelCloserIndex:n}}function Lt(e,t){let n=It(t),r=Ft.get(e);r?r.push(n):Ft.set(e,[n])}function Rt(e){let t=Ft.get(e);t&&(t.pop(),t.length===0&&Ft.delete(e))}function zt(e,t,n){let r=Ft.get(e)?.at(-1);return r&&r.maskedSrc===t?r.lastPossibleEmStrongCloserIndex[n]:It(t).lastPossibleEmStrongCloserIndex[n]}function Bt(e,t){let n=Ft.get(e)?.at(-1);return n&&n.maskedSrc===t?n.lastPossibleDelCloserIndex:It(t).lastPossibleDelCloserIndex}function Vt(e,t=0){let n=t,r=``;for(let t of e)if(t===` `){let e=4-n%4;r+=` `.repeat(e),n+=e}else r+=t,n++;return r}function Ht(e){let t,n=!1;return e.map(e=>{if(n)return e;let{depth:r,expanded:i,keptIndent:a,content:o}=Ut(e,t?.depth??1/0);if(t?.depth!==r&&(t=void 0),t){let e=D.blockquoteFenceClose.exec(o)?.[1];return!e||e[0]!==t.marker[0]||e.length<t.marker.length?a:(t=void 0,i)}if(n=D.blockquoteListItemStart.test(o),n)return e;let s=D.blockquoteFenceOpen.exec(o)?.[1];return s&&(t={marker:s,depth:r}),i}).join(`
|
|
10
|
+
`)}function Ut(e,t){let n=0,r=0,i=0,a=0,o=``;for(;i<t;){let t=n,s=r;for(;e[t]===` `||e[t]===` `;)s+=Wt(e[t],s),t++;if(e[t]!==`>`||s-a>3)break;o+=` `.repeat(s-r)+`>`,i++,n=t+1,r=s+1,a=e[n]===` `||e[n]===` `?r+1:r}if(i===0)return{depth:i,expanded:e,keptIndent:e,content:e};let s=``,c=``;for(;(e[n]===` `||e[n]===` `)&&r<a+4;){let t=Wt(e[n],r);s+=` `.repeat(t),c+=r<a&&t>1?` `.repeat(t):e[n],r+=t,n++}let l=e.slice(n);return{depth:i,expanded:o+s+l,keptIndent:o+c+l,content:` `.repeat(Math.max(0,r-a))+l}}function Wt(e,t){return e===` `?4-t%4:1}function Gt(e,t){let n=``;for(let r=0;r<e.length;r++){if(e[r]==="`"){let i=t.inline.code.exec(e.slice(r));if(i){n+=i[0],r+=i[0].length-1;continue}}e[r]===`\\`&&(e[r+1]===`[`||e[r+1]===`]`)?(n+=e[r+1],r++):n+=e[r]}return n}function Kt(e,t,n,r,i){let a=t.href,o=t.title||null,s=Gt(e[1],i),c=e[0].charAt(0)===`!`,l=r.state.inLink,u=r.state.linkEmitted,d=r.state.inRawBlock;r.state.inLink=!0,r.state.linkEmitted=!1;let f=r.inlineTokens(s),p=r.state.linkEmitted;if(r.state.linkEmitted=u,r.state.inLink=l,!c){if(p){r.state.inRawBlock=d;return}r.state.linkEmitted=!0}return{type:c?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:f}}function qt(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
11
11
|
`).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return e.slice(Math.min(r.length,i.length))}).join(`
|
|
12
|
-
`)}function
|
|
12
|
+
`)}function Jt(e,t,n,r){if(!t.includes(`<`))return!1;for(let i=0;i<t.length;i++){if(t[i]===`\\`){i++;continue}if(t[i]==="`"){let e=r.inline.code.exec(t.slice(i));if(e){i+=e[0].length-1;continue}}if(t[i]!==`<`)continue;let a=e.slice(n+i),o=r.inline.tag.exec(a)||r.inline.autolink.exec(a);if(o){if(o[0].length>t.length-i)return!0;i+=o[0].length-1}}return!1}var R=class{options;rules;lexer;constructor(e){this.options=e||C}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=this.options.pedantic?t[0]:Mt(t[0]);return{type:`code`,raw:e,codeBlockStyle:`indented`,text:e.replace(this.rules.other.codeRemoveIndent,``)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=qt(e,t[3]||``,this.rules);return t[3]!==void 0&&(n===``||n.endsWith(`
|
|
13
13
|
`))&&(n+=`
|
|
14
|
-
`),{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=
|
|
15
|
-
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:
|
|
16
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
14
|
+
`),{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=L(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:L(t[0],`
|
|
15
|
+
`),depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:L(t[0],`
|
|
16
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=L(t[0],`
|
|
17
17
|
`).split(`
|
|
18
18
|
`),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o=0;for(;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
|
|
19
|
-
`),c=(this.lexer.state.top&&!this.lexer.state.inBlockquote&&s.includes(` `)?
|
|
19
|
+
`),c=(this.lexer.state.top&&!this.lexer.state.inBlockquote&&s.includes(` `)?Ht(a):s).replace(this.rules.other.blockquoteMarkerWhitespace,(e,t,n)=>n.startsWith(` `)?t+` `+n.slice(1):t+Vt(n,t.length)).replace(this.rules.other.blockquoteSetextReplace,`
|
|
20
20
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
21
21
|
${s}`:s,r=r?`${r}
|
|
22
22
|
${c}`:c;let l=this.lexer.state.top,u=this.lexer.state.inBlockquote;if(this.lexer.state.top=!0,this.lexer.state.inBlockquote=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,this.lexer.state.inBlockquote=u,e.length===0)break;let d=i.at(-1);if(d?.type===`code`||d?.type===`heading`||d?.type===`hr`||d?.type===`html`||d?.type===`table`)break;if(d?.type===`blockquote`){let t=d,a=e.join(`
|
|
@@ -31,19 +31,19 @@ ${f.join(`
|
|
|
31
31
|
`);n=`${n}
|
|
32
32
|
${t}`,r=`${r}
|
|
33
33
|
${t}`}if(e=e.slice(s),e.length>0&&!this.rules.other.blockquoteStart.test(e[0]))break}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){if(!this.options.pedantic&&this.lexer.state.lastToken?.type===`text`&&!this.rules.other.listInterruptsParagraph.test(e))return;let n=e,r=()=>n.length-e.length,i=t[1].trim(),a=i.length>1,o={type:`list`,raw:``,ordered:a,start:a?+i.slice(0,-1):``,loose:!1,items:[]};i=a?`\\d{1,9}\\${i.slice(-1)}`:`\\${i}`,this.options.pedantic&&(i=a?i:`[*+-]`);let s=this.rules.other.listItemRegex(i),c=!1;for(;e;){let i=!1,a=``;if(!(t=s.exec(e))||this.rules.block.hr.test(e))break;let l=r();e=e.substring(t[0].length);let u=t[2].split(`
|
|
34
|
-
`,1)[0],d=t[1].length,f=this.options.pedantic?
|
|
34
|
+
`,1)[0],d=t[1].length,f=this.options.pedantic?Vt(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>Vt(e,d)),p=e.split(`
|
|
35
35
|
`,1)[0],m=!f.trim(),h=0;if(this.options.pedantic?(h=2,a=f.trimStart()):m?h=d+1:(h=f.search(this.rules.other.nonSpaceChar),h=h>4?1:h,a=f.slice(h),h+=d),m&&this.rules.other.blankLine.test(p)&&(e=e.substring(p.length+1),i=!0),!i){let t=this.rules.other.nextBulletRegex(h),n=this.rules.other.hrRegex(h),r=this.rules.other.fencesBeginRegex(h),i=this.options.pedantic?this.rules.other.pedanticHeadingBeginRegex(h):this.rules.other.headingBeginRegex(h),o=this.rules.other.htmlBeginRegex(h),s=this.rules.other.blockquoteBeginRegex(h),c=!1;for(;e;){let l=e.split(`
|
|
36
|
-
`,1)[0],u;if(p=l,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),u=p):u=p.replace(this.rules.other.leadingSpaceTab,e=>
|
|
36
|
+
`,1)[0],u;if(p=l,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting,` `),u=p):u=p.replace(this.rules.other.leadingSpaceTab,e=>Vt(e)),r.test(p)||i.test(p)||o.test(p)||s.test(p)||t.test(p)||n.test(p))break;if(u.search(this.rules.other.nonSpaceChar)>=h||!p.trim())a+=`
|
|
37
37
|
`+u.slice(h),c=!1;else{if(m)break;let e=f;if(!this.options.pedantic&&!a.includes(`
|
|
38
38
|
`)&&!f.includes(` `)){let t;for(;!n.test(e)&&(t=this.rules.other.nestedBlockMarker.exec(e));)e=e.slice(t[0].length);if(!e.trim())break}if(e.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(e)||i.test(e)||o.test(e)||n.test(e))break;if(!this.options.pedantic&&!c){let e=f.replace(this.rules.other.nestedContainerMarkers,``);if(this.rules.block.fences.test(e)||this.rules.block.heading.test(e)||this.rules.block.hr.test(e))break}let t=!this.options.pedantic&&/^ {0,3}(?:=+|-+) *$/.test(p)&&this.rules.block.lheading.test(`${f}
|
|
39
39
|
${p}`)?` ${u.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
40
|
-
`+t,c=!0}m=!p.trim(),e=e.substring(l.length+1),f=u.slice(h)}}let ee=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(ee)&&(c=!0)),o.items.push({type:`list_item`,raw:ee,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();let u=[];for(let e of o.items)if(this.lexer.state.top=!1,u.push(this.lexer.inlineQueue.length),e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e=0;e<o.items.length;e++){let t=o.items[e],n=t.tokens[0];if(t.task&&(n?.type===`text`||n?.type===`paragraph`)){t.text=t.text.replace(this.rules.other.listReplaceTask,``),n.raw=n.raw.replace(this.rules.other.listReplaceTask,``),n.text=n.text.replace(this.rules.other.listReplaceTask,``);let r=this.lexer.inlineQueue;for(let t=u[e];t<r.length;t++)if(r[t].tokens===n.tokens){r[t].src=r[t].src.replace(this.rules.other.listReplaceTask,``);break}let i=this.rules.other.listTaskCheckbox.exec(t.raw);if(i){let e={type:`checkbox`,raw:i[0]+` `,checked:i[0]!==`[ ]`};t.checked=e.checked,o.loose?t.tokens[0]&&[`paragraph`,`text`].includes(t.tokens[0].type)&&`tokens`in t.tokens[0]&&t.tokens[0].tokens?(t.tokens[0].raw=e.raw+t.tokens[0].raw,t.tokens[0].text=e.raw+t.tokens[0].text,t.tokens[0].tokens.unshift(e)):t.tokens.unshift({type:`paragraph`,raw:e.raw,text:e.raw,tokens:[e]}):t.tokens.unshift(e)}}else t.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){if(this.lexer.state.lastToken?.type===`paragraph`&&!this.rules.other.htmlBeginRegex(4).test(e))return;let n=
|
|
41
|
-
`),href:n,title:r}}}table(e){let t,n;if(this.options.gfm&&!this.options.pedantic){let r=this.rules.other.tableHeader.exec(e);if(!r||!this.rules.other.tableDelimiter.test(r[2])||(t=
|
|
42
|
-
`):[],a={type:`table`,raw:
|
|
43
|
-
`),header:[],align:[],rows:[]};if(t.length===n.length){for(let e of n)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
40
|
+
`+t,c=!0}m=!p.trim(),e=e.substring(l.length+1),f=u.slice(h)}}let ee=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(ee)&&(c=!0)),o.items.push({type:`list_item`,raw:ee,task:!!this.options.gfm&&this.rules.other.listIsTask.test(a),loose:!1,text:a,tokens:[]})}let l=o.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;o.raw=n.slice(0,r()).trimEnd();let u=[];for(let e of o.items)if(this.lexer.state.top=!1,u.push(this.lexer.inlineQueue.length),e.tokens=this.lexer.blockTokens(e.text,[]),!o.loose){let t=e.tokens.filter(e=>e.type===`space`);o.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}for(let e=0;e<o.items.length;e++){let t=o.items[e],n=t.tokens[0];if(t.task&&(n?.type===`text`||n?.type===`paragraph`)){t.text=t.text.replace(this.rules.other.listReplaceTask,``),n.raw=n.raw.replace(this.rules.other.listReplaceTask,``),n.text=n.text.replace(this.rules.other.listReplaceTask,``);let r=this.lexer.inlineQueue;for(let t=u[e];t<r.length;t++)if(r[t].tokens===n.tokens){r[t].src=r[t].src.replace(this.rules.other.listReplaceTask,``);break}let i=this.rules.other.listTaskCheckbox.exec(t.raw);if(i){let e={type:`checkbox`,raw:i[0]+` `,checked:i[0]!==`[ ]`};t.checked=e.checked,o.loose?t.tokens[0]&&[`paragraph`,`text`].includes(t.tokens[0].type)&&`tokens`in t.tokens[0]&&t.tokens[0].tokens?(t.tokens[0].raw=e.raw+t.tokens[0].raw,t.tokens[0].text=e.raw+t.tokens[0].text,t.tokens[0].tokens.unshift(e)):t.tokens.unshift({type:`paragraph`,raw:e.raw,text:e.raw,tokens:[e]}):t.tokens.unshift(e)}}else t.task&&=!1}if(o.loose)for(let e of o.items){e.loose=!0;for(let t of e.tokens)t.type===`text`&&(t.type=`paragraph`)}return o}}html(e){let t=this.rules.block.html.exec(e);if(t){if(this.lexer.state.lastToken?.type===`paragraph`&&!this.rules.other.htmlBeginRegex(4).test(e))return;let n=Mt(t[0]);return{type:`html`,block:!0,raw:n,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:n}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&Pt(t[2],`()`)!==-1)return;let e=Nt(t[1]),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:L(t[0],`
|
|
41
|
+
`),href:n,title:r}}}table(e){let t,n;if(this.options.gfm&&!this.options.pedantic){let r=this.rules.other.tableHeader.exec(e);if(!r||!this.rules.other.tableDelimiter.test(r[2])||(t=jt(r[1]),n=r[2].replace(this.rules.other.tableAlignChars,``).split(`|`),t.length!==n.length))return}let r=this.rules.block.table.exec(e);if(!r||!this.rules.other.tableDelimiter.test(r[2]))return;t??=jt(r[1]),n??=r[2].replace(this.rules.other.tableAlignChars,``).split(`|`);let i=r[3]?.trim()?r[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
42
|
+
`):[],a={type:`table`,raw:L(r[0],`
|
|
43
|
+
`),header:[],align:[],rows:[]};if(t.length===n.length){for(let e of n)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<t.length;e++)a.header.push({text:t[e],tokens:this.lexer.inline(t[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(jt(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let e=t[1].trim();return{type:`heading`,raw:L(t[0],`
|
|
44
44
|
`),depth:t[2].charAt(0)===`=`?1:2,text:e,tokens:this.lexer.inline(e)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
|
|
45
|
-
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t){let n=t[0],r=t[0],i=this.rules.other.textIndentedContinuation.exec(e.slice(n.length));return i&&(n+=i[0],r+=i[0].replace(this.rules.other.codeRemoveIndent,``)),{type:`text`,raw:n,text:r,tokens:this.lexer.inline(r)}}}escape(e){if(e.charCodeAt(0)!==92)return;let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){if(e.charCodeAt(0)!==60)return;let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=e.charCodeAt(0);if(t!==91&&t!==33)return;let n=this.rules.inline.link.exec(e);if(n){let t=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&
|
|
46
|
-
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.state.inRawBlock=!1,this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this;let r=this.state.lastToken;this.options.pedantic&&(e=e.replace(D.tabCharGlobal,` `).replace(D.spaceLine,``));let i=1/0,a,o=this.options.gfm&&!this.options.pedantic&&this.tokenizer.paragraph===
|
|
45
|
+
`?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t){let n=t[0],r=t[0],i=this.rules.other.textIndentedContinuation.exec(e.slice(n.length));return i&&(n+=i[0],r+=i[0].replace(this.rules.other.codeRemoveIndent,``)),{type:`text`,raw:n,text:r,tokens:this.lexer.inline(r)}}}escape(e){if(e.charCodeAt(0)!==92)return;let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){if(e.charCodeAt(0)!==60)return;let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){if(this.lexer.state.linkParenPossible===!1)return;let t=e.charCodeAt(0);if(t!==91&&t!==33)return;let n=this.rules.inline.link.exec(e);if(n){let t=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Jt(e,n[1],t,this.rules))return;let r=n[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=L(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=Pt(n[2],`()`);if(e===-2)return;if(e>-1){let t=(n[0].indexOf(`!`)===0?5:4)+n[1].length+e;n[2]=n[2].substring(0,e),n[0]=n[0].substring(0,t).trim(),n[3]=``}}let i=L(n[0].slice(0,-1),`\\`);if((n[0].length-i.length)%2==0)return;let a=n[2],o=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(a);e&&(a=e[1],o=e[3])}else o=n[3]?n[3].slice(1,-1):``;return a=a.trim(),this.rules.other.startAngleBracket.test(a)&&(a=this.options.pedantic&&!this.rules.other.endAngleBracket.test(r)?a.slice(1):a.slice(1,-1)),Kt(n,{href:a&&a.replace(this.rules.inline.anyPunctuation,`$1`),title:o&&o.replace(this.rules.inline.anyPunctuation,`$1`)},n[0],this.lexer,this.rules)}}reflink(e,t){let n=e.charCodeAt(0);if(n!==91&&n!==33)return;let r;if((r=this.rules.inline.reflink.exec(e))||(r=this.rules.inline.nolink.exec(e))){let n=r[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&Jt(e,r[1],n,this.rules))return;let i=t[Nt(r[2]||r[1])];if(!i){let e=r[0].charAt(0);return{type:`text`,raw:e,text:e}}return Kt(r,i,r[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(!r||!r[1]&&!r[2]&&!r[3]&&!r[4])return;let i=r[0][0],a=n===i,o=t.length-e.length,s=o;for(;!this.options.pedantic&&s>0&&t[s-1]===i;)s--;let c=[...t.slice(Math.max(0,s-2),s)].at(-1)??``,l=c===`*`||c===`_`||!!this.rules.inline.punctuation.exec(c);s<o&&(n=c);let u=s<o?l:n===`*`||n===`_`||!!this.rules.inline.punctuation.exec(n);if(r[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;let d=r[1]||r[3]||``;if(!d||!n||u){let n=[...r[0]].length-1,u,f,p=n,m=0,h=o-s+n,ee=!this.options.pedantic&&!!c.trim()&&(!!d||i===`*`&&!l);if(i!==`*`&&i!==`_`)return;let g=i===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd,_=zt(this,t,i),te=t.length-e.length+n;if(_<te)return;t=t.slice(-1*e.length+n);let ne=_-te;for(g.lastIndex=0;(r=g.exec(t))!==null&&!(r.index>ne);){if(u=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!u)continue;if(f=[...u].length,r[3]||r[4]){p+=f;continue}if((r[5]||r[6]||ee)&&h%3&&!((h+f)%3)){if(a&&(r[5]||r[6]))break;m+=f;continue}if(p-=f,p>0)continue;f=Math.min(f,f+p+m);let t=[...r[0]][0].length,i=e.slice(0,n+r.index+t+f);if(Math.min(n,f)%2){let e=i.slice(1,-1);return{type:`em`,raw:i,text:e,tokens:this.lexer.inlineTokens(e)}}let o=i.slice(2,-2);return{type:`strong`,raw:i,text:o,tokens:this.lexer.inlineTokens(o)}}}}codespan(e){if(e.charCodeAt(0)!==96)return;let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=e.charCodeAt(0);if(t!==32&&t!==92&&t!==10)return;let n=this.rules.inline.br.exec(e);if(n)return{type:`br`,raw:n[0]}}del(e,t,n=``){if(e.charCodeAt(0)!==126)return;let r=this.rules.inline.delLDelim.exec(e);if(r&&(!r[1]||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=this.rules.inline.delRDelim,c=Bt(this,t),l=t.length-e.length+n;if(c<l)return;t=t.slice(-1*e.length+n);let u=c-l;for(s.lastIndex=0;(r=s.exec(t))!==null&&!(r.index>u);){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i||(a=[...i].length,a!==n))continue;if(r[3]||r[4]){o+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o);let t=[...r[0]][0].length,s=e.slice(0,n+r.index+t+a),c=s.slice(n,-n);return{type:`del`,raw:s,text:c,tokens:this.lexer.inlineTokens(c)}}}}autolink(e){if(e.charCodeAt(0)!==60)return;let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,autolink:!0,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:e?t[0]:kt(t[0]),escaped:e}}}},z=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||C,this.options.tokenizer=this.options.tokenizer||new R,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,linkEmitted:!1,linkParenPossible:!0,top:!0,inBlockquote:!1};let t={other:D,block:Tt.normal,inline:Et.normal};this.options.pedantic?(t.block=Tt.pedantic,t.inline=Et.pedantic):this.options.gfm&&(t.block=Tt.gfm,t.inline=this.options.breaks?Et.breaks:Et.gfm),this.tokenizer.rules=t}static get rules(){return{block:Tt,inline:Et}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(D.carriageReturn,`
|
|
46
|
+
`),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.state.inRawBlock=!1,this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){this.tokenizer.lexer=this;let r=this.state.lastToken;this.options.pedantic&&(e=e.replace(D.tabCharGlobal,` `).replace(D.spaceLine,``));let i=1/0,a,o=this.options.gfm&&!this.options.pedantic&&this.tokenizer.paragraph===R.prototype.paragraph;for(;e;){if(e.length<i)i=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}this.state.lastToken=t.at(-1);let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
|
|
47
47
|
`:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
48
48
|
`)?``:`
|
|
49
49
|
`)+r.raw,n.text+=`
|
|
@@ -56,9 +56,9 @@ ${p}`)?` ${u.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
|
56
56
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text,a=i):(t.push(r),a=r),n=s.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=(n.raw.endsWith(`
|
|
57
57
|
`)?``:`
|
|
58
58
|
`)+r.raw,n.text+=`
|
|
59
|
-
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,this.state.lastToken=r,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,
|
|
60
|
-
`:``;return r?`<pre><code class="language-`+
|
|
61
|
-
`:`<pre><code>`+(n?i:
|
|
59
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return this.state.top=!0,this.state.lastToken=r,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}linkInText(e){if(!e.includes(`[`))return!1;let t=this.tokenizer.rules.inline.link;for(let n of e.matchAll(this.tokenizer.rules.inline.blockSkip))if(t.test(n[0])&&e.charAt(n.index-1)!==`!`)return!0;for(let t of e.matchAll(this.tokenizer.rules.inline.reflinkSearch)){let e=t[0],n=e.lastIndexOf(`[`);if(e.charAt(0)!==`!`&&Object.hasOwn(this.tokens.links,Nt(e.slice(n+1,-1)))&&!(n>1&&this.linkInText(e.slice(1,n-1))))return!0}return!1}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let n=this.state.linkParenPossible;this.state.linkParenPossible=e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e.includes(`*`)||e.includes(`_`)||e.includes(`~`),r=n||this.options.hooks?.emStrongMask||this.tokenizer.emStrong!==R.prototype.emStrong||this.tokenizer.del!==R.prototype.del?this.#r(e):e;if(!n)return this.#t(e,r,t);Lt(this.tokenizer,r);try{return this.#t(e,r,t)}finally{Rt(this.tokenizer)}}#t(e,t,n){let r=!1,i=``,a=1/0;for(;e;){if(e.length<a)a=e.length;else{this.infiniteLoopError(e.charCodeAt(0));break}r||(i=``),r=!1;let o;if(this.options.extensions?.inline?.some(t=>(o=t.call({lexer:this},e,n))?(e=e.substring(o.raw.length),n.push(o),!0):!1))continue;if((o=this.tokenizer.escape(e))||(o=this.tokenizer.tag(e))||(o=this.tokenizer.link(e))){e=e.substring(o.raw.length),n.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let t=n.at(-1);o.type===`text`&&t?.type===`text`?(t.raw+=o.raw,t.text+=o.text):n.push(o);continue}let s=e[0];if(s===`*`||s===`_`){let a=t.length-e.length;if(zt(this.tokenizer,t,s)<=a){let t=1;for(;t<e.length&&e.charCodeAt(t)===s.charCodeAt(0);)t++;let a=e.substring(0,t),o=n.at(-1);o?.type===`text`&&!o.escaped?(o.raw+=a,o.text+=a):n.push({type:`text`,raw:a,text:a,escaped:!1}),e=e.substring(t),i=s,r=!0;continue}}else if(s===`~`){let a=t.length-e.length;if(Bt(this.tokenizer,t)<=a){let t=1;for(;t<e.length&&e.charCodeAt(t)===126;)t++;let a=e.substring(0,t),o=n.at(-1);o?.type===`text`&&!o.escaped?(o.raw+=a,o.text+=a):n.push({type:`text`,raw:a,text:a,escaped:!1}),e=e.substring(t),i=s,r=!0;continue}}if((o=this.tokenizer.emStrong(e,t,i))||(o=this.tokenizer.codespan(e))||(o=this.tokenizer.br(e))||(o=this.tokenizer.del(e,t,i))||(o=this.tokenizer.autolink(e))||!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),n.push(o);continue}let c=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(c=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(c)){e=e.substring(o.raw.length),o.raw.slice(-1)!==`_`&&(i=o.raw.slice(-1)),r=!0;let t=n.at(-1);t?.type===`text`?(t.raw+=o.raw,t.text+=o.text):n.push(o)}else if(e){this.infiniteLoopError(e.charCodeAt(0));break}}return n}#n(e){let{blockSkip:t,tag:n,autolink:r}=this.tokenizer.rules.inline,i=``,a=0,o;for(t.lastIndex=0;o=t.exec(e);){let s=o.index+(o[2]?o[2].length:0),c=o.index+o[0].length;if(e.charAt(s)===`<`){let i=e.slice(s),a=n.exec(i)||r.exec(i);if(!a){t.lastIndex=s+1;continue}c=s+a[0].length,t.lastIndex=c}i+=e.slice(a,s)+`[`+`a`.repeat(c-s-2)+`]`,a=c}return i+e.slice(a)}#r(e){let t=e;if(this.tokens.links&&e.includes(`[`)){let e=this.tokenizer.rules.inline.reflinkSearch,n=t=>{let r=t.lastIndexOf(`[`);if(!Object.hasOwn(this.tokens.links,Nt(t.slice(r+1,-1))))return t;if(r>1&&t.charAt(0)!==`!`){let i=t.slice(1,r-1);if(this.linkInText(i))return`[`+i.replace(e,n)+`][`+`a`.repeat(t.length-r-2)+`]`}return`[`+`a`.repeat(t.length-2)+`]`};t=t.replace(e,n)}return t=t.replace(this.tokenizer.rules.inline.anyPunctuationOutsideCode,(e,t,n)=>n?`+`.repeat(e.length):t?t+e.slice(t.length,-t.length).replace(/`/g,`+`)+t:e),t=this.#n(t),t=this.options.hooks?.emStrongMask?.call({lexer:this},t)??t,t}infiniteLoopError(e){let t=`Infinite loop on byte: `+e;if(this.options.silent)console.error(t);else throw Error(t)}};function Yt(e){return e.map(e=>e.type===`codespan`||e.type===`escape`?{...e,text:I(e.text,!0)}:`tokens`in e&&e.tokens?{...e,tokens:Yt(e.tokens)}:e)}var Xt=class{options;parser;constructor(e){this.options=e||C}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(D.notSpaceStart)?.[0],i=e?e.replace(D.endingNewline,``)+`
|
|
60
|
+
`:``;return r?`<pre><code class="language-`+I(r)+`">`+(n?i:I(i,!0))+`</code></pre>
|
|
61
|
+
`:`<pre><code>`+(n?i:I(i,!0))+`</code></pre>
|
|
62
62
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
63
63
|
${this.parser.parse(e)}</blockquote>
|
|
64
64
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -74,16 +74,16 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
74
74
|
`}tablerow({text:e}){return`<tr>
|
|
75
75
|
${e}</tr>
|
|
76
76
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
77
|
-
`}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>${
|
|
78
|
-
`}checkbox({raw:e}){return e}},B=class e{options;renderer;textRenderer;constructor(e){this.options=e||
|
|
79
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+
|
|
80
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tn(e,t){return Sn(e)||Cn(e,t)||En(e,t)||wn()}function En(e,t){if(e){if(typeof e==`string`)return xn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xn(e,t):void 0}}function Dn(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof bn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Dn.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Dn.prototype.next=function(e){return this._invoke(`next`,e)},Dn.prototype.throw=function(e){return this._invoke(`throw`,e)},Dn.prototype.return=function(e){return this._invoke(`return`,e)};var On=Object.entries,kn=Object.keys,An=Object.setPrototypeOf,jn=Object.isFrozen,Mn=Object.getPrototypeOf,Nn=Object.getOwnPropertyDescriptor,H=Object.freeze,U=Object.seal,Pn=Object.create,Fn=typeof Reflect<`u`&&Reflect,In=Fn.apply,Ln=Fn.construct;H||=function(e){return e},U||=function(e){return e},In||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Ln||=function(e){return new e(...[...arguments].slice(1))};var W=J(Array.prototype.forEach),Rn=J(Array.prototype.lastIndexOf),zn=J(Array.prototype.pop),Bn=J(Array.prototype.push),Vn=J(Array.prototype.slice),Hn=J(Array.prototype.splice),Un=Array.isArray,Wn=lr(Set),Gn=J(Set.prototype.add),Kn=J(Set.prototype.has),qn=J(Set.prototype.delete),Jn=lr(Map),Yn=J(Map.prototype.get),Xn=J(Map.prototype.set),Zn=J(String.prototype.toLowerCase),Qn=J(String.prototype.toString),$n=J(String.prototype.match),er=J(String.prototype.replace),tr=J(String.prototype.indexOf),nr=J(String.prototype.trim),rr=J(Number.prototype.toString),ir=J(Boolean.prototype.toString),ar=typeof BigInt>`u`?null:J(BigInt.prototype.toString),or=typeof Symbol>`u`?null:J(Symbol.prototype.toString),G=J(Object.prototype.hasOwnProperty),sr=J(Object.prototype.toString),cr=RegExp.prototype.test,K=function(e,t){return e instanceof RegExp&&(e.lastIndex=0),In(cr,e,[t])},q=lr(TypeError);function J(e){return function(t){var n=[...arguments].slice(1);return In(e,t,n)}}function lr(e){return function(){return Ln(e,[...arguments])}}function Y(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Zn;if(An&&An(e,null),!Un(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(jn(t)||(t[r]=e),i=e)}e[i]=!0}return e}function ur(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function dr(e){let t=Pn(null);for(let r of On(e)){var n=Tn(r,2);let i=n[0],a=n[1];G(e,i)&&(t[i]=Un(a)?ur(a):a&&typeof a==`object`&&a.constructor===Object?dr(a):a)}return t}function fr(e){let t=Pn(null),n=kn(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function pr(e){switch(typeof e){case`string`:return e;case`number`:return rr(e);case`boolean`:return ir(e);case`bigint`:return ar?ar(e):`0`;case`symbol`:return or?or(e):`Symbol()`;case`undefined`:return sr(e);case`function`:case`object`:{if(e===null)return sr(e);let t=e,n=X(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:sr(e)}return sr(e)}default:return sr(e)}}function X(e,t){for(;e!==null;){let n=Nn(e,t);if(n){if(n.get)return J(n.get);if(typeof n.value==`function`)return J(n.value)}e=Mn(e)}function n(){return null}return n}function mr(e,t){for(;e!==null;){let n=Nn(e,t);if(n)return n.get?J(n.get):null;e=Mn(e)}return null}function hr(e){if(!e)return!1;try{return K(e,``),!0}catch{return!1}}var gr=H(/* @__PURE__ */ `a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),_r=H(/* @__PURE__ */ `svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.filter.font.g.glyph.glyphref.hkern.image.line.lineargradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),vr=H([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),yr=H([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),br=H(/* @__PURE__ */ `math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),xr=H([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Sr=H([`#text`]),Cr=H(/* @__PURE__ */ `accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),wr=H(/* @__PURE__ */ `accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Tr=H(/* @__PURE__ */ `accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Er=H([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Dr=U(/{{[\w\W]*|^[\w\W]*}}/g),Or=U(/<%[\w\W]*|^[\w\W]*%>/g),kr=U(/\${[\w\W]*/g),Ar=U(/{{|}}|\${|<%|%>/),jr=U(/[^\t\n\f\r ]/),Mr=U(/\u0000/g),Nr=U(/^data-[\-\w.\u00B7-\uFFFF]+$/),Pr=U(/^aria-[\-\w]+$/),Fr=U(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ir=U(/^(?:\w+script|data):/i),Lr=U(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rr=U(/^html$/i),zr=U(/^[a-z][.\w]*(-[.\w]+)+$/i),Br=U(/<[/\w!]/g),Vr=U(/<[/\w]/g),Hr=U(/<[/\w]|^-?>|--!?>|<!-$/g),Ur=U(/<\/no(script|embed|frames)/i),Wr=U(/\/>/i),Gr=U(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),Kr=U(/^[\r\n\t ]+/),Z={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},qr=H(Y({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),Jr=H(Y({},[`textarea`,`title`])),Yr=H(Y({},[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`])),Xr=function(){return typeof window>`u`?null:window},Zr=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Qr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},$r=function(e,t,n,r){return G(e,t)&&Un(e[t])?Y(r.base?fr(r.base):{},e[t],r.transform):n},ei=function(e,t,n){let r=G(e,t)?e[t]:void 0;return r&&typeof r==`object`?dr(r):n};function ti(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Xr(),t=e=>ti(e);if(t.version=`3.5.0`,t.removed=[],!e||!e.document||e.document.nodeType!==Z.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter,l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=X(d,`cloneNode`),p=X(d,`remove`),m=X(d,`removeChild`),h=X(d,`removeAttributeNode`),ee=X(d,`nextSibling`),g=X(d,`childNodes`),_=X(d,`parentNode`),te=X(d,`shadowRoot`),ne=X(d,`attributes`),v=o&&o.prototype?X(o.prototype,`nodeType`):null,y=o&&o.prototype?X(o.prototype,`nodeName`):null,re=o&&o.prototype?X(o.prototype,`ownerDocument`):null,b=function(e){return v?v(e):e.nodeType},x=function(e){return y?y(e):e.nodeName},ie=mr(d,`namespaceURI`),ae=function(e){return ie?ie(e):e.namespaceURI},oe=function(e){return b(e)===Z.element?ne(e):null};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let S,C=``,se,ce=!1,le=0,w=function(){if(le>0)throw q(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},T=function(e){w(),le++;try{return S.createHTML(e)}finally{le--}},E=function(e){return S&&Ve?T(e):e},ue=function(e){w(),le++;try{return S.createScriptURL(e)}finally{le--}},de=function(){return ce||=(se=Zr(u,i),!0),se},D=n,fe=D.implementation,pe=D.createNodeIterator,me=D.createDocumentFragment,he=D.getElementsByTagName,ge=r.importNode,O=Qr();t.isSupported=typeof On==`function`&&typeof _==`function`&&fe&&fe.createHTMLDocument!==void 0;let _e=Dr,ve=Or,ye=kr,be=Nr,xe=Pr,Se=Ir,Ce=Lr,we=zr,Te=Fr,k=null,Ee=Y({},[...gr,..._r,...vr,...br,...Sr]),A=null,De=Y({},[...Cr,...wr,...Tr,...Er]),j=null,Oe=null,ke=null,M=Object.seal(Pn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ae=!0,je=!0,Me=!1,Ne=!0,N=!1,Pe=!0,Fe=!1,P=!1,Ie=null,Le=null,Re=!1,ze=!1,Be=!1,Ve=!1,He=!0,Ue=!1,We=`user-content-`,Ge=!0,Ke=!1,qe=null,Je=null,Ye=!1,Xe=null,Ze=Y({},/* @__PURE__ */ `annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),Qe=null,$e=Y({},[`audio`,`video`,`img`,`source`,`image`,`track`]),et=null,tt=Y({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),nt=`http://www.w3.org/1998/Math/MathML`,rt=`http://www.w3.org/2000/svg`,F=`http://www.w3.org/1999/xhtml`,it=F,at=!1,ot=null,st=Y({},[nt,rt,F],Qn),ct=H(Y({},[`mi`,`mo`,`mn`,`ms`,`mtext`])),lt=null,ut=H(Y({},[`annotation-xml`])),dt=null,ft=H(Pn(null)),pt=Y({},[`title`,`style`,`font`,`a`,`script`]),mt=null,ht=[`application/xhtml+xml`,`text/html`],I=null,gt=null,_t=null,vt=n.createElement(`form`),yt=function(e){return e instanceof RegExp||e instanceof Function},bt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e&&typeof e==`object`||(e={}),e=dr(e),mt=ht.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,I=mt===`application/xhtml+xml`?Qn:Zn,k=$r(e,`ALLOWED_TAGS`,Ee,{transform:I}),A=$r(e,`ALLOWED_ATTR`,De,{transform:I}),ot=$r(e,`ALLOWED_NAMESPACES`,st,{transform:Qn}),et=$r(e,`ADD_URI_SAFE_ATTR`,tt,{transform:I,base:tt}),Qe=$r(e,`ADD_DATA_URI_TAGS`,$e,{transform:I,base:$e}),Xe=$r(e,`FORBID_CONTENTS`,Ze,{transform:I}),Oe=$r(e,`FORBID_TAGS`,Pn(null),{transform:I}),ke=$r(e,`FORBID_ATTR`,Pn(null),{transform:I}),Ye=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?dr(e.USE_PROFILES):e.USE_PROFILES:!1,Ae=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,N=e.SAFE_FOR_TEMPLATES||!1,Pe=e.SAFE_FOR_XML!==!1,Fe=e.WHOLE_DOCUMENT||!1,ze=e.RETURN_DOM||!1,Be=e.RETURN_DOM_FRAGMENT||!1,Ve=e.RETURN_TRUSTED_TYPE||!1,Re=e.FORCE_BODY||!1,He=e.SANITIZE_DOM!==!1,Ue=e.SANITIZE_NAMED_PROPS||!1,Ge=e.KEEP_CONTENT!==!1,Ke=e.IN_PLACE||!1,Te=hr(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Fr,it=typeof e.NAMESPACE==`string`?e.NAMESPACE:F,lt=ei(e,`MATHML_TEXT_INTEGRATION_POINTS`,ct),dt=ei(e,`HTML_INTEGRATION_POINTS`,ut);let t=ei(e,`CUSTOM_ELEMENT_HANDLING`,ft);if(j=Pn(null),G(t,`tagNameCheck`)&&yt(t.tagNameCheck)&&(j.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&yt(t.attributeNameCheck)&&(j.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(j.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),U(j),N&&(je=!1),Be&&(ze=!0),Ye&&((G(e,`ALLOWED_TAGS`)||G(e,`ALLOWED_ATTR`))&&typeof console<`u`&&typeof console.warn==`function`&&console.warn(`DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together.`),k=Y({},Sr),A=Pn(null),Ye.html===!0&&(Y(k,gr),Y(A,Cr)),Ye.svg===!0&&(Y(k,_r),Y(A,wr),Y(A,Er)),Ye.svgFilters===!0&&(Y(k,vr),Y(A,wr),Y(A,Er)),Ye.mathMl===!0&&(Y(k,br),Y(A,Tr),Y(A,Er))),M.tagCheck=null,M.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?M.tagCheck=e.ADD_TAGS:Un(e.ADD_TAGS)&&(k===Ee&&(k=fr(k)),Y(k,e.ADD_TAGS,I))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?M.attributeCheck=e.ADD_ATTR:Un(e.ADD_ATTR)&&(A===De&&(A=fr(A)),Y(A,e.ADD_ATTR,I))),G(e,`ADD_FORBID_CONTENTS`)&&Un(e.ADD_FORBID_CONTENTS)&&(Xe===Ze&&(Xe=fr(Xe)),Y(Xe,e.ADD_FORBID_CONTENTS,I)),Ge&&(k[`#text`]=!0),Fe&&Y(k,[`html`,`head`,`body`]),k.table&&(k.tbody=!0,delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw q(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw q(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=S;S=e.TRUSTED_TYPES_POLICY;try{C=T(``)}catch(e){throw S=t,e}}else e.TRUSTED_TYPES_POLICY===null?(S=void 0,C=``):(S===void 0&&(S=de()),S&&typeof C==`string`&&(C=T(``)));gt=H(e)},xt=Y({},[..._r,...vr,...yr]),St=Y({},[...br,...xr]),Ct=function(e,t,n){return t===F?e===`svg`:t===nt?e===`svg`&&(n===`annotation-xml`||lt[n]):!!xt[e]},wt=function(e,t,n){return t===F?e===`math`:t===rt?e===`math`&&dt[n]:!!St[e]},Tt=function(e,t,n){return t===rt&&!dt[n]||t===nt&&!lt[n]?!1:!St[e]&&(pt[e]||!xt[e])},Et=function(e){let t=ae(e),n=Zn(x(e)),r=_(e),i=it,a=`template`;return r&&b(r)===Z.element&&(i=ae(r),a=Zn(x(r))),ot[t]?t===rt?Ct(n,i,a):t===nt?wt(n,i,a):t===F?Tt(n,i,a):mt===`application/xhtml+xml`:!1},Dt=function(e){Bn(t.removed,{element:e}),zt(e);try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw q(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},L=function(e,t,n){try{h(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Ot=function(e){jt(e);let t=g(e);t&&W(Vn(t),t=>{try{m(e,t)}catch{}}),b(e)===Z.element&&At(e,!1)},kt=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}if(Bn(t.removed,{attribute:r||null,from:n}),r)L(n,r,e);else try{n.removeAttribute(e)}catch{}if(e===`is`){if(ze||Be)try{Dt(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},At=function(e,t){let n=ne(e);if(n)for(let r=n.length-1;r>=0;--r){let i=n[r],a=i&&i.name;typeof a==`string`&&!(t&&A[I(a)])&&L(e,i,a)}},R=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&b(e)===Z.element){let t=te(e);Xt(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},jt=function(e){R(e,e=>{b(e)===Z.element&&At(e,!0)})},Mt=function(e){let t=[];return R(e,e=>{t.push(e)},!0),t},Nt=function(e,t){let n=Wn();W(Mt(e),e=>{b(e)===Z.element&&Gn(n,e)}),W(t,e=>{b(e)===Z.element&&!Kn(n,e)&&At(e,!0)})},Pt=function(e,n){let r=!1;return W(t.removed,t=>{t.element&&(r||=t.element===e,jt(t.element))}),Nt(e,n),r},Ft=function(e,t){Ot(e),Pt(e,t)},It=function(e,t){let n=qe,r=null,i=()=>(r||(r=Wn(),W(t,e=>{Gn(r,e)})),r);for(let t=0;;t++){let r=Mt(e),a=[e],o=!1;if(W(r,e=>{b(e)===Z.documentFragment?Bn(a,e):!o&&!Kn(n,e)&&(o=Kn(i(),e))}),!o)return;if(t>=8)throw q(`the tree kept changing during in-place sanitization; refusing to return it`);W(a,(t,n)=>{Lt(t,n>0,e,i())})}},Lt=function(e,t,n,r){let i=Ut(e),a;for(;a=i.nextNode();)Kn(r,a)&&!Kn(qe,a)&&(t&&B(O.uponSanitizeShadowNode,a,null),fn(a,n))},Rt=function(e){if(!qe)return;Gn(qe,e);let t=Yn(Je,e);if(t!==void 0){if(t>=8)throw q(`the tree kept changing during in-place sanitization; refusing to return it`);Xn(Je,e,t+1)}},zt=function(e){qe&&(qn(qe,e),Yn(Je,e)===void 0&&Xn(Je,e,0))},Bt=function(e,t){return Pe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Vt=function(e){Pe&&R(e,e=>{let t=b(e);if(t===Z.processingInstruction||t===Z.comment&&K(Vr,e.data)){try{p(e)}catch{}return!1}if(t===Z.element){let t=e,n=I(x(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Bt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Ht=function(e){let t=null,r=null;if(Re)e=`<remove></remove>`+e;else{let t=$n(e,Kr);r=t&&t[0]}mt===`application/xhtml+xml`&&it===F&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=S?T(e):e;if(it===F)try{t=new l().parseFromString(i,mt)}catch{}if(!t||!t.documentElement){t=fe.createDocument(it,`template`,null);try{t.documentElement.innerHTML=at?C:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),it===F?he.call(t,Fe?`html`:`body`)[0]:Fe?t.documentElement:a},Ut=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=re?re(e):e.ownerDocument;return pe.call(n||e,e,(t?0:c.SHOW_ELEMENT)|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Wt=function(e){return e=er(e,_e,` `),e=er(e,ve,` `),e=er(e,ye,` `),e},Gt=function(e){Jt(e);let t=e.querySelectorAll?.call(e,`template`);t&&W(t,e=>{Xt(e.content)&&Gt(e.content)})},Kt=Y({},[`caption`,`colgroup`,`col`,`thead`,`tbody`,`tfoot`,`tr`,`td`,`th`,`style`,`script`,`template`]),qt=function(e){if(mt===`application/xhtml+xml`)return;let t=e.querySelectorAll?.call(e,`table,tbody,thead,tfoot,tr,colgroup`);t&&t.length!==0&&W(t,t=>{W(Vn(g(t)),n=>{let r=b(n);if(!(r===Z.text?K(jr,n.data):r===Z.element&&!Kt[Zn(x(n))]))return;let i=t;for(;i&&Zn(x(i))!==`table`;)i=i===e?null:_(i);let a=i&&i!==e?_(i):null;if(a)try{a.insertBefore(n,i)}catch{}})})},Jt=function(e){qt(e),e.normalize();let t=Ut(e,!0),n=null,r=t.nextNode();for(;r;){let e=r.data;if(K(Mr,e)&&(e=er(e,Mr,``),r.data=e),K(Ar,e)&&(e=Wt(e),r.data=e),e&&b(r)===Z.text){if(n){let t=n.data;K(Ar,t[t.length-1]+e[0])&&(n.data=Wt(t+e[0]))}n=r}r=t.nextNode()}},z=function(e){let t=y?y(e):null;return typeof t!=`string`||I(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ne(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==v(e)||e.childNodes!==g(e)},Yt=function(e){if(!v||typeof e!=`object`||!e)return null;try{let t=v(e);return typeof t==`number`?t:null}catch{return null}},Xt=function(e){return Yt(e)===Z.documentFragment},Zt=function(e){return Yt(e)!==null};function B(e,n,r){e.length!==0&&W(e,e=>{e.call(t,n,r,gt)})}let Qt=function(e,t){let n=!!Yr[t],r=!!qr[t];return!n&&!r&&!Jr[t]||ae(e)!==F?!1:n?e.hasChildNodes():Zt(e.firstElementChild)?!0:r&&typeof e.textContent==`string`&&K(Br,e.textContent)},$t=function(e,t,n){return!!(Pe&&n===Z.element&&e.hasChildNodes()&&!Zt(e.firstElementChild)&&K(Br,e.textContent)&&K(Br,e.innerHTML)||Pe&&n===Z.element&&Qt(e,t)||n===Z.processingInstruction||Pe&&n===Z.comment&&K(Hr,e.data))},en=function(e,t){return e instanceof RegExp?K(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},tn=function(e,t,n){if(!Oe[t]&&sn(t)&&en(j.tagNameCheck,t))return!1;if(Ge&&!Xe[t]&&!Xe[Zn(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,ee(e))}}}return Dt(e),!0},V=function(e,t,n,r){return e.length===0?t:t===n||t===r?fr(t):t},nn=function(e,t){return e===t||_(e)!==null?!1:(Ke&&jt(e),zt(e),!0)},rn=function(e,n){if(Rt(e),B(O.beforeSanitizeElements,e,null),nn(e,n))return!0;if(z(e))return Dt(e),!0;let r=I(x(e)),i=b(e);if(k=V(O.uponSanitizeElement,k,Ee,Ie),B(O.uponSanitizeElement,e,{tagName:r,allowedTags:k}),nn(e,n))return!0;if($t(e,r,i))return Dt(e),!0;if((Oe[r]||!(M.tagCheck instanceof Function&&M.tagCheck(r))&&!k[r])&&tn(e,r,n))return!0;if(i===Z.element&&!Et(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&K(Ur,e.innerHTML))return Dt(e),!0;if(N&&i===Z.text){let n=e.textContent,r=Wt(n);n!==r&&(Bn(t.removed,{element:e.cloneNode()}),e.textContent=r)}return B(O.afterSanitizeElements,e,null),nn(e,n)},an=function(e,t,r){if(ke[t]||Bt(t,e)||He&&(t===`id`||t===`name`)&&(r in n||r in vt))return!1;let i=A[t]||M.attributeCheck instanceof Function&&M.attributeCheck(t,e);if(je&&K(be,t)||Ae&&K(xe,t))return!0;if(!i)return sn(e)&&en(j.tagNameCheck,e)&&en(j.attributeNameCheck,t,e)||t===`is`&&j.allowCustomizedBuiltInElements&&en(j.tagNameCheck,r);if(et[t])return!0;let a=er(r,Ce,``);return K(Te,a)||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&tr(r,`data:`)===0&&Qe[e]||Me&&!K(Se,a)?!0:!r},on=Y({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),sn=function(e){return!on[Zn(e)]&&K(we,e)},cn=function(e,t,n,r){if(S&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return T(r);case`TrustedScriptURL`:return ue(r)}return r},ln=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!z(e)||(Dt(e),!1)}catch{return kt(t,e),!1}},un=function(e,t){return Pe&&K(Gr,t)?!0:Zn(e)===`attributename`&&tr(t,`href`)!==-1},dn=function(e,n){if(B(O.beforeSanitizeAttributes,e,null),nn(e,n))return;let r=oe(e);if(!r||z(e))return;A=V(O.uponSanitizeAttribute,A,De,Le);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0},a=r.length,o=I(x(e));for(;a--;){let n=r[a];if(!n)continue;let s=n.name,c=n.namespaceURI,l=n.value,u=I(s),d=l,f=s===`value`?d:nr(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,B(O.uponSanitizeAttribute,e,i),f=i.attrValue,Ue&&(u===`id`||u===`name`)&&tr(f,We)!==0&&(kt(s,e,n),f=We+f,p=!0),un(s,f)?kt(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ne&&K(Wr,f)?kt(s,e,n):(N&&(f=Wt(f)),an(o,u,f)?(f=cn(o,u,c,f),f!==d&&ln(e,s,c,f)&&p&&zn(t.removed)):kt(s,e,n)):kt(s,e,n))}B(O.afterSanitizeAttributes,e,null),nn(e,n)},fn=function(e,t){rn(e,t),dn(e,t),Xt(e.content)&&pn(e.content)},pn=function(e){let t=null,n=Ut(e);for(B(O.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(B(O.uponSanitizeShadowNode,t,null),fn(t,e),b(t)===Z.element){let e=te(t);Xt(e)&&(mn(e),pn(e))}N&&Jt(e),B(O.afterSanitizeShadowDOM,e,null)},mn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){pn(e.shadow);continue}let n=e.node,r=b(n)===Z.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=y?y(n):null;if(typeof e==`string`&&I(e)===`template`){let e=n.content;Xt(e)&&t.push({node:e,shadow:null})}}if(r){let e=te(n);Xt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}},hn=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(at=!e,at&&(e=`<!-->`),typeof e!=`string`&&!Zt(e)&&(e=pr(e),typeof e!=`string`))throw q(`dirty is not a string, aborting`);if(!t.isSupported)return e;P?(k=Ie,A=Le):bt(n),_t=gt,t.removed=[];let c=Ke&&typeof e!=`string`&&Zt(e),l=[],u=qe,d=Je;if(c){Vt(e),l=Mt(e);let t=x(e);if(typeof t==`string`){let n=I(t);if(!k[n]||Oe[n])throw Ft(e,l),q(`root node is forbidden and cannot be sanitized in-place`)}if(z(e))throw Ft(e,l),q(`root node is clobbered and cannot be sanitized in-place`);qe=Wn(),Je=Jn()}else if(Zt(e))i=Ht(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Z.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),mn(i);else{if(!ze&&!N&&!Fe&&e.indexOf(`<`)===-1)return E(e);if(i=Ht(e),!i)return ze?null:Ve?C:``}i&&Re&&Dt(i.firstChild);let f=c?e:i;try{c&&mn(e);let t=Ut(f);for(;o=t.nextNode();)fn(o,f);c&&It(e,l)}catch(t){throw c&&Ft(e,l),t}finally{qe=u,Je=d}if(c){if(Pt(e,l))throw q(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return N&&Gt(e),e}if(ze){if(N&&Gt(i),Be)for(s=me.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(A.shadowroot||A.shadowrootmode)&&(s=ge.call(r,s,!0)),s}N&&Jt(i);let p=Fe?i.outerHTML:i.innerHTML;return Fe&&k[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(Rr,i.ownerDocument.doctype.name)&&(p=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
81
|
-
`+p),E(p)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=
|
|
77
|
+
`}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>${I(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,text:n,tokens:r,autolink:i}){let a=i?I(n,!0):this.parser.parseInline(r),o=At(e);if(o===null)return a;e=I(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+I(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(Yt(r),this.parser.textRenderer));let i=At(e);if(i===null)return I(n);e=i;let a=`<img src="${I(e)}" alt="${I(n)}"`;return t&&(a+=` title="${I(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:I(e.text)}},Zt=class{parser;strong({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}em({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}codespan({text:e}){return e}del({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}html({text:e}){return e}text({text:e}){return e}link({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}image({text:e,tokens:t}){return t?this.parser.parseInline(t,this):e}br(){return`
|
|
78
|
+
`}checkbox({raw:e}){return e}},B=class e{options;renderer;textRenderer;constructor(e){this.options=e||C,this.options.renderer=this.options.renderer||new Xt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Zt,this.textRenderer.parser=this}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){this.renderer.parser=this;let t=``;for(let n=0;n<e.length;n++){let r=e[n],i=this.options.extensions?.renderers;if(i&&Object.hasOwn(i,r.type)&&i[r.type]){let e=r,n=i[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`checkbox`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n===!1?``:n??``;continue}}let a=r;switch(a.type){case`space`:t+=this.renderer.space(a);break;case`hr`:t+=this.renderer.hr(a);break;case`heading`:t+=this.renderer.heading(a);break;case`code`:t+=this.renderer.code(a);break;case`table`:t+=this.renderer.table(a);break;case`blockquote`:t+=this.renderer.blockquote(a);break;case`list`:t+=this.renderer.list(a);break;case`checkbox`:t+=this.renderer.checkbox(a);break;case`html`:t+=this.renderer.html(a);break;case`def`:t+=this.renderer.def(a);break;case`paragraph`:t+=this.renderer.paragraph(a);break;case`text`:t+=this.renderer.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let n=``;for(let r=0;r<e.length;r++){let i=e[r],a=this.options.extensions?.renderers;if(a&&Object.hasOwn(a,i.type)&&a[i.type]){let e=a[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`checkbox`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e===!1?``:e??``;continue}}let o=i;switch(o.type){case`escape`:n+=t.text(o);break;case`html`:n+=t.html(o);break;case`link`:n+=t.link(o);break;case`image`:n+=t.image(o);break;case`checkbox`:n+=t.checkbox(o);break;case`strong`:n+=t.strong(o);break;case`em`:n+=t.em(o);break;case`codespan`:n+=t.codespan(o);break;case`br`:n+=t.br(o);break;case`del`:n+=t.del(o);break;case`text`:n+=t.text(o);break;default:{let e=`Token with "`+o.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},Qt=class{options;block;constructor(e){this.options=e||C}static passThroughHooks=/* @__PURE__ */ new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=/* @__PURE__ */ 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?z.lex:z.lexInline}provideParser(e=this.block){return e?B.parse:B.parseInline}};function $t(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var en=class{defaults=ce();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=B;Renderer=Xt;TextRenderer=Zt;Lexer=z;Tokenizer=R;Hooks=Qt;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch($t(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)$t(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)$t(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;$t(n,this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{if(e[r]){let i=e[r].flat(1/0);$t(n,this.walkTokens(i,t))}}):e.tokens&&$t(n,this.walkTokens(e.tokens,t))}}return n}use(...e){let t=this.defaults.extensions||{renderers:Object.create(null),childTokens:Object.create(null)};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Xt(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n===!1?``:n??``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new R(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new Qt;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];t[r]=Qt.passThroughHooks.has(n)?e=>{if(t.options.async&&Qt.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:(...e)=>{if(t.options.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return $t(n,r.call(this,e)),t&&$t(n,t.call(this,e)),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return z.lex(e,t??this.defaults)}parser(e,t){return B.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(/* @__PURE__ */ 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 t>`u`||t===null)return a(/* @__PURE__ */ Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(/* @__PURE__ */ Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer(e):e?z.lex:z.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser(e):e?B.parse:B.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer(e):e?z.lex:z.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser(e):e?B.parse:B.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
|
|
79
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+I(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},tn=new en;function V(e,t){return tn.parse(e,t)}V.options=V.setOptions=function(e){return tn.setOptions(e),V.defaults=tn.defaults,le(V.defaults),V},V.getDefaults=ce,V.defaults=C;function nn(...e){return tn.use(...e),V.defaults=tn.defaults,le(V.defaults),V}V.use=nn,V.walkTokens=function(e,t){return tn.walkTokens(e,t)},V.parseInline=tn.parseInline,V.Parser=B,V.parser=B.parse,V.Renderer=Xt,V.TextRenderer=Zt,V.Lexer=z,V.lexer=z.lex,V.Tokenizer=R,V.Hooks=Qt,V.parse=V,V.options,V.setOptions,V.walkTokens,V.parseInline,B.parse,z.lex;function rn(e){let t=e.classList;return t.contains(`language-mermaid`)?`mermaid`:t.contains(`language-vega-lite`)||t.contains(`language-vegalite`)?`vega`:t.contains(`language-a2ui`)?`a2ui`:null}function an(e){let t=null,n=null;return{get:()=>t,load:()=>n??=e().then(e=>t=e,e=>{throw n=null,e})}}var on=an(()=>import(`./bundle/math-Cx-Q-b8s.js`)),sn={mermaid:an(()=>import(`./bundle/mermaid-DaDuEHir.js`).then(e=>e.t)),vega:an(()=>import(`./bundle/vega-eBn1AexV.js`)),a2ui:an(()=>import(`./bundle/a2ui-C-LAbJcp.js`))},cn=`rich-drawing`,ln=/* @__PURE__ */ new WeakMap,un=/* @__PURE__ */ new WeakMap,dn=/* @__PURE__ */ new WeakMap;function fn(e,t){for(let n of e.querySelectorAll(`.${cn}`))dn.get(n)?.(t)}function pn(e){for(let t of e.querySelectorAll(`.${cn}`))un.get(t)?.()}function mn(e){let t=/* @__PURE__ */ new Map;for(let n of e.querySelectorAll(`.${cn}`)){let e=ln.get(n);if(e===void 0)continue;let r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function hn(e){let t=getComputedStyle(e.host);return{host:e.host,root:e.host.shadowRoot??document,dark:_n(t.color),font:t.fontFamily,lang:e.lang,live:e.live??!1,strings:e.strings,interface:e.interface}}function gn(e){let t=/^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)/.exec(e);if(t)return[Number(t[1]),Number(t[2]),Number(t[3])];try{let t=document.createElement(`canvas`);t.width=t.height=1;let n=t.getContext(`2d`,{willReadFrequently:!0});if(!n)return null;n.fillStyle=e,n.fillRect(0,0,1,1);let[r=0,i=0,a=0]=n.getImageData(0,0,1,1).data;return[r,i,a]}catch{return null}}function _n(e){let[t,n,r]=gn(e)??[0,0,0];return .2126*t+.7152*n+.0722*r>140}function vn(e,t,n=/* @__PURE__ */ new Map){if(e.querySelector(`.math-inline, .math-display`)){let n=()=>{on.get()?.renderFormulas(e,t.host)};on.get()?n():on.load().then(n,()=>void 0)}if(t.widgets){let r=null;for(let i of e.querySelectorAll(`pre > code`)){let e=rn(i),a=i.parentElement;if(!e||!a||t.live&&e!==`a2ui`&&a.hasAttribute(`data-open`))continue;let o=(i.textContent??``).replace(/\n$/,``);r??=hn(t);let s=`${e}\n${r.dark}\n${o}`,c=n.get(s)?.shift();if(c){a.replaceWith(c);continue}let l=sn[e],u=l.get(),d=r;u?yn(a,u.draw(o,d),s):l.load().then(e=>{a.parentNode&&yn(a,e.draw(o,d),s)},()=>void 0)}}for(let e of n.values())for(let t of e)un.get(t)?.()}function yn(e,t,n){let r=t=>{!t||!e.parentNode?t&&un.get(t)?.():(t.classList.add(cn),ln.set(t,n),e.replaceWith(t))};t instanceof Promise?t.then(r,()=>void 0):r(t)}function bn(e,t){this.v=e,this.k=t}function xn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Sn(e){if(Array.isArray(e))return e}function Cn(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function wn(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
80
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Tn(e,t){return Sn(e)||Cn(e,t)||En(e,t)||wn()}function En(e,t){if(e){if(typeof e==`string`)return xn(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?xn(e,t):void 0}}function Dn(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof bn;Promise.resolve(s?o.v:o).then(function(n){if(s){var c=t===`return`&&o.k?t:`next`;if(!o.k||n.done)return r(c,n);n=e[c](n).value}i(!!a.done,n)},function(e){r(`throw`,e)})}catch(e){i(2,e)}}function i(e,i){e===2?t.reject(i):t.resolve({value:i,done:e}),(t=t.next)?r(t.key,t.arg):n=null}this._invoke=function(e,i){return new Promise(function(a,o){var s={key:e,arg:i,resolve:a,reject:o,next:null};n?n=n.next=s:(t=n=s,r(e,i))})},typeof e.return!=`function`&&(this.return=void 0)}Dn.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},Dn.prototype.next=function(e){return this._invoke(`next`,e)},Dn.prototype.throw=function(e){return this._invoke(`throw`,e)},Dn.prototype.return=function(e){return this._invoke(`return`,e)};var On=Object.entries,kn=Object.keys,An=Object.setPrototypeOf,jn=Object.isFrozen,Mn=Object.getPrototypeOf,Nn=Object.getOwnPropertyDescriptor,H=Object.freeze,U=Object.seal,Pn=Object.create,Fn=typeof Reflect<`u`&&Reflect,In=Fn.apply,Ln=Fn.construct;H||=function(e){return e},U||=function(e){return e},In||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},Ln||=function(e){return new e(...[...arguments].slice(1))};var W=J(Array.prototype.forEach),Rn=J(Array.prototype.lastIndexOf),zn=J(Array.prototype.pop),Bn=J(Array.prototype.push),Vn=J(Array.prototype.slice),Hn=J(Array.prototype.splice),Un=Array.isArray,Wn=lr(Set),Gn=J(Set.prototype.add),Kn=J(Set.prototype.has),qn=J(Set.prototype.delete),Jn=lr(Map),Yn=J(Map.prototype.get),Xn=J(Map.prototype.set),Zn=J(String.prototype.toLowerCase),Qn=J(String.prototype.toString),$n=J(String.prototype.match),er=J(String.prototype.replace),tr=J(String.prototype.indexOf),nr=J(String.prototype.trim),rr=J(Number.prototype.toString),ir=J(Boolean.prototype.toString),ar=typeof BigInt>`u`?null:J(BigInt.prototype.toString),or=typeof Symbol>`u`?null:J(Symbol.prototype.toString),G=J(Object.prototype.hasOwnProperty),sr=J(Object.prototype.toString),cr=RegExp.prototype.test,K=function(e,t){return e instanceof RegExp&&(e.lastIndex=0),In(cr,e,[t])},q=lr(TypeError);function J(e){return function(t){var n=[...arguments].slice(1);return In(e,t,n)}}function lr(e){return function(){return Ln(e,[...arguments])}}function Y(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Zn;if(An&&An(e,null),!Un(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(jn(t)||(t[r]=e),i=e)}e[i]=!0}return e}function ur(e){for(let t=0;t<e.length;t++)G(e,t)||(e[t]=null);return e}function dr(e){let t=Pn(null);for(let r of On(e)){var n=Tn(r,2);let i=n[0],a=n[1];G(e,i)&&(t[i]=Un(a)?ur(a):a&&typeof a==`object`&&a.constructor===Object?dr(a):a)}return t}function fr(e){let t=Pn(null),n=kn(e),r=n.length;for(;r--;)t[n[r]]=e[n[r]];return t}function pr(e){switch(typeof e){case`string`:return e;case`number`:return rr(e);case`boolean`:return ir(e);case`bigint`:return ar?ar(e):`0`;case`symbol`:return or?or(e):`Symbol()`;case`undefined`:return sr(e);case`function`:case`object`:{if(e===null)return sr(e);let t=e,n=X(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:sr(e)}return sr(e)}default:return sr(e)}}function X(e,t){for(;e!==null;){let n=Nn(e,t);if(n){if(n.get)return J(n.get);if(typeof n.value==`function`)return J(n.value)}e=Mn(e)}function n(){return null}return n}function mr(e,t){for(;e!==null;){let n=Nn(e,t);if(n)return n.get?J(n.get):null;e=Mn(e)}return null}function hr(e){if(!e)return!1;try{return K(e,``),!0}catch{return!1}}var gr=H(/* @__PURE__ */ `a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),_r=H(/* @__PURE__ */ `svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.filter.font.g.glyph.glyphref.hkern.image.line.lineargradient.marker.mask.metadata.mpath.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),vr=H([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),yr=H([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),br=H(/* @__PURE__ */ `math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),xr=H([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Sr=H([`#text`]),Cr=H(/* @__PURE__ */ `accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.command.commandfor.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),wr=H(/* @__PURE__ */ `accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dominant-baseline.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.pointer-events.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-orientation.text-rendering.textlength.type.u1.u2.unicode.values.vector-effect.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),Tr=H(/* @__PURE__ */ `accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Er=H([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Dr=U(/{{[\w\W]*|^[\w\W]*}}/g),Or=U(/<%[\w\W]*|^[\w\W]*%>/g),kr=U(/\${[\w\W]*/g),Ar=U(/{{|}}|\${|<%|%>/),jr=U(/[^\t\n\f\r ]/),Mr=U(/\u0000/g),Nr=U(/^data-[\-\w.\u00B7-\uFFFF]+$/),Pr=U(/^aria-[\-\w]+$/),Fr=U(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ir=U(/^(?:\w+script|data):/i),Lr=U(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Rr=U(/^html$/i),zr=U(/^[a-z][.\w]*(-[.\w]+)+$/i),Br=U(/<[/\w!]/g),Vr=U(/<[/\w]/g),Hr=U(/<[/\w]|^-?>|--!?>|<!-$/g),Ur=U(/<\/no(script|embed|frames)/i),Wr=U(/\/>/i),Gr=U(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i),Kr=U(/^[\r\n\t ]+/),Z={element:1,text:3,processingInstruction:7,comment:8,document:9,documentFragment:11},qr=H(Y({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),Jr=H(Y({},[`textarea`,`title`])),Yr=H(Y({},[`area`,`base`,`basefont`,`bgsound`,`br`,`col`,`embed`,`frame`,`hr`,`img`,`input`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`])),Xr=function(){return typeof window>`u`?null:window},Zr=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Qr=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},$r=function(e,t,n,r){return G(e,t)&&Un(e[t])?Y(r.base?fr(r.base):{},e[t],r.transform):n},ei=function(e,t,n){let r=G(e,t)?e[t]:void 0;return r&&typeof r==`object`?dr(r):n};function ti(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Xr(),t=e=>ti(e);if(t.version=`3.5.0`,t.removed=[],!e||!e.document||e.document.nodeType!==Z.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter,l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=X(d,`cloneNode`),p=X(d,`remove`),m=X(d,`removeChild`),h=X(d,`removeAttributeNode`),ee=X(d,`nextSibling`),g=X(d,`childNodes`),_=X(d,`parentNode`),te=X(d,`shadowRoot`),ne=X(d,`attributes`),re=o&&o.prototype?X(o.prototype,`nodeType`):null,v=o&&o.prototype?X(o.prototype,`nodeName`):null,ie=o&&o.prototype?X(o.prototype,`ownerDocument`):null,y=function(e){return re?re(e):e.nodeType},b=function(e){return v?v(e):e.nodeName},ae=mr(d,`namespaceURI`),oe=function(e){return ae?ae(e):e.namespaceURI},se=function(e){return y(e)===Z.element?ne(e):null};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let x,S=``,ce,C=!1,le=0,w=function(){if(le>0)throw q(`A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.`)},T=function(e){w(),le++;try{return x.createHTML(e)}finally{le--}},E=function(e){return x&&He?T(e):e},ue=function(e){w(),le++;try{return x.createScriptURL(e)}finally{le--}},de=function(){return C||=(ce=Zr(u,i),!0),ce},D=n,fe=D.implementation,pe=D.createNodeIterator,me=D.createDocumentFragment,he=D.getElementsByTagName,ge=r.importNode,O=Qr();t.isSupported=typeof On==`function`&&typeof _==`function`&&fe&&fe.createHTMLDocument!==void 0;let _e=Dr,ve=Or,ye=kr,be=Nr,xe=Pr,Se=Ir,Ce=Lr,we=zr,Te=Fr,k=null,Ee=Y({},[...gr,..._r,...vr,...br,...Sr]),A=null,De=Y({},[...Cr,...wr,...Tr,...Er]),j=null,Oe=null,ke=null,M=Object.seal(Pn(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Ae=!0,je=!0,Me=!1,Ne=!0,Pe=!1,Fe=!0,Ie=!1,N=!1,Le=null,Re=null,ze=!1,Be=!1,Ve=!1,He=!1,Ue=!0,We=!1,Ge=`user-content-`,Ke=!0,qe=!1,Je=null,Ye=null,Xe=!1,Ze=null,Qe=Y({},/* @__PURE__ */ `annotation-xml.audio.colgroup.desc.foreignobject.head.iframe.math.mi.mn.mo.ms.mtext.noembed.noframes.noscript.plaintext.script.selectedcontent.style.svg.template.thead.title.video.xmp`.split(`.`)),$e=null,et=Y({},[`audio`,`video`,`img`,`source`,`image`,`track`]),tt=null,nt=Y({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),rt=`http://www.w3.org/1998/Math/MathML`,it=`http://www.w3.org/2000/svg`,P=`http://www.w3.org/1999/xhtml`,at=P,ot=!1,st=null,ct=Y({},[rt,it,P],Qn),lt=H(Y({},[`mi`,`mo`,`mn`,`ms`,`mtext`])),ut=null,dt=H(Y({},[`annotation-xml`])),ft=null,pt=H(Pn(null)),mt=Y({},[`title`,`style`,`font`,`a`,`script`]),ht=null,gt=[`application/xhtml+xml`,`text/html`],F=null,_t=null,vt=null,yt=n.createElement(`form`),bt=function(e){return e instanceof RegExp||e instanceof Function},xt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e&&typeof e==`object`||(e={}),e=dr(e),ht=gt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,F=ht===`application/xhtml+xml`?Qn:Zn,k=$r(e,`ALLOWED_TAGS`,Ee,{transform:F}),A=$r(e,`ALLOWED_ATTR`,De,{transform:F}),st=$r(e,`ALLOWED_NAMESPACES`,ct,{transform:Qn}),tt=$r(e,`ADD_URI_SAFE_ATTR`,nt,{transform:F,base:nt}),$e=$r(e,`ADD_DATA_URI_TAGS`,et,{transform:F,base:et}),Ze=$r(e,`FORBID_CONTENTS`,Qe,{transform:F}),Oe=$r(e,`FORBID_TAGS`,Pn(null),{transform:F}),ke=$r(e,`FORBID_ATTR`,Pn(null),{transform:F}),Xe=G(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?dr(e.USE_PROFILES):e.USE_PROFILES:!1,Ae=e.ALLOW_ARIA_ATTR!==!1,je=e.ALLOW_DATA_ATTR!==!1,Me=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Pe=e.SAFE_FOR_TEMPLATES||!1,Fe=e.SAFE_FOR_XML!==!1,Ie=e.WHOLE_DOCUMENT||!1,Be=e.RETURN_DOM||!1,Ve=e.RETURN_DOM_FRAGMENT||!1,He=e.RETURN_TRUSTED_TYPE||!1,ze=e.FORCE_BODY||!1,Ue=e.SANITIZE_DOM!==!1,We=e.SANITIZE_NAMED_PROPS||!1,Ke=e.KEEP_CONTENT!==!1,qe=e.IN_PLACE||!1,Te=hr(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Fr,at=typeof e.NAMESPACE==`string`?e.NAMESPACE:P,ut=ei(e,`MATHML_TEXT_INTEGRATION_POINTS`,lt),ft=ei(e,`HTML_INTEGRATION_POINTS`,dt);let t=ei(e,`CUSTOM_ELEMENT_HANDLING`,pt);if(j=Pn(null),G(t,`tagNameCheck`)&&bt(t.tagNameCheck)&&(j.tagNameCheck=t.tagNameCheck),G(t,`attributeNameCheck`)&&bt(t.attributeNameCheck)&&(j.attributeNameCheck=t.attributeNameCheck),G(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(j.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),U(j),Pe&&(je=!1),Ve&&(Be=!0),Xe&&((G(e,`ALLOWED_TAGS`)||G(e,`ALLOWED_ATTR`))&&typeof console<`u`&&typeof console.warn==`function`&&console.warn(`DOMPurify: USE_PROFILES overrides ALLOWED_TAGS and ALLOWED_ATTR. Do not use these options together.`),k=Y({},Sr),A=Pn(null),Xe.html===!0&&(Y(k,gr),Y(A,Cr)),Xe.svg===!0&&(Y(k,_r),Y(A,wr),Y(A,Er)),Xe.svgFilters===!0&&(Y(k,vr),Y(A,wr),Y(A,Er)),Xe.mathMl===!0&&(Y(k,br),Y(A,Tr),Y(A,Er))),M.tagCheck=null,M.attributeCheck=null,G(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?M.tagCheck=e.ADD_TAGS:Un(e.ADD_TAGS)&&(k===Ee&&(k=fr(k)),Y(k,e.ADD_TAGS,F))),G(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?M.attributeCheck=e.ADD_ATTR:Un(e.ADD_ATTR)&&(A===De&&(A=fr(A)),Y(A,e.ADD_ATTR,F))),G(e,`ADD_FORBID_CONTENTS`)&&Un(e.ADD_FORBID_CONTENTS)&&(Ze===Qe&&(Ze=fr(Ze)),Y(Ze,e.ADD_FORBID_CONTENTS,F)),Ke&&(k[`#text`]=!0),Ie&&Y(k,[`html`,`head`,`body`]),k.table&&(k.tbody=!0,delete Oe.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw q(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw q(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=x;x=e.TRUSTED_TYPES_POLICY;try{S=T(``)}catch(e){throw x=t,e}}else e.TRUSTED_TYPES_POLICY===null?(x=void 0,S=``):(x===void 0&&(x=de()),x&&typeof S==`string`&&(S=T(``)));_t=H(e)},St=Y({},[..._r,...vr,...yr]),Ct=Y({},[...br,...xr]),wt=function(e,t,n){return t===P?e===`svg`:t===rt?e===`svg`&&(n===`annotation-xml`||ut[n]):!!St[e]},Tt=function(e,t,n){return t===P?e===`math`:t===it?e===`math`&&ft[n]:!!Ct[e]},Et=function(e,t,n){return t===it&&!ft[n]||t===rt&&!ut[n]?!1:!Ct[e]&&(mt[e]||!St[e])},Dt=function(e){let t=oe(e),n=Zn(b(e)),r=_(e),i=at,a=`template`;return r&&y(r)===Z.element&&(i=oe(r),a=Zn(b(r))),st[t]?t===it?wt(n,i,a):t===rt?Tt(n,i,a):t===P?Et(n,i,a):ht===`application/xhtml+xml`:!1},Ot=function(e){Bn(t.removed,{element:e}),Bt(e);try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw q(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},I=function(e,t,n){try{h(e,t)}catch{try{e.removeAttribute(n)}catch{}}},kt=function(e){Mt(e);let t=g(e);t&&W(Vn(t),t=>{try{m(e,t)}catch{}}),y(e)===Z.element&&jt(e,!1)},At=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}if(Bn(t.removed,{attribute:r||null,from:n}),r)I(n,r,e);else try{n.removeAttribute(e)}catch{}if(e===`is`){if(Be||Ve)try{Ot(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},jt=function(e,t){let n=ne(e);if(n)for(let r=n.length-1;r>=0;--r){let i=n[r],a=i&&i.name;typeof a==`string`&&!(t&&A[F(a)])&&I(e,i,a)}},L=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0&&arguments[2],r=[e];for(;r.length>0;){let e=r.pop();if(t(e)===!1)continue;if(n&&y(e)===Z.element){let t=te(e);Xt(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},Mt=function(e){L(e,e=>{y(e)===Z.element&&jt(e,!0)})},Nt=function(e){let t=[];return L(e,e=>{t.push(e)},!0),t},Pt=function(e,t){let n=Wn();W(Nt(e),e=>{y(e)===Z.element&&Gn(n,e)}),W(t,e=>{y(e)===Z.element&&!Kn(n,e)&&jt(e,!0)})},Ft=function(e,n){let r=!1;return W(t.removed,t=>{t.element&&(r||=t.element===e,Mt(t.element))}),Pt(e,n),r},It=function(e,t){kt(e),Ft(e,t)},Lt=function(e,t){let n=Je,r=null,i=()=>(r||(r=Wn(),W(t,e=>{Gn(r,e)})),r);for(let t=0;;t++){let r=Nt(e),a=[e],o=!1;if(W(r,e=>{y(e)===Z.documentFragment?Bn(a,e):!o&&!Kn(n,e)&&(o=Kn(i(),e))}),!o)return;if(t>=8)throw q(`the tree kept changing during in-place sanitization; refusing to return it`);W(a,(t,n)=>{Rt(t,n>0,e,i())})}},Rt=function(e,t,n,r){let i=Wt(e),a;for(;a=i.nextNode();)Kn(r,a)&&!Kn(Je,a)&&(t&&B(O.uponSanitizeShadowNode,a,null),fn(a,n))},zt=function(e){if(!Je)return;Gn(Je,e);let t=Yn(Ye,e);if(t!==void 0){if(t>=8)throw q(`the tree kept changing during in-place sanitization; refusing to return it`);Xn(Ye,e,t+1)}},Bt=function(e){Je&&(qn(Je,e),Yn(Ye,e)===void 0&&Xn(Ye,e,0))},Vt=function(e,t){return Fe?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Ht=function(e){Fe&&L(e,e=>{let t=y(e);if(t===Z.processingInstruction||t===Z.comment&&K(Vr,e.data)){try{p(e)}catch{}return!1}if(t===Z.element){let t=e,n=F(b(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Vt(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Ut=function(e){let t=null,r=null;if(ze)e=`<remove></remove>`+e;else{let t=$n(e,Kr);r=t&&t[0]}ht===`application/xhtml+xml`&&at===P&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=x?T(e):e;if(at===P)try{t=new l().parseFromString(i,ht)}catch{}if(!t||!t.documentElement){t=fe.createDocument(at,`template`,null);try{t.documentElement.innerHTML=ot?S:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),at===P?he.call(t,Ie?`html`:`body`)[0]:Ie?t.documentElement:a},Wt=function(e){let t=arguments.length>1&&arguments[1]!==void 0&&arguments[1],n=ie?ie(e):e.ownerDocument;return pe.call(n||e,e,(t?0:c.SHOW_ELEMENT)|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Gt=function(e){return e=er(e,_e,` `),e=er(e,ve,` `),e=er(e,ye,` `),e},Kt=function(e){R(e);let t=e.querySelectorAll?.call(e,`template`);t&&W(t,e=>{Xt(e.content)&&Kt(e.content)})},qt=Y({},[`caption`,`colgroup`,`col`,`thead`,`tbody`,`tfoot`,`tr`,`td`,`th`,`style`,`script`,`template`]),Jt=function(e){if(ht===`application/xhtml+xml`)return;let t=e.querySelectorAll?.call(e,`table,tbody,thead,tfoot,tr,colgroup`);t&&t.length!==0&&W(t,t=>{W(Vn(g(t)),n=>{let r=y(n);if(!(r===Z.text?K(jr,n.data):r===Z.element&&!qt[Zn(b(n))]))return;let i=t;for(;i&&Zn(b(i))!==`table`;)i=i===e?null:_(i);let a=i&&i!==e?_(i):null;if(a)try{a.insertBefore(n,i)}catch{}})})},R=function(e){Jt(e),e.normalize();let t=Wt(e,!0),n=null,r=t.nextNode();for(;r;){let e=r.data;if(K(Mr,e)&&(e=er(e,Mr,``),r.data=e),K(Ar,e)&&(e=Gt(e),r.data=e),e&&y(r)===Z.text){if(n){let t=n.data;K(Ar,t[t.length-1]+e[0])&&(n.data=Gt(t+e[0]))}n=r}r=t.nextNode()}},z=function(e){let t=v?v(e):null;return typeof t!=`string`||F(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==ne(e)||typeof e.removeAttribute!=`function`||typeof e.removeAttributeNode!=`function`||typeof e.getAttributeNode!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`||e.nodeType!==re(e)||e.childNodes!==g(e)},Yt=function(e){if(!re||typeof e!=`object`||!e)return null;try{let t=re(e);return typeof t==`number`?t:null}catch{return null}},Xt=function(e){return Yt(e)===Z.documentFragment},Zt=function(e){return Yt(e)!==null};function B(e,n,r){e.length!==0&&W(e,e=>{e.call(t,n,r,_t)})}let Qt=function(e,t){let n=!!Yr[t],r=!!qr[t];return!n&&!r&&!Jr[t]||oe(e)!==P?!1:n?e.hasChildNodes():Zt(e.firstElementChild)?!0:r&&typeof e.textContent==`string`&&K(Br,e.textContent)},$t=function(e,t,n){return!!(Fe&&n===Z.element&&e.hasChildNodes()&&!Zt(e.firstElementChild)&&K(Br,e.textContent)&&K(Br,e.innerHTML)||Fe&&n===Z.element&&Qt(e,t)||n===Z.processingInstruction||Fe&&n===Z.comment&&K(Hr,e.data))},en=function(e,t){return e instanceof RegExp?K(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},tn=function(e,t,n){if(!Oe[t]&&sn(t)&&en(j.tagNameCheck,t))return!1;if(Ke&&!Ze[t]&&!Ze[Zn(t)]){let t=_(e),r=g(e);if(r&&t){let i=r.length;for(let a=i-1;a>=0;--a){let i=e===n?f(r[a],!0):r[a];t.insertBefore(i,ee(e))}}}return Ot(e),!0},V=function(e,t,n,r){return e.length===0?t:t===n||t===r?fr(t):t},nn=function(e,t){return e===t||_(e)!==null?!1:(qe&&Mt(e),Bt(e),!0)},rn=function(e,n){if(zt(e),B(O.beforeSanitizeElements,e,null),nn(e,n))return!0;if(z(e))return Ot(e),!0;let r=F(b(e)),i=y(e);if(k=V(O.uponSanitizeElement,k,Ee,Le),B(O.uponSanitizeElement,e,{tagName:r,allowedTags:k}),nn(e,n))return!0;if($t(e,r,i))return Ot(e),!0;if((Oe[r]||!(M.tagCheck instanceof Function&&M.tagCheck(r))&&!k[r])&&tn(e,r,n))return!0;if(i===Z.element&&!Dt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&K(Ur,e.innerHTML))return Ot(e),!0;if(Pe&&i===Z.text){let n=e.textContent,r=Gt(n);n!==r&&(Bn(t.removed,{element:e.cloneNode()}),e.textContent=r)}return B(O.afterSanitizeElements,e,null),nn(e,n)},an=function(e,t,r){if(ke[t]||Vt(t,e)||Ue&&(t===`id`||t===`name`)&&(r in n||r in yt))return!1;let i=A[t]||M.attributeCheck instanceof Function&&M.attributeCheck(t,e);if(je&&K(be,t)||Ae&&K(xe,t))return!0;if(!i)return sn(e)&&en(j.tagNameCheck,e)&&en(j.attributeNameCheck,t,e)||t===`is`&&j.allowCustomizedBuiltInElements&&en(j.tagNameCheck,r);if(tt[t])return!0;let a=er(r,Ce,``);return K(Te,a)||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&tr(r,`data:`)===0&&$e[e]||Me&&!K(Se,a)?!0:!r},on=Y({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),sn=function(e){return!on[Zn(e)]&&K(we,e)},cn=function(e,t,n,r){if(x&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return T(r);case`TrustedScriptURL`:return ue(r)}return r},ln=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!z(e)||(Ot(e),!1)}catch{return At(t,e),!1}},un=function(e,t){return Fe&&K(Gr,t)?!0:Zn(e)===`attributename`&&tr(t,`href`)!==-1},dn=function(e,n){if(B(O.beforeSanitizeAttributes,e,null),nn(e,n))return;let r=se(e);if(!r||z(e))return;A=V(O.uponSanitizeAttribute,A,De,Re);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:A,forceKeepAttr:void 0},a=r.length,o=F(b(e));for(;a--;){let n=r[a];if(!n)continue;let s=n.name,c=n.namespaceURI,l=n.value,u=F(s),d=l,f=s===`value`?d:nr(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,B(O.uponSanitizeAttribute,e,i),f=i.attrValue,We&&(u===`id`||u===`name`)&&tr(f,Ge)!==0&&(At(s,e,n),f=Ge+f,p=!0),un(s,f)?At(s,e,n):i.forceKeepAttr||(i.keepAttr?!Ne&&K(Wr,f)?At(s,e,n):(Pe&&(f=Gt(f)),an(o,u,f)?(f=cn(o,u,c,f),f!==d&&ln(e,s,c,f)&&p&&zn(t.removed)):At(s,e,n)):At(s,e,n))}B(O.afterSanitizeAttributes,e,null),nn(e,n)},fn=function(e,t){rn(e,t),dn(e,t),Xt(e.content)&&pn(e.content)},pn=function(e){let t=null,n=Wt(e);for(B(O.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(B(O.uponSanitizeShadowNode,t,null),fn(t,e),y(t)===Z.element){let e=te(t);Xt(e)&&(mn(e),pn(e))}Pe&&R(e),B(O.afterSanitizeShadowDOM,e,null)},mn=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){pn(e.shadow);continue}let n=e.node,r=y(n)===Z.element,i=g(n);if(i)for(let e=i.length-1;e>=0;--e)t.push({node:i[e],shadow:null});if(r){let e=v?v(n):null;if(typeof e==`string`&&F(e)===`template`){let e=n.content;Xt(e)&&t.push({node:e,shadow:null})}}if(r){let e=te(n);Xt(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}},hn=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if(ot=!e,ot&&(e=`<!-->`),typeof e!=`string`&&!Zt(e)&&(e=pr(e),typeof e!=`string`))throw q(`dirty is not a string, aborting`);if(!t.isSupported)return e;N?(k=Le,A=Re):xt(n),vt=_t,t.removed=[];let c=qe&&typeof e!=`string`&&Zt(e),l=[],u=Je,d=Ye;if(c){Ht(e),l=Nt(e);let t=b(e);if(typeof t==`string`){let n=F(t);if(!k[n]||Oe[n])throw It(e,l),q(`root node is forbidden and cannot be sanitized in-place`)}if(z(e))throw It(e,l),q(`root node is clobbered and cannot be sanitized in-place`);Je=Wn(),Ye=Jn()}else if(Zt(e))i=Ut(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===Z.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),mn(i);else{if(!Be&&!Pe&&!Ie&&e.indexOf(`<`)===-1)return E(e);if(i=Ut(e),!i)return Be?null:He?S:``}i&&ze&&Ot(i.firstChild);let f=c?e:i;try{c&&mn(e);let t=Wt(f);for(;o=t.nextNode();)fn(o,f);c&&Lt(e,l)}catch(t){throw c&&It(e,l),t}finally{Je=u,Ye=d}if(c){if(Ft(e,l))throw q(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return Pe&&Kt(e),e}if(Be){if(Pe&&Kt(i),Ve)for(s=me.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(A.shadowroot||A.shadowrootmode)&&(s=ge.call(r,s,!0)),s}Pe&&R(i);let p=Ie?i.outerHTML:i.innerHTML;return Ie&&k[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&K(Rr,i.ownerDocument.doctype.name)&&(p=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
81
|
+
`+p),E(p)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=vt,i=k,a=A,o=t.removed;vt=null;try{return hn(e,n)}finally{vt=r,r&&(N||xt(r),k=i,A=a,t.removed=o)}},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};xt(e),N=!0,Le=k,Re=A},t.clearConfig=function(){_t=null,N=!1,Le=null,Re=null,x=ce,S=``},t.isValidAttribute=function(e,t,n){_t||xt({});let r=F(e),i=F(t);return typeof n==`string`&&(un(t,n)||!Ne&&K(Wr,n))?!1:an(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&G(O,e)&&Bn(O[e],t)},t.removeHook=function(e,t){if(G(O,e)){if(t!==void 0){let n=Rn(O[e],t);return n===-1?void 0:Hn(O[e],n,1)[0]}return zn(O[e])}},t.removeHooks=function(e){G(O,e)&&(O[e]=[])},t.removeAllHooks=function(){O=Qr()},t}var ni=ti(),ri;function ii(){if(ri!==void 0)return ri;let e=globalThis.trustedTypes;try{ri=e?.createPolicy(`aicore-agent-chat`,{createHTML:e=>e,createScriptURL:()=>``})??null}catch{ri=null}return ri}var ai=[`img`,`image`,`feImage`,`picture`,`video`,`audio`,`source`,`track`,`iframe`,`frame`,`object`,`embed`,`link`,`meta`,`base`,`style`,`form`,`input`,`button`,`textarea`,`select`],oi=/* @__PURE__ */ new Set([`src`,`srcset`,`poster`,`background`,`lowsrc`,`dynsrc`,`data`,`ping`,`action`,`formaction`]),si=/* @__PURE__ */ new Set([`href`,`xlink:href`,`title`,`alt`]),ci={FORBID_TAGS:ai,FORBID_ATTR:[`style`]},li={USE_PROFILES:{html:!0,svg:!0,svgFilters:!0,mathMl:!0},ADD_TAGS:[`foreignObject`,`semantics`,`annotation`],HTML_INTEGRATION_POINTS:{foreignobject:!0},FORBID_TAGS:ai},ui=/url\(\s*(?!['"]?#)/i,di=/(?:image-set|image|cross-fade|element)\(/i,fi=null,pi=null;function mi(){return pi||(pi=ni(window),pi.addHook(`uponSanitizeElement`,(e,t)=>{fi&&t.tagName===`style`&&fi.sheets.push(e.textContent??``)}),pi.addHook(`uponSanitizeAttribute`,(e,t)=>{let n=t.attrName,r=t.attrValue;n===`style`?(fi&&fi.styles.set(e,r),t.keepAttr=!1):oi.has(n)||fi&&!si.has(n)&&!n.startsWith(`aria-`)&&ui.test(r)?t.keepAttr=!1:n!==`href`&&n!==`xlink:href`||e.nodeName.toLowerCase()===`a`||r.startsWith(`#`)||(t.keepAttr=!1)}),pi.addHook(`afterSanitizeAttributes`,e=>{e.nodeName.toLowerCase()===`a`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer nofollow`))}),pi)}function hi(e){let t=ii();return t?{...e,TRUSTED_TYPES_POLICY:t}:e}function gi(e){return mi().sanitize(e,hi(ci))}function _i(e){let t=ii();return t?t.createHTML(e):e}function vi(e){let t=fi={styles:/* @__PURE__ */ new Map,sheets:[]};try{let n=mi().sanitize(e,{...hi(li),RETURN_DOM_FRAGMENT:!0}),r=document.adoptNode(n);for(let[e,n]of t.styles)bi(e,n);return{fragment:r,css:t.sheets.join(`
|
|
82
82
|
`)}}finally{fi=null}}function yi(e){let t=fi={styles:/* @__PURE__ */ new Map,sheets:[]};try{mi().sanitize(e,{...hi(li),IN_PLACE:!0});for(let[e,n]of t.styles)bi(e,n)}finally{fi=null}}function bi(e,t){let n=e.style;if(n){n.cssText=t;for(let e of[...n]){let t=n.getPropertyValue(e);(ui.test(t)||di.test(t))&&n.removeProperty(e)}}}function xi(e){let t;try{t=new CSSStyleSheet,t.replaceSync(e)}catch{return null}return Ci(t),t}var Si=/* @__PURE__ */ new Set([`CSSStyleRule`,`CSSNestedDeclarations`,`CSSMediaRule`,`CSSSupportsRule`,`CSSContainerRule`,`CSSLayerBlockRule`,`CSSKeyframesRule`,`CSSKeyframeRule`]);function Ci(e){for(let t=e.cssRules.length-1;t>=0;t--){let n=e.cssRules[t];if(!Si.has(n.constructor.name))e.deleteRule(t);else{if(`style`in n){let e=n.style;for(let t of[...e]){let n=e.getPropertyValue(t);(ui.test(n)||di.test(n))&&e.removeProperty(t)}}`cssRules`in n&&Ci(n)}}}function wi(e,t){e.adoptedStyleSheets.includes(t)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,t])}function Ti(e,t){e.adoptedStyleSheets.includes(t)&&(e.adoptedStyleSheets=e.adoptedStyleSheets.filter(e=>e!==t))}var Ei={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Di=e=>e.replace(/[&<>"']/g,e=>Ei[e]),Oi=/^(\$+)(?!\$)([\s\S]*?[^$])\1(?!\$)/,ki=/^ {0,3}(\${2,})[^$\n]*(?:\n|$)/,Ai=/^ {0,3}(\${2,})[ \t]*$/,ji=new en({gfm:!0,breaks:!0,async:!1,extensions:[{name:`blockMath`,level:`block`,start:e=>/^ {0,3}\${2,}[^$\n]*$/m.exec(e)?.index,tokenizer(e){let t=ki.exec(e);if(!t)return;let n=t[1].length,r=e.slice(t[0].length).split(`
|
|
83
83
|
`),i=[],a=t[0];for(let[e,t]of r.entries()){let o=e===r.length-1;a+=o?t:`${t}\n`;let s=Ai.exec(t);if(s&&s[1].length>=n)break;i.push(t)}return{type:`blockMath`,raw:a,text:i.join(`
|
|
84
84
|
`)}},renderer:e=>`<div class="math-display">${Di(e.text)}</div>\n`},{name:`inlineMath`,level:`inline`,start:e=>{let t=e.indexOf(`$`);return t<0?void 0:t},tokenizer(e){let t=Oi.exec(e);if(!t)return;let n=t[2];return/^[ \n]/.test(n)&&/[ \n]$/.test(n)&&/[^ \n]/.test(n)&&(n=n.slice(1,-1)),{type:`inlineMath`,raw:t[0],text:n}},renderer:e=>`<span class="math-inline">${Di(e.text)}</span>`}],renderer:{html:({text:e})=>Di(e),image:({href:e,text:t})=>`<a href="${Di(e)}">${Di(t||e)}</a>`,code:({text:e,lang:t,raw:n})=>{let r=/^\S*/.exec(t??``)?.[0]??``;if(r===`math`)return`<div class="math-display">${Di(e)}</div>\n`;let i=n.trimEnd().split(`
|
|
85
|
-
`),a=/^ {0,3}(`{3,}|~{3,})/.test(i[0]??``)&&(i.length<2||!/^ {0,3}(`{3,}|~{3,})[ \t]*$/.test(i.at(-1))),o=`${Di(e.replace(/\n$/,``))}\n`,s=r?` class="language-${Di(r)}"`:``;return`<pre${a?` data-open`:``}><code${s}>${o}</code></pre>\n`}}});function Mi(e){return gi(ji.parse(e))}function Ni(e,t,n){let r=mn(e);e.innerHTML=_i(t?Mi(t):``),vn(e,n,r)}var Pi=`change`,Fi=5,Ii=1,Li=50,Ri=1500,zi=60,Bi={agentId:null,agent:null,conversations:[],conversationsLoading:!1,conversationsFailed:!1,activeId:null,messages:[],turn:null,turnStartedAt:null,loadingHistory:!1,error:null,files:[],uploading:0,requests:[],events:[],tokens:0},Vi=(e,t)=>[t,...e].slice(0,Li),Hi=e=>typeof e?.rating==`number`?e.rating:null;function Ui(e){return e.map(e=>e.role===`user`?{role:`user`,text:e.content,attachments:e.attachments??[]}:{role:`assistant`,text:e.content,sources:e.sources??[],idQuery:e.id_query??null,error:null,rating:Hi(e.feedback),interrupted:!1})}var Wi=class extends EventTarget{client;#e=Bi;#t=0;#n=null;#r=0;#i=null;constructor(e){super(),this.client=new C({...e,onRequest:e=>this.#a(t=>({requests:Vi(t.requests,e)})),onIdentityChange:()=>this.#d()})}get state(){return this.#e}get busy(){return this.#n!==null}#a(e){this.#e={...this.#e,...e(this.#e)},this.dispatchEvent(new Event(Pi))}#o(e){this.#a(()=>e)}async#s(e,t){try{await t()}catch(t){!a(t)&&e()&&this.#o({error:i(t)})}}#c(e=this.#t){return()=>e===this.#t}#l(e){let t=this.#r;return()=>this.#e.agentId===e&&t===this.#r}#u(){this.#n?.abort(),this.#n=null,this.#i=null,this.#t++,this.#o({activeId:null,messages:[],turn:null,turnStartedAt:null,loadingHistory:!1,files:[],uploading:0,error:null})}#d(){this.#r++,this.#u(),this.#o({conversations:[],conversationsFailed:!1,conversationsLoading:!1,requests:[],events:[],tokens:0}),this.refreshConversations()}async setAgent(e){if(e===this.#e.agentId||(this.#u(),this.#o({agentId:e,agent:null,conversations:[],conversationsFailed:!1}),!e))return;let t=this.#l(e);await Promise.all([this.#s(t,async()=>{let n=await this.client.getAgent(e);t()&&this.#o({agent:n})}),this.refreshConversations()])}async refreshConversations(){let{agentId:e}=this.#e;if(!e)return;let t=this.#l(e);this.#o({conversationsLoading:!0});let n=!0;await this.#s(t,async()=>{let r=await this.client.listConversations(e);n=!1,t()&&this.#o({conversations:[...r.items].sort((e,t)=>t.last_message_at-e.last_message_at)})}),t()&&this.#o({conversationsLoading:!1,conversationsFailed:n})}newConversation(){this.#u()}async open(e){if(e===this.#e.activeId)return;this.#u();let t=this.#t;this.#o({activeId:e,loadingHistory:!0}),await this.#s(this.#c(t),async()=>{let n=await this.client.history(e);t===this.#t&&this.#o({messages:Ui(n)})}),t===this.#t&&this.#o({loadingHistory:!1})}async rename(e,t){let{agentId:n,conversations:r}=this.#e,a=t.trim(),o=r.find(t=>t.id===e);if(!n||!a||o?.title===a)return;let s=this.#l(n),c=t=>this.#a(n=>({conversations:n.conversations.map(n=>n.id===e?{...n,...t(n)}:n)}));c(()=>({title:a}));try{let t=await this.client.renameConversation(e,a);s()&&c(()=>t)}catch(e){if(!s())return;o&&c(e=>e.title===a?{title:o.title}:null),this.#o({error:i(e)})}}async remove(e){let{agentId:t}=this.#e;t&&await this.#s(this.#l(t),async()=>{await this.client.deleteConversation(e),e===this.#e.activeId&&this.#u(),this.#a(t=>({conversations:t.conversations.filter(t=>t.id!==e)}))})}#f(e){if(this.#e.activeId)return Promise.resolve(this.#e.activeId);let t=this.#t;if(this.#i?.epoch===t)return this.#i.promise;let n=this.client.openConversation(e).then(e=>{if(t!==this.#t)throw new DOMException(`moved on`,`AbortError`);return this.#i=null,this.#o({activeId:e.id_conv}),this.refreshConversations(),e.id_conv});return this.#i={epoch:t,promise:n},n.catch(()=>{this.#i?.promise===n&&(this.#i=null)}),n}async#p(e,t,n){let r=!1;try{for(let i=0;i<zi;i++){if(await new Promise(e=>setTimeout(e,Ri)),e!==this.#t)return;let i=(await this.client.listFiles(t)).find(e=>e.id_file===n);if(e!==this.#t||!i)return;if(this.#a(e=>({files:e.files.map(e=>e.id_file===n?i:e)})),i.status!==`processing`){r=!0;return}}}finally{!r&&e===this.#t&&this.#a(e=>({files:e.files.map(e=>e.id_file===n&&e.status===`processing`?{...e,status:`error`,error:`Processing did not finish`}:e)}))}}async attach(e){let{agentId:t}=this.#e;if(!t||this.busy)return;this.#o({error:null});let n=this.#t,r=this.#c(n);this.#a(e=>({uploading:e.uploading+1}));try{await this.#s(r,async()=>{let i=await this.#f(t);for(let t of e){let e=await this.client.uploadFile(i,t);if(n!==this.#t)return;this.#a(t=>({files:[...t.files,e]})),e.status===`processing`&&this.#s(r,()=>this.#p(n,i,e.id_file))}})}finally{n===this.#t&&this.#a(e=>({uploading:Math.max(0,e.uploading-1)}))}}async detach(e){let{activeId:t}=this.#e;t&&await this.#s(this.#c(),async()=>{await this.client.deleteFile(t,e),this.#a(t=>({files:t.files.filter(t=>t.id_file!==e)}))})}async send(e,t={}){let{context:n}=t,{agentId:r,activeId:a,files:o,uploading:s}=this.#e,c=e.trim();if(!r||this.busy||!c||s>0||o.some(e=>e.status===`processing`))return;let l=o.filter(e=>e.status===`ready`),u=this.#t,d=new AbortController;this.#n=d,this.#a(e=>({error:null,files:[],turn:g,turnStartedAt:Date.now(),events:[],tokens:0,messages:[...e.messages,{role:`user`,text:c,attachments:l.map(({id_file:e,name:t,mime:n,size:r})=>({id_file:e,name:t,mime:n,size:r}))}]}));let f=()=>u===this.#t&&!d.signal.aborted;try{let e=await this.client.ask({idAgent:r,idConv:a,request:{text:c,...l.length>0?{attachments:l.map(e=>({id_file:e.id_file}))}:{},...n?{context:n}:{}},signal:d.signal,onConversation:e=>{u===this.#t&&this.#o({activeId:e})},onUpdate:(e,t)=>{f()&&this.#a(n=>t.kind===`token`?{turn:e,tokens:n.tokens+1}:{turn:e,events:Vi(n.events,{at:Date.now(),kind:t.kind,id:t.id,data:t.data})})}});if(u!==this.#t)return;this.#a(t=>({turn:null,messages:[...t.messages,{role:`assistant`,text:ne(e.turn),sources:e.turn.sources,idQuery:e.idQuery,error:e.turn.error,rating:null,interrupted:!e.turn.finished}]})),(a===null||e.turn.title)&&await this.refreshConversations()}catch(e){f()?this.#o({error:i(e)}):u===this.#t&&this.#a(e=>({messages:[...e.messages,{role:`assistant`,text:``,sources:[],idQuery:null,error:null,rating:null,interrupted:!0}]}))}finally{this.#n===d&&(this.#n=null),u===this.#t&&this.#o({turn:null})}}stop(){this.#n?.abort()}async rate(e,t){let{activeId:n}=this.#e;if(!n)return;let r=t=>this.#a(n=>({messages:n.messages.map(n=>n.role===`assistant`&&n.idQuery===e?{...n,rating:t}:n)})),a=this.#e.messages.find(t=>t.role===`assistant`&&t.idQuery===e);r(t);try{await this.client.sendFeedback(n,e,t)}catch(e){r(a?.role===`assistant`?a.rating:null),this.#o({error:i(e)})}}dismissError(){this.#o({error:null})}dispose(){this.#n?.abort(),this.#t++}},Gi={locale:`it-IT`,conversations:`Conversazioni`,newConversation:`Nuova conversazione`,noConversations:`Ancora nessuna conversazione.`,conversationsFailed:`Impossibile leggere le conversazioni.`,loading:`Caricamento…`,untitled:`Senza titolo`,disabled:`disabilitata`,renameConversation:e=>`Rinomina «${e}»`,newTitle:`Nuovo titolo`,save:`Salva`,cancel:`Annulla`,deleteConversation:e=>`Elimina «${e}»`,confirmDelete:e=>`Eliminare la conversazione «${e}»?`,confirmDeleteShort:`Elimina?`,ask:e=>`Chiedi a ${e}`,askGeneric:`Come posso esserti utile?`,noAgent:`Nessun agente indicato.`,notConnected:`Chat non configurata.`,placeholder:`Scrivi un messaggio`,send:`Invia`,stop:`Interrompi`,attach:`Allega documenti`,removeFile:e=>`Rimuovi ${e}`,processing:`in elaborazione`,fileError:`errore`,thinking:`Sto pensando…`,loadingHistory:`Carico la conversazione…`,copy:`Copia`,copied:`Copiato`,rateUp:`Risposta utile`,rateDown:`Risposta non utile`,sources:e=>e===1?`1 fonte`:`${e} fonti`,page:e=>`p. ${e}`,part:e=>`parte ${e}`,untitledSource:`Fonte senza titolo`,interrupted:`Risposta interrotta.`,turnFailed:`L'agente non è riuscito a rispondere.`,trace:e=>`Traccia ${e}`,disclaimer:`Le risposte sono generate da un'intelligenza artificiale e possono contenere errori: verifica sempre le informazioni.`,dismiss:`Chiudi`,you:`Tu`,agent:`Agente`,errors:{auth_required:`Accesso scaduto o non valido: rientra nell'applicazione.`,tenant_refused:`Il tuo account non può usare l'agente in questo spazio di lavoro.`,forbidden:`Non puoi usare questo agente.`,not_found:`Agente o conversazione non trovati.`,busy:`L'agente sta ancora rispondendo, oppure non è pubblicato. Riprova tra poco.`,locked:`Questa conversazione è disabilitata.`,rate_limited:`Troppe richieste.`,network:`Servizio non raggiungibile.`,http:`Errore del servizio.`},retryIn:e=>`Riprova tra ${e} s.`,developer:`Sviluppatore`,requests:`Richieste`,events:e=>`Eventi dell'ultimo turno · ${e} token`,lastError:`Ultimo errore`,renewed:`token rinnovato`,publishedVersion:`Versione pubblicata`,notPublished:`non pubblicato`,conversation:`Conversazione`,context:`Contesto del turno`,none:`—`,a2uiPreparing:`Preparazione del modulo…`,a2uiRefused:e=>`Interfaccia non disegnata: ${e}`,a2uiInvalid:`il blocco non rispetta il catalogo`,a2uiSent:`Inviato`,a2uiDetails:`Dettagli`,a2uiTabs:`Schede`,close:`Chiudi`,a2uiAction:e=>`Azione ${e}`,yes:`sì`,no:`no`},Ki={locale:`en-GB`,conversations:`Conversations`,newConversation:`New conversation`,noConversations:`No conversations yet.`,conversationsFailed:`Could not read the conversations.`,loading:`Loading…`,untitled:`Untitled`,disabled:`disabled`,renameConversation:e=>`Rename “${e}”`,newTitle:`New title`,save:`Save`,cancel:`Cancel`,deleteConversation:e=>`Delete “${e}”`,confirmDelete:e=>`Delete the conversation “${e}”?`,confirmDeleteShort:`Delete?`,ask:e=>`Ask ${e}`,askGeneric:`How can I help?`,noAgent:`No agent set.`,notConnected:`Chat not configured.`,placeholder:`Write a message`,send:`Send`,stop:`Stop`,attach:`Attach documents`,removeFile:e=>`Remove ${e}`,processing:`processing`,fileError:`error`,thinking:`Thinking…`,loadingHistory:`Loading the conversation…`,copy:`Copy`,copied:`Copied`,rateUp:`Helpful answer`,rateDown:`Unhelpful answer`,sources:e=>e===1?`1 source`:`${e} sources`,page:e=>`p. ${e}`,part:e=>`part ${e}`,untitledSource:`Untitled source`,interrupted:`Answer stopped.`,turnFailed:`The agent could not answer.`,trace:e=>`Trace ${e}`,disclaimer:`Answers are generated by AI and may contain mistakes: always check the information.`,dismiss:`Dismiss`,you:`You`,agent:`Agent`,errors:{auth_required:`Your sign-in expired or is invalid: sign in again.`,tenant_refused:`Your account cannot use the agent in this workspace.`,forbidden:`You cannot use this agent.`,not_found:`Agent or conversation not found.`,busy:`The agent is still answering, or it is not published. Try again shortly.`,locked:`This conversation is disabled.`,rate_limited:`Too many requests.`,network:`Service unreachable.`,http:`Service error.`},retryIn:e=>`Try again in ${e} s.`,developer:`Developer`,requests:`Requests`,events:e=>`Events of the last turn · ${e} tokens`,lastError:`Last error`,renewed:`token renewed`,publishedVersion:`Published version`,notPublished:`not published`,conversation:`Conversation`,context:`Turn context`,none:`—`,a2uiPreparing:`Preparing the form…`,a2uiRefused:e=>`Interface not drawn: ${e}`,a2uiInvalid:`the block does not follow the catalog`,a2uiSent:`Sent`,a2uiDetails:`Details`,a2uiTabs:`Tabs`,close:`Close`,a2uiAction:e=>`Action ${e}`,yes:`yes`,no:`no`};function qi(e){let t=e?.trim().toLowerCase()??``;return t===``||t.startsWith(`it`)?`it`:`en`}function Ji(e){return qi(e)===`it`?Gi:Ki}function Yi(e,t){let n=Ji(e);return t?{...n,...t,errors:{...n.errors,...t.errors}}:n}var Xi={add:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`,delete:`M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z`,send:`M2.01 21 23 12 2.01 3 2 10l15 2-15 2z`,stop:`M6 6h12v12H6z`,attach:`M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z`,copy:`M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z`,check:`M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`,thumbUp:`M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.58 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h4v12H1z`,thumbDown:`M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h4v12h-4z`,close:`M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`,menu:`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`,edit:`M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z`},Zi=`http://www.w3.org/2000/svg`;function Qi(e){let t=document.createElementNS(Zi,`svg`);t.setAttribute(`class`,`icon`),t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(Zi,`path`);return n.setAttribute(`d`,Xi[e]),n.setAttribute(`fill`,`currentColor`),t.append(n),t}var $i=`v0.9.1`,ea=`a2ui-action`,ta=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`];function na(t){if(!e(t)||typeof t.version!=`string`)return!1;let n=ta.filter(e=>e in t);if(n.length!==1)return!1;let r=t[n[0]];return e(r)&&typeof r.surfaceId==`string`&&r.surfaceId!==``}function ra(e){let t;try{t=JSON.parse(e)}catch{return null}return!Array.isArray(t)||t.length===0||!t.every(na)?null:t}function ia(t){let n=[];for(let r of t){let t=r.createSurface;e(t)&&typeof t.surfaceId==`string`&&!n.includes(t.surfaceId)&&n.push(t.surfaceId)}return n}function aa(e){let t={name:e.name,surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:e.timestamp||(/* @__PURE__ */ new Date()).toISOString(),context:e.context};return`\`\`\`${ea}\n${JSON.stringify([{version:$i,action:t}])}\n\`\`\``}var oa=RegExp(`^\`\`\`${ea}[ \\t]*\\n([\\s\\S]*?)\\n\`\`\`$`);function sa(t){let n=oa.exec(t.replace(/\r\n/g,`
|
|
86
|
-
`).trim());if(!n)return null;let r;try{r=JSON.parse(n[1])}catch{return null}let i=Array.isArray(r)?r[0]:r;if(!e(i)||!e(i.action))return null;let a=i.action;return typeof a.name!=`string`||a.name===``||typeof a.surfaceId!=`string`||a.surfaceId===``||!e(a.context)?null:{name:a.name,surfaceId:a.surfaceId,sourceComponentId:typeof a.sourceComponentId==`string`?a.sourceComponentId:``,timestamp:typeof a.timestamp==`string`?a.timestamp:``,context:a.context}}var
|
|
85
|
+
`),a=/^ {0,3}(`{3,}|~{3,})/.test(i[0]??``)&&(i.length<2||!/^ {0,3}(`{3,}|~{3,})[ \t]*$/.test(i.at(-1))),o=`${Di(e.replace(/\n$/,``))}\n`,s=r?` class="language-${Di(r)}"`:``;return`<pre${a?` data-open`:``}><code${s}>${o}</code></pre>\n`}}});function Mi(e){return gi(ji.parse(e))}function Ni(e,t,n){let r=mn(e);e.innerHTML=_i(t?Mi(t):``),vn(e,n,r)}var Pi=`change`,Fi=5,Ii=1,Li=50,Ri=2e4;function zi(e){let t=e?/^(\d+)-\d+$/.exec(e):null;return t?Number(t[1]):null}var Bi=()=>({starts:[],events:[],offset:null}),Vi=1500,Hi=60,Ui={agentId:null,agent:null,conversations:[],conversationsLoading:!1,conversationsFailed:!1,activeId:null,messages:[],turn:null,turnStartedAt:null,loadingHistory:!1,error:null,files:[],uploading:0,requests:[],events:[],tokens:0,log:Bi()},Wi=(e,t)=>[t,...e].slice(0,Li),Gi=e=>typeof e?.rating==`number`?e.rating:null;function Ki(e){return e.map(e=>e.role===`user`?{role:`user`,text:e.content,attachments:e.attachments??[]}:{role:`assistant`,text:e.content,sources:e.sources??[],idQuery:e.id_query??null,error:null,rating:Gi(e.feedback),interrupted:!1})}var qi=class extends EventTarget{client;#e=Ui;#t=0;#n=0;#r=null;#i=0;#a=null;constructor(e){super(),this.client=new S({...e,onRequest:e=>this.#o(t=>({requests:Wi(t.requests,e)})),onIdentityChange:()=>this.#f()})}get state(){return this.#e}get busy(){return this.#r!==null}#o(e){this.#e={...this.#e,...e(this.#e)},this.dispatchEvent(new Event(Pi))}#s(e){this.#o(()=>e)}async#c(e,t){try{await t()}catch(t){!a(t)&&e()&&this.#s({error:i(t)})}}#l(e=this.#t){return()=>e===this.#t}#u(e){let t=this.#i;return()=>this.#e.agentId===e&&t===this.#i}#d(){this.#r?.abort(),this.#r=null,this.#a=null,this.#t++,this.#s({activeId:null,messages:[],turn:null,turnStartedAt:null,loadingHistory:!1,files:[],uploading:0,error:null,log:Bi()})}#f(){this.#i++,this.#d(),this.#s({conversations:[],conversationsFailed:!1,conversationsLoading:!1,requests:[],events:[],tokens:0}),this.refreshConversations()}async setAgent(e){if(e===this.#e.agentId||(this.#d(),this.#s({agentId:e,agent:null,conversations:[],conversationsFailed:!1}),!e))return;let t=this.#u(e);await Promise.all([this.#c(t,async()=>{let n=await this.client.getAgent(e);t()&&this.#s({agent:n})}),this.refreshConversations()])}async refreshConversations(){let{agentId:e}=this.#e;if(!e)return;let t=this.#u(e);this.#s({conversationsLoading:!0});let n=!0;await this.#c(t,async()=>{let r=await this.client.listConversations(e);n=!1,t()&&this.#s({conversations:[...r.items].sort((e,t)=>t.last_message_at-e.last_message_at)})}),t()&&this.#s({conversationsLoading:!1,conversationsFailed:n})}#p(e){let{log:t}=this.#e,n=zi(e.id);if(e.kind===`nop`&&n===null)return t;let r=Date.now(),i=n??r,a=n===null?t.offset:Math.min(t.offset??1/0,r-n),o=this.#n;return t.starts.at(-1)?.turn!==o&&t.starts.push({turn:o,at:i}),e.kind===`nop`||(t.events.push({turn:o,at:i,kind:e.kind,data:e.data}),t.events.length>Ri&&t.events.splice(0,t.events.length-Ri)),{starts:t.starts,events:t.events,offset:a}}newConversation(){this.#d()}async open(e){if(e===this.#e.activeId)return;this.#d();let t=this.#t;this.#s({activeId:e,loadingHistory:!0}),await this.#c(this.#l(t),async()=>{let n=await this.client.history(e);t===this.#t&&this.#s({messages:Ki(n)})}),t===this.#t&&this.#s({loadingHistory:!1})}async rename(e,t){let{agentId:n,conversations:r}=this.#e,a=t.trim(),o=r.find(t=>t.id===e);if(!n||!a||o?.title===a)return;let s=this.#u(n),c=t=>this.#o(n=>({conversations:n.conversations.map(n=>n.id===e?{...n,...t(n)}:n)}));c(()=>({title:a}));try{let t=await this.client.renameConversation(e,a);s()&&c(()=>t)}catch(e){if(!s())return;o&&c(e=>e.title===a?{title:o.title}:null),this.#s({error:i(e)})}}async remove(e){let{agentId:t}=this.#e;t&&await this.#c(this.#u(t),async()=>{await this.client.deleteConversation(e),e===this.#e.activeId&&this.#d(),this.#o(t=>({conversations:t.conversations.filter(t=>t.id!==e)}))})}#m(e){if(this.#e.activeId)return Promise.resolve(this.#e.activeId);let t=this.#t;if(this.#a?.epoch===t)return this.#a.promise;let n=this.client.openConversation(e).then(e=>{if(t!==this.#t)throw new DOMException(`moved on`,`AbortError`);return this.#a=null,this.#s({activeId:e.id_conv}),this.refreshConversations(),e.id_conv});return this.#a={epoch:t,promise:n},n.catch(()=>{this.#a?.promise===n&&(this.#a=null)}),n}async#h(e,t,n){let r=!1;try{for(let i=0;i<Hi;i++){if(await new Promise(e=>setTimeout(e,Vi)),e!==this.#t)return;let i=(await this.client.listFiles(t)).find(e=>e.id_file===n);if(e!==this.#t||!i)return;if(this.#o(e=>({files:e.files.map(e=>e.id_file===n?i:e)})),i.status!==`processing`){r=!0;return}}}finally{!r&&e===this.#t&&this.#o(e=>({files:e.files.map(e=>e.id_file===n&&e.status===`processing`?{...e,status:`error`,error:`Processing did not finish`}:e)}))}}async attach(e){let{agentId:t}=this.#e;if(!t||this.busy)return;this.#s({error:null});let n=this.#t,r=this.#l(n);this.#o(e=>({uploading:e.uploading+1}));try{await this.#c(r,async()=>{let i=await this.#m(t);for(let t of e){let e=await this.client.uploadFile(i,t);if(n!==this.#t)return;this.#o(t=>({files:[...t.files,e]})),e.status===`processing`&&this.#c(r,()=>this.#h(n,i,e.id_file))}})}finally{n===this.#t&&this.#o(e=>({uploading:Math.max(0,e.uploading-1)}))}}async detach(e){let{activeId:t}=this.#e;t&&await this.#c(this.#l(),async()=>{await this.client.deleteFile(t,e),this.#o(t=>({files:t.files.filter(t=>t.id_file!==e)}))})}async send(e,t={}){let{context:n}=t,{agentId:r,activeId:a,files:o,uploading:s}=this.#e,c=e.trim();if(!r||this.busy||!c||s>0||o.some(e=>e.status===`processing`))return;let l=o.filter(e=>e.status===`ready`),u=this.#t;this.#n=(this.#e.log.starts.at(-1)?.turn??0)+1;let d=new AbortController;this.#r=d,this.#o(e=>({error:null,files:[],turn:g,turnStartedAt:Date.now(),events:[],tokens:0,messages:[...e.messages,{role:`user`,text:c,attachments:l.map(({id_file:e,name:t,mime:n,size:r})=>({id_file:e,name:t,mime:n,size:r}))}]}));let f=()=>u===this.#t&&!d.signal.aborted;try{let e=await this.client.ask({idAgent:r,idConv:a,request:{text:c,...l.length>0?{attachments:l.map(e=>({id_file:e.id_file}))}:{},...n?{context:n}:{}},signal:d.signal,onConversation:e=>{u===this.#t&&this.#s({activeId:e})},onUpdate:(e,t)=>{if(!f())return;let n=this.#p(t);this.#o(r=>t.kind===`token`?{turn:e,tokens:r.tokens+1,log:n}:{turn:e,log:n,events:Wi(r.events,{at:Date.now(),kind:t.kind,id:t.id,data:t.data})})}});if(u!==this.#t)return;this.#o(t=>({turn:null,messages:[...t.messages,{role:`assistant`,text:ne(e.turn),sources:e.turn.sources,idQuery:e.idQuery,error:e.turn.error,rating:null,interrupted:!e.turn.finished}]})),(a===null||e.turn.title)&&await this.refreshConversations()}catch(e){f()?this.#s({error:i(e)}):u===this.#t&&this.#o(e=>({messages:[...e.messages,{role:`assistant`,text:``,sources:[],idQuery:null,error:null,rating:null,interrupted:!0}]}))}finally{this.#r===d&&(this.#r=null),u===this.#t&&this.#s({turn:null})}}stop(){this.#r?.abort()}async rate(e,t){let{activeId:n}=this.#e;if(!n)return;let r=t=>this.#o(n=>({messages:n.messages.map(n=>n.role===`assistant`&&n.idQuery===e?{...n,rating:t}:n)})),a=this.#e.messages.find(t=>t.role===`assistant`&&t.idQuery===e);r(t);try{await this.client.sendFeedback(n,e,t)}catch(e){r(a?.role===`assistant`?a.rating:null),this.#s({error:i(e)})}}dismissError(){this.#s({error:null})}dispose(){this.#r?.abort(),this.#t++}},Ji={locale:`it-IT`,conversations:`Conversazioni`,newConversation:`Nuova conversazione`,noConversations:`Ancora nessuna conversazione.`,conversationsFailed:`Impossibile leggere le conversazioni.`,loading:`Caricamento…`,untitled:`Senza titolo`,disabled:`disabilitata`,renameConversation:e=>`Rinomina «${e}»`,newTitle:`Nuovo titolo`,save:`Salva`,cancel:`Annulla`,deleteConversation:e=>`Elimina «${e}»`,confirmDelete:e=>`Eliminare la conversazione «${e}»?`,confirmDeleteShort:`Elimina?`,noAgent:`Nessun agente indicato.`,notConnected:`Chat non configurata.`,placeholder:`Scrivi un messaggio`,send:`Invia`,stop:`Interrompi`,attach:`Allega documenti`,removeFile:e=>`Rimuovi ${e}`,processing:`in elaborazione`,fileError:`errore`,thinking:`Sto pensando…`,loadingHistory:`Carico la conversazione…`,copy:`Copia`,copied:`Copiato`,rateUp:`Risposta utile`,rateDown:`Risposta non utile`,sources:e=>e===1?`1 fonte`:`${e} fonti`,page:e=>`p. ${e}`,part:e=>`parte ${e}`,untitledSource:`Fonte senza titolo`,interrupted:`Risposta interrotta.`,turnFailed:`L'agente non è riuscito a rispondere.`,trace:e=>`Traccia ${e}`,dismiss:`Chiudi`,you:`Tu`,agent:`Agente`,errors:{auth_required:`Accesso scaduto o non valido: rientra nell'applicazione.`,tenant_refused:`Il tuo account non può usare l'agente in questo spazio di lavoro.`,forbidden:`Non puoi usare questo agente.`,not_found:`Agente o conversazione non trovati.`,busy:`L'agente sta ancora rispondendo, oppure non è pubblicato. Riprova tra poco.`,locked:`Questa conversazione è disabilitata.`,rate_limited:`Troppe richieste.`,network:`Servizio non raggiungibile.`,http:`Errore del servizio.`},retryIn:e=>`Riprova tra ${e} s.`,developer:`Sviluppatore`,requests:`Richieste`,lastError:`Ultimo errore`,renewed:`token rinnovato`,publishedVersion:`Versione pubblicata`,notPublished:`non pubblicato`,conversation:`Conversazione`,context:`Contesto del turno`,none:`—`,a2uiPreparing:`Preparazione del modulo…`,a2uiRefused:e=>`Interfaccia non disegnata: ${e}`,a2uiInvalid:`il blocco non rispetta il catalogo`,a2uiSent:`Inviato`,a2uiDetails:`Dettagli`,a2uiTabs:`Schede`,close:`Chiudi`,a2uiAction:e=>`Azione ${e}`,yes:`sì`,no:`no`,backstage:`Dietro le quinte`,backstageToggle:`Mostra o nascondi Dietro le quinte`,backstageLog:`Registro`,backstageMap:`Mappa`,backstageViews:`Vista di Dietro le quinte`,noEvents:`Nessun evento: compaiono dopo il primo messaggio.`,turnHeader:(e,t)=>`Turno ${e} · ${t}`,modelWait:`in attesa del modello`,turnDone:e=>`Turno concluso in ${e}`,turnStopped:e=>`Turno interrotto dopo ${e}`,turnCanceled:`Turno interrotto`,tools:`Strumenti`,modelTime:`Attesa del modello`,modelCalls:`Chiamate al modello`,answerTime:`Risposta`,inputTokens:`Token in ingresso`,outputTokens:`Token in uscita`,fromCache:e=>`${e} dalla cache`,mainAgent:`Agente principale`,limitReached:e=>`Limite raggiunto: ${e}`,limitNames:{iterazioni:`iterazioni`,timeout:`tempo`,deleghe:`deleghe`},limitHint:`Puoi alzarlo in Configurazione › Limiti per risposta.`,calls:`chiama`,answers:`risponde a`,expand:`Espandi`,collapse:`Comprimi`,memberKinds:{orchestrator:`Agente principale`,subagent:`Sottoagente`,platform_agent:`Agente pubblicato`,external_a2a:`Agente esterno A2A`,extra:`Non nella versione mostrata`},noTurn:`Nessun turno: la mappa si accende al primo messaggio.`,turnRunning:(e,t)=>`Turno ${e} · ${t}`,turnEnded:e=>`Turno ${e} · concluso`,turnInterrupted:e=>`Turno ${e} · interrotto`,teamAtWork:(e,t)=>`${e} ${e===1?`membro`:`membri`} su ${t} al lavoro`,delegations:e=>`${e} ${e===1?`delega`:`deleghe`}`,toolCalls:e=>`${e} ${e===1?`chiamata`:`chiamate`} a strumenti`,statusFailed:`Turno interrotto`,statusWaiting:e=>`Attende ${e}`,statusTool:e=>`Usa ${e}`,statusExternal:`Al lavoro, all’esterno`,statusWriting:`Scrive la risposta`,statusThinking:`Ragiona`,statusDoneOnce:e=>`Fatto in ${e}`,statusDoneTimes:(e,t)=>`Fatto ${e} volte · ${t}`,statusUnused:`Non usato in questo turno`,and:`e`},Yi={locale:`en-GB`,conversations:`Conversations`,newConversation:`New conversation`,noConversations:`No conversations yet.`,conversationsFailed:`Could not read the conversations.`,loading:`Loading…`,untitled:`Untitled`,disabled:`disabled`,renameConversation:e=>`Rename “${e}”`,newTitle:`New title`,save:`Save`,cancel:`Cancel`,deleteConversation:e=>`Delete “${e}”`,confirmDelete:e=>`Delete the conversation “${e}”?`,confirmDeleteShort:`Delete?`,noAgent:`No agent set.`,notConnected:`Chat not configured.`,placeholder:`Write a message`,send:`Send`,stop:`Stop`,attach:`Attach documents`,removeFile:e=>`Remove ${e}`,processing:`processing`,fileError:`error`,thinking:`Thinking…`,loadingHistory:`Loading the conversation…`,copy:`Copy`,copied:`Copied`,rateUp:`Helpful answer`,rateDown:`Unhelpful answer`,sources:e=>e===1?`1 source`:`${e} sources`,page:e=>`p. ${e}`,part:e=>`part ${e}`,untitledSource:`Untitled source`,interrupted:`Answer stopped.`,turnFailed:`The agent could not answer.`,trace:e=>`Trace ${e}`,dismiss:`Dismiss`,you:`You`,agent:`Agent`,errors:{auth_required:`Your sign-in expired or is invalid: sign in again.`,tenant_refused:`Your account cannot use the agent in this workspace.`,forbidden:`You cannot use this agent.`,not_found:`Agent or conversation not found.`,busy:`The agent is still answering, or it is not published. Try again shortly.`,locked:`This conversation is disabled.`,rate_limited:`Too many requests.`,network:`Service unreachable.`,http:`Service error.`},retryIn:e=>`Try again in ${e} s.`,developer:`Developer`,requests:`Requests`,lastError:`Last error`,renewed:`token renewed`,publishedVersion:`Published version`,notPublished:`not published`,conversation:`Conversation`,context:`Turn context`,none:`—`,a2uiPreparing:`Preparing the form…`,a2uiRefused:e=>`Interface not drawn: ${e}`,a2uiInvalid:`the block does not follow the catalog`,a2uiSent:`Sent`,a2uiDetails:`Details`,a2uiTabs:`Tabs`,close:`Close`,a2uiAction:e=>`Action ${e}`,yes:`yes`,no:`no`,backstage:`Behind the scenes`,backstageToggle:`Show or hide Behind the scenes`,backstageLog:`Log`,backstageMap:`Map`,backstageViews:`Behind the scenes view`,noEvents:`No events: they appear after the first message.`,turnHeader:(e,t)=>`Turn ${e} · ${t}`,modelWait:`waiting for the model`,turnDone:e=>`Turn ended in ${e}`,turnStopped:e=>`Turn stopped after ${e}`,turnCanceled:`Turn stopped`,tools:`Tools`,modelTime:`Waiting for the model`,modelCalls:`Model calls`,answerTime:`Answer`,inputTokens:`Input tokens`,outputTokens:`Output tokens`,fromCache:e=>`${e} from cache`,mainAgent:`Main agent`,limitReached:e=>`Limit reached: ${e}`,limitNames:{iterazioni:`iterations`,timeout:`time`,deleghe:`delegations`},limitHint:`You can raise it in Configuration › Limits per answer.`,calls:`calls`,answers:`answers`,expand:`Expand`,collapse:`Collapse`,memberKinds:{orchestrator:`Main agent`,subagent:`Subagent`,platform_agent:`Published agent`,external_a2a:`External A2A agent`,extra:`Not in the version shown`},noTurn:`No turn: the map lights up at the first message.`,turnRunning:(e,t)=>`Turn ${e} · ${t}`,turnEnded:e=>`Turn ${e} · ended`,turnInterrupted:e=>`Turn ${e} · stopped`,teamAtWork:(e,t)=>`${e} of ${t} ${t===1?`member`:`members`} at work`,delegations:e=>`${e} ${e===1?`delegation`:`delegations`}`,toolCalls:e=>`${e} tool ${e===1?`call`:`calls`}`,statusFailed:`Turn stopped`,statusWaiting:e=>`Waiting for ${e}`,statusTool:e=>`Using ${e}`,statusExternal:`At work, outside`,statusWriting:`Writing the answer`,statusThinking:`Thinking`,statusDoneOnce:e=>`Done in ${e}`,statusDoneTimes:(e,t)=>`Done ${e} times · ${t}`,statusUnused:`Not used in this turn`,and:`and`};function Xi(e){let t=e?.trim().toLowerCase()??``;return t===``||t.startsWith(`it`)?`it`:`en`}function Zi(e){return Xi(e)===`it`?Ji:Yi}function Qi(e,t){let n=Zi(e);return t?{...n,...t,errors:{...n.errors,...t.errors}}:n}var $i={add:`M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z`,arrowUp:`M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z`,sparkles:`M19 9l1.25-2.75L23 5l-2.75-1.25L19 1l-1.25 2.75L15 5l2.75 1.25L19 9zm-7.5.5L9 4 6.5 9.5 1 12l5.5 2.5L9 20l2.5-5.5L17 12l-5.5-2.5zM19 15l-1.25 2.75L15 19l2.75 1.25L19 23l1.25-2.75L23 19l-2.75-1.25L19 15z`,delete:`M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z`,send:`M2.01 21 23 12 2.01 3 2 10l15 2-15 2z`,stop:`M6 6h12v12H6z`,attach:`M16.5 6v11.5c0 2.21-1.79 4-4 4s-4-1.79-4-4V5c0-1.38 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5v10.5c0 .55-.45 1-1 1s-1-.45-1-1V6H10v9.5c0 1.38 1.12 2.5 2.5 2.5s2.5-1.12 2.5-2.5V5c0-2.21-1.79-4-4-4S7 2.79 7 5v12.5c0 3.04 2.46 5.5 5.5 5.5s5.5-2.46 5.5-5.5V6h-1.5z`,copy:`M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z`,check:`M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z`,thumbUp:`M9 21h9c.83 0 1.54-.5 1.84-1.22l3.02-7.05c.09-.23.14-.47.14-.73v-2c0-1.1-.9-2-2-2h-6.31l.95-4.57.03-.32c0-.41-.17-.79-.44-1.06L14.17 1 7.58 7.59C7.22 7.95 7 8.45 7 9v10c0 1.1.9 2 2 2zM9 9l4.34-4.34L12 10h9v2l-3 7H9V9zM1 9h4v12H1z`,thumbDown:`M15 3H6c-.83 0-1.54.5-1.84 1.22l-3.02 7.05c-.09.23-.14.47-.14.73v2c0 1.1.9 2 2 2h6.31l-.95 4.57-.03.32c0 .41.17.79.44 1.06L9.83 23l6.59-6.59c.36-.36.58-.86.58-1.41V5c0-1.1-.9-2-2-2zm0 12-4.34 4.34L12 14H3v-2l3-7h9v10zm4-12h4v12h-4z`,close:`M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z`,menu:`M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z`,panel:`M16 20H2V4h14v16zm2-12h4V4h-4v4zm0 12h4v-4h-4v4zm0-6h4v-4h-4v4z`,edit:`M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z`},ea=`http://www.w3.org/2000/svg`;function ta(e){let t=document.createElementNS(ea,`svg`);t.setAttribute(`class`,`icon`),t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(ea,`path`);return n.setAttribute(`d`,$i[e]),n.setAttribute(`fill`,`currentColor`),t.append(n),t}var na=`v0.9.1`,ra=`a2ui-action`,ia=[`createSurface`,`updateComponents`,`updateDataModel`,`deleteSurface`];function aa(t){if(!e(t)||typeof t.version!=`string`)return!1;let n=ia.filter(e=>e in t);if(n.length!==1)return!1;let r=t[n[0]];return e(r)&&typeof r.surfaceId==`string`&&r.surfaceId!==``}function oa(e){let t;try{t=JSON.parse(e)}catch{return null}return!Array.isArray(t)||t.length===0||!t.every(aa)?null:t}function sa(t){let n=[];for(let r of t){let t=r.createSurface;e(t)&&typeof t.surfaceId==`string`&&!n.includes(t.surfaceId)&&n.push(t.surfaceId)}return n}function ca(e){let t={name:e.name,surfaceId:e.surfaceId,sourceComponentId:e.sourceComponentId,timestamp:e.timestamp||(/* @__PURE__ */ new Date()).toISOString(),context:e.context};return`\`\`\`${ra}\n${JSON.stringify([{version:na,action:t}])}\n\`\`\``}var la=RegExp(`^\`\`\`${ra}[ \\t]*\\n([\\s\\S]*?)\\n\`\`\`$`);function ua(t){let n=la.exec(t.replace(/\r\n/g,`
|
|
86
|
+
`).trim());if(!n)return null;let r;try{r=JSON.parse(n[1])}catch{return null}let i=Array.isArray(r)?r[0]:r;if(!e(i)||!e(i.action))return null;let a=i.action;return typeof a.name!=`string`||a.name===``||typeof a.surfaceId!=`string`||a.surfaceId===``||!e(a.context)?null:{name:a.name,surfaceId:a.surfaceId,sourceComponentId:typeof a.sourceComponentId==`string`?a.sourceComponentId:``,timestamp:typeof a.timestamp==`string`?a.timestamp:``,context:a.context}}var da=/(?:^|\n) {0,3}(`{3,})a2ui[ \t]*\n([\s\S]*?)\n {0,3}\1`*[ \t]*(?=\n|$)/g,fa=/* @__PURE__ */ new WeakMap;function pa(e){let t=fa.get(e);if(!t){t=[];for(let n of e.text.matchAll(da)){let e=oa(n[2]);e&&t.push(...sa(e))}fa.set(e,t)}return t}function ma(e){let t=e.map(()=>/* @__PURE__ */ new Map),n=/* @__PURE__ */ new Map;return e.forEach((e,r)=>{if(e.role===`assistant`){for(let t of pa(e))n.set(t,r);return}if(e.role!==`user`)return;let i=ua(e.text),a=i?n.get(i.surfaceId):void 0;if(!i||a===void 0)return;let o=t[a];o.has(i.surfaceId)||o.set(i.surfaceId,i)}),t}function ha(t,n){let r=null;for(let i of t){let t=i.updateComponents;if(e(t)&&t.surfaceId===n.surfaceId&&Array.isArray(t.components))for(let a of t.components)e(a)&&a.id===n.sourceComponentId&&(r={version:i.version,component:a})}let i=r?.component.action,a=e(i)?i.event:void 0;if(r===null||!e(a)||!e(a.context))return[];let o=[];for(let[t,i]of Object.entries(a.context))e(i)&&typeof i.path==`string`&&i.path.startsWith(`/`)&&t in n.context&&o.push({version:r.version,updateDataModel:{surfaceId:n.surfaceId,path:i.path,value:n.context[t]}});return o}function ga(e,t,n){return e==null?`—`:typeof e==`boolean`?e?t:n:Array.isArray(e)?e.map(e=>ga(e,t,n)).join(`, `):typeof e==`string`?e:typeof e==`number`||typeof e==`bigint`?String(e):typeof e==`function`||typeof e==`symbol`?`—`:JSON.stringify(e)}function _a(e,t){let n=e.name.replace(/_/g,` `).trim();return{label:n.charAt(0).toUpperCase()+n.slice(1),fields:Object.entries(e.context).map(([e,n])=>[e,ga(n,t.yes,t.no)])}}var va=`
|
|
87
87
|
:host {
|
|
88
88
|
--_bg: var(--aicore-chat-surface, rgb(var(--magma-surface-default, 255 255 255)));
|
|
89
89
|
--_raised: var(--aicore-chat-surface-muted, rgb(var(--magma-surface-muted, 245 245 247)));
|
|
@@ -174,7 +174,7 @@ button:focus-visible, summary:focus-visible {
|
|
|
174
174
|
min-block-size: 0;
|
|
175
175
|
padding: 16px 12px;
|
|
176
176
|
border-inline-end: 1px solid var(--_border);
|
|
177
|
-
background: var(--
|
|
177
|
+
background: var(--_raised);
|
|
178
178
|
}
|
|
179
179
|
.main {
|
|
180
180
|
display: flex;
|
|
@@ -199,6 +199,65 @@ button:focus-visible, summary:focus-visible {
|
|
|
199
199
|
.rail-toggle { display: inline-flex; }
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
+
/* «Dietro le quinte» (the backstage attribute): a third column on a wide host, floating
|
|
203
|
+
over the chat on a narrower one, as the rail does. */
|
|
204
|
+
.layout.backstage-open {
|
|
205
|
+
grid-template-columns: minmax(200px, 260px) minmax(0, 1fr) minmax(300px, 400px);
|
|
206
|
+
}
|
|
207
|
+
.backstage {
|
|
208
|
+
display: flex;
|
|
209
|
+
flex-direction: column;
|
|
210
|
+
min-block-size: 0;
|
|
211
|
+
border-inline-start: 1px solid var(--_border);
|
|
212
|
+
background: var(--_bg);
|
|
213
|
+
}
|
|
214
|
+
.backstage-header {
|
|
215
|
+
display: flex;
|
|
216
|
+
align-items: center;
|
|
217
|
+
gap: 8px;
|
|
218
|
+
min-block-size: 60px;
|
|
219
|
+
padding: 8px 12px 8px 20px;
|
|
220
|
+
border-block-end: 1px solid var(--_border);
|
|
221
|
+
}
|
|
222
|
+
.backstage-title { margin: 0; font-size: 1em; font-weight: 600; }
|
|
223
|
+
.backstage-views {
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
gap: 2px;
|
|
226
|
+
padding: 3px;
|
|
227
|
+
border-radius: 999px;
|
|
228
|
+
background: var(--_raised);
|
|
229
|
+
}
|
|
230
|
+
.backstage-view {
|
|
231
|
+
padding: 4px 12px;
|
|
232
|
+
border-radius: 999px;
|
|
233
|
+
color: var(--_muted);
|
|
234
|
+
font-size: calc(var(--_fs) * 13 / 15);
|
|
235
|
+
font-weight: 600;
|
|
236
|
+
}
|
|
237
|
+
.backstage-view[aria-pressed="true"] {
|
|
238
|
+
background: var(--_bg);
|
|
239
|
+
color: var(--_fg);
|
|
240
|
+
box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
|
|
241
|
+
}
|
|
242
|
+
.backstage-header .icon-button { margin-inline-start: auto; }
|
|
243
|
+
.backstage-body { flex: 1; min-block-size: 0; overflow-y: auto; padding: 16px 20px; }
|
|
244
|
+
@container (max-width: 1100px) {
|
|
245
|
+
.layout.backstage-open {
|
|
246
|
+
grid-template-columns: minmax(200px, 260px) minmax(0, 1fr);
|
|
247
|
+
}
|
|
248
|
+
.backstage {
|
|
249
|
+
position: absolute;
|
|
250
|
+
inset-block: 0;
|
|
251
|
+
inset-inline-end: 0;
|
|
252
|
+
z-index: 2;
|
|
253
|
+
inline-size: min(400px, 90%);
|
|
254
|
+
box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
@container (max-width: 720px) {
|
|
258
|
+
.layout.backstage-open { grid-template-columns: minmax(0, 1fr); }
|
|
259
|
+
}
|
|
260
|
+
|
|
202
261
|
/* ---- rail -------------------------------------------------------------- */
|
|
203
262
|
|
|
204
263
|
.new-conversation {
|
|
@@ -206,6 +265,7 @@ button:focus-visible, summary:focus-visible {
|
|
|
206
265
|
align-items: center;
|
|
207
266
|
justify-content: center;
|
|
208
267
|
gap: 8px;
|
|
268
|
+
min-block-size: 44px;
|
|
209
269
|
padding: 8px 12px;
|
|
210
270
|
border-radius: var(--_radius-sm);
|
|
211
271
|
background: var(--_accent);
|
|
@@ -277,16 +337,17 @@ button:focus-visible, summary:focus-visible {
|
|
|
277
337
|
display: flex;
|
|
278
338
|
align-items: center;
|
|
279
339
|
gap: 8px;
|
|
280
|
-
min-block-size:
|
|
281
|
-
padding: 8px 16px;
|
|
340
|
+
min-block-size: 60px;
|
|
341
|
+
padding: 8px 16px 8px 20px;
|
|
282
342
|
border-block-end: 1px solid var(--_border);
|
|
283
343
|
}
|
|
284
|
-
.
|
|
285
|
-
|
|
286
|
-
|
|
344
|
+
.conversation-title {
|
|
345
|
+
flex: 1;
|
|
346
|
+
min-inline-size: 0;
|
|
347
|
+
margin: 0;
|
|
287
348
|
overflow: hidden;
|
|
288
|
-
|
|
289
|
-
font-
|
|
349
|
+
font-size: calc(var(--_fs) * 17 / 15);
|
|
350
|
+
font-weight: 600;
|
|
290
351
|
text-overflow: ellipsis;
|
|
291
352
|
white-space: nowrap;
|
|
292
353
|
}
|
|
@@ -311,22 +372,44 @@ button:focus-visible, summary:focus-visible {
|
|
|
311
372
|
.thread {
|
|
312
373
|
display: flex;
|
|
313
374
|
flex-direction: column;
|
|
375
|
+
min-block-size: 100%;
|
|
314
376
|
gap: 20px;
|
|
315
377
|
max-inline-size: 760px;
|
|
316
378
|
margin-inline: auto;
|
|
317
379
|
padding: 20px 16px;
|
|
318
380
|
}
|
|
381
|
+
/* Prova's empty conversation: in the middle, the AI's sparkles in their
|
|
382
|
+
circle, the agent's name, its description. */
|
|
319
383
|
.empty {
|
|
320
384
|
display: flex;
|
|
385
|
+
flex: 1;
|
|
321
386
|
flex-direction: column;
|
|
322
387
|
align-items: center;
|
|
323
388
|
justify-content: center;
|
|
324
389
|
gap: 8px;
|
|
325
|
-
min-block-size: 40%;
|
|
326
390
|
padding: 32px 16px;
|
|
327
391
|
text-align: center;
|
|
328
392
|
}
|
|
329
|
-
.empty-
|
|
393
|
+
.empty-icon {
|
|
394
|
+
display: inline-flex;
|
|
395
|
+
align-items: center;
|
|
396
|
+
justify-content: center;
|
|
397
|
+
inline-size: 48px;
|
|
398
|
+
block-size: 48px;
|
|
399
|
+
margin-block-end: 4px;
|
|
400
|
+
border-radius: 50%;
|
|
401
|
+
background: var(--_accent-soft);
|
|
402
|
+
color: var(--_accent-fg);
|
|
403
|
+
}
|
|
404
|
+
.empty-icon .icon { inline-size: 24px; block-size: 24px; }
|
|
405
|
+
.empty-title {
|
|
406
|
+
margin: 0;
|
|
407
|
+
font-size: calc(var(--_fs) * 26 / 15);
|
|
408
|
+
font-weight: 700;
|
|
409
|
+
letter-spacing: -0.01em;
|
|
410
|
+
line-height: 1.2;
|
|
411
|
+
}
|
|
412
|
+
.empty-detail { max-inline-size: 560px; margin: 0; }
|
|
330
413
|
|
|
331
414
|
.message { display: flex; flex-direction: column; gap: 6px; }
|
|
332
415
|
.message.user { align-items: flex-end; }
|
|
@@ -446,6 +529,8 @@ button:focus-visible, summary:focus-visible {
|
|
|
446
529
|
|
|
447
530
|
/* ---- composer ---------------------------------------------------------- */
|
|
448
531
|
|
|
532
|
+
/* Prova's composer: a card floating over the conversation, «+» to attach in
|
|
533
|
+
a tinted square, the round send button with its arrow. */
|
|
449
534
|
.composer {
|
|
450
535
|
display: flex;
|
|
451
536
|
flex-direction: column;
|
|
@@ -453,23 +538,32 @@ button:focus-visible, summary:focus-visible {
|
|
|
453
538
|
max-inline-size: 792px;
|
|
454
539
|
inline-size: 100%;
|
|
455
540
|
margin-inline: auto;
|
|
456
|
-
padding: 8px 16px
|
|
541
|
+
padding: 8px 16px 20px;
|
|
457
542
|
}
|
|
458
543
|
.box {
|
|
459
544
|
display: flex;
|
|
460
545
|
align-items: flex-end;
|
|
461
|
-
gap:
|
|
462
|
-
padding:
|
|
546
|
+
gap: 8px;
|
|
547
|
+
padding: 8px;
|
|
463
548
|
border: 1px solid var(--_border);
|
|
464
549
|
border-radius: var(--_radius);
|
|
465
550
|
background: var(--_bg);
|
|
551
|
+
box-shadow: 0 2px 12px rgb(0 0 0 / 0.08);
|
|
552
|
+
}
|
|
553
|
+
.box .attach {
|
|
554
|
+
inline-size: 40px;
|
|
555
|
+
block-size: 40px;
|
|
556
|
+
border-radius: var(--_radius-sm);
|
|
557
|
+
background: var(--_accent-soft);
|
|
558
|
+
color: var(--_accent-fg);
|
|
466
559
|
}
|
|
560
|
+
.box .attach:not(:disabled):hover { background: var(--_accent-soft); color: var(--_accent-fg); filter: brightness(0.96); }
|
|
467
561
|
.box:focus-within { border-color: var(--_accent); box-shadow: 0 0 0 1px var(--_accent); }
|
|
468
562
|
textarea {
|
|
469
563
|
flex: 1;
|
|
470
|
-
min-block-size:
|
|
564
|
+
min-block-size: 40px;
|
|
471
565
|
max-block-size: 200px;
|
|
472
|
-
padding:
|
|
566
|
+
padding: 9px 4px;
|
|
473
567
|
border: 0;
|
|
474
568
|
outline: none;
|
|
475
569
|
resize: none;
|
|
@@ -482,14 +576,13 @@ textarea {
|
|
|
482
576
|
display: inline-flex;
|
|
483
577
|
align-items: center;
|
|
484
578
|
justify-content: center;
|
|
485
|
-
inline-size:
|
|
486
|
-
block-size:
|
|
579
|
+
inline-size: 40px;
|
|
580
|
+
block-size: 40px;
|
|
487
581
|
border-radius: var(--_radius-sm);
|
|
488
582
|
background: var(--_accent);
|
|
489
583
|
color: var(--_on-accent);
|
|
490
584
|
}
|
|
491
585
|
.send:not(:disabled):hover { background: var(--_accent-hover); }
|
|
492
|
-
.footnote { margin: 0; color: var(--_muted); font-size: calc(var(--_fs) * 12 / 15); text-align: center; }
|
|
493
586
|
|
|
494
587
|
/* ---- developer --------------------------------------------------------- */
|
|
495
588
|
|
|
@@ -508,5 +601,5 @@ textarea {
|
|
|
508
601
|
.log { margin: 0; padding: 0; list-style: none; font-family: var(--_mono); }
|
|
509
602
|
.log li { padding-block: 1px; overflow-wrap: anywhere; }
|
|
510
603
|
.log .bad { color: var(--_danger); }
|
|
511
|
-
`,ga=`aicore-agent-chat`,_a=`.pdf,.docx,.txt,.md,.html,.xlsx,.epub`,va=[y.turn,y.error,y.authRequired,y.tenantRefused],ya=160,ba=100,xa=48,Sa=4e3,Ca=[`getToken`,`strings`,`context`,`baseUrl`,`agent`,`tenant`,`conversation`,`developer`,`copyAnswer`,`noDisclaimer`],wa=typeof HTMLElement>`u`?class{}:HTMLElement,Ta;function Ea(){if(Ta!==void 0)return Ta;try{let e=new CSSStyleSheet;e.replaceSync(ha),Ta=`adoptedStyleSheets`in ShadowRoot.prototype?e:null}catch{Ta=null}return Ta}var Da=()=>typeof navigator<`u`&&navigator.clipboard!==void 0;function Q(e,t={},...n){let r=document.createElement(e);t.class&&(r.className=t.class),t.part&&r.setAttribute(`part`,t.part),t.text!==void 0&&(r.textContent=t.text);for(let[e,n]of Object.entries(t.attrs??{}))r.setAttribute(e,n);for(let e of n)e&&r.append(e);return r}function $(e,t,n={},r=``){return Q(`button`,{class:`icon-button ${r}`.trim(),attrs:{type:`button`,"aria-label":t,title:t,...n}},Qi(e))}function Oa(e){return e&&/^https?:\/\//i.test(e)?e:null}function ka(e,t){return t.title??t.name??t.url??t.id_document??e.untitledSource}function Aa(e,t){return t.page==null?t.part==null?``:e.part(t.part):e.page(String(t.page))}function ja(t,n){let r=n===null?``:`+${((t.at-n)/1e3).toFixed(1)}s`,i=e(t.data)?t.data:{},a=typeof i.name==`string`?`${typeof i.node==`string`?`${i.node} → `:``}${i.name}`:``;if(!a)try{a=JSON.stringify(t.data)??``}catch{a=``}return a.length>ya&&(a=`${a.slice(0,ya)}…`),[r,t.kind,t.id?`#${t.id}`:``,a].filter(Boolean).join(` `)}function Ma(e,t){if(e.role!==`assistant`||t.role!==`assistant`)return!1;let n=n=>e[n]===t[n];return n(`text`)&&n(`sources`)&&n(`error`)&&n(`idQuery`)&&n(`interrupted`)}function Na(e,t){for(let n of e.querySelectorAll(`[data-action="rate"]`)){let e=Number(n.dataset.rating)===5;n.setAttribute(`aria-pressed`,String(t!==null&&(e?t>=4:t<=2)))}}var Pa=class extends wa{static observedAttributes=[`base-url`,`agent`,`tenant`,`conversation`,`lang`,`developer`,`copy-answer`,`no-disclaimer`];#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=null;#c=``;#l=null;#u=!1;#d=!0;#f=null;#p=!1;#m=[];#h=null;#g=0;#_=!1;#v=null;#y=!1;#b=!1;#x=!1;#S=!1;#C=!0;#w;constructor(){super();let e=this.attachShadow({mode:`open`}),t=Q(`button`,{class:`new-conversation`,attrs:{type:`button`,"data-action":`new`}}),n=Q(`p`,{class:`rail-status muted small`}),r=Q(`ul`,{class:`conversations`}),i=Q(`aside`,{class:`rail`,part:`rail`},t,n,r),a=$(`menu`,``,{"data-action":`toggle-rail`});a.classList.add(`rail-toggle`);let o=Q(`span`,{class:`agent-name`}),s=Q(`span`,{class:`agent-description`}),c=Q(`header`,{class:`header`,part:`header`},a,Q(`div`,{class:`agent`},o,s)),l=Q(`strong`),u=Q(`span`,{class:`small`}),d=$(`close`,``,{"data-action":`dismiss`}),f=Q(`div`,{class:`banner`,part:`error`,attrs:{role:`alert`}},Q(`div`,{class:`banner-text`},l,u),d);f.hidden=!0;let p=Q(`p`,{class:`empty-title`}),m=Q(`div`,{class:`empty`},p),h=Q(`p`,{class:`status`}),ee=Q(`div`,{class:`messages`}),g=Q(`div`,{class:`answer markdown`}),_=Q(`span`),te=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-busy":`true`}},g,Q(`div`,{class:`status`},Q(`span`,{class:`dots`},Q(`span`),Q(`span`),Q(`span`)),_));te.hidden=!0;let ne=Q(`div`,{class:`thread`,attrs:{role:`log`,"aria-live":`polite`}},m,h,ee,te);ee.style.display=`contents`;let v=Q(`div`,{class:`transcript`,part:`transcript`},ne),y=Q(`ul`,{class:`chips`}),re=Q(`input`,{attrs:{type:`file`,multiple:``,accept:_a}});re.hidden=!0;let b=$(`attach`,``,{"data-action":`attach`}),x=Q(`textarea`,{part:`input`,attrs:{rows:`1`}}),ie=Q(`button`,{class:`send`,part:`send`,attrs:{type:`submit`}},Qi(`send`)),ae=Q(`button`,{class:`send`,part:`stop`,attrs:{type:`button`,"data-action":`stop`}},Qi(`stop`)),oe=Q(`p`,{class:`footnote`}),S=Q(`form`,{class:`composer`,part:`composer`},y,Q(`div`,{class:`box`},b,x,ie,ae),oe,re),C=Q(`summary`),se=Q(`div`),ce=Q(`details`,{class:`developer`,part:`developer`},C,se),le=Q(`div`,{class:`layout`},i,Q(`section`,{class:`main`},c,f,v,S,ce)),w=Ea();w?e.adoptedStyleSheets=[w]:e.append(Q(`style`,{text:ha})),e.append(le),this.#w={layout:le,rail:i,newButton:t,railStatus:n,conversations:r,railToggle:a,agentName:o,agentDescription:s,banner:f,bannerTitle:l,bannerDetail:u,dismiss:d,transcript:v,thread:ne,empty:m,emptyTitle:p,loading:h,messages:ee,live:te,liveAnswer:g,liveActivity:_,files:y,fileInput:re,attach:b,input:x,send:ie,stop:ae,footnote:oe,developer:ce,developerSummary:C,developerBody:se},e.addEventListener(`click`,e=>this.#M(e)),r.addEventListener(`submit`,e=>{e.preventDefault(),this.#L()}),r.addEventListener(`keydown`,e=>{e.key===`Escape`&&this.#i&&(e.preventDefault(),this.#I(!0))}),ne.addEventListener(`toggle`,e=>this.#B(e),!0),S.addEventListener(`submit`,e=>{e.preventDefault(),this.#V()}),x.addEventListener(`input`,()=>this.#ue()),x.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),this.#V())}),re.addEventListener(`change`,()=>{let e=Array.from(re.files??[]);re.value=``,e.length>0&&this.#s?.attach(e)}),v.addEventListener(`scroll`,()=>{this.#C=v.scrollHeight-v.scrollTop-v.clientHeight<xa},{passive:!0}),typeof ResizeObserver<`u`&&new ResizeObserver(()=>{this.#C&&(v.scrollTop=v.scrollHeight)}).observe(v)}get getToken(){return this.#e}set getToken(e){let t=typeof e==`function`?e:null,n=t!==this.#e;this.#e=t,n&&t&&this.#s&&(this.#s.client.clearToken(),this.#s.client.checkIdentity()),this.#E()}get strings(){return this.#t}set strings(t){this.#t=e(t)?t:null,this.#J(!0)}get context(){return this.#n}set context(t){this.#n=e(t)?t:null,this.#r=!0,this.#J()}get baseUrl(){return this.getAttribute(`base-url`)}set baseUrl(e){this.#T(`base-url`,e)}get agent(){return this.getAttribute(`agent`)}set agent(e){this.#T(`agent`,e)}get tenant(){return this.getAttribute(`tenant`)}set tenant(e){this.#T(`tenant`,e)}get conversation(){return this.getAttribute(`conversation`)}set conversation(e){this.#T(`conversation`,e)}get developer(){return this.hasAttribute(`developer`)}set developer(e){this.toggleAttribute(`developer`,!!e)}get copyAnswer(){return this.hasAttribute(`copy-answer`)}set copyAnswer(e){this.toggleAttribute(`copy-answer`,!!e)}get noDisclaimer(){return this.hasAttribute(`no-disclaimer`)}set noDisclaimer(e){this.toggleAttribute(`no-disclaimer`,!!e)}get state(){return this.#s?.state??null}#T(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}connectedCallback(){let e=this;for(let t of Ca)if(Object.prototype.hasOwnProperty.call(this,t)){let n=e[t];delete e[t],e[t]=n}this.#E(),this.#J(!0)}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||this.#D()})}attributeChangedCallback(e,t,n){if(t!==n)switch(e){case`base-url`:case`tenant`:this.#E();break;case`agent`:this.#O(`agent`);break;case`conversation`:this.#O(`conversation`);break;default:this.#J(!0)}}#E(){if(!this.isConnected)return;let e=this.getAttribute(`base-url`),t=this.getAttribute(`tenant`),n=e&&this.#e?`${e}\n${t??``}`:``;if(n!==this.#c){if(this.#D(),this.#c=n,e&&n){let n=new Wi({baseUrl:e,tenant:t,getToken:async e=>this.#e?this.#e(e):null});for(let e of va)n.client.addEventListener(e,this.#A);n.addEventListener(Pi,this.#j),this.#s=n,n.setAgent(this.getAttribute(`agent`)),this.#k()}this.#J(!0)}}#D(){let e=this.#s;if(e){for(let t of va)e.client.removeEventListener(t,this.#A);e.removeEventListener(Pi,this.#j),e.dispose()}this.#s=null,this.#c=``,this.#l=null}#O(e){e===`agent`?this.#y=!0:this.#b=!0,this.#x||(this.#x=!0,queueMicrotask(()=>{let e=this.#y,t=this.#b;this.#x=this.#y=this.#b=!1;let n=this.#s;if(n){if(e){this.#S=!1;let e=this.getAttribute(`agent`);n.setAgent(e===``?null:e),t&&this.#k()}else this.#k()}}))}#k(){let e=this.#s;if(!e)return;let t=this.getAttribute(`conversation`);t?e.open(t):e.state.activeId&&!e.busy&&e.newConversation()}#A=e=>{this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail,bubbles:!0,composed:!0}))};#j=()=>{let e=this.#s?.state;e?.agentId&&e.activeId!==this.#l&&(this.#l=e.activeId,this.dispatchEvent(new CustomEvent(y.conversation,{detail:{idConv:e.activeId,idAgent:e.agentId},bubbles:!0,composed:!0}))),this.#J()};#M(e){let t=e.target?.closest(`[data-action]`);this.#S&&!e.target?.closest(`.rail, .rail-toggle`)&&(this.#S=!1,this.#w.layout.classList.remove(`rail-open`));let{id:n}=t?.dataset??{};if(this.#i&&!e.target?.closest(`.rename`)&&this.#I(!1),this.#a!==null&&(t?.dataset.action!==`delete`||n!==this.#a)&&this.#N(null),!t||t.disabled)return;let r=this.#s;switch(t.dataset.action){case`new`:this.#S=!1,r?.newConversation(),this.#w.input.focus();break;case`open`:this.#S=!1,this.#C=!0,n&&r?.open(n);break;case`rename`:n&&this.#F(n);break;case`cancel-rename`:this.#I(!0);break;case`delete`:if(!n)break;this.#a===n?(this.#N(null),r?.remove(n)):this.#N(n);break;case`toggle-rail`:this.#S=!this.#S;break;case`dismiss`:r?.dismissError();break;case`attach`:this.#w.fileInput.click();break;case`detach`:n&&r?.detach(n);break;case`stop`:r?.stop();break;case`copy`:this.#z(t,Number(t.dataset.index));break;case`rate`:t.dataset.query&&r?.rate(t.dataset.query,Number(t.dataset.rating))}this.#w.layout.classList.toggle(`rail-open`,this.#S)}#N(e){this.#o!==null&&clearTimeout(this.#o),this.#o=e===null?null:setTimeout(()=>this.#N(null),Sa),this.#a!==e&&(this.#a=e,this.#P(),e!==null&&this.#R(`delete`,e))}#P(){this.#Z(this.#K(),this.#s?.state??null,this.#s?.busy??!1)}#F(e){let t=this.#s?.state.conversations.find(t=>t.id===e);if(!t)return;let n=Q(`input`,{attrs:{type:`text`,"aria-label":this.#K().newTitle}});n.value=t.title??``,n.addEventListener(`input`,()=>{let e=n.parentElement?.querySelector(`[type=submit]`);e&&(e.disabled=!n.value.trim())}),this.#i={id:e,input:n},this.#P(),n.focus(),n.select()}#I(e){let t=this.#i?.id;t!==void 0&&(this.#i=null,this.#P(),e&&this.#R(`rename`,t))}#L(){let e=this.#i,t=e?.input.value.trim();e&&t&&!this.#s?.busy&&(this.#I(!0),this.#s?.rename(e.id,t))}#R(e,t){for(let n of this.#w.conversations.querySelectorAll(`[data-action="${e}"]`))n.dataset.id===t&&n.focus()}#z(e,t){let n=this.#s?.state.messages[t];if(!n||!navigator.clipboard)return;let r=this.#K();navigator.clipboard.writeText(n.text).then(()=>{e.replaceChildren(Qi(`check`)),e.setAttribute(`aria-label`,r.copied),setTimeout(()=>{e.replaceChildren(Qi(`copy`)),e.setAttribute(`aria-label`,r.copy)},1500)})}#B(e){let t=e.target;if(!(t instanceof HTMLDetailsElement)||!t.open)return;let{message:n,source:r}=t.dataset,i=t.querySelector(`.source-text`);if(!i||i.hasChildNodes()||n===void 0)return;let a=this.#s?.state.messages[Number(n)],o=a?.role===`assistant`?a.sources[Number(r)]:void 0;if(!o)return;Ni(i,o.text??``,this.#q(!1));let s=Oa(o.url);s&&i.append(Q(`a`,{text:s,attrs:{href:s,target:`_blank`,rel:`noopener noreferrer`}}))}#V(){let e=this.#s,t=this.#w.input.value.trim();e&&t&&!this.#w.send.disabled&&(this.#w.input.value=``,this.#C=!0,e.send(t,{context:this.#n}),this.#ue())}#H(e){let t=this.#s;return!t||!this.#U()?!1:(this.#C=!0,t.send(e,{context:this.#n}),this.#ue(),!0)}#U(){let e=this.#s,t=e?.state;return!!e&&!!t?.agentId&&!e.busy&&t.uploading===0&&t.files.length===0}#W(e){let t=e?.messages??[],n=this.#s?.busy??!1,r=this.#U()?e=>this.#H(e):void 0;return da(t).map(e=>({send:r,working:n,sent:e}))}#G(){return this.closest(`[lang]`)?.getAttribute(`lang`)??(typeof document>`u`?null:document.documentElement.lang)}#K(){return Yi(this.#G(),this.#t)}#q(e,t=!1,n){return{host:this,widgets:e,live:t,lang:qi(this.#G()),strings:this.#K(),interface:n??{working:t,sent:/* @__PURE__ */ new Map}}}#J(e=!1){if(e&&(this.#d=!0),this.#u)return;this.#u=!0;let t=()=>{this.#u=!1,this.#Y()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,16)}#Y(){let e=this.#K(),t=this.#s?.state??null,n=this.#s?.busy??!1,r=this.#d?null:this.#f,i=n!==this.#p||r===null;this.#d=!1,this.#f=t,this.#p=n;let a=(...e)=>r===null||t===null||e.some(e=>r[e]!==t[e]);if(r===null&&this.#X(e),(i||a(`conversations`,`activeId`,`conversationsLoading`,`conversationsFailed`,`agentId`))&&this.#Z(e,t,n),a(`agent`,`agentId`)&&this.#ee(e,t),a(`error`)&&this.#te(e,t),a(`messages`,`loadingHistory`,`agent`)&&this.#ne(e,t,r===null||a(`agent`)),i||a(`messages`,`files`,`uploading`,`agentId`)){let e=this.#W(t);this.#m.forEach(({node:t},n)=>{let r=e[n];r&&fn(t,r)})}this.#se(e,t,r===null),this.#ce(e,t),(i||a(`files`,`agentId`))&&this.#le(e,t,n);let o=this.hasAttribute(`developer`);this.#w.developer.hidden=!o;let s=this.#r;this.#r=!1,o&&(s||a(`requests`,`events`,`error`,`agent`,`activeId`))?this.#fe(e,t):o&&a(`tokens`)&&this.#v&&t&&(this.#v.textContent=e.events(t.tokens)),this.#w.layout.classList.toggle(`rail-open`,this.#S),this.#C&&(this.#w.transcript.scrollTop=this.#w.transcript.scrollHeight)}#X(e){let t=this.#w;t.rail.setAttribute(`aria-label`,e.conversations),t.newButton.replaceChildren(Qi(`add`),e.newConversation);for(let[n,r]of[[t.railToggle,e.conversations],[t.dismiss,e.dismiss],[t.attach,e.attach],[t.send,e.send],[t.stop,e.stop]])n.setAttribute(`aria-label`,r),n.title=r;t.input.placeholder=e.placeholder,t.input.setAttribute(`aria-label`,e.placeholder),t.footnote.textContent=e.disclaimer,t.footnote.hidden=!e.disclaimer||this.hasAttribute(`no-disclaimer`),t.loading.textContent=e.loadingHistory,t.developerSummary.textContent=e.developer}#Z(e,t,n){let r=this.#w;r.newButton.disabled=!t?.agentId||n;let i=t?.conversations??[],a=!t?.agentId||i.length>0?``:t.conversationsLoading?e.loading:t.conversationsFailed?e.conversationsFailed:e.noConversations;r.railStatus.textContent=a,r.railStatus.hidden=a===``;let o=this.#i;o&&!i.some(e=>e.id===o.id)&&(this.#i=null);let s=this.shadowRoot?.activeElement,c=s?r.conversations.contains(s):!1,l=this.#i?.input,u=c&&s===l,d=u?[l.selectionStart,l.selectionEnd]:[],{action:f,id:p}=c&&!u?s?.dataset??{}:{};r.conversations.replaceChildren(...i.map(r=>this.#$(e,r,r.id===t?.activeId,n))),u&&l.isConnected?(l.focus(),l.setSelectionRange(d[0]??null,d[1]??null)):f&&p&&this.#R(f,p)}#Q(e,t){return new Intl.DateTimeFormat(e.locale,{dateStyle:`short`,timeStyle:`short`}).format(t)}#$(e,t,n,r){let i=this.#Q(e,t.last_message_at),a=t.title??i,o=(t.title?i:e.untitled)+(t.enabled?``:` · ${e.disabled}`),s=Q(`button`,{class:`open`,attrs:{type:`button`,"data-action":`open`,"data-id":t.id}},Q(`span`,{class:`title`,text:a}),Q(`span`,{class:`meta`,text:o}));n&&s.setAttribute(`aria-current`,`true`),s.disabled=r;let c=Q(`li`,{class:n?`conversation active`:`conversation`});if(this.#i?.id===t.id){let{input:t}=this.#i,n=$(`check`,e.save,{type:`submit`});return n.disabled=r||!t.value.trim(),c.append(Q(`form`,{class:`rename`},t,n,$(`close`,e.cancel,{"data-action":`cancel-rename`}))),c}let l=$(`edit`,e.renameConversation(a),{"data-action":`rename`,"data-id":t.id});l.disabled=r;let u=this.#a===t.id,d=$(`delete`,u?e.confirmDelete(a):e.deleteConversation(a),{"data-action":`delete`,"data-id":t.id},u?`danger confirming`:`danger`);return u&&d.replaceChildren(e.confirmDeleteShort),d.disabled=r,c.append(s,l,d),c}#ee(e,t){let n=this.#w;n.agentName.textContent=t?.agent?.name??t?.agentId??e.noAgent,n.agentDescription.textContent=t?.agent?.description??``,n.agentDescription.hidden=!t?.agent?.description}#te(e,t){let n=this.#w,r=t?.error??null;n.banner.hidden=r===null,r&&(n.bannerTitle.textContent=e.errors[r.kind]+(r.kind===`rate_limited`&&r.retryAfter?` ${e.retryIn(r.retryAfter)}`:``),n.bannerDetail.textContent=[r.message,r.authDescription].filter(Boolean).join(` · `))}#ne(e,t,n){let r=this.#w,i=t?.loadingHistory??!1;r.loading.hidden=!i;let a=i?[]:t?.messages??[],o=t?.agent?.name??e.agent,s=this.#W(t),c=a.map((t,r)=>{let i=n?void 0:this.#m[r];return i?.message===t?i:i&&Ma(i.message,t)?(Na(i.node,t.rating),{message:t,node:i.node}):{message:t,node:t.role===`user`?this.#ie(e,t):this.#ae(e,t,r,o,s[r])}}),l=new Set(c.map(({node:e})=>e));for(let{node:e}of this.#m)l.has(e)||pn(e);this.#m=c;let u=r.messages.children;(c.length!==u.length||c.some(({node:e},t)=>e!==u[t]))&&r.messages.replaceChildren(...c.map(({node:e})=>e))}#re(e,t){let n=sa(t);if(!n)return Q(`div`,{class:`bubble`,text:t});let{label:r,fields:i}=ma(n,e);return Q(`ul`,{class:`chips action-summary`,attrs:{"aria-label":e.a2uiAction(r)}},Q(`li`,{class:`chip action`},Qi(`check`),Q(`span`,{class:`chip-label`,text:r})),...i.map(([e,t])=>Q(`li`,{class:`chip`},Q(`span`,{class:`chip-label`},Q(`span`,{class:`muted`,text:`${e}: `}),t))))}#ie(e,t){return Q(`article`,{class:`message user`,part:`message message-user`,attrs:{"aria-label":e.you}},this.#re(e,t.text),t.attachments.length>0&&Q(`ul`,{class:`chips`},...t.attachments.map(e=>Q(`li`,{class:`chip`},Q(`span`,{class:`chip-label`,text:e.name})))))}#ae(e,t,n,r,i){let a=Q(`div`,{class:`answer markdown`});Ni(a,t.text,this.#q(!0,!1,i));let o=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-label":r}},a);t.interrupted&&o.append(Q(`p`,{class:`note`,text:e.interrupted})),t.error&&o.append(Q(`p`,{class:`turn-error`,text:v(t.error,{failed:e.turnFailed,trace:e.trace})})),t.sources.length>0&&o.append(this.#oe(e,t.sources,n));let s=Q(`div`,{class:`actions`},t.text&&this.hasAttribute(`copy-answer`)&&Da()&&$(`copy`,e.copy,{"data-action":`copy`,"data-index":String(n)}));return t.idQuery&&(s.append($(`thumbUp`,e.rateUp,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`5`}),$(`thumbDown`,e.rateDown,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`1`})),Na(s,t.rating)),o.append(s),o}#oe(e,t,n){return Q(`details`,{class:`sources`,part:`sources`},Q(`summary`,{text:e.sources(t.length)}),Q(`ol`,{},...t.map((t,r)=>{let i=Aa(e,t);return Q(`li`,{},Q(`details`,{class:`source`,attrs:{"data-message":String(n),"data-source":String(r)}},Q(`summary`,{},ka(e,t),i&&Q(`span`,{class:`source-page`,text:` · ${i}`})),Q(`div`,{class:`source-text markdown`})))})))}#se(e,t,n){let r=this.#w,i=t?.turn??null;if(!n&&i===this.#h)return;if(r.live.hidden=i===null,!i){this.#h=null,pn(r.liveAnswer),r.liveAnswer.replaceChildren();return}r.liveActivity.textContent=i.activity??e.thinking;let a=performance.now()-this.#g;if(!n&&this.#h!==null&&i.text!==this.#h.text&&a<ba){this.#_||(this.#_=!0,setTimeout(()=>{this.#_=!1,this.#J()},ba-a));return}let o=n||this.#h?.text!==i.text;this.#h=i,o&&(this.#g=performance.now(),r.liveAnswer.hidden=!i.text,Ni(r.liveAnswer,i.text,this.#q(!0,!0)))}#ce(e,t){let n=this.#w,r=t===null||!t.loadingHistory&&t.messages.length===0&&!t.turn;n.empty.hidden=!r,r&&(n.emptyTitle.textContent=t===null?e.notConnected:t.agentId?t.agent?e.ask(t.agent.name):e.askGeneric:e.noAgent)}#le(e,t,n){let r=this.#w,i=t?.files??[];r.files.hidden=i.length===0,r.files.replaceChildren(...i.map(t=>{let n=t.name+(t.status===`processing`?` · ${e.processing}`:t.status===`error`?` · ${e.fileError}`:``);return Q(`li`,{class:t.status===`error`?`chip error`:`chip`,attrs:{title:t.error??n}},Q(`span`,{class:`chip-label`,text:n}),$(`close`,e.removeFile(t.name),{"data-action":`detach`,"data-id":t.id_file}))}));let a=!t?.agentId;r.input.disabled=a,r.attach.disabled=a||n,r.send.hidden=n,r.stop.hidden=!n,this.#ue()}#ue(){let e=this.#s?.state,t=(e?.uploading??0)>0||(e?.files.some(e=>e.status===`processing`)??!1);this.#w.send.disabled=!e?.agentId||(this.#s?.busy??!1)||t||!this.#w.input.value.trim()}#de(){if(!this.#n)return null;let e;try{e=JSON.stringify(this.#n)}catch{return`?`}let t=new TextEncoder().encode(e).length;return`${e.length>ya?`${e.slice(0,ya)}…`:e} · ${t} B`}#fe(e,t){let n=this.#w;if(!t||!this.#s){n.developerBody.replaceChildren();return}let r=e=>Q(`dl`,{},...e.flatMap(([e,t])=>[Q(`dt`,{text:e}),Q(`dd`,{text:t})])),{agent:i,error:a}=t,o=[r([[`API`,this.#s.client.apiBase],[`X-Tenant`,this.getAttribute(`tenant`)??e.none],[e.agent,t.agentId??e.none],[e.publishedVersion,i?i.published_version_number===null?e.notPublished:`v${i.published_version_number}`:e.none],[e.conversation,t.activeId??e.none],[e.context,this.#de()??e.none]])];a&&o.push(Q(`h4`,{text:e.lastError}),r([[`status`,`${a.status} · ${a.kind}`],[`message`,a.message],[`error_code`,a.errorCode??e.none],[`error_description`,a.authDescription??e.none],[`X-Request-Id`,a.requestId??e.none]])),this.#v=Q(`h4`,{text:e.events(t.tokens)}),o.push(this.#v,Q(`ol`,{class:`log`},...[...t.events].reverse().map(e=>Q(`li`,{text:ja(e,t.turnStartedAt)}))),Q(`h4`,{text:e.requests}),Q(`ol`,{class:`log`},...t.requests.map(t=>Q(`li`,{class:t.status===0||t.status>=400?`bad`:``,text:`${t.status} ${t.method} ${t.path} · ${t.durationMs} ms`+(t.retriedWithFreshToken?` · ${e.renewed}`:``)+(t.requestId?` · ${t.requestId}`:``)})))),n.developerBody.replaceChildren(...o)}};function Fa(e=ga){typeof customElements>`u`||customElements.get(e)||customElements.define(e,e===`aicore-agent-chat`?Pa:class extends Pa{})}Fa();export{ga as AICORE_AGENT_CHAT_TAG,y as AICORE_EVENTS,Pa as AicoreAgentChat,C as AicoreChatClient,Wi as AicoreChatSession,t as AicoreError,Pi as CHAT_CHANGE,g as EMPTY_TURN,f as EXPIRY_SKEW_MS,Ii as RATING_DOWN,Fi as RATING_UP,ee as TokenCache,Ni as a,ne as answerOf,ie as apiBaseOf,xi as c,ni as d,m as decodeJwtClaims,Fa as defineAicoreAgentChat,c as errorFromResponse,un as f,te as foldTurn,ia as i,a as isAbortError,s as isInvalidToken,h as jwtExpiry,r as kindOf,vi as l,e as m,Ui as messagesFromHistory,ra as n,wi as o,dn as p,o as parseBearerChallenge,fa as r,ae as randomId,Ti as s,aa as t,i as toAicoreError,v as turnErrorText,yi as u};
|
|
604
|
+
`,ya=`aicore-agent-chat`,ba=an(()=>import(`./bundle/backstage-Bfl3Tyo5.js`)),xa=`.pdf,.docx,.txt,.md,.html,.xlsx,.epub`,Sa=[v.turn,v.error,v.authRequired,v.tenantRefused],Ca=160,wa=100,Ta=1100,Ea=48,Da=4e3,Oa=[`getToken`,`strings`,`context`,`baseUrl`,`agent`,`tenant`,`conversation`,`developer`,`copyAnswer`,`backstage`,`team`],ka=typeof HTMLElement>`u`?class{}:HTMLElement,Aa;function ja(){if(Aa!==void 0)return Aa;try{let e=new CSSStyleSheet;e.replaceSync(va),Aa=`adoptedStyleSheets`in ShadowRoot.prototype?e:null}catch{Aa=null}return Aa}var Ma=()=>typeof navigator<`u`&&navigator.clipboard!==void 0;function Q(e,t={},...n){let r=document.createElement(e);t.class&&(r.className=t.class),t.part&&r.setAttribute(`part`,t.part),t.text!==void 0&&(r.textContent=t.text);for(let[e,n]of Object.entries(t.attrs??{}))r.setAttribute(e,n);for(let e of n)e&&r.append(e);return r}function $(e,t,n={},r=``){return Q(`button`,{class:`icon-button ${r}`.trim(),attrs:{type:`button`,"aria-label":t,title:t,...n}},ta(e))}function Na(e){return e&&/^https?:\/\//i.test(e)?e:null}function Pa(e,t){return t.title??t.name??t.url??t.id_document??e.untitledSource}function Fa(e,t){return t.page==null?t.part==null?``:e.part(t.part):e.page(String(t.page))}function Ia(e,t){if(e.role!==`assistant`||t.role!==`assistant`)return!1;let n=n=>e[n]===t[n];return n(`text`)&&n(`sources`)&&n(`error`)&&n(`idQuery`)&&n(`interrupted`)}function La(e,t){for(let n of e.querySelectorAll(`[data-action="rate"]`)){let e=Number(n.dataset.rating)===5;n.setAttribute(`aria-pressed`,String(t!==null&&(e?t>=4:t<=2)))}}var Ra=class extends ka{static observedAttributes=[`base-url`,`agent`,`tenant`,`conversation`,`lang`,`developer`,`copy-answer`,`backstage`];#e=null;#t=null;#n=null;#r=!1;#i=null;#a=null;#o=null;#s=null;#c=``;#l=null;#u=!1;#d=!0;#f=null;#p=!1;#m=[];#h=null;#g=0;#_=!1;#v=!1;#y=!1;#b=!1;#x=!1;#S=!0;#C=!1;#w=`log`;#T=null;#E=!0;#D;constructor(){super();let e=this.attachShadow({mode:`open`}),t=Q(`button`,{class:`new-conversation`,attrs:{type:`button`,"data-action":`new`}}),n=Q(`p`,{class:`rail-status muted small`}),r=Q(`ul`,{class:`conversations`}),i=Q(`aside`,{class:`rail`,part:`rail`},t,n,r),a=$(`menu`,``,{"data-action":`toggle-rail`});a.classList.add(`rail-toggle`);let o=Q(`h2`,{class:`conversation-title`}),s=$(`panel`,``,{"data-action":`toggle-backstage`,"aria-pressed":`true`},`backstage-toggle`),c=Q(`header`,{class:`header`,part:`header`},a,o,s),l=Q(`h2`,{class:`backstage-title`}),u=e=>Q(`button`,{class:`backstage-view`,attrs:{type:`button`,"data-action":`backstage-view`,"data-view":e}}),d=u(`log`),f=u(`map`),p=Q(`div`,{class:`backstage-views`,attrs:{role:`group`}},d,f),m=$(`close`,``,{"data-action":`toggle-backstage`}),h=Q(`div`,{class:`backstage-body`}),ee=Q(`aside`,{class:`backstage`,part:`backstage`},Q(`div`,{class:`backstage-header`},l,p,m),h),g=Q(`strong`),_=Q(`span`,{class:`small`}),te=$(`close`,``,{"data-action":`dismiss`}),ne=Q(`div`,{class:`banner`,part:`error`,attrs:{role:`alert`}},Q(`div`,{class:`banner-text`},g,_),te);ne.hidden=!0;let re=Q(`p`,{class:`empty-title`}),v=Q(`p`,{class:`empty-detail muted`}),ie=Q(`div`,{class:`empty`},Q(`span`,{class:`empty-icon`},ta(`sparkles`)),re,v),y=Q(`p`,{class:`status`}),b=Q(`div`,{class:`messages`}),ae=Q(`div`,{class:`answer markdown`}),oe=Q(`span`),se=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-busy":`true`}},ae,Q(`div`,{class:`status`},Q(`span`,{class:`dots`},Q(`span`),Q(`span`),Q(`span`)),oe));se.hidden=!0;let x=Q(`div`,{class:`thread`,attrs:{role:`log`,"aria-live":`polite`}},ie,y,b,se);b.style.display=`contents`;let S=Q(`div`,{class:`transcript`,part:`transcript`},x),ce=Q(`ul`,{class:`chips`}),C=Q(`input`,{attrs:{type:`file`,multiple:``,accept:xa}});C.hidden=!0;let le=$(`add`,``,{"data-action":`attach`},`attach`),w=Q(`textarea`,{part:`input`,attrs:{rows:`1`}}),T=Q(`button`,{class:`send`,part:`send`,attrs:{type:`submit`}},ta(`arrowUp`)),E=Q(`button`,{class:`send`,part:`stop`,attrs:{type:`button`,"data-action":`stop`}},ta(`stop`)),ue=Q(`form`,{class:`composer`,part:`composer`},ce,Q(`div`,{class:`box`},le,w,T,E),C),de=Q(`summary`),D=Q(`div`),fe=Q(`details`,{class:`developer`,part:`developer`},de,D),pe=Q(`div`,{class:`layout`},i,Q(`section`,{class:`main`},c,ne,S,ue,fe),ee),me=ja();me?e.adoptedStyleSheets=[me]:e.append(Q(`style`,{text:va})),e.append(pe),this.#D={layout:pe,rail:i,newButton:t,railStatus:n,conversations:r,railToggle:a,title:o,banner:ne,backstageToggle:s,backstage:ee,backstageTitle:l,backstageViews:p,backstageLog:d,backstageMap:f,backstageClose:m,backstageBody:h,bannerTitle:g,bannerDetail:_,dismiss:te,transcript:S,thread:x,empty:ie,emptyTitle:re,emptyDetail:v,loading:y,messages:b,live:se,liveAnswer:ae,liveActivity:oe,files:ce,fileInput:C,attach:le,input:w,send:T,stop:E,developer:fe,developerSummary:de,developerBody:D},e.addEventListener(`click`,e=>this.#F(e)),r.addEventListener(`submit`,e=>{e.preventDefault(),this.#B()}),r.addEventListener(`keydown`,e=>{e.key===`Escape`&&this.#i&&(e.preventDefault(),this.#z(!0))}),x.addEventListener(`toggle`,e=>this.#U(e),!0),ue.addEventListener(`submit`,e=>{e.preventDefault(),this.#W()}),w.addEventListener(`input`,()=>this.#me()),w.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),this.#W())}),C.addEventListener(`change`,()=>{let e=Array.from(C.files??[]);C.value=``,e.length>0&&this.#s?.attach(e)}),S.addEventListener(`scroll`,()=>{this.#E=S.scrollHeight-S.scrollTop-S.clientHeight<Ea},{passive:!0}),typeof ResizeObserver<`u`&&new ResizeObserver(()=>{this.#E&&(S.scrollTop=S.scrollHeight)}).observe(S)}get getToken(){return this.#e}set getToken(e){let t=typeof e==`function`?e:null,n=t!==this.#e;this.#e=t,n&&t&&this.#s&&(this.#s.client.clearToken(),this.#s.client.checkIdentity()),this.#k()}get strings(){return this.#t}set strings(t){this.#t=e(t)?t:null,this.#Z(!0)}get context(){return this.#n}set context(t){this.#n=e(t)?t:null,this.#r=!0,this.#Z()}get team(){return this.#T}set team(e){this.#T=Array.isArray(e)?e:null,this.#T||(this.#w=`log`),this.#Z(!0)}get baseUrl(){return this.getAttribute(`base-url`)}set baseUrl(e){this.#O(`base-url`,e)}get agent(){return this.getAttribute(`agent`)}set agent(e){this.#O(`agent`,e)}get tenant(){return this.getAttribute(`tenant`)}set tenant(e){this.#O(`tenant`,e)}get conversation(){return this.getAttribute(`conversation`)}set conversation(e){this.#O(`conversation`,e)}get developer(){return this.hasAttribute(`developer`)}set developer(e){this.toggleAttribute(`developer`,!!e)}get copyAnswer(){return this.hasAttribute(`copy-answer`)}set copyAnswer(e){this.toggleAttribute(`copy-answer`,!!e)}get backstage(){return this.hasAttribute(`backstage`)}set backstage(e){this.toggleAttribute(`backstage`,!!e)}get state(){return this.#s?.state??null}#O(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}connectedCallback(){let e=this;for(let t of Oa)if(Object.prototype.hasOwnProperty.call(this,t)){let n=e[t];delete e[t],e[t]=n}this.#k(),this.#Z(!0)}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||this.#A()})}attributeChangedCallback(e,t,n){if(t!==n)switch(e){case`base-url`:case`tenant`:this.#k();break;case`agent`:this.#j(`agent`);break;case`conversation`:this.#j(`conversation`);break;default:this.#Z(!0)}}#k(){if(!this.isConnected)return;let e=this.getAttribute(`base-url`),t=this.getAttribute(`tenant`),n=e&&this.#e?`${e}\n${t??``}`:``;if(n!==this.#c){if(this.#A(),this.#c=n,e&&n){let n=new qi({baseUrl:e,tenant:t,getToken:async e=>this.#e?this.#e(e):null});for(let e of Sa)n.client.addEventListener(e,this.#N);n.addEventListener(Pi,this.#P),this.#s=n,n.setAgent(this.getAttribute(`agent`)),this.#M()}this.#Z(!0)}}#A(){let e=this.#s;if(e){for(let t of Sa)e.client.removeEventListener(t,this.#N);e.removeEventListener(Pi,this.#P),e.dispose()}this.#s=null,this.#c=``,this.#l=null}#j(e){e===`agent`?this.#v=!0:this.#y=!0,this.#b||(this.#b=!0,queueMicrotask(()=>{let e=this.#v,t=this.#y;this.#b=this.#v=this.#y=!1;let n=this.#s;if(n){if(e){this.#x=!1;let e=this.getAttribute(`agent`);n.setAgent(e===``?null:e),t&&this.#M()}else this.#M()}}))}#M(){let e=this.#s;if(!e)return;let t=this.getAttribute(`conversation`);t?e.open(t):e.state.activeId&&!e.busy&&e.newConversation()}#N=e=>{this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail,bubbles:!0,composed:!0}))};#P=()=>{let e=this.#s?.state;e?.agentId&&e.activeId!==this.#l&&(this.#l=e.activeId,this.dispatchEvent(new CustomEvent(v.conversation,{detail:{idConv:e.activeId,idAgent:e.agentId},bubbles:!0,composed:!0}))),this.#Z()};#F(e){let t=e.target?.closest(`[data-action]`);this.#x&&!e.target?.closest(`.rail, .rail-toggle`)&&(this.#x=!1,this.#D.layout.classList.remove(`rail-open`));let{id:n}=t?.dataset??{};if(this.#i&&!e.target?.closest(`.rename`)&&this.#z(!1),this.#a!==null&&(t?.dataset.action!==`delete`||n!==this.#a)&&this.#I(null),!t||t.disabled)return;let r=this.#s;switch(t.dataset.action){case`new`:this.#x=!1,r?.newConversation(),this.#D.input.focus();break;case`open`:this.#x=!1,this.#E=!0,n&&r?.open(n);break;case`rename`:n&&this.#R(n);break;case`cancel-rename`:this.#z(!0);break;case`delete`:if(!n)break;this.#a===n?(this.#I(null),r?.remove(n)):this.#I(n);break;case`toggle-rail`:this.#x=!this.#x;break;case`backstage-view`:this.#w=t.dataset.view===`map`?`map`:`log`,this.#Z(!0);break;case`toggle-backstage`:this.#S=!this.#S,this.#C=!0,this.#Z(!0);break;case`dismiss`:r?.dismissError();break;case`attach`:this.#D.fileInput.click();break;case`detach`:n&&r?.detach(n);break;case`stop`:r?.stop();break;case`copy`:this.#H(t,Number(t.dataset.index));break;case`rate`:t.dataset.query&&r?.rate(t.dataset.query,Number(t.dataset.rating))}this.#D.layout.classList.toggle(`rail-open`,this.#x)}#I(e){this.#o!==null&&clearTimeout(this.#o),this.#o=e===null?null:setTimeout(()=>this.#I(null),Da),this.#a!==e&&(this.#a=e,this.#L(),e!==null&&this.#V(`delete`,e))}#L(){this.#ee(this.#Y(),this.#s?.state??null,this.#s?.busy??!1)}#R(e){let t=this.#s?.state.conversations.find(t=>t.id===e);if(!t)return;let n=Q(`input`,{attrs:{type:`text`,"aria-label":this.#Y().newTitle}});n.value=t.title??``,n.addEventListener(`input`,()=>{let e=n.parentElement?.querySelector(`[type=submit]`);e&&(e.disabled=!n.value.trim())}),this.#i={id:e,input:n},this.#L(),n.focus(),n.select()}#z(e){let t=this.#i?.id;t!==void 0&&(this.#i=null,this.#L(),e&&this.#V(`rename`,t))}#B(){let e=this.#i,t=e?.input.value.trim();e&&t&&!this.#s?.busy&&(this.#z(!0),this.#s?.rename(e.id,t))}#V(e,t){for(let n of this.#D.conversations.querySelectorAll(`[data-action="${e}"]`))n.dataset.id===t&&n.focus()}#H(e,t){let n=this.#s?.state.messages[t];if(!n||!navigator.clipboard)return;let r=this.#Y();navigator.clipboard.writeText(n.text).then(()=>{e.replaceChildren(ta(`check`)),e.setAttribute(`aria-label`,r.copied),setTimeout(()=>{e.replaceChildren(ta(`copy`)),e.setAttribute(`aria-label`,r.copy)},1500)})}#U(e){let t=e.target;if(!(t instanceof HTMLDetailsElement)||!t.open)return;let{message:n,source:r}=t.dataset,i=t.querySelector(`.source-text`);if(!i||i.hasChildNodes()||n===void 0)return;let a=this.#s?.state.messages[Number(n)],o=a?.role===`assistant`?a.sources[Number(r)]:void 0;if(!o)return;Ni(i,o.text??``,this.#X(!1));let s=Na(o.url);s&&i.append(Q(`a`,{text:s,attrs:{href:s,target:`_blank`,rel:`noopener noreferrer`}}))}#W(){let e=this.#s,t=this.#D.input.value.trim();e&&t&&!this.#D.send.disabled&&(this.#D.input.value=``,this.#E=!0,e.send(t,{context:this.#n}),this.#me())}#G(e){let t=this.#s;return!t||!this.#K()?!1:(this.#E=!0,t.send(e,{context:this.#n}),this.#me(),!0)}#K(){let e=this.#s,t=e?.state;return!!e&&!!t?.agentId&&!e.busy&&t.uploading===0&&t.files.length===0}#q(e){let t=e?.messages??[],n=this.#s?.busy??!1,r=this.#K()?e=>this.#G(e):void 0;return ma(t).map(e=>({send:r,working:n,sent:e}))}#J(){return this.closest(`[lang]`)?.getAttribute(`lang`)??(typeof document>`u`?null:document.documentElement.lang)}#Y(){return Qi(this.#J(),this.#t)}#X(e,t=!1,n){return{host:this,widgets:e,live:t,lang:Xi(this.#J()),strings:this.#Y(),interface:n??{working:t,sent:/* @__PURE__ */ new Map}}}#Z(e=!1){if(e&&(this.#d=!0),this.#u)return;this.#u=!0;let t=()=>{this.#u=!1,this.#Q()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,16)}#Q(){let e=this.#Y(),t=this.#s?.state??null,n=this.#s?.busy??!1,r=this.#d?null:this.#f,i=n!==this.#p||r===null;this.#d=!1,this.#f=t,this.#p=n;let a=(...e)=>r===null||t===null||e.some(e=>r[e]!==t[e]);if(r===null&&this.#$(e),(i||a(`conversations`,`activeId`,`conversationsLoading`,`conversationsFailed`,`agentId`))&&this.#ee(e,t,n),a(`agent`,`agentId`,`activeId`,`conversations`)&&this.#re(e,t),a(`error`)&&this.#ie(e,t),a(`messages`,`loadingHistory`,`agent`)&&this.#ae(e,t,r===null||a(`agent`)),i||a(`messages`,`files`,`uploading`,`agentId`)){let e=this.#q(t);this.#m.forEach(({node:t},n)=>{let r=e[n];r&&fn(t,r)})}this.#ue(e,t,r===null),(r===null||a(`log`,`turn`))&&this.#de(e,t),this.#fe(e,t),(i||a(`files`,`agentId`))&&this.#pe(e,t,n);let o=this.hasAttribute(`developer`);this.#D.developer.hidden=!o;let s=this.#r;this.#r=!1,o&&(s||a(`requests`,`events`,`error`,`agent`,`activeId`))&&this.#ge(e,t),this.#D.layout.classList.toggle(`rail-open`,this.#x),this.#E&&(this.#D.transcript.scrollTop=this.#D.transcript.scrollHeight)}#$(e){let t=this.#D;t.rail.setAttribute(`aria-label`,e.conversations),t.newButton.replaceChildren(ta(`add`),e.newConversation),t.backstageTitle.textContent=e.backstage,t.backstageLog.textContent=e.backstageLog,t.backstageMap.textContent=e.backstageMap,t.backstageViews.setAttribute(`aria-label`,e.backstageViews);for(let[n,r]of[[t.railToggle,e.conversations],[t.dismiss,e.dismiss],[t.attach,e.attach],[t.send,e.send],[t.stop,e.stop],[t.backstageToggle,e.backstageToggle],[t.backstageClose,e.backstageToggle]])n.setAttribute(`aria-label`,r),n.title=r;t.input.placeholder=e.placeholder,t.input.setAttribute(`aria-label`,e.placeholder),t.loading.textContent=e.loadingHistory,t.developerSummary.textContent=e.developer}#ee(e,t,n){let r=this.#D;r.newButton.disabled=!t?.agentId||n;let i=t?.conversations??[],a=!t?.agentId||i.length>0?``:t.conversationsLoading?e.loading:t.conversationsFailed?e.conversationsFailed:e.noConversations;r.railStatus.textContent=a,r.railStatus.hidden=a===``;let o=this.#i;o&&!i.some(e=>e.id===o.id)&&(this.#i=null);let s=this.shadowRoot?.activeElement,c=s?r.conversations.contains(s):!1,l=this.#i?.input,u=c&&s===l,d=u?[l.selectionStart,l.selectionEnd]:[],{action:f,id:p}=c&&!u?s?.dataset??{}:{};r.conversations.replaceChildren(...i.map(r=>this.#ne(e,r,r.id===t?.activeId,n))),u&&l.isConnected?(l.focus(),l.setSelectionRange(d[0]??null,d[1]??null)):f&&p&&this.#V(f,p)}#te(e,t){return new Intl.DateTimeFormat(e.locale,{dateStyle:`short`,timeStyle:`short`}).format(t)}#ne(e,t,n,r){let i=this.#te(e,t.last_message_at),a=t.title??i,o=(t.title?i:e.untitled)+(t.enabled?``:` · ${e.disabled}`),s=Q(`button`,{class:`open`,attrs:{type:`button`,"data-action":`open`,"data-id":t.id}},Q(`span`,{class:`title`,text:a}),Q(`span`,{class:`meta`,text:o}));n&&s.setAttribute(`aria-current`,`true`),s.disabled=r;let c=Q(`li`,{class:n?`conversation active`:`conversation`});if(this.#i?.id===t.id){let{input:t}=this.#i,n=$(`check`,e.save,{type:`submit`});return n.disabled=r||!t.value.trim(),c.append(Q(`form`,{class:`rename`},t,n,$(`close`,e.cancel,{"data-action":`cancel-rename`}))),c}let l=$(`edit`,e.renameConversation(a),{"data-action":`rename`,"data-id":t.id});l.disabled=r;let u=this.#a===t.id,d=$(`delete`,u?e.confirmDelete(a):e.deleteConversation(a),{"data-action":`delete`,"data-id":t.id},u?`danger confirming`:`danger`);return u&&d.replaceChildren(e.confirmDeleteShort),d.disabled=r,c.append(s,l,d),c}#re(e,t){let n=t?.activeId??null,r=n?t?.conversations.find(e=>e.id===n):void 0;this.#D.title.textContent=t?.agentId?n===null?e.newConversation:(r?.title??``)||e.untitled:``}#ie(e,t){let n=this.#D,r=t?.error??null;n.banner.hidden=r===null,r&&(n.bannerTitle.textContent=e.errors[r.kind]+(r.kind===`rate_limited`&&r.retryAfter?` ${e.retryIn(r.retryAfter)}`:``),n.bannerDetail.textContent=[r.message,r.authDescription].filter(Boolean).join(` · `))}#ae(e,t,n){let r=this.#D,i=t?.loadingHistory??!1;r.loading.hidden=!i;let a=i?[]:t?.messages??[],o=t?.agent?.name??e.agent,s=this.#q(t),c=a.map((t,r)=>{let i=n?void 0:this.#m[r];return i?.message===t?i:i&&Ia(i.message,t)?(La(i.node,t.rating),{message:t,node:i.node}):{message:t,node:t.role===`user`?this.#se(e,t):this.#ce(e,t,r,o,s[r])}}),l=new Set(c.map(({node:e})=>e));for(let{node:e}of this.#m)l.has(e)||pn(e);this.#m=c;let u=r.messages.children;(c.length!==u.length||c.some(({node:e},t)=>e!==u[t]))&&r.messages.replaceChildren(...c.map(({node:e})=>e))}#oe(e,t){let n=ua(t);if(!n)return Q(`div`,{class:`bubble`,text:t});let{label:r,fields:i}=_a(n,e);return Q(`ul`,{class:`chips action-summary`,attrs:{"aria-label":e.a2uiAction(r)}},Q(`li`,{class:`chip action`},ta(`check`),Q(`span`,{class:`chip-label`,text:r})),...i.map(([e,t])=>Q(`li`,{class:`chip`},Q(`span`,{class:`chip-label`},Q(`span`,{class:`muted`,text:`${e}: `}),t))))}#se(e,t){return Q(`article`,{class:`message user`,part:`message message-user`,attrs:{"aria-label":e.you}},this.#oe(e,t.text),t.attachments.length>0&&Q(`ul`,{class:`chips`},...t.attachments.map(e=>Q(`li`,{class:`chip`},Q(`span`,{class:`chip-label`,text:e.name})))))}#ce(e,t,n,r,i){let a=Q(`div`,{class:`answer markdown`});Ni(a,t.text,this.#X(!0,!1,i));let o=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-label":r}},a);t.interrupted&&o.append(Q(`p`,{class:`note`,text:e.interrupted})),t.error&&o.append(Q(`p`,{class:`turn-error`,text:re(t.error,{failed:e.turnFailed,trace:e.trace})})),t.sources.length>0&&o.append(this.#le(e,t.sources,n));let s=Q(`div`,{class:`actions`},t.text&&this.hasAttribute(`copy-answer`)&&Ma()&&$(`copy`,e.copy,{"data-action":`copy`,"data-index":String(n)}));return t.idQuery&&(s.append($(`thumbUp`,e.rateUp,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`5`}),$(`thumbDown`,e.rateDown,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`1`})),La(s,t.rating)),o.append(s),o}#le(e,t,n){return Q(`details`,{class:`sources`,part:`sources`},Q(`summary`,{text:e.sources(t.length)}),Q(`ol`,{},...t.map((t,r)=>{let i=Fa(e,t);return Q(`li`,{},Q(`details`,{class:`source`,attrs:{"data-message":String(n),"data-source":String(r)}},Q(`summary`,{},Pa(e,t),i&&Q(`span`,{class:`source-page`,text:` · ${i}`})),Q(`div`,{class:`source-text markdown`})))})))}#ue(e,t,n){let r=this.#D,i=t?.turn??null;if(!n&&i===this.#h)return;if(r.live.hidden=i===null,!i){this.#h=null,pn(r.liveAnswer),r.liveAnswer.replaceChildren();return}r.liveActivity.textContent=i.activity??e.thinking;let a=performance.now()-this.#g;if(!n&&this.#h!==null&&i.text!==this.#h.text&&a<wa){this.#_||(this.#_=!0,setTimeout(()=>{this.#_=!1,this.#Z()},wa-a));return}let o=n||this.#h?.text!==i.text;this.#h=i,o&&(this.#g=performance.now(),r.liveAnswer.hidden=!i.text,Ni(r.liveAnswer,i.text,this.#X(!0,!0)))}#de(e,t){let n=this.#D,r=this.hasAttribute(`backstage`);if(r&&!this.#C){let e=this.getBoundingClientRect().width;this.#S=e===0||e>Ta}let i=r&&this.#S;n.backstageToggle.hidden=!r,n.backstageToggle.setAttribute(`aria-pressed`,String(i)),n.backstage.hidden=!i,n.layout.classList.toggle(`backstage-open`,i);let a=this.#T,o=a?this.#w:`log`;if(n.backstageMap.hidden=!a,n.backstageLog.setAttribute(`aria-pressed`,String(o===`log`)),n.backstageMap.setAttribute(`aria-pressed`,String(o===`map`)),!i||!t)return;let s=t.turn,c={view:o,team:a,agentName:t.agent?.name??t.agentId??``,working:s!==null,log:t.log,live:s&&t.turnStartedAt!==null?{label:s.activity??e.thinking,since:t.turnStartedAt}:null,strings:e,locale:e.locale},l=ba.get();l?l.drawBackstage(n.backstageBody,c):ba.load().then(()=>this.#Z(!0),()=>void 0)}#fe(e,t){let n=this.#D,r=t===null||!t.loadingHistory&&t.messages.length===0&&!t.turn;if(n.empty.hidden=!r,!r)return;n.emptyTitle.textContent=t===null?e.notConnected:t.agentId?t.agent?.name??``:e.noAgent;let i=t?.agentId?t.agent?.description??``:``;n.emptyDetail.textContent=i,n.emptyDetail.hidden=!i}#pe(e,t,n){let r=this.#D,i=t?.files??[];r.files.hidden=i.length===0,r.files.replaceChildren(...i.map(t=>{let n=t.name+(t.status===`processing`?` · ${e.processing}`:t.status===`error`?` · ${e.fileError}`:``);return Q(`li`,{class:t.status===`error`?`chip error`:`chip`,attrs:{title:t.error??n}},Q(`span`,{class:`chip-label`,text:n}),$(`close`,e.removeFile(t.name),{"data-action":`detach`,"data-id":t.id_file}))}));let a=!t?.agentId;r.input.disabled=a,r.attach.disabled=a||n,r.send.hidden=n,r.stop.hidden=!n,this.#me()}#me(){let e=this.#s?.state,t=(e?.uploading??0)>0||(e?.files.some(e=>e.status===`processing`)??!1);this.#D.send.disabled=!e?.agentId||(this.#s?.busy??!1)||t||!this.#D.input.value.trim()}#he(){if(!this.#n)return null;let e;try{e=JSON.stringify(this.#n)}catch{return`?`}let t=new TextEncoder().encode(e).length;return`${e.length>Ca?`${e.slice(0,Ca)}…`:e} · ${t} B`}#ge(e,t){let n=this.#D;if(!t||!this.#s){n.developerBody.replaceChildren();return}let r=e=>Q(`dl`,{},...e.flatMap(([e,t])=>[Q(`dt`,{text:e}),Q(`dd`,{text:t})])),{agent:i,error:a}=t,o=[r([[`API`,this.#s.client.apiBase],[`X-Tenant`,this.getAttribute(`tenant`)??e.none],[e.agent,t.agentId??e.none],[e.publishedVersion,i?i.published_version_number===null?e.notPublished:`v${i.published_version_number}`:e.none],[e.conversation,t.activeId??e.none],[e.context,this.#he()??e.none]])];a&&o.push(Q(`h4`,{text:e.lastError}),r([[`status`,`${a.status} · ${a.kind}`],[`message`,a.message],[`error_code`,a.errorCode??e.none],[`error_description`,a.authDescription??e.none],[`X-Request-Id`,a.requestId??e.none]])),o.push(Q(`h4`,{text:e.requests}),Q(`ol`,{class:`log`},...t.requests.map(t=>Q(`li`,{class:t.status===0||t.status>=400?`bad`:``,text:`${t.status} ${t.method} ${t.path} · ${t.durationMs} ms`+(t.retriedWithFreshToken?` · ${e.renewed}`:``)+(t.requestId?` · ${t.requestId}`:``)})))),n.developerBody.replaceChildren(...o)}};function za(e=ya){typeof customElements>`u`||customElements.get(e)||customElements.define(e,e===`aicore-agent-chat`?Ra:class extends Ra{})}za();export{ya as AICORE_AGENT_CHAT_TAG,v as AICORE_EVENTS,Ra as AicoreAgentChat,S as AicoreChatClient,qi as AicoreChatSession,t as AicoreError,Pi as CHAT_CHANGE,g as EMPTY_TURN,f as EXPIRY_SKEW_MS,Ii as RATING_DOWN,Fi as RATING_UP,ee as TokenCache,Ni as a,ne as answerOf,ae as apiBaseOf,xi as c,ni as d,m as decodeJwtClaims,za as defineAicoreAgentChat,c as errorFromResponse,un as f,te as foldTurn,sa as i,a as isAbortError,s as isInvalidToken,h as jwtExpiry,r as kindOf,vi as l,e as m,Ki as messagesFromHistory,oa as n,wi as o,dn as p,o as parseBearerChallenge,ha as r,oe as randomId,Ti as s,zi as serverMsOf,ca as t,i as toAicoreError,re as turnErrorText,yi as u};
|
|
512
605
|
//# sourceMappingURL=aicore-agent-chat.js.map
|