@kelet-ai/feedback-ui 0.4.0 → 0.4.2

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
@@ -323,7 +323,7 @@ import { VoteFeedback, getOtelTraceId } from '@kelet-ai/feedback-ui';
323
323
  <VoteFeedback.Root tx_id={getOtelTraceId} onFeedback={handleFeedback}>
324
324
  <VoteFeedback.UpvoteButton>👍</VoteFeedback.UpvoteButton>
325
325
  <VoteFeedback.DownvoteButton>👎</VoteFeedback.DownvoteButton>
326
- </VoteFeedback.Root>
326
+ </VoteFeedback.Root>;
327
327
  ```
328
328
 
329
329
  Requires `@opentelemetry/api` and active Span to collect the trace_id from.
@@ -1,4 +1,4 @@
1
- import Ae, { createContext as Ee, useContext as ae, useCallback as W, isValidElement as Z, cloneElement as Q, useState as X, useRef as U, useId as ce, useEffect as De } from "react";
1
+ import De, { createContext as Ee, useContext as ae, useCallback as W, isValidElement as Z, cloneElement as Q, useState as X, useRef as U, useId as ce, useEffect as ke } from "react";
2
2
  function _e(n) {
3
3
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
4
4
  }
@@ -224,8 +224,8 @@ function Ne() {
224
224
  else A(j);
225
225
  if (b.call(T, "key")) {
226
226
  j = n(a);
227
- var Y = Object.keys(T).filter(function(Re) {
228
- return Re !== "key";
227
+ var Y = Object.keys(T).filter(function(Ae) {
228
+ return Ae !== "key";
229
229
  });
230
230
  S = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ne[j + S] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
231
231
  `A props object containing a "key" prop is being spread into JSX:
@@ -262,7 +262,7 @@ React keys must be passed directly to JSX without using spread:
262
262
  function A(a) {
263
263
  typeof a == "object" && a !== null && a.$$typeof === E && a._store && (a._store.validated = 1);
264
264
  }
265
- var w = Ae, E = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), v = Symbol.for("react.consumer"), k = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), I = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), l = Symbol.for("react.activity"), s = Symbol.for("react.client.reference"), c = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, D = Array.isArray, x = console.createTask ? console.createTask : function() {
265
+ var w = De, E = Symbol.for("react.transitional.element"), h = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), v = Symbol.for("react.consumer"), k = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), R = Symbol.for("react.suspense"), I = Symbol.for("react.suspense_list"), L = Symbol.for("react.memo"), i = Symbol.for("react.lazy"), l = Symbol.for("react.activity"), s = Symbol.for("react.client.reference"), c = w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, b = Object.prototype.hasOwnProperty, D = Array.isArray, x = console.createTask ? console.createTask : function() {
266
266
  return null;
267
267
  };
