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