@gengage/assistant-fe 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dist/api-paths-C4GDpeTf.js +1214 -0
  3. package/dist/chat/index.d.ts +1 -374
  4. package/dist/chat/runtime.d.ts +374 -0
  5. package/dist/chat/types.d.ts +1 -1
  6. package/dist/chat-BRKK63lt.js +303 -0
  7. package/dist/chat-runtime.js +13 -0
  8. package/dist/chat.iife.js +7 -7
  9. package/dist/chat.js +11 -10
  10. package/dist/common/config-constants.d.ts +1 -0
  11. package/dist/common/config-schema.d.ts +0 -1
  12. package/dist/common/overlay.d.ts +4 -4
  13. package/dist/common-CEN5OW7E.js +491 -0
  14. package/dist/common.js +78 -76
  15. package/dist/{connection-warning-n88bjkqL.js → connection-warning-B6oIU-9s.js} +1 -1
  16. package/dist/context-VIG4SVcS.js +529 -0
  17. package/dist/index.js +70 -67
  18. package/dist/locale-CfqNifrU.js +7 -0
  19. package/dist/native-webview-DudQ7nHe.js +273 -0
  20. package/dist/native.iife.js +28 -91
  21. package/dist/native.js +1 -1
  22. package/dist/overlay-1EO41ZC7.js +212 -0
  23. package/dist/overlay.d.ts +4 -0
  24. package/dist/overlay.js +10 -0
  25. package/dist/pill-launcher-57nrdLRr.js +364 -0
  26. package/dist/qna/index.d.ts +1 -61
  27. package/dist/qna/runtime.d.ts +61 -0
  28. package/dist/qna-BNvttR6s.js +40 -0
  29. package/dist/qna-runtime.js +8 -0
  30. package/dist/qna.iife.js +4 -4
  31. package/dist/qna.js +6 -5
  32. package/dist/{simrel-K2TGFi1r.js → runtime-BdwZZIrO.js} +244 -293
  33. package/dist/{chat-DI7Vm0gh.js → runtime-C0qZk0y7.js} +1644 -2298
  34. package/dist/{qna-C5Ok3wd0.js → runtime-DDu8Wk0z.js} +87 -121
  35. package/dist/schemas-CLo8wCjs.js +3207 -0
  36. package/dist/{simbut-Cb5RfaAp.js → simbut-BMWC6x_t.js} +24 -22
  37. package/dist/simbut.js +1 -1
  38. package/dist/simrel/index.d.ts +1 -59
  39. package/dist/simrel/runtime.d.ts +59 -0
  40. package/dist/simrel-ohfkluhp.js +55 -0
  41. package/dist/simrel-runtime.js +8 -0
  42. package/dist/simrel.iife.js +4 -4
  43. package/dist/simrel.js +7 -6
  44. package/dist/widget-base-TgwiA8cD.js +578 -0
  45. package/package.json +17 -1
  46. package/dist/common-BxSi3UWt.js +0 -387
  47. package/dist/locale-MM0U5eeR.js +0 -1109
  48. package/dist/native-webview-DFqnyus6.js +0 -586
  49. package/dist/schemas-JpRGzRQT.js +0 -4419
  50. /package/dist/{price-formatter-CR6VT5z4.js → price-formatter-xI3g9Cd4.js} +0 -0
