UNPKG

deep-chat

Version:

Customizable chat component for AI APIs

880 lines 628 kB
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n2 = 0, F = function F() {}; return { s: F, n: function n() { return _n2 >= r.length ? { done: !0 } : { done: !1, value: r[_n2++] }; }, e: function e(r) { throw r; }, f: F }; } 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 o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _wrapNativeSuper(t) { var r = "function" == typeof Map ? new Map() : void 0; return _wrapNativeSuper = function _wrapNativeSuper(t) { if (null === t || !_isNativeFunction(t)) return t; if ("function" != typeof t) throw new TypeError("Super expression must either be null or a function"); if (void 0 !== r) { if (r.has(t)) return r.get(t); r.set(t, Wrapper); } function Wrapper() { return _construct(t, arguments, _getPrototypeOf(this).constructor); } return Wrapper.prototype = Object.create(t.prototype, { constructor: { value: Wrapper, enumerable: !1, writable: !0, configurable: !0 } }), _setPrototypeOf(Wrapper, t); }, _wrapNativeSuper(t); } function _construct(t, e, r) { if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments); var o = [null]; o.push.apply(o, e); var p = new (t.bind.apply(t, o))(); return r && _setPrototypeOf(p, r.prototype), p; } function _isNativeFunction(t) { try { return -1 !== Function.toString.call(t).indexOf("[native code]"); } catch (n) { return "function" == typeof t; } } function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); } function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); } function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; } function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); } function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); } function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); } function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); } function _nonIterableRest() { 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 _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } } function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); } function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; } function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); } function _nonIterableSpread() { 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 _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); } function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } var Pn = /*#__PURE__*/function () { function Pn() { _classCallCheck(this, Pn); } return _createClass(Pn, null, [{ key: "render", value: function render(e, t) { var i = document.createElement("div"); i.id = "error-view", i.innerText = t, e.replaceChildren(i); } }]); }(); var fi = /*#__PURE__*/function () { function fi() { _classCallCheck(this, fi); } return _createClass(fi, null, [{ key: "onLoad", value: function onLoad(e) { e.innerHTML = '<div id="loading-validate-key-property"></div>'; } }, { key: "createElements", value: function createElements() { var e = document.createElement("div"); return e.id = "validate-property-key-view", e; } }, { key: "render", value: function render(e, t, i) { var s = fi.createElements(), r = { onSuccess: t, onFail: Pn.render.bind(this, e, "Your 'key' has failed authentication"), onLoad: fi.onLoad.bind(this, s) }; i.key && i.verifyKey(i.key, r), e.replaceChildren(s); } }]); }(); var R = /*#__PURE__*/function () { function R() { _classCallCheck(this, R); } return _createClass(R, null, [{ key: "unsetStyle", value: function unsetStyle(e, t) { var i = Object.keys(t).reduce(function (s, r) { return s[r] = "", s; }, {}); Object.assign(e.style, i); } }, { key: "unsetActivityCSSMouseStates", value: function unsetActivityCSSMouseStates(e, t) { t.click && R.unsetStyle(e, t.click), t.hover && R.unsetStyle(e, t.hover); } }, { key: "unsetAllCSSMouseStates", value: function unsetAllCSSMouseStates(e, t) { R.unsetActivityCSSMouseStates(e, t), t["default"] && R.unsetStyle(e, t["default"]); } }, { key: "processStateful", value: function processStateful(e, t, i) { var s = e["default"] || {}, r = Object.assign(JSON.parse(JSON.stringify(_objectSpread(_objectSpread({}, s), t))), e == null ? void 0 : e.hover), o = Object.assign(JSON.parse(JSON.stringify(_objectSpread(_objectSpread({}, r), i))), e == null ? void 0 : e.click); return { "default": s, hover: r, click: o }; } }, { key: "mergeStatefulStyles", value: function mergeStatefulStyles(e) { var t = { "default": {}, hover: {}, click: {} }; return e.forEach(function (i) { t["default"] = Object.assign(t["default"], i["default"]), t.hover = Object.assign(t.hover, i.hover), t.click = Object.assign(t.click, i.click); }), t; } }, { key: "overwriteDefaultWithAlreadyApplied", value: function overwriteDefaultWithAlreadyApplied(e, t) { Object.keys(e["default"] || []).forEach(function (i) { var r; var s = i; t.style[s] && (r = e["default"]) != null && r[s] && (e["default"][i] = t.style[s]); }); } }, { key: "applyToStyleIfNotDefined", value: function applyToStyleIfNotDefined(e, t) { for (var i in t) { var s = t[i]; e[i] === "" && s && (e[i] = s); } } }]); }(); var Ke = /*#__PURE__*/function () { function Ke() { _classCallCheck(this, Ke); } return _createClass(Ke, null, [{ key: "attemptAppendStyleSheetToHead", value: function attemptAppendStyleSheetToHead(e) { if (e.fontFamily && e.fontFamily !== Ke.DEFAULT_FONT_FAMILY) return; var t = document.getElementsByTagName("head")[0]; if (!Array.from(t.getElementsByTagName("link")).some(function (s) { return s.getAttribute("href") === Ke.FONT_URL; })) { var s = document.createElement("link"); s.rel = "stylesheet", s.href = Ke.FONT_URL, t.appendChild(s); } } }]); }(); Ke.FONT_URL = "https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap", Ke.DEFAULT_FONT_FAMILY = "'Inter', sans-serif, Avenir, Helvetica, Arial"; var pi = Ke; var mt = /*#__PURE__*/function () { function mt() { _classCallCheck(this, mt); } return _createClass(mt, null, [{ key: "apply", value: function apply(e, t) { if (t) try { mt.applyStyleSheet(e, t); } catch (_unused) { mt.addStyleElement(e, t); } } }, { key: "applyStyleSheet", value: function applyStyleSheet(e, t) { var i = new CSSStyleSheet(); i.replaceSync(e), t.adoptedStyleSheets.push(i); } }, { key: "addStyleElement", value: function addStyleElement(e, t) { var i = document.createElement("style"); i.innerHTML = e, t.appendChild(i); } }, { key: "applyDefaultStyleToComponent", value: function applyDefaultStyleToComponent(e, t) { t && R.applyToStyleIfNotDefined(e, t), R.applyToStyleIfNotDefined(e, mt.DEFAULT_COMPONENT_STYLE); } }]); }(); mt.DEFAULT_COMPONENT_STYLE = { height: "350px", width: "320px", borderTop: "1px solid #cacaca", borderRight: "1px solid #cacaca", borderLeft: "1px solid #cacaca", borderBottom: "1px solid #cacaca", fontFamily: pi.DEFAULT_FONT_FAMILY, fontSize: "0.9rem", backgroundColor: "white", position: "relative", // this is used to prevent inputAreaStyle background color from going beyond the container's rounded border // it will cause issues if there are elements that are meant to be outside of the chat component and in // that instance they should overwrite this // this is also causing the chat to squeeze when there is no space overflow: "hidden" }; var Pt = mt; var st; var Ct = (st = /*#__PURE__*/_createClass(function st() { _classCallCheck(this, st); }), st.IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent), st.IS_CHROMIUM = window.chrome, st); var D = /* @__PURE__ */function (n) { return n.ESCAPE = "Escape", n.ENTER = "Enter", n.TAB = "Tab", n.ARROW_UP = "ArrowUp", n.ARROW_DOWN = "ArrowDown", n.ARROW_RIGHT = "ArrowRight", n.ARROW_LEFT = "ArrowLeft", n.BACKSPACE = "Backspace", n.DELETE = "Delete", n.META = "Meta", n.CONTROL = "Control", n; }(D || {}); var Je = /*#__PURE__*/function () { function Je() { _classCallCheck(this, Je); } return _createClass(Je, null, [{ key: "add", value: // prettier-ignore function add(e, t, i, s) { i !== void 0 && e.addEventListener("keydown", Je.onKeyDown.bind(this, i)), e.oninput = Je.onInput.bind(this, i, s), e.addEventListener("paste", function (r) { var o; r.preventDefault(), (o = r.clipboardData) != null && o.files.length && t.addFilesToAnyType(Array.from(r.clipboardData.files)); }); } // preventing insertion early for a nicer UX // prettier-ignore }, { key: "onKeyDown", value: function onKeyDown(e, t) { var s = t.target.textContent; s && s.length >= e && !Je.PERMITTED_KEYS.has(t.key) && !Je.isKeyCombinationPermitted(t) && t.preventDefault(); } }, { key: "isKeyCombinationPermitted", value: function isKeyCombinationPermitted(e) { return e.key === "a" ? e.ctrlKey || e.metaKey : !1; } }, { key: "onInput", value: function onInput(e, t, i) { var s = i.target, r = s.textContent || ""; e !== void 0 && r.length > e && (s.textContent = r.substring(0, e), Qt.focusEndOfInput(s)), t == null || t(); } }]); }(); Je.PERMITTED_KEYS = /* @__PURE__ */new Set([D.BACKSPACE, D.DELETE, D.ARROW_RIGHT, D.ARROW_LEFT, D.ARROW_DOWN, D.ARROW_UP, D.META, D.CONTROL, D.ENTER]); var ds = Je; var On = /*#__PURE__*/function () { function On() { _classCallCheck(this, On); } return _createClass(On, null, [{ key: "sanitizePastedTextContent", value: function sanitizePastedTextContent(e) { var i, s; e.preventDefault(); var t = (i = e.clipboardData) == null ? void 0 : i.getData("text/plain"); t && ((s = document.execCommand) == null || s.call(document, "insertText", !1, t)); } }]); }(); var Ze = /*#__PURE__*/function () { function Ze(e, t, i) { var _this = this; _classCallCheck(this, Ze); var r, o; var s = Ze.processConfig(t, e.textInput); this.elementRef = Ze.createContainerElement((r = s == null ? void 0 : s.styles) == null ? void 0 : r.container), this._config = s, this.inputElementRef = this.createInputElement(), this.elementRef.appendChild(this.inputElementRef), e.setPlaceholderText = this.setPlaceholderText.bind(this), e.setPlaceholderText(((o = this._config.placeholder) == null ? void 0 : o.text) || "Ask me anything!"), setTimeout(function () { ds.add(_this.inputElementRef, i, _this._config.characterLimit, e._validationHandler); }); } return _createClass(Ze, [{ key: "clear", value: // this also similarly prevents scroll up function clear() { var t; var e = window.scrollY; this.inputElementRef.classList.contains("text-input-disabled") || (Object.assign(this.inputElementRef.style, (t = this._config.placeholder) == null ? void 0 : t.style), this.inputElementRef.textContent = "", Qt.focusEndOfInput(this.inputElementRef)), Ct.IS_CHROMIUM && window.scrollTo({ top: e }); } }, { key: "createInputElement", value: function createInputElement() { var t, i, s, r; var e = document.createElement("div"); return e.id = Ze.TEXT_INPUT_ID, e.classList.add("text-input-styling"), Ct.IS_CHROMIUM && Ze.preventAutomaticScrollUpOnNewLine(e), typeof this._config.disabled == "boolean" && this._config.disabled === !0 ? (e.contentEditable = "false", e.classList.add("text-input-disabled")) : (e.contentEditable = "true", this.addEventListeners(e)), Object.assign(e.style, (t = this._config.styles) == null ? void 0 : t.text), Object.assign(e.style, (i = this._config.placeholder) == null ? void 0 : i.style), (r = (s = this._config.placeholder) == null ? void 0 : s.style) != null && r.color || e.setAttribute("textcolor", ""), e; } }, { key: "removePlaceholderStyle", value: function removePlaceholderStyle() { var e, t, i, s; !this.inputElementRef.classList.contains("text-input-disabled") && (e = this._config.placeholder) != null && e.style && (R.unsetStyle(this.inputElementRef, (t = this._config.placeholder) == null ? void 0 : t.style), Object.assign(this.inputElementRef.style, (s = (i = this._config) == null ? void 0 : i.styles) == null ? void 0 : s.text)); } }, { key: "addEventListeners", value: function addEventListeners(e) { var _this2 = this; var t, i; (t = this._config.styles) != null && t.focus && (e.onfocus = function () { var s; return Object.assign(_this2.elementRef.style, (s = _this2._config.styles) == null ? void 0 : s.focus); }, e.onblur = this.onBlur.bind(this, this._config.styles.focus, (i = this._config.styles) == null ? void 0 : i.container)), e.addEventListener("keydown", this.onKeydown.bind(this)), e.addEventListener("input", this.onInput.bind(this)), e.addEventListener("paste", On.sanitizePastedTextContent); } }, { key: "onBlur", value: function onBlur(e, t) { R.unsetStyle(this.elementRef, e), t && Object.assign(this.elementRef.style, t); } }, { key: "onKeydown", value: function onKeydown(e) { var t; e.key === D.ENTER && !e.ctrlKey && !e.shiftKey && (e.preventDefault(), (t = this.submit) == null || t.call(this)); } }, { key: "onInput", value: function onInput() { var e; this.isTextInputEmpty() ? Object.assign(this.inputElementRef.style, (e = this._config.placeholder) == null ? void 0 : e.style) : this.removePlaceholderStyle(); } }, { key: "setPlaceholderText", value: function setPlaceholderText(e) { this.inputElementRef.setAttribute("deep-chat-placeholder-text", e); } }, { key: "isTextInputEmpty", value: function isTextInputEmpty() { return this.inputElementRef.textContent === ""; } }], [{ key: "processConfig", value: function processConfig(e, t) { var _t2, _t$disabled, _t$placeholder, _i$text; var i; return (_t2 = t) !== null && _t2 !== void 0 ? _t2 : t = {}, (_t$disabled = t.disabled) !== null && _t$disabled !== void 0 ? _t$disabled : t.disabled = e.isTextInputDisabled, (_t$placeholder = t.placeholder) !== null && _t$placeholder !== void 0 ? _t$placeholder : t.placeholder = {}, (_i$text = (i = t.placeholder).text) !== null && _i$text !== void 0 ? _i$text : i.text = e.textInputPlaceholderText, t; } }, { key: "createContainerElement", value: function createContainerElement(e) { var t = document.createElement("div"); return t.id = "text-input-container", Object.assign(t.style, e), t; } // this is is a bug fix where if the browser is scrolled down and the user types in text that creates new line // the browser scrollbar will move up which leads to undesirable UX. // More details in this Stack Overflow question: // https://stackoverflow.com/questions/76285135/prevent-automatic-scroll-when-text-is-inserted-into-contenteditable-div // prettier-ignore }, { key: "preventAutomaticScrollUpOnNewLine", value: function preventAutomaticScrollUpOnNewLine(e) { var t; e.addEventListener("keydown", function () { t = window.scrollY; }), e.addEventListener("input", function () { t !== window.scrollY && window.scrollTo({ top: t }); }); } }]); }(); Ze.TEXT_INPUT_ID = "text-input"; var mi = Ze; var Qt = /*#__PURE__*/function () { function Qt() { _classCallCheck(this, Qt); } return _createClass(Qt, null, [{ key: "focusEndOfInput", value: function focusEndOfInput(e) { var t = document.createRange(); t.selectNodeContents(e), t.collapse(!1); var i = window.getSelection(); i == null || i.removeAllRanges(), i == null || i.addRange(t); } }, { key: "focusFromParentElement", value: function focusFromParentElement(e) { var t = e.querySelector("#".concat(mi.TEXT_INPUT_ID)); t && (Ct.IS_SAFARI && t.focus(), Qt.focusEndOfInput(t)); } }]); }(); function Hs(n) { return n.charAt(0).toUpperCase() + n.slice(1); } function Nn(n) { return n && JSON.stringify(n); } function ks(n, e, t, i) { var s = "\n".concat(Hs(e), " message: ").concat(JSON.stringify(n), " \n"), r = t ? "".concat(Hs(e), " message after interceptor: ").concat(Nn(i), " \n") : ""; return s + r; } function Dn(n, e, t, i) { return "".concat(ks(n, e, t, i), "Make sure the ").concat(e, " 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"); } function Bn(n, e, t) { var i = "response"; return "".concat(ks(n, i, e, t), "Make sure the ").concat(i, " message is using the {text: string} format, e.g: {text: \"Model Response\"}"); } function Fn(n, e) { var t = "request"; return "".concat(ks(n, t, e), "Make sure the ").concat(t, " message is using the {body: {text: string}} format, e.g: {body: {text: \"Model Response\"}}"); } var qs = "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", M = { INVALID_KEY: "Invalid API Key", CONNECTION_FAILED: "Failed to connect", INVALID_RESPONSE: Dn, INVALID_MODEL_REQUEST: Fn, INVALID_MODEL_RESPONSE: Bn, INVALID_STREAM_EVENT: qs, 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(qs) }, Ni = /*#__PURE__*/function () { function Ni() { _classCallCheck(this, Ni); } return _createClass(Ni, null, [{ key: "addElements", value: function addElements(e) { for (var _len = arguments.length, t = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { t[_key - 1] = arguments[_key]; } t.forEach(function (i) { return e.appendChild(i); }); } }, { key: "isScrollbarAtBottomOfElement", value: function isScrollbarAtBottomOfElement(e) { var t = e.scrollHeight, i = e.clientHeight, s = e.scrollTop, r = t - i; return s >= r - Ni.CODE_SNIPPET_GENERATION_JUMP; } }, { key: "cloneElement", value: function cloneElement(e) { var t = e.cloneNode(!0); return e.parentNode.replaceChild(t, e), t; } }, { key: "scrollToBottom", value: function scrollToBottom(e) { e.scrollTop = e.scrollHeight; } }, { key: "scrollToTop", value: function scrollToTop(e) { e.scrollTop = 0; } }]); }(); Ni.CODE_SNIPPET_GENERATION_JUMP = 0.5; var X = Ni; var Di = /*#__PURE__*/function () { function Di() { _classCallCheck(this, Di); } return _createClass(Di, null, [{ key: "speak", value: function speak(e, t) { if (window.SpeechSynthesisUtterance) { var i = new SpeechSynthesisUtterance(e); Object.assign(i, t), speechSynthesis.speak(i); } } }, { key: "processConfig", value: function processConfig(e, t) { var i = {}; setTimeout(function () { if (_typeof(e) == "object" && (e.lang && (i.lang = e.lang), e.pitch && (i.pitch = e.pitch), e.rate && (i.rate = e.rate), e.volume && (i.volume = e.volume), e.voiceName)) { var s = window.speechSynthesis.getVoices().find(function (r) { var o; return r.name.toLocaleLowerCase() === ((o = e.voiceName) == null ? void 0 : o.toLocaleLowerCase()); }); s && (i.voice = s); } t(i); }, Di.LOAD_VOICES_MS); } }]); }(); Di.LOAD_VOICES_MS = 200; var xt = Di; var gt = /*#__PURE__*/function () { function gt() { _classCallCheck(this, gt); } return _createClass(gt, null, [{ key: "colorToHex", value: function colorToHex(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 (r) { return parseInt(r).toString(16).padStart(2, "0"); }).join("")); } }, { key: "setDots", value: function setDots(e, t) { var i, s, r, o; if ((o = (r = (s = (i = t == null ? void 0 : t.loading) == null ? void 0 : i.message) == null ? void 0 : s.styles) == null ? void 0 : r.bubble) != null && o.color) { var a = gt.colorToHex(t.loading.message.styles.bubble.color); e.style.setProperty("--loading-message-color", a), e.style.setProperty("--loading-message-color-fade", "".concat(a, "33")); } else e.style.setProperty("--loading-message-color", "#848484"), e.style.setProperty("--loading-message-color-fade", "#55555533"); } }, { key: "setRing", value: function setRing(e, t) { var _ref = t || {}, i = _ref.color, s = _ref.width, r = _ref.height, o = _ref.margin, a = _ref.border; if (i) { var l = gt.colorToHex(i); e.style.setProperty("--loading-history-color", l); } else e.style.setProperty("--loading-history-color", "#dbdbdb"); e.style.setProperty("--loading-history-height", r || "57px"), e.style.setProperty("--loading-history-width", s || "57px"), e.style.setProperty("--loading-history-margin", o || "7px"), e.style.setProperty("--loading-history-border", a || "6px solid"); } }]); }(); gt.BUBBLE_CLASS = "deep-chat-loading-message-bubble", gt.DOTS_CONTAINER_CLASS = "deep-chat-loading-message-dots-container"; var Oe = gt; var ce = /*#__PURE__*/function () { function ce() { _classCallCheck(this, ce); } return _createClass(ce, null, [{ key: "setElementProps", value: // prettier-ignore function setElementProps(e, t, i, s) { var r; i !== "loading" && (e.applyCustomStyles(t, s, !0, (r = e.messageStyles) == null ? void 0 : r[i]), t.bubbleElement.classList.add(ce.FILE_BUBBLE_CLASS)); } // prettier-ignore }, { key: "addMessage", value: function addMessage(e, t, i, s, r) { ce.setElementProps(e, t, i, s), r || (e.elementRef.appendChild(t.outerContainer), e.elementRef.scrollTop = e.elementRef.scrollHeight); } }, { key: "wrapInLink", value: function wrapInLink(e, t, i) { var s = document.createElement("a"); return s.href = t, s.download = i || ce.DEFAULT_FILE_NAME, s.target = "_blank", s.appendChild(e), s; } }, { key: "isNonLinkableDataUrl", value: function isNonLinkableDataUrl(e, t) { return !t.startsWith("data") || e === "image" ? !1 : e === "any" && t.startsWith("data:text/javascript") || !t.startsWith("data:image") && !t.startsWith("data:application"); } }, { key: "processContent", value: function processContent(e, t, i, s) { return !i || ce.isNonLinkableDataUrl(e, i) ? t : ce.wrapInLink(t, i, s); } }, { key: "waitToLoadThenScroll", value: function waitToLoadThenScroll(e) { setTimeout(function () { e.scrollTop = e.scrollHeight; }, 60); } }, { key: "scrollDownOnImageLoad", value: function scrollDownOnImageLoad(e, t) { if (e.startsWith("data")) ce.waitToLoadThenScroll(t);else try { fetch(e, { mode: "no-cors" })["catch"](function () {})["finally"](function () { ce.waitToLoadThenScroll(t); }); } catch (_unused2) { t.scrollTop = t.scrollHeight; } } // The strategy is to emit the actual file reference in the `onMessage` event for the user to inspect it // But it is not actually used by anything in the chat, hence it is removed when adding a message // after the body has been stringified and parsed - the file reference will disappear, hence this readds it }, { key: "reAddFileRefToObject", value: function reAddFileRefToObject(e, t) { var i; (i = e.files) == null || i.forEach(function (s, r) { var o; s.ref && (o = t.message.files) != null && o[r] && (t.message.files[r].ref = s.ref); }); } // the chat does not use the actual file }, { key: "removeFileRef", value: function removeFileRef(e) { var t = _objectSpread({}, e); return delete t.ref, t; } }, { key: "isAudioFile", value: function isAudioFile(e) { var t = /\.(mp3|ogg|wav|aac|webm|4a)$/i, i = e.type, s = e.src; return i === "audio" || (s == null ? void 0 : s.startsWith("data:audio")) || s && t.test(s); } }, { key: "isImageFile", value: function isImageFile(e) { var t = e.type, i = e.src; return t === "image" || (i == null ? void 0 : i.startsWith("data:image")) || i && ce.isImageFileExtension(i); } }, { key: "isImageFileExtension", value: function isImageFileExtension(e) { return /\.(jpg|jpeg|png|gif|bmp)$/i.test(e); } }]); }(); ce.DEFAULT_FILE_NAME = "file", ce.FILE_BUBBLE_CLASS = "file-message"; var j = ce; var Y = /*#__PURE__*/function () { function Y() { _classCallCheck(this, Y); } return _createClass(Y, null, [{ key: "checkForContainerStyles", value: function checkForContainerStyles(e, t) { var i = e.containerStyle; i && (Object.assign(t.style, i), 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")); } // eslint-disable-next-line @typescript-eslint/no-explicit-any }, { key: "handleResponseProperty", value: function handleResponseProperty(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 processHistory(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 processHistoryFile(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 processValidateInput(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 processSubmitUserMessage(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 flagHTMLUpdateClass(e) { var t; (t = e.children[0]) != null && 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 processConnect(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 checkForStream(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 fireOnNewMessage(e, t) { var s; var i = e; i.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"), (s = i.onNewMessage) == null || s.call(i, t)), e.dispatchEvent(new CustomEvent("new-message", { detail: t })); } }, { key: "processFileConfigConnect", value: function processFileConfigConnect(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 processMessageStyles(e) { if (!e) return; var t = structuredClone(e), i = t.loading; return i && (i.outerContainer || i.innerContainer || i.bubble || i.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: i } }), t; } }, { key: "processDemo", value: function processDemo(e) { return typeof e == "boolean" || 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; } }]); }(); var et = /*#__PURE__*/function () { function et() { _classCallCheck(this, et); } return _createClass(et, null, [{ key: "mouseUp", value: function mouseUp(e, t) { R.unsetAllCSSMouseStates(e, t), Object.assign(e.style, t["default"]), Object.assign(e.style, t.hover); } }, { key: "mouseDown", value: function mouseDown(e, t) { Object.assign(e.style, t.click); } }, { key: "mouseLeave", value: function mouseLeave(e, t) { R.unsetAllCSSMouseStates(e, t), Object.assign(e.style, t["default"]); } }, { key: "mouseEnter", value: function mouseEnter(e, t) { Object.assign(e.style, t.hover); } }, { key: "add", value: function add(e, t) { e.addEventListener("mouseenter", et.mouseEnter.bind(this, e, t)), e.addEventListener("mouseleave", et.mouseLeave.bind(this, e, t)), e.addEventListener("mousedown", et.mouseDown.bind(this, e, t)), e.addEventListener("mouseup", et.mouseUp.bind(this, e, t)); } }]); }(); var Un = "deep-chat-temporary-message", jn = "deep-chat-suggestion-button", hs = { "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" } } } }, zs = Object.keys(hs); var Ne = /*#__PURE__*/function () { function Ne() { _classCallCheck(this, Ne); } return _createClass(Ne, null, [{ key: "applySuggestionEvent", value: function applySuggestionEvent(e, t) { setTimeout(function () { t.addEventListener("click", function () { var i, s; (s = e.submitUserMessage) == null || s.call(e, { text: ((i = t.textContent) == null ? void 0 : i.trim()) || "" }); }); }); } }, { key: "isElementTemporary", value: function isElementTemporary(e) { var t; return e ? (t = e.bubbleElement.children[0]) == null ? void 0 : t.classList.contains(Un) : !1; } }, { key: "doesElementContainDeepChatClass", value: function doesElementContainDeepChatClass(e) { return zs.find(function (t) { return e.classList.contains(t); }); } }, { key: "applyEvents", value: function applyEvents(e, t) { var i = hs[t].events; Object.keys(i || []).forEach(function (s) { e.addEventListener(s, i == null ? void 0 : i[s]); }); } }, { key: "getProcessedStyles", value: function getProcessedStyles(e, t, i) { var s = Array.from(t.classList).reduce(function (a, l) { var d; var c = (d = e[l]) == null ? void 0 : d.styles; return c && e[l].styles && a.push(c), a; }, []), r = hs[i].styles; if (r) { var a = JSON.parse(JSON.stringify(r)); a["default"] && R.overwriteDefaultWithAlreadyApplied(a, t), s.unshift(a); } var o = R.mergeStatefulStyles(s); return R.processStateful(o, {}, {}); } }, { key: "applyDeepChatUtilities", value: function applyDeepChatUtilities(e, t, i) { zs.forEach(function (r) { var o = i.getElementsByClassName(r); Array.from(o || []).forEach(function (a) { var l = Ne.getProcessedStyles(t, a, r); ne.applyStylesToElement(a, l), Ne.applyEvents(a, r); }); }); var s = i.getElementsByClassName(jn); Array.from(s).forEach(function (r) { return Ne.applySuggestionEvent(e, r); }); } }]); }(); var ne = /*#__PURE__*/function () { function ne() { _classCallCheck(this, ne); } return _createClass(ne, null, [{ key: "applyStylesToElement", value: function applyStylesToElement(e, t) { var i = R.processStateful(t, {}, {}); et.add(e, i), Object.assign(e.style, i["default"]); } }, { key: "applyEventsToElement", value: function applyEventsToElement(e, t) { Object.keys(t).forEach(function (i) { var s = t[i]; s && e.addEventListener(i, s); }); } }, { key: "applyClassUtilitiesToElement", value: function applyClassUtilitiesToElement(e, t) { var i = t.events, s = t.styles; i && ne.applyEventsToElement(e, i), s && !Ne.doesElementContainDeepChatClass(e) && ne.applyStylesToElement