@kelet-ai/feedback-ui 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/feedback-ui.es.js +1729 -1122
- package/dist/feedback-ui.es.js.map +1 -0
- package/dist/feedback-ui.es.min.js +1562 -0
- package/dist/feedback-ui.es.min.js.map +1 -0
- package/dist/feedback-ui.umd.js +2167 -36
- package/dist/feedback-ui.umd.js.map +1 -0
- package/dist/feedback-ui.umd.min.js +37 -0
- package/dist/feedback-ui.umd.min.js.map +1 -0
- package/package.json +15 -4
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,968 +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
|
-
|
|
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,
|
|
379
478
|
vote: "upvote",
|
|
380
|
-
...
|
|
381
|
-
...
|
|
479
|
+
...extra_metadata && { extra_metadata },
|
|
480
|
+
...trigger_name && { trigger_name }
|
|
382
481
|
};
|
|
383
482
|
try {
|
|
384
|
-
|
|
483
|
+
setIsSubmitting(true);
|
|
484
|
+
await handler(data);
|
|
385
485
|
} finally {
|
|
386
|
-
|
|
486
|
+
setIsSubmitting(false);
|
|
387
487
|
}
|
|
388
|
-
}, [
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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,
|
|
392
494
|
vote: "downvote",
|
|
393
|
-
...
|
|
394
|
-
...
|
|
495
|
+
...extra_metadata && { extra_metadata },
|
|
496
|
+
...trigger_name && { trigger_name }
|
|
395
497
|
};
|
|
396
498
|
try {
|
|
397
|
-
|
|
499
|
+
setIsSubmitting(true);
|
|
500
|
+
await handler(data);
|
|
398
501
|
} finally {
|
|
399
|
-
|
|
502
|
+
setIsSubmitting(false);
|
|
400
503
|
}
|
|
401
504
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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);
|
|
406
515
|
}, 0);
|
|
407
|
-
}, [
|
|
408
|
-
|
|
409
|
-
|
|
516
|
+
}, [handler, tx_id, extra_metadata, trigger_name]);
|
|
517
|
+
const handleTextareaChange = useCallback(
|
|
518
|
+
(e) => {
|
|
519
|
+
setFeedbackText(e.target.value);
|
|
410
520
|
},
|
|
411
521
|
[]
|
|
412
|
-
)
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
522
|
+
);
|
|
523
|
+
const handleSubmit = useCallback(async () => {
|
|
524
|
+
const hasText = feedbackText.trim().length > 0;
|
|
525
|
+
if (hasText) {
|
|
526
|
+
const data = {
|
|
527
|
+
tx_id,
|
|
417
528
|
vote: "downvote",
|
|
418
|
-
explanation:
|
|
419
|
-
...
|
|
420
|
-
...
|
|
529
|
+
explanation: feedbackText,
|
|
530
|
+
...extra_metadata && { extra_metadata },
|
|
531
|
+
...trigger_name && { trigger_name }
|
|
421
532
|
};
|
|
422
533
|
try {
|
|
423
|
-
|
|
534
|
+
setIsSubmitting(true);
|
|
535
|
+
await handler(data);
|
|
424
536
|
} finally {
|
|
425
|
-
|
|
537
|
+
setIsSubmitting(false);
|
|
426
538
|
}
|
|
427
539
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
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);
|
|
431
550
|
}
|
|
432
|
-
}, [
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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((_) => {
|
|
438
561
|
});
|
|
439
|
-
else if (
|
|
440
|
-
const
|
|
441
|
-
if (
|
|
442
|
-
const
|
|
562
|
+
} else if (e.key === "Tab" && showPopover) {
|
|
563
|
+
const popoverElement = document.getElementById(popoverId);
|
|
564
|
+
if (popoverElement) {
|
|
565
|
+
const focusableElements = popoverElement.querySelectorAll(
|
|
443
566
|
'button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'
|
|
444
|
-
)
|
|
445
|
-
|
|
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
|
+
}
|
|
446
577
|
}
|
|
447
578
|
}
|
|
448
579
|
},
|
|
449
|
-
[
|
|
450
|
-
)
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
|
471
603
|
};
|
|
472
|
-
return /* @__PURE__ */
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
604
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(VoteFeedbackContext.Provider, { value: contextValue, children });
|
|
605
|
+
};
|
|
606
|
+
const UpvoteButton = ({
|
|
607
|
+
asChild,
|
|
608
|
+
children,
|
|
609
|
+
onClick,
|
|
610
|
+
...props
|
|
478
611
|
}) => {
|
|
479
|
-
const { handleUpvote
|
|
480
|
-
|
|
481
|
-
|
|
612
|
+
const { handleUpvote, isSubmitting, vote } = useVoteFeedbackContext();
|
|
613
|
+
const handleClick = useCallback(
|
|
614
|
+
(e) => {
|
|
615
|
+
handleUpvote();
|
|
616
|
+
onClick?.(e);
|
|
482
617
|
},
|
|
483
|
-
[
|
|
484
|
-
)
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
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",
|
|
489
625
|
type: "button"
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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)
|
|
497
634
|
);
|
|
635
|
+
}
|
|
498
636
|
}
|
|
499
|
-
return /* @__PURE__ */
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
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
|
|
505
644
|
}) => {
|
|
506
645
|
const {
|
|
507
|
-
handleDownvote
|
|
508
|
-
showPopover
|
|
509
|
-
isSubmitting
|
|
510
|
-
popoverId
|
|
511
|
-
triggerId
|
|
512
|
-
triggerRef
|
|
513
|
-
vote
|
|
514
|
-
} =
|
|
515
|
-
|
|
516
|
-
|
|
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);
|
|
517
658
|
},
|
|
518
|
-
[
|
|
519
|
-
)
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
"aria-
|
|
526
|
-
"aria-
|
|
527
|
-
|
|
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,
|
|
528
670
|
type: "button"
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
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
|
+
}
|
|
536
680
|
}
|
|
537
|
-
return /* @__PURE__ */
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
|
|
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) {
|
|
541
686
|
return null;
|
|
542
|
-
|
|
543
|
-
|
|
687
|
+
}
|
|
688
|
+
const slotProps = {
|
|
689
|
+
...props,
|
|
544
690
|
role: "dialog",
|
|
545
|
-
"aria-labelledby":
|
|
546
|
-
"aria-modal":
|
|
547
|
-
"aria-describedby": `${
|
|
548
|
-
id:
|
|
549
|
-
onKeyDown:
|
|
691
|
+
"aria-labelledby": triggerId,
|
|
692
|
+
"aria-modal": true,
|
|
693
|
+
"aria-describedby": `${popoverId}-description`,
|
|
694
|
+
id: popoverId,
|
|
695
|
+
onKeyDown: handleKeyDown,
|
|
550
696
|
tabIndex: -1
|
|
551
697
|
};
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
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
|
|
561
710
|
] });
|
|
562
|
-
}
|
|
711
|
+
};
|
|
712
|
+
const Textarea = ({ asChild, value, onChange, ...props }) => {
|
|
563
713
|
const {
|
|
564
|
-
feedbackText
|
|
565
|
-
handleTextareaChange
|
|
566
|
-
textareaRef
|
|
567
|
-
handleKeyDown
|
|
568
|
-
popoverId
|
|
569
|
-
} =
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
"aria-
|
|
578
|
-
|
|
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
|
|
579
730
|
};
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
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
|
|
589
744
|
}) => {
|
|
590
|
-
const { handleSubmit
|
|
591
|
-
|
|
592
|
-
|
|
745
|
+
const { handleSubmit, isSubmitting, feedbackText } = useVoteFeedbackContext();
|
|
746
|
+
const handleClick = useCallback(
|
|
747
|
+
(e) => {
|
|
748
|
+
handleSubmit();
|
|
749
|
+
onClick?.(e);
|
|
593
750
|
},
|
|
594
|
-
[
|
|
595
|
-
)
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
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,
|
|
599
759
|
type: "button",
|
|
600
|
-
"aria-label":
|
|
601
|
-
"aria-describedby":
|
|
760
|
+
"aria-label": props["aria-label"] || buttonText,
|
|
761
|
+
"aria-describedby": hasText ? void 0 : "submit-help"
|
|
602
762
|
};
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
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" })
|
|
612
775
|
] });
|
|
613
|
-
}, mt = {
|
|
614
|
-
Root: Le,
|
|
615
|
-
UpvoteButton: Me,
|
|
616
|
-
DownvoteButton: $e,
|
|
617
|
-
Popover: qe,
|
|
618
|
-
Textarea: We,
|
|
619
|
-
SubmitButton: Ye
|
|
620
776
|
};
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
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, {
|
|
631
802
|
constructor: {
|
|
632
|
-
value:
|
|
633
|
-
enumerable:
|
|
634
|
-
writable:
|
|
635
|
-
configurable:
|
|
803
|
+
value: ctor,
|
|
804
|
+
enumerable: false,
|
|
805
|
+
writable: true,
|
|
806
|
+
configurable: true
|
|
636
807
|
}
|
|
637
808
|
});
|
|
638
809
|
}
|
|
639
|
-
function
|
|
810
|
+
function Diff2(kind, path) {
|
|
640
811
|
Object.defineProperty(this, "kind", {
|
|
641
|
-
value:
|
|
642
|
-
enumerable:
|
|
643
|
-
}), l && l.length && Object.defineProperty(this, "path", {
|
|
644
|
-
value: l,
|
|
645
|
-
enumerable: !0
|
|
812
|
+
value: kind,
|
|
813
|
+
enumerable: true
|
|
646
814
|
});
|
|
815
|
+
if (path && path.length) {
|
|
816
|
+
Object.defineProperty(this, "path", {
|
|
817
|
+
value: path,
|
|
818
|
+
enumerable: true
|
|
819
|
+
});
|
|
820
|
+
}
|
|
647
821
|
}
|
|
648
|
-
function
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
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
|
|
655
831
|
});
|
|
656
832
|
}
|
|
657
|
-
|
|
658
|
-
function
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
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
|
|
662
839
|
});
|
|
663
840
|
}
|
|
664
|
-
|
|
665
|
-
function
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
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
|
|
669
847
|
});
|
|
670
848
|
}
|
|
671
|
-
|
|
672
|
-
function
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
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
|
|
679
859
|
});
|
|
680
860
|
}
|
|
681
|
-
|
|
682
|
-
function
|
|
683
|
-
var
|
|
684
|
-
|
|
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;
|
|
685
867
|
}
|
|
686
|
-
function
|
|
687
|
-
var
|
|
688
|
-
|
|
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";
|
|
689
885
|
}
|
|
690
|
-
function
|
|
691
|
-
var
|
|
692
|
-
if (
|
|
693
|
-
return
|
|
694
|
-
for (var s = 0; s < i.length; s++) {
|
|
695
|
-
var c = i.charCodeAt(s);
|
|
696
|
-
l = (l << 5) - l + c, l = l & l;
|
|
886
|
+
function hashThisString(string) {
|
|
887
|
+
var hash = 0;
|
|
888
|
+
if (string.length === 0) {
|
|
889
|
+
return hash;
|
|
697
890
|
}
|
|
698
|
-
|
|
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;
|
|
699
897
|
}
|
|
700
|
-
function
|
|
701
|
-
var
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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);
|
|
705
904
|
});
|
|
706
|
-
var
|
|
707
|
-
return
|
|
905
|
+
var arrayString = "[type: array, hash: " + accum + "]";
|
|
906
|
+
return accum + hashThisString(arrayString);
|
|
708
907
|
}
|
|
709
|
-
if (
|
|
710
|
-
for (var
|
|
711
|
-
if (
|
|
712
|
-
var
|
|
713
|
-
|
|
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);
|
|
714
913
|
}
|
|
715
|
-
|
|
914
|
+
}
|
|
915
|
+
return accum;
|
|
716
916
|
}
|
|
717
|
-
var
|
|
718
|
-
return
|
|
917
|
+
var stringToHash = "[ type: " + type + " ; value: " + object + "]";
|
|
918
|
+
return accum + hashThisString(stringToHash);
|
|
719
919
|
}
|
|
720
|
-
function
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
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)) {
|
|
726
928
|
return;
|
|
727
|
-
if (typeof
|
|
728
|
-
if (
|
|
929
|
+
} else if (typeof prefilter === "object") {
|
|
930
|
+
if (prefilter.prefilter && prefilter.prefilter(currentPath, key)) {
|
|
729
931
|
return;
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
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
|
+
}
|
|
733
939
|
}
|
|
734
940
|
}
|
|
735
941
|
}
|
|
736
|
-
|
|
942
|
+
currentPath.push(key);
|
|
737
943
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
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;
|
|
752
965
|
break;
|
|
753
966
|
}
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
if (
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
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
|
+
}
|
|
768
990
|
} else {
|
|
769
|
-
var
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
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
|
+
}
|
|
774
1009
|
}
|
|
775
|
-
|
|
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));
|
|
776
1017
|
}
|
|
777
|
-
}
|
|
1018
|
+
}
|
|
778
1019
|
}
|
|
779
|
-
function
|
|
780
|
-
var
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
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;
|
|
785
1029
|
}
|
|
786
|
-
function
|
|
787
|
-
return
|
|
1030
|
+
function orderIndependentDeepDiff(lhs, rhs, changes, prefilter, path, key, stack) {
|
|
1031
|
+
return deepDiff2(lhs, rhs, changes, prefilter, path, key, stack, true);
|
|
788
1032
|
}
|
|
789
|
-
function
|
|
790
|
-
var
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
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;
|
|
794
1041
|
}
|
|
795
|
-
function
|
|
796
|
-
var
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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;
|
|
800
1050
|
}
|
|
801
|
-
function
|
|
802
|
-
if (
|
|
803
|
-
var
|
|
804
|
-
for (
|
|
805
|
-
|
|
806
|
-
|
|
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) {
|
|
807
1058
|
case "A":
|
|
808
|
-
|
|
1059
|
+
applyArrayChange(it[change.path[i]], change.index, change.item);
|
|
809
1060
|
break;
|
|
810
1061
|
case "D":
|
|
811
|
-
delete
|
|
1062
|
+
delete it[change.path[i]];
|
|
812
1063
|
break;
|
|
813
1064
|
case "E":
|
|
814
1065
|
case "N":
|
|
815
|
-
|
|
1066
|
+
it[change.path[i]] = change.rhs;
|
|
816
1067
|
break;
|
|
817
1068
|
}
|
|
818
|
-
} else
|
|
819
|
-
switch (
|
|
1069
|
+
} else {
|
|
1070
|
+
switch (change.kind) {
|
|
820
1071
|
case "A":
|
|
821
|
-
|
|
1072
|
+
applyArrayChange(arr[index], change.index, change.item);
|
|
822
1073
|
break;
|
|
823
1074
|
case "D":
|
|
824
|
-
|
|
1075
|
+
arr = arrayRemove(arr, index);
|
|
825
1076
|
break;
|
|
826
1077
|
case "E":
|
|
827
1078
|
case "N":
|
|
828
|
-
|
|
1079
|
+
arr[index] = change.rhs;
|
|
829
1080
|
break;
|
|
830
1081
|
}
|
|
831
|
-
|
|
1082
|
+
}
|
|
1083
|
+
return arr;
|
|
832
1084
|
}
|
|
833
|
-
function
|
|
834
|
-
if (typeof
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
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) {
|
|
838
1098
|
case "A":
|
|
839
|
-
|
|
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);
|
|
840
1103
|
break;
|
|
841
1104
|
case "D":
|
|
842
|
-
delete
|
|
1105
|
+
delete it[change.path[i]];
|
|
843
1106
|
break;
|
|
844
1107
|
case "E":
|
|
845
1108
|
case "N":
|
|
846
|
-
|
|
1109
|
+
it[change.path[i]] = change.rhs;
|
|
847
1110
|
break;
|
|
848
1111
|
}
|
|
849
1112
|
}
|
|
850
1113
|
}
|
|
851
|
-
function
|
|
852
|
-
if (
|
|
853
|
-
var
|
|
854
|
-
for (
|
|
855
|
-
|
|
856
|
-
|
|
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) {
|
|
857
1121
|
case "A":
|
|
858
|
-
|
|
1122
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
859
1123
|
break;
|
|
860
1124
|
case "D":
|
|
861
|
-
|
|
1125
|
+
it[change.path[i]] = change.lhs;
|
|
862
1126
|
break;
|
|
863
1127
|
case "E":
|
|
864
|
-
|
|
1128
|
+
it[change.path[i]] = change.lhs;
|
|
865
1129
|
break;
|
|
866
1130
|
case "N":
|
|
867
|
-
delete
|
|
1131
|
+
delete it[change.path[i]];
|
|
868
1132
|
break;
|
|
869
1133
|
}
|
|
870
|
-
} else
|
|
871
|
-
switch (
|
|
1134
|
+
} else {
|
|
1135
|
+
switch (change.kind) {
|
|
872
1136
|
case "A":
|
|
873
|
-
|
|
1137
|
+
revertArrayChange(arr[index], change.index, change.item);
|
|
874
1138
|
break;
|
|
875
1139
|
case "D":
|
|
876
|
-
|
|
1140
|
+
arr[index] = change.lhs;
|
|
877
1141
|
break;
|
|
878
1142
|
case "E":
|
|
879
|
-
|
|
1143
|
+
arr[index] = change.lhs;
|
|
880
1144
|
break;
|
|
881
1145
|
case "N":
|
|
882
|
-
|
|
1146
|
+
arr = arrayRemove(arr, index);
|
|
883
1147
|
break;
|
|
884
1148
|
}
|
|
885
|
-
|
|
1149
|
+
}
|
|
1150
|
+
return arr;
|
|
886
1151
|
}
|
|
887
|
-
function
|
|
888
|
-
if (
|
|
889
|
-
var
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
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) {
|
|
893
1163
|
case "A":
|
|
894
|
-
|
|
1164
|
+
revertArrayChange(it[change.path[i]], change.index, change.item);
|
|
895
1165
|
break;
|
|
896
1166
|
case "D":
|
|
897
|
-
|
|
1167
|
+
it[change.path[i]] = change.lhs;
|
|
898
1168
|
break;
|
|
899
1169
|
case "E":
|
|
900
|
-
|
|
1170
|
+
it[change.path[i]] = change.lhs;
|
|
901
1171
|
break;
|
|
902
1172
|
case "N":
|
|
903
|
-
delete
|
|
1173
|
+
delete it[change.path[i]];
|
|
904
1174
|
break;
|
|
905
1175
|
}
|
|
906
1176
|
}
|
|
907
1177
|
}
|
|
908
|
-
function
|
|
909
|
-
if (
|
|
910
|
-
var
|
|
911
|
-
(!
|
|
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
|
+
}
|
|
912
1184
|
};
|
|
913
|
-
|
|
1185
|
+
observableDiff(target, source, onChange);
|
|
914
1186
|
}
|
|
915
1187
|
}
|
|
916
|
-
|
|
1188
|
+
Object.defineProperties(accumulateDiff, {
|
|
917
1189
|
diff: {
|
|
918
|
-
value:
|
|
919
|
-
enumerable:
|
|
1190
|
+
value: accumulateDiff,
|
|
1191
|
+
enumerable: true
|
|
920
1192
|
},
|
|
921
1193
|
orderIndependentDiff: {
|
|
922
|
-
value:
|
|
923
|
-
enumerable:
|
|
1194
|
+
value: accumulateOrderIndependentDiff,
|
|
1195
|
+
enumerable: true
|
|
924
1196
|
},
|
|
925
1197
|
observableDiff: {
|
|
926
|
-
value:
|
|
927
|
-
enumerable:
|
|
1198
|
+
value: observableDiff,
|
|
1199
|
+
enumerable: true
|
|
928
1200
|
},
|
|
929
1201
|
orderIndependentObservableDiff: {
|
|
930
|
-
value:
|
|
931
|
-
enumerable:
|
|
1202
|
+
value: orderIndependentDeepDiff,
|
|
1203
|
+
enumerable: true
|
|
932
1204
|
},
|
|
933
1205
|
orderIndepHash: {
|
|
934
|
-
value:
|
|
935
|
-
enumerable:
|
|
1206
|
+
value: getOrderIndependentHash,
|
|
1207
|
+
enumerable: true
|
|
936
1208
|
},
|
|
937
1209
|
applyDiff: {
|
|
938
|
-
value:
|
|
939
|
-
enumerable:
|
|
1210
|
+
value: applyDiff,
|
|
1211
|
+
enumerable: true
|
|
940
1212
|
},
|
|
941
1213
|
applyChange: {
|
|
942
|
-
value:
|
|
943
|
-
enumerable:
|
|
1214
|
+
value: applyChange,
|
|
1215
|
+
enumerable: true
|
|
944
1216
|
},
|
|
945
1217
|
revertChange: {
|
|
946
|
-
value:
|
|
947
|
-
enumerable:
|
|
1218
|
+
value: revertChange,
|
|
1219
|
+
enumerable: true
|
|
948
1220
|
},
|
|
949
1221
|
isConflict: {
|
|
950
1222
|
value: function() {
|
|
951
|
-
return typeof $conflict
|
|
1223
|
+
return typeof $conflict !== "undefined";
|
|
952
1224
|
},
|
|
953
|
-
enumerable:
|
|
1225
|
+
enumerable: true
|
|
954
1226
|
}
|
|
955
|
-
})
|
|
1227
|
+
});
|
|
1228
|
+
accumulateDiff.DeepDiff = accumulateDiff;
|
|
1229
|
+
if (root) {
|
|
1230
|
+
root.DeepDiff = accumulateDiff;
|
|
1231
|
+
}
|
|
1232
|
+
return accumulateDiff;
|
|
956
1233
|
});
|
|
957
|
-
}(
|
|
1234
|
+
})(deepDiff$1);
|
|
1235
|
+
return deepDiff$1.exports;
|
|
958
1236
|
}
|
|
959
|
-
var
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
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
|
+
}
|
|
969
1315
|
}
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
let
|
|
978
|
-
for (;
|
|
979
|
-
|
|
980
|
-
const
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
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;
|
|
987
1339
|
}
|
|
988
|
-
|
|
989
|
-
|
|
1340
|
+
ph = ph << 1 | pb;
|
|
1341
|
+
mh = mh << 1 | mb;
|
|
1342
|
+
pv = mh | ~(xv | ph);
|
|
1343
|
+
mv = ph & xv;
|
|
990
1344
|
}
|
|
991
|
-
let
|
|
992
|
-
|
|
993
|
-
for (let h = A; h < w; h++)
|
|
994
|
-
z[n.charCodeAt(h)] |= 1 << h;
|
|
995
|
-
let E = r;
|
|
996
|
-
for (let h = 0; h < t; h++) {
|
|
997
|
-
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;
|
|
998
|
-
let O = y | ~(k | m), R = m & k;
|
|
999
|
-
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;
|
|
1000
1347
|
}
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
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;
|
|
1008
1358
|
}
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
let t = 1 / 0, r = 0;
|
|
1012
|
-
for (let o = 0; o < e.length; o++) {
|
|
1013
|
-
const u = Te(n, e[o]);
|
|
1014
|
-
u < t && (t = u, r = o);
|
|
1359
|
+
if (a.length <= 32) {
|
|
1360
|
+
return myers_32(a, b);
|
|
1015
1361
|
}
|
|
1016
|
-
return
|
|
1017
|
-
}
|
|
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({
|
|
1018
1377
|
__proto__: null,
|
|
1019
|
-
closest
|
|
1020
|
-
distance
|
|
1021
|
-
}, Symbol.toStringTag, { value: "Module" }))
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
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) {
|
|
1025
1387
|
(function() {
|
|
1026
|
-
var
|
|
1388
|
+
var collator;
|
|
1027
1389
|
try {
|
|
1028
|
-
|
|
1029
|
-
} catch {
|
|
1390
|
+
collator = typeof Intl !== "undefined" && typeof Intl.Collator !== "undefined" ? Intl.Collator("generic", { sensitivity: "base" }) : null;
|
|
1391
|
+
} catch (err) {
|
|
1030
1392
|
console.log("Collator could not be initialized and wouldn't be used");
|
|
1031
1393
|
}
|
|
1032
|
-
var
|
|
1394
|
+
var levenshtein2 = require$$0;
|
|
1395
|
+
var prevRow = [], str2Char = [];
|
|
1396
|
+
var Levenshtein = {
|
|
1033
1397
|
/**
|
|
1034
1398
|
* Calculate levenshtein distance of the two strings.
|
|
1035
1399
|
*
|
|
@@ -1039,484 +1403,724 @@ function Ge() {
|
|
|
1039
1403
|
* @param [options.useCollator] Use `Intl.Collator` for locale-sensitive string comparison.
|
|
1040
1404
|
* @return Integer the levenshtein distance (0 and above).
|
|
1041
1405
|
*/
|
|
1042
|
-
get: function(
|
|
1043
|
-
var
|
|
1044
|
-
if (
|
|
1045
|
-
var
|
|
1046
|
-
if (
|
|
1047
|
-
if (
|
|
1048
|
-
var
|
|
1049
|
-
for (
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
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;
|
|
1057
1436
|
}
|
|
1058
|
-
return
|
|
1437
|
+
return nextCol;
|
|
1059
1438
|
}
|
|
1060
|
-
return
|
|
1439
|
+
return levenshtein2.distance(str1, str2);
|
|
1061
1440
|
}
|
|
1062
1441
|
};
|
|
1063
|
-
|
|
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
|
+
}
|
|
1064
1449
|
})();
|
|
1065
|
-
}(
|
|
1450
|
+
})(levenshtein$1, levenshtein$1.exports);
|
|
1451
|
+
return levenshtein$1.exports;
|
|
1066
1452
|
}
|
|
1067
|
-
var
|
|
1068
|
-
const
|
|
1069
|
-
class
|
|
1070
|
-
diff(
|
|
1071
|
-
let
|
|
1072
|
-
typeof
|
|
1073
|
-
|
|
1074
|
-
|
|
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);
|
|
1075
1469
|
}
|
|
1076
|
-
diffWithOptionsObj(
|
|
1077
|
-
var
|
|
1078
|
-
const
|
|
1079
|
-
|
|
1470
|
+
diffWithOptionsObj(oldTokens, newTokens, options, callback) {
|
|
1471
|
+
var _a;
|
|
1472
|
+
const done = (value) => {
|
|
1473
|
+
value = this.postProcess(value, options);
|
|
1474
|
+
if (callback) {
|
|
1080
1475
|
setTimeout(function() {
|
|
1081
|
-
|
|
1476
|
+
callback(value);
|
|
1082
1477
|
}, 0);
|
|
1083
|
-
return;
|
|
1084
|
-
} else
|
|
1085
|
-
return
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
let
|
|
1091
|
-
if (
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
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;
|
|
1103
1503
|
}
|
|
1104
|
-
|
|
1105
|
-
if (
|
|
1106
|
-
|
|
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;
|
|
1107
1512
|
continue;
|
|
1108
1513
|
}
|
|
1109
|
-
if (!
|
|
1110
|
-
|
|
1111
|
-
|
|
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
|
+
}
|
|
1112
1531
|
}
|
|
1113
|
-
|
|
1532
|
+
editLength++;
|
|
1114
1533
|
};
|
|
1115
|
-
if (
|
|
1116
|
-
(function
|
|
1534
|
+
if (callback) {
|
|
1535
|
+
(function exec() {
|
|
1117
1536
|
setTimeout(function() {
|
|
1118
|
-
if (
|
|
1119
|
-
return
|
|
1120
|
-
|
|
1537
|
+
if (editLength > maxEditLength || Date.now() > abortAfterTimestamp) {
|
|
1538
|
+
return callback(void 0);
|
|
1539
|
+
}
|
|
1540
|
+
if (!execEditLength()) {
|
|
1541
|
+
exec();
|
|
1542
|
+
}
|
|
1121
1543
|
}, 0);
|
|
1122
1544
|
})();
|
|
1123
|
-
else
|
|
1124
|
-
|
|
1125
|
-
const
|
|
1126
|
-
if (
|
|
1127
|
-
return
|
|
1545
|
+
} else {
|
|
1546
|
+
while (editLength <= maxEditLength && Date.now() <= abortAfterTimestamp) {
|
|
1547
|
+
const ret = execEditLength();
|
|
1548
|
+
if (ret) {
|
|
1549
|
+
return ret;
|
|
1550
|
+
}
|
|
1128
1551
|
}
|
|
1552
|
+
}
|
|
1129
1553
|
}
|
|
1130
|
-
addToPath(
|
|
1131
|
-
const
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
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
|
+
}
|
|
1139
1567
|
}
|
|
1140
|
-
extractCommon(
|
|
1141
|
-
const
|
|
1142
|
-
let
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
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;
|
|
1146
1584
|
}
|
|
1147
|
-
equals(
|
|
1148
|
-
|
|
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
|
+
}
|
|
1149
1591
|
}
|
|
1150
|
-
removeEmpty(
|
|
1151
|
-
const
|
|
1152
|
-
for (let
|
|
1153
|
-
|
|
1154
|
-
|
|
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;
|
|
1155
1600
|
}
|
|
1156
1601
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1157
|
-
castInput(
|
|
1158
|
-
return
|
|
1602
|
+
castInput(value, options) {
|
|
1603
|
+
return value;
|
|
1159
1604
|
}
|
|
1160
1605
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1161
|
-
tokenize(
|
|
1162
|
-
return Array.from(
|
|
1606
|
+
tokenize(value, options) {
|
|
1607
|
+
return Array.from(value);
|
|
1163
1608
|
}
|
|
1164
|
-
join(
|
|
1165
|
-
return
|
|
1609
|
+
join(chars) {
|
|
1610
|
+
return chars.join("");
|
|
1166
1611
|
}
|
|
1167
|
-
postProcess(
|
|
1168
|
-
return
|
|
1612
|
+
postProcess(changeObjects, options) {
|
|
1613
|
+
return changeObjects;
|
|
1169
1614
|
}
|
|
1170
1615
|
get useLongestToken() {
|
|
1171
|
-
return
|
|
1616
|
+
return false;
|
|
1172
1617
|
}
|
|
1173
|
-
buildValues(
|
|
1174
|
-
const
|
|
1175
|
-
let
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
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;
|
|
1195
1650
|
}
|
|
1196
1651
|
}
|
|
1197
|
-
return
|
|
1652
|
+
return components;
|
|
1198
1653
|
}
|
|
1199
1654
|
}
|
|
1200
|
-
class
|
|
1655
|
+
class LineDiff extends Diff {
|
|
1201
1656
|
constructor() {
|
|
1202
|
-
super(...arguments)
|
|
1657
|
+
super(...arguments);
|
|
1658
|
+
this.tokenize = tokenize;
|
|
1203
1659
|
}
|
|
1204
|
-
equals(
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
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);
|
|
1210
1677
|
}
|
|
1211
1678
|
}
|
|
1212
|
-
const
|
|
1213
|
-
function
|
|
1214
|
-
return
|
|
1679
|
+
const lineDiff = new LineDiff();
|
|
1680
|
+
function diffLines(oldStr, newStr, options) {
|
|
1681
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
1215
1682
|
}
|
|
1216
|
-
function
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
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();
|
|
1224
1690
|
}
|
|
1225
|
-
|
|
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;
|
|
1226
1700
|
}
|
|
1227
|
-
function
|
|
1228
|
-
let
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
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) {
|
|
1232
1715
|
throw new Error("newlineIsToken may not be used with patch-generation functions, only with diffing functions");
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
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);
|
|
1238
1724
|
} }));
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
if (!m)
|
|
1725
|
+
}
|
|
1726
|
+
function diffLinesResultToPatch(diff) {
|
|
1727
|
+
if (!diff) {
|
|
1243
1728
|
return;
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1729
|
+
}
|
|
1730
|
+
diff.push({ value: "", lines: [] });
|
|
1731
|
+
function contextLines(lines) {
|
|
1732
|
+
return lines.map(function(entry) {
|
|
1733
|
+
return " " + entry;
|
|
1248
1734
|
});
|
|
1249
1735
|
}
|
|
1250
|
-
const
|
|
1251
|
-
let
|
|
1252
|
-
for (let
|
|
1253
|
-
const
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
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;
|
|
1258
1759
|
}
|
|
1259
|
-
for (const R of O)
|
|
1260
|
-
g.push((k.added ? "+" : "-") + R);
|
|
1261
|
-
k.added ? P += O.length : C += O.length;
|
|
1262
1760
|
} else {
|
|
1263
|
-
if (
|
|
1264
|
-
if (
|
|
1265
|
-
for (const
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
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
|
|
1277
1777
|
};
|
|
1278
|
-
|
|
1778
|
+
hunks.push(hunk);
|
|
1779
|
+
oldRangeStart = 0;
|
|
1780
|
+
newRangeStart = 0;
|
|
1781
|
+
curRange = [];
|
|
1279
1782
|
}
|
|
1280
|
-
|
|
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
|
+
}
|
|
1281
1796
|
}
|
|
1282
1797
|
}
|
|
1283
|
-
for (const v of w)
|
|
1284
|
-
for (let k = 0; k < v.lines.length; k++)
|
|
1285
|
-
v.lines[k].endsWith(`
|
|
1286
|
-
`) ? v.lines[k] = v.lines[k].slice(0, -1) : (v.lines.splice(k + 1, 0, "\"), k++);
|
|
1287
1798
|
return {
|
|
1288
|
-
oldFileName
|
|
1289
|
-
newFileName
|
|
1290
|
-
oldHeader
|
|
1291
|
-
newHeader
|
|
1292
|
-
hunks
|
|
1799
|
+
oldFileName,
|
|
1800
|
+
newFileName,
|
|
1801
|
+
oldHeader,
|
|
1802
|
+
newHeader,
|
|
1803
|
+
hunks
|
|
1293
1804
|
};
|
|
1294
1805
|
}
|
|
1295
1806
|
}
|
|
1296
|
-
function
|
|
1297
|
-
if (Array.isArray(
|
|
1298
|
-
return
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
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
|
+
}
|
|
1307
1830
|
}
|
|
1308
|
-
return
|
|
1309
|
-
`) + `
|
|
1310
|
-
`;
|
|
1831
|
+
return ret.join("\n") + "\n";
|
|
1311
1832
|
}
|
|
1312
|
-
function
|
|
1313
|
-
if (typeof
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
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);
|
|
1318
1843
|
} else {
|
|
1319
|
-
const
|
|
1320
|
-
|
|
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
|
+
} }));
|
|
1321
1852
|
}
|
|
1322
1853
|
}
|
|
1323
|
-
function
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
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;
|
|
1329
1863
|
}
|
|
1330
|
-
function
|
|
1331
|
-
switch (
|
|
1864
|
+
function formatDiff(oldValue, newValue, diffType = "git", context = 3) {
|
|
1865
|
+
switch (diffType) {
|
|
1332
1866
|
case "git":
|
|
1333
|
-
return
|
|
1867
|
+
return formatGitDiff(oldValue, newValue, context);
|
|
1334
1868
|
case "object":
|
|
1335
|
-
return
|
|
1869
|
+
return formatObjectDiff(oldValue, newValue);
|
|
1336
1870
|
case "json":
|
|
1337
|
-
return
|
|
1871
|
+
return formatJsonDiff(oldValue, newValue);
|
|
1338
1872
|
default:
|
|
1339
|
-
return
|
|
1873
|
+
return formatGitDiff(oldValue, newValue, context);
|
|
1340
1874
|
}
|
|
1341
1875
|
}
|
|
1342
|
-
function
|
|
1343
|
-
const
|
|
1344
|
-
|
|
1876
|
+
function formatGitDiff(oldValue, newValue, context = 3) {
|
|
1877
|
+
const oldStr = stringify(oldValue);
|
|
1878
|
+
const newStr = stringify(newValue);
|
|
1879
|
+
const patch = createTwoFilesPatch(
|
|
1345
1880
|
/* oldFilename */
|
|
1346
1881
|
"",
|
|
1347
1882
|
/* newFilename */
|
|
1348
1883
|
"",
|
|
1349
|
-
|
|
1350
|
-
|
|
1884
|
+
oldStr,
|
|
1885
|
+
newStr,
|
|
1351
1886
|
/* oldHeader */
|
|
1352
1887
|
"",
|
|
1353
1888
|
/* newHeader */
|
|
1354
1889
|
"",
|
|
1355
|
-
{ context
|
|
1356
|
-
)
|
|
1357
|
-
|
|
1358
|
-
`);
|
|
1890
|
+
{ context }
|
|
1891
|
+
);
|
|
1892
|
+
return patch.split("\n").slice(2).join("\n");
|
|
1359
1893
|
}
|
|
1360
|
-
function
|
|
1361
|
-
const
|
|
1362
|
-
return JSON.stringify(
|
|
1894
|
+
function formatObjectDiff(oldValue, newValue) {
|
|
1895
|
+
const differences = deepDiffExports.diff(oldValue, newValue) || [];
|
|
1896
|
+
return JSON.stringify(differences, null, 2);
|
|
1363
1897
|
}
|
|
1364
|
-
function
|
|
1898
|
+
function formatJsonDiff(oldValue, newValue) {
|
|
1365
1899
|
return JSON.stringify(
|
|
1366
1900
|
{
|
|
1367
|
-
before:
|
|
1368
|
-
after:
|
|
1901
|
+
before: oldValue,
|
|
1902
|
+
after: newValue
|
|
1369
1903
|
},
|
|
1370
1904
|
null,
|
|
1371
1905
|
2
|
|
1372
1906
|
);
|
|
1373
1907
|
}
|
|
1374
|
-
function
|
|
1375
|
-
|
|
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
|
+
}
|
|
1376
1916
|
}
|
|
1377
|
-
function
|
|
1378
|
-
if (
|
|
1379
|
-
if (
|
|
1380
|
-
|
|
1381
|
-
|
|
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;
|
|
1382
1924
|
}
|
|
1383
|
-
function
|
|
1384
|
-
if (
|
|
1385
|
-
if (
|
|
1386
|
-
const
|
|
1387
|
-
|
|
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);
|
|
1388
1931
|
}
|
|
1389
|
-
function
|
|
1390
|
-
if (
|
|
1391
|
-
const
|
|
1392
|
-
if (
|
|
1393
|
-
const
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
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) {
|
|
1398
1943
|
case "N":
|
|
1399
|
-
|
|
1944
|
+
changeWeight += 1;
|
|
1400
1945
|
break;
|
|
1401
1946
|
case "D":
|
|
1402
|
-
|
|
1947
|
+
changeWeight += 1;
|
|
1403
1948
|
break;
|
|
1404
1949
|
case "E":
|
|
1405
|
-
if (typeof
|
|
1406
|
-
const
|
|
1407
|
-
|
|
1408
|
-
|
|
1950
|
+
if (typeof difference.lhs === "string" && typeof difference.rhs === "string") {
|
|
1951
|
+
const stringChangeRatio = calculateStringDiffPercentage(
|
|
1952
|
+
difference.lhs,
|
|
1953
|
+
difference.rhs
|
|
1409
1954
|
);
|
|
1410
|
-
|
|
1411
|
-
} else if (typeof
|
|
1412
|
-
const
|
|
1413
|
-
|
|
1414
|
-
|
|
1955
|
+
changeWeight += stringChangeRatio;
|
|
1956
|
+
} else if (typeof difference.lhs === "number" && typeof difference.rhs === "number") {
|
|
1957
|
+
const numberChangeRatio = calculateNumberDiffPercentage(
|
|
1958
|
+
difference.lhs,
|
|
1959
|
+
difference.rhs
|
|
1415
1960
|
);
|
|
1416
|
-
|
|
1417
|
-
} else
|
|
1418
|
-
|
|
1961
|
+
changeWeight += numberChangeRatio;
|
|
1962
|
+
} else {
|
|
1963
|
+
changeWeight += 1;
|
|
1964
|
+
}
|
|
1419
1965
|
break;
|
|
1420
1966
|
case "A":
|
|
1421
|
-
|
|
1967
|
+
changeWeight += 0.5;
|
|
1422
1968
|
break;
|
|
1423
1969
|
}
|
|
1424
|
-
|
|
1970
|
+
}
|
|
1971
|
+
return Math.min(changeWeight / totalProps, 1);
|
|
1425
1972
|
}
|
|
1426
|
-
function
|
|
1427
|
-
if (
|
|
1428
|
-
if (typeof
|
|
1429
|
-
if (Array.isArray(
|
|
1430
|
-
let
|
|
1431
|
-
for (const
|
|
1432
|
-
Object.prototype.hasOwnProperty.call(
|
|
1433
|
-
|
|
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;
|
|
1434
1984
|
}
|
|
1435
|
-
function
|
|
1985
|
+
function stringify(value) {
|
|
1436
1986
|
try {
|
|
1437
1987
|
return JSON.stringify(
|
|
1438
|
-
|
|
1439
|
-
(
|
|
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
|
+
},
|
|
1440
1996
|
2
|
|
1441
1997
|
);
|
|
1442
|
-
} catch {
|
|
1443
|
-
return String(
|
|
1998
|
+
} catch (_) {
|
|
1999
|
+
return String(value);
|
|
1444
2000
|
}
|
|
1445
2001
|
}
|
|
1446
|
-
function
|
|
1447
|
-
const
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
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,
|
|
1458
2034
|
source: "IMPLICIT",
|
|
1459
|
-
extra_metadata:
|
|
1460
|
-
trigger_name:
|
|
2035
|
+
extra_metadata: options?.metadata,
|
|
2036
|
+
trigger_name: triggerName
|
|
1461
2037
|
});
|
|
1462
2038
|
},
|
|
1463
|
-
[
|
|
1464
|
-
)
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
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;
|
|
1475
2054
|
}
|
|
1476
|
-
|
|
2055
|
+
currentTriggerNameRef.current = newTriggerName;
|
|
1477
2056
|
},
|
|
1478
|
-
[
|
|
2057
|
+
[currentState, defaultTriggerName, sendFeedback]
|
|
1479
2058
|
);
|
|
1480
|
-
|
|
1481
|
-
if (
|
|
1482
|
-
|
|
2059
|
+
useEffect(() => {
|
|
2060
|
+
if (isFirstRenderRef.current) {
|
|
2061
|
+
isFirstRenderRef.current = false;
|
|
2062
|
+
prevStateRef.current = currentState;
|
|
2063
|
+
changeStartStateRef.current = currentState;
|
|
1483
2064
|
return;
|
|
1484
2065
|
}
|
|
1485
|
-
const
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
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
|
+
}
|
|
1495
2092
|
};
|
|
1496
2093
|
}, [
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
])
|
|
1507
|
-
|
|
2094
|
+
currentState,
|
|
2095
|
+
tx_id,
|
|
2096
|
+
options,
|
|
2097
|
+
feedbackHandler,
|
|
2098
|
+
diffType,
|
|
2099
|
+
debounceMs,
|
|
2100
|
+
compareWith,
|
|
2101
|
+
defaultTriggerName,
|
|
2102
|
+
sendFeedback
|
|
2103
|
+
]);
|
|
2104
|
+
return {
|
|
2105
|
+
notifyChange
|
|
1508
2106
|
};
|
|
1509
2107
|
}
|
|
1510
|
-
function
|
|
1511
|
-
const [
|
|
1512
|
-
|
|
1513
|
-
|
|
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
|
+
});
|
|
1514
2118
|
},
|
|
1515
|
-
[
|
|
2119
|
+
[notifyChange]
|
|
1516
2120
|
);
|
|
1517
|
-
return [
|
|
2121
|
+
return [state, setState];
|
|
1518
2122
|
}
|
|
1519
|
-
let
|
|
2123
|
+
let _loadOtelApi = () => {
|
|
1520
2124
|
try {
|
|
1521
2125
|
return require("@opentelemetry/api");
|
|
1522
2126
|
} catch {
|
|
@@ -1525,21 +2129,23 @@ let ft = () => {
|
|
|
1525
2129
|
);
|
|
1526
2130
|
}
|
|
1527
2131
|
};
|
|
1528
|
-
function
|
|
1529
|
-
const { trace
|
|
2132
|
+
function getOtelTraceId() {
|
|
2133
|
+
const { trace, context } = _loadOtelApi();
|
|
1530
2134
|
try {
|
|
1531
|
-
const
|
|
1532
|
-
if (
|
|
1533
|
-
return
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
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
|
+
}
|
|
1539
2145
|
}
|
|
1540
|
-
} catch (
|
|
2146
|
+
} catch (error) {
|
|
1541
2147
|
throw new Error(
|
|
1542
|
-
`Failed to extract OpenTelemetry trace ID: ${
|
|
2148
|
+
`Failed to extract OpenTelemetry trace ID: ${error instanceof Error ? error.message : "Unknown error"}`
|
|
1543
2149
|
);
|
|
1544
2150
|
}
|
|
1545
2151
|
throw new Error(
|
|
@@ -1547,11 +2153,12 @@ function bt() {
|
|
|
1547
2153
|
);
|
|
1548
2154
|
}
|
|
1549
2155
|
export {
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
2156
|
+
KeletContext,
|
|
2157
|
+
KeletProvider,
|
|
2158
|
+
VoteFeedback,
|
|
2159
|
+
getOtelTraceId,
|
|
2160
|
+
useDefaultFeedbackHandler,
|
|
2161
|
+
useFeedbackState,
|
|
2162
|
+
useKelet
|
|
1557
2163
|
};
|
|
2164
|
+
//# sourceMappingURL=feedback-ui.es.js.map
|