@kelet-ai/feedback-ui 0.4.1 → 0.5.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 +1 -1
- package/dist/feedback-ui.es.js +1729 -1122
- package/dist/feedback-ui.es.js.map +1 -0
- package/dist/feedback-ui.es.min.js +1562 -0
- package/dist/feedback-ui.es.min.js.map +1 -0
- package/dist/feedback-ui.umd.js +2167 -36
- package/dist/feedback-ui.umd.js.map +1 -0
- package/dist/feedback-ui.umd.min.js +37 -0
- package/dist/feedback-ui.umd.min.js.map +1 -0
- package/package.json +15 -4
|
@@ -0,0 +1,1562 @@
|
|
|
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
|
+
function _e(n) {
|
|
3
|
+
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
4
|
+
}
|
|
5
|
+
function Se(n) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
7
|
+
var e = n.default;
|
|
8
|
+
if (typeof e == "function") {
|
|
9
|
+
var t = function r() {
|
|
10
|
+
var o = !1;
|
|
11
|
+
try {
|
|
12
|
+
o = this instanceof r;
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
return o ? Reflect.construct(e, arguments, this.constructor) : e.apply(this, arguments);
|
|
16
|
+
};
|
|
17
|
+
t.prototype = e.prototype;
|
|
18
|
+
} else t = {};
|
|
19
|
+
return Object.defineProperty(t, "__esModule", { value: !0 }), Object.keys(n).forEach(function(r) {
|
|
20
|
+
var o = Object.getOwnPropertyDescriptor(n, r);
|
|
21
|
+
Object.defineProperty(t, r, o.get ? o : {
|
|
22
|
+
enumerable: !0,
|
|
23
|
+
get: function() {
|
|
24
|
+
return n[r];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}), t;
|
|
28
|
+
}
|
|
29
|
+
var re = { exports: {} }, V = {};
|
|
30
|
+
/**
|
|
31
|
+
* @license React
|
|
32
|
+
* react-jsx-runtime.production.js
|
|
33
|
+
*
|
|
34
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
35
|
+
*
|
|
36
|
+
* This source code is licensed under the MIT license found in the
|
|
37
|
+
* LICENSE file in the root directory of this source tree.
|
|
38
|
+
*/
|
|
39
|
+
var fe;
|
|
40
|
+
function je() {
|
|
41
|
+
if (fe) return V;
|
|
42
|
+
fe = 1;
|
|
43
|
+
var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
|
|
44
|
+
function t(r, o, u) {
|
|
45
|
+
var d = null;
|
|
46
|
+
if (u !== void 0 && (d = "" + u), o.key !== void 0 && (d = "" + o.key), "key" in o) {
|
|
47
|
+
u = {};
|
|
48
|
+
for (var f in o)
|
|
49
|
+
f !== "key" && (u[f] = o[f]);
|
|
50
|
+
} else u = o;
|
|
51
|
+
return o = u.ref, {
|
|
52
|
+
$$typeof: n,
|
|
53
|
+
type: r,
|
|
54
|
+
key: d,
|
|
55
|
+
ref: o !== void 0 ? o : null,
|
|
56
|
+
props: u
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return V.Fragment = e, V.jsx = t, V.jsxs = t, V;
|
|
60
|
+
}
|
|
61
|
+
var G = {};
|
|
62
|
+
/**
|
|
63
|
+
* @license React
|
|
64
|
+
* react-jsx-runtime.development.js
|
|
65
|
+
*
|
|
66
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
67
|
+
*
|
|
68
|
+
* This source code is licensed under the MIT license found in the
|
|
69
|
+
* LICENSE file in the root directory of this source tree.
|
|
70
|
+
*/
|
|
71
|
+
var de;
|
|
72
|
+
function Ne() {
|
|
73
|
+
return de || (de = 1, process.env.NODE_ENV !== "production" && function() {
|
|
74
|
+
function n(a) {
|
|
75
|
+
if (a == null) return null;
|
|
76
|
+
if (typeof a == "function")
|
|
77
|
+
return a.$$typeof === s ? null : a.displayName || a.name || null;
|
|
78
|
+
if (typeof a == "string") return a;
|
|
79
|
+
switch (a) {
|
|
80
|
+
case g:
|
|
81
|
+
return "Fragment";
|
|
82
|
+
case P:
|
|
83
|
+
return "Profiler";
|
|
84
|
+
case C:
|
|
85
|
+
return "StrictMode";
|
|
86
|
+
case R:
|
|
87
|
+
return "Suspense";
|
|
88
|
+
case I:
|
|
89
|
+
return "SuspenseList";
|
|
90
|
+
case l:
|
|
91
|
+
return "Activity";
|
|
92
|
+
}
|
|
93
|
+
if (typeof a == "object")
|
|
94
|
+
switch (typeof a.tag == "number" && console.error(
|
|
95
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
96
|
+
), a.$$typeof) {
|
|
97
|
+
case h:
|
|
98
|
+
return "Portal";
|
|
99
|
+
case k:
|
|
100
|
+
return (a.displayName || "Context") + ".Provider";
|
|
101
|
+
case v:
|
|
102
|
+
return (a._context.displayName || "Context") + ".Consumer";
|
|
103
|
+
case O:
|
|
104
|
+
var T = a.render;
|
|
105
|
+
return a = a.displayName, a || (a = T.displayName || T.name || "", a = a !== "" ? "ForwardRef(" + a + ")" : "ForwardRef"), a;
|
|
106
|
+
case L:
|
|
107
|
+
return T = a.displayName || null, T !== null ? T : n(a.type) || "Memo";
|
|
108
|
+
case i:
|
|
109
|
+
T = a._payload, a = a._init;
|
|
110
|
+
try {
|
|
111
|
+
return n(a(T));
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
function e(a) {
|
|
118
|
+
return "" + a;
|
|
119
|
+
}
|
|
120
|
+
function t(a) {
|
|
121
|
+
try {
|
|
122
|
+
e(a);
|
|
123
|
+
var T = !1;
|
|
124
|
+
} catch {
|
|
125
|
+
T = !0;
|
|
126
|
+
}
|
|
127
|
+
if (T) {
|
|
128
|
+
T = console;
|
|
129
|
+
var _ = T.error, S = typeof Symbol == "function" && Symbol.toStringTag && a[Symbol.toStringTag] || a.constructor.name || "Object";
|
|
130
|
+
return _.call(
|
|
131
|
+
T,
|
|
132
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
133
|
+
S
|
|
134
|
+
), e(a);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function r(a) {
|
|
138
|
+
if (a === g) return "<>";
|
|
139
|
+
if (typeof a == "object" && a !== null && a.$$typeof === i)
|
|
140
|
+
return "<...>";
|
|
141
|
+
try {
|
|
142
|
+
var T = n(a);
|
|
143
|
+
return T ? "<" + T + ">" : "<...>";
|
|
144
|
+
} catch {
|
|
145
|
+
return "<...>";
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function o() {
|
|
149
|
+
var a = c.A;
|
|
150
|
+
return a === null ? null : a.getOwner();
|
|
151
|
+
}
|
|
152
|
+
function u() {
|
|
153
|
+
return Error("react-stack-top-frame");
|
|
154
|
+
}
|
|
155
|
+
function d(a) {
|
|
156
|
+
if (b.call(a, "key")) {
|
|
157
|
+
var T = Object.getOwnPropertyDescriptor(a, "key").get;
|
|
158
|
+
if (T && T.isReactWarning) return !1;
|
|
159
|
+
}
|
|
160
|
+
return a.key !== void 0;
|
|
161
|
+
}
|
|
162
|
+
function f(a, T) {
|
|
163
|
+
function _() {
|
|
164
|
+
M || (M = !0, console.error(
|
|
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
|
+
T
|
|
167
|
+
));
|
|
168
|
+
}
|
|
169
|
+
_.isReactWarning = !0, Object.defineProperty(a, "key", {
|
|
170
|
+
get: _,
|
|
171
|
+
configurable: !0
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
function p() {
|
|
175
|
+
var a = n(this.type);
|
|
176
|
+
return N[a] || (N[a] = !0, console.error(
|
|
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
|
+
)), a = this.props.ref, a !== void 0 ? a : null;
|
|
179
|
+
}
|
|
180
|
+
function y(a, T, _, S, q, $, B, K) {
|
|
181
|
+
return _ = $.ref, a = {
|
|
182
|
+
$$typeof: E,
|
|
183
|
+
type: a,
|
|
184
|
+
key: T,
|
|
185
|
+
props: $,
|
|
186
|
+
_owner: q
|
|
187
|
+
}, (_ !== void 0 ? _ : null) !== null ? Object.defineProperty(a, "ref", {
|
|
188
|
+
enumerable: !1,
|
|
189
|
+
get: p
|
|
190
|
+
}) : Object.defineProperty(a, "ref", { enumerable: !1, value: null }), a._store = {}, Object.defineProperty(a._store, "validated", {
|
|
191
|
+
configurable: !1,
|
|
192
|
+
enumerable: !1,
|
|
193
|
+
writable: !0,
|
|
194
|
+
value: 0
|
|
195
|
+
}), Object.defineProperty(a, "_debugInfo", {
|
|
196
|
+
configurable: !1,
|
|
197
|
+
enumerable: !1,
|
|
198
|
+
writable: !0,
|
|
199
|
+
value: null
|
|
200
|
+
}), Object.defineProperty(a, "_debugStack", {
|
|
201
|
+
configurable: !1,
|
|
202
|
+
enumerable: !1,
|
|
203
|
+
writable: !0,
|
|
204
|
+
value: B
|
|
205
|
+
}), Object.defineProperty(a, "_debugTask", {
|
|
206
|
+
configurable: !1,
|
|
207
|
+
enumerable: !1,
|
|
208
|
+
writable: !0,
|
|
209
|
+
value: K
|
|
210
|
+
}), Object.freeze && (Object.freeze(a.props), Object.freeze(a)), a;
|
|
211
|
+
}
|
|
212
|
+
function m(a, T, _, S, q, $, B, K) {
|
|
213
|
+
var j = T.children;
|
|
214
|
+
if (j !== void 0)
|
|
215
|
+
if (S)
|
|
216
|
+
if (D(j)) {
|
|
217
|
+
for (S = 0; S < j.length; S++)
|
|
218
|
+
A(j[S]);
|
|
219
|
+
Object.freeze && Object.freeze(j);
|
|
220
|
+
} else
|
|
221
|
+
console.error(
|
|
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
|
+
);
|
|
224
|
+
else A(j);
|
|
225
|
+
if (b.call(T, "key")) {
|
|
226
|
+
j = n(a);
|
|
227
|
+
var Y = Object.keys(T).filter(function(Ae) {
|
|
228
|
+
return Ae !== "key";
|
|
229
|
+
});
|
|
230
|
+
S = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ne[j + S] || (Y = 0 < Y.length ? "{" + Y.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
231
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
232
|
+
let props = %s;
|
|
233
|
+
<%s {...props} />
|
|
234
|
+
React keys must be passed directly to JSX without using spread:
|
|
235
|
+
let props = %s;
|
|
236
|
+
<%s key={someKey} {...props} />`,
|
|
237
|
+
S,
|
|
238
|
+
j,
|
|
239
|
+
Y,
|
|
240
|
+
j
|
|
241
|
+
), ne[j + S] = !0);
|
|
242
|
+
}
|
|
243
|
+
if (j = null, _ !== void 0 && (t(_), j = "" + _), d(T) && (t(T.key), j = "" + T.key), "key" in T) {
|
|
244
|
+
_ = {};
|
|
245
|
+
for (var le in T)
|
|
246
|
+
le !== "key" && (_[le] = T[le]);
|
|
247
|
+
} else _ = T;
|
|
248
|
+
return j && f(
|
|
249
|
+
_,
|
|
250
|
+
typeof a == "function" ? a.displayName || a.name || "Unknown" : a
|
|
251
|
+
), y(
|
|
252
|
+
a,
|
|
253
|
+
j,
|
|
254
|
+
$,
|
|
255
|
+
q,
|
|
256
|
+
o(),
|
|
257
|
+
_,
|
|
258
|
+
B,
|
|
259
|
+
K
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
function A(a) {
|
|
263
|
+
typeof a == "object" && a !== null && a.$$typeof === E && a._store && (a._store.validated = 1);
|
|
264
|
+
}
|
|
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
|
+
return null;
|
|
267
|
+
};
|
|
268
|
+
w = {
|
|
269
|
+
react_stack_bottom_frame: function(a) {
|
|
270
|
+
return a();
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
var M, N = {}, H = w.react_stack_bottom_frame.bind(
|
|
274
|
+
w,
|
|
275
|
+
u
|
|
276
|
+
)(), J = x(r(u)), ne = {};
|
|
277
|
+
G.Fragment = g, G.jsx = function(a, T, _, S, q) {
|
|
278
|
+
var $ = 1e4 > c.recentlyCreatedOwnerStacks++;
|
|
279
|
+
return m(
|
|
280
|
+
a,
|
|
281
|
+
T,
|
|
282
|
+
_,
|
|
283
|
+
!1,
|
|
284
|
+
S,
|
|
285
|
+
q,
|
|
286
|
+
$ ? Error("react-stack-top-frame") : H,
|
|
287
|
+
$ ? x(r(a)) : J
|
|
288
|
+
);
|
|
289
|
+
}, G.jsxs = function(a, T, _, S, q) {
|
|
290
|
+
var $ = 1e4 > c.recentlyCreatedOwnerStacks++;
|
|
291
|
+
return m(
|
|
292
|
+
a,
|
|
293
|
+
T,
|
|
294
|
+
_,
|
|
295
|
+
!0,
|
|
296
|
+
S,
|
|
297
|
+
q,
|
|
298
|
+
$ ? Error("react-stack-top-frame") : H,
|
|
299
|
+
$ ? x(r(a)) : J
|
|
300
|
+
);
|
|
301
|
+
};
|
|
302
|
+
}()), G;
|
|
303
|
+
}
|
|
304
|
+
var pe;
|
|
305
|
+
function Ie() {
|
|
306
|
+
return pe || (pe = 1, process.env.NODE_ENV === "production" ? re.exports = je() : re.exports = Ne()), re.exports;
|
|
307
|
+
}
|
|
308
|
+
var F = Ie();
|
|
309
|
+
const se = Ee(null), Fe = "https://api.kelet.ai/api", pt = () => {
|
|
310
|
+
const n = ae(se);
|
|
311
|
+
if (!n)
|
|
312
|
+
throw new Error("useKelet must be used within a KeletProvider");
|
|
313
|
+
return n;
|
|
314
|
+
}, Pe = () => {
|
|
315
|
+
const n = ae(se);
|
|
316
|
+
return n ? n.feedback : async () => {
|
|
317
|
+
};
|
|
318
|
+
}, ht = ({ apiKey: n, project: e, children: t }) => {
|
|
319
|
+
const r = ae(se), o = n || r?.api_key;
|
|
320
|
+
if (!o)
|
|
321
|
+
throw new Error(
|
|
322
|
+
"apiKey is required either directly or from a parent KeletProvider"
|
|
323
|
+
);
|
|
324
|
+
const d = {
|
|
325
|
+
api_key: o,
|
|
326
|
+
project: e,
|
|
327
|
+
feedback: async (f) => {
|
|
328
|
+
const p = `${Fe}/projects/${e}/feedback`, y = {
|
|
329
|
+
tx_id: f.tx_id,
|
|
330
|
+
source: f.source || "EXPLICIT",
|
|
331
|
+
vote: f.vote,
|
|
332
|
+
explanation: f.explanation,
|
|
333
|
+
correction: f.correction,
|
|
334
|
+
selection: f.selection
|
|
335
|
+
// Include trigger_name if needed in the future
|
|
336
|
+
}, m = await fetch(p, {
|
|
337
|
+
method: "POST",
|
|
338
|
+
headers: {
|
|
339
|
+
"Content-Type": "application/json",
|
|
340
|
+
Authorization: `Bearer ${o}`
|
|
341
|
+
},
|
|
342
|
+
body: JSON.stringify(y)
|
|
343
|
+
});
|
|
344
|
+
if (!m.ok)
|
|
345
|
+
throw new Error(`Failed to submit feedback: ${m.statusText}`);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
return /* @__PURE__ */ F.jsx(se.Provider, { value: d, children: t });
|
|
349
|
+
}, ee = (n, e) => {
|
|
350
|
+
const t = { ...e };
|
|
351
|
+
for (const r in e) {
|
|
352
|
+
const o = n[r], u = e[r];
|
|
353
|
+
/^on[A-Z]/.test(r) ? o && u ? t[r] = (...f) => {
|
|
354
|
+
u(...f), o(...f);
|
|
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
|
+
}
|
|
357
|
+
return { ...n, ...t };
|
|
358
|
+
}, xe = Ee(
|
|
359
|
+
null
|
|
360
|
+
), te = () => {
|
|
361
|
+
const n = ae(xe);
|
|
362
|
+
if (!n)
|
|
363
|
+
throw new Error(
|
|
364
|
+
"VoteFeedback components must be used within VoteFeedback.Root"
|
|
365
|
+
);
|
|
366
|
+
return n;
|
|
367
|
+
}, Le = ({
|
|
368
|
+
children: n,
|
|
369
|
+
onFeedback: e,
|
|
370
|
+
defaultText: t = "",
|
|
371
|
+
tx_id: r,
|
|
372
|
+
extra_metadata: o,
|
|
373
|
+
trigger_name: u
|
|
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 = 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 () => {
|
|
380
|
+
h("upvote");
|
|
381
|
+
const c = {
|
|
382
|
+
tx_id: d,
|
|
383
|
+
vote: "upvote",
|
|
384
|
+
...o && { extra_metadata: o },
|
|
385
|
+
...u && { trigger_name: u }
|
|
386
|
+
};
|
|
387
|
+
try {
|
|
388
|
+
w(!0), await O(c);
|
|
389
|
+
} finally {
|
|
390
|
+
w(!1);
|
|
391
|
+
}
|
|
392
|
+
}, [O, d, o, u]), I = W(async () => {
|
|
393
|
+
if (h("downvote"), O) {
|
|
394
|
+
const c = {
|
|
395
|
+
tx_id: d,
|
|
396
|
+
vote: "downvote",
|
|
397
|
+
...o && { extra_metadata: o },
|
|
398
|
+
...u && { trigger_name: u }
|
|
399
|
+
};
|
|
400
|
+
try {
|
|
401
|
+
w(!0), await O(c);
|
|
402
|
+
} finally {
|
|
403
|
+
w(!1);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
p(!0), setTimeout(() => {
|
|
407
|
+
g.current?.focus();
|
|
408
|
+
const c = document.createElement("div");
|
|
409
|
+
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);
|
|
410
|
+
}, 0);
|
|
411
|
+
}, [O, d, o, u]), L = W(
|
|
412
|
+
(c) => {
|
|
413
|
+
m(c.target.value);
|
|
414
|
+
},
|
|
415
|
+
[]
|
|
416
|
+
), i = W(async () => {
|
|
417
|
+
const c = y.trim().length > 0;
|
|
418
|
+
if (c) {
|
|
419
|
+
const b = {
|
|
420
|
+
tx_id: d,
|
|
421
|
+
vote: "downvote",
|
|
422
|
+
explanation: y,
|
|
423
|
+
...o && { extra_metadata: o },
|
|
424
|
+
...u && { trigger_name: u }
|
|
425
|
+
};
|
|
426
|
+
try {
|
|
427
|
+
w(!0), await O(b);
|
|
428
|
+
} finally {
|
|
429
|
+
w(!1);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (p(!1), m(t), C.current?.focus(), c) {
|
|
433
|
+
const b = document.createElement("div");
|
|
434
|
+
b.setAttribute("aria-live", "polite"), b.className = "sr-only", b.textContent = "Feedback submitted successfully.", document.body.appendChild(b), setTimeout(() => document.body.removeChild(b), 1e3);
|
|
435
|
+
}
|
|
436
|
+
}, [O, y, t, d, o, u]), l = W(
|
|
437
|
+
(c) => {
|
|
438
|
+
if (c.key === "Escape")
|
|
439
|
+
p(!1), m(t), C.current?.focus();
|
|
440
|
+
else if ((c.metaKey || c.ctrlKey) && c.key === "Enter")
|
|
441
|
+
c.preventDefault(), i().then((b) => {
|
|
442
|
+
});
|
|
443
|
+
else if (c.key === "Tab" && f) {
|
|
444
|
+
const b = document.getElementById(P);
|
|
445
|
+
if (b) {
|
|
446
|
+
const D = b.querySelectorAll(
|
|
447
|
+
'button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'
|
|
448
|
+
), x = D[0], M = D[D.length - 1];
|
|
449
|
+
c.shiftKey && document.activeElement === x ? (c.preventDefault(), M?.focus()) : !c.shiftKey && document.activeElement === M && (c.preventDefault(), x?.focus());
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
},
|
|
453
|
+
[i, f, P, t]
|
|
454
|
+
), s = {
|
|
455
|
+
onFeedback: O,
|
|
456
|
+
showPopover: f,
|
|
457
|
+
setShowPopover: p,
|
|
458
|
+
feedbackText: y,
|
|
459
|
+
setFeedbackText: m,
|
|
460
|
+
isSubmitting: A,
|
|
461
|
+
setIsSubmitting: w,
|
|
462
|
+
vote: E,
|
|
463
|
+
handleUpvote: R,
|
|
464
|
+
handleDownvote: I,
|
|
465
|
+
handleTextareaChange: L,
|
|
466
|
+
handleSubmit: i,
|
|
467
|
+
handleKeyDown: l,
|
|
468
|
+
textareaRef: g,
|
|
469
|
+
triggerRef: C,
|
|
470
|
+
popoverId: P,
|
|
471
|
+
triggerId: v,
|
|
472
|
+
tx_id: d,
|
|
473
|
+
extra_metadata: o,
|
|
474
|
+
trigger_name: u
|
|
475
|
+
};
|
|
476
|
+
return /* @__PURE__ */ F.jsx(xe.Provider, { value: s, children: n });
|
|
477
|
+
}, Me = ({
|
|
478
|
+
asChild: n,
|
|
479
|
+
children: e,
|
|
480
|
+
onClick: t,
|
|
481
|
+
...r
|
|
482
|
+
}) => {
|
|
483
|
+
const { handleUpvote: o, isSubmitting: u, vote: d } = te(), f = W(
|
|
484
|
+
(m) => {
|
|
485
|
+
o(), t?.(m);
|
|
486
|
+
},
|
|
487
|
+
[o, t]
|
|
488
|
+
), p = {
|
|
489
|
+
...r,
|
|
490
|
+
onClick: f,
|
|
491
|
+
disabled: u || r.disabled,
|
|
492
|
+
"aria-label": r["aria-label"] || "Upvote feedback",
|
|
493
|
+
type: "button"
|
|
494
|
+
}, y = d === "upvote";
|
|
495
|
+
if (n) {
|
|
496
|
+
const m = typeof e == "function" ? e({ isSelected: y }) : e;
|
|
497
|
+
if (Z(m))
|
|
498
|
+
return Q(
|
|
499
|
+
m,
|
|
500
|
+
ee(p, m.props)
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
return /* @__PURE__ */ F.jsx("button", { ...p, children: typeof e == "function" ? e({ isSelected: y }) : e });
|
|
504
|
+
}, $e = ({
|
|
505
|
+
asChild: n,
|
|
506
|
+
children: e,
|
|
507
|
+
onClick: t,
|
|
508
|
+
...r
|
|
509
|
+
}) => {
|
|
510
|
+
const {
|
|
511
|
+
handleDownvote: o,
|
|
512
|
+
showPopover: u,
|
|
513
|
+
isSubmitting: d,
|
|
514
|
+
popoverId: f,
|
|
515
|
+
triggerId: p,
|
|
516
|
+
triggerRef: y,
|
|
517
|
+
vote: m
|
|
518
|
+
} = te(), A = W(
|
|
519
|
+
(h) => {
|
|
520
|
+
o(), t?.(h);
|
|
521
|
+
},
|
|
522
|
+
[o, t]
|
|
523
|
+
), w = {
|
|
524
|
+
...r,
|
|
525
|
+
ref: y,
|
|
526
|
+
onClick: A,
|
|
527
|
+
disabled: d || r.disabled,
|
|
528
|
+
"aria-label": r["aria-label"] || "Downvote feedback",
|
|
529
|
+
"aria-expanded": u,
|
|
530
|
+
"aria-controls": f,
|
|
531
|
+
id: p,
|
|
532
|
+
type: "button"
|
|
533
|
+
}, E = m === "downvote";
|
|
534
|
+
if (n) {
|
|
535
|
+
const h = typeof e == "function" ? e({ isSelected: E }) : e;
|
|
536
|
+
if (Z(h))
|
|
537
|
+
return Q(h, ee(w, h.props));
|
|
538
|
+
if (h)
|
|
539
|
+
return h;
|
|
540
|
+
}
|
|
541
|
+
return /* @__PURE__ */ F.jsx("button", { ...w, children: typeof e == "function" ? e({ isSelected: E }) : e });
|
|
542
|
+
}, qe = ({ asChild: n, children: e, ...t }) => {
|
|
543
|
+
const { showPopover: r, handleKeyDown: o, popoverId: u, triggerId: d } = te();
|
|
544
|
+
if (!r)
|
|
545
|
+
return null;
|
|
546
|
+
const f = {
|
|
547
|
+
...t,
|
|
548
|
+
role: "dialog",
|
|
549
|
+
"aria-labelledby": d,
|
|
550
|
+
"aria-modal": !0,
|
|
551
|
+
"aria-describedby": `${u}-description`,
|
|
552
|
+
id: u,
|
|
553
|
+
onKeyDown: o,
|
|
554
|
+
tabIndex: -1
|
|
555
|
+
};
|
|
556
|
+
return n && Z(e) ? /* @__PURE__ */ F.jsxs(F.Fragment, { children: [
|
|
557
|
+
Q(
|
|
558
|
+
e,
|
|
559
|
+
ee(f, e.props)
|
|
560
|
+
),
|
|
561
|
+
/* @__PURE__ */ F.jsx("div", { id: `${u}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
|
|
562
|
+
] }) : /* @__PURE__ */ F.jsxs("div", { ...f, children: [
|
|
563
|
+
/* @__PURE__ */ F.jsx("div", { id: `${u}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
|
|
564
|
+
e
|
|
565
|
+
] });
|
|
566
|
+
}, We = ({ asChild: n, value: e, onChange: t, ...r }) => {
|
|
567
|
+
const {
|
|
568
|
+
feedbackText: o,
|
|
569
|
+
handleTextareaChange: u,
|
|
570
|
+
textareaRef: d,
|
|
571
|
+
handleKeyDown: f,
|
|
572
|
+
popoverId: p
|
|
573
|
+
} = te(), y = {
|
|
574
|
+
...r,
|
|
575
|
+
ref: d,
|
|
576
|
+
value: e !== void 0 ? e : o,
|
|
577
|
+
onChange: t || u,
|
|
578
|
+
onKeyDown: f,
|
|
579
|
+
placeholder: r.placeholder || "What did we miss?",
|
|
580
|
+
"aria-label": r["aria-label"] || "Additional feedback",
|
|
581
|
+
"aria-describedby": `${p}-help`,
|
|
582
|
+
rows: r.rows || 3
|
|
583
|
+
};
|
|
584
|
+
return n && Z(r.children) ? Q(
|
|
585
|
+
r.children,
|
|
586
|
+
ee(y, r.children.props)
|
|
587
|
+
) : /* @__PURE__ */ F.jsx("textarea", { ...y });
|
|
588
|
+
}, Ye = ({
|
|
589
|
+
asChild: n,
|
|
590
|
+
children: e,
|
|
591
|
+
onClick: t,
|
|
592
|
+
...r
|
|
593
|
+
}) => {
|
|
594
|
+
const { handleSubmit: o, isSubmitting: u, feedbackText: d } = te(), f = W(
|
|
595
|
+
(A) => {
|
|
596
|
+
o(), t?.(A);
|
|
597
|
+
},
|
|
598
|
+
[o, t]
|
|
599
|
+
), p = d.trim().length > 0, y = p ? "Submit feedback" : "Close without feedback", m = {
|
|
600
|
+
...r,
|
|
601
|
+
onClick: f,
|
|
602
|
+
disabled: u || r.disabled,
|
|
603
|
+
type: "button",
|
|
604
|
+
"aria-label": r["aria-label"] || y,
|
|
605
|
+
"aria-describedby": p ? void 0 : "submit-help"
|
|
606
|
+
};
|
|
607
|
+
return n && Z(e) ? /* @__PURE__ */ F.jsxs(F.Fragment, { children: [
|
|
608
|
+
Q(
|
|
609
|
+
e,
|
|
610
|
+
ee(m, e.props)
|
|
611
|
+
),
|
|
612
|
+
!p && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
|
|
613
|
+
] }) : /* @__PURE__ */ F.jsxs("button", { ...m, children: [
|
|
614
|
+
e,
|
|
615
|
+
!p && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
|
|
616
|
+
] });
|
|
617
|
+
}, mt = {
|
|
618
|
+
Root: Le,
|
|
619
|
+
UpvoteButton: Me,
|
|
620
|
+
DownvoteButton: $e,
|
|
621
|
+
Popover: qe,
|
|
622
|
+
Textarea: We,
|
|
623
|
+
SubmitButton: Ye
|
|
624
|
+
};
|
|
625
|
+
var ie = { exports: {} }, ze = ie.exports, he;
|
|
626
|
+
function Ke() {
|
|
627
|
+
return he || (he = 1, function(n, e) {
|
|
628
|
+
(function(t, r) {
|
|
629
|
+
var o = r(t);
|
|
630
|
+
n.exports = o;
|
|
631
|
+
})(ze, function(t) {
|
|
632
|
+
var r = ["N", "E", "A", "D"];
|
|
633
|
+
function o(i, l) {
|
|
634
|
+
i.super_ = l, i.prototype = Object.create(l.prototype, {
|
|
635
|
+
constructor: {
|
|
636
|
+
value: i,
|
|
637
|
+
enumerable: !1,
|
|
638
|
+
writable: !0,
|
|
639
|
+
configurable: !0
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
}
|
|
643
|
+
function u(i, l) {
|
|
644
|
+
Object.defineProperty(this, "kind", {
|
|
645
|
+
value: i,
|
|
646
|
+
enumerable: !0
|
|
647
|
+
}), l && l.length && Object.defineProperty(this, "path", {
|
|
648
|
+
value: l,
|
|
649
|
+
enumerable: !0
|
|
650
|
+
});
|
|
651
|
+
}
|
|
652
|
+
function d(i, l, s) {
|
|
653
|
+
d.super_.call(this, "E", i), Object.defineProperty(this, "lhs", {
|
|
654
|
+
value: l,
|
|
655
|
+
enumerable: !0
|
|
656
|
+
}), Object.defineProperty(this, "rhs", {
|
|
657
|
+
value: s,
|
|
658
|
+
enumerable: !0
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
o(d, u);
|
|
662
|
+
function f(i, l) {
|
|
663
|
+
f.super_.call(this, "N", i), Object.defineProperty(this, "rhs", {
|
|
664
|
+
value: l,
|
|
665
|
+
enumerable: !0
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
o(f, u);
|
|
669
|
+
function p(i, l) {
|
|
670
|
+
p.super_.call(this, "D", i), Object.defineProperty(this, "lhs", {
|
|
671
|
+
value: l,
|
|
672
|
+
enumerable: !0
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
o(p, u);
|
|
676
|
+
function y(i, l, s) {
|
|
677
|
+
y.super_.call(this, "A", i), Object.defineProperty(this, "index", {
|
|
678
|
+
value: l,
|
|
679
|
+
enumerable: !0
|
|
680
|
+
}), Object.defineProperty(this, "item", {
|
|
681
|
+
value: s,
|
|
682
|
+
enumerable: !0
|
|
683
|
+
});
|
|
684
|
+
}
|
|
685
|
+
o(y, u);
|
|
686
|
+
function m(i, l, s) {
|
|
687
|
+
var c = i.slice(l + 1 || i.length);
|
|
688
|
+
return i.length = l < 0 ? i.length + l : l, i.push.apply(i, c), i;
|
|
689
|
+
}
|
|
690
|
+
function A(i) {
|
|
691
|
+
var l = typeof i;
|
|
692
|
+
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";
|
|
693
|
+
}
|
|
694
|
+
function w(i) {
|
|
695
|
+
var l = 0;
|
|
696
|
+
if (i.length === 0)
|
|
697
|
+
return l;
|
|
698
|
+
for (var s = 0; s < i.length; s++) {
|
|
699
|
+
var c = i.charCodeAt(s);
|
|
700
|
+
l = (l << 5) - l + c, l = l & l;
|
|
701
|
+
}
|
|
702
|
+
return l;
|
|
703
|
+
}
|
|
704
|
+
function E(i) {
|
|
705
|
+
var l = 0, s = A(i);
|
|
706
|
+
if (s === "array") {
|
|
707
|
+
i.forEach(function(M) {
|
|
708
|
+
l += E(M);
|
|
709
|
+
});
|
|
710
|
+
var c = "[type: array, hash: " + l + "]";
|
|
711
|
+
return l + w(c);
|
|
712
|
+
}
|
|
713
|
+
if (s === "object") {
|
|
714
|
+
for (var b in i)
|
|
715
|
+
if (i.hasOwnProperty(b)) {
|
|
716
|
+
var D = "[ type: object, key: " + b + ", value hash: " + E(i[b]) + "]";
|
|
717
|
+
l += w(D);
|
|
718
|
+
}
|
|
719
|
+
return l;
|
|
720
|
+
}
|
|
721
|
+
var x = "[ type: " + s + " ; value: " + i + "]";
|
|
722
|
+
return l + w(x);
|
|
723
|
+
}
|
|
724
|
+
function h(i, l, s, c, b, D, x, M) {
|
|
725
|
+
s = s || [], b = b || [], x = x || [];
|
|
726
|
+
var N = b.slice(0);
|
|
727
|
+
if (typeof D < "u" && D !== null) {
|
|
728
|
+
if (c) {
|
|
729
|
+
if (typeof c == "function" && c(N, D))
|
|
730
|
+
return;
|
|
731
|
+
if (typeof c == "object") {
|
|
732
|
+
if (c.prefilter && c.prefilter(N, D))
|
|
733
|
+
return;
|
|
734
|
+
if (c.normalize) {
|
|
735
|
+
var H = c.normalize(N, D, i, l);
|
|
736
|
+
H && (i = H[0], l = H[1]);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
N.push(D);
|
|
741
|
+
}
|
|
742
|
+
A(i) === "regexp" && A(l) === "regexp" && (i = i.toString(), l = l.toString());
|
|
743
|
+
var J = typeof i, ne = typeof l, a, T, _, S, q = J !== "undefined" || x && x.length > 0 && x[x.length - 1].lhs && Object.getOwnPropertyDescriptor(x[x.length - 1].lhs, D), $ = ne !== "undefined" || x && x.length > 0 && x[x.length - 1].rhs && Object.getOwnPropertyDescriptor(x[x.length - 1].rhs, D);
|
|
744
|
+
if (!q && $)
|
|
745
|
+
s.push(new f(N, l));
|
|
746
|
+
else if (!$ && q)
|
|
747
|
+
s.push(new p(N, i));
|
|
748
|
+
else if (A(i) !== A(l))
|
|
749
|
+
s.push(new d(N, i, l));
|
|
750
|
+
else if (A(i) === "date" && i - l !== 0)
|
|
751
|
+
s.push(new d(N, i, l));
|
|
752
|
+
else if (J === "object" && i !== null && l !== null) {
|
|
753
|
+
for (a = x.length - 1; a > -1; --a)
|
|
754
|
+
if (x[a].lhs === i) {
|
|
755
|
+
S = !0;
|
|
756
|
+
break;
|
|
757
|
+
}
|
|
758
|
+
if (S)
|
|
759
|
+
i !== l && s.push(new d(N, i, l));
|
|
760
|
+
else {
|
|
761
|
+
if (x.push({ lhs: i, rhs: l }), Array.isArray(i)) {
|
|
762
|
+
for (M && (i.sort(function(j, Y) {
|
|
763
|
+
return E(j) - E(Y);
|
|
764
|
+
}), l.sort(function(j, Y) {
|
|
765
|
+
return E(j) - E(Y);
|
|
766
|
+
})), a = l.length - 1, T = i.length - 1; a > T; )
|
|
767
|
+
s.push(new y(N, a, new f(void 0, l[a--])));
|
|
768
|
+
for (; T > a; )
|
|
769
|
+
s.push(new y(N, T, new p(void 0, i[T--])));
|
|
770
|
+
for (; a >= 0; --a)
|
|
771
|
+
h(i[a], l[a], s, c, N, a, x, M);
|
|
772
|
+
} else {
|
|
773
|
+
var B = Object.keys(i), K = Object.keys(l);
|
|
774
|
+
for (a = 0; a < B.length; ++a)
|
|
775
|
+
_ = B[a], S = K.indexOf(_), S >= 0 ? (h(i[_], l[_], s, c, N, _, x, M), K[S] = null) : h(i[_], void 0, s, c, N, _, x, M);
|
|
776
|
+
for (a = 0; a < K.length; ++a)
|
|
777
|
+
_ = K[a], _ && h(void 0, l[_], s, c, N, _, x, M);
|
|
778
|
+
}
|
|
779
|
+
x.length = x.length - 1;
|
|
780
|
+
}
|
|
781
|
+
} else i !== l && (J === "number" && isNaN(i) && isNaN(l) || s.push(new d(N, i, l)));
|
|
782
|
+
}
|
|
783
|
+
function g(i, l, s, c, b) {
|
|
784
|
+
var D = [];
|
|
785
|
+
if (h(i, l, D, c, null, null, null, b), s)
|
|
786
|
+
for (var x = 0; x < D.length; ++x)
|
|
787
|
+
s(D[x]);
|
|
788
|
+
return D;
|
|
789
|
+
}
|
|
790
|
+
function C(i, l, s, c, b, D, x) {
|
|
791
|
+
return h(i, l, s, c, b, D, x, !0);
|
|
792
|
+
}
|
|
793
|
+
function P(i, l, s, c) {
|
|
794
|
+
var b = c ? function(x) {
|
|
795
|
+
x && c.push(x);
|
|
796
|
+
} : void 0, D = g(i, l, b, s);
|
|
797
|
+
return c || (D.length ? D : void 0);
|
|
798
|
+
}
|
|
799
|
+
function v(i, l, s, c) {
|
|
800
|
+
var b = c ? function(x) {
|
|
801
|
+
x && c.push(x);
|
|
802
|
+
} : void 0, D = g(i, l, b, s, !0);
|
|
803
|
+
return c || (D.length ? D : void 0);
|
|
804
|
+
}
|
|
805
|
+
function k(i, l, s) {
|
|
806
|
+
if (s.path && s.path.length) {
|
|
807
|
+
var c = i[l], b, D = s.path.length - 1;
|
|
808
|
+
for (b = 0; b < D; b++)
|
|
809
|
+
c = c[s.path[b]];
|
|
810
|
+
switch (s.kind) {
|
|
811
|
+
case "A":
|
|
812
|
+
k(c[s.path[b]], s.index, s.item);
|
|
813
|
+
break;
|
|
814
|
+
case "D":
|
|
815
|
+
delete c[s.path[b]];
|
|
816
|
+
break;
|
|
817
|
+
case "E":
|
|
818
|
+
case "N":
|
|
819
|
+
c[s.path[b]] = s.rhs;
|
|
820
|
+
break;
|
|
821
|
+
}
|
|
822
|
+
} else
|
|
823
|
+
switch (s.kind) {
|
|
824
|
+
case "A":
|
|
825
|
+
k(i[l], s.index, s.item);
|
|
826
|
+
break;
|
|
827
|
+
case "D":
|
|
828
|
+
i = m(i, l);
|
|
829
|
+
break;
|
|
830
|
+
case "E":
|
|
831
|
+
case "N":
|
|
832
|
+
i[l] = s.rhs;
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
return i;
|
|
836
|
+
}
|
|
837
|
+
function O(i, l, s) {
|
|
838
|
+
if (typeof s > "u" && l && ~r.indexOf(l.kind) && (s = l), i && s && s.kind) {
|
|
839
|
+
for (var c = i, b = -1, D = s.path ? s.path.length - 1 : 0; ++b < D; )
|
|
840
|
+
typeof c[s.path[b]] > "u" && (c[s.path[b]] = typeof s.path[b + 1] < "u" && typeof s.path[b + 1] == "number" ? [] : {}), c = c[s.path[b]];
|
|
841
|
+
switch (s.kind) {
|
|
842
|
+
case "A":
|
|
843
|
+
s.path && typeof c[s.path[b]] > "u" && (c[s.path[b]] = []), k(s.path ? c[s.path[b]] : c, s.index, s.item);
|
|
844
|
+
break;
|
|
845
|
+
case "D":
|
|
846
|
+
delete c[s.path[b]];
|
|
847
|
+
break;
|
|
848
|
+
case "E":
|
|
849
|
+
case "N":
|
|
850
|
+
c[s.path[b]] = s.rhs;
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
function R(i, l, s) {
|
|
856
|
+
if (s.path && s.path.length) {
|
|
857
|
+
var c = i[l], b, D = s.path.length - 1;
|
|
858
|
+
for (b = 0; b < D; b++)
|
|
859
|
+
c = c[s.path[b]];
|
|
860
|
+
switch (s.kind) {
|
|
861
|
+
case "A":
|
|
862
|
+
R(c[s.path[b]], s.index, s.item);
|
|
863
|
+
break;
|
|
864
|
+
case "D":
|
|
865
|
+
c[s.path[b]] = s.lhs;
|
|
866
|
+
break;
|
|
867
|
+
case "E":
|
|
868
|
+
c[s.path[b]] = s.lhs;
|
|
869
|
+
break;
|
|
870
|
+
case "N":
|
|
871
|
+
delete c[s.path[b]];
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
} else
|
|
875
|
+
switch (s.kind) {
|
|
876
|
+
case "A":
|
|
877
|
+
R(i[l], s.index, s.item);
|
|
878
|
+
break;
|
|
879
|
+
case "D":
|
|
880
|
+
i[l] = s.lhs;
|
|
881
|
+
break;
|
|
882
|
+
case "E":
|
|
883
|
+
i[l] = s.lhs;
|
|
884
|
+
break;
|
|
885
|
+
case "N":
|
|
886
|
+
i = m(i, l);
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
return i;
|
|
890
|
+
}
|
|
891
|
+
function I(i, l, s) {
|
|
892
|
+
if (i && l && s && s.kind) {
|
|
893
|
+
var c = i, b, D;
|
|
894
|
+
for (D = s.path.length - 1, b = 0; b < D; b++)
|
|
895
|
+
typeof c[s.path[b]] > "u" && (c[s.path[b]] = {}), c = c[s.path[b]];
|
|
896
|
+
switch (s.kind) {
|
|
897
|
+
case "A":
|
|
898
|
+
R(c[s.path[b]], s.index, s.item);
|
|
899
|
+
break;
|
|
900
|
+
case "D":
|
|
901
|
+
c[s.path[b]] = s.lhs;
|
|
902
|
+
break;
|
|
903
|
+
case "E":
|
|
904
|
+
c[s.path[b]] = s.lhs;
|
|
905
|
+
break;
|
|
906
|
+
case "N":
|
|
907
|
+
delete c[s.path[b]];
|
|
908
|
+
break;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
function L(i, l, s) {
|
|
913
|
+
if (i && l) {
|
|
914
|
+
var c = function(b) {
|
|
915
|
+
(!s || s(i, l, b)) && O(i, l, b);
|
|
916
|
+
};
|
|
917
|
+
g(i, l, c);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return Object.defineProperties(P, {
|
|
921
|
+
diff: {
|
|
922
|
+
value: P,
|
|
923
|
+
enumerable: !0
|
|
924
|
+
},
|
|
925
|
+
orderIndependentDiff: {
|
|
926
|
+
value: v,
|
|
927
|
+
enumerable: !0
|
|
928
|
+
},
|
|
929
|
+
observableDiff: {
|
|
930
|
+
value: g,
|
|
931
|
+
enumerable: !0
|
|
932
|
+
},
|
|
933
|
+
orderIndependentObservableDiff: {
|
|
934
|
+
value: C,
|
|
935
|
+
enumerable: !0
|
|
936
|
+
},
|
|
937
|
+
orderIndepHash: {
|
|
938
|
+
value: E,
|
|
939
|
+
enumerable: !0
|
|
940
|
+
},
|
|
941
|
+
applyDiff: {
|
|
942
|
+
value: L,
|
|
943
|
+
enumerable: !0
|
|
944
|
+
},
|
|
945
|
+
applyChange: {
|
|
946
|
+
value: O,
|
|
947
|
+
enumerable: !0
|
|
948
|
+
},
|
|
949
|
+
revertChange: {
|
|
950
|
+
value: I,
|
|
951
|
+
enumerable: !0
|
|
952
|
+
},
|
|
953
|
+
isConflict: {
|
|
954
|
+
value: function() {
|
|
955
|
+
return typeof $conflict < "u";
|
|
956
|
+
},
|
|
957
|
+
enumerable: !0
|
|
958
|
+
}
|
|
959
|
+
}), P.DeepDiff = P, t && (t.DeepDiff = P), P;
|
|
960
|
+
});
|
|
961
|
+
}(ie)), ie.exports;
|
|
962
|
+
}
|
|
963
|
+
var Te = Ke(), oe = { exports: {} };
|
|
964
|
+
const z = new Uint32Array(65536), Ue = (n, e) => {
|
|
965
|
+
const t = n.length, r = e.length, o = 1 << t - 1;
|
|
966
|
+
let u = -1, d = 0, f = t, p = t;
|
|
967
|
+
for (; p--; )
|
|
968
|
+
z[n.charCodeAt(p)] |= 1 << p;
|
|
969
|
+
for (p = 0; p < r; p++) {
|
|
970
|
+
let y = z[e.charCodeAt(p)];
|
|
971
|
+
const m = y | d;
|
|
972
|
+
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;
|
|
973
|
+
}
|
|
974
|
+
for (p = t; p--; )
|
|
975
|
+
z[n.charCodeAt(p)] = 0;
|
|
976
|
+
return f;
|
|
977
|
+
}, He = (n, e) => {
|
|
978
|
+
const t = e.length, r = n.length, o = [], u = [], d = Math.ceil(t / 32), f = Math.ceil(r / 32);
|
|
979
|
+
for (let h = 0; h < d; h++)
|
|
980
|
+
u[h] = -1, o[h] = 0;
|
|
981
|
+
let p = 0;
|
|
982
|
+
for (; p < f - 1; p++) {
|
|
983
|
+
let h = 0, g = -1;
|
|
984
|
+
const C = p * 32, P = Math.min(32, r) + C;
|
|
985
|
+
for (let v = C; v < P; v++)
|
|
986
|
+
z[n.charCodeAt(v)] |= 1 << v;
|
|
987
|
+
for (let v = 0; v < t; v++) {
|
|
988
|
+
const k = z[e.charCodeAt(v)], O = u[v / 32 | 0] >>> v & 1, R = o[v / 32 | 0] >>> v & 1, I = k | h, L = ((k | R) & g) + g ^ g | k | R;
|
|
989
|
+
let i = h | ~(L | g), l = g & L;
|
|
990
|
+
i >>> 31 ^ O && (u[v / 32 | 0] ^= 1 << v), l >>> 31 ^ R && (o[v / 32 | 0] ^= 1 << v), i = i << 1 | O, l = l << 1 | R, g = l | ~(I | i), h = i & I;
|
|
991
|
+
}
|
|
992
|
+
for (let v = C; v < P; v++)
|
|
993
|
+
z[n.charCodeAt(v)] = 0;
|
|
994
|
+
}
|
|
995
|
+
let y = 0, m = -1;
|
|
996
|
+
const A = p * 32, w = Math.min(32, r - A) + A;
|
|
997
|
+
for (let h = A; h < w; h++)
|
|
998
|
+
z[n.charCodeAt(h)] |= 1 << h;
|
|
999
|
+
let E = r;
|
|
1000
|
+
for (let h = 0; h < t; h++) {
|
|
1001
|
+
const g = z[e.charCodeAt(h)], C = u[h / 32 | 0] >>> h & 1, P = o[h / 32 | 0] >>> h & 1, v = g | y, k = ((g | P) & m) + m ^ m | g | P;
|
|
1002
|
+
let O = y | ~(k | m), R = m & k;
|
|
1003
|
+
E += O >>> r - 1 & 1, E -= R >>> r - 1 & 1, O >>> 31 ^ C && (u[h / 32 | 0] ^= 1 << h), R >>> 31 ^ P && (o[h / 32 | 0] ^= 1 << h), O = O << 1 | C, R = R << 1 | P, m = R | ~(v | O), y = O & v;
|
|
1004
|
+
}
|
|
1005
|
+
for (let h = A; h < w; h++)
|
|
1006
|
+
z[n.charCodeAt(h)] = 0;
|
|
1007
|
+
return E;
|
|
1008
|
+
}, Ce = (n, e) => {
|
|
1009
|
+
if (n.length < e.length) {
|
|
1010
|
+
const t = e;
|
|
1011
|
+
e = n, n = t;
|
|
1012
|
+
}
|
|
1013
|
+
return e.length === 0 ? n.length : n.length <= 32 ? Ue(n, e) : He(n, e);
|
|
1014
|
+
}, Je = (n, e) => {
|
|
1015
|
+
let t = 1 / 0, r = 0;
|
|
1016
|
+
for (let o = 0; o < e.length; o++) {
|
|
1017
|
+
const u = Ce(n, e[o]);
|
|
1018
|
+
u < t && (t = u, r = o);
|
|
1019
|
+
}
|
|
1020
|
+
return e[r];
|
|
1021
|
+
}, Be = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1022
|
+
__proto__: null,
|
|
1023
|
+
closest: Je,
|
|
1024
|
+
distance: Ce
|
|
1025
|
+
}, Symbol.toStringTag, { value: "Module" })), Ve = /* @__PURE__ */ Se(Be);
|
|
1026
|
+
var me;
|
|
1027
|
+
function Ge() {
|
|
1028
|
+
return me || (me = 1, function(n, e) {
|
|
1029
|
+
(function() {
|
|
1030
|
+
var t;
|
|
1031
|
+
try {
|
|
1032
|
+
t = typeof Intl < "u" && typeof Intl.Collator < "u" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
|
1033
|
+
} catch {
|
|
1034
|
+
console.log("Collator could not be initialized and wouldn't be used");
|
|
1035
|
+
}
|
|
1036
|
+
var r = Ve, o = [], u = [], d = {
|
|
1037
|
+
/**
|
|
1038
|
+
* Calculate levenshtein distance of the two strings.
|
|
1039
|
+
*
|
|
1040
|
+
* @param str1 String the first string.
|
|
1041
|
+
* @param str2 String the second string.
|
|
1042
|
+
* @param [options] Additional options.
|
|
1043
|
+
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
1044
|
+
* @return Integer the levenshtein distance (0 and above).
|
|
1045
|
+
*/
|
|
1046
|
+
get: function(f, p, y) {
|
|
1047
|
+
var m = y && t && y.useCollator;
|
|
1048
|
+
if (m) {
|
|
1049
|
+
var A = f.length, w = p.length;
|
|
1050
|
+
if (A === 0) return w;
|
|
1051
|
+
if (w === 0) return A;
|
|
1052
|
+
var E, h, g, C, P;
|
|
1053
|
+
for (g = 0; g < w; ++g)
|
|
1054
|
+
o[g] = g, u[g] = p.charCodeAt(g);
|
|
1055
|
+
o[w] = w;
|
|
1056
|
+
var v;
|
|
1057
|
+
for (g = 0; g < A; ++g) {
|
|
1058
|
+
for (h = g + 1, C = 0; C < w; ++C)
|
|
1059
|
+
E = h, v = t.compare(f.charAt(g), String.fromCharCode(u[C])) === 0, h = o[C] + (v ? 0 : 1), P = E + 1, h > P && (h = P), P = o[C + 1] + 1, h > P && (h = P), o[C] = E;
|
|
1060
|
+
o[C] = h;
|
|
1061
|
+
}
|
|
1062
|
+
return h;
|
|
1063
|
+
}
|
|
1064
|
+
return r.distance(f, p);
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
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);
|
|
1068
|
+
})();
|
|
1069
|
+
}(oe, oe.exports)), oe.exports;
|
|
1070
|
+
}
|
|
1071
|
+
var Xe = Ge();
|
|
1072
|
+
const Ze = /* @__PURE__ */ _e(Xe);
|
|
1073
|
+
class Qe {
|
|
1074
|
+
diff(e, t, r = {}) {
|
|
1075
|
+
let o;
|
|
1076
|
+
typeof r == "function" ? (o = r, r = {}) : "callback" in r && (o = r.callback);
|
|
1077
|
+
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));
|
|
1078
|
+
return this.diffWithOptionsObj(f, p, r, o);
|
|
1079
|
+
}
|
|
1080
|
+
diffWithOptionsObj(e, t, r, o) {
|
|
1081
|
+
var u;
|
|
1082
|
+
const d = (v) => {
|
|
1083
|
+
if (v = this.postProcess(v, r), o) {
|
|
1084
|
+
setTimeout(function() {
|
|
1085
|
+
o(v);
|
|
1086
|
+
}, 0);
|
|
1087
|
+
return;
|
|
1088
|
+
} else
|
|
1089
|
+
return v;
|
|
1090
|
+
}, f = t.length, p = e.length;
|
|
1091
|
+
let y = 1, m = f + p;
|
|
1092
|
+
r.maxEditLength != null && (m = Math.min(m, r.maxEditLength));
|
|
1093
|
+
const A = (u = r.timeout) !== null && u !== void 0 ? u : 1 / 0, w = Date.now() + A, E = [{ oldPos: -1, lastComponent: void 0 }];
|
|
1094
|
+
let h = this.extractCommon(E[0], t, e, 0, r);
|
|
1095
|
+
if (E[0].oldPos + 1 >= p && h + 1 >= f)
|
|
1096
|
+
return d(this.buildValues(E[0].lastComponent, t, e));
|
|
1097
|
+
let g = -1 / 0, C = 1 / 0;
|
|
1098
|
+
const P = () => {
|
|
1099
|
+
for (let v = Math.max(g, -y); v <= Math.min(C, y); v += 2) {
|
|
1100
|
+
let k;
|
|
1101
|
+
const O = E[v - 1], R = E[v + 1];
|
|
1102
|
+
O && (E[v - 1] = void 0);
|
|
1103
|
+
let I = !1;
|
|
1104
|
+
if (R) {
|
|
1105
|
+
const i = R.oldPos - v;
|
|
1106
|
+
I = R && 0 <= i && i < f;
|
|
1107
|
+
}
|
|
1108
|
+
const L = O && O.oldPos + 1 < p;
|
|
1109
|
+
if (!I && !L) {
|
|
1110
|
+
E[v] = void 0;
|
|
1111
|
+
continue;
|
|
1112
|
+
}
|
|
1113
|
+
if (!L || I && O.oldPos < R.oldPos ? k = this.addToPath(R, !0, !1, 0, r) : k = this.addToPath(O, !1, !0, 1, r), h = this.extractCommon(k, t, e, v, r), k.oldPos + 1 >= p && h + 1 >= f)
|
|
1114
|
+
return d(this.buildValues(k.lastComponent, t, e)) || !0;
|
|
1115
|
+
E[v] = k, k.oldPos + 1 >= p && (C = Math.min(C, v - 1)), h + 1 >= f && (g = Math.max(g, v + 1));
|
|
1116
|
+
}
|
|
1117
|
+
y++;
|
|
1118
|
+
};
|
|
1119
|
+
if (o)
|
|
1120
|
+
(function v() {
|
|
1121
|
+
setTimeout(function() {
|
|
1122
|
+
if (y > m || Date.now() > w)
|
|
1123
|
+
return o(void 0);
|
|
1124
|
+
P() || v();
|
|
1125
|
+
}, 0);
|
|
1126
|
+
})();
|
|
1127
|
+
else
|
|
1128
|
+
for (; y <= m && Date.now() <= w; ) {
|
|
1129
|
+
const v = P();
|
|
1130
|
+
if (v)
|
|
1131
|
+
return v;
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
addToPath(e, t, r, o, u) {
|
|
1135
|
+
const d = e.lastComponent;
|
|
1136
|
+
return d && !u.oneChangePerToken && d.added === t && d.removed === r ? {
|
|
1137
|
+
oldPos: e.oldPos + o,
|
|
1138
|
+
lastComponent: { count: d.count + 1, added: t, removed: r, previousComponent: d.previousComponent }
|
|
1139
|
+
} : {
|
|
1140
|
+
oldPos: e.oldPos + o,
|
|
1141
|
+
lastComponent: { count: 1, added: t, removed: r, previousComponent: d }
|
|
1142
|
+
};
|
|
1143
|
+
}
|
|
1144
|
+
extractCommon(e, t, r, o, u) {
|
|
1145
|
+
const d = t.length, f = r.length;
|
|
1146
|
+
let p = e.oldPos, y = p - o, m = 0;
|
|
1147
|
+
for (; y + 1 < d && p + 1 < f && this.equals(r[p + 1], t[y + 1], u); )
|
|
1148
|
+
y++, p++, m++, u.oneChangePerToken && (e.lastComponent = { count: 1, previousComponent: e.lastComponent, added: !1, removed: !1 });
|
|
1149
|
+
return m && !u.oneChangePerToken && (e.lastComponent = { count: m, previousComponent: e.lastComponent, added: !1, removed: !1 }), e.oldPos = p, y;
|
|
1150
|
+
}
|
|
1151
|
+
equals(e, t, r) {
|
|
1152
|
+
return r.comparator ? r.comparator(e, t) : e === t || !!r.ignoreCase && e.toLowerCase() === t.toLowerCase();
|
|
1153
|
+
}
|
|
1154
|
+
removeEmpty(e) {
|
|
1155
|
+
const t = [];
|
|
1156
|
+
for (let r = 0; r < e.length; r++)
|
|
1157
|
+
e[r] && t.push(e[r]);
|
|
1158
|
+
return t;
|
|
1159
|
+
}
|
|
1160
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1161
|
+
castInput(e, t) {
|
|
1162
|
+
return e;
|
|
1163
|
+
}
|
|
1164
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1165
|
+
tokenize(e, t) {
|
|
1166
|
+
return Array.from(e);
|
|
1167
|
+
}
|
|
1168
|
+
join(e) {
|
|
1169
|
+
return e.join("");
|
|
1170
|
+
}
|
|
1171
|
+
postProcess(e, t) {
|
|
1172
|
+
return e;
|
|
1173
|
+
}
|
|
1174
|
+
get useLongestToken() {
|
|
1175
|
+
return !1;
|
|
1176
|
+
}
|
|
1177
|
+
buildValues(e, t, r) {
|
|
1178
|
+
const o = [];
|
|
1179
|
+
let u;
|
|
1180
|
+
for (; e; )
|
|
1181
|
+
o.push(e), u = e.previousComponent, delete e.previousComponent, e = u;
|
|
1182
|
+
o.reverse();
|
|
1183
|
+
const d = o.length;
|
|
1184
|
+
let f = 0, p = 0, y = 0;
|
|
1185
|
+
for (; f < d; f++) {
|
|
1186
|
+
const m = o[f];
|
|
1187
|
+
if (m.removed)
|
|
1188
|
+
m.value = this.join(r.slice(y, y + m.count)), y += m.count;
|
|
1189
|
+
else {
|
|
1190
|
+
if (!m.added && this.useLongestToken) {
|
|
1191
|
+
let A = t.slice(p, p + m.count);
|
|
1192
|
+
A = A.map(function(w, E) {
|
|
1193
|
+
const h = r[y + E];
|
|
1194
|
+
return h.length > w.length ? h : w;
|
|
1195
|
+
}), m.value = this.join(A);
|
|
1196
|
+
} else
|
|
1197
|
+
m.value = this.join(t.slice(p, p + m.count));
|
|
1198
|
+
p += m.count, m.added || (y += m.count);
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
return o;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
class et extends Qe {
|
|
1205
|
+
constructor() {
|
|
1206
|
+
super(...arguments), this.tokenize = nt;
|
|
1207
|
+
}
|
|
1208
|
+
equals(e, t, r) {
|
|
1209
|
+
return r.ignoreWhitespace ? ((!r.newlineIsToken || !e.includes(`
|
|
1210
|
+
`)) && (e = e.trim()), (!r.newlineIsToken || !t.includes(`
|
|
1211
|
+
`)) && (t = t.trim())) : r.ignoreNewlineAtEof && !r.newlineIsToken && (e.endsWith(`
|
|
1212
|
+
`) && (e = e.slice(0, -1)), t.endsWith(`
|
|
1213
|
+
`) && (t = t.slice(0, -1))), super.equals(e, t, r);
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
const tt = new et();
|
|
1217
|
+
function ve(n, e, t) {
|
|
1218
|
+
return tt.diff(n, e, t);
|
|
1219
|
+
}
|
|
1220
|
+
function nt(n, e) {
|
|
1221
|
+
e.stripTrailingCr && (n = n.replace(/\r\n/g, `
|
|
1222
|
+
`));
|
|
1223
|
+
const t = [], r = n.split(/(\n|\r\n)/);
|
|
1224
|
+
r[r.length - 1] || r.pop();
|
|
1225
|
+
for (let o = 0; o < r.length; o++) {
|
|
1226
|
+
const u = r[o];
|
|
1227
|
+
o % 2 && !e.newlineIsToken ? t[t.length - 1] += u : t.push(u);
|
|
1228
|
+
}
|
|
1229
|
+
return t;
|
|
1230
|
+
}
|
|
1231
|
+
function be(n, e, t, r, o, u, d) {
|
|
1232
|
+
let f;
|
|
1233
|
+
d ? typeof d == "function" ? f = { callback: d } : f = d : f = {}, typeof f.context > "u" && (f.context = 4);
|
|
1234
|
+
const p = f.context;
|
|
1235
|
+
if (f.newlineIsToken)
|
|
1236
|
+
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
1237
|
+
if (f.callback) {
|
|
1238
|
+
const { callback: m } = f;
|
|
1239
|
+
ve(t, r, Object.assign(Object.assign({}, f), { callback: (A) => {
|
|
1240
|
+
const w = y(A);
|
|
1241
|
+
m(w);
|
|
1242
|
+
} }));
|
|
1243
|
+
} else
|
|
1244
|
+
return y(ve(t, r, f));
|
|
1245
|
+
function y(m) {
|
|
1246
|
+
if (!m)
|
|
1247
|
+
return;
|
|
1248
|
+
m.push({ value: "", lines: [] });
|
|
1249
|
+
function A(v) {
|
|
1250
|
+
return v.map(function(k) {
|
|
1251
|
+
return " " + k;
|
|
1252
|
+
});
|
|
1253
|
+
}
|
|
1254
|
+
const w = [];
|
|
1255
|
+
let E = 0, h = 0, g = [], C = 1, P = 1;
|
|
1256
|
+
for (let v = 0; v < m.length; v++) {
|
|
1257
|
+
const k = m[v], O = k.lines || ot(k.value);
|
|
1258
|
+
if (k.lines = O, k.added || k.removed) {
|
|
1259
|
+
if (!E) {
|
|
1260
|
+
const R = m[v - 1];
|
|
1261
|
+
E = C, h = P, R && (g = p > 0 ? A(R.lines.slice(-p)) : [], E -= g.length, h -= g.length);
|
|
1262
|
+
}
|
|
1263
|
+
for (const R of O)
|
|
1264
|
+
g.push((k.added ? "+" : "-") + R);
|
|
1265
|
+
k.added ? P += O.length : C += O.length;
|
|
1266
|
+
} else {
|
|
1267
|
+
if (E)
|
|
1268
|
+
if (O.length <= p * 2 && v < m.length - 2)
|
|
1269
|
+
for (const R of A(O))
|
|
1270
|
+
g.push(R);
|
|
1271
|
+
else {
|
|
1272
|
+
const R = Math.min(O.length, p);
|
|
1273
|
+
for (const L of A(O.slice(0, R)))
|
|
1274
|
+
g.push(L);
|
|
1275
|
+
const I = {
|
|
1276
|
+
oldStart: E,
|
|
1277
|
+
oldLines: C - E + R,
|
|
1278
|
+
newStart: h,
|
|
1279
|
+
newLines: P - h + R,
|
|
1280
|
+
lines: g
|
|
1281
|
+
};
|
|
1282
|
+
w.push(I), E = 0, h = 0, g = [];
|
|
1283
|
+
}
|
|
1284
|
+
C += O.length, P += O.length;
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
for (const v of w)
|
|
1288
|
+
for (let k = 0; k < v.lines.length; k++)
|
|
1289
|
+
v.lines[k].endsWith(`
|
|
1290
|
+
`) ? v.lines[k] = v.lines[k].slice(0, -1) : (v.lines.splice(k + 1, 0, "\"), k++);
|
|
1291
|
+
return {
|
|
1292
|
+
oldFileName: n,
|
|
1293
|
+
newFileName: e,
|
|
1294
|
+
oldHeader: o,
|
|
1295
|
+
newHeader: u,
|
|
1296
|
+
hunks: w
|
|
1297
|
+
};
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
function ue(n) {
|
|
1301
|
+
if (Array.isArray(n))
|
|
1302
|
+
return n.map(ue).join(`
|
|
1303
|
+
`);
|
|
1304
|
+
const e = [];
|
|
1305
|
+
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));
|
|
1306
|
+
for (let t = 0; t < n.hunks.length; t++) {
|
|
1307
|
+
const r = n.hunks[t];
|
|
1308
|
+
r.oldLines === 0 && (r.oldStart -= 1), r.newLines === 0 && (r.newStart -= 1), e.push("@@ -" + r.oldStart + "," + r.oldLines + " +" + r.newStart + "," + r.newLines + " @@");
|
|
1309
|
+
for (const o of r.lines)
|
|
1310
|
+
e.push(o);
|
|
1311
|
+
}
|
|
1312
|
+
return e.join(`
|
|
1313
|
+
`) + `
|
|
1314
|
+
`;
|
|
1315
|
+
}
|
|
1316
|
+
function rt(n, e, t, r, o, u, d) {
|
|
1317
|
+
if (typeof d == "function" && (d = { callback: d }), d?.callback) {
|
|
1318
|
+
const { callback: f } = d;
|
|
1319
|
+
be(n, e, t, r, o, u, Object.assign(Object.assign({}, d), { callback: (p) => {
|
|
1320
|
+
f(p ? ue(p) : void 0);
|
|
1321
|
+
} }));
|
|
1322
|
+
} else {
|
|
1323
|
+
const f = be(n, e, t, r, o, u, d);
|
|
1324
|
+
return f ? ue(f) : void 0;
|
|
1325
|
+
}
|
|
1326
|
+
}
|
|
1327
|
+
function ot(n) {
|
|
1328
|
+
const e = n.endsWith(`
|
|
1329
|
+
`), t = n.split(`
|
|
1330
|
+
`).map((r) => r + `
|
|
1331
|
+
`);
|
|
1332
|
+
return e ? t.pop() : t.push(t.pop().slice(0, -1)), t;
|
|
1333
|
+
}
|
|
1334
|
+
function it(n, e, t = "git", r = 3) {
|
|
1335
|
+
switch (t) {
|
|
1336
|
+
case "git":
|
|
1337
|
+
return ye(n, e, r);
|
|
1338
|
+
case "object":
|
|
1339
|
+
return st(n, e);
|
|
1340
|
+
case "json":
|
|
1341
|
+
return at(n, e);
|
|
1342
|
+
default:
|
|
1343
|
+
return ye(n, e, r);
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
function ye(n, e, t = 3) {
|
|
1347
|
+
const r = ge(n), o = ge(e);
|
|
1348
|
+
return rt(
|
|
1349
|
+
/* oldFilename */
|
|
1350
|
+
"",
|
|
1351
|
+
/* newFilename */
|
|
1352
|
+
"",
|
|
1353
|
+
r,
|
|
1354
|
+
o,
|
|
1355
|
+
/* oldHeader */
|
|
1356
|
+
"",
|
|
1357
|
+
/* newHeader */
|
|
1358
|
+
"",
|
|
1359
|
+
{ context: t }
|
|
1360
|
+
).split(`
|
|
1361
|
+
`).slice(2).join(`
|
|
1362
|
+
`);
|
|
1363
|
+
}
|
|
1364
|
+
function st(n, e) {
|
|
1365
|
+
const t = Te.diff(n, e) || [];
|
|
1366
|
+
return JSON.stringify(t, null, 2);
|
|
1367
|
+
}
|
|
1368
|
+
function at(n, e) {
|
|
1369
|
+
return JSON.stringify(
|
|
1370
|
+
{
|
|
1371
|
+
before: n,
|
|
1372
|
+
after: e
|
|
1373
|
+
},
|
|
1374
|
+
null,
|
|
1375
|
+
2
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1378
|
+
function lt(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);
|
|
1380
|
+
}
|
|
1381
|
+
function Oe(n, e) {
|
|
1382
|
+
if (n === e) return 0;
|
|
1383
|
+
if (n.length === 0 || e.length === 0) return 1;
|
|
1384
|
+
const t = Ze.get(n, e), r = Math.max(n.length, e.length);
|
|
1385
|
+
return t / r;
|
|
1386
|
+
}
|
|
1387
|
+
function Re(n, e) {
|
|
1388
|
+
if (n === e) return 0;
|
|
1389
|
+
if (n === 0) return 1;
|
|
1390
|
+
const t = Math.abs(e - n), r = Math.max(Math.abs(n), Math.abs(e));
|
|
1391
|
+
return Math.min(t / r, 1);
|
|
1392
|
+
}
|
|
1393
|
+
function ut(n, e) {
|
|
1394
|
+
if (n === e) return 0;
|
|
1395
|
+
const t = Te.diff(n, e) || [];
|
|
1396
|
+
if (t.length === 0) return 0;
|
|
1397
|
+
const r = we(n), o = we(e), u = Math.max(r, o);
|
|
1398
|
+
if (u === 0) return 0;
|
|
1399
|
+
let d = 0;
|
|
1400
|
+
for (const f of t)
|
|
1401
|
+
switch (f.kind) {
|
|
1402
|
+
case "N":
|
|
1403
|
+
d += 1;
|
|
1404
|
+
break;
|
|
1405
|
+
case "D":
|
|
1406
|
+
d += 1;
|
|
1407
|
+
break;
|
|
1408
|
+
case "E":
|
|
1409
|
+
if (typeof f.lhs == "string" && typeof f.rhs == "string") {
|
|
1410
|
+
const p = Oe(
|
|
1411
|
+
f.lhs,
|
|
1412
|
+
f.rhs
|
|
1413
|
+
);
|
|
1414
|
+
d += p;
|
|
1415
|
+
} else if (typeof f.lhs == "number" && typeof f.rhs == "number") {
|
|
1416
|
+
const p = Re(
|
|
1417
|
+
f.lhs,
|
|
1418
|
+
f.rhs
|
|
1419
|
+
);
|
|
1420
|
+
d += p;
|
|
1421
|
+
} else
|
|
1422
|
+
d += 1;
|
|
1423
|
+
break;
|
|
1424
|
+
case "A":
|
|
1425
|
+
d += 0.5;
|
|
1426
|
+
break;
|
|
1427
|
+
}
|
|
1428
|
+
return Math.min(d / u, 1);
|
|
1429
|
+
}
|
|
1430
|
+
function we(n) {
|
|
1431
|
+
if (n == null) return 0;
|
|
1432
|
+
if (typeof n != "object") return 1;
|
|
1433
|
+
if (Array.isArray(n)) return n.length;
|
|
1434
|
+
let e = 0;
|
|
1435
|
+
for (const t in n)
|
|
1436
|
+
Object.prototype.hasOwnProperty.call(n, t) && (e += 1);
|
|
1437
|
+
return e;
|
|
1438
|
+
}
|
|
1439
|
+
function ge(n) {
|
|
1440
|
+
try {
|
|
1441
|
+
return JSON.stringify(
|
|
1442
|
+
n,
|
|
1443
|
+
(e, t) => typeof t == "function" ? "[Function]" : t === void 0 ? "[undefined]" : t === 1 / 0 ? "[Infinity]" : Number.isNaN(t) ? "[NaN]" : t,
|
|
1444
|
+
2
|
|
1445
|
+
);
|
|
1446
|
+
} catch {
|
|
1447
|
+
return String(n);
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
function ct(n, e, t) {
|
|
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(
|
|
1452
|
+
(C, P, v) => {
|
|
1453
|
+
const k = lt(C, P), O = it(C, P, d);
|
|
1454
|
+
let R;
|
|
1455
|
+
t?.vote ? typeof t.vote == "function" ? R = t.vote(C, P, k) : R = t.vote : R = k > 0.5 ? "downvote" : "upvote";
|
|
1456
|
+
const I = typeof e == "function" ? e(P) : e;
|
|
1457
|
+
o({
|
|
1458
|
+
tx_id: I,
|
|
1459
|
+
vote: R,
|
|
1460
|
+
explanation: `State change with diff percentage: ${(k * 100).toFixed(1)}%`,
|
|
1461
|
+
correction: O,
|
|
1462
|
+
source: "IMPLICIT",
|
|
1463
|
+
extra_metadata: t?.metadata,
|
|
1464
|
+
trigger_name: v
|
|
1465
|
+
});
|
|
1466
|
+
},
|
|
1467
|
+
[t, e, d, o]
|
|
1468
|
+
), g = W(
|
|
1469
|
+
(C) => {
|
|
1470
|
+
const P = C || p;
|
|
1471
|
+
if (w.current && E.current && E.current !== P) {
|
|
1472
|
+
clearTimeout(w.current);
|
|
1473
|
+
const v = m.current;
|
|
1474
|
+
h(
|
|
1475
|
+
v,
|
|
1476
|
+
n,
|
|
1477
|
+
E.current
|
|
1478
|
+
), w.current = null;
|
|
1479
|
+
}
|
|
1480
|
+
E.current = P;
|
|
1481
|
+
},
|
|
1482
|
+
[n, p, h]
|
|
1483
|
+
);
|
|
1484
|
+
return ke(() => {
|
|
1485
|
+
if (A.current) {
|
|
1486
|
+
A.current = !1, y.current = n, m.current = n;
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
const C = y.current;
|
|
1490
|
+
return (f ? f(C, n) : JSON.stringify(C) === JSON.stringify(n)) || (w.current || (m.current = C), w.current && clearTimeout(w.current), y.current = n, w.current = setTimeout(() => {
|
|
1491
|
+
const v = m.current, k = n;
|
|
1492
|
+
h(
|
|
1493
|
+
v,
|
|
1494
|
+
k,
|
|
1495
|
+
E.current || p
|
|
1496
|
+
), m.current = k, w.current = null;
|
|
1497
|
+
}, u)), () => {
|
|
1498
|
+
w.current && clearTimeout(w.current);
|
|
1499
|
+
};
|
|
1500
|
+
}, [
|
|
1501
|
+
n,
|
|
1502
|
+
e,
|
|
1503
|
+
t,
|
|
1504
|
+
o,
|
|
1505
|
+
d,
|
|
1506
|
+
u,
|
|
1507
|
+
f,
|
|
1508
|
+
p,
|
|
1509
|
+
h
|
|
1510
|
+
]), {
|
|
1511
|
+
notifyChange: g
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
function vt(n, e, t) {
|
|
1515
|
+
const [r, o] = X(n), { notifyChange: u } = ct(r, e, t), d = W(
|
|
1516
|
+
(f, p) => {
|
|
1517
|
+
u(p), o((y) => typeof f == "function" ? f(y) : f);
|
|
1518
|
+
},
|
|
1519
|
+
[u]
|
|
1520
|
+
);
|
|
1521
|
+
return [r, d];
|
|
1522
|
+
}
|
|
1523
|
+
let ft = () => {
|
|
1524
|
+
try {
|
|
1525
|
+
return require("@opentelemetry/api");
|
|
1526
|
+
} catch {
|
|
1527
|
+
throw new Error(
|
|
1528
|
+
"OpenTelemetry is not available. Install @opentelemetry/api to use trace ID extraction."
|
|
1529
|
+
);
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
function bt() {
|
|
1533
|
+
const { trace: n, context: e } = ft();
|
|
1534
|
+
try {
|
|
1535
|
+
const t = n.getSpanContext(e.active());
|
|
1536
|
+
if (t?.traceId)
|
|
1537
|
+
return t.traceId;
|
|
1538
|
+
const r = n.getSpan(e.active());
|
|
1539
|
+
if (r) {
|
|
1540
|
+
const o = r.spanContext();
|
|
1541
|
+
if (o.traceId)
|
|
1542
|
+
return o.traceId;
|
|
1543
|
+
}
|
|
1544
|
+
} catch (t) {
|
|
1545
|
+
throw new Error(
|
|
1546
|
+
`Failed to extract OpenTelemetry trace ID: ${t instanceof Error ? t.message : "Unknown error"}`
|
|
1547
|
+
);
|
|
1548
|
+
}
|
|
1549
|
+
throw new Error(
|
|
1550
|
+
"OpenTelemetry trace ID not available. Ensure XHR/Fetch instrumentation is active and a request is in progress."
|
|
1551
|
+
);
|
|
1552
|
+
}
|
|
1553
|
+
export {
|
|
1554
|
+
se as KeletContext,
|
|
1555
|
+
ht as KeletProvider,
|
|
1556
|
+
mt as VoteFeedback,
|
|
1557
|
+
bt as getOtelTraceId,
|
|
1558
|
+
Pe as useDefaultFeedbackHandler,
|
|
1559
|
+
vt as useFeedbackState,
|
|
1560
|
+
pt as useKelet
|
|
1561
|
+
};
|
|
1562
|
+
//# sourceMappingURL=feedback-ui.es.min.js.map
|