quikchat 1.1.17 → 1.2.4

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.
Files changed (43) hide show
  1. package/README.md +167 -276
  2. package/dist/build-manifest.json +157 -0
  3. package/dist/quikchat-md-full.cjs.js +2742 -0
  4. package/dist/quikchat-md-full.cjs.js.map +1 -0
  5. package/dist/quikchat-md-full.cjs.min.js +10 -0
  6. package/dist/quikchat-md-full.cjs.min.js.map +1 -0
  7. package/dist/quikchat-md-full.esm.js +2740 -0
  8. package/dist/quikchat-md-full.esm.js.map +1 -0
  9. package/dist/quikchat-md-full.esm.min.js +10 -0
  10. package/dist/quikchat-md-full.esm.min.js.map +1 -0
  11. package/dist/quikchat-md-full.umd.js +2748 -0
  12. package/dist/quikchat-md-full.umd.js.map +1 -0
  13. package/dist/quikchat-md-full.umd.min.js +10 -0
  14. package/dist/quikchat-md-full.umd.min.js.map +1 -0
  15. package/dist/quikchat-md.cjs.js +1641 -0
  16. package/dist/quikchat-md.cjs.js.map +1 -0
  17. package/dist/quikchat-md.cjs.min.js +8 -0
  18. package/dist/quikchat-md.cjs.min.js.map +1 -0
  19. package/dist/quikchat-md.esm.js +1639 -0
  20. package/dist/quikchat-md.esm.js.map +1 -0
  21. package/dist/quikchat-md.esm.min.js +8 -0
  22. package/dist/quikchat-md.esm.min.js.map +1 -0
  23. package/dist/quikchat-md.umd.js +1647 -0
  24. package/dist/quikchat-md.umd.js.map +1 -0
  25. package/dist/quikchat-md.umd.min.js +8 -0
  26. package/dist/quikchat-md.umd.min.js.map +1 -0
  27. package/dist/quikchat.cjs.js +454 -1729
  28. package/dist/quikchat.cjs.js.map +1 -1
  29. package/dist/quikchat.cjs.min.js +1 -1
  30. package/dist/quikchat.cjs.min.js.map +1 -1
  31. package/dist/quikchat.css +753 -226
  32. package/dist/quikchat.esm.js +454 -1729
  33. package/dist/quikchat.esm.js.map +1 -1
  34. package/dist/quikchat.esm.min.js +1 -1
  35. package/dist/quikchat.esm.min.js.map +1 -1
  36. package/dist/quikchat.min.css +1 -1
  37. package/dist/quikchat.react.js +63 -0
  38. package/dist/quikchat.umd.js +454 -1729
  39. package/dist/quikchat.umd.js.map +1 -1
  40. package/dist/quikchat.umd.min.js +1 -1
  41. package/dist/quikchat.umd.min.js.map +1 -1
  42. package/package.json +59 -39
  43. package/dist/quikchat.d.ts +0 -194