268
268
  w = {
@@ -306,12 +306,12 @@ function Ie() {
306
306
  return pe || (pe = 1, process.env.NODE_ENV === "production" ? re.exports = je() : re.exports = Ne()), re.exports;
307
307
  }
308
308
  var F = Ie();
309
- const se = Ee(null), Fe = "https://api.kelet.ai/", pt = () => {
309
+ const se = Ee(null), Fe = "https://api.kelet.ai/api", pt = () => {
310
310
  const n = ae(se);
311
311
  if (!n)
312
312
  throw new Error("useKelet must be used within a KeletProvider");
313
313
  return n;
314
- }, ke = () => {
314
+ }, Pe = () => {
315
315
  const n = ae(se);
316
316
  return n ? n.feedback : async () => {
317
317
  };
@@ -355,10 +355,10 @@ const se = Ee(null), Fe = "https://api.kelet.ai/", pt = () => {
355
355
  } : o && (t[r] = o) : r === "style" ? t[r] = { ...o, ...u } : r === "className" ? t[r] = [o, u].filter(Boolean).join(" ") : t[r] = u !== void 0 ? u : o;
356
356
  }
357
357
  return { ...n, ...t };
358
- }, Pe = Ee(
358
+ }, xe = Ee(
359
359
  null
360
360
  ), te = () => {
361
- const n = ae(Pe);
361
+ const n = ae(xe);
362
362
  if (!n)
363
363
  throw new Error(
364
364
  "VoteFeedback components must be used within VoteFeedback.Root"
@@ -372,7 +372,11 @@ const se = Ee(null), Fe = "https://api.kelet.ai/", pt = () => {
372
372
  extra_metadata: o,
373
373
  trigger_name: u
374
374
  }) => {
375
- const d = typeof r == "function" ? r() : r, [f, p] = X(!1), [y, m] = X(t), [A, w] = X(!1), [E, h] = X(null), g = U(null), C = U(null), P = ce(), v = ce(), k = ke(), O = e || k, R = W(async () => {
375
+ const d = typeof r == "function" ? r() : r, [f, p] = X(!1), [y, m] = X(t), [A, w] = X(!1), [E, h] = X(null), g = U(null), C = U(null), P = ce(), v = ce(), k = Pe(), O = e || k;
376
+ ke(() => {
377
+ p(!1), m(t), w(!1), h(null), setTimeout(() => C.current?.focus(), 0);
378
+ }, [d, t]);
379
+ const R = W(async () => {
376
380
  h("upvote");
377
381
  const c = {
378
382
  tx_id: d,
@@ -469,7 +473,7 @@ const se = Ee(null), Fe = "https://api.kelet.ai/", pt = () => {
469
473
  extra_metadata: o,
470
474
  trigger_name: u
471
475
  };
472
- return /* @__PURE__ */ F.jsx(Pe.Provider, { value: s, children: n });
476
+ return /* @__PURE__ */ F.jsx(xe.Provider, { value: s, children: n });
473
477
  }, Me = ({
474
478
  asChild: n,
475
479
  children: e,
@@ -956,7 +960,7 @@ function Ke() {
956
960
  });
957
961
  }(ie)), ie.exports;
958
962
  }
959
- var xe = Ke(), oe = { exports: {} };
963
+ var Te = Ke(), oe = { exports: {} };
960
964
  const z = new Uint32Array(65536), Ue = (n, e) => {
961
965
  const t = n.length, r = e.length, o = 1 << t - 1;
962
966
  let u = -1, d = 0, f = t, p = t;
@@ -1001,7 +1005,7 @@ const z = new Uint32Array(65536), Ue = (n, e) => {
1001
1005
  for (let h = A; h < w; h++)
1002
1006
  z[n.charCodeAt(h)] = 0;
1003
1007
  return E;
1004
- }, Te = (n, e) => {
1008
+ }, Ce = (n, e) => {
1005
1009
  if (n.length < e.length) {
1006
1010
  const t = e;
1007
1011
  e = n, n = t;
@@ -1010,14 +1014,14 @@ const z = new Uint32Array(65536), Ue = (n, e) => {
1010
1014
  }, Je = (n, e) => {
1011
1015
  let t = 1 / 0, r = 0;
1012
1016
  for (let o = 0; o < e.length; o++) {
1013
- const u = Te(n, e[o]);
1017
+ const u = Ce(n, e[o]);
1014
1018
  u < t && (t = u, r = o);
1015
1019
  }
1016
1020
  return e[r];
1017
1021
  }, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1018
1022
  __proto__: null,
1019
1023
  closest: Je,
1020
- distance: Te
1024
+ distance: Ce
1021
1025
  }, Symbol.toStringTag, { value: "Module" })), Ve = /* @__PURE__ */ Se(Be);
1022
1026
  var me;
1023
1027
  function Ge() {
@@ -1358,7 +1362,7 @@ function ye(n, e, t = 3) {
1358
1362
  `);
1359
1363
  }
1360
1364
  function st(n, e) {
1361
- const t = xe.diff(n, e) || [];
1365
+ const t = Te.diff(n, e) || [];
1362
1366
  return JSON.stringify(t, null, 2);
1363
1367
  }
1364
1368
  function at(n, e) {
@@ -1372,15 +1376,15 @@ function at(n, e) {
1372
1376
  );
1373
1377
  }
1374
1378
  function lt(n, e) {
1375
- return typeof n == "string" && typeof e == "string" ? Ce(n, e) : typeof n == "number" && typeof e == "number" ? Oe(n, e) : ut(n, e);
1379
+ return typeof n == "string" && typeof e == "string" ? Oe(n, e) : typeof n == "number" && typeof e == "number" ? Re(n, e) : ut(n, e);
1376
1380
  }
1377
- function Ce(n, e) {
1381
+ function Oe(n, e) {
1378
1382
  if (n === e) return 0;
1379
1383
  if (n.length === 0 || e.length === 0) return 1;
1380
1384
  const t = Ze.get(n, e), r = Math.max(n.length, e.length);
1381
1385
  return t / r;
1382
1386
  }
1383
- function Oe(n, e) {
1387
+ function Re(n, e) {
1384
1388
  if (n === e) return 0;
1385
1389
  if (n === 0) return 1;
1386
1390
  const t = Math.abs(e - n), r = Math.max(Math.abs(n), Math.abs(e));
@@ -1388,7 +1392,7 @@ function Oe(n, e) {
1388
1392
  }
1389
1393
  function ut(n, e) {
1390
1394
  if (n === e) return 0;
1391
- const t = xe.diff(n, e) || [];
1395
+ const t = Te.diff(n, e) || [];
1392
1396
  if (t.length === 0) return 0;
1393
1397
  const r = we(n), o = we(e), u = Math.max(r, o);
1394
1398
  if (u === 0) return 0;
@@ -1403,13 +1407,13 @@ function ut(n, e) {
1403
1407
  break;
1404
1408
  case "E":
1405
1409
  if (typeof f.lhs == "string" && typeof f.rhs == "string") {
1406
- const p = Ce(
1410
+ const p = Oe(
1407
1411
  f.lhs,
1408
1412
  f.rhs
1409
1413
  );
1410
1414
  d += p;
1411
1415
  } else if (typeof f.lhs == "number" && typeof f.rhs == "number") {
1412
- const p = Oe(
1416
+ const p = Re(
1413
1417
  f.lhs,
1414
1418
  f.rhs
1415
1419
  );
@@ -1444,7 +1448,7 @@ function ge(n) {
1444
1448
  }
1445
1449
  }
1446
1450
  function ct(n, e, t) {
1447
- const r = ke(), o = t?.onFeedback || r, u = t?.debounceMs ?? 1500, d = t?.diffType ?? "git", f = t?.compareWith, p = t?.default_trigger_name ?? "auto_state_change", y = U(n), m = U(n), A = U(!0), w = U(null), E = U(void 0), h = W(
1451
+ const r = Pe(), o = t?.onFeedback || r, u = t?.debounceMs ?? 1500, d = t?.diffType ?? "git", f = t?.compareWith, p = t?.default_trigger_name ?? "auto_state_change", y = U(n), m = U(n), A = U(!0), w = U(null), E = U(void 0), h = W(
1448
1452
  (C, P, v) => {
1449
1453
  const k = lt(C, P), O = it(C, P, d);
1450
1454
  let R;
@@ -1477,7 +1481,7 @@ function ct(n, e, t) {
1477
1481
  },
1478
1482
  [n, p, h]
1479
1483
  );
1480
- return De(() => {
1484
+ return ke(() => {
1481
1485
  if (A.current) {
1482
1486
  A.current = !1, y.current = n, m.current = n;
1483
1487
  return;
@@ -1551,7 +1555,7 @@ export {
1551
1555
  ht as KeletProvider,
1552
1556
  mt as VoteFeedback,
1553
1557
  bt as getOtelTraceId,
1554
- ke as useDefaultFeedbackHandler,
1558
+ Pe as useDefaultFeedbackHandler,
1555
1559
  vt as useFeedbackState,
1556
1560
  pt as useKelet
1557
1561
  };
@@ -1,4 +1,4 @@
1
- (function(M,P){typeof exports=="object"&&typeof module<"u"?P(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],P):(M=typeof globalThis<"u"?globalThis:M||self,P(M["@kelet-ai/feedback-ui"]={},M.React))})(this,function(M,P){"use strict";function Ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Pe(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){var o=!1;try{o=this instanceof r}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}),t}var ee={exports:{}},X={};/**
1
+ (function(M,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],k):(M=typeof globalThis<"u"?globalThis:M||self,k(M["@kelet-ai/feedback-ui"]={},M.React))})(this,function(M,k){"use strict";function Ee(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function Pe(n){if(Object.prototype.hasOwnProperty.call(n,"__esModule"))return n;var e=n.default;if(typeof e=="function"){var t=function r(){var o=!1;try{o=this instanceof r}catch{}return o?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(r){var o=Object.getOwnPropertyDescriptor(n,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:function(){return n[r]}})}),t}var ee={exports:{}},X={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -14,18 +14,18 @@
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 n(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===s?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case g:return"Fragment";case x:return"Profiler";case R:return"StrictMode";case D: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 E:return(a.displayName||"Context")+".Provider";case b:return(a._context.displayName||"Context")+".Consumer";case O:var T=a.render;return a=a.displayName,a||(a=T.displayName||T.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case W:return T=a.displayName||null,T!==null?T:n(a.type)||"Memo";case i:T=a._payload,a=a._init;try{return n(a(T))}catch{}}return null}function e(a){return""+a}function t(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 r(a){if(a===g)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===i)return"<...>";try{var T=n(a);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function o(){var a=c.A;return a===null?null:a.getOwner()}function u(){return Error("react-stack-top-frame")}function d(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 _(){Y||(Y=!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 p(){var a=n(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,K,z,G,J){return _=z.ref,a={$$typeof:k,type:a,key:T,props:z,_owner:K},(_!==void 0?_:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:p}):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 m(a,T,_,j,K,z,G,J){var N=T.children;if(N!==void 0)if(j)if(A(N)){for(j=0;j<N.length;j++)S(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 S(N);if(v.call(T,"key")){N=n(a);var U=Object.keys(T).filter(function(et){return et!=="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 Ce(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function n(a){if(a==null)return null;if(typeof a=="function")return a.$$typeof===s?null:a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case g:return"Fragment";case x:return"Profiler";case R:return"StrictMode";case D: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 P:return(a.displayName||"Context")+".Provider";case b:return(a._context.displayName||"Context")+".Consumer";case O:var T=a.render;return a=a.displayName,a||(a=T.displayName||T.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case W:return T=a.displayName||null,T!==null?T:n(a.type)||"Memo";case i:T=a._payload,a=a._init;try{return n(a(T))}catch{}}return null}function e(a){return""+a}function t(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 r(a){if(a===g)return"<>";if(typeof a=="object"&&a!==null&&a.$$typeof===i)return"<...>";try{var T=n(a);return T?"<"+T+">":"<...>"}catch{return"<...>"}}function o(){var a=c.A;return a===null?null:a.getOwner()}function u(){return Error("react-stack-top-frame")}function d(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 _(){Y||(Y=!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 p(){var a=n(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,K,z,G,J){return _=z.ref,a={$$typeof:E,type:a,key:T,props:z,_owner:K},(_!==void 0?_:null)!==null?Object.defineProperty(a,"ref",{enumerable:!1,get:p}):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 m(a,T,_,j,K,z,G,J){var N=T.children;if(N!==void 0)if(j)if(A(N)){for(j=0;j<N.length;j++)S(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 S(N);if(v.call(T,"key")){N=n(a);var U=Object.keys(T).filter(function(et){return et!=="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:
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&&(t(_),N=""+_),d(T)&&(t(T.key),N=""+T.key),"key"in T){_={};for(var se in T)se!=="key"&&(_[se]=T[se])}else _=T;return N&&f(_,typeof a=="function"?a.displayName||a.name||"Unknown":a),y(a,N,z,K,o(),_,G,J)}function S(a){typeof a=="object"&&a!==null&&a.$$typeof===k&&a._store&&(a._store.validated=1)}var w=P,k=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),E=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),l=Symbol.for("react.activity"),s=Symbol.for("react.client.reference"),c=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,A=Array.isArray,C=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(a){return a()}};var Y,I={},B=w.react_stack_bottom_frame.bind(w,u)(),V=C(r(u)),re={};Z.Fragment=g,Z.jsx=function(a,T,_,j,K){var z=1e4>c.recentlyCreatedOwnerStacks++;return m(a,T,_,!1,j,K,z?Error("react-stack-top-frame"):B,z?C(r(a)):V)},Z.jsxs=function(a,T,_,j,K){var z=1e4>c.recentlyCreatedOwnerStacks++;return m(a,T,_,!0,j,K,z?Error("react-stack-top-frame"):B,z?C(r(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=P.createContext(null),Re="https://api.kelet.ai/",Oe=()=>{const n=P.useContext(Q);if(!n)throw new Error("useKelet must be used within a KeletProvider");return n},oe=()=>{const n=P.useContext(Q);return n?n.feedback:async()=>{}},De=({apiKey:n,project:e,children:t})=>{const r=P.useContext(Q),o=n||r?.api_key;if(!o)throw new Error("apiKey is required either directly or from a parent KeletProvider");const d={api_key:o,project:e,feedback:async f=>{const p=`${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},m=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(y)});if(!m.ok)throw new Error(`Failed to submit feedback: ${m.statusText}`)}};return L.jsx(Q.Provider,{value:d,children:t})},q=(n,e)=>{const t={...e};for(const r in e){const o=n[r],u=e[r];/^on[A-Z]/.test(r)?o&&u?t[r]=(...f)=>{u(...f),o(...f)}:o&&(t[r]=o):r==="style"?t[r]={...o,...u}:r==="className"?t[r]=[o,u].filter(Boolean).join(" "):t[r]=u!==void 0?u:o}return{...n,...t}},ce=P.createContext(null),$=()=>{const n=P.useContext(ce);if(!n)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return n},Se={Root:({children:n,onFeedback:e,defaultText:t="",tx_id:r,extra_metadata:o,trigger_name:u})=>{const d=typeof r=="function"?r():r,[f,p]=P.useState(!1),[y,m]=P.useState(t),[S,w]=P.useState(!1),[k,h]=P.useState(null),g=P.useRef(null),R=P.useRef(null),x=P.useId(),b=P.useId(),E=oe(),O=e||E,D=P.useCallback(async()=>{h("upvote");const c={tx_id:d,vote:"upvote",...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(c)}finally{w(!1)}},[O,d,o,u]),F=P.useCallback(async()=>{if(h("downvote"),O){const c={tx_id:d,vote:"downvote",...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(c)}finally{w(!1)}}p(!0),setTimeout(()=>{g.current?.focus();const c=document.createElement("div");c.setAttribute("aria-live","polite"),c.setAttribute("aria-atomic","true"),c.className="sr-only",c.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(c),setTimeout(()=>document.body.removeChild(c),1e3)},0)},[O,d,o,u]),W=P.useCallback(c=>{m(c.target.value)},[]),i=P.useCallback(async()=>{const c=y.trim().length>0;if(c){const v={tx_id:d,vote:"downvote",explanation:y,...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(v)}finally{w(!1)}}if(p(!1),m(t),R.current?.focus(),c){const v=document.createElement("div");v.setAttribute("aria-live","polite"),v.className="sr-only",v.textContent="Feedback submitted successfully.",document.body.appendChild(v),setTimeout(()=>document.body.removeChild(v),1e3)}},[O,y,t,d,o,u]),l=P.useCallback(c=>{if(c.key==="Escape")p(!1),m(t),R.current?.focus();else if((c.metaKey||c.ctrlKey)&&c.key==="Enter")c.preventDefault(),i().then(v=>{});else if(c.key==="Tab"&&f){const v=document.getElementById(x);if(v){const A=v.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),C=A[0],Y=A[A.length-1];c.shiftKey&&document.activeElement===C?(c.preventDefault(),Y?.focus()):!c.shiftKey&&document.activeElement===Y&&(c.preventDefault(),C?.focus())}}},[i,f,x,t]),s={onFeedback:O,showPopover:f,setShowPopover:p,feedbackText:y,setFeedbackText:m,isSubmitting:S,setIsSubmitting:w,vote:k,handleUpvote:D,handleDownvote:F,handleTextareaChange:W,handleSubmit:i,handleKeyDown:l,textareaRef:g,triggerRef:R,popoverId:x,triggerId:b,tx_id:d,extra_metadata:o,trigger_name:u};return L.jsx(ce.Provider,{value:s,children:n})},UpvoteButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleUpvote:o,isSubmitting:u,vote:d}=$(),f=P.useCallback(m=>{o(),t?.(m)},[o,t]),p={...r,onClick:f,disabled:u||r.disabled,"aria-label":r["aria-label"]||"Upvote feedback",type:"button"},y=d==="upvote";if(n){const m=typeof e=="function"?e({isSelected:y}):e;if(P.isValidElement(m))return P.cloneElement(m,q(p,m.props))}return L.jsx("button",{...p,children:typeof e=="function"?e({isSelected:y}):e})},DownvoteButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleDownvote:o,showPopover:u,isSubmitting:d,popoverId:f,triggerId:p,triggerRef:y,vote:m}=$(),S=P.useCallback(h=>{o(),t?.(h)},[o,t]),w={...r,ref:y,onClick:S,disabled:d||r.disabled,"aria-label":r["aria-label"]||"Downvote feedback","aria-expanded":u,"aria-controls":f,id:p,type:"button"},k=m==="downvote";if(n){const h=typeof e=="function"?e({isSelected:k}):e;if(P.isValidElement(h))return P.cloneElement(h,q(w,h.props));if(h)return h}return L.jsx("button",{...w,children:typeof e=="function"?e({isSelected:k}):e})},Popover:({asChild:n,children:e,...t})=>{const{showPopover:r,handleKeyDown:o,popoverId:u,triggerId:d}=$();if(!r)return null;const f={...t,role:"dialog","aria-labelledby":d,"aria-modal":!0,"aria-describedby":`${u}-description`,id:u,onKeyDown:o,tabIndex:-1};return n&&P.isValidElement(e)?L.jsxs(L.Fragment,{children:[P.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:n,value:e,onChange:t,...r})=>{const{feedbackText:o,handleTextareaChange:u,textareaRef:d,handleKeyDown:f,popoverId:p}=$(),y={...r,ref:d,value:e!==void 0?e:o,onChange:t||u,onKeyDown:f,placeholder:r.placeholder||"What did we miss?","aria-label":r["aria-label"]||"Additional feedback","aria-describedby":`${p}-help`,rows:r.rows||3};return n&&P.isValidElement(r.children)?P.cloneElement(r.children,q(y,r.children.props)):L.jsx("textarea",{...y})},SubmitButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleSubmit:o,isSubmitting:u,feedbackText:d}=$(),f=P.useCallback(S=>{o(),t?.(S)},[o,t]),p=d.trim().length>0,y=p?"Submit feedback":"Close without feedback",m={...r,onClick:f,disabled:u||r.disabled,type:"button","aria-label":r["aria-label"]||y,"aria-describedby":p?void 0:"submit-help"};return n&&P.isValidElement(e)?L.jsxs(L.Fragment,{children:[P.cloneElement(e,q(m,e.props)),!p&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):L.jsxs("button",{...m,children:[e,!p&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var te={exports:{}},Ae=te.exports,fe;function _e(){return fe||(fe=1,function(n,e){(function(t,r){var o=r(t);n.exports=o})(Ae,function(t){var r=["N","E","A","D"];function o(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 d(i,l,s){d.super_.call(this,"E",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0}),Object.defineProperty(this,"rhs",{value:s,enumerable:!0})}o(d,u);function f(i,l){f.super_.call(this,"N",i),Object.defineProperty(this,"rhs",{value:l,enumerable:!0})}o(f,u);function p(i,l){p.super_.call(this,"D",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0})}o(p,u);function y(i,l,s){y.super_.call(this,"A",i),Object.defineProperty(this,"index",{value:l,enumerable:!0}),Object.defineProperty(this,"item",{value:s,enumerable:!0})}o(y,u);function m(i,l,s){var c=i.slice(l+1||i.length);return i.length=l<0?i.length+l:l,i.push.apply(i,c),i}function S(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 w(i){var l=0;if(i.length===0)return l;for(var s=0;s<i.length;s++){var c=i.charCodeAt(s);l=(l<<5)-l+c,l=l&l}return l}function k(i){var l=0,s=S(i);if(s==="array"){i.forEach(function(Y){l+=k(Y)});var c="[type: array, hash: "+l+"]";return l+w(c)}if(s==="object"){for(var v in i)if(i.hasOwnProperty(v)){var A="[ type: object, key: "+v+", value hash: "+k(i[v])+"]";l+=w(A)}return l}var C="[ type: "+s+" ; value: "+i+"]";return l+w(C)}function h(i,l,s,c,v,A,C,Y){s=s||[],v=v||[],C=C||[];var I=v.slice(0);if(typeof A<"u"&&A!==null){if(c){if(typeof c=="function"&&c(I,A))return;if(typeof c=="object"){if(c.prefilter&&c.prefilter(I,A))return;if(c.normalize){var B=c.normalize(I,A,i,l);B&&(i=B[0],l=B[1])}}}I.push(A)}S(i)==="regexp"&&S(l)==="regexp"&&(i=i.toString(),l=l.toString());var V=typeof i,re=typeof l,a,T,_,j,K=V!=="undefined"||C&&C.length>0&&C[C.length-1].lhs&&Object.getOwnPropertyDescriptor(C[C.length-1].lhs,A),z=re!=="undefined"||C&&C.length>0&&C[C.length-1].rhs&&Object.getOwnPropertyDescriptor(C[C.length-1].rhs,A);if(!K&&z)s.push(new f(I,l));else if(!z&&K)s.push(new p(I,i));else if(S(i)!==S(l))s.push(new d(I,i,l));else if(S(i)==="date"&&i-l!==0)s.push(new d(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&&s.push(new d(I,i,l));else{if(C.push({lhs:i,rhs:l}),Array.isArray(i)){for(Y&&(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;)s.push(new y(I,a,new f(void 0,l[a--])));for(;T>a;)s.push(new y(I,T,new p(void 0,i[T--])));for(;a>=0;--a)h(i[a],l[a],s,c,I,a,C,Y)}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[_],s,c,I,_,C,Y),J[j]=null):h(i[_],void 0,s,c,I,_,C,Y);for(a=0;a<J.length;++a)_=J[a],_&&h(void 0,l[_],s,c,I,_,C,Y)}C.length=C.length-1}}else i!==l&&(V==="number"&&isNaN(i)&&isNaN(l)||s.push(new d(I,i,l)))}function g(i,l,s,c,v){var A=[];if(h(i,l,A,c,null,null,null,v),s)for(var C=0;C<A.length;++C)s(A[C]);return A}function R(i,l,s,c,v,A,C){return h(i,l,s,c,v,A,C,!0)}function x(i,l,s,c){var v=c?function(C){C&&c.push(C)}:void 0,A=g(i,l,v,s);return c||(A.length?A:void 0)}function b(i,l,s,c){var v=c?function(C){C&&c.push(C)}:void 0,A=g(i,l,v,s,!0);return c||(A.length?A:void 0)}function E(i,l,s){if(s.path&&s.path.length){var c=i[l],v,A=s.path.length-1;for(v=0;v<A;v++)c=c[s.path[v]];switch(s.kind){case"A":E(c[s.path[v]],s.index,s.item);break;case"D":delete c[s.path[v]];break;case"E":case"N":c[s.path[v]]=s.rhs;break}}else switch(s.kind){case"A":E(i[l],s.index,s.item);break;case"D":i=m(i,l);break;case"E":case"N":i[l]=s.rhs;break}return i}function O(i,l,s){if(typeof s>"u"&&l&&~r.indexOf(l.kind)&&(s=l),i&&s&&s.kind){for(var c=i,v=-1,A=s.path?s.path.length-1:0;++v<A;)typeof c[s.path[v]]>"u"&&(c[s.path[v]]=typeof s.path[v+1]<"u"&&typeof s.path[v+1]=="number"?[]:{}),c=c[s.path[v]];switch(s.kind){case"A":s.path&&typeof c[s.path[v]]>"u"&&(c[s.path[v]]=[]),E(s.path?c[s.path[v]]:c,s.index,s.item);break;case"D":delete c[s.path[v]];break;case"E":case"N":c[s.path[v]]=s.rhs;break}}}function D(i,l,s){if(s.path&&s.path.length){var c=i[l],v,A=s.path.length-1;for(v=0;v<A;v++)c=c[s.path[v]];switch(s.kind){case"A":D(c[s.path[v]],s.index,s.item);break;case"D":c[s.path[v]]=s.lhs;break;case"E":c[s.path[v]]=s.lhs;break;case"N":delete c[s.path[v]];break}}else switch(s.kind){case"A":D(i[l],s.index,s.item);break;case"D":i[l]=s.lhs;break;case"E":i[l]=s.lhs;break;case"N":i=m(i,l);break}return i}function F(i,l,s){if(i&&l&&s&&s.kind){var c=i,v,A;for(A=s.path.length-1,v=0;v<A;v++)typeof c[s.path[v]]>"u"&&(c[s.path[v]]={}),c=c[s.path[v]];switch(s.kind){case"A":D(c[s.path[v]],s.index,s.item);break;case"D":c[s.path[v]]=s.lhs;break;case"E":c[s.path[v]]=s.lhs;break;case"N":delete c[s.path[v]];break}}}function W(i,l,s){if(i&&l){var c=function(v){(!s||s(i,l,v))&&O(i,l,v)};g(i,l,c)}}return Object.defineProperties(x,{diff:{value:x,enumerable:!0},orderIndependentDiff:{value:b,enumerable:!0},observableDiff:{value:g,enumerable:!0},orderIndependentObservableDiff:{value:R,enumerable:!0},orderIndepHash:{value:k,enumerable:!0},applyDiff:{value:W,enumerable:!0},applyChange:{value:O,enumerable:!0},revertChange:{value:F,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),x.DeepDiff=x,t&&(t.DeepDiff=x),x})}(te)),te.exports}var de=_e(),ne={exports:{}};const H=new Uint32Array(65536),je=(n,e)=>{const t=n.length,r=e.length,o=1<<t-1;let u=-1,d=0,f=t,p=t;for(;p--;)H[n.charCodeAt(p)]|=1<<p;for(p=0;p<r;p++){let y=H[e.charCodeAt(p)];const m=y|d;y|=(y&u)+u^u,d|=~(y|u),u&=y,d&o&&f++,u&o&&f--,d=d<<1|1,u=u<<1|~(m|d),d&=m}for(p=t;p--;)H[n.charCodeAt(p)]=0;return f},Ne=(n,e)=>{const t=e.length,r=n.length,o=[],u=[],d=Math.ceil(t/32),f=Math.ceil(r/32);for(let h=0;h<d;h++)u[h]=-1,o[h]=0;let p=0;for(;p<f-1;p++){let h=0,g=-1;const R=p*32,x=Math.min(32,r)+R;for(let b=R;b<x;b++)H[n.charCodeAt(b)]|=1<<b;for(let b=0;b<t;b++){const E=H[e.charCodeAt(b)],O=u[b/32|0]>>>b&1,D=o[b/32|0]>>>b&1,F=E|h,W=((E|D)&g)+g^g|E|D;let i=h|~(W|g),l=g&W;i>>>31^O&&(u[b/32|0]^=1<<b),l>>>31^D&&(o[b/32|0]^=1<<b),i=i<<1|O,l=l<<1|D,g=l|~(F|i),h=i&F}for(let b=R;b<x;b++)H[n.charCodeAt(b)]=0}let y=0,m=-1;const S=p*32,w=Math.min(32,r-S)+S;for(let h=S;h<w;h++)H[n.charCodeAt(h)]|=1<<h;let k=r;for(let h=0;h<t;h++){const g=H[e.charCodeAt(h)],R=u[h/32|0]>>>h&1,x=o[h/32|0]>>>h&1,b=g|y,E=((g|x)&m)+m^m|g|x;let O=y|~(E|m),D=m&E;k+=O>>>r-1&1,k-=D>>>r-1&1,O>>>31^R&&(u[h/32|0]^=1<<h),D>>>31^x&&(o[h/32|0]^=1<<h),O=O<<1|R,D=D<<1|x,m=D|~(b|O),y=O&b}for(let h=S;h<w;h++)H[n.charCodeAt(h)]=0;return k},pe=(n,e)=>{if(n.length<e.length){const t=e;e=n,n=t}return e.length===0?n.length:n.length<=32?je(n,e):Ne(n,e)},Ie=Pe(Object.freeze(Object.defineProperty({__proto__:null,closest:(n,e)=>{let t=1/0,r=0;for(let o=0;o<e.length;o++){const u=pe(n,e[o]);u<t&&(t=u,r=o)}return e[r]},distance:pe},Symbol.toStringTag,{value:"Module"})));var he;function Fe(){return he||(he=1,function(n,e){(function(){var t;try{t=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 r=Ie,o=[],u=[],d={get:function(f,p,y){var m=y&&t&&y.useCollator;if(m){var S=f.length,w=p.length;if(S===0)return w;if(w===0)return S;var k,h,g,R,x;for(g=0;g<w;++g)o[g]=g,u[g]=p.charCodeAt(g);o[w]=w;var b;for(g=0;g<S;++g){for(h=g+1,R=0;R<w;++R)k=h,b=t.compare(f.charAt(g),String.fromCharCode(u[R]))===0,h=o[R]+(b?0:1),x=k+1,h>x&&(h=x),x=o[R+1]+1,h>x&&(h=x),o[R]=k;o[R]=h}return h}return r.distance(f,p)}};n!==null&&n.exports===e?n.exports=d:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=d:typeof window<"u"&&window!==null&&(window.Levenshtein=d)})()}(ne,ne.exports)),ne.exports}var Le=Fe();const Me=Ee(Le);class We{diff(e,t,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const u=this.castInput(e,r),d=this.castInput(t,r),f=this.removeEmpty(this.tokenize(u,r)),p=this.removeEmpty(this.tokenize(d,r));return this.diffWithOptionsObj(f,p,r,o)}diffWithOptionsObj(e,t,r,o){var u;const d=b=>{if(b=this.postProcess(b,r),o){setTimeout(function(){o(b)},0);return}else return b},f=t.length,p=e.length;let y=1,m=f+p;r.maxEditLength!=null&&(m=Math.min(m,r.maxEditLength));const S=(u=r.timeout)!==null&&u!==void 0?u:1/0,w=Date.now()+S,k=[{oldPos:-1,lastComponent:void 0}];let h=this.extractCommon(k[0],t,e,0,r);if(k[0].oldPos+1>=p&&h+1>=f)return d(this.buildValues(k[0].lastComponent,t,e));let g=-1/0,R=1/0;const x=()=>{for(let b=Math.max(g,-y);b<=Math.min(R,y);b+=2){let E;const O=k[b-1],D=k[b+1];O&&(k[b-1]=void 0);let F=!1;if(D){const i=D.oldPos-b;F=D&&0<=i&&i<f}const W=O&&O.oldPos+1<p;if(!F&&!W){k[b]=void 0;continue}if(!W||F&&O.oldPos<D.oldPos?E=this.addToPath(D,!0,!1,0,r):E=this.addToPath(O,!1,!0,1,r),h=this.extractCommon(E,t,e,b,r),E.oldPos+1>=p&&h+1>=f)return d(this.buildValues(E.lastComponent,t,e))||!0;k[b]=E,E.oldPos+1>=p&&(R=Math.min(R,b-1)),h+1>=f&&(g=Math.max(g,b+1))}y++};if(o)(function b(){setTimeout(function(){if(y>m||Date.now()>w)return o(void 0);x()||b()},0)})();else for(;y<=m&&Date.now()<=w;){const b=x();if(b)return b}}addToPath(e,t,r,o,u){const d=e.lastComponent;return d&&!u.oneChangePerToken&&d.added===t&&d.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:d.count+1,added:t,removed:r,previousComponent:d.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:d}}}extractCommon(e,t,r,o,u){const d=t.length,f=r.length;let p=e.oldPos,y=p-o,m=0;for(;y+1<d&&p+1<f&&this.equals(r[p+1],t[y+1],u);)y++,p++,m++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!u.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=p,y}equals(e,t,r){return r.comparator?r.comparator(e,t):e===t||!!r.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){const t=[];for(let r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,r){const o=[];let u;for(;e;)o.push(e),u=e.previousComponent,delete e.previousComponent,e=u;o.reverse();const d=o.length;let f=0,p=0,y=0;for(;f<d;f++){const m=o[f];if(m.removed)m.value=this.join(r.slice(y,y+m.count)),y+=m.count;else{if(!m.added&&this.useLongestToken){let S=t.slice(p,p+m.count);S=S.map(function(w,k){const h=r[y+k];return h.length>w.length?h:w}),m.value=this.join(S)}else m.value=this.join(t.slice(p,p+m.count));p+=m.count,m.added||(y+=m.count)}}return o}}class Ye extends We{constructor(){super(...arguments),this.tokenize=Ke}equals(e,t,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
22
+ <%s key={someKey} {...props} />`,j,N,U,N),re[N+j]=!0)}if(N=null,_!==void 0&&(t(_),N=""+_),d(T)&&(t(T.key),N=""+T.key),"key"in T){_={};for(var se in T)se!=="key"&&(_[se]=T[se])}else _=T;return N&&f(_,typeof a=="function"?a.displayName||a.name||"Unknown":a),y(a,N,z,K,o(),_,G,J)}function S(a){typeof a=="object"&&a!==null&&a.$$typeof===E&&a._store&&(a._store.validated=1)}var w=k,E=Symbol.for("react.transitional.element"),h=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),P=Symbol.for("react.context"),O=Symbol.for("react.forward_ref"),D=Symbol.for("react.suspense"),F=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),l=Symbol.for("react.activity"),s=Symbol.for("react.client.reference"),c=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,v=Object.prototype.hasOwnProperty,A=Array.isArray,C=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(a){return a()}};var Y,I={},B=w.react_stack_bottom_frame.bind(w,u)(),V=C(r(u)),re={};Z.Fragment=g,Z.jsx=function(a,T,_,j,K){var z=1e4>c.recentlyCreatedOwnerStacks++;return m(a,T,_,!1,j,K,z?Error("react-stack-top-frame"):B,z?C(r(a)):V)},Z.jsxs=function(a,T,_,j,K){var z=1e4>c.recentlyCreatedOwnerStacks++;return m(a,T,_,!0,j,K,z?Error("react-stack-top-frame"):B,z?C(r(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=k.createContext(null),Re="https://api.kelet.ai/api",Oe=()=>{const n=k.useContext(Q);if(!n)throw new Error("useKelet must be used within a KeletProvider");return n},oe=()=>{const n=k.useContext(Q);return n?n.feedback:async()=>{}},De=({apiKey:n,project:e,children:t})=>{const r=k.useContext(Q),o=n||r?.api_key;if(!o)throw new Error("apiKey is required either directly or from a parent KeletProvider");const d={api_key:o,project:e,feedback:async f=>{const p=`${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},m=await fetch(p,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o}`},body:JSON.stringify(y)});if(!m.ok)throw new Error(`Failed to submit feedback: ${m.statusText}`)}};return L.jsx(Q.Provider,{value:d,children:t})},q=(n,e)=>{const t={...e};for(const r in e){const o=n[r],u=e[r];/^on[A-Z]/.test(r)?o&&u?t[r]=(...f)=>{u(...f),o(...f)}:o&&(t[r]=o):r==="style"?t[r]={...o,...u}:r==="className"?t[r]=[o,u].filter(Boolean).join(" "):t[r]=u!==void 0?u:o}return{...n,...t}},ce=k.createContext(null),$=()=>{const n=k.useContext(ce);if(!n)throw new Error("VoteFeedback components must be used within VoteFeedback.Root");return n},Se={Root:({children:n,onFeedback:e,defaultText:t="",tx_id:r,extra_metadata:o,trigger_name:u})=>{const d=typeof r=="function"?r():r,[f,p]=k.useState(!1),[y,m]=k.useState(t),[S,w]=k.useState(!1),[E,h]=k.useState(null),g=k.useRef(null),R=k.useRef(null),x=k.useId(),b=k.useId(),P=oe(),O=e||P;k.useEffect(()=>{p(!1),m(t),w(!1),h(null),setTimeout(()=>R.current?.focus(),0)},[d,t]);const D=k.useCallback(async()=>{h("upvote");const c={tx_id:d,vote:"upvote",...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(c)}finally{w(!1)}},[O,d,o,u]),F=k.useCallback(async()=>{if(h("downvote"),O){const c={tx_id:d,vote:"downvote",...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(c)}finally{w(!1)}}p(!0),setTimeout(()=>{g.current?.focus();const c=document.createElement("div");c.setAttribute("aria-live","polite"),c.setAttribute("aria-atomic","true"),c.className="sr-only",c.textContent="Feedback dialog opened. You can provide additional details about your downvote.",document.body.appendChild(c),setTimeout(()=>document.body.removeChild(c),1e3)},0)},[O,d,o,u]),W=k.useCallback(c=>{m(c.target.value)},[]),i=k.useCallback(async()=>{const c=y.trim().length>0;if(c){const v={tx_id:d,vote:"downvote",explanation:y,...o&&{extra_metadata:o},...u&&{trigger_name:u}};try{w(!0),await O(v)}finally{w(!1)}}if(p(!1),m(t),R.current?.focus(),c){const v=document.createElement("div");v.setAttribute("aria-live","polite"),v.className="sr-only",v.textContent="Feedback submitted successfully.",document.body.appendChild(v),setTimeout(()=>document.body.removeChild(v),1e3)}},[O,y,t,d,o,u]),l=k.useCallback(c=>{if(c.key==="Escape")p(!1),m(t),R.current?.focus();else if((c.metaKey||c.ctrlKey)&&c.key==="Enter")c.preventDefault(),i().then(v=>{});else if(c.key==="Tab"&&f){const v=document.getElementById(x);if(v){const A=v.querySelectorAll('button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'),C=A[0],Y=A[A.length-1];c.shiftKey&&document.activeElement===C?(c.preventDefault(),Y?.focus()):!c.shiftKey&&document.activeElement===Y&&(c.preventDefault(),C?.focus())}}},[i,f,x,t]),s={onFeedback:O,showPopover:f,setShowPopover:p,feedbackText:y,setFeedbackText:m,isSubmitting:S,setIsSubmitting:w,vote:E,handleUpvote:D,handleDownvote:F,handleTextareaChange:W,handleSubmit:i,handleKeyDown:l,textareaRef:g,triggerRef:R,popoverId:x,triggerId:b,tx_id:d,extra_metadata:o,trigger_name:u};return L.jsx(ce.Provider,{value:s,children:n})},UpvoteButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleUpvote:o,isSubmitting:u,vote:d}=$(),f=k.useCallback(m=>{o(),t?.(m)},[o,t]),p={...r,onClick:f,disabled:u||r.disabled,"aria-label":r["aria-label"]||"Upvote feedback",type:"button"},y=d==="upvote";if(n){const m=typeof e=="function"?e({isSelected:y}):e;if(k.isValidElement(m))return k.cloneElement(m,q(p,m.props))}return L.jsx("button",{...p,children:typeof e=="function"?e({isSelected:y}):e})},DownvoteButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleDownvote:o,showPopover:u,isSubmitting:d,popoverId:f,triggerId:p,triggerRef:y,vote:m}=$(),S=k.useCallback(h=>{o(),t?.(h)},[o,t]),w={...r,ref:y,onClick:S,disabled:d||r.disabled,"aria-label":r["aria-label"]||"Downvote feedback","aria-expanded":u,"aria-controls":f,id:p,type:"button"},E=m==="downvote";if(n){const h=typeof e=="function"?e({isSelected:E}):e;if(k.isValidElement(h))return k.cloneElement(h,q(w,h.props));if(h)return h}return L.jsx("button",{...w,children:typeof e=="function"?e({isSelected:E}):e})},Popover:({asChild:n,children:e,...t})=>{const{showPopover:r,handleKeyDown:o,popoverId:u,triggerId:d}=$();if(!r)return null;const f={...t,role:"dialog","aria-labelledby":d,"aria-modal":!0,"aria-describedby":`${u}-description`,id:u,onKeyDown:o,tabIndex:-1};return n&&k.isValidElement(e)?L.jsxs(L.Fragment,{children:[k.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:n,value:e,onChange:t,...r})=>{const{feedbackText:o,handleTextareaChange:u,textareaRef:d,handleKeyDown:f,popoverId:p}=$(),y={...r,ref:d,value:e!==void 0?e:o,onChange:t||u,onKeyDown:f,placeholder:r.placeholder||"What did we miss?","aria-label":r["aria-label"]||"Additional feedback","aria-describedby":`${p}-help`,rows:r.rows||3};return n&&k.isValidElement(r.children)?k.cloneElement(r.children,q(y,r.children.props)):L.jsx("textarea",{...y})},SubmitButton:({asChild:n,children:e,onClick:t,...r})=>{const{handleSubmit:o,isSubmitting:u,feedbackText:d}=$(),f=k.useCallback(S=>{o(),t?.(S)},[o,t]),p=d.trim().length>0,y=p?"Submit feedback":"Close without feedback",m={...r,onClick:f,disabled:u||r.disabled,type:"button","aria-label":r["aria-label"]||y,"aria-describedby":p?void 0:"submit-help"};return n&&k.isValidElement(e)?L.jsxs(L.Fragment,{children:[k.cloneElement(e,q(m,e.props)),!p&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]}):L.jsxs("button",{...m,children:[e,!p&&L.jsx("span",{id:"submit-help",className:"sr-only",children:"This will close the dialog without submitting feedback"})]})}};var te={exports:{}},Ae=te.exports,fe;function _e(){return fe||(fe=1,function(n,e){(function(t,r){var o=r(t);n.exports=o})(Ae,function(t){var r=["N","E","A","D"];function o(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 d(i,l,s){d.super_.call(this,"E",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0}),Object.defineProperty(this,"rhs",{value:s,enumerable:!0})}o(d,u);function f(i,l){f.super_.call(this,"N",i),Object.defineProperty(this,"rhs",{value:l,enumerable:!0})}o(f,u);function p(i,l){p.super_.call(this,"D",i),Object.defineProperty(this,"lhs",{value:l,enumerable:!0})}o(p,u);function y(i,l,s){y.super_.call(this,"A",i),Object.defineProperty(this,"index",{value:l,enumerable:!0}),Object.defineProperty(this,"item",{value:s,enumerable:!0})}o(y,u);function m(i,l,s){var c=i.slice(l+1||i.length);return i.length=l<0?i.length+l:l,i.push.apply(i,c),i}function S(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 w(i){var l=0;if(i.length===0)return l;for(var s=0;s<i.length;s++){var c=i.charCodeAt(s);l=(l<<5)-l+c,l=l&l}return l}function E(i){var l=0,s=S(i);if(s==="array"){i.forEach(function(Y){l+=E(Y)});var c="[type: array, hash: "+l+"]";return l+w(c)}if(s==="object"){for(var v in i)if(i.hasOwnProperty(v)){var A="[ type: object, key: "+v+", value hash: "+E(i[v])+"]";l+=w(A)}return l}var C="[ type: "+s+" ; value: "+i+"]";return l+w(C)}function h(i,l,s,c,v,A,C,Y){s=s||[],v=v||[],C=C||[];var I=v.slice(0);if(typeof A<"u"&&A!==null){if(c){if(typeof c=="function"&&c(I,A))return;if(typeof c=="object"){if(c.prefilter&&c.prefilter(I,A))return;if(c.normalize){var B=c.normalize(I,A,i,l);B&&(i=B[0],l=B[1])}}}I.push(A)}S(i)==="regexp"&&S(l)==="regexp"&&(i=i.toString(),l=l.toString());var V=typeof i,re=typeof l,a,T,_,j,K=V!=="undefined"||C&&C.length>0&&C[C.length-1].lhs&&Object.getOwnPropertyDescriptor(C[C.length-1].lhs,A),z=re!=="undefined"||C&&C.length>0&&C[C.length-1].rhs&&Object.getOwnPropertyDescriptor(C[C.length-1].rhs,A);if(!K&&z)s.push(new f(I,l));else if(!z&&K)s.push(new p(I,i));else if(S(i)!==S(l))s.push(new d(I,i,l));else if(S(i)==="date"&&i-l!==0)s.push(new d(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&&s.push(new d(I,i,l));else{if(C.push({lhs:i,rhs:l}),Array.isArray(i)){for(Y&&(i.sort(function(N,U){return E(N)-E(U)}),l.sort(function(N,U){return E(N)-E(U)})),a=l.length-1,T=i.length-1;a>T;)s.push(new y(I,a,new f(void 0,l[a--])));for(;T>a;)s.push(new y(I,T,new p(void 0,i[T--])));for(;a>=0;--a)h(i[a],l[a],s,c,I,a,C,Y)}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[_],s,c,I,_,C,Y),J[j]=null):h(i[_],void 0,s,c,I,_,C,Y);for(a=0;a<J.length;++a)_=J[a],_&&h(void 0,l[_],s,c,I,_,C,Y)}C.length=C.length-1}}else i!==l&&(V==="number"&&isNaN(i)&&isNaN(l)||s.push(new d(I,i,l)))}function g(i,l,s,c,v){var A=[];if(h(i,l,A,c,null,null,null,v),s)for(var C=0;C<A.length;++C)s(A[C]);return A}function R(i,l,s,c,v,A,C){return h(i,l,s,c,v,A,C,!0)}function x(i,l,s,c){var v=c?function(C){C&&c.push(C)}:void 0,A=g(i,l,v,s);return c||(A.length?A:void 0)}function b(i,l,s,c){var v=c?function(C){C&&c.push(C)}:void 0,A=g(i,l,v,s,!0);return c||(A.length?A:void 0)}function P(i,l,s){if(s.path&&s.path.length){var c=i[l],v,A=s.path.length-1;for(v=0;v<A;v++)c=c[s.path[v]];switch(s.kind){case"A":P(c[s.path[v]],s.index,s.item);break;case"D":delete c[s.path[v]];break;case"E":case"N":c[s.path[v]]=s.rhs;break}}else switch(s.kind){case"A":P(i[l],s.index,s.item);break;case"D":i=m(i,l);break;case"E":case"N":i[l]=s.rhs;break}return i}function O(i,l,s){if(typeof s>"u"&&l&&~r.indexOf(l.kind)&&(s=l),i&&s&&s.kind){for(var c=i,v=-1,A=s.path?s.path.length-1:0;++v<A;)typeof c[s.path[v]]>"u"&&(c[s.path[v]]=typeof s.path[v+1]<"u"&&typeof s.path[v+1]=="number"?[]:{}),c=c[s.path[v]];switch(s.kind){case"A":s.path&&typeof c[s.path[v]]>"u"&&(c[s.path[v]]=[]),P(s.path?c[s.path[v]]:c,s.index,s.item);break;case"D":delete c[s.path[v]];break;case"E":case"N":c[s.path[v]]=s.rhs;break}}}function D(i,l,s){if(s.path&&s.path.length){var c=i[l],v,A=s.path.length-1;for(v=0;v<A;v++)c=c[s.path[v]];switch(s.kind){case"A":D(c[s.path[v]],s.index,s.item);break;case"D":c[s.path[v]]=s.lhs;break;case"E":c[s.path[v]]=s.lhs;break;case"N":delete c[s.path[v]];break}}else switch(s.kind){case"A":D(i[l],s.index,s.item);break;case"D":i[l]=s.lhs;break;case"E":i[l]=s.lhs;break;case"N":i=m(i,l);break}return i}function F(i,l,s){if(i&&l&&s&&s.kind){var c=i,v,A;for(A=s.path.length-1,v=0;v<A;v++)typeof c[s.path[v]]>"u"&&(c[s.path[v]]={}),c=c[s.path[v]];switch(s.kind){case"A":D(c[s.path[v]],s.index,s.item);break;case"D":c[s.path[v]]=s.lhs;break;case"E":c[s.path[v]]=s.lhs;break;case"N":delete c[s.path[v]];break}}}function W(i,l,s){if(i&&l){var c=function(v){(!s||s(i,l,v))&&O(i,l,v)};g(i,l,c)}}return Object.defineProperties(x,{diff:{value:x,enumerable:!0},orderIndependentDiff:{value:b,enumerable:!0},observableDiff:{value:g,enumerable:!0},orderIndependentObservableDiff:{value:R,enumerable:!0},orderIndepHash:{value:E,enumerable:!0},applyDiff:{value:W,enumerable:!0},applyChange:{value:O,enumerable:!0},revertChange:{value:F,enumerable:!0},isConflict:{value:function(){return typeof $conflict<"u"},enumerable:!0}}),x.DeepDiff=x,t&&(t.DeepDiff=x),x})}(te)),te.exports}var de=_e(),ne={exports:{}};const H=new Uint32Array(65536),je=(n,e)=>{const t=n.length,r=e.length,o=1<<t-1;let u=-1,d=0,f=t,p=t;for(;p--;)H[n.charCodeAt(p)]|=1<<p;for(p=0;p<r;p++){let y=H[e.charCodeAt(p)];const m=y|d;y|=(y&u)+u^u,d|=~(y|u),u&=y,d&o&&f++,u&o&&f--,d=d<<1|1,u=u<<1|~(m|d),d&=m}for(p=t;p--;)H[n.charCodeAt(p)]=0;return f},Ne=(n,e)=>{const t=e.length,r=n.length,o=[],u=[],d=Math.ceil(t/32),f=Math.ceil(r/32);for(let h=0;h<d;h++)u[h]=-1,o[h]=0;let p=0;for(;p<f-1;p++){let h=0,g=-1;const R=p*32,x=Math.min(32,r)+R;for(let b=R;b<x;b++)H[n.charCodeAt(b)]|=1<<b;for(let b=0;b<t;b++){const P=H[e.charCodeAt(b)],O=u[b/32|0]>>>b&1,D=o[b/32|0]>>>b&1,F=P|h,W=((P|D)&g)+g^g|P|D;let i=h|~(W|g),l=g&W;i>>>31^O&&(u[b/32|0]^=1<<b),l>>>31^D&&(o[b/32|0]^=1<<b),i=i<<1|O,l=l<<1|D,g=l|~(F|i),h=i&F}for(let b=R;b<x;b++)H[n.charCodeAt(b)]=0}let y=0,m=-1;const S=p*32,w=Math.min(32,r-S)+S;for(let h=S;h<w;h++)H[n.charCodeAt(h)]|=1<<h;let E=r;for(let h=0;h<t;h++){const g=H[e.charCodeAt(h)],R=u[h/32|0]>>>h&1,x=o[h/32|0]>>>h&1,b=g|y,P=((g|x)&m)+m^m|g|x;let O=y|~(P|m),D=m&P;E+=O>>>r-1&1,E-=D>>>r-1&1,O>>>31^R&&(u[h/32|0]^=1<<h),D>>>31^x&&(o[h/32|0]^=1<<h),O=O<<1|R,D=D<<1|x,m=D|~(b|O),y=O&b}for(let h=S;h<w;h++)H[n.charCodeAt(h)]=0;return E},pe=(n,e)=>{if(n.length<e.length){const t=e;e=n,n=t}return e.length===0?n.length:n.length<=32?je(n,e):Ne(n,e)},Ie=Pe(Object.freeze(Object.defineProperty({__proto__:null,closest:(n,e)=>{let t=1/0,r=0;for(let o=0;o<e.length;o++){const u=pe(n,e[o]);u<t&&(t=u,r=o)}return e[r]},distance:pe},Symbol.toStringTag,{value:"Module"})));var he;function Fe(){return he||(he=1,function(n,e){(function(){var t;try{t=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 r=Ie,o=[],u=[],d={get:function(f,p,y){var m=y&&t&&y.useCollator;if(m){var S=f.length,w=p.length;if(S===0)return w;if(w===0)return S;var E,h,g,R,x;for(g=0;g<w;++g)o[g]=g,u[g]=p.charCodeAt(g);o[w]=w;var b;for(g=0;g<S;++g){for(h=g+1,R=0;R<w;++R)E=h,b=t.compare(f.charAt(g),String.fromCharCode(u[R]))===0,h=o[R]+(b?0:1),x=E+1,h>x&&(h=x),x=o[R+1]+1,h>x&&(h=x),o[R]=E;o[R]=h}return h}return r.distance(f,p)}};n!==null&&n.exports===e?n.exports=d:typeof self<"u"&&typeof self.postMessage=="function"&&typeof self.importScripts=="function"?self.Levenshtein=d:typeof window<"u"&&window!==null&&(window.Levenshtein=d)})()}(ne,ne.exports)),ne.exports}var Le=Fe();const Me=Ee(Le);class We{diff(e,t,r={}){let o;typeof r=="function"?(o=r,r={}):"callback"in r&&(o=r.callback);const u=this.castInput(e,r),d=this.castInput(t,r),f=this.removeEmpty(this.tokenize(u,r)),p=this.removeEmpty(this.tokenize(d,r));return this.diffWithOptionsObj(f,p,r,o)}diffWithOptionsObj(e,t,r,o){var u;const d=b=>{if(b=this.postProcess(b,r),o){setTimeout(function(){o(b)},0);return}else return b},f=t.length,p=e.length;let y=1,m=f+p;r.maxEditLength!=null&&(m=Math.min(m,r.maxEditLength));const S=(u=r.timeout)!==null&&u!==void 0?u:1/0,w=Date.now()+S,E=[{oldPos:-1,lastComponent:void 0}];let h=this.extractCommon(E[0],t,e,0,r);if(E[0].oldPos+1>=p&&h+1>=f)return d(this.buildValues(E[0].lastComponent,t,e));let g=-1/0,R=1/0;const x=()=>{for(let b=Math.max(g,-y);b<=Math.min(R,y);b+=2){let P;const O=E[b-1],D=E[b+1];O&&(E[b-1]=void 0);let F=!1;if(D){const i=D.oldPos-b;F=D&&0<=i&&i<f}const W=O&&O.oldPos+1<p;if(!F&&!W){E[b]=void 0;continue}if(!W||F&&O.oldPos<D.oldPos?P=this.addToPath(D,!0,!1,0,r):P=this.addToPath(O,!1,!0,1,r),h=this.extractCommon(P,t,e,b,r),P.oldPos+1>=p&&h+1>=f)return d(this.buildValues(P.lastComponent,t,e))||!0;E[b]=P,P.oldPos+1>=p&&(R=Math.min(R,b-1)),h+1>=f&&(g=Math.max(g,b+1))}y++};if(o)(function b(){setTimeout(function(){if(y>m||Date.now()>w)return o(void 0);x()||b()},0)})();else for(;y<=m&&Date.now()<=w;){const b=x();if(b)return b}}addToPath(e,t,r,o,u){const d=e.lastComponent;return d&&!u.oneChangePerToken&&d.added===t&&d.removed===r?{oldPos:e.oldPos+o,lastComponent:{count:d.count+1,added:t,removed:r,previousComponent:d.previousComponent}}:{oldPos:e.oldPos+o,lastComponent:{count:1,added:t,removed:r,previousComponent:d}}}extractCommon(e,t,r,o,u){const d=t.length,f=r.length;let p=e.oldPos,y=p-o,m=0;for(;y+1<d&&p+1<f&&this.equals(r[p+1],t[y+1],u);)y++,p++,m++,u.oneChangePerToken&&(e.lastComponent={count:1,previousComponent:e.lastComponent,added:!1,removed:!1});return m&&!u.oneChangePerToken&&(e.lastComponent={count:m,previousComponent:e.lastComponent,added:!1,removed:!1}),e.oldPos=p,y}equals(e,t,r){return r.comparator?r.comparator(e,t):e===t||!!r.ignoreCase&&e.toLowerCase()===t.toLowerCase()}removeEmpty(e){const t=[];for(let r=0;r<e.length;r++)e[r]&&t.push(e[r]);return t}castInput(e,t){return e}tokenize(e,t){return Array.from(e)}join(e){return e.join("")}postProcess(e,t){return e}get useLongestToken(){return!1}buildValues(e,t,r){const o=[];let u;for(;e;)o.push(e),u=e.previousComponent,delete e.previousComponent,e=u;o.reverse();const d=o.length;let f=0,p=0,y=0;for(;f<d;f++){const m=o[f];if(m.removed)m.value=this.join(r.slice(y,y+m.count)),y+=m.count;else{if(!m.added&&this.useLongestToken){let S=t.slice(p,p+m.count);S=S.map(function(w,E){const h=r[y+E];return h.length>w.length?h:w}),m.value=this.join(S)}else m.value=this.join(t.slice(p,p+m.count));p+=m.count,m.added||(y+=m.count)}}return o}}class Ye extends We{constructor(){super(...arguments),this.tokenize=Ke}equals(e,t,r){return r.ignoreWhitespace?((!r.newlineIsToken||!e.includes(`
23
23
  `))&&(e=e.trim()),(!r.newlineIsToken||!t.includes(`
24
24
  `))&&(t=t.trim())):r.ignoreNewlineAtEof&&!r.newlineIsToken&&(e.endsWith(`
25
25
  `)&&(e=e.slice(0,-1)),t.endsWith(`
26
26
  `)&&(t=t.slice(0,-1))),super.equals(e,t,r)}}const ze=new Ye;function me(n,e,t){return ze.diff(n,e,t)}function Ke(n,e){e.stripTrailingCr&&(n=n.replace(/\r\n/g,`
27
- `));const t=[],r=n.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const u=r[o];o%2&&!e.newlineIsToken?t[t.length-1]+=u:t.push(u)}return t}function be(n,e,t,r,o,u,d){let f;d?typeof d=="function"?f={callback:d}:f=d:f={},typeof f.context>"u"&&(f.context=4);const p=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:m}=f;me(t,r,Object.assign(Object.assign({},f),{callback:S=>{const w=y(S);m(w)}}))}else return y(me(t,r,f));function y(m){if(!m)return;m.push({value:"",lines:[]});function S(b){return b.map(function(E){return" "+E})}const w=[];let k=0,h=0,g=[],R=1,x=1;for(let b=0;b<m.length;b++){const E=m[b],O=E.lines||He(E.value);if(E.lines=O,E.added||E.removed){if(!k){const D=m[b-1];k=R,h=x,D&&(g=p>0?S(D.lines.slice(-p)):[],k-=g.length,h-=g.length)}for(const D of O)g.push((E.added?"+":"-")+D);E.added?x+=O.length:R+=O.length}else{if(k)if(O.length<=p*2&&b<m.length-2)for(const D of S(O))g.push(D);else{const D=Math.min(O.length,p);for(const W of S(O.slice(0,D)))g.push(W);const F={oldStart:k,oldLines:R-k+D,newStart:h,newLines:x-h+D,lines:g};w.push(F),k=0,h=0,g=[]}R+=O.length,x+=O.length}}for(const b of w)for(let E=0;E<b.lines.length;E++)b.lines[E].endsWith(`
28
- `)?b.lines[E]=b.lines[E].slice(0,-1):(b.lines.splice(E+1,0,"\"),E++);return{oldFileName:n,newFileName:e,oldHeader:o,newHeader:u,hunks:w}}}function ie(n){if(Array.isArray(n))return n.map(ie).join(`
27
+ `));const t=[],r=n.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let o=0;o<r.length;o++){const u=r[o];o%2&&!e.newlineIsToken?t[t.length-1]+=u:t.push(u)}return t}function be(n,e,t,r,o,u,d){let f;d?typeof d=="function"?f={callback:d}:f=d:f={},typeof f.context>"u"&&(f.context=4);const p=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:m}=f;me(t,r,Object.assign(Object.assign({},f),{callback:S=>{const w=y(S);m(w)}}))}else return y(me(t,r,f));function y(m){if(!m)return;m.push({value:"",lines:[]});function S(b){return b.map(function(P){return" "+P})}const w=[];let E=0,h=0,g=[],R=1,x=1;for(let b=0;b<m.length;b++){const P=m[b],O=P.lines||He(P.value);if(P.lines=O,P.added||P.removed){if(!E){const D=m[b-1];E=R,h=x,D&&(g=p>0?S(D.lines.slice(-p)):[],E-=g.length,h-=g.length)}for(const D of O)g.push((P.added?"+":"-")+D);P.added?x+=O.length:R+=O.length}else{if(E)if(O.length<=p*2&&b<m.length-2)for(const D of S(O))g.push(D);else{const D=Math.min(O.length,p);for(const W of S(O.slice(0,D)))g.push(W);const F={oldStart:E,oldLines:R-E+D,newStart:h,newLines:x-h+D,lines:g};w.push(F),E=0,h=0,g=[]}R+=O.length,x+=O.length}}for(const b of w)for(let P=0;P<b.lines.length;P++)b.lines[P].endsWith(`
28
+ `)?b.lines[P]=b.lines[P].slice(0,-1):(b.lines.splice(P+1,0,"\"),P++);return{oldFileName:n,newFileName:e,oldHeader:o,newHeader:u,hunks:w}}}function ie(n){if(Array.isArray(n))return n.map(ie).join(`
29
29
  `);const e=[];n.oldFileName==n.newFileName&&e.push("Index: "+n.oldFileName),e.push("==================================================================="),e.push("--- "+n.oldFileName+(typeof n.oldHeader>"u"?"":" "+n.oldHeader)),e.push("+++ "+n.newFileName+(typeof n.newHeader>"u"?"":" "+n.newHeader));for(let t=0;t<n.hunks.length;t++){const r=n.hunks[t];r.oldLines===0&&(r.oldStart-=1),r.newLines===0&&(r.newStart-=1),e.push("@@ -"+r.oldStart+","+r.oldLines+" +"+r.newStart+","+r.newLines+" @@");for(const o of r.lines)e.push(o)}return e.join(`
30
30
  `)+`
31
31
  `}function Ue(n,e,t,r,o,u,d){if(typeof d=="function"&&(d={callback:d}),d?.callback){const{callback:f}=d;be(n,e,t,r,o,u,Object.assign(Object.assign({},d),{callback:p=>{f(p?ie(p):void 0)}}))}else{const f=be(n,e,t,r,o,u,d);return f?ie(f):void 0}}function He(n){const e=n.endsWith(`
@@ -33,4 +33,4 @@ React keys must be passed directly to JSX without using spread:
33
33
  `).map(r=>r+`
34
34
  `);return e?t.pop():t.push(t.pop().slice(0,-1)),t}function Je(n,e,t="git",r=3){switch(t){case"git":return ve(n,e,r);case"object":return Be(n,e);case"json":return Ve(n,e);default:return ve(n,e,r)}}function ve(n,e,t=3){const r=ke(n),o=ke(e);return Ue("","",r,o,"","",{context:t}).split(`
35
35
  `).slice(2).join(`
36
- `)}function Be(n,e){const t=de.diff(n,e)||[];return JSON.stringify(t,null,2)}function Ve(n,e){return JSON.stringify({before:n,after:e},null,2)}function Ge(n,e){return typeof n=="string"&&typeof e=="string"?ye(n,e):typeof n=="number"&&typeof e=="number"?we(n,e):Xe(n,e)}function ye(n,e){if(n===e)return 0;if(n.length===0||e.length===0)return 1;const t=Me.get(n,e),r=Math.max(n.length,e.length);return t/r}function we(n,e){if(n===e)return 0;if(n===0)return 1;const t=Math.abs(e-n),r=Math.max(Math.abs(n),Math.abs(e));return Math.min(t/r,1)}function Xe(n,e){if(n===e)return 0;const t=de.diff(n,e)||[];if(t.length===0)return 0;const r=ge(n),o=ge(e),u=Math.max(r,o);if(u===0)return 0;let d=0;for(const f of t)switch(f.kind){case"N":d+=1;break;case"D":d+=1;break;case"E":if(typeof f.lhs=="string"&&typeof f.rhs=="string"){const p=ye(f.lhs,f.rhs);d+=p}else if(typeof f.lhs=="number"&&typeof f.rhs=="number"){const p=we(f.lhs,f.rhs);d+=p}else d+=1;break;case"A":d+=.5;break}return Math.min(d/u,1)}function ge(n){if(n==null)return 0;if(typeof n!="object")return 1;if(Array.isArray(n))return n.length;let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e+=1);return e}function ke(n){try{return JSON.stringify(n,(e,t)=>typeof t=="function"?"[Function]":t===void 0?"[undefined]":t===1/0?"[Infinity]":Number.isNaN(t)?"[NaN]":t,2)}catch{return String(n)}}function Ze(n,e,t){const r=oe(),o=t?.onFeedback||r,u=t?.debounceMs??1500,d=t?.diffType??"git",f=t?.compareWith,p=t?.default_trigger_name??"auto_state_change",y=P.useRef(n),m=P.useRef(n),S=P.useRef(!0),w=P.useRef(null),k=P.useRef(void 0),h=P.useCallback((R,x,b)=>{const E=Ge(R,x),O=Je(R,x,d);let D;t?.vote?typeof t.vote=="function"?D=t.vote(R,x,E):D=t.vote:D=E>.5?"downvote":"upvote";const F=typeof e=="function"?e(x):e;o({tx_id:F,vote:D,explanation:`State change with diff percentage: ${(E*100).toFixed(1)}%`,correction:O,source:"IMPLICIT",extra_metadata:t?.metadata,trigger_name:b})},[t,e,d,o]),g=P.useCallback(R=>{const x=R||p;if(w.current&&k.current&&k.current!==x){clearTimeout(w.current);const b=m.current;h(b,n,k.current),w.current=null}k.current=x},[n,p,h]);return P.useEffect(()=>{if(S.current){S.current=!1,y.current=n,m.current=n;return}const R=y.current;return(f?f(R,n):JSON.stringify(R)===JSON.stringify(n))||(w.current||(m.current=R),w.current&&clearTimeout(w.current),y.current=n,w.current=setTimeout(()=>{const b=m.current,E=n;h(b,E,k.current||p),m.current=E,w.current=null},u)),()=>{w.current&&clearTimeout(w.current)}},[n,e,t,o,d,u,f,p,h]),{notifyChange:g}}function Qe(n,e,t){const[r,o]=P.useState(n),{notifyChange:u}=Ze(r,e,t),d=P.useCallback((f,p)=>{u(p),o(y=>typeof f=="function"?f(y):f)},[u]);return[r,d]}let qe=()=>{try{return require("@opentelemetry/api")}catch{throw new Error("OpenTelemetry is not available. Install @opentelemetry/api to use trace ID extraction.")}};function $e(){const{trace:n,context:e}=qe();try{const t=n.getSpanContext(e.active());if(t?.traceId)return t.traceId;const r=n.getSpan(e.active());if(r){const o=r.spanContext();if(o.traceId)return o.traceId}}catch(t){throw new Error(`Failed to extract OpenTelemetry trace ID: ${t instanceof Error?t.message:"Unknown error"}`)}throw new Error("OpenTelemetry trace ID not available. Ensure XHR/Fetch instrumentation is active and a request is in progress.")}M.KeletContext=Q,M.KeletProvider=De,M.VoteFeedback=Se,M.getOtelTraceId=$e,M.useDefaultFeedbackHandler=oe,M.useFeedbackState=Qe,M.useKelet=Oe,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
36
+ `)}function Be(n,e){const t=de.diff(n,e)||[];return JSON.stringify(t,null,2)}function Ve(n,e){return JSON.stringify({before:n,after:e},null,2)}function Ge(n,e){return typeof n=="string"&&typeof e=="string"?ye(n,e):typeof n=="number"&&typeof e=="number"?we(n,e):Xe(n,e)}function ye(n,e){if(n===e)return 0;if(n.length===0||e.length===0)return 1;const t=Me.get(n,e),r=Math.max(n.length,e.length);return t/r}function we(n,e){if(n===e)return 0;if(n===0)return 1;const t=Math.abs(e-n),r=Math.max(Math.abs(n),Math.abs(e));return Math.min(t/r,1)}function Xe(n,e){if(n===e)return 0;const t=de.diff(n,e)||[];if(t.length===0)return 0;const r=ge(n),o=ge(e),u=Math.max(r,o);if(u===0)return 0;let d=0;for(const f of t)switch(f.kind){case"N":d+=1;break;case"D":d+=1;break;case"E":if(typeof f.lhs=="string"&&typeof f.rhs=="string"){const p=ye(f.lhs,f.rhs);d+=p}else if(typeof f.lhs=="number"&&typeof f.rhs=="number"){const p=we(f.lhs,f.rhs);d+=p}else d+=1;break;case"A":d+=.5;break}return Math.min(d/u,1)}function ge(n){if(n==null)return 0;if(typeof n!="object")return 1;if(Array.isArray(n))return n.length;let e=0;for(const t in n)Object.prototype.hasOwnProperty.call(n,t)&&(e+=1);return e}function ke(n){try{return JSON.stringify(n,(e,t)=>typeof t=="function"?"[Function]":t===void 0?"[undefined]":t===1/0?"[Infinity]":Number.isNaN(t)?"[NaN]":t,2)}catch{return String(n)}}function Ze(n,e,t){const r=oe(),o=t?.onFeedback||r,u=t?.debounceMs??1500,d=t?.diffType??"git",f=t?.compareWith,p=t?.default_trigger_name??"auto_state_change",y=k.useRef(n),m=k.useRef(n),S=k.useRef(!0),w=k.useRef(null),E=k.useRef(void 0),h=k.useCallback((R,x,b)=>{const P=Ge(R,x),O=Je(R,x,d);let D;t?.vote?typeof t.vote=="function"?D=t.vote(R,x,P):D=t.vote:D=P>.5?"downvote":"upvote";const F=typeof e=="function"?e(x):e;o({tx_id:F,vote:D,explanation:`State change with diff percentage: ${(P*100).toFixed(1)}%`,correction:O,source:"IMPLICIT",extra_metadata:t?.metadata,trigger_name:b})},[t,e,d,o]),g=k.useCallback(R=>{const x=R||p;if(w.current&&E.current&&E.current!==x){clearTimeout(w.current);const b=m.current;h(b,n,E.current),w.current=null}E.current=x},[n,p,h]);return k.useEffect(()=>{if(S.current){S.current=!1,y.current=n,m.current=n;return}const R=y.current;return(f?f(R,n):JSON.stringify(R)===JSON.stringify(n))||(w.current||(m.current=R),w.current&&clearTimeout(w.current),y.current=n,w.current=setTimeout(()=>{const b=m.current,P=n;h(b,P,E.current||p),m.current=P,w.current=null},u)),()=>{w.current&&clearTimeout(w.current)}},[n,e,t,o,d,u,f,p,h]),{notifyChange:g}}function Qe(n,e,t){const[r,o]=k.useState(n),{notifyChange:u}=Ze(r,e,t),d=k.useCallback((f,p)=>{u(p),o(y=>typeof f=="function"?f(y):f)},[u]);return[r,d]}let qe=()=>{try{return require("@opentelemetry/api")}catch{throw new Error("OpenTelemetry is not available. Install @opentelemetry/api to use trace ID extraction.")}};function $e(){const{trace:n,context:e}=qe();try{const t=n.getSpanContext(e.active());if(t?.traceId)return t.traceId;const r=n.getSpan(e.active());if(r){const o=r.spanContext();if(o.traceId)return o.traceId}}catch(t){throw new Error(`Failed to extract OpenTelemetry trace ID: ${t instanceof Error?t.message:"Unknown error"}`)}throw new Error("OpenTelemetry trace ID not available. Ensure XHR/Fetch instrumentation is active and a request is in progress.")}M.KeletContext=Q,M.KeletProvider=De,M.VoteFeedback=Se,M.getOtelTraceId=$e,M.useDefaultFeedbackHandler=oe,M.useFeedbackState=Qe,M.useKelet=Oe,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kelet-ai/feedback-ui",
3
- "version": "0.4.0",
3
+ "version": "0.4.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/kelet-ai/feedback-ui.git"