package/dist/chat.js CHANGED
@@ -1,14 +1,15 @@
1
- import { c as e, f as t, i as r, l as s, m as n, n as i, o as l, p as C, r as c, s as h, t as o } from "./chat-DI7Vm0gh.js";
1
+ import { a as e, c as t, i as r, l as s, n as i, o as n, r as l, s as o, t as C, u as c } from "./runtime-C0qZk0y7.js";
2
+ import { t as p } from "./chat-BRKK63lt.js";
2
3
  export {
3
4
  t as CHAT_SCROLL_ELEMENT_ID,
4
- l as ChatPresentationState,
5
- o as GengageChat,
6
- r as chatCatalog,
5
+ r as ChatPresentationState,
6
+ C as GengageChat,
7
+ p as chatCatalog,
7
8
  i as createChatWidget,
8
- h as createDefaultChatUISpecRegistry,
9
- e as defaultChatUnknownUISpecRenderer,
10
- C as getChatScrollElement,
11
- n as invalidateChatScrollCache,
12
- c as isSimilarsAppendGrid,
13
- s as renderUISpec
9
+ e as createDefaultChatUISpecRegistry,
10
+ n as defaultChatUnknownUISpecRenderer,
11
+ s as getChatScrollElement,
12
+ c as invalidateChatScrollCache,
13
+ l as isSimilarsAppendGrid,
14
+ o as renderUISpec
14
15
  };
@@ -0,0 +1 @@
1
+ export declare const DEFAULT_IDEMPOTENCY_KEY = "__gengageWidgetsInit";
@@ -5,7 +5,6 @@ export declare const AnalyticsAuthModeSchema: z.ZodEnum<{
5
5
  "bearer-header": "bearer-header";
6
6
  "body-api-key": "body-api-key";
7
7
  }>;
