@liip/liipgpt 3.14.0-rc.6 → 3.14.0-rc.7

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.
Files changed (87) hide show
  1. package/README.md +2 -2
  2. package/chat/absolute-fade-out-XxeZPth0.js +2 -0
  3. package/chat/button-or-link-J8pmWrVn.js +2 -0
  4. package/chat/chat-logic.svelte-ZWeWjJUU.js +62 -0
  5. package/chat/{chat-panel-DMQMA6GL.js → chat-panel-M35SgfHS.js} +2 -2
  6. package/chat/{context-menu-12uTEQGW.js → context-menu-D5odUEca.js} +1 -1
  7. package/chat/easing-DUD_Cjk6.js +2 -0
  8. package/chat/embed-buttons-BeVL-8y6.js +2 -0
  9. package/chat/embed-combobox-4CAsoOjC.js +3 -0
  10. package/chat/{fake-typing-html-Ckuyip1o.js → fake-typing-html-DPkuXOHm.js} +1 -1
  11. package/chat/liipgpt-chat.iife.js +37 -37
  12. package/chat/liipgpt-chat.js +3 -3
  13. package/chat/{load-default-translations-BuD9xHUi.js → load-default-translations-a30ZO3-V.js} +1 -1
  14. package/chat/{menu-trigger-BBRcUk1D.js → menu-trigger-Cuu5xtMu.js} +1 -1
  15. package/chat/{selector-radio-CFDET-16.js → selector-radio-BBid9c4L.js} +1 -1
  16. package/chat/{selectors-BjZ6MVrq.js → selectors-DvEzt7TH.js} +1 -1
  17. package/chat/{svg-DtWMjI7R.js → svg-sCu6NrKC.js} +1 -1
  18. package/chat/{transition-XkiSng3X.js → transition-C-GmcvBc.js} +1 -1
  19. package/config/index.cjs +560 -552
  20. package/config/index.d.ts +14 -14
  21. package/config/index.js +560 -552
  22. package/configurator/_app/env.js +1 -1
  23. package/configurator/_app/immutable/chunks/{B3pEs5da2.js → 0XkoV4js2.js} +1 -1
  24. package/configurator/_app/immutable/chunks/{DFVfKDDI.js → 5LTQietD.js} +1 -1
  25. package/configurator/_app/immutable/chunks/{DJkWfLiY.js → B4Gh8Esp.js} +1 -1
  26. package/configurator/_app/immutable/chunks/{Dqce3tm9.js → B63CzlhX.js} +1 -1
  27. package/configurator/_app/immutable/chunks/{Dg-1RhhR.js → BDb7ndb6.js} +1 -1
  28. package/configurator/_app/immutable/chunks/{C0D00UGs.js → BG3QC97Q.js} +5 -5
  29. package/configurator/_app/immutable/chunks/{DAPaVlMa2.js → BMivt9VD2.js} +1 -1
  30. package/configurator/_app/immutable/chunks/{B747ckO42.js → BO1z8i0R2.js} +1 -1
  31. package/configurator/_app/immutable/chunks/BZxH-3SJ2.js +1 -0
  32. package/configurator/_app/immutable/chunks/BoRo9o--.js +1 -0
  33. package/configurator/_app/immutable/chunks/{BVt1hRS1.js → C9Mh6mRr.js} +1 -1
  34. package/configurator/_app/immutable/chunks/{BqqiQu5a2.js → CGs5apVK2.js} +1 -1
  35. package/configurator/_app/immutable/chunks/{CKQAcXe72.js → CW8c3Z5e2.js} +1 -1
  36. package/configurator/_app/immutable/chunks/{B9fUK6Tn2.js → C_FBLGnD2.js} +1 -1
  37. package/configurator/_app/immutable/chunks/{Bu14FuxZ2.js → CbE8SUil2.js} +1 -1
  38. package/configurator/_app/immutable/chunks/{DaOyEKKS2.js → Cdf5zcPh2.js} +1 -1
  39. package/configurator/_app/immutable/chunks/{EpR-uKr3.js → D5b1xIAm.js} +1 -1
  40. package/configurator/_app/immutable/chunks/{CfxnfSzA.js → D8-gl1YT.js} +1 -1
  41. package/configurator/_app/immutable/chunks/{o63Yrn5j2.js → D8mLFCTo2.js} +2 -2
  42. package/configurator/_app/immutable/chunks/{B32W_Dsa.js → DPuwLy6I.js} +2 -2
  43. package/configurator/_app/immutable/chunks/{nJOWwmmn2.js → DVoW2IJZ2.js} +1 -1
  44. package/configurator/_app/immutable/chunks/Dgo1hEZl.js +2 -0
  45. package/configurator/_app/immutable/chunks/DgswhBqn2.js +1 -0
  46. package/configurator/_app/immutable/chunks/{O5Fhekzt.js → Djmbd3Ed.js} +1 -1
  47. package/configurator/_app/immutable/chunks/{BzIUquDb2.js → DschELm12.js} +3 -3
  48. package/configurator/_app/immutable/chunks/TJW2RdJ02.js +2 -0
  49. package/configurator/_app/immutable/chunks/{B-y9X2-8.js → YI2Aab2N.js} +1 -1
  50. package/configurator/_app/immutable/chunks/{B3a6HGoe.js → YOH2G2iz.js} +1 -1
  51. package/configurator/_app/immutable/chunks/jIxBZpXH.js +1 -0
  52. package/configurator/_app/immutable/entry/{app.C_DECwZY.js → app.Dp1dOhKM.js} +2 -2
  53. package/configurator/_app/immutable/entry/start.jB6fSOSg.js +1 -0
  54. package/configurator/_app/immutable/nodes/{0.By4OoRjs.js → 0.C7BpUZJJ.js} +1 -1
  55. package/configurator/_app/immutable/nodes/{1.BSdglIqj.js → 1.CSUlNaAg.js} +1 -1
  56. package/configurator/_app/immutable/nodes/{2.DtYCUqQJ.js → 2.CZM5PGJE.js} +3 -3
  57. package/configurator/_app/immutable/nodes/{3.C5ar34a0.js → 3.DddjEWDo.js} +1 -1
  58. package/configurator/_app/version.json +1 -1
  59. package/configurator/index.html +6 -6
  60. package/configurator/sidebar.html +6 -6
  61. package/index.cjs +472 -461
  62. package/index.d.ts +101 -80
  63. package/index.js +472 -461
  64. package/package.json +1 -1
  65. package/search-summary/liipgpt-search-summary.iife.js +28 -28
  66. package/search-summary/liipgpt-search-summary.js +21 -23
  67. package/search-summary/{load-chat-config-BKJ4eg8F.js → load-chat-config-rIrJxcYJ.js} +2 -2
  68. package/search-summary/translations-utils-Du2dWNi1.js +4 -0
  69. package/chat/chat-logic.svelte-Ch4C_vn1.js +0 -62
  70. package/chat/embed-buttons-CeKC4X2u.js +0 -2
  71. package/chat/embed-combobox-C4vUrC24.js +0 -3
  72. package/configurator/_app/immutable/chunks/BKA1zfIz2.js +0 -2
  73. package/configurator/_app/immutable/chunks/CDfqTiXk.js +0 -1
  74. package/configurator/_app/immutable/chunks/CQ4h-YSQ.js +0 -2
  75. package/configurator/_app/immutable/chunks/CVxKVkdn.js +0 -1
  76. package/configurator/_app/immutable/chunks/DGofIY6p2.js +0 -1
  77. package/configurator/_app/immutable/chunks/DRrvYHBh2.js +0 -1
  78. package/configurator/_app/immutable/entry/start.CfccBmAW.js +0 -1
  79. /package/chat/{de-D1oUJG1T.js → de-B-rWS9iD.js} +0 -0
  80. /package/chat/{en-Bg1csyv-.js → en-uBnzwhZ-.js} +0 -0
  81. /package/chat/{fr-CTl7kz6p.js → fr-navcG-i0.js} +0 -0
  82. /package/chat/{it-BSFK0HUL.js → it-BdI1rBuy.js} +0 -0
  83. /package/chat/{tooltip-16JN-qn8.js → tooltip-BNPdEZ1v.js} +0 -0
  84. /package/search-summary/{de-CLq0dR54.js → de-Beh2sxQV.js} +0 -0
  85. /package/search-summary/{en-GeqcPzjE.js → en-Cqq6muzM.js} +0 -0
  86. /package/search-summary/{fr-C_RFjDCQ.js → fr-BRC1Jf3V.js} +0 -0
  87. /package/search-summary/{it-DsMTe5jt.js → it-Csghbz5d.js} +0 -0
package/README.md CHANGED
@@ -36,9 +36,9 @@ that is never opened now downloads about a quarter of what it used to.
36
36
 
37
37
  | gzipped, what a browser downloads before any interaction | IIFE | module |
38
38
  | -------------------------------------------------------- | -------- | -------------------- |
39
- | chat, flyout never opened | 206.2 kB | **51.6 kB** |
39
+ | chat, flyout never opened | 202.0 kB | **52.4 kB** |
40
40
  | button | 48.8 kB | **40.2 kB** |
41
- | search summary, styled through host CSS | 91.8 kB | **71.6 kB** |
41
+ | search summary, styled through host CSS | 88.0 kB | **69.0 kB** |
42
42
 
43
43
  The rest arrives when it is actually needed — the chat panel and engine on first open (prefetched on
44
44
  hover, so the click stays instant), a language when it is selected, an embed when the backend sends
