@kelet-ai/feedback-ui 0.4.2 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/feedback-ui.es.js +1729 -1126
- 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
package/dist/feedback-ui.es.js
CHANGED
|
@@ -1,32 +1,38 @@
|
|
|
1
|
-
import
|
|
2
|
-
function
|
|
3
|
-
return
|
|
1
|
+
import require$$0$1, { createContext, useContext, useCallback, isValidElement, cloneElement, useState, useRef, useId, useEffect } from "react";
|
|
2
|
+
function getDefaultExportFromCjs(x) {
|
|
3
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
4
4
|
}
|
|
5
|
-
function
|
|
5
|
+
function getAugmentedNamespace(n) {
|
|
6
6
|
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
7
|
-
var
|
|
8
|
-
if (typeof
|
|
9
|
-
var
|
|
10
|
-
var
|
|
7
|
+
var f = n.default;
|
|
8
|
+
if (typeof f == "function") {
|
|
9
|
+
var a = function a2() {
|
|
10
|
+
var isInstance = false;
|
|
11
11
|
try {
|
|
12
|
-
|
|
12
|
+
isInstance = this instanceof a2;
|
|
13
13
|
} catch {
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
if (isInstance) {
|
|
16
|
+
return Reflect.construct(f, arguments, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
return f.apply(this, arguments);
|
|
16
19
|
};
|
|
17
|
-
|
|
18
|
-
} else
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Object.
|
|
22
|
-
|
|
20
|
+
a.prototype = f.prototype;
|
|
21
|
+
} else a = {};
|
|
22
|
+
Object.defineProperty(a, "__esModule", { value: true });
|
|
23
|
+
Object.keys(n).forEach(function(k) {
|
|
24
|
+
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
25
|
+
Object.defineProperty(a, k, d.get ? d : {
|
|
26
|
+
enumerable: true,
|
|
23
27
|
get: function() {
|
|
24
|
-
return n[
|
|
28
|
+
return n[k];
|
|
25
29
|
}
|
|
26
30
|
});
|
|
27
|
-
})
|
|
31
|
+
});
|
|
32
|
+
return a;
|
|
28
33
|
}
|
|
29
|
-
var
|
|
34
|
+
var jsxRuntime = { exports: {} };
|
|
35
|
+
var reactJsxRuntime_production = {};
|
|
30
36
|
/**
|
|
31
37
|
* @license React
|
|
32
38
|
* react-jsx-runtime.production.js
|
|
@@ -36,29 +42,35 @@ var re = { exports: {} }, V = {};
|
|
|
36
42
|
* This source code is licensed under the MIT license found in the
|
|
37
43
|
* LICENSE file in the root directory of this source tree.
|
|
38
44
|
*/
|
|
39
|
-
var
|
|
40
|
-
function
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
var
|
|
44
|
-
function
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
45
|
+
var hasRequiredReactJsxRuntime_production;
|
|
46
|
+
function requireReactJsxRuntime_production() {
|
|
47
|
+
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
48
|
+
hasRequiredReactJsxRuntime_production = 1;
|
|
49
|
+
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
50
|
+
function jsxProd(type, config, maybeKey) {
|
|
51
|
+
var key = null;
|
|
52
|
+
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
53
|
+
void 0 !== config.key && (key = "" + config.key);
|
|
54
|
+
if ("key" in config) {
|
|
55
|
+
maybeKey = {};
|
|
56
|
+
for (var propName in config)
|
|
57
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
58
|
+
} else maybeKey = config;
|
|
59
|
+
config = maybeKey.ref;
|
|
60
|
+
return {
|
|
61
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
62
|
+
type,
|
|
63
|
+
key,
|
|
64
|
+
ref: void 0 !== config ? config : null,
|
|
65
|
+
props: maybeKey
|
|
57
66
|
};
|
|
58
67
|
}
|
|
59
|
-
|
|
68
|
+
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
69
|
+
reactJsxRuntime_production.jsx = jsxProd;
|
|
70
|
+
reactJsxRuntime_production.jsxs = jsxProd;
|
|
71
|
+
return reactJsxRuntime_production;
|
|
60
72
|
}
|
|
61
|
-
var
|
|
73
|
+
var reactJsxRuntime_development = {};
|
|
62
74
|
/**
|
|
63
75
|
* @license React
|
|
64
76
|
* react-jsx-runtime.development.js
|
|
@@ -68,972 +80,1320 @@ var G = {};
|
|
|
68
80
|
* This source code is licensed under the MIT license found in the
|
|
69
81
|
* LICENSE file in the root directory of this source tree.
|
|
70
82
|
*/
|
|
71
|
-
var
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
var hasRequiredReactJsxRuntime_development;
|
|
84
|
+
function requireReactJsxRuntime_development() {
|
|
85
|
+
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
86
|
+
hasRequiredReactJsxRuntime_development = 1;
|
|
87
|
+
"production" !== process.env.NODE_ENV && function() {
|
|
88
|
+
function getComponentNameFromType(type) {
|
|
89
|
+
if (null == type) return null;
|
|
90
|
+
if ("function" === typeof type)
|
|
91
|
+
return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
92
|
+
if ("string" === typeof type) return type;
|
|
93
|
+
switch (type) {
|
|
94
|
+
case REACT_FRAGMENT_TYPE:
|
|
81
95
|
return "Fragment";
|
|
82
|
-
case
|
|
96
|
+
case REACT_PROFILER_TYPE:
|
|
83
97
|
return "Profiler";
|
|
84
|
-
case
|
|
98
|
+
case REACT_STRICT_MODE_TYPE:
|
|
85
99
|
return "StrictMode";
|
|
86
|
-
case
|
|
100
|
+
case REACT_SUSPENSE_TYPE:
|
|
87
101
|
return "Suspense";
|
|
88
|
-
case
|
|
102
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
|
89
103
|
return "SuspenseList";
|
|
90
|
-
case
|
|
104
|
+
case REACT_ACTIVITY_TYPE:
|
|
91
105
|
return "Activity";
|
|
92
106
|
}
|
|
93
|
-
if (
|
|
94
|
-
switch (typeof
|
|
107
|
+
if ("object" === typeof type)
|
|
108
|
+
switch ("number" === typeof type.tag && console.error(
|
|
95
109
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
96
|
-
),
|
|
97
|
-
case
|
|
110
|
+
), type.$$typeof) {
|
|
111
|
+
case REACT_PORTAL_TYPE:
|
|
98
112
|
return "Portal";
|
|
99
|
-
case
|
|
100
|
-
return (
|
|
101
|
-
case
|
|
102
|
-
return (
|
|
103
|
-
case
|
|
104
|
-
var
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
case
|
|
109
|
-
|
|
113
|
+
case REACT_CONTEXT_TYPE:
|
|
114
|
+
return (type.displayName || "Context") + ".Provider";
|
|
115
|
+
case REACT_CONSUMER_TYPE:
|
|
116
|
+
return (type._context.displayName || "Context") + ".Consumer";
|
|
117
|
+
case REACT_FORWARD_REF_TYPE:
|
|
118
|
+
var innerType = type.render;
|
|
119
|
+
type = type.displayName;
|
|
120
|
+
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
121
|
+
return type;
|
|
122
|
+
case REACT_MEMO_TYPE:
|
|
123
|
+
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
124
|
+
case REACT_LAZY_TYPE:
|
|
125
|
+
innerType = type._payload;
|
|
126
|
+
type = type._init;
|
|
110
127
|
try {
|
|
111
|
-
return
|
|
112
|
-
} catch {
|
|
128
|
+
return getComponentNameFromType(type(innerType));
|
|
129
|
+
} catch (x) {
|
|
113
130
|
}
|
|
114
131
|
}
|
|
115
132
|
return null;
|
|
116
133
|
}
|
|
117
|
-
function
|
|
118
|
-
return "" +
|
|
134
|
+
function testStringCoercion(value) {
|
|
135
|
+
return "" + value;
|
|
119
136
|
}
|
|
120
|
-
function
|
|
137
|
+
function checkKeyStringCoercion(value) {
|
|
121
138
|
try {
|
|
122
|
-
|
|
123
|
-
var
|
|
124
|
-
} catch {
|
|
125
|
-
|
|
139
|
+
testStringCoercion(value);
|
|
140
|
+
var JSCompiler_inline_result = false;
|
|
141
|
+
} catch (e) {
|
|
142
|
+
JSCompiler_inline_result = true;
|
|
126
143
|
}
|
|
127
|
-
if (
|
|
128
|
-
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
144
|
+
if (JSCompiler_inline_result) {
|
|
145
|
+
JSCompiler_inline_result = console;
|
|
146
|
+
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
147
|
+
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
148
|
+
JSCompiler_temp_const.call(
|
|
149
|
+
JSCompiler_inline_result,
|
|
132
150
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
133
|
-
|
|
134
|
-
)
|
|
151
|
+
JSCompiler_inline_result$jscomp$0
|
|
152
|
+
);
|
|
153
|
+
return testStringCoercion(value);
|
|
135
154
|
}
|
|
136
155
|
}
|
|
137
|
-
function
|
|
138
|
-
if (
|
|
139
|
-
if (
|
|
156
|
+
function getTaskName(type) {
|
|
157
|
+
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
158
|
+
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
|
|
140
159
|
return "<...>";
|
|
141
160
|
try {
|
|
142
|
-
var
|
|
143
|
-
return
|
|
144
|
-
} catch {
|
|
161
|
+
var name = getComponentNameFromType(type);
|
|
162
|
+
return name ? "<" + name + ">" : "<...>";
|
|
163
|
+
} catch (x) {
|
|
145
164
|
return "<...>";
|
|
146
165
|
}
|
|
147
166
|
}
|
|
148
|
-
function
|
|
149
|
-
var
|
|
150
|
-
return
|
|
167
|
+
function getOwner() {
|
|
168
|
+
var dispatcher = ReactSharedInternals.A;
|
|
169
|
+
return null === dispatcher ? null : dispatcher.getOwner();
|
|
151
170
|
}
|
|
152
|
-
function
|
|
171
|
+
function UnknownOwner() {
|
|
153
172
|
return Error("react-stack-top-frame");
|
|
154
173
|
}
|
|
155
|
-
function
|
|
156
|
-
if (
|
|
157
|
-
var
|
|
158
|
-
if (
|
|
174
|
+
function hasValidKey(config) {
|
|
175
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
176
|
+
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
177
|
+
if (getter && getter.isReactWarning) return false;
|
|
159
178
|
}
|
|
160
|
-
return
|
|
179
|
+
return void 0 !== config.key;
|
|
161
180
|
}
|
|
162
|
-
function
|
|
163
|
-
function
|
|
164
|
-
|
|
181
|
+
function defineKeyPropWarningGetter(props, displayName) {
|
|
182
|
+
function warnAboutAccessingKey() {
|
|
183
|
+
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
|
|
165
184
|
"%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
|
-
|
|
185
|
+
displayName
|
|
167
186
|
));
|
|
168
187
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
188
|
+
warnAboutAccessingKey.isReactWarning = true;
|
|
189
|
+
Object.defineProperty(props, "key", {
|
|
190
|
+
get: warnAboutAccessingKey,
|
|
191
|
+
configurable: true
|
|
172
192
|
});
|
|
173
193
|
}
|
|
174
|
-
function
|
|
175
|
-
var
|
|
176
|
-
|
|
194
|
+
function elementRefGetterWithDeprecationWarning() {
|
|
195
|
+
var componentName = getComponentNameFromType(this.type);
|
|
196
|
+
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
|
|
177
197
|
"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
|
-
))
|
|
198
|
+
));
|
|
199
|
+
componentName = this.props.ref;
|
|
200
|
+
return void 0 !== componentName ? componentName : null;
|
|
179
201
|
}
|
|
180
|
-
function
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
202
|
+
function ReactElement(type, key, self2, source, owner, props, debugStack, debugTask) {
|
|
203
|
+
self2 = props.ref;
|
|
204
|
+
type = {
|
|
205
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
206
|
+
type,
|
|
207
|
+
key,
|
|
208
|
+
props,
|
|
209
|
+
_owner: owner
|
|
210
|
+
};
|
|
211
|
+
null !== (void 0 !== self2 ? self2 : null) ? Object.defineProperty(type, "ref", {
|
|
212
|
+
enumerable: false,
|
|
213
|
+
get: elementRefGetterWithDeprecationWarning
|
|
214
|
+
}) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
|
|
215
|
+
type._store = {};
|
|
216
|
+
Object.defineProperty(type._store, "validated", {
|
|
217
|
+
configurable: false,
|
|
218
|
+
enumerable: false,
|
|
219
|
+
writable: true,
|
|
194
220
|
value: 0
|
|
195
|
-
})
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
221
|
+
});
|
|
222
|
+
Object.defineProperty(type, "_debugInfo", {
|
|
223
|
+
configurable: false,
|
|
224
|
+
enumerable: false,
|
|
225
|
+
writable: true,
|
|
199
226
|
value: null
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
227
|
+
});
|
|
228
|
+
Object.defineProperty(type, "_debugStack", {
|
|
229
|
+
configurable: false,
|
|
230
|
+
enumerable: false,
|
|
231
|
+
writable: true,
|
|
232
|
+
value: debugStack
|
|
233
|
+
});
|
|
234
|
+
Object.defineProperty(type, "_debugTask", {
|
|
235
|
+
configurable: false,
|
|
236
|
+
enumerable: false,
|
|
237
|
+
writable: true,
|
|
238
|
+
value: debugTask
|
|
239
|
+
});
|
|
240
|
+
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
241
|
+
return type;
|
|
211
242
|
}
|
|
212
|
-
function
|
|
213
|
-
var
|
|
214
|
-
if (
|
|
215
|
-
if (
|
|
216
|
-
if (
|
|
217
|
-
for (
|
|
218
|
-
|
|
219
|
-
Object.freeze && Object.freeze(
|
|
243
|
+
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, source, self2, debugStack, debugTask) {
|
|
244
|
+
var children = config.children;
|
|
245
|
+
if (void 0 !== children)
|
|
246
|
+
if (isStaticChildren)
|
|
247
|
+
if (isArrayImpl(children)) {
|
|
248
|
+
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++)
|
|
249
|
+
validateChildKeys(children[isStaticChildren]);
|
|
250
|
+
Object.freeze && Object.freeze(children);
|
|
220
251
|
} else
|
|
221
252
|
console.error(
|
|
222
253
|
"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
254
|
);
|
|
224
|
-
else
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
var
|
|
228
|
-
return
|
|
255
|
+
else validateChildKeys(children);
|
|
256
|
+
if (hasOwnProperty.call(config, "key")) {
|
|
257
|
+
children = getComponentNameFromType(type);
|
|
258
|
+
var keys = Object.keys(config).filter(function(k) {
|
|
259
|
+
return "key" !== k;
|
|
229
260
|
});
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
let props = %s
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
j,
|
|
239
|
-
Y,
|
|
240
|
-
j
|
|
241
|
-
), ne[j + S] = !0);
|
|
261
|
+
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
262
|
+
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
263
|
+
'A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />',
|
|
264
|
+
isStaticChildren,
|
|
265
|
+
children,
|
|
266
|
+
keys,
|
|
267
|
+
children
|
|
268
|
+
), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
242
269
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
270
|
+
children = null;
|
|
271
|
+
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
272
|
+
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
273
|
+
if ("key" in config) {
|
|
274
|
+
maybeKey = {};
|
|
275
|
+
for (var propName in config)
|
|
276
|
+
"key" !== propName && (maybeKey[propName] = config[propName]);
|
|
277
|
+
} else maybeKey = config;
|
|
278
|
+
children && defineKeyPropWarningGetter(
|
|
279
|
+
maybeKey,
|
|
280
|
+
"function" === typeof type ? type.displayName || type.name || "Unknown" : type
|
|
281
|
+
);
|
|
282
|
+
return ReactElement(
|
|
283
|
+
type,
|
|
284
|
+
children,
|
|
285
|
+
self2,
|
|
286
|
+
source,
|
|
287
|
+
getOwner(),
|
|
288
|
+
maybeKey,
|
|
289
|
+
debugStack,
|
|
290
|
+
debugTask
|
|
260
291
|
);
|
|
261
292
|
}
|
|
262
|
-
function
|
|
263
|
-
|
|
293
|
+
function validateChildKeys(node) {
|
|
294
|
+
"object" === typeof node && null !== node && node.$$typeof === REACT_ELEMENT_TYPE && node._store && (node._store.validated = 1);
|
|
264
295
|
}
|
|
265
|
-
var
|
|
296
|
+
var React = require$$0$1, REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler");
|
|
297
|
+
var REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
|
|
266
298
|
return null;
|
|
267
299
|
};
|
|
268
|
-
|
|
269
|
-
react_stack_bottom_frame: function(
|
|
270
|
-
return
|
|
300
|
+
React = {
|
|
301
|
+
react_stack_bottom_frame: function(callStackForError) {
|
|
302
|
+
return callStackForError();
|
|
271
303
|
}
|
|
272
304
|
};
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
305
|
+
var specialPropKeyWarningShown;
|
|
306
|
+
var didWarnAboutElementRef = {};
|
|
307
|
+
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(
|
|
308
|
+
React,
|
|
309
|
+
UnknownOwner
|
|
310
|
+
)();
|
|
311
|
+
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
312
|
+
var didWarnAboutKeySpread = {};
|
|
313
|
+
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
314
|
+
reactJsxRuntime_development.jsx = function(type, config, maybeKey, source, self2) {
|
|
315
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
316
|
+
return jsxDEVImpl(
|
|
317
|
+
type,
|
|
318
|
+
config,
|
|
319
|
+
maybeKey,
|
|
320
|
+
false,
|
|
321
|
+
source,
|
|
322
|
+
self2,
|
|
323
|
+
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
324
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
288
325
|
);
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
326
|
+
};
|
|
327
|
+
reactJsxRuntime_development.jsxs = function(type, config, maybeKey, source, self2) {
|
|
328
|
+
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
329
|
+
return jsxDEVImpl(
|
|
330
|
+
type,
|
|
331
|
+
config,
|
|
332
|
+
maybeKey,
|
|
333
|
+
true,
|
|
334
|
+
source,
|
|
335
|
+
self2,
|
|
336
|
+
trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
|
|
337
|
+
trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask
|
|
300
338
|
);
|
|
301
339
|
};
|
|
302
|
-
}()
|
|
340
|
+
}();
|
|
341
|
+
return reactJsxRuntime_development;
|
|
303
342
|
}
|
|
304
|
-
var
|
|
305
|
-
function
|
|
306
|
-
|
|
343
|
+
var hasRequiredJsxRuntime;
|
|
344
|
+
function requireJsxRuntime() {
|
|
345
|
+
if (hasRequiredJsxRuntime) return jsxRuntime.exports;
|
|
346
|
+
hasRequiredJsxRuntime = 1;
|
|
347
|
+
if (process.env.NODE_ENV === "production") {
|
|
348
|
+
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
349
|
+
} else {
|
|
350
|
+
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
351
|
+
}
|
|
352
|
+
return jsxRuntime.exports;
|
|
307
353
|
}
|
|
308
|
-
var
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
|
|
354
|
+
var jsxRuntimeExports = requireJsxRuntime();
|
|
355
|
+
const KeletContext = createContext(null);
|
|
356
|
+
const KeletBaseUrl = "https://api.kelet.ai/api";
|
|
357
|
+
const useKelet = () => {
|
|
358
|
+
const context = useContext(KeletContext);
|
|
359
|
+
if (!context) {
|
|
312
360
|
throw new Error("useKelet must be used within a KeletProvider");
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
361
|
+
}
|
|
362
|
+
return context;
|
|
363
|
+
};
|
|
364
|
+
const useDefaultFeedbackHandler = () => {
|
|
365
|
+
const context = useContext(KeletContext);
|
|
366
|
+
if (!context) {
|
|
367
|
+
return async () => {
|
|
368
|
+
};
|
|
369
|
+
} else {
|
|
370
|
+
return context.feedback;
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
const KeletProvider = ({ apiKey, project, children }) => {
|
|
374
|
+
const parentContext = useContext(KeletContext);
|
|
375
|
+
const resolvedApiKey = apiKey || parentContext?.api_key;
|
|
376
|
+
if (!resolvedApiKey) {
|
|
321
377
|
throw new Error(
|
|
322
378
|
"apiKey is required either directly or from a parent KeletProvider"
|
|
323
379
|
);
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
project
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
380
|
+
}
|
|
381
|
+
const feedback = async (data) => {
|
|
382
|
+
const url = `${KeletBaseUrl}/projects/${project}/feedback`;
|
|
383
|
+
const req = {
|
|
384
|
+
tx_id: data.tx_id,
|
|
385
|
+
source: data.source || "EXPLICIT",
|
|
386
|
+
vote: data.vote,
|
|
387
|
+
explanation: data.explanation,
|
|
388
|
+
correction: data.correction,
|
|
389
|
+
selection: data.selection
|
|
390
|
+
// Include trigger_name if needed in the future
|
|
391
|
+
};
|
|
392
|
+
const response = await fetch(url, {
|
|
393
|
+
method: "POST",
|
|
394
|
+
headers: {
|
|
395
|
+
"Content-Type": "application/json",
|
|
396
|
+
Authorization: `Bearer ${resolvedApiKey}`
|
|
397
|
+
},
|
|
398
|
+
body: JSON.stringify(req)
|
|
399
|
+
});
|
|
400
|
+
if (!response.ok) {
|
|
401
|
+
throw new Error(`Failed to submit feedback: ${response.statusText}`);
|
|
346
402
|
}
|
|
347
403
|
};
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
404
|
+
const value = {
|
|
405
|
+
api_key: resolvedApiKey,
|
|
406
|
+
project,
|
|
407
|
+
feedback
|
|
408
|
+
};
|
|
409
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(KeletContext.Provider, { value, children });
|
|
410
|
+
};
|
|
411
|
+
const mergeProps = (slotProps, childProps) => {
|
|
412
|
+
const overrideProps = { ...childProps };
|
|
413
|
+
for (const propName in childProps) {
|
|
414
|
+
const slotPropValue = slotProps[propName];
|
|
415
|
+
const childPropValue = childProps[propName];
|
|
416
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
417
|
+
if (isHandler) {
|
|
418
|
+
if (slotPropValue && childPropValue) {
|
|
419
|
+
overrideProps[propName] = (...args) => {
|
|
420
|
+
childPropValue(...args);
|
|
421
|
+
slotPropValue(...args);
|
|
422
|
+
};
|
|
423
|
+
} else if (slotPropValue) {
|
|
424
|
+
overrideProps[propName] = slotPropValue;
|
|
425
|
+
}
|
|
426
|
+
} else if (propName === "style") {
|
|
427
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
428
|
+
} else if (propName === "className") {
|
|
429
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
430
|
+
} else {
|
|
431
|
+
overrideProps[propName] = childPropValue !== void 0 ? childPropValue : slotPropValue;
|
|
432
|
+
}
|
|
356
433
|
}
|
|
357
|
-
return { ...
|
|
358
|
-
}
|
|
434
|
+
return { ...slotProps, ...overrideProps };
|
|
435
|
+
};
|
|
436
|
+
const VoteFeedbackContext = createContext(
|
|
359
437
|
null
|
|
360
|
-
)
|
|
361
|
-
|
|
362
|
-
|
|
438
|
+
);
|
|
439
|
+
const useVoteFeedbackContext = () => {
|
|
440
|
+
const context = useContext(VoteFeedbackContext);
|
|
441
|
+
if (!context) {
|
|
363
442
|
throw new Error(
|
|
364
443
|
"VoteFeedback components must be used within VoteFeedback.Root"
|
|
365
444
|
);
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
445
|
+
}
|
|
446
|
+
return context;
|
|
447
|
+
};
|
|
448
|
+
const VoteFeedbackRoot = ({
|
|
449
|
+
children,
|
|
450
|
+
onFeedback,
|
|
451
|
+
defaultText = "",
|
|
452
|
+
tx_id: txIdProp,
|
|
453
|
+
extra_metadata,
|
|
454
|
+
trigger_name
|
|
374
455
|
}) => {
|
|
375
|
-
const
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
456
|
+
const tx_id = typeof txIdProp === "function" ? txIdProp() : txIdProp;
|
|
457
|
+
const [showPopover, setShowPopover] = useState(false);
|
|
458
|
+
const [feedbackText, setFeedbackText] = useState(defaultText);
|
|
459
|
+
const [isSubmitting, setIsSubmitting] = useState(false);
|
|
460
|
+
const [vote, setVote] = useState(null);
|
|
461
|
+
const textareaRef = useRef(null);
|
|
462
|
+
const triggerRef = useRef(null);
|
|
463
|
+
const popoverId = useId();
|
|
464
|
+
const triggerId = useId();
|
|
465
|
+
const defaultHandler = useDefaultFeedbackHandler();
|
|
466
|
+
const handler = onFeedback || defaultHandler;
|
|
467
|
+
useEffect(() => {
|
|
468
|
+
setShowPopover(false);
|
|
469
|
+
setFeedbackText(defaultText);
|
|
470
|
+
setIsSubmitting(false);
|
|
471
|
+
setVote(null);
|
|
472
|
+
setTimeout(() => triggerRef.current?.focus(), 0);
|
|
473
|
+
}, [tx_id, defaultText]);
|
|
474
|
+
const handleUpvote = useCallback(async () => {
|
|
475
|
+
setVote("upvote");
|
|
476
|
+
const data = {
|
|
477
|
+
tx_id,
|
|
383
478
|
vote: "upvote",
|
|
384
|
-
...
|
|
385
|
-
...
|
|
479
|
+
...extra_metadata && { extra_metadata },
|
|
480
|
+
...trigger_name && { trigger_name }
|
|
386
481
|
};
|
|
387
482
|
try {
|
|
388
|
-
|
|
483
|
+
setIsSubmitting(true);
|
|
484
|
+
await handler(data);
|
|
389
485
|
} finally {
|
|
390
|
-
|
|
486
|
+
setIsSubmitting(false);
|
|
391
487
|
}
|
|
392
|
-
}, [
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
488
|
+
}, [handler, tx_id, extra_metadata, trigger_name]);
|
|
489
|
+
const handleDownvote = useCallback(async () => {
|
|
490
|
+
setVote("downvote");
|
|
491
|
+
if (handler) {
|
|
492
|
+
const data = {
|
|
493
|
+
tx_id,
|
|
396
494
|
vote: "downvote",
|
|
397
|
-
...
|
|
398
|
-
...
|
|
495
|
+
...extra_metadata && { extra_metadata },
|
|
496
|
+
...trigger_name && { trigger_name }
|
|
399
497
|
};
|
|
400
498
|
try {
|
|
401
|
-
|
|
499
|
+
setIsSubmitting(true);
|
|
500
|
+
await handler(data);
|
|
402
501
|
} finally {
|
|
403
|
-
|
|
502
|
+
setIsSubmitting(false);
|
|
404
503
|
}
|
|
405
504
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
505
|
+
setShowPopover(true);
|
|
506
|
+
setTimeout(() => {
|
|
507
|
+
textareaRef.current?.focus();
|
|
508
|
+
const announcement = document.createElement("div");
|
|
509
|
+
announcement.setAttribute("aria-live", "polite");
|
|
510
|
+
announcement.setAttribute("aria-atomic", "true");
|
|
511
|
+
announcement.className = "sr-only";
|
|
512
|
+
announcement.textContent = "Feedback dialog opened. You can provide additional details about your downvote.";
|
|
513
|
+
document.body.appendChild(announcement);
|
|
514
|
+
setTimeout(() => document.body.removeChild(announcement), 1e3);
|
|
410
515
|
}, 0);
|
|
411
|
-
}, [
|
|
412
|
-
|
|
413
|
-
|
|
516
|
+
}, [handler, tx_id, extra_metadata, trigger_name]);
|
|
517
|
+
const handleTextareaChange = useCallback(
|
|
518
|
+
(e) => {
|
|
519
|
+
setFeedbackText(e.target.value);
|
|
414
520
|
},
|
|
415
521
|
[]
|
|
416
|
-
)
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
522
|
+
);
|
|
523
|
+
const handleSubmit = useCallback(async () => {
|
|
524
|
+
const hasText = feedbackText.trim().length > 0;
|
|
525
|
+
if (hasText) {
|
|
526
|
+
const data = {
|
|
527
|
+
tx_id,
|
|
421
528
|
vote: "downvote",
|
|
422
|
-
explanation:
|
|
423
|
-
...
|
|
424
|
-
...
|
|
529
|
+
explanation: feedbackText,
|
|
530
|
+
...extra_metadata && { extra_metadata },
|
|
531
|
+
...trigger_name && { trigger_name }
|
|
425
532
|
};
|
|
426
533
|
try {
|
|
427
|
-
|
|
534
|
+
setIsSubmitting(true);
|
|
535
|
+
await handler(data);
|
|
428
536
|
} finally {
|
|
429
|
-
|
|
537
|
+
setIsSubmitting(false);
|
|
430
538
|
}
|
|
431
539
|
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
540
|
+
setShowPopover(false);
|
|
541
|
+
setFeedbackText(defaultText);
|
|
542
|
+
triggerRef.current?.focus();
|
|
543
|
+
if (hasText) {
|
|
544
|
+
const announcement = document.createElement("div");
|
|
545
|
+
announcement.setAttribute("aria-live", "polite");
|
|
546
|
+
announcement.className = "sr-only";
|
|
547
|
+
announcement.textContent = "Feedback submitted successfully.";
|
|
548
|
+
document.body.appendChild(announcement);
|
|
549
|
+
setTimeout(() => document.body.removeChild(announcement), 1e3);
|
|
435
550
|
}
|
|
436
|
-
}, [
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
551
|
+
}, [handler, feedbackText, defaultText, tx_id, extra_metadata, trigger_name]);
|
|
552
|
+
const handleKeyDown = useCallback(
|
|
553
|
+
(e) => {
|
|
554
|
+
if (e.key === "Escape") {
|
|
555
|
+
setShowPopover(false);
|
|
556
|
+
setFeedbackText(defaultText);
|
|
557
|
+
triggerRef.current?.focus();
|
|
558
|
+
} else if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
559
|
+
e.preventDefault();
|
|
560
|
+
handleSubmit().then((_) => {
|
|
442
561
|
});
|
|
443
|
-
else if (
|
|
444
|
-
const
|
|
445
|
-
if (
|
|
446
|
-
const
|
|
562
|
+
} else if (e.key === "Tab" && showPopover) {
|
|
563
|
+
const popoverElement = document.getElementById(popoverId);
|
|
564
|
+
if (popoverElement) {
|
|
565
|
+
const focusableElements = popoverElement.querySelectorAll(
|
|
447
566
|
'button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'
|
|
448
|
-
)
|
|
449
|
-
|
|
567
|
+
);
|
|
568
|
+
const firstElement = focusableElements[0];
|
|
569
|
+
const lastElement = focusableElements[focusableElements.length - 1];
|
|
570
|
+
if (e.shiftKey && document.activeElement === firstElement) {
|
|
571
|
+
e.preventDefault();
|
|
572
|
+
lastElement?.focus();
|
|
573
|
+
} else if (!e.shiftKey && document.activeElement === lastElement) {
|
|
574
|
+
e.preventDefault();
|
|
575
|
+
firstElement?.focus();
|
|
576
|
+
}
|
|
450
577
|
}
|
|
451
578
|
}
|
|
452
579
|
},
|
|
453
|
-
[
|
|
454
|
-
)
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
580
|
+
[handleSubmit, showPopover, popoverId, defaultText]
|
|
581
|
+
);
|
|
582
|
+
const contextValue = {
|
|
583
|
+
onFeedback: handler,
|
|
584
|
+
showPopover,
|
|
585
|
+
setShowPopover,
|
|
586
|
+
feedbackText,
|
|
587
|
+
setFeedbackText,
|
|
588
|
+
isSubmitting,
|
|
589
|
+
setIsSubmitting,
|
|
590
|
+
vote,
|
|
591
|
+
handleUpvote,
|
|
592
|
+
handleDownvote,
|
|
593
|
+
handleTextareaChange,
|
|
594
|
+
handleSubmit,
|
|
595
|
+
handleKeyDown,
|
|
596
|
+
textareaRef,
|
|
597
|
+
triggerRef,
|
|
598
|
+
popoverId,
|
|
599
|
+
triggerId,
|
|
600
|
+
tx_id,
|
|
601
|
+
extra_metadata,
|
|
602
|
+
trigger_name
|
|
475
603
|
};
|
|
476
|
-
return /* @__PURE__ */
|
|
477
|
-
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
604
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(VoteFeedbackContext.Provider, { value: contextValue, children });
|
|
605
|
+
};
|
|
606
|
+
const UpvoteButton = ({
|
|
607
|
+
asChild,
|
|
608
|
+
children,
|
|
609
|
+
onClick,
|
|
610
|
+
...props
|
|
482
611
|
}) => {
|
|
483
|
-
const { handleUpvote
|
|
484
|
-
|
|
485
|
-
|
|
612
|
+
const { handleUpvote, isSubmitting, vote } = useVoteFeedbackContext();
|
|
613
|
+
const handleClick = useCallback(
|
|
614
|
+
(e) => {
|
|
615
|
+
handleUpvote();
|
|
616
|
+
onClick?.(e);
|
|
486
617
|
},
|
|
487
|
-
[
|
|
488
|
-
)
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
618
|
+
[handleUpvote, onClick]
|
|
619
|
+
);
|
|
620
|
+
const slotProps = {
|
|
621
|
+
...props,
|
|
622
|
+
onClick: handleClick,
|
|
623
|
+
disabled: isSubmitting || props.disabled,
|
|
624
|
+
"aria-label": props["aria-label"] || "Upvote feedback",
|
|
493
625
|
type: "button"
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
626
|
+
};
|
|
627
|
+
const isSelected = vote === "upvote";
|
|
628
|
+
if (asChild) {
|
|
629
|
+
const child = typeof children === "function" ? children({ isSelected }) : children;
|
|
630
|
+
if (isValidElement(child)) {
|
|
631
|
+
return cloneElement(
|
|
632
|
+
child,
|
|
633
|
+
mergeProps(slotProps, child.props)
|
|
501
634
|
);
|
|
635
|
+
}
|
|
502
636
|
}
|
|
503
|
-
return /* @__PURE__ */
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
637
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { ...slotProps, children: typeof children === "function" ? children({ isSelected }) : children });
|
|
638
|
+
};
|
|
639
|
+
const DownvoteButton = ({
|
|
640
|
+
asChild,
|
|
641
|
+
children,
|
|
642
|
+
onClick,
|
|
643
|
+
...props
|
|
509
644
|
}) => {
|
|
510
645
|
const {
|
|
511
|
-
handleDownvote
|
|
512
|
-
showPopover
|
|
513
|
-
isSubmitting
|
|
514
|
-
popoverId
|
|
515
|
-
triggerId
|
|
516
|
-
triggerRef
|
|
517
|
-
vote
|
|
518
|
-
} =
|
|
519
|
-
|
|
520
|
-
|
|
646
|
+
handleDownvote,
|
|
647
|
+
showPopover,
|
|
648
|
+
isSubmitting,
|
|
649
|
+
popoverId,
|
|
650
|
+
triggerId,
|
|
651
|
+
triggerRef,
|
|
652
|
+
vote
|
|
653
|
+
} = useVoteFeedbackContext();
|
|
654
|
+
const handleClick = useCallback(
|
|
655
|
+
(e) => {
|
|
656
|
+
handleDownvote();
|
|
657
|
+
onClick?.(e);
|
|
521
658
|
},
|
|
522
|
-
[
|
|
523
|
-
)
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
"aria-
|
|
530
|
-
"aria-
|
|
531
|
-
|
|
659
|
+
[handleDownvote, onClick]
|
|
660
|
+
);
|
|
661
|
+
const slotProps = {
|
|
662
|
+
...props,
|
|
663
|
+
ref: triggerRef,
|
|
664
|
+
onClick: handleClick,
|
|
665
|
+
disabled: isSubmitting || props.disabled,
|
|
666
|
+
"aria-label": props["aria-label"] || "Downvote feedback",
|
|
667
|
+
"aria-expanded": showPopover,
|
|
668
|
+
"aria-controls": popoverId,
|
|
669
|
+
id: triggerId,
|
|
532
670
|
type: "button"
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
671
|
+
};
|
|
672
|
+
const isSelected = vote === "downvote";
|
|
673
|
+
if (asChild) {
|
|
674
|
+
const child = typeof children === "function" ? children({ isSelected }) : children;
|
|
675
|
+
if (isValidElement(child)) {
|
|
676
|
+
return cloneElement(child, mergeProps(slotProps, child.props));
|
|
677
|
+
} else if (child) {
|
|
678
|
+
return child;
|
|
679
|
+
}
|
|
540
680
|
}
|
|
541
|
-
return /* @__PURE__ */
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
|
|
681
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("button", { ...slotProps, children: typeof children === "function" ? children({ isSelected }) : children });
|
|
682
|
+
};
|
|
683
|
+
const Popover = ({ asChild, children, ...props }) => {
|
|
684
|
+
const { showPopover, handleKeyDown, popoverId, triggerId } = useVoteFeedbackContext();
|
|
685
|
+
if (!showPopover) {
|
|
545
686
|
return null;
|
|
546
|
-
|
|
547
|
-
|
|
687
|
+
}
|
|
688
|
+
const slotProps = {
|
|
689
|
+
...props,
|
|
548
690
|
role: "dialog",
|
|
549
|
-
"aria-labelledby":
|
|
550
|
-
"aria-modal":
|
|
551
|
-
"aria-describedby": `${
|
|
552
|
-
id:
|
|
553
|
-
onKeyDown:
|
|
691
|
+
"aria-labelledby": triggerId,
|
|
692
|
+
"aria-modal": true,
|
|
693
|
+
"aria-describedby": `${popoverId}-description`,
|
|
694
|
+
id: popoverId,
|
|
695
|
+
onKeyDown: handleKeyDown,
|
|
554
696
|
tabIndex: -1
|
|
555
697
|
};
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
698
|
+
if (asChild && isValidElement(children)) {
|
|
699
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
700
|
+
cloneElement(
|
|
701
|
+
children,
|
|
702
|
+
mergeProps(slotProps, children.props)
|
|
703
|
+
),
|
|
704
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" })
|
|
705
|
+
] });
|
|
706
|
+
}
|
|
707
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { ...slotProps, children: [
|
|
708
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: `${popoverId}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
|
|
709
|
+
children
|
|
565
710
|
] });
|
|
566
|
-
}
|
|
711
|
+
};
|
|
712
|
+
const Textarea = ({ asChild, value, onChange, ...props }) => {
|
|
567
713
|
const {
|
|
568
|
-
feedbackText
|
|
569
|
-
handleTextareaChange
|
|
570
|
-
textareaRef
|
|
571
|
-
handleKeyDown
|
|
572
|
-
popoverId
|
|
573
|
-
} =
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
"aria-
|
|
582
|
-
|
|
714
|
+
feedbackText,
|
|
715
|
+
handleTextareaChange,
|
|
716
|
+
textareaRef,
|
|
717
|
+
handleKeyDown,
|
|
718
|
+
popoverId
|
|
719
|
+
} = useVoteFeedbackContext();
|
|
720
|
+
const slotProps = {
|
|
721
|
+
...props,
|
|
722
|
+
ref: textareaRef,
|
|
723
|
+
value: value !== void 0 ? value : feedbackText,
|
|
724
|
+
onChange: onChange || handleTextareaChange,
|
|
725
|
+
onKeyDown: handleKeyDown,
|
|
726
|
+
placeholder: props.placeholder || "What did we miss?",
|
|
727
|
+
"aria-label": props["aria-label"] || "Additional feedback",
|
|
728
|
+
"aria-describedby": `${popoverId}-help`,
|
|
729
|
+
rows: props.rows || 3
|
|
583
730
|
};
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
731
|
+
if (asChild && isValidElement(props.children)) {
|
|
732
|
+
return cloneElement(
|
|
733
|
+
props.children,
|
|
734
|
+
mergeProps(slotProps, props.children.props)
|
|
735
|
+
);
|
|
736
|
+
}
|
|
737
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("textarea", { ...slotProps });
|
|
738
|
+
};
|
|
739
|
+
const SubmitButton = ({
|
|
740
|
+
asChild,
|
|
741
|
+
children,
|
|
742
|
+
onClick,
|
|
743
|
+
...props
|
|
593
744
|
}) => {
|
|
594
|
-
const { handleSubmit
|
|
595
|
-
|
|
596
|
-
|
|
745
|
+
const { handleSubmit, isSubmitting, feedbackText } = useVoteFeedbackContext();
|
|
746
|
+
const handleClick = useCallback(
|
|
747
|
+
(e) => {
|
|
748
|
+
handleSubmit();
|
|
749
|
+
onClick?.(e);
|
|
597
750
|
},
|
|
598
|
-
[
|
|
599
|
-
)
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
751
|
+
[handleSubmit, onClick]
|
|
752
|
+
);
|
|
753
|
+
const hasText = feedbackText.trim().length > 0;
|
|
754
|
+
const buttonText = hasText ? "Submit feedback" : "Close without feedback";
|
|
755
|
+
const slotProps = {
|
|
756
|
+
...props,
|
|
757
|
+
onClick: handleClick,
|
|
758
|
+
disabled: isSubmitting || props.disabled,
|
|
603
759
|
type: "button",
|
|
604
|
-
"aria-label":
|
|
605
|
-
"aria-describedby":
|
|
760
|
+
"aria-label": props["aria-label"] || buttonText,
|
|
761
|
+
"aria-describedby": hasText ? void 0 : "submit-help"
|
|
606
762
|
};
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
763
|
+
if (asChild && isValidElement(children)) {
|
|
764
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
765
|
+
cloneElement(
|
|
766
|
+
children,
|
|
767
|
+
mergeProps(slotProps, children.props)
|
|
768
|
+
),
|
|
769
|
+
!hasText && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
|
|
770
|
+
] });
|
|
771
|
+
}
|
|
772
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("button", { ...slotProps, children: [
|
|
773
|
+
children,
|
|
774
|
+
!hasText && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
|
|
616
775
|
] });
|
|
617
|
-
}, mt = {
|
|
618
|
-
Root: Le,
|
|
619
|
-
UpvoteButton: Me,
|
|
620
|
-
DownvoteButton: $e,
|
|
621
|
-
Popover: qe,
|
|
622
|
-
Textarea: We,
|
|
623
|
-
SubmitButton: Ye
|
|
624
776
|
};
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
777
|
+
const VoteFeedback = {
|
|
778
|
+
Root: VoteFeedbackRoot,
|
|
779
|
+
UpvoteButton,
|
|
780
|
+
DownvoteButton,
|
|
781
|
+
Popover,
|
|
782
|
+
Textarea,
|
|
783
|
+
SubmitButton
|
|
784
|
+
};
|
|
785
|
+
var deepDiff$1 = { exports: {} };
|
|
786
|
+
var deepDiff = deepDiff$1.exports;
|
|
787
|
+
var hasRequiredDeepDiff;
|
|
788
|
+
function requireDeepDiff() {
|
|
789
|
+
if (hasRequiredDeepDiff) return deepDiff$1.exports;
|
|
790
|
+
hasRequiredDeepDiff = 1;
|
|
791
|
+
(function(module, exports) {
|
|
792
|
+
(function(root, factory) {
|
|
793
|
+
var deepDiff2 = factory(root);
|
|
794
|
+
{
|
|
795
|
+
module.exports = deepDiff2;
|
|
796
|
+
}
|
|
797
|
+
})(deepDiff, function(root) {
|
|
798
|
+
var validKinds = ["N", "E", "A", "D"];
|
|
799
|
+
function inherits(ctor, superCtor) {
|
|
800
|
+
ctor.super_ = superCtor;
|
|
801
|
+
ctor.prototype = Object.create(superCtor.prototype, {
|
|
635
802
|
constructor: {
|
|
636
|
-
value:
|
|
637
|
-
enumerable:
|
|
638
|
-
writable:
|
|
639
|
-
configurable:
|
|
803
|
+
value: ctor,
|
|
804
|
+
enumerable: false,
|
|
805
|
+
writable: true,
|
|
806
|
+
configurable: true
|
|
640
807
|
}
|
|
641
808
|
});
|
|
642
809
|
}
|
|
643
|
-
function
|
|
810
|
+
function Diff2(kind, path) {
|
|
644
811
|
Object.defineProperty(this, "kind", {
|
|
645
|
-
value:
|
|
646
|
-
enumerable:
|
|
647
|
-
}), l && l.length && Object.defineProperty(this, "path", {
|
|
648
|
-
value: l,
|
|
649
|
-
enumerable: !0
|
|
812
|
+
value: kind,
|
|
813
|
+
enumerable: true
|
|
650
814
|
});
|
|
815
|
+
if (path && path.length) {
|
|
816
|
+
Object.defineProperty(this, "path", {
|
|
817
|
+
value: path,
|
|
818
|
+
enumerable: true
|
|
819
|
+
});
|
|
820
|
+
}
|
|
651
821
|
}
|
|
652
|
-
function
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
822
|
+
function DiffEdit(path, origin, value) {
|
|
823
|
+
DiffEdit.super_.call(this, "E", path);
|
|
824
|
+
Object.defineProperty(this, "lhs", {
|
|
825
|
+
value: origin,
|
|
826
|
+
enumerable: true
|
|
827
|
+
});
|
|
828
|
+
Object.defineProperty(this, "rhs", {
|
|
829
|
+
value,
|
|
830
|
+
enumerable: true
|
|
659
831
|
});
|
|
660
832
|
}
|
|
661
|
-
|
|
662
|
-
function
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
833
|
+
inherits(DiffEdit, Diff2);
|
|
834
|
+
function DiffNew(path, value) {
|
|
835
|
+
DiffNew.super_.call(this, "N", path);
|
|
836
|
+
Object.defineProperty(this, "rhs", {
|
|
837
|
+
value,
|
|
838
|
+
enumerable: true
|
|
666
839
|
});
|
|
667
840
|
}
|
|
668
|
-
|
|
669
|
-
function
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
841
|
+
inherits(DiffNew, Diff2);
|
|
842
|
+
function DiffDeleted(path, value) {
|
|
843
|
+
DiffDeleted.super_.call(this, "D", path);
|
|
844
|
+
Object.defineProperty(this, "lhs", {
|
|
845
|
+
value,
|
|
846
|
+
enumerable: true
|
|
673
847
|
});
|
|
674
848
|
}
|
|
675
|
-
|
|
676
|
-
function
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
849
|
+
inherits(DiffDeleted, Diff2);
|
|
850
|
+
function DiffArray(path, index, item) {
|
|
851
|
+
DiffArray.super_.call(this, "A", path);
|
|
852
|
+
Object.defineProperty(this, "index", {
|
|
853
|
+
value: index,
|
|
854
|
+
enumerable: true
|
|
855
|
+
});
|
|
856
|
+
Object.defineProperty(this, "item", {
|
|
857
|
+
value: item,
|
|
858
|
+
enumerable: true
|
|
683
859
|
});
|
|
684
860
|
}
|
|
685
|
-
|
|
686
|
-
function
|
|
687
|
-
var
|
|
688
|
-
|
|
861
|
+
inherits(DiffArray, Diff2);
|
|
862
|
+
function arrayRemove(arr, from, to) {
|
|
863
|
+
var rest = arr.slice(from + 1 || arr.length);
|
|
864
|
+
arr.length = from < 0 ? arr.length + from : from;
|
|
865
|
+
arr.push.apply(arr, rest);
|
|
866
|
+
return arr;
|
|
689
867
|
}
|
|
690
|
-
function
|
|
691
|
-
var
|
|
692
|
-
|
|
868
|
+
function realTypeOf(subject) {
|
|
869
|
+
var type = typeof subject;
|
|
870
|
+
if (type !== "object") {
|
|
871
|
+
return type;
|
|
872
|
+
}
|
|
873
|
+
if (subject === Math) {
|
|
874
|
+
return "math";
|
|
875
|
+
} else if (subject === null) {
|
|
876
|
+
return "null";
|
|
877
|
+
} else if (Array.isArray(subject)) {
|
|
878
|
+
return "array";
|
|
879
|
+
} else if (Object.prototype.toString.call(subject) === "[object Date]") {
|
|
880
|
+
return "date";
|
|
881
|
+
} else if (typeof subject.toString === "function" && /^\/.*\//.test(subject.toString())) {
|
|
882
|
+
return "regexp";
|
|
883
|
+
}
|
|
884
|
+
return "object";
|
|
693
885
|
}
|
|
694
|
-
function
|
|
695
|
-
var
|
|
696
|
-
if (
|
|
697
|
-
return
|
|
698
|
-
for (var s = 0; s < i.length; s++) {
|
|
699
|
-
var c = i.charCodeAt(s);
|
|
700
|
-
l = (l << 5) - l + c, l = l & l;
|
|
886
|
+
function hashThisString(string) {
|
|
887
|
+
var hash = 0;
|
|
888
|
+
if (string.length === 0) {
|
|
889
|
+
return hash;
|
|
701
890
|
}
|
|
702
|
-
|
|
891
|
+
for (var i = 0; i < string.length; i++) {
|
|
892
|
+
var char = string.charCodeAt(i);
|
|
893
|
+
hash = (hash << 5) - hash + char;
|
|
894
|
+
hash = hash & hash;
|
|
895
|
+
}
|
|
896
|
+
return hash;
|
|
703
897
|
}
|
|
704
|
-
function
|
|
705
|
-
var
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
898
|
+
function getOrderIndependentHash(object) {
|
|
899
|
+
var accum = 0;
|
|
900
|
+
var type = realTypeOf(object);
|
|
901
|
+
if (type === "array") {
|
|
902
|
+
object.forEach(function(item) {
|
|
903
|
+
accum += getOrderIndependentHash(item);
|
|
709
904
|
});
|
|
710
|
-
var
|
|
711
|
-
return
|
|
905
|
+
var arrayString = "[type: array, hash: " + accum + "]";
|
|
906
|
+
return accum + hashThisString(arrayString);
|
|
712
907
|
}
|
|
713
|
-
if (
|
|
714
|
-
for (var
|
|
715
|
-
if (
|
|
716
|
-
var
|
|
717
|
-
|
|
908
|
+
if (type === "object") {
|
|
909
|
+
for (var key in object) {
|
|
910
|
+
if (object.hasOwnProperty(key)) {
|
|
911
|
+
var keyValueString = "[ type: object, key: " + key + ", value hash: " + getOrderIndependentHash(object[key]) + "]";
|
|
912
|
+
accum += hashThisString(keyValueString);
|
|
718
913
|
}
|
|
719
|
-
|
|
914
|
+
}
|
|
915
|
+
return accum;
|
|
720
916
|
}
|
|
721
|
-
var
|
|
722
|
-
return
|
|
917
|
+
var stringToHash = "[ type: " + type + " ; value: " + object + "]";
|
|
918
|
+
return accum + hashThisString(stringToHash);
|
|
723
919
|
}
|
|
724
|
-
function
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
920
|
+
function deepDiff2(lhs, rhs, changes, prefilter, path, key, stack, orderIndependent) {
|
|
921
|
+
changes = changes || [];
|
|
922
|
+
path = path || [];
|
|
923
|
+
stack = stack || [];
|
|
924
|
+
var currentPath = path.slice(0);
|
|
925
|
+
if (typeof key !== "undefined" && key !== null) {
|
|
926
|
+
if (prefilter) {
|
|
927
|
+
if (typeof prefilter === "function" && prefilter(currentPath, key)) {
|
|
730
928
|
return;
|
|
731
|
-
if (typeof
|
|
732
|
-
if (
|
|
929
|
+
} else if (typeof prefilter === "object") {
|
|
930
|
+
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) {
|
|
733
931
|
return;
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
932
|
+
}
|
|
933
|
+
if (prefilter.normalize) {
|
|
934
|
+
var alt = prefilter.normalize(currentPath, key, lhs, rhs);
|
|
935
|
+
if (alt) {
|
|
936
|
+
lhs = alt[0];
|
|
937
|
+
rhs = alt[1];
|
|
938
|
+
}
|
|
737
939
|
}
|
|
738
940
|
}
|
|
739
941
|
}
|
|
740
|
-
|
|
942
|
+
currentPath.push(key);
|
|
741
943
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
944
|
+
if (realTypeOf(lhs) === "regexp" && realTypeOf(rhs) === "regexp") {
|
|
945
|
+
lhs = lhs.toString();
|
|
946
|
+
rhs = rhs.toString();
|
|
947
|
+
}
|
|
948
|
+
var ltype = typeof lhs;
|
|
949
|
+
var rtype = typeof rhs;
|
|
950
|
+
var i, j, k, other;
|
|
951
|
+
var ldefined = ltype !== "undefined" || stack && stack.length > 0 && stack[stack.length - 1].lhs && Object.getOwnPropertyDescriptor(stack[stack.length - 1].lhs, key);
|
|
952
|
+
var rdefined = rtype !== "undefined" || stack && stack.length > 0 && stack[stack.length - 1].rhs && Object.getOwnPropertyDescriptor(stack[stack.length - 1].rhs, key);
|
|
953
|
+
if (!ldefined && rdefined) {
|
|
954
|
+
changes.push(new DiffNew(currentPath, rhs));
|
|
955
|
+
} else if (!rdefined && ldefined) {
|
|
956
|
+
changes.push(new DiffDeleted(currentPath, lhs));
|
|
957
|
+
} else if (realTypeOf(lhs) !== realTypeOf(rhs)) {
|
|
958
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
959
|
+
} else if (realTypeOf(lhs) === "date" && lhs - rhs !== 0) {
|
|
960
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
961
|
+
} else if (ltype === "object" && lhs !== null && rhs !== null) {
|
|
962
|
+
for (i = stack.length - 1; i > -1; --i) {
|
|
963
|
+
if (stack[i].lhs === lhs) {
|
|
964
|
+
other = true;
|
|
756
965
|
break;
|
|
757
966
|
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
if (
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
967
|
+
}
|
|
968
|
+
if (!other) {
|
|
969
|
+
stack.push({ lhs, rhs });
|
|
970
|
+
if (Array.isArray(lhs)) {
|
|
971
|
+
if (orderIndependent) {
|
|
972
|
+
lhs.sort(function(a, b) {
|
|
973
|
+
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
|
|
974
|
+
});
|
|
975
|
+
rhs.sort(function(a, b) {
|
|
976
|
+
return getOrderIndependentHash(a) - getOrderIndependentHash(b);
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
i = rhs.length - 1;
|
|
980
|
+
j = lhs.length - 1;
|
|
981
|
+
while (i > j) {
|
|
982
|
+
changes.push(new DiffArray(currentPath, i, new DiffNew(void 0, rhs[i--])));
|
|
983
|
+
}
|
|
984
|
+
while (j > i) {
|
|
985
|
+
changes.push(new DiffArray(currentPath, j, new DiffDeleted(void 0, lhs[j--])));
|
|
986
|
+
}
|
|
987
|
+
for (; i >= 0; --i) {
|
|
988
|
+
deepDiff2(lhs[i], rhs[i], changes, prefilter, currentPath, i, stack, orderIndependent);
|
|
989
|
+
}
|
|
772
990
|
} else {
|
|
773
|
-
var
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
991
|
+
var akeys = Object.keys(lhs);
|
|
992
|
+
var pkeys = Object.keys(rhs);
|
|
993
|
+
for (i = 0; i < akeys.length; ++i) {
|
|
994
|
+
k = akeys[i];
|
|
995
|
+
other = pkeys.indexOf(k);
|
|
996
|
+
if (other >= 0) {
|
|
997
|
+
deepDiff2(lhs[k], rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
998
|
+
pkeys[other] = null;
|
|
999
|
+
} else {
|
|
1000
|
+
deepDiff2(lhs[k], void 0, changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
for (i = 0; i < pkeys.length; ++i) {
|
|
1004
|
+
k = pkeys[i];
|
|
1005
|
+
if (k) {
|
|
1006
|
+
deepDiff2(void 0, rhs[k], changes, prefilter, currentPath, k, stack, orderIndependent);
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
778
1009
|
}
|
|
779
|
-
|
|
1010
|
+
stack.length = stack.length - 1;
|
|
1011
|
+
} else if (lhs !== rhs) {
|
|
1012
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
1013
|
+
}
|
|
1014
|
+
} else if (lhs !== rhs) {
|
|
1015
|
+
if (!(ltype === "number" && isNaN(lhs) && isNaN(rhs))) {
|
|
1016
|
+
changes.push(new DiffEdit(currentPath, lhs, rhs));
|
|
780
1017
|
}
|
|
781
|
-
}
|
|
1018
|
+
}
|
|
782
1019
|
}
|
|
783
|
-
function
|
|
784
|
-
var
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
1020
|
+
function observableDiff(lhs, rhs, observer, prefilter, orderIndependent) {
|
|
1021
|
+
var changes = [];
|
|
1022
|
+
deepDiff2(lhs, rhs, changes, prefilter, null, null, null, orderIndependent);
|
|
1023
|
+
if (observer) {
|
|
1024
|
+
for (var i = 0; i < changes.length; ++i) {
|
|
1025
|
+
observer(changes[i]);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return changes;
|
|
789
1029
|
}
|
|
790
|
-
function
|
|
791
|
-
return
|
|
1030
|
+
function orderIndependentDeepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
|
|
1031
|
+
return deepDiff2(lhs, rhs, changes, prefilter, path, key, stack, true);
|
|
792
1032
|
}
|
|
793
|
-
function
|
|
794
|
-
var
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
1033
|
+
function accumulateDiff(lhs, rhs, prefilter, accum) {
|
|
1034
|
+
var observer = accum ? function(difference) {
|
|
1035
|
+
if (difference) {
|
|
1036
|
+
accum.push(difference);
|
|
1037
|
+
}
|
|
1038
|
+
} : void 0;
|
|
1039
|
+
var changes = observableDiff(lhs, rhs, observer, prefilter);
|
|
1040
|
+
return accum ? accum : changes.length ? changes : void 0;
|
|
798
1041
|
}
|
|
799
|
-
function
|
|
800
|
-
var
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
1042
|
+
function accumulateOrderIndependentDiff(lhs, rhs, prefilter, accum) {
|
|
1043
|
+
var observer = accum ? function(difference) {
|
|
1044
|
+
if (difference) {
|
|
1045
|
+
accum.push(difference);
|
|
1046
|
+
}
|
|
1047
|
+
} : void 0;
|
|
1048
|
+
var changes = observableDiff(lhs, rhs, observer, prefilter, true);
|
|
1049
|
+
return accum ? accum : changes.length ? changes : void 0;
|
|
804
1050
|
}
|
|
805
|
-
function
|
|
806
|
-
if (
|
|
807
|
-
var
|
|
808
|
-
for (
|
|
809
|
-
|
|
810
|
-
|
|
1051
|
+
function applyArrayChange(arr, index, change) {
|
|
1052
|
+
if (change.path && change.path.length) {
|
|
1053
|
+
var it = arr[index], i, u = change.path.length - 1;
|
|
1054
|
+
for (i = 0; i < u; i++) {
|
|
1055
|
+
it = it[change.path[i]];
|
|
1056
|
+
}
|
|
1057
|
+
switch (change.kind) {
|
|
811
1058
|
case "A":
|
|
812
|
-
|
|
1059
|
+
applyArrayChange(it[change.path[i]], change.index, change.item);
|
|
813
1060
|
break;
|
|
814
1061
|
case "D":
|
|
815
|
-
delete
|
|
1062
|
+
delete it[change.path[i]];
|
|
816
1063
|
break;
|
|
817
1064
|
case "E":
|
|
818
1065
|
case "N":
|
|
819
|
-
|
|
1066
|
+
it[change.path[i]] = change.rhs;
|
|
820
1067
|
break;
|
|
821
1068
|
}
|
|
822
|
-
} else
|
|
823
|
-
switch (
|
|
1069
|
+
} else {
|
|
1070
|
+
switch (change.kind) {
|
|
824
1071
|
case "A":
|
|
825
|
-
|
|
1072
|
+
applyArrayChange(arr[index], change.index, change.item);
|
|
826
1073
|
break;
|
|
827
1074
|
case "D":
|
|
828
|
-
|
|
1075
|
+
arr = arrayRemove(arr, index);
|
|
829
1076
|
break;
|
|
830
1077
|
case "E":
|
|
831
1078
|
case "N":
|
|
832
|
-
|
|
1079
|
+
arr[index] = change.rhs;
|
|
833
1080
|
break;
|
|
834
1081
|
}
|
|
835
|
-
|
|
1082
|
+
}
|
|
1083
|
+
return arr;
|
|
836
1084
|
}
|
|
837
|
-
function
|
|
838
|
-
if (typeof
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
1085
|
+
function applyChange(target, source, change) {
|
|
1086
|
+
if (typeof change === "undefined" && source && ~validKinds.indexOf(source.kind)) {
|
|
1087
|
+
change = source;
|
|
1088
|
+
}
|
|
1089
|
+
if (target && change && change.kind) {
|
|
1090
|
+
var it = target, i = -1, last = change.path ? change.path.length - 1 : 0;
|
|
1091
|
+
while (++i < last) {
|
|
1092
|
+
if (typeof it[change.path[i]] === "undefined") {
|
|
1093
|
+
it[change.path[i]] = typeof change.path[i + 1] !== "undefined" && typeof change.path[i + 1] === "number" ? [] : {};
|
|
1094
|
+
}
|
|
1095
|
+
it = it[change.path[i]];
|
|
1096
|
+
}
|
|
1097
|
+
switch (change.kind) {
|
|
842
1098
|
case "A":
|
|
843
|
-
|
|
1099
|
+
if (change.path && typeof it[change.path[i]] === "undefined") {
|
|
1100
|
+
it[change.path[i]] = [];
|
|
1101
|
+
}
|
|
1102
|
+
applyArrayChange(change.path ? it[change.path[i]] : it, change.index, change.item);
|
|
844
1103
|
break;
|
|
845
1104
|
case "D":
|
|
846
|
-
delete
|
|
1105
|
+
delete it[change.path[i]];
|
|
847
1106
|
break;
|
|
848
1107
|
case "E":
|
|
849
1108
|
case "N":
|
|
850
|
-
|
|
1109
|
+
it[change.path[i]] = change.rhs;
|
|
851
1110
|
break;
|
|
852
1111
|
}
|
|
853
1112
|
}
|
|
854
1113
|
}
|
|
855
|
-
function
|
|
856
|
-
if (
|
|
857
|
-
var
|
|
858
|
-
for (
|
|
859
|
-
|
|
860
|
-
|
|
1114
|
+
function revertArrayChange(arr, index, change) {
|
|
1115
|
+
if (change.path && change.path.length) {
|
|
1116
|
+
var it = arr[index], i, u = change.path.length - 1;
|
|
1117
|
+
for (i = 0; i < u; i++) {
|
|
1118
|
+
it = it[change.path[i]];
|
|
1119
|
+
}
|
|
1120
|
+
switch (change.kind) {
|
|
861
1121
|
case "A":
|
|
862
|
-
|
|
1122
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
863
1123
|
break;
|
|
864
1124
|
case "D":
|
|
865
|
-
|
|
1125
|
+
it[change.path[i]] = change.lhs;
|
|
866
1126
|
break;
|
|
867
1127
|
case "E":
|
|
868
|
-
|
|
1128
|
+
it[change.path[i]] = change.lhs;
|
|
869
1129
|
break;
|
|
870
1130
|
case "N":
|
|
871
|
-
delete
|
|
1131
|
+
delete it[change.path[i]];
|
|
872
1132
|
break;
|
|
873
1133
|
}
|
|
874
|
-
} else
|
|
875
|
-
switch (
|
|
1134
|
+
} else {
|
|
1135
|
+
switch (change.kind) {
|
|
876
1136
|
case "A":
|
|
877
|
-
|
|
1137
|
+
revertArrayChange(arr[index], change.index, change.item);
|
|
878
1138
|
break;
|
|
879
1139
|
case "D":
|
|
880
|
-
|
|
1140
|
+
arr[index] = change.lhs;
|
|
881
1141
|
break;
|
|
882
1142
|
case "E":
|
|
883
|
-
|
|
1143
|
+
arr[index] = change.lhs;
|
|
884
1144
|
break;
|
|
885
1145
|
case "N":
|
|
886
|
-
|
|
1146
|
+
arr = arrayRemove(arr, index);
|
|
887
1147
|
break;
|
|
888
1148
|
}
|
|
889
|
-
|
|
1149
|
+
}
|
|
1150
|
+
return arr;
|
|
890
1151
|
}
|
|
891
|
-
function
|
|
892
|
-
if (
|
|
893
|
-
var
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1152
|
+
function revertChange(target, source, change) {
|
|
1153
|
+
if (target && source && change && change.kind) {
|
|
1154
|
+
var it = target, i, u;
|
|
1155
|
+
u = change.path.length - 1;
|
|
1156
|
+
for (i = 0; i < u; i++) {
|
|
1157
|
+
if (typeof it[change.path[i]] === "undefined") {
|
|
1158
|
+
it[change.path[i]] = {};
|
|
1159
|
+
}
|
|
1160
|
+
it = it[change.path[i]];
|
|
1161
|
+
}
|
|
1162
|
+
switch (change.kind) {
|
|
897
1163
|
case "A":
|
|
898
|
-
|
|
1164
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
899
1165
|
break;
|
|
900
1166
|
case "D":
|
|
901
|
-
|
|
1167
|
+
it[change.path[i]] = change.lhs;
|
|
902
1168
|
break;
|
|
903
1169
|
case "E":
|
|
904
|
-
|
|
1170
|
+
it[change.path[i]] = change.lhs;
|
|
905
1171
|
break;
|
|
906
1172
|
case "N":
|
|
907
|
-
delete
|
|
1173
|
+
delete it[change.path[i]];
|
|
908
1174
|
break;
|
|
909
1175
|
}
|
|
910
1176
|
}
|
|
911
1177
|
}
|
|
912
|
-
function
|
|
913
|
-
if (
|
|
914
|
-
var
|
|
915
|
-
(!
|
|
1178
|
+
function applyDiff(target, source, filter) {
|
|
1179
|
+
if (target && source) {
|
|
1180
|
+
var onChange = function(change) {
|
|
1181
|
+
if (!filter || filter(target, source, change)) {
|
|
1182
|
+
applyChange(target, source, change);
|
|
1183
|
+
}
|
|
916
1184
|
};
|
|
917
|
-
|
|
1185
|
+
observableDiff(target, source, onChange);
|
|
918
1186
|
}
|
|
919
1187
|
}
|
|
920
|
-
|
|
1188
|
+
Object.defineProperties(accumulateDiff, {
|
|
921
1189
|
diff: {
|
|
922
|
-
value:
|
|
923
|
-
enumerable:
|
|
1190
|
+
value: accumulateDiff,
|
|
1191
|
+
enumerable: true
|
|
924
1192
|
},
|
|
925
1193
|
orderIndependentDiff: {
|
|
926
|
-
value:
|
|
927
|
-
enumerable:
|
|
1194
|
+
value: accumulateOrderIndependentDiff,
|
|
1195
|
+
enumerable: true
|
|
928
1196
|
},
|
|
929
1197
|
observableDiff: {
|
|
930
|
-
value:
|
|
931
|
-
enumerable:
|
|
1198
|
+
value: observableDiff,
|
|
1199
|
+
enumerable: true
|
|
932
1200
|
},
|
|
933
1201
|
orderIndependentObservableDiff: {
|
|
934
|
-
value:
|
|
935
|
-
enumerable:
|
|
1202
|
+
value: orderIndependentDeepDiff,
|
|
1203
|
+
enumerable: true
|
|
936
1204
|
},
|
|
937
1205
|
orderIndepHash: {
|
|
938
|
-
value:
|
|
939
|
-
enumerable:
|
|
1206
|
+
value: getOrderIndependentHash,
|
|
1207
|
+
enumerable: true
|
|
940
1208
|
},
|
|
941
1209
|
applyDiff: {
|
|
942
|
-
value:
|
|
943
|
-
enumerable:
|
|
1210
|
+
value: applyDiff,
|
|
1211
|
+
enumerable: true
|
|
944
1212
|
},
|
|
945
1213
|
applyChange: {
|
|
946
|
-
value:
|
|
947
|
-
enumerable:
|
|
1214
|
+
value: applyChange,
|
|
1215
|
+
enumerable: true
|
|
948
1216
|
},
|
|
949
1217
|
revertChange: {
|
|
950
|
-
value:
|
|
951
|
-
enumerable:
|
|
1218
|
+
value: revertChange,
|
|
1219
|
+
enumerable: true
|
|
952
1220
|
},
|
|
953
1221
|
isConflict: {
|
|
954
1222
|
value: function() {
|
|
955
|
-
return typeof $conflict
|
|
1223
|
+
return typeof $conflict !== "undefined";
|
|
956
1224
|
},
|
|
957
|
-
enumerable:
|
|
1225
|
+
enumerable: true
|
|
958
1226
|
}
|
|
959
|
-
})
|
|
1227
|
+
});
|
|
1228
|
+
accumulateDiff.DeepDiff = accumulateDiff;
|
|
1229
|
+
if (root) {
|
|
1230
|
+
root.DeepDiff = accumulateDiff;
|
|
1231
|
+
}
|
|
1232
|
+
return accumulateDiff;
|
|
960
1233
|
});
|
|
961
|
-
}(
|
|
1234
|
+
})(deepDiff$1);
|
|
1235
|
+
return deepDiff$1.exports;
|
|
962
1236
|
}
|
|
963
|
-
var
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1237
|
+
var deepDiffExports = requireDeepDiff();
|
|
1238
|
+
var levenshtein$1 = { exports: {} };
|
|
1239
|
+
const peq = new Uint32Array(65536);
|
|
1240
|
+
const myers_32 = (a, b) => {
|
|
1241
|
+
const n = a.length;
|
|
1242
|
+
const m = b.length;
|
|
1243
|
+
const lst = 1 << n - 1;
|
|
1244
|
+
let pv = -1;
|
|
1245
|
+
let mv = 0;
|
|
1246
|
+
let sc = n;
|
|
1247
|
+
let i = n;
|
|
1248
|
+
while (i--) {
|
|
1249
|
+
peq[a.charCodeAt(i)] |= 1 << i;
|
|
1250
|
+
}
|
|
1251
|
+
for (i = 0; i < m; i++) {
|
|
1252
|
+
let eq = peq[b.charCodeAt(i)];
|
|
1253
|
+
const xv = eq | mv;
|
|
1254
|
+
eq |= (eq & pv) + pv ^ pv;
|
|
1255
|
+
mv |= ~(eq | pv);
|
|
1256
|
+
pv &= eq;
|
|
1257
|
+
if (mv & lst) {
|
|
1258
|
+
sc++;
|
|
1259
|
+
}
|
|
1260
|
+
if (pv & lst) {
|
|
1261
|
+
sc--;
|
|
1262
|
+
}
|
|
1263
|
+
mv = mv << 1 | 1;
|
|
1264
|
+
pv = pv << 1 | ~(xv | mv);
|
|
1265
|
+
mv &= xv;
|
|
1266
|
+
}
|
|
1267
|
+
i = n;
|
|
1268
|
+
while (i--) {
|
|
1269
|
+
peq[a.charCodeAt(i)] = 0;
|
|
1270
|
+
}
|
|
1271
|
+
return sc;
|
|
1272
|
+
};
|
|
1273
|
+
const myers_x = (b, a) => {
|
|
1274
|
+
const n = a.length;
|
|
1275
|
+
const m = b.length;
|
|
1276
|
+
const mhc = [];
|
|
1277
|
+
const phc = [];
|
|
1278
|
+
const hsize = Math.ceil(n / 32);
|
|
1279
|
+
const vsize = Math.ceil(m / 32);
|
|
1280
|
+
for (let i = 0; i < hsize; i++) {
|
|
1281
|
+
phc[i] = -1;
|
|
1282
|
+
mhc[i] = 0;
|
|
1283
|
+
}
|
|
1284
|
+
let j = 0;
|
|
1285
|
+
for (; j < vsize - 1; j++) {
|
|
1286
|
+
let mv2 = 0;
|
|
1287
|
+
let pv2 = -1;
|
|
1288
|
+
const start2 = j * 32;
|
|
1289
|
+
const vlen2 = Math.min(32, m) + start2;
|
|
1290
|
+
for (let k = start2; k < vlen2; k++) {
|
|
1291
|
+
peq[b.charCodeAt(k)] |= 1 << k;
|
|
1292
|
+
}
|
|
1293
|
+
for (let i = 0; i < n; i++) {
|
|
1294
|
+
const eq = peq[a.charCodeAt(i)];
|
|
1295
|
+
const pb = phc[i / 32 | 0] >>> i & 1;
|
|
1296
|
+
const mb = mhc[i / 32 | 0] >>> i & 1;
|
|
1297
|
+
const xv = eq | mv2;
|
|
1298
|
+
const xh = ((eq | mb) & pv2) + pv2 ^ pv2 | eq | mb;
|
|
1299
|
+
let ph = mv2 | ~(xh | pv2);
|
|
1300
|
+
let mh = pv2 & xh;
|
|
1301
|
+
if (ph >>> 31 ^ pb) {
|
|
1302
|
+
phc[i / 32 | 0] ^= 1 << i;
|
|
1303
|
+
}
|
|
1304
|
+
if (mh >>> 31 ^ mb) {
|
|
1305
|
+
mhc[i / 32 | 0] ^= 1 << i;
|
|
1306
|
+
}
|
|
1307
|
+
ph = ph << 1 | pb;
|
|
1308
|
+
mh = mh << 1 | mb;
|
|
1309
|
+
pv2 = mh | ~(xv | ph);
|
|
1310
|
+
mv2 = ph & xv;
|
|
1311
|
+
}
|
|
1312
|
+
for (let k = start2; k < vlen2; k++) {
|
|
1313
|
+
peq[b.charCodeAt(k)] = 0;
|
|
1314
|
+
}
|
|
973
1315
|
}
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
let
|
|
982
|
-
for (;
|
|
983
|
-
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1316
|
+
let mv = 0;
|
|
1317
|
+
let pv = -1;
|
|
1318
|
+
const start = j * 32;
|
|
1319
|
+
const vlen = Math.min(32, m - start) + start;
|
|
1320
|
+
for (let k = start; k < vlen; k++) {
|
|
1321
|
+
peq[b.charCodeAt(k)] |= 1 << k;
|
|
1322
|
+
}
|
|
1323
|
+
let score = m;
|
|
1324
|
+
for (let i = 0; i < n; i++) {
|
|
1325
|
+
const eq = peq[a.charCodeAt(i)];
|
|
1326
|
+
const pb = phc[i / 32 | 0] >>> i & 1;
|
|
1327
|
+
const mb = mhc[i / 32 | 0] >>> i & 1;
|
|
1328
|
+
const xv = eq | mv;
|
|
1329
|
+
const xh = ((eq | mb) & pv) + pv ^ pv | eq | mb;
|
|
1330
|
+
let ph = mv | ~(xh | pv);
|
|
1331
|
+
let mh = pv & xh;
|
|
1332
|
+
score += ph >>> m - 1 & 1;
|
|
1333
|
+
score -= mh >>> m - 1 & 1;
|
|
1334
|
+
if (ph >>> 31 ^ pb) {
|
|
1335
|
+
phc[i / 32 | 0] ^= 1 << i;
|
|
1336
|
+
}
|
|
1337
|
+
if (mh >>> 31 ^ mb) {
|
|
1338
|
+
mhc[i / 32 | 0] ^= 1 << i;
|
|
991
1339
|
}
|
|
992
|
-
|
|
993
|
-
|
|
1340
|
+
ph = ph << 1 | pb;
|
|
1341
|
+
mh = mh << 1 | mb;
|
|
1342
|
+
pv = mh | ~(xv | ph);
|
|
1343
|
+
mv = ph & xv;
|
|
994
1344
|
}
|
|
995
|
-
let
|
|
996
|
-
|
|
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;
|
|
1345
|
+
for (let k = start; k < vlen; k++) {
|
|
1346
|
+
peq[b.charCodeAt(k)] = 0;
|
|
1004
1347
|
}
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1348
|
+
return score;
|
|
1349
|
+
};
|
|
1350
|
+
const distance = (a, b) => {
|
|
1351
|
+
if (a.length < b.length) {
|
|
1352
|
+
const tmp = b;
|
|
1353
|
+
b = a;
|
|
1354
|
+
a = tmp;
|
|
1355
|
+
}
|
|
1356
|
+
if (b.length === 0) {
|
|
1357
|
+
return a.length;
|
|
1012
1358
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
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);
|
|
1359
|
+
if (a.length <= 32) {
|
|
1360
|
+
return myers_32(a, b);
|
|
1019
1361
|
}
|
|
1020
|
-
return
|
|
1021
|
-
}
|
|
1362
|
+
return myers_x(a, b);
|
|
1363
|
+
};
|
|
1364
|
+
const closest = (str, arr) => {
|
|
1365
|
+
let min_distance = Infinity;
|
|
1366
|
+
let min_index = 0;
|
|
1367
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1368
|
+
const dist = distance(str, arr[i]);
|
|
1369
|
+
if (dist < min_distance) {
|
|
1370
|
+
min_distance = dist;
|
|
1371
|
+
min_index = i;
|
|
1372
|
+
}
|
|
1373
|
+
}
|
|
1374
|
+
return arr[min_index];
|
|
1375
|
+
};
|
|
1376
|
+
const mod = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1022
1377
|
__proto__: null,
|
|
1023
|
-
closest
|
|
1024
|
-
distance
|
|
1025
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1378
|
+
closest,
|
|
1379
|
+
distance
|
|
1380
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
1381
|
+
const require$$0 = /* @__PURE__ */ getAugmentedNamespace(mod);
|
|
1382
|
+
var hasRequiredLevenshtein;
|
|
1383
|
+
function requireLevenshtein() {
|
|
1384
|
+
if (hasRequiredLevenshtein) return levenshtein$1.exports;
|
|
1385
|
+
hasRequiredLevenshtein = 1;
|
|
1386
|
+
(function(module, exports) {
|
|
1029
1387
|
(function() {
|
|
1030
|
-
var
|
|
1388
|
+
var collator;
|
|
1031
1389
|
try {
|
|
1032
|
-
|
|
1033
|
-
} catch {
|
|
1390
|
+
collator = typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
|
1391
|
+
} catch (err) {
|
|
1034
1392
|
console.log("Collator could not be initialized and wouldn't be used");
|
|
1035
1393
|
}
|
|
1036
|
-
var
|
|
1394
|
+
var levenshtein2 = require$$0;
|
|
1395
|
+
var prevRow = [], str2Char = [];
|
|
1396
|
+
var Levenshtein = {
|
|
1037
1397
|
/**
|
|
1038
1398
|
* Calculate levenshtein distance of the two strings.
|
|
1039
1399
|
*
|
|
@@ -1043,484 +1403,724 @@ function Ge() {
|
|
|
1043
1403
|
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
1044
1404
|
* @return Integer the levenshtein distance (0 and above).
|
|
1045
1405
|
*/
|
|
1046
|
-
get: function(
|
|
1047
|
-
var
|
|
1048
|
-
if (
|
|
1049
|
-
var
|
|
1050
|
-
if (
|
|
1051
|
-
if (
|
|
1052
|
-
var
|
|
1053
|
-
for (
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1406
|
+
get: function(str1, str2, options) {
|
|
1407
|
+
var useCollator = options && collator && options.useCollator;
|
|
1408
|
+
if (useCollator) {
|
|
1409
|
+
var str1Len = str1.length, str2Len = str2.length;
|
|
1410
|
+
if (str1Len === 0) return str2Len;
|
|
1411
|
+
if (str2Len === 0) return str1Len;
|
|
1412
|
+
var curCol, nextCol, i, j, tmp;
|
|
1413
|
+
for (i = 0; i < str2Len; ++i) {
|
|
1414
|
+
prevRow[i] = i;
|
|
1415
|
+
str2Char[i] = str2.charCodeAt(i);
|
|
1416
|
+
}
|
|
1417
|
+
prevRow[str2Len] = str2Len;
|
|
1418
|
+
var strCmp;
|
|
1419
|
+
for (i = 0; i < str1Len; ++i) {
|
|
1420
|
+
nextCol = i + 1;
|
|
1421
|
+
for (j = 0; j < str2Len; ++j) {
|
|
1422
|
+
curCol = nextCol;
|
|
1423
|
+
strCmp = 0 === collator.compare(str1.charAt(i), String.fromCharCode(str2Char[j]));
|
|
1424
|
+
nextCol = prevRow[j] + (strCmp ? 0 : 1);
|
|
1425
|
+
tmp = curCol + 1;
|
|
1426
|
+
if (nextCol > tmp) {
|
|
1427
|
+
nextCol = tmp;
|
|
1428
|
+
}
|
|
1429
|
+
tmp = prevRow[j + 1] + 1;
|
|
1430
|
+
if (nextCol > tmp) {
|
|
1431
|
+
nextCol = tmp;
|
|
1432
|
+
}
|
|
1433
|
+
prevRow[j] = curCol;
|
|
1434
|
+
}
|
|
1435
|
+
prevRow[j] = nextCol;
|
|
1061
1436
|
}
|
|
1062
|
-
return
|
|
1437
|
+
return nextCol;
|
|
1063
1438
|
}
|
|
1064
|
-
return
|
|
1439
|
+
return levenshtein2.distance(str1, str2);
|
|
1065
1440
|
}
|
|
1066
1441
|
};
|
|
1067
|
-
|
|
1442
|
+
if (module !== null && true && module.exports === exports) {
|
|
1443
|
+
module.exports = Levenshtein;
|
|
1444
|
+
} else if (typeof self !== "undefined" && typeof self.postMessage === "function" && typeof self.importScripts === "function") {
|
|
1445
|
+
self.Levenshtein = Levenshtein;
|
|
1446
|
+
} else if (typeof window !== "undefined" && window !== null) {
|
|
1447
|
+
window.Levenshtein = Levenshtein;
|
|
1448
|
+
}
|
|
1068
1449
|
})();
|
|
1069
|
-
}(
|
|
1450
|
+
})(levenshtein$1, levenshtein$1.exports);
|
|
1451
|
+
return levenshtein$1.exports;
|
|
1070
1452
|
}
|
|
1071
|
-
var
|
|
1072
|
-
const
|
|
1073
|
-
class
|
|
1074
|
-
diff(
|
|
1075
|
-
let
|
|
1076
|
-
typeof
|
|
1077
|
-
|
|
1078
|
-
|
|
1453
|
+
var levenshteinExports = requireLevenshtein();
|
|
1454
|
+
const levenshtein = /* @__PURE__ */ getDefaultExportFromCjs(levenshteinExports);
|
|
1455
|
+
class Diff {
|
|
1456
|
+
diff(oldStr, newStr, options = {}) {
|
|
1457
|
+
let callback;
|
|
1458
|
+
if (typeof options === "function") {
|
|
1459
|
+
callback = options;
|
|
1460
|
+
options = {};
|
|
1461
|
+
} else if ("callback" in options) {
|
|
1462
|
+
callback = options.callback;
|
|
1463
|
+
}
|
|
1464
|
+
const oldString = this.castInput(oldStr, options);
|
|
1465
|
+
const newString = this.castInput(newStr, options);
|
|
1466
|
+
const oldTokens = this.removeEmpty(this.tokenize(oldString, options));
|
|
1467
|
+
const newTokens = this.removeEmpty(this.tokenize(newString, options));
|
|
1468
|
+
return this.diffWithOptionsObj(oldTokens, newTokens, options, callback);
|
|
1079
1469
|
}
|
|
1080
|
-
diffWithOptionsObj(
|
|
1081
|
-
var
|
|
1082
|
-
const
|
|
1083
|
-
|
|
1470
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
1471
|
+
var _a;
|
|
1472
|
+
const done = (value) => {
|
|
1473
|
+
value = this.postProcess(value, options);
|
|
1474
|
+
if (callback) {
|
|
1084
1475
|
setTimeout(function() {
|
|
1085
|
-
|
|
1476
|
+
callback(value);
|
|
1086
1477
|
}, 0);
|
|
1087
|
-
return;
|
|
1088
|
-
} else
|
|
1089
|
-
return
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
let
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1478
|
+
return void 0;
|
|
1479
|
+
} else {
|
|
1480
|
+
return value;
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
1484
|
+
let editLength = 1;
|
|
1485
|
+
let maxEditLength = newLen + oldLen;
|
|
1486
|
+
if (options.maxEditLength != null) {
|
|
1487
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
1488
|
+
}
|
|
1489
|
+
const maxExecutionTime = (_a = options.timeout) !== null && _a !== void 0 ? _a : Infinity;
|
|
1490
|
+
const abortAfterTimestamp = Date.now() + maxExecutionTime;
|
|
1491
|
+
const bestPath = [{ oldPos: -1, lastComponent: void 0 }];
|
|
1492
|
+
let newPos = this.extractCommon(bestPath[0], newTokens, oldTokens, 0, options);
|
|
1493
|
+
if (bestPath[0].oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
1494
|
+
return done(this.buildValues(bestPath[0].lastComponent, newTokens, oldTokens));
|
|
1495
|
+
}
|
|
1496
|
+
let minDiagonalToConsider = -Infinity, maxDiagonalToConsider = Infinity;
|
|
1497
|
+
const execEditLength = () => {
|
|
1498
|
+
for (let diagonalPath = Math.max(minDiagonalToConsider, -editLength); diagonalPath <= Math.min(maxDiagonalToConsider, editLength); diagonalPath += 2) {
|
|
1499
|
+
let basePath;
|
|
1500
|
+
const removePath = bestPath[diagonalPath - 1], addPath = bestPath[diagonalPath + 1];
|
|
1501
|
+
if (removePath) {
|
|
1502
|
+
bestPath[diagonalPath - 1] = void 0;
|
|
1107
1503
|
}
|
|
1108
|
-
|
|
1109
|
-
if (
|
|
1110
|
-
|
|
1504
|
+
let canAdd = false;
|
|
1505
|
+
if (addPath) {
|
|
1506
|
+
const addPathNewPos = addPath.oldPos - diagonalPath;
|
|
1507
|
+
canAdd = addPath && 0 <= addPathNewPos && addPathNewPos < newLen;
|
|
1508
|
+
}
|
|
1509
|
+
const canRemove = removePath && removePath.oldPos + 1 < oldLen;
|
|
1510
|
+
if (!canAdd && !canRemove) {
|
|
1511
|
+
bestPath[diagonalPath] = void 0;
|
|
1111
1512
|
continue;
|
|
1112
1513
|
}
|
|
1113
|
-
if (!
|
|
1114
|
-
|
|
1115
|
-
|
|
1514
|
+
if (!canRemove || canAdd && removePath.oldPos < addPath.oldPos) {
|
|
1515
|
+
basePath = this.addToPath(addPath, true, false, 0, options);
|
|
1516
|
+
} else {
|
|
1517
|
+
basePath = this.addToPath(removePath, false, true, 1, options);
|
|
1518
|
+
}
|
|
1519
|
+
newPos = this.extractCommon(basePath, newTokens, oldTokens, diagonalPath, options);
|
|
1520
|
+
if (basePath.oldPos + 1 >= oldLen && newPos + 1 >= newLen) {
|
|
1521
|
+
return done(this.buildValues(basePath.lastComponent, newTokens, oldTokens)) || true;
|
|
1522
|
+
} else {
|
|
1523
|
+
bestPath[diagonalPath] = basePath;
|
|
1524
|
+
if (basePath.oldPos + 1 >= oldLen) {
|
|
1525
|
+
maxDiagonalToConsider = Math.min(maxDiagonalToConsider, diagonalPath - 1);
|
|
1526
|
+
}
|
|
1527
|
+
if (newPos + 1 >= newLen) {
|
|
1528
|
+
minDiagonalToConsider = Math.max(minDiagonalToConsider, diagonalPath + 1);
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1116
1531
|
}
|
|
1117
|
-
|
|
1532
|
+
editLength++;
|
|
1118
1533
|
};
|
|
1119
|
-
if (
|
|
1120
|
-
(function
|
|
1534
|
+
if (callback) {
|
|
1535
|
+
(function exec() {
|
|
1121
1536
|
setTimeout(function() {
|
|
1122
|
-
if (
|
|
1123
|
-
return
|
|
1124
|
-
|
|
1537
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
1538
|
+
return callback(void 0);
|
|
1539
|
+
}
|
|
1540
|
+
if (!execEditLength()) {
|
|
1541
|
+
exec();
|
|
1542
|
+
}
|
|
1125
1543
|
}, 0);
|
|
1126
1544
|
})();
|
|
1127
|
-
else
|
|
1128
|
-
|
|
1129
|
-
const
|
|
1130
|
-
if (
|
|
1131
|
-
return
|
|
1545
|
+
} else {
|
|
1546
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
1547
|
+
const ret = execEditLength();
|
|
1548
|
+
if (ret) {
|
|
1549
|
+
return ret;
|
|
1550
|
+
}
|
|
1132
1551
|
}
|
|
1552
|
+
}
|
|
1133
1553
|
}
|
|
1134
|
-
addToPath(
|
|
1135
|
-
const
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1554
|
+
addToPath(path, added, removed, oldPosInc, options) {
|
|
1555
|
+
const last = path.lastComponent;
|
|
1556
|
+
if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
|
|
1557
|
+
return {
|
|
1558
|
+
oldPos: path.oldPos + oldPosInc,
|
|
1559
|
+
lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
|
|
1560
|
+
};
|
|
1561
|
+
} else {
|
|
1562
|
+
return {
|
|
1563
|
+
oldPos: path.oldPos + oldPosInc,
|
|
1564
|
+
lastComponent: { count: 1, added, removed, previousComponent: last }
|
|
1565
|
+
};
|
|
1566
|
+
}
|
|
1143
1567
|
}
|
|
1144
|
-
extractCommon(
|
|
1145
|
-
const
|
|
1146
|
-
let
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1568
|
+
extractCommon(basePath, newTokens, oldTokens, diagonalPath, options) {
|
|
1569
|
+
const newLen = newTokens.length, oldLen = oldTokens.length;
|
|
1570
|
+
let oldPos = basePath.oldPos, newPos = oldPos - diagonalPath, commonCount = 0;
|
|
1571
|
+
while (newPos + 1 < newLen && oldPos + 1 < oldLen && this.equals(oldTokens[oldPos + 1], newTokens[newPos + 1], options)) {
|
|
1572
|
+
newPos++;
|
|
1573
|
+
oldPos++;
|
|
1574
|
+
commonCount++;
|
|
1575
|
+
if (options.oneChangePerToken) {
|
|
1576
|
+
basePath.lastComponent = { count: 1, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
1577
|
+
}
|
|
1578
|
+
}
|
|
1579
|
+
if (commonCount && !options.oneChangePerToken) {
|
|
1580
|
+
basePath.lastComponent = { count: commonCount, previousComponent: basePath.lastComponent, added: false, removed: false };
|
|
1581
|
+
}
|
|
1582
|
+
basePath.oldPos = oldPos;
|
|
1583
|
+
return newPos;
|
|
1150
1584
|
}
|
|
1151
|
-
equals(
|
|
1152
|
-
|
|
1585
|
+
equals(left, right, options) {
|
|
1586
|
+
if (options.comparator) {
|
|
1587
|
+
return options.comparator(left, right);
|
|
1588
|
+
} else {
|
|
1589
|
+
return left === right || !!options.ignoreCase && left.toLowerCase() === right.toLowerCase();
|
|
1590
|
+
}
|
|
1153
1591
|
}
|
|
1154
|
-
removeEmpty(
|
|
1155
|
-
const
|
|
1156
|
-
for (let
|
|
1157
|
-
|
|
1158
|
-
|
|
1592
|
+
removeEmpty(array) {
|
|
1593
|
+
const ret = [];
|
|
1594
|
+
for (let i = 0; i < array.length; i++) {
|
|
1595
|
+
if (array[i]) {
|
|
1596
|
+
ret.push(array[i]);
|
|
1597
|
+
}
|
|
1598
|
+
}
|
|
1599
|
+
return ret;
|
|
1159
1600
|
}
|
|
1160
1601
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1161
|
-
castInput(
|
|
1162
|
-
return
|
|
1602
|
+
castInput(value, options) {
|
|
1603
|
+
return value;
|
|
1163
1604
|
}
|
|
1164
1605
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1165
|
-
tokenize(
|
|
1166
|
-
return Array.from(
|
|
1606
|
+
tokenize(value, options) {
|
|
1607
|
+
return Array.from(value);
|
|
1167
1608
|
}
|
|
1168
|
-
join(
|
|
1169
|
-
return
|
|
1609
|
+
join(chars) {
|
|
1610
|
+
return chars.join("");
|
|
1170
1611
|
}
|
|
1171
|
-
postProcess(
|
|
1172
|
-
return
|
|
1612
|
+
postProcess(changeObjects, options) {
|
|
1613
|
+
return changeObjects;
|
|
1173
1614
|
}
|
|
1174
1615
|
get useLongestToken() {
|
|
1175
|
-
return
|
|
1616
|
+
return false;
|
|
1176
1617
|
}
|
|
1177
|
-
buildValues(
|
|
1178
|
-
const
|
|
1179
|
-
let
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1618
|
+
buildValues(lastComponent, newTokens, oldTokens) {
|
|
1619
|
+
const components = [];
|
|
1620
|
+
let nextComponent;
|
|
1621
|
+
while (lastComponent) {
|
|
1622
|
+
components.push(lastComponent);
|
|
1623
|
+
nextComponent = lastComponent.previousComponent;
|
|
1624
|
+
delete lastComponent.previousComponent;
|
|
1625
|
+
lastComponent = nextComponent;
|
|
1626
|
+
}
|
|
1627
|
+
components.reverse();
|
|
1628
|
+
const componentLen = components.length;
|
|
1629
|
+
let componentPos = 0, newPos = 0, oldPos = 0;
|
|
1630
|
+
for (; componentPos < componentLen; componentPos++) {
|
|
1631
|
+
const component = components[componentPos];
|
|
1632
|
+
if (!component.removed) {
|
|
1633
|
+
if (!component.added && this.useLongestToken) {
|
|
1634
|
+
let value = newTokens.slice(newPos, newPos + component.count);
|
|
1635
|
+
value = value.map(function(value2, i) {
|
|
1636
|
+
const oldValue = oldTokens[oldPos + i];
|
|
1637
|
+
return oldValue.length > value2.length ? oldValue : value2;
|
|
1638
|
+
});
|
|
1639
|
+
component.value = this.join(value);
|
|
1640
|
+
} else {
|
|
1641
|
+
component.value = this.join(newTokens.slice(newPos, newPos + component.count));
|
|
1642
|
+
}
|
|
1643
|
+
newPos += component.count;
|
|
1644
|
+
if (!component.added) {
|
|
1645
|
+
oldPos += component.count;
|
|
1646
|
+
}
|
|
1647
|
+
} else {
|
|
1648
|
+
component.value = this.join(oldTokens.slice(oldPos, oldPos + component.count));
|
|
1649
|
+
oldPos += component.count;
|
|
1199
1650
|
}
|
|
1200
1651
|
}
|
|
1201
|
-
return
|
|
1652
|
+
return components;
|
|
1202
1653
|
}
|
|
1203
1654
|
}
|
|
1204
|
-
class
|
|
1655
|
+
class LineDiff extends Diff {
|
|
1205
1656
|
constructor() {
|
|
1206
|
-
super(...arguments)
|
|
1657
|
+
super(...arguments);
|
|
1658
|
+
this.tokenize = tokenize;
|
|
1207
1659
|
}
|
|
1208
|
-
equals(
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1660
|
+
equals(left, right, options) {
|
|
1661
|
+
if (options.ignoreWhitespace) {
|
|
1662
|
+
if (!options.newlineIsToken || !left.includes("\n")) {
|
|
1663
|
+
left = left.trim();
|
|
1664
|
+
}
|
|
1665
|
+
if (!options.newlineIsToken || !right.includes("\n")) {
|
|
1666
|
+
right = right.trim();
|
|
1667
|
+
}
|
|
1668
|
+
} else if (options.ignoreNewlineAtEof && !options.newlineIsToken) {
|
|
1669
|
+
if (left.endsWith("\n")) {
|
|
1670
|
+
left = left.slice(0, -1);
|
|
1671
|
+
}
|
|
1672
|
+
if (right.endsWith("\n")) {
|
|
1673
|
+
right = right.slice(0, -1);
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
return super.equals(left, right, options);
|
|
1214
1677
|
}
|
|
1215
1678
|
}
|
|
1216
|
-
const
|
|
1217
|
-
function
|
|
1218
|
-
return
|
|
1679
|
+
const lineDiff = new LineDiff();
|
|
1680
|
+
function diffLines(oldStr, newStr, options) {
|
|
1681
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
1219
1682
|
}
|
|
1220
|
-
function
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
o % 2 && !e.newlineIsToken ? t[t.length - 1] += u : t.push(u);
|
|
1683
|
+
function tokenize(value, options) {
|
|
1684
|
+
if (options.stripTrailingCr) {
|
|
1685
|
+
value = value.replace(/\r\n/g, "\n");
|
|
1686
|
+
}
|
|
1687
|
+
const retLines = [], linesAndNewlines = value.split(/(\n|\r\n)/);
|
|
1688
|
+
if (!linesAndNewlines[linesAndNewlines.length - 1]) {
|
|
1689
|
+
linesAndNewlines.pop();
|
|
1228
1690
|
}
|
|
1229
|
-
|
|
1691
|
+
for (let i = 0; i < linesAndNewlines.length; i++) {
|
|
1692
|
+
const line = linesAndNewlines[i];
|
|
1693
|
+
if (i % 2 && !options.newlineIsToken) {
|
|
1694
|
+
retLines[retLines.length - 1] += line;
|
|
1695
|
+
} else {
|
|
1696
|
+
retLines.push(line);
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
return retLines;
|
|
1230
1700
|
}
|
|
1231
|
-
function
|
|
1232
|
-
let
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
if (
|
|
1701
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1702
|
+
let optionsObj;
|
|
1703
|
+
if (!options) {
|
|
1704
|
+
optionsObj = {};
|
|
1705
|
+
} else if (typeof options === "function") {
|
|
1706
|
+
optionsObj = { callback: options };
|
|
1707
|
+
} else {
|
|
1708
|
+
optionsObj = options;
|
|
1709
|
+
}
|
|
1710
|
+
if (typeof optionsObj.context === "undefined") {
|
|
1711
|
+
optionsObj.context = 4;
|
|
1712
|
+
}
|
|
1713
|
+
const context = optionsObj.context;
|
|
1714
|
+
if (optionsObj.newlineIsToken) {
|
|
1236
1715
|
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1716
|
+
}
|
|
1717
|
+
if (!optionsObj.callback) {
|
|
1718
|
+
return diffLinesResultToPatch(diffLines(oldStr, newStr, optionsObj));
|
|
1719
|
+
} else {
|
|
1720
|
+
const { callback } = optionsObj;
|
|
1721
|
+
diffLines(oldStr, newStr, Object.assign(Object.assign({}, optionsObj), { callback: (diff) => {
|
|
1722
|
+
const patch = diffLinesResultToPatch(diff);
|
|
1723
|
+
callback(patch);
|
|
1242
1724
|
} }));
|
|
1243
|
-
}
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
if (!m)
|
|
1725
|
+
}
|
|
1726
|
+
function diffLinesResultToPatch(diff) {
|
|
1727
|
+
if (!diff) {
|
|
1247
1728
|
return;
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1729
|
+
}
|
|
1730
|
+
diff.push({ value: "", lines: [] });
|
|
1731
|
+
function contextLines(lines) {
|
|
1732
|
+
return lines.map(function(entry) {
|
|
1733
|
+
return " " + entry;
|
|
1252
1734
|
});
|
|
1253
1735
|
}
|
|
1254
|
-
const
|
|
1255
|
-
let
|
|
1256
|
-
for (let
|
|
1257
|
-
const
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1736
|
+
const hunks = [];
|
|
1737
|
+
let oldRangeStart = 0, newRangeStart = 0, curRange = [], oldLine = 1, newLine = 1;
|
|
1738
|
+
for (let i = 0; i < diff.length; i++) {
|
|
1739
|
+
const current = diff[i], lines = current.lines || splitLines(current.value);
|
|
1740
|
+
current.lines = lines;
|
|
1741
|
+
if (current.added || current.removed) {
|
|
1742
|
+
if (!oldRangeStart) {
|
|
1743
|
+
const prev = diff[i - 1];
|
|
1744
|
+
oldRangeStart = oldLine;
|
|
1745
|
+
newRangeStart = newLine;
|
|
1746
|
+
if (prev) {
|
|
1747
|
+
curRange = context > 0 ? contextLines(prev.lines.slice(-context)) : [];
|
|
1748
|
+
oldRangeStart -= curRange.length;
|
|
1749
|
+
newRangeStart -= curRange.length;
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
for (const line of lines) {
|
|
1753
|
+
curRange.push((current.added ? "+" : "-") + line);
|
|
1754
|
+
}
|
|
1755
|
+
if (current.added) {
|
|
1756
|
+
newLine += lines.length;
|
|
1757
|
+
} else {
|
|
1758
|
+
oldLine += lines.length;
|
|
1262
1759
|
}
|
|
1263
|
-
for (const R of O)
|
|
1264
|
-
g.push((k.added ? "+" : "-") + R);
|
|
1265
|
-
k.added ? P += O.length : C += O.length;
|
|
1266
1760
|
} else {
|
|
1267
|
-
if (
|
|
1268
|
-
if (
|
|
1269
|
-
for (const
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1761
|
+
if (oldRangeStart) {
|
|
1762
|
+
if (lines.length <= context * 2 && i < diff.length - 2) {
|
|
1763
|
+
for (const line of contextLines(lines)) {
|
|
1764
|
+
curRange.push(line);
|
|
1765
|
+
}
|
|
1766
|
+
} else {
|
|
1767
|
+
const contextSize = Math.min(lines.length, context);
|
|
1768
|
+
for (const line of contextLines(lines.slice(0, contextSize))) {
|
|
1769
|
+
curRange.push(line);
|
|
1770
|
+
}
|
|
1771
|
+
const hunk = {
|
|
1772
|
+
oldStart: oldRangeStart,
|
|
1773
|
+
oldLines: oldLine - oldRangeStart + contextSize,
|
|
1774
|
+
newStart: newRangeStart,
|
|
1775
|
+
newLines: newLine - newRangeStart + contextSize,
|
|
1776
|
+
lines: curRange
|
|
1281
1777
|
};
|
|
1282
|
-
|
|
1778
|
+
hunks.push(hunk);
|
|
1779
|
+
oldRangeStart = 0;
|
|
1780
|
+
newRangeStart = 0;
|
|
1781
|
+
curRange = [];
|
|
1283
1782
|
}
|
|
1284
|
-
|
|
1783
|
+
}
|
|
1784
|
+
oldLine += lines.length;
|
|
1785
|
+
newLine += lines.length;
|
|
1786
|
+
}
|
|
1787
|
+
}
|
|
1788
|
+
for (const hunk of hunks) {
|
|
1789
|
+
for (let i = 0; i < hunk.lines.length; i++) {
|
|
1790
|
+
if (hunk.lines[i].endsWith("\n")) {
|
|
1791
|
+
hunk.lines[i] = hunk.lines[i].slice(0, -1);
|
|
1792
|
+
} else {
|
|
1793
|
+
hunk.lines.splice(i + 1, 0, "\");
|
|
1794
|
+
i++;
|
|
1795
|
+
}
|
|
1285
1796
|
}
|
|
1286
1797
|
}
|
|
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
1798
|
return {
|
|
1292
|
-
oldFileName
|
|
1293
|
-
newFileName
|
|
1294
|
-
oldHeader
|
|
1295
|
-
newHeader
|
|
1296
|
-
hunks
|
|
1799
|
+
oldFileName,
|
|
1800
|
+
newFileName,
|
|
1801
|
+
oldHeader,
|
|
1802
|
+
newHeader,
|
|
1803
|
+
hunks
|
|
1297
1804
|
};
|
|
1298
1805
|
}
|
|
1299
1806
|
}
|
|
1300
|
-
function
|
|
1301
|
-
if (Array.isArray(
|
|
1302
|
-
return
|
|
1303
|
-
|
|
1304
|
-
const
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1807
|
+
function formatPatch(patch) {
|
|
1808
|
+
if (Array.isArray(patch)) {
|
|
1809
|
+
return patch.map(formatPatch).join("\n");
|
|
1810
|
+
}
|
|
1811
|
+
const ret = [];
|
|
1812
|
+
if (patch.oldFileName == patch.newFileName) {
|
|
1813
|
+
ret.push("Index: " + patch.oldFileName);
|
|
1814
|
+
}
|
|
1815
|
+
ret.push("===================================================================");
|
|
1816
|
+
ret.push("--- " + patch.oldFileName + (typeof patch.oldHeader === "undefined" ? "" : " " + patch.oldHeader));
|
|
1817
|
+
ret.push("+++ " + patch.newFileName + (typeof patch.newHeader === "undefined" ? "" : " " + patch.newHeader));
|
|
1818
|
+
for (let i = 0; i < patch.hunks.length; i++) {
|
|
1819
|
+
const hunk = patch.hunks[i];
|
|
1820
|
+
if (hunk.oldLines === 0) {
|
|
1821
|
+
hunk.oldStart -= 1;
|
|
1822
|
+
}
|
|
1823
|
+
if (hunk.newLines === 0) {
|
|
1824
|
+
hunk.newStart -= 1;
|
|
1825
|
+
}
|
|
1826
|
+
ret.push("@@ -" + hunk.oldStart + "," + hunk.oldLines + " +" + hunk.newStart + "," + hunk.newLines + " @@");
|
|
1827
|
+
for (const line of hunk.lines) {
|
|
1828
|
+
ret.push(line);
|
|
1829
|
+
}
|
|
1311
1830
|
}
|
|
1312
|
-
return
|
|
1313
|
-
`) + `
|
|
1314
|
-
`;
|
|
1831
|
+
return ret.join("\n") + "\n";
|
|
1315
1832
|
}
|
|
1316
|
-
function
|
|
1317
|
-
if (typeof
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1833
|
+
function createTwoFilesPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1834
|
+
if (typeof options === "function") {
|
|
1835
|
+
options = { callback: options };
|
|
1836
|
+
}
|
|
1837
|
+
if (!(options === null || options === void 0 ? void 0 : options.callback)) {
|
|
1838
|
+
const patchObj = structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
1839
|
+
if (!patchObj) {
|
|
1840
|
+
return;
|
|
1841
|
+
}
|
|
1842
|
+
return formatPatch(patchObj);
|
|
1322
1843
|
} else {
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1844
|
+
const { callback } = options;
|
|
1845
|
+
structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, Object.assign(Object.assign({}, options), { callback: (patchObj) => {
|
|
1846
|
+
if (!patchObj) {
|
|
1847
|
+
callback(void 0);
|
|
1848
|
+
} else {
|
|
1849
|
+
callback(formatPatch(patchObj));
|
|
1850
|
+
}
|
|
1851
|
+
} }));
|
|
1325
1852
|
}
|
|
1326
1853
|
}
|
|
1327
|
-
function
|
|
1328
|
-
const
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1854
|
+
function splitLines(text) {
|
|
1855
|
+
const hasTrailingNl = text.endsWith("\n");
|
|
1856
|
+
const result = text.split("\n").map((line) => line + "\n");
|
|
1857
|
+
if (hasTrailingNl) {
|
|
1858
|
+
result.pop();
|
|
1859
|
+
} else {
|
|
1860
|
+
result.push(result.pop().slice(0, -1));
|
|
1861
|
+
}
|
|
1862
|
+
return result;
|
|
1333
1863
|
}
|
|
1334
|
-
function
|
|
1335
|
-
switch (
|
|
1864
|
+
function formatDiff(oldValue, newValue, diffType = "git", context = 3) {
|
|
1865
|
+
switch (diffType) {
|
|
1336
1866
|
case "git":
|
|
1337
|
-
return
|
|
1867
|
+
return formatGitDiff(oldValue, newValue, context);
|
|
1338
1868
|
case "object":
|
|
1339
|
-
return
|
|
1869
|
+
return formatObjectDiff(oldValue, newValue);
|
|
1340
1870
|
case "json":
|
|
1341
|
-
return
|
|
1871
|
+
return formatJsonDiff(oldValue, newValue);
|
|
1342
1872
|
default:
|
|
1343
|
-
return
|
|
1873
|
+
return formatGitDiff(oldValue, newValue, context);
|
|
1344
1874
|
}
|
|
1345
1875
|
}
|
|
1346
|
-
function
|
|
1347
|
-
const
|
|
1348
|
-
|
|
1876
|
+
function formatGitDiff(oldValue, newValue, context = 3) {
|
|
1877
|
+
const oldStr = stringify(oldValue);
|
|
1878
|
+
const newStr = stringify(newValue);
|
|
1879
|
+
const patch = createTwoFilesPatch(
|
|
1349
1880
|
/* oldFilename */
|
|
1350
1881
|
"",
|
|
1351
1882
|
/* newFilename */
|
|
1352
1883
|
"",
|
|
1353
|
-
|
|
1354
|
-
|
|
1884
|
+
oldStr,
|
|
1885
|
+
newStr,
|
|
1355
1886
|
/* oldHeader */
|
|
1356
1887
|
"",
|
|
1357
1888
|
/* newHeader */
|
|
1358
1889
|
"",
|
|
1359
|
-
{ context
|
|
1360
|
-
)
|
|
1361
|
-
|
|
1362
|
-
`);
|
|
1890
|
+
{ context }
|
|
1891
|
+
);
|
|
1892
|
+
return patch.split("\n").slice(2).join("\n");
|
|
1363
1893
|
}
|
|
1364
|
-
function
|
|
1365
|
-
const
|
|
1366
|
-
return JSON.stringify(
|
|
1894
|
+
function formatObjectDiff(oldValue, newValue) {
|
|
1895
|
+
const differences = deepDiffExports.diff(oldValue, newValue) || [];
|
|
1896
|
+
return JSON.stringify(differences, null, 2);
|
|
1367
1897
|
}
|
|
1368
|
-
function
|
|
1898
|
+
function formatJsonDiff(oldValue, newValue) {
|
|
1369
1899
|
return JSON.stringify(
|
|
1370
1900
|
{
|
|
1371
|
-
before:
|
|
1372
|
-
after:
|
|
1901
|
+
before: oldValue,
|
|
1902
|
+
after: newValue
|
|
1373
1903
|
},
|
|
1374
1904
|
null,
|
|
1375
1905
|
2
|
|
1376
1906
|
);
|
|
1377
1907
|
}
|
|
1378
|
-
function
|
|
1379
|
-
|
|
1908
|
+
function calculateDiffPercentage(oldValue, newValue) {
|
|
1909
|
+
if (typeof oldValue === "string" && typeof newValue === "string") {
|
|
1910
|
+
return calculateStringDiffPercentage(oldValue, newValue);
|
|
1911
|
+
} else if (typeof oldValue === "number" && typeof newValue === "number") {
|
|
1912
|
+
return calculateNumberDiffPercentage(oldValue, newValue);
|
|
1913
|
+
} else {
|
|
1914
|
+
return calculateObjectDiffPercentage(oldValue, newValue);
|
|
1915
|
+
}
|
|
1380
1916
|
}
|
|
1381
|
-
function
|
|
1382
|
-
if (
|
|
1383
|
-
if (
|
|
1384
|
-
|
|
1385
|
-
|
|
1917
|
+
function calculateStringDiffPercentage(oldStr, newStr) {
|
|
1918
|
+
if (oldStr === newStr) return 0;
|
|
1919
|
+
if (oldStr.length === 0) return 1;
|
|
1920
|
+
if (newStr.length === 0) return 1;
|
|
1921
|
+
const distance2 = levenshtein.get(oldStr, newStr);
|
|
1922
|
+
const maxLength = Math.max(oldStr.length, newStr.length);
|
|
1923
|
+
return distance2 / maxLength;
|
|
1386
1924
|
}
|
|
1387
|
-
function
|
|
1388
|
-
if (
|
|
1389
|
-
if (
|
|
1390
|
-
const
|
|
1391
|
-
|
|
1925
|
+
function calculateNumberDiffPercentage(oldNum, newNum) {
|
|
1926
|
+
if (oldNum === newNum) return 0;
|
|
1927
|
+
if (oldNum === 0) return 1;
|
|
1928
|
+
const change = Math.abs(newNum - oldNum);
|
|
1929
|
+
const base = Math.max(Math.abs(oldNum), Math.abs(newNum));
|
|
1930
|
+
return Math.min(change / base, 1);
|
|
1392
1931
|
}
|
|
1393
|
-
function
|
|
1394
|
-
if (
|
|
1395
|
-
const
|
|
1396
|
-
if (
|
|
1397
|
-
const
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1932
|
+
function calculateObjectDiffPercentage(oldObj, newObj) {
|
|
1933
|
+
if (oldObj === newObj) return 0;
|
|
1934
|
+
const differences = deepDiffExports.diff(oldObj, newObj) || [];
|
|
1935
|
+
if (differences.length === 0) return 0;
|
|
1936
|
+
const oldProps = countObjectProperties(oldObj);
|
|
1937
|
+
const newProps = countObjectProperties(newObj);
|
|
1938
|
+
const totalProps = Math.max(oldProps, newProps);
|
|
1939
|
+
if (totalProps === 0) return 0;
|
|
1940
|
+
let changeWeight = 0;
|
|
1941
|
+
for (const difference of differences) {
|
|
1942
|
+
switch (difference.kind) {
|
|
1402
1943
|
case "N":
|
|
1403
|
-
|
|
1944
|
+
changeWeight += 1;
|
|
1404
1945
|
break;
|
|
1405
1946
|
case "D":
|
|
1406
|
-
|
|
1947
|
+
changeWeight += 1;
|
|
1407
1948
|
break;
|
|
1408
1949
|
case "E":
|
|
1409
|
-
if (typeof
|
|
1410
|
-
const
|
|
1411
|
-
|
|
1412
|
-
|
|
1950
|
+
if (typeof difference.lhs === "string" && typeof difference.rhs === "string") {
|
|
1951
|
+
const stringChangeRatio = calculateStringDiffPercentage(
|
|
1952
|
+
difference.lhs,
|
|
1953
|
+
difference.rhs
|
|
1413
1954
|
);
|
|
1414
|
-
|
|
1415
|
-
} else if (typeof
|
|
1416
|
-
const
|
|
1417
|
-
|
|
1418
|
-
|
|
1955
|
+
changeWeight += stringChangeRatio;
|
|
1956
|
+
} else if (typeof difference.lhs === "number" && typeof difference.rhs === "number") {
|
|
1957
|
+
const numberChangeRatio = calculateNumberDiffPercentage(
|
|
1958
|
+
difference.lhs,
|
|
1959
|
+
difference.rhs
|
|
1419
1960
|
);
|
|
1420
|
-
|
|
1421
|
-
} else
|
|
1422
|
-
|
|
1961
|
+
changeWeight += numberChangeRatio;
|
|
1962
|
+
} else {
|
|
1963
|
+
changeWeight += 1;
|
|
1964
|
+
}
|
|
1423
1965
|
break;
|
|
1424
1966
|
case "A":
|
|
1425
|
-
|
|
1967
|
+
changeWeight += 0.5;
|
|
1426
1968
|
break;
|
|
1427
1969
|
}
|
|
1428
|
-
|
|
1970
|
+
}
|
|
1971
|
+
return Math.min(changeWeight / totalProps, 1);
|
|
1429
1972
|
}
|
|
1430
|
-
function
|
|
1431
|
-
if (
|
|
1432
|
-
if (typeof
|
|
1433
|
-
if (Array.isArray(
|
|
1434
|
-
let
|
|
1435
|
-
for (const
|
|
1436
|
-
Object.prototype.hasOwnProperty.call(
|
|
1437
|
-
|
|
1973
|
+
function countObjectProperties(obj) {
|
|
1974
|
+
if (obj === null || obj === void 0) return 0;
|
|
1975
|
+
if (typeof obj !== "object") return 1;
|
|
1976
|
+
if (Array.isArray(obj)) return obj.length;
|
|
1977
|
+
let count = 0;
|
|
1978
|
+
for (const key in obj) {
|
|
1979
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
1980
|
+
count += 1;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
return count;
|
|
1438
1984
|
}
|
|
1439
|
-
function
|
|
1985
|
+
function stringify(value) {
|
|
1440
1986
|
try {
|
|
1441
1987
|
return JSON.stringify(
|
|
1442
|
-
|
|
1443
|
-
(
|
|
1988
|
+
value,
|
|
1989
|
+
(_key, val) => {
|
|
1990
|
+
if (typeof val === "function") return "[Function]";
|
|
1991
|
+
if (val === void 0) return "[undefined]";
|
|
1992
|
+
if (val === Infinity) return "[Infinity]";
|
|
1993
|
+
if (Number.isNaN(val)) return "[NaN]";
|
|
1994
|
+
return val;
|
|
1995
|
+
},
|
|
1444
1996
|
2
|
|
1445
1997
|
);
|
|
1446
|
-
} catch {
|
|
1447
|
-
return String(
|
|
1998
|
+
} catch (_) {
|
|
1999
|
+
return String(value);
|
|
1448
2000
|
}
|
|
1449
2001
|
}
|
|
1450
|
-
function
|
|
1451
|
-
const
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
2002
|
+
function useStateChangeTracking(currentState, tx_id, options) {
|
|
2003
|
+
const defaultFeedbackHandler = useDefaultFeedbackHandler();
|
|
2004
|
+
const feedbackHandler = options?.onFeedback || defaultFeedbackHandler;
|
|
2005
|
+
const debounceMs = options?.debounceMs ?? 1500;
|
|
2006
|
+
const diffType = options?.diffType ?? "git";
|
|
2007
|
+
const compareWith = options?.compareWith;
|
|
2008
|
+
const defaultTriggerName = options?.default_trigger_name ?? "auto_state_change";
|
|
2009
|
+
const prevStateRef = useRef(currentState);
|
|
2010
|
+
const changeStartStateRef = useRef(currentState);
|
|
2011
|
+
const isFirstRenderRef = useRef(true);
|
|
2012
|
+
const timeoutRef = useRef(null);
|
|
2013
|
+
const currentTriggerNameRef = useRef(void 0);
|
|
2014
|
+
const sendFeedback = useCallback(
|
|
2015
|
+
(startState, endState, triggerName) => {
|
|
2016
|
+
const diffPercentage = calculateDiffPercentage(startState, endState);
|
|
2017
|
+
const diffString = formatDiff(startState, endState, diffType);
|
|
2018
|
+
let vote;
|
|
2019
|
+
if (options?.vote) {
|
|
2020
|
+
if (typeof options.vote === "function") {
|
|
2021
|
+
vote = options.vote(startState, endState, diffPercentage);
|
|
2022
|
+
} else {
|
|
2023
|
+
vote = options.vote;
|
|
2024
|
+
}
|
|
2025
|
+
} else {
|
|
2026
|
+
vote = diffPercentage > 0.5 ? "downvote" : "upvote";
|
|
2027
|
+
}
|
|
2028
|
+
const idString = typeof tx_id === "function" ? tx_id(endState) : tx_id;
|
|
2029
|
+
feedbackHandler({
|
|
2030
|
+
tx_id: idString,
|
|
2031
|
+
vote,
|
|
2032
|
+
explanation: `State change with diff percentage: ${(diffPercentage * 100).toFixed(1)}%`,
|
|
2033
|
+
correction: diffString,
|
|
1462
2034
|
source: "IMPLICIT",
|
|
1463
|
-
extra_metadata:
|
|
1464
|
-
trigger_name:
|
|
2035
|
+
extra_metadata: options?.metadata,
|
|
2036
|
+
trigger_name: triggerName
|
|
1465
2037
|
});
|
|
1466
2038
|
},
|
|
1467
|
-
[
|
|
1468
|
-
)
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
2039
|
+
[options, tx_id, diffType, feedbackHandler]
|
|
2040
|
+
);
|
|
2041
|
+
const notifyChange = useCallback(
|
|
2042
|
+
(trigger_name) => {
|
|
2043
|
+
const newTriggerName = trigger_name || defaultTriggerName;
|
|
2044
|
+
if (timeoutRef.current && currentTriggerNameRef.current && currentTriggerNameRef.current !== newTriggerName) {
|
|
2045
|
+
clearTimeout(timeoutRef.current);
|
|
2046
|
+
const startState = changeStartStateRef.current;
|
|
2047
|
+
const currentStateBeforeChange = currentState;
|
|
2048
|
+
sendFeedback(
|
|
2049
|
+
startState,
|
|
2050
|
+
currentStateBeforeChange,
|
|
2051
|
+
currentTriggerNameRef.current
|
|
2052
|
+
);
|
|
2053
|
+
timeoutRef.current = null;
|
|
1479
2054
|
}
|
|
1480
|
-
|
|
2055
|
+
currentTriggerNameRef.current = newTriggerName;
|
|
1481
2056
|
},
|
|
1482
|
-
[
|
|
2057
|
+
[currentState, defaultTriggerName, sendFeedback]
|
|
1483
2058
|
);
|
|
1484
|
-
|
|
1485
|
-
if (
|
|
1486
|
-
|
|
2059
|
+
useEffect(() => {
|
|
2060
|
+
if (isFirstRenderRef.current) {
|
|
2061
|
+
isFirstRenderRef.current = false;
|
|
2062
|
+
prevStateRef.current = currentState;
|
|
2063
|
+
changeStartStateRef.current = currentState;
|
|
1487
2064
|
return;
|
|
1488
2065
|
}
|
|
1489
|
-
const
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
2066
|
+
const prevState = prevStateRef.current;
|
|
2067
|
+
const isEqual = compareWith ? compareWith(prevState, currentState) : JSON.stringify(prevState) === JSON.stringify(currentState);
|
|
2068
|
+
if (!isEqual) {
|
|
2069
|
+
if (!timeoutRef.current) {
|
|
2070
|
+
changeStartStateRef.current = prevState;
|
|
2071
|
+
}
|
|
2072
|
+
if (timeoutRef.current) {
|
|
2073
|
+
clearTimeout(timeoutRef.current);
|
|
2074
|
+
}
|
|
2075
|
+
prevStateRef.current = currentState;
|
|
2076
|
+
timeoutRef.current = setTimeout(() => {
|
|
2077
|
+
const startState = changeStartStateRef.current;
|
|
2078
|
+
const finalState = currentState;
|
|
2079
|
+
sendFeedback(
|
|
2080
|
+
startState,
|
|
2081
|
+
finalState,
|
|
2082
|
+
currentTriggerNameRef.current || defaultTriggerName
|
|
2083
|
+
);
|
|
2084
|
+
changeStartStateRef.current = finalState;
|
|
2085
|
+
timeoutRef.current = null;
|
|
2086
|
+
}, debounceMs);
|
|
2087
|
+
}
|
|
2088
|
+
return () => {
|
|
2089
|
+
if (timeoutRef.current) {
|
|
2090
|
+
clearTimeout(timeoutRef.current);
|
|
2091
|
+
}
|
|
1499
2092
|
};
|
|
1500
2093
|
}, [
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
])
|
|
1511
|
-
|
|
2094
|
+
currentState,
|
|
2095
|
+
tx_id,
|
|
2096
|
+
options,
|
|
2097
|
+
feedbackHandler,
|
|
2098
|
+
diffType,
|
|
2099
|
+
debounceMs,
|
|
2100
|
+
compareWith,
|
|
2101
|
+
defaultTriggerName,
|
|
2102
|
+
sendFeedback
|
|
2103
|
+
]);
|
|
2104
|
+
return {
|
|
2105
|
+
notifyChange
|
|
1512
2106
|
};
|
|
1513
2107
|
}
|
|
1514
|
-
function
|
|
1515
|
-
const [
|
|
1516
|
-
|
|
1517
|
-
|
|
2108
|
+
function useFeedbackState(initialState, tx_id, options) {
|
|
2109
|
+
const [state, setStateInternal] = useState(initialState);
|
|
2110
|
+
const { notifyChange } = useStateChangeTracking(state, tx_id, options);
|
|
2111
|
+
const setState = useCallback(
|
|
2112
|
+
(value, trigger_name) => {
|
|
2113
|
+
notifyChange(trigger_name);
|
|
2114
|
+
setStateInternal((prevState) => {
|
|
2115
|
+
const newState = typeof value === "function" ? value(prevState) : value;
|
|
2116
|
+
return newState;
|
|
2117
|
+
});
|
|
1518
2118
|
},
|
|
1519
|
-
[
|
|
2119
|
+
[notifyChange]
|
|
1520
2120
|
);
|
|
1521
|
-
return [
|
|
2121
|
+
return [state, setState];
|
|
1522
2122
|
}
|
|
1523
|
-
let
|
|
2123
|
+
let _loadOtelApi = () => {
|
|
1524
2124
|
try {
|
|
1525
2125
|
return require("@opentelemetry/api");
|
|
1526
2126
|
} catch {
|
|
@@ -1529,21 +2129,23 @@ let ft = () => {
|
|
|
1529
2129
|
);
|
|
1530
2130
|
}
|
|
1531
2131
|
};
|
|
1532
|
-
function
|
|
1533
|
-
const { trace
|
|
2132
|
+
function getOtelTraceId() {
|
|
2133
|
+
const { trace, context } = _loadOtelApi();
|
|
1534
2134
|
try {
|
|
1535
|
-
const
|
|
1536
|
-
if (
|
|
1537
|
-
return
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
2135
|
+
const spanContext = trace.getSpanContext(context.active());
|
|
2136
|
+
if (spanContext?.traceId) {
|
|
2137
|
+
return spanContext.traceId;
|
|
2138
|
+
}
|
|
2139
|
+
const activeSpan = trace.getSpan(context.active());
|
|
2140
|
+
if (activeSpan) {
|
|
2141
|
+
const spanCtx = activeSpan.spanContext();
|
|
2142
|
+
if (spanCtx.traceId) {
|
|
2143
|
+
return spanCtx.traceId;
|
|
2144
|
+
}
|
|
1543
2145
|
}
|
|
1544
|
-
} catch (
|
|
2146
|
+
} catch (error) {
|
|
1545
2147
|
throw new Error(
|
|
1546
|
-
`Failed to extract OpenTelemetry trace ID: ${
|
|
2148
|
+
`Failed to extract OpenTelemetry trace ID: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1547
2149
|
);
|
|
1548
2150
|
}
|
|
1549
2151
|
throw new Error(
|
|
@@ -1551,11 +2153,12 @@ function bt() {
|
|
|
1551
2153
|
);
|
|
1552
2154
|
}
|
|
1553
2155
|
export {
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
2156
|
+
KeletContext,
|
|
2157
|
+
KeletProvider,
|
|
2158
|
+
VoteFeedback,
|
|
2159
|
+
getOtelTraceId,
|
|
2160
|
+
useDefaultFeedbackHandler,
|
|
2161
|
+
useFeedbackState,
|
|
2162
|
+
useKelet
|
|
1561
2163
|
};
|
|
2164
|
+
//# sourceMappingURL=feedback-ui.es.js.map
|