nerdagent-chat-widget 1.0.0
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/README.md +257 -0
- package/dist/angular/index.d.ts +38 -0
- package/dist/angular/index.js +5 -0
- package/dist/angular/index.js.map +1 -0
- package/dist/angular/nerd-chat-widget.d.ts +11 -0
- package/dist/angular/nerd-chat-widget.js +289 -0
- package/dist/angular/nerd-chat-widget.js.map +1 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js +8 -0
- package/dist/cjs/app-globals-V2Kpy_OQ.js.map +1 -0
- package/dist/cjs/index-CURqjGGU.js +1471 -0
- package/dist/cjs/index-CURqjGGU.js.map +1 -0
- package/dist/cjs/index.cjs.js +235 -0
- package/dist/cjs/index.cjs.js.map +1 -0
- package/dist/cjs/loader.cjs.js +14 -0
- package/dist/cjs/loader.cjs.js.map +1 -0
- package/dist/cjs/nerd-chat-widget.cjs.entry.js +9 -0
- package/dist/cjs/nerd-chat-widget.entry.cjs.js.map +1 -0
- package/dist/cjs/nerdagent-chat-widget.cjs.js +26 -0
- package/dist/cjs/nerdagent-chat-widget.cjs.js.map +1 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/chat-widget/chat-widget.js +808 -0
- package/dist/collection/components/chat-widget/chat-widget.js.map +1 -0
- package/dist/collection/components/chat-widget/chat-widget.scss +420 -0
- package/dist/collection/index.js +2 -0
- package/dist/collection/index.js.map +1 -0
- package/dist/collection/script.js +323 -0
- package/dist/components/index.d.ts +33 -0
- package/dist/components/index.js +1514 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/nerd-chat-widget.d.ts +11 -0
- package/dist/components/nerd-chat-widget.js +9 -0
- package/dist/components/nerd-chat-widget.js.map +1 -0
- package/dist/esm/app-globals-DQuL1Twl.js +6 -0
- package/dist/esm/app-globals-DQuL1Twl.js.map +1 -0
- package/dist/esm/index-Dlv_7oUh.js +1444 -0
- package/dist/esm/index-Dlv_7oUh.js.map +1 -0
- package/dist/esm/index.js +233 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/loader.js +12 -0
- package/dist/esm/loader.js.map +1 -0
- package/dist/esm/nerd-chat-widget.entry.js +3 -0
- package/dist/esm/nerd-chat-widget.entry.js.map +1 -0
- package/dist/esm/nerdagent-chat-widget.js +22 -0
- package/dist/esm/nerdagent-chat-widget.js.map +1 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/nerdagent-chat-widget/index.esm.js +2 -0
- package/dist/nerdagent-chat-widget/index.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/loader.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/nerd-chat-widget.entry.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/nerdagent-chat-widget.esm.js +2 -0
- package/dist/nerdagent-chat-widget/nerdagent-chat-widget.esm.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-395fe7e7.entry.js +2 -0
- package/dist/nerdagent-chat-widget/p-395fe7e7.entry.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-DQuL1Twl.js +2 -0
- package/dist/nerdagent-chat-widget/p-DQuL1Twl.js.map +1 -0
- package/dist/nerdagent-chat-widget/p-Dlv_7oUh.js +3 -0
- package/dist/nerdagent-chat-widget/p-Dlv_7oUh.js.map +1 -0
- package/dist/react/index.d.ts +38 -0
- package/dist/react/index.js +5 -0
- package/dist/react/index.js.map +1 -0
- package/dist/react/nerd-chat-widget.d.ts +11 -0
- package/dist/react/nerd-chat-widget.js +289 -0
- package/dist/react/nerd-chat-widget.js.map +1 -0
- package/dist/types/components/chat-widget/chat-widget.d.ts +95 -0
- package/dist/types/components.d.ts +251 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/stencil-public-runtime.d.ts +1730 -0
- package/dist/vue/index.d.ts +38 -0
- package/dist/vue/index.js +5 -0
- package/dist/vue/index.js.map +1 -0
- package/dist/vue/nerd-chat-widget.d.ts +11 -0
- package/dist/vue/nerd-chat-widget.js +289 -0
- package/dist/vue/nerd-chat-widget.js.map +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/package.json +76 -0
|
@@ -0,0 +1,1514 @@
|
|
|
1
|
+
const NAMESPACE = 'nerdagent-chat-widget';
|
|
2
|
+
const BUILD = /* nerdagent-chat-widget */ { hydratedSelectorName: "hydrated", lazyLoad: false, updatable: true};
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
Stencil Client Platform v4.37.0 | MIT Licensed | https://stenciljs.com
|
|
6
|
+
*/
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/client/client-host-ref.ts
|
|
14
|
+
var getHostRef = (ref) => {
|
|
15
|
+
if (ref.__stencil__getHostRef) {
|
|
16
|
+
return ref.__stencil__getHostRef();
|
|
17
|
+
}
|
|
18
|
+
return void 0;
|
|
19
|
+
};
|
|
20
|
+
var registerHost = (hostElement, cmpMeta) => {
|
|
21
|
+
const hostRef = {
|
|
22
|
+
$flags$: 0,
|
|
23
|
+
$hostElement$: hostElement,
|
|
24
|
+
$cmpMeta$: cmpMeta,
|
|
25
|
+
$instanceValues$: /* @__PURE__ */ new Map()
|
|
26
|
+
};
|
|
27
|
+
{
|
|
28
|
+
hostRef.$onReadyPromise$ = new Promise((r) => hostRef.$onReadyResolve$ = r);
|
|
29
|
+
hostElement["s-p"] = [];
|
|
30
|
+
hostElement["s-rc"] = [];
|
|
31
|
+
}
|
|
32
|
+
const ref = hostRef;
|
|
33
|
+
hostElement.__stencil__getHostRef = () => ref;
|
|
34
|
+
return ref;
|
|
35
|
+
};
|
|
36
|
+
var isMemberInElement = (elm, memberName) => memberName in elm;
|
|
37
|
+
var consoleError = (e, el) => (0, console.error)(e, el);
|
|
38
|
+
|
|
39
|
+
// src/client/client-style.ts
|
|
40
|
+
var styles = /* @__PURE__ */ new Map();
|
|
41
|
+
var SLOT_FB_CSS = "slot-fb{display:contents}slot-fb[hidden]{display:none}";
|
|
42
|
+
var win = typeof window !== "undefined" ? window : {};
|
|
43
|
+
var H = win.HTMLElement || class {
|
|
44
|
+
};
|
|
45
|
+
var plt = {
|
|
46
|
+
$flags$: 0,
|
|
47
|
+
$resourcesUrl$: "",
|
|
48
|
+
jmp: (h2) => h2(),
|
|
49
|
+
raf: (h2) => requestAnimationFrame(h2),
|
|
50
|
+
ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
|
|
51
|
+
rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
|
|
52
|
+
ce: (eventName, opts) => new CustomEvent(eventName, opts)
|
|
53
|
+
};
|
|
54
|
+
var promiseResolve = (v) => Promise.resolve(v);
|
|
55
|
+
var supportsConstructableStylesheets = /* @__PURE__ */ (() => {
|
|
56
|
+
try {
|
|
57
|
+
new CSSStyleSheet();
|
|
58
|
+
return typeof new CSSStyleSheet().replaceSync === "function";
|
|
59
|
+
} catch (e) {
|
|
60
|
+
}
|
|
61
|
+
return false;
|
|
62
|
+
})() ;
|
|
63
|
+
var supportsMutableAdoptedStyleSheets = supportsConstructableStylesheets ? /* @__PURE__ */ (() => !!win.document && Object.getOwnPropertyDescriptor(win.document.adoptedStyleSheets, "length").writable)() : false;
|
|
64
|
+
var queuePending = false;
|
|
65
|
+
var queueDomReads = [];
|
|
66
|
+
var queueDomWrites = [];
|
|
67
|
+
var queueTask = (queue, write) => (cb) => {
|
|
68
|
+
queue.push(cb);
|
|
69
|
+
if (!queuePending) {
|
|
70
|
+
queuePending = true;
|
|
71
|
+
if (write && plt.$flags$ & 4 /* queueSync */) {
|
|
72
|
+
nextTick(flush);
|
|
73
|
+
} else {
|
|
74
|
+
plt.raf(flush);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var consume = (queue) => {
|
|
79
|
+
for (let i2 = 0; i2 < queue.length; i2++) {
|
|
80
|
+
try {
|
|
81
|
+
queue[i2](performance.now());
|
|
82
|
+
} catch (e) {
|
|
83
|
+
consoleError(e);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
queue.length = 0;
|
|
87
|
+
};
|
|
88
|
+
var flush = () => {
|
|
89
|
+
consume(queueDomReads);
|
|
90
|
+
{
|
|
91
|
+
consume(queueDomWrites);
|
|
92
|
+
if (queuePending = queueDomReads.length > 0) {
|
|
93
|
+
plt.raf(flush);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var nextTick = (cb) => promiseResolve().then(cb);
|
|
98
|
+
var writeTask = /* @__PURE__ */ queueTask(queueDomWrites, true);
|
|
99
|
+
|
|
100
|
+
// src/runtime/asset-path.ts
|
|
101
|
+
var getAssetPath = (path) => {
|
|
102
|
+
const assetUrl = new URL(path, plt.$resourcesUrl$);
|
|
103
|
+
return assetUrl.origin !== win.location.origin ? assetUrl.href : assetUrl.pathname;
|
|
104
|
+
};
|
|
105
|
+
var setAssetPath = (path) => plt.$resourcesUrl$ = path;
|
|
106
|
+
var isComplexType = (o) => {
|
|
107
|
+
o = typeof o;
|
|
108
|
+
return o === "object" || o === "function";
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// src/utils/query-nonce-meta-tag-content.ts
|
|
112
|
+
function queryNonceMetaTagContent(doc) {
|
|
113
|
+
var _a, _b, _c;
|
|
114
|
+
return (_c = (_b = (_a = doc.head) == null ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) == null ? void 0 : _b.getAttribute("content")) != null ? _c : void 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/utils/regular-expression.ts
|
|
118
|
+
var escapeRegExpSpecialCharacters = (text) => {
|
|
119
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
// src/utils/result.ts
|
|
123
|
+
var result_exports = {};
|
|
124
|
+
__export(result_exports, {
|
|
125
|
+
err: () => err,
|
|
126
|
+
map: () => map,
|
|
127
|
+
ok: () => ok,
|
|
128
|
+
unwrap: () => unwrap,
|
|
129
|
+
unwrapErr: () => unwrapErr
|
|
130
|
+
});
|
|
131
|
+
var ok = (value) => ({
|
|
132
|
+
isOk: true,
|
|
133
|
+
isErr: false,
|
|
134
|
+
value
|
|
135
|
+
});
|
|
136
|
+
var err = (value) => ({
|
|
137
|
+
isOk: false,
|
|
138
|
+
isErr: true,
|
|
139
|
+
value
|
|
140
|
+
});
|
|
141
|
+
function map(result, fn) {
|
|
142
|
+
if (result.isOk) {
|
|
143
|
+
const val = fn(result.value);
|
|
144
|
+
if (val instanceof Promise) {
|
|
145
|
+
return val.then((newVal) => ok(newVal));
|
|
146
|
+
} else {
|
|
147
|
+
return ok(val);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
if (result.isErr) {
|
|
151
|
+
const value = result.value;
|
|
152
|
+
return err(value);
|
|
153
|
+
}
|
|
154
|
+
throw "should never get here";
|
|
155
|
+
}
|
|
156
|
+
var unwrap = (result) => {
|
|
157
|
+
if (result.isOk) {
|
|
158
|
+
return result.value;
|
|
159
|
+
} else {
|
|
160
|
+
throw result.value;
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
var unwrapErr = (result) => {
|
|
164
|
+
if (result.isErr) {
|
|
165
|
+
return result.value;
|
|
166
|
+
} else {
|
|
167
|
+
throw result.value;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
// src/utils/style.ts
|
|
172
|
+
function createStyleSheetIfNeededAndSupported(styles2) {
|
|
173
|
+
return void 0;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// src/utils/shadow-root.ts
|
|
177
|
+
var globalStyleSheet;
|
|
178
|
+
function createShadowRoot(cmpMeta) {
|
|
179
|
+
var _a;
|
|
180
|
+
const shadowRoot = this.attachShadow({ mode: "open" });
|
|
181
|
+
if (globalStyleSheet === void 0) globalStyleSheet = (_a = createStyleSheetIfNeededAndSupported()) != null ? _a : null;
|
|
182
|
+
if (globalStyleSheet) {
|
|
183
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
184
|
+
shadowRoot.adoptedStyleSheets.push(globalStyleSheet);
|
|
185
|
+
} else {
|
|
186
|
+
shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, globalStyleSheet];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
var createTime = (fnName, tagName = "") => {
|
|
191
|
+
{
|
|
192
|
+
return () => {
|
|
193
|
+
return;
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
var rootAppliedStyles = /* @__PURE__ */ new WeakMap();
|
|
198
|
+
var registerStyle = (scopeId2, cssText, allowCS) => {
|
|
199
|
+
let style = styles.get(scopeId2);
|
|
200
|
+
if (supportsConstructableStylesheets && allowCS) {
|
|
201
|
+
style = style || new CSSStyleSheet();
|
|
202
|
+
if (typeof style === "string") {
|
|
203
|
+
style = cssText;
|
|
204
|
+
} else {
|
|
205
|
+
style.replaceSync(cssText);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
style = cssText;
|
|
209
|
+
}
|
|
210
|
+
styles.set(scopeId2, style);
|
|
211
|
+
};
|
|
212
|
+
var addStyle = (styleContainerNode, cmpMeta, mode) => {
|
|
213
|
+
var _a;
|
|
214
|
+
const scopeId2 = getScopeId(cmpMeta);
|
|
215
|
+
const style = styles.get(scopeId2);
|
|
216
|
+
if (!win.document) {
|
|
217
|
+
return scopeId2;
|
|
218
|
+
}
|
|
219
|
+
styleContainerNode = styleContainerNode.nodeType === 11 /* DocumentFragment */ ? styleContainerNode : win.document;
|
|
220
|
+
if (style) {
|
|
221
|
+
if (typeof style === "string") {
|
|
222
|
+
styleContainerNode = styleContainerNode.head || styleContainerNode;
|
|
223
|
+
let appliedStyles = rootAppliedStyles.get(styleContainerNode);
|
|
224
|
+
let styleElm;
|
|
225
|
+
if (!appliedStyles) {
|
|
226
|
+
rootAppliedStyles.set(styleContainerNode, appliedStyles = /* @__PURE__ */ new Set());
|
|
227
|
+
}
|
|
228
|
+
if (!appliedStyles.has(scopeId2)) {
|
|
229
|
+
{
|
|
230
|
+
styleElm = win.document.createElement("style");
|
|
231
|
+
styleElm.innerHTML = style;
|
|
232
|
+
const nonce = (_a = plt.$nonce$) != null ? _a : queryNonceMetaTagContent(win.document);
|
|
233
|
+
if (nonce != null) {
|
|
234
|
+
styleElm.setAttribute("nonce", nonce);
|
|
235
|
+
}
|
|
236
|
+
if (!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */)) {
|
|
237
|
+
if (styleContainerNode.nodeName === "HEAD") {
|
|
238
|
+
const preconnectLinks = styleContainerNode.querySelectorAll("link[rel=preconnect]");
|
|
239
|
+
const referenceNode2 = preconnectLinks.length > 0 ? preconnectLinks[preconnectLinks.length - 1].nextSibling : styleContainerNode.querySelector("style");
|
|
240
|
+
styleContainerNode.insertBefore(
|
|
241
|
+
styleElm,
|
|
242
|
+
(referenceNode2 == null ? void 0 : referenceNode2.parentNode) === styleContainerNode ? referenceNode2 : null
|
|
243
|
+
);
|
|
244
|
+
} else if ("host" in styleContainerNode) {
|
|
245
|
+
if (supportsConstructableStylesheets) {
|
|
246
|
+
const stylesheet = new CSSStyleSheet();
|
|
247
|
+
stylesheet.replaceSync(style);
|
|
248
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
249
|
+
styleContainerNode.adoptedStyleSheets.unshift(stylesheet);
|
|
250
|
+
} else {
|
|
251
|
+
styleContainerNode.adoptedStyleSheets = [stylesheet, ...styleContainerNode.adoptedStyleSheets];
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
const existingStyleContainer = styleContainerNode.querySelector("style");
|
|
255
|
+
if (existingStyleContainer) {
|
|
256
|
+
existingStyleContainer.innerHTML = style + existingStyleContainer.innerHTML;
|
|
257
|
+
} else {
|
|
258
|
+
styleContainerNode.prepend(styleElm);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
} else {
|
|
262
|
+
styleContainerNode.append(styleElm);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */) {
|
|
266
|
+
styleContainerNode.insertBefore(styleElm, null);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (cmpMeta.$flags$ & 4 /* hasSlotRelocation */) {
|
|
270
|
+
styleElm.innerHTML += SLOT_FB_CSS;
|
|
271
|
+
}
|
|
272
|
+
if (appliedStyles) {
|
|
273
|
+
appliedStyles.add(scopeId2);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
|
|
277
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
278
|
+
styleContainerNode.adoptedStyleSheets.push(style);
|
|
279
|
+
} else {
|
|
280
|
+
styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return scopeId2;
|
|
285
|
+
};
|
|
286
|
+
var attachStyles = (hostRef) => {
|
|
287
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
288
|
+
const elm = hostRef.$hostElement$;
|
|
289
|
+
const flags = cmpMeta.$flags$;
|
|
290
|
+
const endAttachStyles = createTime("attachStyles", cmpMeta.$tagName$);
|
|
291
|
+
const scopeId2 = addStyle(
|
|
292
|
+
elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(),
|
|
293
|
+
cmpMeta);
|
|
294
|
+
if (flags & 10 /* needsScopedEncapsulation */) {
|
|
295
|
+
elm["s-sc"] = scopeId2;
|
|
296
|
+
elm.classList.add(scopeId2 + "-h");
|
|
297
|
+
}
|
|
298
|
+
endAttachStyles();
|
|
299
|
+
};
|
|
300
|
+
var getScopeId = (cmp, mode) => "sc-" + (cmp.$tagName$);
|
|
301
|
+
var h = (nodeName, vnodeData, ...children) => {
|
|
302
|
+
let child = null;
|
|
303
|
+
let key = null;
|
|
304
|
+
let simple = false;
|
|
305
|
+
let lastSimple = false;
|
|
306
|
+
const vNodeChildren = [];
|
|
307
|
+
const walk = (c) => {
|
|
308
|
+
for (let i2 = 0; i2 < c.length; i2++) {
|
|
309
|
+
child = c[i2];
|
|
310
|
+
if (Array.isArray(child)) {
|
|
311
|
+
walk(child);
|
|
312
|
+
} else if (child != null && typeof child !== "boolean") {
|
|
313
|
+
if (simple = typeof nodeName !== "function" && !isComplexType(child)) {
|
|
314
|
+
child = String(child);
|
|
315
|
+
}
|
|
316
|
+
if (simple && lastSimple) {
|
|
317
|
+
vNodeChildren[vNodeChildren.length - 1].$text$ += child;
|
|
318
|
+
} else {
|
|
319
|
+
vNodeChildren.push(simple ? newVNode(null, child) : child);
|
|
320
|
+
}
|
|
321
|
+
lastSimple = simple;
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
walk(children);
|
|
326
|
+
if (vnodeData) {
|
|
327
|
+
if (vnodeData.key) {
|
|
328
|
+
key = vnodeData.key;
|
|
329
|
+
}
|
|
330
|
+
{
|
|
331
|
+
const classData = vnodeData.className || vnodeData.class;
|
|
332
|
+
if (classData) {
|
|
333
|
+
vnodeData.class = typeof classData !== "object" ? classData : Object.keys(classData).filter((k) => classData[k]).join(" ");
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
const vnode = newVNode(nodeName, null);
|
|
338
|
+
vnode.$attrs$ = vnodeData;
|
|
339
|
+
if (vNodeChildren.length > 0) {
|
|
340
|
+
vnode.$children$ = vNodeChildren;
|
|
341
|
+
}
|
|
342
|
+
{
|
|
343
|
+
vnode.$key$ = key;
|
|
344
|
+
}
|
|
345
|
+
return vnode;
|
|
346
|
+
};
|
|
347
|
+
var newVNode = (tag, text) => {
|
|
348
|
+
const vnode = {
|
|
349
|
+
$flags$: 0,
|
|
350
|
+
$tag$: tag,
|
|
351
|
+
$text$: text,
|
|
352
|
+
$elm$: null,
|
|
353
|
+
$children$: null
|
|
354
|
+
};
|
|
355
|
+
{
|
|
356
|
+
vnode.$attrs$ = null;
|
|
357
|
+
}
|
|
358
|
+
{
|
|
359
|
+
vnode.$key$ = null;
|
|
360
|
+
}
|
|
361
|
+
return vnode;
|
|
362
|
+
};
|
|
363
|
+
var Host = {};
|
|
364
|
+
var isHost = (node) => node && node.$tag$ === Host;
|
|
365
|
+
var createSupportsRuleRe = (selector) => {
|
|
366
|
+
const safeSelector2 = escapeRegExpSpecialCharacters(selector);
|
|
367
|
+
return new RegExp(
|
|
368
|
+
// First capture group: match any context before the selector that's not inside @supports selector()
|
|
369
|
+
// Using negative lookahead to avoid matching inside @supports selector(...) condition
|
|
370
|
+
`(^|[^@]|@(?!supports\\s+selector\\s*\\([^{]*?${safeSelector2}))(${safeSelector2}\\b)`,
|
|
371
|
+
"g"
|
|
372
|
+
);
|
|
373
|
+
};
|
|
374
|
+
createSupportsRuleRe("::slotted");
|
|
375
|
+
createSupportsRuleRe(":host");
|
|
376
|
+
createSupportsRuleRe(":host-context");
|
|
377
|
+
var parsePropertyValue = (propValue, propType, isFormAssociated) => {
|
|
378
|
+
if (typeof propValue === "string" && (propType & 16 /* Unknown */ || propType & 8 /* Any */) && (propValue.startsWith("{") && propValue.endsWith("}") || propValue.startsWith("[") && propValue.endsWith("]"))) {
|
|
379
|
+
try {
|
|
380
|
+
return JSON.parse(propValue);
|
|
381
|
+
} catch (e) {
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (propValue != null && !isComplexType(propValue)) {
|
|
385
|
+
if (propType & 4 /* Boolean */) {
|
|
386
|
+
{
|
|
387
|
+
return propValue === "false" ? false : propValue === "" || !!propValue;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
if (propType & 2 /* Number */) {
|
|
391
|
+
return typeof propValue === "string" ? parseFloat(propValue) : typeof propValue === "number" ? propValue : NaN;
|
|
392
|
+
}
|
|
393
|
+
if (propType & 1 /* String */) {
|
|
394
|
+
return String(propValue);
|
|
395
|
+
}
|
|
396
|
+
return propValue;
|
|
397
|
+
}
|
|
398
|
+
return propValue;
|
|
399
|
+
};
|
|
400
|
+
var getElement = (ref) => {
|
|
401
|
+
return ref;
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
// src/runtime/event-emitter.ts
|
|
405
|
+
var createEvent = (ref, name, flags) => {
|
|
406
|
+
const elm = getElement(ref);
|
|
407
|
+
return {
|
|
408
|
+
emit: (detail) => {
|
|
409
|
+
return emitEvent(elm, name, {
|
|
410
|
+
bubbles: true,
|
|
411
|
+
composed: true,
|
|
412
|
+
cancelable: true,
|
|
413
|
+
detail
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
var emitEvent = (elm, name, opts) => {
|
|
419
|
+
const ev = plt.ce(name, opts);
|
|
420
|
+
elm.dispatchEvent(ev);
|
|
421
|
+
return ev;
|
|
422
|
+
};
|
|
423
|
+
var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRender) => {
|
|
424
|
+
if (oldValue === newValue) {
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
let isProp = isMemberInElement(elm, memberName);
|
|
428
|
+
let ln = memberName.toLowerCase();
|
|
429
|
+
if (memberName === "class") {
|
|
430
|
+
const classList = elm.classList;
|
|
431
|
+
const oldClasses = parseClassList(oldValue);
|
|
432
|
+
let newClasses = parseClassList(newValue);
|
|
433
|
+
{
|
|
434
|
+
classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
|
|
435
|
+
classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
|
|
436
|
+
}
|
|
437
|
+
} else if (memberName === "style") {
|
|
438
|
+
{
|
|
439
|
+
for (const prop in oldValue) {
|
|
440
|
+
if (!newValue || newValue[prop] == null) {
|
|
441
|
+
if (prop.includes("-")) {
|
|
442
|
+
elm.style.removeProperty(prop);
|
|
443
|
+
} else {
|
|
444
|
+
elm.style[prop] = "";
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
for (const prop in newValue) {
|
|
450
|
+
if (!oldValue || newValue[prop] !== oldValue[prop]) {
|
|
451
|
+
if (prop.includes("-")) {
|
|
452
|
+
elm.style.setProperty(prop, newValue[prop]);
|
|
453
|
+
} else {
|
|
454
|
+
elm.style[prop] = newValue[prop];
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} else if (memberName === "key") ; else if ((!elm.__lookupSetter__(memberName)) && memberName[0] === "o" && memberName[1] === "n") {
|
|
459
|
+
if (memberName[2] === "-") {
|
|
460
|
+
memberName = memberName.slice(3);
|
|
461
|
+
} else if (isMemberInElement(win, ln)) {
|
|
462
|
+
memberName = ln.slice(2);
|
|
463
|
+
} else {
|
|
464
|
+
memberName = ln[2] + memberName.slice(3);
|
|
465
|
+
}
|
|
466
|
+
if (oldValue || newValue) {
|
|
467
|
+
const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
|
|
468
|
+
memberName = memberName.replace(CAPTURE_EVENT_REGEX, "");
|
|
469
|
+
if (oldValue) {
|
|
470
|
+
plt.rel(elm, memberName, oldValue, capture);
|
|
471
|
+
}
|
|
472
|
+
if (newValue) {
|
|
473
|
+
plt.ael(elm, memberName, newValue, capture);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
} else {
|
|
477
|
+
const isComplex = isComplexType(newValue);
|
|
478
|
+
if ((isProp || isComplex && newValue !== null) && true) {
|
|
479
|
+
try {
|
|
480
|
+
if (!elm.tagName.includes("-")) {
|
|
481
|
+
const n = newValue == null ? "" : newValue;
|
|
482
|
+
if (memberName === "list") {
|
|
483
|
+
isProp = false;
|
|
484
|
+
} else if (oldValue == null || elm[memberName] != n) {
|
|
485
|
+
if (typeof elm.__lookupSetter__(memberName) === "function") {
|
|
486
|
+
elm[memberName] = n;
|
|
487
|
+
} else {
|
|
488
|
+
elm.setAttribute(memberName, n);
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
} else if (elm[memberName] !== newValue) {
|
|
492
|
+
elm[memberName] = newValue;
|
|
493
|
+
}
|
|
494
|
+
} catch (e) {
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (newValue == null || newValue === false) {
|
|
498
|
+
if (newValue !== false || elm.getAttribute(memberName) === "") {
|
|
499
|
+
{
|
|
500
|
+
elm.removeAttribute(memberName);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
} else if ((!isProp || flags & 4 /* isHost */ || isSvg) && !isComplex && elm.nodeType === 1 /* ElementNode */) {
|
|
504
|
+
newValue = newValue === true ? "" : newValue;
|
|
505
|
+
{
|
|
506
|
+
elm.setAttribute(memberName, newValue);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
};
|
|
511
|
+
var parseClassListRegex = /\s/;
|
|
512
|
+
var parseClassList = (value) => {
|
|
513
|
+
if (typeof value === "object" && value && "baseVal" in value) {
|
|
514
|
+
value = value.baseVal;
|
|
515
|
+
}
|
|
516
|
+
if (!value || typeof value !== "string") {
|
|
517
|
+
return [];
|
|
518
|
+
}
|
|
519
|
+
return value.split(parseClassListRegex);
|
|
520
|
+
};
|
|
521
|
+
var CAPTURE_EVENT_SUFFIX = "Capture";
|
|
522
|
+
var CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + "$");
|
|
523
|
+
|
|
524
|
+
// src/runtime/vdom/update-element.ts
|
|
525
|
+
var updateElement = (oldVnode, newVnode, isSvgMode2, isInitialRender) => {
|
|
526
|
+
const elm = newVnode.$elm$.nodeType === 11 /* DocumentFragment */ && newVnode.$elm$.host ? newVnode.$elm$.host : newVnode.$elm$;
|
|
527
|
+
const oldVnodeAttrs = oldVnode && oldVnode.$attrs$ || {};
|
|
528
|
+
const newVnodeAttrs = newVnode.$attrs$ || {};
|
|
529
|
+
{
|
|
530
|
+
for (const memberName of sortedAttrNames(Object.keys(oldVnodeAttrs))) {
|
|
531
|
+
if (!(memberName in newVnodeAttrs)) {
|
|
532
|
+
setAccessor(
|
|
533
|
+
elm,
|
|
534
|
+
memberName,
|
|
535
|
+
oldVnodeAttrs[memberName],
|
|
536
|
+
void 0,
|
|
537
|
+
isSvgMode2,
|
|
538
|
+
newVnode.$flags$);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
for (const memberName of sortedAttrNames(Object.keys(newVnodeAttrs))) {
|
|
543
|
+
setAccessor(
|
|
544
|
+
elm,
|
|
545
|
+
memberName,
|
|
546
|
+
oldVnodeAttrs[memberName],
|
|
547
|
+
newVnodeAttrs[memberName],
|
|
548
|
+
isSvgMode2,
|
|
549
|
+
newVnode.$flags$);
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
function sortedAttrNames(attrNames) {
|
|
553
|
+
return attrNames.includes("ref") ? (
|
|
554
|
+
// we need to sort these to ensure that `'ref'` is the last attr
|
|
555
|
+
[...attrNames.filter((attr) => attr !== "ref"), "ref"]
|
|
556
|
+
) : (
|
|
557
|
+
// no need to sort, return the original array
|
|
558
|
+
attrNames
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
var hostTagName;
|
|
562
|
+
var isSvgMode = false;
|
|
563
|
+
var createElm = (oldParentVNode, newParentVNode, childIndex) => {
|
|
564
|
+
const newVNode2 = newParentVNode.$children$[childIndex];
|
|
565
|
+
let i2 = 0;
|
|
566
|
+
let elm;
|
|
567
|
+
let childNode;
|
|
568
|
+
if (newVNode2.$text$ !== null) {
|
|
569
|
+
elm = newVNode2.$elm$ = win.document.createTextNode(newVNode2.$text$);
|
|
570
|
+
} else {
|
|
571
|
+
if (!win.document) {
|
|
572
|
+
throw new Error(
|
|
573
|
+
"You are trying to render a Stencil component in an environment that doesn't support the DOM. Make sure to populate the [`window`](https://developer.mozilla.org/en-US/docs/Web/API/Window/window) object before rendering a component."
|
|
574
|
+
);
|
|
575
|
+
}
|
|
576
|
+
elm = newVNode2.$elm$ = win.document.createElement(
|
|
577
|
+
newVNode2.$tag$
|
|
578
|
+
);
|
|
579
|
+
{
|
|
580
|
+
updateElement(null, newVNode2, isSvgMode);
|
|
581
|
+
}
|
|
582
|
+
if (newVNode2.$children$) {
|
|
583
|
+
for (i2 = 0; i2 < newVNode2.$children$.length; ++i2) {
|
|
584
|
+
childNode = createElm(oldParentVNode, newVNode2, i2);
|
|
585
|
+
if (childNode) {
|
|
586
|
+
elm.appendChild(childNode);
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
elm["s-hn"] = hostTagName;
|
|
592
|
+
return elm;
|
|
593
|
+
};
|
|
594
|
+
var addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
|
|
595
|
+
let containerElm = parentElm;
|
|
596
|
+
let childNode;
|
|
597
|
+
if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
|
|
598
|
+
containerElm = containerElm.shadowRoot;
|
|
599
|
+
}
|
|
600
|
+
for (; startIdx <= endIdx; ++startIdx) {
|
|
601
|
+
if (vnodes[startIdx]) {
|
|
602
|
+
childNode = createElm(null, parentVNode, startIdx);
|
|
603
|
+
if (childNode) {
|
|
604
|
+
vnodes[startIdx].$elm$ = childNode;
|
|
605
|
+
insertBefore(containerElm, childNode, before);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
var removeVnodes = (vnodes, startIdx, endIdx) => {
|
|
611
|
+
for (let index = startIdx; index <= endIdx; ++index) {
|
|
612
|
+
const vnode = vnodes[index];
|
|
613
|
+
if (vnode) {
|
|
614
|
+
const elm = vnode.$elm$;
|
|
615
|
+
if (elm) {
|
|
616
|
+
elm.remove();
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
|
|
622
|
+
let oldStartIdx = 0;
|
|
623
|
+
let newStartIdx = 0;
|
|
624
|
+
let idxInOld = 0;
|
|
625
|
+
let i2 = 0;
|
|
626
|
+
let oldEndIdx = oldCh.length - 1;
|
|
627
|
+
let oldStartVnode = oldCh[0];
|
|
628
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
629
|
+
let newEndIdx = newCh.length - 1;
|
|
630
|
+
let newStartVnode = newCh[0];
|
|
631
|
+
let newEndVnode = newCh[newEndIdx];
|
|
632
|
+
let node;
|
|
633
|
+
let elmToMove;
|
|
634
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
635
|
+
if (oldStartVnode == null) {
|
|
636
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
637
|
+
} else if (oldEndVnode == null) {
|
|
638
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
639
|
+
} else if (newStartVnode == null) {
|
|
640
|
+
newStartVnode = newCh[++newStartIdx];
|
|
641
|
+
} else if (newEndVnode == null) {
|
|
642
|
+
newEndVnode = newCh[--newEndIdx];
|
|
643
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
|
|
644
|
+
patch(oldStartVnode, newStartVnode, isInitialRender);
|
|
645
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
646
|
+
newStartVnode = newCh[++newStartIdx];
|
|
647
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
|
|
648
|
+
patch(oldEndVnode, newEndVnode, isInitialRender);
|
|
649
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
650
|
+
newEndVnode = newCh[--newEndIdx];
|
|
651
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
|
|
652
|
+
patch(oldStartVnode, newEndVnode, isInitialRender);
|
|
653
|
+
insertBefore(parentElm, oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
|
|
654
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
655
|
+
newEndVnode = newCh[--newEndIdx];
|
|
656
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
|
|
657
|
+
patch(oldEndVnode, newStartVnode, isInitialRender);
|
|
658
|
+
insertBefore(parentElm, oldEndVnode.$elm$, oldStartVnode.$elm$);
|
|
659
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
660
|
+
newStartVnode = newCh[++newStartIdx];
|
|
661
|
+
} else {
|
|
662
|
+
idxInOld = -1;
|
|
663
|
+
{
|
|
664
|
+
for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
|
|
665
|
+
if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
|
|
666
|
+
idxInOld = i2;
|
|
667
|
+
break;
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
if (idxInOld >= 0) {
|
|
672
|
+
elmToMove = oldCh[idxInOld];
|
|
673
|
+
if (elmToMove.$tag$ !== newStartVnode.$tag$) {
|
|
674
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
|
|
675
|
+
} else {
|
|
676
|
+
patch(elmToMove, newStartVnode, isInitialRender);
|
|
677
|
+
oldCh[idxInOld] = void 0;
|
|
678
|
+
node = elmToMove.$elm$;
|
|
679
|
+
}
|
|
680
|
+
newStartVnode = newCh[++newStartIdx];
|
|
681
|
+
} else {
|
|
682
|
+
node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
|
|
683
|
+
newStartVnode = newCh[++newStartIdx];
|
|
684
|
+
}
|
|
685
|
+
if (node) {
|
|
686
|
+
{
|
|
687
|
+
insertBefore(oldStartVnode.$elm$.parentNode, node, oldStartVnode.$elm$);
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
if (oldStartIdx > oldEndIdx) {
|
|
693
|
+
addVnodes(
|
|
694
|
+
parentElm,
|
|
695
|
+
newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$,
|
|
696
|
+
newVNode2,
|
|
697
|
+
newCh,
|
|
698
|
+
newStartIdx,
|
|
699
|
+
newEndIdx
|
|
700
|
+
);
|
|
701
|
+
} else if (newStartIdx > newEndIdx) {
|
|
702
|
+
removeVnodes(oldCh, oldStartIdx, oldEndIdx);
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
|
|
706
|
+
if (leftVNode.$tag$ === rightVNode.$tag$) {
|
|
707
|
+
if (!isInitialRender) {
|
|
708
|
+
return leftVNode.$key$ === rightVNode.$key$;
|
|
709
|
+
}
|
|
710
|
+
if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
|
|
711
|
+
leftVNode.$key$ = rightVNode.$key$;
|
|
712
|
+
}
|
|
713
|
+
return true;
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
716
|
+
};
|
|
717
|
+
var patch = (oldVNode, newVNode2, isInitialRender = false) => {
|
|
718
|
+
const elm = newVNode2.$elm$ = oldVNode.$elm$;
|
|
719
|
+
const oldChildren = oldVNode.$children$;
|
|
720
|
+
const newChildren = newVNode2.$children$;
|
|
721
|
+
const text = newVNode2.$text$;
|
|
722
|
+
if (text === null) {
|
|
723
|
+
{
|
|
724
|
+
updateElement(oldVNode, newVNode2, isSvgMode);
|
|
725
|
+
}
|
|
726
|
+
if (oldChildren !== null && newChildren !== null) {
|
|
727
|
+
updateChildren(elm, oldChildren, newVNode2, newChildren, isInitialRender);
|
|
728
|
+
} else if (newChildren !== null) {
|
|
729
|
+
if (oldVNode.$text$ !== null) {
|
|
730
|
+
elm.textContent = "";
|
|
731
|
+
}
|
|
732
|
+
addVnodes(elm, null, newVNode2, newChildren, 0, newChildren.length - 1);
|
|
733
|
+
} else if (
|
|
734
|
+
// don't do this on initial render as it can cause non-hydrated content to be removed
|
|
735
|
+
!isInitialRender && BUILD.updatable && oldChildren !== null
|
|
736
|
+
) {
|
|
737
|
+
removeVnodes(oldChildren, 0, oldChildren.length - 1);
|
|
738
|
+
} else ;
|
|
739
|
+
} else if (oldVNode.$text$ !== text) {
|
|
740
|
+
elm.data = text;
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
var insertBefore = (parent, newNode, reference) => {
|
|
744
|
+
{
|
|
745
|
+
return parent == null ? void 0 : parent.insertBefore(newNode, reference);
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
|
|
749
|
+
const hostElm = hostRef.$hostElement$;
|
|
750
|
+
const oldVNode = hostRef.$vnode$ || newVNode(null, null);
|
|
751
|
+
const isHostElement = isHost(renderFnResults);
|
|
752
|
+
const rootVnode = isHostElement ? renderFnResults : h(null, null, renderFnResults);
|
|
753
|
+
hostTagName = hostElm.tagName;
|
|
754
|
+
if (isInitialLoad && rootVnode.$attrs$) {
|
|
755
|
+
for (const key of Object.keys(rootVnode.$attrs$)) {
|
|
756
|
+
if (hostElm.hasAttribute(key) && !["key", "ref", "style", "class"].includes(key)) {
|
|
757
|
+
rootVnode.$attrs$[key] = hostElm[key];
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
rootVnode.$tag$ = null;
|
|
762
|
+
rootVnode.$flags$ |= 4 /* isHost */;
|
|
763
|
+
hostRef.$vnode$ = rootVnode;
|
|
764
|
+
rootVnode.$elm$ = oldVNode.$elm$ = hostElm.shadowRoot || hostElm ;
|
|
765
|
+
patch(oldVNode, rootVnode, isInitialLoad);
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
// src/runtime/update-component.ts
|
|
769
|
+
var attachToAncestor = (hostRef, ancestorComponent) => {
|
|
770
|
+
if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent["s-p"]) {
|
|
771
|
+
const index = ancestorComponent["s-p"].push(
|
|
772
|
+
new Promise(
|
|
773
|
+
(r) => hostRef.$onRenderResolve$ = () => {
|
|
774
|
+
ancestorComponent["s-p"].splice(index - 1, 1);
|
|
775
|
+
r();
|
|
776
|
+
}
|
|
777
|
+
)
|
|
778
|
+
);
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
var scheduleUpdate = (hostRef, isInitialLoad) => {
|
|
782
|
+
{
|
|
783
|
+
hostRef.$flags$ |= 16 /* isQueuedForUpdate */;
|
|
784
|
+
}
|
|
785
|
+
if (hostRef.$flags$ & 4 /* isWaitingForChildren */) {
|
|
786
|
+
hostRef.$flags$ |= 512 /* needsRerender */;
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$);
|
|
790
|
+
const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
|
|
791
|
+
if (isInitialLoad) {
|
|
792
|
+
queueMicrotask(() => {
|
|
793
|
+
dispatch();
|
|
794
|
+
});
|
|
795
|
+
return;
|
|
796
|
+
}
|
|
797
|
+
return writeTask(dispatch) ;
|
|
798
|
+
};
|
|
799
|
+
var dispatchHooks = (hostRef, isInitialLoad) => {
|
|
800
|
+
const elm = hostRef.$hostElement$;
|
|
801
|
+
const endSchedule = createTime("scheduleUpdate", hostRef.$cmpMeta$.$tagName$);
|
|
802
|
+
const instance = elm;
|
|
803
|
+
if (!instance) {
|
|
804
|
+
throw new Error(
|
|
805
|
+
`Can't render component <${elm.tagName.toLowerCase()} /> with invalid Stencil runtime! Make sure this imported component is compiled with a \`externalRuntime: true\` flag. For more information, please refer to https://stenciljs.com/docs/custom-elements#externalruntime`
|
|
806
|
+
);
|
|
807
|
+
}
|
|
808
|
+
let maybePromise;
|
|
809
|
+
if (isInitialLoad) {
|
|
810
|
+
maybePromise = safeCall(instance, "componentWillLoad", void 0, elm);
|
|
811
|
+
} else {
|
|
812
|
+
maybePromise = safeCall(instance, "componentWillUpdate", void 0, elm);
|
|
813
|
+
}
|
|
814
|
+
maybePromise = enqueue(maybePromise, () => safeCall(instance, "componentWillRender", void 0, elm));
|
|
815
|
+
endSchedule();
|
|
816
|
+
return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
817
|
+
};
|
|
818
|
+
var enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn).catch((err2) => {
|
|
819
|
+
console.error(err2);
|
|
820
|
+
fn();
|
|
821
|
+
}) : fn();
|
|
822
|
+
var isPromisey = (maybePromise) => maybePromise instanceof Promise || maybePromise && maybePromise.then && typeof maybePromise.then === "function";
|
|
823
|
+
var updateComponent = async (hostRef, instance, isInitialLoad) => {
|
|
824
|
+
var _a;
|
|
825
|
+
const elm = hostRef.$hostElement$;
|
|
826
|
+
const endUpdate = createTime("update", hostRef.$cmpMeta$.$tagName$);
|
|
827
|
+
const rc = elm["s-rc"];
|
|
828
|
+
if (isInitialLoad) {
|
|
829
|
+
attachStyles(hostRef);
|
|
830
|
+
}
|
|
831
|
+
const endRender = createTime("render", hostRef.$cmpMeta$.$tagName$);
|
|
832
|
+
{
|
|
833
|
+
callRender(hostRef, instance, elm, isInitialLoad);
|
|
834
|
+
}
|
|
835
|
+
if (rc) {
|
|
836
|
+
rc.map((cb) => cb());
|
|
837
|
+
elm["s-rc"] = void 0;
|
|
838
|
+
}
|
|
839
|
+
endRender();
|
|
840
|
+
endUpdate();
|
|
841
|
+
{
|
|
842
|
+
const childrenPromises = (_a = elm["s-p"]) != null ? _a : [];
|
|
843
|
+
const postUpdate = () => postUpdateComponent(hostRef);
|
|
844
|
+
if (childrenPromises.length === 0) {
|
|
845
|
+
postUpdate();
|
|
846
|
+
} else {
|
|
847
|
+
Promise.all(childrenPromises).then(postUpdate);
|
|
848
|
+
hostRef.$flags$ |= 4 /* isWaitingForChildren */;
|
|
849
|
+
childrenPromises.length = 0;
|
|
850
|
+
}
|
|
851
|
+
}
|
|
852
|
+
};
|
|
853
|
+
var callRender = (hostRef, instance, elm, isInitialLoad) => {
|
|
854
|
+
try {
|
|
855
|
+
instance = instance.render() ;
|
|
856
|
+
{
|
|
857
|
+
hostRef.$flags$ &= -17 /* isQueuedForUpdate */;
|
|
858
|
+
}
|
|
859
|
+
{
|
|
860
|
+
hostRef.$flags$ |= 2 /* hasRendered */;
|
|
861
|
+
}
|
|
862
|
+
{
|
|
863
|
+
{
|
|
864
|
+
{
|
|
865
|
+
renderVdom(hostRef, instance, isInitialLoad);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
} catch (e) {
|
|
870
|
+
consoleError(e, hostRef.$hostElement$);
|
|
871
|
+
}
|
|
872
|
+
return null;
|
|
873
|
+
};
|
|
874
|
+
var postUpdateComponent = (hostRef) => {
|
|
875
|
+
const tagName = hostRef.$cmpMeta$.$tagName$;
|
|
876
|
+
const elm = hostRef.$hostElement$;
|
|
877
|
+
const endPostUpdate = createTime("postUpdate", tagName);
|
|
878
|
+
const instance = elm;
|
|
879
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
880
|
+
safeCall(instance, "componentDidRender", void 0, elm);
|
|
881
|
+
if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
|
|
882
|
+
hostRef.$flags$ |= 64 /* hasLoadedComponent */;
|
|
883
|
+
{
|
|
884
|
+
addHydratedFlag(elm);
|
|
885
|
+
}
|
|
886
|
+
safeCall(instance, "componentDidLoad", void 0, elm);
|
|
887
|
+
endPostUpdate();
|
|
888
|
+
{
|
|
889
|
+
hostRef.$onReadyResolve$(elm);
|
|
890
|
+
if (!ancestorComponent) {
|
|
891
|
+
appDidLoad();
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
safeCall(instance, "componentDidUpdate", void 0, elm);
|
|
896
|
+
endPostUpdate();
|
|
897
|
+
}
|
|
898
|
+
{
|
|
899
|
+
if (hostRef.$onRenderResolve$) {
|
|
900
|
+
hostRef.$onRenderResolve$();
|
|
901
|
+
hostRef.$onRenderResolve$ = void 0;
|
|
902
|
+
}
|
|
903
|
+
if (hostRef.$flags$ & 512 /* needsRerender */) {
|
|
904
|
+
nextTick(() => scheduleUpdate(hostRef, false));
|
|
905
|
+
}
|
|
906
|
+
hostRef.$flags$ &= -517;
|
|
907
|
+
}
|
|
908
|
+
};
|
|
909
|
+
var appDidLoad = (who) => {
|
|
910
|
+
nextTick(() => emitEvent(win, "appload", { detail: { namespace: NAMESPACE } }));
|
|
911
|
+
};
|
|
912
|
+
var safeCall = (instance, method, arg, elm) => {
|
|
913
|
+
if (instance && instance[method]) {
|
|
914
|
+
try {
|
|
915
|
+
return instance[method](arg);
|
|
916
|
+
} catch (e) {
|
|
917
|
+
consoleError(e, elm);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return void 0;
|
|
921
|
+
};
|
|
922
|
+
var addHydratedFlag = (elm) => {
|
|
923
|
+
var _a;
|
|
924
|
+
return elm.classList.add((_a = BUILD.hydratedSelectorName) != null ? _a : "hydrated") ;
|
|
925
|
+
};
|
|
926
|
+
|
|
927
|
+
// src/runtime/set-value.ts
|
|
928
|
+
var getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
|
|
929
|
+
var setValue = (ref, propName, newVal, cmpMeta) => {
|
|
930
|
+
const hostRef = getHostRef(ref);
|
|
931
|
+
if (!hostRef) {
|
|
932
|
+
return;
|
|
933
|
+
}
|
|
934
|
+
const elm = ref;
|
|
935
|
+
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
936
|
+
const flags = hostRef.$flags$;
|
|
937
|
+
const instance = elm;
|
|
938
|
+
newVal = parsePropertyValue(
|
|
939
|
+
newVal,
|
|
940
|
+
cmpMeta.$members$[propName][0]);
|
|
941
|
+
const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
|
|
942
|
+
const didValueChange = newVal !== oldVal && !areBothNaN;
|
|
943
|
+
if (didValueChange) {
|
|
944
|
+
hostRef.$instanceValues$.set(propName, newVal);
|
|
945
|
+
{
|
|
946
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
947
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
948
|
+
if (watchMethods) {
|
|
949
|
+
watchMethods.map((watchMethodName) => {
|
|
950
|
+
try {
|
|
951
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
952
|
+
} catch (e) {
|
|
953
|
+
consoleError(e, elm);
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
959
|
+
if (instance.componentShouldUpdate) {
|
|
960
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
961
|
+
return;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
scheduleUpdate(hostRef, false);
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
// src/runtime/proxy-component.ts
|
|
971
|
+
var proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
972
|
+
var _a, _b;
|
|
973
|
+
const prototype = Cstr.prototype;
|
|
974
|
+
if (cmpMeta.$members$ || (cmpMeta.$watchers$ || Cstr.watchers)) {
|
|
975
|
+
if (Cstr.watchers && !cmpMeta.$watchers$) {
|
|
976
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
977
|
+
}
|
|
978
|
+
const members = Object.entries((_a = cmpMeta.$members$) != null ? _a : {});
|
|
979
|
+
members.map(([memberName, [memberFlags]]) => {
|
|
980
|
+
if ((memberFlags & 31 /* Prop */ || memberFlags & 32 /* State */)) {
|
|
981
|
+
const { get: origGetter, set: origSetter } = Object.getOwnPropertyDescriptor(prototype, memberName) || {};
|
|
982
|
+
if (origGetter) cmpMeta.$members$[memberName][0] |= 2048 /* Getter */;
|
|
983
|
+
if (origSetter) cmpMeta.$members$[memberName][0] |= 4096 /* Setter */;
|
|
984
|
+
{
|
|
985
|
+
Object.defineProperty(prototype, memberName, {
|
|
986
|
+
get() {
|
|
987
|
+
{
|
|
988
|
+
return origGetter ? origGetter.apply(this) : getValue(this, memberName);
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
configurable: true,
|
|
992
|
+
enumerable: true
|
|
993
|
+
});
|
|
994
|
+
}
|
|
995
|
+
Object.defineProperty(prototype, memberName, {
|
|
996
|
+
set(newValue) {
|
|
997
|
+
const ref = getHostRef(this);
|
|
998
|
+
if (!ref) {
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
if (origSetter) {
|
|
1002
|
+
const currentValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
|
|
1003
|
+
if (typeof currentValue === "undefined" && ref.$instanceValues$.get(memberName)) {
|
|
1004
|
+
newValue = ref.$instanceValues$.get(memberName);
|
|
1005
|
+
} else if (!ref.$instanceValues$.get(memberName) && currentValue) {
|
|
1006
|
+
ref.$instanceValues$.set(memberName, currentValue);
|
|
1007
|
+
}
|
|
1008
|
+
origSetter.apply(this, [
|
|
1009
|
+
parsePropertyValue(
|
|
1010
|
+
newValue,
|
|
1011
|
+
memberFlags)
|
|
1012
|
+
]);
|
|
1013
|
+
newValue = memberFlags & 32 /* State */ ? this[memberName] : ref.$hostElement$[memberName];
|
|
1014
|
+
setValue(this, memberName, newValue, cmpMeta);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
{
|
|
1018
|
+
setValue(this, memberName, newValue, cmpMeta);
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
});
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
{
|
|
1026
|
+
const attrNameToPropName = /* @__PURE__ */ new Map();
|
|
1027
|
+
prototype.attributeChangedCallback = function(attrName, oldValue, newValue) {
|
|
1028
|
+
plt.jmp(() => {
|
|
1029
|
+
var _a2;
|
|
1030
|
+
const propName = attrNameToPropName.get(attrName);
|
|
1031
|
+
if (this.hasOwnProperty(propName) && BUILD.lazyLoad) ; else if (prototype.hasOwnProperty(propName) && typeof this[propName] === "number" && // cast type to number to avoid TS compiler issues
|
|
1032
|
+
this[propName] == newValue) {
|
|
1033
|
+
return;
|
|
1034
|
+
} else if (propName == null) {
|
|
1035
|
+
const hostRef = getHostRef(this);
|
|
1036
|
+
const flags2 = hostRef == null ? void 0 : hostRef.$flags$;
|
|
1037
|
+
if (hostRef && flags2 && !(flags2 & 8 /* isConstructingInstance */) && flags2 & 128 /* isWatchReady */ && newValue !== oldValue) {
|
|
1038
|
+
const elm = this;
|
|
1039
|
+
const instance = elm;
|
|
1040
|
+
const entry = (_a2 = cmpMeta.$watchers$) == null ? void 0 : _a2[attrName];
|
|
1041
|
+
entry == null ? void 0 : entry.forEach((callbackName) => {
|
|
1042
|
+
if (instance[callbackName] != null) {
|
|
1043
|
+
instance[callbackName].call(instance, newValue, oldValue, attrName);
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
return;
|
|
1048
|
+
}
|
|
1049
|
+
const propDesc = Object.getOwnPropertyDescriptor(prototype, propName);
|
|
1050
|
+
newValue = newValue === null && typeof this[propName] === "boolean" ? false : newValue;
|
|
1051
|
+
if (newValue !== this[propName] && (!propDesc.get || !!propDesc.set)) {
|
|
1052
|
+
this[propName] = newValue;
|
|
1053
|
+
}
|
|
1054
|
+
});
|
|
1055
|
+
};
|
|
1056
|
+
Cstr.observedAttributes = Array.from(
|
|
1057
|
+
/* @__PURE__ */ new Set([
|
|
1058
|
+
...Object.keys((_b = cmpMeta.$watchers$) != null ? _b : {}),
|
|
1059
|
+
...members.filter(([_, m]) => m[0] & 31 /* HasAttribute */).map(([propName, m]) => {
|
|
1060
|
+
const attrName = m[1] || propName;
|
|
1061
|
+
attrNameToPropName.set(attrName, propName);
|
|
1062
|
+
return attrName;
|
|
1063
|
+
})
|
|
1064
|
+
])
|
|
1065
|
+
);
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return Cstr;
|
|
1069
|
+
};
|
|
1070
|
+
|
|
1071
|
+
// src/runtime/initialize-component.ts
|
|
1072
|
+
var initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
|
|
1073
|
+
let Cstr;
|
|
1074
|
+
if ((hostRef.$flags$ & 32 /* hasInitializedComponent */) === 0) {
|
|
1075
|
+
hostRef.$flags$ |= 32 /* hasInitializedComponent */;
|
|
1076
|
+
{
|
|
1077
|
+
Cstr = elm.constructor;
|
|
1078
|
+
const cmpTag = elm.localName;
|
|
1079
|
+
const setWatchIsReady = () => hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1080
|
+
if (!!customElements.get(cmpTag)) {
|
|
1081
|
+
setWatchIsReady();
|
|
1082
|
+
} else {
|
|
1083
|
+
customElements.whenDefined(cmpTag).then(setWatchIsReady);
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
if (Cstr && Cstr.style) {
|
|
1087
|
+
let style;
|
|
1088
|
+
if (typeof Cstr.style === "string") {
|
|
1089
|
+
style = Cstr.style;
|
|
1090
|
+
}
|
|
1091
|
+
const scopeId2 = getScopeId(cmpMeta);
|
|
1092
|
+
if (!styles.has(scopeId2)) {
|
|
1093
|
+
const endRegisterStyles = createTime("registerStyles", cmpMeta.$tagName$);
|
|
1094
|
+
registerStyle(scopeId2, style, !!(cmpMeta.$flags$ & 1 /* shadowDomEncapsulation */));
|
|
1095
|
+
endRegisterStyles();
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
const ancestorComponent = hostRef.$ancestorComponent$;
|
|
1100
|
+
const schedule = () => scheduleUpdate(hostRef, true);
|
|
1101
|
+
if (ancestorComponent && ancestorComponent["s-rc"]) {
|
|
1102
|
+
ancestorComponent["s-rc"].push(schedule);
|
|
1103
|
+
} else {
|
|
1104
|
+
schedule();
|
|
1105
|
+
}
|
|
1106
|
+
};
|
|
1107
|
+
var fireConnectedCallback = (instance, elm) => {
|
|
1108
|
+
};
|
|
1109
|
+
|
|
1110
|
+
// src/runtime/connected-callback.ts
|
|
1111
|
+
var connectedCallback = (elm) => {
|
|
1112
|
+
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1113
|
+
const hostRef = getHostRef(elm);
|
|
1114
|
+
if (!hostRef) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const cmpMeta = hostRef.$cmpMeta$;
|
|
1118
|
+
const endConnected = createTime("connectedCallback", cmpMeta.$tagName$);
|
|
1119
|
+
if (!(hostRef.$flags$ & 1 /* hasConnected */)) {
|
|
1120
|
+
hostRef.$flags$ |= 1 /* hasConnected */;
|
|
1121
|
+
{
|
|
1122
|
+
let ancestorComponent = elm;
|
|
1123
|
+
while (ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host) {
|
|
1124
|
+
if (ancestorComponent["s-p"]) {
|
|
1125
|
+
attachToAncestor(hostRef, hostRef.$ancestorComponent$ = ancestorComponent);
|
|
1126
|
+
break;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
if (cmpMeta.$members$) {
|
|
1131
|
+
Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
|
|
1132
|
+
if (memberFlags & 31 /* Prop */ && elm.hasOwnProperty(memberName)) {
|
|
1133
|
+
const value = elm[memberName];
|
|
1134
|
+
delete elm[memberName];
|
|
1135
|
+
elm[memberName] = value;
|
|
1136
|
+
}
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1139
|
+
{
|
|
1140
|
+
initializeComponent(elm, hostRef, cmpMeta);
|
|
1141
|
+
}
|
|
1142
|
+
} else {
|
|
1143
|
+
if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
|
|
1144
|
+
hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
endConnected();
|
|
1148
|
+
}
|
|
1149
|
+
};
|
|
1150
|
+
var disconnectedCallback = async (elm) => {
|
|
1151
|
+
if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
|
|
1152
|
+
getHostRef(elm);
|
|
1153
|
+
}
|
|
1154
|
+
if (rootAppliedStyles.has(elm)) {
|
|
1155
|
+
rootAppliedStyles.delete(elm);
|
|
1156
|
+
}
|
|
1157
|
+
if (elm.shadowRoot && rootAppliedStyles.has(elm.shadowRoot)) {
|
|
1158
|
+
rootAppliedStyles.delete(elm.shadowRoot);
|
|
1159
|
+
}
|
|
1160
|
+
};
|
|
1161
|
+
var proxyCustomElement = (Cstr, compactMeta) => {
|
|
1162
|
+
const cmpMeta = {
|
|
1163
|
+
$flags$: compactMeta[0],
|
|
1164
|
+
$tagName$: compactMeta[1]
|
|
1165
|
+
};
|
|
1166
|
+
{
|
|
1167
|
+
cmpMeta.$members$ = compactMeta[2];
|
|
1168
|
+
}
|
|
1169
|
+
{
|
|
1170
|
+
cmpMeta.$watchers$ = Cstr.$watchers$;
|
|
1171
|
+
}
|
|
1172
|
+
const originalConnectedCallback = Cstr.prototype.connectedCallback;
|
|
1173
|
+
const originalDisconnectedCallback = Cstr.prototype.disconnectedCallback;
|
|
1174
|
+
Object.assign(Cstr.prototype, {
|
|
1175
|
+
__hasHostListenerAttached: false,
|
|
1176
|
+
__registerHost() {
|
|
1177
|
+
registerHost(this, cmpMeta);
|
|
1178
|
+
},
|
|
1179
|
+
connectedCallback() {
|
|
1180
|
+
if (!this.__hasHostListenerAttached) {
|
|
1181
|
+
const hostRef = getHostRef(this);
|
|
1182
|
+
if (!hostRef) {
|
|
1183
|
+
return;
|
|
1184
|
+
}
|
|
1185
|
+
this.__hasHostListenerAttached = true;
|
|
1186
|
+
}
|
|
1187
|
+
connectedCallback(this);
|
|
1188
|
+
if (originalConnectedCallback) {
|
|
1189
|
+
originalConnectedCallback.call(this);
|
|
1190
|
+
}
|
|
1191
|
+
},
|
|
1192
|
+
disconnectedCallback() {
|
|
1193
|
+
disconnectedCallback(this);
|
|
1194
|
+
if (originalDisconnectedCallback) {
|
|
1195
|
+
originalDisconnectedCallback.call(this);
|
|
1196
|
+
}
|
|
1197
|
+
},
|
|
1198
|
+
__attachShadow() {
|
|
1199
|
+
{
|
|
1200
|
+
if (!this.shadowRoot) {
|
|
1201
|
+
createShadowRoot.call(this, cmpMeta);
|
|
1202
|
+
} else {
|
|
1203
|
+
if (this.shadowRoot.mode !== "open") {
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
`Unable to re-use existing shadow root for ${cmpMeta.$tagName$}! Mode is set to ${this.shadowRoot.mode} but Stencil only supports open shadow roots.`
|
|
1206
|
+
);
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
});
|
|
1212
|
+
Cstr.is = cmpMeta.$tagName$;
|
|
1213
|
+
return proxyComponent(Cstr, cmpMeta);
|
|
1214
|
+
};
|
|
1215
|
+
|
|
1216
|
+
// src/runtime/nonce.ts
|
|
1217
|
+
var setNonce = (nonce) => plt.$nonce$ = nonce;
|
|
1218
|
+
|
|
1219
|
+
// src/runtime/platform-options.ts
|
|
1220
|
+
var setPlatformOptions = (opts) => Object.assign(plt, opts);
|
|
1221
|
+
|
|
1222
|
+
// src/runtime/render.ts
|
|
1223
|
+
function render(vnode, container) {
|
|
1224
|
+
const ref = {
|
|
1225
|
+
$hostElement$: container
|
|
1226
|
+
};
|
|
1227
|
+
renderVdom(ref, vnode);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
const chatWidgetScss = ":host {\n --primary-color: #2d3e50;\n --accent-color: #4e8cff;\n --widget-width: 350px;\n --widget-height: 500px;\n --font-family: 'Segoe UI', Arial, sans-serif;\n \n position: fixed;\n z-index: 10000;\n font-family: var(--font-family);\n}\n\n.chat-widget {\n position: fixed !important;\n width: var(--widget-width);\n height: var(--widget-height);\n background: white;\n border-radius: 16px;\n box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);\n overflow: hidden;\n transition: all 0.3s ease;\n display: flex;\n flex-direction: column;\n\n &.position-bottom-right {\n bottom: 20px !important;\n right: 20px !important;\n top: auto !important;\n left: auto !important;\n }\n\n &.position-bottom-left {\n bottom: 20px !important;\n left: 20px !important;\n top: auto !important;\n right: auto !important;\n }\n\n &.position-top-right {\n top: 20px !important;\n right: 20px !important;\n bottom: auto !important;\n left: auto !important;\n }\n\n &.position-top-left {\n top: 20px !important;\n left: 20px !important;\n bottom: auto !important;\n right: auto !important;\n }\n\n &.minimized {\n width: 60px !important;\n height: 60px !important;\n border-radius: 50% !important;\n cursor: pointer;\n\n .chat-header,\n .messages-container,\n .input-container,\n .tabs,\n .powered-by {\n display: none;\n }\n\n .minimize-icon {\n display: flex !important;\n }\n }\n\n &.hidden {\n display: none !important;\n }\n}\n\n.chat-header {\n background: var(--primary-color);\n color: white;\n padding: 16px;\n display: flex;\n align-items: center;\n justify-content: space-between;\n flex-shrink: 0;\n\n .agent-info {\n display: flex;\n align-items: center;\n gap: 12px;\n\n .agent-avatar {\n width: 44px;\n height: 44px;\n border-radius: 50%;\n border: 2px solid rgba(255, 255, 255, 0.3);\n object-fit: cover;\n }\n\n .agent-details {\n h4 {\n margin: 0;\n font-size: 1.1em;\n font-weight: 600;\n }\n\n p {\n margin: 0;\n font-size: 0.95em;\n opacity: 0.8;\n }\n }\n }\n\n .controls {\n display: flex;\n gap: 6px;\n\n .control-btn {\n background: rgba(0, 0, 0, 0.1);\n border: none;\n color: #fff;\n width: 28px;\n height: 28px;\n border-radius: 50%;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.1em;\n transition: background 0.2s;\n\n &:hover {\n background: rgba(0, 0, 0, 0.2);\n }\n\n &.close-btn {\n &:hover {\n background: rgba(255, 0, 0, 0.3);\n }\n }\n }\n }\n}\n\n.messages-container {\n flex: 1;\n overflow-y: auto;\n padding: 18px 16px 12px 16px;\n background: #f7f7f7;\n display: flex;\n flex-direction: column;\n gap: 16px;\n\n .message {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n\n &.user {\n flex-direction: row-reverse;\n }\n\n .message-avatar {\n width: 28px;\n height: 28px;\n border-radius: 50%;\n flex-shrink: 0;\n object-fit: cover;\n border: 1px solid #eee;\n }\n\n .message-content {\n max-width: 70%;\n\n .message-text {\n padding: 10px 14px;\n border-radius: 10px;\n font-size: 1em;\n line-height: 1.4;\n }\n\n .message-time {\n font-size: 11px;\n opacity: 0.6;\n margin-top: 4px;\n }\n }\n\n &.agent .message-content .message-text {\n background: #eafbe7;\n color: #222;\n border-radius: 10px 10px 10px 0;\n }\n\n &.user .message-content .message-text {\n background: #e6f4ff;\n color: #222;\n border-radius: 10px 10px 0 10px;\n }\n }\n\n .typing-indicator {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 8px 16px;\n font-size: 12px;\n color: #666;\n font-style: italic;\n\n .typing-dots {\n display: flex;\n gap: 2px;\n\n .dot {\n width: 4px;\n height: 4px;\n border-radius: 50%;\n background: #666;\n animation: typing 1.4s infinite;\n\n &:nth-child(2) {\n animation-delay: 0.2s;\n }\n\n &:nth-child(3) {\n animation-delay: 0.4s;\n }\n }\n }\n }\n}\n\n.input-container {\n background: #fff;\n border-top: 1px solid #eee;\n padding: 10px 12px 8px 12px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex-shrink: 0;\n\n .message-input {\n flex: 1;\n border: 1px solid #e0e0e0;\n border-radius: 20px;\n padding: 8px 14px;\n font-size: 1em;\n outline: none;\n background: #fafbfc;\n font-family: var(--font-family);\n\n &:focus {\n border-color: var(--accent-color);\n }\n }\n\n .send-btn {\n background: var(--primary-color);\n color: #fff;\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n box-shadow: 0 1px 4px rgba(0, 0, 0, 0.07);\n transition: opacity 0.2s;\n position: relative;\n\n &:hover {\n opacity: 0.9;\n }\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n\n .feature-btn {\n background: var(--primary-color);\n color: var(--accent-color);\n border: none;\n border-radius: 50%;\n width: 36px;\n height: 36px;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 1.2em;\n position: relative;\n\n // Show fallback icons by default\n i {\n font-size: 1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1em;\n display: block;\n }\n }\n}\n\n.tabs {\n background: #f8f8f8;\n border-top: 1.5px solid #e0e7ff;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: space-around;\n height: 48px;\n flex-shrink: 0;\n\n .tab {\n flex: 1;\n text-align: center;\n padding: 7px 0;\n color: var(--primary-color);\n font-weight: 600;\n cursor: pointer;\n transition: background 0.2s;\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 2px;\n\n &:hover {\n background: rgba(0, 0, 0, 0.05);\n }\n\n // Show fallback icons by default\n i {\n font-size: 1.1em;\n display: none;\n }\n\n .fallback-icon {\n font-size: 1.1em;\n display: block;\n }\n\n span:not(.fallback-icon) {\n font-size: 0.91em;\n }\n }\n}\n\n.powered-by {\n text-align: center;\n font-size: 0.95em;\n color: #aaa;\n padding: 7px 0 3px 0;\n background: #fff;\n border-top: 1px solid #f3f3f3;\n flex-shrink: 0;\n\n img {\n height: 18px;\n vertical-align: middle;\n margin-right: 6px;\n opacity: 0.85;\n object-fit: contain;\n }\n\n span {\n font-weight: 500;\n }\n}\n\n.minimize-icon {\n display: none;\n align-items: center;\n justify-content: center;\n width: 100%;\n height: 100%;\n font-size: 24px;\n color: white;\n background: var(--primary-color);\n border-radius: 50%;\n cursor: pointer;\n}\n\n@keyframes typing {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-10px);\n }\n}\n\n// Mobile responsiveness\n@media (max-width: 768px) {\n .chat-widget {\n width: 100% !important;\n height: 100% !important;\n top: 0 !important;\n left: 0 !important;\n right: 0 !important;\n bottom: 0 !important;\n border-radius: 0 !important;\n\n .messages-container {\n height: calc(100vh - 200px);\n }\n }\n}";
|
|
1231
|
+
|
|
1232
|
+
const ChatWidget = /*@__PURE__*/ proxyCustomElement(class ChatWidget extends H {
|
|
1233
|
+
constructor(registerHost) {
|
|
1234
|
+
super();
|
|
1235
|
+
if (registerHost !== false) {
|
|
1236
|
+
this.__registerHost();
|
|
1237
|
+
}
|
|
1238
|
+
this.__attachShadow();
|
|
1239
|
+
this.messageSent = createEvent(this, "messageSent");
|
|
1240
|
+
this.widgetOpened = createEvent(this, "widgetOpened");
|
|
1241
|
+
this.widgetClosed = createEvent(this, "widgetClosed");
|
|
1242
|
+
// Configuration props
|
|
1243
|
+
this.config = {};
|
|
1244
|
+
this.agentName = 'Support Agent';
|
|
1245
|
+
this.agentRole = 'Customer Support';
|
|
1246
|
+
this.agentAvatar = 'https://ui-avatars.com/api/?name=Agent&background=2d3e50&color=ffffff&size=44';
|
|
1247
|
+
this.primaryColor = '#2d3e50';
|
|
1248
|
+
this.accentColor = '#4e8cff';
|
|
1249
|
+
this.welcomeMessage = 'Hi! How can I help you today?';
|
|
1250
|
+
this.position = 'bottom-right';
|
|
1251
|
+
this.showMinimizeButton = true;
|
|
1252
|
+
this.enableFileUpload = false;
|
|
1253
|
+
this.enableSpeech = false;
|
|
1254
|
+
this.showTimestamps = true;
|
|
1255
|
+
this.apiEndpoint = '';
|
|
1256
|
+
this.apiKey = '';
|
|
1257
|
+
this.placeholderText = 'Type your message...';
|
|
1258
|
+
this.thankYouMessage = 'Thank you for chatting with us!';
|
|
1259
|
+
this.showPoweredBy = true;
|
|
1260
|
+
this.poweredByLogo = 'https://innovationincubator.com/wp-content/uploads/2023/05/Innovation-Incubator-logo.png';
|
|
1261
|
+
this.poweredByText = 'Powered by';
|
|
1262
|
+
this.poweredByBrand = 'NerdAgent';
|
|
1263
|
+
this.poweredByColor = '#4e8cff';
|
|
1264
|
+
this.width = 350;
|
|
1265
|
+
this.height = 500;
|
|
1266
|
+
this.fontFamily = 'Segoe UI, Arial, sans-serif';
|
|
1267
|
+
// State
|
|
1268
|
+
this.messages = [];
|
|
1269
|
+
this.isMinimized = false;
|
|
1270
|
+
this.isTyping = false;
|
|
1271
|
+
this.inputValue = '';
|
|
1272
|
+
this.isChatOpen = true;
|
|
1273
|
+
this.currentPosition = 'bottom-right';
|
|
1274
|
+
this.messageIdCounter = 0;
|
|
1275
|
+
}
|
|
1276
|
+
componentDidLoad() {
|
|
1277
|
+
// Initialize position
|
|
1278
|
+
this.currentPosition = this.position;
|
|
1279
|
+
// Load Font Awesome if not already loaded
|
|
1280
|
+
this.loadFontAwesome();
|
|
1281
|
+
// Add welcome message
|
|
1282
|
+
if (this.getConfig().welcomeMessage) {
|
|
1283
|
+
setTimeout(() => {
|
|
1284
|
+
this.addMessage(this.getConfig().welcomeMessage, false);
|
|
1285
|
+
}, 500);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
configChanged() {
|
|
1289
|
+
// React to config changes - Stencil automatically re-renders when @Prop changes
|
|
1290
|
+
// No need to manually trigger re-render
|
|
1291
|
+
}
|
|
1292
|
+
positionChanged() {
|
|
1293
|
+
// Force re-render when position changes
|
|
1294
|
+
console.log('Position changed to:', this.position);
|
|
1295
|
+
this.currentPosition = this.position;
|
|
1296
|
+
// Debug: Check what styles are applied
|
|
1297
|
+
setTimeout(() => {
|
|
1298
|
+
const widgetEl = this.el.shadowRoot.querySelector('.chat-widget');
|
|
1299
|
+
if (widgetEl) {
|
|
1300
|
+
console.log('Widget classes:', widgetEl.className);
|
|
1301
|
+
console.log('Widget inline styles:', widgetEl.style.cssText);
|
|
1302
|
+
console.log('Widget computed styles:', {
|
|
1303
|
+
position: window.getComputedStyle(widgetEl).position,
|
|
1304
|
+
top: window.getComputedStyle(widgetEl).top,
|
|
1305
|
+
right: window.getComputedStyle(widgetEl).right,
|
|
1306
|
+
bottom: window.getComputedStyle(widgetEl).bottom,
|
|
1307
|
+
left: window.getComputedStyle(widgetEl).left
|
|
1308
|
+
});
|
|
1309
|
+
}
|
|
1310
|
+
}, 100);
|
|
1311
|
+
}
|
|
1312
|
+
getConfig() {
|
|
1313
|
+
return Object.assign({ agentName: this.agentName, agentRole: this.agentRole, agentAvatar: this.agentAvatar, primaryColor: this.primaryColor, accentColor: this.accentColor, welcomeMessage: this.welcomeMessage, position: this.position, showMinimizeButton: this.showMinimizeButton, enableFileUpload: this.enableFileUpload, enableSpeech: this.enableSpeech, showTimestamps: this.showTimestamps, apiEndpoint: this.apiEndpoint, apiKey: this.apiKey, placeholderText: this.placeholderText, thankYouMessage: this.thankYouMessage, showPoweredBy: this.showPoweredBy, poweredByLogo: this.poweredByLogo, poweredByText: this.poweredByText, poweredByBrand: this.poweredByBrand, poweredByColor: this.poweredByColor, width: this.width, height: this.height, fontFamily: this.fontFamily }, this.config);
|
|
1314
|
+
}
|
|
1315
|
+
loadFontAwesome() {
|
|
1316
|
+
if (!document.getElementById('fa-cdn-stencil')) {
|
|
1317
|
+
const link = document.createElement('link');
|
|
1318
|
+
link.id = 'fa-cdn-stencil';
|
|
1319
|
+
link.rel = 'stylesheet';
|
|
1320
|
+
link.href = 'https://use.fontawesome.com/releases/v6.4.2/css/all.css';
|
|
1321
|
+
link.crossOrigin = 'anonymous';
|
|
1322
|
+
document.head.appendChild(link);
|
|
1323
|
+
console.log('Loading FontAwesome...');
|
|
1324
|
+
}
|
|
1325
|
+
else {
|
|
1326
|
+
console.log('FontAwesome already loaded');
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
addMessage(text, isUser = false) {
|
|
1330
|
+
const message = {
|
|
1331
|
+
id: `msg-${++this.messageIdCounter}`,
|
|
1332
|
+
text,
|
|
1333
|
+
isUser,
|
|
1334
|
+
timestamp: new Date()
|
|
1335
|
+
};
|
|
1336
|
+
this.messages = [...this.messages, message];
|
|
1337
|
+
}
|
|
1338
|
+
async sendMessage() {
|
|
1339
|
+
const text = this.inputValue.trim();
|
|
1340
|
+
if (!text)
|
|
1341
|
+
return;
|
|
1342
|
+
this.addMessage(text, true);
|
|
1343
|
+
this.inputValue = '';
|
|
1344
|
+
// Emit event
|
|
1345
|
+
this.messageSent.emit({ message: text, widget: this.el });
|
|
1346
|
+
// Handle API or simulate response
|
|
1347
|
+
const config = this.getConfig();
|
|
1348
|
+
if (config.apiEndpoint) {
|
|
1349
|
+
await this.sendToAPI(text);
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
this.simulateResponse();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
async sendToAPI(message) {
|
|
1356
|
+
const config = this.getConfig();
|
|
1357
|
+
this.isTyping = true;
|
|
1358
|
+
try {
|
|
1359
|
+
const response = await fetch(config.apiEndpoint, {
|
|
1360
|
+
method: 'POST',
|
|
1361
|
+
headers: Object.assign({ 'Content-Type': 'application/json' }, (config.apiKey && { 'Authorization': `Bearer ${config.apiKey}` })),
|
|
1362
|
+
body: JSON.stringify({
|
|
1363
|
+
message,
|
|
1364
|
+
timestamp: new Date().toISOString(),
|
|
1365
|
+
sessionId: this.getSessionId()
|
|
1366
|
+
})
|
|
1367
|
+
});
|
|
1368
|
+
const data = await response.json();
|
|
1369
|
+
this.isTyping = false;
|
|
1370
|
+
if (data.response) {
|
|
1371
|
+
this.addMessage(data.response, false);
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
catch (error) {
|
|
1375
|
+
this.isTyping = false;
|
|
1376
|
+
this.addMessage('Sorry, I encountered an error. Please try again.', false);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
simulateResponse() {
|
|
1380
|
+
const responses = [
|
|
1381
|
+
"Thanks for your message! How can I help you further?",
|
|
1382
|
+
"I understand. Let me assist you with that.",
|
|
1383
|
+
"That's a great question! Let me help you.",
|
|
1384
|
+
"I'm here to help! Could you provide more details?"
|
|
1385
|
+
];
|
|
1386
|
+
this.isTyping = true;
|
|
1387
|
+
setTimeout(() => {
|
|
1388
|
+
this.isTyping = false;
|
|
1389
|
+
const response = responses[Math.floor(Math.random() * responses.length)];
|
|
1390
|
+
this.addMessage(response, false);
|
|
1391
|
+
}, 1500);
|
|
1392
|
+
}
|
|
1393
|
+
toggleMinimize() {
|
|
1394
|
+
this.isMinimized = !this.isMinimized;
|
|
1395
|
+
if (this.isMinimized) {
|
|
1396
|
+
this.widgetClosed.emit({ widget: this.el });
|
|
1397
|
+
}
|
|
1398
|
+
else {
|
|
1399
|
+
this.widgetOpened.emit({ widget: this.el });
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
closeWidget() {
|
|
1403
|
+
this.isChatOpen = false;
|
|
1404
|
+
this.widgetClosed.emit({ widget: this.el });
|
|
1405
|
+
}
|
|
1406
|
+
openWidget() {
|
|
1407
|
+
this.isChatOpen = true;
|
|
1408
|
+
this.isMinimized = false;
|
|
1409
|
+
this.widgetOpened.emit({ widget: this.el });
|
|
1410
|
+
}
|
|
1411
|
+
handleKeyPress(event) {
|
|
1412
|
+
if (event.key === 'Enter') {
|
|
1413
|
+
this.sendMessage();
|
|
1414
|
+
}
|
|
1415
|
+
}
|
|
1416
|
+
handleInputChange(event) {
|
|
1417
|
+
const target = event.target;
|
|
1418
|
+
this.inputValue = target.value;
|
|
1419
|
+
}
|
|
1420
|
+
getSessionId() {
|
|
1421
|
+
let sessionId = localStorage.getItem('nerd-chat-session');
|
|
1422
|
+
if (!sessionId) {
|
|
1423
|
+
sessionId = 'session-' + Math.random().toString(36).substr(2, 9);
|
|
1424
|
+
localStorage.setItem('nerd-chat-session', sessionId);
|
|
1425
|
+
}
|
|
1426
|
+
return sessionId;
|
|
1427
|
+
}
|
|
1428
|
+
formatTime(date) {
|
|
1429
|
+
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
|
1430
|
+
}
|
|
1431
|
+
render() {
|
|
1432
|
+
const config = this.getConfig();
|
|
1433
|
+
console.log('Rendering with position:', this.currentPosition);
|
|
1434
|
+
// Get position styles directly
|
|
1435
|
+
const getPositionStyles = () => {
|
|
1436
|
+
switch (this.currentPosition) {
|
|
1437
|
+
case 'bottom-left':
|
|
1438
|
+
return { bottom: '20px', left: '20px', top: 'auto', right: 'auto' };
|
|
1439
|
+
case 'top-right':
|
|
1440
|
+
return { top: '20px', right: '20px', bottom: 'auto', left: 'auto' };
|
|
1441
|
+
case 'top-left':
|
|
1442
|
+
return { top: '20px', left: '20px', bottom: 'auto', right: 'auto' };
|
|
1443
|
+
case 'bottom-right':
|
|
1444
|
+
default:
|
|
1445
|
+
return { bottom: '20px', right: '20px', top: 'auto', left: 'auto' };
|
|
1446
|
+
}
|
|
1447
|
+
};
|
|
1448
|
+
const widgetClasses = {
|
|
1449
|
+
'chat-widget': true,
|
|
1450
|
+
'minimized': this.isMinimized,
|
|
1451
|
+
'hidden': !this.isChatOpen
|
|
1452
|
+
};
|
|
1453
|
+
return (h(Host, null, h("div", { class: widgetClasses, style: Object.assign({ '--primary-color': config.primaryColor || '#2d3e50', '--accent-color': config.accentColor || '#4e8cff', '--widget-width': `${config.width || 350}px`, '--widget-height': `${config.height || 500}px`, '--font-family': config.fontFamily || 'Segoe UI, Arial, sans-serif' }, getPositionStyles()) }, h("div", { class: "chat-header" }, h("div", { class: "agent-info" }, h("img", { src: config.agentAvatar, alt: "Agent", class: "agent-avatar" }), h("div", { class: "agent-details" }, h("h4", null, config.agentName), h("p", null, config.agentRole))), h("div", { class: "controls" }, config.showMinimizeButton && (h("button", { class: "control-btn minimize-btn", onClick: () => this.toggleMinimize(), title: this.isMinimized ? 'Maximize' : 'Minimize' }, this.isMinimized ? '🔼' : '🔽')), h("button", { class: "control-btn close-btn", onClick: () => this.closeWidget(), title: "Close" }, "\u00D7"))), h("div", { class: "messages-container" }, this.messages.map(message => (h("div", { key: message.id, class: `message ${message.isUser ? 'user' : 'agent'}` }, h("img", { src: message.isUser ? 'https://ui-avatars.com/api/?name=User&background=4e8cff&color=ffffff&size=28' : config.agentAvatar, alt: message.isUser ? 'User' : 'Agent', class: "message-avatar" }), h("div", { class: "message-content" }, h("div", { class: "message-text" }, message.text), config.showTimestamps && (h("div", { class: "message-time" }, this.formatTime(message.timestamp))))))), this.isTyping && (h("div", { class: "typing-indicator" }, h("span", null, config.agentName, " is typing"), h("div", { class: "typing-dots" }, h("div", { class: "dot" }), h("div", { class: "dot" }), h("div", { class: "dot" }))))), h("div", { class: "input-container" }, h("input", { type: "text", class: "message-input", placeholder: config.placeholderText || 'Type your message...', value: this.inputValue, onInput: (e) => this.handleInputChange(e), onKeyPress: (e) => this.handleKeyPress(e) }), h("button", { class: "send-btn", onClick: () => this.sendMessage() }, h("i", { class: "fas fa-paper-plane" }), h("span", { class: "fallback-icon" }, "\u27A4")), config.enableFileUpload && (h("button", { class: "feature-btn file-upload" }, h("i", { class: "fas fa-paperclip" }), h("span", { class: "fallback-icon" }, "\uD83D\uDCCE"))), config.enableSpeech && (h("button", { class: "feature-btn speech" }, h("i", { class: "fas fa-microphone" }), h("span", { class: "fallback-icon" }, "\uD83C\uDFA4")))), h("div", { class: "tabs" }, h("div", { class: "tab active" }, h("i", { class: "fas fa-comment-dots" }), h("span", null, "Chat")), h("div", { class: "tab" }, h("i", { class: "fas fa-microphone" }), h("span", null, "Voice")), h("div", { class: "tab" }, h("i", { class: "fas fa-clock" }), h("span", null, "History"))), config.showPoweredBy && (h("div", { class: "powered-by" }, h("img", { src: config.poweredByLogo, alt: "Powered By Logo" }), config.poweredByText, " ", h("span", { style: { color: config.poweredByColor } }, config.poweredByBrand))), h("div", { class: "minimize-icon", onClick: () => this.isChatOpen ? this.toggleMinimize() : this.openWidget() }, "\uD83D\uDCAC"))));
|
|
1454
|
+
}
|
|
1455
|
+
get el() { return this; }
|
|
1456
|
+
static get watchers() { return {
|
|
1457
|
+
"config": ["configChanged"],
|
|
1458
|
+
"position": ["positionChanged"]
|
|
1459
|
+
}; }
|
|
1460
|
+
static get style() { return chatWidgetScss; }
|
|
1461
|
+
}, [257, "nerd-chat-widget", {
|
|
1462
|
+
"config": [16],
|
|
1463
|
+
"agentName": [1, "agent-name"],
|
|
1464
|
+
"agentRole": [1, "agent-role"],
|
|
1465
|
+
"agentAvatar": [1, "agent-avatar"],
|
|
1466
|
+
"primaryColor": [1, "primary-color"],
|
|
1467
|
+
"accentColor": [1, "accent-color"],
|
|
1468
|
+
"welcomeMessage": [1, "welcome-message"],
|
|
1469
|
+
"position": [1],
|
|
1470
|
+
"showMinimizeButton": [4, "show-minimize-button"],
|
|
1471
|
+
"enableFileUpload": [4, "enable-file-upload"],
|
|
1472
|
+
"enableSpeech": [4, "enable-speech"],
|
|
1473
|
+
"showTimestamps": [4, "show-timestamps"],
|
|
1474
|
+
"apiEndpoint": [1, "api-endpoint"],
|
|
1475
|
+
"apiKey": [1, "api-key"],
|
|
1476
|
+
"placeholderText": [1, "placeholder-text"],
|
|
1477
|
+
"thankYouMessage": [1, "thank-you-message"],
|
|
1478
|
+
"showPoweredBy": [4, "show-powered-by"],
|
|
1479
|
+
"poweredByLogo": [1, "powered-by-logo"],
|
|
1480
|
+
"poweredByText": [1, "powered-by-text"],
|
|
1481
|
+
"poweredByBrand": [1, "powered-by-brand"],
|
|
1482
|
+
"poweredByColor": [1, "powered-by-color"],
|
|
1483
|
+
"width": [2],
|
|
1484
|
+
"height": [2],
|
|
1485
|
+
"fontFamily": [1, "font-family"],
|
|
1486
|
+
"messages": [32],
|
|
1487
|
+
"isMinimized": [32],
|
|
1488
|
+
"isTyping": [32],
|
|
1489
|
+
"inputValue": [32],
|
|
1490
|
+
"isChatOpen": [32],
|
|
1491
|
+
"currentPosition": [32]
|
|
1492
|
+
}, undefined, {
|
|
1493
|
+
"config": ["configChanged"],
|
|
1494
|
+
"position": ["positionChanged"]
|
|
1495
|
+
}]);
|
|
1496
|
+
function defineCustomElement() {
|
|
1497
|
+
if (typeof customElements === "undefined") {
|
|
1498
|
+
return;
|
|
1499
|
+
}
|
|
1500
|
+
const components = ["nerd-chat-widget"];
|
|
1501
|
+
components.forEach(tagName => { switch (tagName) {
|
|
1502
|
+
case "nerd-chat-widget":
|
|
1503
|
+
if (!customElements.get(tagName)) {
|
|
1504
|
+
customElements.define(tagName, ChatWidget);
|
|
1505
|
+
}
|
|
1506
|
+
break;
|
|
1507
|
+
} });
|
|
1508
|
+
}
|
|
1509
|
+
defineCustomElement();
|
|
1510
|
+
|
|
1511
|
+
export { ChatWidget, defineCustomElement, getAssetPath, render, setAssetPath, setNonce, setPlatformOptions };
|
|
1512
|
+
//# sourceMappingURL=index.js.map
|
|
1513
|
+
|
|
1514
|
+
//# sourceMappingURL=index.js.map
|