@@ -0,0 +1,2 @@
1
+ /*! @liip/liipgpt | Copyright 2025-2026 Liip AG | Apache-2.0 | see LICENSE and NOTICE */
2
+ function e(e,{delay:t=0,duration:n=500,resetTop:r=!0}){let i=+getComputedStyle(e).opacity;return e.style.position=`absolute`,r&&(e.style.top=`0px`),{delay:t,duration:n,css:e=>`opacity: ${e*i};`}}export{e as t};
@@ -0,0 +1,2 @@
1
+ /*! @liip/liipgpt | Copyright 2025-2026 Liip AG | Apache-2.0 | see LICENSE and NOTICE */
2
+ import{Bt as e,E as t,Ft as n,I as r,Mt as i,Q as a,Vt as o,_ as s,ft as c,g as l,h as u,nt as d,rt as f,w as p,wt as m,z as h}from"./load-default-translations-a30ZO3-V.js";function g(u,g){o(g,!0);let _=l(g,`href`,7),v=l(g,`target`,7),y=l(g,`onclick`,7),b=l(g,`className`,23,()=>[]),x=l(g,`isStandalone`,7,!1),S=l(g,`children`,7),C=l(g,`type`,7,`button`),w=l(g,`use`,7),T=l(g,`class`,7),E=s(g,[`$$slots`,`$$events`,`$$legacy`,`$$host`,`href`,`target`,`onclick`,`className`,`isStandalone`,`children`,`type`,`use`,`class`]),D=i(()=>_()?`a`:`button`),O=i(()=>[...Array.isArray(b())?b():b()?[b()]:[],...T()?[T()]:[]]),k=()=>({}),A=i(()=>w()??k);var j={get href(){return _()},set href(e){_(e),n()},get target(){return v()},set target(e){v(e),n()},get onclick(){return y()},set onclick(e){y(e),n()},get className(){return b()},set className(e=[]){b(e),n()},get isStandalone(){return x()},set isStandalone(e=!1){x(e),n()},get children(){return S()},set children(e){S(e),n()},get type(){return C()},set type(e=`button`){C(e),n()},get use(){return w()},set use(e){w(e),n()},get class(){return T()},set class(e){T(e),n()}},M=f();return h(m(M),()=>c(D),!1,(e,n)=>{r(e,e=>c(A)?.(e)),t(e,()=>({...E,onclick:_()?void 0:y(),type:_()?void 0:C(),href:_(),role:_()?`link`:`button`,target:_()?v():void 0,class:c(O),[p]:{"open-button--standalone":x()}}));var i=f();a(m(i),S),d(n,i)}),d(u,M),e(j)}u(g,{href:{},target:{},onclick:{},className:{},isStandalone:{},children:{},type:{},use:{},class:{}},[],[],{mode:`open`});export{g as t};
@@ -0,0 +1,62 @@
1
+ /*! @liip/liipgpt | Copyright 2025-2026 Liip AG | Apache-2.0 | see LICENSE and NOTICE */
2
+ import{$t as e,At as t,Dt as n,Et as r,Gt as i,Ht as a,It as o,Mt as s,Ot as c,Pt as l,Qt as u,Rt as d,Zt as f,_t as p,a as m,bt as ee,c as h,dt as te,f as ne,ft as g,ht as _,i as re,kt as ie,l as ae,mt as oe,n as se,o as ce,p as v,pt as le,s as ue,t as de,u as fe,yt as pe,zt as me}from"./load-default-translations-a30ZO3-V.js";var{entries:he,setPrototypeOf:ge,isFrozen:_e,getPrototypeOf:ve,getOwnPropertyDescriptor:y}=Object,{freeze:b,seal:x,create:ye}=Object,{apply:S,construct:be}=typeof Reflect<`u`&&Reflect;b||=function(e){return e},x||=function(e){return e},S||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},be||=function(e){return new e(...[...arguments].slice(1))};var xe=T(Array.prototype.forEach),Se=T(Array.prototype.lastIndexOf),Ce=T(Array.prototype.pop),we=T(Array.prototype.push),Te=T(Array.prototype.splice),Ee=T(String.prototype.toLowerCase),De=T(String.prototype.toString),Oe=T(String.prototype.match),ke=T(String.prototype.replace),Ae=T(String.prototype.indexOf),je=T(String.prototype.trim),C=T(Object.prototype.hasOwnProperty),w=T(RegExp.prototype.test),Me=Ne(TypeError);function T(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return S(e,t,n)}}function Ne(e){return function(){return be(e,[...arguments])}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ee;ge&&ge(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(_e(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Pe(e){for(let t=0;t<e.length;t++)C(e,t)||(e[t]=null);return e}function D(e){let t=ye(null);for(let[n,r]of he(e))C(e,n)&&(Array.isArray(r)?t[n]=Pe(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=D(r):t[n]=r);return t}function Fe(e,t){for(;e!==null;){let n=y(e,t);if(n){if(n.get)return T(n.get);if(typeof n.value==`function`)return T(n.value)}e=ve(e)}function n(){return null}return n}var Ie=b(`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(`.`)),Le=b(`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(`.`)),Re=b([`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`]),ze=b([`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`]),Be=b(`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(`.`)),Ve=b([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),He=b([`#text`]),Ue=b(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.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.slot`.split(`.`)),We=b(`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.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.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-rendering.textlength.type.u1.u2.unicode.values.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(`.`)),Ge=b(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.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(`.`)),Ke=b([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),qe=x(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Je=x(/<%[\w\W]*|[\w\W]*%>/gm),Ye=x(/\$\{[\w\W]*/gm),Xe=x(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ze=x(/^aria-[\-\w]+$/),Qe=x(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),$e=x(/^(?:\w+script|data):/i),et=x(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),tt=x(/^html$/i),nt=x(/^[a-z][.\w]*(-[.\w]+)+$/i),rt=Object.freeze({__proto__:null,ARIA_ATTR:Ze,ATTR_WHITESPACE:et,CUSTOM_ELEMENT:nt,DATA_ATTR:Xe,DOCTYPE_NAME:tt,ERB_EXPR:Je,IS_ALLOWED_URI:Qe,IS_SCRIPT_OR_DATA:$e,MUSTACHE_EXPR:qe,TMPLIT_EXPR:Ye}),it={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},at=function(){return typeof window>`u`?null:window},ot=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}},st=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ct(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:at(),t=e=>ct(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==it.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,ee=Fe(m,`cloneNode`),h=Fe(m,`remove`),te=Fe(m,`nextSibling`),ne=Fe(m,`childNodes`),g=Fe(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let _,re=``,{implementation:ie,createNodeIterator:ae,createDocumentFragment:oe,getElementsByTagName:se}=n,{importNode:ce}=r,v=st();t.isSupported=typeof he==`function`&&typeof g==`function`&&ie&&ie.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:le,ERB_EXPR:ue,TMPLIT_EXPR:de,DATA_ATTR:fe,ARIA_ATTR:pe,IS_SCRIPT_OR_DATA:me,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:_e}=rt,{IS_ALLOWED_URI:ve}=rt,y=null,x=E({},[...Ie,...Le,...Re,...Be,...He]),S=null,be=E({},[...Ue,...We,...Ge,...Ke]),T=Object.seal(ye(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}})),Ne=null,Pe=null,qe=Object.seal(ye(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),Je=!0,Ye=!0,Xe=!1,Ze=!0,$e=!1,et=!0,nt=!1,lt=!1,ut=!1,O=!1,dt=!1,k=!1,A=!0,j=!1,ft=!0,pt=!1,mt={},M=null,ht=E({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),gt=null,_t=E({},[`audio`,`video`,`img`,`source`,`image`,`track`]),vt=null,yt=E({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),bt=`http://www.w3.org/1998/Math/MathML`,xt=`http://www.w3.org/2000/svg`,N=`http://www.w3.org/1999/xhtml`,St=N,Ct=!1,wt=null,Tt=E({},[bt,xt,N],De),Et=E({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Dt=E({},[`annotation-xml`]),Ot=E({},[`title`,`style`,`font`,`a`,`script`]),kt=null,At=[`application/xhtml+xml`,`text/html`],P=null,jt=null,Mt=n.createElement(`form`),Nt=function(e){return e instanceof RegExp||e instanceof Function},Pt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(jt&&jt===e)){if((!e||typeof e!=`object`)&&(e={}),e=D(e),kt=At.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,P=kt===`application/xhtml+xml`?De:Ee,y=C(e,`ALLOWED_TAGS`)?E({},e.ALLOWED_TAGS,P):x,S=C(e,`ALLOWED_ATTR`)?E({},e.ALLOWED_ATTR,P):be,wt=C(e,`ALLOWED_NAMESPACES`)?E({},e.ALLOWED_NAMESPACES,De):Tt,vt=C(e,`ADD_URI_SAFE_ATTR`)?E(D(yt),e.ADD_URI_SAFE_ATTR,P):yt,gt=C(e,`ADD_DATA_URI_TAGS`)?E(D(_t),e.ADD_DATA_URI_TAGS,P):_t,M=C(e,`FORBID_CONTENTS`)?E({},e.FORBID_CONTENTS,P):ht,Ne=C(e,`FORBID_TAGS`)?E({},e.FORBID_TAGS,P):D({}),Pe=C(e,`FORBID_ATTR`)?E({},e.FORBID_ATTR,P):D({}),mt=C(e,`USE_PROFILES`)?e.USE_PROFILES:!1,Je=e.ALLOW_ARIA_ATTR!==!1,Ye=e.ALLOW_DATA_ATTR!==!1,Xe=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ze=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,$e=e.SAFE_FOR_TEMPLATES||!1,et=e.SAFE_FOR_XML!==!1,nt=e.WHOLE_DOCUMENT||!1,O=e.RETURN_DOM||!1,dt=e.RETURN_DOM_FRAGMENT||!1,k=e.RETURN_TRUSTED_TYPE||!1,ut=e.FORCE_BODY||!1,A=e.SANITIZE_DOM!==!1,j=e.SANITIZE_NAMED_PROPS||!1,ft=e.KEEP_CONTENT!==!1,pt=e.IN_PLACE||!1,ve=e.ALLOWED_URI_REGEXP||Qe,St=e.NAMESPACE||N,Et=e.MATHML_TEXT_INTEGRATION_POINTS||Et,Dt=e.HTML_INTEGRATION_POINTS||Dt,T=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Nt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(T.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Nt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(T.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(T.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$e&&(Ye=!1),dt&&(O=!0),mt&&(y=E({},He),S=ye(null),mt.html===!0&&(E(y,Ie),E(S,Ue)),mt.svg===!0&&(E(y,Le),E(S,We),E(S,Ke)),mt.svgFilters===!0&&(E(y,Re),E(S,We),E(S,Ke)),mt.mathMl===!0&&(E(y,Be),E(S,Ge),E(S,Ke))),C(e,`ADD_TAGS`)||(qe.tagCheck=null),C(e,`ADD_ATTR`)||(qe.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?qe.tagCheck=e.ADD_TAGS:(y===x&&(y=D(y)),E(y,e.ADD_TAGS,P))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?qe.attributeCheck=e.ADD_ATTR:(S===be&&(S=D(S)),E(S,e.ADD_ATTR,P))),e.ADD_URI_SAFE_ATTR&&E(vt,e.ADD_URI_SAFE_ATTR,P),e.FORBID_CONTENTS&&(M===ht&&(M=D(M)),E(M,e.FORBID_CONTENTS,P)),e.ADD_FORBID_CONTENTS&&(M===ht&&(M=D(M)),E(M,e.ADD_FORBID_CONTENTS,P)),ft&&(y[`#text`]=!0),nt&&E(y,[`html`,`head`,`body`]),y.table&&(E(y,[`tbody`]),delete Ne.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw Me(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw Me(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);_=e.TRUSTED_TYPES_POLICY,re=_.createHTML(``)}else _===void 0&&(_=ot(p,i)),_!==null&&typeof re==`string`&&(re=_.createHTML(``));b&&b(e),jt=e}},Ft=E({},[...Le,...Re,...ze]),It=E({},[...Be,...Ve]),Lt=function(e){let t=g(e);(!t||!t.tagName)&&(t={namespaceURI:St,tagName:`template`});let n=Ee(e.tagName),r=Ee(t.tagName);return wt[e.namespaceURI]?e.namespaceURI===xt?t.namespaceURI===N?n===`svg`:t.namespaceURI===bt?n===`svg`&&(r===`annotation-xml`||Et[r]):!!Ft[n]:e.namespaceURI===bt?t.namespaceURI===N?n===`math`:t.namespaceURI===xt?n===`math`&&Dt[r]:!!It[n]:e.namespaceURI===N?t.namespaceURI===xt&&!Dt[r]||t.namespaceURI===bt&&!Et[r]?!1:!It[n]&&(Ot[n]||!Ft[n]):!!(kt===`application/xhtml+xml`&&wt[e.namespaceURI]):!1},Rt=function(e){we(t.removed,{element:e});try{g(e).removeChild(e)}catch{h(e)}},F=function(e,n){try{we(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{we(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(O||dt)try{Rt(n)}catch{}else try{n.setAttribute(e,``)}catch{}},zt=function(e){let t=null,r=null;if(ut)e=`<remove></remove>`+e;else{let t=Oe(e,/^[\r\n\t ]+/);r=t&&t[0]}kt===`application/xhtml+xml`&&St===N&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=_?_.createHTML(e):e;if(St===N)try{t=new f().parseFromString(i,kt)}catch{}if(!t||!t.documentElement){t=ie.createDocument(St,`template`,null);try{t.documentElement.innerHTML=Ct?re:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),St===N?se.call(t,nt?`html`:`body`)[0]:nt?t.documentElement:a},Bt=function(e){return ae.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},Vt=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Ht=function(e){return typeof s==`function`&&e instanceof s};function I(e,n,r){xe(e,e=>{e.call(t,n,r,jt)})}let Ut=function(e){let n=null;if(I(v.beforeSanitizeElements,e,null),Vt(e))return Rt(e),!0;let r=P(e.nodeName);if(I(v.uponSanitizeElement,e,{tagName:r,allowedTags:y}),et&&e.hasChildNodes()&&!Ht(e.firstElementChild)&&w(/<[/\w!]/g,e.innerHTML)&&w(/<[/\w!]/g,e.textContent)||e.nodeType===it.progressingInstruction||et&&e.nodeType===it.comment&&w(/<[/\w]/g,e.data))return Rt(e),!0;if(!(qe.tagCheck instanceof Function&&qe.tagCheck(r))&&(!y[r]||Ne[r])){if(!Ne[r]&&Gt(r)&&(T.tagNameCheck instanceof RegExp&&w(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r)))return!1;if(ft&&!M[r]){let t=g(e)||e.parentNode,n=ne(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=ee(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,te(e))}}}return Rt(e),!0}return e instanceof c&&!Lt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&w(/<\/no(script|embed|frames)/i,e.innerHTML)?(Rt(e),!0):($e&&e.nodeType===it.text&&(n=e.textContent,xe([le,ue,de],e=>{n=ke(n,e,` `)}),e.textContent!==n&&(we(t.removed,{element:e.cloneNode()}),e.textContent=n)),I(v.afterSanitizeElements,e,null),!1)},Wt=function(e,t,r){if(Pe[t]||A&&(t===`id`||t===`name`)&&(r in n||r in Mt))return!1;if(!(Ye&&!Pe[t]&&w(fe,t))&&!(Je&&w(pe,t))&&!(qe.attributeCheck instanceof Function&&qe.attributeCheck(t,e))){if(!S[t]||Pe[t]){if(!(Gt(e)&&(T.tagNameCheck instanceof RegExp&&w(T.tagNameCheck,e)||T.tagNameCheck instanceof Function&&T.tagNameCheck(e))&&(T.attributeNameCheck instanceof RegExp&&w(T.attributeNameCheck,t)||T.attributeNameCheck instanceof Function&&T.attributeNameCheck(t,e))||t===`is`&&T.allowCustomizedBuiltInElements&&(T.tagNameCheck instanceof RegExp&&w(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r))))return!1}else if(!vt[t]&&!w(ve,ke(r,ge,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ae(r,`data:`)===0&&gt[e])&&!(Xe&&!w(me,ke(r,ge,``)))&&r)return!1}return!0},Gt=function(e){return e!==`annotation-xml`&&Oe(e,_e)},Kt=function(e){I(v.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||Vt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:S,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=P(a),l=s,u=a===`value`?l:je(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,I(v.uponSanitizeAttribute,e,r),u=r.attrValue,j&&(c===`id`||c===`name`)&&(F(a,e),u=`user-content-`+u),et&&w(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){F(a,e);continue}if(c===`attributename`&&Oe(u,`href`)){F(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){F(a,e);continue}if(!Ze&&w(/\/>/i,u)){F(a,e);continue}$e&&xe([le,ue,de],e=>{u=ke(u,e,` `)});let d=P(e.nodeName);if(!Wt(d,c,u)){F(a,e);continue}if(_&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=_.createHTML(u);break;case`TrustedScriptURL`:u=_.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),Vt(e)?Rt(e):Ce(t.removed)}catch{F(a,e)}}I(v.afterSanitizeAttributes,e,null)},qt=function e(t){let n=null,r=Bt(t);for(I(v.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)I(v.uponSanitizeShadowNode,n,null),Ut(n),Kt(n),n.content instanceof a&&e(n.content);I(v.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(Ct=!e,Ct&&(e=`<!-->`),typeof e!=`string`&&!Ht(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw Me(`dirty is not a string, aborting`)}else throw Me(`toString is not a function`);if(!t.isSupported)return e;if(lt||Pt(n),t.removed=[],typeof e==`string`&&(pt=!1),pt){if(e.nodeName){let t=P(e.nodeName);if(!y[t]||Ne[t])throw Me(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=zt(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===it.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!O&&!$e&&!nt&&e.indexOf(`<`)===-1)return _&&k?_.createHTML(e):e;if(i=zt(e),!i)return O?null:k?re:``}i&&ut&&Rt(i.firstChild);let u=Bt(pt?e:i);for(;c=u.nextNode();)Ut(c),Kt(c),c.content instanceof a&&qt(c.content);if(pt)return e;if(O){if(dt)for(l=oe.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(S.shadowroot||S.shadowrootmode)&&(l=ce.call(r,l,!0)),l}let d=nt?i.outerHTML:i.innerHTML;return nt&&y[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&w(tt,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
3
+ `+d),$e&&xe([le,ue,de],e=>{d=ke(d,e,` `)}),_&&k?_.createHTML(d):d},t.setConfig=function(){Pt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),lt=!0},t.clearConfig=function(){jt=null,lt=!1},t.isValidAttribute=function(e,t,n){return jt||Pt({}),Wt(P(e),P(t),n)},t.addHook=function(e,t){typeof t==`function`&&we(v[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=Se(v[e],t);return n===-1?void 0:Te(v[e],n,1)[0]}return Ce(v[e])},t.removeHooks=function(e){v[e]=[]},t.removeAllHooks=function(){v=st()},t}var lt=ct();function ut(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var O=ut();function dt(e){O=e}var k={exec:()=>null};function A(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(j.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var j={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,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:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},ft=/^(?:[ \t]*(?:\n|$))+/,pt=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,mt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,M=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ht=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,gt=/(?:[*+-]|\d{1,9}[.)])/,_t=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,vt=A(_t).replace(/bull/g,gt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),yt=A(_t).replace(/bull/g,gt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),bt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,xt=/^[^\n]+/,N=/(?!\s*\])(?:\\.|[^\[\]\\])+/,St=A(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,N).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ct=A(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,gt).getRegex(),wt=`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`,Tt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Et=A(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,Tt).replace(`tag`,wt).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Dt=A(bt).replace(`hr`,M).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wt).getRegex(),Ot={blockquote:A(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,Dt).getRegex(),code:pt,def:St,fences:mt,heading:ht,hr:M,html:Et,lheading:vt,list:Ct,newline:ft,paragraph:Dt,table:k,text:xt},kt=A(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,M).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wt).getRegex(),At={...Ot,lheading:yt,table:kt,paragraph:A(bt).replace(`hr`,M).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,kt).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,wt).getRegex()},P={...Ot,html:A(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,Tt).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:k,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:A(bt).replace(`hr`,M).replace(`heading`,` *#{1,6} *[^
4
+ ]`).replace(`lheading`,vt).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},jt=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Mt=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Nt=/^( {2,}|\\)\n(?!\s*$)/,Pt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Ft=/[\p{P}\p{S}]/u,It=/[\s\p{P}\p{S}]/u,Lt=/[^\s\p{P}\p{S}]/u,Rt=A(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,It).getRegex(),F=/(?!~)[\p{P}\p{S}]/u,zt=/(?!~)[\s\p{P}\p{S}]/u,Bt=/(?:[^\s\p{P}\p{S}]|~)/u,Vt=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,Ht=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,I=A(Ht,`u`).replace(/punct/g,Ft).getRegex(),Ut=A(Ht,`u`).replace(/punct/g,F).getRegex(),Wt=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Gt=A(Wt,`gu`).replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,It).replace(/punct/g,Ft).getRegex(),Kt=A(Wt,`gu`).replace(/notPunctSpace/g,Bt).replace(/punctSpace/g,zt).replace(/punct/g,F).getRegex(),qt=A(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Lt).replace(/punctSpace/g,It).replace(/punct/g,Ft).getRegex(),Jt=A(/\\(punct)/,`gu`).replace(/punct/g,Ft).getRegex(),Yt=A(/^<(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(),Xt=A(Tt).replace(`(?:-->|$)`,`-->`).getRegex(),Zt=A(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,Xt).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Qt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,$t=A(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Qt).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),en=A(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Qt).replace(`ref`,N).getRegex(),tn=A(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,N).getRegex(),nn={_backpedal:k,anyPunctuation:Jt,autolink:Yt,blockSkip:Vt,br:Nt,code:Mt,del:k,emStrongLDelim:I,emStrongRDelimAst:Gt,emStrongRDelimUnd:qt,escape:jt,link:$t,nolink:tn,punctuation:Rt,reflink:en,reflinkSearch:A(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,en).replace(`nolink`,tn).getRegex(),tag:Zt,text:Pt,url:k},rn={...nn,link:A(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Qt).getRegex(),reflink:A(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Qt).getRegex()},an={...nn,emStrongRDelimAst:Kt,emStrongLDelim:Ut,url:A(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},on={...an,br:A(Nt).replace(`{2,}`,`*`).getRegex(),text:A(an.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},sn={normal:Ot,gfm:At,pedantic:P},cn={normal:nn,gfm:an,breaks:on,pedantic:rn},ln={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},un=e=>ln[e];function L(e,t){if(t){if(j.escapeTest.test(e))return e.replace(j.escapeReplace,un)}else if(j.escapeTestNoEncode.test(e))return e.replace(j.escapeReplaceNoEncode,un);return e}function dn(e){try{e=encodeURI(e).replace(j.percentDecode,`%`)}catch{return null}return e}function fn(e,t){let n=e.replace(j.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(j.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(j.slashPipe,`|`);return n}function pn(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 mn(e,t){if(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}function hn(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function gn(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
5
+ `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
6
+ `)}var _n=class{options;rules;lexer;constructor(e){this.options=e||O}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=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:pn(e,`
7
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=gn(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=pn(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],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:pn(t[0],`
8
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=pn(t[0],`
9
+ `).split(`
10
+ `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;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(`
11
+ `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
12
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
13
+ ${s}`:s,r=r?`${r}
14
+ ${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`)break;if(u?.type===`blockquote`){let t=u,a=t.raw+`
15
+ `+e.join(`
16
+ `),o=this.blockquote(a);i[i.length-1]=o,n=n.substring(0,n.length-t.raw.length)+o.raw,r=r.substring(0,r.length-t.text.length)+o.text;break}else if(u?.type===`list`){let t=u,a=t.raw+`
17
+ `+e.join(`
18
+ `),o=this.list(a);i[i.length-1]=o,n=n.substring(0,n.length-u.raw.length)+o.raw,r=r.substring(0,r.length-t.raw.length)+o.raw,e=a.substring(i.at(-1).raw.length).split(`
19
+ `);continue}}return{type:`blockquote`,raw:n,tokens:i,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),r=n.length>1,i={type:`list`,raw:``,ordered:r,start:r?+n.slice(0,-1):``,loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:`[*+-]`);let a=this.rules.other.listItemRegex(n),o=!1;for(;e;){let n=!1,r=``,s=``;if(!(t=a.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let c=t[2].split(`
20
+ `,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
21
+ `,1)[0],u=!c.trim(),d=0;if(this.options.pedantic?(d=2,s=c.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,s=c.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(l)&&(r+=l+`
22
+ `,e=e.substring(l.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),a=this.rules.other.headingBeginRegex(d),o=this.rules.other.htmlBeginRegex(d);for(;e;){let f=e.split(`
23
+ `,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
24
+ `+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
25
+ `+l}!u&&!l.trim()&&(u=!0),r+=f+`
26
+ `,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),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:t[0],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=fn(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
27
+ `):[],a={type:`table`,raw:t[0],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(fn(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)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
28
+ `?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){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=pn(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=mn(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 n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),hn(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.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 e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return hn(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}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){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}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,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,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:t[0],escaped:e}}}},R=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||O,this.options.tokenizer=this.options.tokenizer||new _n,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:j,block:sn.normal,inline:cn.normal};this.options.pedantic?(t.block=sn.pedantic,t.inline=cn.pedantic):this.options.gfm&&(t.block=sn.gfm,this.options.breaks?t.inline=cn.breaks:t.inline=cn.gfm),this.tokenizer.rules=t}static get rules(){return{block:sn,inline:cn}}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(j.carriageReturn,`
29
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(j.tabCharGlobal,` `).replace(j.spaceLine,``));e;){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+=`
30
+ `: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+=`
31
+ `+r.raw,n.text+=`
32
+ `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
33
+ `+r.raw,n.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title});continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t=1/0,n=e.slice(1),r;this.options.extensions.startBlock.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(i=e.substring(0,t+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let a=t.at(-1);n&&a?.type===`paragraph`?(a.raw+=`
35
+ `+r.raw,a.text+=`
36
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=`
37
+ `+r.raw,n.text+=`
38
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.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.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=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&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},vn=class{options;parser;constructor(e){this.options=e||O}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(j.notSpaceStart)?.[0],i=e.replace(j.endingNewline,``)+`
39
+ `;return r?`<pre><code class="language-`+L(r)+`">`+(n?i:L(i,!0))+`</code></pre>
40
+ `:`<pre><code>`+(n?i:L(i,!0))+`</code></pre>
41
+ `}blockquote({tokens:e}){return`<blockquote>
42
+ ${this.parser.parse(e)}</blockquote>
43
+ `}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
44
+ `}hr(e){return`<hr>
45
+ `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
46
+ `+r+`</`+i+`>
47
+ `}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+L(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
48
+ `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
49
+ `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
50
+ <thead>
51
+ `+t+`</thead>
52
+ `+r+`</table>
53
+ `}tablerow({text:e}){return`<tr>
54
+ ${e}</tr>
55
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
56
+ `}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>${L(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=dn(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+L(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=dn(e);if(i===null)return L(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${L(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:L(e.text)}},yn=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},bn=class e{options;renderer;textRenderer;constructor(e){this.options=e||O,this.options.renderer=this.options.renderer||new vn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new yn}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
57
+ `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){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`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=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`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}},xn=class{options;block;constructor(e){this.options=e||O}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?R.lex:R.lexInline}provideParser(){return this.block?bn.parse:bn.parseInline}},Sn=class{defaults=ut();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=bn;Renderer=vn;TextRenderer=yn;Lexer=R;Tokenizer=_n;Hooks=xn;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(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);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};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 vn(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||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new _n(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 xn;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];xn.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{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 n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return R.lex(e,t??this.defaults)}parser(e,t){return bn.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(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(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?R.lex:R.lexInline,s=i.hooks?i.hooks.provideParser():e?bn.parse:bn.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
58
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+L(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},Cn=new Sn;function z(e,t){return Cn.parse(e,t)}z.options=z.setOptions=function(e){return Cn.setOptions(e),z.defaults=Cn.defaults,dt(z.defaults),z},z.getDefaults=ut,z.defaults=O,z.use=function(...e){return Cn.use(...e),z.defaults=Cn.defaults,dt(z.defaults),z},z.walkTokens=function(e,t){return Cn.walkTokens(e,t)},z.parseInline=Cn.parseInline,z.Parser=bn,z.parser=bn.parse,z.Renderer=vn,z.TextRenderer=yn,z.Lexer=R,z.lexer=R.lex,z.Tokenizer=_n,z.Hooks=xn,z.parse=z,z.options,z.setOptions,z.use,z.walkTokens,z.parseInline,bn.parse,R.lex;var wn=e=>(Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t];n&&typeof n==`object`&&wn(n)}),Object.freeze(e)),Tn=wn({all:[],used:[],unused:[]}),En=(e,t)=>{let n=lt(e);return n.addHook(`uponSanitizeElement`,function(e,t){let n=t.tagName||e.nodeName.toLowerCase();n.startsWith(`liipgpt-`)&&(t.allowedTags[n]=!0)}),n.addHook(`afterSanitizeAttributes`,function(e){if(e.tagName!==`A`||!e.getAttribute(`href`)?.startsWith(`http`)||(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`),!t||e.querySelector(`.sr-only`)))return;let n=e.ownerDocument.createElement(`span`);n.className=`sr-only`,n.textContent=` ${t}`,e.appendChild(n)}),n},Dn=class{marked;currentReferences=Tn;lastUsedIndex=0;DomPurity;constructor(e={}){this.marked=new Sn({async:!1,breaks:!0}).use(this.createFootnoteExtension(),...e.extensions??[]),this.DomPurity=En(e.window,e.newTabSrText)}createFootnoteExtension=()=>{let e=this;return{extensions:[{name:`footnote`,level:`inline`,start(e){return e.match(/\[\^(\d+(?:\.\d+)?)\]/)?.index},tokenizer(e){let t=/^\[\^(\d+(?:\.\d+)?)\]/.exec(e);if(t){let[e,n]=t;return{type:`footnote`,raw:e,refNumber:n}}},renderer(t){if(t.type===`footnote`){let n=e.currentReferences.all,r=n.some(e=>e.citationId!==void 0)?n.findIndex(e=>e.citationId===t.refNumber):/^\d+$/.test(t.refNumber)?Number(t.refNumber)-1:-1,i=e.currentReferences.all[r];if(!i)return console.error(`Could not find ref for citation:`,t.refNumber),``;let a;return i?.referenceIndex.used?a=i.referenceIndex.used:(e.currentReferences.used.push(i),e.lastUsedIndex++,a=e.lastUsedIndex,i.referenceIndex.used=a),` <liipgpt-reference-number data-all-index="${r}" data-used-index="${a}" data-source="${JSON.stringify(i).replace(/"/g,`&quot;`)}"></liipgpt-reference-number>`}}}]}};parse(e){return this.DomPurity.sanitize(this.marked.parse(e),{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0,mathMl:!0},FORBID_TAGS:[`hr`],ADD_ATTR:[`target`]})}toHTML(e,t){this.currentReferences=t;let n=this.parse(e);return this.currentReferences=Tn,n}};Object.freeze({status:`aborted`});function B(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,`_zod`,{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,`name`,{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,`init`,{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,`name`,{value:e}),o}var On=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},kn={};function An(e){return e&&Object.assign(kn,e),kn}function jn(e,t){return typeof t==`bigint`?t.toString():t}function Mn(e){return{get value(){{let t=e();return Object.defineProperty(this,`value`,{value:t}),t}throw Error(`cached value already set`)}}}function Nn(e){let t=e.startsWith(`^`)?1:0,n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}var Pn=Symbol(`evaluating`);function V(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Pn)return r===void 0&&(r=Pn,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function Fn(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function In(...e){let t={};for(let n of e)Object.assign(t,Object.getOwnPropertyDescriptors(n));return Object.defineProperties({},t)}var Ln=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Rn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function zn(e){if(Rn(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(Rn(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function Bn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Vn(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function H(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Hn(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var Un={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Wn(e,t){if(!zn(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return Vn(e,In(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return Fn(this,`shape`,n),n}}))}function Gn(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Kn(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function qn(e){return typeof e==`string`?e:e?.message}function Jn(e,t,n){let r={...e,path:e.path??[]};return e.message||(r.message=qn(e.inst?._zod.def?.error?.(e))??qn(t?.error?.(e))??qn(n.customError?.(e))??qn(n.localeError?.(e))??`Invalid input`),delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}var Yn=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,`_zod`,{value:e._zod,enumerable:!1}),Object.defineProperty(e,`issues`,{value:t,enumerable:!1}),e.message=JSON.stringify(t,jn,2),Object.defineProperty(e,`toString`,{value:()=>e.message,enumerable:!1})},Xn=B(`$ZodError`,Yn),Zn=B(`$ZodError`,Yn,{Parent:Error}),Qn=(e=>(t,n,r,i)=>{let a=r?Object.assign(r,{async:!1}):{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new On;if(o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Jn(e,a,An())));throw Ln(t,i?.callee),t}return o.value})(Zn),$n=(e=>async(t,n,r,i)=>{let a=r?Object.assign(r,{async:!0}):{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new(i?.Err??e)(o.issues.map(e=>Jn(e,a,An())));throw Ln(t,i?.callee),t}return o.value})(Zn),er=(e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new On;return a.issues.length?{success:!1,error:new(e??Xn)(a.issues.map(e=>Jn(e,i,An())))}:{success:!0,data:a.value}})(Zn),tr=(e=>async(t,n,r)=>{let i=r?Object.assign(r,{async:!0}):{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>Jn(e,i,An())))}:{success:!0,data:a.value}})(Zn),nr=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;`${nr}`;function rr(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ir(e){let t=rr({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${nr}T(?:${r})$`)}var ar=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},or=/^-?\d+$/,sr=/^-?\d+(?:\.\d+)?$/,cr=/^(?:true|false)$/i,lr=B(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ur=B(`$ZodCheckNumberFormat`,(e,t)=>{lr.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Un[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=or)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),dr=B(`$ZodCheckStringFormat`,(e,t)=>{var n,r;lr.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),fr={major:4,minor:3,patch:6},U=B(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=fr;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=Gn(e),i;for(let a of t){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,o=a._zod.check(e);if(o instanceof Promise&&n?.async===!1)throw new On;if(i||o instanceof Promise)i=(i??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(r||=Gn(e,t))});else{if(e.issues.length===t)continue;r||=Gn(e,t)}}return i?i.then(()=>e):e},n=(n,i,a)=>{if(Gn(n))return n.aborted=!0,n;let o=t(i,r,a);if(o instanceof Promise){if(a.async===!1)throw new On;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if(a.direction===`backward`){let t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,i,a)):n(t,i,a)}let o=e._zod.parse(i,a);if(o instanceof Promise){if(a.async===!1)throw new On;return o.then(e=>t(e,r,a))}return t(o,r,a)}}V(e,`~standard`,()=>({validate:t=>{try{let n=er(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return tr(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),pr=B(`$ZodString`,(e,t)=>{U.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ar(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),mr=B(`$ZodStringFormat`,(e,t)=>{dr.init(e,t),pr.init(e,t)}),hr=B(`$ZodURL`,(e,t)=>{mr.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),gr=B(`$ZodISODateTime`,(e,t)=>{t.pattern??=ir(t),mr.init(e,t)}),_r=B(`$ZodNumber`,(e,t)=>{U.init(e,t),e._zod.pattern=e._zod.bag.pattern??sr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),vr=B(`$ZodNumberFormat`,(e,t)=>{ur.init(e,t),_r.init(e,t)}),yr=B(`$ZodBoolean`,(e,t)=>{U.init(e,t),e._zod.pattern=cr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}});function br(e,t,n){e.issues.length&&t.issues.push(...Kn(n,e.issues)),t.value[n]=e.value}var xr=B(`$ZodArray`,(e,t)=>{U.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>br(t,n,e))):br(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function Sr(e,t,n,r,i){if(e.issues.length){if(i&&!(n in r))return;t.issues.push(...Kn(n,e.issues))}e.value===void 0?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function Cr(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=Hn(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wr(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optout===`optional`;for(let i in t){if(s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>Sr(e,n,i,t,u))):Sr(a,n,i,t,u)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var Tr=B(`$ZodObject`,(e,t)=>{if(U.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,`shape`,{get:()=>{let n={...e};return Object.defineProperty(t,`shape`,{value:n}),n}})}let n=Mn(()=>Cr(t));V(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=Rn,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optout===`optional`,i=n._zod.run({value:s[e],issues:[]},o);i instanceof Promise?c.push(i.then(n=>Sr(n,t,e,s,r))):Sr(i,t,e,s,r)}return i?wr(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}});function Er(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!Gn(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Jn(e,r,An())))}),t)}var Dr=B(`$ZodUnion`,(e,t)=>{U.init(e,t),V(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),V(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),V(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),V(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>Nn(e.source)).join(`|`)})$`)}});let n=t.options.length===1,r=t.options[0]._zod.run;e._zod.parse=(i,a)=>{if(n)return r(i,a);let o=!1,s=[];for(let e of t.options){let t=e._zod.run({value:i.value,issues:[]},a);if(t instanceof Promise)s.push(t),o=!0;else{if(t.issues.length===0)return t;s.push(t)}}return o?Promise.all(s).then(t=>Er(t,i,e,a)):Er(s,i,e,a)}});function Or(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(zn(e)&&zn(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Or(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Or(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}var kr=B(`$ZodRecord`,(e,t)=>{U.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!zn(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let s=new Set;for(let e of o)if(typeof e==`string`||typeof e==`number`||typeof e==`symbol`){s.add(typeof e==`number`?e.toString():e);let o=t.valueType._zod.run({value:i[e],issues:[]},r);o instanceof Promise?a.push(o.then(t=>{t.issues.length&&n.issues.push(...Kn(e,t.issues)),n.value[e]=t.value})):(o.issues.length&&n.issues.push(...Kn(e,o.issues)),n.value[e]=o.value)}let c;for(let e in i)s.has(e)||(c??=[],c.push(e));c&&c.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:c})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`)continue;let s=t.keyType._zod.run({value:o,issues:[]},r);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&sr.test(o)&&s.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(s=e)}if(s.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>Jn(e,r,An())),input:o,path:[o],inst:e});continue}let c=t.valueType._zod.run({value:i[o],issues:[]},r);c instanceof Promise?a.push(c.then(e=>{e.issues.length&&n.issues.push(...Kn(o,e.issues)),n.value[s.value]=e.value})):(c.issues.length&&n.issues.push(...Kn(o,c.issues)),n.value[s.value]=c.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Ar=B(`$ZodLiteral`,(e,t)=>{if(U.init(e,t),t.values.length===0)throw Error(`Cannot create literal schema with no valid values`);let n=new Set(t.values);e._zod.values=n,e._zod.pattern=RegExp(`^(${t.values.map(e=>typeof e==`string`?Bn(e):e?Bn(e.toString()):String(e)).join(`|`)})$`),e._zod.parse=(r,i)=>{let a=r.value;return n.has(a)||r.issues.push({code:`invalid_value`,values:t.values,input:a,inst:e}),r}});function jr(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}var Mr=B(`$ZodOptional`,(e,t)=>{U.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,V(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),V(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Nn(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>jr(t,e.value)):jr(r,e.value)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Nr=B(`$ZodNullable`,(e,t)=>{U.init(e,t),V(e._zod,`optin`,()=>t.innerType._zod.optin),V(e._zod,`optout`,()=>t.innerType._zod.optout),V(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${Nn(e.source)}|null)$`):void 0}),V(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Pr,Fr=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Ir(){return new Fr}(Pr=globalThis).__zod_globalRegistry??(Pr.__zod_globalRegistry=Ir()),globalThis.__zod_globalRegistry;function Lr(e,t){return new e({type:`string`,...H(t)})}function Rr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...H(t)})}function zr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...H(t)})}function Br(e,t){return new e({type:`number`,checks:[],...H(t)})}function Vr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...H(t)})}function Hr(e,t){return new e({type:`boolean`,...H(t)})}var W=B(`ZodMiniType`,(e,t)=>{if(!e._zod)throw Error(`Uninitialized schema in ZodMiniType.`);U.init(e,t),e.def=t,e.type=t.type,e.parse=(t,n)=>Qn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>er(e,t,n),e.parseAsync=async(t,n)=>$n(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>tr(e,t,n),e.check=(...n)=>e.clone({...t,checks:[...t.checks??[],...n.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]},{parent:!0}),e.with=e.check,e.clone=(t,n)=>Vn(e,t,n),e.brand=()=>e,e.register=((t,n)=>(t.add(e,n),e)),e.apply=t=>t(e)}),Ur=B(`ZodMiniString`,(e,t)=>{pr.init(e,t),W.init(e,t)});function G(e){return Lr(Ur,e)}var Wr=B(`ZodMiniStringFormat`,(e,t)=>{mr.init(e,t),Ur.init(e,t)}),Gr=B(`ZodMiniURL`,(e,t)=>{hr.init(e,t),Wr.init(e,t)});function Kr(e){return Rr(Gr,e)}var qr=B(`ZodMiniNumber`,(e,t)=>{_r.init(e,t),W.init(e,t)});function Jr(e){return Br(qr,e)}var Yr=B(`ZodMiniNumberFormat`,(e,t)=>{vr.init(e,t),qr.init(e,t)});function Xr(e){return Vr(Yr,e)}var Zr=B(`ZodMiniBoolean`,(e,t)=>{yr.init(e,t),W.init(e,t)});function Qr(e){return Hr(Zr,e)}var $r=B(`ZodMiniArray`,(e,t)=>{xr.init(e,t),W.init(e,t)});function ei(e,t){return new $r({type:`array`,element:e,...H(t)})}var ti=B(`ZodMiniObject`,(e,t)=>{Tr.init(e,t),W.init(e,t),V(e,`shape`,()=>t.shape)});function K(e,t){return new ti({type:`object`,shape:e??{},...H(t)})}function ni(e,t){return Wn(e,t)}var ri=B(`ZodMiniUnion`,(e,t)=>{Dr.init(e,t),W.init(e,t)});function ii(e,t){return new ri({type:`union`,options:e,...H(t)})}var ai=B(`ZodMiniRecord`,(e,t)=>{kr.init(e,t),W.init(e,t)});function oi(e,t,n){return new ai({type:`record`,keyType:e,valueType:t,...H(n)})}var si=B(`ZodMiniLiteral`,(e,t)=>{Ar.init(e,t),W.init(e,t)});function ci(e,t){return new si({type:`literal`,values:Array.isArray(e)?e:[e],...H(t)})}var li=B(`ZodMiniOptional`,(e,t)=>{Mr.init(e,t),W.init(e,t)});function q(e){return new li({type:`optional`,innerType:e})}var ui=B(`ZodMiniNullable`,(e,t)=>{Nr.init(e,t),W.init(e,t)});function di(e){return new ui({type:`nullable`,innerType:e})}var fi=B(`ZodMiniISODateTime`,(e,t)=>{gr.init(e,t),Wr.init(e,t)});function pi(e){return zr(fi,e)}var mi=ni(K({url:Kr(),score:Jr(),metadata:oi(G(),ii([G(),Jr(),Qr(),ei(G()),ei(Jr()),ei(Qr())])),language:q(G())}),K({title:G(),description:q(G()),badge:q(G()),breadcrumbs:q(ei(G())),previewImage:q(G()),date:q(pi())}).shape),hi=ei(K({question:G(),answer:G()})),gi=K({predefinedQuestions:ei(K({id:q(G()),label:di(G()),question:G(),switchQuestionId:q(G())}))}),_i=ii([K({maintenance:ci(!0)}),K({id:G(),cID:G()})]),vi={safeParse:e=>({success:!0,data:e})},J=[];for(let e=0;e<256;++e)J.push((e+256).toString(16).slice(1));function yi(e,t=0){return(J[e[t+0]]+J[e[t+1]]+J[e[t+2]]+J[e[t+3]]+`-`+J[e[t+4]]+J[e[t+5]]+`-`+J[e[t+6]]+J[e[t+7]]+`-`+J[e[t+8]]+J[e[t+9]]+`-`+J[e[t+10]]+J[e[t+11]]+J[e[t+12]]+J[e[t+13]]+J[e[t+14]]+J[e[t+15]]).toLowerCase()}var bi,xi=new Uint8Array(16);function Si(){if(!bi){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);bi=crypto.getRandomValues.bind(crypto)}return bi(xi)}var Ci={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function wi(e,t,n){e||={};let r=e.random??e.rng?.()??Si();if(r.length<16)throw Error(`Random bytes length must be >= 16`);if(r[6]=r[6]&15|64,r[8]=r[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=r[e];return t}return yi(r)}function Ti(e,t,n){return Ci.randomUUID&&!t&&!e?Ci.randomUUID():wi(e,t,n)}var Ei={};function Di(e,t,n){let r;if(e)r=ki(e.random??e.rng?.()??Si(),e.msecs,e.seq,t,n);else{let e=Date.now(),i=Si();Oi(Ei,e,i),r=ki(i,Ei.msecs,Ei.seq,t,n)}return t??yi(r)}function Oi(e,t,n){return e.msecs??=-1/0,e.seq??=0,t>e.msecs?(e.seq=n[6]<<23|n[7]<<16|n[8]<<8|n[9],e.msecs=t):(e.seq=e.seq+1|0,e.seq===0&&e.msecs++),e}function ki(e,t,n,r,i=0){if(e.length<16)throw Error(`Random bytes length must be >= 16`);if(!r)r=new Uint8Array(16),i=0;else if(i<0||i+16>r.length)throw RangeError(`UUID byte range ${i}:${i+15} is out of buffer bounds`);return t??=Date.now(),n??=e[6]*127<<24|e[7]<<16|e[8]<<8|e[9],r[i++]=t/1099511627776&255,r[i++]=t/4294967296&255,r[i++]=t/16777216&255,r[i++]=t/65536&255,r[i++]=t/256&255,r[i++]=t&255,r[i++]=112|n>>>28&15,r[i++]=n>>>20&255,r[i++]=128|n>>>14&63,r[i++]=n>>>6&255,r[i++]=n<<2&255|e[10]&3,r[i++]=e[11],r[i++]=e[12],r[i++]=e[13],r[i++]=e[14],r[i++]=e[15],r}var Ai=new Map,ji=class{get length(){return Ai.size}clear(){Ai.clear()}getItem(e){return Ai.get(e)||null}key(e){return Array.from(Ai.keys())[e]||null}removeItem(e){Ai.delete(e)}setItem(e,t){Ai.set(e,String(t))}},Y=globalThis.localStorage??new ji,Mi=async(e,t)=>{try{let n=Y.getItem(`liipgpt:uID`)||Y.getItem(`uID`),r={method:`POST`,headers:{Accept:`application/json`,"Content-Type":`application/json`},body:JSON.stringify({referrer:globalThis?.document?.referrer||null,uID:n,...t?{startParameters:t}:{}})},i=await e.fetchData(`/login`,_i,{},r);if(`maintenance`in i&&i.maintenance)return{mode:`maintenance`};if(!(`id`in i))throw Error(`Invalid response format: missing user id`);return Y.setItem(`liipgpt:uID`,i.id),{mode:`ready`,userId:i.id}}catch(e){throw console.error(`Failed to fetch user data:`,e),e}},X=function(e,t){if(!(this instanceof X))return new X(e,t);this.url=e,t||={},this.headers=t.headers||{},this.payload=t.payload===void 0?``:t.payload,this.method=t.method||this.payload&&`POST`||`GET`,this.withCredentials=!!t.withCredentials,this.debug=!!t.debug,this.autoReconnect=t.autoReconnect===void 0?!1:t.autoReconnect,this.reconnectDelay=t.reconnectDelay===void 0?3e3:t.reconnectDelay,this.maxRetries=t.maxRetries===void 0?null:t.maxRetries,this.retryCount=0,this.reconnectTimer=null,this.useLastEventId=t.useLastEventId===void 0?!0:t.useLastEventId,this.FIELD_SEPARATOR=`:`,this.listeners={},this.xhr=null,this.readyState=X.INITIALIZING,this.progress=0,this.chunk=``,this.lastEventId=``,this._hasParsedBom=!1,this.addEventListener=function(e,t){this.listeners[e]===void 0&&(this.listeners[e]=[]),this.listeners[e].indexOf(t)===-1&&this.listeners[e].push(t)},this.removeEventListener=function(e,t){if(this.listeners[e]===void 0)return;let n=[];this.listeners[e].forEach(function(e){e!==t&&n.push(e)}),n.length===0?delete this.listeners[e]:this.listeners[e]=n},this.dispatchEvent=function(e){if(!e)return!0;this.debug&&console.debug(e),e.source=this;let t=`on`+e.type;return this.hasOwnProperty(t)&&(this[t].call(this,e),e.defaultPrevented)?!1:this.listeners[e.type]?this.listeners[e.type].every(function(t){return t(e),!e.defaultPrevented}):!0},this._markClosed=function(){if(this.xhr=null,this.progress=0,this.chunk=``,this._setReadyState(X.CLOSED),this.autoReconnect){if(this.maxRetries!==null&&this.retryCount>=this.maxRetries){this.debug&&console.debug(`SSE max retries (${this.maxRetries}) reached, stopping reconnection attempts`),this.autoReconnect=!1,this.close();return}this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.debug&&console.debug(`SSE will attempt to reconnect in ${this.reconnectDelay}ms (attempt ${this.retryCount+1}${this.maxRetries?`/`+this.maxRetries:``})`),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.retryCount++,this.stream()},this.reconnectDelay)}},this._setReadyState=function(e){let t=new CustomEvent(`readystatechange`);t.readyState=e,this.readyState=e,this.dispatchEvent(t)},this._onStreamFailure=function(e){let t=new CustomEvent(`error`);t.responseCode=e.currentTarget.status,t.data=e.currentTarget.response,this.dispatchEvent(t),this._markClosed()},this._onStreamAbort=function(){this.dispatchEvent(new CustomEvent(`abort`)),this._markClosed()},this._onStreamProgress=function(e){if(!this.xhr)return;if(this.xhr.status<200||this.xhr.status>=300){this._onStreamFailure(e);return}this.retryCount=0;let t=this.xhr.responseText.substring(this.progress);this.progress+=t.length,!this._hasParsedBom&&this.chunk.length===0&&(t.charCodeAt(0)===65279&&(t=t.substring(1)),this._hasParsedBom=!0);let n=(this.chunk+t).split(/(\r\n\r\n|\r\r|\n\n)/g),r=n.pop();n.forEach(function(e){e.trim().length>0&&this.dispatchEvent(this._parseEventChunk(e))}.bind(this)),this.chunk=r},this._onStreamLoaded=function(e){this._onStreamProgress(e),this.dispatchEvent(this._parseEventChunk(this.chunk)),this.chunk=``,this._markClosed()},this._parseEventChunk=function(e){if(!e||e.length===0)return null;this.debug&&console.debug(e);let t={id:null,retry:null,data:null,event:null};if(e.split(/\n|\r\n|\r/).forEach(function(e){let n=e.indexOf(this.FIELD_SEPARATOR),r,i;if(n>0){let t=e[n+1]===` `?2:1;r=e.substring(0,n),i=e.substring(n+t)}else if(n<0)r=e,i=``;else return;r in t&&(r===`data`&&t[r]!==null?t.data+=`
59
+ `+i:t[r]=i)}.bind(this)),t.id!==null&&t.id.indexOf(`\0`)===-1&&(this.lastEventId=t.id),t.retry!==null&&/^[0-9]+$/.test(t.retry)&&(this.reconnectDelay=parseInt(t.retry,10)),t.data===null)return null;let n=new CustomEvent(t.event||`message`);return n.id=t.id,n.data=t.data||``,n.lastEventId=this.lastEventId,n},this._onReadyStateChange=function(){if(this.xhr&&this.xhr.readyState===XMLHttpRequest.HEADERS_RECEIVED){let e={},t=this.xhr.getAllResponseHeaders().trim().split(`\r
60
+ `);for(let n of t){let[t,...r]=n.split(`:`),i=r.join(`:`).trim();e[t.trim().toLowerCase()]=e[t.trim().toLowerCase()]||[],e[t.trim().toLowerCase()].push(i)}let n=new CustomEvent(`open`);n.responseCode=this.xhr.status,n.headers=e,this.dispatchEvent(n),this._setReadyState(X.OPEN)}},this.stream=function(){if(!this.xhr){this._setReadyState(X.CONNECTING),this.xhr=new XMLHttpRequest,this.xhr.addEventListener(`progress`,this._onStreamProgress.bind(this)),this.xhr.addEventListener(`load`,this._onStreamLoaded.bind(this)),this.xhr.addEventListener(`readystatechange`,this._onReadyStateChange.bind(this)),this.xhr.addEventListener(`error`,this._onStreamFailure.bind(this)),this.xhr.addEventListener(`abort`,this._onStreamAbort.bind(this)),this.xhr.open(this.method,this.url);for(let e in this.headers)this.xhr.setRequestHeader(e,this.headers[e]);this.useLastEventId&&this.lastEventId.length>0&&this.xhr.setRequestHeader(`Last-Event-ID`,this.lastEventId),this.xhr.withCredentials=this.withCredentials,this.xhr.send(this.payload)}},this.close=function(){this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.autoReconnect=!1,this.xhr&&this.xhr.abort()},(t.start===void 0||t.start)&&this.stream()};X.INITIALIZING=-1,X.CONNECTING=0,X.OPEN=1,X.CLOSED=2;var Ni=class{eventSource;triggeredOnClose=!1;constructor(e,t,n){this.options=t,this.payload=n;let r={headers:{"content-type":`application/json`}};n&&(r.payload=JSON.stringify(n)),t.apiKey&&(r.headers[`api-key`]=t.apiKey),this.eventSource=new(t.EventSource??X)(e,r),this.eventSource.onmessage=e=>{try{let n=JSON.parse(e.data);t.onMessage(n)}catch(e){t.onError(new CustomEvent(`parse-error`,{detail:e}))}},this.eventSource.onerror=e=>{t.onError(e),this.isClosed()&&this.close()}}isClosed(){return this.eventSource.readyState===EventSource.CLOSED}close(){this.isClosed()||this.eventSource.close(),this.triggeredOnClose||(this.triggeredOnClose=!0,this.options.onClose())}},Pi=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null)),Fi=class{constructor(e){this.options=e}getDefaultHeaders(e={}){let t={"Content-Type":`application/json`,...e};return this.options.apiKey&&(t[`api-key`]=this.options.apiKey),t}get speechRecognitionApiKey(){return this.options.speechRecognitionApiKey}async subscribeSse(e,t={},n){let r=Pi(t);return this.options.apiKey&&(n.apiKey=this.options.apiKey),new Ni(`${this.options.apiUrl}${e}`,n,r)}async fetchData(e,t,n={},r={}){let i=`${this.options.apiUrl}${e}?${new URLSearchParams(Pi(n)).toString()}`,a={...r,headers:this.getDefaultHeaders(r?.headers)},o=await fetch(i,a);if(!o.ok){let e=await o.text();throw Error(`API request failed: ${o.status} - ${e}`)}let s=await o.json(),c=t.safeParse(s);if(this.options.strict){if(!c.success)throw console.error(`Server response has wrong type:
61
+ `,{error:c.error,url:i,opts:a,data:s}),Error(`Server response has wrong type: ${c.error.message}`);return c.data}else return c.success||console.warn(`Server response has wrong type:
62
+ `,{error:c.error,url:i,opts:a,data:s}),s}async postData(e,t){let n=await fetch(`${this.options.apiUrl}${e}`,{method:`POST`,headers:this.getDefaultHeaders(),body:JSON.stringify(t)});if(!n.ok){let e=await n.text();throw Error(`${n.status} - ${e}`)}return n}async postFormData(e,t){let n=await fetch(`${this.options.apiUrl}${e}`,{method:`POST`,body:t});if(!n.ok){let e=await n.text();throw Error(`${n.status} - ${e}`)}return n}},Ii=K({links:ei(ii([K({url:q(Kr()),title:q(G()),considered:q(Qr()),orgMetadata:q(K({authors:q(ei(G()))})),type:q(G()),date:q(pi()),similarity:q(Jr()),content:q(G()),fromFullTextSearch:q(Qr()),rerank:q(K({index:q(Xr()),adjustment:q(Jr()),score:q(Jr()),similarityOld:q(Jr())}))}),mi]))}),Li=e=>{if(`metadata`in e)return e;console.warn(`Please upgrade your backend you are currently using an old api feature.`);let t=e.orgMetadata??{};e?.fromFullTextSearch&&(t.fromFullTextSearch=e?.fromFullTextSearch),e?.rerank&&(t.rerank=e?.rerank);let n=[],r=e.title??``;if(e.title&&e.title.includes(` > `)){let t=e.title.split(` > `);r=t.pop()??``,n=t}return{url:e.url??``,title:r,score:e.similarity||0,breadcrumbs:n,metadata:t,description:e.content,date:e.date}},Ri=class{id;constructor(e){this.chatResponseData=e,this.id=this.chatResponseData.id}async isReadyForFeedback(){return await this.chatResponseData.readyForFeedback.toPromise(),!0}subscribe(e,t){return this.chatResponseData.readableStore.subscribe(e,t)}getContent(){return this.chatResponseData.content.toPromise()}abort(){return this.chatResponseData.abort()}async thumbsUp(){await this.isReadyForFeedback(),await this.chatResponseData.liipgptClientPrimitive.thumbsUp(this.id,this.chatResponseData.question)}async thumbsDown(){await this.isReadyForFeedback(),await this.chatResponseData.liipgptClientPrimitive.thumbsDown(this.id,this.chatResponseData.question)}async feedback(e){await this.isReadyForFeedback(),await this.chatResponseData.liipgptClientPrimitive.feedback(this.id,this.chatResponseData.question,e)}};function zi(){let e,t;return{promise:new Promise((n,r)=>{t=n,e=r}),reject:e,resolve:t}}var Bi=class{promise;resolve;reject;constructor(){let{promise:e,resolve:t,reject:n}=zi();this.promise=e,this.resolve=t,this.reject=n}then(e,t){return this.promise.then(e,t)}catch(e){return this.promise.catch(e)}finally(e){return this.promise.finally(e)}toPromise(){return this.promise}[Symbol.toStringTag]=`Flag`},Vi=class{hasValue=new Bi;currentValue;setValue(e){this.currentValue=e,this.hasValue.resolve()}cleanup(e){this.hasValue.reject(e)}getCurrentValue(){return this.currentValue}async toPromise(){return await this.hasValue,this.currentValue}then(e,t){return this.toPromise().then(e,t)}catch(e){return this.toPromise().catch(e)}finally(e){return this.toPromise().finally(e)}[Symbol.toStringTag]=`FutureValue`},Hi=e=>{try{return new URL(e).hostname}catch{return e}};function Ui(e){return e.replace(/<[^>]*>/g,``).replace(/&nbsp;/g,` `).replace(/&amp;/g,`&`).replace(/&lt;/g,`<`).replace(/&gt;/g,`>`).replace(/&quot;/g,`"`)}var Wi=({citationId:e,url:t,considered:n,title:r,description:i,summary:a})=>{let o=Hi(t),s=i||a;return{...e?{citationId:e}:{},url:t,considered:n,referenceIndex:{},score:0,metadata:{},display:{card:{title:r,description:s,badge:t},listItem:{title:r,badge:o}}}},Gi=class{store;content=new Vi;backendSendsMappedRefs=!1;constructor(e){this.options=e,this.store=o({id:e.id,state:`loading`,errors:[],type:`bot`,time:new Date().toISOString(),message:{markdown:``,html:``,text:``},references:{all:[],used:[],unused:[]},retrievalQuestion:e.userQuestion})}pushError(e,t){this.options.onError?.(e,t),this.store.update(t=>({...t,errors:[...t.errors,e]}))}updateRequestId(e){this.store.update(t=>({...t,id:e}))}updateText(e){this.store.update(t=>{let n=t.message.markdown+e,r=this.options.markdownRenderer.toHTML(n,t.references);return{...t,state:`streaming`,message:{markdown:n,html:r,text:``}}})}finishMessage(){this.store.update(e=>{let t={...e,state:`done`};return t.references.unused=t.references.all.filter(e=>e.referenceIndex.used===void 0),t.message.text=Ui(t.message.html),this.options?.onFinish?.(t),this.content.setValue(t),t})}addReference(e){this.store.update(t=>{let n=t.references.all,r=n.length,i=[...n,{...e,referenceIndex:{all:r}}];return{...t,references:{used:t.references.used,all:i}}})}addMappedReference(e){this.backendSendsMappedRefs=!0,this.addReference(e)}addOldReference(e){this.backendSendsMappedRefs||this.addReference(Wi(e))}updateRetrievalQuestion(e){this.store.update(t=>({...t,retrievalQuestion:e}))}setNoFeedback(){this.store.update(e=>({...e,noFeedback:!0}))}getReadableStore(){return{subscribe:this.store.subscribe}}getPromise(){return this.content.toPromise()}},Ki=7,qi=8,Ji=160,Yi=e=>{let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===`<`){let r=e.indexOf(`>`,n);if(r!==-1){t.push({type:`tag`,value:e.slice(n,r+1)}),n=r+1;continue}}if(/\s/.test(r)){let r=n;for(;r<e.length&&/\s/.test(e[r]);)r++;t.push({type:`space`,value:e.slice(n,r)}),n=r;continue}let i=n;for(;i<e.length&&!/\s/.test(e[i])&&e[i]!==`<`;)i++;t.push({type:`word`,value:e.slice(n,i)}),n=i}return t},Xi=e=>{let t=Yi(e),n=[],r=``,i=!1;for(let e of t)e.type===`space`&&i?(n.push(r),r=e.value,i=!1):(r+=e.value,e.type===`word`&&(i=!0));return r&&n.push(r),n},Zi=e=>Math.max(qi,Math.min(Ji,e.length*Ki)),Qi=class{queue=[];timeoutId=null;isProcessing=!1;constructor(e){this.onText=e}ingestText(e){let t=Xi(e);if(t.length>=5){for(let e of t)this.queue.push({kind:`text`,chunk:e,delayMs:Zi(e)});this.kickoff();return}this.runAfterTyping(()=>this.onText(e))}runAfterTyping(e){if(this.queue.length===0&&!this.isProcessing){e();return}this.queue.push({kind:`fn`,fn:e}),this.kickoff()}runWithWarmup(e){this.queue.push({kind:`fn`,fn:e}),this.kickoff()}clear(){this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null),this.queue=[],this.isProcessing=!1}kickoff(){this.isProcessing||this.timeoutId!==null||(this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.processNext()},750))}processNext(){let e=this.queue.shift();if(!e){this.isProcessing=!1;return}this.isProcessing=!0,e.kind===`text`?(this.onText(e.chunk),this.timeoutId=setTimeout(()=>{this.timeoutId=null,this.processNext()},e.delayMs)):(e.fn(),this.processNext())}},$i=class{constructor(e){this.results=e}},ea=45e3,ta=class{internalData;renderers=new Map;markedExtensions=[];_newTabSrText;chatTimeout;constructor(e){this.chatTimeout=e.chatTimeout??ea;let t=new Fi({apiUrl:e.apiUrl,apiKey:e.apiKey,speechRecognitionApiKey:e.speechRecognitionApiKey,strict:e.strict??!1,EventSource:e.EventSource??EventSource});this.internalData={restClient:t,metadata:Mi(t,e.startParameters),searchResponseMap:new Map,chatResponseMap:new Map,conversationMap:new Map}}setMarkedExtensions(...e){this.markedExtensions=e}setNewTabSrText(e){this._newTabSrText=e}getMetadata(){return this.internalData.metadata}createConversationId(){let e=Di();return this.renderers.set(e,new Dn({extensions:this.markedExtensions,newTabSrText:this._newTabSrText})),e}chat(e,t,n={}){let r=new Vi,i=Di(),a=new Bi,o=new Gi({id:i,onError:(e,t)=>{n.onError?.(e,t)},onFinish:e=>{r.setValue(e)},markdownRenderer:this.renderers.get(e)??new Dn({extensions:this.markedExtensions,newTabSrText:this._newTabSrText}),userQuestion:t}),s=async()=>{await a,!(f&&!c.getCurrentValue())&&(await c).close()},c=new Vi,l=new Qi(e=>o.updateText(e)),u=n.timeout??this.chatTimeout,d,f=!1,p=()=>{d!==void 0&&clearTimeout(d),d=void 0},m=()=>{f=!0,d=void 0,console.error(`No SSE activity for ${u}ms, giving up on chat request ${i}`),l.clear(),o.pushError(`sse-error`);let e=c.getCurrentValue();if(e){e.close();return}o.finishMessage(),a.resolve()},ee=()=>{p(),u>0&&!f&&(d=setTimeout(m,u))};ee(),(async()=>{let s=await this.internalData.metadata;if(s.mode===`maintenance`)throw Error(`Can not chat in maintenance mode`);let u=await this.internalData.restClient.subscribeSse(`/assistant/sse`,{query:t,uID:s.userId,cID:e,rID:i,lang:n.lang,feature:n.features?.join(`,`),referrer:n.referrer,source:n.source,...n.selectorValues??{},...n.mode?{mode:n.mode}:{},...n.cache?{cache:!0}:{},...n.predefinedQuestionId?{predefinedQuestionId:n.predefinedQuestionId}:{},...n.switchQuestionId?{switchQuestionId:n.switchQuestionId}:{},chat:`true`,version:`2`},{onClose:()=>{p(),l.clear(),o.finishMessage(),a.resolve(),r.cleanup()},onMessage:t=>{let r=t;switch(ee(),r.type){case`error`:l.runAfterTyping(()=>o.pushError(r.error,r.message));break;case`id`:r.for===`request`&&i!==r.id&&console.warn(`Unexpected request id "${r.id}" expected "${i}"`),r.for===`conversation`&&e!==r.id&&console.warn(`Unexpected conversation id "${r.id}" expected "${e}"`);break;case`state`:r.state===`history-entry-initialized`&&a.resolve();break;case`text`:l.ingestText(r.text);break;case`done`:case`answer-done`:p(),l.runAfterTyping(()=>{o.finishMessage(),a.resolve(),c.then(e=>e.close())});break;case`unexpected-call`:l.runAfterTyping(()=>{console.error(`unexpected-call:`,r),o.pushError(`unexpected-call`)});break;case`jsonld-component`:case`mapped-reference`:l.runAfterTyping(()=>o.addMappedReference(r.reference));break;case`reference`:l.runAfterTyping(()=>o.addOldReference(r.reference));break;case`retrieval-question`:l.runAfterTyping(()=>o.updateRetrievalQuestion(r.question));break;case`no-feedback`:l.runAfterTyping(()=>o.setNoFeedback());break;case`component`:l.runWithWarmup(()=>n.onEmbed?.(r));break}l.runAfterTyping(()=>n.onMessage?.(r))},onError:e=>{console.error(` sse-error:`,e),!(`data`in e&&!e.data&&`responseCode`in e&&e.responseCode===0)&&o.pushError(`sse-error`)}});c.setValue(u),f&&u.close()})();let h=new Ri({question:t,id:i,content:r,readableStore:o.getReadableStore(),readyForFeedback:a,abort:s,liipgptClientPrimitive:this});return this.internalData.chatResponseMap.set(h.id,h),h}async thumbs(e,t,n){if((await this.internalData.metadata).mode!==`ready`)throw Error(`Can not post feedback unless we are in ready mode`);let r={feedback:n,rID:e,query:t};await this.internalData.restClient.postData(`/quickfeedback`,r)}thumbsUp(e,t){return this.thumbs(e,t,`positive`)}thumbsDown(e,t){return this.thumbs(e,t,`negative`)}async feedback(e,t,n){let r=await this.internalData.metadata;if(r.mode!==`ready`)throw Error(`Can not post feedback unless we are in ready mode`);if(n.message){let i={body:n.message,email:n.email,rID:e,uID:r.userId,query:t};await this.internalData.restClient.postData(`/feedback`,i)}n.classification&&await this.internalData.restClient.postData(`/classification`,{impact:n.classification.impact,quality:n.classification.quality,rID:e})}async submitAnswerForm(e){let t=await this.internalData.metadata;if(t.mode!==`ready`)throw Error(`Can not submit the answer form unless we are in ready mode`);let n={receiverEmail:e.receiverEmail,fields:e.fields,query:e.question,answer:e.answer,rID:e.requestId,uID:t.userId,lang:e.lang};await this.internalData.restClient.postData(`/customform`,n)}async userAction(e,t={}){let n=await this.internalData.metadata;if(n.mode!==`ready`)throw Error(`Can not post user action unless we are in ready mode`);let r={uID:n.userId,cID:t.conversationId,lang:t.lang,userAction:e};await this.internalData.restClient.postData(`/assistant/userAction`,r)}async search(e,t={}){let n=await this.internalData.metadata,r=n.mode===`ready`?n.userId:void 0,{links:i}=await this.internalData.restClient.fetchData(`/assistant/search`,Ii,{modelId:t.model,lang:t.language,query:e,mapResults:`true`,uID:r});return new $i(i.map(Li))}async getChatConfig(){return this.internalData.restClient.fetchData(`/chatconfig`,vi)}async getChatHistory(e,t){try{let n=await this.internalData.restClient.postData(`/chathistory`,{cID:e,uID:t}),r=hi.safeParse(await n.json());return r.success?r.data:[]}catch(e){return console.error(`Failed to load chat history:`,e),[]}}async getPredefinedQuestions(e){return(await this.internalData.restClient.fetchData(`/topics/questions`,gi,e)).predefinedQuestions}async transcribeAudio(e,t={}){let n=await this.internalData.metadata,r=t.lang||`de-CH`;if(n.mode===`maintenance`)throw Error(`Can not transcribe audio in maintenance mode`);try{let t=(e=>e.includes(`mp4`)?`mp4`:e.includes(`webm`)?`webm`:(e.includes(`wav`),`wav`))(e.type),n=new FormData;return n.append(`file`,e,`audio.${t}`),n.append(`lang`,r),n.append(`type`,e.type),{transcript:await(await this.internalData.restClient.postFormData(`/speech?key=${this.internalData.restClient.speechRecognitionApiKey||``}&lang=${r}`,n)).text()||``,error:void 0}}catch(e){return console.error(`Error transcribing audio:`,e),{transcript:``,error:e instanceof Error?e.message:`Unknown error`}}}},na=(e,t)=>{try{let n=new URL(e),r=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}},ra=e=>{try{return new URL(e).origin===window.location.origin}catch{return!1}},ia=()=>`${window.location.protocol}//${window.location.host}${window.location.pathname}`;function aa(e,{embedded:t}){let n=e??`all`;if(n===`none`)return;if(t||n===`location`)return ia();let r=na(document.referrer,window.location.href)?``:document.referrer;if(r&&!(n===`own`&&!ra(r)))return r}var oa=f(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}}));function sa(...e){return e.filter(Boolean).join(` `)}var ca=typeof document<`u`,la=typeof window<`u`?window:void 0;typeof window<`u`&&window.document,typeof window<`u`&&window.navigator,typeof window<`u`&&window.location;function ua(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}var da=class extends Map{#e=new Map;#t=t(0);#n=t(0);#r=_||-1;constructor(e){if(super(),e){for(var[t,n]of e)super.set(t,n);this.#n.v=super.size}}#i(e){return _===this.#r?t(e):ie(e)}has(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else return g(this.#t),!1;return g(n),!0}forEach(e,t){this.#a(),super.forEach(e,t)}get(e){var t=this.#e,n=t.get(e);if(n===void 0)if(super.has(e))n=this.#i(0),t.set(e,n);else{g(this.#t);return}return g(n),super.get(e)}set(e,t){var r=this.#e,i=r.get(e),a=super.get(e),o=super.set(e,t),s=this.#t;if(i===void 0)i=this.#i(0),r.set(e,i),c(this.#n,super.size),n(s);else if(a!==t){n(i);var l=s.reactions===null?null:new Set(s.reactions);(l===null||!i.reactions?.every(e=>l.has(e)))&&n(s)}return o}delete(e){var t=this.#e,r=t.get(e),i=super.delete(e);return r!==void 0&&(t.delete(e),c(r,-1)),i&&(c(this.#n,super.size),n(this.#t)),i}clear(){if(super.size!==0){super.clear();var e=this.#e;c(this.#n,0);for(var t of e.values())c(t,-1);n(this.#t),e.clear()}}#a(){g(this.#t);var e=this.#e;if(this.#n.v!==e.size){for(var t of super.keys())if(!e.has(t)){var n=this.#i(0);e.set(t,n)}}for([,n]of this.#e)g(n)}keys(){return g(this.#t),super.keys()}values(){return this.#a(),super.values()}entries(){return this.#a(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return g(this.#n),super.size}};new class{#e;#t;constructor(e={}){let{window:t=la,document:n=t?.document}=e;t!==void 0&&(this.#e=n,this.#t=l(e=>{let n=te(t,`focusin`,e),r=te(t,`focusout`,e);return()=>{n(),r()}}))}get current(){return this.#t?.(),this.#e?ua(this.#e):null}};function fa(e){return typeof e==`function`}var pa=class{#e;#t;constructor(e){this.#e=e,this.#t=Symbol(e)}get key(){return this.#t}exists(){return me(this.#t)}get(){let e=d(this.#t);if(e===void 0)throw Error(`Context "${this.#e}" not found`);return e}getOr(e){let t=d(this.#t);return t===void 0?e:t}set(e){return a(this.#t,e)}};function ma(e,t){switch(e){case`post`:pe(t);break;case`pre`:ee(t);break}}function ha(e,t,n,r={}){let{lazy:i=!1}=r,a=!i,o=Array.isArray(e)?[]:void 0;ma(t,()=>{let t=Array.isArray(e)?e.map(e=>e()):e();if(!a){a=!0,o=t;return}let r=oe(()=>n(t,o));return o=t,r})}function ga(e,t,n){let r=p(()=>{let i=!1;ha(e,t,(e,t)=>{if(i){r();return}let a=n(e,t);return i=!0,a},{lazy:!0})});pe(()=>r)}function _a(e,t,n){ha(e,`post`,t,n)}function va(e,t,n){ha(e,`pre`,t,n)}_a.pre=va;function ya(e,t){ga(e,`post`,t)}function ba(e,t){ga(e,`pre`,t)}ya.pre=ba;function xa(e){return fa(e)?e():e}var Sa=class{#e={width:0,height:0};#t=!1;#n;#r;#i;#a=s(()=>(g(this.#s)?.(),this.getSize().width));#o=s(()=>(g(this.#s)?.(),this.getSize().height));#s=s(()=>{let e=xa(this.#r);if(e)return l(t=>{if(!this.#i)return;let n=new this.#i.ResizeObserver(e=>{this.#t=!0;for(let t of e){let e=this.#n.box===`content-box`?t.contentBoxSize:t.borderBoxSize,n=Array.isArray(e)?e:[e];this.#e.width=n.reduce((e,t)=>Math.max(e,t.inlineSize),0),this.#e.height=n.reduce((e,t)=>Math.max(e,t.blockSize),0)}t()});return n.observe(e),()=>{this.#t=!1,n.disconnect()}})});constructor(e,t={box:`border-box`}){this.#i=t.window??la,this.#n=t,this.#r=e,this.#e={width:0,height:0}}calculateSize(){let e=xa(this.#r);if(!e||!this.#i)return;let t=e.offsetWidth,n=e.offsetHeight;if(this.#n.box===`border-box`)return{width:t,height:n};let r=this.#i.getComputedStyle(e),i=parseFloat(r.paddingLeft)+parseFloat(r.paddingRight),a=parseFloat(r.paddingTop)+parseFloat(r.paddingBottom),o=parseFloat(r.borderLeftWidth)+parseFloat(r.borderRightWidth),s=parseFloat(r.borderTopWidth)+parseFloat(r.borderBottomWidth);return{width:t-i-o,height:n-a-s}}getSize(){return this.#t?this.#e:this.calculateSize()??this.#e}get current(){return g(this.#s)?.(),this.getSize()}get width(){return g(this.#a)}get height(){return g(this.#o)}},Ca=class{#e=()=>void 0;#t=s(()=>this.#e());constructor(e,t){let n;t!==void 0&&(n=t),this.#e=()=>{try{return n}finally{n=e()}}}get current(){return g(this.#t)}};function wa(e,t){let n,r=null;return(...i)=>new Promise(a=>{r&&r(void 0),r=a,clearTimeout(n),n=setTimeout(async()=>{let t=await e(...i);r&&=(r(t),null)},t)})}function Ta(e,t){let n=0,r=null;return(...i)=>{let a=Date.now();return n&&a-n<t?r??Promise.resolve(void 0):(n=a,r=e(...i),r)}}function Ea(e,n,i={},a){let{lazy:o=!1,once:s=!1,initialValue:l,debounce:u,throttle:d}=i,f=t(r(l)),p=t(!1),m=t(void 0),ee=t(r([])),h=()=>{g(ee).forEach(e=>e()),c(ee,[],!0)},te=e=>{c(ee,[...g(ee),e],!0)},ne=async(e,t,r=!1)=>{try{c(p,!0),c(m,void 0),h();let i=new AbortController;te(()=>i.abort());let a=await n(e,t,{data:g(f),refetching:r,onCleanup:te,signal:i.signal});return c(f,a,!0),a}catch(e){e instanceof DOMException&&e.name===`AbortError`||c(m,e,!0);return}finally{c(p,!1)}},_=u?wa(ne,u):d?Ta(ne,d):ne,re=Array.isArray(e)?e:[e],ie;return a((t,n)=>{s&&ie||(ie=t,_(Array.isArray(e)?t:t[0],Array.isArray(e)?n:n?.[0]))},{lazy:o}),{get current(){return g(f)},get loading(){return g(p)},get error(){return g(m)},mutate:e=>{c(f,e,!0)},refetch:t=>{let n=re.map(e=>e());return _(Array.isArray(e)?n:n[0],Array.isArray(e)?n:n[0],t??!0)}}}function Da(e,t,n){return Ea(e,t,n,(t,n)=>{let r=Array.isArray(e)?e:[e];_a(()=>r.map(e=>e()),(e,n)=>{t(e,n??[])},n)})}function Oa(e,t,n){return Ea(e,t,n,(t,n)=>{let r=Array.isArray(e)?e:[e];_a.pre(()=>r.map(e=>e()),(e,n)=>{t(e,n??[])},n)})}Da.pre=Oa,new pa(`richColorsContext`);var ka=new pa(`<Toaster/>`),Aa=0;function ja(e){return typeof e?.id==`number`||typeof e?.id==`string`&&e.id.length>0?e.id:Aa++}var Ma=class{#e=t(r([]));get toasts(){return g(this.#e)}set toasts(e){c(this.#e,e,!0)}#t=t(r([]));get heights(){return g(this.#t)}set heights(e){c(this.#t,e,!0)}#n=new Map;#r=e=>{let t=this.toasts.findIndex(t=>t.id===e);return t===-1?null:t};#i=e=>this.heights.findIndex(t=>t.toastId===e);addToast=e=>{ca&&this.toasts.unshift(e)};updateToast=({id:e,data:t,type:n,message:r})=>{let i=this.toasts.findIndex(t=>t.id===e),a=this.toasts[i];this.toasts[i]={...a,...t,id:e,title:r,type:n,dismiss:!1,delete:!1,updated:!0}};markDismissed=e=>{let t=this.#r(e);if(t===null)return;let n=this.toasts[t];n&&(!n.dismiss||!n.delete)&&(this.toasts[t]={...n,dismiss:!0,delete:!0})};scheduleRemoval=(e,t)=>{this.cancelRemoval(e),this.#n.set(e,setTimeout(()=>{this.#n.delete(e),this.remove(e)},t))};cancelRemoval=e=>{let t=this.#n.get(e);t!==void 0&&(clearTimeout(t),this.#n.delete(e))};create=e=>{let{message:t,...n}=e,r=ja(e),i=e.dismissible===void 0?e.dismissable===void 0?!0:e.dismissable:e.dismissible,a=e.type===void 0?`default`:e.type;return oe(()=>{this.cancelRemoval(r);let o=this.toasts.find(e=>e.id===r);o?.dismiss||o?.delete?(this.remove(r),this.addToast({...n,id:r,title:t,dismissible:i,type:a,updated:!0})):o?this.updateToast({id:r,data:e,type:a,message:t,dismissible:i}):this.addToast({...n,id:r,title:t,dismissible:i,type:a})}),r};dismiss=e=>(oe(()=>{if(e===void 0){this.toasts=this.toasts.map(e=>e.dismiss?e:{...e,dismiss:!0});return}let t=this.toasts.findIndex(t=>t.id===e);this.toasts[t]&&(this.toasts[t]={...this.toasts[t],dismiss:!0})}),e);remove=e=>{if(e===void 0){this.toasts=[];return}let t=this.#r(e);if(t!==null)return this.toasts.splice(t,1),e};message=(e,t)=>this.create({...t,type:`default`,message:e});error=(e,t)=>this.create({...t,type:`error`,message:e});success=(e,t)=>this.create({...t,type:`success`,message:e});info=(e,t)=>this.create({...t,type:`info`,message:e});warning=(e,t)=>this.create({...t,type:`warning`,message:e});loading=(e,t)=>this.create({...t,type:`loading`,message:e});promise=(e,t)=>{if(!t)return;let n;t.loading!==void 0&&(n=this.create({...t,promise:e,type:`loading`,message:typeof t.loading==`string`?t.loading:t.loading()}));let r=e instanceof Promise?e:e(),i=n!==void 0;return r.then(e=>{if(typeof e==`object`&&e&&`ok`in e&&typeof e.ok==`boolean`&&!e.ok){i=!1;let t=Na(e);this.create({id:n,type:`error`,message:t})}else if(t.success!==void 0){i=!1;let r=typeof t.success==`function`?t.success(e):t.success;this.create({id:n,type:`success`,message:r})}}).catch(e=>{if(t.error!==void 0){i=!1;let r=typeof t.error==`function`?t.error(e):t.error;this.create({id:n,type:`error`,message:r})}}).finally(()=>{i&&(this.dismiss(n),n=void 0),t.finally?.()}),n};custom=(e,t)=>{let n=ja(t);return this.create({component:e,...t,id:n}),n};removeHeight=e=>{this.heights=this.heights.filter(t=>t.toastId!==e)};setHeight=e=>{oe(()=>{let t=this.#i(e.toastId);if(t!==-1){this.heights[t]=e;return}let n=new Map(this.toasts.map((e,t)=>[e.id,t])),r=n.get(e.toastId)??-1,i=this.heights.findIndex(e=>(n.get(e.toastId)??1/0)>r);i===-1?this.heights.push(e):this.heights.splice(i,0,e)})};reset=()=>{this.toasts=[],this.heights=[],this.#n.forEach(e=>clearTimeout(e)),this.#n.clear()}};function Na(e){return e&&typeof e==`object`&&`status`in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}var Z=new Ma;function Pa(e,t){return Z.message(e,t)}var Fa=class{#e=s(()=>Z.toasts.filter(e=>!e.dismiss));get toasts(){return g(this.#e)}},Ia=Object.assign(Pa,{success:Z.success,info:Z.info,warning:Z.warning,error:Z.error,custom:Z.custom,message:Z.message,promise:Z.promise,dismiss:Z.dismiss,loading:Z.loading,getActiveToasts:()=>Z.toasts.filter(e=>!e.dismiss)}),La=e=>{let t=new Set;Object.getOwnPropertyNames(e).forEach(e=>t.add(e));let n=Object.getPrototypeOf(e);for(;n&&n!==Object.prototype;)Object.getOwnPropertyNames(n).forEach(e=>t.add(e)),n=Object.getPrototypeOf(n);return Array.from(t)},Ra=(e,t)=>{let n={};return t.forEach(t=>{n[t]=e[t]}),n},za=console.warn,Ba=()=>{},Va=(e,t)=>oe(()=>{console.warn=Ba;let n=i(t?Ra(e,t):e);return console.warn=za,n}),Ha=e=>e&&typeof e.then==`function`,Ua=class{config;self;devtools;stateKeys;constructor(e,t){this.config=e,this.self=t,typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&(this.stateKeys=La(this.config.state),this.devtools=window.__REDUX_DEVTOOLS_EXTENSION__.connect({name:this.config.name??`updatelogic`}),this.devtools.init(this.createStateSnapshot()),this.devtools.subscribe(e=>{e.type===`DISPATCH`&&e.state}))}createStateSnapshot(){return Va(this.config.state,this.stateKeys)}sendStart(e,t){this.devtools.send({type:`→ ${e}`,args:t},this.createStateSnapshot())}sendError(e,t,n){this.devtools.send({type:`❌ ${e}`,args:t,error:n},this.createStateSnapshot())}sendSuccess(e,t,n){this.devtools.send({type:`✓ ${e}`,args:t,return:n},this.createStateSnapshot())}isIncluded(e){return this.config.excludeInDevTools?!this.config.excludeInDevTools.includes(e):!0}createProxyFunction(e,t){let n=this.devtools&&this.isIncluded(e);return typeof t==`function`?(...r)=>{if(!n)return oe(()=>t.call(this.self,...r));let i=Va(r);this.sendStart(e,i);try{let n=oe(()=>t.call(this.self,...r));return Ha(n)?n.then(t=>(this.sendSuccess(e,i,t),t),t=>{throw this.sendError(e,i,t),t}):(this.sendSuccess(e,i,n),n)}catch(t){throw this.sendError(e,i,t),t}}:t}},Wa=(e,t)=>{let n={},r=new Ua(e,n);return Object.keys(t).forEach(e=>{if(e===`state`||e===`name`)return;let i=t[e];n[e]=r.createProxyFunction(e,i)}),n};async function Ga(){if(typeof navigator>`u`||!navigator.mediaDevices||!navigator.mediaDevices.enumerateDevices)return!1;try{return(await navigator.mediaDevices.enumerateDevices()).some(e=>e.kind===`audioinput`)}catch(e){return console.error(`Error checking for microphone:`,e),!1}}function Ka(){return typeof window>`u`||!window.MediaRecorder?null:MediaRecorder.isTypeSupported(`audio/mp4`)?`audio/mp4`:MediaRecorder.isTypeSupported(`audio/webm`)?`audio/webm`:MediaRecorder.isTypeSupported(`audio/wav`)?`audio/wav`:null}function qa(){return typeof window>`u`?!1:!!(window.MediaRecorder&&Ka())}function Ja(){if(typeof window>`u`)return!1;if(`ontouchstart`in window||navigator.maxTouchPoints>0)return!0;let e=navigator.msMaxTouchPoints;return!!(`msMaxTouchPoints`in navigator&&e&&e>0)}function Ya(){return typeof window>`u`?!1:!!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||Ja())}var Xa=class{mediaRecorder=null;audioChunks=[];started=!1;starting=!1;stream=null;options;audioContext=null;analyser=null;dataArray=null;volumeUpdateInterval=null;constructor(e={}){this.options=e}async start(){if(this.started||this.starting){console.warn(`AudioRecorder: Start already in progress or already started`);return}if(!qa()||!navigator.mediaDevices){let e=Error(`MediaRecorder not supported or no microphone access`);throw this.options.onError?.(e),e}try{if(this.starting=!0,this.stream=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!0,noiseSuppression:!0,autoGainControl:!0},video:!1}),!this.starting){this.stopStream(this.stream);return}this.mediaRecorder&&this.mediaRecorder.state!==`inactive`&&(console.warn(`AudioRecorder: MediaRecorder already active, stopping previous recording`),this.mediaRecorder.stop(),this.cleanup()),this.started=!0,this.starting=!1;let e=Ka();if(!e)throw Error(`No supported media type found`);let t={mimeType:e};this.mediaRecorder=new MediaRecorder(this.stream,t),this.audioChunks=[],this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.audioChunks.push(e.data)},this.mediaRecorder.onstop=async()=>{let t=this.audioChunks.length>0?new Blob(this.audioChunks,{type:e}):null;await this.options.onDataAvailable?.(t),this.options.onStop?.(),this.cleanup()},this.mediaRecorder.onerror=e=>{let t=Error(`MediaRecorder error: ${e}`);this.options.onError?.(t),this.cleanup()},this.mediaRecorder.start(),this.setupVolumeAnalysis(this.stream),this.options.onStart?.()}catch(e){this.started=!1,this.starting=!1;let t=e instanceof Error?e:Error(String(e));throw this.options.onError?.(t),t}}stop(){this.started=!1,this.starting=!1,this.volumeUpdateInterval&&=(clearInterval(this.volumeUpdateInterval),null),this.mediaRecorder&&this.mediaRecorder.state!==`inactive`?this.mediaRecorder.stop():(this.stream&&this.stopStream(this.stream),this.cleanup())}setupVolumeAnalysis(e){if(this.options.onVolumeChange)try{this.audioContext=new AudioContext,this.analyser=this.audioContext.createAnalyser(),this.analyser.fftSize=256,this.analyser.smoothingTimeConstant=.8;let t=this.analyser.frequencyBinCount;this.dataArray=new Uint8Array(t),this.audioContext.createMediaStreamSource(e).connect(this.analyser),this.startVolumeMonitoring()}catch(e){console.warn(`Failed to set up volume analysis:`,e)}}startVolumeMonitoring(){!this.analyser||!this.dataArray||!this.options.onVolumeChange||(this.volumeUpdateInterval=window.setInterval(()=>{if(!this.analyser||!this.dataArray||!this.started)return;this.analyser.getByteFrequencyData(this.dataArray);let e=0;for(let t=0;t<this.dataArray.length;t++)e+=this.dataArray[t]*this.dataArray[t];let t=Math.sqrt(e/this.dataArray.length)/255;t=(t*3)**.7;let n=Math.min(100,Math.max(0,Math.round(t*100)));this.options.onVolumeChange?.(n)},100))}get recording(){return this.started&&this.mediaRecorder?.state===`recording`}get isStarting(){return this.starting}stopStream(e){e.getTracks().forEach(e=>e.stop())}cleanup(){this.volumeUpdateInterval&&=(clearInterval(this.volumeUpdateInterval),null),this.audioContext&&=(this.audioContext.close().catch(console.warn),null),this.analyser=null,this.dataArray=null,this.stream&&=(this.stopStream(this.stream),null),this.mediaRecorder=null,this.audioChunks=[],this.started=!1,this.starting=!1}static isSupported(){return qa()}static getSupportedMediaType(){return Ka()}},Za=lt(),Qa=(e,t)=>{if(e instanceof HTMLTextAreaElement&&t instanceof HTMLTextAreaElement){t.textContent=e.value;return}if(e instanceof HTMLSelectElement&&t instanceof HTMLSelectElement){Array.from(e.options).forEach((e,n)=>{t.options[n]&&(t.options[n].selected=e.selected)});return}e instanceof HTMLInputElement&&t instanceof HTMLInputElement&&(t.setAttribute(`value`,e.value),(e.type===`checkbox`||e.type===`radio`)&&(e.checked?t.setAttribute(`checked`,`checked`):t.removeAttribute(`checked`)))},$a=e=>{let t=e.cloneNode(!0);if(!(t instanceof Element))return``;let n=`input, textarea, select`,r=e.querySelectorAll(n),i=t.querySelectorAll(n);return r.forEach((e,t)=>{let n=i[t];n&&Qa(e,n)}),Za.sanitize(t.outerHTML,{FORBID_TAGS:[`style`,`script`],FORBID_ATTR:[`style`,`class`]})},eo=e=>{if(!e?.length)return[];let t=e.join(`,`),n=document.querySelectorAll(t);return Array.from(n,$a)},to=`liipgpt:context`,no=()=>localStorage.getItem(to),ro=[{type:`email`,check:e=>/\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}\b/.test(e)},{type:`creditCard`,check:e=>/\b(?:\d[ -]*?){13,16}\b/.test(e)},{type:`ahv`,check:e=>/\b756[.\s-]?\d{2,4}[.\s-]?\d{2,4}[.\s-]?\d{2}\b/.test(e)},{type:`phoneSwiss`,check:e=>/\b0(?:\s*\d){2}(?:\s*\/\s*)?(?:\s*\d){7,}\b/.test(e)},{type:`phoneInternational`,check:e=>/(?:\+|00)(?:\s*\d){10,}\b/.test(e)},{type:`swissPassport`,check:e=>/\b[A-HJ-NP-Z](?=.*\d)[A-HJ-NP-Z0-9]{7}\b/.test(e)},{type:`longNumber`,check:e=>/\b\d{9,}\b/.test(e)}],io=e=>{for(let t of ro)if(t.check(e))return t.type},ao=`liipgpt:selectorValues`,oo=`liipgpt:selectorKnownDefaults`,so=()=>{try{let e=Y.getItem(ao),t=Y.getItem(oo);return e?{values:JSON.parse(e),knownDefaults:t?JSON.parse(t):{}}:null}catch{return null}},co=e=>{let t={};for(let n of e)t[n.settingName]=n.defaultValues??(n.allowEmpty?[]:[n.values[0]]).filter(Boolean);return t},lo=(e,t)=>{try{let n=co(t);Y.setItem(ao,JSON.stringify(e)),Y.setItem(oo,JSON.stringify(n))}catch(e){console.error(`Failed to save selector values:`,e)}},uo=e=>{try{let t=so();if(!t)return;delete t.values[e],delete t.knownDefaults[e],Y.setItem(ao,JSON.stringify(t.values)),Y.setItem(oo,JSON.stringify(t.knownDefaults))}catch(e){console.error(`Failed to clear selector saved state:`,e)}},fo=e=>{let t=so(),n=e.map(e=>{let n=e.defaultValues??(e.allowEmpty?[]:[e.values[0]]).filter(Boolean);if(!t?.values[e.settingName])return[e.settingName,n];let r=t.values[e.settingName],i=t.knownDefaults[e.settingName]||[],a=r.filter(t=>e.values.includes(t)),o=i.filter(e=>!n.includes(e)),s=a.filter(e=>!o.includes(e)),c=n.filter(e=>!i.includes(e)&&!s.includes(e)),l=[...s,...c];return l.length===0&&!e.allowEmpty?[e.settingName,n]:[e.settingName,l]});return Object.fromEntries(n)},po=class extends Error{constructor(e){super(e),this.name=`UnreachableError`}},mo=u({chatState:()=>h,logic:()=>ko}),ho=e(re(),1),go=e(oa(),1),_o=(e,t)=>{if(!e)return;let n=t.find(t=>t.id===e);return n||console.warn(`autofire-predefined-question-id="${e}" did not match any loaded predefined question. Falling back to default routing.`),n},vo=(e,t,n,r,i)=>{if(e&&!t)return{name:`consent-page`};let a=new URLSearchParams(window.location.search),o=a.get(`q`),s=a.get(`id`)??void 0,c=a.get(`sid`)??void 0;return o?{name:`chat-page`,query:o,predefinedQuestionId:s,switchQuestionId:c}:i?{name:`chat-page`,query:i}:r?{name:`chat-page`,query:r.question,predefinedQuestionId:r.id}:n?{name:`chat-page`}:{name:`start-page`}},yo=`follow-up-q`,bo=e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),xo=()=>{let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`cID`)??void 0;return{cID:e&&bo(e)?e:void 0,followUpQuestion:new URLSearchParams(window.location.search).get(yo)?.trim()||void 0}},So=()=>{let e=new URLSearchParams(window.location.search);if(!e.has(yo))return;e.delete(yo);let t=e.toString();history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)},Co=e=>{if(e)try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t;console.warn(`additional-start-parameters must be a JSON object. Received: ${e}`);return}catch(t){console.warn(`Failed to parse additional-start-parameters as JSON: ${e}`,t);return}},wo=e=>{let t=Co(e);return t?(e=>Array.isArray(e)?e.map(String):typeof e==`string`?e.split(`,`).map(e=>e.trim()).filter(Boolean):[])(t.scopeAvailableSlugs).length===1:!1},To=e=>e?e.map(e=>({id:Ti(),...e})):[],Q,$,Eo,Do=new Set,Oo=async e=>{if(Do.has(e))return;let t=(await de([e]))[e];if(t){let n=h.data.chatConfig.translations[e]??{};h.data.chatConfig.translations[e]=(0,ho.default)(t,n)}Do.add(e)},ko=Wa({name:`chat-logic`,state:h,excludeInDevTools:[`onInput`]},{async init(e){$=e;let t=$.speechRecognitionApiKey||void 0;Q=new ta({apiUrl:$.apiUrl,apiKey:$.apiKey,speechRecognitionApiKey:t,strict:!0,startParameters:Co($.additionalStartParameters)});try{let e=await Q.getChatConfig();window.CHAT_CONFIG_OVERRIDE&&Object.assign(e,window.CHAT_CONFIG_OVERRIDE);let t=(await Q.getMetadata()).mode===`maintenance`;t&&this.showErrorToast(`maintenance`);let n=fe($.lang,v(e.supportedLanguages));Do.add(n);let r=se(e,await de([n]));$.inlineLayout!==void 0&&(r.inlineLayout=$.inlineLayout),$.forceChatPage!==void 0&&(r.forceChatPage=$.forceChatPage);let i=n;ne(i,h.targets.mainElement);let a=await this.getPredefinedQuestions(i),o=r.translations[i]?.ariaOpensInNewTab;o&&Q.setNewTabSrText(o);let s=[];if(r.renderKatex){let e=await import(`https://esm.sh/marked-katex-extension@5.1.5`).catch(e=>{console.error(`Couldn't load marked-katex-extension:`,e)});e&&(Q.setMarkedExtensions(e.default({nonStandard:!0,output:`mathml`})),s.push(`https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css`))}let c=Object.keys(r.fullTheme),l=!1;if(r.forceConsent)try{l=Y.getItem(`liipgpt:termsAccepted`)===`true`}catch(e){console.warn(`Failed to load terms acceptance from storage:`,e)}let u=_o($.autofirePredefinedQuestionId,a);h.data={currentConversationState:`idle`,chatConfig:r,language:i,predefinedQuestions:a,isInMaintenance:t,history:To(r.messageAdditions.init),selectedColorScheme:ce(),has2ColorSchemes:c.length===2,currentColorScheme:m(c),conversationFeedbackId:void 0,conversationFeedbackIsOpen:!1,answerFormMessageId:void 0,openedPopup:void 0,props:$,flyoutIsOpen:!1,questionHasPii:void 0,chatInputValue:``,selectorValues:fo(r.selectorsConfig),selectorsIsOpen:!1,predefinedQuestionId:void 0,switchQuestionId:void 0,currentReferencesAsideId:void 0,ariaLiveStatusMessage:void 0,ariaLiveStatusMessageClearingTimeout:void 0,wasReferencesAsideClosed:!1,isAsideMobile:!0,route:vo(r.forceConsent??!1,l,r.forceChatPage??!1,u,$.question),additionalStylesheets:s,hasOpenedOverlays:!1,isInlineLayoutContained:!1,termsAccepted:l,selectedTopic:void 0},window.LIIPGPT_LISTENERS?.route?.(h.data.route),window.LIIPGPT_LISTENERS?.conversation?.(h.data.currentConversationState),h.data.selectorsIsOpen=h.data.chatConfig.showExpandedSelectors??!1,h.initialized=!0,this.checkForOpenedPopup(),window.addEventListener(`hashchange`,()=>{this.checkForOpenedPopup()}),await this.startFromHandoverOrRoute(()=>this.goto(vo(r.forceConsent??!1,l,r.forceChatPage??!1,u,$.question),!0))}catch(e){throw Ia.error(e instanceof Error?e.message:`Failed to load the chatbot. Please reload the page.`,{duration:1e4,unstyled:!0,classes:{toast:`toast`}}),e}},setTarget(e,t){h.targets[e]=t},goto(e,t=!1){if(!(!t&&(0,go.default)(h.data.route,e)))switch(h.data.route=e,window.LIIPGPT_LISTENERS?.route?.(e),e.name){case`consent-page`:break;case`start-page`:e.prefill&&(h.data.chatInputValue=e.prefill);break;case`chat-page`:if(h.data.chatInputValue=e.query??``,h.data.predefinedQuestionId=e.predefinedQuestionId,h.data.switchQuestionId=e.switchQuestionId,e.query&&(this.onSubmit(),h.data.chatConfig.addQueryToUrlParams)){let t=new URLSearchParams(window.location.search);t.set(`q`,e.query),e.predefinedQuestionId?t.set(`id`,e.predefinedQuestionId):t.delete(`id`),e.switchQuestionId?t.set(`sid`,e.switchQuestionId):t.delete(`sid`),history.pushState(null,``,`?${t.toString()}${window.location.hash}`)}break}},getSelectorConfig(e){let t=h.data.chatConfig.selectorsConfig.find(t=>t.settingName===e);if(!t)throw Error(`Setting ${e} not found`);return t},getPrettifiedSelectorValues(){let e=Object.entries(h.data.selectorValues).map(([e,t])=>{let n;try{n=this.getSelectorConfig(e)}catch(t){console.error(`Error getting selector config for ${e}: ${t}`);return}return n.type===`single-select`?[e,t[0]]:[e,t]}).filter(e=>!!e);return Object.fromEntries(e)},setSelectorValue(e,t){let n=this.getSelectorConfig(e);if(!n){console.warn(`Trying to set setting ${e} but it is not defined in the chat config`);return}if(n.type===`single-select`&&t.length>1){console.warn(`Trying to set multiple values for single-select setting ${e}`);return}h.data.selectorValues[e]=t,lo(h.data.selectorValues,h.data.chatConfig.selectorsConfig)},resetSelectorToDefaults(e){let t=this.getSelectorConfig(e);if(!t){console.warn(`Trying to reset setting ${e} but it is not defined in the chat config`);return}let n=t.defaultValues??(t.allowEmpty?[]:[t.values[0]]).filter(Boolean);return uo(e),h.data.selectorValues[e]=n,lo(h.data.selectorValues,h.data.chatConfig.selectorsConfig),n},async getPredefinedQuestions(e){if($?.hidePredefinedQuestions)return[];try{return Q.getPredefinedQuestions({url:window.location.origin+window.location.pathname,language:e})}catch(e){return console.warn(`Failed to load predefined questions:`,e),[]}},setColorScheme(e){h.data.selectedColorScheme=e,h.data.currentColorScheme=ue(e),this.setAriaLiveStatusMessage(e===`dark`?h.t.ariaDarkSelected:h.t.ariaLightSelected)},async abort(){await Eo?.abort()},changeConversationState(e){h.data.currentConversationState=e,window.LIIPGPT_LISTENERS?.conversation?.(e)},onInput(e){h.data.chatConfig.blockPII&&(h.data.questionHasPii=io(e)),h.data.chatInputValue=e,h.data.predefinedQuestionId=void 0,h.data.switchQuestionId=void 0},onSubmit(e=!1,t,n=!1){let r=eo(h.data.chatConfig.parentPageContext?.extractSelectors);if(h.data.questionHasPii){console.warn(`Question contains PII, not submitting:`,h.data.questionHasPii);return}let i=h.data.chatConfig.questionPrefix?`${h.data.chatConfig.questionPrefix} ${h.data.chatInputValue}`:h.data.chatInputValue;n||(h.data.history.push(...To(h.data.chatConfig.messageAdditions.user.before)),h.data.history.push({type:`user`,time:new Date().toISOString(),message:h.data.chatInputValue}),h.data.history.push(...To(h.data.chatConfig.messageAdditions.user.after)));let a=h.data.history.push(...To(h.data.chatConfig.messageAdditions.bot.before));h.data.history.push({id:`UNRESOLVED`,state:`loading`,errors:[],type:`bot`,time:new Date().toISOString(),message:{markdown:``,html:``,text:``},references:{all:[],used:[],unused:[]}});let o=!1,s=!1,c={features:$.features?$.features.trim().split(`,`):[`formatting`],mode:$.mode||void 0,cache:$.cache||void 0,onError:(e,t)=>{this.showErrorToast(e,t),window.LIIPGPT_LISTENERS?.error?.(e,t),(e===`pii-detected`||e===`blocked`)&&this.editLatestQuestion()},onMessage:e=>{e.type===`topic-selected`&&(h.data.selectedTopic={label:e.label,placeholder:e.placeholder,locked:wo($.additionalStartParameters)}),e.type===`state`&&e.state!==`history-entry-initialized`&&!s&&(s=!0,this.setAriaLiveStatusMessage(h.t.ariaQuestionSent))},lang:h.data.language,selectorValues:{...this.getPrettifiedSelectorValues(),context:no(),...t},predefinedQuestionId:h.data.predefinedQuestionId,switchQuestionId:h.data.switchQuestionId,onEmbed:e=>{let t=h.data.history[a];t&&t.type===`bot`&&!t.message.markdown?(h.data.history[a]={...e,id:t.id??Ti()},o=!0):h.data.history.push({...e,id:Ti()})}};h.data.predefinedQuestionId=void 0,h.data.switchQuestionId=void 0,r.length&&(c.selectorValues.parentPageContextHtml=r),c.referrer=aa(h.data.chatConfig.sendReferrer,{embedded:!!h.data.props.flyout}),h.data.props.source?c.source=h.data.props.source:h.data.props.flyout&&(c.source=`flyout`),h.data.currentConversationId||(h.data.currentConversationId=Q.createConversationId());let l=Q.chat(h.data.currentConversationId,i,c);Eo=l,h.data.lastChatResponseId=l.id,h.data.currentConversationState!==`searching`&&this.changeConversationState(`searching`);let u=!1,d,f=!!h.data.currentReferencesAsideId;(e&&f||!e&&h.data.chatConfig.showReferencesByDefault)&&(h.data.isAsideMobile||this.openReferencesAside(l.id)),l.subscribe(e=>{if(!o&&h.data.history[a]&&(h.data.history[a]={question:h.data.chatInputValue,...e}),h.data.chatConfig.addRetrievalQuestionToUrlParams&&e.retrievalQuestion){let t=new URLSearchParams(window.location.search);t.get(`search`)!==e.retrievalQuestion&&(t.set(`search`,e.retrievalQuestion),history.replaceState(null,``,`?${t.toString()}${window.location.hash}`))}h.data.chatConfig.showReferencesByDefault&&!h.data.wasReferencesAsideClosed&&h.data.currentReferencesAsideId!==e.id&&!h.data.isAsideMobile&&this.openReferencesAside(e.id),e.state===`streaming`&&h.data.currentConversationState!==`answering`&&this.changeConversationState(`answering`),e.state===`done`&&(this.changeConversationState(`idle`),u||(u=!0,this.setAriaLiveStatusMessage(`${h.t.ariaAnswerReady} ... ${e.message.text} ... ${h.data.selectedTopic?h.t.ariaAnswerFinishedWithSelectedTopic:h.t.ariaAnswerFinished}`),h.data.history.push(...To(h.data.chatConfig.messageAdditions.bot.after))),h.data.currentReferencesAsideId&&e.references.used.length>0?(clearTimeout(d),d=setTimeout(()=>{this.openReferencesAside(e.id)},100)):this.closeReferencesAside())}),h.data.chatInputValue=``},async onStartSpeechRecognition(){try{if(!await Ga()){this.showErrorToast(`speech-not-supported`);return}if(await navigator.mediaDevices.getUserMedia({audio:!0}),Xa.isSupported())h.data.chatInputValue=``,h.currentAudioRecorder=new Xa({onDataAvailable:async e=>{h.isTranscribing=!0,await this.handleTranscription(e)},onError:()=>{this.showErrorToast(`speech-microphone-access-denied`),h.currentAudioRecorder=null,h.isTranscribing=!1},onVolumeChange:e=>{h.currentAudioVolume=e}}),h.currentAudioRecorder.start();else{this.showErrorToast(`speech-not-supported`);return}}catch(e){throw this.showErrorToast(`speech-microphone-access-denied`),h.currentAudioRecorder=null,h.isTranscribing=!1,e}},editLatestQuestion(){let e=h.data.history.findLastIndex(e=>e?.type===`user`);if(e===-1){console.error(`No last user question, available`);return}let t=h.data.history.splice(e)[0];h.data.chatInputValue=t.message},onStopSpeechRecognition(){if(h.currentAudioRecorder){let e=h.currentAudioRecorder;h.currentAudioRecorder=null,e.stop()}h.currentAudioVolume=0},async handleTranscription(e){if(!e){console.warn(`No audio data received`);return}try{let t=await Q.transcribeAudio(e,{lang:h.data.language});if(t.error){this.showErrorToast(`speech-transcription-failed`);return}if(t.transcript.trim()){if(h.data.chatConfig.blockPII&&(h.data.questionHasPii=io(t.transcript.trim()),h.data.questionHasPii))return;h.data.chatInputValue=t.transcript.trim()}else this.showErrorToast(`speech-no-text-detected`)}catch(e){console.error(`Speech transcription error:`,e),this.showErrorToast(`speech-transcription-failed`)}finally{h.currentAudioRecorder=null,h.isTranscribing=!1,h.currentAudioVolume=0}},async startFromHandoverOrRoute(e){let{cID:t,followUpQuestion:n}=xo();if(!t){e();return}let r=await this.rehydrateFromSearchSummaryHandover(t);n?(h.data.route={name:`chat-page`},h.data.chatInputValue=n,this.onSubmit(!0)):r||e(),So()},async rehydrateFromSearchSummaryHandover(e){h.data.currentConversationId=e;let t=await Q.getMetadata(),n=t.mode===`ready`?t.userId:void 0,r=n?await Q.getChatHistory(e,n):[];if(r.length===0)return h.data.currentConversationId=void 0,!1;let i={all:[],used:[],unused:[]},a=new Dn({newTabSrText:h.t.ariaOpensInNewTab}),o=[];for(let{question:e,answer:t}of r)o.push({type:`user`,time:new Date().toISOString(),message:e,id:Ti()}),o.push({id:Ti(),state:`done`,errors:[],type:`bot`,time:new Date().toISOString(),message:{markdown:t,html:a.toHTML(t,i),text:t},references:{all:[],used:[],unused:[]}});return h.data.history=[...To(h.data.chatConfig.messageAdditions.init),...o],h.data.route={name:`chat-page`},!0},async onStartConversation(e,t,n){await this.abort(),h.data.history=To(h.data.chatConfig.messageAdditions.init),h.data.currentConversationId=Q.createConversationId(),this.goto({name:`chat-page`,query:e,predefinedQuestionId:t,switchQuestionId:n})},async onNewConversation(){await this.abort();let e=h.data.currentConversationId;if(h.data.currentConversationId=void 0,h.data.currentReferencesAsideId=void 0,h.data.history=To(h.data.chatConfig.messageAdditions.init),h.data.predefinedQuestionId=void 0,h.data.switchQuestionId=void 0,h.data.selectedTopic=void 0,h.data.chatConfig.addQueryToUrlParams){let e=new URLSearchParams(window.location.search);e.delete(`q`),e.delete(`id`),e.delete(`sid`),history.pushState(null,``,`?${e.toString()}${window.location.hash}`)}this.goto({name:`start-page`}),e&&Q.userAction(`newDiscussion`,{conversationId:e,lang:h.data.language}).catch(e=>{console.error(`Failed to notify backend of new discussion:`,e)})},async onChangeTopic(){let e=h.data.chatConfig.selectedTopicResetPredefinedQuestionId;if(!e){console.warn("No selectedTopicResetPredefinedQuestionId available to reset the selected topic. Set it in the `Config DB` in the backend, in a `generalConfig` default set.");return}await this.abort(),h.data.selectedTopic=void 0,h.data.predefinedQuestionId=e,h.data.switchQuestionId=void 0,h.data.chatInputValue=``,this.onSubmit(!0,void 0,!0)},showSuccessToast(e){Ia.success(h.t[e],{unstyled:!0,duration:3e3,classes:{toast:`toast`}})},showErrorToast(e,t){let n=t?.trim()?t:h.errorTranslations[e];Ia.error(n,{unstyled:!0,duration:3e3,classes:{toast:`toast`}})},async submitFeedback(e){try{let t=h.data.conversationFeedbackId||h.data.lastChatResponseId;if(!t)throw new po(`Tried to give feedback with no id.`);let n=h.data.history.find(e=>e.type===`bot`&&e.id===t);await Q.feedback(t,n?.question??``,e),setTimeout(()=>{this.showSuccessToast(`thankYouForFeedback`)},500)}catch(e){console.error(`Feedback failed:`,e),this.showErrorToast(`feedback-failed`)}},toggleReferencesAside(e){h.data.currentReferencesAsideId===e?this.closeReferencesAside():this.openReferencesAside(e)},openReferencesAside(e){h.data.chatConfig.referencesLayout!==`inline`&&(h.data.currentReferencesAsideId=e,this.setOpenOverlay(!0))},closeReferencesAside(){h.data.currentReferencesAsideId=void 0,h.data.wasReferencesAsideClosed=!0,this.setOpenOverlay(!1)},setAsideMobile(e){h.data.isAsideMobile=e},openFlyout(){h.data.flyoutIsOpen=!0},closeFlyout(){h.data.flyoutIsOpen=!1},openConversationFeedback(){h.data.conversationFeedbackIsOpen=!0,this.setOpenOverlay(!0)},openMessageFeedback(e){h.data.conversationFeedbackId=e},closeFeedback(){h.data.conversationFeedbackIsOpen=!1,h.data.conversationFeedbackId=void 0,this.setOpenOverlay(!1)},openAnswerForm(e){h.data.answerFormMessageId=e,this.setOpenOverlay(!0)},closeAnswerForm(){h.data.answerFormMessageId=void 0,this.setOpenOverlay(!1)},async submitAnswerForm(e){try{let t=h.data.chatConfig.answerForm,n=h.data.answerFormMessageId;if(!t)throw new po(`Tried to submit the answer form with no answerForm config.`);if(!n)throw new po(`Tried to submit the answer form with no message id.`);let r=h.data.history.findIndex(e=>e.type===`bot`&&e.id===n),i=r===-1?void 0:h.data.history[r],a=h.data.history.slice(0,r===-1?void 0:r).findLast(e=>e.type===`user`)?.message,o=i?.question||a||(i?.type===`bot`?i.retrievalQuestion??``:``);await Q.submitAnswerForm({receiverEmail:t.receiverEmail,fields:t.fields.map(t=>({name:t.name,value:e[t.name]??``})),question:o,answer:i?.type===`bot`?i.message.text:``,requestId:n,lang:h.data.language}),setTimeout(()=>{this.showSuccessToast(`answerFormThankYou`)},500)}catch(e){console.error(`Answer form submission failed:`,e),this.showErrorToast(`answer-form-failed`)}},setOpenOverlay(e){h.data.hasOpenedOverlays=e},setAriaLiveStatusMessage(e){h.data.ariaLiveStatusMessage=e,clearTimeout(h.data.ariaLiveStatusMessageClearingTimeout),h.data.ariaLiveStatusMessageClearingTimeout=setTimeout(()=>{h.data.ariaLiveStatusMessage=``},h.ariaLiveMessagesClearingTimeoutDuration)},closePopup(){window.location.hash=``},checkForOpenedPopup(){let e=window.location.hash.slice(1),t=h.t.popups?.find(t=>t.hash===e);t?h.data.openedPopup=t:h.data.openedPopup=void 0},async thumbs(e,t){try{let n=h.data.history.find(t=>t.type===`bot`&&t.id===e),r=n?.type===`bot`?n:void 0;if(r?.feedback===t)return;t===`up`?await Q.thumbsUp(e,n?.question??``):await Q.thumbsDown(e,n?.question??``);let i=!r?.feedback;r&&(r.feedback=t),i&&this.showSuccessToast(`thankYouForFeedback`)}catch(e){console.error(`Feedback failed:`,e),this.showErrorToast(`feedback-failed`)}},async onLanguageChange(e){let t=ae(e,h.data.chatConfig.supportedLanguages);if(await Oo(t),h.data.language=t,ne(h.data.language,h.targets.mainElement),h.data.predefinedQuestions=await this.getPredefinedQuestions(h.data.language),this.setAriaLiveStatusMessage(h.t.ariaLanguageChanged),h.data.chatConfig.reflectLanguageInPath){let e=new URL(window.location.href);e.pathname=`/${h.data.language}`,window.history.replaceState({},``,e.toString())}},async acceptTerms(){h.data.termsAccepted=!0;try{Y.setItem(`liipgpt:termsAccepted`,`true`)}catch(e){console.warn(`Failed to save terms acceptance to storage:`,e)}this.closePopup(),await le(),this.goto(vo(h.data.chatConfig.forceConsent??!1,!0,h.data.chatConfig.forceChatPage??!1,_o(h.data.props.autofirePredefinedQuestionId,h.data.predefinedQuestions),h.data.props.question))},updateChatInput(e){h.data.chatInputValue=e}});export{Ti as _,Fa as a,Ca as c,pa as d,da as f,Ui as g,Xi as h,Ya as i,Sa as l,Zi as m,ko as n,Z as o,sa as p,Xa as r,ka as s,mo as t,_a as u};