@tekibo/feedpulse-sdk 0.6.1 → 0.7.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/dist/react.mjs CHANGED
@@ -1,147 +1,148 @@
1
- import ie, { useState as y, useEffect as N, useCallback as J, createContext as le, useRef as M, useContext as ce } from "react";
2
- import { CookieManager as B, FeedPulseTracker as ue } from "./index.mjs";
3
- var j = { exports: {} }, E = {};
4
- var $;
5
- function de() {
6
- if ($) return E;
7
- $ = 1;
8
- var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), x = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function n(g, a, i) {
10
- var p = null;
11
- if (i !== void 0 && (p = "" + i), a.key !== void 0 && (p = "" + a.key), "key" in a) {
1
+ import ie, { useState as p, useEffect as G, useCallback as oe, useRef as H, useMemo as le, createContext as ce, useContext as de } from "react";
2
+ import { CookieManager as K, FeedPulseTracker as ue } from "./index.mjs";
3
+ import { S as fe } from "./struggle-detector-BqTHgw95.mjs";
4
+ var q = { exports: {} }, W = {};
5
+ var ee;
6
+ function pe() {
7
+ if (ee) return W;
8
+ ee = 1;
9
+ var o = /* @__PURE__ */ Symbol.for("react.transitional.element"), g = /* @__PURE__ */ Symbol.for("react.fragment");
10
+ function a(h, s, i) {
11
+ var b = null;
12
+ if (i !== void 0 && (b = "" + i), s.key !== void 0 && (b = "" + s.key), "key" in s) {
12
13
  i = {};
13
- for (var m in a)
14
- m !== "key" && (i[m] = a[m]);
15
- } else i = a;
16
- return a = i.ref, {
17
- $$typeof: u,
18
- type: g,
19
- key: p,
20
- ref: a !== void 0 ? a : null,
14
+ for (var x in s)
15
+ x !== "key" && (i[x] = s[x]);
16
+ } else i = s;
17
+ return s = i.ref, {
18
+ $$typeof: o,
19
+ type: h,
20
+ key: b,
21
+ ref: s !== void 0 ? s : null,
21
22
  props: i
22
23
  };
23
24
  }
24
- return E.Fragment = x, E.jsx = n, E.jsxs = n, E;
25
+ return W.Fragment = g, W.jsx = a, W.jsxs = a, W;
25
26
  }
26
- var R = {};
27
- var L;
28
- function fe() {
29
- return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
30
- function u(e) {
27
+ var L = {};
28
+ var te;
29
+ function be() {
30
+ return te || (te = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ function o(e) {
31
32
  if (e == null) return null;
32
33
  if (typeof e == "function")
33
- return e.$$typeof === ae ? null : e.displayName || e.name || null;
34
+ return e.$$typeof === I ? null : e.displayName || e.name || null;
34
35
  if (typeof e == "string") return e;
35
36
  switch (e) {
36
- case T:
37
+ case D:
37
38
  return "Fragment";
38
- case H:
39
+ case Y:
39
40
  return "Profiler";
40
41
  case X:
41
42
  return "StrictMode";
42
- case ee:
43
+ case M:
43
44
  return "Suspense";
44
- case re:
45
+ case B:
45
46
  return "SuspenseList";
46
- case ne:
47
+ case J:
47
48
  return "Activity";
48
49
  }
49
50
  if (typeof e == "object")
50
51
  switch (typeof e.tag == "number" && console.error(
51
52
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
53
  ), e.$$typeof) {
53
- case G:
54
+ case A:
54
55
  return "Portal";
55
- case Q:
56
+ case $:
56
57
  return e.displayName || "Context";
57
58
  case Z:
58
59
  return (e._context.displayName || "Context") + ".Consumer";
59
- case K:
60
+ case O:
60
61
  var r = e.render;
61
62
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case te:
63
- return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
64
- case S:
63
+ case C:
64
+ return r = e.displayName || null, r !== null ? r : o(e.type) || "Memo";
65
+ case R:
65
66
  r = e._payload, e = e._init;
66
67
  try {
67
- return u(e(r));
68
+ return o(e(r));
68
69
  } catch {
69
70
  }
70
71
  }
71
72
  return null;
72
73
  }
73
- function x(e) {
74
+ function g(e) {
74
75
  return "" + e;
75
76
  }
76
- function n(e) {
77
+ function a(e) {
77
78
  try {
78
- x(e);
79
+ g(e);
79
80
  var r = !1;
80
81
  } catch {
81
82
  r = !0;
82
83
  }
83
84
  if (r) {
84
85
  r = console;
85
- var s = r.error, l = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return s.call(
86
+ var n = r.error, f = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
87
+ return n.call(
87
88
  r,
88
89
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- l
90
- ), x(e);
90
+ f
91
+ ), g(e);
91
92
  }
92
93
  }
93
- function g(e) {
94
- if (e === T) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === S)
94
+ function h(e) {
95
+ if (e === D) return "<>";
96
+ if (typeof e == "object" && e !== null && e.$$typeof === R)
96
97
  return "<...>";
97
98
  try {
98
- var r = u(e);
99
+ var r = o(e);
99
100
  return r ? "<" + r + ">" : "<...>";
100
101
  } catch {
101
102
  return "<...>";
102
103
  }
103
104
  }
104
- function a() {
105
- var e = A.A;
105
+ function s() {
106
+ var e = N.A;
106
107
  return e === null ? null : e.getOwner();
107
108
  }
108
109
  function i() {
109
110
  return Error("react-stack-top-frame");
110
111
  }
111
- function p(e) {
112
- if (D.call(e, "key")) {
112
+ function b(e) {
113
+ if (S.call(e, "key")) {
113
114
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
115
  if (r && r.isReactWarning) return !1;
115
116
  }
116
117
  return e.key !== void 0;
117
118
  }
118
- function m(e, r) {
119
- function s() {
120
- F || (F = !0, console.error(
119
+ function x(e, r) {
120
+ function n() {
121
+ U || (U = !0, console.error(
121
122
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
123
  r
123
124
  ));
124
125
  }
125
- s.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: s,
126
+ n.isReactWarning = !0, Object.defineProperty(e, "key", {
127
+ get: n,
127
128
  configurable: !0
128
129
  });
129
130
  }
130
131
  function k() {
131
- var e = u(this.type);
132
- return I[e] || (I[e] = !0, console.error(
132
+ var e = o(this.type);
133
+ return V[e] || (V[e] = !0, console.error(
133
134
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
135
  )), e = this.props.ref, e !== void 0 ? e : null;
135
136
  }
136
- function o(e, r, s, l, w, P) {
137
- var c = s.ref;
137
+ function c(e, r, n, f, E, v) {
138
+ var l = n.ref;
138
139
  return e = {
139
- $$typeof: v,
140
+ $$typeof: w,
140
141
  type: e,
141
142
  key: r,
142
- props: s,
143
- _owner: l
144
- }, (c !== void 0 ? c : null) !== null ? Object.defineProperty(e, "ref", {
143
+ props: n,
144
+ _owner: f
145
+ }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
145
146
  enumerable: !1,
146
147
  get: k
147
148
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
@@ -158,69 +159,69 @@ function fe() {
158
159
  configurable: !1,
159
160
  enumerable: !1,
160
161
  writable: !0,
161
- value: w
162
+ value: E
162
163
  }), Object.defineProperty(e, "_debugTask", {
163
164
  configurable: !1,
164
165
  enumerable: !1,
165
166
  writable: !0,
166
- value: P
167
+ value: v
167
168
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
169
  }
169
- function f(e, r, s, l, w, P) {
170
- var c = r.children;
171
- if (c !== void 0)
172
- if (l)
173
- if (oe(c)) {
174
- for (l = 0; l < c.length; l++)
175
- b(c[l]);
176
- Object.freeze && Object.freeze(c);
170
+ function u(e, r, n, f, E, v) {
171
+ var l = r.children;
172
+ if (l !== void 0)
173
+ if (f)
174
+ if (Q(l)) {
175
+ for (f = 0; f < l.length; f++)
176
+ y(l[f]);
177
+ Object.freeze && Object.freeze(l);
177
178
  } else
178
179
  console.error(
179
180
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
181
  );
181
- else b(c);
182
- if (D.call(r, "key")) {
183
- c = u(e);
182
+ else y(l);
183
+ if (S.call(r, "key")) {
184
+ l = o(e);
184
185
  var _ = Object.keys(r).filter(function(se) {
185
186
  return se !== "key";
186
187
  });
187
- l = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", Y[c + l] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
188
+ f = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", P[l + f] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
188
189
  `A props object containing a "key" prop is being spread into JSX:
189
190
  let props = %s;
190
191
  <%s {...props} />
191
192
  React keys must be passed directly to JSX without using spread:
192
193
  let props = %s;
193
194
  <%s key={someKey} {...props} />`,
195
+ f,
194
196
  l,
195
- c,
196
197
  _,
197
- c
198
- ), Y[c + l] = !0);
198
+ l
199
+ ), P[l + f] = !0);
199
200
  }
200
- if (c = null, s !== void 0 && (n(s), c = "" + s), p(r) && (n(r.key), c = "" + r.key), "key" in r) {
201
- s = {};
202
- for (var O in r)
203
- O !== "key" && (s[O] = r[O]);
204
- } else s = r;
205
- return c && m(
206
- s,
201
+ if (l = null, n !== void 0 && (a(n), l = "" + n), b(r) && (a(r.key), l = "" + r.key), "key" in r) {
202
+ n = {};
203
+ for (var T in r)
204
+ T !== "key" && (n[T] = r[T]);
205
+ } else n = r;
206
+ return l && x(
207
+ n,
207
208
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), o(
209
+ ), c(
209
210
  e,
210
- c,
211
- s,
212
- a(),
213
- w,
214
- P
211
+ l,
212
+ n,
213
+ s(),
214
+ E,
215
+ v
215
216
  );
216
217
  }
217
- function b(e) {
218
- h(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === S && (e._payload.status === "fulfilled" ? h(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ function y(e) {
219
+ j(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === R && (e._payload.status === "fulfilled" ? j(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
220
  }
220
- function h(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === v;
221
+ function j(e) {
222
+ return typeof e == "object" && e !== null && e.$$typeof === w;
222
223
  }
223
- var d = ie, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), G = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), X = /* @__PURE__ */ Symbol.for("react.strict_mode"), H = /* @__PURE__ */ Symbol.for("react.profiler"), Z = /* @__PURE__ */ Symbol.for("react.consumer"), Q = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), ee = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), te = /* @__PURE__ */ Symbol.for("react.memo"), S = /* @__PURE__ */ Symbol.for("react.lazy"), ne = /* @__PURE__ */ Symbol.for("react.activity"), ae = /* @__PURE__ */ Symbol.for("react.client.reference"), A = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, oe = Array.isArray, C = console.createTask ? console.createTask : function() {
224
+ var d = ie, w = /* @__PURE__ */ Symbol.for("react.transitional.element"), A = /* @__PURE__ */ Symbol.for("react.portal"), D = /* @__PURE__ */ Symbol.for("react.fragment"), X = /* @__PURE__ */ Symbol.for("react.strict_mode"), Y = /* @__PURE__ */ Symbol.for("react.profiler"), Z = /* @__PURE__ */ Symbol.for("react.consumer"), $ = /* @__PURE__ */ Symbol.for("react.context"), O = /* @__PURE__ */ Symbol.for("react.forward_ref"), M = /* @__PURE__ */ Symbol.for("react.suspense"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), C = /* @__PURE__ */ Symbol.for("react.memo"), R = /* @__PURE__ */ Symbol.for("react.lazy"), J = /* @__PURE__ */ Symbol.for("react.activity"), I = /* @__PURE__ */ Symbol.for("react.client.reference"), N = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, S = Object.prototype.hasOwnProperty, Q = Array.isArray, F = console.createTask ? console.createTask : function() {
224
225
  return null;
225
226
  };
226
227
  d = {
@@ -228,158 +229,416 @@ React keys must be passed directly to JSX without using spread:
228
229
  return e();
229
230
  }
230
231
  };
231
- var F, I = {}, z = d.react_stack_bottom_frame.bind(
232
+ var U, V = {}, m = d.react_stack_bottom_frame.bind(
232
233
  d,
233
234
  i
234
- )(), W = C(g(i)), Y = {};
235
- R.Fragment = T, R.jsx = function(e, r, s) {
236
- var l = 1e4 > A.recentlyCreatedOwnerStacks++;
237
- return f(
235
+ )(), z = F(h(i)), P = {};
236
+ L.Fragment = D, L.jsx = function(e, r, n) {
237
+ var f = 1e4 > N.recentlyCreatedOwnerStacks++;
238
+ return u(
238
239
  e,
239
240
  r,
240
- s,
241
+ n,
241
242
  !1,
242
- l ? Error("react-stack-top-frame") : z,
243
- l ? C(g(e)) : W
243
+ f ? Error("react-stack-top-frame") : m,
244
+ f ? F(h(e)) : z
244
245
  );
245
- }, R.jsxs = function(e, r, s) {
246
- var l = 1e4 > A.recentlyCreatedOwnerStacks++;
247
- return f(
246
+ }, L.jsxs = function(e, r, n) {
247
+ var f = 1e4 > N.recentlyCreatedOwnerStacks++;
248
+ return u(
248
249
  e,
249
250
  r,
250
- s,
251
+ n,
251
252
  !0,
252
- l ? Error("react-stack-top-frame") : z,
253
- l ? C(g(e)) : W
253
+ f ? Error("react-stack-top-frame") : m,
254
+ f ? F(h(e)) : z
254
255
  );
255
256
  };
256
- })()), R;
257
+ })()), L;
257
258
  }
258
- var U;
259
- function pe() {
260
- return U || (U = 1, process.env.NODE_ENV === "production" ? j.exports = de() : j.exports = fe()), j.exports;
259
+ var re;
260
+ function xe() {
261
+ return re || (re = 1, process.env.NODE_ENV === "production" ? q.exports = pe() : q.exports = be()), q.exports;
261
262
  }
262
- var t = pe();
263
- const V = new B();
264
- function me({ onConsent: u }) {
265
- const [x, n] = y(!1), [g, a] = y(!1), [i, p] = y(!1), [m, k] = y(!1);
266
- N(() => {
267
- const d = V.getConsent();
268
- n(!d || V.isConsentExpired()), d && (p(d.analytics), k(d.marketing));
263
+ var t = xe();
264
+ const ne = new K();
265
+ function he({ onConsent: o }) {
266
+ const [g, a] = p(!1), [h, s] = p(!1), [i, b] = p(!1), [x, k] = p(!1);
267
+ G(() => {
268
+ const d = ne.getConsent();
269
+ a(!d || ne.isConsentExpired()), d && (b(d.analytics), k(d.marketing));
269
270
  }, []);
270
- const o = () => {
271
- u({ analytics: !0, marketing: !0, action: "accept_all" }), n(!1);
272
- }, f = () => {
273
- u({ analytics: !1, marketing: !1, action: "reject_all" }), n(!1);
274
- }, b = () => {
275
- u({ analytics: i, marketing: m, action: "custom" }), n(!1);
276
- }, h = J(() => {
277
- u({ analytics: !1, marketing: !1, action: "withdraw" }), p(!1), k(!1), n(!0);
278
- }, [u]);
279
- return N(() => {
271
+ const c = () => {
272
+ o({ analytics: !0, marketing: !0, action: "accept_all" }), a(!1);
273
+ }, u = () => {
274
+ o({ analytics: !1, marketing: !1, action: "reject_all" }), a(!1);
275
+ }, y = () => {
276
+ o({ analytics: i, marketing: x, action: "custom" }), a(!1);
277
+ }, j = oe(() => {
278
+ o({ analytics: !1, marketing: !1, action: "withdraw" }), b(!1), k(!1), a(!0);
279
+ }, [o]);
280
+ return G(() => {
280
281
  const d = () => {
281
- n(!0), a(!0);
282
+ a(!0), s(!0);
282
283
  };
283
- return window.addEventListener("feedpulse:open-consent", d), window.addEventListener("feedpulse:withdraw-consent", h), () => {
284
- window.removeEventListener("feedpulse:open-consent", d), window.removeEventListener("feedpulse:withdraw-consent", h);
284
+ return window.addEventListener("feedpulse:open-consent", d), window.addEventListener("feedpulse:withdraw-consent", j), () => {
285
+ window.removeEventListener("feedpulse:open-consent", d), window.removeEventListener("feedpulse:withdraw-consent", j);
285
286
  };
286
- }, [h]), x ? /* @__PURE__ */ t.jsx("div", { style: { position: "fixed", bottom: 0, left: 0, right: 0, zIndex: 99999, background: "#1a1a1a", color: "#fff", padding: "20px 24px", borderTop: "1px solid #333", fontFamily: "sans-serif" }, children: /* @__PURE__ */ t.jsxs("div", { style: { maxWidth: 900, margin: "0 auto" }, children: [
287
+ }, [j]), g ? /* @__PURE__ */ t.jsx("div", { style: { position: "fixed", bottom: 0, left: 0, right: 0, zIndex: 99999, background: "#1a1a1a", color: "#fff", padding: "20px 24px", borderTop: "1px solid #333", fontFamily: "sans-serif" }, children: /* @__PURE__ */ t.jsxs("div", { style: { maxWidth: 900, margin: "0 auto" }, children: [
287
288
  /* @__PURE__ */ t.jsxs("p", { style: { margin: "0 0 12px", fontSize: 14, lineHeight: 1.5 }, children: [
288
289
  "We use cookies to improve reliability and understand usage.",
289
290
  " ",
290
291
  /* @__PURE__ */ t.jsx("a", { href: "/privacy", style: { color: "#818cf8" }, children: "Privacy Policy" })
291
292
  ] }),
292
- g && /* @__PURE__ */ t.jsxs("div", { style: { marginBottom: 12, fontSize: 13 }, children: [
293
+ h && /* @__PURE__ */ t.jsxs("div", { style: { marginBottom: 12, fontSize: 13 }, children: [
293
294
  /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6, opacity: 0.75 }, children: [
294
295
  /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: !0, disabled: !0 }),
295
296
  "Necessary (always on)"
296
297
  ] }),
297
298
  /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6 }, children: [
298
- /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: i, onChange: (d) => p(d.target.checked) }),
299
+ /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: i, onChange: (d) => b(d.target.checked) }),
299
300
  "Analytics"
300
301
  ] }),
301
302
  /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
302
- /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: m, onChange: (d) => k(d.target.checked) }),
303
+ /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: x, onChange: (d) => k(d.target.checked) }),
303
304
  "Marketing"
304
305
  ] })
305
306
  ] }),
306
307
  /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center" }, children: [
307
- /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "#4f46e5", color: "#fff", border: "1px solid #4f46e5", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: o, children: "Accept All" }),
308
- /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "transparent", color: "#fff", border: "1px solid #555", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: f, children: "Reject All" }),
309
- /* @__PURE__ */ t.jsx("button", { type: "button", style: { padding: "9px 16px", background: "transparent", color: "#aaa", border: "1px solid #333", borderRadius: 6, fontSize: 13, cursor: "pointer" }, onClick: () => g ? b() : a(!0), children: g ? "Save Preferences" : "Customize" })
308
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "#4f46e5", color: "#fff", border: "1px solid #4f46e5", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: c, children: "Accept All" }),
309
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "transparent", color: "#fff", border: "1px solid #555", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: u, children: "Reject All" }),
310
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { padding: "9px 16px", background: "transparent", color: "#aaa", border: "1px solid #333", borderRadius: 6, fontSize: 13, cursor: "pointer" }, onClick: () => h ? y() : s(!0), children: h ? "Save Preferences" : "Customize" })
310
311
  ] })
311
312
  ] }) }) : null;
312
313
  }
313
- const q = le({ tracker: null });
314
- function ke({
315
- proxyEndpoint: u = "/api/fp-proxy",
316
- debug: x,
317
- consentRequired: n = !0,
318
- children: g
314
+ function me() {
315
+ if (typeof document > "u" || document.getElementById("fp-bot-animations"))
316
+ return;
317
+ const o = document.createElement("style");
318
+ o.id = "fp-bot-animations", o.textContent = `
319
+ @keyframes fp-bubble-in {
320
+ 0% { opacity: 0; transform: scale(0.8) translateY(6px); }
321
+ 100% { opacity: 1; transform: scale(1) translateY(0); }
322
+ }
323
+ @keyframes fp-bounce {
324
+ 0% { transform: translateY(0); }
325
+ 50% { transform: translateY(-8px); }
326
+ 100% { transform: translateY(0); }
327
+ }
328
+ @keyframes fp-panel-open {
329
+ 0% { opacity: 0; transform: translateY(40px); }
330
+ 100% { opacity: 1; transform: translateY(0); }
331
+ }
332
+ @keyframes fp-dot {
333
+ 0% { opacity: 0.2; transform: translateY(0); }
334
+ 50% { opacity: 1; transform: translateY(-3px); }
335
+ 100% { opacity: 0.2; transform: translateY(0); }
336
+ }
337
+ `, document.head.appendChild(o);
338
+ }
339
+ function we({
340
+ faq: o = [],
341
+ pageContext: g = "",
342
+ systemPrompt: a = "",
343
+ canNavigate: h = !1,
344
+ canHelpForms: s = !1,
345
+ escalateTo: i,
346
+ initialMessage: b = "👋 Need help?",
347
+ position: x = "bottom-right"
319
348
  }) {
320
- const a = M(null), i = M(new B()), [p, m] = y(null), k = J((o) => {
321
- const f = i.current, b = f.setConsent({
322
- analytics: o.analytics,
323
- marketing: o.marketing,
349
+ const k = H(new K()), [c, u] = p(!1), [y, j] = p(!1), [d, w] = p(!1), [A, D] = p(""), [X, Y] = p(null), [Z, $] = p(!1), [O, M] = p(!1), [B, C] = p([]), [R, J] = p(""), [I, N] = p(!1), S = H(null), Q = le(
350
+ () => ({ faq: o, pageContext: g, systemPrompt: a, canNavigate: h, canHelpForms: s, escalateTo: i }),
351
+ [o, g, a, h, s, i]
352
+ );
353
+ G(() => {
354
+ me();
355
+ const m = new fe({
356
+ onTrigger: async (z, P) => {
357
+ j(!0), u(!0), Y(null), $(!1), M(!1), S.current && clearTimeout(S.current), S.current = setTimeout(() => u(!1), 8e3);
358
+ try {
359
+ const e = k.current.getAllData(!0), r = await fetch("/api/bot/session-proxy", {
360
+ method: "POST",
361
+ headers: { "content-type": "application/json" },
362
+ body: JSON.stringify({
363
+ page: window.location.pathname,
364
+ triggerScore: z,
365
+ triggerReasons: P,
366
+ sessionId: e.sessionId,
367
+ visitorId: e.userId,
368
+ device: navigator.userAgent
369
+ })
370
+ });
371
+ if (r.status === 402) {
372
+ M(!0);
373
+ return;
374
+ }
375
+ const n = await r.json().catch(() => null);
376
+ n?.botSessionId && D(n.botSessionId);
377
+ } catch {
378
+ }
379
+ }
380
+ });
381
+ return m.start(), () => {
382
+ m.stop(), S.current && clearTimeout(S.current);
383
+ };
384
+ }, []);
385
+ const F = {
386
+ position: "fixed",
387
+ bottom: 24,
388
+ zIndex: 1e4,
389
+ ...x === "bottom-left" ? { left: 24 } : { right: 24 }
390
+ }, U = (m) => {
391
+ if (m.preventDefault(), !R.trim() || O || I || !A)
392
+ return;
393
+ const z = R.trim();
394
+ J("");
395
+ const P = { id: `user-${Date.now()}`, role: "user", content: z }, e = `assistant-${Date.now()}`;
396
+ C((r) => [...r, P, { id: e, role: "assistant", content: "" }]), N(!0), (async () => {
397
+ try {
398
+ const r = await fetch("/api/bot/chat-proxy", {
399
+ method: "POST",
400
+ headers: { "content-type": "application/json" },
401
+ body: JSON.stringify({
402
+ botSessionId: A,
403
+ config: Q,
404
+ messages: [...B, P].map((v) => ({ role: v.role, content: v.content }))
405
+ })
406
+ });
407
+ if (r.status === 402) {
408
+ M(!0), C((v) => v.map((l) => l.id === e ? { ...l, content: "Service temporarily unavailable." } : l));
409
+ return;
410
+ }
411
+ if (!r.ok)
412
+ throw new Error("chat failed");
413
+ const n = r.body?.getReader();
414
+ if (!n)
415
+ throw new Error("no body");
416
+ const f = new TextDecoder();
417
+ let E = !1;
418
+ for (; !E; ) {
419
+ const v = await n.read();
420
+ if (E = v.done, v.value) {
421
+ const l = f.decode(v.value, { stream: !E });
422
+ C((_) => _.map((T) => T.id === e ? { ...T, content: T.content + l } : T));
423
+ }
424
+ }
425
+ } catch {
426
+ C((r) => r.map((n) => n.id === e && !n.content ? { ...n, content: "Sorry, I couldn't process that. Please try again." } : n));
427
+ } finally {
428
+ N(!1);
429
+ }
430
+ })();
431
+ }, V = async () => {
432
+ if (w(!1), !!A) {
433
+ try {
434
+ await fetch("/api/bot/session-end-proxy", {
435
+ method: "POST",
436
+ headers: { "content-type": "application/json" },
437
+ body: JSON.stringify({
438
+ botSessionId: A,
439
+ wasHelpful: X,
440
+ escalated: Z
441
+ })
442
+ });
443
+ } catch {
444
+ }
445
+ C([]);
446
+ }
447
+ };
448
+ return /* @__PURE__ */ t.jsxs("div", { style: F, children: [
449
+ c && !d && /* @__PURE__ */ t.jsx(
450
+ "div",
451
+ {
452
+ style: {
453
+ position: "absolute",
454
+ bottom: 62,
455
+ right: x === "bottom-right" ? 0 : void 0,
456
+ left: x === "bottom-left" ? 0 : void 0,
457
+ background: "#fff",
458
+ border: "2px solid #6366f1",
459
+ color: "#1f2937",
460
+ borderRadius: "12px 12px 0 12px",
461
+ padding: "10px 12px",
462
+ maxWidth: 240,
463
+ fontSize: 13,
464
+ boxShadow: "0 10px 22px rgba(0,0,0,0.16)",
465
+ animation: "fp-bubble-in 300ms ease-out"
466
+ },
467
+ children: b
468
+ }
469
+ ),
470
+ y && !d && /* @__PURE__ */ t.jsx(
471
+ "button",
472
+ {
473
+ style: {
474
+ width: 48,
475
+ height: 48,
476
+ borderRadius: 999,
477
+ border: "none",
478
+ background: "#6366f1",
479
+ boxShadow: "0 12px 26px rgba(79,70,229,0.45)",
480
+ cursor: "pointer",
481
+ display: "grid",
482
+ placeItems: "center",
483
+ animation: "fp-bounce 600ms ease-out"
484
+ },
485
+ onClick: () => {
486
+ w(!0), u(!1);
487
+ },
488
+ children: /* @__PURE__ */ t.jsxs("svg", { width: "28", height: "28", viewBox: "0 0 24 24", fill: "none", stroke: "white", strokeWidth: "2", children: [
489
+ /* @__PURE__ */ t.jsx("rect", { x: "3", y: "8", width: "18", height: "13", rx: "2" }),
490
+ /* @__PURE__ */ t.jsx("path", { d: "M12 8V5" }),
491
+ /* @__PURE__ */ t.jsx("circle", { cx: "12", cy: "4", r: "1" }),
492
+ /* @__PURE__ */ t.jsx("circle", { cx: "8", cy: "13", r: "1.5", fill: "white", stroke: "none" }),
493
+ /* @__PURE__ */ t.jsx("circle", { cx: "16", cy: "13", r: "1.5", fill: "white", stroke: "none" }),
494
+ /* @__PURE__ */ t.jsx("path", { d: "M9 17h6", strokeLinecap: "round" })
495
+ ] })
496
+ }
497
+ ),
498
+ d && !!A && /* @__PURE__ */ t.jsxs(
499
+ "div",
500
+ {
501
+ style: {
502
+ width: 360,
503
+ height: 520,
504
+ background: "#111827",
505
+ color: "#e5e7eb",
506
+ borderRadius: 16,
507
+ border: "1px solid #374151",
508
+ boxShadow: "0 20px 40px rgba(0,0,0,0.35)",
509
+ display: "flex",
510
+ flexDirection: "column",
511
+ overflow: "hidden",
512
+ animation: "fp-panel-open 300ms ease-out"
513
+ },
514
+ children: [
515
+ /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "12px 14px", borderBottom: "1px solid #374151", background: "#0f172a" }, children: [
516
+ /* @__PURE__ */ t.jsxs("div", { style: { display: "grid", gap: 2 }, children: [
517
+ /* @__PURE__ */ t.jsx("strong", { style: { fontSize: 14, color: "#fff" }, children: "Pulse Bot" }),
518
+ /* @__PURE__ */ t.jsx("span", { style: { fontSize: 11, color: "#94a3b8" }, children: "Powered by FeedPulse AI" })
519
+ ] }),
520
+ /* @__PURE__ */ t.jsx("button", { style: { border: "none", background: "transparent", color: "#cbd5e1", cursor: "pointer", fontSize: 18 }, onClick: V, children: "×" })
521
+ ] }),
522
+ /* @__PURE__ */ t.jsxs("div", { style: { flex: 1, overflowY: "auto", padding: 12, display: "grid", gap: 10 }, children: [
523
+ B.map((m) => /* @__PURE__ */ t.jsxs("div", { style: { display: "grid", justifyItems: m.role === "user" ? "end" : "start", gap: 6 }, children: [
524
+ /* @__PURE__ */ t.jsx(
525
+ "div",
526
+ {
527
+ style: {
528
+ maxWidth: "85%",
529
+ padding: "9px 11px",
530
+ borderRadius: m.role === "user" ? "14px 14px 2px 14px" : "14px 14px 14px 2px",
531
+ background: m.role === "user" ? "#4f46e5" : "#1f2937",
532
+ color: "#fff",
533
+ fontSize: 13,
534
+ whiteSpace: "pre-wrap"
535
+ },
536
+ children: m.content
537
+ }
538
+ ),
539
+ m.role === "assistant" && /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", gap: 8 }, children: [
540
+ /* @__PURE__ */ t.jsx("button", { style: { border: "1px solid #334155", background: "#0f172a", color: "#e2e8f0", borderRadius: 8, fontSize: 12, padding: "4px 8px", cursor: "pointer" }, onClick: () => Y(!0), children: "👍" }),
541
+ /* @__PURE__ */ t.jsx("button", { style: { border: "1px solid #334155", background: "#0f172a", color: "#e2e8f0", borderRadius: 8, fontSize: 12, padding: "4px 8px", cursor: "pointer" }, onClick: () => Y(!1), children: "👎" })
542
+ ] })
543
+ ] }, m.id)),
544
+ I && /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
545
+ /* @__PURE__ */ t.jsx("span", { style: { width: 8, height: 8, borderRadius: 999, background: "#94a3b8", animation: "fp-dot 1s infinite 0ms" } }),
546
+ /* @__PURE__ */ t.jsx("span", { style: { width: 8, height: 8, borderRadius: 999, background: "#94a3b8", animation: "fp-dot 1s infinite 160ms" } }),
547
+ /* @__PURE__ */ t.jsx("span", { style: { width: 8, height: 8, borderRadius: 999, background: "#94a3b8", animation: "fp-dot 1s infinite 320ms" } })
548
+ ] }),
549
+ O && /* @__PURE__ */ t.jsx("div", { style: { border: "1px solid #f59e0b", background: "#451a03", color: "#fde68a", borderRadius: 10, padding: 10, fontSize: 12 }, children: "Service temporarily unavailable." })
550
+ ] }),
551
+ /* @__PURE__ */ t.jsxs("form", { style: { padding: 10, borderTop: "1px solid #374151", display: "grid", gap: 8 }, onSubmit: U, children: [
552
+ /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", gap: 8 }, children: [
553
+ /* @__PURE__ */ t.jsx(
554
+ "input",
555
+ {
556
+ value: R,
557
+ disabled: I || O,
558
+ onChange: (m) => J(m.target.value),
559
+ style: { flex: 1, borderRadius: 10, border: "1px solid #475569", background: "#0f172a", color: "#fff", fontSize: 13, padding: "8px 10px", outline: "none" },
560
+ placeholder: "Ask a question..."
561
+ }
562
+ ),
563
+ /* @__PURE__ */ t.jsx("button", { type: "submit", disabled: !R.trim() || I || O, style: { border: "none", borderRadius: 10, background: "#6366f1", color: "#fff", fontWeight: 600, fontSize: 12, padding: "0 14px", cursor: "pointer" }, children: "Send" })
564
+ ] }),
565
+ i && /* @__PURE__ */ t.jsx("a", { href: i.url, style: { color: "#c4b5fd", fontSize: 12, textDecoration: "none" }, onClick: () => $(!0), children: i.label })
566
+ ] })
567
+ ]
568
+ }
569
+ )
570
+ ] });
571
+ }
572
+ const ae = ce({ tracker: null });
573
+ function je({
574
+ proxyEndpoint: o = "/api/fp-proxy",
575
+ debug: g,
576
+ consentRequired: a = !0,
577
+ children: h
578
+ }) {
579
+ const s = H(null), i = H(new K()), [b, x] = p(null), k = oe((c) => {
580
+ const u = i.current, y = u.setConsent({
581
+ analytics: c.analytics,
582
+ marketing: c.marketing,
324
583
  version: "1.0"
325
584
  });
326
- o.analytics || f.clearAnalyticsCookies(), a.current?.updateCookieData(f.getAllData(o.analytics)), a.current?.track("consent", "__consent__", {
327
- analytics: o.analytics,
328
- marketing: o.marketing,
329
- action: o.action,
585
+ c.analytics || u.clearAnalyticsCookies(), s.current?.updateCookieData(u.getAllData(c.analytics)), s.current?.track("consent", "__consent__", {
586
+ analytics: c.analytics,
587
+ marketing: c.marketing,
588
+ action: c.action,
330
589
  userAgent: navigator.userAgent,
331
- version: b.version
590
+ version: y.version
332
591
  });
333
592
  }, []);
334
- return N(() => {
335
- const o = new ue({ proxyEndpoint: u, debug: x });
336
- a.current = o, m(o);
337
- const f = i.current, b = f.getConsent();
338
- return n ? b && !f.isConsentExpired() ? o.updateCookieData(f.getAllData(b.analytics)) : o.updateCookieData(f.getAllData(!1)) : (f.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), o.updateCookieData(f.getAllData(!0))), o.init(), () => {
339
- o.destroy(), a.current = null, m(null);
593
+ return G(() => {
594
+ const c = new ue({ proxyEndpoint: o, debug: g });
595
+ s.current = c, x(c);
596
+ const u = i.current, y = u.getConsent();
597
+ return a ? y && !u.isConsentExpired() ? c.updateCookieData(u.getAllData(y.analytics)) : c.updateCookieData(u.getAllData(!1)) : (u.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), c.updateCookieData(u.getAllData(!0))), c.init(), () => {
598
+ c.destroy(), s.current = null, x(null);
340
599
  };
341
- }, [u, x, n]), /* @__PURE__ */ t.jsxs(q.Provider, { value: { tracker: p }, children: [
342
- g,
343
- n && /* @__PURE__ */ t.jsx(me, { onConsent: k })
600
+ }, [o, g, a]), /* @__PURE__ */ t.jsxs(ae.Provider, { value: { tracker: b }, children: [
601
+ h,
602
+ a && /* @__PURE__ */ t.jsx(he, { onConsent: k })
344
603
  ] });
345
604
  }
346
605
  function ge() {
347
- return ce(q);
606
+ return de(ae);
348
607
  }
349
- function ye({ id: u, placeholder: x, position: n = "bottom-right" }) {
350
- const { tracker: g } = ge(), [a, i] = y(n === "inline"), [p, m] = y(null), [k, o] = y(""), [f, b] = y(!1), h = () => {
351
- !p && !k.trim() || (g?.trackFeedback(u ?? null, p, k || null), b(!0), setTimeout(() => {
352
- i(n === "inline"), b(!1), m(null), o("");
608
+ function Re({ id: o, placeholder: g, position: a = "bottom-right" }) {
609
+ const { tracker: h } = ge(), [s, i] = p(a === "inline"), [b, x] = p(null), [k, c] = p(""), [u, y] = p(!1), j = () => {
610
+ !b && !k.trim() || (h?.trackFeedback(o ?? null, b, k || null), y(!0), setTimeout(() => {
611
+ i(a === "inline"), y(!1), x(null), c("");
353
612
  }, 2e3));
354
- }, d = n !== "inline" ? { position: "fixed", bottom: 24, [n === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
613
+ }, d = a !== "inline" ? { position: "fixed", bottom: 24, [a === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
355
614
  return /* @__PURE__ */ t.jsxs("div", { style: d, children: [
356
- n !== "inline" && /* @__PURE__ */ t.jsx(
615
+ a !== "inline" && /* @__PURE__ */ t.jsx(
357
616
  "button",
358
617
  {
359
- onClick: () => i(!a),
618
+ onClick: () => i(!s),
360
619
  style: { background: "#6366f1", color: "#fff", border: "none", borderRadius: "50%", width: 48, height: 48, fontSize: 20, cursor: "pointer" },
361
620
  children: "💬"
362
621
  }
363
622
  ),
364
- a && /* @__PURE__ */ t.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: f ? /* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
623
+ s && /* @__PURE__ */ t.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: u ? /* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
365
624
  /* @__PURE__ */ t.jsx("p", { style: { fontSize: 28, margin: 0 }, children: "🎉" }),
366
625
  /* @__PURE__ */ t.jsx("p", { style: { margin: "8px 0 0", fontWeight: 600 }, children: "Thanks for your feedback!" })
367
626
  ] }) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
368
- /* @__PURE__ */ t.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: x ?? "How was your experience?" }),
369
- /* @__PURE__ */ t.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((v) => /* @__PURE__ */ t.jsx(
627
+ /* @__PURE__ */ t.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: g ?? "How was your experience?" }),
628
+ /* @__PURE__ */ t.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((w) => /* @__PURE__ */ t.jsx(
370
629
  "button",
371
630
  {
372
- onClick: () => m(v),
373
- style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: p !== null && v <= p ? 1 : 0.3 },
631
+ onClick: () => x(w),
632
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: b !== null && w <= b ? 1 : 0.3 },
374
633
  children: "⭐"
375
634
  },
376
- v
635
+ w
377
636
  )) }),
378
637
  /* @__PURE__ */ t.jsx(
379
638
  "textarea",
380
639
  {
381
640
  value: k,
382
- onChange: (v) => o(v.target.value),
641
+ onChange: (w) => c(w.target.value),
383
642
  placeholder: "Tell us more (optional)...",
384
643
  rows: 3,
385
644
  style: { width: "100%", padding: 8, border: "1px solid #d1d5db", borderRadius: 8, resize: "none", fontSize: 14 }
@@ -388,7 +647,7 @@ function ye({ id: u, placeholder: x, position: n = "bottom-right" }) {
388
647
  /* @__PURE__ */ t.jsx(
389
648
  "button",
390
649
  {
391
- onClick: h,
650
+ onClick: j,
392
651
  style: { marginTop: 10, width: "100%", background: "#6366f1", color: "#fff", border: "none", borderRadius: 8, padding: 10, fontWeight: 600, cursor: "pointer" },
393
652
  children: "Submit Feedback"
394
653
  }
@@ -397,8 +656,9 @@ function ye({ id: u, placeholder: x, position: n = "bottom-right" }) {
397
656
  ] });
398
657
  }
399
658
  export {
400
- me as ConsentBanner,
401
- ke as FeedPulseProvider,
402
- ye as FeedPulseWidget,
659
+ he as ConsentBanner,
660
+ we as FeedPulseBot,
661
+ je as FeedPulseProvider,
662
+ Re as FeedPulseWidget,
403
663
  ge as useFeedPulse
404
664
  };