{"version":3,"file":"utils.esm-C570BaG5.js","sources":["../../../node_modules/.pnpm/@chatwoot+utils@0.0.41/node_modules/@chatwoot/utils/dist/utils.esm.js"],"sourcesContent":["import isToday from 'date-fns/isToday';\nimport isYesterday from 'date-fns/isYesterday';\n\n// Returns a function, that, as long as it continues to be invoked, will not\n// be triggered. The function will be called after it stops being called for\n// N milliseconds. If `immediate` is passed, trigger the function on the\n// leading edge, instead of the trailing.\n\n/**\r\n * @func Callback function to be called after delay\r\n * @delay Delay for debounce in ms\r\n * @immediate should execute immediately\r\n * @returns debounced callback function\r\n */\nvar debounce = function debounce(func, wait, immediate) {\n var timeout;\n return function () {\n var context = null;\n var args = arguments;\n\n var later = function later() {\n timeout = null;\n if (!immediate) func.apply(context, args);\n };\n\n var callNow = immediate && !timeout;\n clearTimeout(timeout);\n timeout = window.setTimeout(later, wait);\n if (callNow) func.apply(context, args);\n };\n};\n\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n Promise.resolve(value).then(_next, _throw);\n }\n}\n\nfunction _asyncToGenerator(fn) {\n return function () {\n var self = this,\n args = arguments;\n return new Promise(function (resolve, reject) {\n var gen = fn.apply(self, args);\n\n function _next(value) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value);\n }\n\n function _throw(err) {\n asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err);\n }\n\n _next(undefined);\n });\n };\n}\n\nfunction _extends() {\n _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n };\n\n return _extends.apply(this, arguments);\n}\n\nfunction createCommonjsModule(fn, module) {\n\treturn module = { exports: {} }, fn(module, module.exports), module.exports;\n}\n\nvar runtime_1 = createCommonjsModule(function (module) {\n/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nvar runtime = (function (exports) {\n\n var Op = Object.prototype;\n var hasOwn = Op.hasOwnProperty;\n var undefined$1; // More compressible than void 0.\n var $Symbol = typeof Symbol === \"function\" ? Symbol : {};\n var iteratorSymbol = $Symbol.iterator || \"@@iterator\";\n var asyncIteratorSymbol = $Symbol.asyncIterator || \"@@asyncIterator\";\n var toStringTagSymbol = $Symbol.toStringTag || \"@@toStringTag\";\n\n function define(obj, key, value) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n return obj[key];\n }\n try {\n // IE 8 has a broken Object.defineProperty that only works on DOM objects.\n define({}, \"\");\n } catch (err) {\n define = function(obj, key, value) {\n return obj[key] = value;\n };\n }\n\n function wrap(innerFn, outerFn, self, tryLocsList) {\n // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.\n var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;\n var generator = Object.create(protoGenerator.prototype);\n var context = new Context(tryLocsList || []);\n\n // The ._invoke method unifies the implementations of the .next,\n // .throw, and .return methods.\n generator._invoke = makeInvokeMethod(innerFn, self, context);\n\n return generator;\n }\n exports.wrap = wrap;\n\n // Try/catch helper to minimize deoptimizations. Returns a completion\n // record like context.tryEntries[i].completion. This interface could\n // have been (and was previously) designed to take a closure to be\n // invoked without arguments, but in all the cases we care about we\n // already have an existing method we want to call, so there's no need\n // to create a new function object. We can even get away with assuming\n // the method takes exactly one argument, since that happens to be true\n // in every case, so we don't have to touch the arguments object. The\n // only additional allocation required is the completion record, which\n // has a stable shape and so hopefully should be cheap to allocate.\n function tryCatch(fn, obj, arg) {\n try {\n return { type: \"normal\", arg: fn.call(obj, arg) };\n } catch (err) {\n return { type: \"throw\", arg: err };\n }\n }\n\n var GenStateSuspendedStart = \"suspendedStart\";\n var GenStateSuspendedYield = \"suspendedYield\";\n var GenStateExecuting = \"executing\";\n var GenStateCompleted = \"completed\";\n\n // Returning this object from the innerFn has the same effect as\n // breaking out of the dispatch switch statement.\n var ContinueSentinel = {};\n\n // Dummy constructor functions that we use as the .constructor and\n // .constructor.prototype properties for functions that return Generator\n // objects. For full spec compliance, you may wish to configure your\n // minifier not to mangle the names of these two functions.\n function Generator() {}\n function GeneratorFunction() {}\n function GeneratorFunctionPrototype() {}\n\n // This is a polyfill for %IteratorPrototype% for environments that\n // don't natively support it.\n var IteratorPrototype = {};\n IteratorPrototype[iteratorSymbol] = function () {\n return this;\n };\n\n var getProto = Object.getPrototypeOf;\n var NativeIteratorPrototype = getProto && getProto(getProto(values([])));\n if (NativeIteratorPrototype &&\n NativeIteratorPrototype !== Op &&\n hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {\n // This environment has a native %IteratorPrototype%; use it instead\n // of the polyfill.\n IteratorPrototype = NativeIteratorPrototype;\n }\n\n var Gp = GeneratorFunctionPrototype.prototype =\n Generator.prototype = Object.create(IteratorPrototype);\n GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;\n GeneratorFunctionPrototype.constructor = GeneratorFunction;\n GeneratorFunction.displayName = define(\n GeneratorFunctionPrototype,\n toStringTagSymbol,\n \"GeneratorFunction\"\n );\n\n // Helper for defining the .next, .throw, and .return methods of the\n // Iterator interface in terms of a single ._invoke method.\n function defineIteratorMethods(prototype) {\n [\"next\", \"throw\", \"return\"].forEach(function(method) {\n define(prototype, method, function(arg) {\n return this._invoke(method, arg);\n });\n });\n }\n\n exports.isGeneratorFunction = function(genFun) {\n var ctor = typeof genFun === \"function\" && genFun.constructor;\n return ctor\n ? ctor === GeneratorFunction ||\n // For the native GeneratorFunction constructor, the best we can\n // do is to check its .name property.\n (ctor.displayName || ctor.name) === \"GeneratorFunction\"\n : false;\n };\n\n exports.mark = function(genFun) {\n if (Object.setPrototypeOf) {\n Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);\n } else {\n genFun.__proto__ = GeneratorFunctionPrototype;\n define(genFun, toStringTagSymbol, \"GeneratorFunction\");\n }\n genFun.prototype = Object.create(Gp);\n return genFun;\n };\n\n // Within the body of any async function, `await x` is transformed to\n // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test\n // `hasOwn.call(value, \"__await\")` to determine if the yielded value is\n // meant to be awaited.\n exports.awrap = function(arg) {\n return { __await: arg };\n };\n\n function AsyncIterator(generator, PromiseImpl) {\n function invoke(method, arg, resolve, reject) {\n var record = tryCatch(generator[method], generator, arg);\n if (record.type === \"throw\") {\n reject(record.arg);\n } else {\n var result = record.arg;\n var value = result.value;\n if (value &&\n typeof value === \"object\" &&\n hasOwn.call(value, \"__await\")) {\n return PromiseImpl.resolve(value.__await).then(function(value) {\n invoke(\"next\", value, resolve, reject);\n }, function(err) {\n invoke(\"throw\", err, resolve, reject);\n });\n }\n\n return PromiseImpl.resolve(value).then(function(unwrapped) {\n // When a yielded Promise is resolved, its final value becomes\n // the .value of the Promise<{value,done}> result for the\n // current iteration.\n result.value = unwrapped;\n resolve(result);\n }, function(error) {\n // If a rejected Promise was yielded, throw the rejection back\n // into the async generator function so it can be handled there.\n return invoke(\"throw\", error, resolve, reject);\n });\n }\n }\n\n var previousPromise;\n\n function enqueue(method, arg) {\n function callInvokeWithMethodAndArg() {\n return new PromiseImpl(function(resolve, reject) {\n invoke(method, arg, resolve, reject);\n });\n }\n\n return previousPromise =\n // If enqueue has been called before, then we want to wait until\n // all previous Promises have been resolved before calling invoke,\n // so that results are always delivered in the correct order. If\n // enqueue has not been called before, then it is important to\n // call invoke immediately, without waiting on a callback to fire,\n // so that the async generator function has the opportunity to do\n // any necessary setup in a predictable way. This predictability\n // is why the Promise constructor synchronously invokes its\n // executor callback, and why async functions synchronously\n // execute code before the first await. Since we implement simple\n // async functions in terms of async generators, it is especially\n // important to get this right, even though it requires care.\n previousPromise ? previousPromise.then(\n callInvokeWithMethodAndArg,\n // Avoid propagating failures to Promises returned by later\n // invocations of the iterator.\n callInvokeWithMethodAndArg\n ) : callInvokeWithMethodAndArg();\n }\n\n // Define the unified helper method that is used to implement .next,\n // .throw, and .return (see defineIteratorMethods).\n this._invoke = enqueue;\n }\n\n defineIteratorMethods(AsyncIterator.prototype);\n AsyncIterator.prototype[asyncIteratorSymbol] = function () {\n return this;\n };\n exports.AsyncIterator = AsyncIterator;\n\n // Note that simple async functions are implemented on top of\n // AsyncIterator objects; they just return a Promise for the value of\n // the final result produced by the iterator.\n exports.async = function(innerFn, outerFn, self, tryLocsList, PromiseImpl) {\n if (PromiseImpl === void 0) PromiseImpl = Promise;\n\n var iter = new AsyncIterator(\n wrap(innerFn, outerFn, self, tryLocsList),\n PromiseImpl\n );\n\n return exports.isGeneratorFunction(outerFn)\n ? iter // If outerFn is a generator, return the full iterator.\n : iter.next().then(function(result) {\n return result.done ? result.value : iter.next();\n });\n };\n\n function makeInvokeMethod(innerFn, self, context) {\n var state = GenStateSuspendedStart;\n\n return function invoke(method, arg) {\n if (state === GenStateExecuting) {\n throw new Error(\"Generator is already running\");\n }\n\n if (state === GenStateCompleted) {\n if (method === \"throw\") {\n throw arg;\n }\n\n // Be forgiving, per 25.3.3.3.3 of the spec:\n // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume\n return doneResult();\n }\n\n context.method = method;\n context.arg = arg;\n\n while (true) {\n var delegate = context.delegate;\n if (delegate) {\n var delegateResult = maybeInvokeDelegate(delegate, context);\n if (delegateResult) {\n if (delegateResult === ContinueSentinel) continue;\n return delegateResult;\n }\n }\n\n if (context.method === \"next\") {\n // Setting context._sent for legacy support of Babel's\n // function.sent implementation.\n context.sent = context._sent = context.arg;\n\n } else if (context.method === \"throw\") {\n if (state === GenStateSuspendedStart) {\n state = GenStateCompleted;\n throw context.arg;\n }\n\n context.dispatchException(context.arg);\n\n } else if (context.method === \"return\") {\n context.abrupt(\"return\", context.arg);\n }\n\n state = GenStateExecuting;\n\n var record = tryCatch(innerFn, self, context);\n if (record.type === \"normal\") {\n // If an exception is thrown from innerFn, we leave state ===\n // GenStateExecuting and loop back for another invocation.\n state = context.done\n ? GenStateCompleted\n : GenStateSuspendedYield;\n\n if (record.arg === ContinueSentinel) {\n continue;\n }\n\n return {\n value: record.arg,\n done: context.done\n };\n\n } else if (record.type === \"throw\") {\n state = GenStateCompleted;\n // Dispatch the exception by looping back around to the\n // context.dispatchException(context.arg) call above.\n context.method = \"throw\";\n context.arg = record.arg;\n }\n }\n };\n }\n\n // Call delegate.iterator[context.method](context.arg) and handle the\n // result, either by returning a { value, done } result from the\n // delegate iterator, or by modifying context.method and context.arg,\n // setting context.delegate to null, and returning the ContinueSentinel.\n function maybeInvokeDelegate(delegate, context) {\n var method = delegate.iterator[context.method];\n if (method === undefined$1) {\n // A .throw or .return when the delegate iterator has no .throw\n // method always terminates the yield* loop.\n context.delegate = null;\n\n if (context.method === \"throw\") {\n // Note: [\"return\"] must be used for ES3 parsing compatibility.\n if (delegate.iterator[\"return\"]) {\n // If the delegate iterator has a return method, give it a\n // chance to clean up.\n context.method = \"return\";\n context.arg = undefined$1;\n maybeInvokeDelegate(delegate, context);\n\n if (context.method === \"throw\") {\n // If maybeInvokeDelegate(context) changed context.method from\n // \"return\" to \"throw\", let that override the TypeError below.\n return ContinueSentinel;\n }\n }\n\n context.method = \"throw\";\n context.arg = new TypeError(\n \"The iterator does not provide a 'throw' method\");\n }\n\n return ContinueSentinel;\n }\n\n var record = tryCatch(method, delegate.iterator, context.arg);\n\n if (record.type === \"throw\") {\n context.method = \"throw\";\n context.arg = record.arg;\n context.delegate = null;\n return ContinueSentinel;\n }\n\n var info = record.arg;\n\n if (! info) {\n context.method = \"throw\";\n context.arg = new TypeError(\"iterator result is not an object\");\n context.delegate = null;\n return ContinueSentinel;\n }\n\n if (info.done) {\n // Assign the result of the finished delegate to the temporary\n // variable specified by delegate.resultName (see delegateYield).\n context[delegate.resultName] = info.value;\n\n // Resume execution at the desired location (see delegateYield).\n context.next = delegate.nextLoc;\n\n // If context.method was \"throw\" but the delegate handled the\n // exception, let the outer generator proceed normally. If\n // context.method was \"next\", forget context.arg since it has been\n // \"consumed\" by the delegate iterator. If context.method was\n // \"return\", allow the original .return call to continue in the\n // outer generator.\n if (context.method !== \"return\") {\n context.method = \"next\";\n context.arg = undefined$1;\n }\n\n } else {\n // Re-yield the result returned by the delegate method.\n return info;\n }\n\n // The delegate iterator is finished, so forget it and continue with\n // the outer generator.\n context.delegate = null;\n return ContinueSentinel;\n }\n\n // Define Generator.prototype.{next,throw,return} in terms of the\n // unified ._invoke helper method.\n defineIteratorMethods(Gp);\n\n define(Gp, toStringTagSymbol, \"Generator\");\n\n // A Generator should always return itself as the iterator object when the\n // @@iterator function is called on it. Some browsers' implementations of the\n // iterator prototype chain incorrectly implement this, causing the Generator\n // object to not be returned from this call. This ensures that doesn't happen.\n // See https://github.com/facebook/regenerator/issues/274 for more details.\n Gp[iteratorSymbol] = function() {\n return this;\n };\n\n Gp.toString = function() {\n return \"[object Generator]\";\n };\n\n function pushTryEntry(locs) {\n var entry = { tryLoc: locs[0] };\n\n if (1 in locs) {\n entry.catchLoc = locs[1];\n }\n\n if (2 in locs) {\n entry.finallyLoc = locs[2];\n entry.afterLoc = locs[3];\n }\n\n this.tryEntries.push(entry);\n }\n\n function resetTryEntry(entry) {\n var record = entry.completion || {};\n record.type = \"normal\";\n delete record.arg;\n entry.completion = record;\n }\n\n function Context(tryLocsList) {\n // The root entry object (effectively a try statement without a catch\n // or a finally block) gives us a place to store values thrown from\n // locations where there is no enclosing try statement.\n this.tryEntries = [{ tryLoc: \"root\" }];\n tryLocsList.forEach(pushTryEntry, this);\n this.reset(true);\n }\n\n exports.keys = function(object) {\n var keys = [];\n for (var key in object) {\n keys.push(key);\n }\n keys.reverse();\n\n // Rather than returning an object with a next method, we keep\n // things simple and return the next function itself.\n return function next() {\n while (keys.length) {\n var key = keys.pop();\n if (key in object) {\n next.value = key;\n next.done = false;\n return next;\n }\n }\n\n // To avoid creating an additional object, we just hang the .value\n // and .done properties off the next function object itself. This\n // also ensures that the minifier will not anonymize the function.\n next.done = true;\n return next;\n };\n };\n\n function values(iterable) {\n if (iterable) {\n var iteratorMethod = iterable[iteratorSymbol];\n if (iteratorMethod) {\n return iteratorMethod.call(iterable);\n }\n\n if (typeof iterable.next === \"function\") {\n return iterable;\n }\n\n if (!isNaN(iterable.length)) {\n var i = -1, next = function next() {\n while (++i < iterable.length) {\n if (hasOwn.call(iterable, i)) {\n next.value = iterable[i];\n next.done = false;\n return next;\n }\n }\n\n next.value = undefined$1;\n next.done = true;\n\n return next;\n };\n\n return next.next = next;\n }\n }\n\n // Return an iterator with no values.\n return { next: doneResult };\n }\n exports.values = values;\n\n function doneResult() {\n return { value: undefined$1, done: true };\n }\n\n Context.prototype = {\n constructor: Context,\n\n reset: function(skipTempReset) {\n this.prev = 0;\n this.next = 0;\n // Resetting context._sent for legacy support of Babel's\n // function.sent implementation.\n this.sent = this._sent = undefined$1;\n this.done = false;\n this.delegate = null;\n\n this.method = \"next\";\n this.arg = undefined$1;\n\n this.tryEntries.forEach(resetTryEntry);\n\n if (!skipTempReset) {\n for (var name in this) {\n // Not sure about the optimal order of these conditions:\n if (name.charAt(0) === \"t\" &&\n hasOwn.call(this, name) &&\n !isNaN(+name.slice(1))) {\n this[name] = undefined$1;\n }\n }\n }\n },\n\n stop: function() {\n this.done = true;\n\n var rootEntry = this.tryEntries[0];\n var rootRecord = rootEntry.completion;\n if (rootRecord.type === \"throw\") {\n throw rootRecord.arg;\n }\n\n return this.rval;\n },\n\n dispatchException: function(exception) {\n if (this.done) {\n throw exception;\n }\n\n var context = this;\n function handle(loc, caught) {\n record.type = \"throw\";\n record.arg = exception;\n context.next = loc;\n\n if (caught) {\n // If the dispatched exception was caught by a catch block,\n // then let that catch block handle the exception normally.\n context.method = \"next\";\n context.arg = undefined$1;\n }\n\n return !! caught;\n }\n\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n var record = entry.completion;\n\n if (entry.tryLoc === \"root\") {\n // Exception thrown outside of any try block that could handle\n // it, so set the completion value of the entire function to\n // throw the exception.\n return handle(\"end\");\n }\n\n if (entry.tryLoc <= this.prev) {\n var hasCatch = hasOwn.call(entry, \"catchLoc\");\n var hasFinally = hasOwn.call(entry, \"finallyLoc\");\n\n if (hasCatch && hasFinally) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n } else if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else if (hasCatch) {\n if (this.prev < entry.catchLoc) {\n return handle(entry.catchLoc, true);\n }\n\n } else if (hasFinally) {\n if (this.prev < entry.finallyLoc) {\n return handle(entry.finallyLoc);\n }\n\n } else {\n throw new Error(\"try statement without catch or finally\");\n }\n }\n }\n },\n\n abrupt: function(type, arg) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc <= this.prev &&\n hasOwn.call(entry, \"finallyLoc\") &&\n this.prev < entry.finallyLoc) {\n var finallyEntry = entry;\n break;\n }\n }\n\n if (finallyEntry &&\n (type === \"break\" ||\n type === \"continue\") &&\n finallyEntry.tryLoc <= arg &&\n arg <= finallyEntry.finallyLoc) {\n // Ignore the finally entry if control is not jumping to a\n // location outside the try/catch block.\n finallyEntry = null;\n }\n\n var record = finallyEntry ? finallyEntry.completion : {};\n record.type = type;\n record.arg = arg;\n\n if (finallyEntry) {\n this.method = \"next\";\n this.next = finallyEntry.finallyLoc;\n return ContinueSentinel;\n }\n\n return this.complete(record);\n },\n\n complete: function(record, afterLoc) {\n if (record.type === \"throw\") {\n throw record.arg;\n }\n\n if (record.type === \"break\" ||\n record.type === \"continue\") {\n this.next = record.arg;\n } else if (record.type === \"return\") {\n this.rval = this.arg = record.arg;\n this.method = \"return\";\n this.next = \"end\";\n } else if (record.type === \"normal\" && afterLoc) {\n this.next = afterLoc;\n }\n\n return ContinueSentinel;\n },\n\n finish: function(finallyLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.finallyLoc === finallyLoc) {\n this.complete(entry.completion, entry.afterLoc);\n resetTryEntry(entry);\n return ContinueSentinel;\n }\n }\n },\n\n \"catch\": function(tryLoc) {\n for (var i = this.tryEntries.length - 1; i >= 0; --i) {\n var entry = this.tryEntries[i];\n if (entry.tryLoc === tryLoc) {\n var record = entry.completion;\n if (record.type === \"throw\") {\n var thrown = record.arg;\n resetTryEntry(entry);\n }\n return thrown;\n }\n }\n\n // The context.catch method must only be called with a location\n // argument that corresponds to a known catch block.\n throw new Error(\"illegal catch attempt\");\n },\n\n delegateYield: function(iterable, resultName, nextLoc) {\n this.delegate = {\n iterator: values(iterable),\n resultName: resultName,\n nextLoc: nextLoc\n };\n\n if (this.method === \"next\") {\n // Deliberately forget the last sent value so that we don't\n // accidentally pass it on to the delegate.\n this.arg = undefined$1;\n }\n\n return ContinueSentinel;\n }\n };\n\n // Regardless of whether this script is executing as a CommonJS module\n // or not, return the runtime object so that we can declare the variable\n // regeneratorRuntime in the outer scope, which allows this module to be\n // injected easily by `bin/regenerator --include-runtime script.js`.\n return exports;\n\n}(\n // If this script is executing as a CommonJS module, use module.exports\n // as the regeneratorRuntime namespace. Otherwise create a new empty\n // object. Either way, the resulting object will be used to initialize\n // the regeneratorRuntime variable at the top of this file.\n module.exports \n));\n\ntry {\n regeneratorRuntime = runtime;\n} catch (accidentalStrictMode) {\n // This module should not be running in strict mode, so the above\n // assignment should always work unless something is misconfigured. Just\n // in case runtime.js accidentally runs in strict mode, we can escape\n // strict mode using a global Function call. This could conceivably fail\n // if a Content Security Policy forbids using Function, but in that case\n // the proper solution is to fix the accidental strict mode problem. If\n // you've misconfigured your bundler to force strict mode and applied a\n // CSP to forbid Function, and you're not willing to fix either of those\n // problems, please detail your unique predicament in a GitHub issue.\n Function(\"r\", \"regeneratorRuntime = r\")(runtime);\n}\n});\n\n/**\r\n * @name Get contrasting text color\r\n * @description Get contrasting text color from a text color\r\n * @param bgColor Background color of text.\r\n * @returns contrasting text color\r\n */\n\nvar getContrastingTextColor = function getContrastingTextColor(bgColor) {\n var color = bgColor.replace('#', '');\n var r = parseInt(color.slice(0, 2), 16);\n var g = parseInt(color.slice(2, 4), 16);\n var b = parseInt(color.slice(4, 6), 16); // http://stackoverflow.com/a/3943023/112731\n\n return r * 0.299 + g * 0.587 + b * 0.114 > 186 ? '#000000' : '#FFFFFF';\n};\n/**\r\n * @name Get formatted date\r\n * @description Get date in today, yesterday or any other date format\r\n * @param date date\r\n * @param todayText Today text\r\n * @param yesterdayText Yesterday text\r\n * @returns formatted date\r\n */\n\nvar formatDate = function formatDate(_ref) {\n var date = _ref.date,\n todayText = _ref.todayText,\n yesterdayText = _ref.yesterdayText;\n var dateValue = new Date(date);\n if (isToday(dateValue)) return todayText;\n if (isYesterday(dateValue)) return yesterdayText;\n return date;\n};\n/**\r\n * @name formatTime\r\n * @description Format time to Hour, Minute and Second\r\n * @param timeInSeconds number\r\n * @returns formatted time\r\n */\n\nvar formatTime = function formatTime(timeInSeconds) {\n var formattedTime = '';\n\n if (timeInSeconds >= 60 && timeInSeconds < 3600) {\n var minutes = Math.floor(timeInSeconds / 60);\n formattedTime = minutes + \" Min\";\n var seconds = minutes === 60 ? 0 : Math.floor(timeInSeconds % 60);\n return formattedTime + (\"\" + (seconds > 0 ? ' ' + seconds + ' Sec' : ''));\n }\n\n if (timeInSeconds >= 3600 && timeInSeconds < 86400) {\n var hours = Math.floor(timeInSeconds / 3600);\n formattedTime = hours + \" Hr\";\n\n var _minutes = timeInSeconds % 3600 < 60 || hours === 24 ? 0 : Math.floor(timeInSeconds % 3600 / 60);\n\n return formattedTime + (\"\" + (_minutes > 0 ? ' ' + _minutes + ' Min' : ''));\n }\n\n if (timeInSeconds >= 86400) {\n var days = Math.floor(timeInSeconds / 86400);\n formattedTime = days + \" Day\";\n\n var _hours = timeInSeconds % 86400 < 3600 || days >= 364 ? 0 : Math.floor(timeInSeconds % 86400 / 3600);\n\n return formattedTime + (\"\" + (_hours > 0 ? ' ' + _hours + ' Hr' : ''));\n }\n\n return Math.floor(timeInSeconds) + \" Sec\";\n};\n/**\r\n * @name trimContent\r\n * @description Trim a string to max length\r\n * @param content String to trim\r\n * @param maxLength Length of the string to trim, default 1024\r\n * @param ellipsis Boolean to add dots at the end of the string, default false\r\n * @returns trimmed string\r\n */\n\nvar trimContent = function trimContent(content, maxLength, ellipsis) {\n if (content === void 0) {\n content = '';\n }\n\n if (maxLength === void 0) {\n maxLength = 1024;\n }\n\n if (ellipsis === void 0) {\n ellipsis = false;\n }\n\n var trimmedContent = content;\n\n if (content.length > maxLength) {\n trimmedContent = content.substring(0, maxLength);\n }\n\n if (ellipsis) {\n trimmedContent = trimmedContent + '...';\n }\n\n return trimmedContent;\n};\n/**\r\n * @name convertSecondsToTimeUnit\r\n * @description Convert seconds to time unit\r\n * @param seconds number\r\n * @param unitNames object\r\n * @returns time and unit\r\n * @example\r\n * convertToUnit(60, { minute: 'm', hour: 'h', day: 'd' }); // { time: 1, unit: 'm' }\r\n * convertToUnit(60, { minute: 'Minutes', hour: 'Hours', day: 'Days' }); // { time: 1, unit: 'Minutes' }\r\n */\n\nvar convertSecondsToTimeUnit = function convertSecondsToTimeUnit(seconds, unitNames) {\n if (seconds === null || seconds === 0) return {\n time: '',\n unit: ''\n };\n if (seconds < 3600) return {\n time: Number((seconds / 60).toFixed(1)),\n unit: unitNames.minute\n };\n if (seconds < 86400) return {\n time: Number((seconds / 3600).toFixed(1)),\n unit: unitNames.hour\n };\n return {\n time: Number((seconds / 86400).toFixed(1)),\n unit: unitNames.day\n };\n};\n/**\r\n * @name fileNameWithEllipsis\r\n * @description Truncates a filename while preserving the extension\r\n * @param {Object} file - File object containing filename or name property\r\n * @param {number} [maxLength=26] - Maximum length of the filename (excluding extension)\r\n * @param {string} [ellipsis='…'] - Character to use for truncation\r\n * @returns {string} Truncated filename with extension\r\n * @example\r\n * fileNameWithEllipsis({ filename: 'very-long-filename.pdf' }, 10) // 'very-long-f….pdf'\r\n * fileNameWithEllipsis({ name: 'short.txt' }, 10) // 'short.txt'\r\n */\n\nvar fileNameWithEllipsis = function fileNameWithEllipsis(file, maxLength, ellipsis) {\n var _ref2, _file$filename;\n\n if (maxLength === void 0) {\n maxLength = 26;\n }\n\n if (ellipsis === void 0) {\n ellipsis = '…';\n }\n\n var fullName = (_ref2 = (_file$filename = file == null ? void 0 : file.filename) != null ? _file$filename : file == null ? void 0 : file.name) != null ? _ref2 : 'Untitled';\n var dotIndex = fullName.lastIndexOf('.');\n if (dotIndex === -1) return fullName;\n var _ref3 = [fullName.slice(0, dotIndex), fullName.slice(dotIndex)],\n name = _ref3[0],\n extension = _ref3[1];\n if (name.length <= maxLength) return fullName;\n return \"\" + name.slice(0, maxLength) + ellipsis + extension;\n};\n/**\r\n * @name splitName\r\n * @description Splits a full name into firstName and lastName\r\n * @param {string} name - Full name of the user\r\n * @returns {Object} Object with firstName and lastName\r\n * @example\r\n * splitName('Mary Jane Smith') // { firstName: 'Mary Jane', lastName: 'Smith' }\r\n * splitName('Alice') // { firstName: 'Alice', lastName: '' }\r\n * splitName('John Doe') // { firstName: 'John', lastName: 'Doe' }\r\n * splitName('') // { firstName: '', lastName: '' }\r\n */\n\nvar splitName = function splitName(fullName) {\n var trimmedName = fullName.trim();\n\n if (!trimmedName) {\n return {\n firstName: '',\n lastName: ''\n };\n } // Split the name by spaces\n\n\n var nameParts = trimmedName.split(/\\s+/); // If only one word, treat it as firstName\n\n if (nameParts.length === 1) {\n return {\n firstName: nameParts[0],\n lastName: ''\n };\n } // Last element is lastName, everything else is firstName\n\n\n var lastName = nameParts.pop() || '';\n var firstName = nameParts.join(' ');\n return {\n firstName: firstName,\n lastName: lastName\n };\n};\n/**\r\n * Downloads a file from a URL with proper file type handling\r\n * @name downloadFile\r\n * @description Downloads file from URL with proper type handling and cleanup\r\n * @param {Object} options Download configuration options\r\n * @param {string} options.url File URL to download\r\n * @param {string} options.type File type identifier\r\n * @param {string} [options.extension] Optional file extension\r\n * @returns {Promise} Returns true if download successful, false otherwise\r\n */\n\nvar downloadFile = /*#__PURE__*/function () {\n var _ref5 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref4) {\n var url, type, _ref4$extension, extension, _filenameMatch$, response, blobData, contentType, fileExtension, dispositionHeader, filenameMatch, filename, blobUrl, link;\n\n return runtime_1.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n url = _ref4.url, type = _ref4.type, _ref4$extension = _ref4.extension, extension = _ref4$extension === void 0 ? null : _ref4$extension;\n\n if (!(!url || !type)) {\n _context.next = 3;\n break;\n }\n\n throw new Error('Invalid download parameters');\n\n case 3:\n _context.prev = 3;\n _context.next = 6;\n return fetch(url, {\n cache: 'no-store'\n });\n\n case 6:\n response = _context.sent;\n\n if (response.ok) {\n _context.next = 9;\n break;\n }\n\n throw new Error(\"Download failed: \" + response.status);\n\n case 9:\n _context.next = 11;\n return response.blob();\n\n case 11:\n blobData = _context.sent;\n contentType = response.headers.get('content-type');\n fileExtension = extension || (contentType ? contentType.split('/')[1] : type);\n dispositionHeader = response.headers.get('content-disposition');\n filenameMatch = dispositionHeader == null ? void 0 : dispositionHeader.match(/filename=\"(.*?)\"/);\n filename = (_filenameMatch$ = filenameMatch == null ? void 0 : filenameMatch[1]) != null ? _filenameMatch$ : \"attachment_\" + Date.now() + \".\" + fileExtension;\n blobUrl = URL.createObjectURL(blobData);\n link = Object.assign(document.createElement('a'), {\n href: blobUrl,\n download: filename,\n style: 'display: none'\n });\n document.body.append(link);\n link.click();\n link.remove();\n URL.revokeObjectURL(blobUrl);\n _context.next = 28;\n break;\n\n case 25:\n _context.prev = 25;\n _context.t0 = _context[\"catch\"](3);\n throw _context.t0 instanceof Error ? _context.t0 : new Error('Download failed');\n\n case 28:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee, null, [[3, 25]]);\n }));\n\n return function downloadFile(_x) {\n return _ref5.apply(this, arguments);\n };\n}();\n/**\r\n * Extracts file information from a URL or file path.\r\n *\r\n * @param {string} url - The URL or file path to process\r\n * @returns {FileInfo} Object containing file information\r\n *\r\n * @example\r\n * getFileInfo('https://example.com/path/Document%20Name.PDF')\r\n * returns {\r\n * name: 'Document Name.PDF',\r\n * type: 'pdf',\r\n * base: 'Document Name'\r\n * }\r\n *\r\n * getFileInfo('invalid/url')\r\n * returns {\r\n * name: 'Unknown File',\r\n * type: '',\r\n * base: 'Unknown File'\r\n * }\r\n */\n\nvar getFileInfo = function getFileInfo(url) {\n var defaultInfo = {\n name: 'Unknown File',\n type: '',\n base: 'Unknown File'\n };\n\n if (!url || typeof url !== 'string') {\n return defaultInfo;\n }\n\n try {\n // Handle both URL and file path cases\n var cleanUrl = url.split(/[?#]/)[0] // Remove query params and hash\n .replace(/\\\\/g, '/'); // Normalize path separators\n\n var encodedFilename = cleanUrl.split('/').pop();\n\n if (!encodedFilename) {\n return defaultInfo;\n }\n\n var fileName = decodeURIComponent(encodedFilename); // Handle hidden files (starting with dot)\n\n if (fileName.startsWith('.') && !fileName.includes('.', 1)) {\n return {\n name: fileName,\n type: '',\n base: fileName\n };\n } // last index is where the file extension starts\n // This will handle cases where the file name has multiple dots\n\n\n var lastDotIndex = fileName.lastIndexOf('.');\n\n if (lastDotIndex === -1 || lastDotIndex === 0) {\n return {\n name: fileName,\n type: '',\n base: fileName\n };\n }\n\n var base = fileName.slice(0, lastDotIndex);\n var type = fileName.slice(lastDotIndex + 1).toLowerCase();\n return {\n name: fileName,\n type: type,\n base: base\n };\n } catch (error) {\n console.error('Error processing file info:', error);\n return defaultInfo;\n }\n};\n\nvar MessageType;\n\n(function (MessageType) {\n MessageType[MessageType[\"INCOMING\"] = 0] = \"INCOMING\";\n MessageType[MessageType[\"OUTGOING\"] = 1] = \"OUTGOING\";\n MessageType[MessageType[\"ACTIVITY\"] = 2] = \"ACTIVITY\";\n MessageType[MessageType[\"TEMPLATE\"] = 3] = \"TEMPLATE\";\n})(MessageType || (MessageType = {}));\n\nfunction getRecipients(lastEmail, conversationContact, inboxEmail, forwardToEmail) {\n var _emailAttributes$from;\n\n var to = [];\n var cc = [];\n var bcc = []; // Reset emails if there's no lastEmail\n\n if (!lastEmail) {\n return {\n to: to,\n cc: cc,\n bcc: bcc\n };\n } // Extract values from lastEmail and current conversation context\n\n\n var messageType = lastEmail.message_type;\n var isIncoming = messageType === MessageType.INCOMING;\n var emailAttributes = {};\n\n if (isIncoming) {\n var contentAttributes = lastEmail.content_attributes;\n var email = contentAttributes.email;\n emailAttributes = {\n cc: (email == null ? void 0 : email.cc) || [],\n bcc: (email == null ? void 0 : email.bcc) || [],\n from: (email == null ? void 0 : email.from) || [],\n to: []\n };\n } else {\n var _contentAttributes = lastEmail.content_attributes;\n\n var _ref = _contentAttributes != null ? _contentAttributes : {},\n _ref$cc_emails = _ref.cc_emails,\n ccEmails = _ref$cc_emails === void 0 ? [] : _ref$cc_emails,\n _ref$bcc_emails = _ref.bcc_emails,\n bccEmails = _ref$bcc_emails === void 0 ? [] : _ref$bcc_emails,\n _ref$to_emails = _ref.to_emails,\n toEmails = _ref$to_emails === void 0 ? [] : _ref$to_emails;\n\n emailAttributes = {\n cc: ccEmails,\n bcc: bccEmails,\n to: toEmails,\n from: []\n };\n }\n\n var isLastEmailFromContact = false; // this will be false anyway if the last email was outgoing\n\n isLastEmailFromContact = isIncoming && ((_emailAttributes$from = emailAttributes.from) != null ? _emailAttributes$from : []).includes(conversationContact);\n\n if (isIncoming) {\n var _to, _emailAttributes$from2;\n\n // Reply to sender if incoming\n (_to = to).push.apply(_to, (_emailAttributes$from2 = emailAttributes.from) != null ? _emailAttributes$from2 : []);\n } else {\n var _to2, _emailAttributes$to;\n\n // Otherwise, reply to the last recipient (for outgoing message)\n // If there is no to_emails, reply to the conversation contact\n (_to2 = to).push.apply(_to2, (_emailAttributes$to = emailAttributes.to) != null ? _emailAttributes$to : [conversationContact]);\n } // Start building the cc list, including additional recipients\n // If the email had multiple recipients, include them in the cc list\n\n\n cc = emailAttributes.cc ? [].concat(emailAttributes.cc) : [];\n\n if (Array.isArray(emailAttributes.to)) {\n var _cc;\n\n (_cc = cc).push.apply(_cc, emailAttributes.to);\n } // Add the conversation contact to cc if the last email wasn't sent by them\n // Ensure the message is an incoming one\n\n\n if (!isLastEmailFromContact && isIncoming) {\n cc.push(conversationContact);\n } // Process BCC: Remove conversation contact from bcc as it is already in cc\n\n\n bcc = (emailAttributes.bcc || []).filter(function (emailAddress) {\n return emailAddress !== conversationContact;\n }); // Filter out undesired emails from cc:\n // - Remove conversation contact from cc if they sent the last email\n // - Remove inbox and forward-to email to prevent loops\n // - Remove emails matching the reply UUID pattern\n\n var replyUUIDPattern = /^reply\\+([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/i;\n cc = cc.filter(function (email) {\n if (email === conversationContact && isLastEmailFromContact) {\n return false;\n }\n\n if (email === inboxEmail || email === forwardToEmail) {\n return false;\n }\n\n if (replyUUIDPattern.test(email)) {\n return false;\n }\n\n return true;\n });\n bcc = bcc.filter(function (email) {\n if (email === inboxEmail || email === forwardToEmail || replyUUIDPattern.test(email)) {\n return false;\n }\n\n return true;\n }); // Deduplicate each recipient list by converting to a Set then back to an array\n\n to = Array.from(new Set(to));\n cc = Array.from(new Set(cc));\n bcc = Array.from(new Set(bcc));\n return {\n to: to,\n cc: cc,\n bcc: bcc\n };\n}\n\n/**\r\n * Function that parses a string boolean value and returns the corresponding boolean value\r\n * @param {string | number} candidate - The string boolean value to be parsed\r\n * @return {boolean} - The parsed boolean value\r\n */\nfunction parseBoolean(candidate) {\n try {\n // lowercase the string, so TRUE becomes true\n var candidateString = String(candidate).toLowerCase(); // wrap in boolean to ensure that the return value\n // is a boolean even if values like 0 or 1 are passed\n\n return Boolean(JSON.parse(candidateString));\n } catch (error) {\n return false;\n }\n}\n\n/**\r\n * Sorts an array of numbers in ascending order.\r\n * @param {number[]} arr - The array of numbers to be sorted.\r\n * @returns {number[]} - The sorted array.\r\n */\nfunction sortAsc(arr) {\n // .slice() is used to create a copy of the array so that the original array is not mutated\n return arr.slice().sort(function (a, b) {\n return a - b;\n });\n}\n/**\r\n * Calculates the quantile value of an array at a specified percentile.\r\n * @param {number[]} arr - The array of numbers to calculate the quantile value from.\r\n * @param {number} q - The percentile to calculate the quantile value for.\r\n * @returns {number} - The quantile value.\r\n */\n\nfunction quantile(arr, q) {\n var sorted = sortAsc(arr); // Sort the array in ascending order\n\n return _quantileForSorted(sorted, q); // Calculate the quantile value\n}\n/**\r\n * Clamps a value between a minimum and maximum range.\r\n * @param {number} min - The minimum range.\r\n * @param {number} max - The maximum range.\r\n * @param {number} value - The value to be clamped.\r\n * @returns {number} - The clamped value.\r\n */\n\nfunction clamp(min, max, value) {\n if (value < min) {\n return min;\n }\n\n if (value > max) {\n return max;\n }\n\n return value;\n}\n/**\r\n * This method assumes the the array provided is already sorted in ascending order.\r\n * It's a helper method for the quantile method and should not be exported as is.\r\n *\r\n * @param {number[]} arr - The array of numbers to calculate the quantile value from.\r\n * @param {number} q - The percentile to calculate the quantile value for.\r\n * @returns {number} - The quantile value.\r\n */\n\nfunction _quantileForSorted(sorted, q) {\n var clamped = clamp(0, 1, q); // Clamp the percentile between 0 and 1\n\n var pos = (sorted.length - 1) * clamped; // Calculate the index of the element at the specified percentile\n\n var base = Math.floor(pos); // Find the index of the closest element to the specified percentile\n\n var rest = pos - base; // Calculate the decimal value between the closest elements\n // Interpolate the quantile value between the closest elements\n // Most libraries don't to the interpolation, but I'm just having fun here\n // also see https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample\n\n if (sorted[base + 1] !== undefined) {\n // in case the position was a integer, the rest will be 0 and the interpolation will be skipped\n return sorted[base] + rest * (sorted[base + 1] - sorted[base]);\n } // Return the closest element if there is no interpolation possible\n\n\n return sorted[base];\n}\n/**\r\n * Calculates the quantile values for an array of intervals.\r\n * @param {number[]} data - The array of numbers to calculate the quantile values from.\r\n * @param {number[]} intervals - The array of intervals to calculate the quantile values for.\r\n * @returns {number[]} - The array of quantile values for the intervals.\r\n */\n\n\nvar getQuantileIntervals = function getQuantileIntervals(data, intervals) {\n // Sort the array in ascending order before looping through the intervals.\n // depending on the size of the array and the number of intervals, this can speed up the process by at least twice\n // for a random array of 100 numbers and 5 intervals, the speedup is 3x\n var sorted = sortAsc(data);\n return intervals.map(function (interval) {\n return _quantileForSorted(sorted, interval);\n });\n};\n/**\r\n * Calculates the relative position of a point from the center of an element\r\n *\r\n * @param {number} mouseX - The x-coordinate of the mouse pointer\r\n * @param {number} mouseY - The y-coordinate of the mouse pointer\r\n * @param {DOMRect} rect - The bounding client rectangle of the target element\r\n * @returns {{relativeX: number, relativeY: number}} Object containing x and y distances from center\r\n */\n\nvar calculateCenterOffset = function calculateCenterOffset(mouseX, mouseY, rect) {\n var centerX = rect.left + rect.width / 2;\n var centerY = rect.top + rect.height / 2;\n return {\n relativeX: mouseX - centerX,\n relativeY: mouseY - centerY\n };\n};\n/**\r\n * Applies a rotation matrix to coordinates\r\n * Used to adjust mouse coordinates based on the current rotation of the image\r\n * This function implements a standard 2D rotation matrix transformation:\r\n * [x'] [cos(θ) -sin(θ)] [x]\r\n * [y'] = [sin(θ) cos(θ)] [y]\r\n *\r\n * @see {@link https://mathworld.wolfram.com/RotationMatrix.html} for mathematical derivation\r\n *\r\n * @param {number} relativeX - X-coordinate relative to center before rotation\r\n * @param {number} relativeY - Y-coordinate relative to center before rotation\r\n * @param {number} angle - Rotation angle in degrees\r\n * @returns {{rotatedX: number, rotatedY: number}} Coordinates after applying rotation matrix\r\n */\n\nvar applyRotationTransform = function applyRotationTransform(relativeX, relativeY, angle) {\n var radians = angle * Math.PI / 180;\n var cos = Math.cos(-radians);\n var sin = Math.sin(-radians);\n return {\n rotatedX: relativeX * cos - relativeY * sin,\n rotatedY: relativeX * sin + relativeY * cos\n };\n};\n/**\r\n * Converts absolute rotated coordinates to percentage values relative to image dimensions\r\n * Ensures values are clamped between 0-100% for valid CSS transform-origin properties\r\n *\r\n * @param {number} rotatedX - X-coordinate after rotation transformation\r\n * @param {number} rotatedY - Y-coordinate after rotation transformation\r\n * @param {number} width - Width of the target element\r\n * @param {number} height - Height of the target element\r\n * @returns {{x: number, y: number}} Normalized coordinates as percentages (0-100%)\r\n */\n\nvar normalizeToPercentage = function normalizeToPercentage(rotatedX, rotatedY, width, height) {\n // Convert to percentages (0-100%) relative to image dimensions\n // 50% represents the center point\n // The division by (width/2) maps the range [-width/2, width/2] to [-50%, 50%]\n // Adding 50% shifts this to [0%, 100%]\n return {\n x: Math.max(0, Math.min(100, 50 + rotatedX / (width / 2) * 50)),\n y: Math.max(0, Math.min(100, 50 + rotatedY / (height / 2) * 50))\n };\n};\n\nvar MESSAGE_VARIABLES_REGEX = /{{(.*?)}}/g;\n\nvar skipCodeBlocks = function skipCodeBlocks(str) {\n return str.replace(/```(?:.|\\n)+?```/g, '');\n};\n\nvar capitalizeName = function capitalizeName(name) {\n if (!name) return ''; // Return empty string for null or undefined input\n\n return name.split(' ') // Split the name into words based on spaces\n .map(function (word) {\n if (!word) return ''; // Handle empty strings that might result from multiple spaces\n // Capitalize only the first character, leaving the rest unchanged\n // This correctly handles accented characters like 'í' in 'Aríel'\n\n return word.charAt(0).toUpperCase() + word.slice(1);\n }).join(' '); // Rejoin the words with spaces\n};\nvar getFirstName = function getFirstName(_ref) {\n var user = _ref.user;\n var firstName = user != null && user.name ? user.name.split(' ').shift() : '';\n return capitalizeName(firstName);\n};\nvar getLastName = function getLastName(_ref2) {\n var user = _ref2.user;\n\n if (user && user.name) {\n var lastName = user.name.split(' ').length > 1 ? user.name.split(' ').pop() : '';\n return capitalizeName(lastName);\n }\n\n return '';\n};\nvar getMessageVariables = function getMessageVariables(_ref3) {\n var _assignee$email;\n\n var conversation = _ref3.conversation,\n contact = _ref3.contact;\n var _conversation$meta = conversation.meta,\n assignee = _conversation$meta.assignee,\n sender = _conversation$meta.sender,\n id = conversation.id,\n _conversation$custom_ = conversation.custom_attributes,\n conversationCustomAttributes = _conversation$custom_ === void 0 ? {} : _conversation$custom_;\n\n var _ref4 = contact || {},\n contactCustomAttributes = _ref4.custom_attributes;\n\n var standardVariables = {\n 'contact.name': capitalizeName((sender == null ? void 0 : sender.name) || ''),\n 'contact.first_name': getFirstName({\n user: sender\n }),\n 'contact.last_name': getLastName({\n user: sender\n }),\n 'contact.email': sender == null ? void 0 : sender.email,\n 'contact.phone': sender == null ? void 0 : sender.phone_number,\n 'contact.id': sender == null ? void 0 : sender.id,\n 'conversation.id': id,\n 'agent.name': capitalizeName((assignee == null ? void 0 : assignee.name) || ''),\n 'agent.first_name': getFirstName({\n user: assignee\n }),\n 'agent.last_name': getLastName({\n user: assignee\n }),\n 'agent.email': (_assignee$email = assignee == null ? void 0 : assignee.email) != null ? _assignee$email : ''\n };\n var conversationCustomAttributeVariables = Object.entries(conversationCustomAttributes != null ? conversationCustomAttributes : {}).reduce(function (acc, _ref5) {\n var key = _ref5[0],\n value = _ref5[1];\n acc[\"conversation.custom_attribute.\" + key] = value;\n return acc;\n }, {});\n var contactCustomAttributeVariables = Object.entries(contactCustomAttributes != null ? contactCustomAttributes : {}).reduce(function (acc, _ref6) {\n var key = _ref6[0],\n value = _ref6[1];\n acc[\"contact.custom_attribute.\" + key] = value;\n return acc;\n }, {});\n\n var variables = _extends({}, standardVariables, conversationCustomAttributeVariables, contactCustomAttributeVariables);\n\n return variables;\n};\nvar replaceVariablesInMessage = function replaceVariablesInMessage(_ref7) {\n var message = _ref7.message,\n variables = _ref7.variables;\n // @ts-ignore\n return message == null ? void 0 : message.replace(MESSAGE_VARIABLES_REGEX, function (_, replace) {\n return variables[replace.trim()] ? variables[replace.trim().toLowerCase()] : '';\n });\n};\nvar getUndefinedVariablesInMessage = function getUndefinedVariablesInMessage(_ref8) {\n var message = _ref8.message,\n variables = _ref8.variables;\n var messageWithOutCodeBlocks = skipCodeBlocks(message);\n var matches = messageWithOutCodeBlocks.match(MESSAGE_VARIABLES_REGEX);\n if (!matches) return [];\n return matches.map(function (match) {\n return match.replace('{{', '').replace('}}', '').trim();\n }).filter(function (variable) {\n return variables[variable] === undefined;\n });\n};\n\n/**\r\n * Creates a typing indicator utility.\r\n * @param onStartTyping Callback function to be called when typing starts\r\n * @param onStopTyping Callback function to be called when typing stops after delay\r\n * @param idleTime Delay for idle time in ms before considering typing stopped\r\n * @returns An object with start and stop methods for typing indicator\r\n */\nvar createTypingIndicator = function createTypingIndicator(onStartTyping, onStopTyping, idleTime) {\n var timer = null;\n\n var start = function start() {\n if (!timer) {\n onStartTyping();\n }\n\n reset();\n };\n\n var stop = function stop() {\n if (timer) {\n clearTimeout(timer);\n timer = null;\n onStopTyping();\n }\n };\n\n var reset = function reset() {\n if (timer) {\n clearTimeout(timer);\n }\n\n timer = setTimeout(function () {\n stop();\n }, idleTime);\n };\n\n return {\n start: start,\n stop: stop\n };\n};\n\n/**\r\n * Calculates the threshold for an SLA based on the current time and the provided threshold.\r\n * @param timeOffset - The time offset in seconds.\r\n * @param threshold - The threshold in seconds or null if not applicable.\r\n * @returns The calculated threshold in seconds or null if the threshold is null.\r\n */\nvar calculateThreshold = function calculateThreshold(timeOffset, threshold) {\n // Calculate the time left for the SLA to breach or the time since the SLA has missed\n if (threshold === null) return null;\n var currentTime = Math.floor(Date.now() / 1000);\n return timeOffset + threshold - currentTime;\n};\n/**\r\n * Finds the most urgent SLA status based on the threshold.\r\n * @param SLAStatuses - An array of SLAStatus objects.\r\n * @returns The most urgent SLAStatus object.\r\n */\n\n\nvar findMostUrgentSLAStatus = function findMostUrgentSLAStatus(SLAStatuses) {\n // Sort the SLAs based on the threshold and return the most urgent SLA\n SLAStatuses.sort(function (sla1, sla2) {\n return Math.abs(sla1.threshold) - Math.abs(sla2.threshold);\n });\n return SLAStatuses[0];\n};\n/**\r\n * Formats the SLA time in a human-readable format.\r\n * @param seconds - The time in seconds.\r\n * @returns A formatted string representing the time.\r\n */\n\n\nvar formatSLATime = function formatSLATime(seconds) {\n var units = {\n y: 31536000,\n mo: 2592000,\n d: 86400,\n h: 3600,\n m: 60\n };\n\n if (seconds < 60) {\n return '1m';\n } // we will only show two parts, two max granularity's, h-m, y-d, d-h, m, but no seconds\n\n\n var parts = [];\n Object.keys(units).forEach(function (unit) {\n var value = Math.floor(seconds / units[unit]);\n if (seconds < 60 && parts.length > 0) return;\n if (parts.length === 2) return;\n\n if (value > 0) {\n parts.push(value + unit);\n seconds -= value * units[unit];\n }\n });\n return parts.join(' ');\n};\n/**\r\n * Creates an SLA object based on the type, applied SLA, and chat details.\r\n * @param type - The type of SLA (FRT, NRT, RT).\r\n * @param appliedSla - The applied SLA details.\r\n * @param chat - The chat details.\r\n * @returns An object containing the SLA status or null if conditions are not met.\r\n */\n\n\nvar createSLAObject = function createSLAObject(type, appliedSla, chat) {\n var frtThreshold = appliedSla.sla_first_response_time_threshold,\n nrtThreshold = appliedSla.sla_next_response_time_threshold,\n rtThreshold = appliedSla.sla_resolution_time_threshold,\n createdAt = appliedSla.created_at;\n var firstReplyCreatedAt = chat.first_reply_created_at,\n waitingSince = chat.waiting_since,\n status = chat.status;\n var SLATypes = {\n FRT: {\n threshold: calculateThreshold(createdAt, frtThreshold),\n // Check FRT only if threshold is not null and first reply hasn't been made\n condition: frtThreshold !== null && (!firstReplyCreatedAt || firstReplyCreatedAt === 0)\n },\n NRT: {\n threshold: calculateThreshold(waitingSince, nrtThreshold),\n // Check NRT only if threshold is not null, first reply has been made and we are waiting since\n condition: nrtThreshold !== null && !!firstReplyCreatedAt && !!waitingSince\n },\n RT: {\n threshold: calculateThreshold(createdAt, rtThreshold),\n // Check RT only if the conversation is open and threshold is not null\n condition: status === 'open' && rtThreshold !== null\n }\n };\n var SLAStatus = SLATypes[type];\n return SLAStatus ? _extends({}, SLAStatus, {\n type: type\n }) : null;\n};\n/**\r\n * Evaluates SLA conditions and returns an array of SLAStatus objects.\r\n * @param appliedSla - The applied SLA details.\r\n * @param chat - The chat details.\r\n * @returns An array of SLAStatus objects.\r\n */\n\n\nvar evaluateSLAConditions = function evaluateSLAConditions(appliedSla, chat) {\n // Filter out the SLA based on conditions and update the object with the breach status(icon, isSlaMissed)\n var SLATypes = ['FRT', 'NRT', 'RT'];\n return SLATypes.map(function (type) {\n return createSLAObject(type, appliedSla, chat);\n }).filter(function (SLAStatus) {\n return !!SLAStatus && SLAStatus.condition;\n }).map(function (SLAStatus) {\n return _extends({}, SLAStatus, {\n icon: SLAStatus.threshold <= 0 ? 'flame' : 'alarm',\n isSlaMissed: SLAStatus.threshold <= 0\n });\n });\n};\n/**\r\n * Evaluates the SLA status for a given chat and applied SLA.\r\n * @param {Object} params - The parameters object.\r\n * @param params.appliedSla - The applied SLA details.\r\n * @param params.chat - The chat details.\r\n * @returns An object containing the most urgent SLA status.\r\n */\n\n\nvar evaluateSLAStatus = function evaluateSLAStatus(_ref) {\n var appliedSla = _ref.appliedSla,\n chat = _ref.chat;\n if (!appliedSla || !chat) return {\n type: '',\n threshold: '',\n icon: '',\n isSlaMissed: false\n }; // Filter out the SLA and create the object for each breach\n\n var SLAStatuses = evaluateSLAConditions(appliedSla, chat); // Return the most urgent SLA which is latest to breach or has missed\n\n var mostUrgent = findMostUrgentSLAStatus(SLAStatuses);\n return mostUrgent ? {\n type: mostUrgent == null ? void 0 : mostUrgent.type,\n threshold: formatSLATime(mostUrgent.threshold <= 0 ? -mostUrgent.threshold : mostUrgent.threshold),\n icon: mostUrgent.icon,\n isSlaMissed: mostUrgent.isSlaMissed\n } : {\n type: '',\n threshold: '',\n icon: '',\n isSlaMissed: false\n };\n};\n\nexport { applyRotationTransform, calculateCenterOffset, clamp, convertSecondsToTimeUnit, createTypingIndicator, debounce, downloadFile, evaluateSLAStatus, fileNameWithEllipsis, formatDate, formatTime, getContrastingTextColor, getFileInfo, getMessageVariables, getQuantileIntervals, getRecipients, getUndefinedVariablesInMessage, normalizeToPercentage, parseBoolean, quantile, replaceVariablesInMessage, sortAsc, splitName, trimContent };\n//# sourceMappingURL=utils.esm.js.map\n"],"names":["debounce","func","wait","immediate","timeout","context","args","later","callNow","asyncGeneratorStep","gen","resolve","reject","_next","_throw","key","arg","info","value","error","_asyncToGenerator","fn","self","err","_extends","target","i","source","createCommonjsModule","module","runtime_1","runtime","exports","Op","hasOwn","undefined$1","$Symbol","iteratorSymbol","asyncIteratorSymbol","toStringTagSymbol","define","obj","wrap","innerFn","outerFn","tryLocsList","protoGenerator","Generator","generator","Context","makeInvokeMethod","tryCatch","GenStateSuspendedStart","GenStateSuspendedYield","GenStateExecuting","GenStateCompleted","ContinueSentinel","GeneratorFunction","GeneratorFunctionPrototype","IteratorPrototype","getProto","NativeIteratorPrototype","values","Gp","defineIteratorMethods","prototype","method","genFun","ctor","AsyncIterator","PromiseImpl","invoke","record","result","unwrapped","previousPromise","enqueue","callInvokeWithMethodAndArg","iter","state","doneResult","delegate","delegateResult","maybeInvokeDelegate","pushTryEntry","locs","entry","resetTryEntry","object","keys","next","iterable","iteratorMethod","skipTempReset","name","rootEntry","rootRecord","exception","handle","loc","caught","hasCatch","hasFinally","type","finallyEntry","afterLoc","finallyLoc","tryLoc","thrown","resultName","nextLoc","getContrastingTextColor","bgColor","color","r","g","b","formatTime","timeInSeconds","formattedTime","minutes","seconds","hours","_minutes","days","_hours","trimContent","content","maxLength","ellipsis","trimmedContent","convertSecondsToTimeUnit","unitNames","fileNameWithEllipsis","file","_ref2","_file$filename","fullName","dotIndex","_ref3","extension","splitName","trimmedName","nameParts","lastName","firstName","downloadFile","_ref5","_callee","_ref4","url","_ref4$extension","_filenameMatch$","response","blobData","contentType","fileExtension","dispositionHeader","filenameMatch","filename","blobUrl","link","_context","_x","getFileInfo","defaultInfo","cleanUrl","encodedFilename","fileName","lastDotIndex","base","MessageType","getRecipients","lastEmail","conversationContact","inboxEmail","forwardToEmail","_emailAttributes$from","to","cc","bcc","messageType","isIncoming","emailAttributes","contentAttributes","email","_contentAttributes","_ref","_ref$cc_emails","ccEmails","_ref$bcc_emails","bccEmails","_ref$to_emails","toEmails","isLastEmailFromContact","_to","_emailAttributes$from2","_to2","_emailAttributes$to","_cc","emailAddress","replyUUIDPattern","parseBoolean","candidate","candidateString","sortAsc","arr","a","clamp","min","max","_quantileForSorted","sorted","q","clamped","pos","rest","getQuantileIntervals","data","intervals","interval","calculateCenterOffset","mouseX","mouseY","rect","centerX","centerY","applyRotationTransform","relativeX","relativeY","angle","radians","cos","sin","normalizeToPercentage","rotatedX","rotatedY","width","height","MESSAGE_VARIABLES_REGEX","skipCodeBlocks","str","capitalizeName","word","getFirstName","user","getLastName","getMessageVariables","_assignee$email","conversation","contact","_conversation$meta","assignee","sender","id","_conversation$custom_","conversationCustomAttributes","contactCustomAttributes","standardVariables","conversationCustomAttributeVariables","acc","contactCustomAttributeVariables","_ref6","variables","replaceVariablesInMessage","_ref7","message","_","replace","getUndefinedVariablesInMessage","_ref8","messageWithOutCodeBlocks","matches","match","variable","createTypingIndicator","onStartTyping","onStopTyping","idleTime","timer","start","reset","stop","calculateThreshold","timeOffset","threshold","currentTime","findMostUrgentSLAStatus","SLAStatuses","sla1","sla2","formatSLATime","units","parts","unit","createSLAObject","appliedSla","chat","frtThreshold","nrtThreshold","rtThreshold","createdAt","firstReplyCreatedAt","waitingSince","status","SLATypes","SLAStatus","evaluateSLAConditions","evaluateSLAStatus","mostUrgent"],"mappings":"AAcG,IAACA,GAAW,SAAkBC,EAAMC,EAAMC,EAAW,CACtD,IAAIC,EACJ,OAAO,UAAY,CACjB,IAAIC,EAAU,KACVC,EAAO,UAEPC,EAAQ,UAAiB,CAC3BH,EAAU,KACLD,GAAWF,EAAK,MAAMI,EAASC,CAAI,CACzC,EAEGE,EAAUL,GAAa,CAACC,EAC5B,aAAaA,CAAO,EACpBA,EAAU,OAAO,WAAWG,EAAOL,CAAI,EACnCM,GAASP,EAAK,MAAMI,EAASC,CAAI,CACtC,CACH,EAEA,SAASG,EAAmB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