@@ -0,0 +1,1639 @@
1
+ function _arrayLikeToArray(r, a) {
2
+ (null == a || a > r.length) && (a = r.length);
3
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4
+ return n;
5
+ }
6
+ function _assertThisInitialized(e) {
7
+ if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
8
+ return e;
9
+ }
10
+ function _callSuper(t, o, e) {
11
+ return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e));
12
+ }
13
+ function _classCallCheck(a, n) {
14
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
15
+ }
16
+ function _defineProperties(e, r) {
17
+ for (var t = 0; t < r.length; t++) {
18
+ var o = r[t];
19
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
20
+ }
21
+ }
22
+ function _createClass(e, r, t) {
23
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
24
+ writable: false
25
+ }), e;
26
+ }
27
+ function _createForOfIteratorHelper(r, e) {
28
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
29
+ if (!t) {
30
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
31
+ t && (r = t);
32
+ var n = 0,
33
+ F = function () {};
34
+ return {
35
+ s: F,
36
+ n: function () {
37
+ return n >= r.length ? {
38
+ done: true
39
+ } : {
40
+ done: false,
41
+ value: r[n++]
42
+ };
43
+ },
44
+ e: function (r) {
45
+ throw r;
46
+ },
47
+ f: F
48
+ };
49
+ }
50
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
51
+ }
52
+ var o,
53
+ a = true,
54
+ u = false;
55
+ return {
56
+ s: function () {
57
+ t = t.call(r);
58
+ },
59
+ n: function () {
60
+ var r = t.next();
61
+ return a = r.done, r;
62
+ },
63
+ e: function (r) {
64
+ u = true, o = r;
65
+ },
66
+ f: function () {
67
+ try {
68
+ a || null == t.return || t.return();
69
+ } finally {
70
+ if (u) throw o;
71
+ }
72
+ }
73
+ };
74
+ }
75
+ function _defineProperty(e, r, t) {
76
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
77
+ value: t,
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true
81
+ }) : e[r] = t, e;
82
+ }
83
+ function _getPrototypeOf(t) {
84
+ return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
85
+ return t.__proto__ || Object.getPrototypeOf(t);
86
+ }, _getPrototypeOf(t);
87
+ }
88
+ function _inherits(t, e) {
89
+ if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
90
+ t.prototype = Object.create(e && e.prototype, {
91
+ constructor: {
92
+ value: t,
93
+ writable: true,
94
+ configurable: true
95
+ }
96
+ }), Object.defineProperty(t, "prototype", {
97
+ writable: false
98
+ }), e && _setPrototypeOf(t, e);
99
+ }
100
+ function _isNativeReflectConstruct() {
101
+ try {
102
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
103
+ } catch (t) {}
104
+ return (_isNativeReflectConstruct = function () {
105
+ return !!t;
106
+ })();
107
+ }
108
+ function ownKeys(e, r) {
109
+ var t = Object.keys(e);
110
+ if (Object.getOwnPropertySymbols) {
111
+ var o = Object.getOwnPropertySymbols(e);
112
+ r && (o = o.filter(function (r) {
113
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
114
+ })), t.push.apply(t, o);
115
+ }
116
+ return t;
117
+ }
118
+ function _objectSpread2(e) {
119
+ for (var r = 1; r < arguments.length; r++) {
120
+ var t = null != arguments[r] ? arguments[r] : {};
121
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
122
+ _defineProperty(e, r, t[r]);
123
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
124
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
125
+ });
126
+ }
127
+ return e;
128
+ }
129
+ function _possibleConstructorReturn(t, e) {
130
+ if (e && ("object" == typeof e || "function" == typeof e)) return e;
131
+ if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
132
+ return _assertThisInitialized(t);
133
+ }
134
+ function _setPrototypeOf(t, e) {
135
+ return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
136
+ return t.__proto__ = e, t;
137
+ }, _setPrototypeOf(t, e);
138
+ }
139
+ function _toPrimitive(t, r) {
140
+ if ("object" != typeof t || !t) return t;
141
+ var e = t[Symbol.toPrimitive];
142
+ if (void 0 !== e) {
143
+ var i = e.call(t, r);
144
+ if ("object" != typeof i) return i;
145
+ throw new TypeError("@@toPrimitive must return a primitive value.");
146
+ }
147
+ return ("string" === r ? String : Number)(t);
148
+ }
149
+ function _toPropertyKey(t) {
150
+ var i = _toPrimitive(t, "string");
151
+ return "symbol" == typeof i ? i : i + "";
152
+ }
153
+ function _unsupportedIterableToArray(r, a) {
154
+ if (r) {
155
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
156
+ var t = {}.toString.call(r).slice(8, -1);
157
+ 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;
158
+ }
159
+ }
160
+
161
+ var quikchat = /*#__PURE__*/function () {
162
+ /**
163
+ *
164
+ * @param string or DOM element parentElement
165
+ * @param {*} meta
166
+ */
167
+ function quikchat(parentElement) {
168
+ var onSend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
169
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
170
+ _classCallCheck(this, quikchat);
171
+ var defaultOpts = {
172
+ theme: 'quikchat-theme-light',
173
+ trackHistory: true,
174
+ showTimestamps: false,
175
+ titleArea: {
176
+ title: "Chat",
177
+ show: false,
178
+ align: "center"
179
+ },
180
+ messagesArea: {
181
+ alternating: true
182
+ }
183
+ };
184
+ var meta = _objectSpread2(_objectSpread2({}, defaultOpts), options); // merge options with defaults
185
+
186
+ if (typeof parentElement === 'string') {
187
+ parentElement = document.querySelector(parentElement);
188
+ }
189
+ this._parentElement = parentElement;
190
+ this._theme = meta.theme;
191
+ this._onSend = onSend ? onSend : function () {}; // call back function for onSend
192
+ this._messageFormatter = meta.messageFormatter || null;
193
+ this._sanitize = meta.sanitize || false;
194
+ this._createWidget();
195
+ // title area
196
+ if (meta.titleArea) {
197
+ this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
198
+ if (meta.titleArea.show === true) {
199
+ this.titleAreaShow();
200
+ } else {
201
+ this.titleAreaHide();
202
+ }
203
+ }
204
+ // messages area
205
+ if (meta.messagesArea) {
206
+ this.messagesAreaAlternateColors(meta.messagesArea.alternating);
207
+ }
208
+ // timestamps
209
+ if (meta.showTimestamps) {
210
+ this.messagesAreaShowTimestamps(true);
211
+ }
212
+ // direction (ltr/rtl)
213
+ if (meta.direction) {
214
+ this.setDirection(meta.direction);
215
+ }
216
+ // plumbing
217
+ this._attachEventListeners();
218
+ this.trackHistory = meta.trackHistory !== false;
219
+ this._historyLimit = 10000000;
220
+ this._history = [];
221
+ }
222
+ return _createClass(quikchat, [{
223
+ key: "_createWidget",
224
+ value: function _createWidget() {
225
+ var widgetHTML = "\n <div class=\"quikchat-base ".concat(this.theme, "\">\n <div class=\"quikchat-title-area\"></div>\n <div class=\"quikchat-messages-wrapper\"><div class=\"quikchat-messages-area\" role=\"log\" aria-live=\"polite\" aria-label=\"Chat messages\"></div><button class=\"quikchat-scroll-bottom\" aria-label=\"Scroll to bottom\"></button></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\" rows=\"1\" aria-label=\"Type a message\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\n ");
226
+ this._parentElement.innerHTML = widgetHTML;
227
+ this._chatWidget = this._parentElement.querySelector('.quikchat-base');
228
+ this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');
229
+ this._messagesWrapper = this._chatWidget.querySelector('.quikchat-messages-wrapper');
230
+ this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');
231
+ this._scrollBottomBtn = this._messagesWrapper.querySelector('.quikchat-scroll-bottom');
232
+ this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');
233
+ this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');
234
+ this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');
235
+ this.msgid = 0;
236
+ }
237
+
238
+ /**
239
+ * Attach event listeners to the widget
240
+ */
241
+ }, {
242
+ key: "_attachEventListeners",
243
+ value: function _attachEventListeners() {
244
+ var _this = this;
245
+ this._sendButton.addEventListener('click', function () {
246
+ var text = _this._textEntry.value.trim();
247
+ if (text === '') return;
248
+ _this._onSend(_this, text);
249
+ });
250
+ this._textEntry.addEventListener('keydown', function (event) {
251
+ // Check if Shift + Enter is pressed
252
+ if (event.shiftKey && event.keyCode === 13) {
253
+ event.preventDefault();
254
+ var text = _this._textEntry.value.trim();
255
+ if (text === '') return;
256
+ _this._onSend(_this, text);
257
+ }
258
+ });
259
+
260
+ // Auto-grow textarea
261
+ this._textEntry.addEventListener('input', function () {
262
+ return _this._autoGrowTextarea();
263
+ });
264
+ this._messagesArea.addEventListener('scroll', function () {
265
+ var _this$_messagesArea = _this._messagesArea,
266
+ scrollTop = _this$_messagesArea.scrollTop,
267
+ scrollHeight = _this$_messagesArea.scrollHeight,
268
+ clientHeight = _this$_messagesArea.clientHeight;
269
+ _this.userScrolledUp = scrollTop + clientHeight < scrollHeight - 1;
270
+ _this._updateScrollBottomBtn();
271
+ });
272
+
273
+ // Scroll-to-bottom button
274
+ this._scrollBottomBtn.addEventListener('click', function () {
275
+ return _this.scrollToBottom();
276
+ });
277
+
278
+ // Ctrl+End to scroll to bottom
279
+ this._chatWidget.addEventListener('keydown', function (event) {
280
+ if (event.ctrlKey && event.key === 'End') {
281
+ event.preventDefault();
282
+ _this.scrollToBottom();
283
+ }
284
+ });
285
+
286
+ // Use ResizeObserver to detect parent container resize
287
+ if (typeof ResizeObserver !== 'undefined') {
288
+ this._resizeObserver = new ResizeObserver(function () {
289
+ return _this._handleContainerResize();
290
+ });
291
+ this._resizeObserver.observe(this._parentElement);
292
+ }
293
+ }
294
+
295
+ // set the onSend function callback.
296
+ }, {
297
+ key: "setCallbackOnSend",
298
+ value: function setCallbackOnSend(callback) {
299
+ this._onSend = callback;
300
+ }
301
+ // set a callback for everytime a message is added (listener)
302
+ }, {
303
+ key: "setCallbackonMessageAdded",
304
+ value: function setCallbackonMessageAdded(callback) {
305
+ this._onMessageAdded = callback;
306
+ }
307
+ }, {
308
+ key: "setCallbackonMessageAppend",
309
+ value: function setCallbackonMessageAppend(callback) {
310
+ this._onMessageAppend = callback;
311
+ }
312
+ }, {
313
+ key: "setCallbackonMessageReplace",
314
+ value: function setCallbackonMessageReplace(callback) {
315
+ this._onMessageReplace = callback;
316
+ }
317
+ }, {
318
+ key: "setCallbackonMessageDelete",
319
+ value: function setCallbackonMessageDelete(callback) {
320
+ this._onMessageDelete = callback;
321
+ }
322
+
323
+ // Public methods
324
+ }, {
325
+ key: "titleAreaToggle",
326
+ value: function titleAreaToggle() {
327
+ if (this._titleArea.style.display === 'none') {
328
+ this.titleAreaShow();
329
+ } else {
330
+ this.titleAreaHide();
331
+ }
332
+ }
333
+ }, {
334
+ key: "titleAreaShow",
335
+ value: function titleAreaShow() {
336
+ this._titleArea.style.display = '';
337
+ }
338
+ }, {
339
+ key: "titleAreaHide",
340
+ value: function titleAreaHide() {
341
+ this._titleArea.style.display = 'none';
342
+ }
343
+ }, {
344
+ key: "titleAreaSetContents",
345
+ value: function titleAreaSetContents(title) {
346
+ var align = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'center';
347
+ this._titleArea.innerHTML = title;
348
+ this._titleArea.style.textAlign = align;
349
+ }
350
+ }, {
351
+ key: "titleAreaGetContents",
352
+ value: function titleAreaGetContents() {
353
+ return this._titleArea.innerHTML;
354
+ }
355
+ }, {
356
+ key: "inputAreaToggle",
357
+ value: function inputAreaToggle() {
358
+ if (this._inputArea.style.display === 'none') {
359
+ this.inputAreaShow();
360
+ } else {
361
+ this.inputAreaHide();
362
+ }
363
+ }
364
+ }, {
365
+ key: "inputAreaShow",
366
+ value: function inputAreaShow() {
367
+ this._inputArea.style.display = '';
368
+ }
369
+ }, {
370
+ key: "inputAreaHide",
371
+ value: function inputAreaHide() {
372
+ this._inputArea.style.display = 'none';
373
+ }
374
+ }, {
375
+ key: "inputAreaSetEnabled",
376
+ value: function inputAreaSetEnabled(enabled) {
377
+ this._textEntry.disabled = !enabled;
378
+ this._sendButton.disabled = !enabled;
379
+ }
380
+ }, {
381
+ key: "inputAreaSetButtonText",
382
+ value: function inputAreaSetButtonText(text) {
383
+ this._sendButton.textContent = text;
384
+ }
385
+ }, {
386
+ key: "inputAreaGetButtonText",
387
+ value: function inputAreaGetButtonText() {
388
+ return this._sendButton.textContent;
389
+ }
390
+ }, {
391
+ key: "setDirection",
392
+ value: function setDirection(dir) {
393
+ var d = dir === 'rtl' ? 'rtl' : 'ltr';
394
+ this._chatWidget.setAttribute('dir', d);
395
+ if (d === 'rtl') {
396
+ this._chatWidget.classList.add('quikchat-rtl');
397
+ } else {
398
+ this._chatWidget.classList.remove('quikchat-rtl');
399
+ }
400
+ }
401
+ }, {
402
+ key: "getDirection",
403
+ value: function getDirection() {
404
+ return this._chatWidget.getAttribute('dir') || 'ltr';
405
+ }
406
+ }, {
407
+ key: "_handleContainerResize",
408
+ value: function _handleContainerResize() {
409
+ // Layout is handled by CSS flexbox — no JS height calculation needed.
410
+ // This hook exists for future use or custom resize callbacks.
411
+ }
412
+ }, {
413
+ key: "scrollToBottom",
414
+ value: function scrollToBottom() {
415
+ this._messagesArea.scrollTop = this._messagesArea.scrollHeight;
416
+ this.userScrolledUp = false;
417
+ this._updateScrollBottomBtn();
418
+ }
419
+ }, {
420
+ key: "_updateScrollBottomBtn",
421
+ value: function _updateScrollBottomBtn() {
422
+ if (this.userScrolledUp) {
423
+ this._scrollBottomBtn.classList.add('quikchat-scroll-bottom-visible');
424
+ } else {
425
+ this._scrollBottomBtn.classList.remove('quikchat-scroll-bottom-visible');
426
+ }
427
+ }
428
+ }, {
429
+ key: "_autoGrowTextarea",
430
+ value: function _autoGrowTextarea() {
431
+ var el = this._textEntry;
432
+ el.style.height = 'auto';
433
+ var maxHeight = parseInt(getComputedStyle(el).getPropertyValue('--quikchat-input-max-height')) || 120;
434
+ el.style.height = Math.min(el.scrollHeight, maxHeight) + 'px';
435
+ el.style.overflowY = el.scrollHeight > maxHeight ? 'auto' : 'hidden';
436
+ }
437
+ }, {
438
+ key: "_formatTimestamp",
439
+ value: function _formatTimestamp(isoString) {
440
+ var d = new Date(isoString);
441
+ var h = d.getHours();
442
+ var m = String(d.getMinutes()).padStart(2, '0');
443
+ var ampm = h >= 12 ? 'PM' : 'AM';
444
+ var h12 = h % 12 || 12;
445
+ return h12 + ':' + m + ' ' + ampm;
446
+ }
447
+ }, {
448
+ key: "messagesAreaShowTimestamps",
449
+ value: function messagesAreaShowTimestamps(show) {
450
+ if (show) {
451
+ this._messagesArea.classList.add('quikchat-show-timestamps');
452
+ } else {
453
+ this._messagesArea.classList.remove('quikchat-show-timestamps');
454
+ }
455
+ }
456
+ }, {
457
+ key: "messagesAreaShowTimestampsGet",
458
+ value: function messagesAreaShowTimestampsGet() {
459
+ return this._messagesArea.classList.contains('quikchat-show-timestamps');
460
+ }
461
+ }, {
462
+ key: "messagesAreaShowTimestampsToggle",
463
+ value: function messagesAreaShowTimestampsToggle() {
464
+ this._messagesArea.classList.toggle('quikchat-show-timestamps');
465
+ }
466
+ }, {
467
+ key: "_escapeHTML",
468
+ value: function _escapeHTML(str) {
469
+ var div = document.createElement('div');
470
+ div.textContent = str;
471
+ return div.innerHTML;
472
+ }
473
+ }, {
474
+ key: "_processContent",
475
+ value: function _processContent(content) {
476
+ if (this._sanitize === true) {
477
+ content = this._escapeHTML(content);
478
+ } else if (typeof this._sanitize === 'function') {
479
+ content = this._sanitize(content);
480
+ }
481
+ if (this._messageFormatter) {
482
+ content = this._messageFormatter(content);
483
+ }
484
+ return content;
485
+ }
486
+
487
+ //messagesArea functions
488
+ }, {
489
+ key: "messagesAreaAlternateColors",
490
+ value: function messagesAreaAlternateColors() {
491
+ var alt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
492
+ if (alt) {
493
+ this._messagesArea.classList.add('quikchat-messages-area-alt');
494
+ } else {
495
+ this._messagesArea.classList.remove('quikchat-messages-area-alt');
496
+ }
497
+ return alt === true;
498
+ }
499
+ }, {
500
+ key: "messagesAreaAlternateColorsToggle",
501
+ value: function messagesAreaAlternateColorsToggle() {
502
+ this._messagesArea.classList.toggle('quikchat-messages-area-alt');
503
+ }
504
+ }, {
505
+ key: "messagesAreaAlternateColorsGet",
506
+ value: function messagesAreaAlternateColorsGet() {
507
+ return this._messagesArea.classList.contains('quikchat-messages-area-alt');
508
+ }
509
+ // message functions
510
+ }, {
511
+ key: "messageAddFull",
512
+ value: function messageAddFull() {
513
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
514
+ content: "",
515
+ userString: "user",
516
+ align: "right",
517
+ role: "user",
518
+ userID: -1
519
+ };
520
+ var msgid = this.msgid;
521
+ var messageDiv = document.createElement('div');
522
+ var msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');
523
+ messageDiv.classList.add('quikchat-message', msgidClass);
524
+ messageDiv.classList.add('quikchat-role-' + (input.role || 'user'));
525
+ messageDiv.classList.add('quikchat-align-' + (input.align || 'right'));
526
+ this.msgid++;
527
+ messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
528
+
529
+ // Visibility: default true, hidden messages get display:none
530
+ var visible = input.visible !== false;
531
+ if (!visible) {
532
+ messageDiv.style.display = 'none';
533
+ }
534
+
535
+ // Tags: array of strings for group-based visibility control
536
+ var tags = Array.isArray(input.tags) ? input.tags.slice() : [];
537
+ var userDiv = document.createElement('div');
538
+ userDiv.classList.add('quikchat-user-label');
539
+ userDiv.style.textAlign = input.align;
540
+ userDiv.innerHTML = input.userString;
541
+ var contentDiv = document.createElement('div');
542
+ contentDiv.classList.add('quikchat-message-content');
543
+ contentDiv.style.textAlign = input.align;
544
+ contentDiv.innerHTML = this._processContent(input.content);
545
+ var timestamp = new Date().toISOString();
546
+ var timestampSpan = document.createElement('span');
547
+ timestampSpan.classList.add('quikchat-timestamp');
548
+ timestampSpan.textContent = this._formatTimestamp(timestamp);
549
+ messageDiv.appendChild(userDiv);
550
+ messageDiv.appendChild(contentDiv);
551
+ messageDiv.appendChild(timestampSpan);
552
+ this._messagesArea.appendChild(messageDiv);
553
+
554
+ // Scroll to the last message only if the user is not actively scrolling up
555
+ if (!this.userScrolledUp) {
556
+ this._messagesArea.scrollTop = this._messagesArea.scrollHeight;
557
+ }
558
+ this._textEntry.value = '';
559
+ this._autoGrowTextarea();
560
+ var updatedtime = timestamp;
561
+ if (this.trackHistory) {
562
+ this._history.push(_objectSpread2(_objectSpread2({
563
+ msgid: msgid
564
+ }, input), {}, {
565
+ visible: visible,
566
+ tags: tags,
567
+ timestamp: timestamp,
568
+ updatedtime: updatedtime,
569
+ messageDiv: messageDiv
570
+ }));
571
+ if (this._history.length > this._historyLimit) {
572
+ this._history.shift();
573
+ }
574
+ }
575
+ if (this._onMessageAdded) {
576
+ this._onMessageAdded(this, msgid);
577
+ }
578
+ return msgid;
579
+ }
580
+ }, {
581
+ key: "messageAddNew",
582
+ value: function messageAddNew() {
583
+ var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
584
+ var userString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "user";
585
+ var align = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "right";
586
+ var role = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "user";
587
+ return this.messageAddFull({
588
+ content: content,
589
+ userString: userString,
590
+ align: align,
591
+ role: role
592
+ });
593
+ }
594
+ }, {
595
+ key: "messageRemove",
596
+ value: function messageRemove(n) {
597
+ var success = false;
598
+ try {
599
+ this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))));
600
+ success = true;
601
+ } catch (_error) {
602
+ // Message ID not found
603
+ }
604
+ if (success) {
605
+ this._history.splice(this._history.findIndex(function (item) {
606
+ return item.msgid === n;
607
+ }), 1);
608
+ if (this._onMessageDelete) {
609
+ this._onMessageDelete(this, n);
610
+ }
611
+ }
612
+ return success;
613
+ }
614
+ /* returns the message html object from the DOM
615
+ */
616
+ }, {
617
+ key: "messageGetDOMObject",
618
+ value: function messageGetDOMObject(n) {
619
+ var msg = null;
620
+ try {
621
+ msg = this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0')));
622
+ } catch (_error) {
623
+ // Message ID not found
624
+ }
625
+ return msg;
626
+ }
627
+ /* returns the message content only
628
+ */
629
+ }, {
630
+ key: "messageGetContent",
631
+ value: function messageGetContent(n) {
632
+ var content = "";
633
+ try {
634
+ content = this._history.filter(function (item) {
635
+ return item.msgid === n;
636
+ })[0].content;
637
+ } catch (_error) {
638
+ // Message ID not found
639
+ }
640
+ return content;
641
+ }
642
+ }, {
643
+ key: "messageSetVisible",
644
+ value: function messageSetVisible(n, visible) {
645
+ var msgEl = this.messageGetDOMObject(n);
646
+ if (!msgEl) return false;
647
+ msgEl.style.display = visible ? '' : 'none';
648
+ var item = this._history.find(function (entry) {
649
+ return entry.msgid === n;
650
+ });
651
+ if (item) item.visible = visible;
652
+ return true;
653
+ }
654
+ }, {
655
+ key: "messageGetVisible",
656
+ value: function messageGetVisible(n) {
657
+ var item = this._history.find(function (entry) {
658
+ return entry.msgid === n;
659
+ });
660
+ return item ? item.visible !== false : false;
661
+ }
662
+ }, {
663
+ key: "messageToggleVisible",
664
+ value: function messageToggleVisible(n) {
665
+ var current = this.messageGetVisible(n);
666
+ return this.messageSetVisible(n, !current);
667
+ }
668
+ }, {
669
+ key: "messageSetVisibleByTag",
670
+ value: function messageSetVisibleByTag(tag, visible) {
671
+ var count = 0;
672
+ var _iterator = _createForOfIteratorHelper(this._history),
673
+ _step;
674
+ try {
675
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
676
+ var item = _step.value;
677
+ if (item.tags && item.tags.includes(tag)) {
678
+ this.messageSetVisible(item.msgid, visible);
679
+ count++;
680
+ }
681
+ }
682
+ } catch (err) {
683
+ _iterator.e(err);
684
+ } finally {
685
+ _iterator.f();
686
+ }
687
+ return count;
688
+ }
689
+ }, {
690
+ key: "messageGetTags",
691
+ value: function messageGetTags(n) {
692
+ var item = this._history.find(function (entry) {
693
+ return entry.msgid === n;
694
+ });
695
+ return item && item.tags ? item.tags.slice() : [];
696
+ }
697
+ }, {
698
+ key: "messageSetTags",
699
+ value: function messageSetTags(n, tags) {
700
+ var item = this._history.find(function (entry) {
701
+ return entry.msgid === n;
702
+ });
703
+ if (!item) return false;
704
+ item.tags = Array.isArray(tags) ? tags.slice() : [];
705
+ return true;
706
+ }
707
+
708
+ /* append message to the message content
709
+ */
710
+ }, {
711
+ key: "messageAppendContent",
712
+ value: function messageAppendContent(n, content) {
713
+ var success = false;
714
+ try {
715
+ var msgEl = this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0')));
716
+ var item = this._history.filter(function (entry) {
717
+ return entry.msgid === n;
718
+ })[0];
719
+ item.content += content;
720
+ item.updatedtime = new Date().toISOString();
721
+ msgEl.querySelector('.quikchat-message-content').innerHTML = this._processContent(item.content);
722
+ msgEl.classList.remove('quikchat-typing');
723
+ success = true;
724
+ if (!this.userScrolledUp) {
725
+ this._messagesArea.scrollTop = this._messagesArea.scrollHeight;
726
+ }
727
+ if (this._onMessageAppend) {
728
+ this._onMessageAppend(this, n, content);
729
+ }
730
+ } catch (_error) {
731
+ // Message ID not found
732
+ }
733
+ return success;
734
+ }
735
+
736
+ /* replace message content
737
+ */
738
+ }, {
739
+ key: "messageReplaceContent",
740
+ value: function messageReplaceContent(n, content) {
741
+ var success = false;
742
+ try {
743
+ var msgEl = this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0')));
744
+ var item = this._history.filter(function (entry) {
745
+ return entry.msgid === n;
746
+ })[0];
747
+ item.content = content;
748
+ item.updatedtime = new Date().toISOString();
749
+ msgEl.querySelector('.quikchat-message-content').innerHTML = this._processContent(content);
750
+ msgEl.classList.remove('quikchat-typing');
751
+ success = true;
752
+ if (!this.userScrolledUp) {
753
+ this._messagesArea.scrollTop = this._messagesArea.scrollHeight;
754
+ }
755
+ if (this._onMessageReplace) {
756
+ this._onMessageReplace(this, n, content);
757
+ }
758
+ } catch (_error) {
759
+ // Message ID not found
760
+ }
761
+ return success;
762
+ }
763
+ }, {
764
+ key: "messageAddTypingIndicator",
765
+ value: function messageAddTypingIndicator() {
766
+ var userString = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
767
+ var align = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'left';
768
+ var msgid = this.messageAddFull({
769
+ content: '',
770
+ userString: userString,
771
+ align: align,
772
+ role: 'assistant'
773
+ });
774
+ var msgEl = this.messageGetDOMObject(msgid);
775
+ msgEl.classList.add('quikchat-typing');
776
+ var contentDiv = msgEl.querySelector('.quikchat-message-content');
777
+ contentDiv.innerHTML = '<span class="quikchat-typing-dots"><span>.</span><span>.</span><span>.</span></span>';
778
+ return msgid;
779
+ }
780
+ }, {
781
+ key: "setMessageFormatter",
782
+ value: function setMessageFormatter(formatter) {
783
+ this._messageFormatter = formatter;
784
+ }
785
+ }, {
786
+ key: "setSanitize",
787
+ value: function setSanitize(sanitize) {
788
+ this._sanitize = sanitize;
789
+ }
790
+
791
+ // history functions
792
+ /**
793
+ *
794
+ * @param {*} n
795
+ * @param {*} m
796
+ * @returns array of history messages
797
+ */
798
+ }, {
799
+ key: "historyGet",
800
+ value: function historyGet(n, m) {
801
+ if (n === undefined) {
802
+ return this._history.slice();
803
+ }
804
+ if (m === undefined) {
805
+ if (n < 0) {
806
+ return this._history.slice(n);
807
+ }
808
+ return this._history.slice(n, n + 1);
809
+ }
810
+ return this._history.slice(n, m);
811
+ }
812
+ }, {
813
+ key: "historyClear",
814
+ value: function historyClear() {
815
+ this.msgid = 0;
816
+ this._history = [];
817
+ }
818
+ }, {
819
+ key: "historyGetLength",
820
+ value: function historyGetLength() {
821
+ return this._history.length;
822
+ }
823
+ }, {
824
+ key: "historyGetMessage",
825
+ value: function historyGetMessage(n) {
826
+ if (n >= 0 && n < this._history.length) {
827
+ return this._history[n];
828
+ }
829
+ return {};
830
+ }
831
+ }, {
832
+ key: "historyGetMessageContent",
833
+ value: function historyGetMessageContent(n) {
834
+ if (n >= 0 && n < this._history.length) {
835
+ return this._history[n].content;
836
+ }
837
+ return "";
838
+ }
839
+ }, {
840
+ key: "historyExport",
841
+ value: function historyExport() {
842
+ return this._history.map(function (item) {
843
+ return {
844
+ msgid: item.msgid,
845
+ content: item.content,
846
+ userString: item.userString,
847
+ align: item.align,
848
+ role: item.role,
849
+ userID: item.userID,
850
+ visible: item.visible,
851
+ tags: item.tags ? item.tags.slice() : [],
852
+ timestamp: item.timestamp,
853
+ updatedtime: item.updatedtime
854
+ };
855
+ });
856
+ }
857
+ }, {
858
+ key: "historyImport",
859
+ value: function historyImport(data) {
860
+ // Clear existing messages from DOM and history
861
+ this._messagesArea.innerHTML = '';
862
+ this._history = [];
863
+ this.msgid = 0;
864
+ var _iterator2 = _createForOfIteratorHelper(data),
865
+ _step2;
866
+ try {
867
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
868
+ var entry = _step2.value;
869
+ this.messageAddFull({
870
+ content: entry.content || '',
871
+ userString: entry.userString || 'user',
872
+ align: entry.align || 'right',
873
+ role: entry.role || 'user',
874
+ userID: entry.userID,
875
+ visible: entry.visible,
876
+ tags: entry.tags
877
+ });
878
+ }
879
+ } catch (err) {
880
+ _iterator2.e(err);
881
+ } finally {
882
+ _iterator2.f();
883
+ }
884
+ }
885
+ }, {
886
+ key: "changeTheme",
887
+ value: function changeTheme(newTheme) {
888
+ this._chatWidget.classList.remove(this._theme);
889
+ this._chatWidget.classList.add(newTheme);
890
+ this._theme = newTheme;
891
+ }
892
+ }, {
893
+ key: "theme",
894
+ get: function get() {
895
+ return this._theme;
896
+ }
897
+ }], [{
898
+ key: "version",
899
+ value: function version() {
900
+ return {
901
+ "version": "1.2.4",
902
+ "license": "BSD-2",
903
+ "url": "https://github/deftio/quikchat"
904
+ };
905
+ }
906
+
907
+ /**
908
+ * quikchat.loremIpsum() - Generate a simple string of Lorem Ipsum text (sample typographer's text) of numChars in length.
909
+ * borrowed from github.com/deftio/bitwrench.js
910
+ * @param {number} numChars - The number of characters to generate (random btw 25 and 150 if undefined).
911
+ * @param {number} [startSpot=0] - The starting index in the Lorem Ipsum text. If undefined, a random startSpot will be generated.
912
+ * @param {boolean} [startWithCapitalLetter=true] - If true, capitalize the first character or inject a capital letter if the first character isn't a capital letter.
913
+ *
914
+ * @returns {string} A string of Lorem Ipsum text.
915
+ *
916
+ * @example
917
+ * // Returns 200 characters of Lorem Ipsum starting from index 50
918
+ * loremIpsum(200, 50);
919
+ *
920
+ * @example
921
+ * //Returns a 200 Lorem Ipsum characters starting from a random index
922
+ * loremIpsum(200);
923
+ */
924
+ }, {
925
+ key: "loremIpsum",
926
+ value: function loremIpsum(numChars) {
927
+ var startSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
928
+ var startWithCapitalLetter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
929
+ var loremText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ";
930
+ if (typeof numChars !== "number") {
931
+ numChars = Math.floor(Math.random() * 126) + 25;
932
+ }
933
+ if (startSpot === undefined) {
934
+ startSpot = Math.floor(Math.random() * loremText.length);
935
+ }
936
+ startSpot = startSpot % loremText.length;
937
+
938
+ // Move startSpot to the next non-whitespace and non-punctuation character
939
+ while (loremText[startSpot] === ' ' || /[.,:;!?]/.test(loremText[startSpot])) {
940
+ startSpot = (startSpot + 1) % loremText.length;
941
+ }
942
+ var l = loremText.substring(startSpot) + loremText.substring(0, startSpot);
943
+ var s = "";
944
+ while (numChars > 0) {
945
+ s += numChars < l.length ? l.substring(0, numChars) : l;
946
+ numChars -= l.length;
947
+ }
948
+ if (s[s.length - 1] === " ") {
949
+ s = s.substring(0, s.length - 1) + "."; // always end on non-whitespace. "." was chosen arbitrarily.
950
+ }
951
+ if (startWithCapitalLetter) {
952
+ s = s[0].toUpperCase() + s.substring(1);
953
+ }
954
+ return s;
955
+ }
956
+ }]);
957
+ }();
958
+
959
+ /**
960
+ * quikdown - Lightweight Markdown Parser
961
+ * @version 1.1.1
962
+ * @license BSD-2-Clause
963
+ * @copyright DeftIO 2025
964
+ */
965
+ /**
966
+ * quikdown - A minimal markdown parser optimized for chat/LLM output
967
+ * Supports tables, code blocks, lists, and common formatting
968
+ * @param {string} markdown - The markdown source text
969
+ * @param {Object} options - Optional configuration object
970
+ * @param {Function} options.fence_plugin - Custom renderer for fenced code blocks
971
+ * (content, fence_string) => html string
972
+ * @param {boolean} options.inline_styles - If true, uses inline styles instead of classes
973
+ * @param {boolean} options.bidirectional - If true, adds data-qd attributes for source tracking
974
+ * @param {boolean} options.lazy_linefeeds - If true, single newlines become <br> tags
975
+ * @returns {string} - The rendered HTML
976
+ */
977
+
978
+ // Version will be injected at build time
979
+ const quikdownVersion = '1.1.1';
980
+
981
+ // Constants for reuse
982
+ const CLASS_PREFIX = 'quikdown-';
983
+ const PLACEHOLDER_CB = '§CB';
984
+ const PLACEHOLDER_IC = '§IC';
985
+
986
+ // Escape map at module level
987
+ const ESC_MAP = {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'};
988
+
989
+ // Single source of truth for all style definitions - optimized
990
+ const QUIKDOWN_STYLES = {
991
+ h1: 'font-size:2em;font-weight:600;margin:.67em 0;text-align:left',
992
+ h2: 'font-size:1.5em;font-weight:600;margin:.83em 0',
993
+ h3: 'font-size:1.25em;font-weight:600;margin:1em 0',
994
+ h4: 'font-size:1em;font-weight:600;margin:1.33em 0',
995
+ h5: 'font-size:.875em;font-weight:600;margin:1.67em 0',
996
+ h6: 'font-size:.85em;font-weight:600;margin:2em 0',
997
+ pre: 'background:#f4f4f4;padding:10px;border-radius:4px;overflow-x:auto;margin:1em 0',
998
+ code: 'background:#f0f0f0;padding:2px 4px;border-radius:3px;font-family:monospace',
999
+ blockquote: 'border-left:4px solid #ddd;margin-left:0;padding-left:1em',
1000
+ table: 'border-collapse:collapse;width:100%;margin:1em 0',
1001
+ th: 'border:1px solid #ddd;padding:8px;background-color:#f2f2f2;font-weight:bold;text-align:left',
1002
+ td: 'border:1px solid #ddd;padding:8px;text-align:left',
1003
+ hr: 'border:none;border-top:1px solid #ddd;margin:1em 0',
1004
+ img: 'max-width:100%;height:auto',
1005
+ a: 'color:#06c;text-decoration:underline',
1006
+ strong: 'font-weight:bold',
1007
+ em: 'font-style:italic',
1008
+ del: 'text-decoration:line-through',
1009
+ ul: 'margin:.5em 0;padding-left:2em',
1010
+ ol: 'margin:.5em 0;padding-left:2em',
1011
+ li: 'margin:.25em 0',
1012
+ // Task list specific styles
1013
+ 'task-item': 'list-style:none',
1014
+ 'task-checkbox': 'margin-right:.5em'
1015
+ };
1016
+
1017
+ // Factory function to create getAttr for a given context
1018
+ function createGetAttr(inline_styles, styles) {
1019
+ return function(tag, additionalStyle = '') {
1020
+ if (inline_styles) {
1021
+ let style = styles[tag];
1022
+ if (!style && !additionalStyle) return '';
1023
+
1024
+ // Remove default text-align if we're adding a different alignment
1025
+ if (additionalStyle && additionalStyle.includes('text-align') && style && style.includes('text-align')) {
1026
+ style = style.replace(/text-align:[^;]+;?/, '').trim();
1027
+ if (style && !style.endsWith(';')) style += ';';
1028
+ }
1029
+
1030
+ /* istanbul ignore next - defensive: additionalStyle without style doesn't occur with current tags */
1031
+ const fullStyle = additionalStyle ? (style ? `${style}${additionalStyle}` : additionalStyle) : style;
1032
+ return ` style="${fullStyle}"`;
1033
+ } else {
1034
+ const classAttr = ` class="${CLASS_PREFIX}${tag}"`;
1035
+ // Apply inline styles for alignment even when using CSS classes
1036
+ if (additionalStyle) {
1037
+ return `${classAttr} style="${additionalStyle}"`;
1038
+ }
1039
+ return classAttr;
1040
+ }
1041
+ };
1042
+ }
1043
+
1044
+ function quikdown(markdown, options = {}) {
1045
+ if (!markdown || typeof markdown !== 'string') {
1046
+ return '';
1047
+ }
1048
+
1049
+ const { fence_plugin, inline_styles = false, bidirectional = false, lazy_linefeeds = false } = options;
1050
+ const styles = QUIKDOWN_STYLES; // Use module-level styles
1051
+ const getAttr = createGetAttr(inline_styles, styles); // Create getAttr once
1052
+
1053
+ // Escape HTML entities to prevent XSS
1054
+ function escapeHtml(text) {
1055
+ return text.replace(/[&<>"']/g, m => ESC_MAP[m]);
1056
+ }
1057
+
1058
+ // Helper to add data-qd attributes for bidirectional support
1059
+ const dataQd = bidirectional ? (marker) => ` data-qd="${escapeHtml(marker)}"` : () => '';
1060
+
1061
+ // Sanitize URLs to prevent XSS attacks
1062
+ function sanitizeUrl(url, allowUnsafe = false) {
1063
+ /* istanbul ignore next - defensive programming, regex ensures url is never empty */
1064
+ if (!url) return '';
1065
+
1066
+ // If unsafe URLs are explicitly allowed, return as-is
1067
+ if (allowUnsafe) return url;
1068
+
1069
+ const trimmedUrl = url.trim();
1070
+ const lowerUrl = trimmedUrl.toLowerCase();
1071
+
1072
+ // Block dangerous protocols
1073
+ const dangerousProtocols = ['javascript:', 'vbscript:', 'data:'];
1074
+
1075
+ for (const protocol of dangerousProtocols) {
1076
+ if (lowerUrl.startsWith(protocol)) {
1077
+ // Exception: Allow data:image/* for images
1078
+ if (protocol === 'data:' && lowerUrl.startsWith('data:image/')) {
1079
+ return trimmedUrl;
1080
+ }
1081
+ // Return safe empty link for dangerous protocols
1082
+ return '#';
1083
+ }
1084
+ }
1085
+
1086
+ return trimmedUrl;
1087
+ }
1088
+
1089
+ // Process the markdown in phases
1090
+ let html = markdown;
1091
+
1092
+ // Phase 1: Extract and protect code blocks and inline code
1093
+ const codeBlocks = [];
1094
+ const inlineCodes = [];
1095
+
1096
+ // Extract fenced code blocks first (supports both ``` and ~~~)
1097
+ // Match paired fences - ``` with ``` and ~~~ with ~~~
1098
+ // Fence must be at start of line
1099
+ html = html.replace(/^(```|~~~)([^\n]*)\n([\s\S]*?)^\1$/gm, (match, fence, lang, code) => {
1100
+ const placeholder = `${PLACEHOLDER_CB}${codeBlocks.length}§`;
1101
+
1102
+ // Trim the language specification
1103
+ const langTrimmed = lang ? lang.trim() : '';
1104
+
1105
+ // If custom fence plugin is provided, use it (v1.1.0: object format required)
1106
+ if (fence_plugin && fence_plugin.render && typeof fence_plugin.render === 'function') {
1107
+ codeBlocks.push({
1108
+ lang: langTrimmed,
1109
+ code: code.trimEnd(),
1110
+ custom: true,
1111
+ fence: fence,
1112
+ hasReverse: !!fence_plugin.reverse
1113
+ });
1114
+ } else {
1115
+ codeBlocks.push({
1116
+ lang: langTrimmed,
1117
+ code: escapeHtml(code.trimEnd()),
1118
+ custom: false,
1119
+ fence: fence
1120
+ });
1121
+ }
1122
+ return placeholder;
1123
+ });
1124
+
1125
+ // Extract inline code
1126
+ html = html.replace(/`([^`]+)`/g, (match, code) => {
1127
+ const placeholder = `${PLACEHOLDER_IC}${inlineCodes.length}§`;
1128
+ inlineCodes.push(escapeHtml(code));
1129
+ return placeholder;
1130
+ });
1131
+
1132
+ // Now escape HTML in the rest of the content
1133
+ html = escapeHtml(html);
1134
+
1135
+ // Phase 2: Process block elements
1136
+
1137
+ // Process tables
1138
+ html = processTable(html, getAttr);
1139
+
1140
+ // Process headings (supports optional trailing #'s)
1141
+ html = html.replace(/^(#{1,6})\s+(.+?)\s*#*$/gm, (match, hashes, content) => {
1142
+ const level = hashes.length;
1143
+ return `<h${level}${getAttr('h' + level)}${dataQd(hashes)}>${content}</h${level}>`;
1144
+ });
1145
+
1146
+ // Process blockquotes (must handle escaped > since we already escaped HTML)
1147
+ html = html.replace(/^&gt;\s+(.+)$/gm, `<blockquote${getAttr('blockquote')}>$1</blockquote>`);
1148
+ // Merge consecutive blockquotes
1149
+ html = html.replace(/<\/blockquote>\n<blockquote>/g, '\n');
1150
+
1151
+ // Process horizontal rules (allow trailing spaces)
1152
+ html = html.replace(/^---+\s*$/gm, `<hr${getAttr('hr')}>`);
1153
+
1154
+ // Process lists
1155
+ html = processLists(html, getAttr, inline_styles, bidirectional);
1156
+
1157
+ // Phase 3: Process inline elements
1158
+
1159
+ // Images (must come before links, with URL sanitization)
1160
+ html = html.replace(/!\[([^\]]*)\]\(([^)]+)\)/g, (match, alt, src) => {
1161
+ const sanitizedSrc = sanitizeUrl(src, options.allow_unsafe_urls);
1162
+ const altAttr = bidirectional && alt ? ` data-qd-alt="${escapeHtml(alt)}"` : '';
1163
+ const srcAttr = bidirectional ? ` data-qd-src="${escapeHtml(src)}"` : '';
1164
+ return `<img${getAttr('img')} src="${sanitizedSrc}" alt="${alt}"${altAttr}${srcAttr}${dataQd('!')}>`;
1165
+ });
1166
+
1167
+ // Links (with URL sanitization)
1168
+ html = html.replace(/\[([^\]]+)\]\(([^)]+)\)/g, (match, text, href) => {
1169
+ // Sanitize URL to prevent XSS
1170
+ const sanitizedHref = sanitizeUrl(href, options.allow_unsafe_urls);
1171
+ const isExternal = /^https?:\/\//i.test(sanitizedHref);
1172
+ const rel = isExternal ? ' rel="noopener noreferrer"' : '';
1173
+ const textAttr = bidirectional ? ` data-qd-text="${escapeHtml(text)}"` : '';
1174
+ return `<a${getAttr('a')} href="${sanitizedHref}"${rel}${textAttr}${dataQd('[')}>${text}</a>`;
1175
+ });
1176
+
1177
+ // Autolinks - convert bare URLs to clickable links
1178
+ html = html.replace(/(^|\s)(https?:\/\/[^\s<]+)/g, (match, prefix, url) => {
1179
+ const sanitizedUrl = sanitizeUrl(url, options.allow_unsafe_urls);
1180
+ return `${prefix}<a${getAttr('a')} href="${sanitizedUrl}" rel="noopener noreferrer">${url}</a>`;
1181
+ });
1182
+
1183
+ // Process inline formatting (bold, italic, strikethrough)
1184
+ const inlinePatterns = [
1185
+ [/\*\*(.+?)\*\*/g, 'strong', '**'],
1186
+ [/__(.+?)__/g, 'strong', '__'],
1187
+ [/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, 'em', '*'],
1188
+ [/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, 'em', '_'],
1189
+ [/~~(.+?)~~/g, 'del', '~~']
1190
+ ];
1191
+
1192
+ inlinePatterns.forEach(([pattern, tag, marker]) => {
1193
+ html = html.replace(pattern, `<${tag}${getAttr(tag)}${dataQd(marker)}>$1</${tag}>`);
1194
+ });
1195
+
1196
+ // Line breaks
1197
+ if (lazy_linefeeds) {
1198
+ // Lazy linefeeds: single newline becomes <br> (except between paragraphs and after/before block elements)
1199
+ const blocks = [];
1200
+ let bi = 0;
1201
+
1202
+ // Protect tables and lists
1203
+ html = html.replace(/<(table|[uo]l)[^>]*>[\s\S]*?<\/\1>/g, m => {
1204
+ blocks[bi] = m;
1205
+ return `§B${bi++}§`;
1206
+ });
1207
+
1208
+ // Handle paragraphs and block elements
1209
+ html = html.replace(/\n\n+/g, '§P§')
1210
+ // After block elements
1211
+ .replace(/(<\/(?:h[1-6]|blockquote|pre)>)\n/g, '$1§N§')
1212
+ .replace(/(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)\n/g, '$1§N§')
1213
+ // Before block elements
1214
+ .replace(/\n(<(?:h[1-6]|blockquote|pre|hr)[^>]*>)/g, '§N§$1')
1215
+ .replace(/\n(§B\d+§)/g, '§N§$1')
1216
+ .replace(/(§B\d+§)\n/g, '$1§N§')
1217
+ // Convert remaining newlines
1218
+ .replace(/\n/g, `<br${getAttr('br')}>`)
1219
+ // Restore
1220
+ .replace(/§N§/g, '\n')
1221
+ .replace(/§P§/g, '</p><p>');
1222
+
1223
+ // Restore protected blocks
1224
+ blocks.forEach((b, i) => html = html.replace(`§B${i}§`, b));
1225
+
1226
+ html = '<p>' + html + '</p>';
1227
+ } else {
1228
+ // Standard: two spaces at end of line for line breaks
1229
+ html = html.replace(/ $/gm, `<br${getAttr('br')}>`);
1230
+
1231
+ // Paragraphs (double newlines)
1232
+ // Don't add </p> after block elements (they're not in paragraphs)
1233
+ html = html.replace(/\n\n+/g, (match, offset) => {
1234
+ // Check if we're after a block element closing tag
1235
+ const before = html.substring(0, offset);
1236
+ if (before.match(/<\/(h[1-6]|blockquote|ul|ol|table|pre|hr)>$/)) {
1237
+ return '<p>'; // Just open a new paragraph
1238
+ }
1239
+ return '</p><p>'; // Normal paragraph break
1240
+ });
1241
+ html = '<p>' + html + '</p>';
1242
+ }
1243
+
1244
+ // Clean up empty paragraphs and unwrap block elements
1245
+ const cleanupPatterns = [
1246
+ [/<p><\/p>/g, ''],
1247
+ [/<p>(<h[1-6][^>]*>)/g, '$1'],
1248
+ [/(<\/h[1-6]>)<\/p>/g, '$1'],
1249
+ [/<p>(<blockquote[^>]*>)/g, '$1'],
1250
+ [/(<\/blockquote>)<\/p>/g, '$1'],
1251
+ [/<p>(<ul[^>]*>|<ol[^>]*>)/g, '$1'],
1252
+ [/(<\/ul>|<\/ol>)<\/p>/g, '$1'],
1253
+ [/<p>(<hr[^>]*>)<\/p>/g, '$1'],
1254
+ [/<p>(<table[^>]*>)/g, '$1'],
1255
+ [/(<\/table>)<\/p>/g, '$1'],
1256
+ [/<p>(<pre[^>]*>)/g, '$1'],
1257
+ [/(<\/pre>)<\/p>/g, '$1'],
1258
+ [new RegExp(`<p>(${PLACEHOLDER_CB}\\d+§)<\/p>`, 'g'), '$1']
1259
+ ];
1260
+
1261
+ cleanupPatterns.forEach(([pattern, replacement]) => {
1262
+ html = html.replace(pattern, replacement);
1263
+ });
1264
+
1265
+ // Fix orphaned closing </p> tags after block elements
1266
+ // When a paragraph follows a block element, ensure it has opening <p>
1267
+ html = html.replace(/(<\/(?:h[1-6]|blockquote|ul|ol|table|pre|hr)>)\n([^<])/g, '$1\n<p>$2');
1268
+
1269
+ // Phase 4: Restore code blocks and inline code
1270
+
1271
+ // Restore code blocks
1272
+ codeBlocks.forEach((block, i) => {
1273
+ let replacement;
1274
+
1275
+ if (block.custom && fence_plugin && fence_plugin.render) {
1276
+ // Use custom fence plugin (v1.1.0: object format with render function)
1277
+ replacement = fence_plugin.render(block.code, block.lang);
1278
+
1279
+ // If plugin returns undefined, fall back to default rendering
1280
+ if (replacement === undefined) {
1281
+ const langClass = !inline_styles && block.lang ? ` class="language-${block.lang}"` : '';
1282
+ const codeAttr = inline_styles ? getAttr('code') : langClass;
1283
+ const langAttr = bidirectional && block.lang ? ` data-qd-lang="${escapeHtml(block.lang)}"` : '';
1284
+ const fenceAttr = bidirectional ? ` data-qd-fence="${escapeHtml(block.fence)}"` : '';
1285
+ replacement = `<pre${getAttr('pre')}${fenceAttr}${langAttr}><code${codeAttr}>${escapeHtml(block.code)}</code></pre>`;
1286
+ } else if (bidirectional) {
1287
+ // If bidirectional and plugin provided HTML, add data attributes for roundtrip
1288
+ replacement = replacement.replace(/^<(\w+)/,
1289
+ `<$1 data-qd-fence="${escapeHtml(block.fence)}" data-qd-lang="${escapeHtml(block.lang)}" data-qd-source="${escapeHtml(block.code)}"`);
1290
+ }
1291
+ } else {
1292
+ // Default rendering
1293
+ const langClass = !inline_styles && block.lang ? ` class="language-${block.lang}"` : '';
1294
+ const codeAttr = inline_styles ? getAttr('code') : langClass;
1295
+ const langAttr = bidirectional && block.lang ? ` data-qd-lang="${escapeHtml(block.lang)}"` : '';
1296
+ const fenceAttr = bidirectional ? ` data-qd-fence="${escapeHtml(block.fence)}"` : '';
1297
+ replacement = `<pre${getAttr('pre')}${fenceAttr}${langAttr}><code${codeAttr}>${block.code}</code></pre>`;
1298
+ }
1299
+
1300
+ const placeholder = `${PLACEHOLDER_CB}${i}§`;
1301
+ html = html.replace(placeholder, replacement);
1302
+ });
1303
+
1304
+ // Restore inline code
1305
+ inlineCodes.forEach((code, i) => {
1306
+ const placeholder = `${PLACEHOLDER_IC}${i}§`;
1307
+ html = html.replace(placeholder, `<code${getAttr('code')}${dataQd('`')}>${code}</code>`);
1308
+ });
1309
+
1310
+ return html.trim();
1311
+ }
1312
+
1313
+ /**
1314
+ * Process inline markdown formatting
1315
+ */
1316
+ function processInlineMarkdown(text, getAttr) {
1317
+
1318
+ // Process inline formatting patterns
1319
+ const patterns = [
1320
+ [/\*\*(.+?)\*\*/g, 'strong'],
1321
+ [/__(.+?)__/g, 'strong'],
1322
+ [/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g, 'em'],
1323
+ [/(?<!_)_(?!_)(.+?)(?<!_)_(?!_)/g, 'em'],
1324
+ [/~~(.+?)~~/g, 'del'],
1325
+ [/`([^`]+)`/g, 'code']
1326
+ ];
1327
+
1328
+ patterns.forEach(([pattern, tag]) => {
1329
+ text = text.replace(pattern, `<${tag}${getAttr(tag)}>$1</${tag}>`);
1330
+ });
1331
+
1332
+ return text;
1333
+ }
1334
+
1335
+ /**
1336
+ * Process markdown tables
1337
+ */
1338
+ function processTable(text, getAttr) {
1339
+ const lines = text.split('\n');
1340
+ const result = [];
1341
+ let inTable = false;
1342
+ let tableLines = [];
1343
+
1344
+ for (let i = 0; i < lines.length; i++) {
1345
+ const line = lines[i].trim();
1346
+
1347
+ // Check if this line looks like a table row (with or without trailing |)
1348
+ if (line.includes('|') && (line.startsWith('|') || /[^\\|]/.test(line))) {
1349
+ if (!inTable) {
1350
+ inTable = true;
1351
+ tableLines = [];
1352
+ }
1353
+ tableLines.push(line);
1354
+ } else {
1355
+ // Not a table line
1356
+ if (inTable) {
1357
+ // Process the accumulated table
1358
+ const tableHtml = buildTable(tableLines, getAttr);
1359
+ if (tableHtml) {
1360
+ result.push(tableHtml);
1361
+ } else {
1362
+ // Not a valid table, restore original lines
1363
+ result.push(...tableLines);
1364
+ }
1365
+ inTable = false;
1366
+ tableLines = [];
1367
+ }
1368
+ result.push(lines[i]);
1369
+ }
1370
+ }
1371
+
1372
+ // Handle table at end of text
1373
+ if (inTable && tableLines.length > 0) {
1374
+ const tableHtml = buildTable(tableLines, getAttr);
1375
+ if (tableHtml) {
1376
+ result.push(tableHtml);
1377
+ } else {
1378
+ result.push(...tableLines);
1379
+ }
1380
+ }
1381
+
1382
+ return result.join('\n');
1383
+ }
1384
+
1385
+ /**
1386
+ * Build an HTML table from markdown table lines
1387
+ */
1388
+ function buildTable(lines, getAttr) {
1389
+
1390
+ if (lines.length < 2) return null;
1391
+
1392
+ // Check for separator line (second line should be the separator)
1393
+ let separatorIndex = -1;
1394
+ for (let i = 1; i < lines.length; i++) {
1395
+ // Support separator with or without leading/trailing pipes
1396
+ if (/^\|?[\s\-:|]+\|?$/.test(lines[i]) && lines[i].includes('-')) {
1397
+ separatorIndex = i;
1398
+ break;
1399
+ }
1400
+ }
1401
+
1402
+ if (separatorIndex === -1) return null;
1403
+
1404
+ const headerLines = lines.slice(0, separatorIndex);
1405
+ const bodyLines = lines.slice(separatorIndex + 1);
1406
+
1407
+ // Parse alignment from separator
1408
+ const separator = lines[separatorIndex];
1409
+ // Handle pipes at start/end or not
1410
+ const separatorCells = separator.trim().replace(/^\|/, '').replace(/\|$/, '').split('|');
1411
+ const alignments = separatorCells.map(cell => {
1412
+ const trimmed = cell.trim();
1413
+ if (trimmed.startsWith(':') && trimmed.endsWith(':')) return 'center';
1414
+ if (trimmed.endsWith(':')) return 'right';
1415
+ return 'left';
1416
+ });
1417
+
1418
+ let html = `<table${getAttr('table')}>\n`;
1419
+
1420
+ // Build header
1421
+ // Note: headerLines will always have length > 0 since separatorIndex starts from 1
1422
+ html += `<thead${getAttr('thead')}>\n`;
1423
+ headerLines.forEach(line => {
1424
+ html += `<tr${getAttr('tr')}>\n`;
1425
+ // Handle pipes at start/end or not
1426
+ const cells = line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|');
1427
+ cells.forEach((cell, i) => {
1428
+ const alignStyle = alignments[i] && alignments[i] !== 'left' ? `text-align:${alignments[i]}` : '';
1429
+ const processedCell = processInlineMarkdown(cell.trim(), getAttr);
1430
+ html += `<th${getAttr('th', alignStyle)}>${processedCell}</th>\n`;
1431
+ });
1432
+ html += '</tr>\n';
1433
+ });
1434
+ html += '</thead>\n';
1435
+
1436
+ // Build body
1437
+ if (bodyLines.length > 0) {
1438
+ html += `<tbody${getAttr('tbody')}>\n`;
1439
+ bodyLines.forEach(line => {
1440
+ html += `<tr${getAttr('tr')}>\n`;
1441
+ // Handle pipes at start/end or not
1442
+ const cells = line.trim().replace(/^\|/, '').replace(/\|$/, '').split('|');
1443
+ cells.forEach((cell, i) => {
1444
+ const alignStyle = alignments[i] && alignments[i] !== 'left' ? `text-align:${alignments[i]}` : '';
1445
+ const processedCell = processInlineMarkdown(cell.trim(), getAttr);
1446
+ html += `<td${getAttr('td', alignStyle)}>${processedCell}</td>\n`;
1447
+ });
1448
+ html += '</tr>\n';
1449
+ });
1450
+ html += '</tbody>\n';
1451
+ }
1452
+
1453
+ html += '</table>';
1454
+ return html;
1455
+ }
1456
+
1457
+ /**
1458
+ * Process markdown lists (ordered and unordered)
1459
+ */
1460
+ function processLists(text, getAttr, inline_styles, bidirectional) {
1461
+
1462
+ const lines = text.split('\n');
1463
+ const result = [];
1464
+ let listStack = []; // Track nested lists
1465
+
1466
+ // Helper to escape HTML for data-qd attributes
1467
+ const escapeHtml = (text) => text.replace(/[&<>"']/g, m => ({'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'})[m]);
1468
+ const dataQd = bidirectional ? (marker) => ` data-qd="${escapeHtml(marker)}"` : () => '';
1469
+
1470
+ for (let i = 0; i < lines.length; i++) {
1471
+ const line = lines[i];
1472
+ const match = line.match(/^(\s*)([*\-+]|\d+\.)\s+(.+)$/);
1473
+
1474
+ if (match) {
1475
+ const [, indent, marker, content] = match;
1476
+ const level = Math.floor(indent.length / 2);
1477
+ const isOrdered = /^\d+\./.test(marker);
1478
+ const listType = isOrdered ? 'ol' : 'ul';
1479
+
1480
+ // Check for task list items
1481
+ let listItemContent = content;
1482
+ let taskListClass = '';
1483
+ const taskMatch = content.match(/^\[([x ])\]\s+(.*)$/i);
1484
+ if (taskMatch && !isOrdered) {
1485
+ const [, checked, taskContent] = taskMatch;
1486
+ const isChecked = checked.toLowerCase() === 'x';
1487
+ const checkboxAttr = inline_styles
1488
+ ? ' style="margin-right:.5em"'
1489
+ : ` class="${CLASS_PREFIX}task-checkbox"`;
1490
+ listItemContent = `<input type="checkbox"${checkboxAttr}${isChecked ? ' checked' : ''} disabled> ${taskContent}`;
1491
+ taskListClass = inline_styles ? ' style="list-style:none"' : ` class="${CLASS_PREFIX}task-item"`;
1492
+ }
1493
+
1494
+ // Close deeper levels
1495
+ while (listStack.length > level + 1) {
1496
+ const list = listStack.pop();
1497
+ result.push(`</${list.type}>`);
1498
+ }
1499
+
1500
+ // Open new level if needed
1501
+ if (listStack.length === level) {
1502
+ // Need to open a new list
1503
+ listStack.push({ type: listType, level });
1504
+ result.push(`<${listType}${getAttr(listType)}>`);
1505
+ } else if (listStack.length === level + 1) {
1506
+ // Check if we need to switch list type
1507
+ const currentList = listStack[listStack.length - 1];
1508
+ if (currentList.type !== listType) {
1509
+ result.push(`</${currentList.type}>`);
1510
+ listStack.pop();
1511
+ listStack.push({ type: listType, level });
1512
+ result.push(`<${listType}${getAttr(listType)}>`);
1513
+ }
1514
+ }
1515
+
1516
+ const liAttr = taskListClass || getAttr('li');
1517
+ result.push(`<li${liAttr}${dataQd(marker)}>${listItemContent}</li>`);
1518
+ } else {
1519
+ // Not a list item, close all lists
1520
+ while (listStack.length > 0) {
1521
+ const list = listStack.pop();
1522
+ result.push(`</${list.type}>`);
1523
+ }
1524
+ result.push(line);
1525
+ }
1526
+ }
1527
+
1528
+ // Close any remaining lists
1529
+ while (listStack.length > 0) {
1530
+ const list = listStack.pop();
1531
+ result.push(`</${list.type}>`);
1532
+ }
1533
+
1534
+ return result.join('\n');
1535
+ }
1536
+
1537
+ /**
1538
+ * Emit CSS styles for quikdown elements
1539
+ * @param {string} prefix - Optional class prefix (default: 'quikdown-')
1540
+ * @param {string} theme - Optional theme: 'light' (default) or 'dark'
1541
+ * @returns {string} CSS string with quikdown styles
1542
+ */
1543
+ quikdown.emitStyles = function(prefix = 'quikdown-', theme = 'light') {
1544
+ const styles = QUIKDOWN_STYLES;
1545
+
1546
+ // Define theme color overrides
1547
+ const themeOverrides = {
1548
+ dark: {
1549
+ '#f4f4f4': '#2a2a2a', // pre background
1550
+ '#f0f0f0': '#2a2a2a', // code background
1551
+ '#f2f2f2': '#2a2a2a', // th background
1552
+ '#ddd': '#3a3a3a', // borders
1553
+ '#06c': '#6db3f2', // links
1554
+ _textColor: '#e0e0e0'
1555
+ },
1556
+ light: {
1557
+ _textColor: '#333' // Explicit text color for light theme
1558
+ }
1559
+ };
1560
+
1561
+ let css = '';
1562
+ for (const [tag, style] of Object.entries(styles)) {
1563
+ let themedStyle = style;
1564
+
1565
+ // Apply theme overrides if dark theme
1566
+ if (theme === 'dark' && themeOverrides.dark) {
1567
+ // Replace colors
1568
+ for (const [oldColor, newColor] of Object.entries(themeOverrides.dark)) {
1569
+ if (!oldColor.startsWith('_')) {
1570
+ themedStyle = themedStyle.replace(new RegExp(oldColor, 'g'), newColor);
1571
+ }
1572
+ }
1573
+
1574
+ // Add text color for certain elements in dark theme
1575
+ const needsTextColor = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'td', 'li', 'blockquote'];
1576
+ if (needsTextColor.includes(tag)) {
1577
+ themedStyle += `;color:${themeOverrides.dark._textColor}`;
1578
+ }
1579
+ } else if (theme === 'light' && themeOverrides.light) {
1580
+ // Add explicit text color for light theme elements too
1581
+ const needsTextColor = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'td', 'li', 'blockquote'];
1582
+ if (needsTextColor.includes(tag)) {
1583
+ themedStyle += `;color:${themeOverrides.light._textColor}`;
1584
+ }
1585
+ }
1586
+
1587
+ css += `.${prefix}${tag} { ${themedStyle} }\n`;
1588
+ }
1589
+
1590
+ return css;
1591
+ };
1592
+
1593
+ /**
1594
+ * Configure quikdown with options and return a function
1595
+ * @param {Object} options - Configuration options
1596
+ * @returns {Function} Configured quikdown function
1597
+ */
1598
+ quikdown.configure = function(options) {
1599
+ return function(markdown) {
1600
+ return quikdown(markdown, options);
1601
+ };
1602
+ };
1603
+
1604
+ /**
1605
+ * Version information
1606
+ */
1607
+ quikdown.version = quikdownVersion;
1608
+
1609
+ // Export for both CommonJS and ES6
1610
+ /* istanbul ignore next */
1611
+ if (typeof module !== 'undefined' && module.exports) {
1612
+ module.exports = quikdown;
1613
+ }
1614
+
1615
+ // For browser global
1616
+ /* istanbul ignore next */
1617
+ if (typeof window !== 'undefined') {
1618
+ window.quikdown = quikdown;
1619
+ }
1620
+
1621
+ // Subclass that pre-wires quikdown as the message formatter
1622
+ var quikchatMD = /*#__PURE__*/function (_quikchat) {
1623
+ function quikchatMD(parentElement, onSend) {
1624
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1625
+ _classCallCheck(this, quikchatMD);
1626
+ if (!options.messageFormatter) {
1627
+ options.messageFormatter = function (content) {
1628
+ return quikdown(content);
1629
+ };
1630
+ }
1631
+ return _callSuper(this, quikchatMD, [parentElement, onSend, options]);
1632
+ }
1633
+ _inherits(quikchatMD, _quikchat);
1634
+ return _createClass(quikchatMD);
1635
+ }(quikchat); // Expose quikdown on the class for direct access
1636
+ quikchatMD.quikdown = quikdown;
1637
+
1638
+ export { quikchatMD as default };
1639
+ //# sourceMappingURL=quikchat-md.esm.js.map