diff --git a/404.html b/404.html index 471948320..8ffd0ca58 100644 --- a/404.html +++ b/404.html @@ -13,7 +13,7 @@ - + diff --git a/assets/js/6715.072f205a.js b/assets/js/6715.bf7b0686.js similarity index 62% rename from assets/js/6715.072f205a.js rename to assets/js/6715.bf7b0686.js index d76b75c73..4d98d4c1f 100644 --- a/assets/js/6715.072f205a.js +++ b/assets/js/6715.bf7b0686.js @@ -1,2 +1,2 @@ -/*! For license information please see 6715.072f205a.js.LICENSE.txt */ -"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[6715],{78478:(e,t,n)=>{n.d(t,{A:()=>s});n(96540);var r=n(92303),i=n(74848);function s(e){let{children:t,fallback:n}=e;return(0,r.A)()?(0,i.jsx)(i.Fragment,{children:t?.()}):n??null}},37615:(e,t,n)=>{n.d(t,{a:()=>a});const r=new Set(["children","localName","ref","style","className"]),i=new WeakMap,s=(e,t,n,r,s)=>{const a=s?.[t];void 0===a?(e[t]=n,null==n&&t in HTMLElement.prototype&&e.removeAttribute(t)):n!==r&&((e,t,n)=>{let r=i.get(e);void 0===r&&i.set(e,r=new Map);let s=r.get(t);void 0!==n?void 0===s?(r.set(t,s={handleEvent:n}),e.addEventListener(t,s)):s.handleEvent=n:void 0!==s&&(r.delete(t),e.removeEventListener(t,s))})(e,a,n)},a=({react:e,tagName:t,elementClass:n,events:i,displayName:a})=>{const o=new Set(Object.keys(i??{})),l=e.forwardRef(((a,l)=>{const c=e.useRef(new Map),u=e.useRef(null),d={},h={};for(const[e,t]of Object.entries(a))r.has(e)?d["className"===e?"class":e]=t:o.has(e)||e in n.prototype?h[e]=t:d[e]=t;return e.useLayoutEffect((()=>{if(null===u.current)return;const e=new Map;for(const t in h)s(u.current,t,a[t],c.current.get(t),i),c.current.delete(t),e.set(t,a[t]);for(const[t,n]of c.current)s(u.current,t,void 0,n,i);c.current=e})),e.useLayoutEffect((()=>{u.current?.removeAttribute("defer-hydration")}),[]),d.suppressHydrationWarning=!0,e.createElement(t,{...d,ref:e.useCallback((e=>{u.current=e,"function"==typeof l?l(e):null!==l&&(l.current=e)}),[l])})}));return l.displayName=a??n.name,l}},78152:(e,t,n)=>{function r(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=v(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,i=function(){};return{s:i,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){o=!0,s=e},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}function i(e){var t="function"==typeof Map?new Map:void 0;return i=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return function(e,t,n){if(o())return Reflect.construct.apply(null,arguments);var r=[null];r.push.apply(r,t);var i=new(e.bind.apply(e,r));return n&&u(i,n.prototype),i}(e,arguments,l(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,e)},i(e)}function s(e,t,n){return t=l(t),function(e,t){if(t&&("object"==_(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return a(e)}(e,o()?Reflect.construct(t,n||[],l(e).constructor):t.apply(e,n))}function a(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function o(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(o=function(){return!!e})()}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,s,a,o=[],l=!0,c=!1;try{if(s=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=s.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){c=!0,i=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return o}}(e,t)||v(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(){h=function(){return t};var e,t={},n=Object.prototype,r=n.hasOwnProperty,i=Object.defineProperty||function(e,t,n){e[t]=n.value},s="function"==typeof Symbol?Symbol:{},a=s.iterator||"@@iterator",o=s.asyncIterator||"@@asyncIterator",l=s.toStringTag||"@@toStringTag";function c(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,n){return e[t]=n}}function u(e,t,n,r){var s=t&&t.prototype instanceof y?t:y,a=Object.create(s.prototype),o=new R(r||[]);return i(a,"_invoke",{value:A(e,n,o)}),a}function d(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}t.wrap=u;var p="suspendedStart",f="suspendedYield",m="executing",v="completed",g={};function y(){}function b(){}function k(){}var x={};c(x,a,(function(){return this}));var S=Object.getPrototypeOf,E=S&&S(S(O([])));E&&E!==n&&r.call(E,a)&&(x=E);var w=k.prototype=y.prototype=Object.create(x);function C(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function T(e,t){function n(i,s,a,o){var l=d(e[i],e,s);if("throw"!==l.type){var c=l.arg,u=c.value;return u&&"object"==_(u)&&r.call(u,"__await")?t.resolve(u.__await).then((function(e){n("next",e,a,o)}),(function(e){n("throw",e,a,o)})):t.resolve(u).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,o)}))}o(l.arg)}var s;i(this,"_invoke",{value:function(e,r){function i(){return new t((function(t,i){n(e,r,t,i)}))}return s=s?s.then(i,i):i()}})}function A(t,n,r){var i=p;return function(s,a){if(i===m)throw Error("Generator is already running");if(i===v){if("throw"===s)throw a;return{value:e,done:!0}}for(r.method=s,r.arg=a;;){var o=r.delegate;if(o){var l=M(o,r);if(l){if(l===g)continue;return l}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(i===p)throw i=v,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);i=m;var c=d(t,n,r);if("normal"===c.type){if(i=r.done?v:f,c.arg===g)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(i=v,r.method="throw",r.arg=c.arg)}}}function M(t,n){var r=n.method,i=t.iterator[r];if(i===e)return n.delegate=null,"throw"===r&&t.iterator.return&&(n.method="return",n.arg=e,M(t,n),"throw"===n.method)||"return"!==r&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var s=d(i,t.iterator,n.arg);if("throw"===s.type)return n.method="throw",n.arg=s.arg,n.delegate=null,g;var a=s.arg;return a?a.done?(n[t.resultName]=a.value,n.next=t.nextLoc,"return"!==n.method&&(n.method="next",n.arg=e),n.delegate=null,g):a:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,g)}function I(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function L(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function R(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(I,this),this.reset(!0)}function O(t){if(t||""===t){var n=t[a];if(n)return n.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function n(){for(;++i=0;--s){var a=this.tryEntries[s],o=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var l=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(l&&c){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),L(n),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;L(n)}return i}}throw Error("illegal catch attempt")},delegateYield:function(t,n,r){return this.delegate={iterator:O(t),resultName:n,nextLoc:r},"next"===this.method&&(this.arg=e),g}},t}function p(e,t,n,r,i,s,a){try{var o=e[s](a),l=o.value}catch(e){return void n(e)}o.done?t(l):Promise.resolve(l).then(r,i)}function f(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var s=e.apply(t,n);function a(e){p(s,r,i,a,o,"next",e)}function o(e){p(s,r,i,a,o,"throw",e)}a(void 0)}))}}function m(e){return function(e){if(Array.isArray(e))return g(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||v(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(e,t){if(e){if("string"==typeof e)return g(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?g(e,t):void 0}}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);nsa});var C=function(){return E((function e(){x(this,e)}),null,[{key:"render",value:function(e,t){var n=document.createElement("div");n.id="error-view",n.innerText=t,e.replaceChildren(n)}}])}(),T=function(){function e(){x(this,e)}return E(e,null,[{key:"onLoad",value:function(e){e.innerHTML='
'}},{key:"createElements",value:function(){var e=document.createElement("div");return e.id="validate-property-key-view",e}},{key:"render",value:function(t,n,r){var i=e.createElements(),s={onSuccess:n,onFail:C.render.bind(this,t,"Your 'key' has failed authentication"),onLoad:e.onLoad.bind(this,i)};r.key&&r.verifyKey(r.key,s),t.replaceChildren(i)}}])}(),A=function(){function e(){x(this,e)}return E(e,null,[{key:"unsetStyle",value:function(e,t){var n=Object.keys(t).reduce((function(e,t){return e[t]="",e}),{});Object.assign(e.style,n)}},{key:"unsetActivityCSSMouseStates",value:function(t,n){n.click&&e.unsetStyle(t,n.click),n.hover&&e.unsetStyle(t,n.hover)}},{key:"unsetAllCSSMouseStates",value:function(t,n){e.unsetActivityCSSMouseStates(t,n),n.default&&e.unsetStyle(t,n.default)}},{key:"processStateful",value:function(e,t,n){var r=e.default||{},i=Object.assign(JSON.parse(JSON.stringify(b(b({},r),t))),null==e?void 0:e.hover);return{default:r,hover:i,click:Object.assign(JSON.parse(JSON.stringify(b(b({},i),n))),null==e?void 0:e.click)}}},{key:"mergeStatefulStyles",value:function(e){var t={default:{},hover:{},click:{}};return e.forEach((function(e){t.default=Object.assign(t.default,e.default),t.hover=Object.assign(t.hover,e.hover),t.click=Object.assign(t.click,e.click)})),t}},{key:"overwriteDefaultWithAlreadyApplied",value:function(e,t){Object.keys(e.default||[]).forEach((function(n){var r,i=n;t.style[i]&&null!=(r=e.default)&&r[i]&&(e.default[n]=t.style[i])}))}},{key:"applyToStyleIfNotDefined",value:function(e,t){for(var n in t){var r=t[n];""===e[n]&&r&&(e[n]=r)}}}])}(),M=function(){function e(){x(this,e)}return E(e,null,[{key:"attemptAppendStyleSheetToHead",value:function(t){if(!t.fontFamily||t.fontFamily===e.DEFAULT_FONT_FAMILY){var n=document.getElementsByTagName("head")[0];if(!Array.from(n.getElementsByTagName("link")).some((function(t){return t.getAttribute("href")===e.FONT_URL}))){var r=document.createElement("link");r.rel="stylesheet",r.href=e.FONT_URL,n.appendChild(r)}}}}])}();M.FONT_URL="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap",M.DEFAULT_FONT_FAMILY="'Inter', sans-serif, Avenir, Helvetica, Arial";var I=M,L=function(){function e(){x(this,e)}return E(e,null,[{key:"apply",value:function(t,n){if(n)try{e.applyStyleSheet(t,n)}catch(r){e.addStyleElement(t,n)}}},{key:"applyStyleSheet",value:function(e,t){var n=new CSSStyleSheet;n.replaceSync(e),t.adoptedStyleSheets.push(n)}},{key:"addStyleElement",value:function(e,t){var n=document.createElement("style");n.innerHTML=e,t.appendChild(n)}},{key:"applyDefaultStyleToComponent",value:function(t,n){n&&A.applyToStyleIfNotDefined(t,n),A.applyToStyleIfNotDefined(t,e.DEFAULT_COMPONENT_STYLE)}}])}();L.DEFAULT_COMPONENT_STYLE={height:"350px",width:"320px",borderTop:"1px solid #cacaca",borderRight:"1px solid #cacaca",borderLeft:"1px solid #cacaca",borderBottom:"1px solid #cacaca",fontFamily:I.DEFAULT_FONT_FAMILY,fontSize:"0.9rem",backgroundColor:"white",position:"relative",overflow:"hidden"};var R,O=L,P=((R=E((function e(){x(this,e)}))).IS_SAFARI=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),R.IS_CHROMIUM=window.chrome,R),N=function(e){return e.ESCAPE="Escape",e.ENTER="Enter",e.TAB="Tab",e.ARROW_UP="ArrowUp",e.ARROW_DOWN="ArrowDown",e.ARROW_RIGHT="ArrowRight",e.ARROW_LEFT="ArrowLeft",e.BACKSPACE="Backspace",e.DELETE="Delete",e.META="Meta",e.CONTROL="Control",e}(N||{}),B=function(){function e(){x(this,e)}return E(e,null,[{key:"add",value:function(t,n,r,i){void 0!==r&&t.addEventListener("keydown",e.onKeyDown.bind(this,r)),t.oninput=e.onInput.bind(this,r,i),t.addEventListener("paste",(function(e){var t;e.preventDefault(),null!=(t=e.clipboardData)&&t.files.length&&n.addFilesToAnyType(Array.from(e.clipboardData.files))}))}},{key:"onKeyDown",value:function(t,n){var r=n.target.textContent;r&&r.length>=t&&!e.PERMITTED_KEYS.has(n.key)&&!e.isKeyCombinationPermitted(n)&&n.preventDefault()}},{key:"isKeyCombinationPermitted",value:function(e){return"a"===e.key&&(e.ctrlKey||e.metaKey)}},{key:"onInput",value:function(e,t,n){var r=n.target,i=r.textContent||"";void 0!==e&&i.length>e&&(r.textContent=i.substring(0,e),H.focusEndOfInput(r)),null==t||t()}}])}();B.PERMITTED_KEYS=new Set([N.BACKSPACE,N.DELETE,N.ARROW_RIGHT,N.ARROW_LEFT,N.ARROW_DOWN,N.ARROW_UP,N.META,N.CONTROL,N.ENTER]);var D=B,F=function(){return E((function e(){x(this,e)}),null,[{key:"sanitizePastedTextContent",value:function(e){var t,n;e.preventDefault();var r=null==(t=e.clipboardData)?void 0:t.getData("text/plain");r&&(null==(n=document.execCommand)||n.call(document,"insertText",!1,r))}}])}(),j=function(){function e(t,n,r){var i,s,a=this;x(this,e);var o=e.processConfig(n,t.textInput);this.elementRef=e.createContainerElement(null==(i=null==o?void 0:o.styles)?void 0:i.container),this._config=o,this.inputElementRef=this.createInputElement(),this.elementRef.appendChild(this.inputElementRef),t.setPlaceholderText=this.setPlaceholderText.bind(this),t.setPlaceholderText((null==(s=this._config.placeholder)?void 0:s.text)||"Ask me anything!"),setTimeout((function(){D.add(a.inputElementRef,r,a._config.characterLimit,t._validationHandler)}))}return E(e,[{key:"clear",value:function(){var e,t=window.scrollY;this.inputElementRef.classList.contains("text-input-disabled")||(Object.assign(this.inputElementRef.style,null==(e=this._config.placeholder)?void 0:e.style),this.inputElementRef.textContent="",H.focusEndOfInput(this.inputElementRef)),P.IS_CHROMIUM&&window.scrollTo({top:t})}},{key:"createInputElement",value:function(){var t,n,r,i,s=document.createElement("div");return s.id=e.TEXT_INPUT_ID,s.classList.add("text-input-styling"),P.IS_CHROMIUM&&e.preventAutomaticScrollUpOnNewLine(s),"boolean"==typeof this._config.disabled&&!0===this._config.disabled?(s.contentEditable="false",s.classList.add("text-input-disabled")):(s.contentEditable="true",this.addEventListeners(s)),Object.assign(s.style,null==(t=this._config.styles)?void 0:t.text),Object.assign(s.style,null==(n=this._config.placeholder)?void 0:n.style),null!=(i=null==(r=this._config.placeholder)?void 0:r.style)&&i.color||s.setAttribute("textcolor",""),s}},{key:"removePlaceholderStyle",value:function(){var e,t,n,r;!this.inputElementRef.classList.contains("text-input-disabled")&&null!=(e=this._config.placeholder)&&e.style&&(A.unsetStyle(this.inputElementRef,null==(t=this._config.placeholder)?void 0:t.style),Object.assign(this.inputElementRef.style,null==(r=null==(n=this._config)?void 0:n.styles)?void 0:r.text))}},{key:"addEventListeners",value:function(e){var t,n,r=this;null!=(t=this._config.styles)&&t.focus&&(e.onfocus=function(){var e;return Object.assign(r.elementRef.style,null==(e=r._config.styles)?void 0:e.focus)},e.onblur=this.onBlur.bind(this,this._config.styles.focus,null==(n=this._config.styles)?void 0:n.container)),e.addEventListener("keydown",this.onKeydown.bind(this)),e.addEventListener("input",this.onInput.bind(this)),e.addEventListener("paste",F.sanitizePastedTextContent)}},{key:"onBlur",value:function(e,t){A.unsetStyle(this.elementRef,e),t&&Object.assign(this.elementRef.style,t)}},{key:"onKeydown",value:function(e){var t;e.key===N.ENTER&&!e.ctrlKey&&!e.shiftKey&&(e.preventDefault(),null==(t=this.submit)||t.call(this))}},{key:"onInput",value:function(){var e;this.isTextInputEmpty()?Object.assign(this.inputElementRef.style,null==(e=this._config.placeholder)?void 0:e.style):this.removePlaceholderStyle()}},{key:"setPlaceholderText",value:function(e){this.inputElementRef.setAttribute("deep-chat-placeholder-text",e)}},{key:"isTextInputEmpty",value:function(){return""===this.inputElementRef.textContent}}],[{key:"processConfig",value:function(e,t){var n,r,i,s,a;return null!==(n=t)&&void 0!==n||(t={}),null!==(r=t.disabled)&&void 0!==r||(t.disabled=e.isTextInputDisabled),null!==(i=t.placeholder)&&void 0!==i||(t.placeholder={}),null!==(s=(a=t.placeholder).text)&&void 0!==s||(a.text=e.textInputPlaceholderText),t}},{key:"createContainerElement",value:function(e){var t=document.createElement("div");return t.id="text-input-container",Object.assign(t.style,e),t}},{key:"preventAutomaticScrollUpOnNewLine",value:function(e){var t;e.addEventListener("keydown",(function(){t=window.scrollY})),e.addEventListener("input",(function(){t!==window.scrollY&&window.scrollTo({top:t})}))}}])}();j.TEXT_INPUT_ID="text-input";var U=j,H=function(){function e(){x(this,e)}return E(e,null,[{key:"focusEndOfInput",value:function(e){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();null==n||n.removeAllRanges(),null==n||n.addRange(t)}},{key:"focusFromParentElement",value:function(t){var n=t.querySelector("#".concat(U.TEXT_INPUT_ID));n&&(P.IS_SAFARI&&n.focus(),e.focusEndOfInput(n))}}])}();function q(e){return e.charAt(0).toUpperCase()+e.slice(1)}function z(e,t,n,r){var i="\n".concat(q(t)," message: ").concat(JSON.stringify(e)," \n"),s=n?"".concat(q(t)," message after interceptor: ").concat(function(e){return e&&JSON.stringify(e)}(r)," \n"):"";return i+s}var V="Make sure the events are using {text: string} or {html: string} format.\nYou can also augment them using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor",G={INVALID_KEY:"Invalid API Key",CONNECTION_FAILED:"Failed to connect",INVALID_RESPONSE:function(e,t,n,r){return"".concat(z(e,t,n,r),"Make sure the ").concat(t," message is using the Response format: https://deepchat.dev/docs/connect/#Response \nYou can also augment it using the responseInterceptor property: https://deepchat.dev/docs/interceptors#responseInterceptor")},INVALID_MODEL_REQUEST:function(e,t){var n="request";return"".concat(z(e,n,t),"Make sure the ").concat(n,' message is using the {body: {text: string}} format, e.g: {body: {text: "Model Response"}}')},INVALID_MODEL_RESPONSE:function(e,t,n){var r="response";return"".concat(z(e,r,t,n),"Make sure the ").concat(r,' message is using the {text: string} format, e.g: {text: "Model Response"}')},INVALID_STREAM_EVENT:V,INVALID_STREAM_EVENT_MIX:"Cannot mix {text: string} and {html: string} responses.",NO_VALID_STREAM_EVENTS_SENT:"No valid stream events were sent.\n".concat(V)},W=function(){function e(){x(this,e)}return E(e,null,[{key:"addElements",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r=n-r-e.CODE_SNIPPET_GENERATION_JUMP}},{key:"cloneElement",value:function(e){var t=e.cloneNode(!0);return e.parentNode.replaceChild(t,e),t}},{key:"scrollToBottom",value:function(e){e.scrollTop=e.scrollHeight}},{key:"scrollToTop",value:function(e){e.scrollTop=0}}])}();W.CODE_SNIPPET_GENERATION_JUMP=.5;var K=W,J=function(){function e(){x(this,e)}return E(e,null,[{key:"speak",value:function(e,t){if(window.SpeechSynthesisUtterance){var n=new SpeechSynthesisUtterance(e);Object.assign(n,t),speechSynthesis.speak(n)}}},{key:"processConfig",value:function(t,n){var r={};setTimeout((function(){if("object"==_(t)&&(t.lang&&(r.lang=t.lang),t.pitch&&(r.pitch=t.pitch),t.rate&&(r.rate=t.rate),t.volume&&(r.volume=t.volume),t.voiceName)){var e=window.speechSynthesis.getVoices().find((function(e){var n;return e.name.toLocaleLowerCase()===(null==(n=t.voiceName)?void 0:n.toLocaleLowerCase())}));e&&(r.voice=e)}n(r)}),e.LOAD_VOICES_MS)}}])}();J.LOAD_VOICES_MS=200;var Y=J,Z=function(){function e(){x(this,e)}return E(e,null,[{key:"colorToHex",value:function(e){var t=document.createElement("div");return t.style.color=e,document.body.appendChild(t),"#".concat(window.getComputedStyle(t).color.match(/\d+/g).map((function(e){return parseInt(e).toString(16).padStart(2,"0")})).join(""))}},{key:"setDots",value:function(t,n){var r,i,s,a;if(null!=(a=null==(s=null==(i=null==(r=null==n?void 0:n.loading)?void 0:r.message)?void 0:i.styles)?void 0:s.bubble)&&a.color){var o=e.colorToHex(n.loading.message.styles.bubble.color);t.style.setProperty("--loading-message-color",o),t.style.setProperty("--loading-message-color-fade","".concat(o,"33"))}else t.style.setProperty("--loading-message-color","#848484"),t.style.setProperty("--loading-message-color-fade","#55555533")}},{key:"setRing",value:function(t,n){var r=n||{},i=r.color,s=r.width,a=r.height,o=r.margin,l=r.border;if(i){var c=e.colorToHex(i);t.style.setProperty("--loading-history-color",c)}else t.style.setProperty("--loading-history-color","#dbdbdb");t.style.setProperty("--loading-history-height",a||"57px"),t.style.setProperty("--loading-history-width",s||"57px"),t.style.setProperty("--loading-history-margin",o||"7px"),t.style.setProperty("--loading-history-border",l||"6px solid")}}])}();Z.BUBBLE_CLASS="deep-chat-loading-message-bubble",Z.DOTS_CONTAINER_CLASS="deep-chat-loading-message-dots-container";var X=Z,Q=function(){function e(){x(this,e)}return E(e,null,[{key:"setElementProps",value:function(t,n,r,i){var s;"loading"!==r&&(t.applyCustomStyles(n,i,!0,null==(s=t.messageStyles)?void 0:s[r]),n.bubbleElement.classList.add(e.FILE_BUBBLE_CLASS))}},{key:"addMessage",value:function(t,n,r,i,s){e.setElementProps(t,n,r,i),s||(t.elementRef.appendChild(n.outerContainer),t.elementRef.scrollTop=t.elementRef.scrollHeight)}},{key:"wrapInLink",value:function(t,n,r){var i=document.createElement("a");return i.href=n,i.download=r||e.DEFAULT_FILE_NAME,i.target="_blank",i.appendChild(t),i}},{key:"isNonLinkableDataUrl",value:function(e,t){return!(!t.startsWith("data")||"image"===e)&&("any"===e&&t.startsWith("data:text/javascript")||!t.startsWith("data:image")&&!t.startsWith("data:application"))}},{key:"processContent",value:function(t,n,r,i){return!r||e.isNonLinkableDataUrl(t,r)?n:e.wrapInLink(n,r,i)}},{key:"waitToLoadThenScroll",value:function(e){setTimeout((function(){e.scrollTop=e.scrollHeight}),60)}},{key:"scrollDownOnImageLoad",value:function(t,n){if(t.startsWith("data"))e.waitToLoadThenScroll(n);else try{fetch(t,{mode:"no-cors"}).catch((function(){})).finally((function(){e.waitToLoadThenScroll(n)}))}catch(r){n.scrollTop=n.scrollHeight}}},{key:"reAddFileRefToObject",value:function(e,t){var n;null==(n=e.files)||n.forEach((function(e,n){var r;e.ref&&null!=(r=t.message.files)&&r[n]&&(t.message.files[n].ref=e.ref)}))}},{key:"removeFileRef",value:function(e){var t=b({},e);return delete t.ref,t}},{key:"isAudioFile",value:function(e){var t=e.type,n=e.src;return"audio"===t||(null==n?void 0:n.startsWith("data:audio"))||n&&/\.(mp3|ogg|wav|aac|webm|4a)$/i.test(n)}},{key:"isImageFile",value:function(t){var n=t.type,r=t.src;return"image"===n||(null==r?void 0:r.startsWith("data:image"))||r&&e.isImageFileExtension(r)}},{key:"isImageFileExtension",value:function(e){return/\.(jpg|jpeg|png|gif|bmp)$/i.test(e)}}])}();Q.DEFAULT_FILE_NAME="file",Q.FILE_BUBBLE_CLASS="file-message";var $=Q,ee=function(){return E((function e(){x(this,e)}),null,[{key:"checkForContainerStyles",value:function(e,t){var n=e.containerStyle;n&&(Object.assign(t.style,n),console.error("The containerStyle property is deprecated since version 1.3.14."),console.error("Please change to using the style property instead: https://deepchat.dev/docs/styles#style"))}},{key:"handleResponseProperty",value:function(e){return console.error("The {result: ....} response object type is deprecated since version 1.3.0."),console.error("Please change to using the new response object: https://deepchat.dev/docs/connect#Response"),e.result}},{key:"processHistory",value:function(e){var t=e.initialMessages;if(t)return console.error("The initialMessages property is deprecated since version 2.0.0."),console.error("Please change to using the history property instead: https://deepchat.dev/docs/messages/#history"),t}},{key:"processHistoryFile",value:function(e){var t=e.file;t&&(console.error("The file property in MessageContent is deprecated since version 1.3.17."),console.error("Please change to using the files array property: https://deepchat.dev/docs/messages/#MessageContent"),e.files=[t])}},{key:"processValidateInput",value:function(e){var t=e.validateMessageBeforeSending;if(t)return console.error("The validateMessageBeforeSending property is deprecated since version 1.3.24."),console.error("Please change to using validateInput: https://deepchat.dev/docs/interceptors#validateInput"),t}},{key:"processSubmitUserMessage",value:function(e){return console.error("The submitUserMessage(text: string) argument string type is deprecated since version 1.4.4."),console.error("Please change to using the new argument type: https://deepchat.dev/docs/methods#submitUserMessage"),{text:e}}},{key:"flagHTMLUpdateClass",value:function(e){var t;null!=(t=e.children[0])&&t.classList.contains("deep-chat-update-message")&&(console.error('The "deep-chat-update-message" html class is deprecated since version 1.4.4.'),console.error("Please change to using {..., overwrite: true} object: https://deepchat.dev/docs/connect#Response"))}},{key:"processConnect",value:function(e){var t=e;t.request&&(t.connect?Object.assign(t.connect,t.request):t.connect=t.request,console.error("The request property is deprecated since version 2.0.0."),console.error("Please see the connect object: https://deepchat.dev/docs/connect#connect-1"))}},{key:"checkForStream",value:function(e){var t=e.stream;if(t)return console.error("The stream property has been moved to the connect object in version 2.0.0."),console.error("Please see the connect object: https://deepchat.dev/docs/connect#connect-1"),t}},{key:"fireOnNewMessage",value:function(e,t){var n,r=e;r.onNewMessage&&(console.error("The onNewMessage event has been deprecated since version 2.0.0."),console.error("Please see the onMessage event: https://deepchat.dev/docs/events#onMessage"),null==(n=r.onNewMessage)||n.call(r,t)),e.dispatchEvent(new CustomEvent("new-message",{detail:t}))}},{key:"processFileConfigConnect",value:function(e){var t=e;t.request&&(console.error("The request property in file configuration is deprecated since version 2.0.0."),console.error("Please use the connect property instead: https://deepchat.dev/docs/files"),t.connect||(t.connect=t.request))}},{key:"processMessageStyles",value:function(e){if(e){var t=structuredClone(e),n=t.loading;return n&&(n.outerContainer||n.innerContainer||n.bubble||n.media)&&(console.error("The loading message styles are defined using LoadingMessageStyles interface since version 2.1.0."),console.error("Check it out here: https://deepchat.dev/docs/messages/styles#LoadingMessageStyles"),t.loading={message:{styles:n}}),t}}},{key:"processDemo",value:function(e){return"boolean"==typeof e||e.displayLoadingBubble&&(console.error("The demo displayLoadingBubble property is deprecated since version 2.1.0."),console.error("Please use displayLoading instead: https://deepchat.dev/docs/demo#demo"),e.displayLoading={message:!0}),e}}])}(),te=function(){function e(){x(this,e)}return E(e,null,[{key:"mouseUp",value:function(e,t){A.unsetAllCSSMouseStates(e,t),Object.assign(e.style,t.default),Object.assign(e.style,t.hover)}},{key:"mouseDown",value:function(e,t){Object.assign(e.style,t.click)}},{key:"mouseLeave",value:function(e,t){A.unsetAllCSSMouseStates(e,t),Object.assign(e.style,t.default)}},{key:"mouseEnter",value:function(e,t){Object.assign(e.style,t.hover)}},{key:"add",value:function(t,n){t.addEventListener("mouseenter",e.mouseEnter.bind(this,t,n)),t.addEventListener("mouseleave",e.mouseLeave.bind(this,t,n)),t.addEventListener("mousedown",e.mouseDown.bind(this,t,n)),t.addEventListener("mouseup",e.mouseUp.bind(this,t,n))}}])}(),ne={"deep-chat-button":{styles:{default:{backgroundColor:"white",padding:"5px",paddingLeft:"7px",paddingRight:"7px",border:"1px solid #c2c2c2",borderRadius:"6px",cursor:"pointer"},hover:{backgroundColor:"#fafafa"},click:{backgroundColor:"#f1f1f1"}}}},re=Object.keys(ne),ie=function(){function e(){x(this,e)}return E(e,null,[{key:"applySuggestionEvent",value:function(e,t){setTimeout((function(){t.addEventListener("click",(function(){var n,r;null==(r=e.submitUserMessage)||r.call(e,{text:(null==(n=t.textContent)?void 0:n.trim())||""})}))}))}},{key:"isElementTemporary",value:function(e){var t;return!!e&&(null==(t=e.bubbleElement.children[0])?void 0:t.classList.contains("deep-chat-temporary-message"))}},{key:"doesElementContainDeepChatClass",value:function(e){return re.find((function(t){return e.classList.contains(t)}))}},{key:"applyEvents",value:function(e,t){var n=ne[t].events;Object.keys(n||[]).forEach((function(t){e.addEventListener(t,null==n?void 0:n[t])}))}},{key:"getProcessedStyles",value:function(e,t,n){var r=Array.from(t.classList).reduce((function(t,n){var r,i=null==(r=e[n])?void 0:r.styles;return i&&e[n].styles&&t.push(i),t}),[]),i=ne[n].styles;if(i){var s=JSON.parse(JSON.stringify(i));s.default&&A.overwriteDefaultWithAlreadyApplied(s,t),r.unshift(s)}var a=A.mergeStatefulStyles(r);return A.processStateful(a,{},{})}},{key:"applyDeepChatUtilities",value:function(t,n,r){re.forEach((function(t){var i=r.getElementsByClassName(t);Array.from(i||[]).forEach((function(r){var i=e.getProcessedStyles(n,r,t);se.applyStylesToElement(r,i),e.applyEvents(r,t)}))}));var i=r.getElementsByClassName("deep-chat-suggestion-button");Array.from(i).forEach((function(n){return e.applySuggestionEvent(t,n)}))}}])}(),se=function(){function e(){x(this,e)}return E(e,null,[{key:"applyStylesToElement",value:function(e,t){var n=A.processStateful(t,{},{});te.add(e,n),Object.assign(e.style,n.default)}},{key:"applyEventsToElement",value:function(e,t){Object.keys(t).forEach((function(n){var r=t[n];r&&e.addEventListener(n,r)}))}},{key:"applyClassUtilitiesToElement",value:function(t,n){var r=n.events,i=n.styles;r&&e.applyEventsToElement(t,r),i&&!ie.doesElementContainDeepChatClass(t)&&e.applyStylesToElement(t,i)}},{key:"applyCustomClassUtilities",value:function(t,n){Object.keys(t).forEach((function(r){var i=n.getElementsByClassName(r);Array.from(i).forEach((function(n){t[r]&&e.applyClassUtilitiesToElement(n,t[r])}))}))}},{key:"apply",value:function(t,n){ie.applyDeepChatUtilities(t,t.htmlClassUtilities,n),e.applyCustomClassUtilities(t.htmlClassUtilities,n)}},{key:"traverseNodes",value:function(t,n){t.nodeType===Node.ELEMENT_NODE&&n.push(t.outerHTML),t.childNodes.forEach((function(t){e.traverseNodes(t,n)}))}},{key:"splitHTML",value:function(t){var n=(new DOMParser).parseFromString(t,"text/html"),r=[];return n.body.childNodes.forEach((function(t){e.traverseNodes(t,r)})),r}}])}(),ae=function(){function e(){x(this,e)}return E(e,null,[{key:"addElement",value:function(e,t){e.elementRef.appendChild(t),e.elementRef.scrollTop=e.elementRef.scrollHeight}},{key:"createElements",value:function(t,n,r,i){var s=t.createMessageElementsOnOrientation("",r,i);return s.bubbleElement.classList.add(e.HTML_BUBBLE_CLASS),s.bubbleElement.innerHTML=n,s}},{key:"overwriteElements",value:function(e,t,n){n.bubbleElement.innerHTML=t,se.apply(e,n.outerContainer),ee.flagHTMLUpdateClass(n.bubbleElement)}},{key:"overwrite",value:function(t,n,r,i){var s=t.messageToElements,a=Wt.overwriteMessage(s,i,n,r,"html",e.HTML_BUBBLE_CLASS);return a&&e.overwriteElements(t,n,a),a}},{key:"create",value:function(t,n,r){var i,s=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=e.createElements(t,n,r,s);return Wt.fillEmptyMessageElement(a.bubbleElement,n),se.apply(t,a.outerContainer),ee.flagHTMLUpdateClass(a.bubbleElement),t.applyCustomStyles(a,r,!1,null==(i=t.messageStyles)?void 0:i.html),a}},{key:"add",value:function(t,n,r,i,s){var a=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(null!=s&&s.status){var o=this.overwrite(t,n,r,i);if(o)return o;s.status=!1}var l=e.create(t,n,r,a);return a||e.addElement(t,l.outerContainer),l}}])}();ae.HTML_BUBBLE_CLASS="html-message";var oe,le=ae;function ce(e){return(oe=oe||document.createElement("textarea")).innerHTML="&"+e+";",oe.value}var ue=Object.prototype.hasOwnProperty;function de(e){return[].slice.call(arguments,1).forEach((function(t){if(t){if("object"!=_(t))throw new TypeError(t+"must be object");Object.keys(t).forEach((function(n){e[n]=t[n]}))}})),e}var he=/\\([\\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;function pe(e){return e.indexOf("\\")<0?e:e.replace(he,"$1")}function fe(e){return!(e>=55296&&e<=57343||e>=64976&&e<=65007||!(65535&~e)||65534==(65535&e)||e>=0&&e<=8||11===e||e>=14&&e<=31||e>=127&&e<=159||e>1114111)}function me(e){if(e>65535){var t=55296+((e-=65536)>>10),n=56320+(1023&e);return String.fromCharCode(t,n)}return String.fromCharCode(e)}var ve=/&([a-z#][a-z0-9]{1,31});/gi,ge=/^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;function ye(e,t){var n=0,r=ce(t);return t!==r?r:35===t.charCodeAt(0)&&ge.test(t)&&fe(n="x"===t[1].toLowerCase()?parseInt(t.slice(2),16):parseInt(t.slice(1),10))?me(n):e}function be(e){return e.indexOf("&")<0?e:e.replace(ve,ye)}var ke=/[&<>"]/,_e=/[&<>"]/g,xe={"&":"&","<":"<",">":">",'"':"""};function Se(e){return xe[e]}function Ee(e){return ke.test(e)?e.replace(_e,Se):e}var we={};function Ce(e,t){return++t>=e.length-2?t:"paragraph_open"===e[t].type&&e[t].tight&&"inline"===e[t+1].type&&0===e[t+1].content.length&&"paragraph_close"===e[t+2].type&&e[t+2].tight?Ce(e,t+2):t}we.blockquote_open=function(){return"
\n"},we.blockquote_close=function(e,t){return"
"+Te(e,t)},we.code=function(e,t){return e[t].block?"
"+Ee(e[t].content)+"
"+Te(e,t):""+Ee(e[t].content)+""},we.fence=function(e,t,n,r,i){var s,a,o=e[t],l="",c=n.langPrefix;if(o.params){if(a=(s=o.params.split(/\s+/g)).join(" "),function(e,t){return!!e&&ue.call(e,t)}(i.rules.fence_custom,s[0]))return i.rules.fence_custom[s[0]](e,t,n,r,i);l=' class="'+c+Ee(be(pe(a)))+'"'}return"
"+(n.highlight&&n.highlight.apply(n.highlight,[o.content].concat(s))||Ee(o.content))+"
"+Te(e,t)},we.fence_custom={},we.heading_open=function(e,t){return""},we.heading_close=function(e,t){return"\n"},we.hr=function(e,t,n){return(n.xhtmlOut?"
":"
")+Te(e,t)},we.bullet_list_open=function(){return"
    \n"},we.bullet_list_close=function(e,t){return"
"+Te(e,t)},we.list_item_open=function(){return"
  • "},we.list_item_close=function(){return"
  • \n"},we.ordered_list_open=function(e,t){var n=e[t];return"1?' start="'+n.order+'"':"")+">\n"},we.ordered_list_close=function(e,t){return""+Te(e,t)},we.paragraph_open=function(e,t){return e[t].tight?"":"

    "},we.paragraph_close=function(e,t){var n=!(e[t].tight&&t&&"inline"===e[t-1].type&&!e[t-1].content);return(e[t].tight?"":"

    ")+(n?Te(e,t):"")},we.link_open=function(e,t,n){var r=e[t].title?' title="'+Ee(be(e[t].title))+'"':"",i=n.linkTarget?' target="'+n.linkTarget+'"':"";return'"},we.link_close=function(){return""},we.image=function(e,t,n){var r=' src="'+Ee(e[t].src)+'"',i=e[t].title?' title="'+Ee(be(e[t].title))+'"':"";return""},we.table_open=function(){return"\n"},we.table_close=function(){return"
    \n"},we.thead_open=function(){return"\n"},we.thead_close=function(){return"\n"},we.tbody_open=function(){return"\n"},we.tbody_close=function(){return"\n"},we.tr_open=function(){return""},we.tr_close=function(){return"\n"},we.th_open=function(e,t){var n=e[t];return""},we.th_close=function(){return""},we.td_open=function(e,t){var n=e[t];return""},we.td_close=function(){return""},we.strong_open=function(){return""},we.strong_close=function(){return""},we.em_open=function(){return""},we.em_close=function(){return""},we.del_open=function(){return""},we.del_close=function(){return""},we.ins_open=function(){return""},we.ins_close=function(){return""},we.mark_open=function(){return""},we.mark_close=function(){return""},we.sub=function(e,t){return""+Ee(e[t].content)+""},we.sup=function(e,t){return""+Ee(e[t].content)+""},we.hardbreak=function(e,t,n){return n.xhtmlOut?"
    \n":"
    \n"},we.softbreak=function(e,t,n){return n.breaks?n.xhtmlOut?"
    \n":"
    \n":"\n"},we.text=function(e,t){return Ee(e[t].content)},we.htmlblock=function(e,t){return e[t].content},we.htmltag=function(e,t){return e[t].content},we.abbr_open=function(e,t){return''},we.abbr_close=function(){return""},we.footnote_ref=function(e,t){var n=Number(e[t].id+1).toString(),r="fnref"+n;return e[t].subId>0&&(r+=":"+e[t].subId),'['+n+"]"},we.footnote_block_open=function(e,t,n){return(n.xhtmlOut?'
    \n':'
    \n')+'
    \n
      \n'},we.footnote_block_close=function(){return"
    \n
    \n"},we.footnote_open=function(e,t){return'
  • '},we.footnote_close=function(){return"
  • \n"},we.footnote_anchor=function(e,t){var n="fnref"+Number(e[t].id+1).toString();return e[t].subId>0&&(n+=":"+e[t].subId),' \u21a9'},we.dl_open=function(){return"
    \n"},we.dt_open=function(){return"
    "},we.dd_open=function(){return"
    "},we.dl_close=function(){return"
    \n"},we.dt_close=function(){return"\n"},we.dd_close=function(){return"\n"};var Te=we.getBreak=function(e,t){return(t=Ce(e,t))"u"&&(r.abbreviations[":"+l]=c),a)}function Oe(e){var t=be(e);try{t=decodeURI(t)}catch(n){}return encodeURI(t)}function Pe(e,t){var n,r,i,s=t,a=e.posMax;if(60===e.src.charCodeAt(t)){for(t++;t1||41===n&&--r<0)break;t++}return!(s===t||(i=pe(e.src.slice(s,t)),!e.parser.validateLink(i)))&&(e.linkContent=i,e.pos=t,!0)}function Ne(e,t){var n,r=t,i=e.posMax,s=e.src.charCodeAt(t);if(34!==s&&39!==s&&40!==s)return!1;for(t++,40===s&&(s=41);t"u"&&(r.references[h]={title:d,href:u}),a)}Ae.prototype.renderInline=function(e,t,n){for(var r=this.rules,i=e.length,s=0,a="";i--;)a+=r[e[s].type](e,s++,t,n,this);return a},Ae.prototype.render=function(e,t,n){for(var r=this.rules,i=e.length,s=-1,a="";++s=e.length)&&!We.test(e[t])}function Je(e,t,n){return e.substr(0,t)+n+e.substr(t+1)}var Ye=[["block",function(e){e.inlineMode?e.tokens.push({type:"inline",content:e.src.replace(/\n/g," ").trim(),level:0,lines:[0,1],children:[]}):e.block.parse(e.src,e.options,e.env,e.tokens)}],["abbr",function(e){var t,n,r,i,s=e.tokens;if(!e.inlineMode)for(t=1,n=s.length-1;t0?a[t].count:1,r=0;r=0;t--)if("text"===(s=i[t]).type){for(l=0,a=s.content,u.lastIndex=0,c=s.level,o=[];d=u.exec(a);)u.lastIndex>l&&o.push({type:"text",content:a.slice(l,d.index+d[1].length),level:c}),o.push({type:"abbr_open",title:e.env.abbreviations[":"+d[2]],level:c++}),o.push({type:"text",content:d[2],level:c}),o.push({type:"abbr_close",level:--c}),l=u.lastIndex-d[3].length;o.length&&(l=0;s--)if("inline"===e.tokens[s].type)for(t=(i=e.tokens[s].children).length-1;t>=0;t--)"text"===(n=i[t]).type&&(r=ze(r=n.content),Ue.test(r)&&(r=r.replace(/\+-/g,"\xb1").replace(/\.{2,}/g,"\u2026").replace(/([?!])\u2026/g,"$1..").replace(/([?!]){4,}/g,"$1$1$1").replace(/,{2,}/g,",").replace(/(^|[^-])---([^-]|$)/gm,"$1\u2014$2").replace(/(^|\s)--(\s|$)/gm,"$1\u2013$2").replace(/(^|[^-\s])--([^-\s]|$)/gm,"$1\u2013$2")),n.content=r)}],["smartquotes",function(e){var t,n,r,i,s,a,o,l,c,u,d,h,p,f,m,v,g;if(e.options.typographer)for(g=[],m=e.tokens.length-1;m>=0;m--)if("inline"===e.tokens[m].type)for(v=e.tokens[m].children,g.length=0,t=0;t=0&&!(g[p].level<=o);p--);g.length=p+1,s=0,a=(r=n.content).length;e:for(;s=0&&(u=g[p],!(g[p].level=(i=e.eMarks[t])||42!==(n=e.src.charCodeAt(r++))&&45!==n&&43!==n||r=i||((n=e.src.charCodeAt(r++))<48||n>57))return-1;for(;;){if(r>=i)return-1;if(!((n=e.src.charCodeAt(r++))>=48&&n<=57)){if(41===n||46===n)break;return-1}}return r=this.eMarks[e]},Xe.prototype.skipEmptyLines=function(e){for(var t=this.lineMax;en;)if(t!==this.src.charCodeAt(--e))return e+1;return e},Xe.prototype.getLines=function(e,t,n,r){var i,s,a,o,l,c=e;if(e>=t)return"";if(c+1===t)return s=this.bMarks[c]+Math.min(this.tShift[c],n),a=r?this.eMarks[c]+1:this.eMarks[c],this.src.slice(s,a);for(o=new Array(t-e),i=0;cn&&(l=n),l<0&&(l=0),s=this.bMarks[c]+l,a=c+1]/,nt=/^<\/([a-zA-Z]{1,15})[\s>]/;function rt(e,t){var n=e.bMarks[t]+e.blkIndent,r=e.eMarks[t];return e.src.substr(n,r-n)}function it(e,t){var n,r,i=e.bMarks[t]+e.tShift[t],s=e.eMarks[t];return i>=s||126!==(r=e.src.charCodeAt(i++))&&58!==r||i===(n=e.skipSpaces(i))||n>=s?-1:n}var st=[["code",function(e,t,n){var r,i;if(e.tShift[t]-e.blkIndent<4)return!1;for(i=r=t+1;r=4))break;i=++r}return e.line=r,e.tokens.push({type:"code",content:e.getLines(t,i,4+e.blkIndent,!0),block:!0,lines:[t,e.line],level:e.level}),!0}],["fences",function(e,t,n,r){var i,s,a,o,l,c=!1,u=e.bMarks[t]+e.tShift[t],d=e.eMarks[t];if(u+3>d||126!==(i=e.src.charCodeAt(u))&&96!==i||(l=u,(s=(u=e.skipChars(u,i))-l)<3)||(a=e.src.slice(u,d).trim()).indexOf("`")>=0)return!1;if(r)return!0;for(o=t;!(++o>=n||(u=l=e.bMarks[o]+e.tShift[o],d=e.eMarks[o],u=4||(u=e.skipChars(u,i),u-lv||62!==e.src.charCodeAt(m++)||e.level>=e.options.maxNesting)return!1;if(r)return!0;for(32===e.src.charCodeAt(m)&&m++,l=e.blkIndent,e.blkIndent=0,o=[e.bMarks[t]],e.bMarks[t]=m,s=(m=m=v,a=[e.tShift[t]],e.tShift[t]=m-e.bMarks[t],d=e.parser.ruler.getRules("blockquote"),i=t+1;i=(v=e.eMarks[i]));i++)if(62!==e.src.charCodeAt(m++)){if(s)break;for(f=!1,h=0,p=d.length;h=v,a.push(e.tShift[i]),e.tShift[i]=m-e.bMarks[i];for(c=e.parentType,e.parentType="blockquote",e.tokens.push({type:"blockquote_open",lines:u=[t,0],level:e.level++}),e.parser.tokenize(e,t,i),e.tokens.push({type:"blockquote_close",level:--e.level}),e.parentType=c,u[1]=e.line,h=0;hl||42!==(i=e.src.charCodeAt(o++))&&45!==i&&95!==i)return!1;for(s=1;o=0)m=!0;else{if(!((d=Qe(e,t))>=0))return!1;m=!1}if(e.level>=e.options.maxNesting)return!1;if(f=e.src.charCodeAt(d-1),r)return!0;for(g=e.tokens.length,m?(u=e.bMarks[t]+e.tShift[t],p=Number(e.src.substr(u,d-u-1)),e.tokens.push({type:"ordered_list_open",order:p,lines:b=[t,0],level:e.level++})):e.tokens.push({type:"bullet_list_open",lines:b=[t,0],level:e.level++}),i=t,y=!1,_=e.parser.ruler.getRules("list");i=e.eMarks[i]?1:v-d)>4&&(h=1),h<1&&(h=1),s=d-e.bMarks[i]+h,e.tokens.push({type:"list_item_open",lines:k=[t,0],level:e.level++}),o=e.blkIndent,l=e.tight,a=e.tShift[t],c=e.parentType,e.tShift[t]=v-e.bMarks[t],e.blkIndent=s,e.tight=!0,e.parentType="list",e.parser.tokenize(e,t,n,!0),(!e.tight||y)&&(w=!1),y=e.line-t>1&&e.isEmpty(e.line-1),e.blkIndent=o,e.tShift[t]=a,e.tight=l,e.parentType=c,e.tokens.push({type:"list_item_close",level:--e.level}),i=t=e.line,k[1]=i,v=e.bMarks[t],!(i>=n||e.isEmpty(i)||e.tShift[i]u||91!==e.src.charCodeAt(c)||94!==e.src.charCodeAt(c+1)||e.level>=e.options.maxNesting)return!1;for(o=c+2;o=u||58!==e.src.charCodeAt(++o))&&(r||(o++,e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.refs||(e.env.footnotes.refs={}),l=e.src.slice(c+2,o-2),e.env.footnotes.refs[":"+l]=-1,e.tokens.push({type:"footnote_reference_open",label:l,level:e.level++}),i=e.bMarks[t],s=e.tShift[t],a=e.parentType,e.tShift[t]=e.skipSpaces(o)-o,e.bMarks[t]=o,e.blkIndent+=4,e.parentType="footnote",e.tShift[t]=l||(35!==(i=e.src.charCodeAt(o))||o>=l))return!1;for(s=1,i=e.src.charCodeAt(++o);35===i&&o6||oo&&32===e.src.charCodeAt(a-1)&&(l=a),e.line=t+1,e.tokens.push({type:"heading_open",hLevel:s,lines:[t,e.line],level:e.level}),o=n||e.tShift[a]3||(i=e.bMarks[a]+e.tShift[a],s=e.eMarks[a],i>=s)||(r=e.src.charCodeAt(i),45!==r&&61!==r)||(i=e.skipChars(i,r),i=e.skipSpaces(i),i3||o+2>=l||60!==e.src.charCodeAt(o))return!1;if(33===(i=e.src.charCodeAt(o+1))||63===i){if(r)return!0}else{if(47!==i&&!function(e){var t=32|e;return t>=97&&t<=122}(i))return!1;if(47===i){if(!(s=e.src.slice(o,l).match(nt)))return!1}else if(!(s=e.src.slice(o,l).match(tt)))return!1;if(!0!==et[s[1].toLowerCase()])return!1;if(r)return!0}for(a=t+1;an||(l=t+1,e.tShift[l]=e.eMarks[l]||124!==(i=e.src.charCodeAt(a))&&45!==i&&58!==i||(s=rt(e,t+1),!/^[-:| ]+$/.test(s))||(c=s.split("|"))<=2)return!1;for(d=[],o=0;o=0;if(u=t+1,e.isEmpty(u)&&++u>n||e.tShift[u]=e.options.maxNesting)return!1;c=e.tokens.length,e.tokens.push({type:"dl_open",lines:l=[t,0],level:e.level++}),a=t,s=u;e:for(;;){for(g=!0,v=!1,e.tokens.push({type:"dt_open",lines:[a,a],level:e.level++}),e.tokens.push({type:"inline",content:e.getLines(a,a+1,e.blkIndent,!1).trim(),level:e.level+1,lines:[a,a],children:[]}),e.tokens.push({type:"dt_close",level:--e.level});;){if(e.tokens.push({type:"dd_open",lines:o=[u,0],level:e.level++}),m=e.tight,h=e.ddIndent,d=e.blkIndent,f=e.tShift[s],p=e.parentType,e.blkIndent=e.ddIndent=e.tShift[s]+2,e.tShift[s]=i-e.bMarks[s],e.tight=!0,e.parentType="deflist",e.parser.tokenize(e,s,n,!0),(!e.tight||v)&&(g=!1),v=e.line-s>1&&e.isEmpty(e.line-1),e.tShift[s]=f,e.tight=m,e.parentType=p,e.blkIndent=d,e.ddIndent=h,e.tokens.push({type:"dd_close",level:--e.level}),o[1]=u=e.line,u>=n||e.tShift[u]=n||(a=u,e.isEmpty(a))||e.tShift[a]=n||(e.isEmpty(s)&&s++,s>=n)||e.tShift[s]3)){for(i=!1,s=0,a=o.length;s=n||e.tShift[a]=0&&(e=e.replace(ot,(function(t,n){var r;return 10===e.charCodeAt(n)?(s=n+1,a=0,t):(r=" ".slice((n-s-a)%4),a=n-s+1,r)}))),i=new Xe(e,this,t,n,r),this.tokenize(i,i.line,i.lineMax)};for(var dt=[],ht=0;ht<256;ht++)dt.push(0);function pt(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122}function ft(e,t){var n,r,i,s=t,a=!0,o=!0,l=e.posMax,c=e.src.charCodeAt(t);for(n=t>0?e.src.charCodeAt(t-1):-1;s=l&&(a=!1),(i=s-t)>=4?a=o=!1:((32===(r=s?@[]^_`{|}~-".split("").forEach((function(e){dt[e.charCodeAt(0)]=1}));var mt=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var vt=/\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;var gt=["coap","doi","javascript","aaa","aaas","about","acap","cap","cid","crid","data","dav","dict","dns","file","ftp","geo","go","gopher","h323","http","https","iax","icap","im","imap","info","ipp","iris","iris.beep","iris.xpc","iris.xpcs","iris.lwz","ldap","mailto","mid","msrp","msrps","mtqp","mupdate","news","nfs","ni","nih","nntp","opaquelocktoken","pop","pres","rtsp","service","session","shttp","sieve","sip","sips","sms","snmp","soap.beep","soap.beeps","tag","tel","telnet","tftp","thismessage","tn3270","tip","tv","urn","vemmi","ws","wss","xcon","xcon-userid","xmlrpc.beep","xmlrpc.beeps","xmpp","z39.50r","z39.50s","adiumxtra","afp","afs","aim","apt","attachment","aw","beshare","bitcoin","bolo","callto","chrome","chrome-extension","com-eventbrite-attendee","content","cvs","dlna-playsingle","dlna-playcontainer","dtn","dvb","ed2k","facetime","feed","finger","fish","gg","git","gizmoproject","gtalk","hcp","icon","ipn","irc","irc6","ircs","itms","jar","jms","keyparc","lastfm","ldaps","magnet","maps","market","message","mms","ms-help","msnim","mumble","mvn","notes","oid","palm","paparazzi","platform","proxy","psyc","query","res","resource","rmi","rsync","rtmp","secondlife","sftp","sgn","skype","smb","soldat","spotify","ssh","steam","svn","teamspeak","things","udp","unreal","ut2004","ventrilo","view-source","webcal","wtai","wyciwyg","xfire","xri","ymsgr"],yt=/^<([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])?)*)>/,bt=/^<([a-zA-Z.\-]{1,25}):([^<>\x00-\x20]*)>/;function kt(e,t){return e=e.source,t=t||"",function n(r,i){return r?(i=i.source||i,e=e.replace(r,i),n):new RegExp(e,t)}}var _t=kt(/(?:unquoted|single_quoted|double_quoted)/)("unquoted",/[^"'=<>`\x00-\x20]+/)("single_quoted",/'[^']*'/)("double_quoted",/"[^"]*"/)(),xt=kt(/(?:\s+attr_name(?:\s*=\s*attr_value)?)/)("attr_name",/[a-zA-Z_:][a-zA-Z0-9:._-]*/)("attr_value",_t)(),St=kt(/<[A-Za-z][A-Za-z0-9]*attribute*\s*\/?>/)("attribute",xt)(),Et=kt(/^(?:open_tag|close_tag|comment|processing|declaration|cdata)/)("open_tag",St)("close_tag",/<\/[A-Za-z][A-Za-z0-9]*\s*>/)("comment",/|/)("processing",/<[?].*?[?]>/)("declaration",/]*>/)("cdata",//)();var wt=/^&#((?:x[a-f0-9]{1,8}|[0-9]{1,8}));/i,Ct=/^&([a-z][a-z0-9]{1,31});/i;var Tt=[["text",function(e,t){for(var n=e.pos;n=0&&32===e.pending.charCodeAt(n))if(n>=1&&32===e.pending.charCodeAt(n-1)){for(var s=n-2;s>=0;s--)if(32!==e.pending.charCodeAt(s)){e.pending=e.pending.substring(0,s+1);break}e.push({type:"hardbreak",level:e.level})}else e.pending=e.pending.slice(0,-1),e.push({type:"softbreak",level:e.level});else e.push({type:"softbreak",level:e.level});for(i++;i=o||126!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(s=l>0?e.src.charCodeAt(l-1):-1,a=e.src.charCodeAt(l+2),126===s)||126===a||32===a||10===a)return!1;for(r=l+2;rl+3)return e.pos+=r-l,t||(e.pending+=e.src.slice(l,r)),!0;for(e.pos=l+2,i=1;e.pos+1=o||43!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(s=l>0?e.src.charCodeAt(l-1):-1,a=e.src.charCodeAt(l+2),43===s)||43===a||32===a||10===a)return!1;for(r=l+2;r=o||61!==e.src.charCodeAt(l+1)||e.level>=e.options.maxNesting||(s=l>0?e.src.charCodeAt(l-1):-1,a=e.src.charCodeAt(l+2),61===s)||61===a||32===a||10===a)return!1;for(r=l+2;r=e.options.maxNesting)return!1;for(e.pos=u+n,o=[n];e.pos=i||e.level>=e.options.maxNesting)return!1;for(e.pos=s+1;e.pos=i||e.level>=e.options.maxNesting)return!1;for(e.pos=s+1;e.pos=e.options.maxNesting||(n=p+1,(r=Le(e,p))<0))return!1;if((o=r+1)=h)return!1;for(p=o,Pe(e,o)?(s=e.linkContent,o=e.pos):s="",p=o;o=h||41!==e.src.charCodeAt(o))return e.pos=d,!1;o++}else{if(e.linkLevel>0)return!1;for(;o=0?i=e.src.slice(p,o++):o=p-1),i||(_(i)>"u"&&(o=r+1),i=e.src.slice(n,r)),!(l=e.env.references[Be(i)]))return e.pos=d,!1;s=l.href,a=l.title}return t||(e.pos=n,e.posMax=r,u?e.push({type:"image",src:s,title:a,alt:e.src.substr(n,r-n),level:e.level}):(e.push({type:"link_open",href:s,title:a,level:e.level++}),e.linkLevel++,e.parser.tokenize(e),e.linkLevel--,e.push({type:"link_close",level:--e.level}))),e.pos=o,e.posMax=h,!0}],["footnote_inline",function(e,t){var n,r,i,s,a=e.posMax,o=e.pos;return!(o+2>=a||94!==e.src.charCodeAt(o)||91!==e.src.charCodeAt(o+1)||e.level>=e.options.maxNesting||(n=o+2,r=Le(e,o+1),r<0))&&(t||(e.env.footnotes||(e.env.footnotes={}),e.env.footnotes.list||(e.env.footnotes.list=[]),i=e.env.footnotes.list.length,e.pos=n,e.posMax=r,e.push({type:"footnote_ref",id:i,level:e.level}),e.linkLevel++,s=e.tokens.length,e.parser.tokenize(e),e.env.footnotes.list[i]={tokens:e.tokens.splice(s)},e.linkLevel--),e.pos=r+1,e.posMax=a,!0)}],["footnote_ref",function(e,t){var n,r,i,s,a=e.posMax,o=e.pos;if(o+3>a||!e.env.footnotes||!e.env.footnotes.refs||91!==e.src.charCodeAt(o)||94!==e.src.charCodeAt(o+1)||e.level>=e.options.maxNesting)return!1;for(r=o+2;r=a||(r++,n=e.src.slice(o+2,r-1),_(e.env.footnotes.refs[":"+n])>"u"))&&(t||(e.env.footnotes.list||(e.env.footnotes.list=[]),e.env.footnotes.refs[":"+n]<0?(i=e.env.footnotes.list.length,e.env.footnotes.list[i]={label:n,count:0},e.env.footnotes.refs[":"+n]=i):i=e.env.footnotes.refs[":"+n],s=e.env.footnotes.list[i].count,e.env.footnotes.list[i].count++,e.push({type:"footnote_ref",id:i,subId:s,level:e.level})),e.pos=r,e.posMax=a,!0)}],["autolink",function(e,t){var n,r,i,s,a,o=e.pos;return!(60!==e.src.charCodeAt(o)||(n=e.src.slice(o),n.indexOf(">")<0))&&((r=n.match(bt))?!(gt.indexOf(r[1].toLowerCase())<0||(s=r[0].slice(1,-1),a=Oe(s),!e.parser.validateLink(s)))&&(t||(e.push({type:"link_open",href:a,level:e.level}),e.push({type:"text",content:s,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=r[0].length,!0):!!(i=n.match(yt))&&(a=Oe("mailto:"+(s=i[0].slice(1,-1))),!!e.parser.validateLink(a)&&(t||(e.push({type:"link_open",href:a,level:e.level}),e.push({type:"text",content:s,level:e.level+1}),e.push({type:"link_close",level:e.level})),e.pos+=i[0].length,!0)))}],["htmltag",function(e,t){var n,r,i,s=e.pos;return!(!e.options.html||(i=e.posMax,60!==e.src.charCodeAt(s)||s+2>=i)||(n=e.src.charCodeAt(s+1),33!==n&&63!==n&&47!==n&&!function(e){var t=32|e;return t>=97&&t<=122}(n))||(r=e.src.slice(s).match(Et),!r))&&(t||e.push({type:"htmltag",content:e.src.slice(s,s+r[0].length),level:e.level}),e.pos+=r[0].length,!0)}],["entity",function(e,t){var n,r,i=e.pos,s=e.posMax;if(38!==e.src.charCodeAt(i))return!1;if(i+10)e.pos=n;else{for(t=0;t=s)break}else e.pending+=e.src[e.pos++]}e.pending&&e.pushPending()},At.prototype.parse=function(e,t,n,r){var i=new Ie(e,this,t,n,r);this.tokenize(i)};var It={default:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","replacements","smartquotes","references","abbr2","footnote_tail"]},block:{rules:["blockquote","code","fences","footnote","heading","hr","htmlblock","lheading","list","paragraph","table"]},inline:{rules:["autolink","backticks","del","emphasis","entity","escape","footnote_ref","htmltag","links","newline","text"]}}},full:{options:{html:!1,xhtmlOut:!1,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:20},components:{core:{},block:{},inline:{}}},commonmark:{options:{html:!0,xhtmlOut:!0,breaks:!1,langPrefix:"language-",linkTarget:"",typographer:!1,quotes:"\u201c\u201d\u2018\u2019",highlight:null,maxNesting:20},components:{core:{rules:["block","inline","references","abbr2"]},block:{rules:["blockquote","code","fences","heading","hr","htmlblock","lheading","list","paragraph"]},inline:{rules:["autolink","backticks","emphasis","entity","escape","htmltag","links","newline","text"]}}}};function Lt(e,t,n){this.src=t,this.env=n,this.options=e.options,this.tokens=[],this.inlineMode=!1,this.inline=e.inline,this.block=e.block,this.renderer=e.renderer,this.typographer=e.typographer}function Rt(e,t){"string"!=typeof e&&(t=e,e="default"),t&&null!=t.linkify&&console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"),this.inline=new At,this.block=new at,this.core=new Ze,this.renderer=new Ae,this.ruler=new Me,this.options={},this.configure(It[e]),this.set(t||{})}Rt.prototype.set=function(e){de(this.options,e)},Rt.prototype.configure=function(e){var t=this;if(!e)throw new Error("Wrong `remarkable` preset, check name/content");e.options&&t.set(e.options),e.components&&Object.keys(e.components).forEach((function(n){e.components[n].rules&&t[n].ruler.enable(e.components[n].rules,!0)}))},Rt.prototype.use=function(e,t){return e(this,t),this},Rt.prototype.parse=function(e,t){var n=new Lt(this,e,t);return this.core.process(n),n.tokens},Rt.prototype.render=function(e,t){return t=t||{},this.renderer.render(this.parse(e,t),this.options,t)},Rt.prototype.parseInline=function(e,t){var n=new Lt(this,e,t);return n.inlineMode=!0,this.core.process(n),n.tokens},Rt.prototype.renderInline=function(e,t){return t=t||{},this.renderer.render(this.parseInline(e,t),this.options,t)};var Ot=function(){function e(){x(this,e)}return E(e,null,[{key:"instantiate",value:function(t){if(t)return new Rt(b(b({},e.DEFAULT_PROPERTIES),t));if(window.hljs){var n=window.hljs;return new Rt({highlight:function(e,t){if(t&&n.getLanguage(t))try{return n.highlight(t,e).value}catch(r){console.error("failed to setup the highlight dependency")}try{return n.highlightAuto(e).value}catch(i){console.error("failed to automatically highlight messages")}return""},html:!1,xhtmlOut:!1,breaks:!0,langPrefix:"language-",linkTarget:"_blank",typographer:!0})}return new Rt(e.DEFAULT_PROPERTIES)}},{key:"createNew",value:function(t){var n=e.instantiate(t);return n.inline.validateLink=function(){return!0},n}}])}();Ot.DEFAULT_PROPERTIES={breaks:!0,linkTarget:"_blank"};var Pt=Ot,Nt=function(){function e(){x(this,e)}return E(e,null,[{key:"applyCustomStylesToElements",value:function(e,t,n){if(n&&(Object.assign(e.outerContainer.style,n.outerContainer),Object.assign(e.innerContainer.style,n.innerContainer),Object.assign(e.bubbleElement.style,n.bubble),t)){var r=e.bubbleElement.children[0],i="a"!==r.tagName.toLocaleLowerCase()?r:r.children[0];Object.assign(i.style,n.media)}}},{key:"applySideStyles",value:function(t,n,r,i){i&&(e.applyCustomStylesToElements(t,r,i.shared),n===Wt.USER_ROLE?e.applyCustomStylesToElements(t,r,i.user):(e.applyCustomStylesToElements(t,r,i.ai),e.applyCustomStylesToElements(t,r,i[n])))}},{key:"isElementsStyles",value:function(e){return!!(e.outerContainer||e.innerContainer||e.bubble||e.media)}},{key:"applyCustomStyles",value:function(t,n,r,i,s){var a;s&&t.default!==s?e.isElementsStyles(s)?(e.applyCustomStylesToElements(n,i,null==(a=t.default)?void 0:a.shared),e.applyCustomStylesToElements(n,i,s)):(e.applySideStyles(n,r,i,t.default),e.applySideStyles(n,r,i,s)):e.applySideStyles(n,r,i,t.default)}},{key:"extractParticularSharedStyles",value:function(e,t){if(null!=t&&t.shared){var n=t.shared,r={outerContainer:{},innerContainer:{},bubble:{},media:{}};return e.forEach((function(e){var t,i,s,a;r.outerContainer[e]=(null==(t=n.outerContainer)?void 0:t[e])||"",r.innerContainer[e]=(null==(i=n.innerContainer)?void 0:i[e])||"",r.bubble[e]=(null==(s=n.bubble)?void 0:s[e])||"",r.media[e]=(null==(a=n.media)?void 0:a[e])||""})),r}}}])}(),Bt=function(){return E((function e(){x(this,e)}),null,[{key:"onMessage",value:function(e,t,n){var r,i=JSON.parse(JSON.stringify({message:t,isHistory:n,isInitial:n}));$.reAddFileRefToObject(t,i),null==(r=e.onMessage)||r.call(e,i),e.dispatchEvent(new CustomEvent("message",{detail:i})),ee.fireOnNewMessage(e,i)}},{key:"onClearMessages",value:function(e){var t;null==(t=e.onClearMessages)||t.call(e),e.dispatchEvent(new CustomEvent("clear-messages"))}},{key:"onRender",value:function(e){var t;null==(t=e.onComponentRender)||t.call(e,e),e.dispatchEvent(new CustomEvent("render",{detail:e}))}},{key:"onError",value:function(e,t){var n;null==(n=e.onError)||n.call(e,t),e.dispatchEvent(new CustomEvent("error",{detail:t}))}}])}(),Dt=function(){function e(){x(this,e)}return E(e,null,[{key:"generateLoadingRingElement",value:function(){var e=document.createElement("div");return e.classList.add("loading-history"),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e.appendChild(document.createElement("div")),e}},{key:"apply",value:function(e,t,n){X.setRing(t.bubbleElement,null==n?void 0:n.bubble),null!=n&&n.bubble&&delete(n=JSON.parse(JSON.stringify(n))).bubble,e.applyCustomStyles(t,"history",!1,n)}},{key:"addLoadHistoryMessage",value:function(t,n){var r,i,s,a,o,l,c,u,d=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t.bubbleElement.classList.add(e.CLASS);var h=d?e.FULL_VIEW_CLASS:e.SMALL_CLASS;t.outerContainer.classList.add(h);var p=d?null==(a=null==(s=null==(i=null==(r=n.messageStyles)?void 0:r.loading)?void 0:i.history)?void 0:s.full)?void 0:a.styles:null==(u=null==(c=null==(l=null==(o=n.messageStyles)?void 0:o.loading)?void 0:l.history)?void 0:c.small)?void 0:u.styles;e.apply(n,t,p),n.elementRef.prepend(t.outerContainer)}},{key:"createDefaultElements",value:function(t){var n=t.createMessageElements("",Wt.AI_ROLE),r=n.bubbleElement,i=e.generateLoadingRingElement();return r.appendChild(i),n}},{key:"addMessage",value:function(t){var n,r,i,s,a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],o=null==(s=null==(i=null==(r=null==(n=t.messageStyles)?void 0:n.loading)?void 0:r.history)?void 0:i.full)?void 0:s.html,l=o?le.createElements(t,o,Wt.AI_ROLE,!0):e.createDefaultElements(t);return e.addLoadHistoryMessage(l,t,a),l}},{key:"tryChangeViewToSmall",value:function(t,n){var r,i,s,a,o,l,c,u;if(null!=n&&n.outerContainer.classList.contains(e.FULL_VIEW_CLASS)){n.outerContainer.classList.replace(e.FULL_VIEW_CLASS,e.SMALL_CLASS);var d=null==(a=null==(s=null==(i=null==(r=t.messageStyles)?void 0:r.loading)?void 0:i.history)?void 0:s.small)?void 0:a.styles;d&&e.apply(t,n,d);var h=null==(u=null==(c=null==(l=null==(o=t.messageStyles)?void 0:o.loading)?void 0:l.history)?void 0:c.small)?void 0:u.html;return h&&(n.bubbleElement.innerHTML=h),!0}return!1}},{key:"changeFullViewToSmall",value:function(t){var n=t.messageElementRefs[t.messageElementRefs.length-1];e.tryChangeViewToSmall(t,n)||e.tryChangeViewToSmall(t,t.messageElementRefs[0])}}])}();Dt.CLASS="loading-history-message",Dt.FULL_VIEW_CLASS="loading-history-message-full-view",Dt.SMALL_CLASS="loading-history-message-small";var Ft=Dt,jt=function(){function e(t){var n=this;x(this,e),this.messageElementRefs=[],this.htmlClassUtilities={},this.messageToElements=[],this.elementRef=e.createContainerElement(),this.messageStyles=ee.processMessageStyles(t.messageStyles),this._remarkable=Pt.createNew(t.remarkable),this._avatars=t.avatars,this._names=t.names,this._onMessage=Bt.onMessage.bind(this,t),t.htmlClassUtilities&&(this.htmlClassUtilities=t.htmlClassUtilities),setTimeout((function(){n.submitUserMessage=t.submitUserMessage}))}return E(e,[{key:"addNewTextMessage",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(null!=r&&r.status){var s=this.overwriteText(n,t,this.messageElementRefs);if(s)return s;r.status=!1}var a=i?this.createAndPrependNewMessageElement(t,n,i):this.createAndAppendNewMessageElement(t,n);return a.bubbleElement.classList.add(e.TEXT_BUBBLE_CLASS),this.applyCustomStyles(a,n,!1),Wt.fillEmptyMessageElement(a.bubbleElement,t),a}},{key:"overwriteText",value:function(t,n,r){var i=Wt.overwriteMessage(this.messageToElements,r,n,t,"text",e.TEXT_BUBBLE_CLASS);return i&&this.renderText(i.bubbleElement,n),i}},{key:"createAndAppendNewMessageElement",value:function(e,t){var n=this,r=this.createNewMessageElement(e,t);return this.elementRef.appendChild(r.outerContainer),setTimeout((function(){return K.scrollToBottom(n.elementRef)})),r}},{key:"createAndPrependNewMessageElement",value:function(t,n,r){var i,s=this.createNewMessageElement(t,n,r);if(r&&null!=(i=this.elementRef.firstChild)&&i.classList.contains(e.INTRO_CLASS)){this.elementRef.firstChild.insertAdjacentElement("afterend",s.outerContainer);var a=this.messageElementRefs[0];this.messageElementRefs[0]=this.messageElementRefs[1],this.messageElementRefs[1]=a}else this.elementRef.insertBefore(s.outerContainer,this.elementRef.firstChild);return s}},{key:"createMessageElementsOnOrientation",value:function(e,t,n){return n?this.createAndPrependNewMessageElement(e,t,!0):this.createNewMessageElement(e,t)}},{key:"createNewMessageElement",value:function(t,n){var r,i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null==(r=this._introPanel)||r.hide();var s=this.messageElementRefs[this.messageElementRefs.length-1];return Ft.changeFullViewToSmall(this),e.isTemporaryElement(s)&&(this.revealRoleElementsIfTempRemoved(s,n),s.outerContainer.remove(),this.messageElementRefs.pop()),this.createMessageElements(t,n,i)}},{key:"revealRoleElementsIfTempRemoved",value:function(e,t){if((this._avatars||this._names)&&ie.isElementTemporary(e)){var n=this.messageElementRefs[this.messageElementRefs.length-2];n&&this.messageToElements.length>0&&!e.bubbleElement.classList.contains(Wt.getRoleClass(t))&&Wt.revealRoleElements(n.innerContainer,this._avatars,this._names)}}},{key:"createElements",value:function(t,n){var r=e.createBaseElements(n),i=r.outerContainer,s=r.innerContainer,a=r.bubbleElement;return i.appendChild(s),this.addInnerContainerElements(a,t,n),r}},{key:"createMessageElements",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=this.createElements(e,t);return Wt.updateRefArr(this.messageElementRefs,r,n),Wt.classifyMessages(t,this.messageElementRefs),r}},{key:"addInnerContainerElements",value:function(e,t,n){var r;return(null==(r=this.messageToElements[this.messageToElements.length-1])?void 0:r[0].role)===n&&!this.isLastMessageError()&&Wt.hideRoleElements(this.messageElementRefs,!!this._avatars,!!this._names),e.classList.add("message-bubble",Wt.getRoleClass(n),n===Wt.USER_ROLE?"user-message-text":"ai-message-text"),this.renderText(e,t),Wt.addRoleElements(e,n,this._avatars,this._names),{bubbleElement:e}}},{key:"applyCustomStyles",value:function(e,t,n,r){e&&this.messageStyles&&Nt.applyCustomStyles(this.messageStyles,e,t,n,r)}},{key:"removeMessage",value:function(e){e.outerContainer.remove();var t=this.messageElementRefs.findIndex((function(t){return t===e}));this.messageElementRefs.splice(t,1)}},{key:"removeLastMessage",value:function(){this.messageElementRefs[this.messageElementRefs.length-1].outerContainer.remove(),this.messageElementRefs.pop()}},{key:"isLastMessageError",value:function(){var e;return null==(e=Wt.getLastMessageBubbleElement(this.elementRef))?void 0:e.classList.contains("error-message-text")}},{key:"sendClientUpdate",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];null==(t=this._onMessage)||t.call(this,e,n)}},{key:"renderText",value:function(e,t){e.innerHTML=this._remarkable.render(t),0===e.innerText.trim().length&&(e.innerText=t)}},{key:"refreshTextMessages",value:function(e){var t=this;this._remarkable=Pt.createNew(e),this.messageToElements.forEach((function(e){e[1].text&&e[0].text&&t.renderText(e[1].text.bubbleElement,e[0].text)}))}}],[{key:"createContainerElement",value:function(){var e=document.createElement("div");return e.id="messages",e}},{key:"isTemporaryElement",value:function(t){return e.isLoadingMessage(t)||ie.isElementTemporary(t)}},{key:"createBaseElements",value:function(e){var t=document.createElement("div"),n=document.createElement("div");n.classList.add("inner-message-container"),t.appendChild(n),t.classList.add("outer-message-container"),t.classList.add(Wt.buildRoleContainerClass(e));var r=document.createElement("div");return r.classList.add("message-bubble"),n.appendChild(r),{outerContainer:t,innerContainer:n,bubbleElement:r}}},{key:"createMessageContent",value:function(e){var t=e.text,n=e.files,r=e.html,i=e._sessionId,s={role:e.role||Wt.AI_ROLE};return t&&(s.text=t),n&&(s.files=n),r&&(s.html=r),!t&&!n&&!r&&(s.text=""),i&&(s._sessionId=i),s}},{key:"isLoadingMessage",value:function(e){return null==e?void 0:e.bubbleElement.classList.contains(X.BUBBLE_CLASS)}}])}();jt.TEXT_BUBBLE_CLASS="text-message",jt.INTRO_CLASS="deep-chat-intro";var Ut=jt,Ht=function(){function e(){x(this,e)}return E(e,null,[{key:"hide",value:function(t){var n;(n=t.getElementsByClassName(e.CONTAINER_CLASS)[0].style).visibility||(n.visibility="hidden")}},{key:"reveal",value:function(t){t.getElementsByClassName(e.CONTAINER_CLASS)[0].style.visibility=""}},{key:"applyCustomStylesToElements",value:function(e,t,n){Object.assign(e.style,n.container),Object.assign(t.style,n.avatar)}},{key:"applyCustomStyles",value:function(t,n,r,i){var s,a,o,l;if(null!=(s=r.default)&&s.styles&&e.applyCustomStylesToElements(t,n,r.default.styles),i===Wt.USER_ROLE)null!=(a=r.user)&&a.styles&&e.applyCustomStylesToElements(t,n,r.user.styles);else{null!=(o=r.ai)&&o.styles&&e.applyCustomStylesToElements(t,n,r.ai.styles);var c=null==(l=r[i])?void 0:l.styles;c&&e.applyCustomStylesToElements(t,n,c)}}},{key:"createAvatar",value:function(t,n){var r,i,s,a,o,l=document.createElement("img");t===Wt.USER_ROLE?l.src=(null==(r=null==n?void 0:n.user)?void 0:r.src)||(null==(i=null==n?void 0:n.default)?void 0:i.src)||"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPoAAAD6CAMAAAC/MqoPAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAADNQTFRF////9vX18vLy/Pz86enp4+Li2tnZ1tbWzczM+fn57Ozs4N/f09LS0M/P5uXl7+/v3dzcwtncCAAAAAFiS0dEAIgFHUgAAAAJcEhZcwAAAEgAAABIAEbJaz4AAAZNSURBVHja7d3bdtsqEABQYABZSLH9/3+ZpnUsIcF5iOM6PfElNoMHMfPQdq3GmL0GkLhEUqLaUExnOtOZznSmM53pTGc605nOdKYznelMZzrTmV4LXSqllKyJDkob26xWq8Zae/iH0QoWTm9d1xur4WuypQJtTd+5dqn0VjcxzNO5/57mEBvdLo8Oron6aseWOjYOFkVvjQs3DmgyONMuht52EfztP+4hdu0i6LCO808/M8c1lE/fuPGej41uUzgdtoO/75N+2ELJ9I3b3//hPXbiMenm3pR/Jt4USgcLBIp4Bh10gqKVhvLo0klCxeSky96nKcj3siw6pJIL4XsoiQ7apyvMY/V3HHrSRioLopvEhSpTCn2TPEuwKYMOIX0tAxRBf/Hpa+lfSqBv9gi1FPsNfTrMAiVmIE/vJhz61FGnQxRIEYE4vfNYdN8Rp6MlHaHotHTn8ejekaZPAjEmyvQWdZFTtYTpXqCGJ0zvcek9Yfoel76nS0ffv1NMp1ca+pkgyfRCGind4L7OWWc605l+cxjsyhqy9AGbPpClc1/nvl5VX0c/3Alk6RU3+Am7shNZ+h6bvidLr7jBB+zKBrL0irOOudmIUDzTmf5gIP+iEuXtRuTVaEmY/oZLfyNMrzjryPc0gerMTdpVg0tvjJUU6bLPcGOoUv46SLL6Wi8yhLf06C7TUyekI0efRaaYqdFltkeNpPumRPSMDxgBYvSM035FrKAmH72hRW99PrpvSdEHkTEGUvSsK3yKVDkuJ92RohcZaehzzirPpOg+J92Tolfc4Cumx5xVXpGiZ34+ICX6W84qv5GiR5NPbiIpOv6BCoSvSkTX+eiaGP092zINvBOj4x8mSf9FqejvNo/cvpOji19ZbmviL0GPLsYMFzgzCor0+Bv/ePDvSJKOb9dJ5UlnbnEHiHgzv6cdTpJOWuc/u3FEucLDOL75xGtBiefrcwgoC9NDSH/jkH6pAuXmBqPQ9HSUPVdZBH1GGOrMXAQdYxcKZfxAoK+KKBKFLosoEoX+u4giUehz8jlcnAuhp78I46yDYNAd+QLR6K+pr+yvxdBTHyVDubQh0UfSxaHSd0lbvNkVRE87JGOtc+PQd2QLQ6fHhJkKsSh6yg13tO08JPprsgrrXWH0dJd2vH1MLPprot4eXoujpzrdhngiD40ek2y92lggPcnWa8qN1Yz0BFuvZhRl0uOfR0v4Ewuli/Bg4Qr3lArqGdndQ3UPO1EunXYwnelMZzrTmc50pjOd6UxnOtOZznSmM53pTGf6kuj6oedFKV0s3fX6sX1S3bsi6a4PD7+/YAqYeBw6pIB/4qEgOqxdSPbGiim4NRRCbzs3Jj0L4UfXtQXQVRfn5IdA/Bw7RZzurEV6EtdsLeGXkIPuA+K1UoVeA0l62zmN/LqfSSft9KkepmoRuvi3nd5uKNFB9zbbXEANqdr941XO0NJx2v2jdJenpf+/3bvn0ts16ph+sd6hX7dPo2+2cZzE02Ia43bzDHqr+2Evnhz74ZHU30ffbKOeng1/NPV30Ns1gYQnSP2P6e65Pfxc6h02XZqXQCjhJ6kPL6bFo4NrGvAU4UII4SE2P1vQuZkuOxckVfehisF1MjUddN/MZBN+kvq5uf0O/xa66gyNS9ktMWlz44rO1Z8C19i5FPdHzPamXn+F3hryPfxMr78+4F+kq22kO6Rf6fUQt+puuustyWv4rbG3l/duztFB96GYoe1cTBdXMr+nw9qVM6ZfxOvzezff0nXi/ZOndvrR6Zvpm0c3h6nhdb+5iS7tsIim/qXZD9+97/Jf+rpZ5BET1ayv0GUzLhEuhBBjIy/RdVPgndutIRt9nt7p5cKFEEJ3Z+jQFDZL+XnMDXxHB73gxn5s9Kc3d3/pFciFkN/QTSXHJpX5l66gDrkQoP6hL3xsPw39la4qOiV8tH78XeSbue6N9mvWa6J/ybpc1CT1Wnh5Qq9meP8IOKH3ddH7E/ri1iYux/SXDrXR4UiPdck/wUpU+FtPf6/orja6O9KL3l56LOvVxe5Ib2qjN0d6Vbex4ghWlU3bPqI90If66MNng680FNpbJijH6kCvaF3uMzQ3+IrpFerV4Y9dffQdN3im10ivbuImhD3Qq5u4HdZkua8znelMZ/pS4z9CPVKkxowNxgAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNy0wMy0yN1QxNTo0NToxNSswMDowMN1xSg4AAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTctMDMtMjdUMTU6NDU6MTUrMDA6MDCsLPKyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAABJRU5ErkJggg==":l.src=(null==(s=null==n?void 0:n[t])?void 0:s.src)||(null==(a=null==n?void 0:n.ai)?void 0:a.src)||(null==(o=null==n?void 0:n.default)?void 0:o.src)||"data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e%3csvg%20fill='%23000000'%20version='1.1'%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20viewBox='0%200%2032%2032'%20xml:space='preserve'%3e%3cpath%20d='M23,30.36H9c-2.404,0-4.36-1.956-4.36-4.36V15c0-2.404,1.956-4.36,4.36-4.36h3.659%20c0.167-1.566,1.415-2.813,2.981-2.981V5.333c-1.131-0.174-2-1.154-2-2.333c0-1.301,1.059-2.36,2.36-2.36%20c1.302,0,2.36,1.059,2.36,2.36c0,1.179-0.869,2.159-2,2.333V7.66c1.566,0.167,2.814,1.415,2.981,2.981H23%20c2.404,0,4.36,1.956,4.36,4.36v11C27.36,28.404,25.404,30.36,23,30.36z%20M9,11.36c-2.007,0-3.64,1.633-3.64,3.64v11%20c0,2.007,1.633,3.64,3.64,3.64h14c2.007,0,3.64-1.633,3.64-3.64V15c0-2.007-1.633-3.64-3.64-3.64H9z%20M13.384,10.64h5.231%20C18.439,9.354,17.334,8.36,16,8.36C14.667,8.36,13.561,9.354,13.384,10.64z%20M16,1.36c-0.904,0-1.64,0.736-1.64,1.64%20S15.096,4.64,16,4.64c0.904,0,1.64-0.736,1.64-1.64S16.904,1.36,16,1.36z%20M20,27.36h-8c-1.301,0-2.36-1.059-2.36-2.36%20s1.059-2.36,2.36-2.36h8c1.302,0,2.36,1.059,2.36,2.36S21.302,27.36,20,27.36z%20M12,23.36c-0.904,0-1.64,0.735-1.64,1.64%20s0.736,1.64,1.64,1.64h8c0.904,0,1.64-0.735,1.64-1.64s-0.735-1.64-1.64-1.64H12z%20M31,23.86h-2c-0.199,0-0.36-0.161-0.36-0.36V15%20c0-0.199,0.161-0.36,0.36-0.36h2c0.199,0,0.36,0.161,0.36,0.36v8.5C31.36,23.699,31.199,23.86,31,23.86z%20M29.36,23.14h1.279v-7.78%20H29.36V23.14z%20M3,23.86H1c-0.199,0-0.36-0.161-0.36-0.36V15c0-0.199,0.161-0.36,0.36-0.36h2c0.199,0,0.36,0.161,0.36,0.36v8.5%20C3.36,23.699,3.199,23.86,3,23.86z%20M1.36,23.14h1.28v-7.78H1.36V23.14z%20M20,20.36c-1.302,0-2.36-1.059-2.36-2.36%20s1.059-2.36,2.36-2.36s2.36,1.059,2.36,2.36C22.36,19.302,21.302,20.36,20,20.36z%20M20,16.36c-0.904,0-1.64,0.736-1.64,1.64%20s0.735,1.64,1.64,1.64s1.64-0.735,1.64-1.64S20.904,16.36,20,16.36z%20M12,20.36c-1.301,0-2.36-1.059-2.36-2.36s1.059-2.36,2.36-2.36%20s2.36,1.059,2.36,2.36C14.36,19.302,13.301,20.36,12,20.36z%20M12,16.36c-0.904,0-1.64,0.736-1.64,1.64s0.736,1.64,1.64,1.64%20s1.64-0.735,1.64-1.64S12.904,16.36,12,16.36z'/%3e%3crect%20style='fill:none;'%20width='32'%20height='32'/%3e%3c/svg%3e",l.classList.add("avatar"),l.alt="".concat(t," avatar");var c=document.createElement("div");return c.classList.add(e.CONTAINER_CLASS),c.appendChild(l),n&&e.applyCustomStyles(c,l,n,t),c}},{key:"getPosition",value:function(e,t){var n,r,i,s,a,o,l,c,u,d=null==(a=null==(s=null==t?void 0:t[e])?void 0:s.styles)?void 0:a.position;return e!==Wt.USER_ROLE&&(null!==(n=d)&&void 0!==n||(d=null==(l=null==(o=null==t?void 0:t.ai)?void 0:o.styles)?void 0:l.position)),null!==(r=d)&&void 0!==r||(d=null==(u=null==(c=null==t?void 0:t.default)?void 0:c.styles)?void 0:u.position),null!==(i=d)&&void 0!==i||(d=e===Wt.USER_ROLE?"right":"left"),d}},{key:"add",value:function(t,n,r){var i="boolean"==typeof r?void 0:r,s=e.createAvatar(n,i),a=e.getPosition(n,i);s.classList.add("left"===a?"left-item-position":"right-item-position"),t.insertAdjacentElement("left"===a?"beforebegin":"afterend",s)}}])}();Ht.CONTAINER_CLASS="avatar-container";var qt=Ht,zt=function(){function e(){x(this,e)}return E(e,null,[{key:"hide",value:function(t){var n;(n=t.getElementsByClassName(e.NAME_CLASS)[0].style).visibility||(n.visibility="hidden")}},{key:"reveal",value:function(t){t.getElementsByClassName(e.NAME_CLASS)[0].style.visibility=""}},{key:"getPosition",value:function(e,t){var n,r,i,s,a,o,l=null==(s=null==t?void 0:t[e])?void 0:s.position;return e!==Wt.USER_ROLE&&(null!==(n=l)&&void 0!==n||(l=null==(a=null==t?void 0:t.ai)?void 0:a.position)),null!==(r=l)&&void 0!==r||(l=null==(o=null==t?void 0:t.default)?void 0:o.position),null!==(i=l)&&void 0!==i||(l=e===Wt.USER_ROLE?"right":"left"),l}},{key:"applyStyle",value:function(e,t,n){var r,i,s,a;Object.assign(e.style,null==(r=n.default)?void 0:r.style),t===Wt.USER_ROLE?Object.assign(e.style,null==(i=n.user)?void 0:i.style):(Object.assign(e.style,null==(s=n.ai)?void 0:s.style),Object.assign(e.style,null==(a=n[t])?void 0:a.style))}},{key:"getNameText",value:function(e,t){var n,r,i,s,a,o;return e===Wt.USER_ROLE?(null==(n=t.user)?void 0:n.text)||(null==(r=t.default)?void 0:r.text)||"User":e===Wt.AI_ROLE?(null==(i=t.ai)?void 0:i.text)||(null==(s=t.default)?void 0:s.text)||"AI":(null==(a=t[e])?void 0:a.text)||(null==(o=t.default)?void 0:o.text)||e}},{key:"createName",value:function(t,n){var r=document.createElement("div");return r.classList.add(e.NAME_CLASS),r.textContent=e.getNameText(t,n),e.applyStyle(r,t,n),r}},{key:"add",value:function(t,n,r){var i="boolean"==typeof r?{}:r,s=e.createName(n,i),a=e.getPosition(n,i);s.classList.add("left"===a?"left-item-position":"right-item-position"),t.insertAdjacentElement("left"===a?"beforebegin":"afterend",s)}}])}();zt.NAME_CLASS="name";var Vt=zt,Gt=function(){function e(){x(this,e)}return E(e,null,[{key:"getLastElementsByClass",value:function(e,t,n){for(var r,i=function(){var r=e[s];if(r.bubbleElement.classList.contains(t[0])&&!t.slice(1).find((function(e){return!r.bubbleElement.classList.contains(e)}))){if(!n)return{v:r};if(!n.find((function(e){return r.bubbleElement.classList.contains(e)})))return{v:r}}},s=e.length-1;s>=0;s-=1)if(r=i())return r.v}},{key:"getLastMessage",value:function(e,t,n){for(var r=e.length-1;r>=0;r-=1)if(e[r][0].role===t){if(!n)return e[r][0];if(e[r][0][n])return e[r][0]}}},{key:"getLastTextToElement",value:function(e,t){for(var n=e.length-1;n>=0;n-=1)if(e[n][0]===t)return e[n]}},{key:"overwriteMessage",value:function(t,n,r,i,s,a){var o=e.getLastElementsByClass(n,[e.getRoleClass(i),a],[X.BUBBLE_CLASS]),l=e.getLastMessage(t,i,s);return l&&(l[s]=r),o}},{key:"getRoleClass",value:function(e){return"".concat(e,"-message")}},{key:"fillEmptyMessageElement",value:function(t,n){0===n.trim().length&&(t.classList.add(e.EMPTY_MESSAGE_CLASS),t.innerHTML='
    .
    ')}},{key:"unfillEmptyMessageElement",value:function(t,n){t.classList.contains(e.EMPTY_MESSAGE_CLASS)&&n.trim().length>0&&t.replaceChildren()}},{key:"getLastMessageBubbleElement",value:function(t){var n,r,i;return Array.from((null==(i=null==(r=null==(n=e.getLastMessageElement(t))?void 0:n.children)?void 0:r[0])?void 0:i.children)||[]).find((function(e){return e.classList.contains("message-bubble")}))}},{key:"getLastMessageElement",value:function(e){return e.children[e.children.length-1]}},{key:"addRoleElements",value:function(e,t,n,r){n&&qt.add(e,t,n),r&&Vt.add(e,t,r)}},{key:"hideRoleElements",value:function(e,t,n){var r=e[e.length-1].innerContainer;t&&qt.hide(r),n&&Vt.hide(r)}},{key:"revealRoleElements",value:function(e,t,n){t&&qt.reveal(e),n&&Vt.reveal(e)}},{key:"updateRefArr",value:function(e,t,n){n?e.unshift(t):e.push(t)}},{key:"buildRoleContainerClass",value:function(e){return"deep-chat-".concat(e,"-container")}},{key:"addNewPositionClasses",value:function(t,n){var r;t.outerContainer.classList.remove(e.POSITION_TOP_MESSAGE_CLASS,e.POSITION_MIDDLE_MESSAGE_CLASS,e.POSITION_BOTTOM_MESSAGE_CLASS),(r=t.outerContainer.classList).add.apply(r,m(n))}},{key:"getNumberOfElements",value:function(e){var t=0;return void 0!==e.text&&(t+=1),void 0!==e.html&&(t+=1),e.files&&(t+=e.files.length),t}},{key:"filterdMessageElements",value:function(e,t){return e.filter((function(e){return e.bubbleElement.classList.contains(t)}))}},{key:"findMessageElements",value:function(e,t){return e.find((function(e){return e.bubbleElement.classList.contains(t)}))}},{key:"generateMessageBodyElements",value:function(t,n){var r={};return t.text&&(r.text=e.findMessageElements(n,Ut.TEXT_BUBBLE_CLASS)),t.html&&(r.html=e.findMessageElements(n,le.HTML_BUBBLE_CLASS)),t.files&&(r.files=e.filterdMessageElements(n,$.FILE_BUBBLE_CLASS)),r}},{key:"generateMessageBody",value:function(t,n){var r=e.getNumberOfElements(t),i=n.slice(n.length-r);return e.generateMessageBodyElements(t,i)}},{key:"classifyMessages",value:function(t,n){var r=e.buildRoleContainerClass(t);n.forEach((function(t,i){var s=t.outerContainer.classList.contains(r),a=n[i-1],o=n[i+1],l=null==a?void 0:a.outerContainer.classList.contains(r),c=null==o?void 0:o.outerContainer.classList.contains(r);s&&(!l&&c?e.addNewPositionClasses(t,[e.POSITION_TOP_MESSAGE_CLASS]):l&&c?e.addNewPositionClasses(t,[e.POSITION_MIDDLE_MESSAGE_CLASS]):l&&!c?e.addNewPositionClasses(t,[e.POSITION_BOTTOM_MESSAGE_CLASS]):!l&&!c&&e.addNewPositionClasses(t,[e.POSITION_TOP_MESSAGE_CLASS,e.POSITION_BOTTOM_MESSAGE_CLASS]))}))}}])}();Gt.AI_ROLE="ai",Gt.USER_ROLE="user",Gt.EMPTY_MESSAGE_CLASS="empty-message",Gt.POSITION_TOP_MESSAGE_CLASS="deep-chat-top-message",Gt.POSITION_MIDDLE_MESSAGE_CLASS="deep-chat-middle-message",Gt.POSITION_BOTTOM_MESSAGE_CLASS="deep-chat-bottom-message";var Wt=Gt,Kt=function(){function e(t){x(this,e),this._fileAdded=!1,this._streamType="",this._hasStreamEnded=!1,this._messages=t}return E(e,[{key:"upsertStreamedMessage",value:function(e){var t;if(!this._hasStreamEnded){if(void 0===(null==e?void 0:e.text)&&void 0===(null==e?void 0:e.html))return console.error(G.INVALID_STREAM_EVENT);var n=(null==e?void 0:e.text)||(null==e?void 0:e.html)||"",r=K.isScrollbarAtBottomOfElement(this._messages.elementRef),i=void 0!==(null==e?void 0:e.text)?"text":"html";if(this._elements||this._message){if(this._streamType!==i)return console.error(G.INVALID_STREAM_EVENT_MIX);this.updateBasedOnType(n,i,null==(t=this._elements)?void 0:t.bubbleElement,null==e?void 0:e.overwrite)}else this.setInitialState(i,n,null==e?void 0:e.role);r&&K.scrollToBottom(this._messages.elementRef)}}},{key:"setInitialState",value:function(t,n,r){var i;this._streamType=t,null!==(i=r)&&void 0!==i||(r=Wt.AI_ROLE),this._elements="text"===t?this._messages.addNewTextMessage(n,r):le.add(this._messages,n,r,this._messages.messageElementRefs),this._elements.bubbleElement.classList.add(e.MESSAGE_CLASS),this._activeMessageRole=r,this._message=k({role:this._activeMessageRole},t,n),this._messages.messageToElements.push([this._message,k({},t,this._elements)])}},{key:"updateBasedOnType",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];Wt.unfillEmptyMessageElement(n,e),("text"===t?this.updateText:this.updateHTML).bind(this)(e,n,r)}},{key:"updateText",value:function(e,t,n){this._message&&(this._message.text=n?e:this._message.text+e,this._messages.renderText(t,this._message.text))}},{key:"updateHTML",value:function(e,t,n){if(this._message)if(n)this._message.html=e,t.innerHTML=e;else{var r=document.createElement("span");r.innerHTML=e,t.appendChild(r),this._message.html=(null==t?void 0:t.innerHTML)||""}}},{key:"finaliseStreamedMessage",value:function(){var t;if(!this._endStreamAfterOperation&&this._message&&(!this._fileAdded||this._elements)){if(!this._elements)throw Error(G.NO_VALID_STREAM_EVENTS_SENT);null!=(t=this._elements.bubbleElement)&&t.classList.contains(e.MESSAGE_CLASS)&&("text"===this._streamType?this._messages.textToSpeech&&Y.speak(this._message.text||"",this._messages.textToSpeech):"html"===this._streamType&&this._elements&&se.apply(this._messages,this._elements.outerContainer),this._elements.bubbleElement.classList.remove(e.MESSAGE_CLASS),this._message&&this._messages.sendClientUpdate(Ut.createMessageContent(this._message),!1),this._hasStreamEnded=!0)}}},{key:"markFileAdded",value:function(){this._fileAdded=!0}},{key:"newMessage",value:function(){this.finaliseStreamedMessage(),this._elements=void 0,delete this._message,this._fileAdded=!1,this._hasStreamEnded=!1,this._activeMessageRole=void 0}},{key:"endStreamAfterFileDownloaded",value:(t=f(h().mark((function e(t,n){var r,i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._endStreamAfterOperation=!0,e.next=3,n();case 3:i=e.sent,s=i.text,a=i.files,s&&this.updateBasedOnType(s,"text",null==(r=this._elements)?void 0:r.bubbleElement,!0),this._endStreamAfterOperation=!1,this.finaliseStreamedMessage(),a&&t.addNewMessage({files:a});case 7:case"end":return e.stop()}}),e,this)}))),function(e,n){return t.apply(this,arguments)})}]);var t}();Kt.MESSAGE_CLASS="streamed-message";var Jt=Kt,Yt=function(){function e(){x(this,e)}return E(e,null,[{key:"tempRemoveContentHeader",value:(n=f(h().mark((function t(n,r,i){var s,a;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(null!=n&&n.headers){t.next=2;break}throw new Error("Request settings have not been set up");case 2:return s=n.headers[e.CONTENT_TYPE],delete n.headers[e.CONTENT_TYPE],t.prev=4,t.next=7,r(i);case 7:a=t.sent,t.next=13;break;case 10:throw t.prev=10,t.t0=t.catch(4),n.headers[e.CONTENT_TYPE]=s,t.t0;case 13:return t.abrupt("return",(n.headers[e.CONTENT_TYPE]=s,a));case 14:case"end":return t.stop()}}),t,null,[[4,10]])}))),function(e,t,r){return n.apply(this,arguments)})},{key:"displayError",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"Service error, please try again.";if(console.error(t),"object"==_(t))return t instanceof Error?e.addNewErrorMessage("service",t.message):Array.isArray(t)||"string"==typeof t.error?e.addNewErrorMessage("service",t):0===Object.keys(t).length?e.addNewErrorMessage("service",n):e.addNewErrorMessage("service",JSON.stringify(t));e.addNewErrorMessage("service",t)}},{key:"fetch",value:function(e){function t(t,n,r,i){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}((function(e,t,n,r){var i,s,a={method:(null==(i=e.connectSettings)?void 0:i.method)||"POST",headers:t};return"GET"!==a.method&&(a.body=n?JSON.stringify(r):r),e.connectSettings.credentials&&(a.credentials=e.connectSettings.credentials),fetch((null==(s=e.connectSettings)?void 0:s.url)||e.url||"",a)}))},{key:"processResponseByType",value:function(e){var t=e.headers.get("content-type");return null!=t&&t.includes("application/json")?e.json():null!=t&&t.includes("text/plain")||!t?e:e.blob()}},{key:"processRequestInterceptor",value:(t=f(h().mark((function e(t,n){var r,i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==(r=t.requestInterceptor)?void 0:r.call(t,n);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=n;case 5:return i=e.t0,s=i,a=i,e.abrupt("return",{body:s.body,headers:s.headers,error:a.error});case 9:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"validateResponseFormat",value:function(e){return e&&"object"==_(e)&&("string"==typeof e.error||"string"==typeof e.text||"string"==typeof e.html||Array.isArray(e.files))}},{key:"onInterceptorError",value:function(e,t,n){e.addNewErrorMessage("service",t),null==n||n()}}]);var t,n}();Yt.CONTENT_TYPE="Content-Type";var Zt=Yt;function Xt(e,t){return Qt.apply(this,arguments)}function Qt(){return(Qt=f(h().mark((function e(t,n){var r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.getReader();case 1:return e.next=3,r.read();case 3:if((i=e.sent).done){e.next=7;break}n(i.value);case 5:e.next=1;break;case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function $t(e){var t,n,r,i=!1;return function(s){void 0===t?(t=s,n=0,r=-1):t=function(e,t){var n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n}(t,s);for(var a=t.length,o=0;n0){var o=i.decode(s.subarray(0,a)),l=a+(32===s[a+1]?2:1),c=i.decode(s.subarray(l));switch(o){case"data":r.data=r.data?r.data+"\n"+c:c;break;case"event":r.event=c;break;case"id":e(r.id=c);break;case"retry":var u=parseInt(c,10);isNaN(u)||t(r.retry=u)}}}}var tn="text/event-stream",nn="last-event-id";function rn(e,t){var n=t.signal,r=t.headers,i=t.onopen,s=t.onmessage,a=t.onclose,o=t.onerror,l=t.openWhenHidden,c=t.fetch,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i3&&void 0!==C[3])||C[3],a=C.length>4&&void 0!==C[4]&&C[4],m={body:r,headers:null==(o=n.connectSettings)?void 0:o.headers},t.next=5,Zt.processRequestInterceptor(n.deepChat,m);case 5:if(v=t.sent,g=v.body,y=v.headers,b=v.error,k=n.streamHandlers,_=k.onOpen,x=k.onClose,S=k.abortStream,!b){t.next=15;break}return t.abrupt("return",Zt.onInterceptorError(i,b,x));case 15:if(null==(l=n.connectSettings)||!l.handler){t.next=17;break}return t.abrupt("return",un.stream(n,g,i));case 17:if((null==(c=n.connectSettings)?void 0:c.url)!==ln.URL){t.next=19;break}return t.abrupt("return",ln.requestStream(i,n.streamHandlers));case 19:return E=new Jt(i),w=Zt.fetch.bind(this,n,y,s),t.abrupt("return",(rn((null==(u=n.connectSettings)?void 0:u.url)||n.url||"",{method:(null==(d=n.connectSettings)?void 0:d.method)||"POST",headers:y,credentials:null==(p=n.connectSettings)?void 0:p.credentials,body:s?JSON.stringify(g):g,openWhenHidden:!0,onopen:function(e){return f(h().mark((function t(){return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!e.ok){t.next=2;break}return t.abrupt("return",_());case 2:return t.next=4,Zt.processResponseByType(e);case 4:throw t.sent;case 5:case"end":return t.stop()}}),t)})))()},onmessage:function(t){return f(h().mark((function r(){var s,a,o,l,c;return h().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:if(JSON.stringify(t.data)===JSON.stringify("[DONE]")){r.next=9;break}try{l=JSON.parse(t.data)}catch(u){l={}}return r.next=4,null==(a=(s=n.deepChat).responseInterceptor)?void 0:a.call(s,l);case 4:if(r.t0=r.sent,r.t0){r.next=7;break}r.t0=l;case 7:c=r.t0,null==(o=n.extractResultData)||o.call(n,c,w,g).then((function(t){n.asyncCallInProgress&&t&&""!==t.text?(e.simulate(i,n.streamHandlers,t),x(),n.asyncCallInProgress=!1):e.upsertWFiles(i,E.upsertStreamedMessage.bind(E),E,t)})).catch((function(e){return Zt.displayError(i,e)}));case 9:case"end":return r.stop()}}),r)})))()},onerror:function(e){throw x(),e},onclose:function(){if(!n.asyncCallInProgress)try{E.finaliseStreamedMessage(),x()}catch(e){if(!a)throw e}},signal:S.signal}).catch((function(e){var t;i.isLastMessageError()||null==(t=n.extractResultData)||t.call(n,e).then((function(){Zt.displayError(i,e)})).catch((function(e){Zt.displayError(i,e)}))})),E));case 21:case"end":return t.stop()}}),t,this)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"simulate",value:function(t,n,r){var i=n;if(r.files&&t.addNewMessage(b({sendUpdate:!1,ignoreText:!0},r),!1),r.text){n.onOpen();var s=r.text.split("");e.populateMessages(s,new Jt(t),i,"text")}if(r.html){n.onOpen();var a=se.splitHTML(r.html);0===a.length&&(a=r.html.split("")),e.populateMessages(a,new Jt(t),i,"html")}}},{key:"populateMessages",value:function(t,n,r,i){var s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,a=t[s];if(a){n.upsertStreamedMessage(k({},i,a));var o=setTimeout((function(){e.populateMessages(t,n,r,i,s+1)}),r.simulationInterim||6);r.abortStream.abort=function(){e.abort(o,n,r.onClose)}}else n.finaliseStreamedMessage(),r.onClose()}},{key:"isSimulation",value:function(e){return"object"==_(e)&&!!e.simulation}},{key:"isSimulatable",value:function(t,n){return e.isSimulation(t)&&n&&(n.text||n.html)}},{key:"abort",value:function(e,t,n){clearTimeout(e),t.finaliseStreamedMessage(),n()}},{key:"upsertWFiles",value:function(e,t,n,r){if(null!=r&&r.text||null!=r&&r.html){var i,s=t(r);null!==(i=n)&&void 0!==i||(n=s||void 0)}null!=r&&r.files&&(e.addNewMessage({files:r.files}),null==n||n.markFileAdded())}}]);var t}(),on=function(){function e(){x(this,e)}return E(e,null,[{key:"generateResponse",value:function(e){var t=e[e.length-1][0];if(t.files&&t.files.length>0){if(t.files.length>1)return"These are interesting files!";var n=t.files[0];return n.src&&n.src.startsWith("data:image/gif")?"That is a nice gif!":"image"===n.type?"That is a nice image!":"audio"===n.type?"I like the sound of that!":"That is an interesting file!"}if(t.text){if("?"===t.text.charAt(t.text.length-1))return"I'm sorry but I can't answer that question...";if(t.text.includes("updog"))return"What's updog?"}return"Hi there! This is a demo response!"}},{key:"getCustomResponse",value:function(e,t){return"function"==typeof e?e(t):e}},{key:"getResponse",value:function(t){var n=t.customDemoResponse,r=t.messageToElements;return n?e.getCustomResponse(n,r[r.length-1][0]):{text:e.generateResponse(r)}}},{key:"request",value:function(t,n){var r=e.getResponse(n);setTimeout(f(h().mark((function e(){var i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==(s=(i=t.deepChat).responseInterceptor)?void 0:s.call(i,r);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=r;case 5:(a=e.t0).error?(n.addNewErrorMessage("service",a.error),t.completionsHandlers.onFinish()):an.isSimulatable(t.stream,a)?an.simulate(n,t.streamHandlers,a):(n.addNewMessage(a),t.completionsHandlers.onFinish());case 7:case"end":return e.stop()}}),e)}))),400)}},{key:"requestStream",value:function(t,n){setTimeout((function(){var r=e.getResponse(t);an.simulate(t,n,r)}),400)}}])}();on.URL="deep-chat-demo";var ln=on,cn=function(){function e(){x(this,e)}return E(e,null,[{key:"setup",value:function(e){e.connectSettings.url!==ln.URL&&(e.permittedErrorPrefixes=["Connection error","Error in server message"],e.websocket="pending")}},{key:"isElementPresentInDOM",value:function(e){return e.getRootNode({composed:!0})instanceof Document}},{key:"createConnection",value:function(t,n){if(e.isElementPresentInDOM(t.deepChat)){var r=t.connectSettings.websocket;if(r){if(t.connectSettings.handler)return un.websocket(t,n);try{var i="boolean"!=typeof r?r:void 0,s=new WebSocket(t.connectSettings.url||"",i);t.websocket=s,t.websocket.onopen=function(){var r,i;n.removeError(),t.websocket&&"object"==_(t.websocket)&&e.assignListeners(t,s,n),null==(i=(r=t.deepChat)._validationHandler)||i.call(r)},t.websocket.onerror=function(r){console.error(r),e.retryConnection(t,n)}}catch(i){console.error(i),e.retryConnection(t,n)}}}}},{key:"retryConnection",value:function(t,n){var r,i;null==(i=(r=t.deepChat)._validationHandler)||i.call(r),e.isElementPresentInDOM(t.deepChat)&&(t.websocket="pending",n.isLastMessageError()||n.addNewErrorMessage("service","Connection error"),setTimeout((function(){e.createConnection(t,n)}),5e3))}},{key:"assignListeners",value:function(t,n,r){var i=this,s={};n.onmessage=function(){var n=f(h().mark((function n(a){var o,l,c,u,d,p,f;return h().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(!t.extractResultData){n.next=20;break}return n.prev=1,c=JSON.parse(a.data),n.next=5,null==(l=(o=t.deepChat).responseInterceptor)?void 0:l.call(o,c);case 5:if(n.t0=n.sent,n.t0){n.next=8;break}n.t0=c;case 8:return u=n.t0,n.next=11,t.extractResultData(u);case 11:if((d=n.sent)&&"object"==_(d)){n.next=14;break}throw Error(G.INVALID_RESPONSE(c,"server",!!t.deepChat.responseInterceptor,u));case 14:an.isSimulation(t.stream)?(p=e.stream.bind(i,t,r,s),f=s[c.role||Wt.AI_ROLE],an.upsertWFiles(r,p,f,d)):r.addNewMessage(d),n.next=20;break;case 17:n.prev=17,n.t1=n.catch(1),Zt.displayError(r,n.t1,"Error in server message");case 20:case"end":return n.stop()}}),n,null,[[1,17]])})));return function(e){return n.apply(this,arguments)}}(),n.onclose=function(){console.error("Connection closed"),r.isLastMessageError()||r.addNewErrorMessage("service","Connection error"),t.stream&&t.streamHandlers.abortStream.abort(),e.createConnection(t,r)}}},{key:"sendWebsocket",value:(t=f(h().mark((function t(n,r,i){var s,a,o,l,c,u,d,p,f,m=arguments;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(s=!(m.length>3&&void 0!==m[3])||m[3],(l=n.websocket)&&"pending"!==l){t.next=4;break}return t.abrupt("return");case 4:return c={body:r,headers:null==(a=n.connectSettings)?void 0:a.headers},t.next=7,Zt.processRequestInterceptor(n.deepChat,c);case 7:if(u=t.sent,d=u.body,!(p=u.error)){t.next=12;break}return t.abrupt("return",i.addNewErrorMessage("service",p));case 12:if(e.isWebSocket(l)){t.next=14;break}return t.abrupt("return",l.newUserMessage.listener(d));case 14:if(f=s?JSON.stringify(d):d,(null==(o=n.connectSettings)?void 0:o.url)!==ln.URL){t.next=17;break}return t.abrupt("return",ln.request(n,i));case 17:void 0===l.readyState||l.readyState!==l.OPEN?(console.error("Connection is not open"),i.isLastMessageError()||i.addNewErrorMessage("service","Connection error")):(l.send(JSON.stringify(f)),n.completionsHandlers.onFinish());case 18:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"canSendMessage",value:function(t){return!t||"pending"!==t&&(e.isWebSocket(t)?void 0!==t.readyState&&t.readyState===t.OPEN:t.isOpen)}},{key:"isWebSocket",value:function(e){return void 0!==e.send}},{key:"stream",value:function(e,t,n,r){if(r){var i=e.stream.simulation;if("string"==typeof i){var s,a=r.role||Wt.AI_ROLE,o=n[a];r.text===i||r.html===i?(null==o||o.finaliseStreamedMessage(),delete n[a]):(null!==(s=n[a])&&void 0!==s||(n[a]=new Jt(t)),n[a].upsertStreamedMessage(r))}else an.simulate(t,e.streamHandlers,r)}}}]);var t}(),un=function(){function e(){x(this,e)}return E(e,null,[{key:"request",value:(t=f(h().mark((function t(n,r,i){var s,a,o,l,c;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:o=!0,l=function(){var e=f(h().mark((function e(t){var r,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}return e.abrupt("return");case 2:return o=!1,e.next=5,null==(s=(r=n.deepChat).responseInterceptor)?void 0:s.call(r,t);case 5:if(e.t0=e.sent,e.t0){e.next=8;break}e.t0=t;case 8:a=e.t0,Zt.validateResponseFormat(a)?"string"==typeof a.error?(console.error(a.error),i.addNewErrorMessage("service",a.error),n.completionsHandlers.onFinish()):an.isSimulatable(n.stream,a)?an.simulate(i,n.streamHandlers,a):(i.addNewMessage(a),n.completionsHandlers.onFinish()):(console.error(G.INVALID_RESPONSE(t,"server",!!n.deepChat.responseInterceptor,a)),i.addNewErrorMessage("service","Error in server message"),n.completionsHandlers.onFinish());case 10:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),c=e.generateOptionalSignals(),null==(a=(s=n.connectSettings).handler)||a.call(s,r,b(b({},c),{},{onResponse:l}));case 3:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"attemptToFinaliseStream",value:function(e,t){try{var n=t.messageElementRefs[t.messageElementRefs.length-1];Ut.isLoadingMessage(n)?t.removeLastMessage():e.finaliseStreamedMessage()}catch(n){console.error(n),t.addNewErrorMessage("service",n)}}},{key:"stream",value:function(t,n,r){var i,s,a=!0,o=!1,l=new Jt(r),c=function(){var e=f(h().mark((function e(n){var i,s,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,null==(s=(i=t.deepChat).responseInterceptor)?void 0:s.call(i,n);case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=n;case 7:o=e.t0,Zt.validateResponseFormat(o)?o.error?(console.error(o.error),l.finaliseStreamedMessage(),r.addNewErrorMessage("service",o.error),t.streamHandlers.onClose(),a=!1):an.upsertWFiles(r,l.upsertStreamedMessage.bind(l),l,o):console.error(G.INVALID_RESPONSE(n,"server",!!t.deepChat.responseInterceptor,o));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();t.streamHandlers.abortStream.abort=function(){e.attemptToFinaliseStream(l,r),t.streamHandlers.onClose(),a=!1};var u=e.generateOptionalSignals();null==(s=(i=t.connectSettings).handler)||s.call(i,n,b(b({},u),{},{onOpen:function(){o||!a||(t.streamHandlers.onOpen(),o=!0)},onResponse:c,onClose:function(){a&&(e.attemptToFinaliseStream(l,r),t.streamHandlers.onClose(),a=!1)},stopClicked:t.streamHandlers.stopClicked}))}},{key:"websocket",value:function(t,n){var r,i,s=this,a={isOpen:!1,newUserMessage:{listener:function(){}},roleToStream:{}};t.websocket=a;var o=function(){var e=f(h().mark((function e(r){var i,o,l,c,u;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a.isOpen){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,null==(o=(i=t.deepChat).responseInterceptor)?void 0:o.call(i,r);case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=r;case 7:l=e.t0,Zt.validateResponseFormat(l)?"string"==typeof l.error?(console.error(l.error),n.isLastMessageError()||n.addNewErrorMessage("service",l.error)):an.isSimulation(t.stream)?(c=cn.stream.bind(s,t,n,a.roleToStream),u=a.roleToStream[r.role||Wt.AI_ROLE],an.upsertWFiles(n,c,u,r)):n.addNewMessage(l):(console.error(G.INVALID_RESPONSE(r,"server",!!t.deepChat.responseInterceptor,l)),n.addNewErrorMessage("service","Error in server message"));case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),l=e.generateOptionalSignals();null==(i=(r=t.connectSettings).handler)||i.call(r,void 0,b(b({},l),{},{onOpen:function(){n.removeError(),a.isOpen=!0},onResponse:o,onClose:function(){a.isOpen=!1},newUserMessage:a.newUserMessage}))}},{key:"generateOptionalSignals",value:function(){return{onClose:function(){},onOpen:function(){},stopClicked:{listener:function(){}},newUserMessage:{listener:function(){}}}}}]);var t}(),dn=function(){function e(){x(this,e)}return E(e,null,[{key:"request",value:(n=f(h().mark((function e(t,n,r){var i,s,a,o,l,c,u,d,p,m,v,g,y=arguments;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!(y.length>3&&void 0!==y[3])||y[3],l={body:n,headers:null==(s=t.connectSettings)?void 0:s.headers},e.next=4,Zt.processRequestInterceptor(t.deepChat,l);case 4:if(c=e.sent,u=c.body,d=c.headers,p=c.error,m=t.completionsHandlers.onFinish,!p){e.next=11;break}return e.abrupt("return",Zt.onInterceptorError(r,p,m));case 11:if(null==(a=t.connectSettings)||!a.handler){e.next=13;break}return e.abrupt("return",un.request(t,u,r));case 13:if((null==(o=t.connectSettings)?void 0:o.url)!==ln.URL){e.next=15;break}return e.abrupt("return",ln.request(t,r));case 15:v=!0,(g=Zt.fetch.bind(this,t,d,i))(u).then((function(e){return v=!!e.ok,e})).then((function(e){return Zt.processResponseByType(e)})).then(function(){var e=f(h().mark((function e(n){var i,s,a,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.extractResultData){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,null==(s=(i=t.deepChat).responseInterceptor)?void 0:s.call(i,n);case 4:if(e.t0=e.sent,e.t0){e.next=7;break}e.t0=n;case 7:return a=e.t0,e.next=10,t.extractResultData(a,g,u);case 10:if(o=e.sent,v){e.next=13;break}throw n;case 13:if(o&&"object"==_(o)){e.next=15;break}throw Error(G.INVALID_RESPONSE(n,"response",!!t.deepChat.responseInterceptor,a));case 15:o.makingAnotherRequest||(an.isSimulatable(t.stream,o)?an.simulate(r,t.streamHandlers,o):(r.addNewMessage(o),m()));case 16:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){Zt.displayError(r,e),m()}));case 18:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"executePollRequest",value:function(t,n,r,i){var s=t.completionsHandlers.onFinish;fetch(n,r).then((function(e){return e.json()})).then(function(){var a=f(h().mark((function a(o){var l,c,u;return h().wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(t.extractPollResultData){a.next=2;break}return a.abrupt("return");case 2:return a.t0=t,a.next=5,null==(c=(l=t.deepChat).responseInterceptor)?void 0:c.call(l,o);case 5:if(a.t1=a.sent,a.t1){a.next=8;break}a.t1=o;case 8:return a.t2=a.t1,a.next=11,a.t0.extractPollResultData.call(a.t0,a.t2);case 11:(u=a.sent).timeoutMS?setTimeout((function(){e.executePollRequest(t,n,r,i)}),u.timeoutMS):an.isSimulatable(t.stream,u)?an.simulate(i,t.streamHandlers,u):(i.addNewMessage(u),s());case 13:case"end":return a.stop()}}),a)})));return function(e){return a.apply(this,arguments)}}()).catch((function(e){Zt.displayError(i,e),s()}))}},{key:"poll",value:(t=f(h().mark((function t(n,r,i){var s,a,o,l,c,u,d,p,f,m,v,g,y,b=arguments;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=!(b.length>3&&void 0!==b[3])||b[3],c={body:r,headers:null==(a=n.connectSettings)?void 0:a.headers},t.next=4,Zt.processRequestInterceptor(n.deepChat,c);case 4:if(u=t.sent,d=u.body,p=u.headers,!(f=u.error)){t.next=10;break}return t.abrupt("return",Zt.onInterceptorError(i,f));case 10:m=(null==(o=n.connectSettings)?void 0:o.url)||n.url||"",v=(null==(l=n.connectSettings)?void 0:l.method)||"POST",g=s?JSON.stringify(d):d,y={method:v,body:g,headers:p},n.connectSettings.credentials&&(y.credentials=n.connectSettings.credentials),e.executePollRequest(n,m,y,i);case 12:case"end":return t.stop()}}),t)}))),function(e,n,r){return t.apply(this,arguments)})},{key:"verifyKey",value:function(e,t,n,r,i,s,a,o,l){if(""===e)return s(G.INVALID_KEY);a(),fetch(t,{method:r,headers:n,body:l||null}).then((function(e){return Zt.processResponseByType(e)})).then((function(t){o(t,e,i,s)})).catch((function(e){s(G.CONNECTION_FAILED),console.error(e)}))}}]);var t,n}(),hn=function(){function e(t,n,r){x(this,e),this._isLoading=!1,this._isPaginationComplete=!1,this._index=0,this._messages=n,r.fetchHistory&&this.fetchHistory(r.fetchHistory),t.loadHistory&&this.setupLoadHistoryOnScroll(t.loadHistory),this.setupInitialHistory(t)}return E(e,[{key:"fetchHistory",value:(i=f(h().mark((function e(t){var n,r,i=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=Ft.addMessage(this._messages),e.next=3,t();case 3:r=e.sent,this._messages.removeMessage(n),r.forEach((function(e){return i._messages.addAnyMessage(e,!0)})),setTimeout((function(){return K.scrollToBottom(i._messages.elementRef)}),0);case 5:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"processLoadedHistory",value:function(e){var t,n=this,r=this._messages,i=r.messageElementRefs,s=r.messageToElements,a=r.elementRef,o=null==(t=i.find((function(e){return!e.outerContainer.classList.contains(Ut.INTRO_CLASS)})))?void 0:t.outerContainer,l=a.scrollTop;null==e||e.reverse().map((function(e){var t=n._messages.addAnyMessage(b(b({},e),{},{sendUpdate:!0}),!0,!0);if(t){var r=Wt.generateMessageBody(t,i);s.unshift([t,r])}return t})).filter((function(e){return!!e})).reverse().forEach((function(e){return n._messages.sendClientUpdate(e,!0)})),o&&(a.scrollTop=l+o.offsetTop-40)}},{key:"populateMessages",value:function(e,t){this._messages.removeMessage(e),this._isPaginationComplete=t.findIndex((function(e){return!e}))<0;var n=t.filter((function(e){return!!e}));this.processLoadedHistory(n)}},{key:"setupLoadHistoryOnScroll",value:(r=f(h().mark((function t(n){var r=this;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:this._messages.elementRef.onscroll=f(h().mark((function t(){var i,s;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r._isLoading||r._isPaginationComplete||0!==r._messages.elementRef.scrollTop){t.next=13;break}return r._isLoading=!0,i=Ft.addMessage(r._messages,!1),t.prev=3,t.next=6,n(r._index++);case 6:s=t.sent,r.populateMessages(i,s),r._isLoading=!1,t.next=13;break;case 10:t.prev=10,t.t0=t.catch(3),r._messages.removeMessage(i),r._isPaginationComplete=!0,r._messages.addNewErrorMessage("service",e.FAILED_ERROR_MESSAGE,!0),console.error(t.t0);case 13:case"end":return t.stop()}}),t,null,[[3,10]])})));case 1:case"end":return t.stop()}}),t,this)}))),function(e){return r.apply(this,arguments)})},{key:"populateInitialHistory",value:function(e){var t=this;e.forEach((function(e){ee.processHistoryFile(e),t._messages.addNewMessage(e,!0)}))}},{key:"loadInitialHistory",value:(n=f(h().mark((function t(n){var r,i,s,a=this;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this._isLoading=!0,r=Ft.addMessage(this._messages),t.prev=2,t.next=5,n(this._index++);case 5:i=t.sent,s=this._messages.elementRef.scrollTop,this.populateMessages(r,i),0===s&&setTimeout((function(){return K.scrollToBottom(a._messages.elementRef)}),0),t.next=13;break;case 10:t.prev=10,t.t0=t.catch(2),this._messages.removeMessage(r),this._isPaginationComplete=!0,this._messages.addNewErrorMessage("service",e.FAILED_ERROR_MESSAGE,!0),console.error(t.t0);case 13:this._isLoading=!1;case 14:case"end":return t.stop()}}),t,this,[[2,10]])}))),function(e){return n.apply(this,arguments)})},{key:"setupInitialHistory",value:(t=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.loadHistory&&this.loadInitialHistory(t.loadHistory),(n=t.history||ee.processHistory(t))&&(this.populateInitialHistory(n),this._index+=1);case 3:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)})}],[{key:"addErrorPrefix",value:function(t){var n;null!==(n=t.permittedErrorPrefixes)&&void 0!==n||(t.permittedErrorPrefixes=[]),t.permittedErrorPrefixes.push(e.FAILED_ERROR_MESSAGE)}}]);var t,n,r,i}();hn.FAILED_ERROR_MESSAGE="Failed to load history";var pn=hn,fn=function(){function e(){x(this,e)}return E(e,null,[{key:"getCharacterLimitMessages",value:function(e,t){var n;if(-1===t)return e;for(var r=0,i=e.length-1;i>=0;i-=1){var s=null==(n=e[i])?void 0:n.text;if(void 0!==s&&(r+=s.length)>t){e[i].text=s.substring(0,s.length-(r-t));break}}return e.slice(Math.max(i,0))}},{key:"getMaxMessages",value:function(e,t){return e.slice(Math.max(e.length-t,0))}},{key:"processMessages",value:function(t,n,r){return void 0!==n?n>0&&(t=e.getMaxMessages(t,n)):t=[t[t.length-1]],t=JSON.parse(JSON.stringify(t)),void 0===r?t:e.getCharacterLimitMessages(t,r)}}])}(),mn=function(){function e(){x(this,e)}return E(e,null,[{key:"parseConfig",value:function(e,t,n,r){var i,s={files:t};if("object"==_(r)){ee.processFileConfigConnect(r);var a=r.files,o=r.connect,l=r.button;a&&(a.infoModal&&(s.files.infoModal=a.infoModal,null!=(i=a.infoModal)&&i.textMarkDown&&(s.infoModalTextMarkUp=n.render(a.infoModal.textMarkDown))),a.acceptedFormats&&(s.files.acceptedFormats=a.acceptedFormats),a.maxNumberOfFiles&&(s.files.maxNumberOfFiles=a.maxNumberOfFiles)),s.button=l,o&&(o.headers||o.method||o.url||o.credentials||e.headers||e.method||e.url||e.credentials)&&(s.connect={url:(null==o?void 0:o.url)||e.url,method:(null==o?void 0:o.method)||e.method,headers:(null==o?void 0:o.headers)||e.headers,credentials:(null==o?void 0:o.credentials)||e.credentials})}return s}},{key:"processMixedFiles",value:function(t,n,r){if(r){t.fileTypes.mixedFiles=e.parseConfig(t.connectSettings,{acceptedFormats:""},n,r)}}},{key:"processMicrophone",value:function(t,n,r,i){var s,a,o,l,c,u,d,h,p=b({acceptedFormats:"audio/*"},(null==(o=t.fileTypes.audio)?void 0:o.files)||{});r&&(void 0!==navigator.mediaDevices.getUserMedia?(t.recordAudio=e.parseConfig(t.connectSettings,p,n,r),"object"==_(r)&&r.files&&(null!==(s=(l=t.recordAudio).files)&&void 0!==s||(l.files={}),t.recordAudio.files.format=null==(c=r.files)?void 0:c.format,t.recordAudio.files.maxDurationSeconds=null==(u=r.files)?void 0:u.maxDurationSeconds,null!=(d=t.fileTypes.audio)&&d.files&&(null!==(a=(h=t.fileTypes.audio.files).maxNumberOfFiles)&&void 0!==a||(h.maxNumberOfFiles=r.files.maxNumberOfFiles)))):i||(t.fileTypes.audio=e.parseConfig(t.connectSettings,p,n,r)))}},{key:"processAudioConfig",value:function(t,n,r,i){if(r||i){var s=b({acceptedFormats:"audio/*"},(null==i?void 0:i.files)||{});t.fileTypes.audio=e.parseConfig(t.connectSettings,s,n,r)}}},{key:"processGifConfig",value:function(t,n,r,i){if(r||i){var s=b({acceptedFormats:"image/gif"},(null==i?void 0:i.files)||{});t.fileTypes.gifs=e.parseConfig(t.connectSettings,s,n,r)}}},{key:"processCamera",value:function(t,n,r,i){var s,a,o,l,c,u=b({acceptedFormats:"image/*"},(null==(a=t.fileTypes.images)?void 0:a.files)||{});r&&(void 0!==navigator.mediaDevices.getUserMedia?(t.camera=e.parseConfig(t.connectSettings,u,n,r),"object"==_(r)&&(t.camera.modalContainerStyle=r.modalContainerStyle,r.files&&(null!==(s=(o=t.camera).files)&&void 0!==s||(o.files={}),t.camera.files.format=null==(l=r.files)?void 0:l.format,t.camera.files.dimensions=null==(c=r.files)?void 0:c.dimensions))):i||(t.fileTypes.images=e.parseConfig(t.connectSettings,u,n,r)))}},{key:"processImagesConfig",value:function(t,n,r,i){if(r||i){var s=b({acceptedFormats:"image/*"},(null==i?void 0:i.files)||{});t.fileTypes.images=e.parseConfig(t.connectSettings,s,n,r)}}},{key:"populateDefaultFileIO",value:function(e,t){var n,r,i,s,a;e&&(null!==(n=e.files)&&void 0!==n||(e.files={}),null!==(r=(s=e.files).acceptedFormats)&&void 0!==r||(s.acceptedFormats=t),null!==(i=(a=e.files).maxNumberOfFiles)&&void 0!==i||(a.maxNumberOfFiles=1))}},{key:"set",value:function(t,n,r){e.populateDefaultFileIO(null==r?void 0:r.audio,".4a,.mp3,.webm,.mp4,.mpga,.wav,.mpeg,.m4a"),e.populateDefaultFileIO(null==r?void 0:r.images,".png,.jpg");var i=Pt.createNew(t.remarkable);e.processImagesConfig(n,i,t.images,null==r?void 0:r.images),e.processCamera(n,i,t.camera,t.images),e.processGifConfig(n,i,t.gifs,null==r?void 0:r.gifs),e.processAudioConfig(n,i,t.audio,null==r?void 0:r.audio),e.processMicrophone(n,i,t.microphone,t.audio),e.processMixedFiles(n,i,t.mixedFiles)}}])}(),vn=function(){function e(t,n,r){var i,s,a,o,l,c;x(this,e),this.rawBody={},this.validateKeyProperty=!1,this.canSendMessage=e.canSendMessage,this.connectSettings={},this.fileTypes={},this.completionsHandlers={},this.streamHandlers={},this.deepChat=t,this.demo=r,Object.assign(this.rawBody,null==(s=t.connect)?void 0:s.additionalBodyProps),this.totalMessagesMaxCharLength=null==(a=null==t?void 0:t.requestBodyLimits)?void 0:a.totalMessagesMaxCharLength,this.maxMessages=null==(o=null==t?void 0:t.requestBodyLimits)?void 0:o.maxMessages,mn.set(t,this,n),t.connect&&(this.connectSettings=t.connect),this.demo&&(null!==(i=(l=this.connectSettings).url)&&void 0!==i||(l.url=ln.URL)),this.connectSettings.websocket&&cn.setup(this),this.stream=(null==(c=this.deepChat.connect)?void 0:c.stream)||ee.checkForStream(this.deepChat),t.loadHistory&&pn.addErrorPrefix(this)}return E(e,[{key:"verifyKey",value:function(e,t){}},{key:"getServiceIOByType",value:function(e){if(e.type.startsWith("audio")&&this.fileTypes.audio)return this.fileTypes.audio;if(e.type.startsWith("image")){if(this.fileTypes.gifs&&e.type.endsWith("/gif"))return this.fileTypes.gifs;if(this.fileTypes.images)return this.fileTypes.images;if(this.camera)return this.camera}return this.fileTypes.mixedFiles}},{key:"request",value:(a=f(h().mark((function e(t,n){var r,i=arguments;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=!(i.length>2&&void 0!==i[2])||i[2],e.abrupt("return",this.stream&&!an.isSimulation(this.stream)?an.request(this,t,n,r):dn.request(this,t,n,r));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"callAPIWithText",value:(s=f(h().mark((function e(t,n){var r,i,s,a,o,l,c,u;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c=b({messages:n},this.rawBody),u=!1,null!=(s=this.connectSettings.headers)&&s["Content-Type"]||(null!==(r=(a=this.connectSettings).headers)&&void 0!==r||(a.headers={}),null!==(i=(o=this.connectSettings.headers)["Content-Type"])&&void 0!==i||(o["Content-Type"]="application/json"),u=!0),e.next=5,this.request(c,t);case 5:u&&(null==(l=this.connectSettings.headers)||delete l["Content-Type"]);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return s.apply(this,arguments)})},{key:"callApiWithFiles",value:(i=f(h().mark((function t(n,r,i){var s,a,o;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=e.createCustomFormDataBody(this.rawBody,r,i),a=this.connectSettings,o=this.getServiceIOByType(i[0]),this.connectSettings=(null==o?void 0:o.connect)||this.connectSettings,t.next=4,this.request(s,n,!1);case 4:this.connectSettings=a;case 5:case"end":return t.stop()}}),t,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r?this.callApiWithFiles(t,n,r):this.callAPIWithText(t,n);case 1:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"callAPI",value:(n=f(h().mark((function e(t,n){var r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=fn.processMessages(n.messageToElements.map((function(e){return d(e,1)[0]})),this.maxMessages,this.totalMessagesMaxCharLength),this.connectSettings.websocket?(i=b({messages:r},this.rawBody),cn.sendWebsocket(this,i,n,!1)):this.callServiceAPI(n,r,t.files);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return n.apply(this,arguments)})},{key:"extractResultData",value:(t=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:if(!t.result){e.next=4;break}return e.abrupt("return",ee.handleResponseProperty(t));case 4:if(!Zt.validateResponseFormat(t)){e.next=6;break}return e.abrupt("return",t);case 6:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})},{key:"isDirectConnection",value:function(){return!1}},{key:"isWebModel",value:function(){return!1}}],[{key:"canSendMessage",value:function(e,t,n){return!!n||(!(!e||""===e.trim())||!!(t&&t.length>0))}},{key:"createCustomFormDataBody",value:function(e,t,n){var r=new FormData;n.forEach((function(e){return r.append("files",e)})),Object.keys(e).forEach((function(t){return r.append(t,String(e[t]))}));var i=0;t.slice(0,t.length-1).forEach((function(e){r.append("message".concat(i+=1),JSON.stringify(e))}));var s=t[t.length-1];return s.text&&(delete s.files,r.append("message".concat(i+=1),JSON.stringify(s))),r}}]);var t,n,r,i,s,a}(),gn=function(e){function t(e,n,r,i,a){var o,l;return x(this,t),(o=s(this,t,[e,a])).insertKeyPlaceholderText="API Key",o.keyHelpUrl="",Object.assign(o.rawBody,null==(l=e.connect)?void 0:l.additionalBodyProps),o.keyVerificationDetails=n,o.buildHeadersFunc=r,i&&o.setApiKeyProperties(i),o.connectSettings=o.buildConnectSettings(o.key||"",e.connect),o}return c(t,e),E(t,[{key:"setApiKeyProperties",value:function(e){this.key=e.key,e.validateKeyProperty&&(this.validateKeyProperty=e.validateKeyProperty)}},{key:"buildConnectSettings",value:function(e,t){var n,r=null!=t?t:{};return null!==(n=r.headers)&&void 0!==n||(r.headers={}),Object.assign(r.headers,this.buildHeadersFunc(e)),r}},{key:"keyAuthenticated",value:function(e,t){this.connectSettings=this.buildConnectSettings(t,this.connectSettings),this.key=t,e()}},{key:"verifyKey",value:function(e,t){var n=this.keyVerificationDetails,r=n.url,i=n.method,s=n.handleVerificationResult,a=n.createHeaders,o=n.body,l=(null==a?void 0:a(e))||this.buildHeadersFunc(e);dn.verifyKey(e,r,l,i,this.keyAuthenticated.bind(this,t.onSuccess),t.onFail,t.onLoad,s,o)}},{key:"isDirectConnection",value:function(){return!0}}])}(vn),yn=function(){function e(){x(this,e)}return E(e,null,[{key:"waitForPropertiesToBeUpdatedBeforeRender",value:function(t){t._propUpdated_=!1,setTimeout((function(){t._propUpdated_?e.waitForPropertiesToBeUpdatedBeforeRender(t):(t._waitingToRender_=!1,t.onRender())}))}},{key:"attemptRender",value:function(t){t._propUpdated_=!0,t._waitingToRender_||(t._waitingToRender_=!0,e.waitForPropertiesToBeUpdatedBeforeRender(t))}}])}(),bn=function(e){function t(){var e;return x(this,t),(e=s(this,t))._waitingToRender_=!1,e._propUpdated_=!1,Object.keys(t._attributeToProperty_).forEach((function(n){var r=t._attributeToProperty_[n];e.constructPropertyAccessors(r),e.hasOwnProperty(n)||e.constructPropertyAccessors(r,n)})),e}return c(t,e),E(t,[{key:"constructPropertyAccessors",value:function(e,t){var n;Object.defineProperty(this,t||e,{get:function(){return n},set:function(r){n=r,t?this[e]=r:yn.attemptRender(this)}})}},{key:"attributeChangedCallback",value:function(e,n,r){if(n!==r){var i=t._attributes_[e](r);this[t._attributeToProperty_[e]]=i}}},{key:"onRender",value:function(){}}],[{key:"observedAttributes",get:function(){return Object.keys(t._attributes_)||[]}}])}(i(HTMLElement));bn._attributes_={},bn._attributeToProperty_={};var kn=bn,_n=function(){return E((function e(){x(this,e)}),null,[{key:"createSVGElement",value:function(e){return(new DOMParser).parseFromString(e,"image/svg+xml").documentElement}}])}(),xn=function(){function e(){x(this,e)}return E(e,null,[{key:"changeVisibility",value:function(t,n,r,i){i.target.id===e.VISIBLE_ICON_ID?(n.style.display="none",r.style.display="block",t.type="password"):(n.style.display="block",r.style.display="none",t.type="text")}},{key:"createIconElement",value:function(e,t){var n=_n.createSVGElement(e);return n.id=t,n.classList.add("visibility-icon"),n}},{key:"create",value:function(t){var n=document.createElement("div");n.id="visibility-icon-container";var r=e.createIconElement('\n\n\t\t\n\n',e.VISIBLE_ICON_ID);r.style.display="none",n.appendChild(r);var i=e.createIconElement('\n\n\t\t\n\n',"not-visible-icon");return n.appendChild(i),n.onclick=e.changeVisibility.bind(this,t,r,i),n}}])}();xn.VISIBLE_ICON_ID="visible-icon";var Sn=xn,En=function(){function e(){x(this,e)}return E(e,null,[{key:"createCautionText",value:function(){var e=document.createElement("a");return e.classList.add("insert-key-input-help-text"),e.innerText="Please exercise CAUTION when inserting your API key outside of deepchat.dev or localhost!!",e}},{key:"createHelpLink",value:function(e){var t=document.createElement("a");return t.classList.add("insert-key-input-help-text"),t.href=e,t.innerText="Find more info here",t.target="_blank",t}},{key:"createFailText",value:function(){var e=document.createElement("div");return e.id="insert-key-input-invalid-text",e.style.display="none",e}},{key:"createHelpTextContainer",value:function(t){var n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=document.createElement("div");r.id="insert-key-help-text-container";var i=document.createElement("div");i.id="insert-key-help-text-contents";var s=e.createFailText();if(i.appendChild(s),t){var a=e.createHelpLink(t);i.appendChild(a)}if(!0===n){var o=e.createCautionText();i.appendChild(o)}return r.appendChild(i),{helpTextContainerElement:r,failTextElement:s}}},{key:"onFail",value:function(e,t,n,r){e.classList.replace("insert-key-input-valid","insert-key-input-invalid"),n.innerText=r,n.style.display="block",t.innerText="Start",e.classList.remove("loading")}},{key:"onLoad",value:function(e,t){e.classList.add("loading"),t.innerHTML='
    '}},{key:"verifyKey",value:function(e,t,n){var r=e.value.trim();n.verifyKey(r,t)}},{key:"addVerificationEvents",value:function(t,n,r,i,s){var a={onSuccess:i,onFail:e.onFail.bind(this,t,n,r),onLoad:e.onLoad.bind(this,t,n)},o=e.verifyKey.bind(this,t,a,s);n.onclick=o,t.onkeydown=function(e){!t.classList.contains("loading")&&e.key===N.ENTER&&o()}}},{key:"createStartButton",value:function(){var e=document.createElement("div");return e.id="start-button",e.innerText="Start",e}},{key:"onInputFocus",value:function(e){e.target.classList.replace("insert-key-input-invalid","insert-key-input-valid")}},{key:"createInput",value:function(t){var n=document.createElement("div");n.id="insert-key-input-container";var r=document.createElement("input");return r.id="insert-key-input",r.placeholder=t||"API Key",r.type="password",r.classList.add("insert-key-input-valid"),r.onfocus=e.onInputFocus,n.appendChild(r),n}},{key:"createContents",value:function(t,n){var r,i=document.createElement("div");i.id="insert-key-contents";var s=e.createInput(n.insertKeyPlaceholderText),a=s.children[0],o=Sn.create(a);s.appendChild(o),i.appendChild(s);var l=e.createStartButton(),c=e.createHelpTextContainer(n.keyHelpUrl,null==(r=n.deepChat._insertKeyViewStyles)?void 0:r.displayCautionText),u=c.helpTextContainerElement,d=c.failTextElement;return i.appendChild(l),i.appendChild(u),e.addVerificationEvents(a,l,d,t,n),i}},{key:"createElements",value:function(t,n){var r=document.createElement("div");r.id="insert-key-view";var i=e.createContents(t,n);return r.appendChild(i),r}},{key:"render",value:function(t,n,r){var i=e.createElements(n,r);t.replaceChildren(i)}}])}(),wn=function(){function e(){x(this,e)}return E(e,null,[{key:"enableButtons",value:function(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;window.webLLM?(t&&(t.disabled=!1),n&&(n.disabled=!1)):r<4*Mn.MODULE_SEARCH_LIMIT_S&&setTimeout((function(){return e.enableButtons(t,n,r+1)}),250)}},{key:"setUpInitial",value:function(t,n,r,i){var s=(null==n?void 0:n.downloadClass)||e.DOWNLOAD_BUTTON_CLASS,a=(null==n?void 0:n.uploadClass)||e.UPLOAD_BUTTON_CLASS,o=(null==n?void 0:n.fileInputClass)||e.FILE_INPUT_CLASS;return setTimeout((function(){var n=null==r?void 0:r.getElementsByClassName(s)[0],i=null==r?void 0:r.getElementsByClassName(o)[0],l=null==r?void 0:r.getElementsByClassName(a)[0];n&&(n.onclick=function(){return t()}),i&&(i.onchange=function(){i.files&&i.files.length>0&&t(i.files)}),l&&(l.onclick=function(){return i.click()}),(n||l)&&e.enableButtons(n,l)})),(null==n?void 0:n.initialHtml)||'
    \n Download or upload a web model that will run entirely on your browser:
    \n \n ').concat(i?"":'\n '),"\n
    ")}},{key:"exportFile",value:function(e){for(var t=document.createElement("a"),n=function(n){setTimeout((function(){for(var r=4*n,i=r;i\n Model loaded successfully and has been cached for future requests.\n ".concat(i?"":'
    '),"\n ")}}])}();wn.DOWNLOAD_BUTTON_CLASS="deep-chat-download-button",wn.UPLOAD_BUTTON_CLASS="deep-chat-upload-button",wn.FILE_INPUT_CLASS="deep-chat-file-input",wn.EXPORT_BUTTON_CLASS="deep-chat-export-button";var Cn=wn,Tn={model_list:[{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f32_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f32_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f32_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:9109.03,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:6749.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-7b-chat-hf-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-7b-chat-hf/Llama-2-7b-chat-hf-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:4618.52,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-13b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-13b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-13b-chat-hf/Llama-2-13b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:11814.09,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Llama-2-70b-chat-hf-q4f16_1-MLC/resolve/main/",local_id:"Llama-2-70b-chat-hf-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Llama-2-70b-chat-hf/Llama-2-70b-chat-hf-q4f16_1-ctx4k_cs1k-webgpu.wasm",vram_required_MB:43729.05,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f16_1-ctx2k-webgpu.wasm",vram_required_MB:2972.09,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f32_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f32_1-ctx2k-webgpu.wasm",vram_required_MB:3928.09,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:2041.09,low_resource_required:!0,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f32_1-MLC/resolve/main/",local_id:"RedPajama-INCITE-Chat-3B-v1-q4f32_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/RedPajama-INCITE-Chat-3B-v1/RedPajama-INCITE-Chat-3B-v1-q4f32_1-ctx1k-webgpu.wasm",vram_required_MB:2558.09,low_resource_required:!0},{model_url:"https://huggingface.co/mlc-ai/WizardMath-7B-V1.1-q4f16_1-MLC/resolve/main/",local_id:"WizardMath-7B-V1.1-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/Mistral-7B-Instruct-v0.2-q4f16_1-MLC/resolve/main/",local_id:"Mistral-7B-Instruct-v0.2-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/OpenHermes-2.5-Mistral-7B-q4f16_1-MLC/resolve/main/",local_id:"OpenHermes-2.5-Mistral-7B-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/NeuralHermes-2.5-Mistral-7B-q4f16_1-MLC/resolve/main/",local_id:"NeuralHermes-2.5-Mistral-7B-q4f16_1",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/Mistral-7B-Instruct-v0.2/Mistral-7B-Instruct-v0.2-q4f16_1-sw4k_cs1k-webgpu.wasm",vram_required_MB:6079.02,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q0f16-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q0f16",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q0f16-ctx2k-webgpu.wasm",vram_required_MB:5063.52,low_resource_required:!1,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q0f32-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q0f32",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q0f32-ctx2k-webgpu.wasm",vram_required_MB:5394.53,low_resource_required:!1},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q4f16_1-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q4f16_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q4f16_1-ctx1k-webgpu.wasm",vram_required_MB:899.11,low_resource_required:!0,required_features:["shader-f16"]},{model_url:"https://huggingface.co/mlc-ai/TinyLlama-1.1B-Chat-v0.4-q4f32_1-MLC/resolve/main/",local_id:"TinyLlama-1.1B-Chat-v0.4-q4f32_1-1k",model_lib_url:"https://raw.githubusercontent.com/mlc-ai/binary-mlc-llm-libs/main/TinyLlama-1.1B-Chat-v0.4/TinyLlama-1.1B-Chat-v0.4-q4f32_1-ctx1k-webgpu.wasm",vram_required_MB:992.11,low_resource_required:!0}],use_web_worker:!0},An=function(e){function t(e){var n,r,i;return x(this,t),(n=s(this,t,[e]))._isModelLoaded=!1,n._isModelLoading=!1,n._loadOnFirstMessage=!1,n._webModel={},n.permittedErrorPrefixes=[t.MULTIPLE_MODELS_ERROR,t.WEB_LLM_NOT_FOUND_ERROR,t.GENERIC_ERROR],n._conversationHistory=[],"object"==_(e.webModel)&&(n._webModel=e.webModel),null!=(r=n._webModel.load)&&r.clearCache&&t.clearAllCache(),n.findModelInWindow(e),n.canSendMessage=n.canSubmit.bind(a(n)),n._chatEl=null==(i=e.shadowRoot)?void 0:i.children[0],e.history&&t.setUpHistory(n._conversationHistory,e.history),n}return c(t,e),E(t,[{key:"setUpMessages",value:function(e){var t=this;this._messages=e,this._removeIntro=function(){e.removeIntroductoryMessage(),t._removeIntro=void 0}}},{key:"findModelInWindow",value:function(e){var n,r=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;window.webLLM?this.configureInit(this.shouldAddIntroMessage(e.introMessage)):i>t.MODULE_SEARCH_LIMIT_S?(null==(n=this._messages)||n.addNewErrorMessage("service",t.WEB_LLM_NOT_FOUND_ERROR),console.error("The deep-chat-web-llm module has not been attached to the window object. Please see the following guide:"),console.error("https://deepchat.dev/examples/externalModules")):setTimeout((function(){return r.findModelInWindow(e,i+1)}),1e3)}},{key:"shouldAddIntroMessage",value:function(e){var t;return!e&&this._webModel&&!1!==(null==(t=this._webModel.introMessage)?void 0:t.displayed)}},{key:"scrollToTop",value:function(e){var t,n=this;!1!==(null==(t=this._webModel.introMessage)?void 0:t.autoScroll)&&setTimeout((function(){var e,t;null!=(e=n._messages)&&e.elementRef&&K.scrollToTop(null==(t=n._messages)?void 0:t.elementRef)}),e)}},{key:"getIntroMessage",value:function(e){if(this.shouldAddIntroMessage(e)&&this._chatEl){var t=Cn.setUpInitial(this.init.bind(this),this._webModel.introMessage,this._chatEl,!!this._webModel.worker);return this.scrollToTop(1),{role:Wt.AI_ROLE,html:t,sendUpdate:!1}}}},{key:"configureInit",value:(v=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(n=this._webModel.load)){e.next=8;break}if(!n.onInit){e.next=5;break}return this.init(),e.abrupt("return");case 5:if(!n.onMessage){e.next=8;break}return this._loadOnFirstMessage=!0,e.abrupt("return");case 8:t||this.init();case 9:case"end":return e.stop()}}),e,this)}))),function(e){return v.apply(this,arguments)})},{key:"init",value:(m=f(h().mark((function e(t){var n,r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(n=this._messages)||n.removeError(),r=this.attemptToCreateChat(),e.t0=r,!e.t0){e.next=6;break}return e.next=6,this.loadModel(r,t);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return m.apply(this,arguments)})},{key:"attemptToCreateChat",value:function(){var e;if(t.chat)return null==(e=this._messages)||e.addNewErrorMessage("service",t.MULTIPLE_MODELS_ERROR),void console.error(t.MULTIPLE_MODELS_ERROR);if(!this._isModelLoaded&&!this._isModelLoading){var n=this._webModel.worker;return Tn.use_web_worker&&n?new window.webLLM.ChatWorkerClient(n):new window.webLLM.ChatModule}}},{key:"getConfig",value:function(){var e,n=t.DEFAULT_MODEL;this._webModel.model&&(n=this._webModel.model);var r=JSON.parse(JSON.stringify(Tn));if(this._webModel.urls){var i=r.model_list.find((function(e){return e.local_id=n}));i&&(this._webModel.urls.model&&(i.model_url=this._webModel.urls.model),this._webModel.urls.wasm&&(i.model_lib_url=this._webModel.urls.wasm))}return null!=(e=this._webModel.load)&&e.skipCache&&(r.use_cache=!1),{model:n,appConfig:r}}},{key:"loadModel",value:(p=f(h().mark((function e(n,r){var i,s,a,o,l,c,u,d,p,f,m,v,g,y,b,k=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.scrollToTop(),t.chat=n,this._isModelLoading=!0,d=!1===(null==(i=this._webModel.introMessage)?void 0:i.displayed),p=function(e){var t;null==(t=k._messages)||t.addNewMessage({html:"
    ".concat(e.text,"
    "),overwrite:!0,sendUpdate:!1}),d&&(setTimeout((function(){var e;return K.scrollToBottom(null==(e=k._messages)?void 0:e.elementRef)})),d=!1)},t.chat.setInitProgressCallback(p),e.prev=4,m=this.getConfig(),v=m.model,g=m.appConfig,y={},this._webModel.instruction&&(y.conv_config={system:this._webModel.instruction}),this._conversationHistory.length>0&&(y.conversation_history=this._conversationHistory),e.next=10,t.chat.reload(v,y,g,r);case 10:f=e.sent,e.next=16;break;case 13:return e.prev=13,e.t0=e.catch(4),e.abrupt("return",this.unloadChat(e.t0));case 16:null==(a=(s=this.deepChat)._validationHandler)||a.call(s),null!=(o=this._webModel.introMessage)&&o.removeAfterLoad?!1===this._webModel.introMessage.displayed?null==(c=this._messages)||c.removeLastMessage():null==(u=this._removeIntro)||u.call(this):(b=Cn.setUpAfterLoad(f,this._webModel.introMessage,this._chatEl,!!this._webModel.worker),null==(l=this._messages)||l.addNewMessage({html:b,overwrite:!0,sendUpdate:!1})),this._isModelLoaded=!0,this._isModelLoading=!1;case 18:case"end":return e.stop()}}),e,this,[[4,13]])}))),function(e,t){return p.apply(this,arguments)})},{key:"unloadChat",value:(d=f(h().mark((function e(n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null==(r=this._messages)||r.addNewErrorMessage("service",t.GENERIC_ERROR),console.error(n),this._isModelLoaded=!1,this._isModelLoading=!1,e.t0=t.chat,!e.t0){e.next=9;break}return e.next=8,t.chat.unload();case 8:t.chat=void 0;case 9:case"end":return e.stop()}}),e,this)}))),function(e){return d.apply(this,arguments)})},{key:"immediateResp",value:(u=f(h().mark((function e(n,r,i){var s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.generate(r,void 0,0);case 2:return e.t0=e.sent,s={text:e.t0},e.next=6,t.processResponse(this.deepChat,n,s);case 6:(a=e.sent)&&n.addNewMessage(a),this.completionsHandlers.onFinish();case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return u.apply(this,arguments)})},{key:"streamResp",value:(l=f(h().mark((function e(n,r,i){var s,a=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.streamHandlers.abortStream.abort=function(){i.interruptGenerate()},this.streamHandlers.onOpen(),s=new Jt(n),e.next=4,i.generate(r,function(){var e=f(h().mark((function e(r,i){var o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.processResponse(a.deepChat,n,{text:i});case 2:(o=e.sent)&&s.upsertStreamedMessage({text:o.text,overwrite:!0});case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}());case 4:s.finaliseStreamedMessage(),this.streamHandlers.onClose();case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return l.apply(this,arguments)})},{key:"generateRespByType",value:(o=f(h().mark((function e(t,n,r,i){var s;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,!r){e.next=6;break}return e.next=4,this.streamResp(t,n,i);case 4:e.next=8;break;case 6:return e.next=8,this.immediateResp(t,n,i);case 8:e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),null==(s=this._messages)||s.addNewErrorMessage("service"),console.log(e.t0);case 13:case"end":return e.stop()}}),e,this,[[0,10]])}))),function(e,t,n,r){return o.apply(this,arguments)})},{key:"generateResp",value:(i=f(h().mark((function e(t,n,r){var i,s,a,o,l,c,u;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n[n.length-1].text,e.next=3,Zt.processRequestInterceptor(this.deepChat,{body:{text:i}});case 3:s=e.sent,a=s.body,o=s.error,l=!!this.stream;try{o?(Zt.displayError(t,new Error(o)),(l?this.streamHandlers.onClose:this.completionsHandlers.onFinish)()):a&&a.text?this.generateRespByType(t,a.text,!!this.stream,r):(c=G.INVALID_MODEL_REQUEST({body:a},!1),console.error(c),u=l?this.streamHandlers.onClose:this.completionsHandlers.onFinish,Zt.onInterceptorError(t,c,u))}catch(c){this.unloadChat(c)}case 8:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"callServiceAPI",value:(r=f(h().mark((function e(n,r){var i,s;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this._isModelLoaded){e.next=7;break}if(!this._loadOnFirstMessage){e.next=6;break}return e.next=4,this.init();case 4:e.next=7;break;case 6:return e.abrupt("return");case 7:!t.chat||this._isModelLoading||(null!=(i=this._webModel.introMessage)&&i.removeAfterMessage&&(null==(s=this._removeIntro)||s.call(this)),n.addLoadingMessage(),this.generateResp(n,r,t.chat));case 8:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"canSubmit",value:function(e){return!(null==e||!e.trim()||this._isModelLoading)&&(!!this._loadOnFirstMessage||!!this._isModelLoaded)}},{key:"isWebModel",value:function(){return!0}}],[{key:"setUpHistory",value:function(e,t){t.forEach((function(n,r){if(n.role===Wt.USER_ROLE&&n.text){var i=t[r+1];null!=i&&i.text&&i.role!==Wt.USER_ROLE&&e.push([n.text,i.text])}}))}},{key:"processResponse",value:(n=f(h().mark((function e(t,n,r){var i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==(i=t.responseInterceptor)?void 0:i.call(t,r);case 2:if(e.t0=e.sent,e.t0){e.next=5;break}e.t0=r;case 5:if(!(s=e.t0).error){e.next=11;break}return Zt.displayError(n,new Error(s.error)),e.abrupt("return");case 11:if(s&&s.text){e.next=15;break}return a=G.INVALID_MODEL_RESPONSE(r,!!t.responseInterceptor,s),Zt.displayError(n,new Error(a)),e.abrupt("return");case 15:return e.abrupt("return",s);case 16:case"end":return e.stop()}}),e)}))),function(e,t,r){return n.apply(this,arguments)})},{key:"clearAllCache",value:function(){t.clearCache("webllm/model"),t.clearCache("webllm/wasm")}},{key:"clearCache",value:function(e){caches.open(e).then((function(e){e.keys().then((function(t){t.forEach((function(t){e.delete(t)}))}))}))}}]);var n,r,i,o,l,u,d,p,m,v}(vn);An.GENERIC_ERROR="Error, please check the [troubleshooting](https://deepchat.dev/docs/webModel#troubleshooting) section of documentation for help.",An.MULTIPLE_MODELS_ERROR="Cannot run multiple web models",An.WEB_LLM_NOT_FOUND_ERROR="WebLLM module not found",An.DEFAULT_MODEL="Llama-2-7b-chat-hf-q4f32_1",An.MODULE_SEARCH_LIMIT_S=5;var Mn=An,In=function(){function e(){x(this,e)}return E(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;Array.isArray(i.error)&&"Error in `parameters`: field required"===i.error[0]?n(t):r(G.INVALID_KEY)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api-inference.huggingface.co/models/gpt2",method:"POST",handleVerificationResult:e.handleVerificationResult}}}])}(),Ln=function(e){function t(e,n,r,i,a,o){var l;return x(this,t),(l=s(this,t,[e,In.buildKeyVerificationDetails(),In.buildHeaders,a,o])).insertKeyPlaceholderText="Hugging Face Token",l.keyHelpUrl="https://huggingface.co/settings/tokens",l.introPanelMarkUp='\n
    Hugging Face
    \n

    First message may take an extented amount of time to complete as the model needs to be initialized.

    ',l.permittedErrorPrefixes=["Authorization header"],l.url="".concat(t.URL_PREFIX).concat(r),l.textInputPlaceholderText=n,"object"==_(i)&&(i.model&&(l.url="".concat(t.URL_PREFIX).concat(i.model)),i.options&&(l.rawBody.options=i.options),i.parameters&&(l.rawBody.parameters=i.parameters)),l}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t,n){var r,i=JSON.parse(JSON.stringify(e)),s=t[t.length-1].text;if(s)return null!==(r=i.options)&&void 0!==r||(i.options={}),i.options.wait_for_model=!0,b({inputs:s},i)}},{key:"callServiceAPI",value:(n=f(h().mark((function e(t,n,r){var i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:i=this.preprocessBody(this.rawBody,n,r),dn.request(this,i,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})}]);var n}(gn);Ln.URL_PREFIX="https://api-inference.huggingface.co/models/";var Rn=Ln,On=function(e){function t(e,n,r,i,a,o){var l;return x(this,t),(l=s(this,t,[e,n,r,i,a,o])).isTextInputDisabled=!0,l.canSendMessage=t.canSendFile,l}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t,n){return n[0]}},{key:"callServiceAPI",value:(n=f(h().mark((function e(t,n,r){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:dn.poll(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return n.apply(this,arguments)})}],[{key:"canSendFile",value:function(e,t){return!(null==t||!t[0])}}]);var n}(Rn),Pn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Attach an audio file","ehcalabres/wav2vec2-lg-xlsr-en-speech-emotion-recognition",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.audioClassification,null==(i=e.directConnection)?void 0:i.huggingFace,{audio:{}}])}return c(t,e),E(t,[{key:"extractPollResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.label)||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(On),Nn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Attach an image file","google/vit-base-patch16-224",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.imageClassification,null==(i=e.directConnection)?void 0:i.huggingFace,{images:{}}])}return c(t,e),E(t,[{key:"extractPollResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.label)||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(On),Bn="data:image/png;base64,",Dn=function(){function e(){x(this,e)}return E(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){e.message?r(G.INVALID_KEY):n(t)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.stability.ai/v1/engines/list",method:"GET",handleVerificationResult:e.handleVerificationResult}}}])}(),Fn=function(e){function t(e,n,r,i,a){var o;return x(this,t),(o=s(this,t,[e,n,r,i,a])).insertKeyPlaceholderText="Stability AI API Key",o.keyHelpUrl="https://platform.stability.ai/docs/getting-started/authentication",o.permittedErrorPrefixes=["Incorrect","invalid_"],o}return c(t,e),E(t)}(gn),jn=function(e){function t(e){var n,r;x(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=null==i?void 0:i.stabilityAI;(n=s(this,t,[e,Dn.buildKeyVerificationDetails(),Dn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:1}}}])).url="https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n
    Stability AI
    \n
    Image to Image Upscale
    \n

    Upload an image to generate a new one with higher resolution.

    \n

    Click here for more info.

    ';var o=null==(r=null==i?void 0:i.stabilityAI)?void 0:r.imageToImageUpscale;return"object"==_(o)&&(o.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(o.engine_id,"/image-to-image/upscale")),t.cleanConfig(o),Object.assign(n.rawBody,o)),n.canSendMessage=t.canSendFileMessage,n}return c(t,e),E(t,[{key:"createFormDataBody",value:function(e,t){var n=new FormData;return n.append("image",t),Object.keys(e).forEach((function(t){n.append(t,String(e[t]))})),n}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){var i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r){e.next=4;break}throw new Error("Image was not found");case 4:i=this.createFormDataBody(this.rawBody,r[0]),Zt.tempRemoveContentHeader(this.connectSettings,dn.request.bind(this,this,i,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Bn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id}},{key:"canSendFileMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(Fn),Un=function(e){function t(e){var n,r;x(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=null==i?void 0:i.stabilityAI;(n=s(this,t,[e,Dn.buildKeyVerificationDetails(),Dn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}}])).url="https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image/masking",n._maskSource="MASK_IMAGE_WHITE",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n
    Stability AI
    \n
    Image to Image Masking
    \n

    Upload an image, its mask image to create a new one based on the changes you have described for the mask area.

    \n

    Click here for more info.

    ';var o=null==(r=null==i?void 0:i.stabilityAI)?void 0:r.imageToImageMasking;return"object"==_(o)&&(o.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(o.engine_id,"/image-to-image/masking")),void 0!==o.weight&&null!==o.weight&&(n._imageWeight=o.weight),void 0!==o.mask_source&&null!==o.mask_source&&(n._maskSource=o.mask_source),t.cleanConfig(o),Object.assign(n.rawBody,o)),n.canSendMessage=t.canSendFileTextMessage,n}return c(t,e),E(t,[{key:"createFormDataBody",value:function(e,t,n,r){var i=new FormData;return i.append("init_image",t),i.append("mask_source",String(this._maskSource)),i.append("mask_image",n),r&&""!==r&&i.append("text_prompts[0][text]",r),void 0!==this._imageWeight&&null!==this._imageWeight&&i.append("text_prompts[0][weight]",String(this._imageWeight)),Object.keys(e).forEach((function(t){i.append(t,String(e[t]))})),void 0===i.get("weight")&&i.append("weight",String(1)),i}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){var i,s,a,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r&&r[0]&&r[1]){e.next=4;break}throw new Error("Image was not found");case 4:a=null==(s=null==(i=n[n.length-1])?void 0:i.text)?void 0:s.trim(),o=this.createFormDataBody(this.rawBody,r[0],r[1],a),Zt.tempRemoveContentHeader(this.connectSettings,dn.request.bind(this,this,o,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Bn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendFileTextMessage",value:function(e,t){return!(null==t||!t[0]||!e||""===e.trim())}}]);var n,r}(Fn),Hn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Attach an audio file","facebook/wav2vec2-large-960h-lv60-self",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.audioSpeechRecognition,null==(i=e.directConnection)?void 0:i.huggingFace,{audio:{}}])}return c(t,e),E(t,[{key:"extractPollResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.estimated_time){e.next=2;break}return e.abrupt("return",{timeoutMS:1e3*(t.estimated_time+1)});case 2:if(!t.error){e.next=4;break}throw t.error;case 4:return e.abrupt("return",{text:t.text||""});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(On),qn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Once upon a time","gpt2",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.textGeneration,null==(i=e.directConnection)?void 0:i.huggingFace])}return c(t,e),E(t,[{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.generated_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),zn=function(e){function t(e){var n,r,i,a;x(this,t);var o=null==(i=null==(r=e.directConnection)?void 0:r.huggingFace)?void 0:i.questionAnswer;return(n=s(this,t,[e,"Ask a question","bert-large-uncased-whole-word-masking-finetuned-squad",o,null==(a=e.directConnection)?void 0:a.huggingFace])).permittedErrorPrefixes=["Authorization header","Error in"],n.context=o.context,n}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return{inputs:{question:n,context:this.context,options:{wait_for_model:!0}}}}},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.answer||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),Vn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Insert text to summarize","facebook/bart-large-cnn",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.summarization,null==(i=e.directConnection)?void 0:i.huggingFace])}return c(t,e),E(t,[{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.summary_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),Gn=function(e){function t(e){var n,r,i,a,o;return x(this,t),null!==(n=(r=s(this,t,[e,"Ask me anything!","facebook/blenderbot-400M-distill",null==(a=null==(i=e.directConnection)?void 0:i.huggingFace)?void 0:a.conversation,null==(o=e.directConnection)?void 0:o.huggingFace])).maxMessages)&&void 0!==n||(r.maxMessages=-1),r}return c(t,e),E(t,[{key:"processMessages",value:function(e){var t=e.filter((function(e){return e.text})),n=t[t.length-1].text,r=t.slice(0,t.length-1);if(n)return{past_user_inputs:r.filter((function(e){return"user"===e.role})).map((function(e){return e.text})),generated_responses:r.filter((function(e){return"ai"===e.role})).map((function(e){return e.text})),mostRecentMessageText:n}}},{key:"preprocessBody",value:function(e,t){var n,r=JSON.parse(JSON.stringify(e)),i=this.processMessages(t);if(i)return null!==(n=r.options)&&void 0!==n||(r.options={}),r.options.wait_for_model=!0,b({inputs:{past_user_inputs:i.past_user_inputs,generated_responses:i.generated_responses,text:i.mostRecentMessageText}},r)}},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.generated_text||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),Wn=function(e){function t(e){var n,r;x(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=i.stabilityAI;(n=s(this,t,[e,Dn.buildKeyVerificationDetails(),Dn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:1}}}])).url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/image-to-image",n.textInputPlaceholderText="Describe image changes",n.introPanelMarkUp='\n
    Stability AI: Image to Image
    \n

    Upload an image to create a new one with the changes you have described.

    \n

    Click here for more info.

    ';var o=null==(r=i.stabilityAI)?void 0:r.imageToImage;return"object"==_(o)&&(o.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(o.engine_id,"/text-to-image")),void 0!==o.weight&&null!==o.weight&&(n._imageWeight=o.weight),t.cleanConfig(o),Object.assign(n.rawBody,o)),n.canSendMessage=t.canSendFileTextMessage,n}return c(t,e),E(t,[{key:"createFormDataBody",value:function(e,t,n){var r=new FormData;return r.append("init_image",t),n&&""!==n&&r.append("text_prompts[0][text]",n),void 0!==this._imageWeight&&null!==this._imageWeight&&r.append("text_prompts[0][weight]",String(this._imageWeight)),Object.keys(e).forEach((function(t){r.append(t,String(e[t]))})),void 0===r.get("weight")&&r.append("weight",String(1)),r}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){var i,s,a,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(r){e.next=4;break}throw new Error("Image was not found");case 4:a=null==(s=null==(i=n[n.length-1])?void 0:i.text)?void 0:s.trim(),o=this.createFormDataBody(this.rawBody,r[0],a),Zt.tempRemoveContentHeader(this.connectSettings,dn.request.bind(this,this,o,t),!1);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Bn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendFileTextMessage",value:function(e,t){return!(null==t||!t[0]||!e||""===e.trim())}}]);var n,r}(Fn),Kn=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"Insert text to translate","Helsinki-NLP/opus-tatoeba-en-ja",null==(r=null==(n=e.directConnection)?void 0:n.huggingFace)?void 0:r.translation,null==(i=e.directConnection)?void 0:i.huggingFace])}return c(t,e),E(t,[{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.translation_text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),Jn=function(e){function t(e){var n,r;x(this,t);var i=JSON.parse(JSON.stringify(e.directConnection)),a=i.stabilityAI;(n=s(this,t,[e,Dn.buildKeyVerificationDetails(),Dn.buildHeaders,a])).url="https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image",n.textInputPlaceholderText="Describe an image",n.introPanelMarkUp='\n
    Stability AI: Text to Image
    \n

    Insert text to generate an image.

    \n

    Click here for more info.

    ';var o=null==(r=i.stabilityAI)?void 0:r.textToImage;return"object"==_(o)&&(o.engine_id&&(n.url="https://api.stability.ai/v1/generation/".concat(o.engine_id,"/text-to-image")),void 0!==o.weight&&null!==o.weight&&(n._imageWeight=o.weight),t.cleanConfig(o),Object.assign(n.rawBody,o)),n.canSendMessage=t.canSendTextMessage,n}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r={text:t};return this._imageWeight&&(r.weight=this._imageWeight),n.text_prompts=[r],n}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n[n.length-1].text),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{files:t.artifacts.map((function(e){return{src:"".concat(Bn).concat(e.base64),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"cleanConfig",value:function(e){delete e.engine_id,delete e.weight}},{key:"canSendTextMessage",value:function(e){return!(!e||""===e.trim())}}]);var n,r}(Fn),Yn=function(e){function t(e){var n,r,i,a;return x(this,t),(n=s(this,t,[e,"The goal of life is [MASK].","bert-base-uncased",null==(i=null==(r=e.directConnection)?void 0:r.huggingFace)?void 0:i.fillMask,null==(a=e.directConnection)?void 0:a.huggingFace])).introPanelMarkUp='\n
    Hugging Face
    \n

    Insert a sentence with the word [MASK] and the model will try to fill it for you. E.g. I want [MASK].

    \n

    First message may take an extented amount of time to complete as the model needs to be initialized.

    ',n.permittedErrorPrefixes=["Authorization header","No mask_token"],n}return c(t,e),E(t,[{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:(null==(n=t[0])?void 0:n.sequence)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n}(Rn),Zn=function(){function e(){x(this,e)}return E(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;i.error?"invalid_api_key"===i.error.code?r(G.INVALID_KEY):r(G.CONNECTION_FAILED):n(t)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.openai.com/v1/models",method:"GET",handleVerificationResult:e.handleVerificationResult}}},{key:"directFetch",value:(t=f(h().mark((function e(t,n,r){var i,s,a=arguments;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=!(a.length>3&&void 0!==a[3])||a[3],t.connectSettings.method=r,e.next=4,Zt.fetch(t,t.connectSettings.headers,i,n).then((function(e){return Zt.processResponseByType(e)}));case 4:if(!(s=e.sent).error){e.next=7;break}throw s.error.message;case 7:return e.abrupt("return",s);case 8:case"end":return e.stop()}}),e)}))),function(e,n,r){return t.apply(this,arguments)})}]);var t}();Zn.FUNCTION_TOOL_RESP_ERROR="Response object must either be {response: string}[] for each individual function or {text: string} for a direct response, see https://deepchat.dev/docs/directConnection/OpenAI#FunctionHandler.";var Xn=Zn,Qn=function(){function e(){x(this,e)}return E(e,null,[{key:"storeFiles",value:(a=f(h().mark((function e(t,n,r,i){var s,a,o,l;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(s=t.connectSettings.headers){e.next=3;break}return e.abrupt("return");case 3:return t.url=i,a=s[Zt.CONTENT_TYPE],delete s[Zt.CONTENT_TYPE],o=r.map(function(){var e=f(h().mark((function e(n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new FormData,e.abrupt("return",(r.append("purpose","assistants"),r.append("file",n),new Promise((function(e){e(Xn.directFetch(t,r,"POST",!1))}))));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),e.prev=7,e.next=10,Promise.all(o);case 10:return l=e.sent.map((function(e){return{id:e.id,name:e.filename}})),e.abrupt("return",(s[Zt.CONTENT_TYPE]=a,l));case 14:throw e.prev=14,e.t0=e.catch(7),s[Zt.CONTENT_TYPE]=a,Zt.displayError(n,e.t0),t.completionsHandlers.onFinish(),e.t0;case 17:case"end":return e.stop()}}),e,null,[[7,14]])}))),function(e,t,n,r){return a.apply(this,arguments)})},{key:"getType",value:function(e,t){var n=e[t].path;return!n||n.endsWith("png")?"image":"any"}},{key:"getFiles",value:(s=f(h().mark((function t(n,r,i,s){var a,o;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=r.map((function(e){var t=e.fileId;return n.url="".concat(i).concat(t).concat(s),new Promise((function(e){e(Xn.directFetch(n,void 0,"GET",!1))}))})),t.next=3,Promise.all(a);case 3:return o=t.sent.map((function(t,n){return new Promise((function(i){var s=new FileReader;s.readAsDataURL(t),s.onload=function(t){i({src:t.target.result,name:r[n].name,type:e.getType(r,n)})}}))})),t.next=6,Promise.all(o);case 6:return t.abrupt("return",t.sent);case 7:case"end":return t.stop()}}),t)}))),function(e,t,n,r){return s.apply(this,arguments)})},{key:"getFileName",value:function(e){var t=e.split("/");return t[t.length-1]}},{key:"getFilesAndNewText",value:(i=f(h().mark((function t(n,r,i,s,a){var o,l,c,u,d;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(u=i.getFilesPrefix,d=i.getFilesPostfix,t.t0=r.length>0,!t.t0){t.next=7;break}return t.next=5,e.getFiles(n,r,u,d);case 5:c=t.sent,null!=(o=null==a?void 0:a.text)&&o.value&&c.forEach((function(e,t){var n;if(e.src){var i=r[t].path;null!=(n=null==a?void 0:a.text)&&n.value&&i&&(a.text.value=a.text.value.replace(i,e.src))}}));case 7:return t.abrupt("return",null!=(l=null==a?void 0:a.text)&&l.value?{text:a.text.value,role:s}:{files:c,role:s});case 8:case"end":return t.stop()}}),t)}))),function(e,t,n,r,s){return i.apply(this,arguments)})},{key:"getFileDetails",value:function(t,n){var r,i=[];return null!=(r=null==n?void 0:n.text)&&r.value&&t.content.forEach((function(t){var n,r;null==(r=null==(n=t.text)?void 0:n.annotations)||r.forEach((function(t){var n;t.text&&t.text.startsWith("sandbox:")&&null!=(n=t.file_path)&&n.file_id&&i.push({path:t.text,fileId:t.file_path.file_id,name:e.getFileName(t.text)})}))})),null!=n&&n.image_file&&i.push({fileId:n.image_file.file_id}),i}},{key:"getFilesAndText",value:(r=f(h().mark((function t(n,r,i,s){var a;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return a=e.getFileDetails(r,s),t.next=3,e.getFilesAndNewText(n,a,i,r.role,s);case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}}),t)}))),function(e,t,n,i){return r.apply(this,arguments)})},{key:"parseResult",value:function(e,t){var n=[];if(t)n=e.data;else for(var r=0;r0){var s=this.filesToolType;if("function"==typeof this.filesToolType){var a=this.filesToolType(n.map((function(e){return e.name})));"code_interpreter"===a||"file_search"===a||"images"===a?s=a:(console.error('Tool type "'.concat(a,'" is not valid')),console.error('Expected "code_interpreter" or "file_search" or "images". Going to default to "images"'))}if("file_search"===s)return t.processAttachmentsMessage(i,n,"file_search");if("code_interpreter"===s)return t.processAttachmentsMessage(i,n,"code_interpreter");if(n.find((function(e){var t=e.name;return!$.isImageFileExtension(t)})))console.error("The uploaded files contained a non-image file"),console.error('Make sure only images can be uploaded or define a "code_interpreter" or "file_search" value in the "files_tool_type" property'),console.warn('Make sure your existing assistant supports these "tools" or specify them in the "new_assistant" property');else{var o=t.processImageMessage(i,n);if(o)return o}}return{content:i.text||"",role:"user"}}},{key:"createNewThreadMessages",value:function(e,t,n){var r=JSON.parse(JSON.stringify(e)),i=this.processMessage(t,n);return r.thread={messages:[i]},r}},{key:"callService",value:function(e,t,n){if(this.messages=e,this.sessionId){this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/messages").concat(this.urlSegments.createMessagePostfix);var r=this.processMessage(t,n);dn.request(this,r,e)}else{this.url="".concat(this.urlSegments.threadsPrefix,"/runs").concat(this.urlSegments.threadsPosfix);var i=this.createNewThreadMessages(this.rawBody,t,n);this.isSSEStream?this.createStreamRun(i):dn.request(this,i,e)}}},{key:"callServiceAPI",value:(v=f(h().mark((function e(t,n,r){var i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.waitingForStreamResponse=!1,this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null===(i=(s=this.rawBody).assistant_id)||void 0===i){e.next=6;break}e.next=12;break;case 6:if(e.t0=this.config.assistant_id,e.t0){e.next=11;break}return e.next=10,this.createNewAssistant();case 10:e.t0=e.sent;case 11:s.assistant_id=e.t0;case 12:if(this.searchedForThreadId||this.searchPreviousMessagesForThreadId(t.messageToElements),!r){e.next=19;break}return e.next=16,$n.storeFiles(this,t,r,this.urlSegments.storeFiles);case 16:e.t1=e.sent,e.next=20;break;case 19:e.t1=void 0;case 20:a=e.t1,this.connectSettings.method="POST",this.callService(t,n,a);case 22:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return v.apply(this,arguments)})},{key:"createNewAssistant",value:(m=f(h().mark((function e(){var t;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,this.url=this.urlSegments.newAssistantUrl,e.next=4,Xn.directFetch(this,JSON.parse(JSON.stringify(this.newAssistantDetails)),"POST");case 4:return t=e.sent,e.abrupt("return",(this.config.assistant_id=t.id,this.config.assistant_id));case 8:e.prev=8,e.t0=e.catch(0),console.error(e.t0),console.error("Failed to create a new assistant");case 11:case"end":return e.stop()}}),e,this,[[0,8]])}))),function(){return m.apply(this,arguments)})},{key:"searchPreviousMessagesForThreadId",value:function(e){var t=e.find((function(e){return d(e,1)[0]._sessionId}));t&&(this.sessionId=t[0]._sessionId),this.searchedForThreadId=!0}},{key:"extractResultData",value:(p=f(h().mark((function e(t){var n,r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(this.waitingForStreamResponse||this.isSSEStream&&this.sessionId)){e.next=4;break}return e.next=3,this.handleStream(t);case 3:return e.abrupt("return",e.sent);case 4:if(!t.error){e.next=6;break}throw t.error.message.startsWith($n.FILES_WITH_TEXT_ERROR)?Error("Please send text with your file(s)"):t.error.message;case 6:return e.next=8,this.assignThreadAndRun(t);case 8:return r="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs/").concat(this.run_id).concat(this.urlSegments.threadsPosfix),i={method:"GET",headers:null==(n=this.connectSettings)?void 0:n.headers},e.abrupt("return",(dn.executePollRequest(this,r,i,this.messages),{makingAnotherRequest:!0}));case 10:case"end":return e.stop()}}),e,this)}))),function(e){return p.apply(this,arguments)})},{key:"assignThreadAndRun",value:(u=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.sessionId){e.next=8;break}return this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs").concat(this.urlSegments.threadsPosfix),e.next=4,Xn.directFetch(this,JSON.parse(JSON.stringify(this.rawBody)),"POST");case 4:n=e.sent,this.run_id=n.id,e.next=9;break;case 8:this.sessionId=t.thread_id,this.run_id=t.id,this.messages&&this.messages.messageToElements.length>0&&(this.messages.messageToElements[this.messages.messageToElements.length-1][0]._sessionId=this.sessionId);case 9:case"end":return e.stop()}}),e,this)}))),function(e){return u.apply(this,arguments)})},{key:"getThreadMessages",value:(l=f(h().mark((function e(t){var n,r,i,s,a=arguments;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=a.length>1&&void 0!==a[1]&&a[1],this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(t,"/messages?").concat(this.urlSegments.listMessagesPostfix),e.next=4,Xn.directFetch(this,{},"GET");case 4:if(s=e.sent,e.t0=!n&&this.deepChat.responseInterceptor,!e.t0){e.next=10;break}return e.next=9,null==(i=(r=this.deepChat).responseInterceptor)?void 0:i.call(r,s);case 9:s=e.sent;case 10:return e.abrupt("return",$n.processAPIMessages(this,s,n,this.urlSegments));case 11:case"end":return e.stop()}}),e,this)}))),function(e){return l.apply(this,arguments)})},{key:"extractPollResultData",value:(o=f(h().mark((function e(n){var r,i,s,a,o,l,c,u,d=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=n.status,s=n.required_action,"queued"!==i&&"in_progress"!==i){e.next=3;break}return e.abrupt("return",{timeoutMS:t.POLLING_TIMEOUT_MS});case 3:if("completed"!==i||!this.messages){e.next=11;break}return e.next=6,this.getThreadMessages(n.thread_id);case 6:return a=e.sent,o=a.shift(),l=o.text,c=o.files,e.abrupt("return",(setTimeout((function(){a.forEach((function(e){return d.deepChat.addMessage(e)}))})),{text:l,_sessionId:this.sessionId,files:c}));case 11:if(u=null==(r=null==s?void 0:s.submit_tool_outputs)?void 0:r.tool_calls,"requires_action"!==i||!u){e.next=16;break}return e.next=15,this.handleTools(u);case 15:return e.abrupt("return",e.sent);case 16:throw Error("Thread run status: ".concat(i));case 17:case"end":return e.stop()}}),e,this)}))),function(e){return o.apply(this,arguments)})},{key:"handleTools",value:(a=f(h().mark((function e(n){var r,i,s,a,o,l;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.functionHandler){e.next=2;break}throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Assistant) object.");case 2:return r=n.map((function(e){return{name:e.function.name,arguments:e.function.arguments}})),e.next=5,this.functionHandler(r);case 5:if(i=e.sent,Array.isArray(i)&&n.length===i.length){e.next=8;break}throw Error($n.FUNCTION_TOOL_RESP_ERROR);case 8:return e.next=10,Promise.all(i);case 10:if(!(s=e.sent).find((function(e){return"string"!=typeof e}))){e.next=13;break}throw Error($n.FUNCTION_TOOL_RESP_ERROR);case 13:if(a=s.map((function(e,t){return{tool_call_id:n[t].id,output:e}})),o="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId),l="/runs/".concat(this.run_id,"/submit_tool_outputs").concat(this.urlSegments.threadsPosfix),this.url="".concat(o).concat(l),!this.isSSEStream){e.next=20;break}return e.next=18,this.createStreamRun({tool_outputs:a});case 18:e.next=22;break;case 20:return e.next=22,Xn.directFetch(this,{tool_outputs:a},"POST");case 22:return e.abrupt("return",{timeoutMS:t.POLLING_TIMEOUT_MS});case 23:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"handleStream",value:(i=f(h().mark((function e(t){var n,r,i,s;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=null==(r=null==(n=t.required_action)?void 0:n.submit_tool_outputs)?void 0:r.tool_calls,"requires_action"!==t.status||!i){e.next=6;break}return this.run_id=t.id,e.next=5,this.handleTools(i);case 5:return e.abrupt("return",e.sent);case 6:if(!this.waitingForStreamResponse){e.next=8;break}return e.abrupt("return",this.parseStreamResult(t));case 8:return this.isSSEStream&&this.sessionId&&(this.url="".concat(this.urlSegments.threadsPrefix,"/").concat(this.sessionId,"/runs").concat(this.urlSegments.threadsPosfix),s=JSON.parse(JSON.stringify(this.rawBody)),this.createStreamRun(s)),e.abrupt("return",{makingAnotherRequest:!0});case 10:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"parseStreamResult",value:(r=f(h().mark((function e(t){var n,r,i,s,a,o,l,c,u,d;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t.content&&t.content.length>0&&this.messages)){e.next=5;break}if(o=t.content.find((function(e){return e.text})),!(null!=(n=null==o?void 0:o.text)&&n.annotations&&o.text.annotations.length>0)){e.next=5;break}return l=t.content.find((function(e){return!!e.text}))||t.content[0],c=$n.getFilesAndText.bind(this,this,{role:"assistant",content:t.content},this.urlSegments,l),e.abrupt("return",(null==(r=this.messageStream)||r.endStreamAfterFileDownloaded(this.messages,c),{text:""}));case 5:if(null==(i=t.delta)||!i.content){e.next=14;break}if(!(t.delta.content.length>1)){e.next=13;break}if(u=t.delta.content.find((function(e){return e.text})),null==(s=null==u?void 0:u.text)||!s.annotations||0!==u.text.annotations.length){e.next=13;break}return e.next=11,$n.processStreamMessages(this,t.delta.content,this.urlSegments);case 11:return d=e.sent,e.abrupt("return",{text:d[0].text,files:d[1].files});case 13:return e.abrupt("return",{text:null==(a=t.delta.content[0].text)?void 0:a.value});case 14:return e.abrupt("return",(!this.sessionId&&t.thread_id&&(this.sessionId=t.thread_id),{makingAnotherRequest:!0}));case 15:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"createStreamRun",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.stream=!0,this.waitingForStreamResponse=!0,e.next=4,an.request(this,t,this.messages,!0,!0);case 4:this.messageStream=e.sent;case 5:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"processImageMessage",value:function(e,t){var n=null==t?void 0:t.filter((function(e){return $.isImageFileExtension(e.name)})).map((function(e){return{type:"image_file",image_file:{file_id:e.id}}}));if(n&&n.length>0)return e.text&&e.text.length>0&&n.push({type:"text",text:e.text}),{content:n,role:"user"}}},{key:"processAttachmentsMessage",value:function(e,t,n){return{attachments:t.map((function(e){return{tools:[{type:n}],file_id:e.id}})),content:[{type:"text",text:e.text}],role:"user"}}}]);var n,r,i,a,o,l,u,p,m,v,g}(gn);er.POLLING_TIMEOUT_MS=800;var tr=er,nr=function(e){function t(e){var n,r,i,o,l,c,u,d;x(this,t);var h=JSON.parse(JSON.stringify(e.directConnection)),p=h.openAI,f=null==(o=h.openAI)?void 0:o.assistant;if(null!==(n=(l=(i=s(this,t,[e,f,t.URL_SEGMENTS,Xn.buildKeyVerificationDetails(),Xn.buildHeaders,p])).connectSettings).headers)&&void 0!==n||(l.headers={}),null!==(r=(c=i.connectSettings.headers)["OpenAI-Beta"])&&void 0!==r||(c["OpenAI-Beta"]="assistants=v2"),i.shouldFetchHistory&&i.sessionId&&(i.fetchHistory=i.fetchHistoryFunc.bind(a(i))),"object"==_(f)){var m=null==(d=null==(u=e.directConnection)?void 0:u.openAI)?void 0:d.assistant,v=m.function_handler,g=m.files_tool_type;v&&(i.functionHandler=v),g&&(i.filesToolType=g)}return i}return c(t,e),E(t)}(tr);nr.URL_SEGMENTS={threadsPrefix:"https://api.openai.com/v1/threads",threadsPosfix:"",newAssistantUrl:"https://api.openai.com/v1/assistants",createMessagePostfix:"",listMessagesPostfix:"order=desc",storeFiles:"https://api.openai.com/v1/files",getFilesPrefix:"https://api.openai.com/v1/files/",getFilesPostfix:"/content"};var rr=nr,ir=function(){function e(){x(this,e)}return E(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json",accept:"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i;null!=(i=e.message)&&i.includes("invalid request: prompt must be at least 1 token long")?n(t):r(G.INVALID_KEY)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.cohere.ai/v1/generate",method:"POST",handleVerificationResult:e.handleVerificationResult,body:JSON.stringify({prompt:""})}}}])}(),sr=function(e){function t(e,n,r,i,a){var o;return x(this,t),(o=s(this,t,[e,ir.buildKeyVerificationDetails(),ir.buildHeaders,a])).insertKeyPlaceholderText="Cohere API Key",o.keyHelpUrl="https://dashboard.cohere.ai/api-keys",o.permittedErrorPrefixes=["invalid"],o.url=n,o.textInputPlaceholderText=r,i&&"object"==_(i)&&Object.assign(o.rawBody,i),o}return c(t,e),E(t)}(gn),ar=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"https://api.cohere.ai/v1/generate","Once upon a time",null==(r=null==(n=e.directConnection)?void 0:n.cohere)?void 0:r.textGeneration,null==(i=e.directConnection)?void 0:i.cohere])}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t[t.length-1].text;if(r)return b({prompt:r},n)}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:(null==(n=t.generations)?void 0:n[0].text)||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(sr),or=function(){return E((function e(){x(this,e)}),null,[{key:"buildHeaders",value:function(e){return{"api-key":e,"Content-Type":"application/json"}}},{key:"buildKeyVerificationDetails",value:function(e){return{url:"".concat(e.endpoint,"/openai/models?api-version=").concat(e.version),method:"GET",handleVerificationResult:Xn.handleVerificationResult}}},{key:"validateURLDetails",value:function(e){var t=e.endpoint,n=e.version,r=e.deploymentId;return t&&n&&r}}])}();or.URL_DETAILS_ERROR_MESSAGE="Please define the Azure URL Details. [More Information](https://deepchat.dev/docs/directConnection/Azure)";var lr=or,cr=function(e){function t(e){var n,r,i,a,o,l,c,u,d,h;x(this,t);var p=JSON.parse(JSON.stringify(e.directConnection)),f=p.azure,m=null==(i=p.azure)?void 0:i.openAI,v=(null==m?void 0:m.urlDetails)||{},g="".concat(null==(a=null==m?void 0:m.urlDetails)?void 0:a.endpoint,"/openai/"),y="?api-version=".concat(null==(o=null==m?void 0:m.urlDetails)?void 0:o.version),b={threadsPrefix:"".concat(g).concat(t.THREAD_RESOURCE),threadsPosfix:y,newAssistantUrl:"".concat(g).concat(t.NEW_ASSISTANT_RESOURCE).concat(y),createMessagePostfix:y,listMessagesPostfix:"order=desc&api-version=".concat(null==(l=null==m?void 0:m.urlDetails)?void 0:l.version),storeFiles:"".concat(g,"files").concat(y),getFilesPrefix:"".concat(g,"files/"),getFilesPostfix:"/content".concat(y)};if((r=s(this,t,[e,null==m?void 0:m.assistant,b,lr.buildKeyVerificationDetails(v),lr.buildHeaders,f])).permittedErrorPrefixes=[lr.URL_DETAILS_ERROR_MESSAGE],r.insertKeyPlaceholderText="Azure OpenAI API Key",r.keyHelpUrl="https://learn.microsoft.com/en-us/answers/questions/1193991/how-to-get-the-value-of-openai-api-key",r.isTextInputDisabled=!1,"object"==_(null==m?void 0:m.assistant)){var k=null==(d=null==(u=null==(c=e.directConnection)?void 0:c.azure)?void 0:u.openAI)?void 0:d.assistant,S=k.function_handler,E=k.files_tool_type;S&&(r.functionHandler=S),E&&(r.filesToolType=E)}return lr.validateURLDetails(v)?null!==(n=(h=r.connectSettings).headers)&&void 0!==n||(h.headers={}):(r.isTextInputDisabled=!0,r.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:lr.URL_DETAILS_ERROR_MESSAGE})}))),r}return c(t,e),E(t)}(tr);cr.THREAD_RESOURCE="threads",cr.NEW_ASSISTANT_RESOURCE="assistants";var ur=cr,dr=function(e){function t(e){var n,r,i;return x(this,t),s(this,t,[e,"https://api.cohere.ai/v1/summarize","Insert text to summarize",null==(r=null==(n=e.directConnection)?void 0:n.cohere)?void 0:r.summarization,null==(i=e.directConnection)?void 0:i.cohere])}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t[t.length-1].text;if(r)return b({text:r},n)}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.summary||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(sr),hr=function(e){function t(e){var n,r,i,a,o,l;x(this,t);var c=JSON.parse(JSON.stringify(e.directConnection)),u=null==c?void 0:c.openAI;(i=s(this,t,[e,Xn.buildKeyVerificationDetails(),Xn.buildHeaders,u])).insertKeyPlaceholderText="OpenAI API Key",i.keyHelpUrl="https://platform.openai.com/account/api-keys",i.url="https://api.openai.com/v1/audio/speech",i.permittedErrorPrefixes=["Invalid"],i.introPanelMarkUp='\n
    OpenAI : Text To Speech
    \n

    Generate an audio file based on your text input.

    \n

    Click here for more information.

    ';var d=null==(a=null==c?void 0:c.openAI)?void 0:a.textToSpeech;return"object"==_(d)&&Object.assign(i.rawBody,d),null!==(n=(o=i.rawBody).model)&&void 0!==n||(o.model=t.DEFAULT_MODEL),null!==(r=(l=i.rawBody).voice)&&void 0!==r||(l.voice=t.DEFAULT_VOIDE),i.textInputPlaceholderText="Insert text to generate audio",i.rawBody.response_format="mp3",i}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n,r,i=JSON.parse(JSON.stringify(e)),s=null==(r=null==(n=t[t.length-1])?void 0:n.text)?void 0:r.trim();return s&&""!==s&&(i.input=s),i}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=this.connectSettings)&&r.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:this.url=this.connectSettings.url||this.url,i=this.preprocessBody(this.rawBody,n),dn.request(this,i,t);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(t instanceof Blob)){e.next=2;break}return e.abrupt("return",new Promise((function(e){var n=new FileReader;n.readAsDataURL(t),n.onload=function(t){e({files:[{src:t.target.result,type:"audio"}]})}})));case 2:if(!t.error){e.next=4;break}throw t.error.message;case 4:return e.abrupt("return",{error:"error"});case 5:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(gn);hr.DEFAULT_MODEL="tts-1",hr.DEFAULT_VOIDE="alloy";var pr=hr,fr=function(e){function t(e){var n,r,i,a;x(this,t);var o=JSON.parse(JSON.stringify(e.directConnection)),l=null==o?void 0:o.openAI;(r=s(this,t,[e,Xn.buildKeyVerificationDetails(),Xn.buildHeaders,l,{audio:{}}])).insertKeyPlaceholderText="OpenAI API Key",r.keyHelpUrl="https://platform.openai.com/account/api-keys",r.introPanelMarkUp='\n
    OpenAI : Speech To Text
    \n

    Upload an audio file to transcribe it into text. You can optionally provide text to guide the audio\n processing.\n

    Click here for more info.

    ',r.url="",r.permittedErrorPrefixes=["Invalid"],r.textInputPlaceholderText="Upload an audio file",r._service_url=t.AUDIO_TRANSCRIPTIONS_URL;var c=null==(i=null==o?void 0:o.openAI)?void 0:i.audio;return"object"==_(c)&&(r.processConfig(c),t.cleanConfig(c),Object.assign(r.rawBody,c)),null!==(n=(a=r.rawBody).model)&&void 0!==n||(a.model=t.DEFAULT_MODEL),r.rawBody.response_format="json",r.canSendMessage=t.canSendFileMessage,r}return c(t,e),E(t,[{key:"processConfig",value:function(e){null!=e&&e.type&&"translation"===e.type&&(this._service_url=t.AUDIO_TRANSLATIONS_URL,delete e.language)}},{key:"preprocessBody",value:function(e,t){var n,r,i=JSON.parse(JSON.stringify(e)),s=null==(r=null==(n=t[t.length-1])?void 0:n.text)?void 0:r.trim();return s&&""!==s&&(i.prompt=s),i}},{key:"callServiceAPI",value:(r=f(h().mark((function e(n,r,i){var s,a,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(s=this.connectSettings)&&s.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=i&&i[0]){e.next=4;break}throw new Error("No file was added");case 4:this.url=this.connectSettings.url||this._service_url,a=this.preprocessBody(this.rawBody,r),o=t.createFormDataBody(a,i[0]),Zt.tempRemoveContentHeader(this.connectSettings,dn.request.bind(this,this,o,n),!1);case 7:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canSendFileMessage",value:function(e,t){return!(null==t||!t[0])}},{key:"cleanConfig",value:function(e){delete e.type}},{key:"createFormDataBody",value:function(e,t){var n=new FormData;return n.append("file",t),Object.keys(e).forEach((function(t){n.append(t,String(e[t]))})),n}}]);var n,r}(gn);fr.AUDIO_TRANSCRIPTIONS_URL="https://api.openai.com/v1/audio/transcriptions",fr.AUDIO_TRANSLATIONS_URL="https://api.openai.com/v1/audio/translations",fr.DEFAULT_MODEL="whisper-1";var mr=fr,vr=function(){function e(){x(this,e)}return E(e,null,[{key:"buildTextToSpeechHeaders",value:function(e,t){return{"Ocp-Apim-Subscription-Key":t,"Content-Type":"application/ssml+xml","X-Microsoft-OutputFormat":e}}},{key:"buildSpeechToTextHeaders",value:function(e){return{"Ocp-Apim-Subscription-Key":e,Accept:"application/json"}}},{key:"handleSpeechVerificationResult",value:function(e,t,n,r){e.error?r(G.INVALID_KEY):n(t)}},{key:"buildSpeechKeyVerificationDetails",value:function(t){return{url:"https://".concat(t,".api.cognitive.microsoft.com/sts/v1.0/issuetoken"),method:"POST",createHeaders:function(e){return{"Ocp-Apim-Subscription-Key":"".concat(e)}},handleVerificationResult:e.handleSpeechVerificationResult}}},{key:"buildSummarizationHeader",value:function(e){return{"Ocp-Apim-Subscription-Key":e,"Content-Type":"application/json"}}},{key:"handleLanguageVerificationResult",value:function(e,t,n,r){var i;"401"===(null==(i=e.error)?void 0:i.code)?r(G.INVALID_KEY):n(t)}},{key:"buildLanguageKeyVerificationDetails",value:function(t){return{url:"".concat(t,"/language/analyze-text/jobs?api-version=2022-10-01-preview"),method:"POST",createHeaders:function(e){return{"Ocp-Apim-Subscription-Key":"".concat(e)}},handleVerificationResult:e.handleLanguageVerificationResult}}},{key:"handleTranslationVerificationResult",value:function(e,t,n,r){e.json().then((function(e){Array.isArray(e)||401e3!==e.error.code?n(t):r(G.INVALID_KEY)}))}},{key:"buildTranslationKeyVerificationDetails",value:function(t){return{url:"https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=es",method:"POST",createHeaders:function(n){return e.buildTranslationHeaders(t,n)},handleVerificationResult:e.handleTranslationVerificationResult}}},{key:"buildTranslationHeaders",value:function(e,t){var n={"Ocp-Apim-Subscription-Key":t,"Content-Type":"application/json"};return e&&(n["Ocp-Apim-Subscription-Region"]=e),n}}])}(),gr=function(e){function t(e){var n,r,i,a,o,l;x(this,t);var c=null==(a=null==(i=e.directConnection)?void 0:i.azure)?void 0:a.summarization,u=null==(o=e.directConnection)?void 0:o.azure;return(r=s(this,t,[e,vr.buildSummarizationHeader,c.endpoint,u])).permittedErrorPrefixes=[t.ENDPOINT_ERROR_MESSAGE],r.url="",r.textInputPlaceholderText="Insert text to summarize",r.isTextInputDisabled=!1,c.endpoint?(null!==(n=(l=r.rawBody).language)&&void 0!==n||(l.language="en"),Object.assign(r.rawBody,c),r.url="".concat(c.endpoint,"/language/analyze-text/jobs?api-version=2022-10-01-preview")):(r.isTextInputDisabled=!0,r.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.ENDPOINT_ERROR_MESSAGE})}))),r}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return{analysisInput:{documents:[{id:"1",language:e.language,text:n}]},tasks:[{kind:"ExtractiveSummarization"}]}}},{key:"callServiceAPI",value:(a=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t),this.messages=t;case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"extractResultData",value:(i=f(h().mark((function e(t){var n,r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return this.messages&&this.completionsHandlers&&(r=t.headers.get("operation-location"),i={method:"GET",headers:null==(n=this.connectSettings)?void 0:n.headers},dn.executePollRequest(this,r,i,this.messages)),e.abrupt("return",{makingAnotherRequest:!0});case 4:case"end":return e.stop()}}),e,this)}))),function(e){return i.apply(this,arguments)})},{key:"extractPollResultData",value:(n=f(h().mark((function e(t){var n,i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:if("running"!==t.status){e.next=4;break}return e.abrupt("return",{timeoutMS:2e3});case 4:if(!(t.errors.length>0)){e.next=6;break}throw t.errors[0];case 6:if(!(t.tasks.items[0].results.errors.length>0)){e.next=8;break}throw t.tasks.items[0].results.errors[0];case 8:n="",i=r(t.tasks.items[0].results.documents[0].sentences);try{for(i.s();!(s=i.n()).done;)a=s.value,n+=a.text}catch(o){i.e(o)}finally{i.f()}return e.abrupt("return",{text:n||""});case 12:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,i,a}(function(e){function t(e,n,r,i,a){var o;return x(this,t),(o=s(this,t,[e,vr.buildLanguageKeyVerificationDetails(r),n,i,a])).insertKeyPlaceholderText="Azure Language Subscription Key",o.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",o.permittedErrorPrefixes=["Access"],o}return c(t,e),E(t)}(gn));gr.ENDPOINT_ERROR_MESSAGE="Please define the azure endpoint. [More Information](https://deepchat.dev/docs/directConnection/Azure#Summarization)";var yr=gr,br=function(){function e(){x(this,e)}return E(e,null,[{key:"poll",value:(t=f(h().mark((function e(t,n){var r,i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={authorization:t,"content-type":"application/json"},e.t0="https://api.assemblyai.com/v2/transcript/",e.next=4,fetch("https://api.assemblyai.com/v2/transcript",{method:"POST",body:JSON.stringify({audio_url:n}),headers:r});case 4:return e.next=6,e.sent.json();case 6:e.t1=e.sent.id,i=e.t0.concat.call(e.t0,e.t1);case 8:if(s){e.next=24;break}return e.next=11,fetch(i,{headers:r});case 11:return e.next=13,e.sent.json();case 13:if("completed"!==(a=e.sent).status){e.next=18;break}s=a,e.next=22;break;case 18:if("error"!==a.status){e.next=20;break}throw new Error("Transcription failed: ".concat(a.error));case 20:return e.next=22,new Promise((function(e){return setTimeout(e,3e3)}));case 22:e.next=8;break;case 24:return e.abrupt("return",s);case 25:case"end":return e.stop()}}),e)}))),function(e,n){return t.apply(this,arguments)})},{key:"buildHeaders",value:function(e){return{Authorization:e,"Content-Type":"application/octet-stream"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i=e;i.error?"invalid_api_key"===i.error.code?r(G.INVALID_KEY):r(G.CONNECTION_FAILED):n(t)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.assemblyai.com/v2/upload",method:"POST",handleVerificationResult:e.handleVerificationResult}}}]);var t}(),kr=function(e){function t(e){var n,r;x(this,t);var i=null==(r=e.directConnection)?void 0:r.assemblyAI;return(n=s(this,t,[e,br.buildKeyVerificationDetails(),br.buildHeaders,i,{audio:{}}])).insertKeyPlaceholderText="AssemblyAI API Key",n.keyHelpUrl="https://www.assemblyai.com/app/account",n.introPanelMarkUp='\n
    AssemblyAI Audio
    \n

    Upload an audio file to transcribe it into text.\n

    \n Click here for more info.\n

    ',n.url="https://api.assemblyai.com/v2/upload",n.isTextInputDisabled=!0,n.textInputPlaceholderText="Upload an audio file",n.permittedErrorPrefixes=["Authentication","Invalid"],n.canSendMessage=t.canFileSendMessage,n}return c(t,e),E(t,[{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){var i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(i=this.connectSettings)&&i.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:dn.request(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){var n,r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return i=null==(r=null==(n=this.connectSettings)?void 0:n.headers)?void 0:r.Authorization,e.next=5,br.poll(i,t.upload_url);case 5:return e.t0=e.sent.text,e.abrupt("return",{text:e.t0});case 7:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(gn),_r=function(e){function t(e,n,r,i,a){var o;return x(this,t),(o=s(this,t,[e,vr.buildSpeechKeyVerificationDetails(r),n,i,a])).insertKeyPlaceholderText="Azure Speech Subscription Key",o.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",o}return c(t,e),E(t)}(gn),xr=function(e){function t(e){var n,r,i,a,o,l,c,u,d,h;x(this,t);var p=null==(l=null==(o=e.directConnection)?void 0:o.azure)?void 0:l.textToSpeech,f=null==(c=e.directConnection)?void 0:c.azure;return(a=s(this,t,[e,vr.buildTextToSpeechHeaders.bind({},(null==p?void 0:p.outputFormat)||"audio-16khz-128kbitrate-mono-mp3"),p.region,f])).permittedErrorPrefixes=[t.REGION_ERROR_MESSAGE],a.introPanelMarkUp='\n
    Azure Text To Speech
    \n

    Insert text to synthesize it to audio.\n

    \n Click here for more info.\n

    '),a.isTextInputDisabled=!1,a.url="",p.region?(Object.assign(a.rawBody,p),null!==(n=(u=a.rawBody).lang)&&void 0!==n||(u.lang="en-US"),null!==(r=(d=a.rawBody).name)&&void 0!==r||(d.name="en-US-JennyNeural"),null!==(i=(h=a.rawBody).gender)&&void 0!==i||(h.gender="Female"),a.url="https://".concat(p.region,".tts.speech.microsoft.com/cognitiveservices/v1")):(a.isTextInputDisabled=!0,a.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.REGION_ERROR_MESSAGE})}))),a}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=t[t.length-1].text;if(n)return"\n \n ").concat(n,"\n \n ")}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t,!1);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){var n=new FileReader;n.readAsDataURL(t),n.onload=function(t){e({files:[{src:t.target.result,type:"audio"}]})}})));case 1:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(_r);xr.HELP_LINK="https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest",xr.REGION_ERROR_MESSAGE="Please define a region config property. [More Information](https://deepchat.dev/docs/directConnection/Azure#TextToSpeech)";var Sr=xr,Er=function(e){function t(e){var n,r,i,a;x(this,t);var o=null==(i=null==(r=e.directConnection)?void 0:r.azure)?void 0:i.speechToText,l=null==(a=e.directConnection)?void 0:a.azure;if((n=s(this,t,[e,vr.buildSpeechToTextHeaders,o.region,l,{audio:{files:{acceptedFormats:".wav,.ogg"}}}])).permittedErrorPrefixes=[t.REGION_ERROR_MESSAGE],n.introPanelMarkUp='\n
    Azure Speech To Text
    \n

    Upload a .wav or .ogg audio file to transcribe it into text.\n

    \n Click here for more info.\n

    '),n.url="",n.isTextInputDisabled=!0,n.textInputPlaceholderText="Upload an audio file",o.region){n.canSendMessage=t.canFileSendMessage;var c=o.lang||"en-US";n.url="https://".concat(o.region,".stt.speech.microsoft.com/speech/recognition/conversation/cognitiveservices/v1?language=").concat(c,"&format=detailed"),n.recordAudio=void 0}else n.isTextInputDisabled=!0,n.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:t.REGION_ERROR_MESSAGE})}));return n}return c(t,e),E(t,[{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n,r){var i,s;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(i=this.connectSettings)&&i.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null!=r&&r[0]){e.next=4;break}throw new Error("No file was added");case 4:null!=(s=this.connectSettings)&&s.headers&&(this.connectSettings.headers["Content-Type"]=r[0].name.toLocaleLowerCase().endsWith(".wav")?"audio/wav; codecs=audio/pcm; samplerate=16000":"audio/ogg; codecs=opus"),dn.request(this,r[0],t,!1);case 5:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error;case 2:return e.abrupt("return",{text:t.DisplayText||""});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])}}]);var n,r}(_r);Er.HELP_LINK="https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest",Er.REGION_ERROR_MESSAGE="Please define a region config property. [More Information](https://deepchat.dev/docs/directConnection/Azure#SpeechToText)";var wr=Er,Cr=function(e){function t(e){var n,r,i,a;x(this,t);var o=null==(i=null==(r=e.directConnection)?void 0:r.azure)?void 0:i.translation,l=null==(a=e.directConnection)?void 0:a.azure;return(n=s(this,t,[e,vr.buildTranslationKeyVerificationDetails(o.region),vr.buildTranslationHeaders.bind({},null==o?void 0:o.region),l])).insertKeyPlaceholderText="Azure Translate Subscription Key",n.keyHelpUrl="https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",n.url="",n.url="https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(o.language||"es"),n}return c(t,e),E(t,[{key:"preprocessBody",value:function(e){var t=e[e.length-1].text;if(t)return[{Text:t}]}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(n),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!Array.isArray(t)){e.next=2;break}return e.abrupt("return",{text:(null==(n=t[0].translations)?void 0:n[0].text)||""});case 2:throw t.error;case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(gn),Tr=function(e){function t(e,n,r,i,a){var o,l,c,u,d,h,p;x(this,t);var f=JSON.parse(JSON.stringify(e.directConnection));(c=s(this,t,[e,n||Xn.buildKeyVerificationDetails(),r||Xn.buildHeaders,i||f.openAI])).insertKeyPlaceholderText="OpenAI API Key",c.keyHelpUrl="https://platform.openai.com/account/api-keys",c.url="https://api.openai.com/v1/chat/completions",c.permittedErrorPrefixes=["Incorrect"],c.asyncCallInProgress=!1,c._systemMessage=t.generateSystemMessage("You are a helpful assistant.");var m=a||(null==(u=f.openAI)?void 0:u.chat);if("object"==_(m)){m.system_prompt&&(c._systemMessage=t.generateSystemMessage(m.system_prompt));var v=(null==(h=null==(d=e.directConnection)?void 0:d.openAI)?void 0:h.chat).function_handler;v&&(c._functionHandler=v),c.cleanConfig(m),Object.assign(c.rawBody,m)}return null!==(o=c.maxMessages)&&void 0!==o||(c.maxMessages=-1),null!==(l=(p=c.rawBody).model)&&void 0!==l||(p.model="gpt-4o"),c}return c(t,e),E(t,[{key:"cleanConfig",value:function(e){delete e.system_prompt,delete e.function_handler}},{key:"preprocessBody",value:function(e,n){var r,i=JSON.parse(JSON.stringify(e)),s=fn.getCharacterLimitMessages(n,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.content.length:-1).map((function(e){return{content:t.getContent(e),role:e.role===Wt.USER_ROLE?"user":"assistant"}}));return n.find((function(e){return e.files&&e.files.length>0}))&&(null!==(r=i.max_tokens)&&void 0!==r||(i.max_tokens=300)),i.messages=[this._systemMessage].concat(m(s)),i}},{key:"callServiceAPI",value:(a=f(h().mark((function e(t,n){var r,i;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),(i=this.stream)&&("object"!=_(i)||!i.simulation)||r.stream?(r.stream=!0,an.request(this,r,t)):dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return a.apply(this,arguments)})},{key:"extractResultData",value:(i=f(h().mark((function e(t,n,r){var i,s,a,o;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",null!=(s=null==(i=t.choices)?void 0:i[0])&&s.delta?this.extractStreamResult(t.choices[0],n,r):null!=(o=null==(a=t.choices)?void 0:a[0])&&o.message?t.choices[0].message.tool_calls?this.handleTools(t.choices[0].message,n,r):{text:t.choices[0].message.content}:{text:""});case 3:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return i.apply(this,arguments)})},{key:"extractStreamResult",value:(r=f(h().mark((function e(t,n,r){var i,s,a=this;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=t.delta,"tool_calls"!==t.finish_reason){e.next=7;break}return this.asyncCallInProgress=!0,s={tool_calls:this._streamToolCalls},e.abrupt("return",(this._streamToolCalls=void 0,this.handleTools(s,n,r)));case 7:null!=i&&i.tool_calls&&(this._streamToolCalls?i.tool_calls.forEach((function(e,t){a._streamToolCalls&&(a._streamToolCalls[t].function.arguments+=e.function.arguments)})):this._streamToolCalls=i.tool_calls);case 8:return e.abrupt("return",{text:(null==i?void 0:i.content)||""});case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"handleTools",value:(n=f(h().mark((function e(t,n,r){var i,s,a,o,l,c,u,d,p,f,m;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.tool_calls&&n&&r&&this._functionHandler){e.next=2;break}throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Chat) object.");case 2:return c=JSON.parse(JSON.stringify(r)),u=t.tool_calls.map((function(e){return{name:e.function.name,arguments:e.function.arguments}})),e.next=6,null==(i=this._functionHandler)?void 0:i.call(this,u);case 6:if(d=e.sent,Array.isArray(d)){e.next=17;break}if(!d.text){e.next=16;break}return p={text:d.text},e.next=12,null==(a=(s=this.deepChat).responseInterceptor)?void 0:a.call(s,p);case 12:if(e.t0=e.sent,e.t0){e.next=15;break}e.t0=p;case 15:return e.abrupt("return",e.t0);case 16:throw Error(Xn.FUNCTION_TOOL_RESP_ERROR);case 17:return e.next=19,Promise.all(d);case 19:if(f=e.sent,c.messages.push({tool_calls:t.tool_calls,role:"assistant",content:null}),f.find((function(e){return"string"!=typeof e}))||u.length!==f.length){e.next=40;break}return f.forEach((function(e,n){var r,i=null==(r=t.tool_calls)?void 0:r[n];null==c||c.messages.push({role:"tool",tool_call_id:null==i?void 0:i.id,name:null==i?void 0:i.function.name,content:e.response})})),delete c.tools,delete c.tool_choice,delete c.stream,e.prev=22,e.next=25,null==n?void 0:n(c).then((function(e){return Zt.processResponseByType(e)}));case 25:return m=e.sent,e.next=28,null==(l=(o=this.deepChat).responseInterceptor)?void 0:l.call(o,m);case 28:if(e.t1=e.sent,e.t1){e.next=31;break}e.t1=m;case 31:if(!(m=e.t1).error){e.next=34;break}throw m.error.message;case 34:return e.abrupt("return",{text:m.choices[0].message.content||""});case 37:throw e.prev=37,e.t2=e.catch(22),this.asyncCallInProgress=!1,e.t2;case 40:throw Error(Xn.FUNCTION_TOOL_RESP_ERROR);case 41:case"end":return e.stop()}}),e,this,[[22,37]])}))),function(e,t,r){return n.apply(this,arguments)})}],[{key:"generateSystemMessage",value:function(e){return{role:"system",content:e}}},{key:"getContent",value:function(e){if(e.files&&e.files.length>0){var t=e.files.map((function(e){return{type:"image_url",image_url:{url:e.src}}}));return e.text&&e.text.trim().length>0&&t.unshift({type:"text",text:e.text}),t}return e.text}}]);var n,r,i,a}(gn),Ar=function(e){function t(e){var n,r,i,a,o,l,c,u;x(this,t);var d=JSON.parse(JSON.stringify(e.directConnection)),h=d.azure,p=(null==(i=null==(r=d.azure)?void 0:r.openAI)?void 0:i.urlDetails)||{},f=null==(o=null==(a=d.azure)?void 0:a.openAI)?void 0:o.chat;if((n=s(this,t,[e,lr.buildKeyVerificationDetails(p),lr.buildHeaders,h,f])).permittedErrorPrefixes=[lr.URL_DETAILS_ERROR_MESSAGE],n.isTextInputDisabled=!1,"object"==_(f)){var m=(null==(u=null==(c=null==(l=e.directConnection)?void 0:l.azure)?void 0:c.openAI)?void 0:u.chat).function_handler;m&&(n._functionHandler=m)}return lr.validateURLDetails(p)?n.url=t.buildURL(p):(n.isTextInputDisabled=!0,n.canSendMessage=function(){return!1},setTimeout((function(){e.addMessage({error:lr.URL_DETAILS_ERROR_MESSAGE})}))),n}return c(t,e),E(t,null,[{key:"buildURL",value:function(e){var t=e.endpoint,n=e.deploymentId,r=e.version;return"".concat(t,"/openai/deployments/").concat(n,"/completions?api-version=").concat(r)}}])}(Tr),Mr=function(e){function t(e){var n,r;x(this,t);var i=e.directConnection,a=null==i?void 0:i.openAI;(n=s(this,t,[e,Xn.buildKeyVerificationDetails(),Xn.buildHeaders,a,{images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}}])).insertKeyPlaceholderText="OpenAI API Key",n.keyHelpUrl="https://platform.openai.com/account/api-keys",n.introPanelMarkUp='\n
    OpenAI DALL\xb7E
    \n

    Insert text to generate an image.

    \n

    Upload 1 PNG image to generate its variation and optionally insert text to specify the change.

    \n

    Upload 2 PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.

    \n

    Click here for more info.

    ',n.url="",n.permittedErrorPrefixes=["Incorrect","Invalid input image"];var o=null==(r=null==i?void 0:i.openAI)?void 0:r.images;if(n.camera){var l="object"==_(o)&&o.size?Number.parseInt(o.size):1024;n.camera.files={dimensions:{width:l,height:l}}}return"object"==_(o)&&Object.assign(n.rawBody,o),n.canSendMessage=t.canFileSendMessage,n}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e));return t&&""!==t&&(n.prompt=t),n}},{key:"callApiWithImage",value:function(e,n,r){var i,s,a,o=null==(s=null==(i=n[n.length-1])?void 0:i.text)?void 0:s.trim();if(r[1]||o&&""!==o){this.url=t.IMAGE_EDIT_URL;var l=this.preprocessBody(this.rawBody,o);a=t.createFormDataBody(l,r[0],r[1])}else this.url=t.IMAGE_VARIATIONS_URL,a=t.createFormDataBody(this.rawBody,r[0]);Zt.tempRemoveContentHeader(this.connectSettings,dn.request.bind(this,this,a,e),!1)}},{key:"callServiceAPI",value:(r=f(h().mark((function e(n,r,i){var s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(s=this.connectSettings)&&s.headers){e.next=2;break}throw new Error("Request settings have not been set up");case 2:if(null==i||!i[0]){e.next=6;break}this.callApiWithImage(n,r,i),e.next=11;break;case 6:if(this.connectSettings){e.next=8;break}throw new Error("Request settings have not been set up");case 8:this.url=t.IMAGE_GENERATION_URL,a=this.preprocessBody(this.rawBody,r[r.length-1].text),dn.request(this,a,n);case 11:case"end":return e.stop()}}),e,this)}))),function(e,t,n){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.error){e.next=2;break}throw t.error.message;case 2:return e.abrupt("return",{files:t.data.map((function(e){return e.url?{src:e.url,type:"image"}:{src:"".concat(Bn).concat(e.b64_json),type:"image"}}))});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}],[{key:"canFileSendMessage",value:function(e,t){return!(null==t||!t[0])||!(!e||""===e.trim())}},{key:"createFormDataBody",value:function(e,t,n){var r=new FormData;return r.append("image",t),n&&r.append("mask",n),Object.keys(e).forEach((function(t){r.append(t,String(e[t]))})),r}}]);var n,r}(gn);Mr.IMAGE_GENERATION_URL="https://api.openai.com/v1/images/generations",Mr.IMAGE_VARIATIONS_URL="https://api.openai.com/v1/images/variations",Mr.IMAGE_EDIT_URL="https://api.openai.com/v1/images/edits";var Ir=Mr,Lr=function(e){function t(e){var n,r,i;x(this,t);var a=JSON.parse(JSON.stringify(e.directConnection)),o=null==(i=a.cohere)?void 0:i.chat;return r=s(this,t,[e,"https://api.cohere.ai/v1/chat","Ask me anything!",o,a.cohere]),"object"==_(o)&&Object.assign(r.rawBody,o),null!==(n=r.maxMessages)&&void 0!==n||(r.maxMessages=-1),r}return c(t,e),E(t,[{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t.filter((function(e){return e.text}));return n.query=r[r.length-1].text,n.chat_history=r.slice(0,r.length-1).map((function(e){return{text:e.text,user_name:"ai"===e.role?"CHATBOT":"USER"}})),n}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(sr),Rr=function(){function e(){x(this,e)}return E(e,null,[{key:"buildHeaders",value:function(e){return{Authorization:"Bearer ".concat(e),"Content-Type":"application/json",accept:"application/json"}}},{key:"handleVerificationResult",value:function(e,t,n,r){var i;null!=(i=e.message)&&i.includes("invalid request: prompt must be at least 1 token long")?n(t):r(G.INVALID_KEY)}},{key:"buildKeyVerificationDetails",value:function(){return{url:"https://api.mistral.ai/v1/models",method:"GET",handleVerificationResult:e.handleVerificationResult}}}])}(),Or=function(e){function t(e){var n,r,i,a;x(this,t);var o=JSON.parse(JSON.stringify(e.directConnection)).mistral;return(i=s(this,t,[e,Rr.buildKeyVerificationDetails(),Rr.buildHeaders,o])).insertKeyPlaceholderText="Mistral API Key",i.keyHelpUrl="https://console.mistral.ai/api-keys/",i.url="https://api.mistral.ai/v1/chat/completions",i.permittedErrorPrefixes=["invalid"],o&&(i.cleanConfig(o),Object.assign(i.rawBody,o)),null!==(n=i.maxMessages)&&void 0!==n||(i.maxMessages=-1),null!==(r=(a=i.rawBody).model)&&void 0!==r||(a.model="open-mistral-7b"),i}return c(t,e),E(t,[{key:"cleanConfig",value:function(e){delete e.key}},{key:"preprocessBody",value:function(e,t){var n=JSON.parse(JSON.stringify(e)),r=t.filter((function(e){return e.text}));return n.messages=r.slice(0,r.length-1).map((function(e){return{text:e.text,user_name:"ai"===e.role?"system":"user"}})),n}},{key:"callServiceAPI",value:(r=f(h().mark((function e(t,n){var r;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.connectSettings){e.next=2;break}throw new Error("Request settings have not been set up");case 2:r=this.preprocessBody(this.rawBody,n),dn.request(this,r,t);case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"extractResultData",value:(n=f(h().mark((function e(t){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.message){e.next=2;break}throw t.message;case 2:return e.abrupt("return",{text:t.text});case 3:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})}]);var n,r}(gn),Pr=function(){return E((function e(){x(this,e)}),null,[{key:"create",value:function(e){var t=e.directConnection,n=e.connect,r=e.demo;if(e.webModel)return new Mn(e);if(t){if(t.openAI)return t.openAI.images?new Ir(e):t.openAI.speechToText?new mr(e):t.openAI.textToSpeech?new pr(e):t.openAI.assistant?new rr(e):new Tr(e);if(t.assemblyAI)return new kr(e);if(t.cohere)return t.cohere.textGeneration?new ar(e):t.cohere.summarization?new dr(e):new Lr(e);if(t.huggingFace)return t.huggingFace.textGeneration?new qn(e):t.huggingFace.summarization?new Vn(e):t.huggingFace.translation?new Kn(e):t.huggingFace.fillMask?new Yn(e):t.huggingFace.questionAnswer?new zn(e):t.huggingFace.audioSpeechRecognition?new Hn(e):t.huggingFace.audioClassification?new Pn(e):t.huggingFace.imageClassification?new Nn(e):new Gn(e);if(t.azure){if(t.azure.openAI){if(t.azure.openAI.chat)return new Ar(e);if(t.azure.openAI.assistant)return new ur(e)}if(t.azure.speechToText)return new wr(e);if(t.azure.textToSpeech)return new Sr(e);if(t.azure.summarization)return new yr(e);if(t.azure.translation)return new Cr(e)}if(t.stabilityAI)return t.stabilityAI.imageToImage?new Wn(e):t.stabilityAI.imageToImageUpscale?new jn(e):t.stabilityAI.imageToImageMasking?new Un(e):new Jn(e);if(t.mistral)return new Or(e)}return!n||r&&n.stream?new vn(e,void 0,r||!0):new vn(e)}}])}(),Nr=E((function e(){x(this,e)}));Nr.attibutes={string:function(e){return e},number:function(e){return parseFloat(e)},boolean:function(e){return"true"===e},object:function(e){return JSON.parse(e)},array:function(e){return JSON.parse(e)},function:function(e){return new Function("return ".concat(e))()}};var Br=Nr;function Dr(e){return function(t,n){Object.defineProperty(t,n,{});var r=t.constructor,i=n.toLocaleLowerCase();r._attributes_[i]=Br.attibutes[e],r._attributeToProperty_[i]=n}}var Fr=function(){function e(t,n,r){x(this,e),this._isDisplayed=!1,t?(this._elementRef=this.createIntroPanelWithChild(t,r),this._isDisplayed=!0):n&&(this._elementRef=this.createInternalIntroPanel(n,r),this._isDisplayed=!0)}return E(e,[{key:"createIntroPanelWithChild",value:function(t,n){var r=e.createIntroPanel(n);return"none"===t.style.display&&(t.style.display="block"),r.appendChild(t),r}},{key:"createInternalIntroPanel",value:function(t,n){var r=e.createIntroPanel(n);return r.id="internal-intro-panel",r.innerHTML=t,r}},{key:"hide",value:function(){this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="none",this._isDisplayed=!1)}},{key:"display",value:function(){!this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="",this._isDisplayed=!0)}}],[{key:"createIntroPanel",value:function(e){var t=document.createElement("div");return t.classList.add("intro-panel"),Object.assign(t.style,e),t}}])}(),jr=function(){function e(){x(this,e)}return E(e,null,[{key:"createImage",value:function(e,t,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3],i=new Image;return i.src=e.src,!n&&r&&$.scrollDownOnImageLoad(i.src,t),$.processContent("image",i,i.src,e.name)}},{key:"createImageMessage",value:function(t,n,r,i){var s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],a=e.createImage(n,t.elementRef,i,s),o=t.createNewMessageElement("",r);return o.bubbleElement.appendChild(a),o.bubbleElement.classList.add(e.IMAGE_BUBBLE_CLASS),{type:"image",elements:o}}},{key:"createAudioElement",value:function(e,t){var n=document.createElement("audio");return n.src=e.src,n.classList.add("audio-player"),n.controls=!0,P.IS_SAFARI&&(n.classList.add("audio-player-safari"),n.classList.add(t===Wt.USER_ROLE?"audio-player-safari-right":"audio-player-safari-left")),n}},{key:"createNewAudioMessage",value:function(t,n,r,i){var s=e.createAudioElement(n,r),a=t.createMessageElementsOnOrientation("",r,i);return a.bubbleElement.appendChild(s),a.bubbleElement.classList.add(e.AUDIO_BUBBLE_CLASS),{type:"audio",elements:a}}},{key:"createAnyFile",value:function(e){var t=document.createElement("div");t.classList.add("any-file-message-contents");var n=document.createElement("div");n.classList.add("any-file-message-icon-container");var r=_n.createSVGElement('\n\n\n\t\n\t\t\n\t\n\n\n\t\n\t\t\n\t\n\n\n\t\n\t\t\n\t\n\n\n\t\n\t\t\n\t\n\n\n\t\n\t\t\n\t\n\n');r.classList.add("any-file-message-icon"),n.appendChild(r);var i=document.createElement("div");return i.classList.add("any-file-message-text"),i.textContent=e.name||$.DEFAULT_FILE_NAME,t.appendChild(n),t.appendChild(i),$.processContent("any",t,e.src,i.textContent)}},{key:"createNewAnyFileMessage",value:function(t,n,r,i){var s=t.createMessageElementsOnOrientation("",r,i),a=e.createAnyFile(n);return s.bubbleElement.classList.add(e.ANY_FILE_BUBBLE_CLASS),s.bubbleElement.appendChild(a),{type:"file",elements:s}}},{key:"createMessages",value:function(t,n,r){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];return n.map((function(n){return n.ref&&(n=$.removeFileRef(n)),$.isAudioFile(n)?e.createNewAudioMessage(t,n,r,i):$.isImageFile(n)?e.createImageMessage(t,n,r,i,s):e.createNewAnyFileMessage(t,n,r,i)}))}},{key:"addMessages",value:function(t,n,r,i){e.createMessages(t,n,r,i).forEach((function(e){var n=e.type,s=e.elements;$.addMessage(t,s,n,r,i)}))}}])}();jr.IMAGE_BUBBLE_CLASS="image-message",jr.AUDIO_BUBBLE_CLASS="audio-message",jr.ANY_FILE_BUBBLE_CLASS="any-file-message";var Ur=jr,Hr=function(){function e(){x(this,e)}return E(e,null,[{key:"removeElements",value:function(e,t){if(t){var n=e.findIndex((function(e){return e===t}));e.splice(n,1),null==t||t.outerContainer.remove()}}},{key:"removeFilesMessages",value:function(t,n){var r;null==(r=n[1].files)||r.forEach((function(n){e.removeElements(t.messageElementRefs,n)})),delete n[0].files,delete n[1].files}},{key:"removeTextHTMLMessage",value:function(t,n,r){var i=n[1][r];e.removeElements(t.messageElementRefs,i),delete n[0][r],delete n[1][r]}},{key:"updateHTMLMessage",value:function(e,t,n){var r,i;if(t[1].html)le.overwriteElements(e,n,t[1].html);else{var s=le.create(e,n,t[0].role),a=(null==(i=t[1].files)?void 0:i[(null==(r=t[1].files)?void 0:r.length)-1])||t[1].text;e.elementRef.insertBefore(s.outerContainer,a.outerContainer.nextSibling),e.messageElementRefs.splice(e.messageElementRefs.length-1,1);var o=e.messageElementRefs.findIndex((function(e){return e===a}));e.messageElementRefs.splice(o+1,0,s),t[1].html=s}t[0].html=n}},{key:"updateFileMessages",value:function(t,n,r){var i,s,a=n[0].role,o=Ur.createMessages(t,r,a),l=n[1].html,c=(null==(s=n[1].files)?void 0:s[(null==(i=n[1].files)?void 0:i.length)-1])||n[1].text,u=l||c,d=t.messageElementRefs.findIndex((function(e){return e===u}));c&&(d+=1);var h=(null==l?void 0:l.outerContainer)||(null==c?void 0:c.outerContainer.nextSibling);o.forEach((function(e,n){var r=e.type,i=e.elements;$.setElementProps(t,i,r,a),t.elementRef.insertBefore(i.outerContainer,h),t.messageElementRefs.splice(t.messageElementRefs.length-1,1),t.messageElementRefs.splice(d+n,0,i)})),e.removeFilesMessages(t,n),n[1].files=o.map((function(e){return e.elements})),n[0].files=r}},{key:"updateTextMessage",value:function(e,t,n){var r;if(t[1].text)e.renderText(t[1].text.bubbleElement,n);else{var i=e.createElements(n,t[0].role),s=(null==(r=t[1].files)?void 0:r[0])||t[1].html;e.elementRef.insertBefore(i.outerContainer,s.outerContainer);var a=e.messageElementRefs.findIndex((function(e){return e===s}));e.messageElementRefs.splice(a,0,i),t[1].text=i}t[0].text=n}},{key:"isElementActive",value:function(e){var t,n;return zr.isActiveElement(null==(t=e.text)?void 0:t.bubbleElement.classList)||zr.isActiveElement(null==(n=e.html)?void 0:n.bubbleElement.classList)}},{key:"update",value:function(t,n,r){var i=t.messageToElements[r];if(i){if(e.isElementActive(i[1]))return console.error("Cannot update a message that is being streamed");n.text&&e.updateTextMessage(t,i,n.text),n.html&&e.updateHTMLMessage(t,i,n.html),n.files?e.updateFileMessages(t,i,n.files):e.removeFilesMessages(t,i),!n.text&&i[1].text&&e.removeTextHTMLMessage(t,i,"text"),!n.html&&i[1].html&&e.removeTextHTMLMessage(t,i,"html")}else console.error("Message index not found. Please use the `getMessages` method to find the correct index")}}])}(),qr=function(){return E((function e(){x(this,e)}),null,[{key:"getText",value:function(e,t){var n;if(!(e.directConnection||e.connect||e.webModel||e.demo))return"Connect to any API using the [connect](https://deepchat.dev/docs/connect#connect-1) property or a popular service via [directConnection](https://deepchat.dev/docs/directConnection/#directConnection).\n Host AI entirely on your browser via a [webModel](https://deepchat.dev/docs/webModel).\n To get started checkout the [Start](https://deepchat.dev/start) page and live code [examples](https://deepchat.dev/examples/frameworks).\n To remove this message set the [demo](https://deepchat.dev/docs/demo#demo) property to true.";if(e.directConnection){if(!t.isDirectConnection())return"Please define a valid service inside\n the [directConnection](https://deepchat.dev/docs/directConnection/#directConnection) object.";var r=null==(n=e.directConnection.openAI)?void 0:n.chat;if("object"==_(r)&&r.tools&&!r.function_handler)return"Please define the `function_handler` property inside the openAI [chat](https://deepchat.dev/docs/directConnection/openAI#Chat) object."}else if(e.connect&&!e.connect.url&&!e.connect.handler)return e.demo?e.connect.stream?null:"When [demo](https://deepchat.dev/docs/demo) mode is enabled - the [connect](https://deepchat.dev/docs/connect#connect-1) object can only accept the [stream](https://deepchat.dev/docs/connect#Stream) property.":"Please define a `url` or a `handler` property inside the [connect](https://deepchat.dev/docs/connect#connect-1) object.";return null}}])}(),zr=function(e){function t(e,n,r){var i,a,o;x(this,t),i=s(this,t,[e]);var l=n.permittedErrorPrefixes,c=n.introPanelMarkUp,u=n.demo;return i._errorMessageOverrides=null==(a=e.errorMessages)?void 0:a.overrides,i._onClearMessages=Bt.onClearMessages.bind(i,e),i._onError=Bt.onError.bind(i,e),i._displayLoadingMessage=t.getDisplayLoadingMessage(e,n),i._permittedErrorPrefixes=l,i.addSetupMessageIfNeeded(e,n)||i.populateIntroPanel(r,c,e.introPanelStyle),i.addIntroductoryMessages(e,n),new pn(e,i,n),i._displayServiceErrorMessages=null==(o=e.errorMessages)?void 0:o.displayServiceErrorMessages,e.getMessages=function(){return JSON.parse(JSON.stringify(i.messageToElements.map((function(e){return d(e,1)[0]}))))},e.clearMessages=i.clearMessages.bind(i,n),e.refreshMessages=i.refreshTextMessages.bind(i,e.remarkable),e.scrollToBottom=K.scrollToBottom.bind(i,i.elementRef),e.addMessage=function(e,t){i.addAnyMessage(b(b({},e),{},{sendUpdate:!!t}),!t)},e.updateMessage=function(e,t){return Hr.update(i,e,t)},n.isWebModel()&&n.setUpMessages(i),u&&i.prepareDemo(ee.processDemo(u)),e.textToSpeech&&Y.processConfig(e.textToSpeech,(function(e){i.textToSpeech=e})),i}return c(t,e),E(t,[{key:"prepareDemo",value:function(e){var t;if("object"==_(e)){if(e.displayLoading){var n=e.displayLoading.history;null!=n&&n.small&&Ft.addMessage(this,!1),null!=n&&n.full&&Ft.addMessage(this)}e.displayErrors&&(e.displayErrors.default&&this.addNewErrorMessage("",""),e.displayErrors.service&&this.addNewErrorMessage("service",""),e.displayErrors.speechToText&&this.addNewErrorMessage("speechToText","")),null!=(t=e.displayLoading)&&t.message&&this.addLoadingMessage(),e.response&&(this.customDemoResponse=e.response)}}},{key:"addSetupMessageIfNeeded",value:function(e,t){var n=qr.getText(e,t);if(n){var r=this.createAndAppendNewMessageElement(n,Wt.AI_ROLE);this.applyCustomStyles(r,Wt.AI_ROLE,!1)}return!!n}},{key:"addIntroductoryMessages",value:function(e,t){var n,r=this;null!=e&&e.shadowRoot&&(this._introMessage=e.introMessage);var i=this._introMessage;null!=t&&t.isWebModel()&&(null!==(n=i)&&void 0!==n||(i=t.getIntroMessage(i))),i&&(Array.isArray(i)?i.forEach((function(e,t){0!==t&&Wt.hideRoleElements(r.messageElementRefs,!!r._avatars,!!r._names),r.addIntroductoryMessage(e)})):this.addIntroductoryMessage(i))}},{key:"addIntroductoryMessage",value:function(e){var t,n;null!=e&&e.text?n=this.createAndAppendNewMessageElement(e.text,Wt.AI_ROLE):null!=e&&e.html&&(n=le.add(this,e.html,Wt.AI_ROLE,this.messageElementRefs)),n&&(this.applyCustomStyles(n,Wt.AI_ROLE,!1,null==(t=this.messageStyles)?void 0:t.intro),n.outerContainer.classList.add(Ut.INTRO_CLASS))}},{key:"removeIntroductoryMessage",value:function(){var e=this.messageElementRefs[0];e.outerContainer.classList.contains(Ut.INTRO_CLASS)&&(e.outerContainer.remove(),this.messageElementRefs.shift())}},{key:"addAnyMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return e.error?this.addNewErrorMessage("service",e.error):this.addNewMessage(e,t,n)}},{key:"addNewMessage",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=t.createMessageContent(e),s={status:e.overwrite};if(!e.ignoreText&&void 0!==i.text&&null!==e.text&&(this.addNewTextMessage(i.text,i.role,s,r),!n&&this.textToSpeech&&i.role!==Wt.USER_ROLE&&Y.speak(i.text,this.textToSpeech)),i.files&&Array.isArray(i.files)&&Ur.addMessages(this,i.files,i.role,r),void 0!==i.html&&null!==i.html){var a=le.add(this,i.html,i.role,this.messageElementRefs,s,r);ie.isElementTemporary(a)&&delete i.html}return this.isValidMessageContent(i)&&!r&&this.updateStateOnMessage(i,e.overwrite,e.sendUpdate,n),i}},{key:"isValidMessageContent",value:function(e){return e.text||e.html||e.files&&e.files.length>0}},{key:"updateStateOnMessage",value:function(e,t){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!t){var i=Wt.generateMessageBody(e,this.messageElementRefs);this.messageToElements.push([e,i])}n&&this.sendClientUpdate(e,r)}},{key:"removeMessageOnError",value:function(){var e=this.messageElementRefs[this.messageElementRefs.length-1],n=null==e?void 0:e.bubbleElement;(null!=n&&n.classList.contains(Jt.MESSAGE_CLASS)&&""===n.textContent||t.isTemporaryElement(e))&&this.removeLastMessage()}},{key:"addNewErrorMessage",value:function(e,t){var n,r,i,s,a,o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.removeMessageOnError();var l=this.getPermittedMessage(t)||(null==(n=this._errorMessageOverrides)?void 0:n[e])||(null==(r=this._errorMessageOverrides)?void 0:r.default)||"Error, please try again.",c=this.createMessageElementsOnOrientation(l,"error",o);Wt.hideRoleElements(this.messageElementRefs,!!this._avatars,!!this._names);var u=c.bubbleElement,d=c.outerContainer;u.classList.add("error-message-text"),this.renderText(u,l);var h=Nt.extractParticularSharedStyles(["fontSize","fontFamily"],null==(i=this.messageStyles)?void 0:i.default);Nt.applyCustomStylesToElements(c,!1,h),Nt.applyCustomStylesToElements(c,!1,null==(s=this.messageStyles)?void 0:s.error),o||this.elementRef.appendChild(d),this.textToSpeech&&Y.speak(l,this.textToSpeech),null==(a=this._onError)||a.call(this,l)}},{key:"getPermittedMessage",value:function(e){if(e)for(var n=t.extractErrorMessages(e),r=0;r0&&e.classList.add("text-input-inner-left-adjustment"),t["inside-right"].length>0&&e.classList.add("text-input-inner-right-adjustment")}},{key:"adjustForOutsideButton",value:function(t,n,r){0===r["outside-right"].length&&r["outside-left"].length>0?(t[0].classList.add(e.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS)):0===r["outside-left"].length&&r["outside-right"].length>0&&(t[3].classList.add(e.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS))}},{key:"adjustOutsideSubmit",value:function(t,n,r){if(!(r["inside-left"].length>0||r["inside-right"].length>0)){if(0===r["outside-right"].length&&r["outside-left"].length>0)return t[0].classList.add(e.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),r["outside-left"].map((function(e){return e.button.elementRef.classList.add("submit-button-enlarged")}));if(0===r["outside-left"].length&&r["outside-right"].length>0)return t[3].classList.add(e.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),n.classList.add(e.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),r["outside-right"].map((function(e){return e.button.elementRef.classList.add("submit-button-enlarged")}))}}},{key:"set",value:function(t,n,r,i){!!e.adjustOutsideSubmit(n,r,i)||e.adjustForOutsideButton(n,r,i),e.adjustInputPadding(t,i)}}])}();Vr.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS="text-input-container-left-adjustment",Vr.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS="text-input-container-right-adjustment",Vr.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS="text-input-container-left-small-adjustment",Vr.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS="text-input-container-right-small-adjustment";var Gr=Vr,Wr=function(){function e(){x(this,e)}return E(e,null,[{key:"create",value:function(){return Array.from({length:4}).map((function(e,t){var n=document.createElement("div");return n.classList.add("input-button-container"),(0===t||3===t)&&n.classList.add("outer-button-container"),(1===t||2===t)&&n.classList.add("inner-button-container"),n}))}},{key:"add",value:function(e,t){e.insertBefore(t[1],e.firstChild),e.insertBefore(t[0],e.firstChild),e.appendChild(t[2]),e.appendChild(t[3])}},{key:"getContainerIndex",value:function(e){return"outside-left"===e?0:"inside-left"===e?1:"inside-right"===e?2:3}},{key:"addButton",value:function(t,n,r){n.classList.add(r);var i=e.getContainerIndex(r);t[i].appendChild(n),3===i&&n.classList.add("outside-right")}}])}(),Kr=["camera","gifs","images","audio","mixedFiles","submit","microphone"],Jr=function(){function e(){x(this,e)}return E(e,null,[{key:"createTextElement",value:function(e){var t=document.createElement("div");return t.classList.add("text-button"),t.innerText=e,t}},{key:"createElement",value:function(t,n){return n?e.createTextElement(t):_n.createSVGElement(t)}},{key:"createCustomElement",value:function(t,n){var r,i,s,a,o=null==n?void 0:n[t];return null!=(r=null==o?void 0:o.svg)&&r.content?e.createElement(null==(i=null==o?void 0:o.svg)?void 0:i.content,!1):null!=(s=null==o?void 0:o.text)&&s.content?e.createElement(null==(a=null==o?void 0:o.text)?void 0:a.content,!0):void 0}},{key:"processElement",value:function(e,t){null!=t&&t.classList.contains("text-button")||e.classList.add("input-button-svg")}},{key:"createSpecificStateElement",value:function(t,n,r){var i;return r&&(i=e.createCustomElement(n,r)),e.processElement(t,i),i}},{key:"createInnerElement",value:function(t,n,r,i){var s,a;return(!(arguments.length>4&&void 0!==arguments[4]&&arguments[4])||null!=(a=null==(s=null==i?void 0:i[r])?void 0:s.svg)&&a.content)&&e.createSpecificStateElement(t,r,i)||n}}])}(),Yr=function(){function e(){x(this,e)}return E(e,null,[{key:"unsetAllCSS",value:function(e,t){var n,r;t.container&&A.unsetAllCSSMouseStates(e,t.container),null!=(n=t.svg)&&n.styles&&A.unsetAllCSSMouseStates(e.children[0],t.svg.styles),null!=(r=t.text)&&r.styles&&A.unsetAllCSSMouseStates(e.children[0],t.text.styles)}},{key:"unsetActionCSS",value:function(e,t){var n,r;t.container&&A.unsetActivityCSSMouseStates(e,t.container),null!=(n=t.svg)&&n.styles&&A.unsetActivityCSSMouseStates(e.children[0],t.svg.styles),null!=(r=t.text)&&r.styles&&A.unsetActivityCSSMouseStates(e.children[0],t.text.styles)}},{key:"setElementsCSS",value:function(e,t,n){var r,i,s,a,o;Object.assign(e.style,null==(r=t.container)?void 0:r[n]),Object.assign(e.children[0].style,null==(s=null==(i=t.svg)?void 0:i.styles)?void 0:s[n]),Object.assign(e.children[0].style,null==(o=null==(a=t.text)?void 0:a.styles)?void 0:o[n])}},{key:"setElementCssUpToState",value:function(t,n,r){e.setElementsCSS(t,n,"default"),"default"!==r&&(e.setElementsCSS(t,n,"hover"),"hover"!==r&&e.setElementsCSS(t,n,"click"))}}])}(),Zr=function(){return E((function e(t,n,r,i){x(this,e),this._mouseState={state:"default"},this.elementRef=t,this._customStyles=r,this.position=n,this.dropupText=i}),[{key:"buttonMouseLeave",value:function(e){this._mouseState.state="default",e&&(Yr.unsetAllCSS(this.elementRef,e),Yr.setElementsCSS(this.elementRef,e,"default"))}},{key:"buttonMouseEnter",value:function(e){this._mouseState.state="hover",e&&Yr.setElementsCSS(this.elementRef,e,"hover")}},{key:"buttonMouseUp",value:function(e){e&&Yr.unsetActionCSS(this.elementRef,e),this.buttonMouseEnter(e)}},{key:"buttonMouseDown",value:function(e){this._mouseState.state="click",e&&Yr.setElementsCSS(this.elementRef,e,"click")}},{key:"setEvents",value:function(e){this.elementRef.onmousedown=this.buttonMouseDown.bind(this,e),this.elementRef.onmouseup=this.buttonMouseUp.bind(this,e),this.elementRef.onmouseenter=this.buttonMouseEnter.bind(this,e),this.elementRef.onmouseleave=this.buttonMouseLeave.bind(this,e)}},{key:"unsetCustomStateStyles",value:function(e){if(this._customStyles)for(var t=0;t3&&void 0!==arguments[3]&&arguments[3]?t:t[r?"nextSibling":"previousSibling"];i?(t.dispatchEvent(new MouseEvent("mouseleave")),i.dispatchEvent(new MouseEvent("mouseenter"))):(t.dispatchEvent(new MouseEvent("mouseleave")),e.focusItemWhenOnEdge(n,r))}}])}(),Qr=function(){function e(){x(this,e)}return E(e,null,[{key:"addItemEvents",value:function(e,t,n,r){te.add(t,r),t.addEventListener("click",(function(){n.click()})),t.addEventListener("mouseenter",(function(t){e.highlightedItem=t.target})),t.addEventListener("mouseleave",(function(){e.highlightedItem=void 0}))}},{key:"createItemText",value:function(e,t){var n=document.createElement("div");return Object.assign(n.style,t),n.classList.add("dropup-menu-item-text"),n.textContent=e||"File",n}},{key:"createItemIcon",value:function(e,t){var n=document.createElement("div");return Object.assign(n.style,t),n.classList.add("dropup-menu-item-icon"),n.appendChild(e.children[0]),n}},{key:"populateItem",value:function(t,n,r,i){var s=t.children[0];s.classList.contains("text-button")?n.appendChild(e.createItemText(s.textContent,null==i?void 0:i.text)):(n.appendChild(e.createItemIcon(t,null==i?void 0:i.iconContainer)),n.appendChild(e.createItemText(r,null==i?void 0:i.text)))}},{key:"createItem",value:function(t,n,r){var i,s=n.elementRef,a=n.dropupText,o=document.createElement("div");Object.assign(o.style,null==(i=null==r?void 0:r.item)?void 0:i.default),e.populateItem(s,o,a,r),o.classList.add("dropup-menu-item");var l=A.processStateful((null==r?void 0:r.item)||{},{backgroundColor:"#f3f3f3"},{backgroundColor:"#ebebeb"});return e.addItemEvents(t,o,s,l),o}}])}(),$r=function(){return E((function e(t,n){var r,i=this;x(this,e),this._isOpen=!0,this._styles=n,this.elementRef=e.createElement(null==(r=this._styles)?void 0:r.container),this.close(),setTimeout((function(){return i.addWindowEvents(t)}))}),[{key:"open",value:function(){this.elementRef.style.display="block",this._isOpen=!0}},{key:"close",value:function(){this._isOpen&&(this.elementRef.style.display="none",this._isOpen=!1)}},{key:"toggle",value:function(){this._isOpen?this.close():this.open()}},{key:"addItem",value:function(e){var t=Qr.createItem(this,e,this._styles);this.elementRef.appendChild(t)}},{key:"addWindowEvents",value:function(e){this.clickEvent=this.windowClick.bind(this,e),window.addEventListener("click",this.clickEvent),this.keyDownEvent=this.windowKeyDown.bind(this,e),window.addEventListener("keydown",this.keyDownEvent)}},{key:"windowClick",value:function(e,t){var n;!e.isConnected&&this.clickEvent?window.removeEventListener("click",this.clickEvent):e.parentElement!==(null==(n=t.target.shadowRoot)?void 0:n.children[0])&&this.close()}},{key:"windowKeyDown",value:function(e,t){var n,r,i;!e.isConnected&&this.keyDownEvent?window.removeEventListener("keydown",this.keyDownEvent):this._isOpen&&(t.key===N.ESCAPE?(this.close(),null==(n=this.highlightedItem)||n.dispatchEvent(new MouseEvent("mouseleave"))):t.key===N.ENTER?(null==(r=this.highlightedItem)||r.click(),null==(i=this.highlightedItem)||i.dispatchEvent(new MouseEvent("mouseleave"))):t.key===N.ARROW_DOWN?Xr.focusSiblingItem(this.highlightedItem||this.elementRef.children[this.elementRef.children.length-1],this.elementRef,!0):t.key===N.ARROW_UP&&Xr.focusSiblingItem(this.highlightedItem||this.elementRef.children[0],this.elementRef,!1))}}],[{key:"createElement",value:function(e){var t=document.createElement("div");return t.id="dropup-menu",Object.assign(t.style,e),t}}])}(),ei=function(e){function t(e,n){var r,i;x(this,t);var a=(r=s(this,t,[t.createButtonElement(),void 0,{styles:null==(i=null==n?void 0:n.button)?void 0:i.styles}])).createInnerElements(r._customStyles);return r._menu=new $r(e,null==n?void 0:n.menu),r.addClickEvent(),r.buttonContainer=t.createButtonContainer(),r.elementRef.appendChild(a.styles),r.buttonContainer.appendChild(r.elementRef),r.elementRef.classList.add("dropup-icon","upload-file-button"),r.elementRef.children[0].id="dropup-icon",r.buttonContainer.appendChild(r._menu.elementRef),r.reapplyStateStyle("styles"),r.addContainerEvents(e),r}return c(t,e),E(t,[{key:"createInnerElements",value:function(e){return{styles:this.createInnerElement(t.createSVGIconElement(),"styles",e)}}},{key:"createInnerElement",value:function(e,t,n){return Jr.createSpecificStateElement(this.elementRef,t,n)||e}},{key:"addClickEvent",value:function(){this.elementRef.onclick=this._menu.toggle.bind(this._menu)}},{key:"addItem",value:function(e){this._menu.addItem(e)}},{key:"addContainerEvents",value:function(e){var t=this;e.addEventListener("click",(function(e){e.target.classList.contains("dropup-icon")||t._menu.close()}))}}],[{key:"createButtonElement",value:function(){var e=document.createElement("div");return e.classList.add("input-button"),e}},{key:"createSVGIconElement",value:function(){return _n.createSVGElement('\n\n \n')}},{key:"createButtonContainer",value:function(){var e=document.createElement("div");return e.id="dropup-container",e}},{key:"getPosition",value:function(e,t){var n,r;return null!=(n=null==t?void 0:t.button)&&n.position?null==(r=null==t?void 0:t.button)?void 0:r.position:e["outside-left"].length>0&&0===e["outside-right"].length?"outside-right":"outside-left"}}])}(Zr),ti=function(){function e(){x(this,e)}return E(e,null,[{key:"addToDropup",value:function(e,t,n,r){var i=new ei(n,r);Kr.forEach((function(e){var n=t["dropup-menu"].findIndex((function(t){return t.buttonType===e})),r=t["dropup-menu"][n];r&&(i.addItem(r.button),t["dropup-menu"].splice(n,1))}));var s=ei.getPosition(t,r);Wr.addButton(e,i.buttonContainer,s),t[s].push({})}},{key:"addToSideContainer",value:function(e,t){["inside-left","inside-right","outside-left","outside-right"].forEach((function(n){var r=n;t[r].forEach((function(t){Wr.addButton(e,t.button.elementRef,r)}))}))}},{key:"setPosition",value:function(e,t,n){var r=b(b({},e[t]),{},{buttonType:t});n.push(r),delete e[t]}},{key:"createPositionsObj",value:function(){return{"dropup-menu":[],"outside-left":[],"inside-left":[],"inside-right":[],"outside-right":[]}}},{key:"generatePositions",value:function(t){var n=e.createPositionsObj();Object.keys(t).forEach((function(r){var i,s=null==(i=t[r])?void 0:i.button.position;s&&e.setPosition(t,r,n[s])})),0===n["inside-right"].length&&t.submit&&e.setPosition(t,"submit",n["inside-right"]),0===n["outside-right"].length&&(t.submit?e.setPosition(t,"submit",n["outside-right"]):t.microphone?e.setPosition(t,"microphone",n["outside-right"]):t.camera&&e.setPosition(t,"camera",n["outside-right"])),t.submit&&e.setPosition(t,"submit",0===n["outside-left"].length?n["outside-left"]:n["inside-right"]),t.microphone&&e.setPosition(t,"microphone",0===n["outside-left"].length?n["outside-left"]:n["inside-right"]);var r=Object.keys(t);return r.length>1||n["dropup-menu"].length>0?Kr.forEach((function(e){t[e]&&n["dropup-menu"].push(b(b({},t[e]),{},{buttonType:e}))})):1===r.length&&e.setPosition(t,r[0],0===n["outside-right"].length?n["outside-right"]:n["outside-left"]),n}},{key:"addButtons",value:function(t,n,r,i){var s=e.generatePositions(n);return e.addToSideContainer(t,s),s["dropup-menu"].length>0&&e.addToDropup(t,s,r,i),s}}])}(),ni={images:{id:"upload-images-icon",svgString:'\n\n \n\n',dropupText:"Image"},gifs:{id:"upload-gifs-icon",svgString:'\n\n \n \n \n \n\n',dropupText:"GIF"},audio:{id:"upload-audio-icon",svgString:'\n \n \n \n \n \n \n \n \n \n \n',dropupText:"Audio"},mixedFiles:{id:"upload-mixed-files-icon",svgString:'\n\nfile\n\n',dropupText:"File"}},ri=function(){function e(){x(this,e)}return E(e,null,[{key:"addAttributes",value:function(e){e.role="button",e.setAttribute("tabindex","0")}},{key:"addAriaBusy",value:function(e){e.setAttribute("aria-busy","true")}},{key:"removeAriaBusy",value:function(e){e.removeAttribute("aria-busy")}},{key:"addAriaDisabled",value:function(e){e.setAttribute("aria-disabled","true")}},{key:"removeAriaDisabled",value:function(e){e.removeAttribute("aria-disabled")}},{key:"removeAriaAttributes",value:function(t){e.removeAriaBusy(t),e.removeAriaDisabled(t)}}])}(),ii=function(e){function t(e){var n;return x(this,t),"dropup-menu"===(null==e?void 0:e.position)&&(e.position="outside-right"),(n=s(this,t,[t.createMicrophoneElement(),null==e?void 0:e.position,e])).isActive=!1,n._innerElements=n.createInnerElements(n._customStyles),n.changeToDefault(),n}return c(t,e),E(t,[{key:"createInnerElements",value:function(e){var n=t.createSVGIconElement();return{default:this.createInnerElement(n,"default",e),active:this.createInnerElement(n,"active",e),unsupported:this.createInnerElement(n,"unsupported",e),commandMode:this.createInnerElement(n,"commandMode",e)}}},{key:"createInnerElement",value:function(e,t,n){return Jr.createSpecificStateElement(this.elementRef,t,n)||e}},{key:"changeToActive",value:function(){this.elementRef.replaceChildren(this._innerElements.active),this.toggleIconFilter("active"),this.reapplyStateStyle("active",["default","commandMode"]),this.isActive=!0}},{key:"changeToDefault",value:function(){this.elementRef.replaceChildren(this._innerElements.default),this.toggleIconFilter("default"),this.reapplyStateStyle("default",["active","commandMode"]),this.isActive=!1}},{key:"changeToCommandMode",value:function(){this.elementRef.replaceChildren(this._innerElements.unsupported),this.toggleIconFilter("command"),this.reapplyStateStyle("commandMode",["active"])}},{key:"changeToUnsupported",value:function(){this.elementRef.replaceChildren(this._innerElements.unsupported),this.elementRef.classList.add("unsupported-microphone"),this.reapplyStateStyle("unsupported",["active"])}},{key:"toggleIconFilter",value:function(e){var t=this.elementRef.children[0];if("svg"===t.tagName.toLocaleLowerCase())switch(e){case"default":t.classList.remove("active-microphone-icon","command-microphone-icon"),t.classList.add("default-microphone-icon");break;case"active":t.classList.remove("default-microphone-icon","command-microphone-icon"),t.classList.add("active-microphone-icon");break;case"command":t.classList.remove("active-microphone-icon","default-microphone-icon"),t.classList.add("command-microphone-icon")}}}],[{key:"createMicrophoneElement",value:function(){var e=document.createElement("div");return e.id="microphone-button",e.classList.add("input-button"),ri.addAttributes(e),e}},{key:"createSVGIconElement",value:function(){var e=_n.createSVGElement('\n\n\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\n\t\n\n');return e.id="microphone-icon",e}}])}(Zr),si={},ai={},oi={},li={},ci={};Object.defineProperty(ci,"__esModule",{value:!0}),ci.Text=void 0;var ui=function(){function e(){x(this,e)}return E(e,null,[{key:"capitalize",value:function(t){return t.replace(e.FIRST_CHAR_REGEX,(function(e){return e.toUpperCase()}))}},{key:"lineBreak",value:function(t){return t.replace(e.DOUBLE_LINE,"

    ").replace(e.ONE_LINE,"
    ")}},{key:"isCharDefined",value:function(e){return void 0!==e&&"\xa0"!==e&&" "!==e&&"\n"!==e&&""!==e}},{key:"breakupIntoWordsArr",value:function(e){return e.split(/(\W+)/)}}])}();ci.Text=ui,ui.FIRST_CHAR_REGEX=/\S/,ui.DOUBLE_LINE=/\n\n/g,ui.ONE_LINE=/\n/g,Object.defineProperty(li,"__esModule",{value:!0}),li.Translate=void 0;var di=ci,hi=function(){return E((function e(){x(this,e)}),null,[{key:"translate",value:function(e,t){for(var n=di.Text.breakupIntoWordsArr(e),r=0;re.clientHeight||e.scrollWidth>e.clientWidth}},{key:"isRequired",value:function(t,n){return t&&e.isElementOverflown(n)}}])}();Si.AutoScroll=Ei;var wi={};Object.defineProperty(wi,"__esModule",{value:!0}),wi.Elements=void 0;var Ci=function(){return E((function e(){x(this,e)}),null,[{key:"isPrimitiveElement",value:function(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName}},{key:"createInterimSpan",value:function(){var e=document.createElement("span");return e.style.color="grey",e.style.pointerEvents="none",e}},{key:"createGenericSpan",value:function(){var e=document.createElement("span");return e.style.pointerEvents="none",e}},{key:"appendSpans",value:function(e,t){if(e.spansPopulated=!0,e.insertInCursorLocation&&document.activeElement===t){var n=window.getSelection();if(null!=n&&n.focusNode){var r=n.getRangeAt(0);return r.insertNode(e.scrollingSpan),r.insertNode(e.interimSpan),r.insertNode(e.finalSpan),r.collapse(!1),n.removeAllRanges(),void n.addRange(r)}}t.appendChild(e.finalSpan),t.appendChild(e.interimSpan),t.appendChild(e.scrollingSpan)}},{key:"applyCustomColors",value:function(e,t){t.interim&&(e.interimSpan.style.color=t.interim),t.final&&(e.finalSpan.style.color=t.final)}},{key:"isInsideShadowDOM",value:function(e){return e.getRootNode()instanceof ShadowRoot}}])}();wi.Elements=Ci;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0}),Ti.Cursor=void 0;var Ai=function(){function e(){x(this,e)}return E(e,null,[{key:"setOffsetForGeneric",value:function(t,n){for(var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=0,s=0;s0){var o=e.setOffsetForGeneric(a,n,r);if(-1===o)return-1;r+=o}else if(null!==a.textContent){if(r+a.textContent.length>n){var l=document.createRange();l.setStart(a,n-r),l.collapse(!0);var c=window.getSelection();return null==c||c.removeAllRanges(),null==c||c.addRange(l),t.focus(),-1}r+=a.textContent.length,i+=a.textContent.length}}return i}},{key:"focusEndOfGeneric",value:function(e){var t=document.createRange();t.selectNodeContents(e),t.collapse(!1);var n=window.getSelection();n&&(n.removeAllRanges(),n.addRange(t))}},{key:"setOffsetForSafariGeneric",value:function(t,n){var r=window.getSelection();if(r){var i=e.getGenericElementCursorOffset(t,r,!0);console.log(i),setTimeout((function(){}),100),e.setOffsetForGeneric(t,i+n)}}},{key:"setOffsetForPrimitive",value:function(e,t,n){n&&e.blur(),e.setSelectionRange(t,t),e.focus()}},{key:"getGenericElementCursorOffset",value:function(e,t,n){var r=0;if(t.rangeCount>0){var i=t.getRangeAt(0),s=i.cloneRange();s.selectNodeContents(e),n?s.setEnd(i.startContainer,i.startOffset):s.setEnd(i.endContainer,i.endOffset),r=s.toString().length}return r}}])}();Ti.Cursor=Ai,Object.defineProperty(xi,"__esModule",{value:!0}),xi.CommandUtils=void 0;var Mi=Si,Ii=wi,Li=mi,Ri=Ti,Oi=ci,Pi=function(){function e(){x(this,e)}return E(e,null,[{key:"processCommand",value:function(e,t){return(!t||!t.caseSensitive)&&(e=e.toLowerCase()),!1===(null==t?void 0:t.substrings)?Oi.Text.breakupIntoWordsArr(e):e}},{key:"process",value:function(t){var n;return!0===(null===(n=t.settings)||void 0===n?void 0:n.caseSensitive)?t:Object.keys(t).reduce((function(n,r){var i=t[r];return n[r]="string"==typeof i?e.processCommand(i,t.settings):i,n}),{})}},{key:"toggleCommandModeOn",value:function(e){var t;e.isWaitingForCommand=!0,null===(t=e.onCommandModeTrigger)||void 0===t||t.call(e,!0)}},{key:"toggleCommandModeOff",value:function(e){var t;e.isWaitingForCommand&&(null===(t=e.onCommandModeTrigger)||void 0===t||t.call(e,!1),e.isWaitingForCommand=!1)}},{key:"setText",value:function(t,n,r,i){e.toggleCommandModeOff(t),Ii.Elements.isPrimitiveElement(i)?(i.value=r,t.isTargetInShadow||Ri.Cursor.setOffsetForPrimitive(i,r.length,!0),Li.Browser.IS_SAFARI()&&t.autoScroll&&Mi.AutoScroll.scrollSafariPrimitiveToEnd(i)):(i.textContent=r,t.isTargetInShadow||Ri.Cursor.focusEndOfGeneric(i),setTimeout((function(){return Mi.AutoScroll.scrollGeneric(t,i)}))),t.resetRecording(n)}},{key:"checkIfMatchesSubstring",value:function(e,t){return t.includes(e)}},{key:"checkIfMatchesWord",value:function(e,t,n){for(var r=e,i=n.length-1;i>=0;i-=1){for(var s=i,a=r.length-1;n[s]===r[a]&&a>=0;)s-=1,a-=1;if(a<0)return!0}return!1}},{key:"execCommand",value:function(t,n,r,i,s){var a,o,l,c=t.commands;if(c&&i&&r){var u=!0===(null===(a=c.settings)||void 0===a?void 0:a.caseSensitive)?n:n.toLowerCase(),d=Oi.Text.breakupIntoWordsArr(u),h=!1===(null===(o=c.settings)||void 0===o?void 0:o.substrings)?e.checkIfMatchesWord:e.checkIfMatchesSubstring;if(c.commandMode&&h(c.commandMode,u,d))return t.setInterimColorToFinal(),setTimeout((function(){return e.toggleCommandModeOn(t)})),{doNotProcessTranscription:!1};if(!c.commandMode||t.isWaitingForCommand){if(c.stop&&h(c.stop,u,d))return e.toggleCommandModeOff(t),setTimeout((function(){return t.stop()})),{doNotProcessTranscription:!1};if(c.pause&&h(c.pause,u,d))return e.toggleCommandModeOff(t),t.setInterimColorToFinal(),setTimeout((function(){var e;t.isPaused=!0,null===(e=t.onPauseTrigger)||void 0===e||e.call(t,!0)})),{doNotProcessTranscription:!1};if(c.resume&&h(c.resume,u,d))return t.isPaused=!1,null===(l=t.onPauseTrigger)||void 0===l||l.call(t,!1),e.toggleCommandModeOff(t),t.resetRecording(r),{doNotProcessTranscription:!0};if(c.reset&&h(c.reset,u,d))return void 0!==s&&e.setText(t,r,s,i),{doNotProcessTranscription:!0};if(c.removeAllText&&h(c.removeAllText,u,d))return e.setText(t,r,"",i),{doNotProcessTranscription:!0}}}}}])}();xi.CommandUtils=Pi;var Ni={};Object.defineProperty(Ni,"__esModule",{value:!0}),Ni.Highlight=void 0;var Bi=wi,Di=Ti,Fi=function(){function e(){x(this,e)}return E(e,null,[{key:"setStateForPrimitive",value:function(e,t){var n,r;null!==t.selectionStart&&(n=t.selectionStart),null!==t.selectionEnd&&(r=t.selectionEnd),e.isHighlighted=n!==r}},{key:"setStateForGeneric",value:function(e,t){var n=window.getSelection();if(null!=n&&n.focusNode){var r=Di.Cursor.getGenericElementCursorOffset(t,n,!0),i=Di.Cursor.getGenericElementCursorOffset(t,n,!1);e.isHighlighted=r!==i}}},{key:"setState",value:function(t,n){document.activeElement===n&&(Bi.Elements.isPrimitiveElement(n)?e.setStateForPrimitive(t,n):e.setStateForGeneric(t,n))}},{key:"removeForGeneric",value:function(e,t){var n=window.getSelection();if(n){var r=Di.Cursor.getGenericElementCursorOffset(t,n,!0);n.deleteFromDocument(),Di.Cursor.setOffsetForGeneric(t,r),e.isHighlighted=!1}}},{key:"removeForPrimitive",value:function(e,t){var n=t.selectionStart,r=t.selectionEnd,i=t.value;if(n&&r){var s=i.substring(0,n)+i.substring(r);t.value=s,Di.Cursor.setOffsetForPrimitive(t,n,e.autoScroll)}e.isHighlighted=!1}}])}();Ni.Highlight=Fi;var ji={};Object.defineProperty(ji,"__esModule",{value:!0}),ji.Padding=void 0;var Ui=wi,Hi=Ti,qi=ci,zi=function(){function e(){x(this,e)}return E(e,null,[{key:"setStateForPrimitiveElement",value:function(e,t){if(document.activeElement===t&&null!==t.selectionStart){var n=t.selectionStart,r=t.value[n-1],i=null===t.selectionEnd?n:t.selectionEnd,s=t.value[i];return qi.Text.isCharDefined(r)&&(e.startPadding=" ",e.numberOfSpacesBeforeNewText=1),qi.Text.isCharDefined(s)&&(e.endPadding=" ",e.numberOfSpacesAfterNewText=1),void(e.isCursorAtEnd=t.value.length===i)}var a=t.value[t.value.length-1];qi.Text.isCharDefined(a)&&(e.startPadding=" ",e.numberOfSpacesBeforeNewText=1),e.isCursorAtEnd=!0}},{key:"setStateForGenericElement",value:function(e,t){var n,r,i;if(document.activeElement===t){var s=window.getSelection();if(null!=s&&s.focusNode){var a=Hi.Cursor.getGenericElementCursorOffset(t,s,!0),o=null===(n=t.textContent)||void 0===n?void 0:n[a-1],l=Hi.Cursor.getGenericElementCursorOffset(t,s,!1),c=null===(r=t.textContent)||void 0===r?void 0:r[l];return qi.Text.isCharDefined(o)&&(e.startPadding=" "),qi.Text.isCharDefined(c)&&(e.endPadding=" "),void(e.isCursorAtEnd=(null===(i=t.textContent)||void 0===i?void 0:i.length)===l)}}var u=t.innerText.charAt(t.innerText.length-1);qi.Text.isCharDefined(u)&&(e.startPadding=" "),e.isCursorAtEnd=!0}},{key:"setState",value:function(t,n){Ui.Elements.isPrimitiveElement(n)?e.setStateForPrimitiveElement(t,n):e.setStateForGenericElement(t,n)}},{key:"adjustStateAfterRecodingPrimitiveElement",value:function(e,t){e.primitiveTextRecorded=!0,e.insertInCursorLocation&&document.activeElement===t&&(null!==t.selectionEnd&&(e.endPadding=e.endPadding+t.value.slice(t.selectionEnd)),null!==t.selectionStart)?e.startPadding=t.value.slice(0,t.selectionStart)+e.startPadding:e.startPadding=t.value+e.startPadding}},{key:"adjustSateForNoTextPrimitiveElement",value:function(e){1===e.numberOfSpacesBeforeNewText&&(e.startPadding=e.startPadding.substring(0,e.startPadding.length-1),e.numberOfSpacesBeforeNewText=0),1===e.numberOfSpacesAfterNewText&&(e.endPadding=e.endPadding.substring(1),e.numberOfSpacesAfterNewText=0)}}])}();ji.Padding=zi,Object.defineProperty(gi,"__esModule",{value:!0}),gi.Speech=void 0;var Vi=yi,Gi=ki,Wi=xi,Ki=Si,Ji=Ni,Yi=wi,Zi=ji,Xi=mi,Qi=Ti,$i=ci,es=function(){return E((function e(){x(this,e),this.finalTranscript="",this.interimSpan=Yi.Elements.createInterimSpan(),this.finalSpan=Yi.Elements.createGenericSpan(),this.scrollingSpan=Yi.Elements.createGenericSpan(),this.isCursorAtEnd=!1,this.spansPopulated=!1,this.startPadding="",this.endPadding="",this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.recognizing=!1,this._displayInterimResults=!0,this.insertInCursorLocation=!0,this.autoScroll=!0,this.isRestarting=!1,this.isPaused=!1,this.isWaitingForCommand=!1,this.isTargetInShadow=!1,this.cannotBeStopped=!1,this.resetState()}),[{key:"prepareBeforeStart",value:function(e){var t,n;if(null!=e&&e.element)if(Vi.EventListeners.add(this,e),Array.isArray(e.element)){var r=e.element.find((function(e){return e===document.activeElement}))||e.element[0];if(!r)return;this.prepare(r)}else this.prepare(e.element);void 0!==(null==e?void 0:e.displayInterimResults)&&(this._displayInterimResults=e.displayInterimResults),null!=e&&e.textColor&&(this._finalTextColor=null===(t=null==e?void 0:e.textColor)||void 0===t?void 0:t.final,Yi.Elements.applyCustomColors(this,e.textColor)),void 0!==(null==e?void 0:e.insertInCursorLocation)&&(this.insertInCursorLocation=e.insertInCursorLocation),void 0!==(null==e?void 0:e.autoScroll)&&(this.autoScroll=e.autoScroll),this._onResult=null==e?void 0:e.onResult,this._onPreResult=null==e?void 0:e.onPreResult,this._onStart=null==e?void 0:e.onStart,this._onStop=null==e?void 0:e.onStop,this._onError=null==e?void 0:e.onError,this.onCommandModeTrigger=null==e?void 0:e.onCommandModeTrigger,this.onPauseTrigger=null==e?void 0:e.onPauseTrigger,this._options=e,null!==(n=this._options)&&void 0!==n&&n.commands&&(this.commands=Wi.CommandUtils.process(this._options.commands))}},{key:"prepare",value:function(e){Zi.Padding.setState(this,e),Ji.Highlight.setState(this,e),this.isTargetInShadow=Yi.Elements.isInsideShadowDOM(e),Yi.Elements.isPrimitiveElement(e)?(this._primitiveElement=e,this._originalText=this._primitiveElement.value):(this._genericElement=e,this._originalText=this._genericElement.textContent)}},{key:"resetRecording",value:function(e){this.isRestarting=!0,this.stop(!0),this.resetState(!0),this.start(e,!0)}},{key:"updateElements",value:function(e,t,n){var r,i=$i.Text.capitalize(t);if(this.finalTranscript!==i||""!==e){Gi.PreResultUtils.process(this,n,""===e,this._onPreResult,this._options)&&(e="",n="");var s=this.commands&&Wi.CommandUtils.execCommand(this,n,this._options,this._primitiveElement||this._genericElement,this._originalText);if(s){if(s.doNotProcessTranscription)return;e="",n=""}if(!this.isPaused&&!this.isWaitingForCommand){null===(r=this._onResult)||void 0===r||r.call(this,n,""===e),this.finalTranscript=i,this._displayInterimResults||(e="");var a=""===this.finalTranscript&&""===e;this._primitiveElement?this.updatePrimitiveElement(this._primitiveElement,e,a):this._genericElement&&this.updateGenericElement(this._genericElement,e,a)}}}},{key:"updatePrimitiveElement",value:function(e,t,n){this.isHighlighted&&Ji.Highlight.removeForPrimitive(this,e),this.primitiveTextRecorded||Zi.Padding.adjustStateAfterRecodingPrimitiveElement(this,e),n&&Zi.Padding.adjustSateForNoTextPrimitiveElement(this);var r=this.startPadding+this.finalTranscript+t;if(e.value=r+this.endPadding,!this.isTargetInShadow){var i=r.length+this.numberOfSpacesAfterNewText;Qi.Cursor.setOffsetForPrimitive(e,i,this.autoScroll)}this.autoScroll&&Xi.Browser.IS_SAFARI()&&this.isCursorAtEnd&&Ki.AutoScroll.scrollSafariPrimitiveToEnd(e)}},{key:"updateGenericElement",value:function(e,t,n){this.isHighlighted&&Ji.Highlight.removeForGeneric(this,e),this.spansPopulated||Yi.Elements.appendSpans(this,e);var r=(n?"":this.startPadding)+$i.Text.lineBreak(this.finalTranscript);this.finalSpan.innerHTML=r;var i=Ki.AutoScroll.isRequired(this.autoScroll,e);Ki.AutoScroll.changeStateIfNeeded(this,i);var s=$i.Text.lineBreak(t)+(n?"":this.endPadding);this.interimSpan.innerHTML=s,Xi.Browser.IS_SAFARI()&&this.insertInCursorLocation&&Qi.Cursor.setOffsetForSafariGeneric(e,r.length+s.length),i&&Ki.AutoScroll.scrollGeneric(this,e),n&&(this.scrollingSpan.innerHTML="")}},{key:"finalise",value:function(e){this._genericElement&&(e?(this.finalSpan=Yi.Elements.createGenericSpan(),this.setInterimColorToFinal(),this.interimSpan=Yi.Elements.createInterimSpan(),this.scrollingSpan=Yi.Elements.createGenericSpan()):this._genericElement.textContent=this._genericElement.textContent,this.spansPopulated=!1),Vi.EventListeners.remove(this)}},{key:"setInterimColorToFinal",value:function(){this.interimSpan.style.color=this._finalTextColor||"black"}},{key:"resetState",value:function(e){this._primitiveElement=void 0,this._genericElement=void 0,this.finalTranscript="",this.finalSpan.innerHTML="",this.interimSpan.innerHTML="",this.scrollingSpan.innerHTML="",this.startPadding="",this.endPadding="",this.isHighlighted=!1,this.primitiveTextRecorded=!1,this.numberOfSpacesBeforeNewText=0,this.numberOfSpacesAfterNewText=0,e||(this.stopTimeout=void 0)}},{key:"setStateOnStart",value:function(){var e;this.recognizing=!0,this.isRestarting?this.isRestarting=!1:null===(e=this._onStart)||void 0===e||e.call(this)}},{key:"setStateOnStop",value:function(){var e;this.recognizing=!1,this.isRestarting||null===(e=this._onStop)||void 0===e||e.call(this)}},{key:"setStateOnError",value:function(e){var t;null===(t=this._onError)||void 0===t||t.call(this,e),this.recognizing=!1}}])}();gi.Speech=es,Object.defineProperty(ai,"__esModule",{value:!0}),ai.WebSpeech=void 0;var ts=oi,ns=mi,rs=function(e){function t(){return x(this,t),s(this,t)}return c(t,e),E(t,[{key:"start",value:function(e){var t;void 0===this._extractText&&(this._extractText=ns.Browser.IS_SAFARI()?ts.WebSpeechTranscript.extractSafari:ts.WebSpeechTranscript.extract),this.validate()&&(this.prepareBeforeStart(e),this.instantiateService(e),null===(t=this._service)||void 0===t||t.start(),this._translations=null==e?void 0:e.translations)}},{key:"validate",value:function(){return!!t.getAPI()||(this.error("Speech Recognition is unsupported"),!1)}},{key:"instantiateService",value:function(e){var n,r,i=t.getAPI();this._service=new i,this._service.continuous=!0,this._service.interimResults=null===(n=null==e?void 0:e.displayInterimResults)||void 0===n||n,this._service.lang=(null===(r=null==e?void 0:e.language)||void 0===r?void 0:r.trim())||"en-US",this.setEvents()}},{key:"setEvents",value:function(){var e=this;this._service&&(this._service.onstart=function(){e.setStateOnStart()},this._service.onerror=function(t){ns.Browser.IS_SAFARI()&&"Another request is started"===t.message||"aborted"===t.error&&e.isRestarting||"no-speech"!==t.error&&e.error(t.message||t.error)},this._service.onaudioend=function(){e.setStateOnStop()},this._service.onend=function(){e._stopping=!1},this._service.onresult=function(t){if(_(t.results)>"u"&&e._service)e._service.onend=null,e._service.stop();else if(e._extractText&&!e._stopping){var n=e._extractText(t,e.finalTranscript,e._translations),r=n.interimTranscript,i=n.finalTranscript,s=n.newText;e.updateElements(r,i,s)}})}},{key:"stop",value:function(e){var t;this._stopping=!0,null===(t=this._service)||void 0===t||t.stop(),this.finalise(e)}},{key:"error",value:function(e){console.error(e),this.setStateOnError(e),this.stop()}}],[{key:"getAPI",value:function(){return window.webkitSpeechRecognition||window.SpeechRecognition}}])}(gi.Speech);ai.WebSpeech=rs;var is={};Object.defineProperty(is,"__esModule",{value:!0}),is.GlobalState=void 0;var ss=function(){function e(){x(this,e)}return E(e,null,[{key:"doubleClickDetector",value:function(){return!!e.doubleClickPending||(e.doubleClickPending=!0,setTimeout((function(){e.doubleClickPending=!1}),300),!1)}}])}();is.GlobalState=ss,ss.doubleClickPending=!1;var as={},os={};Object.defineProperty(os,"__esModule",{value:!0}),os.PreventConnectionStop=void 0;var ls=function(){return E((function e(){x(this,e)}),null,[{key:"applyPrevention",value:function(e){clearTimeout(e._manualConnectionStopPrevention),e.cannotBeStopped=!0,e._manualConnectionStopPrevention=setTimeout((function(){e.cannotBeStopped=!1}),800)}},{key:"clearPrevention",value:function(e){clearTimeout(e._manualConnectionStopPrevention),e.cannotBeStopped=!1}}])}();os.PreventConnectionStop=ls;var cs={},us={};Object.defineProperty(us,"__esModule",{value:!0}),us.README_URL=void 0,us.README_URL="https://github.com/OvidijusParsiunas/speech-to-element",Object.defineProperty(cs,"__esModule",{value:!0}),cs.AzureSpeechConfig=void 0;var ds=us,hs=function(){function e(){x(this,e)}return E(e,null,[{key:"validateOptions",value:function(e,t){return t?t.subscriptionKey||t.token||t.retrieveToken?!!t.region||(e("Please define a 'region' property - more info: ".concat(ds.README_URL)),!1):(e("Please define a 'subscriptionKey', 'token' or 'retrieveToken' property - more info: ".concat(ds.README_URL)),!1):(e("Please provide subscription details - more info: ".concat(ds.README_URL)),!1)}},{key:"getNewSpeechConfig",value:(n=f(h().mark((function e(t,n){return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!n.region){e.next=2;break}return e.abrupt("return",n.subscriptionKey?t.fromSubscription(n.subscriptionKey.trim(),n.region.trim()):n.token?t.fromAuthorizationToken(n.token.trim(),n.region.trim()):n.retrieveToken?n.retrieveToken().then((function(e){return n.region?t.fromAuthorizationToken((null==e?void 0:e.trim())||"",n.region.trim()):null})).catch((function(e){return console.error(e),null})):null);case 2:case"end":return e.stop()}}),e)}))),function(e,t){return n.apply(this,arguments)})},{key:"process",value:function(e,t){t.language&&(e.speechRecognitionLanguage=t.language.trim())}},{key:"get",value:(t=f(h().mark((function t(n,r){var i;return h().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e.getNewSpeechConfig(n,r);case 2:return i=t.sent,t.abrupt("return",(i&&e.process(i,r),i));case 4:case"end":return t.stop()}}),t)}))),function(e,n){return t.apply(this,arguments)})}]);var t,n}();cs.AzureSpeechConfig=hs;var ps={};Object.defineProperty(ps,"__esModule",{value:!0}),ps.StopTimeout=void 0;var fs=function(){function e(){x(this,e)}return E(e,null,[{key:"set",value:function(e){e.stopTimeout=setTimeout((function(){return e.stop()}),e.stopTimeoutMS)}},{key:"reset",value:function(t,n){t.stopTimeoutMS=n||e.DEFAULT_MS,t.stopTimeout&&clearTimeout(t.stopTimeout),e.set(t)}}])}();ps.StopTimeout=fs,fs.DEFAULT_MS=2e4;var ms={};Object.defineProperty(ms,"__esModule",{value:!0}),ms.AzureTranscript=void 0;var vs=li,gs=function(){return E((function e(){x(this,e)}),null,[{key:"extract",value:function(e,t,n,r){return r&&(e=vs.Translate.translate(e,r)),n?{interimTranscript:"",finalTranscript:t+e,newText:e}:{interimTranscript:e,finalTranscript:t,newText:e}}}])}();ms.AzureTranscript=gs,Object.defineProperty(as,"__esModule",{value:!0}),as.Azure=void 0;var ys=os,bs=cs,ks=ps,_s=ms,xs=function(e){function t(){var e;return x(this,t),(e=s(this,t,arguments))._newTextPadding="",e}return c(t,e),E(t,[{key:"start",value:function(e,t){this._newTextPadding="",void 0===this.stopTimeout&&ks.StopTimeout.reset(this,null==e?void 0:e.stopAfterSilenceMs),this.prepareBeforeStart(e),this.startAsync(e),t||ys.PreventConnectionStop.applyPrevention(this)}},{key:"startAsync",value:(r=f(h().mark((function e(t){var n;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.t0=this.validate(t),!e.t0){e.next=6;break}return e.next=4,this.instantiateService(t);case 4:this._translations=null==t?void 0:t.translations,null===(n=this._service)||void 0===n||n.startContinuousRecognitionAsync((function(){}),this.error);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"validate",value:function(e){return t.getAPI()?bs.AzureSpeechConfig.validateOptions(this.error.bind(this),e):(this.moduleNotFound(),!1)}},{key:"instantiateService",value:(n=f(h().mark((function e(n){var r,i,s,a;return h().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.getAPI(),i=r.AudioConfig.fromDefaultMicrophoneInput(),e.next=4,bs.AzureSpeechConfig.get(r.SpeechConfig,n);case 4:(s=e.sent)?(a=new r.SpeechRecognizer(s,i),this.setEvents(a),this._service=a,n.retrieveToken&&this.retrieveTokenInterval(n.retrieveToken)):this.error("Unable to contact Azure server");case 6:case"end":return e.stop()}}),e,this)}))),function(e){return n.apply(this,arguments)})},{key:"setEvents",value:function(e){e.recognizing=this.onRecognizing.bind(this),e.recognized=this.onRecognized.bind(this),e.sessionStarted=this.onSessionStarted.bind(this),e.canceled=this.onCanceled.bind(this),e.sessionStopped=this.onSessionStopped.bind(this)}},{key:"onRecognizing",value:function(e,t){if(!this._stopping){var n=_s.AzureTranscript.extract(this._newTextPadding+t.result.text,this.finalTranscript,!1,this._translations),r=n.interimTranscript,i=n.finalTranscript,s=n.newText;ks.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(r,i,s)}}},{key:"onRecognized",value:function(e,t){var n=t.result;switch(n.reason){case window.SpeechSDK.ResultReason.Canceled:break;case window.SpeechSDK.ResultReason.RecognizedSpeech:if(n.text&&!this._stopping){var r=_s.AzureTranscript.extract(this._newTextPadding+n.text,this.finalTranscript,!0,this._translations),i=r.interimTranscript,s=r.finalTranscript,a=r.newText;ks.StopTimeout.reset(this,this.stopTimeoutMS),this.updateElements(i,s,a),""!==s&&(this._newTextPadding=" ")}}}},{key:"onCanceled",value:function(e,t){t.reason===window.SpeechSDK.CancellationReason.Error&&this.error(t.errorDetails)}},{key:"onSessionStarted",value:function(){ys.PreventConnectionStop.clearPrevention(this),this.setStateOnStart()}},{key:"onSessionStopped",value:function(){this._retrieveTokenInterval||clearInterval(this._retrieveTokenInterval),this._stopping=!1,this.setStateOnStop()}},{key:"retrieveTokenInterval",value:function(e){var t=this;this._retrieveTokenInterval=setInterval((function(){null==e||e().then((function(e){t._service&&(t._service.authorizationToken=(null==e?void 0:e.trim())||"")})).catch((function(e){t.error(e)}))}),1e4)}},{key:"stop",value:function(e){var t;!e&&this._retrieveTokenInterval&&clearInterval(this._retrieveTokenInterval),this._stopping=!0,null===(t=this._service)||void 0===t||t.stopContinuousRecognitionAsync(),this.finalise(e)}},{key:"moduleNotFound",value:function(){console.error("speech recognition module not found:"),console.error("please install the 'microsoft-cognitiveservices-speech-sdk' npm package or add a script tag: + diff --git a/docs/demo/index.html b/docs/demo/index.html index f1e49cf35..1b11ff4c5 100644 --- a/docs/demo/index.html +++ b/docs/demo/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/AssemblyAI/index.html b/docs/directConnection/AssemblyAI/index.html index f5f93883e..036c93a06 100644 --- a/docs/directConnection/AssemblyAI/index.html +++ b/docs/directConnection/AssemblyAI/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/Azure/index.html b/docs/directConnection/Azure/index.html index 4d168777e..284f66045 100644 --- a/docs/directConnection/Azure/index.html +++ b/docs/directConnection/Azure/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/Cohere/index.html b/docs/directConnection/Cohere/index.html index d89b0563d..449ae3870 100644 --- a/docs/directConnection/Cohere/index.html +++ b/docs/directConnection/Cohere/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/HuggingFace/index.html b/docs/directConnection/HuggingFace/index.html index 9d5a429a9..e36df39cf 100644 --- a/docs/directConnection/HuggingFace/index.html +++ b/docs/directConnection/HuggingFace/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/OpenAI/index.html b/docs/directConnection/OpenAI/index.html index 266edfe68..52cf4e975 100644 --- a/docs/directConnection/OpenAI/index.html +++ b/docs/directConnection/OpenAI/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/StabilityAI/index.html b/docs/directConnection/StabilityAI/index.html index 329294d78..dcde81e17 100644 --- a/docs/directConnection/StabilityAI/index.html +++ b/docs/directConnection/StabilityAI/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/directConnection/index.html b/docs/directConnection/index.html index b8e524559..9403340c4 100644 --- a/docs/directConnection/index.html +++ b/docs/directConnection/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/events/index.html b/docs/events/index.html index d73d6f02b..fe3b82609 100644 --- a/docs/events/index.html +++ b/docs/events/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/files/index.html b/docs/files/index.html index 1b3e50110..69295555e 100644 --- a/docs/files/index.html +++ b/docs/files/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/installation/index.html b/docs/installation/index.html index 9ad6207a0..c69c2b8b4 100644 --- a/docs/installation/index.html +++ b/docs/installation/index.html @@ -13,7 +13,7 @@ - + @@ -23,6 +23,6 @@

    For React, install the following instead:

    npm install deep-chat-react

    Access the component via CDN:

    -
    https://unpkg.com/deep-chat@2.1.0/dist/deepChat.bundle.js
    +
    https://unpkg.com/deep-chat@2.1.1/dist/deepChat.bundle.js
    \ No newline at end of file diff --git a/docs/interceptors/index.html b/docs/interceptors/index.html index 63a553f48..0e5faa5da 100644 --- a/docs/interceptors/index.html +++ b/docs/interceptors/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/introPanel/index.html b/docs/introPanel/index.html index 1845989f9..80c063604 100644 --- a/docs/introPanel/index.html +++ b/docs/introPanel/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/introduction/index.html b/docs/introduction/index.html index 765942e34..11b7d3fce 100644 --- a/docs/introduction/index.html +++ b/docs/introduction/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/messages/HTML/index.html b/docs/messages/HTML/index.html index d086c3858..4ad61151f 100644 --- a/docs/messages/HTML/index.html +++ b/docs/messages/HTML/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/messages/index.html b/docs/messages/index.html index 796b21ee2..c07914cce 100644 --- a/docs/messages/index.html +++ b/docs/messages/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/messages/styles/index.html b/docs/messages/styles/index.html index 06923f693..0dfe67aca 100644 --- a/docs/messages/styles/index.html +++ b/docs/messages/styles/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/methods/index.html b/docs/methods/index.html index 8e998244c..b9402c6b5 100644 --- a/docs/methods/index.html +++ b/docs/methods/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/speech/index.html b/docs/speech/index.html index 20c523fac..af2a8b026 100644 --- a/docs/speech/index.html +++ b/docs/speech/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/styles/index.html b/docs/styles/index.html index 672b7f3de..01514a001 100644 --- a/docs/styles/index.html +++ b/docs/styles/index.html @@ -13,7 +13,7 @@ - + diff --git a/docs/webModel/index.html b/docs/webModel/index.html index 1208f0ab3..7c73326f4 100644 --- a/docs/webModel/index.html +++ b/docs/webModel/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/Layout/fullScreen/index.html b/examples/Layout/fullScreen/index.html index aad3f12d1..f4aa9bbe9 100644 --- a/examples/Layout/fullScreen/index.html +++ b/examples/Layout/fullScreen/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/Layout/sticky/index.html b/examples/Layout/sticky/index.html index 225389459..0ba0ca596 100644 --- a/examples/Layout/sticky/index.html +++ b/examples/Layout/sticky/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/design/index.html b/examples/design/index.html index 645cacd91..a837fd7c6 100644 --- a/examples/design/index.html +++ b/examples/design/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/externalModules/index.html b/examples/externalModules/index.html index bba766c2d..a01a82768 100644 --- a/examples/externalModules/index.html +++ b/examples/externalModules/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/frameworks/index.html b/examples/frameworks/index.html index 0f319c5ef..f12f9e9c7 100644 --- a/examples/frameworks/index.html +++ b/examples/frameworks/index.html @@ -13,7 +13,7 @@ - + diff --git a/examples/servers/index.html b/examples/servers/index.html index 305773e55..f3756690e 100644 --- a/examples/servers/index.html +++ b/examples/servers/index.html @@ -13,7 +13,7 @@ - + diff --git a/exploreButton/exploreButton/index.html b/exploreButton/exploreButton/index.html index efab03d43..508e1dd67 100644 --- a/exploreButton/exploreButton/index.html +++ b/exploreButton/exploreButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/captureFiles/captureFiles/index.html b/features/captureFiles/captureFiles/index.html index cfae750de..5d8eb80e2 100644 --- a/features/captureFiles/captureFiles/index.html +++ b/features/captureFiles/captureFiles/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/connect/connect/index.html b/features/connect/connect/index.html index 54a0a7d8a..a2c4f89ca 100644 --- a/features/connect/connect/index.html +++ b/features/connect/connect/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/customize/customize/index.html b/features/customize/customize/index.html index be6104f82..de6d2a231 100644 --- a/features/customize/customize/index.html +++ b/features/customize/customize/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/features/index.html b/features/features/index.html index 0736855cc..d9652ce10 100644 --- a/features/features/index.html +++ b/features/features/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/media/media/index.html b/features/media/media/index.html index 86ba8c58d..945be2722 100644 --- a/features/media/media/index.html +++ b/features/media/media/index.html @@ -13,7 +13,7 @@ - + diff --git a/features/speech/speech/index.html b/features/speech/speech/index.html index fe9271b7b..5b4a54413 100644 --- a/features/speech/speech/index.html +++ b/features/speech/speech/index.html @@ -13,7 +13,7 @@ - + diff --git a/footer/footer/index.html b/footer/footer/index.html index a5e0d157c..99b8e7dbd 100644 --- a/footer/footer/index.html +++ b/footer/footer/index.html @@ -13,7 +13,7 @@ - + diff --git a/index.html b/index.html index 8de1c603e..2510a6b76 100644 --- a/index.html +++ b/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/manipulate/playgroundAddButton/index.html b/playground/chat/manipulate/playgroundAddButton/index.html index bd81f5f1b..000f544a7 100644 --- a/playground/chat/manipulate/playgroundAddButton/index.html +++ b/playground/chat/manipulate/playgroundAddButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/playgroundChatComponent/index.html b/playground/chat/playgroundChatComponent/index.html index d28fba347..17dc3a597 100644 --- a/playground/chat/playgroundChatComponent/index.html +++ b/playground/chat/playgroundChatComponent/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/playgroundChatWrapper/index.html b/playground/chat/playgroundChatWrapper/index.html index 8980a3175..a60648ff8 100644 --- a/playground/chat/playgroundChatWrapper/index.html +++ b/playground/chat/playgroundChatWrapper/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/playgroundChatWrapperConfig/index.html b/playground/chat/playgroundChatWrapperConfig/index.html index a908b2d87..6d8f49831 100644 --- a/playground/chat/playgroundChatWrapperConfig/index.html +++ b/playground/chat/playgroundChatWrapperConfig/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/playgroundChatWrapperLogo/index.html b/playground/chat/playgroundChatWrapperLogo/index.html index 861d048f1..b47545460 100644 --- a/playground/chat/playgroundChatWrapperLogo/index.html +++ b/playground/chat/playgroundChatWrapperLogo/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/chat/playgroundChatWrapperText/index.html b/playground/chat/playgroundChatWrapperText/index.html index 912ac8c0f..4cf987b06 100644 --- a/playground/chat/playgroundChatWrapperText/index.html +++ b/playground/chat/playgroundChatWrapperText/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/export/modal/playgroundExportModal/index.html b/playground/header/export/modal/playgroundExportModal/index.html index f4ebc4fdd..2805cc648 100644 --- a/playground/header/export/modal/playgroundExportModal/index.html +++ b/playground/header/export/modal/playgroundExportModal/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/export/playgroundExportButton/index.html b/playground/header/export/playgroundExportButton/index.html index 929e3a3fb..08968e61b 100644 --- a/playground/header/export/playgroundExportButton/index.html +++ b/playground/header/export/playgroundExportButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/information/modal/playgroundInformationModal/index.html b/playground/header/information/modal/playgroundInformationModal/index.html index 7521848a5..56ff80a20 100644 --- a/playground/header/information/modal/playgroundInformationModal/index.html +++ b/playground/header/information/modal/playgroundInformationModal/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/information/playgroundInformationButton/index.html b/playground/header/information/playgroundInformationButton/index.html index df8e53862..5d54a47b5 100644 --- a/playground/header/information/playgroundInformationButton/index.html +++ b/playground/header/information/playgroundInformationButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/layout/playgroundLayoutButton/index.html b/playground/header/layout/playgroundLayoutButton/index.html index 640138129..69dac0644 100644 --- a/playground/header/layout/playgroundLayoutButton/index.html +++ b/playground/header/layout/playgroundLayoutButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/playgroundCog/index.html b/playground/header/playgroundCog/index.html index 78239652a..fe92f5fa6 100644 --- a/playground/header/playgroundCog/index.html +++ b/playground/header/playgroundCog/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/playgroundHeaderButtons/index.html b/playground/header/playgroundHeaderButtons/index.html index f4ea6d9f8..2a0fa339f 100644 --- a/playground/header/playgroundHeaderButtons/index.html +++ b/playground/header/playgroundHeaderButtons/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/playgroundShield/index.html b/playground/header/playgroundShield/index.html index d4885c5bf..303dbdfac 100644 --- a/playground/header/playgroundShield/index.html +++ b/playground/header/playgroundShield/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/upload/modal/playgroundUploadModal/index.html b/playground/header/upload/modal/playgroundUploadModal/index.html index b19f33b0f..24c4c5988 100644 --- a/playground/header/upload/modal/playgroundUploadModal/index.html +++ b/playground/header/upload/modal/playgroundUploadModal/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/header/upload/playgroundUploadButton/index.html b/playground/header/upload/playgroundUploadButton/index.html index 08053645c..6a0bb060b 100644 --- a/playground/header/upload/playgroundUploadButton/index.html +++ b/playground/header/upload/playgroundUploadButton/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/index.html b/playground/index.html index 833e9c1a7..b3866bc5d 100644 --- a/playground/index.html +++ b/playground/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/playgroundSelect/index.html b/playground/playgroundSelect/index.html index ee05e3d31..48cfb5303 100644 --- a/playground/playgroundSelect/index.html +++ b/playground/playgroundSelect/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/close/serviceModalCloseButtons/index.html b/playground/serviceModal/close/serviceModalCloseButtons/index.html index 426070142..50141b6eb 100644 --- a/playground/serviceModal/close/serviceModalCloseButtons/index.html +++ b/playground/serviceModal/close/serviceModalCloseButtons/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/code/serviceCode/index.html b/playground/serviceModal/code/serviceCode/index.html index d2f06f293..84efe71ae 100644 --- a/playground/serviceModal/code/serviceCode/index.html +++ b/playground/serviceModal/code/serviceCode/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/fields/serviceConstructableObject/index.html b/playground/serviceModal/fields/serviceConstructableObject/index.html index 261576ff4..cec3a68fd 100644 --- a/playground/serviceModal/fields/serviceConstructableObject/index.html +++ b/playground/serviceModal/fields/serviceConstructableObject/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/fields/serviceField/index.html b/playground/serviceModal/fields/serviceField/index.html index eb359bcc2..a798dc9cd 100644 --- a/playground/serviceModal/fields/serviceField/index.html +++ b/playground/serviceModal/fields/serviceField/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/fields/serviceOptionalParametersFields/index.html b/playground/serviceModal/fields/serviceOptionalParametersFields/index.html index c9a53840c..0380323d0 100644 --- a/playground/serviceModal/fields/serviceOptionalParametersFields/index.html +++ b/playground/serviceModal/fields/serviceOptionalParametersFields/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/fields/serviceRequiredField/index.html b/playground/serviceModal/fields/serviceRequiredField/index.html index 951c79a7a..7a343c615 100644 --- a/playground/serviceModal/fields/serviceRequiredField/index.html +++ b/playground/serviceModal/fields/serviceRequiredField/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/fields/serviceTypeField/index.html b/playground/serviceModal/fields/serviceTypeField/index.html index 4df9e4111..114058f6c 100644 --- a/playground/serviceModal/fields/serviceTypeField/index.html +++ b/playground/serviceModal/fields/serviceTypeField/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/serviceModal/index.html b/playground/serviceModal/serviceModal/index.html index 75716a4b3..23b3d873d 100644 --- a/playground/serviceModal/serviceModal/index.html +++ b/playground/serviceModal/serviceModal/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/serviceModal/wrappers/collapsableSection/index.html b/playground/serviceModal/wrappers/collapsableSection/index.html index 338194ec4..17cc01264 100644 --- a/playground/serviceModal/wrappers/collapsableSection/index.html +++ b/playground/serviceModal/wrappers/collapsableSection/index.html @@ -13,7 +13,7 @@ - + diff --git a/playground/tooltip/playgroundTooltipWrapper/index.html b/playground/tooltip/playgroundTooltipWrapper/index.html index 159d93053..437d19c45 100644 --- a/playground/tooltip/playgroundTooltipWrapper/index.html +++ b/playground/tooltip/playgroundTooltipWrapper/index.html @@ -13,7 +13,7 @@ - + diff --git a/preload/preloadImages/index.html b/preload/preloadImages/index.html index d5cced7f7..60afd2c5a 100644 --- a/preload/preloadImages/index.html +++ b/preload/preloadImages/index.html @@ -13,7 +13,7 @@ - + diff --git a/preload/preloadPlaygroundImages/index.html b/preload/preloadPlaygroundImages/index.html index 3ae3b809d..44c212eb5 100644 --- a/preload/preloadPlaygroundImages/index.html +++ b/preload/preloadPlaygroundImages/index.html @@ -13,7 +13,7 @@ - + diff --git a/preload/preloadStartImages/index.html b/preload/preloadStartImages/index.html index 560d058d5..2e1de8226 100644 --- a/preload/preloadStartImages/index.html +++ b/preload/preloadStartImages/index.html @@ -13,7 +13,7 @@ - + diff --git a/search/index.html b/search/index.html index 00bb63bec..c361680ed 100644 --- a/search/index.html +++ b/search/index.html @@ -13,7 +13,7 @@ - + diff --git a/smallScreen/deepChatLogo/index.html b/smallScreen/deepChatLogo/index.html index bbdcf0180..5fcdbde50 100644 --- a/smallScreen/deepChatLogo/index.html +++ b/smallScreen/deepChatLogo/index.html @@ -13,7 +13,7 @@ - + diff --git a/smallScreen/smallScreen/index.html b/smallScreen/smallScreen/index.html index 72e9d0c47..261542936 100644 --- a/smallScreen/smallScreen/index.html +++ b/smallScreen/smallScreen/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/aiInYourBrowser/index.html b/start/aiInYourBrowser/index.html index 5d3cf6d7c..2789a4c3a 100644 --- a/start/aiInYourBrowser/index.html +++ b/start/aiInYourBrowser/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/connectToCustomAPI/index.html b/start/connectToCustomAPI/index.html index 7f3eb1498..c8a9caf78 100644 --- a/start/connectToCustomAPI/index.html +++ b/start/connectToCustomAPI/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/connectToPopularAPI/index.html b/start/connectToPopularAPI/index.html index 2204b34ff..5b1b06153 100644 --- a/start/connectToPopularAPI/index.html +++ b/start/connectToPopularAPI/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/createComponent/index.html b/start/createComponent/index.html index 352c2d9be..80e27e154 100644 --- a/start/createComponent/index.html +++ b/start/createComponent/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/index.html b/start/index.html index 9228d4015..29b44396c 100644 --- a/start/index.html +++ b/start/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/options/index.html b/start/options/index.html index 38e81e033..80dc5687b 100644 --- a/start/options/index.html +++ b/start/options/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/startParticles/index.html b/start/startParticles/index.html index a859e2398..d0fbbe171 100644 --- a/start/startParticles/index.html +++ b/start/startParticles/index.html @@ -13,7 +13,7 @@ - + diff --git a/start/startSmallScreen/index.html b/start/startSmallScreen/index.html index c4c69a6c0..7ebd98298 100644 --- a/start/startSmallScreen/index.html +++ b/start/startSmallScreen/index.html @@ -13,7 +13,7 @@ - + diff --git a/startPanel/startPanel/index.html b/startPanel/startPanel/index.html index d22a72d87..0adbda9e2 100644 --- a/startPanel/startPanel/index.html +++ b/startPanel/startPanel/index.html @@ -13,7 +13,7 @@ - + diff --git a/startPanel/startPanelParticles/index.html b/startPanel/startPanelParticles/index.html index 04ea81243..e703a48ca 100644 --- a/startPanel/startPanelParticles/index.html +++ b/startPanel/startPanelParticles/index.html @@ -13,7 +13,7 @@ - + diff --git a/utils/fadeInContent/index.html b/utils/fadeInContent/index.html index 2e1a5cdeb..08ab9f126 100644 --- a/utils/fadeInContent/index.html +++ b/utils/fadeInContent/index.html @@ -13,7 +13,7 @@ - + diff --git a/utils/fadeInNav/index.html b/utils/fadeInNav/index.html index aeedb6bf1..649f12603 100644 --- a/utils/fadeInNav/index.html +++ b/utils/fadeInNav/index.html @@ -13,7 +13,7 @@ - + diff --git a/utils/onVisibleAnimation/index.html b/utils/onVisibleAnimation/index.html index c0ab6cb41..34deb0a87 100644 --- a/utils/onVisibleAnimation/index.html +++ b/utils/onVisibleAnimation/index.html @@ -13,7 +13,7 @@ - +