@kelet-ai/feedback-ui 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -28,7 +28,7 @@ import { ShadcnVoteFeedback } from '@/components/ui/vote-feedback';
28
28
  function App() {
29
29
  return (
30
30
  <ShadcnVoteFeedback
31
- identifier="my-feature"
31
+ tx_id="my-feature"
32
32
  onFeedback={feedback => console.log(feedback)}
33
33
  variant="outline"
34
34
  />
@@ -91,7 +91,7 @@ Users explicitly vote and provide comments:
91
91
  ```tsx
92
92
  import { VoteFeedback } from '@kelet-ai/feedback-ui';
93
93
 
94
- <VoteFeedback.Root onFeedback={handleFeedback} identifier="ai-response">
94
+ <VoteFeedback.Root onFeedback={handleFeedback} tx_id="ai-response">
95
95
  <VoteFeedback.UpvoteButton>👍 Helpful</VoteFeedback.UpvoteButton>
96
96
  <VoteFeedback.DownvoteButton>👎 Not helpful</VoteFeedback.DownvoteButton>
97
97
  <VoteFeedback.Popover>
@@ -158,14 +158,14 @@ Understanding these fundamental concepts will help you implement feedback collec
158
158
  **Best Practice**: Use traceable IDs from your logging system (session ID, trace ID, request ID)
159
159
 
160
160
  ```tsx
161
- // ✅ Good: Traceable identifier
162
- <VoteFeedback.Root identifier="session-abc123-ai-response-456"/>
161
+ // ✅ Good: Traceable tx_id
162
+ <VoteFeedback.Root tx_id="session-abc123-ai-response-456"/>
163
163
 
164
- // ✅ Good: Content-based identifier
165
- <VoteFeedback.Root identifier={`article-${articleId}-section-${sectionId}`}/>
164
+ // ✅ Good: Content-based tx_id
165
+ <VoteFeedback.Root tx_id={`article-${articleId}-section-${sectionId}`}/>
166
166
 
167
- // ❌ Poor: Generic identifier
168
- <VoteFeedback.Root identifier="feedback"/>
167
+ // ❌ Poor: Generic tx_id
168
+ <VoteFeedback.Root tx_id="feedback"/>
169
169
  ```
170
170
 
171
171
  ### **📊 Feedback Sources**
@@ -290,8 +290,8 @@ const [data, setData] = useFeedbackState(initial, 'tracker', {
290
290
  #### **Identifiers**
291
291
 
292
292
  ✅ Use traceable session/request IDs
293
- ✅ Include context in identifier structure
294
- ✅ Keep identifiers consistent across related actions
293
+ ✅ Include context in tx_id structure
294
+ ✅ Keep tx_ids consistent across related actions
295
295
 
296
296
  #### **Feedback Sources**
297
297
 
@@ -321,7 +321,7 @@ Main container component that manages feedback state.
321
321
 
322
322
  ```tsx
323
323
  <VoteFeedback.Root
324
- identifier="unique-id" // Required: Unique tracking ID
324
+ tx_id="unique-id" // Required: Unique tracking ID
325
325
  onFeedback={handleFeedback} // Required: Callback function
326
326
  trigger_name="user_feedback" // Optional: Categorization
327
327
  extra_metadata={{ page: 'home' }} // Optional: Additional data
@@ -370,7 +370,7 @@ const [count, setCount] = useFeedbackState(0, 'counter-widget');
370
370
  ```tsx
371
371
  const [profile, setProfile] = useFeedbackState(
372
372
  { name: '', email: '' },
373
- state => `profile-${state.email}`, // Dynamic identifier
373
+ state => `profile-${state.email}`, // Dynamic tx_id
374
374
  {
375
375
  debounceMs: 2000, // Wait time before sending feedback
376
376
  diffType: 'object', // Format: 'git' | 'object' | 'json'
@@ -460,7 +460,7 @@ dispatch({ type: 'custom' }, 'override'); // Custom trigger name
460
460
 
461
461
  ```tsx
462
462
  <VoteFeedback.Root
463
- identifier="ai-response-123"
463
+ tx_id="ai-response-123"
464
464
  onFeedback={handleFeedback}
465
465
  trigger_name="ai_evaluation"
466
466
  extra_metadata={{
@@ -486,7 +486,7 @@ dispatch({ type: 'custom' }, 'override'); // Custom trigger name
486
486
 
487
487
  ```typescript
488
488
  interface FeedbackData {
489
- identifier: string; // Unique tracking ID
489
+ tx_id: string; // Unique tracking ID
490
490
  vote: 'upvote' | 'downvote'; // User's vote
491
491
  explanation?: string; // Optional user comment
492
492
  extra_metadata?: Record<string, any>; // Additional context data
@@ -501,7 +501,7 @@ interface FeedbackData {
501
501
 
502
502
  | Prop | Type | Required | Description |
503
503
  | ---------------- | ------------------------------ | -------- | ----------------------------------- |
504
- | `identifier` | `string` | ✅ | Unique identifier for tracking |
504
+ | `tx_id` | `string` | ✅ | Unique transaction ID for tracking |
505
505
  | `onFeedback` | `(data: FeedbackData) => void` | ✅ | Callback when feedback is submitted |
506
506
  | `trigger_name` | `string` | ❌ | Optional categorization tag |
507
507
  | `extra_metadata` | `object` | ❌ | Additional context data |
@@ -586,9 +586,9 @@ bun run checks # Run all quality checks (lint, format, typecheck, tests)
586
586
  <VoteFeedback.UpvoteButton>👍</VoteFeedback.UpvoteButton>
587
587
  </VoteFeedback.Root>
588
588
 
589
- // ✅ Include required identifier and onFeedback
589
+ // ✅ Include required tx_id and onFeedback
590
590
  <VoteFeedback.Root
591
- identifier="my-feature"
591
+ tx_id="my-feature"
592
592
  onFeedback={handleFeedback}
593
593
  >
594
594
  <VoteFeedback.UpvoteButton>👍</VoteFeedback.UpvoteButton>
@@ -624,14 +624,14 @@ const [value, setValue] = useFeedbackState('initial', 'test', {
624
624
 
625
625
  ### **Best Practices**
626
626
 
627
- ✅ **Use unique identifiers** for each feedback instance - the identifier should be traceable back to the session's log
627
+ ✅ **Use unique tx_ids** for each feedback instance - the tx_id should be traceable back to the session's log
628
628
  and allow us to understand the context of the feedback.
629
629
  ✅ **Handle feedback data asynchronously** in your callback
630
630
  ✅ **Test keyboard navigation** in your implementation
631
631
  ✅ **Provide meaningful trigger names** for categorization
632
632
  ✅ **Include relevant metadata** for context
633
633
 
634
- ❌ **Don't use the same identifier** for multiple components. An identifier should be traced back to the session's log -
634
+ ❌ **Don't use the same tx_id** for multiple components. A tx_id should be traced back to the session's log -
635
635
  allows us to understand the context of the feedback.
636
636
 
637
637
  ---
@@ -1,6 +1,6 @@
1
1
  import { DownvoteButtonProps, PopoverProps, SubmitButtonProps, TextareaProps, UpvoteButtonProps, VoteFeedbackRootProps } from '../types';
2
2
  export declare const VoteFeedback: {
3
- Root: ({ children, onFeedback, defaultText, identifier, extra_metadata, trigger_name, }: VoteFeedbackRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ Root: ({ children, onFeedback, defaultText, tx_id, extra_metadata, trigger_name, }: VoteFeedbackRootProps) => import("react/jsx-runtime").JSX.Element;
4
4
  UpvoteButton: ({ asChild, children, onClick, ...props }: UpvoteButtonProps) => import("react/jsx-runtime").JSX.Element;
5
5
  DownvoteButton: ({ asChild, children, onClick, ...props }: DownvoteButtonProps) => string | number | bigint | true | Iterable<import('react').ReactNode> | Promise<string | number | bigint | boolean | import('react').ReactPortal | import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>> | Iterable<import('react').ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element;
6
6
  Popover: ({ asChild, children, ...props }: PopoverProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -1,8 +1,8 @@
1
1
  import Ae, { createContext as ke, useContext as ae, useCallback as q, isValidElement as Z, cloneElement as Q, useState as X, useRef as U, useId as fe, useEffect as De } from "react";
2
- function _e(t) {
2
+ function je(t) {
3
3
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
4
4
  }
5
- function je(t) {
5
+ function Se(t) {
6
6
  if (Object.prototype.hasOwnProperty.call(t, "__esModule")) return t;
7
7
  var e = t.default;
8
8
  if (typeof e == "function") {
@@ -37,7 +37,7 @@ var re = { exports: {} }, V = {};
37
37
  * LICENSE file in the root directory of this source tree.
38
38
  */
39
39
  var ce;
40
- function Se() {
40
+ function _e() {
41
41
  if (ce) return V;
42
42
  ce = 1;
43
43
  var t = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
@@ -126,11 +126,11 @@ function Ne() {
126
126
  }
127
127
  if (T) {
128
128
  T = console;
129
- var _ = T.error, j = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
130
- return _.call(
129
+ var j = T.error, S = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
130
+ return j.call(
131
131
  T,
132
132
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
133
- j
133
+ S
134
134
  ), e(a);
135
135
  }
136
136
  }
@@ -160,14 +160,14 @@ function Ne() {
160
160
  return a.key !== void 0;
161
161
  }
162
162
  function f(a, T) {
163
- function _() {
163
+ function j() {
164
164
  W || (W = !0, console.error(
165
165
  "%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)",
166
166
  T
167
167
  ));
168
168
  }
169
- _.isReactWarning = !0, Object.defineProperty(a, "key", {
170
- get: _,
169
+ j.isReactWarning = !0, Object.defineProperty(a, "key", {
170
+ get: j,
171
171
  configurable: !0
172
172
  });
173
173
  }
@@ -177,14 +177,14 @@ function Ne() {
177
177
  "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."
178
178
  )), a = this.props.ref, a !== void 0 ? a : null;
179
179
  }
180
- function y(a, T, _, j, $, M, B, K) {
181
- return _ = M.ref, a = {
180
+ function y(a, T, j, S, $, M, B, K) {
181
+ return j = M.ref, a = {
182
182
  $$typeof: k,
183
183
  type: a,
184
184
  key: T,
185
185
  props: M,
186
186
  _owner: $
187
- }, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(a, "ref", {
187
+ }, (j !== void 0 ? j : null) !== null ? Object.defineProperty(a, "ref", {
188
188
  enumerable: !1,
189
189
  get: d
190
190
  }) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
@@ -209,52 +209,52 @@ function Ne() {
209
209
  value: K
210
210
  }), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
211
211
  }
212
- function b(a, T, _, j, $, M, B, K) {
213
- var S = T.children;
214
- if (S !== void 0)
215
- if (j)
216
- if (A(S)) {
217
- for (j = 0; j < S.length; j++)
218
- E(S[j]);
219
- Object.freeze && Object.freeze(S);
212
+ function b(a, T, j, S, $, M, B, K) {
213
+ var _ = T.children;
214
+ if (_ !== void 0)
215
+ if (S)
216
+ if (A(_)) {
217
+ for (S = 0; S < _.length; S++)
218
+ E(_[S]);
219
+ Object.freeze && Object.freeze(_);
220
220
  } else
221
221
  console.error(
222
222
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
223
223
  );
224
- else E(S);
224
+ else E(_);
225
225
  if (v.call(T, "key")) {
226
- S = t(a);
226
+ _ = t(a);
227
227
  var Y = Object.keys(T).filter(function(Re) {
228
228
  return Re !== "key";
229
229
  });
230
- j = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ne[S + j] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
230
+ S = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ne[_ + S] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
231
231
  `A props object containing a "key" prop is being spread into JSX:
232
232
  let props = %s;
233
233
  <%s {...props} />
234
234
  React keys must be passed directly to JSX without using spread:
235
235
  let props = %s;
236
236
  <%s key={someKey} {...props} />`,
237
- j,
238
237
  S,
238
+ _,
239
239
  Y,
240
- S
241
- ), ne[S + j] = !0);
240
+ _
241
+ ), ne[_ + S] = !0);
242
242
  }
243
- if (S = null, _ !== void 0 && (r(_), S = "" + _), c(T) && (r(T.key), S = "" + T.key), "key" in T) {
244
- _ = {};
243
+ if (_ = null, j !== void 0 && (r(j), _ = "" + j), c(T) && (r(T.key), _ = "" + T.key), "key" in T) {
244
+ j = {};
245
245
  for (var le in T)
246
- le !== "key" && (_[le] = T[le]);
247
- } else _ = T;
248
- return S && f(
249
- _,
246
+ le !== "key" && (j[le] = T[le]);
247
+ } else j = T;
248
+ return _ && f(
249
+ j,
250
250
  typeof a == "function" ? a.displayName || a.name || "Unknown" : a
251
251
  ), y(
252
252
  a,
253
- S,
253
+ _,
254
254
  M,
255
255
  $,
256
256
  i(),
257
- _,
257
+ j,
258
258
  B,
259
259
  K
260
260
  );
@@ -274,26 +274,26 @@ React keys must be passed directly to JSX without using spread:
274
274
  P,
275
275
  u
276
276
  )(), J = x(n(u)), ne = {};
277
- G.Fragment = g, G.jsx = function(a, T, _, j, $) {
277
+ G.Fragment = g, G.jsx = function(a, T, j, S, $) {
278
278
  var M = 1e4 > p.recentlyCreatedOwnerStacks++;
279
279
  return b(
280
280
  a,
281
281
  T,
282
- _,
283
- !1,
284
282
  j,
283
+ !1,
284
+ S,
285
285
  $,
286
286
  M ? Error("react-stack-top-frame") : H,
287
287
  M ? x(n(a)) : J
288
288
  );
289
- }, G.jsxs = function(a, T, _, j, $) {
289
+ }, G.jsxs = function(a, T, j, S, $) {
290
290
  var M = 1e4 > p.recentlyCreatedOwnerStacks++;
291
291
  return b(
292
292
  a,
293
293
  T,
294
- _,
295
- !0,
296
294
  j,
295
+ !0,
296
+ S,
297
297
  $,
298
298
  M ? Error("react-stack-top-frame") : H,
299
299
  M ? x(n(a)) : J
@@ -303,7 +303,7 @@ React keys must be passed directly to JSX without using spread:
303
303
  }
304
304
  var pe;
305
305
  function Ie() {
306
- return pe || (pe = 1, process.env.NODE_ENV === "production" ? re.exports = Se() : re.exports = Ne()), re.exports;
306
+ return pe || (pe = 1, process.env.NODE_ENV === "production" ? re.exports = _e() : re.exports = Ne()), re.exports;
307
307
  }
308
308
  var L = Ie();
309
309
  const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
@@ -326,7 +326,7 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
326
326
  project: e,
327
327
  feedback: async (f) => {
328
328
  const d = `${Fe}/projects/${e}/feedback`, y = {
329
- tx_id: f.identifier,
329
+ tx_id: f.tx_id,
330
330
  source: f.source || "EXPLICIT",
331
331
  vote: f.vote,
332
332
  explanation: f.explanation,
@@ -368,14 +368,14 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
368
368
  children: t,
369
369
  onFeedback: e,
370
370
  defaultText: r = "",
371
- identifier: n,
371
+ tx_id: n,
372
372
  extra_metadata: i,
373
373
  trigger_name: u
374
374
  }) => {
375
375
  const [c, f] = X(!1), [d, y] = X(r), [b, E] = X(!1), [P, k] = X(null), h = U(null), g = U(null), C = fe(), O = fe(), m = Pe(), w = e || m, D = q(async () => {
376
376
  k("upvote");
377
377
  const o = {
378
- identifier: n,
378
+ tx_id: n,
379
379
  vote: "upvote",
380
380
  ...i && { extra_metadata: i },
381
381
  ...u && { trigger_name: u }
@@ -388,7 +388,7 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
388
388
  }, [w, n, i, u]), R = q(async () => {
389
389
  if (k("downvote"), w) {
390
390
  const o = {
391
- identifier: n,
391
+ tx_id: n,
392
392
  vote: "downvote",
393
393
  ...i && { extra_metadata: i },
394
394
  ...u && { trigger_name: u }
@@ -413,7 +413,7 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
413
413
  const o = d.trim().length > 0;
414
414
  if (o) {
415
415
  const p = {
416
- identifier: n,
416
+ tx_id: n,
417
417
  vote: "downvote",
418
418
  explanation: d,
419
419
  ...i && { extra_metadata: i },
@@ -429,14 +429,7 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
429
429
  const p = document.createElement("div");
430
430
  p.setAttribute("aria-live", "polite"), p.className = "sr-only", p.textContent = "Feedback submitted successfully.", document.body.appendChild(p), setTimeout(() => document.body.removeChild(p), 1e3);
431
431
  }
432
- }, [
433
- w,
434
- d,
435
- r,
436
- n,
437
- i,
438
- u
439
- ]), s = q(
432
+ }, [w, d, r, n, i, u]), s = q(
440
433
  (o) => {
441
434
  if (o.key === "Escape")
442
435
  f(!1), y(r), g.current?.focus();
@@ -472,7 +465,7 @@ const se = ke(null), Fe = "https://api.kelet.ai/", dt = () => {
472
465
  triggerRef: g,
473
466
  popoverId: C,
474
467
  triggerId: O,
475
- identifier: n,
468
+ tx_id: n,
476
469
  extra_metadata: i,
477
470
  trigger_name: u
478
471
  };
@@ -743,7 +736,7 @@ function Ke() {
743
736
  N.push(A);
744
737
  }
745
738
  E(s) === "regexp" && E(l) === "regexp" && (s = s.toString(), l = l.toString());
746
- var J = typeof s, ne = typeof l, a, T, _, j, $ = J !== "undefined" || x && x.length > 0 && x[x.length - 1].lhs && Object.getOwnPropertyDescriptor(x[x.length - 1].lhs, A), M = ne !== "undefined" || x && x.length > 0 && x[x.length - 1].rhs && Object.getOwnPropertyDescriptor(x[x.length - 1].rhs, A);
739
+ var J = typeof s, ne = typeof l, a, T, j, S, $ = J !== "undefined" || x && x.length > 0 && x[x.length - 1].lhs && Object.getOwnPropertyDescriptor(x[x.length - 1].lhs, A), M = ne !== "undefined" || x && x.length > 0 && x[x.length - 1].rhs && Object.getOwnPropertyDescriptor(x[x.length - 1].rhs, A);
747
740
  if (!$ && M)
748
741
  o.push(new f(N, l));
749
742
  else if (!M && $)
@@ -755,17 +748,17 @@ function Ke() {
755
748
  else if (J === "object" && s !== null && l !== null) {
756
749
  for (a = x.length - 1; a > -1; --a)
757
750
  if (x[a].lhs === s) {
758
- j = !0;
751
+ S = !0;
759
752
  break;
760
753
  }
761
- if (j)
754
+ if (S)
762
755
  s !== l && o.push(new c(N, s, l));
763
756
  else {
764
757
  if (x.push({ lhs: s, rhs: l }), Array.isArray(s)) {
765
- for (W && (s.sort(function(S, Y) {
766
- return k(S) - k(Y);
767
- }), l.sort(function(S, Y) {
768
- return k(S) - k(Y);
758
+ for (W && (s.sort(function(_, Y) {
759
+ return k(_) - k(Y);
760
+ }), l.sort(function(_, Y) {
761
+ return k(_) - k(Y);
769
762
  })), a = l.length - 1, T = s.length - 1; a > T; )
770
763
  o.push(new y(N, a, new f(void 0, l[a--])));
771
764
  for (; T > a; )
@@ -775,9 +768,9 @@ function Ke() {
775
768
  } else {
776
769
  var B = Object.keys(s), K = Object.keys(l);
777
770
  for (a = 0; a < B.length; ++a)
778
- _ = B[a], j = K.indexOf(_), j >= 0 ? (h(s[_], l[_], o, p, N, _, x, W), K[j] = null) : h(s[_], void 0, o, p, N, _, x, W);
771
+ j = B[a], S = K.indexOf(j), S >= 0 ? (h(s[j], l[j], o, p, N, j, x, W), K[S] = null) : h(s[j], void 0, o, p, N, j, x, W);
779
772
  for (a = 0; a < K.length; ++a)
780
- _ = K[a], _ && h(void 0, l[_], o, p, N, _, x, W);
773
+ j = K[a], j && h(void 0, l[j], o, p, N, j, x, W);
781
774
  }
782
775
  x.length = x.length - 1;
783
776
  }
@@ -1025,7 +1018,7 @@ const z = new Uint32Array(65536), Ue = (t, e) => {
1025
1018
  __proto__: null,
1026
1019
  closest: Je,
1027
1020
  distance: Te
1028
- }, Symbol.toStringTag, { value: "Module" })), Ve = /* @__PURE__ */ je(Be);
1021
+ }, Symbol.toStringTag, { value: "Module" })), Ve = /* @__PURE__ */ Se(Be);
1029
1022
  var me;
1030
1023
  function Ge() {
1031
1024
  return me || (me = 1, function(t, e) {
@@ -1072,7 +1065,7 @@ function Ge() {
1072
1065
  }(oe, oe.exports)), oe.exports;
1073
1066
  }
1074
1067
  var Xe = Ge();
1075
- const Ze = /* @__PURE__ */ _e(Xe);
1068
+ const Ze = /* @__PURE__ */ je(Xe);
1076
1069
  class Qe {
1077
1070
  diff(e, r, n = {}) {
1078
1071
  let i;
@@ -1458,7 +1451,7 @@ function ft(t, e, r) {
1458
1451
  r?.vote ? typeof r.vote == "function" ? R = r.vote(C, O, w) : R = r.vote : R = w > 0.5 ? "downvote" : "upvote";
1459
1452
  const I = typeof e == "function" ? e(O) : e;
1460
1453
  i({
1461
- identifier: I,
1454
+ tx_id: I,
1462
1455
  vote: R,
1463
1456
  explanation: `State change with diff percentage: ${(w * 100).toFixed(1)}%`,
1464
1457
  correction: D,
@@ -1,4 +1,4 @@
1
- (function(Y,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(Y=typeof globalThis<"u"?globalThis:Y||self,E(Y["@kelet-ai/feedback-ui"]={},Y.React))})(this,function(Y,E){"use strict";function Ee(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Pe(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function n(){var s=!1;try{s=this instanceof n}catch{}return s?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return t[n]}})}),r}var ee={exports:{}},X={};/**
1
+ (function(Y,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],E):(Y=typeof globalThis<"u"?globalThis:Y||self,E(Y["@kelet-ai/feedback-ui"]={},Y.React))})(this,function(Y,E){"use strict";function Ee(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Pe(t){if(Object.prototype.hasOwnProperty.call(t,"__esModule"))return t;var e=t.default;if(typeof e=="function"){var r=function n(){var i=!1;try{i=this instanceof n}catch{}return i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}var ee={exports:{}},X={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ae;function xe(){if(ae)return X;ae=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(n,s,u){var c=null;if(u!==void 0&&(c=""+u),s.key!==void 0&&(c=""+s.key),"key"in s){u={};for(var f in s)f!=="key"&&(u[f]=s[f])}else u=s;return s=u.ref,{$$typeof:t,type:n,key:c,ref:s!==void 0?s:null,props:u}}return X.Fragment=e,X.jsx=r,X.jsxs=r,X}var Z={};/**
9
+ */var ae;function Ce(){if(ae)return X;ae=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(n,i,u){var c=null;if(u!==void 0&&(c=""+u),i.key!==void 0&&(c=""+i.key),"key"in i){u={};for(var f in i)f!=="key"&&(u[f]=i[f])}else u=i;return i=u.ref,{$$typeof:t,type:n,key:c,ref:i!==void 0?i:null,props:u}}return X.Fragment=e,X.jsx=r,X.jsxs=r,X}var Z={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,23 +14,23 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var le;function Ce(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function t(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===o?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case g:return"Fragment";case O:return"Profiler";case R:return"StrictMode";case A:return"Suspense";case F:return"SuspenseList";case l:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case h:return"Portal";case w:return(a.displayName||"Context")+".Provider";case m:return(a._context.displayName||"Context")+".Consumer";case S:var T=a.render;return a=a.displayName,a||(a=T.displayName||T.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case M:return T=a.displayName||null,T!==null?T:t(a.type)||"Memo";case i:T=a._payload,a=a._init;try{return t(a(T))}catch{}}return null}function e(a){return""+a}function r(a){try{e(a);var T=!1}catch{T=!0}if(T){T=console;var _=T.error,j=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return _.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",j),e(a)}}function n(a){if(a===g)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===i)return"<...>";try{var T=t(a);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function s(){var a=p.A;return a===null?null:a.getOwner()}function u(){return Error("react-stack-top-frame")}function c(a){if(v.call(a,"key")){var T=Object.getOwnPropertyDescriptor(a,"key").get;if(T&&T.isReactWarning)return!1}return a.key!==void 0}function f(a,T){function _(){K||(K=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",T))}_.isReactWarning=!0,Object.defineProperty(a,"key",{get:_,configurable:!0})}function d(){var a=t(this.type);return I[a]||(I[a]=!0,console.error("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.")),a=this.props.ref,a!==void 0?a:null}function y(a,T,_,j,z,W,G,J){return _=W.ref,a={$$typeof:k,type:a,key:T,props:W,_owner:z},(_!==void 0?_:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:d}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function b(a,T,_,j,z,W,G,J){var N=T.children;if(N!==void 0)if(j)if(D(N)){for(j=0;j<N.length;j++)x(N[j]);Object.freeze&&Object.freeze(N)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else x(N);if(v.call(T,"key")){N=t(a);var U=Object.keys(T).filter(function(qe){return qe!=="key"});j=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",re[N+j]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var le;function xe(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function t(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===o?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case g:return"Fragment";case O:return"Profiler";case R:return"StrictMode";case A:return"Suspense";case F:return"SuspenseList";case l:return"Activity"}if(typeof a=="object")switch(typeof a.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),a.$$typeof){case h:return"Portal";case w:return(a.displayName||"Context")+".Provider";case m:return(a._context.displayName||"Context")+".Consumer";case S:var T=a.render;return a=a.displayName,a||(a=T.displayName||T.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case M:return T=a.displayName||null,T!==null?T:t(a.type)||"Memo";case s:T=a._payload,a=a._init;try{return t(a(T))}catch{}}return null}function e(a){return""+a}function r(a){try{e(a);var T=!1}catch{T=!0}if(T){T=console;var j=T.error,_=typeof Symbol=="function"&&Symbol.toStringTag&&a[Symbol.toStringTag]||a.constructor.name||"Object";return j.call(T,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",_),e(a)}}function n(a){if(a===g)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===s)return"<...>";try{var T=t(a);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function i(){var a=p.A;return a===null?null:a.getOwner()}function u(){return Error("react-stack-top-frame")}function c(a){if(v.call(a,"key")){var T=Object.getOwnPropertyDescriptor(a,"key").get;if(T&&T.isReactWarning)return!1}return a.key!==void 0}function f(a,T){function j(){K||(K=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",T))}j.isReactWarning=!0,Object.defineProperty(a,"key",{get:j,configurable:!0})}function d(){var a=t(this.type);return I[a]||(I[a]=!0,console.error("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.")),a=this.props.ref,a!==void 0?a:null}function y(a,T,j,_,z,W,G,J){return j=W.ref,a={$$typeof:k,type:a,key:T,props:W,_owner:z},(j!==void 0?j:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:d}):Object.defineProperty(a,"ref",{enumerable:!1,value:null}),a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(a,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(a,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.defineProperty(a,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a}function b(a,T,j,_,z,W,G,J){var N=T.children;if(N!==void 0)if(_)if(D(N)){for(_=0;_<N.length;_++)C(N[_]);Object.freeze&&Object.freeze(N)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else C(N);if(v.call(T,"key")){N=t(a);var U=Object.keys(T).filter(function(qe){return qe!=="key"});_=0<U.length?"{key: someKey, "+U.join(": ..., ")+": ...}":"{key: someKey}",re[N+_]||(U=0<U.length?"{"+U.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,j,N,U,N),re[N+j]=!0)}if(N=null,_!==void 0&&(r(_),N=""+_),c(T)&&(r(T.key),N=""+T.key),"key"in T){_={};for(var ie in T)ie!=="key"&&(_[ie]=T[ie])}else _=T;return N&&f(_,typeof a=="function"?a.displayName||a.name||"Unknown":a),y(a,N,W,z,s(),_,G,J)}function x(a){typeof a=="object"&&a!==null&&a.$$typeof===k&&a._store&&(a._store.validated=1)}var P=E,k=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),w=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),l=Symbol.for("react.activity"),o=Symbol.for("react.client.reference"),p=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,D=Array.isArray,C=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(a){return a()}};var K,I={},B=P.react_stack_bottom_frame.bind(P,u)(),V=C(n(u)),re={};Z.Fragment=g,Z.jsx=function(a,T,_,j,z){var W=1e4>p.recentlyCreatedOwnerStacks++;return b(a,T,_,!1,j,z,W?Error("react-stack-top-frame"):B,W?C(n(a)):V)},Z.jsxs=function(a,T,_,j,z){var W=1e4>p.recentlyCreatedOwnerStacks++;return b(a,T,_,!0,j,z,W?Error("react-stack-top-frame"):B,W?C(n(a)):V)}}()),Z}var ue;function Te(){return ue||(ue=1,process.env.NODE_ENV==="production"?ee.exports=xe():ee.exports=Ce()),ee.exports}var L=Te();const Q=E.createContext(null),Re="https://api.kelet.ai/",Oe=()=>{const t=E.useContext(Q);if(!t)throw new Error("useKelet must be used within a KeletProvider");return t},oe=()=>{const t=E.useContext(Q);return t?t.feedback:async()=>{}},Ae=({apiKey:t,project:e,children:r})=>{const n=E.useContext(Q),s=t||n?.api_key;if(!s)throw new Error("apiKey is required either directly or from a parent KeletProvider");const c={api_key:s,project:e,feedback:async f=>{const d=`${Re}/projects/${e}/feedback`,y={tx_id:f.identifier,source:f.source||"EXPLICIT",vote:f.vote,explanation:f.explanation,correction:f.correction,selection:f.selection},b=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},body:JSON.stringify(y)});if(!b.ok)throw new Error(`Failed to submit feedback: ${b.statusText}`)}};return L.jsx(Q.Provider,{value:c,children:r})},q=(t,e)=>{const r={...e};for(const n in e){const s=t[n],u=e[n];/^on[A-Z]/.test(n)?s&&u?r[n]=(...f)=>{u(...f),s(...f)}:s&&(r[n]=s):n==="style"?r[n]={...s,...u}:n==="className"?r[n]=[s,u].filter(Boolean).join(" "):r[n]=u!==void 0?u:s}return{...t,...r}},fe=E.createContext(null),$=()=>{const t=E.useContext(fe);if(!t)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return t},De={Root:({children:t,onFeedback:e,defaultText:r="",identifier:n,extra_metadata:s,trigger_name:u})=>{const[c,f]=E.useState(!1),[d,y]=E.useState(r),[b,x]=E.useState(!1),[P,k]=E.useState(null),h=E.useRef(null),g=E.useRef(null),R=E.useId(),O=E.useId(),m=oe(),w=e||m,S=E.useCallback(async()=>{k("upvote");const o={identifier:n,vote:"upvote",...s&&{extra_metadata:s},...u&&{trigger_name:u}};try{x(!0),await w(o)}finally{x(!1)}},[w,n,s,u]),A=E.useCallback(async()=>{if(k("downvote"),w){const o={identifier:n,vote:"downvote",...s&&{extra_metadata:s},...u&&{trigger_name:u}};try{x(!0),await w(o)}finally{x(!1)}}f(!0),setTimeout(()=>{h.current?.focus();const o=document.createElement("div");o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.className="sr-only",o.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(o),setTimeout(()=>document.body.removeChild(o),1e3)},0)},[w,n,s,u]),F=E.useCallback(o=>{y(o.target.value)},[]),M=E.useCallback(async()=>{const o=d.trim().length>0;if(o){const p={identifier:n,vote:"downvote",explanation:d,...s&&{extra_metadata:s},...u&&{trigger_name:u}};try{x(!0),await w(p)}finally{x(!1)}}if(f(!1),y(r),g.current?.focus(),o){const p=document.createElement("div");p.setAttribute("aria-live","polite"),p.className="sr-only",p.textContent="Feedback submitted successfully.",document.body.appendChild(p),setTimeout(()=>document.body.removeChild(p),1e3)}},[w,d,r,n,s,u]),i=E.useCallback(o=>{if(o.key==="Escape")f(!1),y(r),g.current?.focus();else if((o.metaKey||o.ctrlKey)&&o.key==="Enter")o.preventDefault(),M().then(p=>{});else if(o.key==="Tab"&&c){const p=document.getElementById(R);if(p){const v=p.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),D=v[0],C=v[v.length-1];o.shiftKey&&document.activeElement===D?(o.preventDefault(),C?.focus()):!o.shiftKey&&document.activeElement===C&&(o.preventDefault(),D?.focus())}}},[M,c,R,r]),l={onFeedback:w,showPopover:c,setShowPopover:f,feedbackText:d,setFeedbackText:y,isSubmitting:b,setIsSubmitting:x,vote:P,handleUpvote:S,handleDownvote:A,handleTextareaChange:F,handleSubmit:M,handleKeyDown:i,textareaRef:h,triggerRef:g,popoverId:R,triggerId:O,identifier:n,extra_metadata:s,trigger_name:u};return L.jsx(fe.Provider,{value:l,children:t})},UpvoteButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleUpvote:s,isSubmitting:u,vote:c}=$(),f=E.useCallback(b=>{s(),r?.(b)},[s,r]),d={...n,onClick:f,disabled:u||n.disabled,"aria-label":n["aria-label"]||"Upvote feedback",type:"button"},y=c==="upvote";if(t){const b=typeof e=="function"?e({isSelected:y}):e;if(E.isValidElement(b))return E.cloneElement(b,q(d,b.props))}return L.jsx("button",{...d,children:typeof e=="function"?e({isSelected:y}):e})},DownvoteButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleDownvote:s,showPopover:u,isSubmitting:c,popoverId:f,triggerId:d,triggerRef:y,vote:b}=$(),x=E.useCallback(h=>{s(),r?.(h)},[s,r]),P={...n,ref:y,onClick:x,disabled:c||n.disabled,"aria-label":n["aria-label"]||"Downvote feedback","aria-expanded":u,"aria-controls":f,id:d,type:"button"},k=b==="downvote";if(t){const h=typeof e=="function"?e({isSelected:k}):e;if(E.isValidElement(h))return E.cloneElement(h,q(P,h.props));if(h)return h}return L.jsx("button",{...P,children:typeof e=="function"?e({isSelected:k}):e})},Popover:({asChild:t,children:e,...r})=>{const{showPopover:n,handleKeyDown:s,popoverId:u,triggerId:c}=$();if(!n)return null;const f={...r,role:"dialog","aria-labelledby":c,"aria-modal":!0,"aria-describedby":`${u}-description`,id:u,onKeyDown:s,tabIndex:-1};return t&&E.isValidElement(e)?L.jsxs(L.Fragment,{children:[E.cloneElement(e,q(f,e.props)),L.jsx("div",{id:`${u}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"})]}):L.jsxs("div",{...f,children:[L.jsx("div",{id:`${u}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"}),e]})},Textarea:({asChild:t,value:e,onChange:r,...n})=>{const{feedbackText:s,handleTextareaChange:u,textareaRef:c,handleKeyDown:f,popoverId:d}=$(),y={...n,ref:c,value:e!==void 0?e:s,onChange:r||u,onKeyDown:f,placeholder:n.placeholder||"What did we miss?","aria-label":n["aria-label"]||"Additional feedback","aria-describedby":`${d}-help`,rows:n.rows||3};return t&&E.isValidElement(n.children)?E.cloneElement(n.children,q(y,n.children.props)):L.jsx("textarea",{...y})},SubmitButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleSubmit:s,isSubmitting:u,feedbackText:c}=$(),f=E.useCallback(x=>{s(),r?.(x)},[s,r]),d=c.trim().length>0,y=d?"Submit feedback":"Close without feedback",b={...n,onClick:f,disabled:u||n.disabled,type:"button","aria-label":n["aria-label"]||y,"aria-describedby":d?void 0:"submit-help"};return t&&E.isValidElement(e)?L.jsxs(L.Fragment,{children:[E.cloneElement(e,q(b,e.props)),!d&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):L.jsxs("button",{...b,children:[e,!d&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var te={exports:{}},Se=te.exports,ce;function _e(){return ce||(ce=1,function(t,e){(function(r,n){var s=n(r);t.exports=s})(Se,function(r){var n=["N","E","A","D"];function s(i,l){i.super_=l,i.prototype=Object.create(l.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}})}function u(i,l){Object.defineProperty(this,"kind",{value:i,enumerable:!0}),l&&l.length&&Object.defineProperty(this,"path",{value:l,enumerable:!0})}function c(i,l,o){c.super_.call(this,"E",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0}),Object.defineProperty(this,"rhs",{value:o,enumerable:!0})}s(c,u);function f(i,l){f.super_.call(this,"N",i),Object.defineProperty(this,"rhs",{value:l,enumerable:!0})}s(f,u);function d(i,l){d.super_.call(this,"D",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0})}s(d,u);function y(i,l,o){y.super_.call(this,"A",i),Object.defineProperty(this,"index",{value:l,enumerable:!0}),Object.defineProperty(this,"item",{value:o,enumerable:!0})}s(y,u);function b(i,l,o){var p=i.slice(l+1||i.length);return i.length=l<0?i.length+l:l,i.push.apply(i,p),i}function x(i){var l=typeof i;return l!=="object"?l:i===Math?"math":i===null?"null":Array.isArray(i)?"array":Object.prototype.toString.call(i)==="[object Date]"?"date":typeof i.toString=="function"&&/^\/.*\//.test(i.toString())?"regexp":"object"}function P(i){var l=0;if(i.length===0)return l;for(var o=0;o<i.length;o++){var p=i.charCodeAt(o);l=(l<<5)-l+p,l=l&l}return l}function k(i){var l=0,o=x(i);if(o==="array"){i.forEach(function(K){l+=k(K)});var p="[type: array, hash: "+l+"]";return l+P(p)}if(o==="object"){for(var v in i)if(i.hasOwnProperty(v)){var D="[ type: object, key: "+v+", value hash: "+k(i[v])+"]";l+=P(D)}return l}var C="[ type: "+o+" ; value: "+i+"]";return l+P(C)}function h(i,l,o,p,v,D,C,K){o=o||[],v=v||[],C=C||[];var I=v.slice(0);if(typeof D<"u"&&D!==null){if(p){if(typeof p=="function"&&p(I,D))return;if(typeof p=="object"){if(p.prefilter&&p.prefilter(I,D))return;if(p.normalize){var B=p.normalize(I,D,i,l);B&&(i=B[0],l=B[1])}}}I.push(D)}x(i)==="regexp"&&x(l)==="regexp"&&(i=i.toString(),l=l.toString());var V=typeof i,re=typeof l,a,T,_,j,z=V!=="undefined"||C&&C.length>0&&C[C.length-1].lhs&&Object.getOwnPropertyDescriptor(C[C.length-1].lhs,D),W=re!=="undefined"||C&&C.length>0&&C[C.length-1].rhs&&Object.getOwnPropertyDescriptor(C[C.length-1].rhs,D);if(!z&&W)o.push(new f(I,l));else if(!W&&z)o.push(new d(I,i));else if(x(i)!==x(l))o.push(new c(I,i,l));else if(x(i)==="date"&&i-l!==0)o.push(new c(I,i,l));else if(V==="object"&&i!==null&&l!==null){for(a=C.length-1;a>-1;--a)if(C[a].lhs===i){j=!0;break}if(j)i!==l&&o.push(new c(I,i,l));else{if(C.push({lhs:i,rhs:l}),Array.isArray(i)){for(K&&(i.sort(function(N,U){return k(N)-k(U)}),l.sort(function(N,U){return k(N)-k(U)})),a=l.length-1,T=i.length-1;a>T;)o.push(new y(I,a,new f(void 0,l[a--])));for(;T>a;)o.push(new y(I,T,new d(void 0,i[T--])));for(;a>=0;--a)h(i[a],l[a],o,p,I,a,C,K)}else{var G=Object.keys(i),J=Object.keys(l);for(a=0;a<G.length;++a)_=G[a],j=J.indexOf(_),j>=0?(h(i[_],l[_],o,p,I,_,C,K),J[j]=null):h(i[_],void 0,o,p,I,_,C,K);for(a=0;a<J.length;++a)_=J[a],_&&h(void 0,l[_],o,p,I,_,C,K)}C.length=C.length-1}}else i!==l&&(V==="number"&&isNaN(i)&&isNaN(l)||o.push(new c(I,i,l)))}function g(i,l,o,p,v){var D=[];if(h(i,l,D,p,null,null,null,v),o)for(var C=0;C<D.length;++C)o(D[C]);return D}function R(i,l,o,p,v,D,C){return h(i,l,o,p,v,D,C,!0)}function O(i,l,o,p){var v=p?function(C){C&&p.push(C)}:void 0,D=g(i,l,v,o);return p||(D.length?D:void 0)}function m(i,l,o,p){var v=p?function(C){C&&p.push(C)}:void 0,D=g(i,l,v,o,!0);return p||(D.length?D:void 0)}function w(i,l,o){if(o.path&&o.path.length){var p=i[l],v,D=o.path.length-1;for(v=0;v<D;v++)p=p[o.path[v]];switch(o.kind){case"A":w(p[o.path[v]],o.index,o.item);break;case"D":delete p[o.path[v]];break;case"E":case"N":p[o.path[v]]=o.rhs;break}}else switch(o.kind){case"A":w(i[l],o.index,o.item);break;case"D":i=b(i,l);break;case"E":case"N":i[l]=o.rhs;break}return i}function S(i,l,o){if(typeof o>"u"&&l&&~n.indexOf(l.kind)&&(o=l),i&&o&&o.kind){for(var p=i,v=-1,D=o.path?o.path.length-1:0;++v<D;)typeof p[o.path[v]]>"u"&&(p[o.path[v]]=typeof o.path[v+1]<"u"&&typeof o.path[v+1]=="number"?[]:{}),p=p[o.path[v]];switch(o.kind){case"A":o.path&&typeof p[o.path[v]]>"u"&&(p[o.path[v]]=[]),w(o.path?p[o.path[v]]:p,o.index,o.item);break;case"D":delete p[o.path[v]];break;case"E":case"N":p[o.path[v]]=o.rhs;break}}}function A(i,l,o){if(o.path&&o.path.length){var p=i[l],v,D=o.path.length-1;for(v=0;v<D;v++)p=p[o.path[v]];switch(o.kind){case"A":A(p[o.path[v]],o.index,o.item);break;case"D":p[o.path[v]]=o.lhs;break;case"E":p[o.path[v]]=o.lhs;break;case"N":delete p[o.path[v]];break}}else switch(o.kind){case"A":A(i[l],o.index,o.item);break;case"D":i[l]=o.lhs;break;case"E":i[l]=o.lhs;break;case"N":i=b(i,l);break}return i}function F(i,l,o){if(i&&l&&o&&o.kind){var p=i,v,D;for(D=o.path.length-1,v=0;v<D;v++)typeof p[o.path[v]]>"u"&&(p[o.path[v]]={}),p=p[o.path[v]];switch(o.kind){case"A":A(p[o.path[v]],o.index,o.item);break;case"D":p[o.path[v]]=o.lhs;break;case"E":p[o.path[v]]=o.lhs;break;case"N":delete p[o.path[v]];break}}}function M(i,l,o){if(i&&l){var p=function(v){(!o||o(i,l,v))&&S(i,l,v)};g(i,l,p)}}return Object.defineProperties(O,{diff:{value:O,enumerable:!0},orderIndependentDiff:{value:m,enumerable:!0},observableDiff:{value:g,enumerable:!0},orderIndependentObservableDiff:{value:R,enumerable:!0},orderIndepHash:{value:k,enumerable:!0},applyDiff:{value:M,enumerable:!0},applyChange:{value:S,enumerable:!0},revertChange:{value:F,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),O.DeepDiff=O,r&&(r.DeepDiff=O),O})}(te)),te.exports}var de=_e(),ne={exports:{}};const H=new Uint32Array(65536),je=(t,e)=>{const r=t.length,n=e.length,s=1<<r-1;let u=-1,c=0,f=r,d=r;for(;d--;)H[t.charCodeAt(d)]|=1<<d;for(d=0;d<n;d++){let y=H[e.charCodeAt(d)];const b=y|c;y|=(y&u)+u^u,c|=~(y|u),u&=y,c&s&&f++,u&s&&f--,c=c<<1|1,u=u<<1|~(b|c),c&=b}for(d=r;d--;)H[t.charCodeAt(d)]=0;return f},Ne=(t,e)=>{const r=e.length,n=t.length,s=[],u=[],c=Math.ceil(r/32),f=Math.ceil(n/32);for(let h=0;h<c;h++)u[h]=-1,s[h]=0;let d=0;for(;d<f-1;d++){let h=0,g=-1;const R=d*32,O=Math.min(32,n)+R;for(let m=R;m<O;m++)H[t.charCodeAt(m)]|=1<<m;for(let m=0;m<r;m++){const w=H[e.charCodeAt(m)],S=u[m/32|0]>>>m&1,A=s[m/32|0]>>>m&1,F=w|h,M=((w|A)&g)+g^g|w|A;let i=h|~(M|g),l=g&M;i>>>31^S&&(u[m/32|0]^=1<<m),l>>>31^A&&(s[m/32|0]^=1<<m),i=i<<1|S,l=l<<1|A,g=l|~(F|i),h=i&F}for(let m=R;m<O;m++)H[t.charCodeAt(m)]=0}let y=0,b=-1;const x=d*32,P=Math.min(32,n-x)+x;for(let h=x;h<P;h++)H[t.charCodeAt(h)]|=1<<h;let k=n;for(let h=0;h<r;h++){const g=H[e.charCodeAt(h)],R=u[h/32|0]>>>h&1,O=s[h/32|0]>>>h&1,m=g|y,w=((g|O)&b)+b^b|g|O;let S=y|~(w|b),A=b&w;k+=S>>>n-1&1,k-=A>>>n-1&1,S>>>31^R&&(u[h/32|0]^=1<<h),A>>>31^O&&(s[h/32|0]^=1<<h),S=S<<1|R,A=A<<1|O,b=A|~(m|S),y=S&m}for(let h=x;h<P;h++)H[t.charCodeAt(h)]=0;return k},pe=(t,e)=>{if(t.length<e.length){const r=e;e=t,t=r}return e.length===0?t.length:t.length<=32?je(t,e):Ne(t,e)},Ie=Pe(Object.freeze(Object.defineProperty({__proto__:null,closest:(t,e)=>{let r=1/0,n=0;for(let s=0;s<e.length;s++){const u=pe(t,e[s]);u<r&&(r=u,n=s)}return e[n]},distance:pe},Symbol.toStringTag,{value:"Module"})));var he;function Fe(){return he||(he=1,function(t,e){(function(){var r;try{r=typeof Intl<"u"&&typeof Intl.Collator<"u"?Intl.Collator("generic",{sensitivity:"base"}):null}catch{console.log("Collator could not be initialized and wouldn't be used")}var n=Ie,s=[],u=[],c={get:function(f,d,y){var b=y&&r&&y.useCollator;if(b){var x=f.length,P=d.length;if(x===0)return P;if(P===0)return x;var k,h,g,R,O;for(g=0;g<P;++g)s[g]=g,u[g]=d.charCodeAt(g);s[P]=P;var m;for(g=0;g<x;++g){for(h=g+1,R=0;R<P;++R)k=h,m=r.compare(f.charAt(g),String.fromCharCode(u[R]))===0,h=s[R]+(m?0:1),O=k+1,h>O&&(h=O),O=s[R+1]+1,h>O&&(h=O),s[R]=k;s[R]=h}return h}return n.distance(f,d)}};t!==null&&t.exports===e?t.exports=c:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=c:typeof window<"u"&&window!==null&&(window.Levenshtein=c)})()}(ne,ne.exports)),ne.exports}var Le=Fe();const Me=Ee(Le);class We{diff(e,r,n={}){let s;typeof n=="function"?(s=n,n={}):"callback"in n&&(s=n.callback);const u=this.castInput(e,n),c=this.castInput(r,n),f=this.removeEmpty(this.tokenize(u,n)),d=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(f,d,n,s)}diffWithOptionsObj(e,r,n,s){var u;const c=m=>{if(m=this.postProcess(m,n),s){setTimeout(function(){s(m)},0);return}else return m},f=r.length,d=e.length;let y=1,b=f+d;n.maxEditLength!=null&&(b=Math.min(b,n.maxEditLength));const x=(u=n.timeout)!==null&&u!==void 0?u:1/0,P=Date.now()+x,k=[{oldPos:-1,lastComponent:void 0}];let h=this.extractCommon(k[0],r,e,0,n);if(k[0].oldPos+1>=d&&h+1>=f)return c(this.buildValues(k[0].lastComponent,r,e));let g=-1/0,R=1/0;const O=()=>{for(let m=Math.max(g,-y);m<=Math.min(R,y);m+=2){let w;const S=k[m-1],A=k[m+1];S&&(k[m-1]=void 0);let F=!1;if(A){const i=A.oldPos-m;F=A&&0<=i&&i<f}const M=S&&S.oldPos+1<d;if(!F&&!M){k[m]=void 0;continue}if(!M||F&&S.oldPos<A.oldPos?w=this.addToPath(A,!0,!1,0,n):w=this.addToPath(S,!1,!0,1,n),h=this.extractCommon(w,r,e,m,n),w.oldPos+1>=d&&h+1>=f)return c(this.buildValues(w.lastComponent,r,e))||!0;k[m]=w,w.oldPos+1>=d&&(R=Math.min(R,m-1)),h+1>=f&&(g=Math.max(g,m+1))}y++};if(s)(function m(){setTimeout(function(){if(y>b||Date.now()>P)return s(void 0);O()||m()},0)})();else for(;y<=b&&Date.now()<=P;){const m=O();if(m)return m}}addToPath(e,r,n,s,u){const c=e.lastComponent;return c&&!u.oneChangePerToken&&c.added===r&&c.removed===n?{oldPos:e.oldPos+s,lastComponent:{count:c.count+1,added:r,removed:n,previousComponent:c.previousComponent}}:{oldPos:e.oldPos+s,lastComponent:{count:1,added:r,removed:n,previousComponent:c}}}extractCommon(e,r,n,s,u){const c=r.length,f=n.length;let d=e.oldPos,y=d-s,b=0;for(;y+1<c&&d+1<f&&this.equals(n[d+1],r[y+1],u);)y++,d++,b++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return b&&!u.oneChangePerToken&&(e.lastComponent={count:b,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=d,y}equals(e,r,n){return n.comparator?n.comparator(e,r):e===r||!!n.ignoreCase&&e.toLowerCase()===r.toLowerCase()}removeEmpty(e){const r=[];for(let n=0;n<e.length;n++)e[n]&&r.push(e[n]);return r}castInput(e,r){return e}tokenize(e,r){return Array.from(e)}join(e){return e.join("")}postProcess(e,r){return e}get useLongestToken(){return!1}buildValues(e,r,n){const s=[];let u;for(;e;)s.push(e),u=e.previousComponent,delete e.previousComponent,e=u;s.reverse();const c=s.length;let f=0,d=0,y=0;for(;f<c;f++){const b=s[f];if(b.removed)b.value=this.join(n.slice(y,y+b.count)),y+=b.count;else{if(!b.added&&this.useLongestToken){let x=r.slice(d,d+b.count);x=x.map(function(P,k){const h=n[y+k];return h.length>P.length?h:P}),b.value=this.join(x)}else b.value=this.join(r.slice(d,d+b.count));d+=b.count,b.added||(y+=b.count)}}return s}}class Ye extends We{constructor(){super(...arguments),this.tokenize=Ke}equals(e,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
22
+ <%s key={someKey} {...props} />`,_,N,U,N),re[N+_]=!0)}if(N=null,j!==void 0&&(r(j),N=""+j),c(T)&&(r(T.key),N=""+T.key),"key"in T){j={};for(var se in T)se!=="key"&&(j[se]=T[se])}else j=T;return N&&f(j,typeof a=="function"?a.displayName||a.name||"Unknown":a),y(a,N,W,z,i(),j,G,J)}function C(a){typeof a=="object"&&a!==null&&a.$$typeof===k&&a._store&&(a._store.validated=1)}var P=E,k=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),m=Symbol.for("react.consumer"),w=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),A=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),M=Symbol.for("react.memo"),s=Symbol.for("react.lazy"),l=Symbol.for("react.activity"),o=Symbol.for("react.client.reference"),p=P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,D=Array.isArray,x=console.createTask?console.createTask:function(){return null};P={react_stack_bottom_frame:function(a){return a()}};var K,I={},B=P.react_stack_bottom_frame.bind(P,u)(),V=x(n(u)),re={};Z.Fragment=g,Z.jsx=function(a,T,j,_,z){var W=1e4>p.recentlyCreatedOwnerStacks++;return b(a,T,j,!1,_,z,W?Error("react-stack-top-frame"):B,W?x(n(a)):V)},Z.jsxs=function(a,T,j,_,z){var W=1e4>p.recentlyCreatedOwnerStacks++;return b(a,T,j,!0,_,z,W?Error("react-stack-top-frame"):B,W?x(n(a)):V)}}()),Z}var ue;function Te(){return ue||(ue=1,process.env.NODE_ENV==="production"?ee.exports=Ce():ee.exports=xe()),ee.exports}var L=Te();const Q=E.createContext(null),Re="https://api.kelet.ai/",Oe=()=>{const t=E.useContext(Q);if(!t)throw new Error("useKelet must be used within a KeletProvider");return t},oe=()=>{const t=E.useContext(Q);return t?t.feedback:async()=>{}},Ae=({apiKey:t,project:e,children:r})=>{const n=E.useContext(Q),i=t||n?.api_key;if(!i)throw new Error("apiKey is required either directly or from a parent KeletProvider");const c={api_key:i,project:e,feedback:async f=>{const d=`${Re}/projects/${e}/feedback`,y={tx_id:f.tx_id,source:f.source||"EXPLICIT",vote:f.vote,explanation:f.explanation,correction:f.correction,selection:f.selection},b=await fetch(d,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify(y)});if(!b.ok)throw new Error(`Failed to submit feedback: ${b.statusText}`)}};return L.jsx(Q.Provider,{value:c,children:r})},q=(t,e)=>{const r={...e};for(const n in e){const i=t[n],u=e[n];/^on[A-Z]/.test(n)?i&&u?r[n]=(...f)=>{u(...f),i(...f)}:i&&(r[n]=i):n==="style"?r[n]={...i,...u}:n==="className"?r[n]=[i,u].filter(Boolean).join(" "):r[n]=u!==void 0?u:i}return{...t,...r}},fe=E.createContext(null),$=()=>{const t=E.useContext(fe);if(!t)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return t},De={Root:({children:t,onFeedback:e,defaultText:r="",tx_id:n,extra_metadata:i,trigger_name:u})=>{const[c,f]=E.useState(!1),[d,y]=E.useState(r),[b,C]=E.useState(!1),[P,k]=E.useState(null),h=E.useRef(null),g=E.useRef(null),R=E.useId(),O=E.useId(),m=oe(),w=e||m,S=E.useCallback(async()=>{k("upvote");const o={tx_id:n,vote:"upvote",...i&&{extra_metadata:i},...u&&{trigger_name:u}};try{C(!0),await w(o)}finally{C(!1)}},[w,n,i,u]),A=E.useCallback(async()=>{if(k("downvote"),w){const o={tx_id:n,vote:"downvote",...i&&{extra_metadata:i},...u&&{trigger_name:u}};try{C(!0),await w(o)}finally{C(!1)}}f(!0),setTimeout(()=>{h.current?.focus();const o=document.createElement("div");o.setAttribute("aria-live","polite"),o.setAttribute("aria-atomic","true"),o.className="sr-only",o.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(o),setTimeout(()=>document.body.removeChild(o),1e3)},0)},[w,n,i,u]),F=E.useCallback(o=>{y(o.target.value)},[]),M=E.useCallback(async()=>{const o=d.trim().length>0;if(o){const p={tx_id:n,vote:"downvote",explanation:d,...i&&{extra_metadata:i},...u&&{trigger_name:u}};try{C(!0),await w(p)}finally{C(!1)}}if(f(!1),y(r),g.current?.focus(),o){const p=document.createElement("div");p.setAttribute("aria-live","polite"),p.className="sr-only",p.textContent="Feedback submitted successfully.",document.body.appendChild(p),setTimeout(()=>document.body.removeChild(p),1e3)}},[w,d,r,n,i,u]),s=E.useCallback(o=>{if(o.key==="Escape")f(!1),y(r),g.current?.focus();else if((o.metaKey||o.ctrlKey)&&o.key==="Enter")o.preventDefault(),M().then(p=>{});else if(o.key==="Tab"&&c){const p=document.getElementById(R);if(p){const v=p.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),D=v[0],x=v[v.length-1];o.shiftKey&&document.activeElement===D?(o.preventDefault(),x?.focus()):!o.shiftKey&&document.activeElement===x&&(o.preventDefault(),D?.focus())}}},[M,c,R,r]),l={onFeedback:w,showPopover:c,setShowPopover:f,feedbackText:d,setFeedbackText:y,isSubmitting:b,setIsSubmitting:C,vote:P,handleUpvote:S,handleDownvote:A,handleTextareaChange:F,handleSubmit:M,handleKeyDown:s,textareaRef:h,triggerRef:g,popoverId:R,triggerId:O,tx_id:n,extra_metadata:i,trigger_name:u};return L.jsx(fe.Provider,{value:l,children:t})},UpvoteButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleUpvote:i,isSubmitting:u,vote:c}=$(),f=E.useCallback(b=>{i(),r?.(b)},[i,r]),d={...n,onClick:f,disabled:u||n.disabled,"aria-label":n["aria-label"]||"Upvote feedback",type:"button"},y=c==="upvote";if(t){const b=typeof e=="function"?e({isSelected:y}):e;if(E.isValidElement(b))return E.cloneElement(b,q(d,b.props))}return L.jsx("button",{...d,children:typeof e=="function"?e({isSelected:y}):e})},DownvoteButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleDownvote:i,showPopover:u,isSubmitting:c,popoverId:f,triggerId:d,triggerRef:y,vote:b}=$(),C=E.useCallback(h=>{i(),r?.(h)},[i,r]),P={...n,ref:y,onClick:C,disabled:c||n.disabled,"aria-label":n["aria-label"]||"Downvote feedback","aria-expanded":u,"aria-controls":f,id:d,type:"button"},k=b==="downvote";if(t){const h=typeof e=="function"?e({isSelected:k}):e;if(E.isValidElement(h))return E.cloneElement(h,q(P,h.props));if(h)return h}return L.jsx("button",{...P,children:typeof e=="function"?e({isSelected:k}):e})},Popover:({asChild:t,children:e,...r})=>{const{showPopover:n,handleKeyDown:i,popoverId:u,triggerId:c}=$();if(!n)return null;const f={...r,role:"dialog","aria-labelledby":c,"aria-modal":!0,"aria-describedby":`${u}-description`,id:u,onKeyDown:i,tabIndex:-1};return t&&E.isValidElement(e)?L.jsxs(L.Fragment,{children:[E.cloneElement(e,q(f,e.props)),L.jsx("div",{id:`${u}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"})]}):L.jsxs("div",{...f,children:[L.jsx("div",{id:`${u}-description`,className:"sr-only",children:"Provide additional feedback for your downvote"}),e]})},Textarea:({asChild:t,value:e,onChange:r,...n})=>{const{feedbackText:i,handleTextareaChange:u,textareaRef:c,handleKeyDown:f,popoverId:d}=$(),y={...n,ref:c,value:e!==void 0?e:i,onChange:r||u,onKeyDown:f,placeholder:n.placeholder||"What did we miss?","aria-label":n["aria-label"]||"Additional feedback","aria-describedby":`${d}-help`,rows:n.rows||3};return t&&E.isValidElement(n.children)?E.cloneElement(n.children,q(y,n.children.props)):L.jsx("textarea",{...y})},SubmitButton:({asChild:t,children:e,onClick:r,...n})=>{const{handleSubmit:i,isSubmitting:u,feedbackText:c}=$(),f=E.useCallback(C=>{i(),r?.(C)},[i,r]),d=c.trim().length>0,y=d?"Submit feedback":"Close without feedback",b={...n,onClick:f,disabled:u||n.disabled,type:"button","aria-label":n["aria-label"]||y,"aria-describedby":d?void 0:"submit-help"};return t&&E.isValidElement(e)?L.jsxs(L.Fragment,{children:[E.cloneElement(e,q(b,e.props)),!d&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):L.jsxs("button",{...b,children:[e,!d&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var te={exports:{}},Se=te.exports,ce;function je(){return ce||(ce=1,function(t,e){(function(r,n){var i=n(r);t.exports=i})(Se,function(r){var n=["N","E","A","D"];function i(s,l){s.super_=l,s.prototype=Object.create(l.prototype,{constructor:{value:s,enumerable:!1,writable:!0,configurable:!0}})}function u(s,l){Object.defineProperty(this,"kind",{value:s,enumerable:!0}),l&&l.length&&Object.defineProperty(this,"path",{value:l,enumerable:!0})}function c(s,l,o){c.super_.call(this,"E",s),Object.defineProperty(this,"lhs",{value:l,enumerable:!0}),Object.defineProperty(this,"rhs",{value:o,enumerable:!0})}i(c,u);function f(s,l){f.super_.call(this,"N",s),Object.defineProperty(this,"rhs",{value:l,enumerable:!0})}i(f,u);function d(s,l){d.super_.call(this,"D",s),Object.defineProperty(this,"lhs",{value:l,enumerable:!0})}i(d,u);function y(s,l,o){y.super_.call(this,"A",s),Object.defineProperty(this,"index",{value:l,enumerable:!0}),Object.defineProperty(this,"item",{value:o,enumerable:!0})}i(y,u);function b(s,l,o){var p=s.slice(l+1||s.length);return s.length=l<0?s.length+l:l,s.push.apply(s,p),s}function C(s){var l=typeof s;return l!=="object"?l:s===Math?"math":s===null?"null":Array.isArray(s)?"array":Object.prototype.toString.call(s)==="[object Date]"?"date":typeof s.toString=="function"&&/^\/.*\//.test(s.toString())?"regexp":"object"}function P(s){var l=0;if(s.length===0)return l;for(var o=0;o<s.length;o++){var p=s.charCodeAt(o);l=(l<<5)-l+p,l=l&l}return l}function k(s){var l=0,o=C(s);if(o==="array"){s.forEach(function(K){l+=k(K)});var p="[type: array, hash: "+l+"]";return l+P(p)}if(o==="object"){for(var v in s)if(s.hasOwnProperty(v)){var D="[ type: object, key: "+v+", value hash: "+k(s[v])+"]";l+=P(D)}return l}var x="[ type: "+o+" ; value: "+s+"]";return l+P(x)}function h(s,l,o,p,v,D,x,K){o=o||[],v=v||[],x=x||[];var I=v.slice(0);if(typeof D<"u"&&D!==null){if(p){if(typeof p=="function"&&p(I,D))return;if(typeof p=="object"){if(p.prefilter&&p.prefilter(I,D))return;if(p.normalize){var B=p.normalize(I,D,s,l);B&&(s=B[0],l=B[1])}}}I.push(D)}C(s)==="regexp"&&C(l)==="regexp"&&(s=s.toString(),l=l.toString());var V=typeof s,re=typeof l,a,T,j,_,z=V!=="undefined"||x&&x.length>0&&x[x.length-1].lhs&&Object.getOwnPropertyDescriptor(x[x.length-1].lhs,D),W=re!=="undefined"||x&&x.length>0&&x[x.length-1].rhs&&Object.getOwnPropertyDescriptor(x[x.length-1].rhs,D);if(!z&&W)o.push(new f(I,l));else if(!W&&z)o.push(new d(I,s));else if(C(s)!==C(l))o.push(new c(I,s,l));else if(C(s)==="date"&&s-l!==0)o.push(new c(I,s,l));else if(V==="object"&&s!==null&&l!==null){for(a=x.length-1;a>-1;--a)if(x[a].lhs===s){_=!0;break}if(_)s!==l&&o.push(new c(I,s,l));else{if(x.push({lhs:s,rhs:l}),Array.isArray(s)){for(K&&(s.sort(function(N,U){return k(N)-k(U)}),l.sort(function(N,U){return k(N)-k(U)})),a=l.length-1,T=s.length-1;a>T;)o.push(new y(I,a,new f(void 0,l[a--])));for(;T>a;)o.push(new y(I,T,new d(void 0,s[T--])));for(;a>=0;--a)h(s[a],l[a],o,p,I,a,x,K)}else{var G=Object.keys(s),J=Object.keys(l);for(a=0;a<G.length;++a)j=G[a],_=J.indexOf(j),_>=0?(h(s[j],l[j],o,p,I,j,x,K),J[_]=null):h(s[j],void 0,o,p,I,j,x,K);for(a=0;a<J.length;++a)j=J[a],j&&h(void 0,l[j],o,p,I,j,x,K)}x.length=x.length-1}}else s!==l&&(V==="number"&&isNaN(s)&&isNaN(l)||o.push(new c(I,s,l)))}function g(s,l,o,p,v){var D=[];if(h(s,l,D,p,null,null,null,v),o)for(var x=0;x<D.length;++x)o(D[x]);return D}function R(s,l,o,p,v,D,x){return h(s,l,o,p,v,D,x,!0)}function O(s,l,o,p){var v=p?function(x){x&&p.push(x)}:void 0,D=g(s,l,v,o);return p||(D.length?D:void 0)}function m(s,l,o,p){var v=p?function(x){x&&p.push(x)}:void 0,D=g(s,l,v,o,!0);return p||(D.length?D:void 0)}function w(s,l,o){if(o.path&&o.path.length){var p=s[l],v,D=o.path.length-1;for(v=0;v<D;v++)p=p[o.path[v]];switch(o.kind){case"A":w(p[o.path[v]],o.index,o.item);break;case"D":delete p[o.path[v]];break;case"E":case"N":p[o.path[v]]=o.rhs;break}}else switch(o.kind){case"A":w(s[l],o.index,o.item);break;case"D":s=b(s,l);break;case"E":case"N":s[l]=o.rhs;break}return s}function S(s,l,o){if(typeof o>"u"&&l&&~n.indexOf(l.kind)&&(o=l),s&&o&&o.kind){for(var p=s,v=-1,D=o.path?o.path.length-1:0;++v<D;)typeof p[o.path[v]]>"u"&&(p[o.path[v]]=typeof o.path[v+1]<"u"&&typeof o.path[v+1]=="number"?[]:{}),p=p[o.path[v]];switch(o.kind){case"A":o.path&&typeof p[o.path[v]]>"u"&&(p[o.path[v]]=[]),w(o.path?p[o.path[v]]:p,o.index,o.item);break;case"D":delete p[o.path[v]];break;case"E":case"N":p[o.path[v]]=o.rhs;break}}}function A(s,l,o){if(o.path&&o.path.length){var p=s[l],v,D=o.path.length-1;for(v=0;v<D;v++)p=p[o.path[v]];switch(o.kind){case"A":A(p[o.path[v]],o.index,o.item);break;case"D":p[o.path[v]]=o.lhs;break;case"E":p[o.path[v]]=o.lhs;break;case"N":delete p[o.path[v]];break}}else switch(o.kind){case"A":A(s[l],o.index,o.item);break;case"D":s[l]=o.lhs;break;case"E":s[l]=o.lhs;break;case"N":s=b(s,l);break}return s}function F(s,l,o){if(s&&l&&o&&o.kind){var p=s,v,D;for(D=o.path.length-1,v=0;v<D;v++)typeof p[o.path[v]]>"u"&&(p[o.path[v]]={}),p=p[o.path[v]];switch(o.kind){case"A":A(p[o.path[v]],o.index,o.item);break;case"D":p[o.path[v]]=o.lhs;break;case"E":p[o.path[v]]=o.lhs;break;case"N":delete p[o.path[v]];break}}}function M(s,l,o){if(s&&l){var p=function(v){(!o||o(s,l,v))&&S(s,l,v)};g(s,l,p)}}return Object.defineProperties(O,{diff:{value:O,enumerable:!0},orderIndependentDiff:{value:m,enumerable:!0},observableDiff:{value:g,enumerable:!0},orderIndependentObservableDiff:{value:R,enumerable:!0},orderIndepHash:{value:k,enumerable:!0},applyDiff:{value:M,enumerable:!0},applyChange:{value:S,enumerable:!0},revertChange:{value:F,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),O.DeepDiff=O,r&&(r.DeepDiff=O),O})}(te)),te.exports}var de=je(),ne={exports:{}};const H=new Uint32Array(65536),_e=(t,e)=>{const r=t.length,n=e.length,i=1<<r-1;let u=-1,c=0,f=r,d=r;for(;d--;)H[t.charCodeAt(d)]|=1<<d;for(d=0;d<n;d++){let y=H[e.charCodeAt(d)];const b=y|c;y|=(y&u)+u^u,c|=~(y|u),u&=y,c&i&&f++,u&i&&f--,c=c<<1|1,u=u<<1|~(b|c),c&=b}for(d=r;d--;)H[t.charCodeAt(d)]=0;return f},Ne=(t,e)=>{const r=e.length,n=t.length,i=[],u=[],c=Math.ceil(r/32),f=Math.ceil(n/32);for(let h=0;h<c;h++)u[h]=-1,i[h]=0;let d=0;for(;d<f-1;d++){let h=0,g=-1;const R=d*32,O=Math.min(32,n)+R;for(let m=R;m<O;m++)H[t.charCodeAt(m)]|=1<<m;for(let m=0;m<r;m++){const w=H[e.charCodeAt(m)],S=u[m/32|0]>>>m&1,A=i[m/32|0]>>>m&1,F=w|h,M=((w|A)&g)+g^g|w|A;let s=h|~(M|g),l=g&M;s>>>31^S&&(u[m/32|0]^=1<<m),l>>>31^A&&(i[m/32|0]^=1<<m),s=s<<1|S,l=l<<1|A,g=l|~(F|s),h=s&F}for(let m=R;m<O;m++)H[t.charCodeAt(m)]=0}let y=0,b=-1;const C=d*32,P=Math.min(32,n-C)+C;for(let h=C;h<P;h++)H[t.charCodeAt(h)]|=1<<h;let k=n;for(let h=0;h<r;h++){const g=H[e.charCodeAt(h)],R=u[h/32|0]>>>h&1,O=i[h/32|0]>>>h&1,m=g|y,w=((g|O)&b)+b^b|g|O;let S=y|~(w|b),A=b&w;k+=S>>>n-1&1,k-=A>>>n-1&1,S>>>31^R&&(u[h/32|0]^=1<<h),A>>>31^O&&(i[h/32|0]^=1<<h),S=S<<1|R,A=A<<1|O,b=A|~(m|S),y=S&m}for(let h=C;h<P;h++)H[t.charCodeAt(h)]=0;return k},pe=(t,e)=>{if(t.length<e.length){const r=e;e=t,t=r}return e.length===0?t.length:t.length<=32?_e(t,e):Ne(t,e)},Ie=Pe(Object.freeze(Object.defineProperty({__proto__:null,closest:(t,e)=>{let r=1/0,n=0;for(let i=0;i<e.length;i++){const u=pe(t,e[i]);u<r&&(r=u,n=i)}return e[n]},distance:pe},Symbol.toStringTag,{value:"Module"})));var he;function Fe(){return he||(he=1,function(t,e){(function(){var r;try{r=typeof Intl<"u"&&typeof Intl.Collator<"u"?Intl.Collator("generic",{sensitivity:"base"}):null}catch{console.log("Collator could not be initialized and wouldn't be used")}var n=Ie,i=[],u=[],c={get:function(f,d,y){var b=y&&r&&y.useCollator;if(b){var C=f.length,P=d.length;if(C===0)return P;if(P===0)return C;var k,h,g,R,O;for(g=0;g<P;++g)i[g]=g,u[g]=d.charCodeAt(g);i[P]=P;var m;for(g=0;g<C;++g){for(h=g+1,R=0;R<P;++R)k=h,m=r.compare(f.charAt(g),String.fromCharCode(u[R]))===0,h=i[R]+(m?0:1),O=k+1,h>O&&(h=O),O=i[R+1]+1,h>O&&(h=O),i[R]=k;i[R]=h}return h}return n.distance(f,d)}};t!==null&&t.exports===e?t.exports=c:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=c:typeof window<"u"&&window!==null&&(window.Levenshtein=c)})()}(ne,ne.exports)),ne.exports}var Le=Fe();const Me=Ee(Le);class We{diff(e,r,n={}){let i;typeof n=="function"?(i=n,n={}):"callback"in n&&(i=n.callback);const u=this.castInput(e,n),c=this.castInput(r,n),f=this.removeEmpty(this.tokenize(u,n)),d=this.removeEmpty(this.tokenize(c,n));return this.diffWithOptionsObj(f,d,n,i)}diffWithOptionsObj(e,r,n,i){var u;const c=m=>{if(m=this.postProcess(m,n),i){setTimeout(function(){i(m)},0);return}else return m},f=r.length,d=e.length;let y=1,b=f+d;n.maxEditLength!=null&&(b=Math.min(b,n.maxEditLength));const C=(u=n.timeout)!==null&&u!==void 0?u:1/0,P=Date.now()+C,k=[{oldPos:-1,lastComponent:void 0}];let h=this.extractCommon(k[0],r,e,0,n);if(k[0].oldPos+1>=d&&h+1>=f)return c(this.buildValues(k[0].lastComponent,r,e));let g=-1/0,R=1/0;const O=()=>{for(let m=Math.max(g,-y);m<=Math.min(R,y);m+=2){let w;const S=k[m-1],A=k[m+1];S&&(k[m-1]=void 0);let F=!1;if(A){const s=A.oldPos-m;F=A&&0<=s&&s<f}const M=S&&S.oldPos+1<d;if(!F&&!M){k[m]=void 0;continue}if(!M||F&&S.oldPos<A.oldPos?w=this.addToPath(A,!0,!1,0,n):w=this.addToPath(S,!1,!0,1,n),h=this.extractCommon(w,r,e,m,n),w.oldPos+1>=d&&h+1>=f)return c(this.buildValues(w.lastComponent,r,e))||!0;k[m]=w,w.oldPos+1>=d&&(R=Math.min(R,m-1)),h+1>=f&&(g=Math.max(g,m+1))}y++};if(i)(function m(){setTimeout(function(){if(y>b||Date.now()>P)return i(void 0);O()||m()},0)})();else for(;y<=b&&Date.now()<=P;){const m=O();if(m)return m}}addToPath(e,r,n,i,u){const c=e.lastComponent;return c&&!u.oneChangePerToken&&c.added===r&&c.removed===n?{oldPos:e.oldPos+i,lastComponent:{count:c.count+1,added:r,removed:n,previousComponent:c.previousComponent}}:{oldPos:e.oldPos+i,lastComponent:{count:1,added:r,removed:n,previousComponent:c}}}extractCommon(e,r,n,i,u){const c=r.length,f=n.length;let d=e.oldPos,y=d-i,b=0;for(;y+1<c&&d+1<f&&this.equals(n[d+1],r[y+1],u);)y++,d++,b++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return b&&!u.oneChangePerToken&&(e.lastComponent={count:b,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=d,y}equals(e,r,n){return n.comparator?n.comparator(e,r):e===r||!!n.ignoreCase&&e.toLowerCase()===r.toLowerCase()}removeEmpty(e){const r=[];for(let n=0;n<e.length;n++)e[n]&&r.push(e[n]);return r}castInput(e,r){return e}tokenize(e,r){return Array.from(e)}join(e){return e.join("")}postProcess(e,r){return e}get useLongestToken(){return!1}buildValues(e,r,n){const i=[];let u;for(;e;)i.push(e),u=e.previousComponent,delete e.previousComponent,e=u;i.reverse();const c=i.length;let f=0,d=0,y=0;for(;f<c;f++){const b=i[f];if(b.removed)b.value=this.join(n.slice(y,y+b.count)),y+=b.count;else{if(!b.added&&this.useLongestToken){let C=r.slice(d,d+b.count);C=C.map(function(P,k){const h=n[y+k];return h.length>P.length?h:P}),b.value=this.join(C)}else b.value=this.join(r.slice(d,d+b.count));d+=b.count,b.added||(y+=b.count)}}return i}}class Ye extends We{constructor(){super(...arguments),this.tokenize=Ke}equals(e,r,n){return n.ignoreWhitespace?((!n.newlineIsToken||!e.includes(`
23
23
  `))&&(e=e.trim()),(!n.newlineIsToken||!r.includes(`
24
24
  `))&&(r=r.trim())):n.ignoreNewlineAtEof&&!n.newlineIsToken&&(e.endsWith(`
25
25
  `)&&(e=e.slice(0,-1)),r.endsWith(`
26
26
  `)&&(r=r.slice(0,-1))),super.equals(e,r,n)}}const ze=new Ye;function me(t,e,r){return ze.diff(t,e,r)}function Ke(t,e){e.stripTrailingCr&&(t=t.replace(/\r\n/g,`
27
- `));const r=[],n=t.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let s=0;s<n.length;s++){const u=n[s];s%2&&!e.newlineIsToken?r[r.length-1]+=u:r.push(u)}return r}function be(t,e,r,n,s,u,c){let f;c?typeof c=="function"?f={callback:c}:f=c:f={},typeof f.context>"u"&&(f.context=4);const d=f.context;if(f.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(f.callback){const{callback:b}=f;me(r,n,Object.assign(Object.assign({},f),{callback:x=>{const P=y(x);b(P)}}))}else return y(me(r,n,f));function y(b){if(!b)return;b.push({value:"",lines:[]});function x(m){return m.map(function(w){return" "+w})}const P=[];let k=0,h=0,g=[],R=1,O=1;for(let m=0;m<b.length;m++){const w=b[m],S=w.lines||He(w.value);if(w.lines=S,w.added||w.removed){if(!k){const A=b[m-1];k=R,h=O,A&&(g=d>0?x(A.lines.slice(-d)):[],k-=g.length,h-=g.length)}for(const A of S)g.push((w.added?"+":"-")+A);w.added?O+=S.length:R+=S.length}else{if(k)if(S.length<=d*2&&m<b.length-2)for(const A of x(S))g.push(A);else{const A=Math.min(S.length,d);for(const M of x(S.slice(0,A)))g.push(M);const F={oldStart:k,oldLines:R-k+A,newStart:h,newLines:O-h+A,lines:g};P.push(F),k=0,h=0,g=[]}R+=S.length,O+=S.length}}for(const m of P)for(let w=0;w<m.lines.length;w++)m.lines[w].endsWith(`
28
- `)?m.lines[w]=m.lines[w].slice(0,-1):(m.lines.splice(w+1,0,"\"),w++);return{oldFileName:t,newFileName:e,oldHeader:s,newHeader:u,hunks:P}}}function se(t){if(Array.isArray(t))return t.map(se).join(`
29
- `);const e=[];t.oldFileName==t.newFileName&&e.push("Index: "+t.oldFileName),e.push("==================================================================="),e.push("--- "+t.oldFileName+(typeof t.oldHeader>"u"?"":" "+t.oldHeader)),e.push("+++ "+t.newFileName+(typeof t.newHeader>"u"?"":" "+t.newHeader));for(let r=0;r<t.hunks.length;r++){const n=t.hunks[r];n.oldLines===0&&(n.oldStart-=1),n.newLines===0&&(n.newStart-=1),e.push("@@ -"+n.oldStart+","+n.oldLines+" +"+n.newStart+","+n.newLines+" @@");for(const s of n.lines)e.push(s)}return e.join(`
27
+ `));const r=[],n=t.split(/(\n|\r\n)/);n[n.length-1]||n.pop();for(let i=0;i<n.length;i++){const u=n[i];i%2&&!e.newlineIsToken?r[r.length-1]+=u:r.push(u)}return r}function be(t,e,r,n,i,u,c){let f;c?typeof c=="function"?f={callback:c}:f=c:f={},typeof f.context>"u"&&(f.context=4);const d=f.context;if(f.newlineIsToken)throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");if(f.callback){const{callback:b}=f;me(r,n,Object.assign(Object.assign({},f),{callback:C=>{const P=y(C);b(P)}}))}else return y(me(r,n,f));function y(b){if(!b)return;b.push({value:"",lines:[]});function C(m){return m.map(function(w){return" "+w})}const P=[];let k=0,h=0,g=[],R=1,O=1;for(let m=0;m<b.length;m++){const w=b[m],S=w.lines||He(w.value);if(w.lines=S,w.added||w.removed){if(!k){const A=b[m-1];k=R,h=O,A&&(g=d>0?C(A.lines.slice(-d)):[],k-=g.length,h-=g.length)}for(const A of S)g.push((w.added?"+":"-")+A);w.added?O+=S.length:R+=S.length}else{if(k)if(S.length<=d*2&&m<b.length-2)for(const A of C(S))g.push(A);else{const A=Math.min(S.length,d);for(const M of C(S.slice(0,A)))g.push(M);const F={oldStart:k,oldLines:R-k+A,newStart:h,newLines:O-h+A,lines:g};P.push(F),k=0,h=0,g=[]}R+=S.length,O+=S.length}}for(const m of P)for(let w=0;w<m.lines.length;w++)m.lines[w].endsWith(`
28
+ `)?m.lines[w]=m.lines[w].slice(0,-1):(m.lines.splice(w+1,0,"\"),w++);return{oldFileName:t,newFileName:e,oldHeader:i,newHeader:u,hunks:P}}}function ie(t){if(Array.isArray(t))return t.map(ie).join(`
29
+ `);const e=[];t.oldFileName==t.newFileName&&e.push("Index: "+t.oldFileName),e.push("==================================================================="),e.push("--- "+t.oldFileName+(typeof t.oldHeader>"u"?"":" "+t.oldHeader)),e.push("+++ "+t.newFileName+(typeof t.newHeader>"u"?"":" "+t.newHeader));for(let r=0;r<t.hunks.length;r++){const n=t.hunks[r];n.oldLines===0&&(n.oldStart-=1),n.newLines===0&&(n.newStart-=1),e.push("@@ -"+n.oldStart+","+n.oldLines+" +"+n.newStart+","+n.newLines+" @@");for(const i of n.lines)e.push(i)}return e.join(`
30
30
  `)+`
31
- `}function Ue(t,e,r,n,s,u,c){if(typeof c=="function"&&(c={callback:c}),c?.callback){const{callback:f}=c;be(t,e,r,n,s,u,Object.assign(Object.assign({},c),{callback:d=>{f(d?se(d):void 0)}}))}else{const f=be(t,e,r,n,s,u,c);return f?se(f):void 0}}function He(t){const e=t.endsWith(`
31
+ `}function Ue(t,e,r,n,i,u,c){if(typeof c=="function"&&(c={callback:c}),c?.callback){const{callback:f}=c;be(t,e,r,n,i,u,Object.assign(Object.assign({},c),{callback:d=>{f(d?ie(d):void 0)}}))}else{const f=be(t,e,r,n,i,u,c);return f?ie(f):void 0}}function He(t){const e=t.endsWith(`
32
32
  `),r=t.split(`
33
33
  `).map(n=>n+`
34
- `);return e?r.pop():r.push(r.pop().slice(0,-1)),r}function Je(t,e,r="git",n=3){switch(r){case"git":return ve(t,e,n);case"object":return Be(t,e);case"json":return Ve(t,e);default:return ve(t,e,n)}}function ve(t,e,r=3){const n=ke(t),s=ke(e);return Ue("","",n,s,"","",{context:r}).split(`
34
+ `);return e?r.pop():r.push(r.pop().slice(0,-1)),r}function Je(t,e,r="git",n=3){switch(r){case"git":return ve(t,e,n);case"object":return Be(t,e);case"json":return Ve(t,e);default:return ve(t,e,n)}}function ve(t,e,r=3){const n=ke(t),i=ke(e);return Ue("","",n,i,"","",{context:r}).split(`
35
35
  `).slice(2).join(`
36
- `)}function Be(t,e){const r=de.diff(t,e)||[];return JSON.stringify(r,null,2)}function Ve(t,e){return JSON.stringify({before:t,after:e},null,2)}function Ge(t,e){return typeof t=="string"&&typeof e=="string"?ye(t,e):typeof t=="number"&&typeof e=="number"?we(t,e):Xe(t,e)}function ye(t,e){if(t===e)return 0;if(t.length===0||e.length===0)return 1;const r=Me.get(t,e),n=Math.max(t.length,e.length);return r/n}function we(t,e){if(t===e)return 0;if(t===0)return 1;const r=Math.abs(e-t),n=Math.max(Math.abs(t),Math.abs(e));return Math.min(r/n,1)}function Xe(t,e){if(t===e)return 0;const r=de.diff(t,e)||[];if(r.length===0)return 0;const n=ge(t),s=ge(e),u=Math.max(n,s);if(u===0)return 0;let c=0;for(const f of r)switch(f.kind){case"N":c+=1;break;case"D":c+=1;break;case"E":if(typeof f.lhs=="string"&&typeof f.rhs=="string"){const d=ye(f.lhs,f.rhs);c+=d}else if(typeof f.lhs=="number"&&typeof f.rhs=="number"){const d=we(f.lhs,f.rhs);c+=d}else c+=1;break;case"A":c+=.5;break}return Math.min(c/u,1)}function ge(t){if(t==null)return 0;if(typeof t!="object")return 1;if(Array.isArray(t))return t.length;let e=0;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e+=1);return e}function ke(t){try{return JSON.stringify(t,(e,r)=>typeof r=="function"?"[Function]":r===void 0?"[undefined]":r===1/0?"[Infinity]":Number.isNaN(r)?"[NaN]":r,2)}catch{return String(t)}}function Ze(t,e,r){const n=oe(),s=r?.onFeedback||n,u=r?.debounceMs??1500,c=r?.diffType??"git",f=r?.compareWith,d=r?.default_trigger_name??"auto_state_change",y=E.useRef(t),b=E.useRef(t),x=E.useRef(!0),P=E.useRef(null),k=E.useRef(void 0),h=E.useCallback((R,O,m)=>{const w=Ge(R,O),S=Je(R,O,c);let A;r?.vote?typeof r.vote=="function"?A=r.vote(R,O,w):A=r.vote:A=w>.5?"downvote":"upvote";const F=typeof e=="function"?e(O):e;s({identifier:F,vote:A,explanation:`State change with diff percentage: ${(w*100).toFixed(1)}%`,correction:S,source:"IMPLICIT",extra_metadata:r?.metadata,trigger_name:m})},[r,e,c,s]),g=E.useCallback(R=>{const O=R||d;if(P.current&&k.current&&k.current!==O){clearTimeout(P.current);const m=b.current;h(m,t,k.current),P.current=null}k.current=O},[t,d,h]);return E.useEffect(()=>{if(x.current){x.current=!1,y.current=t,b.current=t;return}const R=y.current;return(f?f(R,t):JSON.stringify(R)===JSON.stringify(t))||(P.current||(b.current=R),P.current&&clearTimeout(P.current),y.current=t,P.current=setTimeout(()=>{const m=b.current,w=t;h(m,w,k.current||d),b.current=w,P.current=null},u)),()=>{P.current&&clearTimeout(P.current)}},[t,e,r,s,c,u,f,d,h]),{notifyChange:g}}function Qe(t,e,r){const[n,s]=E.useState(t),{notifyChange:u}=Ze(n,e,r),c=E.useCallback((f,d)=>{u(d),s(y=>typeof f=="function"?f(y):f)},[u]);return[n,c]}Y.KeletContext=Q,Y.KeletProvider=Ae,Y.VoteFeedback=De,Y.useDefaultFeedbackHandler=oe,Y.useFeedbackState=Qe,Y.useKelet=Oe,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
36
+ `)}function Be(t,e){const r=de.diff(t,e)||[];return JSON.stringify(r,null,2)}function Ve(t,e){return JSON.stringify({before:t,after:e},null,2)}function Ge(t,e){return typeof t=="string"&&typeof e=="string"?ye(t,e):typeof t=="number"&&typeof e=="number"?we(t,e):Xe(t,e)}function ye(t,e){if(t===e)return 0;if(t.length===0||e.length===0)return 1;const r=Me.get(t,e),n=Math.max(t.length,e.length);return r/n}function we(t,e){if(t===e)return 0;if(t===0)return 1;const r=Math.abs(e-t),n=Math.max(Math.abs(t),Math.abs(e));return Math.min(r/n,1)}function Xe(t,e){if(t===e)return 0;const r=de.diff(t,e)||[];if(r.length===0)return 0;const n=ge(t),i=ge(e),u=Math.max(n,i);if(u===0)return 0;let c=0;for(const f of r)switch(f.kind){case"N":c+=1;break;case"D":c+=1;break;case"E":if(typeof f.lhs=="string"&&typeof f.rhs=="string"){const d=ye(f.lhs,f.rhs);c+=d}else if(typeof f.lhs=="number"&&typeof f.rhs=="number"){const d=we(f.lhs,f.rhs);c+=d}else c+=1;break;case"A":c+=.5;break}return Math.min(c/u,1)}function ge(t){if(t==null)return 0;if(typeof t!="object")return 1;if(Array.isArray(t))return t.length;let e=0;for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e+=1);return e}function ke(t){try{return JSON.stringify(t,(e,r)=>typeof r=="function"?"[Function]":r===void 0?"[undefined]":r===1/0?"[Infinity]":Number.isNaN(r)?"[NaN]":r,2)}catch{return String(t)}}function Ze(t,e,r){const n=oe(),i=r?.onFeedback||n,u=r?.debounceMs??1500,c=r?.diffType??"git",f=r?.compareWith,d=r?.default_trigger_name??"auto_state_change",y=E.useRef(t),b=E.useRef(t),C=E.useRef(!0),P=E.useRef(null),k=E.useRef(void 0),h=E.useCallback((R,O,m)=>{const w=Ge(R,O),S=Je(R,O,c);let A;r?.vote?typeof r.vote=="function"?A=r.vote(R,O,w):A=r.vote:A=w>.5?"downvote":"upvote";const F=typeof e=="function"?e(O):e;i({tx_id:F,vote:A,explanation:`State change with diff percentage: ${(w*100).toFixed(1)}%`,correction:S,source:"IMPLICIT",extra_metadata:r?.metadata,trigger_name:m})},[r,e,c,i]),g=E.useCallback(R=>{const O=R||d;if(P.current&&k.current&&k.current!==O){clearTimeout(P.current);const m=b.current;h(m,t,k.current),P.current=null}k.current=O},[t,d,h]);return E.useEffect(()=>{if(C.current){C.current=!1,y.current=t,b.current=t;return}const R=y.current;return(f?f(R,t):JSON.stringify(R)===JSON.stringify(t))||(P.current||(b.current=R),P.current&&clearTimeout(P.current),y.current=t,P.current=setTimeout(()=>{const m=b.current,w=t;h(m,w,k.current||d),b.current=w,P.current=null},u)),()=>{P.current&&clearTimeout(P.current)}},[t,e,r,i,c,u,f,d,h]),{notifyChange:g}}function Qe(t,e,r){const[n,i]=E.useState(t),{notifyChange:u}=Ze(n,e,r),c=E.useCallback((f,d)=>{u(d),i(y=>typeof f=="function"?f(y):f)},[u]);return[n,c]}Y.KeletContext=Q,Y.KeletProvider=Ae,Y.VoteFeedback=De,Y.useDefaultFeedbackHandler=oe,Y.useFeedbackState=Qe,Y.useKelet=Oe,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
@@ -5,16 +5,16 @@ import { FeedbackStateOptions, FeedbackReducerReturn } from './types';
5
5
  *
6
6
  * @param reducer The reducer function - same as React's useReducer
7
7
  * @param initialState The initial state value
8
- * @param identifier A unique identifier for the state (string or function that derives from state)
8
+ * @param tx_id A unique transaction ID for the state (string or function that derives from state)
9
9
  * @param options Optional configuration options
10
10
  * @param initializer Optional initializer function - same as React's useReducer
11
11
  * @returns A tuple of [state, dispatch] just like React's useReducer
12
12
  *
13
13
  * @example
14
- * // Basic usage with required identifier
14
+ * // Basic usage with required tx_id
15
15
  * const [state, dispatch] = useFeedbackReducer(reducer, initialState, 'counter');
16
16
  *
17
- * // Using with options and dynamic identifier
17
+ * // Using with options and dynamic tx_id
18
18
  * const [items, dispatch] = useFeedbackReducer(
19
19
  * itemsReducer,
20
20
  * [],
@@ -31,4 +31,4 @@ import { FeedbackStateOptions, FeedbackReducerReturn } from './types';
31
31
  * // Dispatch with explicit trigger name
32
32
  * dispatch({ type: 'ADD_ITEM', payload: 'new item' }, 'user_action');
33
33
  */
34
- export declare function useFeedbackReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S, identifier: string | ((state: S) => string), options?: FeedbackStateOptions<S>, initializer?: (arg: S) => S): FeedbackReducerReturn<S, A>;
34
+ export declare function useFeedbackReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S, tx_id: string | ((state: S) => string), options?: FeedbackStateOptions<S>, initializer?: (arg: S) => S): FeedbackReducerReturn<S, A>;
@@ -4,15 +4,15 @@ import { FeedbackStateReturn, FeedbackStateOptions } from './types';
4
4
  * and automatically sends these changes as implicit feedback through the Kelet system.
5
5
  *
6
6
  * @param initialState The initial state value
7
- * @param identifier A unique identifier for the state (string or function that derives from state)
7
+ * @param tx_id A unique transaction ID for the state (string or function that derives from state)
8
8
  * @param options Optional configuration options
9
9
  * @returns A tuple of [state, setState] just like React's useState
10
10
  *
11
11
  * @example
12
- * // Basic usage with required identifier
12
+ * // Basic usage with required tx_id
13
13
  * const [count, setCount] = useFeedbackState(0, 'counter');
14
14
  *
15
- * // Using with static identifier and options
15
+ * // Using with static tx_id and options
16
16
  * const [preferences, setPreferences] = useFeedbackState(
17
17
  * {theme: 'light', notifications: true},
18
18
  * 'user-preferences',
@@ -22,10 +22,10 @@ import { FeedbackStateReturn, FeedbackStateOptions } from './types';
22
22
  * }
23
23
  * );
24
24
  *
25
- * // With dynamic identifier derived from state
25
+ * // With dynamic tx_id derived from state
26
26
  * const [items, setItems] = useFeedbackState(
27
27
  * [1, 2, 3],
28
28
  * (items) => `items-${items.length}`
29
29
  * );
30
30
  */
31
- export declare function useFeedbackState<T>(initialState: T, identifier: string | ((state: T) => string), options?: FeedbackStateOptions<T>): FeedbackStateReturn<T>;
31
+ export declare function useFeedbackState<T>(initialState: T, tx_id: string | ((state: T) => string), options?: FeedbackStateOptions<T>): FeedbackStateReturn<T>;
@@ -4,10 +4,10 @@ import { FeedbackStateOptions } from './types';
4
4
  * This contains all the shared logic between useFeedbackState and useFeedbackReducer.
5
5
  *
6
6
  * @param currentState The current state to track changes for
7
- * @param identifier A unique identifier for the state (string or function that derives from state)
7
+ * @param tx_id A unique transaction ID for the state (string or function that derives from state)
8
8
  * @param options Optional configuration options
9
9
  * @returns Object with notifyChange function to notify of impending state changes
10
10
  */
11
- export declare function useStateChangeTracking<T>(currentState: T, identifier: string | ((state: T) => string), options?: FeedbackStateOptions<T>): {
11
+ export declare function useStateChangeTracking<T>(currentState: T, tx_id: string | ((state: T) => string), options?: FeedbackStateOptions<T>): {
12
12
  notifyChange: (trigger_name?: string) => void;
13
13
  };
@@ -3,7 +3,7 @@ import { ButtonHTMLAttributes, HTMLAttributes, ReactNode, TextareaHTMLAttributes
3
3
  * Feedback data structure returned by the component
4
4
  */
5
5
  export interface FeedbackData {
6
- identifier: string;
6
+ tx_id: string;
7
7
  extra_metadata?: Record<string, any>;
8
8
  vote: 'upvote' | 'downvote';
9
9
  explanation?: string;
@@ -20,7 +20,7 @@ export interface VoteFeedbackRootProps {
20
20
  children: ReactNode;
21
21
  onFeedback?: (data: FeedbackData) => void | Promise<void>;
22
22
  defaultText?: string;
23
- identifier: string;
23
+ tx_id: string;
24
24
  extra_metadata?: Record<string, any>;
25
25
  trigger_name?: string;
26
26
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kelet-ai/feedback-ui",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/kelet-ai/feedback-ui.git"