@liip/liipgpt 3.6.6 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/button/liipgpt-button.iife.js +8 -8
- package/chat/liipgpt-chat.iife.js +19 -19
- package/config/index.cjs +10 -1
- package/config/index.d.ts +8 -0
- package/config/index.js +10 -1
- package/configurator/_app/env.js +1 -1
- package/configurator/_app/immutable/chunks/{dgLflWK3.js → 7oe4YkCP.js} +2 -2
- package/configurator/_app/immutable/chunks/{Ct405RO9.js → C0FfTxd-.js} +1 -1
- package/configurator/_app/immutable/chunks/{D9izXPjZ.js → C44XFFk1.js} +1 -1
- package/configurator/_app/immutable/chunks/{COBaZaOi.js → CG82rIPn.js} +2 -2
- package/configurator/_app/immutable/chunks/{CmSp37Zg.js → CLIirUbv.js} +3 -3
- package/configurator/_app/immutable/chunks/{jMDVv85c.js → CMlXs0zR.js} +1 -1
- package/configurator/_app/immutable/chunks/{B-hpNbtj.js → CzVuCgPt.js} +1 -1
- package/configurator/_app/immutable/chunks/D1EjYV4X.js +1 -0
- package/configurator/_app/immutable/chunks/{mmrLjPYJ.js → DEXLjy8F.js} +1 -1
- package/configurator/_app/immutable/chunks/{CwrZBvVS.js → DRgXMAej.js} +1 -1
- package/configurator/_app/immutable/chunks/DaqY3Yc5.js +61 -0
- package/configurator/_app/immutable/chunks/Djc2CDZL.js +1 -0
- package/configurator/_app/immutable/chunks/DlFt-05G.js +1 -0
- package/configurator/_app/immutable/chunks/{CvIUpsE2.js → Dmocya4I.js} +5 -5
- package/configurator/_app/immutable/chunks/Dn-8Wrys.js +2 -0
- package/configurator/_app/immutable/chunks/{ZDmpvzUI.js → DrOLA3Pz.js} +1 -1
- package/configurator/_app/immutable/entry/{app.E2ldf754.js → app.DVMov4zD.js} +2 -2
- package/configurator/_app/immutable/entry/start.DbzW6hb9.js +1 -0
- package/configurator/_app/immutable/nodes/{0.Ll1kqQ46.js → 0.DSJ64uDY.js} +2 -2
- package/configurator/_app/immutable/nodes/{1.CoQietVY.js → 1.Dpfcltpd.js} +1 -1
- package/configurator/_app/immutable/nodes/{2.BQPbJpTW.js → 2.BYCMfO_y.js} +3 -3
- package/configurator/_app/immutable/nodes/{3.D869uPuW.js → 3.yXZWk1TH.js} +1 -1
- package/configurator/_app/version.json +1 -1
- package/configurator/index.html +6 -6
- package/configurator/sidebar.html +6 -6
- package/index.cjs +38 -18
- package/index.d.ts +28 -0
- package/index.js +38 -18
- package/package.json +1 -1
- package/search-summary/liipgpt-search-summary.iife.js +29 -29
- package/configurator/_app/immutable/chunks/2Hh8DJQG.js +0 -1
- package/configurator/_app/immutable/chunks/B0fliJXa.js +0 -2
- package/configurator/_app/immutable/chunks/B3LnmtSW.js +0 -1
- package/configurator/_app/immutable/chunks/BClMDlJ1.js +0 -61
- package/configurator/_app/immutable/chunks/Bd-qHRpI.js +0 -1
- package/configurator/_app/immutable/entry/start.M4_rYTfO.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e=`https://liipgpt.api.dev.genai.liip.ch/liipgpt`,t=`3.
|
|
1
|
+
var e=`https://liipgpt.api.dev.genai.liip.ch/liipgpt`,t=`3.7.0`,n=new Map;async function r(e){let t=n.get(e);if(t)return t;let r=await fetch(e),i=r.url,a=await r.arrayBuffer(),o=await crypto.subtle.digest(`SHA-384`,a),s={versionedUrl:i,integrity:`sha384-${btoa(String.fromCharCode(...new Uint8Array(o)))}`};return n.set(e,s),s}var i=/\/\*\s*@host-class:\s*([a-zA-Z_-][\w-]*)\s*\*\//;function a(e,t=`your-custom-class-wrapper`){let n=e.match(i);if(n)return n[1];let r=e.match(/\.([a-zA-Z_-][\w-]*)\s+\.search-summary\b/);if(r)return r[1];let a=e.match(/liipgpt-search-summary\.([a-zA-Z_-][\w-]*)/);return a?a[1]:t}var o=`/* Host tokens — set on the custom element, inherited by .search-summary and descendants */
|
|
2
2
|
liipgpt-search-summary.your-custom-class-wrapper {
|
|
3
3
|
--search-summary-padding: 1rem;
|
|
4
4
|
--search-summary-background: #fff;
|
|
@@ -43,7 +43,7 @@ liipgpt-search-summary.your-custom-class-wrapper {
|
|
|
43
43
|
}`,s=`liipgpt-search-summary:not(:defined) { visibility: hidden; }
|
|
44
44
|
liipgpt-search-summary:not(:defined) > * { display: none !important; }
|
|
45
45
|
liipgpt-search-summary > [slot] { display: none; }
|
|
46
|
-
liipgpt-search-summary .search-summary:not(.search-summary--ready) { opacity: 0; }`,c=null;function l(e){c||(c=document.createElement(`style`),c.id=`preview-css-injection`,document.head.appendChild(c)),c.textContent=e}function u(){c?.remove(),c=null}var d=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`'`).replace(/\n/g,` `),f=(e,t)=>{if(t!==void 0){if(typeof t==`string`)return`${e}="${d(t)}"`;if(typeof t==`boolean`)return t?e:void 0}},p=(e,t)=>{if(!(typeof t!=`string`||!t))return`${e}='${t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/'/g,`'`)}'`},m=(e,n)=>n===`search-summary`?e.cdn.value?`https://cdn.jsdelivr.net/npm/@liip/liipgpt@${t}/search-summary/liipgpt-search-summary.iife.min.js`:`${e[`api-url`].value}/cdn/npm/@liip/liipgpt/search-summary/liipgpt-search-summary.iife.min.js`:e.cdn.value?`https://cdn.jsdelivr.net/npm/@liip/liipgpt@${t}/${n}/liipgpt-${n}.iife.min.js`:`${e[`api-url`].value}/cdn/npm/@liip/liipgpt/${n}/liipgpt-${n}.iife.min.js`,h=(e,t)=>t?`<script async src="${t.versionedUrl}" integrity="${t.integrity}" crossorigin="anonymous"><\/script>`:`<script async src="${e}"><\/script>`,g=(e,t,n)=>{let r=`<liipgpt-button ${[f(`lang`,e.lang.value),f(`force-theme`,e?.[`force-theme`]?.value),f(`api-url`,e[`api-url`].value),f(`button-class`,e[`button-class`]?.value),f(`button-style`,e[`button-style`]?.value)].filter(Boolean).join(` `)}</liipgpt-button>`;if(t){let t=`${h(m(e,`button`),n)}\n${r}`;return e.CHAT_CONFIG_OVERRIDE.value&&(t=`<script>\n${e.CHAT_CONFIG_OVERRIDE.value}<\/script>\n`+t),e.onclosechat.value&&(t+=`\n<script>${e.onclosechat.value}<\/script>`),t}return r},_=(e,t,n)=>{let r=`<liipgpt-chat ${[f(`lang`,e.lang.value),f(`force-theme`,e?.[`force-theme`]?.value),f(`api-url`,e[`api-url`].value),f(`loader-background`,e[`loader-background`].value),f(`loader-color`,e[`loader-color`].value),f(`flyout`,e.flyout.value),f(`flyout-style`,e[`flyout-style`].value),f(`flyout-class`,e[`flyout-class`].value),f(`chat-class`,e[`chat-class`].value),f(`inline-layout`,e[`inline-layout`].value),f(`force-chat-page`,e[`force-chat-page`].value),f(`autofire-predefined-question-id`,e[`autofire-predefined-question-id`].value),f(`question`,e.question.value),p(`additional-start-parameters`,e[`additional-start-parameters`].value)].filter(Boolean).join(` `)}>${e[`custom-loader`].value?`<div slot="loader">${e[`custom-loader`].value}</div>`:``}</liipgpt-chat>`;if(t){let t=`${h(m(e,`chat`),n)}\n${r}`;return e.CHAT_CONFIG_OVERRIDE.value&&(t=`<script>\n${e.CHAT_CONFIG_OVERRIDE.value}<\/script>\n`+t),e.onclosechat.value&&(t+=`\n<script>${e.onclosechat.value}<\/script>`),t}return r},v=`ai-overview`,y={de:`KI-Übersicht`,en:`AI overview`,fr:`Aperçu IA`,it:`Panoramica IA`},b=`<p><strong>Get an AI-generated summary above your search results.</strong></p>
|
|
46
|
+
liipgpt-search-summary .search-summary:not(.search-summary--ready) { opacity: 0; }`,c=null;function l(e){c||(c=document.createElement(`style`),c.id=`preview-css-injection`,document.head.appendChild(c)),c.textContent=e}function u(){c?.remove(),c=null}var d=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`'`).replace(/\n/g,` `),f=(e,t)=>{if(t!==void 0){if(typeof t==`string`)return`${e}="${d(t)}"`;if(typeof t==`boolean`)return t?e:void 0}},p=(e,t)=>{if(!(typeof t!=`string`||!t))return`${e}='${t.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/'/g,`'`)}'`},m=(e,n)=>n===`search-summary`?e.cdn.value?`https://cdn.jsdelivr.net/npm/@liip/liipgpt@${t}/search-summary/liipgpt-search-summary.iife.min.js`:`${e[`api-url`].value}/cdn/npm/@liip/liipgpt/search-summary/liipgpt-search-summary.iife.min.js`:e.cdn.value?`https://cdn.jsdelivr.net/npm/@liip/liipgpt@${t}/${n}/liipgpt-${n}.iife.min.js`:`${e[`api-url`].value}/cdn/npm/@liip/liipgpt/${n}/liipgpt-${n}.iife.min.js`,h=(e,t)=>t?`<script async src="${t.versionedUrl}" integrity="${t.integrity}" crossorigin="anonymous"><\/script>`:`<script async src="${e}"><\/script>`,g=(e,t,n)=>{let r=`<liipgpt-button ${[f(`lang`,e.lang.value),f(`force-theme`,e?.[`force-theme`]?.value),f(`api-url`,e[`api-url`].value),f(`button-class`,e[`button-class`]?.value),f(`button-style`,e[`button-style`]?.value)].filter(Boolean).join(` `)}</liipgpt-button>`;if(t){let t=`${h(m(e,`button`),n)}\n${r}`;return e.CHAT_CONFIG_OVERRIDE.value&&(t=`<script>\n${e.CHAT_CONFIG_OVERRIDE.value}<\/script>\n`+t),e.onclosechat.value&&(t+=`\n<script>${e.onclosechat.value}<\/script>`),t}return r},_=(e,t,n)=>{let r=`<liipgpt-chat ${[f(`lang`,e.lang.value),f(`force-theme`,e?.[`force-theme`]?.value),f(`api-url`,e[`api-url`].value),f(`loader-background`,e[`loader-background`].value),f(`loader-color`,e[`loader-color`].value),f(`flyout`,e.flyout.value),f(`flyout-style`,e[`flyout-style`].value),f(`flyout-class`,e[`flyout-class`].value),f(`chat-class`,e[`chat-class`].value),f(`inline-layout`,e[`inline-layout`].value),f(`force-chat-page`,e[`force-chat-page`].value),f(`autofire-predefined-question-id`,e[`autofire-predefined-question-id`].value),f(`question`,e.question.value),f(`hide-predefined-questions`,e[`hide-predefined-questions`].value),p(`additional-start-parameters`,e[`additional-start-parameters`].value)].filter(Boolean).join(` `)}>${e[`custom-loader`].value?`<div slot="loader">${e[`custom-loader`].value}</div>`:``}</liipgpt-chat>`;if(t){let t=`${h(m(e,`chat`),n)}\n${r}`;return e.CHAT_CONFIG_OVERRIDE.value&&(t=`<script>\n${e.CHAT_CONFIG_OVERRIDE.value}<\/script>\n`+t),e.onclosechat.value&&(t+=`\n<script>${e.onclosechat.value}<\/script>`),t}return r},v=`ai-overview`,y={de:`KI-Übersicht`,en:`AI overview`,fr:`Aperçu IA`,it:`Panoramica IA`},b=`<p><strong>Get an AI-generated summary above your search results.</strong></p>
|
|
47
47
|
<p>When enabled, an AI overview will appear at the top of every search results page, synthesising the most relevant information for your query. Classical search results remain accessible below.</p>
|
|
48
48
|
<p>AI-generated answers may not always be accurate. <a href="https://example.com/privacy">Privacy policy</a></p>`,x=`<button
|
|
49
49
|
type="button"
|
|
@@ -66,7 +66,7 @@ liipgpt-search-summary .search-summary:not(.search-summary--ready) { opacity: 0;
|
|
|
66
66
|
class="your-custom-class-btn your-custom-class-btn--secondary"
|
|
67
67
|
>
|
|
68
68
|
Disable AI
|
|
69
|
-
</button>`,S=(e,t,n)=>{let r=typeof window<`u`&&new URLSearchParams(window.location.search).get(`q`)||`What is liip?`,i=typeof e.lang.value==`string`?e.lang.value:`en`,c=y[i]??y.en,l=e[`use-chat-config`]?.value,u=e[`host-css`]?.value,p=a((!l&&typeof u==`string`?u:``)||o),g=[f(`lang`,i),f(`api-url`,e[`api-url`].value),f(`question`,r),f(`labelled-by`,v),f(`height`,e.height?.value??`280`),f(`opt-in`,e[`opt-in`]?.value),f(`use-chat-config`,l),l?f(`force-theme`,e?.[`force-theme`]?.value):void 0,l?void 0:f(`class`,p)].filter(Boolean),_=e[`disclaimer-slot`]?.value,x=typeof _==`string`?_:b,S=!l&&e[`opt-in`]?.value?`\n <div slot="disclaimer">\n ${x.trim().replace(/\n/g,`
|
|
69
|
+
</button>`,S=(e,t,n)=>{let r=typeof window<`u`&&new URLSearchParams(window.location.search).get(`q`)||`What is liip?`,i=typeof e.lang.value==`string`?e.lang.value:`en`,c=y[i]??y.en,l=e[`use-chat-config`]?.value,u=e[`host-css`]?.value,p=a((!l&&typeof u==`string`?u:``)||o),g=[f(`lang`,i),f(`api-url`,e[`api-url`].value),f(`question`,r),f(`labelled-by`,v),f(`height`,e.height?.value??`280`),f(`max-height`,e[`max-height`]?.value),f(`opt-in`,e[`opt-in`]?.value),f(`use-chat-config`,l),l?f(`force-theme`,e?.[`force-theme`]?.value):void 0,l?void 0:f(`class`,p),f(`chat-url`,e[`chat-url`]?.value)].filter(Boolean),_=e[`disclaimer-slot`]?.value,x=typeof _==`string`?_:b,S=!l&&e[`opt-in`]?.value?`\n <div slot="disclaimer">\n ${x.trim().replace(/\n/g,`
|
|
70
70
|
`)}\n </div>`:``,C=e[`buttons-slots`]?.value,w=typeof C==`string`?C.trim():``,T=!l&&w?`\n ${w.replace(/\n/g,`
|
|
71
71
|
`)}`:``,E=`<liipgpt-search-summary\n ${g.join(`
|
|
72
72
|
`)}\n>${S}${T}\n</liipgpt-search-summary>`,D=`${`<h2 id="${v}">${d(c)}</h2>`}\n${E}`;if(t){let t=m(e,`search-summary`),r=e[`host-css`]?.value,i=!l&&typeof r==`string`?r:``,a=`<style>\n${[s,...i?[i]:[]].join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rEsbAd0y.js";import{a as e,i as t,r as n}from"./
|
|
1
|
+
import"./rEsbAd0y.js";import{a as e,i as t,r as n}from"./DrOLA3Pz.js";var r={get data(){return e.data},get error(){return e.error},get form(){return e.form},get params(){return e.params},get route(){return e.route},get state(){return e.state},get status(){return e.status},get url(){return e.url}};Object.defineProperty({get from(){return t.current?t.current.from:null},get to(){return t.current?t.current.to:null},get type(){return t.current?t.current.type:null},get willUnload(){return t.current?t.current.willUnload:null},get delta(){return t.current?t.current.delta:null},get complete(){return t.current?t.current.complete:null}},`current`,{get(){throw Error(`Replace navigating.current.<prop> with navigating.<prop>`)}}),n.updated.check;var i=r;export{i as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Kt as e,Lt as t,Mt as n,Rt as r,c as i,i as a,kt as o,o as s,ot as c}from"./rEsbAd0y.js";import"./Bo0U8J3e.js";import"./CFKVnMbq.js";import"./CZzAbm1q.js";import"./
|
|
1
|
+
import{Kt as e,Lt as t,Mt as n,Rt as r,c as i,i as a,kt as o,o as s,ot as c}from"./rEsbAd0y.js";import"./Bo0U8J3e.js";import"./CFKVnMbq.js";import"./CZzAbm1q.js";import"./Dmocya4I.js";import"./DKyUMEyV.js";import"./DaqY3Yc5.js";import"./D1EjYV4X.js";import"./DlFt-05G.js";import{t as l}from"./C44XFFk1.js";import{t as u}from"./BiTRwaVm.js";function d(a,d){r(d,!0);let f=s(d,`onclick`,7),p=s(d,`buttonClass`,7),m=s(d,`buttonStyle`,7),h=s(d,`apiUrl`,7),g=s(d,`forceTheme`,7),_=s(d,`lang`,7),v=o(()=>({onclick:f(),buttonClass:p(),buttonStyle:m(),apiUrl:h(),forceTheme:g(),lang:_()}));return u(a,{silent:!0,body:(t,n=e)=>{l(t,i({host:d.$$host,get onError(){return n()}},()=>c(v)))},$$slots:{body:!0}}),t({get onclick(){return f()},set onclick(e){f(e),n()},get buttonClass(){return p()},set buttonClass(e){p(e),n()},get buttonStyle(){return m()},set buttonStyle(e){m(e),n()},get apiUrl(){return h()},set apiUrl(e){h(e),n()},get forceTheme(){return g()},set forceTheme(e){g(e),n()},get lang(){return _()},set lang(e){_(e),n()}})}customElements.define(`liipgpt-button`,a(d,{forceTheme:{attribute:`force-theme`,type:`String`},buttonClass:{attribute:`button-class`,type:`String`},buttonStyle:{attribute:`button-style`,type:`String`},apiUrl:{attribute:`api-url`,type:`String`},lang:{attribute:`lang`,type:`String`},onclick:{}},[],[],{mode:`open`}));export{d as LiipGPTButton};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,c as t,d as n,f as r,i,l as a,m as o,n as s,o as c,p as l,r as u,s as d,t as f,u as p}from"./DKyUMEyV.js";var m=a({blocked:r(),maintenance:r(),"rate-limit":r(),"server-error":r(),"too-short":r(),"too-long":r(),"quota-reached":r(),aborted:r(),"sse-error":r(),"client-error":r(),"unexpected-call":r(),"incomplete-error":r(),"feedback-failed":r(),"answer-form-failed":r(),"speech-not-supported":r(),"speech-transcription-failed":r(),"speech-no-text-detected":r(),"speech-microphone-access-denied":r(),"pii-detected":r()}),h=a({email:r(),creditCard:r(),ahv:r(),phoneSwiss:r(),phoneInternational:r(),swissPassport:r(),longNumber:r()}),g=a({name:r(),namePlural:r().optional(),intro:r().optional(),placeholder:r(),values:n(r(),r())}),_=a({action:r(),label:r(),type:s([`primary`,`secondary`]).optional()}),v=a({hash:r(),title:r(),content:r(),actions:u(_).optional()}),y=a({introductionTitle:r(),introductionDisclaimer:r().optional(),termsInvitationToConsent:r().optional(),chatInputPlaceholder:r(),chatInputPlaceholderListening:r().optional(),chatInputSubmit:r(),chatInputAbort:r(),chatInputStartListening:r(),chatInputStopListening:r(),referenceLink:r(),referencesDisplay:r(),referencesHide:r(),referencesTitle:r(),referencesFurtherTitle:r(),newChat:r(),maintenanceModeError:r(),messageBotLoading:r(),messageBotError:r(),messageBotDefaultError:r(),noResultsFound:r(),chatFooterText:r().optional(),scrollToBottom:r(),openButtonTitle:r().optional(),openButtonDescription:r().optional(),openMenu:r(),openInfo:r(),aboutThisChat:r().optional(),closeMenu:r(),closeChat:r(),close:r(),send:r(),thankYouForFeedback:r(),answerFormThankYou:r(),giveFeedback:r(),sendFeedback:r(),feedbackFormTitle:r(),feedbackFormMessage:r(),feedbackFormMessagePlaceholder:r(),feedbackFormEmail:r(),feedbackFormEmailPlaceholder:r(),askQuestionAgain:r(),answerGood:r(),answerBad:r(),classificationSubmit:r(),classificationThankYou:r(),classificationTitle:r(),selectLanguage:r(),languageChanged:r(),selectColorTheme:r(),lightMode:r(),darkMode:r(),ariaMainNavigation:r(),ariaMainNavigationInfo:r(),ariaMainNavigationLinks:r(),ariaMainNavigationLanguageSwitch:r(),ariaMainNavigationColorMode:r(),ariaGotoMainNavigation:r(),ariaAskQuestion:r(),ariaAskQuestionRegion:r(),ariaNotifications:r(),ariaPredefinedQuestions:r(),ariaPredefinedQuestionsRegion:r(),ariaChatHistory:r(),ariaOpenChat:r(),ariaQuestionFromYou:r(),ariaAnswerFromBot:r(),ariaLastAnswerNavigation:r(),ariaQuestionSent:r(),ariaAnswerReady:r(),ariaAnswerFinished:r(),ariaAnswerFinishedWithSelectedTopic:r(),ariaAskQuestionAgain:r(),ariaAnswerGood:r(),ariaAnswerBad:r(),ariaReferenceSource:r(),ariaGiveFeedback:r(),ariaAnswerForm:r(),ariaLanguageChanged:r(),ariaLightSelected:r(),ariaDarkSelected:r(),ariaSettings:r(),ariaSettingsRegion:r(),ariaReferencesRegion:r(),ariaOpensInNewTab:r(),ariaPageTitle:r(),ariaCloseWithEsc:r(),ariaInfoTitle:r(),ariaFlyoutRegion:r(),ariaSelected:r(),ariaUnselected:r(),ariaAllSelected:r(),ariaAllUnselected:r(),ariaAllReseted:r(),ariaChangeTopic:r(),popups:u(v).optional(),termsAcceptButton:r().optional(),termsReadButton:r().optional(),selectors:n(r(),g).optional(),hideSettings:r(),showSettings:r(),chooseAtLeastOneOption:r(),selectAll:r(),selectNone:r(),resetToDefaults:r(),messageTooLong:r(),selectedTopic:r(),changeTopic:r(),searchSummaryExpand:r(),searchSummaryCollapse:r(),searchSummaryOptInDefault:r(),searchSummaryOptOut:r(),searchSummaryError:r(),searchSummaryDisclaimer:r().optional(),searchSummaryLoading:r(),searchSummaryFollowUpPlaceholder:r(),searchSummaryFollowUpSubmit:r(),ariaSearchSummaryExpand:r(),ariaSearchSummaryCollapse:r(),ariaSearchSummaryOptOut:r(),ariaSearchSummaryFollowUpInput:r(),jsonLdEventDate:r(),jsonLdEventLocation:r(),jsonLdEventDescription:r(),jsonLdEventCtaLabel:r(),jsonLdCtaLabel:r(),jsonLdMapOpenMap:r(),ariaJsonLdMapCanvas:r(),ariaJsonLdEventCard:r(),ariaJsonLdMapCard:r(),ariaJsonLdCtaCard:r()}),b=s([`en`,`de`,`fr`,`it`]),x=p(b,y.partial().extend({selectors:n(r(),g).optional()}));n(b,m),n(b,h);var S=p(b,r()),C=a({componentName:d(`buttons`),data:a({caption:r().optional(),buttons:u(a({label:r(),href:r().url().optional(),value:r(),variant:s([`primary`,`secondary`,`tertiary`]).optional(),icon:r().optional(),target:r().optional()}))})}),w=a({componentName:d(`combobox`),data:a({caption:S.optional(),placeholder:S,values:u(a({label:S,value:r(),metadata:n(r(),o()).optional()})),removeComponentAfterValueSelection:i().optional(),selectorKey:r().optional()})}),T=a({componentName:d(`alva-init`),data:a({})}),ee=a({componentName:d(`alva-score-survey`),data:a({})}),E=a({type:d(`component`),id:r().optional(),time:r().optional(),hideAvatar:i().optional(),noSectionPadding:i().optional(),hideChatInput:i().optional()}),D=c(e(`componentName`,[C,w,T,ee]),E),O=l([r(),t(),i(),u(r()),u(t()),u(i())]),k=a({title:r(),description:r().optional(),badge:r().optional(),breadcrumbs:u(r()).optional(),previewImage:r().optional(),date:r().datetime().optional()}),A=a({url:r().url(),score:t(),metadata:n(r(),O),language:r().optional()}).extend(k.shape);s([`start`,`chat`]),e(`name`,[a({name:d(`start-page`),prefill:r().optional()}),a({name:d(`consent-page`)}),a({name:d(`chat-page`),query:r().optional(),predefinedQuestionId:r().optional(),switchQuestionId:r().optional()})]);var j=a({type:d(`user`),time:r(),message:r(),id:r().optional()});s([`idle`,`searching`,`answering`]);var M=l([r(),t(),i(),u(r()),u(t()),u(i())]),N=a({url:r(),score:t(),metadata:n(r(),M),considered:i(),display:a({card:k,listItem:k})}).extend({referenceIndex:a({all:t(),used:t().optional()})}),P=a({all:u(N),used:u(N),unused:u(N)}),F=l([s([`pii-detected`,`blocked`,`maintenance`,`rate-limit`,`server-error`,`too-short`,`too-long`,`quota-reached`,`aborted`]),d(`sse-error`),d(`client-error`),d(`unexpected-call`)]),I=a({type:d(`bot`),time:r(),id:r(),message:a({markdown:r(),html:r(),text:r()}),references:P,errors:u(F),retrievalQuestion:r().optional(),noFeedback:i().optional()}),L=I.extend({state:s([`streaming`,`done`])}),R=l([l([I.extend({state:d(`loading`)}),L]),j,D]),z=u(a({question:r(),answer:r()})),B=a({label:r(),options:u(a({label:r(),value:t()}))}),V=a({label:r(),icon:r(),url:r(),target:s([`_blank`,`_self`]).optional()}),H=a({id:r().optional(),label:r().nullable(),question:r(),switchQuestionId:r().optional()}),U=a({impact:B.optional(),quality:B.optional()});a({classification:U.optional()});var W=a({predefinedQuestions:u(H)}),G=l([a({maintenance:d(!0)}),a({id:r(),cID:r()})]);n(b,y),a({label:r(),placeholder:r(),locked:i().optional()});var K=a({settingName:r(),iconName:r(),settingIntro:r().optional(),type:s([`single-select`,`multi-select`]),allowEmpty:i(),values:u(r()),defaultValues:u(r()).optional()}),q=a({type:s([`text`,`select`,`checkbox`,`radio`]),name:r(),label:S,placeholder:S.optional(),required:i().optional(),options:u(a({value:r(),label:S})).optional()}),J=a({receiverEmail:r(),triggerLabel:S,title:S.optional(),caption:S.optional(),submitLabel:S,fields:u(q)}),Y=a({before:u(R).optional(),after:u(R).optional()}),X=a({init:u(R).optional(),bot:Y.optional(),user:Y.optional()}),Z=c(a({forcePredefinedQuestions:i().optional(),forceChatPage:i().optional(),showOverallFeedbackButton:i(),showOverallFeedbackEmail:i(),showCloseChatButton:i(),showContextMenu:i(),showContextInfo:i(),showReferencesByDefault:i(),showExpandedSelectors:i(),showTextFeedback:i(),inlineLayout:i(),allowAudioInput:i(),blockPII:i(),questionPrefix:r(),menu:p(b,u(V)).optional(),supportedLanguages:u(b),classification:U.optional(),answerForm:J.optional(),theme:f,translations:x,buttonHref:r().optional(),addQueryToUrlParams:i().optional(),addRetrievalQuestionToUrlParams:i().optional(),renderKatex:i().optional(),reflectLanguageInPath:i().optional(),sendReferrer:s([`all`,`own`,`none`,`location`]).optional(),selectorsConfig:u(K).default([]),questionLengthLimit:t().optional(),forceConsent:i().optional(),askQuestionAgain:i(),enableBackdrop:i().optional(),parentPageContext:a({extractSelectors:r().array().optional()}),messageAdditions:X.optional(),contextVersion:t().optional(),selectedTopicResetPredefinedQuestionId:r().optional()}).partial(),a({theme:a({name:r().optional()}).optional()})),Q=(e,t)=>t.includes(e),$=(e,t)=>{if(Q(e,t))return e;let n=te();return Q(n,t)?n:`en`},te=()=>navigator.language.split(`-`)[0],ne=(e,t)=>{localStorage.setItem(`liipgpt:selectedLanguage`,e),t&&(t.lang=e)},re=e=>$(localStorage.getItem(`liipgpt:selectedLanguage`),e),ie=(e,t,n)=>{if(!e)return``;if(e[t])return e[t];for(let t of n)if(e[t])return e[t];return e.en?e.en:Object.values(e).find(e=>typeof e==`string`&&e.length>0)??``};export{Z as a,z as c,ne as i,A as l,$ as n,W as o,ie as r,G as s,re as t,x as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{A as e,J as t,Lt as n,Mt as r,Rt as i,U as a,X as o,Y as s,i as c,nt as l,o as u,tt as d,xt as f}from"./rEsbAd0y.js";import{t as p}from"./
|
|
1
|
+
import{A as e,J as t,Lt as n,Mt as r,Rt as i,U as a,X as o,Y as s,i as c,nt as l,o as u,tt as d,xt as f}from"./rEsbAd0y.js";import{t as p}from"./DrOLA3Pz.js";import{t as m}from"./CMlXs0zR.js";var h=(e,t)=>{let n=new URLSearchParams(m.url.searchParams);t===void 0?n.delete(e):n.set(e,String(t));let r=`?${n.toString()}`;window.top&&window.top.postMessage(`liipgpt-url:`+r,`*`),p(r,{replaceState:!0})},g=e=>{let t=new URLSearchParams(m.url.searchParams);for(let[n,r]of Object.entries(e))r===void 0?t.delete(n):t.set(n,String(r));let n=`?${t.toString()}`;window.top&&window.top.postMessage(`liipgpt-url:`+n,`*`),p(n,{replaceState:!0})},_=o(`<button type="button" class="sidebar-hide svelte-q6hwt7" aria-label="Hide sidebar">Hide sidebar</button>`),v=o(`<button type="button" class="sidebar-reopen svelte-q6hwt7" aria-label="Show sidebar"><span class="sidebar-reopen__label svelte-q6hwt7" aria-hidden="true">Show sidebar</span></button>`),y={hash:`svelte-q6hwt7`,code:`.sidebar-hide.svelte-q6hwt7 {display:block;padding:0.375rem 0.75rem;border:1px solid #e5e7eb;border-radius:0.375rem;background:#fff;color:#4b5563;font-weight:500;font-size:0.75rem;line-height:1.25;font-family:system-ui, sans-serif;cursor:pointer;}.sidebar-hide.svelte-q6hwt7:hover {background:#f3f4f6;color:#111827;}.sidebar-reopen.svelte-q6hwt7 {display:flex;z-index:50;position:fixed;bottom:5rem;left:0;align-items:center;justify-content:center;padding:0.5rem 0.25rem;border:1px solid #e5e7eb;border-left:none;border-radius:0 0.375rem 0.375rem 0;background:#fff;box-shadow:0 1px 3px 0 rgb(0 0 0 / 0.1),
|
|
2
2
|
0 1px 2px -1px rgb(0 0 0 / 0.1);color:#4b5563;font-weight:500;font-size:0.6rem;font-family:system-ui, sans-serif;cursor:pointer;}.sidebar-reopen.svelte-q6hwt7:hover {background:#f3f4f6;color:#111827;}.sidebar-reopen__label.svelte-q6hwt7 {letter-spacing:0.04em;text-orientation:mixed;writing-mode:vertical-rl;}
|
|
3
3
|
|
|
4
4
|
@media (prefers-color-scheme: dark) {.sidebar-hide.svelte-q6hwt7 {border-color:#4b5563;background:#1f2937;color:#d1d5db;}.sidebar-hide.svelte-q6hwt7:hover {background:#374151;color:#f3f4f6;}.sidebar-reopen.svelte-q6hwt7 {border-color:#4b5563;background:#1f2937;color:#d1d5db;}.sidebar-reopen.svelte-q6hwt7:hover {background:#374151;color:#f3f4f6;}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./CZzAbm1q.js";import{i as e,t}from"./
|
|
1
|
+
import"./CZzAbm1q.js";import{i as e,t}from"./Dmocya4I.js";import"./DKyUMEyV.js";import{a as n,n as r}from"./D1EjYV4X.js";var i=async e=>{let t=await(await fetch(`${e}/chatconfig`)).json();return n.parse(t)};async function a({apiUrl:n,lang:a,forceTheme:o}){let s=e(await i(n));return{chatConfig:s,language:r(a,s.supportedLanguages),colorScheme:t(Object.keys(s.fullTheme))}}export{a as loadChatConfig};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import{Dt as e,Et as t,J as n,Lt as r,M as i,Mt as a,Nt as o,Rt as s,Tt as c,U as l,Y as u,g as d,ht as f,i as p,it as m,jt as ee,k as te,o as ne,ot as h,s as re,ut as g,wt as _,xt as ie}from"./rEsbAd0y.js";import{c as ae,f as oe,i as se,l as ce,r as v}from"./DKyUMEyV.js";import{a as le,c as ue,l as de,o as fe,s as pe}from"./D1EjYV4X.js";var{entries:me,setPrototypeOf:he,isFrozen:ge,getPrototypeOf:_e,getOwnPropertyDescriptor:ve}=Object,{freeze:y,seal:b,create:ye}=Object,{apply:be,construct:x}=typeof Reflect<`u`&&Reflect;y||=function(e){return e},b||=function(e){return e},be||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},x||=function(e){return new e(...[...arguments].slice(1))};var xe=w(Array.prototype.forEach),Se=w(Array.prototype.lastIndexOf),Ce=w(Array.prototype.pop),we=w(Array.prototype.push),Te=w(Array.prototype.splice),Ee=w(String.prototype.toLowerCase),De=w(String.prototype.toString),Oe=w(String.prototype.match),ke=w(String.prototype.replace),Ae=w(String.prototype.indexOf),je=w(String.prototype.trim),S=w(Object.prototype.hasOwnProperty),C=w(RegExp.prototype.test),Me=T(TypeError);function w(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return be(e,t,n)}}function T(e){return function(){return x(e,[...arguments])}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Ee;he&&he(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(ge(t)||(t[r]=e),i=e)}e[i]=!0}return e}function Ne(e){for(let t=0;t<e.length;t++)S(e,t)||(e[t]=null);return e}function D(e){let t=ye(null);for(let[n,r]of me(e))S(e,n)&&(Array.isArray(r)?t[n]=Ne(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=D(r):t[n]=r);return t}function Pe(e,t){for(;e!==null;){let n=ve(e,t);if(n){if(n.get)return w(n.get);if(typeof n.value==`function`)return w(n.value)}e=_e(e)}function n(){return null}return n}var Fe=y(`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(`.`)),Ie=y(`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(`.`)),Le=y([`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`]),Re=y([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ze=y(`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(`.`)),Be=y([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),Ve=y([`#text`]),He=y(`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(`.`)),Ue=y(`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(`.`)),We=y(`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(`.`)),Ge=y([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ke=b(/\{\{[\w\W]*|[\w\W]*\}\}/gm),O=b(/<%[\w\W]*|[\w\W]*%>/gm),qe=b(/\$\{[\w\W]*/gm),Je=b(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ye=b(/^aria-[\-\w]+$/),Xe=b(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ze=b(/^(?:\w+script|data):/i),k=b(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qe=b(/^html$/i),$e=b(/^[a-z][.\w]*(-[.\w]+)+$/i),et=Object.freeze({__proto__:null,ARIA_ATTR:Ye,ATTR_WHITESPACE:k,CUSTOM_ELEMENT:$e,DATA_ATTR:Je,DOCTYPE_NAME:Qe,ERB_EXPR:O,IS_ALLOWED_URI:Xe,IS_SCRIPT_OR_DATA:Ze,MUSTACHE_EXPR:Ke,TMPLIT_EXPR:qe}),tt={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},nt=function(){return typeof window>`u`?null:window},rt=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}},it=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function at(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:nt(),t=e=>at(e);if(t.version=`3.3.3`,t.removed=[],!e||!e.document||e.document.nodeType!==tt.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=Pe(m,`cloneNode`),te=Pe(m,`remove`),ne=Pe(m,`nextSibling`),h=Pe(m,`childNodes`),re=Pe(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let g,_=``,{implementation:ie,createNodeIterator:ae,createDocumentFragment:oe,getElementsByTagName:se}=n,{importNode:ce}=r,v=it();t.isSupported=typeof me==`function`&&typeof re==`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:he,ATTR_WHITESPACE:ge,CUSTOM_ELEMENT:_e}=et,{IS_ALLOWED_URI:ve}=et,b=null,be=E({},[...Fe,...Ie,...Le,...ze,...Ve]),x=null,w=E({},[...He,...Ue,...We,...Ge]),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,Ke=null,O=Object.seal(ye(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),qe=!0,Je=!0,Ye=!1,Ze=!0,k=!1,$e=!0,A=!1,ot=!1,j=!1,M=!1,N=!1,P=!1,F=!0,st=!1,ct=!0,lt=!1,I={},L=null,ut=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`]),dt=null,ft=E({},[`audio`,`video`,`img`,`source`,`image`,`track`]),pt=null,mt=E({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),ht=`http://www.w3.org/1998/Math/MathML`,R=`http://www.w3.org/2000/svg`,z=`http://www.w3.org/1999/xhtml`,B=z,V=!1,gt=null,_t=E({},[ht,R,z],De),vt=E({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),H=E({},[`annotation-xml`]),yt=E({},[`title`,`style`,`font`,`a`,`script`]),bt=null,xt=[`application/xhtml+xml`,`text/html`],U=null,St=null,Ct=n.createElement(`form`),wt=function(e){return e instanceof RegExp||e instanceof Function},Tt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(St&&St===e)){if((!e||typeof e!=`object`)&&(e={}),e=D(e),bt=xt.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,U=bt===`application/xhtml+xml`?De:Ee,b=S(e,`ALLOWED_TAGS`)?E({},e.ALLOWED_TAGS,U):be,x=S(e,`ALLOWED_ATTR`)?E({},e.ALLOWED_ATTR,U):w,gt=S(e,`ALLOWED_NAMESPACES`)?E({},e.ALLOWED_NAMESPACES,De):_t,pt=S(e,`ADD_URI_SAFE_ATTR`)?E(D(mt),e.ADD_URI_SAFE_ATTR,U):mt,dt=S(e,`ADD_DATA_URI_TAGS`)?E(D(ft),e.ADD_DATA_URI_TAGS,U):ft,L=S(e,`FORBID_CONTENTS`)?E({},e.FORBID_CONTENTS,U):ut,Ne=S(e,`FORBID_TAGS`)?E({},e.FORBID_TAGS,U):D({}),Ke=S(e,`FORBID_ATTR`)?E({},e.FORBID_ATTR,U):D({}),I=S(e,`USE_PROFILES`)?e.USE_PROFILES:!1,qe=e.ALLOW_ARIA_ATTR!==!1,Je=e.ALLOW_DATA_ATTR!==!1,Ye=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ze=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,k=e.SAFE_FOR_TEMPLATES||!1,$e=e.SAFE_FOR_XML!==!1,A=e.WHOLE_DOCUMENT||!1,M=e.RETURN_DOM||!1,N=e.RETURN_DOM_FRAGMENT||!1,P=e.RETURN_TRUSTED_TYPE||!1,j=e.FORCE_BODY||!1,F=e.SANITIZE_DOM!==!1,st=e.SANITIZE_NAMED_PROPS||!1,ct=e.KEEP_CONTENT!==!1,lt=e.IN_PLACE||!1,ve=e.ALLOWED_URI_REGEXP||Xe,B=e.NAMESPACE||z,vt=e.MATHML_TEXT_INTEGRATION_POINTS||vt,H=e.HTML_INTEGRATION_POINTS||H,T=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&wt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(T.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&wt(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),k&&(Je=!1),N&&(M=!0),I&&(b=E({},Ve),x=ye(null),I.html===!0&&(E(b,Fe),E(x,He)),I.svg===!0&&(E(b,Ie),E(x,Ue),E(x,Ge)),I.svgFilters===!0&&(E(b,Le),E(x,Ue),E(x,Ge)),I.mathMl===!0&&(E(b,ze),E(x,We),E(x,Ge))),S(e,`ADD_TAGS`)||(O.tagCheck=null),S(e,`ADD_ATTR`)||(O.attributeCheck=null),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?O.tagCheck=e.ADD_TAGS:(b===be&&(b=D(b)),E(b,e.ADD_TAGS,U))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?O.attributeCheck=e.ADD_ATTR:(x===w&&(x=D(x)),E(x,e.ADD_ATTR,U))),e.ADD_URI_SAFE_ATTR&&E(pt,e.ADD_URI_SAFE_ATTR,U),e.FORBID_CONTENTS&&(L===ut&&(L=D(L)),E(L,e.FORBID_CONTENTS,U)),e.ADD_FORBID_CONTENTS&&(L===ut&&(L=D(L)),E(L,e.ADD_FORBID_CONTENTS,U)),ct&&(b[`#text`]=!0),A&&E(b,[`html`,`head`,`body`]),b.table&&(E(b,[`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.`);g=e.TRUSTED_TYPES_POLICY,_=g.createHTML(``)}else g===void 0&&(g=rt(p,i)),g!==null&&typeof _==`string`&&(_=g.createHTML(``));y&&y(e),St=e}},Et=E({},[...Ie,...Le,...Re]),Dt=E({},[...ze,...Be]),Ot=function(e){let t=re(e);(!t||!t.tagName)&&(t={namespaceURI:B,tagName:`template`});let n=Ee(e.tagName),r=Ee(t.tagName);return gt[e.namespaceURI]?e.namespaceURI===R?t.namespaceURI===z?n===`svg`:t.namespaceURI===ht?n===`svg`&&(r===`annotation-xml`||vt[r]):!!Et[n]:e.namespaceURI===ht?t.namespaceURI===z?n===`math`:t.namespaceURI===R?n===`math`&&H[r]:!!Dt[n]:e.namespaceURI===z?t.namespaceURI===R&&!H[r]||t.namespaceURI===ht&&!vt[r]?!1:!Dt[n]&&(yt[n]||!Et[n]):!!(bt===`application/xhtml+xml`&>[e.namespaceURI]):!1},W=function(e){we(t.removed,{element:e});try{re(e).removeChild(e)}catch{te(e)}},G=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(M||N)try{W(n)}catch{}else try{n.setAttribute(e,``)}catch{}},kt=function(e){let t=null,r=null;if(j)e=`<remove></remove>`+e;else{let t=Oe(e,/^[\r\n\t ]+/);r=t&&t[0]}bt===`application/xhtml+xml`&&B===z&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=g?g.createHTML(e):e;if(B===z)try{t=new f().parseFromString(i,bt)}catch{}if(!t||!t.documentElement){t=ie.createDocument(B,`template`,null);try{t.documentElement.innerHTML=V?_:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),B===z?se.call(t,A?`html`:`body`)[0]:A?t.documentElement:a},At=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)},jt=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`)},Mt=function(e){return typeof s==`function`&&e instanceof s};function K(e,n,r){xe(e,e=>{e.call(t,n,r,St)})}let Nt=function(e){let n=null;if(K(v.beforeSanitizeElements,e,null),jt(e))return W(e),!0;let r=U(e.nodeName);if(K(v.uponSanitizeElement,e,{tagName:r,allowedTags:b}),$e&&e.hasChildNodes()&&!Mt(e.firstElementChild)&&C(/<[/\w!]/g,e.innerHTML)&&C(/<[/\w!]/g,e.textContent)||e.nodeType===tt.progressingInstruction||$e&&e.nodeType===tt.comment&&C(/<[/\w]/g,e.data))return W(e),!0;if(!(O.tagCheck instanceof Function&&O.tagCheck(r))&&(!b[r]||Ne[r])){if(!Ne[r]&&Ft(r)&&(T.tagNameCheck instanceof RegExp&&C(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r)))return!1;if(ct&&!L[r]){let t=re(e)||e.parentNode,n=h(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,ne(e))}}}return W(e),!0}return e instanceof c&&!Ot(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&C(/<\/no(script|embed|frames)/i,e.innerHTML)?(W(e),!0):(k&&e.nodeType===tt.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)),K(v.afterSanitizeElements,e,null),!1)},Pt=function(e,t,r){if(Ke[t]||F&&(t===`id`||t===`name`)&&(r in n||r in Ct))return!1;if(!(Je&&!Ke[t]&&C(fe,t))&&!(qe&&C(pe,t))&&!(O.attributeCheck instanceof Function&&O.attributeCheck(t,e))){if(!x[t]||Ke[t]){if(!(Ft(e)&&(T.tagNameCheck instanceof RegExp&&C(T.tagNameCheck,e)||T.tagNameCheck instanceof Function&&T.tagNameCheck(e))&&(T.attributeNameCheck instanceof RegExp&&C(T.attributeNameCheck,t)||T.attributeNameCheck instanceof Function&&T.attributeNameCheck(t,e))||t===`is`&&T.allowCustomizedBuiltInElements&&(T.tagNameCheck instanceof RegExp&&C(T.tagNameCheck,r)||T.tagNameCheck instanceof Function&&T.tagNameCheck(r))))return!1}else if(!pt[t]&&!C(ve,ke(r,ge,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&Ae(r,`data:`)===0&&dt[e])&&!(Ye&&!C(he,ke(r,ge,``)))&&r)return!1}return!0},Ft=function(e){return e!==`annotation-xml`&&Oe(e,_e)},It=function(e){K(v.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||jt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:x,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=U(a),l=s,u=a===`value`?l:je(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,K(v.uponSanitizeAttribute,e,r),u=r.attrValue,st&&(c===`id`||c===`name`)&&(G(a,e),u=`user-content-`+u),$e&&C(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)){G(a,e);continue}if(c===`attributename`&&Oe(u,`href`)){G(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){G(a,e);continue}if(!Ze&&C(/\/>/i,u)){G(a,e);continue}k&&xe([le,ue,de],e=>{u=ke(u,e,` `)});let d=U(e.nodeName);if(!Pt(d,c,u)){G(a,e);continue}if(g&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=g.createHTML(u);break;case`TrustedScriptURL`:u=g.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),jt(e)?W(e):Ce(t.removed)}catch{G(a,e)}}K(v.afterSanitizeAttributes,e,null)},Lt=function e(t){let n=null,r=At(t);for(K(v.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)K(v.uponSanitizeShadowNode,n,null),Nt(n),It(n),n.content instanceof a&&e(n.content);K(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(V=!e,V&&(e=`<!-->`),typeof e!=`string`&&!Mt(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(ot||Tt(n),t.removed=[],typeof e==`string`&&(lt=!1),lt){if(e.nodeName){let t=U(e.nodeName);if(!b[t]||Ne[t])throw Me(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=kt(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===tt.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!M&&!k&&!A&&e.indexOf(`<`)===-1)return g&&P?g.createHTML(e):e;if(i=kt(e),!i)return M?null:P?_:``}i&&j&&W(i.firstChild);let u=At(lt?e:i);for(;c=u.nextNode();)Nt(c),It(c),c.content instanceof a&&Lt(c.content);if(lt)return e;if(M){if(N)for(l=oe.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(x.shadowroot||x.shadowrootmode)&&(l=ce.call(r,l,!0)),l}let d=A?i.outerHTML:i.innerHTML;return A&&b[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&C(Qe,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
2
|
+
`+d),k&&xe([le,ue,de],e=>{d=ke(d,e,` `)}),g&&P?g.createHTML(d):d},t.setConfig=function(){Tt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),ot=!0},t.clearConfig=function(){St=null,ot=!1},t.isValidAttribute=function(e,t,n){return St||Tt({}),Pt(U(e),U(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=it()},t}var A=at();function ot(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var j=ot();function M(e){j=e}var N={exec:()=>null};function P(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(F.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var F={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`)},st=/^(?:[ \t]*(?:\n|$))+/,ct=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,lt=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,I=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,L=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ut=/(?:[*+-]|\d{1,9}[.)])/,dt=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ft=P(dt).replace(/bull/g,ut).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(),pt=P(dt).replace(/bull/g,ut).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(),mt=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,ht=/^[^\n]+/,R=/(?!\s*\])(?:\\.|[^\[\]\\])+/,z=P(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,R).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),B=P(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ut).getRegex(),V=`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`,gt=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_t=P(`^ {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`,gt).replace(`tag`,V).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vt=P(mt).replace(`hr`,I).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`,V).getRegex(),H={blockquote:P(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,vt).getRegex(),code:ct,def:z,fences:lt,heading:L,hr:I,html:_t,lheading:ft,list:B,newline:st,paragraph:vt,table:N,text:ht},yt=P(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,I).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`,V).getRegex(),bt={...H,lheading:pt,table:yt,paragraph:P(mt).replace(`hr`,I).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,yt).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`,V).getRegex()},xt={...H,html:P(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,gt).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:N,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:P(mt).replace(`hr`,I).replace(`heading`,` *#{1,6} *[^
|
|
3
|
+
]`).replace(`lheading`,ft).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},U=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,St=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Ct=/^( {2,}|\\)\n(?!\s*$)/,wt=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Tt=/[\p{P}\p{S}]/u,Et=/[\s\p{P}\p{S}]/u,Dt=/[^\s\p{P}\p{S}]/u,Ot=P(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,Et).getRegex(),W=/(?!~)[\p{P}\p{S}]/u,G=/(?!~)[\s\p{P}\p{S}]/u,kt=/(?:[^\s\p{P}\p{S}]|~)/u,At=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,jt=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Mt=P(jt,`u`).replace(/punct/g,Tt).getRegex(),K=P(jt,`u`).replace(/punct/g,W).getRegex(),Nt=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,Pt=P(Nt,`gu`).replace(/notPunctSpace/g,Dt).replace(/punctSpace/g,Et).replace(/punct/g,Tt).getRegex(),Ft=P(Nt,`gu`).replace(/notPunctSpace/g,kt).replace(/punctSpace/g,G).replace(/punct/g,W).getRegex(),It=P(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,Dt).replace(/punctSpace/g,Et).replace(/punct/g,Tt).getRegex(),Lt=P(/\\(punct)/,`gu`).replace(/punct/g,Tt).getRegex(),Rt=P(/^<(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(),zt=P(gt).replace(`(?:-->|$)`,`-->`).getRegex(),Bt=P(`^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`,zt).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Vt=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ht=P(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,Vt).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ut=P(/^!?\[(label)\]\[(ref)\]/).replace(`label`,Vt).replace(`ref`,R).getRegex(),Wt=P(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,R).getRegex(),Gt={_backpedal:N,anyPunctuation:Lt,autolink:Rt,blockSkip:At,br:Ct,code:St,del:N,emStrongLDelim:Mt,emStrongRDelimAst:Pt,emStrongRDelimUnd:It,escape:U,link:Ht,nolink:Wt,punctuation:Ot,reflink:Ut,reflinkSearch:P(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,Ut).replace(`nolink`,Wt).getRegex(),tag:Bt,text:wt,url:N},Kt={...Gt,link:P(/^!?\[(label)\]\((.*?)\)/).replace(`label`,Vt).getRegex(),reflink:P(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,Vt).getRegex()},qt={...Gt,emStrongRDelimAst:Ft,emStrongLDelim:K,url:P(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},Jt={...qt,br:P(Ct).replace(`{2,}`,`*`).getRegex(),text:P(qt.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},Yt={normal:H,gfm:bt,pedantic:xt},Xt={normal:Gt,gfm:qt,breaks:Jt,pedantic:Kt},Zt={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},Qt=e=>Zt[e];function q(e,t){if(t){if(F.escapeTest.test(e))return e.replace(F.escapeReplace,Qt)}else if(F.escapeTestNoEncode.test(e))return e.replace(F.escapeReplaceNoEncode,Qt);return e}function $t(e){try{e=encodeURI(e).replace(F.percentDecode,`%`)}catch{return null}return e}function en(e,t){let n=e.replace(F.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(F.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(F.slashPipe,`|`);return n}function tn(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 nn(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 rn(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 an(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
4
|
+
`).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(`
|
|
5
|
+
`)}var on=class{options;rules;lexer;constructor(e){this.options=e||j}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:tn(e,`
|
|
6
|
+
`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=an(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=tn(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:tn(t[0],`
|
|
7
|
+
`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=tn(t[0],`
|
|
8
|
+
`).split(`
|
|
9
|
+
`),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(`
|
|
10
|
+
`),c=s.replace(this.rules.other.blockquoteSetextReplace,`
|
|
11
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,``);n=n?`${n}
|
|
12
|
+
${s}`:s,r=r?`${r}
|
|
13
|
+
${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+`
|
|
14
|
+
`+e.join(`
|
|
15
|
+
`),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+`
|
|
16
|
+
`+e.join(`
|
|
17
|
+
`),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(`
|
|
18
|
+
`);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(`
|
|
19
|
+
`,1)[0].replace(this.rules.other.listReplaceTabs,e=>` `.repeat(3*e.length)),l=e.split(`
|
|
20
|
+
`,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+`
|
|
21
|
+
`,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(`
|
|
22
|
+
`,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+=`
|
|
23
|
+
`+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+=`
|
|
24
|
+
`+l}!u&&!l.trim()&&(u=!0),r+=f+`
|
|
25
|
+
`,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=en(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
|
|
26
|
+
`):[],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(en(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)===`
|
|
27
|
+
`?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=tn(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=nn(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)),rn(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 rn(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}}}},J=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||j,this.options.tokenizer=this.options.tokenizer||new on,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:F,block:Yt.normal,inline:Xt.normal};this.options.pedantic?(t.block=Yt.pedantic,t.inline=Xt.pedantic):this.options.gfm&&(t.block=Yt.gfm,this.options.breaks?t.inline=Xt.breaks:t.inline=Xt.gfm),this.tokenizer.rules=t}static get rules(){return{block:Yt,inline:Xt}}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(F.carriageReturn,`
|
|
28
|
+
`),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(F.tabCharGlobal,` `).replace(F.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+=`
|
|
29
|
+
`: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+=`
|
|
30
|
+
`+r.raw,n.text+=`
|
|
31
|
+
`+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+=`
|
|
32
|
+
`+r.raw,n.text+=`
|
|
33
|
+
`+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+=`
|
|
34
|
+
`+r.raw,a.text+=`
|
|
35
|
+
`+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+=`
|
|
36
|
+
`+r.raw,n.text+=`
|
|
37
|
+
`+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}},sn=class{options;parser;constructor(e){this.options=e||j}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(F.notSpaceStart)?.[0],i=e.replace(F.endingNewline,``)+`
|
|
38
|
+
`;return r?`<pre><code class="language-`+q(r)+`">`+(n?i:q(i,!0))+`</code></pre>
|
|
39
|
+
`:`<pre><code>`+(n?i:q(i,!0))+`</code></pre>
|
|
40
|
+
`}blockquote({tokens:e}){return`<blockquote>
|
|
41
|
+
${this.parser.parse(e)}</blockquote>
|
|
42
|
+
`}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
|
|
43
|
+
`}hr(e){return`<hr>
|
|
44
|
+
`}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+`>
|
|
45
|
+
`+r+`</`+i+`>
|
|
46
|
+
`}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+` `+q(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>
|
|
47
|
+
`}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
|
|
48
|
+
`}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>
|
|
49
|
+
<thead>
|
|
50
|
+
`+t+`</thead>
|
|
51
|
+
`+r+`</table>
|
|
52
|
+
`}tablerow({text:e}){return`<tr>
|
|
53
|
+
${e}</tr>
|
|
54
|
+
`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
|
|
55
|
+
`}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${q(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=$t(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+q(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=$t(e);if(i===null)return q(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${q(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:q(e.text)}},cn=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``}},Y=class e{options;renderer;textRenderer;constructor(e){this.options=e||j,this.options.renderer=this.options.renderer||new sn,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new cn}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+=`
|
|
56
|
+
`+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}},ln=class{options;block;constructor(e){this.options=e||j}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?J.lex:J.lexInline}provideParser(){return this.block?Y.parse:Y.parseInline}},un=class{defaults=ot();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Y;Renderer=sn;TextRenderer=cn;Lexer=J;Tokenizer=on;Hooks=ln;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 sn(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 on(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 ln;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];ln.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 J.lex(e,t??this.defaults)}parser(e,t){return Y.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?J.lex:J.lexInline,s=i.hooks?i.hooks.provideParser():e?Y.parse:Y.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+=`
|
|
57
|
+
Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+q(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},dn=new un;function X(e,t){return dn.parse(e,t)}X.options=X.setOptions=function(e){return dn.setOptions(e),X.defaults=dn.defaults,M(X.defaults),X},X.getDefaults=ot,X.defaults=j,X.use=function(...e){return dn.use(...e),X.defaults=dn.defaults,M(X.defaults),X},X.walkTokens=function(e,t){return dn.walkTokens(e,t)},X.parseInline=dn.parseInline,X.Parser=Y,X.parser=Y.parse,X.Renderer=sn,X.TextRenderer=cn,X.Lexer=J,X.lexer=J.lex,X.Tokenizer=on,X.Hooks=ln,X.parse=X,X.options,X.setOptions,X.use,X.walkTokens,X.parseInline,Y.parse,J.lex;var fn=e=>(Object.getOwnPropertyNames(e).forEach(t=>{let n=e[t];n&&typeof n==`object`&&fn(n)}),Object.freeze(e)),pn=fn({all:[],used:[],unused:[]}),mn=(e,t)=>{let n=A(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},hn=class{marked;currentReferences=pn;lastUsedIndex=0;DomPurity;constructor(e={}){this.marked=new un({async:!1,breaks:!0}).use(this.createFootnoteExtension(),...e.extensions??[]),this.DomPurity=mn(e.window,e.newTabSrText)}createFootnoteExtension=()=>{let e=this;return{extensions:[{name:`footnote`,level:`inline`,start(e){return e.match(/\[\^(\d+)\]/)?.index},tokenizer(e){let t=/^\[\^(\d+)\]/.exec(e);if(t){let[e,n]=t;return{type:`footnote`,raw:e,refNumber:n}}},renderer(t){if(t.type===`footnote`){let n=parseInt(t.refNumber)-1,r=e.currentReferences.all[n];if(!r)return console.error(`Could not find ref with index:`,n),``;let i;return r?.referenceIndex.used?i=r.referenceIndex.used:(e.currentReferences.used.push(r),e.lastUsedIndex++,i=e.lastUsedIndex,r.referenceIndex.used=i),` <liipgpt-reference-number data-all-index="${n}" data-used-index="${i}" data-source="${JSON.stringify(r).replace(/"/g,`"`)}"></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=pn,n}};function gn(){let e,t;return{promise:new Promise((n,r)=>{t=n,e=r}),reject:e,resolve:t}}var _n=class{promise;resolve;reject;constructor(){let{promise:e,resolve:t,reject:n}=gn();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`},vn=class{hasValue=new _n;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`},yn=e=>{try{return new URL(e).hostname}catch{return e}};function bn(e){return e.replace(/<[^>]*>/g,``).replace(/ /g,` `).replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}var xn=({url:e,considered:t,title:n,description:r,summary:i})=>{let a=yn(e);return{url:e,considered:t,referenceIndex:{},score:0,metadata:{},display:{card:{title:n,description:r||i,badge:e},listItem:{title:n,badge:a}}}},Sn=class{store;content=new vn;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){this.options.onError?.(e),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=bn(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(xn(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()}},Cn=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)}},wn=class{latestRequest=new vn;state=o({state:`idle`});id;history=[];constructor(e){this.clientPrimitive=e,this.id=e.createConversationId()}subscribe(e){return this.state.subscribe(e)}chat(e,t={}){let n=this.clientPrimitive.chat(this.id,e,t);return this.history.push(n),this.latestRequest.setValue({question:e,response:n}),n}async abort(){let e=this.history.map(e=>e.abort());await Promise.all(e)}async thumbsUp(){let{question:e,response:t}=await this.latestRequest;await t.isReadyForFeedback(),await this.clientPrimitive.thumbsUp(t.id,e)}async thumbsDown(){let{question:e,response:t}=await this.latestRequest;await t.isReadyForFeedback(),await this.clientPrimitive.thumbsDown(t.id,e)}async feedback(e){let{question:t,response:n}=await this.latestRequest;await n.isReadyForFeedback(),await this.clientPrimitive.feedback(n.id,t,e)}},Z=[];for(let e=0;e<256;++e)Z.push((e+256).toString(16).slice(1));function Tn(e,t=0){return(Z[e[t+0]]+Z[e[t+1]]+Z[e[t+2]]+Z[e[t+3]]+`-`+Z[e[t+4]]+Z[e[t+5]]+`-`+Z[e[t+6]]+Z[e[t+7]]+`-`+Z[e[t+8]]+Z[e[t+9]]+`-`+Z[e[t+10]]+Z[e[t+11]]+Z[e[t+12]]+Z[e[t+13]]+Z[e[t+14]]+Z[e[t+15]]).toLowerCase()}var En,Dn=new Uint8Array(16);function On(){if(!En){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);En=crypto.getRandomValues.bind(crypto)}return En(Dn)}var kn={};function An(e,t,n){let r;if(e)r=Mn(e.random??e.rng?.()??On(),e.msecs,e.seq,t,n);else{let e=Date.now(),i=On();jn(kn,e,i),r=Mn(i,kn.msecs,kn.seq,t,n)}return t??Tn(r)}function jn(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 Mn(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 Nn=new Map,Pn=class{get length(){return Nn.size}clear(){Nn.clear()}getItem(e){return Nn.get(e)||null}key(e){return Array.from(Nn.keys())[e]||null}removeItem(e){Nn.delete(e)}setItem(e,t){Nn.set(e,String(t))}},Fn=globalThis.localStorage??new Pn,In=async(e,t)=>{try{let n=Fn.getItem(`liipgpt:uID`)||Fn.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`,pe,{},r).catch(t=>(console.log(`Failed to /login use /log`,t),e.fetchData(`/log`,pe,{},r)));if(`maintenance`in i&&i.maintenance)return{mode:`maintenance`};if(!(`id`in i))throw Error(`Invalid response format: missing user id`);return Fn.setItem(`liipgpt:uID`,i.id),{mode:`ready`,userId:i.id}}catch(e){throw console.error(`Failed to fetch user data:`,e),e}},Q=function(e,t){if(!(this instanceof Q))return new Q(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=Q.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(Q.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+=`
|
|
58
|
+
`+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
|
|
59
|
+
`);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(Q.OPEN)}},this.stream=function(){if(!this.xhr){this._setReadyState(Q.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()};Q.INITIALIZING=-1,Q.CONNECTING=0,Q.OPEN=1,Q.CLOSED=2;var Ln=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??Q)(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())}},Rn=e=>Object.fromEntries(Object.entries(e).filter(([e,t])=>t!=null)),zn=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=Rn(t);return this.options.apiKey&&(n.apiKey=this.options.apiKey),new Ln(`${this.options.apiUrl}${e}`,n,r)}async fetchData(e,t,n={},r={}){let i=`${this.options.apiUrl}${e}?${new URLSearchParams(Rn(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(),{success:c,data:l,error:u}=t.safeParse(s);if(this.options.strict){if(!c)throw console.error(`Server response has wrong type:
|
|
60
|
+
`,{error:u,url:i,opts:a,data:s}),Error(`Server response has wrong type: ${u.message}`);return l}else return c||console.warn(`Server response has wrong type:
|
|
61
|
+
`,{error:u,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}},Bn=ce({links:v(ce({url:oe().url().optional(),title:oe().optional(),considered:se().optional(),orgMetadata:ce({authors:v(oe()).optional()}).optional(),type:oe().optional(),date:oe().datetime().optional(),similarity:ae().optional(),content:oe().optional(),fromFullTextSearch:se().optional(),rerank:ce({index:ae().int().optional(),adjustment:ae().optional(),score:ae().optional(),similarityOld:ae().optional()}).optional()}).or(de))}),Vn=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}},Hn=7,Un=8,Wn=160,Gn=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},Kn=e=>{let t=Gn(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},qn=e=>Math.max(Un,Math.min(Wn,e.length*Hn)),Jn=class{queue=[];timeoutId=null;isProcessing=!1;constructor(e){this.onText=e}ingestText(e){let t=Kn(e);if(t.length>=5){for(let e of t)this.queue.push({kind:`text`,chunk:e,delayMs:qn(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())}},Yn=class{constructor(e){this.results=e}},Xn=class{internalData;renderers=new Map;markedExtensions=[];_newTabSrText;constructor(e){let t=new zn({apiUrl:e.apiUrl,apiKey:e.apiKey,speechRecognitionApiKey:e.speechRecognitionApiKey,strict:e.strict??!1,EventSource:e.EventSource??EventSource});this.internalData={restClient:t,metadata:In(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=An();return this.renderers.set(e,new hn({extensions:this.markedExtensions,newTabSrText:this._newTabSrText})),e}chat(e,t,n={}){let r=new vn,i=An(),a=new _n,o=new Sn({id:i,onError:e=>{n.onError?.(e)},onFinish:e=>{r.setValue(e)},markdownRenderer:this.renderers.get(e)??new hn({extensions:this.markedExtensions,newTabSrText:this._newTabSrText}),userQuestion:t}),s=async()=>{await a,(await c).close()},c=new vn,l=new Jn(e=>o.updateText(e));(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,...n.selectorValues??{},...n.predefinedQuestionId?{predefinedQuestionId:n.predefinedQuestionId}:{},...n.switchQuestionId?{switchQuestionId:n.switchQuestionId}:{},chat:`true`,version:`2`},{onClose:()=>{l.clear(),o.finishMessage(),a.resolve(),r.cleanup()},onMessage:t=>{let r=t;switch(r.type){case`error`:l.runAfterTyping(()=>o.pushError(r.error));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`: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)})();let u=new Cn({question:t,id:i,content:r,readableStore:o.getReadableStore(),readyForFeedback:a,abort:s,liipgptClientPrimitive:this});return this.internalData.chatResponseMap.set(u.id,u),u}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`,Bn,{modelId:t.model,lang:t.language,query:e,mapResults:`true`,uID:r});return new Yn(i.map(Vn))}async getChatConfig(){return this.internalData.restClient.fetchData(`/chatconfig`,le)}async getChatHistory(e,t){try{let n=await this.internalData.restClient.postData(`/chathistory`,{cID:e,uID:t}),r=ue.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`,fe,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`}}}},Zn=class{clientPrimitive;constructor(e){this.clientPrimitive=new Xn(e)}getMetadata(){return this.clientPrimitive.getMetadata()}createConversation(){return new wn(this.clientPrimitive)}search(e,t={}){return this.clientPrimitive.search(e,t)}getChatConfig(){return this.clientPrimitive.getChatConfig()}getPredefinedQuestions(e){return this.clientPrimitive.getPredefinedQuestions(e)}},Qn=class extends Map{#e=new Map;#t=e(0);#n=e(0);#r=g||-1;constructor(e){if(super(),e){for(var[t,n]of e)super.set(t,n);this.#n.v=super.size}}#i(n){return g===this.#r?e(n):t(n)}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 h(this.#t),!1;return h(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{h(this.#t);return}return h(n),super.get(e)}set(e,t){var n=this.#e,r=n.get(e),i=super.get(e),a=super.set(e,t),o=this.#t;if(r===void 0)r=this.#i(0),n.set(e,r),c(this.#n,super.size),_(o);else if(i!==t){_(r);var s=o.reactions===null?null:new Set(o.reactions);(s===null||!r.reactions?.every(e=>s.has(e)))&&_(o)}return a}delete(e){var t=this.#e,n=t.get(e),r=super.delete(e);return n!==void 0&&(t.delete(e),c(n,-1)),r&&(c(this.#n,super.size),_(this.#t)),r}clear(){if(super.size!==0){super.clear();var e=this.#e;c(this.#n,0);for(var t of e.values())c(t,-1);_(this.#t),e.clear()}}#a(){h(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)h(n)}keys(){return h(this.#t),super.keys()}values(){return this.#a(),super.values()}entries(){return this.#a(),super.entries()}[Symbol.iterator](){return this.entries()}get size(){return h(this.#n),super.size}},$n=class{#e;#t;constructor(e,t){this.#e=e,this.#t=ee(t)}get current(){return this.#t(),this.#e()}},er=/\(.+\)/,tr=new Set([`all`,`print`,`screen`,`and`,`or`,`not`,`only`]),nr=class extends $n{constructor(e,t){let n=er.test(e)||e.split(/[\s,]+/).some(e=>tr.has(e.trim()))?e:`(${e})`,r=window.matchMedia(n);super(()=>r.matches,e=>m(r,`change`,e))}};function rr(e,t){s(t,!0);let o=ne(t,`css`,7),c=re(t,[`$$slots`,`$$events`,`$$legacy`,`$$host`,`css`]),p=e=>{f(()=>{o()&&(e.innerHTML=o())})};var m={get css(){return o()},set css(e){o(e),a()}},ee=u(),h=ie(ee),g=e=>{var t=u();i(ie(t),()=>`style`,!1,(e,t)=>{te(e,e=>p?.(e)),d(e,()=>({...c}))}),n(e,t)};return l(h,e=>{o()&&e(g)}),n(e,ee),r(m)}p(rr,{css:{}},[],[],{mode:`open`});var ir=RegExp(`([\\p{Ll}\\d])(\\p{Lu})`,`gu`),ar=RegExp(`(\\p{Lu})([\\p{Lu}][\\p{Ll}])`,`gu`),or=RegExp(`(\\d)(\\p{Ll})`,`gu`),sr=RegExp(`(\\p{L})(\\d)`,`gu`),cr=/[^\p{L}\d]+/giu,lr=`$1\0$2`,ur=``;function dr(e,t){let n=e.trim();n=n.replace(ir,lr).replace(ar,lr),t?.separateNumbers&&(n=n.replace(or,lr).replace(sr,lr)),n=n.replace(cr,`\0`);let r=0,i=n.length;for(;n.charAt(r)===`\0`;)r++;if(r===i)return[];for(;n.charAt(i-1)===`\0`;)i--;return n.slice(r,i).split(/\0/g)}function fr(e,t){return Dr(e,t?.prefixCharacters)+dr(e,t).map(Cr(t?.locale)).join(t?.delimiter??` `)}function pr(e,t){let n=Dr(e,t?.prefixCharacters),r=Cr(t?.locale),i=wr(t?.locale),a=t?.mergeAmbiguousCharacters?Tr(r,i):Er(r,i);return n+dr(e,t).map((e,t)=>t===0?r(e):a(e,t)).join(t?.delimiter??``)}function mr(e,t){let n=Dr(e,t?.prefixCharacters),r=Cr(t?.locale),i=wr(t?.locale),a=t?.mergeAmbiguousCharacters?Tr(r,i):Er(r,i);return n+dr(e,t).map(a).join(t?.delimiter??``)}function hr(e,t){let n=Dr(e,t?.prefixCharacters),r=Cr(t?.locale),i=wr(t?.locale);return n+dr(e,t).map(Tr(r,i)).join(t?.delimiter??` `)}function gr(e,t){return Dr(e,t?.prefixCharacters)+dr(e,t).map(wr(t?.locale)).join(t?.delimiter??`_`)}function _r(e,t){return fr(e,{delimiter:`.`,...t})}function vr(e,t){return fr(e,{delimiter:`-`,...t})}function yr(e,t){return fr(e,{delimiter:`/`,...t})}function br(e,t){let n=Dr(e,t?.prefixCharacters),r=Cr(t?.locale),i=Tr(r,wr(t?.locale));return n+dr(e,t).map((e,t)=>t===0?i(e):r(e)).join(t?.delimiter??` `)}function xr(e,t){return fr(e,{delimiter:`_`,...t})}function Sr(e,t){return hr(e,{delimiter:`-`,...t})}function Cr(e){return e===!1?e=>e.toLowerCase():t=>t.toLocaleLowerCase(e)}function wr(e){return e===!1?e=>e.toUpperCase():t=>t.toLocaleUpperCase(e)}function Tr(e,t){return n=>`${t(n[0])}${e(n.slice(1))}`}function Er(e,t){return(n,r)=>{let i=n[0];return(r>0&&i>=`0`&&i<=`9`?`_`+i:t(i))+e(n.slice(1))}}function Dr(e,t=ur){let n=``;for(let r=0;r<e.length;r++){let i=e.charAt(r);if(t.includes(i))n+=i;else break}return n}function Or(e,t){let n=``;for(let r of e)n+=Math.random()>.5?r.toLocaleUpperCase(t):r.toLocaleLowerCase(t);return n}function kr(e,t){let n=``;for(let r of e){let e=r.toLocaleLowerCase(t);n+=r===e?r.toLocaleUpperCase(t):e}return n}var Ar=/\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i,jr=/[^\s:–—-]+|./g,Mr=/\s/,Nr=/.(?=[A-Z]|\..)/,Pr=/[A-Za-z0-9\u00C0-\u00FF]/;function Fr(e){for(var t=``,n;(n=jr.exec(e))!==null;){var r=n[0],i=n.index;if(!Nr.test(r)&&(!Ar.test(r)||i===0||i+r.length===e.length)&&(e.charAt(i+r.length)!==`:`||Mr.test(e.charAt(i+r.length+1)))){t+=r.replace(Pr,function(e){return e.toUpperCase()});continue}t+=r}return t}var Ir=pr,Lr=hr,Rr=gr,zr=_r,Br=fr,Vr=mr,Hr=yr,Ur=br,Wr=xr,Gr=Sr,Kr=vr,qr=Or,Jr=kr,Yr=Fr,Xr=e=>e.toUpperCase(),Zr=(e,t)=>e.toLocaleUpperCase(t),Qr=e=>e.toLowerCase(),$r=(e,t)=>e.toLocaleLowerCase(t),ei=e=>e.charAt(0).toLowerCase()+e.slice(1),ti=e=>e.charAt(0).toUpperCase()+e.slice(1),ni=e=>e===e.toUpperCase(),ri=e=>e===e.toLowerCase(),$=class{};$.camel=Ir,$.capital=Lr,$.constant=Rr,$.dot=zr,$.kebab=Kr,$.lower=Qr,$.lowerFirst=ei,$.localeLower=$r,$.localeUpper=Zr,$.no=Br,$.pascal=Vr,$.path=Hr,$.sentence=Ur,$.snake=Wr,$.sponge=qr,$.swap=Jr,$.title=Yr,$.train=Gr,$.upper=Xr,$.upperFirst=ti,$.isUpper=ni,$.isLower=ri;var ii=640,ai=1024,oi=null,si=()=>{if(oi)return oi;if(!globalThis.document)return 16;let e=globalThis.document.querySelector(`:root`);return oi=Number(getComputedStyle(e).fontSize.slice(0,-2)),oi},ci=({minRem:e,maxRem:t})=>{let n=si(),r=ii/n,i=ai/n,a=(t-e)/(i-r);return`clamp( ${e}rem, ${-r*a+e}rem + ${a*100}cqw, ${t}rem )`},li=e=>typeof e==`string`?e:typeof e==`number`?String(e):typeof e==`object`?e.minRem===e.maxRem?`${e.minRem}rem`:ci(e):``,ui=(e,t,n,r=!1)=>{let i=``;return n.forEach(n=>{let a=t[n];r&&!a&&n===`borderWidth`&&(a=`0px`),r&&!a&&n===`borderColor`&&(a=`transparent`),a&&(i+=`--${Kr(e)}-${Kr(n)}:${li(a)}; `)}),i},di=(e,t)=>Object.entries(t).map(([t,n])=>`--${e}-${Kr(t)}:${li(n)}`).join(`; `)+`; `,fi=(e,t)=>{let n=``;return n+=ui(e,t,[`background`,`borderWidth`,`borderColor`,`boxShadow`,`borderRadius`,`color`],!0),t.hover&&(n+=ui(`${e}-hover`,t.hover,[`background`,`borderWidth`,`borderColor`,`boxShadow`,`color`])),t.focus&&(n+=ui(`${e}-focus`,t.focus,[`background`,`borderWidth`,`borderColor`,`boxShadow`,`color`])),t.custom&&(n+=di(e,t.custom)),n},pi=(e,t)=>Object.entries(t).map(([t,n])=>`--color-${e}-${t}:${n}`).join(`; `)+`; `,mi=e=>`--font-family: ${e?.family||`inherit`};`,hi=(e,t={})=>`${t.root??`.chat-app`} {${mi(e.font)} ${Object.entries(e.colors).map(([e,t])=>pi(e,t)).join(``)} ${di(`base`,e.base)} ${Object.entries(e.components).map(([e,t])=>fi(Kr(e),t)).join(``)}};`;export{Zn as a,Kn as c,Tn as d,bn as f,Qn as i,Fn as l,A as m,rr as n,Xn as o,hn as p,nr as r,qn as s,hi as t,On as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Kt as e,Lt as t,Mt as n,Rt as r,c as i,i as a,kt as o,o as s,ot as c}from"./rEsbAd0y.js";import"./Bo0U8J3e.js";import"./CFKVnMbq.js";import"./CZzAbm1q.js";import"./Dmocya4I.js";import"./DKyUMEyV.js";import"./CPPDi2Fg.js";import"./DaqY3Yc5.js";import"./D1EjYV4X.js";import"./DlFt-05G.js";import{t as l}from"./7oe4YkCP.js";import"./CG82rIPn.js";import"./C44XFFk1.js";import{t as u}from"./BiTRwaVm.js";function d(a,d){r(d,!0);let f=s(d,`forceTheme`,7),p=s(d,`apiUrl`,7),m=s(d,`apiKey`,7),h=s(d,`speechRecognitionApiKey`,7),g=s(d,`lang`,7),_=s(d,`features`,7),v=s(d,`loaderBackground`,7),y=s(d,`loaderColor`,7),b=s(d,`flyout`,7),x=s(d,`flyoutStyle`,7),S=s(d,`flyoutClass`,7),C=s(d,`chatClass`,7),w=s(d,`inlineLayout`,7),T=s(d,`forceChatPage`,7),E=s(d,`hidePredefinedQuestions`,7),D=s(d,`autofirePredefinedQuestionId`,7),O=s(d,`additionalStartParameters`,7),k=s(d,`question`,7),A=o(()=>({forceTheme:f(),apiUrl:p(),apiKey:m(),speechRecognitionApiKey:h(),lang:g(),features:_(),loaderBackground:v(),loaderColor:y(),flyout:b(),flyoutStyle:x(),flyoutClass:S(),chatClass:C(),inlineLayout:w(),forceChatPage:T(),hidePredefinedQuestions:E(),autofirePredefinedQuestionId:D(),additionalStartParameters:O(),question:k()}));var j={get forceTheme(){return f()},set forceTheme(e){f(e),n()},get apiUrl(){return p()},set apiUrl(e){p(e),n()},get apiKey(){return m()},set apiKey(e){m(e),n()},get speechRecognitionApiKey(){return h()},set speechRecognitionApiKey(e){h(e),n()},get lang(){return g()},set lang(e){g(e),n()},get features(){return _()},set features(e){_(e),n()},get loaderBackground(){return v()},set loaderBackground(e){v(e),n()},get loaderColor(){return y()},set loaderColor(e){y(e),n()},get flyout(){return b()},set flyout(e){b(e),n()},get flyoutStyle(){return x()},set flyoutStyle(e){x(e),n()},get flyoutClass(){return S()},set flyoutClass(e){S(e),n()},get chatClass(){return C()},set chatClass(e){C(e),n()},get inlineLayout(){return w()},set inlineLayout(e){w(e),n()},get forceChatPage(){return T()},set forceChatPage(e){T(e),n()},get hidePredefinedQuestions(){return E()},set hidePredefinedQuestions(e){E(e),n()},get autofirePredefinedQuestionId(){return D()},set autofirePredefinedQuestionId(e){D(e),n()},get additionalStartParameters(){return O()},set additionalStartParameters(e){O(e),n()},get question(){return k()},set question(e){k(e),n()}};{let t=(t,n=e)=>{l(t,i({host:d.$$host,get onError(){return n()}},()=>c(A)))},n=o(()=>c(A).flyout??!1);u(a,{get silent(){return c(n)},body:t,$$slots:{body:!0}})}return t(j)}customElements.define(`liipgpt-chat`,a(d,{forceTheme:{attribute:`force-theme`,type:`String`},apiUrl:{attribute:`api-url`,type:`String`},apiKey:{attribute:`api-key`,type:`String`},speechRecognitionApiKey:{attribute:`speech-recognition-api-key`,type:`String`},lang:{attribute:`lang`,type:`String`},features:{attribute:`features`,type:`String`},loaderBackground:{attribute:`loader-background`,type:`String`},loaderColor:{attribute:`loader-color`,type:`String`},flyout:{attribute:`flyout`,type:`Boolean`},flyoutStyle:{attribute:`flyout-style`,type:`String`},flyoutClass:{attribute:`flyout-class`,type:`String`},chatClass:{attribute:`chat-class`,type:`String`},inlineLayout:{attribute:`inline-layout`,type:`Boolean`},forceChatPage:{attribute:`force-chat-page`,type:`Boolean`},hidePredefinedQuestions:{attribute:`hide-predefined-questions`,type:`Boolean`},autofirePredefinedQuestionId:{attribute:`autofire-predefined-question-id`,type:`String`},additionalStartParameters:{attribute:`additional-start-parameters`,type:`String`},question:{attribute:`question`,type:`String`}},[],[],{mode:`open`}));export{d as LiipGPTChat};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e,t}from"./CibALFW0.js";import{Ct as n,Dt as r,Ft as i,Ht as a,It as o,J as s,L as c,Lt as l,M as u,Mt as d,Rt as f,Tt as p,Y as m,ct as h,ft as g,g as _,gt as v,ht as y,i as b,it as x,jt as ee,k as te,kt as S,lt as C,m as ne,o as w,ot as T,s as re,xt as E,zt as D}from"./rEsbAd0y.js";import{t as O}from"./DjVmpym-.js";import{i as ie,n as ae,r as oe,t as se}from"./Dmocya4I.js";import{d as ce,l as k,m as le,o as ue,p as de,u as fe}from"./DaqY3Yc5.js";import{i as pe,n as me,t as he}from"./D1EjYV4X.js";var ge={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function _e(e,t,n){e||={};let r=e.random??e.rng?.()??fe();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 ce(r)}function A(e,t,n){return ge.randomUUID&&!t&&!e?ge.randomUUID():_e(e,t,n)}var j={de:{aborted:`Verbindung zum Server wurde unerwartet unterbrochen. Bitte versuchen Sie es erneut.`,"client-error":`Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es erneut.`,"server-error":`Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es erneut.`,"sse-error":`Ein unbekannter Fehler ist aufgetreten. Bitte versuchen Sie es erneut.`,blocked:`Ihre Anfrage wurde blockiert.`,"pii-detected":`Es wurden persönliche Daten erkannt. Bitte entfernen Sie diese und versuchen Sie es erneut.`,"incomplete-error":`Ein unbekannter Fehler ist aufgetreten. Die Antwort könnte unvollständig sein.`,"unexpected-call":`Ein unbekannter Fehler ist aufgetreten. Die Antwort könnte unvollständig sein.`,"quota-reached":`Kontingent überschritten. Bitte versuchen Sie es später erneut.`,"rate-limit":`Kontingent überschritten. Bitte versuchen Sie es später erneut.`,maintenance:`Der Chat ist derzeit nicht verfügbar. Bitte versuchen Sie es später erneut.`,"too-long":`Ihre Frage war zu lang, versuchen Sie es mit einer Kürzeren.`,"too-short":`Ihre Frage war zu kurz, versuchen Sie es mit einer Längeren.`,"feedback-failed":`Feedback senden fehlgeschlagen. Bitte versuchen Sie es erneut.`,"answer-form-failed":`Formular konnte nicht gesendet werden. Bitte versuchen Sie es erneut.`,"speech-not-supported":`Spracherkennung wird nicht unterstützt.`,"speech-transcription-failed":`Sprachtranskription fehlgeschlagen.`,"speech-no-text-detected":`Kein Text in der Spracheingabe erkannt.`,"speech-microphone-access-denied":`Mikrofonzugriff verweigert.`},en:{aborted:`Connection to the server was unexpectedly interrupted. Please try again.`,"client-error":`An unknown error has occurred. Please try again.`,"server-error":`An unknown error has occurred. Please try again.`,"sse-error":`An unknown error has occurred. Please try again.`,blocked:`Your request has been blocked.`,"pii-detected":`Personal data has been detected. Please remove it and try again.`,"incomplete-error":`An unknown error has occurred. The response might be incomplete.`,"unexpected-call":`An unknown error has occurred. The response might be incomplete.`,"quota-reached":`Quota exceeded. Please try again later.`,"rate-limit":`Quota exceeded. Please try again later.`,maintenance:`The chat is currently unavailable. Please try again later.`,"too-long":`Your question was too long, try a shorter one.`,"too-short":`Your question was too short, try a longer one.`,"feedback-failed":`Failed to send feedback. Please try again.`,"answer-form-failed":`Failed to send the form. Please try again.`,"speech-not-supported":`Speech recognition is not supported.`,"speech-transcription-failed":`Speech transcription failed.`,"speech-no-text-detected":`No text detected in speech input.`,"speech-microphone-access-denied":`Microphone access denied.`},it:{aborted:`La connessione al server è stata interrotta inaspettatamente. Si prega di riprovare.`,"client-error":`Si è verificato un errore sconosciuto. Si prega di riprovare.`,"server-error":`Si è verificato un errore sconosciuto. Si prega di riprovare.`,"sse-error":`Si è verificato un errore sconosciuto. Si prega di riprovare.`,blocked:`La tua richiesta è stata bloccata.`,"pii-detected":`Sono stati rilevati dati personali. Si prega di rimuoverli e riprovare.`,"incomplete-error":`Si è verificato un errore sconosciuto. La risposta potrebbe essere incompleta.`,"unexpected-call":`Si è verificato un errore sconosciuto. La risposta potrebbe essere incompleta.`,"quota-reached":`Quota superata. Si prega di riprovare più tardi.`,"rate-limit":`Quota superata. Si prega di riprovare più tardi.`,maintenance:`La chat non è attualmente disponibile. Si prega di riprovare più tardi.`,"too-long":`La tua domanda era troppo lunga, prova con una più breve.`,"too-short":`La tua domanda era troppo breve, prova con una più lunga.`,"feedback-failed":`Invio del feedback non riuscito. Si prega di riprovare.`,"answer-form-failed":`Invio del modulo non riuscito. Si prega di riprovare.`,"speech-not-supported":`Il riconoscimento vocale non è supportato.`,"speech-transcription-failed":`Trascrizione vocale fallita.`,"speech-no-text-detected":`Nessun testo rilevato nell'input vocale.`,"speech-microphone-access-denied":`Accesso al microfono negato.`},fr:{aborted:`La connexion au serveur a été interrompue de façon inattendue. Veuillez réessayer.`,"client-error":`Une erreur inconnue s'est produite. Veuillez réessayer.`,"server-error":`Une erreur inconnue s'est produite. Veuillez réessayer.`,"sse-error":`Une erreur inconnue s'est produite. Veuillez réessayer.`,"pii-detected":`Des données personnelles ont été détectées. Veuillez les supprimer et réessayer.`,blocked:`Votre demande a été bloquée.`,"incomplete-error":`Une erreur inconnue s'est produite. La réponse pourrait être incomplète.`,"unexpected-call":`Une erreur inconnue s'est produite. La réponse pourrait être incomplète.`,"quota-reached":`Quota dépassé. Veuillez réessayer plus tard.`,"rate-limit":`Quota dépassé. Veuillez réessayer plus tard.`,maintenance:`Le chat est actuellement indisponible. Veuillez réessayer plus tard.`,"too-long":`Votre question était trop longue, essayez d'en poser une plus courte.`,"too-short":`Votre question était trop courte, essayez d'en poser une plus longue.`,"feedback-failed":`Échec de l'envoi du feedback. Veuillez réessayer.`,"answer-form-failed":`Échec de l'envoi du formulaire. Veuillez réessayer.`,"speech-not-supported":`La reconnaissance vocale n'est pas prise en charge.`,"speech-transcription-failed":`Échec de la transcription vocale.`,"speech-no-text-detected":`Aucun texte détecté dans l'entrée vocale.`,"speech-microphone-access-denied":`Accès au microphone refusé.`}},ve={de:{email:`Bitte keine E-Mail Adressen eingeben`,creditCard:`Bitte keine Kreditkarteninformationen eingeben`,ahv:`Bitte keine AHV-Nummern eingeben`,phoneSwiss:`Bitte keine Telefonnummern eingeben`,phoneInternational:`Bitte keine Telefonnummern eingeben`,swissPassport:`Bitte keine Passinformationen eingeben`,longNumber:`Bitte keine langen Nummern eingeben`},en:{email:`Please do not enter email addresses`,creditCard:`Please do not enter credit card information`,ahv:`Please do not enter AHV numbers`,phoneSwiss:`Please do not enter phone numbers`,phoneInternational:`Please do not enter phone numbers`,swissPassport:`Please do not enter passport information`,longNumber:`Please do not enter long numbers`},it:{email:`Si prega di non inserire indirizzi email`,creditCard:`Si prega di non inserire informazioni sulla carta di credito`,ahv:`Si prega di non inserire numeri AVS`,phoneSwiss:`Si prega di non inserire numeri di telefono`,phoneInternational:`Si prega di non inserire numeri di telefono`,swissPassport:`Si prega di non inserire informazioni sul passaporto`,longNumber:`Si prega di non inserire numeri lunghi`},fr:{email:`Veuillez ne pas saisir d'adresses e-mail`,creditCard:`Veuillez ne pas saisir d'informations de carte de crédit`,ahv:`Veuillez ne pas saisir de numéros AVS`,phoneSwiss:`Veuillez ne pas saisir de numéros de téléphone`,phoneInternational:`Veuillez ne pas saisir de numéros de téléphone`,swissPassport:`Veuillez ne pas saisir d'informations de passeport`,longNumber:`Veuillez ne pas saisir de longs numéros`}},ye=t(((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 be(...e){return e.filter(Boolean).join(` `)}var xe=typeof document<`u`,Se=typeof window<`u`?window:void 0;typeof window<`u`&&window.document,typeof window<`u`&&window.navigator,typeof window<`u`&&window.location;function Ce(e){let t=e.activeElement;for(;t?.shadowRoot;){let e=t.shadowRoot.activeElement;if(e===t)break;t=e}return t}new class{#e;#t;constructor(e={}){let{window:t=Se,document:n=t?.document}=e;t!==void 0&&(this.#e=n,this.#t=ee(e=>{let n=x(t,`focusin`,e),r=x(t,`focusout`,e);return()=>{n(),r()}}))}get current(){return this.#t?.(),this.#e?Ce(this.#e):null}};var M=class{#e;#t;constructor(e){this.#e=e,this.#t=Symbol(e)}get key(){return this.#t}exists(){return o(this.#t)}get(){let e=i(this.#t);if(e===void 0)throw Error(`Context "${this.#e}" not found`);return e}getOr(e){let t=i(this.#t);return t===void 0?e:t}set(e){return D(this.#t,e)}};function we(e,t){switch(e){case`post`:y(t);break;case`pre`:v(t);break}}function N(e,t,n,r={}){let{lazy:i=!1}=r,a=!i,o=Array.isArray(e)?[]:void 0;we(t,()=>{let t=Array.isArray(e)?e.map(e=>e()):e();if(!a){a=!0,o=t;return}let r=C(()=>n(t,o));return o=t,r})}function Te(e,t,n){let r=g(()=>{let i=!1;N(e,t,(e,t)=>{if(i){r();return}let a=n(e,t);return i=!0,a},{lazy:!0})});y(()=>r)}function P(e,t,n){N(e,`post`,t,n)}function Ee(e,t,n){N(e,`pre`,t,n)}P.pre=Ee;function De(e,t){Te(e,`post`,t)}function Oe(e,t){Te(e,`pre`,t)}De.pre=Oe;function ke(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 Ae(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 F(e,t,i={},a){let{lazy:o=!1,once:s=!1,initialValue:c,debounce:l,throttle:u}=i,d=r(n(c)),f=r(!1),m=r(void 0),h=r(n([])),g=()=>{T(h).forEach(e=>e()),p(h,[],!0)},_=e=>{p(h,[...T(h),e],!0)},v=async(e,n,r=!1)=>{try{p(f,!0),p(m,void 0),g();let i=new AbortController;_(()=>i.abort());let a=await t(e,n,{data:T(d),refetching:r,onCleanup:_,signal:i.signal});return p(d,a,!0),a}catch(e){e instanceof DOMException&&e.name===`AbortError`||p(m,e,!0);return}finally{p(f,!1)}},y=l?ke(v,l):u?Ae(v,u):v,b=Array.isArray(e)?e:[e],x;return a((t,n)=>{s&&x||(x=t,y(Array.isArray(e)?t:t[0],Array.isArray(e)?n:n?.[0]))},{lazy:o}),{get current(){return T(d)},get loading(){return T(f)},get error(){return T(m)},mutate:e=>{p(d,e,!0)},refetch:t=>{let n=b.map(e=>e());return y(Array.isArray(e)?n:n[0],Array.isArray(e)?n:n[0],t??!0)}}}function je(e,t,n){return F(e,t,n,(t,n)=>{let r=Array.isArray(e)?e:[e];P(()=>r.map(e=>e()),(e,n)=>{t(e,n??[])},n)})}function Me(e,t,n){return F(e,t,n,(t,n)=>{let r=Array.isArray(e)?e:[e];P.pre(()=>r.map(e=>e()),(e,n)=>{t(e,n??[])},n)})}je.pre=Me,new M(`richColorsContext`);var Ne=new M(`<Toaster/>`),I=0,Pe=class{#e=r(n([]));get toasts(){return T(this.#e)}set toasts(e){p(this.#e,e,!0)}#t=r(n([]));get heights(){return T(this.#t)}set heights(e){p(this.#t,e,!0)}#n=e=>{let t=this.toasts.findIndex(t=>t.id===e);return t===-1?null:t};addToast=e=>{xe&&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,updated:!0}};create=e=>{let{message:t,...n}=e,r=typeof e?.id==`number`||e.id&&e.id?.length>0?e.id:I++,i=e.dismissible===void 0?e.dismissable===void 0?!0:e.dismissable:e.dismissible,a=e.type===void 0?`default`:e.type;return C(()=>{this.toasts.find(e=>e.id===r)?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=>(C(()=>{if(e===void 0){this.toasts=this.toasts.map(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.#n(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=Fe(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=t?.id||I++;return this.create({component:e,id:n,...t}),n};removeHeight=e=>{this.heights=this.heights.filter(t=>t.toastId!==e)};setHeight=e=>{let t=this.#n(e.toastId);if(t===null){this.heights.push(e);return}this.heights[t]=e};reset=()=>{this.toasts=[],this.heights=[]}};function Fe(e){return e&&typeof e==`object`&&`status`in e?`HTTP error! Status: ${e.status}`:`Error! ${e}`}var L=new Pe;function Ie(e,t){return L.create({message:e,...t})}var Le=class{#e=S(()=>L.toasts.filter(e=>!e.dismiss));get toasts(){return T(this.#e)}},R=Object.assign(Ie,{success:L.success,info:L.info,warning:L.warning,error:L.error,custom:L.custom,message:L.message,promise:L.promise,dismiss:L.dismiss,loading:L.loading,getActiveToasts:()=>L.toasts.filter(e=>!e.dismiss)}),Re=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)},ze=(e,t)=>{let n={};return t.forEach(t=>{n[t]=e[t]}),n},Be=console.warn,Ve=()=>{},He=(e,t)=>C(()=>{console.warn=Ve;let n=a(t?ze(e,t):e);return console.warn=Be,n}),Ue=e=>e&&typeof e.then==`function`,We=class{config;self;devtools;stateKeys;constructor(e,t){this.config=e,this.self=t,typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&(this.stateKeys=Re(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 He(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 C(()=>t.call(this.self,...r));let i=He(r);this.sendStart(e,i);try{let n=C(()=>t.call(this.self,...r));return Ue(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}},Ge=(e,t)=>{let n={},r=new We(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 Ke(){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 z(){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 qe(){return typeof window>`u`?!1:!!(window.MediaRecorder&&z())}function Je(){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 Ye(){return typeof window>`u`?!1:!!(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||Je())}var B=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(!qe()||!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=z();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 qe()}static getSupportedMediaType(){return z()}},Xe=le(),Ze=(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`)))},Qe=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&&Ze(e,n)}),Xe.sanitize(t.outerHTML,{FORBID_TAGS:[`style`,`script`],FORBID_ATTR:[`style`,`class`]})},$e=e=>{if(!e?.length)return[];let t=e.join(`,`),n=document.querySelectorAll(t);return Array.from(n,Qe)},V=`liipgpt:context`,et=class{contextVersion=0;#e=r();get currentContext(){return T(this.#e)}set currentContext(e){p(this.#e,e,!0)}getFromLocalStorage(){let e=localStorage.getItem(V);if(e){let t;try{if(t=JSON.parse(e),t.version!==this.contextVersion){localStorage.removeItem(V);return}else return t.context}catch(e){console.error(`Failed to parse liipgpt:context`,e);return}}}storeToLocalStorage(){localStorage.setItem(`liipgpt:context`,JSON.stringify({version:Z.data.chatConfig.contextVersion,context:this.currentContext}))}constructor(e){this.init=e,this.currentContext=this.getFromLocalStorage()??e.initialValue}getContext(){return a(this.currentContext)}setContextVersion(e){this.contextVersion=e}setContext(e){this.currentContext=e,this.storeToLocalStorage()}resetContext(){this.currentContext=this.init.initialValue,this.storeToLocalStorage()}updateContext(e){this.setContext(e(this.currentContext))}},tt=()=>localStorage.getItem(V),nt=[{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\.\d{4}\.\d{4}\.\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)}],H=e=>{for(let t of nt)if(t.check(e))return t.type},U=`liipgpt:selectorValues`,W=`liipgpt:selectorKnownDefaults`,G=()=>{try{let e=k.getItem(U),t=k.getItem(W);return e?{values:JSON.parse(e),knownDefaults:t?JSON.parse(t):{}}:null}catch{return null}},rt=e=>{let t={};for(let n of e)t[n.settingName]=n.defaultValues??(n.allowEmpty?[]:[n.values[0]]).filter(Boolean);return t},K=(e,t)=>{try{let n=rt(t);k.setItem(U,JSON.stringify(e)),k.setItem(W,JSON.stringify(n))}catch(e){console.error(`Failed to save selector values:`,e)}},it=e=>{try{let t=G();if(!t)return;delete t.values[e],delete t.knownDefaults[e],k.setItem(U,JSON.stringify(t.values)),k.setItem(W,JSON.stringify(t.knownDefaults))}catch(e){console.error(`Failed to clear selector saved state:`,e)}},at=e=>{let t=G(),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)},q=class extends Error{constructor(e){super(e),this.name=`UnreachableError`}},ot=e(ye(),1),st=(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},J=(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`}},Y=`follow-up-q`,ct=e=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e),lt=()=>{let e=new URLSearchParams(window.location.hash.replace(/^#/,``)).get(`cID`)??void 0;return{cID:e&&ct(e)?e:void 0,followUpQuestion:new URLSearchParams(window.location.search).get(Y)?.trim()||void 0}},ut=()=>{let e=new URLSearchParams(window.location.search);if(!e.has(Y))return;e.delete(Y);let t=e.toString();history.replaceState(null,``,`${window.location.pathname}${t?`?${t}`:``}${window.location.hash}`)},dt=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}},ft=e=>{let t=dt(e);if(!t)return!1;let n=e=>Array.isArray(e)?e.map(String):typeof e==`string`?e.split(`,`).map(e=>e.trim()).filter(Boolean):[];return[...n(t.availableTopicSlugs),...n(t.availableTopicIds??t.topicIds)].length===1},X=e=>e?e.map(e=>({id:A(),...e})):[],Z=new class{#e=r(n({}));get data(){return T(this.#e)}set data(e){p(this.#e,e,!0)}#t=r(n({}));get targets(){return T(this.#t)}set targets(e){p(this.#t,e,!0)}#n=r(!1);get initialized(){return T(this.#n)}set initialized(e){p(this.#n,e,!0)}#r=r(0);get currentAudioVolume(){return T(this.#r)}set currentAudioVolume(e){p(this.#r,e,!0)}ariaLiveMessagesClearingTimeoutDuration=350;#i=r(null);get currentAudioRecorder(){return T(this.#i)}set currentAudioRecorder(e){p(this.#i,e,!0)}#a=r(!1);get isTranscribing(){return T(this.#a)}set isTranscribing(e){p(this.#a,e,!0)}#o=S(()=>{if(!this.initialized)return[];let e=this.data.chatConfig.menu;return e?e[this.data.language]??[]:[]});get menu(){return T(this.#o)}set menu(e){p(this.#o,e)}#s=S(()=>this.initialized?this.data.chatConfig.translations[this.data.language]??{}:{});get t(){return T(this.#s)}set t(e){p(this.#s,e)}#c=S(()=>this.initialized?j[this.data.language]??{}:j.en??{});get errorTranslations(){return T(this.#c)}set errorTranslations(e){p(this.#c,e)}#l=S(()=>this.initialized?ve[this.data.language]??{}:ve.en??{});get piiTranslations(){return T(this.#l)}set piiTranslations(e){p(this.#l,e)}#u=S(()=>this.initialized?this.data.currentColorScheme:`light`);get colorScheme(){return T(this.#u)}set colorScheme(e){p(this.#u,e)}#d=S(()=>this.initialized?this.data.chatConfig.fullTheme[this.data.currentColorScheme]:{});get themeBase(){return T(this.#d)}set themeBase(e){p(this.#d,e)}#f=S(()=>this.themeBase.tokens);get theme(){return T(this.#f)}set theme(e){p(this.#f,e)}#p=S(()=>{if(!this.initialized)return[];let e=[];for(let t of this.data.chatConfig.selectorsConfig)t.allowEmpty||(this.data.selectorValues[t.settingName]||[]).length===0&&e.push(t.settingName);return e});get selectorsWithErrors(){return T(this.#p)}set selectorsWithErrors(e){p(this.#p,e)}#m=S(()=>{if(!this.initialized)return!1;let e=this.data.chatConfig;return this.data.route.name===`chat-page`&&!e.forceChatPage||e.showContextInfo||e.showContextMenu||e.showCloseChatButton||this.data.props.flyout});get hasMainNavigationContent(){return T(this.#m)}set hasMainNavigationContent(e){p(this.#m,e)}#h=S(()=>{if(!this.initialized)return``;let e=this.t,t=this.data.chatConfig,n=this.data.route.name===`chat-page`&&!t.forceChatPage,r=[];return n&&r.push(e.newChat),t.showContextInfo&&r.push(e.ariaMainNavigationInfo),t.showContextMenu&&(this.menu.length>0&&r.push(e.ariaMainNavigationLinks),t.supportedLanguages.length>0&&r.push(e.ariaMainNavigationLanguageSwitch),this.data.has2ColorSchemes&&r.push(e.ariaMainNavigationColorMode)),(t.showCloseChatButton||this.data.props.flyout)&&r.push(e.closeChat),r.length===0?e.ariaMainNavigation:`${e.ariaMainNavigation}: ${r.join(`, `)}`});get ariaMainNavigationRegion(){return T(this.#h)}set ariaMainNavigationRegion(e){p(this.#h,e)}},Q,$,pt,mt=Ge({name:`chat-logic`,state:Z,excludeInDevTools:[`onInput`]},{async init(e){$=e;let t=$.speechRecognitionApiKey||void 0;Q=new ue({apiUrl:$.apiUrl,apiKey:$.apiKey,speechRecognitionApiKey:t,strict:!0,startParameters:dt($.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=ie(e);$.inlineLayout!==void 0&&(n.inlineLayout=$.inlineLayout),$.forceChatPage!==void 0&&(n.forceChatPage=$.forceChatPage);let r;r=$.lang?me($.lang,n.supportedLanguages):he(n.supportedLanguages),pe(r,Z.targets.mainElement);let i=await this.getPredefinedQuestions(r),a=n.translations[r]?.ariaOpensInNewTab;a&&Q.setNewTabSrText(a);let o=[];if(n.renderKatex){let e=await O(()=>import(`https://esm.sh/marked-katex-extension@5.1.5`),[],import.meta.url).catch(e=>{console.error(`Couldn't load marked-katex-extension:`,e)});e&&(Q.setMarkedExtensions(e.default({nonStandard:!0,output:`mathml`})),o.push(`https://cdn.jsdelivr.net/npm/katex@0.16.22/dist/katex.min.css`))}let s=Object.keys(n.fullTheme),c=!1;if(n.forceConsent)try{c=k.getItem(`liipgpt:termsAccepted`)===`true`}catch(e){console.warn(`Failed to load terms acceptance from storage:`,e)}let l=st($.autofirePredefinedQuestionId,i);Z.data={currentConversationState:`idle`,chatConfig:n,language:r,predefinedQuestions:i,isInMaintenance:t,history:X(n.messageAdditions.init),selectedColorScheme:ae(),has2ColorSchemes:s.length===2,currentColorScheme:se(s),conversationFeedbackId:void 0,conversationFeedbackIsOpen:!1,answerFormMessageId:void 0,openedPopup:void 0,props:$,flyoutIsOpen:!1,questionHasPii:void 0,chatInputValue:``,selectorValues:at(n.selectorsConfig),selectorsIsOpen:!1,predefinedQuestionId:void 0,switchQuestionId:void 0,currentReferencesAsideId:void 0,ariaLiveStatusMessage:void 0,ariaLiveStatusMessageClearingTimeout:void 0,wasReferencesAsideClosed:!1,isAsideMobile:!0,route:J(n.forceConsent??!1,c,n.forceChatPage??!1,l,$.question),additionalStylesheets:o,hasOpenedOverlays:!1,isInlineLayoutContained:!1,termsAccepted:c,selectedTopic:void 0},window.LIIPGPT_LISTENERS?.route?.(Z.data.route),window.LIIPGPT_LISTENERS?.conversation?.(Z.data.currentConversationState),Z.data.selectorsIsOpen=Z.data.chatConfig.showExpandedSelectors??!1,Z.initialized=!0,this.checkForOpenedPopup(),window.addEventListener(`hashchange`,()=>{this.checkForOpenedPopup()}),await this.startFromHandoverOrRoute(()=>this.goto(J(n.forceConsent??!1,c,n.forceChatPage??!1,l,$.question),!0))}catch(e){throw R.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){Z.targets[e]=t},goto(e,t=!1){if(!(!t&&(0,ot.default)(Z.data.route,e)))switch(Z.data.route=e,window.LIIPGPT_LISTENERS?.route?.(e),e.name){case`consent-page`:break;case`start-page`:e.prefill&&(Z.data.chatInputValue=e.prefill);break;case`chat-page`:if(Z.data.chatInputValue=e.query??``,Z.data.predefinedQuestionId=e.predefinedQuestionId,Z.data.switchQuestionId=e.switchQuestionId,e.query&&(this.onSubmit(),Z.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=Z.data.chatConfig.selectorsConfig.find(t=>t.settingName===e);if(!t)throw Error(`Setting ${e} not found`);return t},getPrettifiedSelectorValues(){let e=Object.entries(Z.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}Z.data.selectorValues[e]=t,K(Z.data.selectorValues,Z.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 it(e),Z.data.selectorValues[e]=n,K(Z.data.selectorValues,Z.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){Z.data.selectedColorScheme=e,Z.data.currentColorScheme=oe(e),this.setAriaLiveStatusMessage(e===`dark`?Z.t.ariaDarkSelected:Z.t.ariaLightSelected)},async abort(){await pt?.abort()},changeConversationState(e){Z.data.currentConversationState=e,window.LIIPGPT_LISTENERS?.conversation?.(e)},onInput(e){Z.data.chatConfig.blockPII&&(Z.data.questionHasPii=H(e)),Z.data.chatInputValue=e,Z.data.predefinedQuestionId=void 0,Z.data.switchQuestionId=void 0},onSubmit(e=!1,t,n=!1){let r=$e(Z.data.chatConfig.parentPageContext?.extractSelectors);if(Z.data.questionHasPii){console.warn(`Question contains PII, not submitting:`,Z.data.questionHasPii);return}let i=Z.data.chatConfig.questionPrefix?`${Z.data.chatConfig.questionPrefix} ${Z.data.chatInputValue}`:Z.data.chatInputValue;n||(Z.data.history.push(...X(Z.data.chatConfig.messageAdditions.user.before)),Z.data.history.push({type:`user`,time:new Date().toISOString(),message:Z.data.chatInputValue}),Z.data.history.push(...X(Z.data.chatConfig.messageAdditions.user.after)));let a=Z.data.history.push(...X(Z.data.chatConfig.messageAdditions.bot.before));Z.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`],onError:e=>{this.showErrorToast(e),window.LIIPGPT_LISTENERS?.error?.(e),(e===`pii-detected`||e===`blocked`)&&this.editLatestQuestion()},onMessage:e=>{e.type===`topic-selected`&&(Z.data.selectedTopic={label:e.label,placeholder:e.placeholder,locked:ft($.additionalStartParameters)}),e.type===`state`&&e.state!==`history-entry-initialized`&&!s&&(s=!0,this.setAriaLiveStatusMessage(Z.t.ariaQuestionSent))},lang:Z.data.language,selectorValues:{...this.getPrettifiedSelectorValues(),context:tt(),...t},predefinedQuestionId:Z.data.predefinedQuestionId,switchQuestionId:Z.data.switchQuestionId,onEmbed:e=>{let t=Z.data.history[a];t&&t.type===`bot`&&!t.message.markdown?(Z.data.history[a]={...e,id:t.id??A()},o=!0):Z.data.history.push({...e,id:A()})}};Z.data.predefinedQuestionId=void 0,Z.data.switchQuestionId=void 0,r.length&&(c.selectorValues.parentPageContextHtml=r);let l=(e,t)=>{try{let n=new URL(e),r=new URL(t);return n.origin===r.origin&&n.pathname===r.pathname}catch{return!1}},u=Z.data.chatConfig.sendReferrer??`all`;if([`all`,`own`,`location`].includes(u)){let e=u===`location`||Z.data.props.flyout,t;t=e?`${window.location.protocol}//${window.location.host}${window.location.pathname}`:l(document.referrer,window.location.href)?null:document.referrer;let n=u===`own`&&!Z.data.props.flyout&&t&&!t.startsWith(window.location.origin);c.referrer=t&&!n?t:void 0}Z.data.currentConversationId||(Z.data.currentConversationId=Q.createConversationId());let d=Q.chat(Z.data.currentConversationId,i,c);pt=d,Z.data.lastChatResponseId=d.id,Z.data.currentConversationState!==`searching`&&this.changeConversationState(`searching`);let f=!1,p,m=!!Z.data.currentReferencesAsideId;(e&&m||!e&&Z.data.chatConfig.showReferencesByDefault)&&(Z.data.isAsideMobile||this.openReferencesAside(d.id)),d.subscribe(e=>{if(!o&&Z.data.history[a]&&(Z.data.history[a]={question:Z.data.chatInputValue,...e}),Z.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}`))}Z.data.chatConfig.showReferencesByDefault&&!Z.data.wasReferencesAsideClosed&&Z.data.currentReferencesAsideId!==e.id&&!Z.data.isAsideMobile&&this.openReferencesAside(e.id),e.state===`streaming`&&Z.data.currentConversationState!==`answering`&&this.changeConversationState(`answering`),e.state===`done`&&(this.changeConversationState(`idle`),f||(f=!0,this.setAriaLiveStatusMessage(`${Z.t.ariaAnswerReady} ... ${e.message.text} ... ${Z.data.selectedTopic?Z.t.ariaAnswerFinishedWithSelectedTopic:Z.t.ariaAnswerFinished}`),Z.data.history.push(...X(Z.data.chatConfig.messageAdditions.bot.after))),Z.data.currentReferencesAsideId&&e.references.used.length>0?(clearTimeout(p),p=setTimeout(()=>{this.openReferencesAside(e.id)},100)):this.closeReferencesAside())}),Z.data.chatInputValue=``},async onStartSpeechRecognition(){try{if(!await Ke()){this.showErrorToast(`speech-not-supported`);return}if(await navigator.mediaDevices.getUserMedia({audio:!0}),B.isSupported())Z.data.chatInputValue=``,Z.currentAudioRecorder=new B({onDataAvailable:async e=>{Z.isTranscribing=!0,await this.handleTranscription(e)},onError:()=>{this.showErrorToast(`speech-microphone-access-denied`),Z.currentAudioRecorder=null,Z.isTranscribing=!1},onVolumeChange:e=>{Z.currentAudioVolume=e}}),Z.currentAudioRecorder.start();else{this.showErrorToast(`speech-not-supported`);return}}catch(e){throw this.showErrorToast(`speech-microphone-access-denied`),Z.currentAudioRecorder=null,Z.isTranscribing=!1,e}},editLatestQuestion(){let e=Z.data.history.findLastIndex(e=>e?.type===`user`);if(e===-1){console.error(`No last user question, available`);return}let t=Z.data.history.splice(e)[0];Z.data.chatInputValue=t.message},onStopSpeechRecognition(){if(Z.currentAudioRecorder){let e=Z.currentAudioRecorder;Z.currentAudioRecorder=null,e.stop()}Z.currentAudioVolume=0},async handleTranscription(e){if(!e){console.warn(`No audio data received`);return}try{let t=await Q.transcribeAudio(e,{lang:Z.data.language});if(t.error){this.showErrorToast(`speech-transcription-failed`);return}if(t.transcript.trim()){if(Z.data.chatConfig.blockPII&&(Z.data.questionHasPii=H(t.transcript.trim()),Z.data.questionHasPii))return;Z.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{Z.currentAudioRecorder=null,Z.isTranscribing=!1,Z.currentAudioVolume=0}},async startFromHandoverOrRoute(e){let{cID:t,followUpQuestion:n}=lt();if(!t){e();return}let r=await this.rehydrateFromSearchSummaryHandover(t);n?(Z.data.route={name:`chat-page`},Z.data.chatInputValue=n,this.onSubmit(!0)):r||e(),ut()},async rehydrateFromSearchSummaryHandover(e){Z.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 Z.data.currentConversationId=void 0,!1;let i={all:[],used:[],unused:[]},a=new de({newTabSrText:Z.t.ariaOpensInNewTab}),o=[];for(let{question:e,answer:t}of r)o.push({type:`user`,time:new Date().toISOString(),message:e,id:A()}),o.push({id:A(),state:`done`,errors:[],type:`bot`,time:new Date().toISOString(),message:{markdown:t,html:a.toHTML(t,i),text:t},references:{all:[],used:[],unused:[]}});return Z.data.history=[...X(Z.data.chatConfig.messageAdditions.init),...o],Z.data.route={name:`chat-page`},!0},async onStartConversation(e,t,n){await this.abort(),Z.data.history=X(Z.data.chatConfig.messageAdditions.init),Z.data.currentConversationId=Q.createConversationId(),this.goto({name:`chat-page`,query:e,predefinedQuestionId:t,switchQuestionId:n})},async onNewConversation(){await this.abort();let e=Z.data.currentConversationId;if(Z.data.currentConversationId=void 0,Z.data.currentReferencesAsideId=void 0,Z.data.history=X(Z.data.chatConfig.messageAdditions.init),Z.data.predefinedQuestionId=void 0,Z.data.switchQuestionId=void 0,Z.data.selectedTopic=void 0,Z.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:Z.data.language}).catch(e=>{console.error(`Failed to notify backend of new discussion:`,e)})},async onChangeTopic(){let e=Z.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(),Z.data.selectedTopic=void 0,Z.data.predefinedQuestionId=e,Z.data.switchQuestionId=void 0,Z.data.chatInputValue=``,this.onSubmit(!0,void 0,!0)},showSuccessToast(e){R.success(Z.t[e],{unstyled:!0,duration:3e3,classes:{toast:`toast`}})},showErrorToast(e){R.error(Z.errorTranslations[e],{unstyled:!0,duration:3e3,classes:{toast:`toast`}})},async submitFeedback(e){try{let t=Z.data.conversationFeedbackId||Z.data.lastChatResponseId;if(!t)throw new q(`Tried to give feedback with no id.`);let n=Z.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){Z.data.currentReferencesAsideId===e?this.closeReferencesAside():this.openReferencesAside(e)},openReferencesAside(e){Z.data.currentReferencesAsideId=e,this.setOpenOverlay(!0)},closeReferencesAside(){Z.data.currentReferencesAsideId=void 0,Z.data.wasReferencesAsideClosed=!0,this.setOpenOverlay(!1)},setAsideMobile(e){Z.data.isAsideMobile=e},openFlyout(){Z.data.flyoutIsOpen=!0},closeFlyout(){Z.data.flyoutIsOpen=!1},openConversationFeedback(){Z.data.conversationFeedbackIsOpen=!0,this.setOpenOverlay(!0)},openMessageFeedback(e){Z.data.conversationFeedbackId=e},closeFeedback(){Z.data.conversationFeedbackIsOpen=!1,Z.data.conversationFeedbackId=void 0,this.setOpenOverlay(!1)},openAnswerForm(e){Z.data.answerFormMessageId=e,this.setOpenOverlay(!0)},closeAnswerForm(){Z.data.answerFormMessageId=void 0,this.setOpenOverlay(!1)},async submitAnswerForm(e){try{let t=Z.data.chatConfig.answerForm,n=Z.data.answerFormMessageId;if(!t)throw new q(`Tried to submit the answer form with no answerForm config.`);if(!n)throw new q(`Tried to submit the answer form with no message id.`);let r=Z.data.history.findIndex(e=>e.type===`bot`&&e.id===n),i=r===-1?void 0:Z.data.history[r],a=Z.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:Z.data.language}),setTimeout(()=>{this.showSuccessToast(`answerFormThankYou`)},500)}catch(e){console.error(`Answer form submission failed:`,e),this.showErrorToast(`answer-form-failed`)}},setOpenOverlay(e){Z.data.hasOpenedOverlays=e},setAriaLiveStatusMessage(e){Z.data.ariaLiveStatusMessage=e,clearTimeout(Z.data.ariaLiveStatusMessageClearingTimeout),Z.data.ariaLiveStatusMessageClearingTimeout=setTimeout(()=>{Z.data.ariaLiveStatusMessage=``},Z.ariaLiveMessagesClearingTimeoutDuration)},closePopup(){window.location.hash=``},checkForOpenedPopup(){let e=window.location.hash.slice(1),t=Z.t.popups?.find(t=>t.hash===e);t?Z.data.openedPopup=t:Z.data.openedPopup=void 0},async thumbs(e,t){try{let n=Z.data.history.find(t=>t.type===`bot`&&t.id===e);t===`up`?await Q.thumbsUp(e,n?.question??``):await Q.thumbsDown(e,n?.question??``),this.showSuccessToast(`thankYouForFeedback`)}catch(e){console.error(`Feedback failed:`,e),this.showErrorToast(`feedback-failed`)}},async onLanguageChange(e){if(Z.data.language=me(e,Z.data.chatConfig.supportedLanguages),pe(Z.data.language,Z.targets.mainElement),Z.data.predefinedQuestions=await this.getPredefinedQuestions(Z.data.language),this.setAriaLiveStatusMessage(Z.t.ariaLanguageChanged),Z.data.chatConfig.reflectLanguageInPath){let e=new URL(window.location.href);e.pathname=`/${Z.data.language}`,window.history.replaceState({},``,e.toString())}},async acceptTerms(){Z.data.termsAccepted=!0;try{k.setItem(`liipgpt:termsAccepted`,`true`)}catch(e){console.warn(`Failed to save terms acceptance to storage:`,e)}this.closePopup(),await h(),this.goto(J(Z.data.chatConfig.forceConsent??!1,!0,Z.data.chatConfig.forceChatPage??!1,st(Z.data.props.autofirePredefinedQuestionId,Z.data.predefinedQuestions),Z.data.props.question))},updateChatInput(e){Z.data.chatInputValue=e}});function ht(e,t){f(t,!0);let n=w(t,`href`,7),r=w(t,`target`,7),i=w(t,`onclick`,7),a=w(t,`className`,23,()=>[]),o=w(t,`isStandalone`,7,!1),p=w(t,`children`,7),h=w(t,`type`,7,`button`),g=w(t,`use`,7),v=w(t,`class`,7),y=re(t,[`$$slots`,`$$events`,`$$legacy`,`$$host`,`href`,`target`,`onclick`,`className`,`isStandalone`,`children`,`type`,`use`,`class`]),b=S(()=>n()?`a`:`button`),x=S(()=>[...Array.isArray(a())?a():a()?[a()]:[],...v()?[v()]:[]]),ee=()=>({}),C=S(()=>g()??ee);var D={get href(){return n()},set href(e){n(e),d()},get target(){return r()},set target(e){r(e),d()},get onclick(){return i()},set onclick(e){i(e),d()},get className(){return a()},set className(e=[]){a(e),d()},get isStandalone(){return o()},set isStandalone(e=!1){o(e),d()},get children(){return p()},set children(e){p(e),d()},get type(){return h()},set type(e=`button`){h(e),d()},get use(){return g()},set use(e){g(e),d()},get class(){return v()},set class(e){v(e),d()}},O=m();return u(E(O),()=>T(b),!1,(e,t)=>{te(e,e=>T(C)?.(e)),_(e,()=>({...y,onclick:n()?void 0:i(),type:n()?void 0:h(),href:n(),role:n()?`link`:`button`,target:n()?r():void 0,class:T(x),[ne]:{"open-button--standalone":o()}}));var a=m();c(E(a),p),s(t,a)}),s(e,O),l(D)}b(ht,{href:{},target:{},onclick:{},className:{},isStandalone:{},children:{},type:{},use:{},class:{}},[],[],{mode:`open`});export{B as a,R as c,be as d,A as f,et as i,L as l,Z as n,Ye as o,mt as r,Le as s,ht as t,Ne as u};
|