@aktarulrahul/floater-chatbot 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,1898 @@
1
+ 'use strict';
2
+
3
+ var require$$0 = require('react');
4
+ var axios = require('axios');
5
+ require('./components/ChatWidget.css');
6
+ require('./components/SupportChatWidget.css');
7
+
8
+ var jsxRuntime = {exports: {}};
9
+
10
+ var reactJsxRuntime_production_min = {};
11
+
12
+ /**
13
+ * @license React
14
+ * react-jsx-runtime.production.min.js
15
+ *
16
+ * Copyright (c) Facebook, Inc. and its affiliates.
17
+ *
18
+ * This source code is licensed under the MIT license found in the
19
+ * LICENSE file in the root directory of this source tree.
20
+ */
21
+
22
+ var hasRequiredReactJsxRuntime_production_min;
23
+
24
+ function requireReactJsxRuntime_production_min () {
25
+ if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
26
+ hasRequiredReactJsxRuntime_production_min = 1;
27
+ var f=require$$0,k=Symbol.for("react.element"),l=Symbol.for("react.fragment"),m=Object.prototype.hasOwnProperty,n=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p={key:true,ref:true,__self:true,__source:true};
28
+ function q(c,a,g){var b,d={},e=null,h=null;void 0!==g&&(e=""+g);void 0!==a.key&&(e=""+a.key);void 0!==a.ref&&(h=a.ref);for(b in a)m.call(a,b)&&!p.hasOwnProperty(b)&&(d[b]=a[b]);if(c&&c.defaultProps)for(b in a=c.defaultProps,a) void 0===d[b]&&(d[b]=a[b]);return {$$typeof:k,type:c,key:e,ref:h,props:d,_owner:n.current}}reactJsxRuntime_production_min.Fragment=l;reactJsxRuntime_production_min.jsx=q;reactJsxRuntime_production_min.jsxs=q;
29
+ return reactJsxRuntime_production_min;
30
+ }
31
+
32
+ var reactJsxRuntime_development = {};
33
+
34
+ /**
35
+ * @license React
36
+ * react-jsx-runtime.development.js
37
+ *
38
+ * Copyright (c) Facebook, Inc. and its affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */
43
+
44
+ var hasRequiredReactJsxRuntime_development;
45
+
46
+ function requireReactJsxRuntime_development () {
47
+ if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
48
+ hasRequiredReactJsxRuntime_development = 1;
49
+
50
+ if (process.env.NODE_ENV !== "production") {
51
+ (function() {
52
+
53
+ var React = require$$0;
54
+
55
+ // ATTENTION
56
+ // When adding new symbols to this file,
57
+ // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
58
+ // The Symbol used to tag the ReactElement-like types.
59
+ var REACT_ELEMENT_TYPE = Symbol.for('react.element');
60
+ var REACT_PORTAL_TYPE = Symbol.for('react.portal');
61
+ var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
62
+ var REACT_STRICT_MODE_TYPE = Symbol.for('react.strict_mode');
63
+ var REACT_PROFILER_TYPE = Symbol.for('react.profiler');
64
+ var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
65
+ var REACT_CONTEXT_TYPE = Symbol.for('react.context');
66
+ var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
67
+ var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
68
+ var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
69
+ var REACT_MEMO_TYPE = Symbol.for('react.memo');
70
+ var REACT_LAZY_TYPE = Symbol.for('react.lazy');
71
+ var REACT_OFFSCREEN_TYPE = Symbol.for('react.offscreen');
72
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
73
+ var FAUX_ITERATOR_SYMBOL = '@@iterator';
74
+ function getIteratorFn(maybeIterable) {
75
+ if (maybeIterable === null || typeof maybeIterable !== 'object') {
76
+ return null;
77
+ }
78
+
79
+ var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
80
+
81
+ if (typeof maybeIterator === 'function') {
82
+ return maybeIterator;
83
+ }
84
+
85
+ return null;
86
+ }
87
+
88
+ var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
89
+
90
+ function error(format) {
91
+ {
92
+ {
93
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
94
+ args[_key2 - 1] = arguments[_key2];
95
+ }
96
+
97
+ printWarning('error', format, args);
98
+ }
99
+ }
100
+ }
101
+
102
+ function printWarning(level, format, args) {
103
+ // When changing this logic, you might want to also
104
+ // update consoleWithStackDev.www.js as well.
105
+ {
106
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
107
+ var stack = ReactDebugCurrentFrame.getStackAddendum();
108
+
109
+ if (stack !== '') {
110
+ format += '%s';
111
+ args = args.concat([stack]);
112
+ } // eslint-disable-next-line react-internal/safe-string-coercion
113
+
114
+
115
+ var argsWithFormat = args.map(function (item) {
116
+ return String(item);
117
+ }); // Careful: RN currently depends on this prefix
118
+
119
+ argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
120
+ // breaks IE9: https://github.com/facebook/react/issues/13610
121
+ // eslint-disable-next-line react-internal/no-production-logging
122
+
123
+ Function.prototype.apply.call(console[level], console, argsWithFormat);
124
+ }
125
+ }
126
+
127
+ // -----------------------------------------------------------------------------
128
+
129
+ var enableScopeAPI = false; // Experimental Create Event Handle API.
130
+ var enableCacheElement = false;
131
+ var enableTransitionTracing = false; // No known bugs, but needs performance testing
132
+
133
+ var enableLegacyHidden = false; // Enables unstable_avoidThisFallback feature in Fiber
134
+ // stuff. Intended to enable React core members to more easily debug scheduling
135
+ // issues in DEV builds.
136
+
137
+ var enableDebugTracing = false; // Track which Fiber(s) schedule render work.
138
+
139
+ var REACT_MODULE_REFERENCE;
140
+
141
+ {
142
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
143
+ }
144
+
145
+ function isValidElementType(type) {
146
+ if (typeof type === 'string' || typeof type === 'function') {
147
+ return true;
148
+ } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
149
+
150
+
151
+ if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing ) {
152
+ return true;
153
+ }
154
+
155
+ if (typeof type === 'object' && type !== null) {
156
+ if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
157
+ // types supported by any Flight configuration anywhere since
158
+ // we don't know which Flight build this will end up being used
159
+ // with.
160
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
161
+ return true;
162
+ }
163
+ }
164
+
165
+ return false;
166
+ }
167
+
168
+ function getWrappedName(outerType, innerType, wrapperName) {
169
+ var displayName = outerType.displayName;
170
+
171
+ if (displayName) {
172
+ return displayName;
173
+ }
174
+
175
+ var functionName = innerType.displayName || innerType.name || '';
176
+ return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
177
+ } // Keep in sync with react-reconciler/getComponentNameFromFiber
178
+
179
+
180
+ function getContextName(type) {
181
+ return type.displayName || 'Context';
182
+ } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
183
+
184
+
185
+ function getComponentNameFromType(type) {
186
+ if (type == null) {
187
+ // Host root, text node or just invalid type.
188
+ return null;
189
+ }
190
+
191
+ {
192
+ if (typeof type.tag === 'number') {
193
+ error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
194
+ }
195
+ }
196
+
197
+ if (typeof type === 'function') {
198
+ return type.displayName || type.name || null;
199
+ }
200
+
201
+ if (typeof type === 'string') {
202
+ return type;
203
+ }
204
+
205
+ switch (type) {
206
+ case REACT_FRAGMENT_TYPE:
207
+ return 'Fragment';
208
+
209
+ case REACT_PORTAL_TYPE:
210
+ return 'Portal';
211
+
212
+ case REACT_PROFILER_TYPE:
213
+ return 'Profiler';
214
+
215
+ case REACT_STRICT_MODE_TYPE:
216
+ return 'StrictMode';
217
+
218
+ case REACT_SUSPENSE_TYPE:
219
+ return 'Suspense';
220
+
221
+ case REACT_SUSPENSE_LIST_TYPE:
222
+ return 'SuspenseList';
223
+
224
+ }
225
+
226
+ if (typeof type === 'object') {
227
+ switch (type.$$typeof) {
228
+ case REACT_CONTEXT_TYPE:
229
+ var context = type;
230
+ return getContextName(context) + '.Consumer';
231
+
232
+ case REACT_PROVIDER_TYPE:
233
+ var provider = type;
234
+ return getContextName(provider._context) + '.Provider';
235
+
236
+ case REACT_FORWARD_REF_TYPE:
237
+ return getWrappedName(type, type.render, 'ForwardRef');
238
+
239
+ case REACT_MEMO_TYPE:
240
+ var outerName = type.displayName || null;
241
+
242
+ if (outerName !== null) {
243
+ return outerName;
244
+ }
245
+
246
+ return getComponentNameFromType(type.type) || 'Memo';
247
+
248
+ case REACT_LAZY_TYPE:
249
+ {
250
+ var lazyComponent = type;
251
+ var payload = lazyComponent._payload;
252
+ var init = lazyComponent._init;
253
+
254
+ try {
255
+ return getComponentNameFromType(init(payload));
256
+ } catch (x) {
257
+ return null;
258
+ }
259
+ }
260
+
261
+ // eslint-disable-next-line no-fallthrough
262
+ }
263
+ }
264
+
265
+ return null;
266
+ }
267
+
268
+ var assign = Object.assign;
269
+
270
+ // Helpers to patch console.logs to avoid logging during side-effect free
271
+ // replaying on render function. This currently only patches the object
272
+ // lazily which won't cover if the log function was extracted eagerly.
273
+ // We could also eagerly patch the method.
274
+ var disabledDepth = 0;
275
+ var prevLog;
276
+ var prevInfo;
277
+ var prevWarn;
278
+ var prevError;
279
+ var prevGroup;
280
+ var prevGroupCollapsed;
281
+ var prevGroupEnd;
282
+
283
+ function disabledLog() {}
284
+
285
+ disabledLog.__reactDisabledLog = true;
286
+ function disableLogs() {
287
+ {
288
+ if (disabledDepth === 0) {
289
+ /* eslint-disable react-internal/no-production-logging */
290
+ prevLog = console.log;
291
+ prevInfo = console.info;
292
+ prevWarn = console.warn;
293
+ prevError = console.error;
294
+ prevGroup = console.group;
295
+ prevGroupCollapsed = console.groupCollapsed;
296
+ prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099
297
+
298
+ var props = {
299
+ configurable: true,
300
+ enumerable: true,
301
+ value: disabledLog,
302
+ writable: true
303
+ }; // $FlowFixMe Flow thinks console is immutable.
304
+
305
+ Object.defineProperties(console, {
306
+ info: props,
307
+ log: props,
308
+ warn: props,
309
+ error: props,
310
+ group: props,
311
+ groupCollapsed: props,
312
+ groupEnd: props
313
+ });
314
+ /* eslint-enable react-internal/no-production-logging */
315
+ }
316
+
317
+ disabledDepth++;
318
+ }
319
+ }
320
+ function reenableLogs() {
321
+ {
322
+ disabledDepth--;
323
+
324
+ if (disabledDepth === 0) {
325
+ /* eslint-disable react-internal/no-production-logging */
326
+ var props = {
327
+ configurable: true,
328
+ enumerable: true,
329
+ writable: true
330
+ }; // $FlowFixMe Flow thinks console is immutable.
331
+
332
+ Object.defineProperties(console, {
333
+ log: assign({}, props, {
334
+ value: prevLog
335
+ }),
336
+ info: assign({}, props, {
337
+ value: prevInfo
338
+ }),
339
+ warn: assign({}, props, {
340
+ value: prevWarn
341
+ }),
342
+ error: assign({}, props, {
343
+ value: prevError
344
+ }),
345
+ group: assign({}, props, {
346
+ value: prevGroup
347
+ }),
348
+ groupCollapsed: assign({}, props, {
349
+ value: prevGroupCollapsed
350
+ }),
351
+ groupEnd: assign({}, props, {
352
+ value: prevGroupEnd
353
+ })
354
+ });
355
+ /* eslint-enable react-internal/no-production-logging */
356
+ }
357
+
358
+ if (disabledDepth < 0) {
359
+ error('disabledDepth fell below zero. ' + 'This is a bug in React. Please file an issue.');
360
+ }
361
+ }
362
+ }
363
+
364
+ var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
365
+ var prefix;
366
+ function describeBuiltInComponentFrame(name, source, ownerFn) {
367
+ {
368
+ if (prefix === undefined) {
369
+ // Extract the VM specific prefix used by each line.
370
+ try {
371
+ throw Error();
372
+ } catch (x) {
373
+ var match = x.stack.trim().match(/\n( *(at )?)/);
374
+ prefix = match && match[1] || '';
375
+ }
376
+ } // We use the prefix to ensure our stacks line up with native stack frames.
377
+
378
+
379
+ return '\n' + prefix + name;
380
+ }
381
+ }
382
+ var reentry = false;
383
+ var componentFrameCache;
384
+
385
+ {
386
+ var PossiblyWeakMap = typeof WeakMap === 'function' ? WeakMap : Map;
387
+ componentFrameCache = new PossiblyWeakMap();
388
+ }
389
+
390
+ function describeNativeComponentFrame(fn, construct) {
391
+ // If something asked for a stack inside a fake render, it should get ignored.
392
+ if ( !fn || reentry) {
393
+ return '';
394
+ }
395
+
396
+ {
397
+ var frame = componentFrameCache.get(fn);
398
+
399
+ if (frame !== undefined) {
400
+ return frame;
401
+ }
402
+ }
403
+
404
+ var control;
405
+ reentry = true;
406
+ var previousPrepareStackTrace = Error.prepareStackTrace; // $FlowFixMe It does accept undefined.
407
+
408
+ Error.prepareStackTrace = undefined;
409
+ var previousDispatcher;
410
+
411
+ {
412
+ previousDispatcher = ReactCurrentDispatcher.current; // Set the dispatcher in DEV because this might be call in the render function
413
+ // for warnings.
414
+
415
+ ReactCurrentDispatcher.current = null;
416
+ disableLogs();
417
+ }
418
+
419
+ try {
420
+ // This should throw.
421
+ if (construct) {
422
+ // Something should be setting the props in the constructor.
423
+ var Fake = function () {
424
+ throw Error();
425
+ }; // $FlowFixMe
426
+
427
+
428
+ Object.defineProperty(Fake.prototype, 'props', {
429
+ set: function () {
430
+ // We use a throwing setter instead of frozen or non-writable props
431
+ // because that won't throw in a non-strict mode function.
432
+ throw Error();
433
+ }
434
+ });
435
+
436
+ if (typeof Reflect === 'object' && Reflect.construct) {
437
+ // We construct a different control for this case to include any extra
438
+ // frames added by the construct call.
439
+ try {
440
+ Reflect.construct(Fake, []);
441
+ } catch (x) {
442
+ control = x;
443
+ }
444
+
445
+ Reflect.construct(fn, [], Fake);
446
+ } else {
447
+ try {
448
+ Fake.call();
449
+ } catch (x) {
450
+ control = x;
451
+ }
452
+
453
+ fn.call(Fake.prototype);
454
+ }
455
+ } else {
456
+ try {
457
+ throw Error();
458
+ } catch (x) {
459
+ control = x;
460
+ }
461
+
462
+ fn();
463
+ }
464
+ } catch (sample) {
465
+ // This is inlined manually because closure doesn't do it for us.
466
+ if (sample && control && typeof sample.stack === 'string') {
467
+ // This extracts the first frame from the sample that isn't also in the control.
468
+ // Skipping one frame that we assume is the frame that calls the two.
469
+ var sampleLines = sample.stack.split('\n');
470
+ var controlLines = control.stack.split('\n');
471
+ var s = sampleLines.length - 1;
472
+ var c = controlLines.length - 1;
473
+
474
+ while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
475
+ // We expect at least one stack frame to be shared.
476
+ // Typically this will be the root most one. However, stack frames may be
477
+ // cut off due to maximum stack limits. In this case, one maybe cut off
478
+ // earlier than the other. We assume that the sample is longer or the same
479
+ // and there for cut off earlier. So we should find the root most frame in
480
+ // the sample somewhere in the control.
481
+ c--;
482
+ }
483
+
484
+ for (; s >= 1 && c >= 0; s--, c--) {
485
+ // Next we find the first one that isn't the same which should be the
486
+ // frame that called our sample function and the control.
487
+ if (sampleLines[s] !== controlLines[c]) {
488
+ // In V8, the first line is describing the message but other VMs don't.
489
+ // If we're about to return the first line, and the control is also on the same
490
+ // line, that's a pretty good indicator that our sample threw at same line as
491
+ // the control. I.e. before we entered the sample frame. So we ignore this result.
492
+ // This can happen if you passed a class to function component, or non-function.
493
+ if (s !== 1 || c !== 1) {
494
+ do {
495
+ s--;
496
+ c--; // We may still have similar intermediate frames from the construct call.
497
+ // The next one that isn't the same should be our match though.
498
+
499
+ if (c < 0 || sampleLines[s] !== controlLines[c]) {
500
+ // V8 adds a "new" prefix for native classes. Let's remove it to make it prettier.
501
+ var _frame = '\n' + sampleLines[s].replace(' at new ', ' at '); // If our component frame is labeled "<anonymous>"
502
+ // but we have a user-provided "displayName"
503
+ // splice it in to make the stack more readable.
504
+
505
+
506
+ if (fn.displayName && _frame.includes('<anonymous>')) {
507
+ _frame = _frame.replace('<anonymous>', fn.displayName);
508
+ }
509
+
510
+ {
511
+ if (typeof fn === 'function') {
512
+ componentFrameCache.set(fn, _frame);
513
+ }
514
+ } // Return the line we found.
515
+
516
+
517
+ return _frame;
518
+ }
519
+ } while (s >= 1 && c >= 0);
520
+ }
521
+
522
+ break;
523
+ }
524
+ }
525
+ }
526
+ } finally {
527
+ reentry = false;
528
+
529
+ {
530
+ ReactCurrentDispatcher.current = previousDispatcher;
531
+ reenableLogs();
532
+ }
533
+
534
+ Error.prepareStackTrace = previousPrepareStackTrace;
535
+ } // Fallback to just using the name if we couldn't make it throw.
536
+
537
+
538
+ var name = fn ? fn.displayName || fn.name : '';
539
+ var syntheticFrame = name ? describeBuiltInComponentFrame(name) : '';
540
+
541
+ {
542
+ if (typeof fn === 'function') {
543
+ componentFrameCache.set(fn, syntheticFrame);
544
+ }
545
+ }
546
+
547
+ return syntheticFrame;
548
+ }
549
+ function describeFunctionComponentFrame(fn, source, ownerFn) {
550
+ {
551
+ return describeNativeComponentFrame(fn, false);
552
+ }
553
+ }
554
+
555
+ function shouldConstruct(Component) {
556
+ var prototype = Component.prototype;
557
+ return !!(prototype && prototype.isReactComponent);
558
+ }
559
+
560
+ function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
561
+
562
+ if (type == null) {
563
+ return '';
564
+ }
565
+
566
+ if (typeof type === 'function') {
567
+ {
568
+ return describeNativeComponentFrame(type, shouldConstruct(type));
569
+ }
570
+ }
571
+
572
+ if (typeof type === 'string') {
573
+ return describeBuiltInComponentFrame(type);
574
+ }
575
+
576
+ switch (type) {
577
+ case REACT_SUSPENSE_TYPE:
578
+ return describeBuiltInComponentFrame('Suspense');
579
+
580
+ case REACT_SUSPENSE_LIST_TYPE:
581
+ return describeBuiltInComponentFrame('SuspenseList');
582
+ }
583
+
584
+ if (typeof type === 'object') {
585
+ switch (type.$$typeof) {
586
+ case REACT_FORWARD_REF_TYPE:
587
+ return describeFunctionComponentFrame(type.render);
588
+
589
+ case REACT_MEMO_TYPE:
590
+ // Memo may contain any component type so we recursively resolve it.
591
+ return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
592
+
593
+ case REACT_LAZY_TYPE:
594
+ {
595
+ var lazyComponent = type;
596
+ var payload = lazyComponent._payload;
597
+ var init = lazyComponent._init;
598
+
599
+ try {
600
+ // Lazy may contain any component type so we recursively resolve it.
601
+ return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
602
+ } catch (x) {}
603
+ }
604
+ }
605
+ }
606
+
607
+ return '';
608
+ }
609
+
610
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
611
+
612
+ var loggedTypeFailures = {};
613
+ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
614
+
615
+ function setCurrentlyValidatingElement(element) {
616
+ {
617
+ if (element) {
618
+ var owner = element._owner;
619
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
620
+ ReactDebugCurrentFrame.setExtraStackFrame(stack);
621
+ } else {
622
+ ReactDebugCurrentFrame.setExtraStackFrame(null);
623
+ }
624
+ }
625
+ }
626
+
627
+ function checkPropTypes(typeSpecs, values, location, componentName, element) {
628
+ {
629
+ // $FlowFixMe This is okay but Flow doesn't know it.
630
+ var has = Function.call.bind(hasOwnProperty);
631
+
632
+ for (var typeSpecName in typeSpecs) {
633
+ if (has(typeSpecs, typeSpecName)) {
634
+ var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
635
+ // fail the render phase where it didn't fail before. So we log it.
636
+ // After these have been cleaned up, we'll let them throw.
637
+
638
+ try {
639
+ // This is intentionally an invariant that gets caught. It's the same
640
+ // behavior as without this statement except with a better message.
641
+ if (typeof typeSpecs[typeSpecName] !== 'function') {
642
+ // eslint-disable-next-line react-internal/prod-error-codes
643
+ var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
644
+ err.name = 'Invariant Violation';
645
+ throw err;
646
+ }
647
+
648
+ error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
649
+ } catch (ex) {
650
+ error$1 = ex;
651
+ }
652
+
653
+ if (error$1 && !(error$1 instanceof Error)) {
654
+ setCurrentlyValidatingElement(element);
655
+
656
+ error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
657
+
658
+ setCurrentlyValidatingElement(null);
659
+ }
660
+
661
+ if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
662
+ // Only monitor this failure once because there tends to be a lot of the
663
+ // same error.
664
+ loggedTypeFailures[error$1.message] = true;
665
+ setCurrentlyValidatingElement(element);
666
+
667
+ error('Failed %s type: %s', location, error$1.message);
668
+
669
+ setCurrentlyValidatingElement(null);
670
+ }
671
+ }
672
+ }
673
+ }
674
+ }
675
+
676
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
677
+
678
+ function isArray(a) {
679
+ return isArrayImpl(a);
680
+ }
681
+
682
+ /*
683
+ * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol
684
+ * and Temporal.* types. See https://github.com/facebook/react/pull/22064.
685
+ *
686
+ * The functions in this module will throw an easier-to-understand,
687
+ * easier-to-debug exception with a clear errors message message explaining the
688
+ * problem. (Instead of a confusing exception thrown inside the implementation
689
+ * of the `value` object).
690
+ */
691
+ // $FlowFixMe only called in DEV, so void return is not possible.
692
+ function typeName(value) {
693
+ {
694
+ // toStringTag is needed for namespaced types like Temporal.Instant
695
+ var hasToStringTag = typeof Symbol === 'function' && Symbol.toStringTag;
696
+ var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || 'Object';
697
+ return type;
698
+ }
699
+ } // $FlowFixMe only called in DEV, so void return is not possible.
700
+
701
+
702
+ function willCoercionThrow(value) {
703
+ {
704
+ try {
705
+ testStringCoercion(value);
706
+ return false;
707
+ } catch (e) {
708
+ return true;
709
+ }
710
+ }
711
+ }
712
+
713
+ function testStringCoercion(value) {
714
+ // If you ended up here by following an exception call stack, here's what's
715
+ // happened: you supplied an object or symbol value to React (as a prop, key,
716
+ // DOM attribute, CSS property, string ref, etc.) and when React tried to
717
+ // coerce it to a string using `'' + value`, an exception was thrown.
718
+ //
719
+ // The most common types that will cause this exception are `Symbol` instances
720
+ // and Temporal objects like `Temporal.Instant`. But any object that has a
721
+ // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this
722
+ // exception. (Library authors do this to prevent users from using built-in
723
+ // numeric operators like `+` or comparison operators like `>=` because custom
724
+ // methods are needed to perform accurate arithmetic or comparison.)
725
+ //
726
+ // To fix the problem, coerce this object or symbol value to a string before
727
+ // passing it to React. The most reliable way is usually `String(value)`.
728
+ //
729
+ // To find which value is throwing, check the browser or debugger console.
730
+ // Before this exception was thrown, there should be `console.error` output
731
+ // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the
732
+ // problem and how that type was used: key, atrribute, input value prop, etc.
733
+ // In most cases, this console output also shows the component and its
734
+ // ancestor components where the exception happened.
735
+ //
736
+ // eslint-disable-next-line react-internal/safe-string-coercion
737
+ return '' + value;
738
+ }
739
+ function checkKeyStringCoercion(value) {
740
+ {
741
+ if (willCoercionThrow(value)) {
742
+ error('The provided key is an unsupported type %s.' + ' This value must be coerced to a string before before using it here.', typeName(value));
743
+
744
+ return testStringCoercion(value); // throw (to help callers find troubleshooting comments)
745
+ }
746
+ }
747
+ }
748
+
749
+ var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
750
+ var RESERVED_PROPS = {
751
+ key: true,
752
+ ref: true,
753
+ __self: true,
754
+ __source: true
755
+ };
756
+ var specialPropKeyWarningShown;
757
+ var specialPropRefWarningShown;
758
+
759
+ function hasValidRef(config) {
760
+ {
761
+ if (hasOwnProperty.call(config, 'ref')) {
762
+ var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
763
+
764
+ if (getter && getter.isReactWarning) {
765
+ return false;
766
+ }
767
+ }
768
+ }
769
+
770
+ return config.ref !== undefined;
771
+ }
772
+
773
+ function hasValidKey(config) {
774
+ {
775
+ if (hasOwnProperty.call(config, 'key')) {
776
+ var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
777
+
778
+ if (getter && getter.isReactWarning) {
779
+ return false;
780
+ }
781
+ }
782
+ }
783
+
784
+ return config.key !== undefined;
785
+ }
786
+
787
+ function warnIfStringRefCannotBeAutoConverted(config, self) {
788
+ {
789
+ if (typeof config.ref === 'string' && ReactCurrentOwner.current && self) ;
790
+ }
791
+ }
792
+
793
+ function defineKeyPropWarningGetter(props, displayName) {
794
+ {
795
+ var warnAboutAccessingKey = function () {
796
+ if (!specialPropKeyWarningShown) {
797
+ specialPropKeyWarningShown = true;
798
+
799
+ error('%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
800
+ }
801
+ };
802
+
803
+ warnAboutAccessingKey.isReactWarning = true;
804
+ Object.defineProperty(props, 'key', {
805
+ get: warnAboutAccessingKey,
806
+ configurable: true
807
+ });
808
+ }
809
+ }
810
+
811
+ function defineRefPropWarningGetter(props, displayName) {
812
+ {
813
+ var warnAboutAccessingRef = function () {
814
+ if (!specialPropRefWarningShown) {
815
+ specialPropRefWarningShown = true;
816
+
817
+ error('%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://reactjs.org/link/special-props)', displayName);
818
+ }
819
+ };
820
+
821
+ warnAboutAccessingRef.isReactWarning = true;
822
+ Object.defineProperty(props, 'ref', {
823
+ get: warnAboutAccessingRef,
824
+ configurable: true
825
+ });
826
+ }
827
+ }
828
+ /**
829
+ * Factory method to create a new React element. This no longer adheres to
830
+ * the class pattern, so do not use new to call it. Also, instanceof check
831
+ * will not work. Instead test $$typeof field against Symbol.for('react.element') to check
832
+ * if something is a React Element.
833
+ *
834
+ * @param {*} type
835
+ * @param {*} props
836
+ * @param {*} key
837
+ * @param {string|object} ref
838
+ * @param {*} owner
839
+ * @param {*} self A *temporary* helper to detect places where `this` is
840
+ * different from the `owner` when React.createElement is called, so that we
841
+ * can warn. We want to get rid of owner and replace string `ref`s with arrow
842
+ * functions, and as long as `this` and owner are the same, there will be no
843
+ * change in behavior.
844
+ * @param {*} source An annotation object (added by a transpiler or otherwise)
845
+ * indicating filename, line number, and/or other information.
846
+ * @internal
847
+ */
848
+
849
+
850
+ var ReactElement = function (type, key, ref, self, source, owner, props) {
851
+ var element = {
852
+ // This tag allows us to uniquely identify this as a React Element
853
+ $$typeof: REACT_ELEMENT_TYPE,
854
+ // Built-in properties that belong on the element
855
+ type: type,
856
+ key: key,
857
+ ref: ref,
858
+ props: props,
859
+ // Record the component responsible for creating this element.
860
+ _owner: owner
861
+ };
862
+
863
+ {
864
+ // The validation flag is currently mutative. We put it on
865
+ // an external backing store so that we can freeze the whole object.
866
+ // This can be replaced with a WeakMap once they are implemented in
867
+ // commonly used development environments.
868
+ element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
869
+ // the validation flag non-enumerable (where possible, which should
870
+ // include every environment we run tests in), so the test framework
871
+ // ignores it.
872
+
873
+ Object.defineProperty(element._store, 'validated', {
874
+ configurable: false,
875
+ enumerable: false,
876
+ writable: true,
877
+ value: false
878
+ }); // self and source are DEV only properties.
879
+
880
+ Object.defineProperty(element, '_self', {
881
+ configurable: false,
882
+ enumerable: false,
883
+ writable: false,
884
+ value: self
885
+ }); // Two elements created in two different places should be considered
886
+ // equal for testing purposes and therefore we hide it from enumeration.
887
+
888
+ Object.defineProperty(element, '_source', {
889
+ configurable: false,
890
+ enumerable: false,
891
+ writable: false,
892
+ value: source
893
+ });
894
+
895
+ if (Object.freeze) {
896
+ Object.freeze(element.props);
897
+ Object.freeze(element);
898
+ }
899
+ }
900
+
901
+ return element;
902
+ };
903
+ /**
904
+ * https://github.com/reactjs/rfcs/pull/107
905
+ * @param {*} type
906
+ * @param {object} props
907
+ * @param {string} key
908
+ */
909
+
910
+ function jsxDEV(type, config, maybeKey, source, self) {
911
+ {
912
+ var propName; // Reserved names are extracted
913
+
914
+ var props = {};
915
+ var key = null;
916
+ var ref = null; // Currently, key can be spread in as a prop. This causes a potential
917
+ // issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
918
+ // or <div key="Hi" {...props} /> ). We want to deprecate key spread,
919
+ // but as an intermediary step, we will use jsxDEV for everything except
920
+ // <div {...props} key="Hi" />, because we aren't currently able to tell if
921
+ // key is explicitly declared to be undefined or not.
922
+
923
+ if (maybeKey !== undefined) {
924
+ {
925
+ checkKeyStringCoercion(maybeKey);
926
+ }
927
+
928
+ key = '' + maybeKey;
929
+ }
930
+
931
+ if (hasValidKey(config)) {
932
+ {
933
+ checkKeyStringCoercion(config.key);
934
+ }
935
+
936
+ key = '' + config.key;
937
+ }
938
+
939
+ if (hasValidRef(config)) {
940
+ ref = config.ref;
941
+ warnIfStringRefCannotBeAutoConverted(config, self);
942
+ } // Remaining properties are added to a new props object
943
+
944
+
945
+ for (propName in config) {
946
+ if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
947
+ props[propName] = config[propName];
948
+ }
949
+ } // Resolve default props
950
+
951
+
952
+ if (type && type.defaultProps) {
953
+ var defaultProps = type.defaultProps;
954
+
955
+ for (propName in defaultProps) {
956
+ if (props[propName] === undefined) {
957
+ props[propName] = defaultProps[propName];
958
+ }
959
+ }
960
+ }
961
+
962
+ if (key || ref) {
963
+ var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
964
+
965
+ if (key) {
966
+ defineKeyPropWarningGetter(props, displayName);
967
+ }
968
+
969
+ if (ref) {
970
+ defineRefPropWarningGetter(props, displayName);
971
+ }
972
+ }
973
+
974
+ return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
975
+ }
976
+ }
977
+
978
+ var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
979
+ var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
980
+
981
+ function setCurrentlyValidatingElement$1(element) {
982
+ {
983
+ if (element) {
984
+ var owner = element._owner;
985
+ var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
986
+ ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
987
+ } else {
988
+ ReactDebugCurrentFrame$1.setExtraStackFrame(null);
989
+ }
990
+ }
991
+ }
992
+
993
+ var propTypesMisspellWarningShown;
994
+
995
+ {
996
+ propTypesMisspellWarningShown = false;
997
+ }
998
+ /**
999
+ * Verifies the object is a ReactElement.
1000
+ * See https://reactjs.org/docs/react-api.html#isvalidelement
1001
+ * @param {?object} object
1002
+ * @return {boolean} True if `object` is a ReactElement.
1003
+ * @final
1004
+ */
1005
+
1006
+
1007
+ function isValidElement(object) {
1008
+ {
1009
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1010
+ }
1011
+ }
1012
+
1013
+ function getDeclarationErrorAddendum() {
1014
+ {
1015
+ if (ReactCurrentOwner$1.current) {
1016
+ var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
1017
+
1018
+ if (name) {
1019
+ return '\n\nCheck the render method of `' + name + '`.';
1020
+ }
1021
+ }
1022
+
1023
+ return '';
1024
+ }
1025
+ }
1026
+
1027
+ function getSourceInfoErrorAddendum(source) {
1028
+ {
1029
+
1030
+ return '';
1031
+ }
1032
+ }
1033
+ /**
1034
+ * Warn if there's no key explicitly set on dynamic arrays of children or
1035
+ * object keys are not valid. This allows us to keep track of children between
1036
+ * updates.
1037
+ */
1038
+
1039
+
1040
+ var ownerHasKeyUseWarning = {};
1041
+
1042
+ function getCurrentComponentErrorInfo(parentType) {
1043
+ {
1044
+ var info = getDeclarationErrorAddendum();
1045
+
1046
+ if (!info) {
1047
+ var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
1048
+
1049
+ if (parentName) {
1050
+ info = "\n\nCheck the top-level render call using <" + parentName + ">.";
1051
+ }
1052
+ }
1053
+
1054
+ return info;
1055
+ }
1056
+ }
1057
+ /**
1058
+ * Warn if the element doesn't have an explicit key assigned to it.
1059
+ * This element is in an array. The array could grow and shrink or be
1060
+ * reordered. All children that haven't already been validated are required to
1061
+ * have a "key" property assigned to it. Error statuses are cached so a warning
1062
+ * will only be shown once.
1063
+ *
1064
+ * @internal
1065
+ * @param {ReactElement} element Element that requires a key.
1066
+ * @param {*} parentType element's parent's type.
1067
+ */
1068
+
1069
+
1070
+ function validateExplicitKey(element, parentType) {
1071
+ {
1072
+ if (!element._store || element._store.validated || element.key != null) {
1073
+ return;
1074
+ }
1075
+
1076
+ element._store.validated = true;
1077
+ var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
1078
+
1079
+ if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
1080
+ return;
1081
+ }
1082
+
1083
+ ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
1084
+ // property, it may be the creator of the child that's responsible for
1085
+ // assigning it a key.
1086
+
1087
+ var childOwner = '';
1088
+
1089
+ if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
1090
+ // Give the component that originally created this child.
1091
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
1092
+ }
1093
+
1094
+ setCurrentlyValidatingElement$1(element);
1095
+
1096
+ error('Each child in a list should have a unique "key" prop.' + '%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
1097
+
1098
+ setCurrentlyValidatingElement$1(null);
1099
+ }
1100
+ }
1101
+ /**
1102
+ * Ensure that every element either is passed in a static location, in an
1103
+ * array with an explicit keys property defined, or in an object literal
1104
+ * with valid key property.
1105
+ *
1106
+ * @internal
1107
+ * @param {ReactNode} node Statically passed child of any type.
1108
+ * @param {*} parentType node's parent's type.
1109
+ */
1110
+
1111
+
1112
+ function validateChildKeys(node, parentType) {
1113
+ {
1114
+ if (typeof node !== 'object') {
1115
+ return;
1116
+ }
1117
+
1118
+ if (isArray(node)) {
1119
+ for (var i = 0; i < node.length; i++) {
1120
+ var child = node[i];
1121
+
1122
+ if (isValidElement(child)) {
1123
+ validateExplicitKey(child, parentType);
1124
+ }
1125
+ }
1126
+ } else if (isValidElement(node)) {
1127
+ // This element was passed in a valid location.
1128
+ if (node._store) {
1129
+ node._store.validated = true;
1130
+ }
1131
+ } else if (node) {
1132
+ var iteratorFn = getIteratorFn(node);
1133
+
1134
+ if (typeof iteratorFn === 'function') {
1135
+ // Entry iterators used to provide implicit keys,
1136
+ // but now we print a separate warning for them later.
1137
+ if (iteratorFn !== node.entries) {
1138
+ var iterator = iteratorFn.call(node);
1139
+ var step;
1140
+
1141
+ while (!(step = iterator.next()).done) {
1142
+ if (isValidElement(step.value)) {
1143
+ validateExplicitKey(step.value, parentType);
1144
+ }
1145
+ }
1146
+ }
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1151
+ /**
1152
+ * Given an element, validate that its props follow the propTypes definition,
1153
+ * provided by the type.
1154
+ *
1155
+ * @param {ReactElement} element
1156
+ */
1157
+
1158
+
1159
+ function validatePropTypes(element) {
1160
+ {
1161
+ var type = element.type;
1162
+
1163
+ if (type === null || type === undefined || typeof type === 'string') {
1164
+ return;
1165
+ }
1166
+
1167
+ var propTypes;
1168
+
1169
+ if (typeof type === 'function') {
1170
+ propTypes = type.propTypes;
1171
+ } else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
1172
+ // Inner props are checked in the reconciler.
1173
+ type.$$typeof === REACT_MEMO_TYPE)) {
1174
+ propTypes = type.propTypes;
1175
+ } else {
1176
+ return;
1177
+ }
1178
+
1179
+ if (propTypes) {
1180
+ // Intentionally inside to avoid triggering lazy initializers:
1181
+ var name = getComponentNameFromType(type);
1182
+ checkPropTypes(propTypes, element.props, 'prop', name, element);
1183
+ } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
1184
+ propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
1185
+
1186
+ var _name = getComponentNameFromType(type);
1187
+
1188
+ error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
1189
+ }
1190
+
1191
+ if (typeof type.getDefaultProps === 'function' && !type.getDefaultProps.isReactClassApproved) {
1192
+ error('getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.');
1193
+ }
1194
+ }
1195
+ }
1196
+ /**
1197
+ * Given a fragment, validate that it can only be provided with fragment props
1198
+ * @param {ReactElement} fragment
1199
+ */
1200
+
1201
+
1202
+ function validateFragmentProps(fragment) {
1203
+ {
1204
+ var keys = Object.keys(fragment.props);
1205
+
1206
+ for (var i = 0; i < keys.length; i++) {
1207
+ var key = keys[i];
1208
+
1209
+ if (key !== 'children' && key !== 'key') {
1210
+ setCurrentlyValidatingElement$1(fragment);
1211
+
1212
+ error('Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
1213
+
1214
+ setCurrentlyValidatingElement$1(null);
1215
+ break;
1216
+ }
1217
+ }
1218
+
1219
+ if (fragment.ref !== null) {
1220
+ setCurrentlyValidatingElement$1(fragment);
1221
+
1222
+ error('Invalid attribute `ref` supplied to `React.Fragment`.');
1223
+
1224
+ setCurrentlyValidatingElement$1(null);
1225
+ }
1226
+ }
1227
+ }
1228
+
1229
+ var didWarnAboutKeySpread = {};
1230
+ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
1231
+ {
1232
+ var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
1233
+ // succeed and there will likely be errors in render.
1234
+
1235
+ if (!validType) {
1236
+ var info = '';
1237
+
1238
+ if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
1239
+ info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
1240
+ }
1241
+
1242
+ var sourceInfo = getSourceInfoErrorAddendum();
1243
+
1244
+ if (sourceInfo) {
1245
+ info += sourceInfo;
1246
+ } else {
1247
+ info += getDeclarationErrorAddendum();
1248
+ }
1249
+
1250
+ var typeString;
1251
+
1252
+ if (type === null) {
1253
+ typeString = 'null';
1254
+ } else if (isArray(type)) {
1255
+ typeString = 'array';
1256
+ } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
1257
+ typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
1258
+ info = ' Did you accidentally export a JSX literal instead of a component?';
1259
+ } else {
1260
+ typeString = typeof type;
1261
+ }
1262
+
1263
+ error('React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
1264
+ }
1265
+
1266
+ var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
1267
+ // TODO: Drop this when these are no longer allowed as the type argument.
1268
+
1269
+ if (element == null) {
1270
+ return element;
1271
+ } // Skip key warning if the type isn't valid since our key validation logic
1272
+ // doesn't expect a non-string/function type and can throw confusing errors.
1273
+ // We don't want exception behavior to differ between dev and prod.
1274
+ // (Rendering will throw with a helpful message and as soon as the type is
1275
+ // fixed, the key warnings will appear.)
1276
+
1277
+
1278
+ if (validType) {
1279
+ var children = props.children;
1280
+
1281
+ if (children !== undefined) {
1282
+ if (isStaticChildren) {
1283
+ if (isArray(children)) {
1284
+ for (var i = 0; i < children.length; i++) {
1285
+ validateChildKeys(children[i], type);
1286
+ }
1287
+
1288
+ if (Object.freeze) {
1289
+ Object.freeze(children);
1290
+ }
1291
+ } else {
1292
+ error('React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
1293
+ }
1294
+ } else {
1295
+ validateChildKeys(children, type);
1296
+ }
1297
+ }
1298
+ }
1299
+
1300
+ {
1301
+ if (hasOwnProperty.call(props, 'key')) {
1302
+ var componentName = getComponentNameFromType(type);
1303
+ var keys = Object.keys(props).filter(function (k) {
1304
+ return k !== 'key';
1305
+ });
1306
+ var beforeExample = keys.length > 0 ? '{key: someKey, ' + keys.join(': ..., ') + ': ...}' : '{key: someKey}';
1307
+
1308
+ if (!didWarnAboutKeySpread[componentName + beforeExample]) {
1309
+ var afterExample = keys.length > 0 ? '{' + keys.join(': ..., ') + ': ...}' : '{}';
1310
+
1311
+ error('A props object containing a "key" prop is being spread into JSX:\n' + ' let props = %s;\n' + ' <%s {...props} />\n' + 'React keys must be passed directly to JSX without using spread:\n' + ' let props = %s;\n' + ' <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
1312
+
1313
+ didWarnAboutKeySpread[componentName + beforeExample] = true;
1314
+ }
1315
+ }
1316
+ }
1317
+
1318
+ if (type === REACT_FRAGMENT_TYPE) {
1319
+ validateFragmentProps(element);
1320
+ } else {
1321
+ validatePropTypes(element);
1322
+ }
1323
+
1324
+ return element;
1325
+ }
1326
+ } // These two functions exist to still get child warnings in dev
1327
+ // even with the prod transform. This means that jsxDEV is purely
1328
+ // opt-in behavior for better messages but that we won't stop
1329
+ // giving you warnings if you use production apis.
1330
+
1331
+ function jsxWithValidationStatic(type, props, key) {
1332
+ {
1333
+ return jsxWithValidation(type, props, key, true);
1334
+ }
1335
+ }
1336
+ function jsxWithValidationDynamic(type, props, key) {
1337
+ {
1338
+ return jsxWithValidation(type, props, key, false);
1339
+ }
1340
+ }
1341
+
1342
+ var jsx = jsxWithValidationDynamic ; // we may want to special case jsxs internally to take advantage of static children.
1343
+ // for now we can ship identical prod functions
1344
+
1345
+ var jsxs = jsxWithValidationStatic ;
1346
+
1347
+ reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
1348
+ reactJsxRuntime_development.jsx = jsx;
1349
+ reactJsxRuntime_development.jsxs = jsxs;
1350
+ })();
1351
+ }
1352
+ return reactJsxRuntime_development;
1353
+ }
1354
+
1355
+ if (process.env.NODE_ENV === 'production') {
1356
+ jsxRuntime.exports = requireReactJsxRuntime_production_min();
1357
+ } else {
1358
+ jsxRuntime.exports = requireReactJsxRuntime_development();
1359
+ }
1360
+
1361
+ var jsxRuntimeExports = jsxRuntime.exports;
1362
+
1363
+ class ChatApiClient {
1364
+ constructor(config) {
1365
+ this.conversationId = null;
1366
+ this.config = config;
1367
+ this.conversationId = config.conversationId || null;
1368
+ this.client = axios.create({
1369
+ baseURL: config.webhookUrl,
1370
+ timeout: 30000,
1371
+ headers: {
1372
+ "Content-Type": "application/json",
1373
+ },
1374
+ });
1375
+ }
1376
+ /**
1377
+ * Send a message to the chat API
1378
+ */
1379
+ async sendMessage(message, additionalData) {
1380
+ try {
1381
+ const payload = {
1382
+ token: this.config.accessToken,
1383
+ message: message.trim(),
1384
+ conversation_id: this.conversationId,
1385
+ ...(this.config.apiEndpoints && {
1386
+ api_endpoints: this.config.apiEndpoints,
1387
+ }),
1388
+ };
1389
+ // Include support-specific fields if provided
1390
+ if (additionalData) {
1391
+ if (additionalData.custOrgId !== undefined) {
1392
+ payload.custOrgId = additionalData.custOrgId;
1393
+ }
1394
+ if (additionalData.serviceItemId !== undefined) {
1395
+ payload.serviceItemId = additionalData.serviceItemId;
1396
+ }
1397
+ if (additionalData.category) {
1398
+ payload.category = additionalData.category;
1399
+ }
1400
+ if (additionalData.priority) {
1401
+ payload.priority = additionalData.priority;
1402
+ }
1403
+ if (additionalData.stage) {
1404
+ payload.stage = additionalData.stage;
1405
+ }
1406
+ }
1407
+ // Include support config from config if available (only if not already set)
1408
+ if (this.config.supportConfig) {
1409
+ if (payload.custOrgId === undefined &&
1410
+ this.config.supportConfig.custOrgId !== undefined) {
1411
+ payload.custOrgId = this.config.supportConfig.custOrgId;
1412
+ }
1413
+ if (payload.serviceItemId === undefined &&
1414
+ this.config.supportConfig.serviceItemId !== undefined) {
1415
+ payload.serviceItemId = this.config.supportConfig.serviceItemId;
1416
+ }
1417
+ if (!payload.category && this.config.supportConfig.category) {
1418
+ payload.category = this.config.supportConfig.category;
1419
+ }
1420
+ if (!payload.priority && this.config.supportConfig.priority) {
1421
+ payload.priority = this.config.supportConfig.priority;
1422
+ }
1423
+ if (!payload.stage && this.config.supportConfig.stage) {
1424
+ payload.stage = this.config.supportConfig.stage;
1425
+ }
1426
+ }
1427
+ const response = await this.client.post("", payload);
1428
+ // Update conversation ID from response
1429
+ if (response.data.conversation_id) {
1430
+ this.conversationId = response.data.conversation_id;
1431
+ }
1432
+ return response.data;
1433
+ }
1434
+ catch (error) {
1435
+ if (axios.isAxiosError(error)) {
1436
+ const errorMessage = error.response?.data
1437
+ ?.message ||
1438
+ error.response?.data
1439
+ ?.error ||
1440
+ "Failed to send message. Please try again.";
1441
+ throw new Error(errorMessage);
1442
+ }
1443
+ if (error instanceof Error) {
1444
+ throw error;
1445
+ }
1446
+ throw new Error("Failed to send message. Please try again.");
1447
+ }
1448
+ }
1449
+ /**
1450
+ * Get current conversation ID
1451
+ */
1452
+ getConversationId() {
1453
+ return this.conversationId;
1454
+ }
1455
+ /**
1456
+ * Set conversation ID
1457
+ */
1458
+ setConversationId(id) {
1459
+ this.conversationId = id;
1460
+ }
1461
+ }
1462
+
1463
+ const useChat = (config) => {
1464
+ const [messages, setMessages] = require$$0.useState([]);
1465
+ const [isLoading, setIsLoading] = require$$0.useState(false);
1466
+ const [error, setError] = require$$0.useState(null);
1467
+ const apiClientRef = require$$0.useRef(new ChatApiClient(config));
1468
+ const sendMessage = require$$0.useCallback(async (text) => {
1469
+ if (!text.trim() || isLoading)
1470
+ return;
1471
+ const userMessage = {
1472
+ id: `user-${Date.now()}`,
1473
+ text: text.trim(),
1474
+ sender: "user",
1475
+ timestamp: new Date(),
1476
+ };
1477
+ const botMessage = {
1478
+ id: `bot-${Date.now()}`,
1479
+ text: "",
1480
+ sender: "bot",
1481
+ timestamp: new Date(),
1482
+ isLoading: true,
1483
+ };
1484
+ // Add user message and loading bot message
1485
+ setMessages((prev) => [...prev, userMessage, botMessage]);
1486
+ setIsLoading(true);
1487
+ setError(null);
1488
+ // Call callback
1489
+ config.callbacks?.onMessageSent?.(text);
1490
+ try {
1491
+ const response = await apiClientRef.current.sendMessage(text);
1492
+ // Update conversation ID if provided
1493
+ if (response.conversation_id) {
1494
+ apiClientRef.current.setConversationId(response.conversation_id);
1495
+ }
1496
+ // Update bot message with response
1497
+ setMessages((prev) => prev.map((msg) => msg.id === botMessage.id
1498
+ ? {
1499
+ ...msg,
1500
+ text: response.response ||
1501
+ "I apologize, but I could not generate a response.",
1502
+ isLoading: false,
1503
+ }
1504
+ : msg));
1505
+ // Call callbacks
1506
+ config.callbacks?.onMessageReceived?.(response);
1507
+ if (response.ticket_id && response.ticket_url) {
1508
+ config.callbacks?.onTicketCreated?.(response.ticket_id, response.ticket_url);
1509
+ }
1510
+ }
1511
+ catch (err) {
1512
+ const errorMessage = err instanceof Error
1513
+ ? err.message
1514
+ : "Failed to send message. Please try again.";
1515
+ // Update bot message with error
1516
+ setMessages((prev) => prev.map((msg) => msg.id === botMessage.id
1517
+ ? {
1518
+ ...msg,
1519
+ text: `Sorry, I encountered an error: ${errorMessage}`,
1520
+ isLoading: false,
1521
+ }
1522
+ : msg));
1523
+ setError(errorMessage);
1524
+ config.callbacks?.onError?.(err instanceof Error ? err : new Error(errorMessage));
1525
+ }
1526
+ finally {
1527
+ setIsLoading(false);
1528
+ }
1529
+ }, [isLoading, config]);
1530
+ const clearMessages = require$$0.useCallback(() => {
1531
+ setMessages([]);
1532
+ setError(null);
1533
+ }, []);
1534
+ return {
1535
+ messages,
1536
+ isLoading,
1537
+ error,
1538
+ sendMessage,
1539
+ clearMessages,
1540
+ };
1541
+ };
1542
+
1543
+ const ChatWidget = ({ config }) => {
1544
+ const [isOpen, setIsOpen] = require$$0.useState(false);
1545
+ const [inputValue, setInputValue] = require$$0.useState("");
1546
+ const messagesEndRef = require$$0.useRef(null);
1547
+ const inputRef = require$$0.useRef(null);
1548
+ const { messages, isLoading, sendMessage, clearMessages } = useChat(config);
1549
+ const appearance = config.appearance || {};
1550
+ const position = appearance.position || "bottom-right";
1551
+ const primaryColor = appearance.primaryColor || "#007bff";
1552
+ const title = appearance.title || "Chat Support";
1553
+ const subtitle = appearance.subtitle || "How can we help you?";
1554
+ const placeholder = appearance.placeholder || "Type your message...";
1555
+ const showAvatar = appearance.showAvatar !== false;
1556
+ const avatarUrl = appearance.avatarUrl ||
1557
+ "https://ui-avatars.com/api/?name=AI+Support&background=007bff&color=fff";
1558
+ // Auto-scroll to bottom when new messages arrive
1559
+ require$$0.useEffect(() => {
1560
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1561
+ }, [messages]);
1562
+ // Focus input when chat opens
1563
+ require$$0.useEffect(() => {
1564
+ if (isOpen && inputRef.current) {
1565
+ inputRef.current.focus();
1566
+ }
1567
+ }, [isOpen]);
1568
+ const handleSend = () => {
1569
+ if (inputValue.trim() && !isLoading) {
1570
+ sendMessage(inputValue);
1571
+ setInputValue("");
1572
+ }
1573
+ };
1574
+ const handleKeyPress = require$$0.useCallback((e) => {
1575
+ if (e.key === "Enter" && !e.shiftKey) {
1576
+ e.preventDefault();
1577
+ handleSend();
1578
+ }
1579
+ }, [handleSend]);
1580
+ const getPositionClasses = () => {
1581
+ const classes = {
1582
+ "bottom-right": "chat-widget-bottom-right",
1583
+ "bottom-left": "chat-widget-bottom-left",
1584
+ "top-right": "chat-widget-top-right",
1585
+ "top-left": "chat-widget-top-left",
1586
+ };
1587
+ return classes[position] || classes["bottom-right"];
1588
+ };
1589
+ return (jsxRuntimeExports.jsxs("div", { className: `chat-widget-container ${getPositionClasses()}`, children: [!isOpen && (jsxRuntimeExports.jsx("button", { className: "chat-widget-button", onClick: () => setIsOpen(true), style: { backgroundColor: primaryColor }, "aria-label": "Open chat", children: jsxRuntimeExports.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: jsxRuntimeExports.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) }) })), isOpen && (jsxRuntimeExports.jsxs("div", { className: "chat-widget-window", children: [jsxRuntimeExports.jsxs("div", { className: "chat-widget-header", style: { backgroundColor: primaryColor }, children: [jsxRuntimeExports.jsxs("div", { className: "chat-widget-header-content", children: [showAvatar && (jsxRuntimeExports.jsx("img", { src: avatarUrl, alt: "Avatar", className: "chat-widget-avatar" })), jsxRuntimeExports.jsxs("div", { className: "chat-widget-header-text", children: [jsxRuntimeExports.jsx("div", { className: "chat-widget-title", children: title }), jsxRuntimeExports.jsx("div", { className: "chat-widget-subtitle", children: subtitle })] })] }), jsxRuntimeExports.jsx("button", { className: "chat-widget-close", onClick: () => setIsOpen(false), "aria-label": "Close chat", children: jsxRuntimeExports.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }), jsxRuntimeExports.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })] }) })] }), jsxRuntimeExports.jsxs("div", { className: "chat-widget-messages", children: [messages.length === 0 && (jsxRuntimeExports.jsx("div", { className: "chat-widget-empty", children: jsxRuntimeExports.jsx("p", { children: "Start a conversation! Ask me anything." }) })), messages.map((message) => (jsxRuntimeExports.jsxs("div", { className: `chat-widget-message ${message.sender === "user"
1590
+ ? "chat-widget-message-user"
1591
+ : "chat-widget-message-bot"}`, children: [message.sender === "bot" && showAvatar && (jsxRuntimeExports.jsx("img", { src: avatarUrl, alt: "Bot", className: "chat-widget-message-avatar" })), jsxRuntimeExports.jsxs("div", { className: "chat-widget-message-content", children: [message.isLoading ? (jsxRuntimeExports.jsxs("div", { className: "chat-widget-typing", children: [jsxRuntimeExports.jsx("span", {}), jsxRuntimeExports.jsx("span", {}), jsxRuntimeExports.jsx("span", {})] })) : (jsxRuntimeExports.jsx("div", { className: "chat-widget-message-text", children: message.text })), jsxRuntimeExports.jsx("div", { className: "chat-widget-message-time", children: message.timestamp.toLocaleTimeString([], {
1592
+ hour: "2-digit",
1593
+ minute: "2-digit",
1594
+ }) })] })] }, message.id))), jsxRuntimeExports.jsx("div", { ref: messagesEndRef })] }), jsxRuntimeExports.jsxs("div", { className: "chat-widget-input-container", children: [jsxRuntimeExports.jsx("input", { ref: inputRef, type: "text", className: "chat-widget-input", placeholder: placeholder, value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyPress: handleKeyPress, disabled: isLoading }), jsxRuntimeExports.jsx("button", { className: "chat-widget-send", onClick: handleSend, disabled: !inputValue.trim() || isLoading, style: { backgroundColor: primaryColor }, "aria-label": "Send message", children: jsxRuntimeExports.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [jsxRuntimeExports.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }), jsxRuntimeExports.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })] }) })] })] }))] }));
1595
+ };
1596
+
1597
+ const DEFAULT_CATEGORIES = [
1598
+ {
1599
+ id: "general-query",
1600
+ name: "General Query",
1601
+ icon: "❓",
1602
+ description: "Questions, information, general inquiries",
1603
+ },
1604
+ {
1605
+ id: "existing-service",
1606
+ name: "Existing Service Issue",
1607
+ icon: "🔧",
1608
+ description: "Problems with current services, technical issues",
1609
+ },
1610
+ {
1611
+ id: "check-status",
1612
+ name: "Check Ticket Status",
1613
+ icon: "📋",
1614
+ description: "Track existing tickets, get updates",
1615
+ },
1616
+ {
1617
+ id: "raise-ticket",
1618
+ name: "Raise General Ticket",
1619
+ icon: "🎫",
1620
+ description: "Create new support ticket for any issue",
1621
+ },
1622
+ ];
1623
+ const DEFAULT_PRIORITIES = [
1624
+ {
1625
+ id: "low",
1626
+ name: "Low",
1627
+ color: "#10b981",
1628
+ description: "General questions, minor issues",
1629
+ },
1630
+ {
1631
+ id: "medium",
1632
+ name: "Medium",
1633
+ color: "#f59e0b",
1634
+ description: "Standard support requests",
1635
+ },
1636
+ {
1637
+ id: "high",
1638
+ name: "High",
1639
+ color: "#ef4444",
1640
+ description: "Urgent issues affecting service",
1641
+ },
1642
+ {
1643
+ id: "critical",
1644
+ name: "Critical",
1645
+ color: "#dc2626",
1646
+ description: "Service down, data loss, security",
1647
+ },
1648
+ ];
1649
+ const SupportChatWidget = ({ config, }) => {
1650
+ const [isOpen, setIsOpen] = require$$0.useState(false);
1651
+ const [messages, setMessages] = require$$0.useState([]);
1652
+ const [inputMessage, setInputMessage] = require$$0.useState("");
1653
+ const [isLoading, setIsLoading] = require$$0.useState(false);
1654
+ const [isTyping, setIsTyping] = require$$0.useState(false);
1655
+ const [unreadCount, setUnreadCount] = require$$0.useState(0);
1656
+ const [currentTicket, setCurrentTicket] = require$$0.useState(null);
1657
+ const [supportCategory, setSupportCategory] = require$$0.useState(null);
1658
+ const [priority, setPriority] = require$$0.useState("medium");
1659
+ const [conversationStage, setConversationStage] = require$$0.useState("welcome");
1660
+ const [attachments, setAttachments] = require$$0.useState([]);
1661
+ const messagesEndRef = require$$0.useRef(null);
1662
+ const inputRef = require$$0.useRef(null);
1663
+ const apiClientRef = require$$0.useRef(new ChatApiClient(config));
1664
+ const supportCategories = config.supportCategories || DEFAULT_CATEGORIES;
1665
+ const priorityLevels = config.priorityLevels || DEFAULT_PRIORITIES;
1666
+ const custOrgId = config.supportConfig?.custOrgId || 0;
1667
+ const serviceItemId = config.supportConfig?.serviceItemId || 0;
1668
+ // Initialize chat
1669
+ const initializeChat = require$$0.useCallback(() => {
1670
+ const welcomeMessage = {
1671
+ id: Date.now(),
1672
+ text: "👋 Welcome to our Support Center!\n\n" +
1673
+ "I'm here to help you with any questions or issues. Let's get started by understanding what you need help with.\n\n" +
1674
+ "**What can I help you with today?**",
1675
+ sender: "bot",
1676
+ timestamp: new Date(),
1677
+ data: { type: "welcome", stage: "category-selection" },
1678
+ };
1679
+ setMessages([welcomeMessage]);
1680
+ setConversationStage("category");
1681
+ }, []);
1682
+ // Auto-scroll
1683
+ require$$0.useEffect(() => {
1684
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
1685
+ }, [messages]);
1686
+ // Focus input when open
1687
+ require$$0.useEffect(() => {
1688
+ if (isOpen && inputRef.current) {
1689
+ inputRef.current.focus();
1690
+ }
1691
+ }, [isOpen]);
1692
+ // Update unread count
1693
+ require$$0.useEffect(() => {
1694
+ if (!isOpen && messages.length > 0) {
1695
+ const lastMessage = messages[messages.length - 1];
1696
+ if (lastMessage.sender === "bot") {
1697
+ setUnreadCount((prev) => prev + 1);
1698
+ }
1699
+ }
1700
+ }, [messages, isOpen]);
1701
+ // Initialize on mount
1702
+ require$$0.useEffect(() => {
1703
+ initializeChat();
1704
+ }, [initializeChat]);
1705
+ const addMessage = require$$0.useCallback((text, sender, data = null) => {
1706
+ const newMessage = {
1707
+ id: Date.now(),
1708
+ text,
1709
+ sender,
1710
+ timestamp: new Date(),
1711
+ data: data || undefined,
1712
+ };
1713
+ setMessages((prev) => [...prev, newMessage]);
1714
+ }, []);
1715
+ const addBotMessage = require$$0.useCallback((text, data = null) => {
1716
+ addMessage(text, "bot", data);
1717
+ }, [addMessage]);
1718
+ const addUserMessage = require$$0.useCallback((text) => {
1719
+ addMessage(text, "user");
1720
+ }, [addMessage]);
1721
+ const toggleChat = require$$0.useCallback(() => {
1722
+ setIsOpen(!isOpen);
1723
+ if (!isOpen) {
1724
+ setUnreadCount(0);
1725
+ }
1726
+ }, [isOpen]);
1727
+ const handleSendMessage = async (e) => {
1728
+ e.preventDefault();
1729
+ if (!inputMessage.trim() || isLoading)
1730
+ return;
1731
+ const userMsg = inputMessage.trim();
1732
+ setInputMessage("");
1733
+ addUserMessage(userMsg);
1734
+ setIsTyping(true);
1735
+ setIsLoading(true);
1736
+ try {
1737
+ if (conversationStage === "ticket-lookup") {
1738
+ await new Promise((resolve) => setTimeout(resolve, 1000));
1739
+ await handleTicketStatusLookup();
1740
+ }
1741
+ else if (conversationStage === "details" &&
1742
+ supportCategory &&
1743
+ (priority || supportCategory.id === "general-query")) {
1744
+ await new Promise((resolve) => setTimeout(resolve, 1000));
1745
+ if (supportCategory.id === "general-query") {
1746
+ await handleGeneralQuery(userMsg);
1747
+ }
1748
+ else {
1749
+ await createSupportTicket(userMsg);
1750
+ }
1751
+ }
1752
+ else {
1753
+ // Call n8n webhook with support context
1754
+ const response = await apiClientRef.current.sendMessage(userMsg, {
1755
+ custOrgId: custOrgId || undefined,
1756
+ serviceItemId: serviceItemId || undefined,
1757
+ category: supportCategory?.id,
1758
+ priority: priority,
1759
+ stage: conversationStage,
1760
+ });
1761
+ await new Promise((resolve) => setTimeout(resolve, 500));
1762
+ if (response.success) {
1763
+ addBotMessage(response.response, { response });
1764
+ config.callbacks?.onMessageReceived?.(response);
1765
+ if (response.ticket_id && response.ticket_url) {
1766
+ config.callbacks?.onTicketCreated?.(response.ticket_id, response.ticket_url);
1767
+ }
1768
+ }
1769
+ else {
1770
+ addBotMessage("❌ Sorry, I encountered an error. Please try again or contact support.");
1771
+ }
1772
+ }
1773
+ }
1774
+ catch (error) {
1775
+ console.error("Error sending message:", error);
1776
+ const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
1777
+ addBotMessage("❌ Sorry, I'm having trouble connecting to the support system.\n\n" +
1778
+ "Please try again in a moment or contact us directly.");
1779
+ config.callbacks?.onError?.(error instanceof Error ? error : new Error(errorMessage));
1780
+ }
1781
+ finally {
1782
+ setIsTyping(false);
1783
+ setIsLoading(false);
1784
+ }
1785
+ };
1786
+ const handleCategorySelect = require$$0.useCallback((category) => {
1787
+ setSupportCategory(category);
1788
+ if (category.id === "check-status") {
1789
+ setConversationStage("ticket-lookup");
1790
+ addBotMessage(`Perfect! I can help you check your ticket status.\n\n**Please provide your ticket ID** (e.g., TKT-123456) or describe the issue you submitted a ticket for, and I'll look it up for you.`, { type: "status-check-requested", category });
1791
+ }
1792
+ else if (category.id === "general-query") {
1793
+ setConversationStage("details");
1794
+ addBotMessage(`Great! I'm here to help with your general query.\n\n**What would you like to know?** Please describe your question or the information you need.`, { type: "general-query-selected", category });
1795
+ }
1796
+ else {
1797
+ setConversationStage("priority");
1798
+ addBotMessage(`Great! I see you need help with **${category.name}**.\n\nNow, let's determine the priority level for your request:`, { type: "category-selected", category });
1799
+ }
1800
+ }, [addBotMessage]);
1801
+ const handlePrioritySelect = require$$0.useCallback((priorityLevel) => {
1802
+ setPriority(priorityLevel.id);
1803
+ setConversationStage("details");
1804
+ addBotMessage(`Perfect! I've set the priority to **${priorityLevel.name}**.\n\nNow, please describe your issue in detail. The more information you provide, the better I can help you.\n\n**What's the specific problem you're experiencing?**`, { type: "priority-selected", priority: priorityLevel });
1805
+ }, [addBotMessage]);
1806
+ const handleTicketStatusLookup = require$$0.useCallback(async () => {
1807
+ const mockTicket = {
1808
+ id: "TKT-123456",
1809
+ status: "In Progress",
1810
+ category: "Technical Support",
1811
+ priority: "High",
1812
+ created: "2024-01-15",
1813
+ lastUpdate: "2024-01-16",
1814
+ description: "Server connectivity issues",
1815
+ assignedTo: "Support Team",
1816
+ };
1817
+ addBotMessage(`📋 **Ticket Status Found!**\n\n**Ticket ID:** ${mockTicket.id}\n**Status:** ${mockTicket.status}\n**Category:** ${mockTicket.category}\n**Priority:** ${mockTicket.priority}\n**Created:** ${mockTicket.created}\n**Last Update:** ${mockTicket.lastUpdate}\n**Assigned To:** ${mockTicket.assignedTo}\n\n**Description:** ${mockTicket.description}\n\nOur support team is actively working on your ticket. You'll receive updates as progress is made.\n\nIs there anything else I can help you with?`, { type: "ticket-status", ticket: mockTicket });
1818
+ setCurrentTicket(mockTicket);
1819
+ setConversationStage("ticket-created");
1820
+ }, [addBotMessage]);
1821
+ const handleGeneralQuery = require$$0.useCallback(async (query) => {
1822
+ addBotMessage(`✅ **Query Received!**\n\nThank you for your question: "${query}"\n\nI've noted your inquiry and our support team will provide a detailed response within 24 hours. For immediate assistance, you can also:\n\n• Check our FAQ section\n• Browse our knowledge base\n• Contact us directly\n\nIs there anything else I can help you with?`, { type: "general-query-response", query });
1823
+ setConversationStage("ticket-created");
1824
+ }, [addBotMessage]);
1825
+ const createSupportTicket = require$$0.useCallback(async (description) => {
1826
+ const ticketData = {
1827
+ category: supportCategory?.id,
1828
+ priority: priority,
1829
+ description: description,
1830
+ attachments: attachments,
1831
+ timestamp: new Date().toISOString(),
1832
+ status: "open",
1833
+ };
1834
+ const ticketId = `TKT-${Date.now().toString().slice(-6)}`;
1835
+ setCurrentTicket({
1836
+ id: ticketId,
1837
+ status: ticketData.status,
1838
+ category: ticketData.category || "",
1839
+ priority: ticketData.priority || "",
1840
+ created: ticketData.timestamp,
1841
+ lastUpdate: ticketData.timestamp,
1842
+ description: ticketData.description,
1843
+ assignedTo: "Support Team",
1844
+ });
1845
+ setConversationStage("ticket-created");
1846
+ const priorityName = priorityLevels.find((p) => p.id === priority)?.name || "Medium";
1847
+ addBotMessage(`🎫 **Support Ticket Created Successfully!**\n\n**Ticket ID:** ${ticketId}\n**Category:** ${supportCategory?.name}\n**Priority:** ${priorityName}\n**Status:** Open\n\nYour ticket has been submitted and our support team will review it shortly. You'll receive updates via email.\n\nIs there anything else I can help you with?`, {
1848
+ type: "ticket-created",
1849
+ ticket: { id: ticketId, ...ticketData },
1850
+ });
1851
+ }, [supportCategory, priority, attachments, priorityLevels, addBotMessage]);
1852
+ const resetConversation = require$$0.useCallback(() => {
1853
+ setSupportCategory(null);
1854
+ setPriority("medium");
1855
+ setConversationStage("welcome");
1856
+ setCurrentTicket(null);
1857
+ setAttachments([]);
1858
+ initializeChat();
1859
+ }, [initializeChat]);
1860
+ const formatTime = (date) => {
1861
+ return new Intl.DateTimeFormat("en-US", {
1862
+ hour: "numeric",
1863
+ minute: "numeric",
1864
+ hour12: true,
1865
+ }).format(date);
1866
+ };
1867
+ const handleKeyDown = require$$0.useCallback((e) => {
1868
+ if (e.key === "Escape" && isOpen) {
1869
+ setIsOpen(false);
1870
+ }
1871
+ }, [isOpen]);
1872
+ require$$0.useEffect(() => {
1873
+ document.addEventListener("keydown", handleKeyDown);
1874
+ return () => {
1875
+ document.removeEventListener("keydown", handleKeyDown);
1876
+ };
1877
+ }, [handleKeyDown]);
1878
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs("button", { className: `chat-button ${isOpen ? "hidden" : ""}`, onClick: toggleChat, "aria-label": "Open support chat", "aria-expanded": isOpen, type: "button", children: [jsxRuntimeExports.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: jsxRuntimeExports.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) }), unreadCount > 0 && (jsxRuntimeExports.jsx("div", { className: "unread-badge", "aria-label": `${unreadCount} unread messages`, children: unreadCount }))] }), jsxRuntimeExports.jsxs("div", { className: `chat-widget ${isOpen ? "open" : ""}`, role: "dialog", "aria-label": "Support chat window", "aria-hidden": !isOpen, children: [jsxRuntimeExports.jsxs("div", { className: "chat-header", children: [jsxRuntimeExports.jsxs("div", { className: "chat-header-info", children: [jsxRuntimeExports.jsx("div", { className: "chat-avatar", children: jsxRuntimeExports.jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z" }) }) }), jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx("div", { className: "chat-title", children: currentTicket
1879
+ ? `Ticket ${currentTicket.id}`
1880
+ : config.appearance?.title || "Support Center" }), jsxRuntimeExports.jsxs("div", { className: "chat-status", children: [jsxRuntimeExports.jsx("span", { className: "status-dot" }), currentTicket ? "Ticket Active" : "Online"] })] })] }), jsxRuntimeExports.jsx("button", { className: "chat-close-btn", onClick: toggleChat, "aria-label": "Close support chat", type: "button", children: jsxRuntimeExports.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsxRuntimeExports.jsx("line", { x1: "15", y1: "5", x2: "5", y2: "15" }), jsxRuntimeExports.jsx("line", { x1: "5", y1: "5", x2: "15", y2: "15" })] }) })] }), jsxRuntimeExports.jsxs("div", { className: "chat-messages", role: "log", "aria-label": "Chat messages", "aria-live": "polite", "aria-atomic": "false", children: [messages.map((message) => (jsxRuntimeExports.jsxs("div", { className: `message ${message.sender === "user" ? "user-message" : "bot-message"}`, role: "article", "aria-label": `Message from ${message.sender === "user" ? "you" : "support agent"}`, children: [message.sender === "bot" && (jsxRuntimeExports.jsx("div", { className: "message-avatar", children: jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z" }) }) })), jsxRuntimeExports.jsxs("div", { className: "message-content", children: [jsxRuntimeExports.jsx("div", { className: "message-bubble", children: jsxRuntimeExports.jsx("div", { className: "message-text", children: message.text.split("\n").map((line, i) => {
1881
+ const formattedLine = line.replace(/\*\*(.*?)\*\*/g, "<strong>$1</strong>");
1882
+ return (jsxRuntimeExports.jsxs(require$$0.Fragment, { children: [jsxRuntimeExports.jsx("span", { dangerouslySetInnerHTML: { __html: formattedLine } }), i < message.text.split("\n").length - 1 && jsxRuntimeExports.jsx("br", {})] }, i));
1883
+ }) }) }), jsxRuntimeExports.jsx("div", { className: "message-time", children: formatTime(message.timestamp) })] })] }, message.id))), isTyping && (jsxRuntimeExports.jsxs("div", { className: "message bot-message", children: [jsxRuntimeExports.jsx("div", { className: "message-avatar", children: jsxRuntimeExports.jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: jsxRuntimeExports.jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 3c1.66 0 3 1.34 3 3s-1.34 3-3 3-3-1.34-3-3 1.34-3 3-3zm0 14.2c-2.5 0-4.71-1.28-6-3.22.03-1.99 4-3.08 6-3.08 1.99 0 5.97 1.09 6 3.08-1.29 1.94-3.5 3.22-6 3.22z" }) }) }), jsxRuntimeExports.jsx("div", { className: "message-content", children: jsxRuntimeExports.jsx("div", { className: "message-bubble", children: jsxRuntimeExports.jsxs("div", { className: "typing-indicator", children: [jsxRuntimeExports.jsx("span", {}), jsxRuntimeExports.jsx("span", {}), jsxRuntimeExports.jsx("span", {})] }) }) })] })), jsxRuntimeExports.jsx("div", { ref: messagesEndRef })] }), conversationStage === "category" && (jsxRuntimeExports.jsx("div", { className: "category-selection", children: jsxRuntimeExports.jsx("div", { className: "category-grid", children: supportCategories.map((category) => (jsxRuntimeExports.jsxs("button", { className: "category-btn", onClick: () => handleCategorySelect(category), "aria-label": `Select ${category.name}`, type: "button", children: [jsxRuntimeExports.jsx("div", { className: "category-icon", children: category.icon }), jsxRuntimeExports.jsx("div", { className: "category-name", children: category.name }), jsxRuntimeExports.jsx("div", { className: "category-description", children: category.description })] }, category.id))) }) })), conversationStage === "priority" && (jsxRuntimeExports.jsx("div", { className: "priority-selection", children: jsxRuntimeExports.jsx("div", { className: "priority-grid", children: priorityLevels.map((priorityLevel) => (jsxRuntimeExports.jsxs("button", { className: "priority-btn", onClick: () => handlePrioritySelect(priorityLevel), "aria-label": `Select ${priorityLevel.name} priority`, type: "button", style: { borderColor: priorityLevel.color }, children: [jsxRuntimeExports.jsx("div", { className: "priority-indicator", style: { backgroundColor: priorityLevel.color } }), jsxRuntimeExports.jsx("div", { className: "priority-name", children: priorityLevel.name }), jsxRuntimeExports.jsx("div", { className: "priority-description", children: priorityLevel.description })] }, priorityLevel.id))) }) })), conversationStage === "ticket-created" && (jsxRuntimeExports.jsxs("div", { className: "quick-actions", children: [jsxRuntimeExports.jsx("button", { className: "action-btn primary", onClick: resetConversation, "aria-label": "Start new conversation", type: "button", children: "\uD83D\uDCAC New Conversation" }), jsxRuntimeExports.jsx("button", { className: "action-btn secondary", onClick: () => {
1884
+ setInputMessage("Check ticket status");
1885
+ inputRef.current?.focus();
1886
+ }, "aria-label": "Check ticket status", type: "button", children: "\uD83D\uDCCB Check Status" })] })), jsxRuntimeExports.jsxs("form", { className: "chat-input-form", onSubmit: handleSendMessage, children: [jsxRuntimeExports.jsxs("div", { className: "chat-input-wrapper", children: [jsxRuntimeExports.jsx("input", { ref: inputRef, type: "text", className: "chat-input", placeholder: config.appearance?.placeholder || "Type your message...", value: inputMessage, onChange: (e) => setInputMessage(e.target.value), onKeyPress: (e) => {
1887
+ if (e.key === "Enter" && !e.shiftKey) {
1888
+ e.preventDefault();
1889
+ handleSendMessage(e);
1890
+ }
1891
+ }, disabled: isLoading, "aria-label": "Type your message", "aria-describedby": "chat-input-help" }), jsxRuntimeExports.jsx("button", { type: "submit", className: "chat-send-btn", disabled: !inputMessage.trim() || isLoading, "aria-label": "Send message", children: jsxRuntimeExports.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [jsxRuntimeExports.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }), jsxRuntimeExports.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })] }) })] }), jsxRuntimeExports.jsx("div", { className: "chat-input-footer", id: "chat-input-help", children: currentTicket ? (jsxRuntimeExports.jsxs("span", { children: ["\uD83C\uDFAB Ticket ", currentTicket.id, " \u2022 ", supportCategory?.name, " \u2022", " ", priorityLevels.find((p) => p.id === priority)?.name, " Priority"] })) : (jsxRuntimeExports.jsx("span", { children: "Powered by Smart Support System" })) })] })] })] }));
1892
+ };
1893
+
1894
+ exports.ChatApiClient = ChatApiClient;
1895
+ exports.ChatWidget = ChatWidget;
1896
+ exports.SupportChatWidget = SupportChatWidget;
1897
+ exports.useChat = useChat;
1898
+ //# sourceMappingURL=index.js.map