@maggioli-rd/aicore-agent-chat 1.0.1 → 1.1.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 +18 -1
- package/dist/aicore-agent-chat.js +44 -23
- package/dist/aicore-agent-chat.js.map +1 -1
- package/dist/chunks/{core-CdSjbHFC.js → core-DOTdJRxc.js} +30 -4
- package/dist/chunks/core-DOTdJRxc.js.map +1 -0
- package/dist/chunks/{src-CfPZVl62.js → src-CaHNyUXp.js} +160 -11
- package/dist/chunks/src-CaHNyUXp.js.map +1 -0
- package/dist/core.js +1 -1
- package/dist/define.js +2 -2
- package/dist/index.js +2 -2
- package/dist/types/core/session.d.ts +15 -2
- package/dist/types/element/i18n.d.ts +7 -0
- package/dist/types/element/icons.d.ts +1 -0
- package/dist/types/element/index.d.ts +8 -1
- package/dist/types/element/styles.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-CdSjbHFC.js.map +0 -1
- package/dist/chunks/src-CfPZVl62.js.map +0 -1
|
@@ -2,20 +2,20 @@ function e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var t=class exte
|
|
|
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
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 g=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}},_={text:``,result:null,sources:[],activity:null,title:null,error:null,finished:!1},ee=t=>e(t)?t:{};function v(e,t,n){let r=ee(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 y({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 b({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
4
|
`)}var x={conversation:`aicore-conversation`,turn:`aicore-turn`,error:`aicore-error`,authRequired:`aicore-auth-required`,tenantRefused:`aicore-tenant-refused`},S=3,te=1e3;function ne(e){let t=e.trim().replace(/\/+$/,``);return t.endsWith(`/api/v1`)?t:`${t}/api/v1`}function re(){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 C=e=>e instanceof t&&(e.status===0||e.status>=502);function w(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 ie=class extends EventTarget{apiBase;tenant;#e;#t;#n;#r;#i;#a=null;constructor(e){super(),this.apiBase=ne(e.baseUrl),this.tenant=e.tenant??null,this.#e=new g(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?re():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(x.error,{detail:e})),e.kind===`auth_required`&&this.dispatchEvent(new CustomEvent(x.authRequired,{detail:e})),e.kind===`tenant_refused`&&this.dispatchEvent(new CustomEvent(x.tenantRefused,{detail:e}))}listAgents(e){let t=new URLSearchParams({limit:`200`});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(x.conversation,{detail:{idConv:t.id_conv,idAgent:e}})),t}async history(e){let t=[],n=null;do{let r=new URLSearchParams({limit:`100`});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||!C(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>S)throw new t({status:0,message:`Connection lost while streaming`});if(await w(te*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=_,a=!1;try{for await(let t of this.streamTurn(n,r,e.signal))i=v(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(x.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{..._,text:n?.content??``,sources:n?.sources??[],finished:!0}}};function ae(e,t){this.v=e,this.k=t}function oe(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 se(e){if(Array.isArray(e))return e}function ce(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 le(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ue(e,t){return se(e)||ce(e,t)||de(e,t)||le()}function de(e,t){if(e){if(typeof e==`string`)return oe(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)?oe(e,t):void 0}}function fe(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ae;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)}fe.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},fe.prototype.next=function(e){return this._invoke(`next`,e)},fe.prototype.throw=function(e){return this._invoke(`throw`,e)},fe.prototype.return=function(e){return this._invoke(`return`,e)};var pe=Object.entries,me=Object.setPrototypeOf,he=Object.isFrozen,ge=Object.getPrototypeOf,_e=Object.getOwnPropertyDescriptor,T=Object.freeze,E=Object.seal,ve=Object.create,D=typeof Reflect<`u`&&Reflect,ye=D.apply,be=D.construct;T||=function(e){return e},E||=function(e){return e},ye||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},be||=function(e){return new e(...[...arguments].slice(1))};var xe=A(Array.prototype.forEach);Array.prototype.indexOf;var Se=A(Array.prototype.lastIndexOf),Ce=A(Array.prototype.pop),we=A(Array.prototype.push),Te=A(Array.prototype.slice),Ee=A(Array.prototype.splice),De=Array.isArray,Oe=Ue(Set),ke=A(Set.prototype.add),Ae=A(Set.prototype.has),je=A(String.prototype.toLowerCase),Me=A(String.prototype.toString),Ne=A(String.prototype.match),Pe=A(String.prototype.replace),Fe=A(String.prototype.indexOf),Ie=A(String.prototype.trim),Le=A(Number.prototype.toString),Re=A(Boolean.prototype.toString),ze=typeof BigInt>`u`?null:A(BigInt.prototype.toString),Be=typeof Symbol>`u`?null:A(Symbol.prototype.toString),O=A(Object.prototype.hasOwnProperty),Ve=A(Object.prototype.toString),k=A(RegExp.prototype.test),He=Ue(TypeError);function A(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ye(e,t,n)}}function Ue(e){return function(){return be(e,[...arguments])}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:je;if(me&&me(e,null),!De(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(he(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t<e.length;t++)O(e,t)||(e[t]=null);return e}function N(e){let t=ve(null);for(let r of pe(e)){var n=ue(r,2);let i=n[0],a=n[1];O(e,i)&&(t[i]=De(a)?M(a):a&&typeof a==`object`&&a.constructor===Object?N(a):a)}return t}function We(e){switch(typeof e){case`string`:return e;case`number`:return Le(e);case`boolean`:return Re(e);case`bigint`:return ze?ze(e):`0`;case`symbol`:return Be?Be(e):`Symbol()`;case`undefined`:return Ve(e);case`function`:case`object`:{if(e===null)return Ve(e);let t=e,n=P(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ve(e)}return Ve(e)}default:return Ve(e)}}function P(e,t){for(;e!==null;){let n=_e(e,t);if(n){if(n.get)return A(n.get);if(typeof n.value==`function`)return A(n.value)}e=ge(e)}function n(){return null}return n}function Ge(e,t){for(;e!==null;){let n=_e(e,t);if(n)return n.get?A(n.get):null;e=ge(e)}return null}function Ke(e){try{return k(e,``),!0}catch{return!1}}var qe=T(/* @__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(`.`)),Je=T(/* @__PURE__ */ `svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ye=T([`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`]),Xe=T([`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`]),Ze=T(/* @__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(`.`)),Qe=T([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),$e=T([`#text`]),et=T(/* @__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(`.`)),tt=T(/* @__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(`.`)),nt=T(/* @__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(`.`)),rt=T([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),it=E(/{{[\w\W]*|^[\w\W]*}}/g),at=E(/<%[\w\W]*|^[\w\W]*%>/g),ot=E(/\${[\w\W]*/g),st=E(/^data-[\-\w.\u00B7-\uFFFF]+$/),ct=E(/^aria-[\-\w]+$/),lt=E(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ut=E(/^(?:\w+script|data):/i),dt=E(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ft=E(/^html$/i),pt=E(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=E(/<[/\w!]/g),ht=E(/<[/\w]/g),gt=E(/<\/no(script|embed|frames)/i),_t=E(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vt=T(j({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),yt=function(){return typeof window>`u`?null:window},bt=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}},xt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},St=function(e,t,n,r){return O(e,t)&&De(e[t])?j(r.base?N(r.base):{},e[t],r.transform):n},Ct=function(e,t,n){let r=O(e,t)?e[t]:void 0;return r&&typeof r==`object`?N(r):n()};function wt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yt(),t=e=>wt(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==F.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=P(d,`cloneNode`),p=P(d,`remove`),m=P(d,`removeAttributeNode`),h=P(d,`nextSibling`),g=P(d,`childNodes`),_=P(d,`parentNode`),ee=P(d,`shadowRoot`),v=P(d,`attributes`),y=o&&o.prototype?P(o.prototype,`nodeType`):null,b=o&&o.prototype?P(o.prototype,`nodeName`):null,x=o&&o.prototype?P(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},te=function(e){return b?b(e):e.nodeName},ne=Ge(d,`namespaceURI`),re=function(e){return ne?ne(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let C,w=``,ie,ae=!1,oe=0,se=function(){if(oe>0)throw He(`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.`)},ce=function(e){se(),oe++;try{return C.createHTML(e)}finally{oe--}},le=function(e){se(),oe++;try{return C.createScriptURL(e)}finally{oe--}},ue=function(){return ae||=(ie=bt(u,i),!0),ie},de=n,fe=de.implementation,me=de.createNodeIterator,he=de.createDocumentFragment,ge=de.getElementsByTagName,_e=r.importNode,D=xt();t.isSupported=typeof pe==`function`&&typeof _==`function`&&fe&&fe.createHTMLDocument!==void 0;let ye=it,be=at,Le=ot,Re=st,ze=ct,Be=ut,Ve=dt,A=pt,Ue=lt,M=null,Tt=j({},[...qe,...Je,...Ye,...Ze,...$e]),I=null,L=j({},[...et,...tt,...nt,...rt]),R=Object.seal(ve(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),z=null,Et=null,B=Object.seal(ve(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Dt=!0,V=!0,Ot=!1,kt=!0,H=!1,U=!0,At=!1,jt=!1,Mt=null,Nt=null,Pt=!1,Ft=!1,It=!1,Lt=!1,Rt=!0,zt=!1,Bt=`user-content-`,Vt=!0,Ht=!1,Ut=null,Wt={},Gt=null,Kt=j({},/* @__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(`.`)),qt=null,Jt=j({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Yt=null,Xt=j({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Zt=`http://www.w3.org/1998/Math/MathML`,Qt=`http://www.w3.org/2000/svg`,W=`http://www.w3.org/1999/xhtml`,G=W,$t=!1,en=null,tn=j({},[Zt,Qt,W],Me),nn=T([`mi`,`mo`,`mn`,`ms`,`mtext`]),rn=j({},nn),an=T([`annotation-xml`]),on=j({},an),sn=j({},[`title`,`style`,`font`,`a`,`script`]),cn=null,ln=[`application/xhtml+xml`,`text/html`],K=null,un=null,dn=n.createElement(`form`),fn=function(e){return e instanceof RegExp||e instanceof Function},pn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(un&&un===e)return;e&&typeof e==`object`||(e={}),e=N(e),cn=ln.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,K=cn===`application/xhtml+xml`?Me:je,M=St(e,`ALLOWED_TAGS`,Tt,{transform:K}),I=St(e,`ALLOWED_ATTR`,L,{transform:K}),en=St(e,`ALLOWED_NAMESPACES`,tn,{transform:Me}),Yt=St(e,`ADD_URI_SAFE_ATTR`,Xt,{transform:K,base:Xt}),qt=St(e,`ADD_DATA_URI_TAGS`,Jt,{transform:K,base:Jt}),Gt=St(e,`FORBID_CONTENTS`,Kt,{transform:K}),z=St(e,`FORBID_TAGS`,N({}),{transform:K}),Et=St(e,`FORBID_ATTR`,N({}),{transform:K}),Wt=O(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N(e.USE_PROFILES):e.USE_PROFILES:!1,Dt=e.ALLOW_ARIA_ATTR!==!1,V=e.ALLOW_DATA_ATTR!==!1,Ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,kt=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=e.SAFE_FOR_TEMPLATES||!1,U=e.SAFE_FOR_XML!==!1,At=e.WHOLE_DOCUMENT||!1,Ft=e.RETURN_DOM||!1,It=e.RETURN_DOM_FRAGMENT||!1,Lt=e.RETURN_TRUSTED_TYPE||!1,Pt=e.FORCE_BODY||!1,Rt=e.SANITIZE_DOM!==!1,zt=e.SANITIZE_NAMED_PROPS||!1,Vt=e.KEEP_CONTENT!==!1,Ht=e.IN_PLACE||!1,Ue=Ke(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:lt,G=typeof e.NAMESPACE==`string`?e.NAMESPACE:W,rn=Ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>j({},nn)),on=Ct(e,`HTML_INTEGRATION_POINTS`,()=>j({},an));let t=Ct(e,`CUSTOM_ELEMENT_HANDLING`,()=>ve(null));if(R=ve(null),O(t,`tagNameCheck`)&&fn(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),O(t,`attributeNameCheck`)&&fn(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),O(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),E(R),H&&(V=!1),It&&(Ft=!0),Wt&&(M=j({},$e),I=ve(null),Wt.html===!0&&(j(M,qe),j(I,et)),Wt.svg===!0&&(j(M,Je),j(I,tt),j(I,rt)),Wt.svgFilters===!0&&(j(M,Ye),j(I,tt),j(I,rt)),Wt.mathMl===!0&&(j(M,Ze),j(I,nt),j(I,rt))),B.tagCheck=null,B.attributeCheck=null,O(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?B.tagCheck=e.ADD_TAGS:De(e.ADD_TAGS)&&(M===Tt&&(M=N(M)),j(M,e.ADD_TAGS,K))),O(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?B.attributeCheck=e.ADD_ATTR:De(e.ADD_ATTR)&&(I===L&&(I=N(I)),j(I,e.ADD_ATTR,K))),O(e,`ADD_FORBID_CONTENTS`)&&De(e.ADD_FORBID_CONTENTS)&&(Gt===Kt&&(Gt=N(Gt)),j(Gt,e.ADD_FORBID_CONTENTS,K)),Vt&&(M[`#text`]=!0),At&&j(M,[`html`,`head`,`body`]),M.table&&(j(M,[`tbody`]),delete z.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=C;C=e.TRUSTED_TYPES_POLICY;try{w=ce(``)}catch(e){throw C=t,e}}else e.TRUSTED_TYPES_POLICY===null?(C=void 0,w=``):(C===void 0&&(C=ue()),C&&typeof w==`string`&&(w=ce(``)));T&&T(e),un=e},mn=j({},[...Je,...Ye,...Xe]),hn=j({},[...Ze,...Qe]),gn=function(e,t,n){return t.namespaceURI===W?e===`svg`:t.namespaceURI===Zt?e===`svg`&&(n===`annotation-xml`||rn[n]):!!mn[e]},_n=function(e,t,n){return t.namespaceURI===W?e===`math`:t.namespaceURI===Qt?e===`math`&&on[n]:!!hn[e]},vn=function(e,t,n){return t.namespaceURI===Qt&&!on[n]||t.namespaceURI===Zt&&!rn[n]?!1:!hn[e]&&(sn[e]||!mn[e])},yn=function(e){let t=re(e),n=je(te(e)),r=_(e),i,a;return r&&S(r)===F.element?(i={namespaceURI:re(r)},a=je(te(r))):(i={namespaceURI:G},a=`template`),en[t]?t===Qt?gn(n,i,a):t===Zt?_n(n,i,a):t===W?vn(n,i,a):!!(cn===`application/xhtml+xml`&&en[t]):!1},bn=function(e){we(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw He(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xn=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Sn=function(e){En(e);let t=g(e);t&&xe(Te(t),e=>{try{p(e)}catch{}});let n=S(e)===F.element?v(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xn(e,r,i)}},Cn=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}we(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ft||It)try{bn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},wn=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[K(i)]||xn(e,r,i)}},Tn=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&&S(e)===F.element){let t=ee(e);q(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},En=function(e){Tn(e,e=>{S(e)===F.element&&wn(e)})},Dn=function(e){let t=[];return Tn(e,e=>{t.push(e)},!0),t},On=function(e,t){let n=Oe();xe(Dn(e),e=>{S(e)===F.element&&ke(n,e)}),xe(t,e=>{S(e)===F.element&&!Ae(n,e)&&wn(e)})},kn=function(e,n){let r=!1;return xe(t.removed,t=>{t.element&&(r||=t.element===e,En(t.element))}),On(e,n),r},An=function(e,t){let n=Ut,r=null,i=()=>(r||(r=Oe(),xe(t,e=>{ke(r,e)})),r);for(let t=0;;t++){let r=Dn(e),a=[e],o=!1;if(xe(r,e=>{S(e)===F.documentFragment?we(a,e):!o&&!Ae(n,e)&&(o=Ae(i(),e))}),!o)return;if(t>=8)throw He(`the tree kept changing during in-place sanitization; refusing to return it`);xe(a,(t,n)=>{jn(t,n>0,e,i())})}},jn=function(e,t,n,r){let i=In(e),a;for(;a=i.nextNode();)Ae(r,a)&&!Ae(Ut,a)&&(t&&Y(D.uponSanitizeShadowNode,a,null),Kn(a,n),$n(a,n),q(a.content)&&er(a.content))},Mn=function(e){Ut&&ke(Ut,e)},Nn=function(e,t){return U?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Pn=function(e){U&&Tn(e,e=>{let t=S(e);if(t===F.processingInstruction||t===F.comment&&k(ht,e.data)){try{p(e)}catch{}return!1}if(t===F.element){let t=e,n=K(te(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Nn(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Fn=function(e){let t=null,r=null;if(Pt)e=`<remove></remove>`+e;else{let t=Ne(e,/^[\r\n\t ]+/);r=t&&t[0]}cn===`application/xhtml+xml`&&G===W&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=C?ce(e):e;if(G===W)try{t=new l().parseFromString(i,cn)}catch{}if(!t||!t.documentElement){t=fe.createDocument(G,`template`,null);try{t.documentElement.innerHTML=$t?w:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),G===W?ge.call(t,At?`html`:`body`)[0]:At?t.documentElement:a},In=function(e){let t=x?x(e):e.ownerDocument;return me.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ln=function(e){return e=Pe(e,ye,` `),e=Pe(e,be,` `),e=Pe(e,Le,` `),e},Rn=function(e){zn(e);let t=e.querySelectorAll?.call(e,`template`);t&&xe(t,e=>{q(e.content)&&Rn(e.content)})},zn=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=me.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Ln(r.data),r=n.nextNode()},Bn=function(e){let t=b?b(e):null;return typeof t!=`string`||K(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(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!==y(e)||e.childNodes!==g(e)},q=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===F.documentFragment}catch{return!1}},J=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function Y(e,n,r){e.length!==0&&xe(e,e=>{e.call(t,n,r,un)})}let Vn=function(e,t){return!!(U&&e.hasChildNodes()&&!J(e.firstElementChild)&&k(mt,e.textContent)&&k(mt,e.innerHTML)||U&&vt[t]&&S(e)===F.element&&re(e)===W&&(J(e.firstElementChild)||typeof e.textContent==`string`&&k(mt,e.textContent))||e.nodeType===F.processingInstruction||U&&e.nodeType===F.comment&&k(ht,e.data))},Hn=function(e,t){return e instanceof RegExp?k(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Un=function(e,t,n){if(!z[t]&&Yn(t)&&Hn(R.tagNameCheck,t))return!1;if(Vt&&!Gt[t]&&!Gt[je(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,h(e))}}}return bn(e),!0},Wn=function(e,t,n,r){return e.length===0?t:t===n||t===r?N(t):t},Gn=function(e,t){return e===t||_(e)!==null?!1:(Ht&&En(e),!0)},Kn=function(e,n){if(Mn(e),Y(D.beforeSanitizeElements,e,null),Gn(e,n))return!0;if(Bn(e))return bn(e),!0;let r=K(te(e));if(M=Wn(D.uponSanitizeElement,M,Tt,Mt),Y(D.uponSanitizeElement,e,{tagName:r,allowedTags:M}),Gn(e,n))return!0;if(Vn(e,r))return bn(e),!0;if(z[r]||!(B.tagCheck instanceof Function&&B.tagCheck(r))&&!M[r]){let t=Un(e,r,n);return t===!1&&(Y(D.afterSanitizeElements,e,null),Gn(e,n))?!0:t}if(S(e)===F.element&&!yn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&k(gt,e.innerHTML))return bn(e),!0;if(H&&e.nodeType===F.text){let n=Ln(e.textContent);e.textContent!==n&&(we(t.removed,{element:e.cloneNode()}),e.textContent=n)}return Y(D.afterSanitizeElements,e,null),Gn(e,n)},qn=function(e,t,r){if(Et[t]||Nn(t,e)||Rt&&(t===`id`||t===`name`)&&(r in n||r in dn))return!1;let i=I[t]||B.attributeCheck instanceof Function&&B.attributeCheck(t,e);return V&&k(Re,t)||Dt&&k(ze,t)?!0:i?Yt[t]||k(Ue,Pe(r,Ve,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Fe(r,`data:`)===0&&qt[e]||Ot&&!k(Be,Pe(r,Ve,``))?!0:!r:Yn(e)&&Hn(R.tagNameCheck,e)&&Hn(R.attributeNameCheck,t,e)||t===`is`&&R.allowCustomizedBuiltInElements&&Hn(R.tagNameCheck,r)},Jn=j({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Yn=function(e){return!Jn[je(e)]&&k(A,e)},Xn=function(e,t,n,r){if(C&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ce(r);case`TrustedScriptURL`:return le(r)}return r},Zn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Bn(e)||(bn(e),!1)}catch{return Cn(t,e),!1}},Qn=function(e,t){return U&&k(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:je(e)===`attributename`&&Ne(t,`href`)!==null},$n=function(e,n){if(Y(D.beforeSanitizeAttributes,e,null),Gn(e,n))return;let r=e.attributes;if(!r||Bn(e))return;I=Wn(D.uponSanitizeAttribute,I,L,Nt);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=K(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=K(s),d=l,f=s===`value`?d:Ie(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,Y(D.uponSanitizeAttribute,e,i),f=i.attrValue,zt&&(u===`id`||u===`name`)&&Fe(f,Bt)!==0&&(Cn(s,e,n),f=Bt+f,p=!0),Qn(s,f)?Cn(s,e,n):i.forceKeepAttr||(i.keepAttr?!kt&&k(_t,f)?Cn(s,e,n):(H&&(f=Ln(f)),qn(o,u,f)?(f=Xn(o,u,c,f),f!==d&&Zn(e,s,c,f)&&p&&Ce(t.removed)):Cn(s,e,n)):Cn(s,e,n))}Y(D.afterSanitizeAttributes,e,null),Gn(e,n)},er=function(e){let t=null,n=In(e);for(Y(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(Y(D.uponSanitizeShadowNode,t,null),Kn(t,e),$n(t,e),q(t.content)&&er(t.content),S(t)===F.element){let e=ee(t);q(e)&&(tr(e),er(e))}H&&zn(e),Y(D.afterSanitizeShadowDOM,e,null)},tr=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){er(e.shadow);continue}let n=e.node,r=S(n)===F.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=b?b(n):null;if(typeof e==`string`&&K(e)===`template`){let e=n.content;q(e)&&t.push({node:e,shadow:null})}}if(r){let e=ee(n);q(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if($t=!e,$t&&(e=`<!-->`),typeof e!=`string`&&!J(e)&&(e=We(e),typeof e!=`string`))throw He(`dirty is not a string, aborting`);if(!t.isSupported)return e;jt?(M=Mt,I=Nt):pn(n),(D.uponSanitizeElement.length>0||D.uponSanitizeAttribute.length>0)&&(M=N(M)),D.uponSanitizeAttribute.length>0&&(I=N(I)),t.removed=[];let c=Ht&&typeof e!=`string`&&J(e),l=[],u=Ut;if(c){Pn(e);let t=te(e);if(typeof t==`string`){let n=K(t);if(!M[n]||z[n])throw Sn(e),He(`root node is forbidden and cannot be sanitized in-place`)}if(Bn(e))throw Sn(e),He(`root node is clobbered and cannot be sanitized in-place`);l=Dn(e),Ut=Oe()}else if(J(e))i=Fn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===F.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),tr(i);else{if(!Ft&&!H&&!At&&e.indexOf(`<`)===-1)return C&&Lt?ce(e):e;if(i=Fn(e),!i)return Ft?null:Lt?w:``}i&&Pt&&bn(i.firstChild);let d=c?e:i;try{c&&tr(e);let t=In(d);for(;o=t.nextNode();)Kn(o,d),$n(o,d),q(o.content)&&er(o.content);c&&An(e,l)}catch(t){throw c&&(Sn(e),kn(e,l)),t}finally{Ut=u}if(c){if(kn(e,l))throw He(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return H&&Rn(e),e}if(Ft){if(H&&Rn(i),It)for(s=he.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=_e.call(r,s,!0)),s}let f=At?i.outerHTML:i.innerHTML;return At&&M[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&k(ft,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
6
|
-
`+f),H&&(f=Ln(f)),C&&Lt?ce(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pn(e),jt=!0,Mt=M,Nt=I},t.clearConfig=function(){un=null,jt=!1,Mt=null,Nt=null,C=ie,w=``},t.isValidAttribute=function(e,t,n){un||pn({});let r=K(e),i=K(t);return typeof n==`string`&&(
|
|
7
|
-
]`).replace(`lheading`,Nt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Xt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Qt=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,W=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,G=/[\p{P}\p{S}]/u,$t=/[\s\p{P}\p{S}]/u,en=/[^\s\p{P}\p{S}]/u,tn=B(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,$t).getRegex(),nn=/[\p{Pi}\p{Ps}"']/u,rn=/(?!~)[\p{P}\p{S}]/u,an=/(?!~)[\s\p{P}\p{S}]/u,on=/(?:[^\s\p{P}\p{S}]|~)/u,sn=B(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Dt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),cn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ln=B(cn,`u`).replace(/punct/g,G).getRegex(),K=B(cn,`u`).replace(/punct/g,rn).getRegex(),un=B(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,nn).replace(/punct/g,G).getRegex(),dn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fn=B(dn,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),pn=B(dn,`gu`).replace(/notPunctSpace/g,on).replace(/punctSpace/g,an).replace(/punct/g,rn).getRegex(),mn=B(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),hn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),gn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),_n=B(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,G).getRegex(),vn=B(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),yn=B(/\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),bn=B(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),xn=B(/^<(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(),Sn=B(Vt).replace(`(?:-->|$)`,`-->`).getRegex(),Cn=B(`^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`,Sn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wn=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Tn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,wn).getRegex(),En=B(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Tn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),Dn=B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Tn).replace(`ref`,Lt).getRegex(),On=B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Lt).getRegex(),kn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,An=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,wn).getRegex(),jn=B(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,An).replace(`ref`,kn).getRegex()).replace(`nolink`,B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kn).getRegex()).getRegex(),Mn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Nn=B(/(?: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(),Pn={_backpedal:z,anyPunctuation:yn,anyPunctuationOutsideCode:bn,autolink:xn,blockSkip:sn,br:Qt,code:Zt,del:z,delLDelim:z,delRDelim:z,emStrongLDelim:ln,emStrongRDelimAst:fn,emStrongRDelimUnd:hn,escape:Xt,link:En,nolink:On,punctuation:tn,reflink:Dn,reflinkSearch:jn,tag:Cn,text:W,url:z},Fn={...Pn,emStrongLDelim:un,emStrongRDelimAst:mn,emStrongRDelimUnd:gn,link:B(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Tn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Tn).getRegex()},In={...Pn,emStrongRDelimAst:pn,emStrongLDelim:K,delLDelim:_n,delRDelim:vn,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Nn).replace(`protocol`,Mn).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:B(/^(?:[^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`,Mn).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,Dt?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},Ln={...In,br:B(Qt).replace(`{2,}`,`*`).getRegex(),text:B(In.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Rn={normal:Kt,gfm:Jt,pedantic:Yt},zn={normal:Pn,gfm:In,breaks:Ln,pedantic:Fn},Bn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ue(e,t){return se(e)||ce(e,t)||de(e,t)||le()}function de(e,t){if(e){if(typeof e==`string`)return oe(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)?oe(e,t):void 0}}function fe(e){var t,n;function r(t,n){try{var a=e[t](n),o=a.value,s=o instanceof ae;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)}fe.prototype[typeof Symbol==`function`&&Symbol.asyncIterator||`@@asyncIterator`]=function(){return this},fe.prototype.next=function(e){return this._invoke(`next`,e)},fe.prototype.throw=function(e){return this._invoke(`throw`,e)},fe.prototype.return=function(e){return this._invoke(`return`,e)};var pe=Object.entries,me=Object.setPrototypeOf,he=Object.isFrozen,ge=Object.getPrototypeOf,_e=Object.getOwnPropertyDescriptor,T=Object.freeze,E=Object.seal,ve=Object.create,D=typeof Reflect<`u`&&Reflect,ye=D.apply,be=D.construct;T||=function(e){return e},E||=function(e){return e},ye||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},be||=function(e){return new e(...[...arguments].slice(1))};var xe=A(Array.prototype.forEach);Array.prototype.indexOf;var Se=A(Array.prototype.lastIndexOf),Ce=A(Array.prototype.pop),we=A(Array.prototype.push),Te=A(Array.prototype.slice),Ee=A(Array.prototype.splice),De=Array.isArray,Oe=Ue(Set),ke=A(Set.prototype.add),Ae=A(Set.prototype.has),je=A(String.prototype.toLowerCase),Me=A(String.prototype.toString),Ne=A(String.prototype.match),Pe=A(String.prototype.replace),Fe=A(String.prototype.indexOf),Ie=A(String.prototype.trim),Le=A(Number.prototype.toString),Re=A(Boolean.prototype.toString),ze=typeof BigInt>`u`?null:A(BigInt.prototype.toString),Be=typeof Symbol>`u`?null:A(Symbol.prototype.toString),O=A(Object.prototype.hasOwnProperty),Ve=A(Object.prototype.toString),k=A(RegExp.prototype.test),He=Ue(TypeError);function A(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return ye(e,t,n)}}function Ue(e){return function(){return be(e,[...arguments])}}function j(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:je;if(me&&me(e,null),!De(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(he(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t<e.length;t++)O(e,t)||(e[t]=null);return e}function N(e){let t=ve(null);for(let r of pe(e)){var n=ue(r,2);let i=n[0],a=n[1];O(e,i)&&(t[i]=De(a)?M(a):a&&typeof a==`object`&&a.constructor===Object?N(a):a)}return t}function We(e){switch(typeof e){case`string`:return e;case`number`:return Le(e);case`boolean`:return Re(e);case`bigint`:return ze?ze(e):`0`;case`symbol`:return Be?Be(e):`Symbol()`;case`undefined`:return Ve(e);case`function`:case`object`:{if(e===null)return Ve(e);let t=e,n=P(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:Ve(e)}return Ve(e)}default:return Ve(e)}}function P(e,t){for(;e!==null;){let n=_e(e,t);if(n){if(n.get)return A(n.get);if(typeof n.value==`function`)return A(n.value)}e=ge(e)}function n(){return null}return n}function Ge(e,t){for(;e!==null;){let n=_e(e,t);if(n)return n.get?A(n.get):null;e=ge(e)}return null}function Ke(e){try{return k(e,``),!0}catch{return!1}}var qe=T(/* @__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(`.`)),Je=T(/* @__PURE__ */ `svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),Ye=T([`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`]),Xe=T([`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`]),Ze=T(/* @__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(`.`)),Qe=T([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),$e=T([`#text`]),et=T(/* @__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(`.`)),tt=T(/* @__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(`.`)),nt=T(/* @__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(`.`)),rt=T([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),it=E(/{{[\w\W]*|^[\w\W]*}}/g),at=E(/<%[\w\W]*|^[\w\W]*%>/g),ot=E(/\${[\w\W]*/g),st=E(/^data-[\-\w.\u00B7-\uFFFF]+$/),ct=E(/^aria-[\-\w]+$/),lt=E(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ut=E(/^(?:\w+script|data):/i),dt=E(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ft=E(/^html$/i),pt=E(/^[a-z][.\w]*(-[.\w]+)+$/i),mt=E(/<[/\w!]/g),ht=E(/<[/\w]/g),gt=E(/<\/no(script|embed|frames)/i),_t=E(/\/>/i),F={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},vt=T(j({},[`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`])),yt=function(){return typeof window>`u`?null:window},bt=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}},xt=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},St=function(e,t,n,r){return O(e,t)&&De(e[t])?j(r.base?N(r.base):{},e[t],r.transform):n},Ct=function(e,t,n){let r=O(e,t)?e[t]:void 0;return r&&typeof r==`object`?N(r):n()};function wt(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:yt(),t=e=>wt(e);if(t.version=`3.4.17`,t.removed=[],!e||!e.document||e.document.nodeType!==F.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript;e.DocumentFragment;let a=e.HTMLTemplateElement,o=e.Node,s=e.Element,c=e.NodeFilter;e.NamedNodeMap===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;let l=e.DOMParser,u=e.trustedTypes,d=s.prototype,f=P(d,`cloneNode`),p=P(d,`remove`),m=P(d,`removeAttributeNode`),h=P(d,`nextSibling`),g=P(d,`childNodes`),_=P(d,`parentNode`),ee=P(d,`shadowRoot`),v=P(d,`attributes`),y=o&&o.prototype?P(o.prototype,`nodeType`):null,b=o&&o.prototype?P(o.prototype,`nodeName`):null,x=o&&o.prototype?P(o.prototype,`ownerDocument`):null,S=function(e){return y?y(e):e.nodeType},te=function(e){return b?b(e):e.nodeName},ne=Ge(d,`namespaceURI`),re=function(e){return ne?ne(e):e.namespaceURI};if(typeof a==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let C,w=``,ie,ae=!1,oe=0,se=function(){if(oe>0)throw He(`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.`)},ce=function(e){se(),oe++;try{return C.createHTML(e)}finally{oe--}},le=function(e){se(),oe++;try{return C.createScriptURL(e)}finally{oe--}},ue=function(){return ae||=(ie=bt(u,i),!0),ie},de=n,fe=de.implementation,me=de.createNodeIterator,he=de.createDocumentFragment,ge=de.getElementsByTagName,_e=r.importNode,D=xt();t.isSupported=typeof pe==`function`&&typeof _==`function`&&fe&&fe.createHTMLDocument!==void 0;let ye=it,be=at,Le=ot,Re=st,ze=ct,Be=ut,Ve=dt,A=pt,Ue=lt,M=null,Tt=j({},[...qe,...Je,...Ye,...Ze,...$e]),I=null,L=j({},[...et,...tt,...nt,...rt]),R=Object.seal(ve(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),z=null,Et=null,B=Object.seal(ve(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Dt=!0,V=!0,Ot=!1,kt=!0,H=!1,U=!0,At=!1,jt=!1,Mt=null,Nt=null,Pt=!1,Ft=!1,It=!1,Lt=!1,Rt=!0,zt=!1,Bt=`user-content-`,Vt=!0,Ht=!1,Ut=null,Wt={},Gt=null,Kt=j({},/* @__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(`.`)),qt=null,Jt=j({},[`audio`,`video`,`img`,`source`,`image`,`track`]),Yt=null,Xt=j({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Zt=`http://www.w3.org/1998/Math/MathML`,Qt=`http://www.w3.org/2000/svg`,W=`http://www.w3.org/1999/xhtml`,G=W,$t=!1,en=null,tn=j({},[Zt,Qt,W],Me),nn=T([`mi`,`mo`,`mn`,`ms`,`mtext`]),rn=j({},nn),an=T([`annotation-xml`]),on=j({},an),sn=j({},[`title`,`style`,`font`,`a`,`script`]),cn=null,ln=[`application/xhtml+xml`,`text/html`],K=null,un=null,dn=n.createElement(`form`),fn=function(e){return e instanceof RegExp||e instanceof Function},pn=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(un&&un===e)return;e&&typeof e==`object`||(e={}),e=N(e),cn=ln.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,K=cn===`application/xhtml+xml`?Me:je,M=St(e,`ALLOWED_TAGS`,Tt,{transform:K}),I=St(e,`ALLOWED_ATTR`,L,{transform:K}),en=St(e,`ALLOWED_NAMESPACES`,tn,{transform:Me}),Yt=St(e,`ADD_URI_SAFE_ATTR`,Xt,{transform:K,base:Xt}),qt=St(e,`ADD_DATA_URI_TAGS`,Jt,{transform:K,base:Jt}),Gt=St(e,`FORBID_CONTENTS`,Kt,{transform:K}),z=St(e,`FORBID_TAGS`,N({}),{transform:K}),Et=St(e,`FORBID_ATTR`,N({}),{transform:K}),Wt=O(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?N(e.USE_PROFILES):e.USE_PROFILES:!1,Dt=e.ALLOW_ARIA_ATTR!==!1,V=e.ALLOW_DATA_ATTR!==!1,Ot=e.ALLOW_UNKNOWN_PROTOCOLS||!1,kt=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,H=e.SAFE_FOR_TEMPLATES||!1,U=e.SAFE_FOR_XML!==!1,At=e.WHOLE_DOCUMENT||!1,Ft=e.RETURN_DOM||!1,It=e.RETURN_DOM_FRAGMENT||!1,Lt=e.RETURN_TRUSTED_TYPE||!1,Pt=e.FORCE_BODY||!1,Rt=e.SANITIZE_DOM!==!1,zt=e.SANITIZE_NAMED_PROPS||!1,Vt=e.KEEP_CONTENT!==!1,Ht=e.IN_PLACE||!1,Ue=Ke(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:lt,G=typeof e.NAMESPACE==`string`?e.NAMESPACE:W,rn=Ct(e,`MATHML_TEXT_INTEGRATION_POINTS`,()=>j({},nn)),on=Ct(e,`HTML_INTEGRATION_POINTS`,()=>j({},an));let t=Ct(e,`CUSTOM_ELEMENT_HANDLING`,()=>ve(null));if(R=ve(null),O(t,`tagNameCheck`)&&fn(t.tagNameCheck)&&(R.tagNameCheck=t.tagNameCheck),O(t,`attributeNameCheck`)&&fn(t.attributeNameCheck)&&(R.attributeNameCheck=t.attributeNameCheck),O(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(R.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),E(R),H&&(V=!1),It&&(Ft=!0),Wt&&(M=j({},$e),I=ve(null),Wt.html===!0&&(j(M,qe),j(I,et)),Wt.svg===!0&&(j(M,Je),j(I,tt),j(I,rt)),Wt.svgFilters===!0&&(j(M,Ye),j(I,tt),j(I,rt)),Wt.mathMl===!0&&(j(M,Ze),j(I,nt),j(I,rt))),B.tagCheck=null,B.attributeCheck=null,O(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?B.tagCheck=e.ADD_TAGS:De(e.ADD_TAGS)&&(M===Tt&&(M=N(M)),j(M,e.ADD_TAGS,K))),O(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?B.attributeCheck=e.ADD_ATTR:De(e.ADD_ATTR)&&(I===L&&(I=N(I)),j(I,e.ADD_ATTR,K))),O(e,`ADD_FORBID_CONTENTS`)&&De(e.ADD_FORBID_CONTENTS)&&(Gt===Kt&&(Gt=N(Gt)),j(Gt,e.ADD_FORBID_CONTENTS,K)),Vt&&(M[`#text`]=!0),At&&j(M,[`html`,`head`,`body`]),M.table&&(j(M,[`tbody`]),delete z.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw He(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);let t=C;C=e.TRUSTED_TYPES_POLICY;try{w=ce(``)}catch(e){throw C=t,e}}else e.TRUSTED_TYPES_POLICY===null?(C=void 0,w=``):(C===void 0&&(C=ue()),C&&typeof w==`string`&&(w=ce(``)));T&&T(e),un=e},mn=j({},[...Je,...Ye,...Xe]),hn=j({},[...Ze,...Qe]),gn=function(e,t,n){return t.namespaceURI===W?e===`svg`:t.namespaceURI===Zt?e===`svg`&&(n===`annotation-xml`||rn[n]):!!mn[e]},_n=function(e,t,n){return t.namespaceURI===W?e===`math`:t.namespaceURI===Qt?e===`math`&&on[n]:!!hn[e]},vn=function(e,t,n){return t.namespaceURI===Qt&&!on[n]||t.namespaceURI===Zt&&!rn[n]?!1:!hn[e]&&(sn[e]||!mn[e])},yn=function(e){let t=re(e),n=je(te(e)),r=_(e),i,a;return r&&S(r)===F.element?(i={namespaceURI:re(r)},a=je(te(r))):(i={namespaceURI:G},a=`template`),en[t]?t===Qt?gn(n,i,a):t===Zt?_n(n,i,a):t===W?vn(n,i,a):!!(cn===`application/xhtml+xml`&&en[t]):!1},bn=function(e){we(t.removed,{element:e});try{_(e).removeChild(e)}catch{if(p(e),!_(e))throw He(`a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place`)}},xn=function(e,t,n){try{m(e,t)}catch{try{e.removeAttribute(n)}catch{}}},Sn=function(e){En(e);let t=g(e);t&&xe(Te(t),e=>{try{p(e)}catch{}});let n=S(e)===F.element?v(e):null;if(n)for(let t=n.length-1;t>=0;--t){let r=n[t],i=r&&r.name;typeof i==`string`&&xn(e,r,i)}},Cn=function(e,n,r){if(!r)try{r=n.getAttributeNode(e)}catch{r=null}we(t.removed,{attribute:r||null,from:n});try{r?m(n,r):n.removeAttribute(e)}catch{try{n.removeAttribute(e)}catch{}}if(e===`is`){if(Ft||It)try{bn(n)}catch{}else try{n.setAttribute(e,``)}catch{}}},wn=function(e){let t=v(e);if(t)for(let n=t.length-1;n>=0;--n){let r=t[n],i=r&&r.name;typeof i!=`string`||I[K(i)]||xn(e,r,i)}},Tn=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&&S(e)===F.element){let t=ee(e);Vn(t)&&r.push(t)}let i=g(e);if(i)for(let e=i.length-1;e>=0;--e)r.push(i[e])}},En=function(e){Tn(e,e=>{S(e)===F.element&&wn(e)})},Dn=function(e){let t=[];return Tn(e,e=>{t.push(e)},!0),t},On=function(e,t){let n=Oe();xe(Dn(e),e=>{S(e)===F.element&&ke(n,e)}),xe(t,e=>{S(e)===F.element&&!Ae(n,e)&&wn(e)})},kn=function(e,n){let r=!1;return xe(t.removed,t=>{t.element&&(r||=t.element===e,En(t.element))}),On(e,n),r},An=function(e,t){let n=Ut,r=null,i=()=>(r||(r=Oe(),xe(t,e=>{ke(r,e)})),r);for(let t=0;;t++){let r=Dn(e),a=[e],o=!1;if(xe(r,e=>{S(e)===F.documentFragment?we(a,e):!o&&!Ae(n,e)&&(o=Ae(i(),e))}),!o)return;if(t>=8)throw He(`the tree kept changing during in-place sanitization; refusing to return it`);xe(a,(t,n)=>{jn(t,n>0,e,i())})}},jn=function(e,t,n,r){let i=In(e),a;for(;a=i.nextNode();)Ae(r,a)&&!Ae(Ut,a)&&(t&&J(D.uponSanitizeShadowNode,a,null),qn(a,n),er(a,n),Vn(a.content)&&tr(a.content))},Mn=function(e){Ut&&ke(Ut,e)},Nn=function(e,t){return U?e===`patchsrc`||e===`for`&&t!==`label`&&t!==`output`:!1},Pn=function(e){U&&Tn(e,e=>{let t=S(e);if(t===F.processingInstruction||t===F.comment&&k(ht,e.data)){try{p(e)}catch{}return!1}if(t===F.element){let t=e,n=K(te(e));try{t.hasAttribute&&t.hasAttribute(`patchsrc`)&&t.removeAttribute(`patchsrc`),t.hasAttribute&&t.hasAttribute(`for`)&&Nn(`for`,n)&&t.removeAttribute(`for`)}catch{}}return!0})},Fn=function(e){let t=null,r=null;if(Pt)e=`<remove></remove>`+e;else{let t=Ne(e,/^[\r\n\t ]+/);r=t&&t[0]}cn===`application/xhtml+xml`&&G===W&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=C?ce(e):e;if(G===W)try{t=new l().parseFromString(i,cn)}catch{}if(!t||!t.documentElement){t=fe.createDocument(G,`template`,null);try{t.documentElement.innerHTML=$t?w:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),G===W?ge.call(t,At?`html`:`body`)[0]:At?t.documentElement:a},In=function(e){let t=x?x(e):e.ownerDocument;return me.call(t||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Ln=function(e){return e=Pe(e,ye,` `),e=Pe(e,be,` `),e=Pe(e,Le,` `),e},Rn=function(e){zn(e);let t=e.querySelectorAll?.call(e,`template`);t&&xe(t,e=>{Vn(e.content)&&Rn(e.content)})},zn=function(e){e.normalize();let t=x?x(e):e.ownerDocument,n=me.call(t||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null),r=n.nextNode();for(;r;)r.data=Ln(r.data),r=n.nextNode()},Bn=function(e){let t=b?b(e):null;return typeof t!=`string`||K(t)!==`form`?!1:typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||e.attributes!==v(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!==y(e)||e.childNodes!==g(e)},Vn=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return y(e)===F.documentFragment}catch{return!1}},q=function(e){if(!y||typeof e!=`object`||!e)return!1;try{return typeof y(e)==`number`}catch{return!1}};function J(e,n,r){e.length!==0&&xe(e,e=>{e.call(t,n,r,un)})}let Hn=function(e,t){return!!(U&&e.hasChildNodes()&&!q(e.firstElementChild)&&k(mt,e.textContent)&&k(mt,e.innerHTML)||U&&vt[t]&&S(e)===F.element&&re(e)===W&&(q(e.firstElementChild)||typeof e.textContent==`string`&&k(mt,e.textContent))||e.nodeType===F.processingInstruction||U&&e.nodeType===F.comment&&k(ht,e.data))},Un=function(e,t){return e instanceof RegExp?k(e,t):e instanceof Function&&!!e(t,...[...arguments].slice(2))},Wn=function(e,t,n){if(!z[t]&&Xn(t)&&Un(R.tagNameCheck,t))return!1;if(Vt&&!Gt[t]&&!Gt[je(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,h(e))}}}return bn(e),!0},Gn=function(e,t,n,r){return e.length===0?t:t===n||t===r?N(t):t},Kn=function(e,t){return e===t||_(e)!==null?!1:(Ht&&En(e),!0)},qn=function(e,n){if(Mn(e),J(D.beforeSanitizeElements,e,null),Kn(e,n))return!0;if(Bn(e))return bn(e),!0;let r=K(te(e));if(M=Gn(D.uponSanitizeElement,M,Tt,Mt),J(D.uponSanitizeElement,e,{tagName:r,allowedTags:M}),Kn(e,n))return!0;if(Hn(e,r))return bn(e),!0;if(z[r]||!(B.tagCheck instanceof Function&&B.tagCheck(r))&&!M[r]){let t=Wn(e,r,n);return t===!1&&(J(D.afterSanitizeElements,e,null),Kn(e,n))?!0:t}if(S(e)===F.element&&!yn(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&k(gt,e.innerHTML))return bn(e),!0;if(H&&e.nodeType===F.text){let n=Ln(e.textContent);e.textContent!==n&&(we(t.removed,{element:e.cloneNode()}),e.textContent=n)}return J(D.afterSanitizeElements,e,null),Kn(e,n)},Jn=function(e,t,r){if(Et[t]||Nn(t,e)||Rt&&(t===`id`||t===`name`)&&(r in n||r in dn))return!1;let i=I[t]||B.attributeCheck instanceof Function&&B.attributeCheck(t,e);return V&&k(Re,t)||Dt&&k(ze,t)?!0:i?Yt[t]||k(Ue,Pe(r,Ve,``))||(t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Fe(r,`data:`)===0&&qt[e]||Ot&&!k(Be,Pe(r,Ve,``))?!0:!r:Xn(e)&&Un(R.tagNameCheck,e)&&Un(R.attributeNameCheck,t,e)||t===`is`&&R.allowCustomizedBuiltInElements&&Un(R.tagNameCheck,r)},Yn=j({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Xn=function(e){return!Yn[je(e)]&&k(A,e)},Zn=function(e,t,n,r){if(C&&typeof u==`object`&&typeof u.getAttributeType==`function`&&!n)switch(u.getAttributeType(e,t)){case`TrustedHTML`:return ce(r);case`TrustedScriptURL`:return le(r)}return r},Qn=function(e,t,n,r){try{return n?e.setAttributeNS(n,t,r):e.setAttribute(t,r),!Bn(e)||(bn(e),!1)}catch{return Cn(t,e),!1}},$n=function(e,t){return U&&k(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,t)?!0:je(e)===`attributename`&&Ne(t,`href`)!==null},er=function(e,n){if(J(D.beforeSanitizeAttributes,e,null),Kn(e,n))return;let r=e.attributes;if(!r||Bn(e))return;I=Gn(D.uponSanitizeAttribute,I,L,Nt);let i={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:I,forceKeepAttr:void 0},a=r.length,o=K(e.nodeName);for(;a--;){let n=r[a],s=n.name,c=n.namespaceURI,l=n.value,u=K(s),d=l,f=s===`value`?d:Ie(d),p=!1;i.attrName=u,i.attrValue=f,i.keepAttr=!0,i.forceKeepAttr=void 0,J(D.uponSanitizeAttribute,e,i),f=i.attrValue,zt&&(u===`id`||u===`name`)&&Fe(f,Bt)!==0&&(Cn(s,e,n),f=Bt+f,p=!0),$n(s,f)?Cn(s,e,n):i.forceKeepAttr||(i.keepAttr?!kt&&k(_t,f)?Cn(s,e,n):(H&&(f=Ln(f)),Jn(o,u,f)?(f=Zn(o,u,c,f),f!==d&&Qn(e,s,c,f)&&p&&Ce(t.removed)):Cn(s,e,n)):Cn(s,e,n))}J(D.afterSanitizeAttributes,e,null),Kn(e,n)},tr=function(e){let t=null,n=In(e);for(J(D.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(J(D.uponSanitizeShadowNode,t,null),qn(t,e),er(t,e),Vn(t.content)&&tr(t.content),S(t)===F.element){let e=ee(t);Vn(e)&&(nr(e),tr(e))}H&&zn(e),J(D.afterSanitizeShadowDOM,e,null)},nr=function(e){let t=[{node:e,shadow:null}];for(;t.length>0;){let e=t.pop();if(e.shadow){tr(e.shadow);continue}let n=e.node,r=S(n)===F.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=b?b(n):null;if(typeof e==`string`&&K(e)===`template`){let e=n.content;Vn(e)&&t.push({node:e,shadow:null})}}if(r){let e=ee(n);Vn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,a=null,o=null,s=null;if($t=!e,$t&&(e=`<!-->`),typeof e!=`string`&&!q(e)&&(e=We(e),typeof e!=`string`))throw He(`dirty is not a string, aborting`);if(!t.isSupported)return e;jt?(M=Mt,I=Nt):pn(n),(D.uponSanitizeElement.length>0||D.uponSanitizeAttribute.length>0)&&(M=N(M)),D.uponSanitizeAttribute.length>0&&(I=N(I)),t.removed=[];let c=Ht&&typeof e!=`string`&&q(e),l=[],u=Ut;if(c){Pn(e);let t=te(e);if(typeof t==`string`){let n=K(t);if(!M[n]||z[n])throw Sn(e),He(`root node is forbidden and cannot be sanitized in-place`)}if(Bn(e))throw Sn(e),He(`root node is clobbered and cannot be sanitized in-place`);l=Dn(e),Ut=Oe()}else if(q(e))i=Fn(`<!---->`),a=i.ownerDocument.importNode(e,!0),a.nodeType===F.element&&a.nodeName===`BODY`||a.nodeName===`HTML`?i=a:i.appendChild(a),nr(i);else{if(!Ft&&!H&&!At&&e.indexOf(`<`)===-1)return C&&Lt?ce(e):e;if(i=Fn(e),!i)return Ft?null:Lt?w:``}i&&Pt&&bn(i.firstChild);let d=c?e:i;try{c&&nr(e);let t=In(d);for(;o=t.nextNode();)qn(o,d),er(o,d),Vn(o.content)&&tr(o.content);c&&An(e,l)}catch(t){throw c&&(Sn(e),kn(e,l)),t}finally{Ut=u}if(c){if(kn(e,l))throw He(`a node selected for removal could not be safely returned; refusing to sanitize in place`);return H&&Rn(e),e}if(Ft){if(H&&Rn(i),It)for(s=he.call(i.ownerDocument);i.firstChild;)s.appendChild(i.firstChild);else s=i;return(I.shadowroot||I.shadowrootmode)&&(s=_e.call(r,s,!0)),s}let f=At?i.outerHTML:i.innerHTML;return At&&M[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&k(ft,i.ownerDocument.doctype.name)&&(f=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
6
|
+
`+f),H&&(f=Ln(f)),C&&Lt?ce(f):f},t.setConfig=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};pn(e),jt=!0,Mt=M,Nt=I},t.clearConfig=function(){un=null,jt=!1,Mt=null,Nt=null,C=ie,w=``},t.isValidAttribute=function(e,t,n){un||pn({});let r=K(e),i=K(t);return typeof n==`string`&&($n(t,n)||!kt&&k(_t,n))?!1:Jn(r,i,n)},t.addHook=function(e,t){typeof t==`function`&&O(D,e)&&we(D[e],t)},t.removeHook=function(e,t){if(O(D,e)){if(t!==void 0){let n=Se(D[e],t);return n===-1?void 0:Ee(D[e],n,1)[0]}return Ce(D[e])}},t.removeHooks=function(e){O(D,e)&&(D[e]=[])},t.removeAllHooks=function(){D=xt()},t}var Tt=wt();function I(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var L=I();function R(e){L=e}var z={exec:()=>null};function Et(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 B(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(V.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var Dt=((e=``)=>{try{return!!RegExp(`(?<=1)(?<!1)`+e)}catch{return!1}})(),V={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]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+)[ \t]*)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,blockquoteMarkerWhitespace:/^( {0,3}>)([ \t]+)/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\][ \t]+\S/,listReplaceTask:/^\[[ xX]\][ \t]+/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,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:Et(e=>RegExp(`^ {0,${e}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`)),hrRegex:Et(e=>RegExp(`^ {0,${e}}((?:-[ ]*){3,}|(?:_[ ]*){3,}|(?:\\*[ ]*){3,})(?:\\n+|$)`)),fencesBeginRegex:Et(e=>RegExp(`^ {0,${e}}(?:\`\`\`|~~~)`)),headingBeginRegex:Et(e=>RegExp(`^ {0,${e}}#{1,6}(?:\\s|$)`)),pedanticHeadingBeginRegex:Et(e=>RegExp(`^ {0,${e}}#`)),htmlBeginRegex:Et(e=>RegExp(`^ {0,${e}}(?:</?(?:${Bt})(?: +|$|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`,`i`)),blockquoteBeginRegex:Et(e=>RegExp(`^ {0,${e}}>`)),nestedContainerMarkers:/^(?: {0,3}(?:(?:[*+-]|\d{1,9}[.)])[ \t]+|>[ \t]?))+/},Ot=/^(?:[ \t]*(?:\n|$))+/,kt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,H=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}(?:(?=`)\1`*|(?=~)\1~*) *(?=\n|$)|$)/,U=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,At=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,jt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Mt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |fences|blockquote|heading|hr|html|table))+?)\n {0,3}(=+|-+)[ \t]*(?:\n+|$)/,Nt=B(Mt).replace(/bull/g,jt).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),Pt=B(Mt).replace(/bull/g,jt).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(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Ft=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table|[ \t]+\n)[^\n]+)*)/,It=/^[^\n]+/,Lt=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\\n]|\n(?![ \t]*\n))+/,Rt=B(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,Lt).replace(`title`,/(?:"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\\n]|\n(?!\n))*'|\((?:\\[\s\S]|[^()\\])*\))/).getRegex(),zt=B(/^(bull)([ \t][^\n]*?)?(?:\n|$)/).replace(/bull/g,jt).getRegex(),Bt=`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`,Vt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ht=B(`^ {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]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</[a-z][a-z0-9-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Vt).replace(`tag`,Bt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Ut=e=>B(Ft).replace(`hr`,U).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`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex(),Wt=Ut(/ {0,3}(?:[*+-]|1[.)])[ \t]+[^ \t\n]/),Gt=Ut(/ {0,3}(?:[*+-]|\d{1,9}[.)])(?:[ \t]|\n|$)/),Kt={blockquote:B(/^( {0,3}> ?(?:(?![ \t]*(?:\n|$))(paragraph)|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Gt).getRegex(),code:kt,def:Rt,fences:H,heading:At,hr:U,html:Ht,lheading:Nt,list:zt,newline:Ot,paragraph:Wt,table:z,text:It},qt=B(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,U).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`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex(),Jt={...Kt,lheading:Pt,table:qt,paragraph:B(Ft).replace(`hr`,U).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,qt).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*(?:\\n|$))|~~~)[^\\n]*(?:\\n|$)").replace(`list`,` {0,3}(?:[*+-]|1[.)])[ \\t]+[^ \\t\\n]`).replace(`html`,` {0,3}(?:</?(?:tag)(?: +|\\n|/?>)|<(?:(?:script|pre|style|textarea)(?:[\\s>]|$)|!--)|<\\?|<![A-Za-z]|<!\\[CDATA\\[)`).replace(`tag`,Bt).getRegex()},Yt={...Kt,html:B(`^ *(?:comment(?: *\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1>(?: *\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?>(?: *\\n{2,}|\\s*$))`).replace(`comment`,Vt).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:z,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:B(Ft).replace(`hr`,U).replace(`heading`,` *#{1,6} *[^
|
|
7
|
+
]`).replace(`lheading`,Nt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},Xt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Zt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Qt=/^( {2,}|\\)\n(?!\s*$)[ \t]*/,W=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,G=/[\p{P}\p{S}]/u,$t=/[\s\p{P}\p{S}]/u,en=/[^\s\p{P}\p{S}]/u,tn=B(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,$t).getRegex(),nn=/[\p{Pi}\p{Ps}"']/u,rn=/(?!~)[\p{P}\p{S}]/u,an=/(?!~)[\s\p{P}\p{S}]/u,on=/(?:[^\s\p{P}\p{S}]|~)/u,sn=B(/link|precode-code|html/,`g`).replace(`link`,/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace(`precode-`,Dt?"(?<!`)()":"(^^|[^`])").replace(`code`,/(?<b>`+)[^`]+\k<b>(?!`)/).replace(`html`,/<(?! )[^<>]*?>/).getRegex(),cn=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ln=B(cn,`u`).replace(/punct/g,G).getRegex(),K=B(cn,`u`).replace(/punct/g,rn).getRegex(),un=B(/^(?:\*+(?:((?!\*)(?!openQuote)punct)|([^\s*]))?)|^_+(?:((?!_)(?!openQuote)punct)|([^\s_]))?/,`u`).replace(/openQuote/g,nn).replace(/punct/g,G).getRegex(),dn=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,fn=B(dn,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),pn=B(dn,`gu`).replace(/notPunctSpace/g,on).replace(/punctSpace/g,an).replace(/punct/g,rn).getRegex(),mn=B(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)[\\s](\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|(?:(?!\\*)punct|notPunctSpace)(\\*+)(?!\\*)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),hn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),gn=B(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)[\\s](_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)|(?:(?!_)punct|notPunctSpace)(_+)(?!_)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),_n=B(/^~~?(?:((?!~)punct)|[^\s~])/,`u`).replace(/punct/g,G).getRegex(),vn=B(`^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)`,`gu`).replace(/notPunctSpace/g,en).replace(/punctSpace/g,$t).replace(/punct/g,G).getRegex(),yn=B(/\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),bn=B(/(`+)(?:[^`]|[^`][\s\S]*?[^`])\1(?!`)|`+|\\(punct)/,`gu`).replace(/punct/g,G).getRegex(),xn=B(/^<(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(),Sn=B(Vt).replace(`(?:-->|$)`,`-->`).getRegex(),Cn=B(`^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`,Sn).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),wn=/\[(?:\\[\s\S]|[^\[\]\\])*\]/,Tn=B(/(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/).replace(`brackets`,wn).getRegex(),En=B(/^!?\[(label)\]\([ \t\n]*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?[ \t\n]*\)/).replace(`label`,Tn).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]+|(?=\))/).replace(`title`,/"(?:\\[\s\S]|[^"\\])*"|'(?:\\[\s\S]|[^'\\])*'|\((?:\\[\s\S]|[^)\\])*\)/).getRegex(),Dn=B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Tn).replace(`ref`,Lt).getRegex(),On=B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,Lt).getRegex(),kn=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\]){1,999}/,An=B(/(?:[^\[\]\\`]*(?:\[(?:brackets|\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\]))){0,999}?[^\[\]\\`]*?/).replace(`brackets`,wn).getRegex(),jn=B(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,B(/^!?\[(label)\]\[(ref)\]/).replace(`label`,An).replace(`ref`,kn).getRegex()).replace(`nolink`,B(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,kn).getRegex()).getRegex(),Mn=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Nn=B(/(?: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(),Pn={_backpedal:z,anyPunctuation:yn,anyPunctuationOutsideCode:bn,autolink:xn,blockSkip:sn,br:Qt,code:Zt,del:z,delLDelim:z,delRDelim:z,emStrongLDelim:ln,emStrongRDelimAst:fn,emStrongRDelimUnd:hn,escape:Xt,link:En,nolink:On,punctuation:tn,reflink:Dn,reflinkSearch:jn,tag:Cn,text:W,url:z},Fn={...Pn,emStrongLDelim:un,emStrongRDelimAst:mn,emStrongRDelimUnd:gn,link:B(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Tn).getRegex(),reflink:B(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Tn).getRegex()},In={...Pn,emStrongRDelimAst:pn,emStrongLDelim:K,delLDelim:_n,delRDelim:vn,url:B(/^emailProtocol|^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace(`emailProtocol`,Nn).replace(`protocol`,Mn).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:B(/^(?:[^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`,Mn).replace(/emailProtocol/g,/(?:mailto|xmpp):/).replace(`wwwStart`,Dt?`(?<![^\\s*_~(])www\\.`:`www\\.`).getRegex()},Ln={...In,br:B(Qt).replace(`{2,}`,`*`).getRegex(),text:B(In.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Rn={normal:Kt,gfm:Jt,pedantic:Yt},zn={normal:Pn,gfm:In,breaks:Ln,pedantic:Fn},Bn={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Vn=e=>Bn[e];function q(e,t){if(t){if(V.escapeTest.test(e))return e.replace(V.escapeReplace,Vn)}else if(V.escapeTestNoEncode.test(e))return e.replace(V.escapeReplaceNoEncode,Vn);return e}function J(e){return V.numericCharacterReference.test(e)?e.replace(V.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 Hn(e){try{e=encodeURI(e).replace(V.percentDecode,`%`)}catch{return null}return e}function Un(e,t){let n=e.replace(V.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(V.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(V.slashPipe,`|`);return n}function Wn(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 Gn(e){let t=e.split(`
|
|
8
8
|
`),n=t.length-1;for(;n>=0&&V.blankLine.test(t[n]);)n--;return t.length-n<=2?e:t.slice(0,n+1).join(`
|
|
9
|
-
`)}function
|
|
9
|
+
`)}function Kn(e){return e.trim().replace(V.multipleSpaceGlobal,` `).toLowerCase().toUpperCase().toLowerCase()}function qn(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 Jn=/* @__PURE__ */ new WeakMap;function Yn(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?`
|
|
10
10
|
`:e[i-1],s=i+1;for(;s<r&&e[s]===a;)s++;o!==` `&&o!==` `&&o!==`
|
|
11
|
-
`&&o!==`\r`&&o!==`\f`&&(a===`~`?n=i:t[a]=i),i=s-1}return{maskedSrc:e,lastPossibleEmStrongCloserIndex:t,lastPossibleDelCloserIndex:n}}function
|
|
11
|
+
`&&o!==`\r`&&o!==`\f`&&(a===`~`?n=i:t[a]=i),i=s-1}return{maskedSrc:e,lastPossibleEmStrongCloserIndex:t,lastPossibleDelCloserIndex:n}}function Xn(e,t){let n=Yn(t),r=Jn.get(e);r?r.push(n):Jn.set(e,[n])}function Zn(e){let t=Jn.get(e);t&&(t.pop(),t.length===0&&Jn.delete(e))}function Qn(e,t,n){let r=Jn.get(e)?.at(-1);return r&&r.maskedSrc===t?r.lastPossibleEmStrongCloserIndex[n]:Yn(t).lastPossibleEmStrongCloserIndex[n]}function $n(e,t){let n=Jn.get(e)?.at(-1);return n&&n.maskedSrc===t?n.lastPossibleDelCloserIndex:Yn(t).lastPossibleDelCloserIndex}function er(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 tr(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`),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 nr(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
12
12
|
`).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(`
|
|
13
|
-
`)}function
|
|
14
|
-
`),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:
|
|
15
|
-
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=
|
|
13
|
+
`)}function rr(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 ir=class{options;rules;lexer;constructor(e){this.options=e||L}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]:Gn(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=nr(e,t[3]||``,this.rules);return{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=Wn(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceTabChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:Wn(t[0],`
|
|
14
|
+
`),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:Wn(t[0],`
|
|
15
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=Wn(t[0],`
|
|
16
16
|
`).split(`
|
|
17
17
|
`),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(`
|
|
18
|
-
`),c=s.replace(this.rules.other.blockquoteMarkerWhitespace,(e,t,n)=>t
|
|
18
|
+
`),c=s.replace(this.rules.other.blockquoteMarkerWhitespace,(e,t,n)=>t+er(n,t.length)).replace(this.rules.other.blockquoteSetextReplace,`
|
|
19
19
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
20
20
|
${s}`:s,r=r?`${r}
|
|
21
21
|
${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(c,i,!0),this.lexer.state.top=l,e.length===0)break;let u=i.at(-1);if(u?.type===`code`||u?.type===`heading`||u?.type===`hr`||u?.type===`html`||u?.type===`table`)break;if(u?.type===`blockquote`){let t=u,a=e.join(`
|
|
@@ -30,17 +30,17 @@ ${d.join(`
|
|
|
30
30
|
`);n=`${n}
|
|
31
31
|
${t}`,r=`${r}
|
|
32
32
|
${t}`}e=e.slice(s)}}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(`
|
|
33
|
-
`,1)[0],d=t[1].length,f=this.options.pedantic
|
|
33
|
+
`,1)[0],d=t[1].length,f=this.options.pedantic?er(u,d):u.replace(this.rules.other.leadingSpaceTab,e=>er(e,d)),p=e.split(`
|
|
34
34
|
`,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(`
|
|
35
|
-
`,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
|
|
35
|
+
`,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=>er(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+=`
|
|
36
36
|
`+u.slice(h),c=!1;else{if(m||f.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||r.test(f)||i.test(f)||o.test(f)||n.test(f))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 e=!this.options.pedantic&&/^ {0,3}(?:=+|-+) *$/.test(p)&&this.rules.block.lheading.test(`${f}
|
|
37
37
|
${p}`)?` ${u.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
38
|
-
`+e,c=!0}m=!p.trim(),e=e.substring(l.length+1),f=u.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,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();for(let e of o.items)if(this.lexer.state.top=!1,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 of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.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){let e=
|
|
39
|
-
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=
|
|
40
|
-
`):[],a={type:`table`,raw:
|
|
41
|
-
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)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<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(
|
|
38
|
+
`+e,c=!0}m=!p.trim(),e=e.substring(l.length+1),f=u.slice(h)}}let g=n.slice(l,r());o.loose||(c?o.loose=!0:this.rules.other.doubleBlankLine.test(g)&&(c=!0)),o.items.push({type:`list_item`,raw:g,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();for(let e of o.items)if(this.lexer.state.top=!1,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 of o.items){let t=e.tokens[0];if(e.task&&(t?.type===`text`||t?.type===`paragraph`)){e.text=e.text.replace(this.rules.other.listReplaceTask,``),t.raw=t.raw.replace(this.rules.other.listReplaceTask,``),t.text=t.text.replace(this.rules.other.listReplaceTask,``);for(let e=this.lexer.inlineQueue.length-1;e>=0;e--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[e].src)){this.lexer.inlineQueue[e].src=this.lexer.inlineQueue[e].src.replace(this.rules.other.listReplaceTask,``);break}let n=this.rules.other.listTaskCheckbox.exec(e.raw);if(n){let t={type:`checkbox`,raw:n[0]+` `,checked:n[0]!==`[ ]`};e.checked=t.checked,o.loose?e.tokens[0]&&[`paragraph`,`text`].includes(e.tokens[0].type)&&`tokens`in e.tokens[0]&&e.tokens[0].tokens?(e.tokens[0].raw=t.raw+e.tokens[0].raw,e.tokens[0].text=t.raw+e.tokens[0].text,e.tokens[0].tokens.unshift(t)):e.tokens.unshift({type:`paragraph`,raw:t.raw,text:t.raw,tokens:[t]}):e.tokens.unshift(t)}}else e.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){let e=Gn(t[0]);return{type:`html`,block:!0,raw:e,pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:e}}}def(e){let t=this.rules.block.def.exec(e);if(t){if(!this.rules.other.startAngleBracket.test(t[2])&&qn(t[2],`()`)!==-1)return;let e=Kn(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:Wn(t[0],`
|
|
39
|
+
`),href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=Un(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
40
|
+
`):[],a={type:`table`,raw:Wn(t[0],`
|
|
41
|
+
`),header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)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<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(Un(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:Wn(t[0],`
|
|
42
42
|
`),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)===`
|
|
43
|
-
`?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)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){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=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&
|
|
43
|
+
`?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)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){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=this.rules.inline.link.exec(e);if(t){let n=t[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&rr(e,t[1],n,this.rules))return;let r=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(r)){if(!this.rules.other.endAngleBracket.test(r))return;let e=Wn(r.slice(0,-1),`\\`);if((r.length-e.length)%2==0)return}else{let e=qn(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let i=Wn(t[0].slice(0,-1),`\\`);if((t[0].length-i.length)%2==0)return;let a=t[2],o=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(a);e&&(a=e[1],o=e[3])}else o=t[3]?t[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)),tr(t,{href:a&&a.replace(this.rules.inline.anyPunctuation,`$1`),title:o&&o.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let r=n[0].charAt(0)===`!`?2:1;if(!this.options.pedantic&&rr(e,n[1],r,this.rules))return;let i=t[Kn(n[2]||n[1])];if(!i){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return tr(n,i,n[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,g=!this.options.pedantic&&!!c.trim()&&(!!d||i===`*`&&!l);if(i!==`*`&&i!==`_`)return;let _=i===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd,ee=Qn(this,t,i),v=t.length-e.length+n;if(ee<v)return;t=t.slice(-1*e.length+n);let y=ee-v;for(_.lastIndex=0;(r=_.exec(t))!==null&&!(r.index>y);){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]||g){if(a&&(r[5]||r[6]))break;if(h%3&&!((h+f)%3)){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){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=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e,t,n=``){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=$n(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){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]:J(t[0]),escaped:e}}}},Y=class e{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||L,this.options.tokenizer=this.options.tokenizer||new ir,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};let t={other:V,block:Rn.normal,inline:zn.normal};this.options.pedantic?(t.block=Rn.pedantic,t.inline=zn.pedantic):this.options.gfm&&(t.block=Rn.gfm,t.inline=this.options.breaks?zn.breaks:zn.gfm),this.tokenizer.rules=t}static get rules(){return{block:Rn,inline:zn}}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(V.carriageReturn,`
|
|
44
44
|
`),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(V.tabCharGlobal,` `).replace(V.spaceLine,``));let i=1/0;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+=`
|
|
45
45
|
`: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(`
|
|
46
46
|
`)?``:`
|
|
@@ -54,9 +54,9 @@ ${p}`)?` ${u.replace(/^ {0,3}/,``)}`:p;a+=`
|
|
|
54
54
|
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):t.push(r),n=a.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(`
|
|
55
55
|
`)?``:`
|
|
56
56
|
`)+r.raw,n.text+=`
|
|
57
|
-
`+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,
|
|
58
|
-
`:``;return r?`<pre><code class="language-`+
|
|
59
|
-
`:`<pre><code>`+(n?i:
|
|
57
|
+
`+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,Kn(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=n&&e.includes(`)`);try{return this.#e(e,t)}finally{this.state.linkParenPossible=n}}#e(e,t){let n=e.includes(`*`)||e.includes(`_`)||e.includes(`~`)||this.options.hooks?.emStrongMask||this.tokenizer.emStrong!==ir.prototype.emStrong||this.tokenizer.del!==ir.prototype.del?this.#r(e):e;Xn(this.tokenizer,n);try{return this.#t(e,n,t)}finally{Zn(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}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 s=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&&(s=e.substring(0,t+1))}if(o=this.tokenizer.inlineText(s)){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,Kn(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)}},ar=class{options;parser;constructor(e){this.options=e||L}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(V.notSpaceStart)?.[0],i=e?e.replace(V.endingNewline,``)+`
|
|
58
|
+
`:``;return r?`<pre><code class="language-`+q(r)+`">`+(n?i:q(i,!0))+`</code></pre>
|
|
59
|
+
`:`<pre><code>`+(n?i:q(i,!0))+`</code></pre>
|
|
60
60
|
`}blockquote({tokens:e}){return`<blockquote>
|
|
61
61
|
${this.parser.parse(e)}</blockquote>
|
|
62
62
|
`}html({text:e}){return e}def(e){return``}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
@@ -72,9 +72,9 @@ ${this.parser.parse(e)}</blockquote>
|
|
|
72
72
|
`}tablerow({text:e}){return`<tr>
|
|
73
73
|
${e}</tr>
|
|
74
74
|
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
75
|
-
`}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>${
|
|
76
|
-
`}checkbox({raw:e}){return e}},
|
|
77
|
-
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+J(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},lr=new cr;function Q(e,t){return lr.parse(e,t)}Q.options=Q.setOptions=function(e){return lr.setOptions(e),Q.defaults=lr.defaults,R(Q.defaults),Q},Q.getDefaults=I,Q.defaults=L;function ur(...e){return lr.use(...e),Q.defaults=lr.defaults,R(Q.defaults),Q}Q.use=ur,Q.walkTokens=function(e,t){return lr.walkTokens(e,t)},Q.parseInline=lr.parseInline,Q.Parser=Z,Q.parser=Z.parse,Q.Renderer=ir,Q.TextRenderer=ar,Q.Lexer=X,Q.lexer=X.lex,Q.Tokenizer=rr,Q.Hooks=or,Q.parse=Q,Q.options,Q.setOptions,Q.walkTokens,Q.parseInline,Z.parse,X.lex;var dr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},fr=e=>e.replace(/[&<>"']/g,e=>dr[e]),pr=new cr({gfm:!0,breaks:!0,async:!1,renderer:{html:({text:e})=>fr(e),image:({href:e,text:t})=>`<a href="${fr(e)}">${fr(t||e)}</a>`}}),mr=null;function hr(){return mr||(mr=Tt(window),mr.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer nofollow`))}),mr)}function gr(e){let t=pr.parse(e);return hr().sanitize(t,{FORBID_TAGS:[`img`,`style`,`form`,`input`,`button`,`textarea`],FORBID_ATTR:[`style`]})}var _r;function vr(){if(_r!==void 0)return _r;let e=globalThis.trustedTypes;try{_r=e?.createPolicy(`aicore-agent-chat`,{createHTML:e=>e})??null}catch{_r=null}return _r}function yr(e,t){let n=t?gr(t):``,r=vr();e.innerHTML=r?r.createHTML(n):n}var br=`change`,xr=5,Sr=1,Cr=50,wr=1500,Tr=60,Er={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},Dr=(e,t)=>[t,...e].slice(0,Cr),Or=e=>typeof e?.rating==`number`?e.rating:null;function kr(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:Or(e.feedback),interrupted:!1})}var Ar=class extends EventTarget{client;#e=Er;#t=0;#n=null;#r=0;#i=null;constructor(e){super(),this.client=new ie({...e,onRequest:e=>this.#a(t=>({requests:Dr(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(br))}#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:kr(n)})}),t===this.#t&&this.#o({loadingHistory:!1})}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<Tr;i++){if(await new Promise(e=>setTimeout(e,wr)),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){let{agentId:t,activeId:n,files:r,uploading:a}=this.#e,o=e.trim();if(!t||this.busy||!o||a>0||r.some(e=>e.status===`processing`))return;let s=r.filter(e=>e.status===`ready`),c=this.#t,l=new AbortController;this.#n=l,this.#a(e=>({error:null,files:[],turn:_,turnStartedAt:Date.now(),events:[],tokens:0,messages:[...e.messages,{role:`user`,text:o,attachments:s.map(({id_file:e,name:t,mime:n,size:r})=>({id_file:e,name:t,mime:n,size:r}))}]}));let u=()=>c===this.#t&&!l.signal.aborted;try{let e=await this.client.ask({idAgent:t,idConv:n,request:{text:o,...s.length>0?{attachments:s.map(e=>({id_file:e.id_file}))}:{}},signal:l.signal,onConversation:e=>{c===this.#t&&this.#o({activeId:e})},onUpdate:(e,t)=>{u()&&this.#a(n=>t.kind===`token`?{turn:e,tokens:n.tokens+1}:{turn:e,events:Dr(n.events,{at:Date.now(),kind:t.kind,id:t.id,data:t.data})})}});if(c!==this.#t)return;this.#a(t=>({turn:null,messages:[...t.messages,{role:`assistant`,text:y(e.turn),sources:e.turn.sources,idQuery:e.idQuery,error:e.turn.error,rating:null,interrupted:!e.turn.finished}]})),(n===null||e.turn.title)&&await this.refreshConversations()}catch(e){u()?this.#o({error:i(e)}):c===this.#t&&this.#a(e=>({messages:[...e.messages,{role:`assistant`,text:``,sources:[],idQuery:null,error:null,rating:null,interrupted:!0}]}))}finally{this.#n===l&&(this.#n=null),c===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++}},jr={locale:`it-IT`,conversations:`Conversazioni`,newConversation:`Nuova conversazione`,noConversations:`Ancora nessuna conversazione.`,conversationsFailed:`Impossibile leggere le conversazioni.`,loading:`Caricamento…`,untitled:`Senza titolo`,disabled:`disabilitata`,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`,none:`—`},Mr={locale:`en-GB`,conversations:`Conversations`,newConversation:`New conversation`,noConversations:`No conversations yet.`,conversationsFailed:`Could not read the conversations.`,loading:`Loading…`,untitled:`Untitled`,disabled:`disabled`,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`,none:`—`};function Nr(e){let t=e?.trim().toLowerCase()??``;return t===``||t.startsWith(`it`)?jr:Mr}function Pr(e,t){let n=Nr(e);return t?{...n,...t,errors:{...n.errors,...t.errors}}:n}var Fr={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`},Ir=`http://www.w3.org/2000/svg`;function Lr(e){let t=document.createElementNS(Ir,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(Ir,`path`);return n.setAttribute(`d`,Fr[e]),n.setAttribute(`fill`,`currentColor`),t.append(n),t}var Rr=`
|
|
75
|
+
`}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>${q(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?q(n,!0):this.parser.parseInline(r),o=Hn(e);if(o===null)return a;e=q(o,i);let s=`<a href="`+e+`"`;return t&&(s+=` title="`+q(t)+`"`),s+=`>`+a+`</a>`,s}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Hn(e);if(i===null)return q(n);e=i;let a=`<img src="${q(e)}" alt="${q(n)}"`;return t&&(a+=` title="${q(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:q(e.text)}},or=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`
|
|
76
|
+
`}checkbox({raw:e}){return e}},X=class e{options;renderer;textRenderer;constructor(e){this.options=e||L,this.options.renderer=this.options.renderer||new ar,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new or,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];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[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 i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.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];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[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 a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.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 n}},sr=class{options;block;constructor(e){this.options=e||L}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?Y.lex:Y.lexInline}provideParser(e=this.block){return e?X.parse:X.parseInline}};function cr(e,t){if(Array.isArray(t))for(let n=0;n<t.length;n++)e.push(t[n]);else e.push(t)}var lr=class{defaults=I();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=X;Renderer=ar;TextRenderer=or;Lexer=Y;Tokenizer=ir;Hooks=sr;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(cr(n,t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)cr(n,this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)cr(n,this.walkTokens(e.tokens,t));break}case`list`:{let e=r;cr(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=>{let i=e[r].flat(1/0);cr(n,this.walkTokens(i,t))}):e.tokens&&cr(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 ar(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 ir(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 sr;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]=sr.passThroughHooks.has(n)?e=>{if(t.options.async&&sr.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 cr(n,r.call(this,e)),t&&cr(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 Y.lex(e,t??this.defaults)}parser(e,t){return X.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?Y.lex:Y.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?X.parse:X.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?Y.lex:Y.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?X.parse:X.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+=`
|
|
77
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+q(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},ur=new lr;function Z(e,t){return ur.parse(e,t)}Z.options=Z.setOptions=function(e){return ur.setOptions(e),Z.defaults=ur.defaults,R(Z.defaults),Z},Z.getDefaults=I,Z.defaults=L;function dr(...e){return ur.use(...e),Z.defaults=ur.defaults,R(Z.defaults),Z}Z.use=dr,Z.walkTokens=function(e,t){return ur.walkTokens(e,t)},Z.parseInline=ur.parseInline,Z.Parser=X,Z.parser=X.parse,Z.Renderer=ar,Z.TextRenderer=or,Z.Lexer=Y,Z.lexer=Y.lex,Z.Tokenizer=ir,Z.Hooks=sr,Z.parse=Z,Z.options,Z.setOptions,Z.walkTokens,Z.parseInline,X.parse,Y.lex;var fr={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},pr=e=>e.replace(/[&<>"']/g,e=>fr[e]),mr=new lr({gfm:!0,breaks:!0,async:!1,renderer:{html:({text:e})=>pr(e),image:({href:e,text:t})=>`<a href="${pr(e)}">${pr(t||e)}</a>`}}),hr=null;function gr(){return hr||(hr=Tt(window),hr.addHook(`afterSanitizeAttributes`,e=>{e.tagName===`A`&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer nofollow`))}),hr)}function _r(e){let t=mr.parse(e);return gr().sanitize(t,{FORBID_TAGS:[`img`,`style`,`form`,`input`,`button`,`textarea`],FORBID_ATTR:[`style`]})}var vr;function yr(){if(vr!==void 0)return vr;let e=globalThis.trustedTypes;try{vr=e?.createPolicy(`aicore-agent-chat`,{createHTML:e=>e})??null}catch{vr=null}return vr}function br(e,t){let n=t?_r(t):``,r=yr();e.innerHTML=r?r.createHTML(n):n}var xr=`change`,Sr=5,Cr=1,wr=50,Tr=1500,Er=60,Dr={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},Or=(e,t)=>[t,...e].slice(0,wr),kr=e=>typeof e?.rating==`number`?e.rating:null;function Ar(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:kr(e.feedback),interrupted:!1})}var jr=class extends EventTarget{client;#e=Dr;#t=0;#n=null;#r=0;#i=null;constructor(e){super(),this.client=new ie({...e,onRequest:e=>this.#a(t=>({requests:Or(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(xr))}#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:Ar(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<Er;i++){if(await new Promise(e=>setTimeout(e,Tr)),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:_,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:Or(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:y(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++}},Mr={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:`—`},Nr={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:`—`};function Pr(e){let t=e?.trim().toLowerCase()??``;return t===``||t.startsWith(`it`)?Mr:Nr}function Fr(e,t){let n=Pr(e);return t?{...n,...t,errors:{...n.errors,...t.errors}}:n}var Ir={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`},Lr=`http://www.w3.org/2000/svg`;function Rr(e){let t=document.createElementNS(Lr,`svg`);t.setAttribute(`viewBox`,`0 0 24 24`),t.setAttribute(`aria-hidden`,`true`),t.setAttribute(`focusable`,`false`);let n=document.createElementNS(Lr,`path`);return n.setAttribute(`d`,Ir[e]),n.setAttribute(`fill`,`currentColor`),t.append(n),t}var zr=`
|
|
78
78
|
:host {
|
|
79
79
|
--_bg: var(--aicore-chat-surface, rgb(var(--magma-surface-default, 255 255 255)));
|
|
80
80
|
--_raised: var(--aicore-chat-surface-muted, rgb(var(--magma-surface-muted, 245 245 247)));
|
|
@@ -240,6 +240,27 @@ button:focus-visible, summary:focus-visible {
|
|
|
240
240
|
}
|
|
241
241
|
.conversation.active .title { font-weight: 600; }
|
|
242
242
|
.conversation .meta { color: var(--_muted); font-size: calc(var(--_fs) * 12 / 15); }
|
|
243
|
+
.conversation .rename {
|
|
244
|
+
display: flex;
|
|
245
|
+
flex: 1;
|
|
246
|
+
align-items: center;
|
|
247
|
+
gap: 2px;
|
|
248
|
+
min-inline-size: 0;
|
|
249
|
+
padding-block: 4px;
|
|
250
|
+
}
|
|
251
|
+
.rename input {
|
|
252
|
+
flex: 1;
|
|
253
|
+
min-inline-size: 0;
|
|
254
|
+
padding: 4px 8px;
|
|
255
|
+
border: 1px solid var(--_border);
|
|
256
|
+
border-radius: var(--_radius-sm);
|
|
257
|
+
outline: none;
|
|
258
|
+
background: var(--_bg);
|
|
259
|
+
color: inherit;
|
|
260
|
+
font: inherit;
|
|
261
|
+
font-size: calc(var(--_fs) * 14 / 15);
|
|
262
|
+
}
|
|
263
|
+
.rename input:focus { border-color: var(--_accent); box-shadow: 0 0 0 1px var(--_accent); }
|
|
243
264
|
|
|
244
265
|
/* ---- header and banner ------------------------------------------------- */
|
|
245
266
|
|
|
@@ -466,5 +487,5 @@ textarea {
|
|
|
466
487
|
.log { margin: 0; padding: 0; list-style: none; font-family: var(--_mono); }
|
|
467
488
|
.log li { padding-block: 1px; overflow-wrap: anywhere; }
|
|
468
489
|
.log .bad { color: var(--_danger); }
|
|
469
|
-
`,zr=`aicore-agent-chat`,Br=`.pdf,.docx,.txt,.md,.html,.xlsx,.epub`,Vr=[x.turn,x.error,x.authRequired,x.tenantRefused],Hr=160,Ur=100,Wr=48,Gr=4e3,Kr=[`getToken`,`strings`,`baseUrl`,`agent`,`tenant`,`conversation`,`developer`],qr=typeof HTMLElement>`u`?class{}:HTMLElement,Jr;function Yr(){if(Jr!==void 0)return Jr;try{let e=new CSSStyleSheet;e.replaceSync(Rr),Jr=`adoptedStyleSheets`in ShadowRoot.prototype?e:null}catch{Jr=null}return Jr}var Xr=()=>typeof navigator<`u`&&navigator.clipboard!==void 0;function $(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 Zr(e,t,n={},r=``){return $(`button`,{class:`icon-button ${r}`.trim(),attrs:{type:`button`,"aria-label":t,title:t,...n}},Lr(e))}function Qr(e){return e&&/^https?:\/\//i.test(e)?e:null}function $r(e,t){return t.title??t.name??t.url??t.id_document??e.untitledSource}function ei(e,t){return t.page==null?t.part==null?``:e.part(t.part):e.page(String(t.page))}function ti(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>Hr&&(a=`${a.slice(0,Hr)}…`),[r,t.kind,t.id?`#${t.id}`:``,a].filter(Boolean).join(` `)}function ni(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 ri(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 ii=class extends qr{static observedAttributes=[`base-url`,`agent`,`tenant`,`conversation`,`lang`,`developer`];#e=null;#t=null;#n=null;#r=null;#i=null;#a=``;#o=null;#s=!1;#c=!0;#l=null;#u=!1;#d=[];#f=null;#p=0;#m=!1;#h=null;#g=!1;#_=!1;#v=!1;#y=!1;#b=!0;#x;constructor(){super();let e=this.attachShadow({mode:`open`}),t=$(`button`,{class:`new-conversation`,attrs:{type:`button`,"data-action":`new`}}),n=$(`p`,{class:`rail-status muted small`}),r=$(`ul`,{class:`conversations`}),i=$(`aside`,{class:`rail`,part:`rail`},t,n,r),a=Zr(`menu`,``,{"data-action":`toggle-rail`});a.classList.add(`rail-toggle`);let o=$(`span`,{class:`agent-name`}),s=$(`span`,{class:`agent-description`}),c=$(`header`,{class:`header`,part:`header`},a,$(`div`,{class:`agent`},o,s)),l=$(`strong`),u=$(`span`,{class:`small`}),d=Zr(`close`,``,{"data-action":`dismiss`}),f=$(`div`,{class:`banner`,part:`error`,attrs:{role:`alert`}},$(`div`,{class:`banner-text`},l,u),d);f.hidden=!0;let p=$(`p`,{class:`empty-title`}),m=$(`div`,{class:`empty`},p),h=$(`p`,{class:`status`}),g=$(`div`,{class:`messages`}),_=$(`div`,{class:`answer markdown`}),ee=$(`span`),v=$(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-busy":`true`}},_,$(`div`,{class:`status`},$(`span`,{class:`dots`},$(`span`),$(`span`),$(`span`)),ee));v.hidden=!0;let y=$(`div`,{class:`thread`,attrs:{role:`log`,"aria-live":`polite`}},m,h,g,v);g.style.display=`contents`;let b=$(`div`,{class:`transcript`,part:`transcript`},y),x=$(`ul`,{class:`chips`}),S=$(`input`,{attrs:{type:`file`,multiple:``,accept:Br}});S.hidden=!0;let te=Zr(`attach`,``,{"data-action":`attach`}),ne=$(`textarea`,{part:`input`,attrs:{rows:`1`}}),re=$(`button`,{class:`send`,part:`send`,attrs:{type:`submit`}},Lr(`send`)),C=$(`button`,{class:`send`,part:`stop`,attrs:{type:`button`,"data-action":`stop`}},Lr(`stop`)),w=$(`p`,{class:`footnote`}),ie=$(`form`,{class:`composer`,part:`composer`},x,$(`div`,{class:`box`},te,ne,re,C),w,S),ae=$(`summary`),oe=$(`div`),se=$(`details`,{class:`developer`,part:`developer`},ae,oe),ce=$(`div`,{class:`layout`},i,$(`section`,{class:`main`},c,f,b,ie,se)),le=Yr();le?e.adoptedStyleSheets=[le]:e.append($(`style`,{text:Rr})),e.append(ce),this.#x={layout:ce,rail:i,newButton:t,railStatus:n,conversations:r,railToggle:a,agentName:o,agentDescription:s,banner:f,bannerTitle:l,bannerDetail:u,dismiss:d,transcript:b,thread:y,empty:m,emptyTitle:p,loading:h,messages:g,live:v,liveAnswer:_,liveActivity:ee,files:x,fileInput:S,attach:te,input:ne,send:re,stop:C,footnote:w,developer:se,developerSummary:ae,developerBody:oe},e.addEventListener(`click`,e=>this.#k(e)),y.addEventListener(`toggle`,e=>this.#M(e),!0),ie.addEventListener(`submit`,e=>{e.preventDefault(),this.#N()}),ne.addEventListener(`input`,()=>this.#Z()),ne.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),this.#N())}),S.addEventListener(`change`,()=>{let e=Array.from(S.files??[]);S.value=``,e.length>0&&this.#i?.attach(e)}),b.addEventListener(`scroll`,()=>{this.#b=b.scrollHeight-b.scrollTop-b.clientHeight<Wr},{passive:!0}),typeof ResizeObserver<`u`&&new ResizeObserver(()=>{this.#b&&(b.scrollTop=b.scrollHeight)}).observe(b)}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.#i&&(this.#i.client.clearToken(),this.#i.client.checkIdentity()),this.#C()}get strings(){return this.#t}set strings(t){this.#t=e(t)?t:null,this.#I(!0)}get baseUrl(){return this.getAttribute(`base-url`)}set baseUrl(e){this.#S(`base-url`,e)}get agent(){return this.getAttribute(`agent`)}set agent(e){this.#S(`agent`,e)}get tenant(){return this.getAttribute(`tenant`)}set tenant(e){this.#S(`tenant`,e)}get conversation(){return this.getAttribute(`conversation`)}set conversation(e){this.#S(`conversation`,e)}get developer(){return this.hasAttribute(`developer`)}set developer(e){this.toggleAttribute(`developer`,!!e)}get state(){return this.#i?.state??null}#S(e,t){t==null||t===``?this.removeAttribute(e):this.setAttribute(e,String(t))}connectedCallback(){let e=this;for(let t of Kr)if(Object.prototype.hasOwnProperty.call(this,t)){let n=e[t];delete e[t],e[t]=n}this.#C(),this.#I(!0)}disconnectedCallback(){queueMicrotask(()=>{this.isConnected||this.#w()})}attributeChangedCallback(e,t,n){if(t!==n)switch(e){case`base-url`:case`tenant`:this.#C();break;case`agent`:this.#T(`agent`);break;case`conversation`:this.#T(`conversation`);break;default:this.#I(!0)}}#C(){if(!this.isConnected)return;let e=this.getAttribute(`base-url`),t=this.getAttribute(`tenant`),n=e&&this.#e?`${e}\n${t??``}`:``;if(n!==this.#a){if(this.#w(),this.#a=n,e&&n){let n=new Ar({baseUrl:e,tenant:t,getToken:async e=>this.#e?this.#e(e):null});for(let e of Vr)n.client.addEventListener(e,this.#D);n.addEventListener(br,this.#O),this.#i=n,n.setAgent(this.getAttribute(`agent`)),this.#E()}this.#I(!0)}}#w(){let e=this.#i;if(e){for(let t of Vr)e.client.removeEventListener(t,this.#D);e.removeEventListener(br,this.#O),e.dispose()}this.#i=null,this.#a=``,this.#o=null}#T(e){e===`agent`?this.#g=!0:this.#_=!0,this.#v||(this.#v=!0,queueMicrotask(()=>{let e=this.#g,t=this.#_;this.#v=this.#g=this.#_=!1;let n=this.#i;if(n){if(e){this.#y=!1;let e=this.getAttribute(`agent`);n.setAgent(e===``?null:e),t&&this.#E()}else this.#E()}}))}#E(){let e=this.#i;if(!e)return;let t=this.getAttribute(`conversation`);t?e.open(t):e.state.activeId&&!e.busy&&e.newConversation()}#D=e=>{this.dispatchEvent(new CustomEvent(e.type,{detail:e.detail,bubbles:!0,composed:!0}))};#O=()=>{let e=this.#i?.state;e?.agentId&&e.activeId!==this.#o&&(this.#o=e.activeId,this.dispatchEvent(new CustomEvent(x.conversation,{detail:{idConv:e.activeId,idAgent:e.agentId},bubbles:!0,composed:!0}))),this.#I()};#k(e){let t=e.target?.closest(`[data-action]`);this.#y&&!e.target?.closest(`.rail, .rail-toggle`)&&(this.#y=!1,this.#x.layout.classList.remove(`rail-open`));let{id:n}=t?.dataset??{};if(this.#n!==null&&(t?.dataset.action!==`delete`||n!==this.#n)&&this.#A(null),!t||t.disabled)return;let r=this.#i;switch(t.dataset.action){case`new`:this.#y=!1,r?.newConversation(),this.#x.input.focus();break;case`open`:this.#y=!1,this.#b=!0,n&&r?.open(n);break;case`delete`:if(!n)break;this.#n===n?(this.#A(null),r?.remove(n)):this.#A(n);break;case`toggle-rail`:this.#y=!this.#y;break;case`dismiss`:r?.dismissError();break;case`attach`:this.#x.fileInput.click();break;case`detach`:n&&r?.detach(n);break;case`stop`:r?.stop();break;case`copy`:this.#j(t,Number(t.dataset.index));break;case`rate`:t.dataset.query&&r?.rate(t.dataset.query,Number(t.dataset.rating))}this.#x.layout.classList.toggle(`rail-open`,this.#y)}#A(e){if(this.#r!==null&&clearTimeout(this.#r),this.#r=e===null?null:setTimeout(()=>this.#A(null),Gr),this.#n!==e&&(this.#n=e,this.#z(this.#F(),this.#i?.state??null,this.#i?.busy??!1),e!==null))for(let t of this.#x.conversations.querySelectorAll(`[data-action="delete"]`))t.dataset.id===e&&t.focus()}#j(e,t){let n=this.#i?.state.messages[t];if(!n||!navigator.clipboard)return;let r=this.#F();navigator.clipboard.writeText(n.text).then(()=>{e.replaceChildren(Lr(`check`)),e.setAttribute(`aria-label`,r.copied),setTimeout(()=>{e.replaceChildren(Lr(`copy`)),e.setAttribute(`aria-label`,r.copy)},1500)})}#M(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.#i?.state.messages[Number(n)],o=a?.role===`assistant`?a.sources[Number(r)]:void 0;if(!o)return;yr(i,o.text??``);let s=Qr(o.url);s&&i.append($(`a`,{text:s,attrs:{href:s,target:`_blank`,rel:`noopener noreferrer`}}))}#N(){let e=this.#i,t=this.#x.input.value.trim();e&&t&&!this.#x.send.disabled&&(this.#x.input.value=``,this.#b=!0,e.send(t),this.#Z())}#P(){return this.closest(`[lang]`)?.getAttribute(`lang`)??(typeof document>`u`?null:document.documentElement.lang)}#F(){return Pr(this.#P(),this.#t)}#I(e=!1){if(e&&(this.#c=!0),this.#s)return;this.#s=!0;let t=()=>{this.#s=!1,this.#L()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,16)}#L(){let e=this.#F(),t=this.#i?.state??null,n=this.#i?.busy??!1,r=this.#c?null:this.#l,i=n!==this.#u||r===null;this.#c=!1,this.#l=t,this.#u=n;let a=(...e)=>r===null||t===null||e.some(e=>r[e]!==t[e]);r===null&&this.#R(e),(i||a(`conversations`,`activeId`,`conversationsLoading`,`conversationsFailed`,`agentId`))&&this.#z(e,t,n),a(`agent`,`agentId`)&&this.#H(e,t),a(`error`)&&this.#U(e,t),a(`messages`,`loadingHistory`,`agent`)&&this.#W(e,t,r===null||a(`agent`)),this.#J(e,t,r===null),this.#Y(e,t),(i||a(`files`,`agentId`))&&this.#X(e,t,n);let o=this.hasAttribute(`developer`);this.#x.developer.hidden=!o,o&&a(`requests`,`events`,`error`,`agent`,`activeId`)?this.#Q(e,t):o&&a(`tokens`)&&this.#h&&t&&(this.#h.textContent=e.events(t.tokens)),this.#x.layout.classList.toggle(`rail-open`,this.#y),this.#b&&(this.#x.transcript.scrollTop=this.#x.transcript.scrollHeight)}#R(e){let t=this.#x;t.rail.setAttribute(`aria-label`,e.conversations),t.newButton.replaceChildren(Lr(`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.loading.textContent=e.loadingHistory,t.developerSummary.textContent=e.developer}#z(e,t,n){let r=this.#x;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===``,r.conversations.replaceChildren(...i.map(r=>this.#V(e,r,r.id===t?.activeId,n)))}#B(e,t){return new Intl.DateTimeFormat(e.locale,{dateStyle:`short`,timeStyle:`short`}).format(t)}#V(e,t,n,r){let i=this.#B(e,t.last_message_at),a=t.title??i,o=(t.title?i:e.untitled)+(t.enabled?``:` · ${e.disabled}`),s=$(`button`,{class:`open`,attrs:{type:`button`,"data-action":`open`,"data-id":t.id}},$(`span`,{class:`title`,text:a}),$(`span`,{class:`meta`,text:o}));n&&s.setAttribute(`aria-current`,`true`),s.disabled=r;let c=this.#n===t.id,l=Zr(`delete`,c?e.confirmDelete(a):e.deleteConversation(a),{"data-action":`delete`,"data-id":t.id},c?`danger confirming`:`danger`);return c&&l.replaceChildren(e.confirmDeleteShort),l.disabled=r,$(`li`,{class:n?`conversation active`:`conversation`},s,l)}#H(e,t){let n=this.#x;n.agentName.textContent=t?.agent?.name??t?.agentId??e.noAgent,n.agentDescription.textContent=t?.agent?.description??``,n.agentDescription.hidden=!t?.agent?.description}#U(e,t){let n=this.#x,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(` · `))}#W(e,t,n){let r=this.#x,i=t?.loadingHistory??!1;r.loading.hidden=!i;let a=i?[]:t?.messages??[],o=t?.agent?.name??e.agent,s=a.map((t,r)=>{let i=n?void 0:this.#d[r];return i?.message===t?i:i&&ni(i.message,t)?(ri(i.node,t.rating),{message:t,node:i.node}):{message:t,node:t.role===`user`?this.#G(e,t):this.#K(e,t,r,o)}});this.#d=s;let c=r.messages.children;(s.length!==c.length||s.some(({node:e},t)=>e!==c[t]))&&r.messages.replaceChildren(...s.map(({node:e})=>e))}#G(e,t){return $(`article`,{class:`message user`,part:`message message-user`,attrs:{"aria-label":e.you}},$(`div`,{class:`bubble`,text:t.text}),t.attachments.length>0&&$(`ul`,{class:`chips`},...t.attachments.map(e=>$(`li`,{class:`chip`},$(`span`,{class:`chip-label`,text:e.name})))))}#K(e,t,n,r){let i=$(`div`,{class:`answer markdown`});yr(i,t.text);let a=$(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-label":r}},i);t.interrupted&&a.append($(`p`,{class:`note`,text:e.interrupted})),t.error&&a.append($(`p`,{class:`turn-error`,text:b(t.error,{failed:e.turnFailed,trace:e.trace})})),t.sources.length>0&&a.append(this.#q(e,t.sources,n));let o=$(`div`,{class:`actions`},t.text&&Xr()&&Zr(`copy`,e.copy,{"data-action":`copy`,"data-index":String(n)}));return t.idQuery&&(o.append(Zr(`thumbUp`,e.rateUp,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`5`}),Zr(`thumbDown`,e.rateDown,{"data-action":`rate`,"data-query":t.idQuery,"data-rating":`1`})),ri(o,t.rating)),a.append(o),a}#q(e,t,n){return $(`details`,{class:`sources`,part:`sources`},$(`summary`,{text:e.sources(t.length)}),$(`ol`,{},...t.map((t,r)=>{let i=ei(e,t);return $(`li`,{},$(`details`,{class:`source`,attrs:{"data-message":String(n),"data-source":String(r)}},$(`summary`,{},$r(e,t),i&&$(`span`,{class:`source-page`,text:` · ${i}`})),$(`div`,{class:`source-text markdown`})))})))}#J(e,t,n){let r=this.#x,i=t?.turn??null;if(!n&&i===this.#f)return;if(r.live.hidden=i===null,!i){this.#f=null,r.liveAnswer.replaceChildren();return}r.liveActivity.textContent=i.activity??e.thinking;let a=performance.now()-this.#p;if(!n&&this.#f!==null&&i.text!==this.#f.text&&a<Ur){this.#m||(this.#m=!0,setTimeout(()=>{this.#m=!1,this.#I()},Ur-a));return}let o=n||this.#f?.text!==i.text;this.#f=i,o&&(this.#p=performance.now(),r.liveAnswer.hidden=!i.text,yr(r.liveAnswer,i.text))}#Y(e,t){let n=this.#x,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)}#X(e,t,n){let r=this.#x,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 $(`li`,{class:t.status===`error`?`chip error`:`chip`,attrs:{title:t.error??n}},$(`span`,{class:`chip-label`,text:n}),Zr(`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.#Z()}#Z(){let e=this.#i?.state,t=(e?.uploading??0)>0||(e?.files.some(e=>e.status===`processing`)??!1);this.#x.send.disabled=!e?.agentId||(this.#i?.busy??!1)||t||!this.#x.input.value.trim()}#Q(e,t){let n=this.#x;if(!t||!this.#i){n.developerBody.replaceChildren();return}let r=e=>$(`dl`,{},...e.flatMap(([e,t])=>[$(`dt`,{text:e}),$(`dd`,{text:t})])),{agent:i,error:a}=t,o=[r([[`API`,this.#i.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]])];a&&o.push($(`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.#h=$(`h4`,{text:e.events(t.tokens)}),o.push(this.#h,$(`ol`,{class:`log`},...[...t.events].reverse().map(e=>$(`li`,{text:ti(e,t.turnStartedAt)}))),$(`h4`,{text:e.requests}),$(`ol`,{class:`log`},...t.requests.map(t=>$(`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 ai(e=zr){typeof customElements>`u`||customElements.get(e)||customElements.define(e,e===`aicore-agent-chat`?ii:class extends ii{})}ai();export{zr as AICORE_AGENT_CHAT_TAG,x as AICORE_EVENTS,ii as AicoreAgentChat,ie as AicoreChatClient,Ar as AicoreChatSession,t as AicoreError,br as CHAT_CHANGE,_ as EMPTY_TURN,f as EXPIRY_SKEW_MS,Sr as RATING_DOWN,xr as RATING_UP,g as TokenCache,y as answerOf,ne as apiBaseOf,m as decodeJwtClaims,ai as defineAicoreAgentChat,c as errorFromResponse,v as foldTurn,a as isAbortError,s as isInvalidToken,h as jwtExpiry,r as kindOf,kr as messagesFromHistory,o as parseBearerChallenge,re as randomId,i as toAicoreError,b as turnErrorText};
|
|
490
|
+
`,Br=`aicore-agent-chat`,Vr=`.pdf,.docx,.txt,.md,.html,.xlsx,.epub`,Hr=[x.turn,x.error,x.authRequired,x.tenantRefused],Ur=160,Wr=100,Gr=48,Kr=4e3,qr=[`getToken`,`strings`,`context`,`baseUrl`,`agent`,`tenant`,`conversation`,`developer`],Jr=typeof HTMLElement>`u`?class{}:HTMLElement,Yr;function Xr(){if(Yr!==void 0)return Yr;try{let e=new CSSStyleSheet;e.replaceSync(zr),Yr=`adoptedStyleSheets`in ShadowRoot.prototype?e:null}catch{Yr=null}return Yr}var Zr=()=>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}},Rr(e))}function Qr(e){return e&&/^https?:\/\//i.test(e)?e:null}function $r(e,t){return t.title??t.name??t.url??t.id_document??e.untitledSource}function ei(e,t){return t.page==null?t.part==null?``:e.part(t.part):e.page(String(t.page))}function ti(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>Ur&&(a=`${a.slice(0,Ur)}…`),[r,t.kind,t.id?`#${t.id}`:``,a].filter(Boolean).join(` `)}function ni(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 ri(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 ii=class extends Jr{static observedAttributes=[`base-url`,`agent`,`tenant`,`conversation`,`lang`,`developer`];#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`}),g=Q(`div`,{class:`messages`}),_=Q(`div`,{class:`answer markdown`}),ee=Q(`span`),v=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-busy":`true`}},_,Q(`div`,{class:`status`},Q(`span`,{class:`dots`},Q(`span`),Q(`span`),Q(`span`)),ee));v.hidden=!0;let y=Q(`div`,{class:`thread`,attrs:{role:`log`,"aria-live":`polite`}},m,h,g,v);g.style.display=`contents`;let b=Q(`div`,{class:`transcript`,part:`transcript`},y),x=Q(`ul`,{class:`chips`}),S=Q(`input`,{attrs:{type:`file`,multiple:``,accept:Vr}});S.hidden=!0;let te=$(`attach`,``,{"data-action":`attach`}),ne=Q(`textarea`,{part:`input`,attrs:{rows:`1`}}),re=Q(`button`,{class:`send`,part:`send`,attrs:{type:`submit`}},Rr(`send`)),C=Q(`button`,{class:`send`,part:`stop`,attrs:{type:`button`,"data-action":`stop`}},Rr(`stop`)),w=Q(`p`,{class:`footnote`}),ie=Q(`form`,{class:`composer`,part:`composer`},x,Q(`div`,{class:`box`},te,ne,re,C),w,S),ae=Q(`summary`),oe=Q(`div`),se=Q(`details`,{class:`developer`,part:`developer`},ae,oe),ce=Q(`div`,{class:`layout`},i,Q(`section`,{class:`main`},c,f,b,ie,se)),le=Xr();le?e.adoptedStyleSheets=[le]:e.append(Q(`style`,{text:zr})),e.append(ce),this.#w={layout:ce,rail:i,newButton:t,railStatus:n,conversations:r,railToggle:a,agentName:o,agentDescription:s,banner:f,bannerTitle:l,bannerDetail:u,dismiss:d,transcript:b,thread:y,empty:m,emptyTitle:p,loading:h,messages:g,live:v,liveAnswer:_,liveActivity:ee,files:x,fileInput:S,attach:te,input:ne,send:re,stop:C,footnote:w,developer:se,developerSummary:ae,developerBody:oe},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))}),y.addEventListener(`toggle`,e=>this.#B(e),!0),ie.addEventListener(`submit`,e=>{e.preventDefault(),this.#V()}),ne.addEventListener(`input`,()=>this.#ae()),ne.addEventListener(`keydown`,e=>{e.key===`Enter`&&!e.shiftKey&&!e.isComposing&&(e.preventDefault(),this.#V())}),S.addEventListener(`change`,()=>{let e=Array.from(S.files??[]);S.value=``,e.length>0&&this.#s?.attach(e)}),b.addEventListener(`scroll`,()=>{this.#C=b.scrollHeight-b.scrollTop-b.clientHeight<Gr},{passive:!0}),typeof ResizeObserver<`u`&&new ResizeObserver(()=>{this.#C&&(b.scrollTop=b.scrollHeight)}).observe(b)}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.#W(!0)}get context(){return this.#n}set context(t){this.#n=e(t)?t:null,this.#r=!0,this.#W()}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 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 qr)if(Object.prototype.hasOwnProperty.call(this,t)){let n=e[t];delete e[t],e[t]=n}this.#E(),this.#W(!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.#W(!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 jr({baseUrl:e,tenant:t,getToken:async e=>this.#e?this.#e(e):null});for(let e of Hr)n.client.addEventListener(e,this.#A);n.addEventListener(xr,this.#j),this.#s=n,n.setAgent(this.getAttribute(`agent`)),this.#k()}this.#W(!0)}}#D(){let e=this.#s;if(e){for(let t of Hr)e.client.removeEventListener(t,this.#A);e.removeEventListener(xr,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(x.conversation,{detail:{idConv:e.activeId,idAgent:e.agentId},bubbles:!0,composed:!0}))),this.#W()};#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),Kr),this.#a!==e&&(this.#a=e,this.#P(),e!==null&&this.#R(`delete`,e))}#P(){this.#q(this.#U(),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.#U().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.#U();navigator.clipboard.writeText(n.text).then(()=>{e.replaceChildren(Rr(`check`)),e.setAttribute(`aria-label`,r.copied),setTimeout(()=>{e.replaceChildren(Rr(`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;br(i,o.text??``);let s=Qr(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.#ae())}#H(){return this.closest(`[lang]`)?.getAttribute(`lang`)??(typeof document>`u`?null:document.documentElement.lang)}#U(){return Fr(this.#H(),this.#t)}#W(e=!1){if(e&&(this.#d=!0),this.#u)return;this.#u=!0;let t=()=>{this.#u=!1,this.#G()};typeof requestAnimationFrame==`function`?requestAnimationFrame(t):setTimeout(t,16)}#G(){let e=this.#U(),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]);r===null&&this.#K(e),(i||a(`conversations`,`activeId`,`conversationsLoading`,`conversationsFailed`,`agentId`))&&this.#q(e,t,n),a(`agent`,`agentId`)&&this.#X(e,t),a(`error`)&&this.#Z(e,t),a(`messages`,`loadingHistory`,`agent`)&&this.#Q(e,t,r===null||a(`agent`)),this.#ne(e,t,r===null),this.#re(e,t),(i||a(`files`,`agentId`))&&this.#ie(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.#se(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)}#K(e){let t=this.#w;t.rail.setAttribute(`aria-label`,e.conversations),t.newButton.replaceChildren(Rr(`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.loading.textContent=e.loadingHistory,t.developerSummary.textContent=e.developer}#q(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.#Y(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)}#J(e,t){return new Intl.DateTimeFormat(e.locale,{dateStyle:`short`,timeStyle:`short`}).format(t)}#Y(e,t,n,r){let i=this.#J(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}#X(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}#Z(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(` · `))}#Q(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=a.map((t,r)=>{let i=n?void 0:this.#m[r];return i?.message===t?i:i&&ni(i.message,t)?(ri(i.node,t.rating),{message:t,node:i.node}):{message:t,node:t.role===`user`?this.#$(e,t):this.#ee(e,t,r,o)}});this.#m=s;let c=r.messages.children;(s.length!==c.length||s.some(({node:e},t)=>e!==c[t]))&&r.messages.replaceChildren(...s.map(({node:e})=>e))}#$(e,t){return Q(`article`,{class:`message user`,part:`message message-user`,attrs:{"aria-label":e.you}},Q(`div`,{class:`bubble`,text: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})))))}#ee(e,t,n,r){let i=Q(`div`,{class:`answer markdown`});br(i,t.text);let a=Q(`article`,{class:`message assistant`,part:`message message-assistant`,attrs:{"aria-label":r}},i);t.interrupted&&a.append(Q(`p`,{class:`note`,text:e.interrupted})),t.error&&a.append(Q(`p`,{class:`turn-error`,text:b(t.error,{failed:e.turnFailed,trace:e.trace})})),t.sources.length>0&&a.append(this.#te(e,t.sources,n));let o=Q(`div`,{class:`actions`},t.text&&Zr()&&$(`copy`,e.copy,{"data-action":`copy`,"data-index":String(n)}));return t.idQuery&&(o.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`})),ri(o,t.rating)),a.append(o),a}#te(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=ei(e,t);return Q(`li`,{},Q(`details`,{class:`source`,attrs:{"data-message":String(n),"data-source":String(r)}},Q(`summary`,{},$r(e,t),i&&Q(`span`,{class:`source-page`,text:` · ${i}`})),Q(`div`,{class:`source-text markdown`})))})))}#ne(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,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<Wr){this.#_||(this.#_=!0,setTimeout(()=>{this.#_=!1,this.#W()},Wr-a));return}let o=n||this.#h?.text!==i.text;this.#h=i,o&&(this.#g=performance.now(),r.liveAnswer.hidden=!i.text,br(r.liveAnswer,i.text))}#re(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)}#ie(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.#ae()}#ae(){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()}#oe(){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>Ur?`${e.slice(0,Ur)}…`:e} · ${t} B`}#se(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.#oe()??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:ti(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 ai(e=Br){typeof customElements>`u`||customElements.get(e)||customElements.define(e,e===`aicore-agent-chat`?ii:class extends ii{})}ai();export{Br as AICORE_AGENT_CHAT_TAG,x as AICORE_EVENTS,ii as AicoreAgentChat,ie as AicoreChatClient,jr as AicoreChatSession,t as AicoreError,xr as CHAT_CHANGE,_ as EMPTY_TURN,f as EXPIRY_SKEW_MS,Cr as RATING_DOWN,Sr as RATING_UP,g as TokenCache,y as answerOf,ne as apiBaseOf,m as decodeJwtClaims,ai as defineAicoreAgentChat,c as errorFromResponse,v as foldTurn,a as isAbortError,s as isInvalidToken,h as jwtExpiry,r as kindOf,Ar as messagesFromHistory,o as parseBearerChallenge,re as randomId,i as toAicoreError,b as turnErrorText};
|
|
470
491
|
//# sourceMappingURL=aicore-agent-chat.js.map
|