8
- export declare const DEFAULT_IDEMPOTENCY_KEY = "__gengageWidgetsInit";
9
8
  export declare const UnknownActionPolicySchema: z.ZodEnum<{
10
9
  "log-and-ignore": "log-and-ignore";
11
10
  throw: "throw";
@@ -1,8 +1,8 @@
1
- import { GengageChat } from '../chat/index.js';
1
+ import { GengageChat } from '../chat/runtime.js';
2
2
  import { ChatI18n, ChatWidgetConfig } from '../chat/types.js';
3
- import { GengageQNA } from '../qna/index.js';
3
+ import { GengageQNA } from '../qna/runtime.js';
4
4
  import { QNAWidgetConfig } from '../qna/types.js';
5
- import { GengageSimRel } from '../simrel/index.js';
5
+ import { GengageSimRel } from '../simrel/runtime.js';
6
6
  import { SimRelWidgetConfig } from '../simrel/types.js';
7
7
  import { GengageSimBut } from '../simbut/index.js';
8
8
  import { SimButWidgetConfig } from '../simbut/types.js';
@@ -138,7 +138,7 @@ export interface OverlayWidgetsController {
138
138
  *
139
139
  * @example
140
140
  * ```ts
141
- * import { initOverlayWidgets } from '@gengage/assistant-fe';
141
+ * import { initOverlayWidgets } from '@gengage/assistant-fe/overlay';
142
142
  *
143
143
  * const controller = await initOverlayWidgets({
144
144
  * accountId: 'mystore',
@@ -0,0 +1,491 @@
1
+ import { n as w } from "./api-paths-C4GDpeTf.js";
2
+ import { n as f } from "./widget-base-TgwiA8cD.js";
3
+ import { a as h, c as s, i as b, o as d, r as u, t as p } from "./schemas-CLo8wCjs.js";
4
+ import { a as T, i as k } from "./overlay-1EO41ZC7.js";
5
+ var c = d({ enabled: u().default(!0) }), S = d({
6
+ chat: s().optional(),
7
+ qna: s().optional(),
8
+ simrel: s().optional(),
9
+ simbut: s().optional()
10
+ }), I = d({}), U = p([
11
+ "none",
12
+ "x-api-key-header",
13
+ "bearer-header",
14
+ "body-api-key"
15
+ ]), _ = d({
16
+ mode: U.default("none"),
17
+ key: s().optional(),
18
+ headerName: s().optional(),
19
+ bodyField: s().default("api_key")
20
+ }), A = d({
21
+ enabled: u().default(!0),
22
+ endpoint: s().default("/analytics"),
23
+ auth: _.default({
24
+ mode: "none",
25
+ bodyField: "api_key"
26
+ }),
27
+ fireAndForget: u().default(!0),
28
+ useBeacon: u().default(!0),
29
+ keepaliveFetch: u().default(!0),
30
+ timeoutMs: h().int().positive().default(4e3),
31
+ maxRetries: h().int().min(0).max(5).default(1)
32
+ }), C = d({
33
+ idempotencyKey: s().default(T),
34
+ requireDomReady: u().default(!0)
35
+ }), E = p([
36
+ "log-and-ignore",
37
+ "throw",
38
+ "delegate"
39
+ ]), P = d({
40
+ unknownActionPolicy: E.default("log-and-ignore"),
41
+ allowScriptCall: u().default(!1)
42
+ }), v = d({
43
+ version: b("1", { error: 'version must be "1"' }),
44
+ accountId: s({ error: "accountId must be a non-empty string" }).min(1, { error: "accountId must be a non-empty string" }),
45
+ middlewareUrl: s({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }).url({ error: 'middlewareUrl must be a valid URL (e.g. "https://your-backend.example.com")' }),
46
+ locale: s().optional(),
47
+ widgets: d({
48
+ chat: c.default({ enabled: !0 }),
49
+ qna: c.default({ enabled: !0 }),
50
+ simrel: c.optional(),
51
+ simbut: c.default({ enabled: !1 })
52
+ }),
53
+ mounts: S.default({}),
54
+ transport: I.default({}),
55
+ analytics: A.default({
56
+ enabled: !0,
57
+ endpoint: "/analytics",
58
+ auth: {
59
+ mode: "none",
60
+ bodyField: "api_key"
61
+ },
62
+ fireAndForget: !0,
63
+ useBeacon: !0,
64
+ keepaliveFetch: !0,
65
+ timeoutMs: 4e3,
66
+ maxRetries: 1
67
+ }),
68
+ gtm: C.default({
69
+ idempotencyKey: "__gengageWidgetsInit",
70
+ requireDomReady: !0
71
+ }),
72
+ actionHandling: P.default({
73
+ unknownActionPolicy: "log-and-ignore",
74
+ allowScriptCall: !1
75
+ })
76
+ });
77
+ function R(e) {
78
+ f("config", "parsing account runtime config", e);
79
+ const t = v.parse(e);
80
+ return f("config", "config resolved", {
81
+ accountId: t.accountId,
82
+ middlewareUrl: t.middlewareUrl
83
+ }), t;
84
+ }
85
+ function L(e) {
86
+ return v.safeParse(e);
87
+ }
88
+ function Y(e) {
89
+ return R({
90
+ version: "1",
91
+ accountId: e.accountId,
92
+ middlewareUrl: e.middlewareUrl,
93
+ locale: e.locale,
94
+ widgets: {
95
+ chat: { enabled: !0 },
96
+ qna: { enabled: !0 },
97
+ simbut: { enabled: !1 }
98
+ }
99
+ });
100
+ }
101
+ var q = {
102
+ enabled: !0,
103
+ endpoint: "/analytics",
104
+ fireAndForget: !0,
105
+ useBeacon: !0,
106
+ keepaliveFetch: !0,
107
+ timeoutMs: 4e3,
108
+ maxRetries: 0,
109
+ batchSize: 10,
110
+ flushIntervalMs: 250
111
+ }, F = {
112
+ mode: "none",
113
+ key: "",
114
+ headerName: "X-API-Key",
115
+ bodyField: "api_key"
116
+ }, D = class {
117
+ constructor(e) {
118
+ this.queue = [], this.flushTimer = null, this.config = {
119
+ ...q,
120
+ ...e,
121
+ auth: {
122
+ ...F,
123
+ ...e.auth ?? {}
124
+ }
125
+ }, this.onPageHideBound = () => {
126
+ this.queue.length !== 0 && this.flushAllSync();
127
+ }, typeof window < "u" && window.addEventListener("pagehide", this.onPageHideBound);
128
+ }
129
+ track(e) {
130
+ if (!this.config.enabled) return;
131
+ const t = O(e);
132
+ if (this.queue.push(t), this.queue.length >= this.config.batchSize) {
133
+ this.scheduleImmediateFlush();
134
+ return;
135
+ }
136
+ this.scheduleFlush();
137
+ }
138
+ flush() {
139
+ if (!this.config.enabled || this.queue.length === 0) return;
140
+ const e = this.queue.splice(0, this.config.batchSize), t = this.buildTransportBody(e), n = g(this.config.endpoint, this.config.middlewareUrl);
141
+ this.send(n, t);
142
+ }
143
+ flushAll() {
144
+ for (; this.queue.length > 0; ) this.flush();
145
+ }
146
+ destroy() {
147
+ this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null), this.queue.length > 0 && this.flushAllSync(), typeof window < "u" && window.removeEventListener("pagehide", this.onPageHideBound);
148
+ }
149
+ scheduleFlush() {
150
+ this.flushTimer || (this.flushTimer = setTimeout(() => {
151
+ this.flushTimer = null, this.flush();
152
+ }, this.config.flushIntervalMs));
153
+ }
154
+ scheduleImmediateFlush() {
155
+ this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null), this.flush();
156
+ }
157
+ buildTransportBody(e) {
158
+ const t = { events: e };
159
+ return this.config.auth.mode === "body-api-key" && this.config.auth.key && (t[this.config.auth.bodyField] = this.config.auth.key), t;
160
+ }
161
+ send(e, t) {
162
+ try {
163
+ const n = JSON.stringify(t);
164
+ if (this.config.useBeacon && this.config.auth.mode !== "x-api-key-header" && this.config.auth.mode !== "bearer-header" && y()) {
165
+ const o = new Blob([n], { type: "application/json" });
166
+ navigator.sendBeacon(e, o);
167
+ return;
168
+ }
169
+ if (typeof fetch > "u") return;
170
+ const i = { "Content-Type": "application/json" };
171
+ this.config.auth.mode === "x-api-key-header" && this.config.auth.key && (i[this.config.auth.headerName] = this.config.auth.key), this.config.auth.mode === "bearer-header" && this.config.auth.key && (i.Authorization = `Bearer ${this.config.auth.key}`), fetch(e, {
172
+ method: "POST",
173
+ headers: i,
174
+ body: n,
175
+ keepalive: !0
176
+ }).catch(() => {
177
+ });
178
+ } catch {
179
+ }
180
+ }
181
+ flushAllSync() {
182
+ if (!this.config.enabled) return;
183
+ const e = g(this.config.endpoint, this.config.middlewareUrl);
184
+ for (; this.queue.length > 0; ) {
185
+ const t = this.queue.splice(0, this.config.batchSize), n = this.buildTransportBody(t);
186
+ try {
187
+ const i = JSON.stringify(n);
188
+ if (y()) {
189
+ const o = new Blob([i], { type: "application/json" });
190
+ navigator.sendBeacon(e, o);
191
+ }
192
+ } catch {
193
+ }
194
+ }
195
+ }
196
+ };
197
+ function J(e) {
198
+ return new D(e);
199
+ }
200
+ function O(e) {
201
+ const t = {
202
+ event_name: e.event_name,
203
+ event_version: e.event_version ?? "1",
204
+ timestamp_ms: e.timestamp_ms ?? Date.now(),
205
+ account_id: e.account_id,
206
+ session_id: e.session_id,
207
+ correlation_id: e.correlation_id,
208
+ payload: e.payload
209
+ };
210
+ return e.view_id !== void 0 && (t.view_id = e.view_id), e.user_id !== void 0 && (t.user_id = e.user_id), e.widget !== void 0 && (t.widget = e.widget), e.page_type !== void 0 && (t.page_type = e.page_type), e.sku !== void 0 && (t.sku = e.sku), t;
211
+ }
212
+ function g(e, t) {
213
+ return /^https?:\/\//i.test(e) ? e : `${w(t)}${e.startsWith("/") ? e : `/${e}`}`;
214
+ }
215
+ function y() {
216
+ return typeof navigator < "u" && typeof navigator.sendBeacon == "function";
217
+ }
218
+ var Q = "tr";
219
+ function V(e) {
220
+ return {
221
+ ACCOUNT_ID: e.accountId,
222
+ MIDDLEWARE_URL: e.middlewareUrl,
223
+ LOCALE: e.locale ?? "tr"
224
+ };
225
+ }
226
+ function X(e, t = {}) {
227
+ const n = {
228
+ accountId: e.accountId,
229
+ middlewareUrl: e.middlewareUrl,
230
+ session: { sessionId: e.sessionId },
231
+ variant: "floating",
232
+ locale: e.locale ?? "tr",
233
+ ...t
234
+ };
235
+ return e.theme !== void 0 && (n.theme = e.theme), n;
236
+ }
237
+ function Z(e, t = {}) {
238
+ const n = {
239
+ accountId: e.accountId,
240
+ middlewareUrl: e.middlewareUrl,
241
+ session: { sessionId: e.sessionId },
242
+ pageContext: {
243
+ pageType: "pdp",
244
+ sku: e.sku
245
+ },
246
+ mountTarget: e.mountTarget,
247
+ ...t
248
+ };
249
+ return e.theme !== void 0 && (n.theme = e.theme), n;
250
+ }
251
+ function ee(e, t = {}) {
252
+ const n = {
253
+ accountId: e.accountId,
254
+ middlewareUrl: e.middlewareUrl,
255
+ session: { sessionId: e.sessionId },
256
+ sku: e.sku,
257
+ mountTarget: e.mountTarget,
258
+ ...t
259
+ };
260
+ return e.theme !== void 0 && (n.theme = e.theme), n;
261
+ }
262
+ function te(e, t = {}) {
263
+ return {
264
+ enabled: !0,
265
+ middlewareUrl: e,
266
+ endpoint: "/analytics",
267
+ fireAndForget: !0,
268
+ useBeacon: !0,
269
+ ...t
270
+ };
271
+ }
272
+ function x(e) {
273
+ try {
274
+ return document.querySelector(e), !0;
275
+ } catch {
276
+ return !1;
277
+ }
278
+ }
279
+ function B(e, t) {
280
+ const n = [], i = e.mounts, o = [
281
+ ["qna", i.qna],
282
+ ["simrel", i.simrel],
283
+ ["simbut", i.simbut],
284
+ ["chat", i.chat]
285
+ ];
286
+ for (const [a, l] of o)
287
+ if (l !== void 0) {
288
+ if (a === "simrel" && e.widgets.simrel === void 0) {
289
+ n.push({
290
+ code: "SIMREL_MOUNT_IGNORED",
291
+ message: "[gengage preflight] mounts.simrel is set but widgets.simrel is not declared — SimRel will not initialize. Add widgets.simrel: { enabled: true } to enable it.",
292
+ severity: "warn"
293
+ });
294
+ continue;
295
+ }
296
+ if (!x(l)) {
297
+ n.push({
298
+ code: "INVALID_SELECTOR",
299
+ message: `[gengage preflight] ${a} mount selector is invalid CSS: "${l}"`,
300
+ severity: "error"
301
+ });
302
+ continue;
303
+ }
304
+ document.querySelector(l) || n.push({
305
+ code: "MOUNT_NOT_FOUND",
306
+ message: `[gengage preflight] ${a} mount target not found: "${l}" — widget will skip or wait for DOM`,
307
+ severity: "warn"
308
+ });
309
+ }
310
+ if (e.widgets.simbut.enabled && i.simbut === void 0) {
311
+ const a = "#gengage-simbut";
312
+ document.querySelector(a) || n.push({
313
+ code: "SIMBUT_MOUNT_REQUIRED",
314
+ message: `[gengage preflight] SimBut is enabled but no mount target is configured. Set mounts.simbut to your product image wrapper selector (e.g. "#product-gallery"). The default "${a}" was not found in the DOM.`,
315
+ severity: "error"
316
+ });
317
+ }
318
+ const r = e.gtm.idempotencyKey;
319
+ if (window[r] !== void 0 && n.push({
320
+ code: "DUPLICATE_IDEMPOTENCY",
321
+ message: `[gengage preflight] window["${r}"] already exists — widgets may have already initialized`,
322
+ severity: "warn"
323
+ }), !t?.skipCspCheck) {
324
+ let a = !1;
325
+ const l = (m) => {
326
+ m.blockedURI && e.middlewareUrl.startsWith(m.blockedURI) && (a = !0);
327
+ };
328
+ document.addEventListener("securitypolicyviolation", l);
329
+ try {
330
+ fetch(e.middlewareUrl, {
331
+ method: "HEAD",
332
+ mode: "no-cors"
333
+ }).catch(() => {
334
+ });
335
+ } catch {
336
+ a = !0;
337
+ }
338
+ document.removeEventListener("securitypolicyviolation", l), a && n.push({
339
+ code: "CSP_BLOCKED",
340
+ message: `[gengage preflight] middleware URL may be blocked by Content-Security-Policy: "${e.middlewareUrl}". Add it to connect-src.`,
341
+ severity: "warn"
342
+ });
343
+ }
344
+ for (const a of n) a.severity === "error" ? console.error(a.message) : console.warn(a.message);
345
+ return {
346
+ ok: n.every((a) => a.severity !== "error"),
347
+ warnings: n
348
+ };
349
+ }
350
+ function M(e) {
351
+ const t = L(e);
352
+ if (!t.success) {
353
+ const n = t.error.issues.map((i) => `${i.path.join(".")}: ${i.message}`).join("; ");
354
+ throw new Error(`[gengage] Invalid runtime config: ${n}`);
355
+ }
356
+ return t.data;
357
+ }
358
+ function N(e, t, n) {
359
+ const i = {
360
+ accountId: e.accountId,
361
+ middlewareUrl: e.middlewareUrl,
362
+ idempotencyKey: e.gtm.idempotencyKey
363
+ };
364
+ return e.locale !== void 0 && (i.locale = e.locale), n !== void 0 && (i.pageContext = n, n.sku !== void 0 && (i.sku = n.sku)), i.chat = { enabled: e.widgets.chat.enabled }, e.mounts.chat !== void 0 && (i.chat.mountTarget = e.mounts.chat), i.qna = { enabled: e.widgets.qna.enabled }, e.mounts.qna !== void 0 && (i.qna.mountTarget = e.mounts.qna), e.widgets.simrel !== void 0 && (i.simrel = {
365
+ enabled: e.widgets.simrel.enabled,
366
+ ...e.mounts.simrel !== void 0 ? { mountTarget: e.mounts.simrel } : {}
367
+ }), i.simbut = { enabled: e.widgets.simbut.enabled }, e.mounts.simbut !== void 0 && (i.simbut.mountTarget = e.mounts.simbut), t?.onAddToCart !== void 0 && (i.onAddToCart = t.onAddToCart), t?.onProductNavigate !== void 0 && (i.onProductNavigate = t.onProductNavigate), t?.onFindSimilar !== void 0 && (i.simbut.onFindSimilar = t.onFindSimilar), t?.onScriptCall !== void 0 && (i.onScriptCall = t.onScriptCall), i;
368
+ }
369
+ async function ne(e) {
370
+ const t = M(e.runtimeConfig);
371
+ if (e.preflight !== !1) {
372
+ const o = B(t);
373
+ if (!o.ok) {
374
+ const r = o.warnings.filter((a) => a.severity === "error");
375
+ throw new Error(`[gengage] Preflight failed: ${r.map((a) => a.message).join("; ")}`);
376
+ }
377
+ }
378
+ const n = e.contextResolver?.(), i = await k(N(t, e.hostActions, n));
379
+ if (e.contextResolver !== void 0) {
380
+ const o = e.contextResolver, r = () => {
381
+ const l = o();
382
+ i.updateContext(l);
383
+ };
384
+ window.addEventListener("gengage:context:update", r);
385
+ const a = i.destroy.bind(i);
386
+ i.destroy = () => {
387
+ window.removeEventListener("gengage:context:update", r), a();
388
+ };
389
+ }
390
+ return i;
391
+ }
392
+ var $ = [
393
+ {
394
+ pageType: "home",
395
+ urlPatterns: [
396
+ "^/$",
397
+ "^/index\\.html?$",
398
+ "^/anasayfa$"
399
+ ]
400
+ },
401
+ {
402
+ pageType: "search",
403
+ urlPatterns: [
404
+ "/arama",
405
+ "/search",
406
+ "/ara\\?"
407
+ ],
408
+ queryParam: "q"
409
+ },
410
+ {
411
+ pageType: "cart",
412
+ urlPatterns: [
413
+ "/sepet",
414
+ "/cart",
415
+ "/basket",
416
+ "/sepetim"
417
+ ]
418
+ },
419
+ {
420
+ pageType: "plp",
421
+ urlPatterns: [
422
+ "/kategori/",
423
+ "/category/",
424
+ "/c/",
425
+ "/koleksiyon/",
426
+ "/collection/"
427
+ ]
428
+ },
429
+ {
430
+ pageType: "pdp",
431
+ urlPatterns: [
432
+ "/urun/",
433
+ "/product/",
434
+ "/p/",
435
+ "/-p-",
436
+ "/-pm-"
437
+ ]
438
+ }
439
+ ];
440
+ function z(e, t) {
441
+ const n = t ?? (typeof window < "u" ? new URL(window.location.href) : null);
442
+ if (!n) return "other";
443
+ const i = e ?? $, o = n.pathname;
444
+ for (const r of i)
445
+ if (!(r.urlPatterns && !r.urlPatterns.some((a) => {
446
+ try {
447
+ return new RegExp(a, "i").test(o);
448
+ } catch {
449
+ return !1;
450
+ }
451
+ })) && !(r.queryParam && !n.searchParams.has(r.queryParam)) && !(r.selector && typeof document < "u" && !document.querySelector(r.selector)))
452
+ return r.pageType;
453
+ return "other";
454
+ }
455
+ function K(e) {
456
+ const t = e ?? (typeof window < "u" ? new URL(window.location.href) : null);
457
+ if (!t) return;
458
+ const n = t.pathname, i = n.match(/\/(?:p|urun|product)\/([^/?#]+)/i);
459
+ if (i?.[1]) return i[1];
460
+ const o = n.match(/-p-(\d+)/i);
461
+ if (o?.[1]) return o[1];
462
+ }
463
+ function ie(e) {
464
+ const t = z(e), n = { pageType: t };
465
+ if (t === "pdp") {
466
+ const i = K();
467
+ i && (n.sku = i);
468
+ }
469
+ return typeof window < "u" && (n.url = window.location.href), n;
470
+ }
471
+ export {
472
+ Y as _,
473
+ B as a,
474
+ te as c,
475
+ ee as d,
476
+ D as f,
477
+ E as g,
478
+ U as h,
479
+ ne as i,
480
+ X as l,
481
+ v as m,
482
+ z as n,
483
+ Q as o,
484
+ J as p,
485
+ K as r,
486
+ V as s,
487
+ ie as t,
488
+ Z as u,
489
+ R as v,
490
+ L as y
491
+ };