@bigbinary/neeto-commons-frontend 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/utils.js ADDED
@@ -0,0 +1,605 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var axios = require('axios');
6
+ var ramda = require('ramda');
7
+ var i18next = require('i18next');
8
+ var general = require('pure/general');
9
+ var dayjs = require('dayjs');
10
+ var relativeTime = require('dayjs/plugin/relativeTime');
11
+ var updateLocale = require('dayjs/plugin/updateLocale');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
+
15
+ var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
16
+ var i18next__default = /*#__PURE__*/_interopDefaultLegacy(i18next);
17
+ var dayjs__default = /*#__PURE__*/_interopDefaultLegacy(dayjs);
18
+ var relativeTime__default = /*#__PURE__*/_interopDefaultLegacy(relativeTime);
19
+ var updateLocale__default = /*#__PURE__*/_interopDefaultLegacy(updateLocale);
20
+
21
+ var HEADERS_KEYS = {
22
+ xAuthEmail: "X-Auth-Email",
23
+ xAuthToken: "X-Auth-Token",
24
+ xCsrfToken: "X-CSRF-TOKEN"
25
+ };
26
+
27
+ var resetAuthTokens = function resetAuthTokens() {
28
+ ramda.values(HEADERS_KEYS).forEach(function (header) {
29
+ delete axios__default["default"].defaults.headers[header];
30
+ });
31
+ };
32
+
33
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
34
+ try {
35
+ var info = gen[key](arg);
36
+ var value = info.value;
37
+ } catch (error) {
38
+ reject(error);
39
+ return;
40
+ }
41
+
42
+ if (info.done) {
43
+ resolve(value);
44
+ } else {
45
+ Promise.resolve(value).then(_next, _throw);
46
+ }
47
+ }
48
+
49
+ function _asyncToGenerator(fn) {
50
+ return function () {
51
+ var self = this,
52
+ args = arguments;
53
+ return new Promise(function (resolve, reject) {
54
+ var gen = fn.apply(self, args);
55
+
56
+ function _next(value) {
57
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
58
+ }
59
+
60
+ function _throw(err) {
61
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
62
+ }
63
+
64
+ _next(undefined);
65
+ });
66
+ };
67
+ }
68
+
69
+ function _defineProperty(obj, key, value) {
70
+ if (key in obj) {
71
+ Object.defineProperty(obj, key, {
72
+ value: value,
73
+ enumerable: true,
74
+ configurable: true,
75
+ writable: true
76
+ });
77
+ } else {
78
+ obj[key] = value;
79
+ }
80
+
81
+ return obj;
82
+ }
83
+
84
+ var regeneratorRuntime$1 = {exports: {}};
85
+
86
+ var _typeof = {exports: {}};
87
+
88
+ (function (module) {
89
+ function _typeof(obj) {
90
+ "@babel/helpers - typeof";
91
+
92
+ return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
93
+ return typeof obj;
94
+ } : function (obj) {
95
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
96
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
97
+ }
98
+
99
+ module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
100
+ } (_typeof));
101
+
102
+ (function (module) {
103
+ var _typeof$1 = _typeof.exports["default"];
104
+
105
+ function _regeneratorRuntime() {
106
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
107
+
108
+ module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
109
+ return exports;
110
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
111
+ var exports = {},
112
+ Op = Object.prototype,
113
+ hasOwn = Op.hasOwnProperty,
114
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
115
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
116
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
117
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
118
+
119
+ function define(obj, key, value) {
120
+ return Object.defineProperty(obj, key, {
121
+ value: value,
122
+ enumerable: !0,
123
+ configurable: !0,
124
+ writable: !0
125
+ }), obj[key];
126
+ }
127
+
128
+ try {
129
+ define({}, "");
130
+ } catch (err) {
131
+ define = function define(obj, key, value) {
132
+ return obj[key] = value;
133
+ };
134
+ }
135
+
136
+ function wrap(innerFn, outerFn, self, tryLocsList) {
137
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
138
+ generator = Object.create(protoGenerator.prototype),
139
+ context = new Context(tryLocsList || []);
140
+ return generator._invoke = function (innerFn, self, context) {
141
+ var state = "suspendedStart";
142
+ return function (method, arg) {
143
+ if ("executing" === state) throw new Error("Generator is already running");
144
+
145
+ if ("completed" === state) {
146
+ if ("throw" === method) throw arg;
147
+ return doneResult();
148
+ }
149
+
150
+ for (context.method = method, context.arg = arg;;) {
151
+ var delegate = context.delegate;
152
+
153
+ if (delegate) {
154
+ var delegateResult = maybeInvokeDelegate(delegate, context);
155
+
156
+ if (delegateResult) {
157
+ if (delegateResult === ContinueSentinel) continue;
158
+ return delegateResult;
159
+ }
160
+ }
161
+
162
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
163
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
164
+ context.dispatchException(context.arg);
165
+ } else "return" === context.method && context.abrupt("return", context.arg);
166
+ state = "executing";
167
+ var record = tryCatch(innerFn, self, context);
168
+
169
+ if ("normal" === record.type) {
170
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
171
+ return {
172
+ value: record.arg,
173
+ done: context.done
174
+ };
175
+ }
176
+
177
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
178
+ }
179
+ };
180
+ }(innerFn, self, context), generator;
181
+ }
182
+
183
+ function tryCatch(fn, obj, arg) {
184
+ try {
185
+ return {
186
+ type: "normal",
187
+ arg: fn.call(obj, arg)
188
+ };
189
+ } catch (err) {
190
+ return {
191
+ type: "throw",
192
+ arg: err
193
+ };
194
+ }
195
+ }
196
+
197
+ exports.wrap = wrap;
198
+ var ContinueSentinel = {};
199
+
200
+ function Generator() {}
201
+
202
+ function GeneratorFunction() {}
203
+
204
+ function GeneratorFunctionPrototype() {}
205
+
206
+ var IteratorPrototype = {};
207
+ define(IteratorPrototype, iteratorSymbol, function () {
208
+ return this;
209
+ });
210
+ var getProto = Object.getPrototypeOf,
211
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
212
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
213
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
214
+
215
+ function defineIteratorMethods(prototype) {
216
+ ["next", "throw", "return"].forEach(function (method) {
217
+ define(prototype, method, function (arg) {
218
+ return this._invoke(method, arg);
219
+ });
220
+ });
221
+ }
222
+
223
+ function AsyncIterator(generator, PromiseImpl) {
224
+ function invoke(method, arg, resolve, reject) {
225
+ var record = tryCatch(generator[method], generator, arg);
226
+
227
+ if ("throw" !== record.type) {
228
+ var result = record.arg,
229
+ value = result.value;
230
+ return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
231
+ invoke("next", value, resolve, reject);
232
+ }, function (err) {
233
+ invoke("throw", err, resolve, reject);
234
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
235
+ result.value = unwrapped, resolve(result);
236
+ }, function (error) {
237
+ return invoke("throw", error, resolve, reject);
238
+ });
239
+ }
240
+
241
+ reject(record.arg);
242
+ }
243
+
244
+ var previousPromise;
245
+
246
+ this._invoke = function (method, arg) {
247
+ function callInvokeWithMethodAndArg() {
248
+ return new PromiseImpl(function (resolve, reject) {
249
+ invoke(method, arg, resolve, reject);
250
+ });
251
+ }
252
+
253
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
254
+ };
255
+ }
256
+
257
+ function maybeInvokeDelegate(delegate, context) {
258
+ var method = delegate.iterator[context.method];
259
+
260
+ if (undefined === method) {
261
+ if (context.delegate = null, "throw" === context.method) {
262
+ if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
263
+ context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
264
+ }
265
+
266
+ return ContinueSentinel;
267
+ }
268
+
269
+ var record = tryCatch(method, delegate.iterator, context.arg);
270
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
271
+ var info = record.arg;
272
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
273
+ }
274
+
275
+ function pushTryEntry(locs) {
276
+ var entry = {
277
+ tryLoc: locs[0]
278
+ };
279
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
280
+ }
281
+
282
+ function resetTryEntry(entry) {
283
+ var record = entry.completion || {};
284
+ record.type = "normal", delete record.arg, entry.completion = record;
285
+ }
286
+
287
+ function Context(tryLocsList) {
288
+ this.tryEntries = [{
289
+ tryLoc: "root"
290
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
291
+ }
292
+
293
+ function values(iterable) {
294
+ if (iterable) {
295
+ var iteratorMethod = iterable[iteratorSymbol];
296
+ if (iteratorMethod) return iteratorMethod.call(iterable);
297
+ if ("function" == typeof iterable.next) return iterable;
298
+
299
+ if (!isNaN(iterable.length)) {
300
+ var i = -1,
301
+ next = function next() {
302
+ for (; ++i < iterable.length;) {
303
+ if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
304
+ }
305
+
306
+ return next.value = undefined, next.done = !0, next;
307
+ };
308
+
309
+ return next.next = next;
310
+ }
311
+ }
312
+
313
+ return {
314
+ next: doneResult
315
+ };
316
+ }
317
+
318
+ function doneResult() {
319
+ return {
320
+ value: undefined,
321
+ done: !0
322
+ };
323
+ }
324
+
325
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
326
+ var ctor = "function" == typeof genFun && genFun.constructor;
327
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
328
+ }, exports.mark = function (genFun) {
329
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
330
+ }, exports.awrap = function (arg) {
331
+ return {
332
+ __await: arg
333
+ };
334
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
335
+ return this;
336
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
337
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
338
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
339
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
340
+ return result.done ? result.value : iter.next();
341
+ });
342
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
343
+ return this;
344
+ }), define(Gp, "toString", function () {
345
+ return "[object Generator]";
346
+ }), exports.keys = function (object) {
347
+ var keys = [];
348
+
349
+ for (var key in object) {
350
+ keys.push(key);
351
+ }
352
+
353
+ return keys.reverse(), function next() {
354
+ for (; keys.length;) {
355
+ var key = keys.pop();
356
+ if (key in object) return next.value = key, next.done = !1, next;
357
+ }
358
+
359
+ return next.done = !0, next;
360
+ };
361
+ }, exports.values = values, Context.prototype = {
362
+ constructor: Context,
363
+ reset: function reset(skipTempReset) {
364
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
365
+ "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
366
+ }
367
+ },
368
+ stop: function stop() {
369
+ this.done = !0;
370
+ var rootRecord = this.tryEntries[0].completion;
371
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
372
+ return this.rval;
373
+ },
374
+ dispatchException: function dispatchException(exception) {
375
+ if (this.done) throw exception;
376
+ var context = this;
377
+
378
+ function handle(loc, caught) {
379
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
380
+ }
381
+
382
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
383
+ var entry = this.tryEntries[i],
384
+ record = entry.completion;
385
+ if ("root" === entry.tryLoc) return handle("end");
386
+
387
+ if (entry.tryLoc <= this.prev) {
388
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
389
+ hasFinally = hasOwn.call(entry, "finallyLoc");
390
+
391
+ if (hasCatch && hasFinally) {
392
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
393
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
394
+ } else if (hasCatch) {
395
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
396
+ } else {
397
+ if (!hasFinally) throw new Error("try statement without catch or finally");
398
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
399
+ }
400
+ }
401
+ }
402
+ },
403
+ abrupt: function abrupt(type, arg) {
404
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
405
+ var entry = this.tryEntries[i];
406
+
407
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
408
+ var finallyEntry = entry;
409
+ break;
410
+ }
411
+ }
412
+
413
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
414
+ var record = finallyEntry ? finallyEntry.completion : {};
415
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
416
+ },
417
+ complete: function complete(record, afterLoc) {
418
+ if ("throw" === record.type) throw record.arg;
419
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
420
+ },
421
+ finish: function finish(finallyLoc) {
422
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
423
+ var entry = this.tryEntries[i];
424
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
425
+ }
426
+ },
427
+ "catch": function _catch(tryLoc) {
428
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
429
+ var entry = this.tryEntries[i];
430
+
431
+ if (entry.tryLoc === tryLoc) {
432
+ var record = entry.completion;
433
+
434
+ if ("throw" === record.type) {
435
+ var thrown = record.arg;
436
+ resetTryEntry(entry);
437
+ }
438
+
439
+ return thrown;
440
+ }
441
+ }
442
+
443
+ throw new Error("illegal catch attempt");
444
+ },
445
+ delegateYield: function delegateYield(iterable, resultName, nextLoc) {
446
+ return this.delegate = {
447
+ iterator: values(iterable),
448
+ resultName: resultName,
449
+ nextLoc: nextLoc
450
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
451
+ }
452
+ }, exports;
453
+ }
454
+
455
+ module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
456
+ } (regeneratorRuntime$1));
457
+
458
+ // TODO(Babel 8): Remove this file.
459
+
460
+ var runtime = regeneratorRuntime$1.exports();
461
+ var regenerator = runtime;
462
+
463
+ // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
464
+ try {
465
+ regeneratorRuntime = runtime;
466
+ } catch (accidentalStrictMode) {
467
+ if (typeof globalThis === "object") {
468
+ globalThis.regeneratorRuntime = runtime;
469
+ } else {
470
+ Function("r", "regeneratorRuntime = r")(runtime);
471
+ }
472
+ }
473
+
474
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
475
+
476
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
477
+ var withEventTargetValue = ramda.curry(function (func, event) {
478
+ return func(event.target.value);
479
+ });
480
+ var getSubdomain = function getSubdomain() {
481
+ var host = window.location.host;
482
+ var parts = host.split(".");
483
+ return parts.length >= 3 ? parts[0] : "";
484
+ };
485
+ var simulateApiCall = function simulateApiCall(result, error) {
486
+ var errorProbability = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.1;
487
+ var delay = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : general.getRandomInt(350, 1000);
488
+ return new Promise(function (resolve, reject) {
489
+ return setTimeout(function () {
490
+ var defaultErrorObj = {
491
+ success: false,
492
+ notice: i18next__default["default"].t("neetoCommons.notice.errorOccurred")
493
+ };
494
+ Math.random() < errorProbability ? reject(_objectSpread(_objectSpread({}, defaultErrorObj), error)) : resolve(result);
495
+ }, delay);
496
+ });
497
+ };
498
+ var copyToClipboard = /*#__PURE__*/function () {
499
+ var _ref = _asyncToGenerator( /*#__PURE__*/regenerator.mark(function _callee(text) {
500
+ var _ref2,
501
+ _ref2$showToastr,
502
+ showToastr,
503
+ _ref2$message,
504
+ message,
505
+ _require,
506
+ Toastr,
507
+ textArea,
508
+ _args = arguments;
509
+
510
+ return regenerator.wrap(function _callee$(_context) {
511
+ while (1) {
512
+ switch (_context.prev = _context.next) {
513
+ case 0:
514
+ _ref2 = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}, _ref2$showToastr = _ref2.showToastr, showToastr = _ref2$showToastr === void 0 ? true : _ref2$showToastr, _ref2$message = _ref2.message, message = _ref2$message === void 0 ? i18next__default["default"].t("neetoCommons.toastr.success.copiedToClipboard") : _ref2$message;
515
+
516
+ /*
517
+ This is a workaround to prevent the jest tests from failing. Once the issue in neetoUI
518
+ https://github.com/bigbinary/neeto-ui/issues/1175 is resolved, this import can be moved to the top of the file.
519
+ */
520
+ _require = require("@bigbinary/neetoui"), Toastr = _require.Toastr;
521
+ _context.prev = 2;
522
+
523
+ if (!(navigator.clipboard && window.isSecureContext)) {
524
+ _context.next = 8;
525
+ break;
526
+ }
527
+
528
+ _context.next = 6;
529
+ return navigator.clipboard.writeText(text);
530
+
531
+ case 6:
532
+ _context.next = 18;
533
+ break;
534
+
535
+ case 8:
536
+ textArea = document.createElement("textarea");
537
+ textArea.value = text;
538
+ textArea.style.top = "0";
539
+ textArea.style.left = "0";
540
+ textArea.style.position = "fixed";
541
+ document.body.appendChild(textArea);
542
+ textArea.focus();
543
+ textArea.select();
544
+ document.execCommand("copy");
545
+ document.body.removeChild(textArea);
546
+
547
+ case 18:
548
+ showToastr && Toastr.success(message);
549
+ _context.next = 24;
550
+ break;
551
+
552
+ case 21:
553
+ _context.prev = 21;
554
+ _context.t0 = _context["catch"](2);
555
+ Toastr.error(_context.t0);
556
+
557
+ case 24:
558
+ case "end":
559
+ return _context.stop();
560
+ }
561
+ }
562
+ }, _callee, null, [[2, 21]]);
563
+ }));
564
+
565
+ return function copyToClipboard(_x) {
566
+ return _ref.apply(this, arguments);
567
+ };
568
+ }();
569
+
570
+ dayjs__default["default"].extend(relativeTime__default["default"]);
571
+ dayjs__default["default"].extend(updateLocale__default["default"]);
572
+ var timeFormat = {
573
+ fromNow: function fromNow(time) {
574
+ return dayjs__default["default"](time).fromNow();
575
+ },
576
+ time: function time(_time) {
577
+ return dayjs__default["default"](_time).format("h:mm A");
578
+ },
579
+ date: function date(time) {
580
+ return dayjs__default["default"](time).format("MMM D, YYYY");
581
+ },
582
+ dateWeek: function dateWeek(time) {
583
+ return dayjs__default["default"](time).format("MMM D, YYYY ddd");
584
+ },
585
+ dateTime: function dateTime(time) {
586
+ return dayjs__default["default"](time).format("MMM D, YYYY h:mm A");
587
+ },
588
+ dateWeekTime: function dateWeekTime(time) {
589
+ return dayjs__default["default"](time).format("MMM D, YYYY ddd h:mm A");
590
+ },
591
+ extended: function extended(time) {
592
+ var dateTime = dayjs__default["default"](time).format("dddd MMMM D, YYYY h:mm A");
593
+ var fromNow = dayjs__default["default"](time).fromNow();
594
+ return "".concat(dateTime, " (").concat(fromNow, ")");
595
+ }
596
+ };
597
+ var dateFormat = timeFormat;
598
+
599
+ exports.copyToClipboard = copyToClipboard;
600
+ exports.dateFormat = dateFormat;
601
+ exports.getSubdomain = getSubdomain;
602
+ exports.resetAuthTokens = resetAuthTokens;
603
+ exports.simulateApiCall = simulateApiCall;
604
+ exports.timeFormat = timeFormat;
605
+ exports.withEventTargetValue = withEventTargetValue;