@_sh/strapi-plugin-ckeditor 4.0.5 → 4.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_chunks/index--I-k72y7.js +3638 -0
- package/dist/_chunks/index--I-k72y7.js.map +1 -0
- package/dist/_chunks/index-B-8RH8Ci.js +1154 -0
- package/dist/_chunks/index-B-8RH8Ci.js.map +1 -0
- package/dist/_chunks/index-B3EDXnAT.js +1154 -0
- package/dist/_chunks/index-B3EDXnAT.js.map +1 -0
- package/dist/_chunks/index-C0jjn4gQ.mjs +3619 -0
- package/dist/_chunks/index-C0jjn4gQ.mjs.map +1 -0
- package/dist/_chunks/index-CAcXCAV_.js +3638 -0
- package/dist/_chunks/index-CAcXCAV_.js.map +1 -0
- package/dist/_chunks/index-CArd4Wrq.mjs +1128 -0
- package/dist/_chunks/index-CArd4Wrq.mjs.map +1 -0
- package/dist/_chunks/index-CEyU-aaI.js +1154 -0
- package/dist/_chunks/index-CEyU-aaI.js.map +1 -0
- package/dist/_chunks/index-CR_x4n2j.mjs +3619 -0
- package/dist/_chunks/index-CR_x4n2j.mjs.map +1 -0
- package/dist/_chunks/index-D94Z_pt1.mjs +3619 -0
- package/dist/_chunks/index-D94Z_pt1.mjs.map +1 -0
- package/dist/_chunks/index-DV4dFYkp.js +1154 -0
- package/dist/_chunks/index-DV4dFYkp.js.map +1 -0
- package/dist/_chunks/index-Ddlr4vFi.js +3638 -0
- package/dist/_chunks/index-Ddlr4vFi.js.map +1 -0
- package/dist/_chunks/index-DnN7vdyg.js +3638 -0
- package/dist/_chunks/index-DnN7vdyg.js.map +1 -0
- package/dist/_chunks/index-Dov2jT-v.mjs +1128 -0
- package/dist/_chunks/index-Dov2jT-v.mjs.map +1 -0
- package/dist/_chunks/index-Jw3MMVXa.mjs +3619 -0
- package/dist/_chunks/index-Jw3MMVXa.mjs.map +1 -0
- package/dist/_chunks/index-_ebKr7ko.mjs +1128 -0
- package/dist/_chunks/index-_ebKr7ko.mjs.map +1 -0
- package/dist/_chunks/index-ddlYBO9L.mjs +1128 -0
- package/dist/_chunks/index-ddlYBO9L.mjs.map +1 -0
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +1 -1
- package/dist/server/index.js +16 -9
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +16 -9
- package/dist/server/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,3638 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
require("react");
|
|
3
|
+
const cke = require("ckeditor5");
|
|
4
|
+
const sanitizeHtml = require("sanitize-html");
|
|
5
|
+
const jsxRuntime = require("react/jsx-runtime");
|
|
6
|
+
const styled = require("styled-components");
|
|
7
|
+
const designSystem = require("@strapi/design-system");
|
|
8
|
+
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
9
|
+
function _interopNamespace(e) {
|
|
10
|
+
if (e && e.__esModule)
|
|
11
|
+
return e;
|
|
12
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
13
|
+
if (e) {
|
|
14
|
+
for (const k in e) {
|
|
15
|
+
if (k !== "default") {
|
|
16
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
17
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: () => e[k]
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
n.default = e;
|
|
25
|
+
return Object.freeze(n);
|
|
26
|
+
}
|
|
27
|
+
const cke__namespace = /* @__PURE__ */ _interopNamespace(cke);
|
|
28
|
+
const sanitizeHtml__default = /* @__PURE__ */ _interopDefault(sanitizeHtml);
|
|
29
|
+
var map;
|
|
30
|
+
try {
|
|
31
|
+
map = Map;
|
|
32
|
+
} catch (_) {
|
|
33
|
+
}
|
|
34
|
+
var set;
|
|
35
|
+
try {
|
|
36
|
+
set = Set;
|
|
37
|
+
} catch (_) {
|
|
38
|
+
}
|
|
39
|
+
function baseClone(src, circulars, clones) {
|
|
40
|
+
if (!src || typeof src !== "object" || typeof src === "function") {
|
|
41
|
+
return src;
|
|
42
|
+
}
|
|
43
|
+
if (src.nodeType && "cloneNode" in src) {
|
|
44
|
+
return src.cloneNode(true);
|
|
45
|
+
}
|
|
46
|
+
if (src instanceof Date) {
|
|
47
|
+
return new Date(src.getTime());
|
|
48
|
+
}
|
|
49
|
+
if (src instanceof RegExp) {
|
|
50
|
+
return new RegExp(src);
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(src)) {
|
|
53
|
+
return src.map(clone);
|
|
54
|
+
}
|
|
55
|
+
if (map && src instanceof map) {
|
|
56
|
+
return new Map(Array.from(src.entries()));
|
|
57
|
+
}
|
|
58
|
+
if (set && src instanceof set) {
|
|
59
|
+
return new Set(Array.from(src.values()));
|
|
60
|
+
}
|
|
61
|
+
if (src instanceof Object) {
|
|
62
|
+
circulars.push(src);
|
|
63
|
+
var obj = Object.create(src);
|
|
64
|
+
clones.push(obj);
|
|
65
|
+
for (var key in src) {
|
|
66
|
+
var idx = circulars.findIndex(function(i) {
|
|
67
|
+
return i === src[key];
|
|
68
|
+
});
|
|
69
|
+
obj[key] = idx > -1 ? clones[idx] : baseClone(src[key], circulars, clones);
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
return src;
|
|
74
|
+
}
|
|
75
|
+
function clone(src) {
|
|
76
|
+
return baseClone(src, [], []);
|
|
77
|
+
}
|
|
78
|
+
const toString$2 = Object.prototype.toString;
|
|
79
|
+
const errorToString = Error.prototype.toString;
|
|
80
|
+
const regExpToString = RegExp.prototype.toString;
|
|
81
|
+
const symbolToString$1 = typeof Symbol !== "undefined" ? Symbol.prototype.toString : () => "";
|
|
82
|
+
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
|
|
83
|
+
function printNumber(val) {
|
|
84
|
+
if (val != +val)
|
|
85
|
+
return "NaN";
|
|
86
|
+
const isNegativeZero = val === 0 && 1 / val < 0;
|
|
87
|
+
return isNegativeZero ? "-0" : "" + val;
|
|
88
|
+
}
|
|
89
|
+
function printSimpleValue(val, quoteStrings = false) {
|
|
90
|
+
if (val == null || val === true || val === false)
|
|
91
|
+
return "" + val;
|
|
92
|
+
const typeOf = typeof val;
|
|
93
|
+
if (typeOf === "number")
|
|
94
|
+
return printNumber(val);
|
|
95
|
+
if (typeOf === "string")
|
|
96
|
+
return quoteStrings ? `"${val}"` : val;
|
|
97
|
+
if (typeOf === "function")
|
|
98
|
+
return "[Function " + (val.name || "anonymous") + "]";
|
|
99
|
+
if (typeOf === "symbol")
|
|
100
|
+
return symbolToString$1.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
|
|
101
|
+
const tag = toString$2.call(val).slice(8, -1);
|
|
102
|
+
if (tag === "Date")
|
|
103
|
+
return isNaN(val.getTime()) ? "" + val : val.toISOString(val);
|
|
104
|
+
if (tag === "Error" || val instanceof Error)
|
|
105
|
+
return "[" + errorToString.call(val) + "]";
|
|
106
|
+
if (tag === "RegExp")
|
|
107
|
+
return regExpToString.call(val);
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function printValue(value, quoteStrings) {
|
|
111
|
+
let result = printSimpleValue(value, quoteStrings);
|
|
112
|
+
if (result !== null)
|
|
113
|
+
return result;
|
|
114
|
+
return JSON.stringify(value, function(key, value2) {
|
|
115
|
+
let result2 = printSimpleValue(this[key], quoteStrings);
|
|
116
|
+
if (result2 !== null)
|
|
117
|
+
return result2;
|
|
118
|
+
return value2;
|
|
119
|
+
}, 2);
|
|
120
|
+
}
|
|
121
|
+
let mixed = {
|
|
122
|
+
default: "${path} is invalid",
|
|
123
|
+
required: "${path} is a required field",
|
|
124
|
+
oneOf: "${path} must be one of the following values: ${values}",
|
|
125
|
+
notOneOf: "${path} must not be one of the following values: ${values}",
|
|
126
|
+
notType: ({
|
|
127
|
+
path,
|
|
128
|
+
type,
|
|
129
|
+
value,
|
|
130
|
+
originalValue
|
|
131
|
+
}) => {
|
|
132
|
+
let isCast = originalValue != null && originalValue !== value;
|
|
133
|
+
let msg = `${path} must be a \`${type}\` type, but the final value was: \`${printValue(value, true)}\`` + (isCast ? ` (cast from the value \`${printValue(originalValue, true)}\`).` : ".");
|
|
134
|
+
if (value === null) {
|
|
135
|
+
msg += `
|
|
136
|
+
If "null" is intended as an empty value be sure to mark the schema as \`.nullable()\``;
|
|
137
|
+
}
|
|
138
|
+
return msg;
|
|
139
|
+
},
|
|
140
|
+
defined: "${path} must be defined"
|
|
141
|
+
};
|
|
142
|
+
let string = {
|
|
143
|
+
length: "${path} must be exactly ${length} characters",
|
|
144
|
+
min: "${path} must be at least ${min} characters",
|
|
145
|
+
max: "${path} must be at most ${max} characters",
|
|
146
|
+
matches: '${path} must match the following: "${regex}"',
|
|
147
|
+
email: "${path} must be a valid email",
|
|
148
|
+
url: "${path} must be a valid URL",
|
|
149
|
+
uuid: "${path} must be a valid UUID",
|
|
150
|
+
trim: "${path} must be a trimmed string",
|
|
151
|
+
lowercase: "${path} must be a lowercase string",
|
|
152
|
+
uppercase: "${path} must be a upper case string"
|
|
153
|
+
};
|
|
154
|
+
let number = {
|
|
155
|
+
min: "${path} must be greater than or equal to ${min}",
|
|
156
|
+
max: "${path} must be less than or equal to ${max}",
|
|
157
|
+
lessThan: "${path} must be less than ${less}",
|
|
158
|
+
moreThan: "${path} must be greater than ${more}",
|
|
159
|
+
positive: "${path} must be a positive number",
|
|
160
|
+
negative: "${path} must be a negative number",
|
|
161
|
+
integer: "${path} must be an integer"
|
|
162
|
+
};
|
|
163
|
+
let date = {
|
|
164
|
+
min: "${path} field must be later than ${min}",
|
|
165
|
+
max: "${path} field must be at earlier than ${max}"
|
|
166
|
+
};
|
|
167
|
+
let boolean = {
|
|
168
|
+
isValue: "${path} field must be ${value}"
|
|
169
|
+
};
|
|
170
|
+
let object = {
|
|
171
|
+
noUnknown: "${path} field has unspecified keys: ${unknown}"
|
|
172
|
+
};
|
|
173
|
+
let array = {
|
|
174
|
+
min: "${path} field must have at least ${min} items",
|
|
175
|
+
max: "${path} field must have less than or equal to ${max} items",
|
|
176
|
+
length: "${path} must be have ${length} items"
|
|
177
|
+
};
|
|
178
|
+
Object.assign(/* @__PURE__ */ Object.create(null), {
|
|
179
|
+
mixed,
|
|
180
|
+
string,
|
|
181
|
+
number,
|
|
182
|
+
date,
|
|
183
|
+
object,
|
|
184
|
+
array,
|
|
185
|
+
boolean
|
|
186
|
+
});
|
|
187
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
188
|
+
function getDefaultExportFromCjs(x) {
|
|
189
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
190
|
+
}
|
|
191
|
+
var objectProto$c = Object.prototype;
|
|
192
|
+
var hasOwnProperty$9 = objectProto$c.hasOwnProperty;
|
|
193
|
+
function baseHas$1(object2, key) {
|
|
194
|
+
return object2 != null && hasOwnProperty$9.call(object2, key);
|
|
195
|
+
}
|
|
196
|
+
var _baseHas = baseHas$1;
|
|
197
|
+
var isArray$8 = Array.isArray;
|
|
198
|
+
var isArray_1 = isArray$8;
|
|
199
|
+
var freeGlobal$1 = typeof commonjsGlobal == "object" && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
200
|
+
var _freeGlobal = freeGlobal$1;
|
|
201
|
+
var freeGlobal = _freeGlobal;
|
|
202
|
+
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
203
|
+
var root$8 = freeGlobal || freeSelf || Function("return this")();
|
|
204
|
+
var _root = root$8;
|
|
205
|
+
var root$7 = _root;
|
|
206
|
+
var Symbol$5 = root$7.Symbol;
|
|
207
|
+
var _Symbol = Symbol$5;
|
|
208
|
+
var Symbol$4 = _Symbol;
|
|
209
|
+
var objectProto$b = Object.prototype;
|
|
210
|
+
var hasOwnProperty$8 = objectProto$b.hasOwnProperty;
|
|
211
|
+
var nativeObjectToString$1 = objectProto$b.toString;
|
|
212
|
+
var symToStringTag$1 = Symbol$4 ? Symbol$4.toStringTag : void 0;
|
|
213
|
+
function getRawTag$1(value) {
|
|
214
|
+
var isOwn = hasOwnProperty$8.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
215
|
+
try {
|
|
216
|
+
value[symToStringTag$1] = void 0;
|
|
217
|
+
var unmasked = true;
|
|
218
|
+
} catch (e) {
|
|
219
|
+
}
|
|
220
|
+
var result = nativeObjectToString$1.call(value);
|
|
221
|
+
if (unmasked) {
|
|
222
|
+
if (isOwn) {
|
|
223
|
+
value[symToStringTag$1] = tag;
|
|
224
|
+
} else {
|
|
225
|
+
delete value[symToStringTag$1];
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
var _getRawTag = getRawTag$1;
|
|
231
|
+
var objectProto$a = Object.prototype;
|
|
232
|
+
var nativeObjectToString = objectProto$a.toString;
|
|
233
|
+
function objectToString$1(value) {
|
|
234
|
+
return nativeObjectToString.call(value);
|
|
235
|
+
}
|
|
236
|
+
var _objectToString = objectToString$1;
|
|
237
|
+
var Symbol$3 = _Symbol, getRawTag = _getRawTag, objectToString = _objectToString;
|
|
238
|
+
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
239
|
+
var symToStringTag = Symbol$3 ? Symbol$3.toStringTag : void 0;
|
|
240
|
+
function baseGetTag$5(value) {
|
|
241
|
+
if (value == null) {
|
|
242
|
+
return value === void 0 ? undefinedTag : nullTag;
|
|
243
|
+
}
|
|
244
|
+
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
245
|
+
}
|
|
246
|
+
var _baseGetTag = baseGetTag$5;
|
|
247
|
+
function isObjectLike$5(value) {
|
|
248
|
+
return value != null && typeof value == "object";
|
|
249
|
+
}
|
|
250
|
+
var isObjectLike_1 = isObjectLike$5;
|
|
251
|
+
var baseGetTag$4 = _baseGetTag, isObjectLike$4 = isObjectLike_1;
|
|
252
|
+
var symbolTag$1 = "[object Symbol]";
|
|
253
|
+
function isSymbol$3(value) {
|
|
254
|
+
return typeof value == "symbol" || isObjectLike$4(value) && baseGetTag$4(value) == symbolTag$1;
|
|
255
|
+
}
|
|
256
|
+
var isSymbol_1 = isSymbol$3;
|
|
257
|
+
var isArray$7 = isArray_1, isSymbol$2 = isSymbol_1;
|
|
258
|
+
var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/;
|
|
259
|
+
function isKey$3(value, object2) {
|
|
260
|
+
if (isArray$7(value)) {
|
|
261
|
+
return false;
|
|
262
|
+
}
|
|
263
|
+
var type = typeof value;
|
|
264
|
+
if (type == "number" || type == "symbol" || type == "boolean" || value == null || isSymbol$2(value)) {
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object2 != null && value in Object(object2);
|
|
268
|
+
}
|
|
269
|
+
var _isKey = isKey$3;
|
|
270
|
+
function isObject$3(value) {
|
|
271
|
+
var type = typeof value;
|
|
272
|
+
return value != null && (type == "object" || type == "function");
|
|
273
|
+
}
|
|
274
|
+
var isObject_1 = isObject$3;
|
|
275
|
+
var baseGetTag$3 = _baseGetTag, isObject$2 = isObject_1;
|
|
276
|
+
var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
277
|
+
function isFunction$2(value) {
|
|
278
|
+
if (!isObject$2(value)) {
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
var tag = baseGetTag$3(value);
|
|
282
|
+
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
283
|
+
}
|
|
284
|
+
var isFunction_1 = isFunction$2;
|
|
285
|
+
var root$6 = _root;
|
|
286
|
+
var coreJsData$1 = root$6["__core-js_shared__"];
|
|
287
|
+
var _coreJsData = coreJsData$1;
|
|
288
|
+
var coreJsData = _coreJsData;
|
|
289
|
+
var maskSrcKey = function() {
|
|
290
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
291
|
+
return uid ? "Symbol(src)_1." + uid : "";
|
|
292
|
+
}();
|
|
293
|
+
function isMasked$1(func) {
|
|
294
|
+
return !!maskSrcKey && maskSrcKey in func;
|
|
295
|
+
}
|
|
296
|
+
var _isMasked = isMasked$1;
|
|
297
|
+
var funcProto$1 = Function.prototype;
|
|
298
|
+
var funcToString$1 = funcProto$1.toString;
|
|
299
|
+
function toSource$2(func) {
|
|
300
|
+
if (func != null) {
|
|
301
|
+
try {
|
|
302
|
+
return funcToString$1.call(func);
|
|
303
|
+
} catch (e) {
|
|
304
|
+
}
|
|
305
|
+
try {
|
|
306
|
+
return func + "";
|
|
307
|
+
} catch (e) {
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return "";
|
|
311
|
+
}
|
|
312
|
+
var _toSource = toSource$2;
|
|
313
|
+
var isFunction$1 = isFunction_1, isMasked = _isMasked, isObject$1 = isObject_1, toSource$1 = _toSource;
|
|
314
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
315
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
316
|
+
var funcProto = Function.prototype, objectProto$9 = Object.prototype;
|
|
317
|
+
var funcToString = funcProto.toString;
|
|
318
|
+
var hasOwnProperty$7 = objectProto$9.hasOwnProperty;
|
|
319
|
+
var reIsNative = RegExp(
|
|
320
|
+
"^" + funcToString.call(hasOwnProperty$7).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
321
|
+
);
|
|
322
|
+
function baseIsNative$1(value) {
|
|
323
|
+
if (!isObject$1(value) || isMasked(value)) {
|
|
324
|
+
return false;
|
|
325
|
+
}
|
|
326
|
+
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
327
|
+
return pattern.test(toSource$1(value));
|
|
328
|
+
}
|
|
329
|
+
var _baseIsNative = baseIsNative$1;
|
|
330
|
+
function getValue$1(object2, key) {
|
|
331
|
+
return object2 == null ? void 0 : object2[key];
|
|
332
|
+
}
|
|
333
|
+
var _getValue = getValue$1;
|
|
334
|
+
var baseIsNative = _baseIsNative, getValue = _getValue;
|
|
335
|
+
function getNative$7(object2, key) {
|
|
336
|
+
var value = getValue(object2, key);
|
|
337
|
+
return baseIsNative(value) ? value : void 0;
|
|
338
|
+
}
|
|
339
|
+
var _getNative = getNative$7;
|
|
340
|
+
var getNative$6 = _getNative;
|
|
341
|
+
var nativeCreate$4 = getNative$6(Object, "create");
|
|
342
|
+
var _nativeCreate = nativeCreate$4;
|
|
343
|
+
var nativeCreate$3 = _nativeCreate;
|
|
344
|
+
function hashClear$1() {
|
|
345
|
+
this.__data__ = nativeCreate$3 ? nativeCreate$3(null) : {};
|
|
346
|
+
this.size = 0;
|
|
347
|
+
}
|
|
348
|
+
var _hashClear = hashClear$1;
|
|
349
|
+
function hashDelete$1(key) {
|
|
350
|
+
var result = this.has(key) && delete this.__data__[key];
|
|
351
|
+
this.size -= result ? 1 : 0;
|
|
352
|
+
return result;
|
|
353
|
+
}
|
|
354
|
+
var _hashDelete = hashDelete$1;
|
|
355
|
+
var nativeCreate$2 = _nativeCreate;
|
|
356
|
+
var HASH_UNDEFINED$2 = "__lodash_hash_undefined__";
|
|
357
|
+
var objectProto$8 = Object.prototype;
|
|
358
|
+
var hasOwnProperty$6 = objectProto$8.hasOwnProperty;
|
|
359
|
+
function hashGet$1(key) {
|
|
360
|
+
var data = this.__data__;
|
|
361
|
+
if (nativeCreate$2) {
|
|
362
|
+
var result = data[key];
|
|
363
|
+
return result === HASH_UNDEFINED$2 ? void 0 : result;
|
|
364
|
+
}
|
|
365
|
+
return hasOwnProperty$6.call(data, key) ? data[key] : void 0;
|
|
366
|
+
}
|
|
367
|
+
var _hashGet = hashGet$1;
|
|
368
|
+
var nativeCreate$1 = _nativeCreate;
|
|
369
|
+
var objectProto$7 = Object.prototype;
|
|
370
|
+
var hasOwnProperty$5 = objectProto$7.hasOwnProperty;
|
|
371
|
+
function hashHas$1(key) {
|
|
372
|
+
var data = this.__data__;
|
|
373
|
+
return nativeCreate$1 ? data[key] !== void 0 : hasOwnProperty$5.call(data, key);
|
|
374
|
+
}
|
|
375
|
+
var _hashHas = hashHas$1;
|
|
376
|
+
var nativeCreate = _nativeCreate;
|
|
377
|
+
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
378
|
+
function hashSet$1(key, value) {
|
|
379
|
+
var data = this.__data__;
|
|
380
|
+
this.size += this.has(key) ? 0 : 1;
|
|
381
|
+
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED$1 : value;
|
|
382
|
+
return this;
|
|
383
|
+
}
|
|
384
|
+
var _hashSet = hashSet$1;
|
|
385
|
+
var hashClear = _hashClear, hashDelete = _hashDelete, hashGet = _hashGet, hashHas = _hashHas, hashSet = _hashSet;
|
|
386
|
+
function Hash$1(entries) {
|
|
387
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
388
|
+
this.clear();
|
|
389
|
+
while (++index2 < length) {
|
|
390
|
+
var entry = entries[index2];
|
|
391
|
+
this.set(entry[0], entry[1]);
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
Hash$1.prototype.clear = hashClear;
|
|
395
|
+
Hash$1.prototype["delete"] = hashDelete;
|
|
396
|
+
Hash$1.prototype.get = hashGet;
|
|
397
|
+
Hash$1.prototype.has = hashHas;
|
|
398
|
+
Hash$1.prototype.set = hashSet;
|
|
399
|
+
var _Hash = Hash$1;
|
|
400
|
+
function listCacheClear$1() {
|
|
401
|
+
this.__data__ = [];
|
|
402
|
+
this.size = 0;
|
|
403
|
+
}
|
|
404
|
+
var _listCacheClear = listCacheClear$1;
|
|
405
|
+
function eq$2(value, other) {
|
|
406
|
+
return value === other || value !== value && other !== other;
|
|
407
|
+
}
|
|
408
|
+
var eq_1 = eq$2;
|
|
409
|
+
var eq$1 = eq_1;
|
|
410
|
+
function assocIndexOf$4(array2, key) {
|
|
411
|
+
var length = array2.length;
|
|
412
|
+
while (length--) {
|
|
413
|
+
if (eq$1(array2[length][0], key)) {
|
|
414
|
+
return length;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return -1;
|
|
418
|
+
}
|
|
419
|
+
var _assocIndexOf = assocIndexOf$4;
|
|
420
|
+
var assocIndexOf$3 = _assocIndexOf;
|
|
421
|
+
var arrayProto = Array.prototype;
|
|
422
|
+
var splice = arrayProto.splice;
|
|
423
|
+
function listCacheDelete$1(key) {
|
|
424
|
+
var data = this.__data__, index2 = assocIndexOf$3(data, key);
|
|
425
|
+
if (index2 < 0) {
|
|
426
|
+
return false;
|
|
427
|
+
}
|
|
428
|
+
var lastIndex = data.length - 1;
|
|
429
|
+
if (index2 == lastIndex) {
|
|
430
|
+
data.pop();
|
|
431
|
+
} else {
|
|
432
|
+
splice.call(data, index2, 1);
|
|
433
|
+
}
|
|
434
|
+
--this.size;
|
|
435
|
+
return true;
|
|
436
|
+
}
|
|
437
|
+
var _listCacheDelete = listCacheDelete$1;
|
|
438
|
+
var assocIndexOf$2 = _assocIndexOf;
|
|
439
|
+
function listCacheGet$1(key) {
|
|
440
|
+
var data = this.__data__, index2 = assocIndexOf$2(data, key);
|
|
441
|
+
return index2 < 0 ? void 0 : data[index2][1];
|
|
442
|
+
}
|
|
443
|
+
var _listCacheGet = listCacheGet$1;
|
|
444
|
+
var assocIndexOf$1 = _assocIndexOf;
|
|
445
|
+
function listCacheHas$1(key) {
|
|
446
|
+
return assocIndexOf$1(this.__data__, key) > -1;
|
|
447
|
+
}
|
|
448
|
+
var _listCacheHas = listCacheHas$1;
|
|
449
|
+
var assocIndexOf = _assocIndexOf;
|
|
450
|
+
function listCacheSet$1(key, value) {
|
|
451
|
+
var data = this.__data__, index2 = assocIndexOf(data, key);
|
|
452
|
+
if (index2 < 0) {
|
|
453
|
+
++this.size;
|
|
454
|
+
data.push([key, value]);
|
|
455
|
+
} else {
|
|
456
|
+
data[index2][1] = value;
|
|
457
|
+
}
|
|
458
|
+
return this;
|
|
459
|
+
}
|
|
460
|
+
var _listCacheSet = listCacheSet$1;
|
|
461
|
+
var listCacheClear = _listCacheClear, listCacheDelete = _listCacheDelete, listCacheGet = _listCacheGet, listCacheHas = _listCacheHas, listCacheSet = _listCacheSet;
|
|
462
|
+
function ListCache$4(entries) {
|
|
463
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
464
|
+
this.clear();
|
|
465
|
+
while (++index2 < length) {
|
|
466
|
+
var entry = entries[index2];
|
|
467
|
+
this.set(entry[0], entry[1]);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
ListCache$4.prototype.clear = listCacheClear;
|
|
471
|
+
ListCache$4.prototype["delete"] = listCacheDelete;
|
|
472
|
+
ListCache$4.prototype.get = listCacheGet;
|
|
473
|
+
ListCache$4.prototype.has = listCacheHas;
|
|
474
|
+
ListCache$4.prototype.set = listCacheSet;
|
|
475
|
+
var _ListCache = ListCache$4;
|
|
476
|
+
var getNative$5 = _getNative, root$5 = _root;
|
|
477
|
+
var Map$4 = getNative$5(root$5, "Map");
|
|
478
|
+
var _Map = Map$4;
|
|
479
|
+
var Hash = _Hash, ListCache$3 = _ListCache, Map$3 = _Map;
|
|
480
|
+
function mapCacheClear$1() {
|
|
481
|
+
this.size = 0;
|
|
482
|
+
this.__data__ = {
|
|
483
|
+
"hash": new Hash(),
|
|
484
|
+
"map": new (Map$3 || ListCache$3)(),
|
|
485
|
+
"string": new Hash()
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
var _mapCacheClear = mapCacheClear$1;
|
|
489
|
+
function isKeyable$1(value) {
|
|
490
|
+
var type = typeof value;
|
|
491
|
+
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
492
|
+
}
|
|
493
|
+
var _isKeyable = isKeyable$1;
|
|
494
|
+
var isKeyable = _isKeyable;
|
|
495
|
+
function getMapData$4(map2, key) {
|
|
496
|
+
var data = map2.__data__;
|
|
497
|
+
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
498
|
+
}
|
|
499
|
+
var _getMapData = getMapData$4;
|
|
500
|
+
var getMapData$3 = _getMapData;
|
|
501
|
+
function mapCacheDelete$1(key) {
|
|
502
|
+
var result = getMapData$3(this, key)["delete"](key);
|
|
503
|
+
this.size -= result ? 1 : 0;
|
|
504
|
+
return result;
|
|
505
|
+
}
|
|
506
|
+
var _mapCacheDelete = mapCacheDelete$1;
|
|
507
|
+
var getMapData$2 = _getMapData;
|
|
508
|
+
function mapCacheGet$1(key) {
|
|
509
|
+
return getMapData$2(this, key).get(key);
|
|
510
|
+
}
|
|
511
|
+
var _mapCacheGet = mapCacheGet$1;
|
|
512
|
+
var getMapData$1 = _getMapData;
|
|
513
|
+
function mapCacheHas$1(key) {
|
|
514
|
+
return getMapData$1(this, key).has(key);
|
|
515
|
+
}
|
|
516
|
+
var _mapCacheHas = mapCacheHas$1;
|
|
517
|
+
var getMapData = _getMapData;
|
|
518
|
+
function mapCacheSet$1(key, value) {
|
|
519
|
+
var data = getMapData(this, key), size = data.size;
|
|
520
|
+
data.set(key, value);
|
|
521
|
+
this.size += data.size == size ? 0 : 1;
|
|
522
|
+
return this;
|
|
523
|
+
}
|
|
524
|
+
var _mapCacheSet = mapCacheSet$1;
|
|
525
|
+
var mapCacheClear = _mapCacheClear, mapCacheDelete = _mapCacheDelete, mapCacheGet = _mapCacheGet, mapCacheHas = _mapCacheHas, mapCacheSet = _mapCacheSet;
|
|
526
|
+
function MapCache$3(entries) {
|
|
527
|
+
var index2 = -1, length = entries == null ? 0 : entries.length;
|
|
528
|
+
this.clear();
|
|
529
|
+
while (++index2 < length) {
|
|
530
|
+
var entry = entries[index2];
|
|
531
|
+
this.set(entry[0], entry[1]);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
MapCache$3.prototype.clear = mapCacheClear;
|
|
535
|
+
MapCache$3.prototype["delete"] = mapCacheDelete;
|
|
536
|
+
MapCache$3.prototype.get = mapCacheGet;
|
|
537
|
+
MapCache$3.prototype.has = mapCacheHas;
|
|
538
|
+
MapCache$3.prototype.set = mapCacheSet;
|
|
539
|
+
var _MapCache = MapCache$3;
|
|
540
|
+
var MapCache$2 = _MapCache;
|
|
541
|
+
var FUNC_ERROR_TEXT = "Expected a function";
|
|
542
|
+
function memoize$1(func, resolver) {
|
|
543
|
+
if (typeof func != "function" || resolver != null && typeof resolver != "function") {
|
|
544
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
545
|
+
}
|
|
546
|
+
var memoized = function() {
|
|
547
|
+
var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
|
|
548
|
+
if (cache.has(key)) {
|
|
549
|
+
return cache.get(key);
|
|
550
|
+
}
|
|
551
|
+
var result = func.apply(this, args);
|
|
552
|
+
memoized.cache = cache.set(key, result) || cache;
|
|
553
|
+
return result;
|
|
554
|
+
};
|
|
555
|
+
memoized.cache = new (memoize$1.Cache || MapCache$2)();
|
|
556
|
+
return memoized;
|
|
557
|
+
}
|
|
558
|
+
memoize$1.Cache = MapCache$2;
|
|
559
|
+
var memoize_1 = memoize$1;
|
|
560
|
+
var memoize = memoize_1;
|
|
561
|
+
var MAX_MEMOIZE_SIZE = 500;
|
|
562
|
+
function memoizeCapped$1(func) {
|
|
563
|
+
var result = memoize(func, function(key) {
|
|
564
|
+
if (cache.size === MAX_MEMOIZE_SIZE) {
|
|
565
|
+
cache.clear();
|
|
566
|
+
}
|
|
567
|
+
return key;
|
|
568
|
+
});
|
|
569
|
+
var cache = result.cache;
|
|
570
|
+
return result;
|
|
571
|
+
}
|
|
572
|
+
var _memoizeCapped = memoizeCapped$1;
|
|
573
|
+
var memoizeCapped = _memoizeCapped;
|
|
574
|
+
var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
|
|
575
|
+
var reEscapeChar = /\\(\\)?/g;
|
|
576
|
+
var stringToPath$1 = memoizeCapped(function(string2) {
|
|
577
|
+
var result = [];
|
|
578
|
+
if (string2.charCodeAt(0) === 46) {
|
|
579
|
+
result.push("");
|
|
580
|
+
}
|
|
581
|
+
string2.replace(rePropName, function(match, number2, quote, subString) {
|
|
582
|
+
result.push(quote ? subString.replace(reEscapeChar, "$1") : number2 || match);
|
|
583
|
+
});
|
|
584
|
+
return result;
|
|
585
|
+
});
|
|
586
|
+
var _stringToPath = stringToPath$1;
|
|
587
|
+
function arrayMap$1(array2, iteratee) {
|
|
588
|
+
var index2 = -1, length = array2 == null ? 0 : array2.length, result = Array(length);
|
|
589
|
+
while (++index2 < length) {
|
|
590
|
+
result[index2] = iteratee(array2[index2], index2, array2);
|
|
591
|
+
}
|
|
592
|
+
return result;
|
|
593
|
+
}
|
|
594
|
+
var _arrayMap = arrayMap$1;
|
|
595
|
+
var Symbol$2 = _Symbol, arrayMap = _arrayMap, isArray$6 = isArray_1, isSymbol$1 = isSymbol_1;
|
|
596
|
+
var INFINITY$1 = 1 / 0;
|
|
597
|
+
var symbolProto$1 = Symbol$2 ? Symbol$2.prototype : void 0, symbolToString = symbolProto$1 ? symbolProto$1.toString : void 0;
|
|
598
|
+
function baseToString$1(value) {
|
|
599
|
+
if (typeof value == "string") {
|
|
600
|
+
return value;
|
|
601
|
+
}
|
|
602
|
+
if (isArray$6(value)) {
|
|
603
|
+
return arrayMap(value, baseToString$1) + "";
|
|
604
|
+
}
|
|
605
|
+
if (isSymbol$1(value)) {
|
|
606
|
+
return symbolToString ? symbolToString.call(value) : "";
|
|
607
|
+
}
|
|
608
|
+
var result = value + "";
|
|
609
|
+
return result == "0" && 1 / value == -INFINITY$1 ? "-0" : result;
|
|
610
|
+
}
|
|
611
|
+
var _baseToString = baseToString$1;
|
|
612
|
+
var baseToString = _baseToString;
|
|
613
|
+
function toString$1(value) {
|
|
614
|
+
return value == null ? "" : baseToString(value);
|
|
615
|
+
}
|
|
616
|
+
var toString_1 = toString$1;
|
|
617
|
+
var isArray$5 = isArray_1, isKey$2 = _isKey, stringToPath = _stringToPath, toString = toString_1;
|
|
618
|
+
function castPath$2(value, object2) {
|
|
619
|
+
if (isArray$5(value)) {
|
|
620
|
+
return value;
|
|
621
|
+
}
|
|
622
|
+
return isKey$2(value, object2) ? [value] : stringToPath(toString(value));
|
|
623
|
+
}
|
|
624
|
+
var _castPath = castPath$2;
|
|
625
|
+
var baseGetTag$2 = _baseGetTag, isObjectLike$3 = isObjectLike_1;
|
|
626
|
+
var argsTag$2 = "[object Arguments]";
|
|
627
|
+
function baseIsArguments$1(value) {
|
|
628
|
+
return isObjectLike$3(value) && baseGetTag$2(value) == argsTag$2;
|
|
629
|
+
}
|
|
630
|
+
var _baseIsArguments = baseIsArguments$1;
|
|
631
|
+
var baseIsArguments = _baseIsArguments, isObjectLike$2 = isObjectLike_1;
|
|
632
|
+
var objectProto$6 = Object.prototype;
|
|
633
|
+
var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
|
|
634
|
+
var propertyIsEnumerable$1 = objectProto$6.propertyIsEnumerable;
|
|
635
|
+
var isArguments$2 = baseIsArguments(/* @__PURE__ */ function() {
|
|
636
|
+
return arguments;
|
|
637
|
+
}()) ? baseIsArguments : function(value) {
|
|
638
|
+
return isObjectLike$2(value) && hasOwnProperty$4.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
|
|
639
|
+
};
|
|
640
|
+
var isArguments_1 = isArguments$2;
|
|
641
|
+
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
642
|
+
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
643
|
+
function isIndex$2(value, length) {
|
|
644
|
+
var type = typeof value;
|
|
645
|
+
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
646
|
+
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
647
|
+
}
|
|
648
|
+
var _isIndex = isIndex$2;
|
|
649
|
+
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
650
|
+
function isLength$3(value) {
|
|
651
|
+
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
652
|
+
}
|
|
653
|
+
var isLength_1 = isLength$3;
|
|
654
|
+
var isSymbol = isSymbol_1;
|
|
655
|
+
var INFINITY = 1 / 0;
|
|
656
|
+
function toKey$4(value) {
|
|
657
|
+
if (typeof value == "string" || isSymbol(value)) {
|
|
658
|
+
return value;
|
|
659
|
+
}
|
|
660
|
+
var result = value + "";
|
|
661
|
+
return result == "0" && 1 / value == -INFINITY ? "-0" : result;
|
|
662
|
+
}
|
|
663
|
+
var _toKey = toKey$4;
|
|
664
|
+
var castPath$1 = _castPath, isArguments$1 = isArguments_1, isArray$4 = isArray_1, isIndex$1 = _isIndex, isLength$2 = isLength_1, toKey$3 = _toKey;
|
|
665
|
+
function hasPath$2(object2, path, hasFunc) {
|
|
666
|
+
path = castPath$1(path, object2);
|
|
667
|
+
var index2 = -1, length = path.length, result = false;
|
|
668
|
+
while (++index2 < length) {
|
|
669
|
+
var key = toKey$3(path[index2]);
|
|
670
|
+
if (!(result = object2 != null && hasFunc(object2, key))) {
|
|
671
|
+
break;
|
|
672
|
+
}
|
|
673
|
+
object2 = object2[key];
|
|
674
|
+
}
|
|
675
|
+
if (result || ++index2 != length) {
|
|
676
|
+
return result;
|
|
677
|
+
}
|
|
678
|
+
length = object2 == null ? 0 : object2.length;
|
|
679
|
+
return !!length && isLength$2(length) && isIndex$1(key, length) && (isArray$4(object2) || isArguments$1(object2));
|
|
680
|
+
}
|
|
681
|
+
var _hasPath = hasPath$2;
|
|
682
|
+
var baseHas = _baseHas, hasPath$1 = _hasPath;
|
|
683
|
+
function has(object2, path) {
|
|
684
|
+
return object2 != null && hasPath$1(object2, path, baseHas);
|
|
685
|
+
}
|
|
686
|
+
var has_1 = has;
|
|
687
|
+
const has$1 = /* @__PURE__ */ getDefaultExportFromCjs(has_1);
|
|
688
|
+
const isSchema = (obj) => obj && obj.__isYupSchema__;
|
|
689
|
+
class Condition {
|
|
690
|
+
constructor(refs, options) {
|
|
691
|
+
this.refs = refs;
|
|
692
|
+
this.refs = refs;
|
|
693
|
+
if (typeof options === "function") {
|
|
694
|
+
this.fn = options;
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
if (!has$1(options, "is"))
|
|
698
|
+
throw new TypeError("`is:` is required for `when()` conditions");
|
|
699
|
+
if (!options.then && !options.otherwise)
|
|
700
|
+
throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");
|
|
701
|
+
let {
|
|
702
|
+
is,
|
|
703
|
+
then,
|
|
704
|
+
otherwise
|
|
705
|
+
} = options;
|
|
706
|
+
let check = typeof is === "function" ? is : (...values) => values.every((value) => value === is);
|
|
707
|
+
this.fn = function(...args) {
|
|
708
|
+
let options2 = args.pop();
|
|
709
|
+
let schema = args.pop();
|
|
710
|
+
let branch = check(...args) ? then : otherwise;
|
|
711
|
+
if (!branch)
|
|
712
|
+
return void 0;
|
|
713
|
+
if (typeof branch === "function")
|
|
714
|
+
return branch(schema);
|
|
715
|
+
return schema.concat(branch.resolve(options2));
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
resolve(base, options) {
|
|
719
|
+
let values = this.refs.map((ref) => ref.getValue(options == null ? void 0 : options.value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context));
|
|
720
|
+
let schema = this.fn.apply(base, values.concat(base, options));
|
|
721
|
+
if (schema === void 0 || schema === base)
|
|
722
|
+
return base;
|
|
723
|
+
if (!isSchema(schema))
|
|
724
|
+
throw new TypeError("conditions must return a schema object");
|
|
725
|
+
return schema.resolve(options);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
function toArray(value) {
|
|
729
|
+
return value == null ? [] : [].concat(value);
|
|
730
|
+
}
|
|
731
|
+
function _extends$2() {
|
|
732
|
+
_extends$2 = Object.assign || function(target) {
|
|
733
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
734
|
+
var source = arguments[i];
|
|
735
|
+
for (var key in source) {
|
|
736
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
737
|
+
target[key] = source[key];
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
return target;
|
|
742
|
+
};
|
|
743
|
+
return _extends$2.apply(this, arguments);
|
|
744
|
+
}
|
|
745
|
+
let strReg = /\$\{\s*(\w+)\s*\}/g;
|
|
746
|
+
class ValidationError extends Error {
|
|
747
|
+
static formatError(message, params) {
|
|
748
|
+
const path = params.label || params.path || "this";
|
|
749
|
+
if (path !== params.path)
|
|
750
|
+
params = _extends$2({}, params, {
|
|
751
|
+
path
|
|
752
|
+
});
|
|
753
|
+
if (typeof message === "string")
|
|
754
|
+
return message.replace(strReg, (_, key) => printValue(params[key]));
|
|
755
|
+
if (typeof message === "function")
|
|
756
|
+
return message(params);
|
|
757
|
+
return message;
|
|
758
|
+
}
|
|
759
|
+
static isError(err) {
|
|
760
|
+
return err && err.name === "ValidationError";
|
|
761
|
+
}
|
|
762
|
+
constructor(errorOrErrors, value, field, type) {
|
|
763
|
+
super();
|
|
764
|
+
this.name = "ValidationError";
|
|
765
|
+
this.value = value;
|
|
766
|
+
this.path = field;
|
|
767
|
+
this.type = type;
|
|
768
|
+
this.errors = [];
|
|
769
|
+
this.inner = [];
|
|
770
|
+
toArray(errorOrErrors).forEach((err) => {
|
|
771
|
+
if (ValidationError.isError(err)) {
|
|
772
|
+
this.errors.push(...err.errors);
|
|
773
|
+
this.inner = this.inner.concat(err.inner.length ? err.inner : err);
|
|
774
|
+
} else {
|
|
775
|
+
this.errors.push(err);
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
this.message = this.errors.length > 1 ? `${this.errors.length} errors occurred` : this.errors[0];
|
|
779
|
+
if (Error.captureStackTrace)
|
|
780
|
+
Error.captureStackTrace(this, ValidationError);
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
const once = (cb) => {
|
|
784
|
+
let fired = false;
|
|
785
|
+
return (...args) => {
|
|
786
|
+
if (fired)
|
|
787
|
+
return;
|
|
788
|
+
fired = true;
|
|
789
|
+
cb(...args);
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
function runTests(options, cb) {
|
|
793
|
+
let {
|
|
794
|
+
endEarly,
|
|
795
|
+
tests,
|
|
796
|
+
args,
|
|
797
|
+
value,
|
|
798
|
+
errors,
|
|
799
|
+
sort,
|
|
800
|
+
path
|
|
801
|
+
} = options;
|
|
802
|
+
let callback = once(cb);
|
|
803
|
+
let count = tests.length;
|
|
804
|
+
const nestedErrors = [];
|
|
805
|
+
errors = errors ? errors : [];
|
|
806
|
+
if (!count)
|
|
807
|
+
return errors.length ? callback(new ValidationError(errors, value, path)) : callback(null, value);
|
|
808
|
+
for (let i = 0; i < tests.length; i++) {
|
|
809
|
+
const test = tests[i];
|
|
810
|
+
test(args, function finishTestRun(err) {
|
|
811
|
+
if (err) {
|
|
812
|
+
if (!ValidationError.isError(err)) {
|
|
813
|
+
return callback(err, value);
|
|
814
|
+
}
|
|
815
|
+
if (endEarly) {
|
|
816
|
+
err.value = value;
|
|
817
|
+
return callback(err, value);
|
|
818
|
+
}
|
|
819
|
+
nestedErrors.push(err);
|
|
820
|
+
}
|
|
821
|
+
if (--count <= 0) {
|
|
822
|
+
if (nestedErrors.length) {
|
|
823
|
+
if (sort)
|
|
824
|
+
nestedErrors.sort(sort);
|
|
825
|
+
if (errors.length)
|
|
826
|
+
nestedErrors.push(...errors);
|
|
827
|
+
errors = nestedErrors;
|
|
828
|
+
}
|
|
829
|
+
if (errors.length) {
|
|
830
|
+
callback(new ValidationError(errors, value, path), value);
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
callback(null, value);
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
var getNative$4 = _getNative;
|
|
839
|
+
var defineProperty$1 = function() {
|
|
840
|
+
try {
|
|
841
|
+
var func = getNative$4(Object, "defineProperty");
|
|
842
|
+
func({}, "", {});
|
|
843
|
+
return func;
|
|
844
|
+
} catch (e) {
|
|
845
|
+
}
|
|
846
|
+
}();
|
|
847
|
+
var _defineProperty = defineProperty$1;
|
|
848
|
+
var defineProperty = _defineProperty;
|
|
849
|
+
function baseAssignValue$1(object2, key, value) {
|
|
850
|
+
if (key == "__proto__" && defineProperty) {
|
|
851
|
+
defineProperty(object2, key, {
|
|
852
|
+
"configurable": true,
|
|
853
|
+
"enumerable": true,
|
|
854
|
+
"value": value,
|
|
855
|
+
"writable": true
|
|
856
|
+
});
|
|
857
|
+
} else {
|
|
858
|
+
object2[key] = value;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
var _baseAssignValue = baseAssignValue$1;
|
|
862
|
+
function createBaseFor$1(fromRight) {
|
|
863
|
+
return function(object2, iteratee, keysFunc) {
|
|
864
|
+
var index2 = -1, iterable = Object(object2), props = keysFunc(object2), length = props.length;
|
|
865
|
+
while (length--) {
|
|
866
|
+
var key = props[fromRight ? length : ++index2];
|
|
867
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
return object2;
|
|
872
|
+
};
|
|
873
|
+
}
|
|
874
|
+
var _createBaseFor = createBaseFor$1;
|
|
875
|
+
var createBaseFor = _createBaseFor;
|
|
876
|
+
var baseFor$1 = createBaseFor();
|
|
877
|
+
var _baseFor = baseFor$1;
|
|
878
|
+
function baseTimes$1(n, iteratee) {
|
|
879
|
+
var index2 = -1, result = Array(n);
|
|
880
|
+
while (++index2 < n) {
|
|
881
|
+
result[index2] = iteratee(index2);
|
|
882
|
+
}
|
|
883
|
+
return result;
|
|
884
|
+
}
|
|
885
|
+
var _baseTimes = baseTimes$1;
|
|
886
|
+
var isBuffer$2 = { exports: {} };
|
|
887
|
+
function stubFalse() {
|
|
888
|
+
return false;
|
|
889
|
+
}
|
|
890
|
+
var stubFalse_1 = stubFalse;
|
|
891
|
+
isBuffer$2.exports;
|
|
892
|
+
(function(module2, exports2) {
|
|
893
|
+
var root2 = _root, stubFalse2 = stubFalse_1;
|
|
894
|
+
var freeExports = exports2 && !exports2.nodeType && exports2;
|
|
895
|
+
var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
|
|
896
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
897
|
+
var Buffer = moduleExports ? root2.Buffer : void 0;
|
|
898
|
+
var nativeIsBuffer = Buffer ? Buffer.isBuffer : void 0;
|
|
899
|
+
var isBuffer2 = nativeIsBuffer || stubFalse2;
|
|
900
|
+
module2.exports = isBuffer2;
|
|
901
|
+
})(isBuffer$2, isBuffer$2.exports);
|
|
902
|
+
var isBufferExports = isBuffer$2.exports;
|
|
903
|
+
var baseGetTag$1 = _baseGetTag, isLength$1 = isLength_1, isObjectLike$1 = isObjectLike_1;
|
|
904
|
+
var argsTag$1 = "[object Arguments]", arrayTag$1 = "[object Array]", boolTag$1 = "[object Boolean]", dateTag$1 = "[object Date]", errorTag$1 = "[object Error]", funcTag = "[object Function]", mapTag$2 = "[object Map]", numberTag$1 = "[object Number]", objectTag$2 = "[object Object]", regexpTag$1 = "[object RegExp]", setTag$2 = "[object Set]", stringTag$1 = "[object String]", weakMapTag$1 = "[object WeakMap]";
|
|
905
|
+
var arrayBufferTag$1 = "[object ArrayBuffer]", dataViewTag$2 = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
|
|
906
|
+
var typedArrayTags = {};
|
|
907
|
+
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
908
|
+
typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$2] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
|
|
909
|
+
function baseIsTypedArray$1(value) {
|
|
910
|
+
return isObjectLike$1(value) && isLength$1(value.length) && !!typedArrayTags[baseGetTag$1(value)];
|
|
911
|
+
}
|
|
912
|
+
var _baseIsTypedArray = baseIsTypedArray$1;
|
|
913
|
+
function baseUnary$1(func) {
|
|
914
|
+
return function(value) {
|
|
915
|
+
return func(value);
|
|
916
|
+
};
|
|
917
|
+
}
|
|
918
|
+
var _baseUnary = baseUnary$1;
|
|
919
|
+
var _nodeUtil = { exports: {} };
|
|
920
|
+
_nodeUtil.exports;
|
|
921
|
+
(function(module2, exports2) {
|
|
922
|
+
var freeGlobal2 = _freeGlobal;
|
|
923
|
+
var freeExports = exports2 && !exports2.nodeType && exports2;
|
|
924
|
+
var freeModule = freeExports && true && module2 && !module2.nodeType && module2;
|
|
925
|
+
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
926
|
+
var freeProcess = moduleExports && freeGlobal2.process;
|
|
927
|
+
var nodeUtil2 = function() {
|
|
928
|
+
try {
|
|
929
|
+
var types = freeModule && freeModule.require && freeModule.require("util").types;
|
|
930
|
+
if (types) {
|
|
931
|
+
return types;
|
|
932
|
+
}
|
|
933
|
+
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
934
|
+
} catch (e) {
|
|
935
|
+
}
|
|
936
|
+
}();
|
|
937
|
+
module2.exports = nodeUtil2;
|
|
938
|
+
})(_nodeUtil, _nodeUtil.exports);
|
|
939
|
+
var _nodeUtilExports = _nodeUtil.exports;
|
|
940
|
+
var baseIsTypedArray = _baseIsTypedArray, baseUnary = _baseUnary, nodeUtil = _nodeUtilExports;
|
|
941
|
+
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
942
|
+
var isTypedArray$2 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
943
|
+
var isTypedArray_1 = isTypedArray$2;
|
|
944
|
+
var baseTimes = _baseTimes, isArguments = isArguments_1, isArray$3 = isArray_1, isBuffer$1 = isBufferExports, isIndex = _isIndex, isTypedArray$1 = isTypedArray_1;
|
|
945
|
+
var objectProto$5 = Object.prototype;
|
|
946
|
+
var hasOwnProperty$3 = objectProto$5.hasOwnProperty;
|
|
947
|
+
function arrayLikeKeys$1(value, inherited) {
|
|
948
|
+
var isArr = isArray$3(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
|
|
949
|
+
for (var key in value) {
|
|
950
|
+
if ((inherited || hasOwnProperty$3.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
951
|
+
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
952
|
+
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
953
|
+
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
954
|
+
isIndex(key, length)))) {
|
|
955
|
+
result.push(key);
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
return result;
|
|
959
|
+
}
|
|
960
|
+
var _arrayLikeKeys = arrayLikeKeys$1;
|
|
961
|
+
var objectProto$4 = Object.prototype;
|
|
962
|
+
function isPrototype$1(value) {
|
|
963
|
+
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$4;
|
|
964
|
+
return value === proto;
|
|
965
|
+
}
|
|
966
|
+
var _isPrototype = isPrototype$1;
|
|
967
|
+
function overArg$1(func, transform) {
|
|
968
|
+
return function(arg) {
|
|
969
|
+
return func(transform(arg));
|
|
970
|
+
};
|
|
971
|
+
}
|
|
972
|
+
var _overArg = overArg$1;
|
|
973
|
+
var overArg = _overArg;
|
|
974
|
+
var nativeKeys$1 = overArg(Object.keys, Object);
|
|
975
|
+
var _nativeKeys = nativeKeys$1;
|
|
976
|
+
var isPrototype = _isPrototype, nativeKeys = _nativeKeys;
|
|
977
|
+
var objectProto$3 = Object.prototype;
|
|
978
|
+
var hasOwnProperty$2 = objectProto$3.hasOwnProperty;
|
|
979
|
+
function baseKeys$1(object2) {
|
|
980
|
+
if (!isPrototype(object2)) {
|
|
981
|
+
return nativeKeys(object2);
|
|
982
|
+
}
|
|
983
|
+
var result = [];
|
|
984
|
+
for (var key in Object(object2)) {
|
|
985
|
+
if (hasOwnProperty$2.call(object2, key) && key != "constructor") {
|
|
986
|
+
result.push(key);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
return result;
|
|
990
|
+
}
|
|
991
|
+
var _baseKeys = baseKeys$1;
|
|
992
|
+
var isFunction = isFunction_1, isLength = isLength_1;
|
|
993
|
+
function isArrayLike$1(value) {
|
|
994
|
+
return value != null && isLength(value.length) && !isFunction(value);
|
|
995
|
+
}
|
|
996
|
+
var isArrayLike_1 = isArrayLike$1;
|
|
997
|
+
var arrayLikeKeys = _arrayLikeKeys, baseKeys = _baseKeys, isArrayLike = isArrayLike_1;
|
|
998
|
+
function keys$3(object2) {
|
|
999
|
+
return isArrayLike(object2) ? arrayLikeKeys(object2) : baseKeys(object2);
|
|
1000
|
+
}
|
|
1001
|
+
var keys_1 = keys$3;
|
|
1002
|
+
var baseFor = _baseFor, keys$2 = keys_1;
|
|
1003
|
+
function baseForOwn$1(object2, iteratee) {
|
|
1004
|
+
return object2 && baseFor(object2, iteratee, keys$2);
|
|
1005
|
+
}
|
|
1006
|
+
var _baseForOwn = baseForOwn$1;
|
|
1007
|
+
var ListCache$2 = _ListCache;
|
|
1008
|
+
function stackClear$1() {
|
|
1009
|
+
this.__data__ = new ListCache$2();
|
|
1010
|
+
this.size = 0;
|
|
1011
|
+
}
|
|
1012
|
+
var _stackClear = stackClear$1;
|
|
1013
|
+
function stackDelete$1(key) {
|
|
1014
|
+
var data = this.__data__, result = data["delete"](key);
|
|
1015
|
+
this.size = data.size;
|
|
1016
|
+
return result;
|
|
1017
|
+
}
|
|
1018
|
+
var _stackDelete = stackDelete$1;
|
|
1019
|
+
function stackGet$1(key) {
|
|
1020
|
+
return this.__data__.get(key);
|
|
1021
|
+
}
|
|
1022
|
+
var _stackGet = stackGet$1;
|
|
1023
|
+
function stackHas$1(key) {
|
|
1024
|
+
return this.__data__.has(key);
|
|
1025
|
+
}
|
|
1026
|
+
var _stackHas = stackHas$1;
|
|
1027
|
+
var ListCache$1 = _ListCache, Map$2 = _Map, MapCache$1 = _MapCache;
|
|
1028
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
1029
|
+
function stackSet$1(key, value) {
|
|
1030
|
+
var data = this.__data__;
|
|
1031
|
+
if (data instanceof ListCache$1) {
|
|
1032
|
+
var pairs = data.__data__;
|
|
1033
|
+
if (!Map$2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
1034
|
+
pairs.push([key, value]);
|
|
1035
|
+
this.size = ++data.size;
|
|
1036
|
+
return this;
|
|
1037
|
+
}
|
|
1038
|
+
data = this.__data__ = new MapCache$1(pairs);
|
|
1039
|
+
}
|
|
1040
|
+
data.set(key, value);
|
|
1041
|
+
this.size = data.size;
|
|
1042
|
+
return this;
|
|
1043
|
+
}
|
|
1044
|
+
var _stackSet = stackSet$1;
|
|
1045
|
+
var ListCache = _ListCache, stackClear = _stackClear, stackDelete = _stackDelete, stackGet = _stackGet, stackHas = _stackHas, stackSet = _stackSet;
|
|
1046
|
+
function Stack$2(entries) {
|
|
1047
|
+
var data = this.__data__ = new ListCache(entries);
|
|
1048
|
+
this.size = data.size;
|
|
1049
|
+
}
|
|
1050
|
+
Stack$2.prototype.clear = stackClear;
|
|
1051
|
+
Stack$2.prototype["delete"] = stackDelete;
|
|
1052
|
+
Stack$2.prototype.get = stackGet;
|
|
1053
|
+
Stack$2.prototype.has = stackHas;
|
|
1054
|
+
Stack$2.prototype.set = stackSet;
|
|
1055
|
+
var _Stack = Stack$2;
|
|
1056
|
+
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
1057
|
+
function setCacheAdd$1(value) {
|
|
1058
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
1059
|
+
return this;
|
|
1060
|
+
}
|
|
1061
|
+
var _setCacheAdd = setCacheAdd$1;
|
|
1062
|
+
function setCacheHas$1(value) {
|
|
1063
|
+
return this.__data__.has(value);
|
|
1064
|
+
}
|
|
1065
|
+
var _setCacheHas = setCacheHas$1;
|
|
1066
|
+
var MapCache = _MapCache, setCacheAdd = _setCacheAdd, setCacheHas = _setCacheHas;
|
|
1067
|
+
function SetCache$1(values) {
|
|
1068
|
+
var index2 = -1, length = values == null ? 0 : values.length;
|
|
1069
|
+
this.__data__ = new MapCache();
|
|
1070
|
+
while (++index2 < length) {
|
|
1071
|
+
this.add(values[index2]);
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
SetCache$1.prototype.add = SetCache$1.prototype.push = setCacheAdd;
|
|
1075
|
+
SetCache$1.prototype.has = setCacheHas;
|
|
1076
|
+
var _SetCache = SetCache$1;
|
|
1077
|
+
function arraySome$1(array2, predicate) {
|
|
1078
|
+
var index2 = -1, length = array2 == null ? 0 : array2.length;
|
|
1079
|
+
while (++index2 < length) {
|
|
1080
|
+
if (predicate(array2[index2], index2, array2)) {
|
|
1081
|
+
return true;
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
return false;
|
|
1085
|
+
}
|
|
1086
|
+
var _arraySome = arraySome$1;
|
|
1087
|
+
function cacheHas$1(cache, key) {
|
|
1088
|
+
return cache.has(key);
|
|
1089
|
+
}
|
|
1090
|
+
var _cacheHas = cacheHas$1;
|
|
1091
|
+
var SetCache = _SetCache, arraySome = _arraySome, cacheHas = _cacheHas;
|
|
1092
|
+
var COMPARE_PARTIAL_FLAG$5 = 1, COMPARE_UNORDERED_FLAG$3 = 2;
|
|
1093
|
+
function equalArrays$2(array2, other, bitmask, customizer, equalFunc, stack) {
|
|
1094
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$5, arrLength = array2.length, othLength = other.length;
|
|
1095
|
+
if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
|
|
1096
|
+
return false;
|
|
1097
|
+
}
|
|
1098
|
+
var arrStacked = stack.get(array2);
|
|
1099
|
+
var othStacked = stack.get(other);
|
|
1100
|
+
if (arrStacked && othStacked) {
|
|
1101
|
+
return arrStacked == other && othStacked == array2;
|
|
1102
|
+
}
|
|
1103
|
+
var index2 = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG$3 ? new SetCache() : void 0;
|
|
1104
|
+
stack.set(array2, other);
|
|
1105
|
+
stack.set(other, array2);
|
|
1106
|
+
while (++index2 < arrLength) {
|
|
1107
|
+
var arrValue = array2[index2], othValue = other[index2];
|
|
1108
|
+
if (customizer) {
|
|
1109
|
+
var compared = isPartial ? customizer(othValue, arrValue, index2, other, array2, stack) : customizer(arrValue, othValue, index2, array2, other, stack);
|
|
1110
|
+
}
|
|
1111
|
+
if (compared !== void 0) {
|
|
1112
|
+
if (compared) {
|
|
1113
|
+
continue;
|
|
1114
|
+
}
|
|
1115
|
+
result = false;
|
|
1116
|
+
break;
|
|
1117
|
+
}
|
|
1118
|
+
if (seen) {
|
|
1119
|
+
if (!arraySome(other, function(othValue2, othIndex) {
|
|
1120
|
+
if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
|
|
1121
|
+
return seen.push(othIndex);
|
|
1122
|
+
}
|
|
1123
|
+
})) {
|
|
1124
|
+
result = false;
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
} else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
|
|
1128
|
+
result = false;
|
|
1129
|
+
break;
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
stack["delete"](array2);
|
|
1133
|
+
stack["delete"](other);
|
|
1134
|
+
return result;
|
|
1135
|
+
}
|
|
1136
|
+
var _equalArrays = equalArrays$2;
|
|
1137
|
+
var root$4 = _root;
|
|
1138
|
+
var Uint8Array$1 = root$4.Uint8Array;
|
|
1139
|
+
var _Uint8Array = Uint8Array$1;
|
|
1140
|
+
function mapToArray$1(map2) {
|
|
1141
|
+
var index2 = -1, result = Array(map2.size);
|
|
1142
|
+
map2.forEach(function(value, key) {
|
|
1143
|
+
result[++index2] = [key, value];
|
|
1144
|
+
});
|
|
1145
|
+
return result;
|
|
1146
|
+
}
|
|
1147
|
+
var _mapToArray = mapToArray$1;
|
|
1148
|
+
function setToArray$1(set2) {
|
|
1149
|
+
var index2 = -1, result = Array(set2.size);
|
|
1150
|
+
set2.forEach(function(value) {
|
|
1151
|
+
result[++index2] = value;
|
|
1152
|
+
});
|
|
1153
|
+
return result;
|
|
1154
|
+
}
|
|
1155
|
+
var _setToArray = setToArray$1;
|
|
1156
|
+
var Symbol$1 = _Symbol, Uint8Array = _Uint8Array, eq = eq_1, equalArrays$1 = _equalArrays, mapToArray = _mapToArray, setToArray = _setToArray;
|
|
1157
|
+
var COMPARE_PARTIAL_FLAG$4 = 1, COMPARE_UNORDERED_FLAG$2 = 2;
|
|
1158
|
+
var boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", mapTag$1 = "[object Map]", numberTag = "[object Number]", regexpTag = "[object RegExp]", setTag$1 = "[object Set]", stringTag = "[object String]", symbolTag = "[object Symbol]";
|
|
1159
|
+
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag$1 = "[object DataView]";
|
|
1160
|
+
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
|
|
1161
|
+
function equalByTag$1(object2, other, tag, bitmask, customizer, equalFunc, stack) {
|
|
1162
|
+
switch (tag) {
|
|
1163
|
+
case dataViewTag$1:
|
|
1164
|
+
if (object2.byteLength != other.byteLength || object2.byteOffset != other.byteOffset) {
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
object2 = object2.buffer;
|
|
1168
|
+
other = other.buffer;
|
|
1169
|
+
case arrayBufferTag:
|
|
1170
|
+
if (object2.byteLength != other.byteLength || !equalFunc(new Uint8Array(object2), new Uint8Array(other))) {
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
return true;
|
|
1174
|
+
case boolTag:
|
|
1175
|
+
case dateTag:
|
|
1176
|
+
case numberTag:
|
|
1177
|
+
return eq(+object2, +other);
|
|
1178
|
+
case errorTag:
|
|
1179
|
+
return object2.name == other.name && object2.message == other.message;
|
|
1180
|
+
case regexpTag:
|
|
1181
|
+
case stringTag:
|
|
1182
|
+
return object2 == other + "";
|
|
1183
|
+
case mapTag$1:
|
|
1184
|
+
var convert = mapToArray;
|
|
1185
|
+
case setTag$1:
|
|
1186
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$4;
|
|
1187
|
+
convert || (convert = setToArray);
|
|
1188
|
+
if (object2.size != other.size && !isPartial) {
|
|
1189
|
+
return false;
|
|
1190
|
+
}
|
|
1191
|
+
var stacked = stack.get(object2);
|
|
1192
|
+
if (stacked) {
|
|
1193
|
+
return stacked == other;
|
|
1194
|
+
}
|
|
1195
|
+
bitmask |= COMPARE_UNORDERED_FLAG$2;
|
|
1196
|
+
stack.set(object2, other);
|
|
1197
|
+
var result = equalArrays$1(convert(object2), convert(other), bitmask, customizer, equalFunc, stack);
|
|
1198
|
+
stack["delete"](object2);
|
|
1199
|
+
return result;
|
|
1200
|
+
case symbolTag:
|
|
1201
|
+
if (symbolValueOf) {
|
|
1202
|
+
return symbolValueOf.call(object2) == symbolValueOf.call(other);
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
return false;
|
|
1206
|
+
}
|
|
1207
|
+
var _equalByTag = equalByTag$1;
|
|
1208
|
+
function arrayPush$1(array2, values) {
|
|
1209
|
+
var index2 = -1, length = values.length, offset = array2.length;
|
|
1210
|
+
while (++index2 < length) {
|
|
1211
|
+
array2[offset + index2] = values[index2];
|
|
1212
|
+
}
|
|
1213
|
+
return array2;
|
|
1214
|
+
}
|
|
1215
|
+
var _arrayPush = arrayPush$1;
|
|
1216
|
+
var arrayPush = _arrayPush, isArray$2 = isArray_1;
|
|
1217
|
+
function baseGetAllKeys$1(object2, keysFunc, symbolsFunc) {
|
|
1218
|
+
var result = keysFunc(object2);
|
|
1219
|
+
return isArray$2(object2) ? result : arrayPush(result, symbolsFunc(object2));
|
|
1220
|
+
}
|
|
1221
|
+
var _baseGetAllKeys = baseGetAllKeys$1;
|
|
1222
|
+
function arrayFilter$1(array2, predicate) {
|
|
1223
|
+
var index2 = -1, length = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
|
|
1224
|
+
while (++index2 < length) {
|
|
1225
|
+
var value = array2[index2];
|
|
1226
|
+
if (predicate(value, index2, array2)) {
|
|
1227
|
+
result[resIndex++] = value;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
return result;
|
|
1231
|
+
}
|
|
1232
|
+
var _arrayFilter = arrayFilter$1;
|
|
1233
|
+
function stubArray$1() {
|
|
1234
|
+
return [];
|
|
1235
|
+
}
|
|
1236
|
+
var stubArray_1 = stubArray$1;
|
|
1237
|
+
var arrayFilter = _arrayFilter, stubArray = stubArray_1;
|
|
1238
|
+
var objectProto$2 = Object.prototype;
|
|
1239
|
+
var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
|
|
1240
|
+
var nativeGetSymbols = Object.getOwnPropertySymbols;
|
|
1241
|
+
var getSymbols$1 = !nativeGetSymbols ? stubArray : function(object2) {
|
|
1242
|
+
if (object2 == null) {
|
|
1243
|
+
return [];
|
|
1244
|
+
}
|
|
1245
|
+
object2 = Object(object2);
|
|
1246
|
+
return arrayFilter(nativeGetSymbols(object2), function(symbol) {
|
|
1247
|
+
return propertyIsEnumerable.call(object2, symbol);
|
|
1248
|
+
});
|
|
1249
|
+
};
|
|
1250
|
+
var _getSymbols = getSymbols$1;
|
|
1251
|
+
var baseGetAllKeys = _baseGetAllKeys, getSymbols = _getSymbols, keys$1 = keys_1;
|
|
1252
|
+
function getAllKeys$1(object2) {
|
|
1253
|
+
return baseGetAllKeys(object2, keys$1, getSymbols);
|
|
1254
|
+
}
|
|
1255
|
+
var _getAllKeys = getAllKeys$1;
|
|
1256
|
+
var getAllKeys = _getAllKeys;
|
|
1257
|
+
var COMPARE_PARTIAL_FLAG$3 = 1;
|
|
1258
|
+
var objectProto$1 = Object.prototype;
|
|
1259
|
+
var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
|
|
1260
|
+
function equalObjects$1(object2, other, bitmask, customizer, equalFunc, stack) {
|
|
1261
|
+
var isPartial = bitmask & COMPARE_PARTIAL_FLAG$3, objProps = getAllKeys(object2), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
|
|
1262
|
+
if (objLength != othLength && !isPartial) {
|
|
1263
|
+
return false;
|
|
1264
|
+
}
|
|
1265
|
+
var index2 = objLength;
|
|
1266
|
+
while (index2--) {
|
|
1267
|
+
var key = objProps[index2];
|
|
1268
|
+
if (!(isPartial ? key in other : hasOwnProperty$1.call(other, key))) {
|
|
1269
|
+
return false;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
var objStacked = stack.get(object2);
|
|
1273
|
+
var othStacked = stack.get(other);
|
|
1274
|
+
if (objStacked && othStacked) {
|
|
1275
|
+
return objStacked == other && othStacked == object2;
|
|
1276
|
+
}
|
|
1277
|
+
var result = true;
|
|
1278
|
+
stack.set(object2, other);
|
|
1279
|
+
stack.set(other, object2);
|
|
1280
|
+
var skipCtor = isPartial;
|
|
1281
|
+
while (++index2 < objLength) {
|
|
1282
|
+
key = objProps[index2];
|
|
1283
|
+
var objValue = object2[key], othValue = other[key];
|
|
1284
|
+
if (customizer) {
|
|
1285
|
+
var compared = isPartial ? customizer(othValue, objValue, key, other, object2, stack) : customizer(objValue, othValue, key, object2, other, stack);
|
|
1286
|
+
}
|
|
1287
|
+
if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
|
|
1288
|
+
result = false;
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
skipCtor || (skipCtor = key == "constructor");
|
|
1292
|
+
}
|
|
1293
|
+
if (result && !skipCtor) {
|
|
1294
|
+
var objCtor = object2.constructor, othCtor = other.constructor;
|
|
1295
|
+
if (objCtor != othCtor && ("constructor" in object2 && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
|
|
1296
|
+
result = false;
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
stack["delete"](object2);
|
|
1300
|
+
stack["delete"](other);
|
|
1301
|
+
return result;
|
|
1302
|
+
}
|
|
1303
|
+
var _equalObjects = equalObjects$1;
|
|
1304
|
+
var getNative$3 = _getNative, root$3 = _root;
|
|
1305
|
+
var DataView$1 = getNative$3(root$3, "DataView");
|
|
1306
|
+
var _DataView = DataView$1;
|
|
1307
|
+
var getNative$2 = _getNative, root$2 = _root;
|
|
1308
|
+
var Promise$2 = getNative$2(root$2, "Promise");
|
|
1309
|
+
var _Promise = Promise$2;
|
|
1310
|
+
var getNative$1 = _getNative, root$1 = _root;
|
|
1311
|
+
var Set$2 = getNative$1(root$1, "Set");
|
|
1312
|
+
var _Set = Set$2;
|
|
1313
|
+
var getNative = _getNative, root = _root;
|
|
1314
|
+
var WeakMap$1 = getNative(root, "WeakMap");
|
|
1315
|
+
var _WeakMap = WeakMap$1;
|
|
1316
|
+
var DataView = _DataView, Map$1 = _Map, Promise$1 = _Promise, Set$1 = _Set, WeakMap = _WeakMap, baseGetTag = _baseGetTag, toSource = _toSource;
|
|
1317
|
+
var mapTag = "[object Map]", objectTag$1 = "[object Object]", promiseTag = "[object Promise]", setTag = "[object Set]", weakMapTag = "[object WeakMap]";
|
|
1318
|
+
var dataViewTag = "[object DataView]";
|
|
1319
|
+
var dataViewCtorString = toSource(DataView), mapCtorString = toSource(Map$1), promiseCtorString = toSource(Promise$1), setCtorString = toSource(Set$1), weakMapCtorString = toSource(WeakMap);
|
|
1320
|
+
var getTag$1 = baseGetTag;
|
|
1321
|
+
if (DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag || Map$1 && getTag$1(new Map$1()) != mapTag || Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag || Set$1 && getTag$1(new Set$1()) != setTag || WeakMap && getTag$1(new WeakMap()) != weakMapTag) {
|
|
1322
|
+
getTag$1 = function(value) {
|
|
1323
|
+
var result = baseGetTag(value), Ctor = result == objectTag$1 ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
|
|
1324
|
+
if (ctorString) {
|
|
1325
|
+
switch (ctorString) {
|
|
1326
|
+
case dataViewCtorString:
|
|
1327
|
+
return dataViewTag;
|
|
1328
|
+
case mapCtorString:
|
|
1329
|
+
return mapTag;
|
|
1330
|
+
case promiseCtorString:
|
|
1331
|
+
return promiseTag;
|
|
1332
|
+
case setCtorString:
|
|
1333
|
+
return setTag;
|
|
1334
|
+
case weakMapCtorString:
|
|
1335
|
+
return weakMapTag;
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return result;
|
|
1339
|
+
};
|
|
1340
|
+
}
|
|
1341
|
+
var _getTag = getTag$1;
|
|
1342
|
+
var Stack$1 = _Stack, equalArrays = _equalArrays, equalByTag = _equalByTag, equalObjects = _equalObjects, getTag = _getTag, isArray$1 = isArray_1, isBuffer = isBufferExports, isTypedArray = isTypedArray_1;
|
|
1343
|
+
var COMPARE_PARTIAL_FLAG$2 = 1;
|
|
1344
|
+
var argsTag = "[object Arguments]", arrayTag = "[object Array]", objectTag = "[object Object]";
|
|
1345
|
+
var objectProto = Object.prototype;
|
|
1346
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
1347
|
+
function baseIsEqualDeep$1(object2, other, bitmask, customizer, equalFunc, stack) {
|
|
1348
|
+
var objIsArr = isArray$1(object2), othIsArr = isArray$1(other), objTag = objIsArr ? arrayTag : getTag(object2), othTag = othIsArr ? arrayTag : getTag(other);
|
|
1349
|
+
objTag = objTag == argsTag ? objectTag : objTag;
|
|
1350
|
+
othTag = othTag == argsTag ? objectTag : othTag;
|
|
1351
|
+
var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
|
|
1352
|
+
if (isSameTag && isBuffer(object2)) {
|
|
1353
|
+
if (!isBuffer(other)) {
|
|
1354
|
+
return false;
|
|
1355
|
+
}
|
|
1356
|
+
objIsArr = true;
|
|
1357
|
+
objIsObj = false;
|
|
1358
|
+
}
|
|
1359
|
+
if (isSameTag && !objIsObj) {
|
|
1360
|
+
stack || (stack = new Stack$1());
|
|
1361
|
+
return objIsArr || isTypedArray(object2) ? equalArrays(object2, other, bitmask, customizer, equalFunc, stack) : equalByTag(object2, other, objTag, bitmask, customizer, equalFunc, stack);
|
|
1362
|
+
}
|
|
1363
|
+
if (!(bitmask & COMPARE_PARTIAL_FLAG$2)) {
|
|
1364
|
+
var objIsWrapped = objIsObj && hasOwnProperty.call(object2, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
|
|
1365
|
+
if (objIsWrapped || othIsWrapped) {
|
|
1366
|
+
var objUnwrapped = objIsWrapped ? object2.value() : object2, othUnwrapped = othIsWrapped ? other.value() : other;
|
|
1367
|
+
stack || (stack = new Stack$1());
|
|
1368
|
+
return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
if (!isSameTag) {
|
|
1372
|
+
return false;
|
|
1373
|
+
}
|
|
1374
|
+
stack || (stack = new Stack$1());
|
|
1375
|
+
return equalObjects(object2, other, bitmask, customizer, equalFunc, stack);
|
|
1376
|
+
}
|
|
1377
|
+
var _baseIsEqualDeep = baseIsEqualDeep$1;
|
|
1378
|
+
var baseIsEqualDeep = _baseIsEqualDeep, isObjectLike = isObjectLike_1;
|
|
1379
|
+
function baseIsEqual$2(value, other, bitmask, customizer, stack) {
|
|
1380
|
+
if (value === other) {
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
|
|
1384
|
+
return value !== value && other !== other;
|
|
1385
|
+
}
|
|
1386
|
+
return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual$2, stack);
|
|
1387
|
+
}
|
|
1388
|
+
var _baseIsEqual = baseIsEqual$2;
|
|
1389
|
+
var Stack = _Stack, baseIsEqual$1 = _baseIsEqual;
|
|
1390
|
+
var COMPARE_PARTIAL_FLAG$1 = 1, COMPARE_UNORDERED_FLAG$1 = 2;
|
|
1391
|
+
function baseIsMatch$1(object2, source, matchData, customizer) {
|
|
1392
|
+
var index2 = matchData.length, length = index2, noCustomizer = !customizer;
|
|
1393
|
+
if (object2 == null) {
|
|
1394
|
+
return !length;
|
|
1395
|
+
}
|
|
1396
|
+
object2 = Object(object2);
|
|
1397
|
+
while (index2--) {
|
|
1398
|
+
var data = matchData[index2];
|
|
1399
|
+
if (noCustomizer && data[2] ? data[1] !== object2[data[0]] : !(data[0] in object2)) {
|
|
1400
|
+
return false;
|
|
1401
|
+
}
|
|
1402
|
+
}
|
|
1403
|
+
while (++index2 < length) {
|
|
1404
|
+
data = matchData[index2];
|
|
1405
|
+
var key = data[0], objValue = object2[key], srcValue = data[1];
|
|
1406
|
+
if (noCustomizer && data[2]) {
|
|
1407
|
+
if (objValue === void 0 && !(key in object2)) {
|
|
1408
|
+
return false;
|
|
1409
|
+
}
|
|
1410
|
+
} else {
|
|
1411
|
+
var stack = new Stack();
|
|
1412
|
+
if (customizer) {
|
|
1413
|
+
var result = customizer(objValue, srcValue, key, object2, source, stack);
|
|
1414
|
+
}
|
|
1415
|
+
if (!(result === void 0 ? baseIsEqual$1(srcValue, objValue, COMPARE_PARTIAL_FLAG$1 | COMPARE_UNORDERED_FLAG$1, customizer, stack) : result)) {
|
|
1416
|
+
return false;
|
|
1417
|
+
}
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
return true;
|
|
1421
|
+
}
|
|
1422
|
+
var _baseIsMatch = baseIsMatch$1;
|
|
1423
|
+
var isObject = isObject_1;
|
|
1424
|
+
function isStrictComparable$2(value) {
|
|
1425
|
+
return value === value && !isObject(value);
|
|
1426
|
+
}
|
|
1427
|
+
var _isStrictComparable = isStrictComparable$2;
|
|
1428
|
+
var isStrictComparable$1 = _isStrictComparable, keys = keys_1;
|
|
1429
|
+
function getMatchData$1(object2) {
|
|
1430
|
+
var result = keys(object2), length = result.length;
|
|
1431
|
+
while (length--) {
|
|
1432
|
+
var key = result[length], value = object2[key];
|
|
1433
|
+
result[length] = [key, value, isStrictComparable$1(value)];
|
|
1434
|
+
}
|
|
1435
|
+
return result;
|
|
1436
|
+
}
|
|
1437
|
+
var _getMatchData = getMatchData$1;
|
|
1438
|
+
function matchesStrictComparable$2(key, srcValue) {
|
|
1439
|
+
return function(object2) {
|
|
1440
|
+
if (object2 == null) {
|
|
1441
|
+
return false;
|
|
1442
|
+
}
|
|
1443
|
+
return object2[key] === srcValue && (srcValue !== void 0 || key in Object(object2));
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
var _matchesStrictComparable = matchesStrictComparable$2;
|
|
1447
|
+
var baseIsMatch = _baseIsMatch, getMatchData = _getMatchData, matchesStrictComparable$1 = _matchesStrictComparable;
|
|
1448
|
+
function baseMatches$1(source) {
|
|
1449
|
+
var matchData = getMatchData(source);
|
|
1450
|
+
if (matchData.length == 1 && matchData[0][2]) {
|
|
1451
|
+
return matchesStrictComparable$1(matchData[0][0], matchData[0][1]);
|
|
1452
|
+
}
|
|
1453
|
+
return function(object2) {
|
|
1454
|
+
return object2 === source || baseIsMatch(object2, source, matchData);
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
var _baseMatches = baseMatches$1;
|
|
1458
|
+
var castPath = _castPath, toKey$2 = _toKey;
|
|
1459
|
+
function baseGet$2(object2, path) {
|
|
1460
|
+
path = castPath(path, object2);
|
|
1461
|
+
var index2 = 0, length = path.length;
|
|
1462
|
+
while (object2 != null && index2 < length) {
|
|
1463
|
+
object2 = object2[toKey$2(path[index2++])];
|
|
1464
|
+
}
|
|
1465
|
+
return index2 && index2 == length ? object2 : void 0;
|
|
1466
|
+
}
|
|
1467
|
+
var _baseGet = baseGet$2;
|
|
1468
|
+
var baseGet$1 = _baseGet;
|
|
1469
|
+
function get$1(object2, path, defaultValue) {
|
|
1470
|
+
var result = object2 == null ? void 0 : baseGet$1(object2, path);
|
|
1471
|
+
return result === void 0 ? defaultValue : result;
|
|
1472
|
+
}
|
|
1473
|
+
var get_1 = get$1;
|
|
1474
|
+
function baseHasIn$1(object2, key) {
|
|
1475
|
+
return object2 != null && key in Object(object2);
|
|
1476
|
+
}
|
|
1477
|
+
var _baseHasIn = baseHasIn$1;
|
|
1478
|
+
var baseHasIn = _baseHasIn, hasPath = _hasPath;
|
|
1479
|
+
function hasIn$1(object2, path) {
|
|
1480
|
+
return object2 != null && hasPath(object2, path, baseHasIn);
|
|
1481
|
+
}
|
|
1482
|
+
var hasIn_1 = hasIn$1;
|
|
1483
|
+
var baseIsEqual = _baseIsEqual, get = get_1, hasIn = hasIn_1, isKey$1 = _isKey, isStrictComparable = _isStrictComparable, matchesStrictComparable = _matchesStrictComparable, toKey$1 = _toKey;
|
|
1484
|
+
var COMPARE_PARTIAL_FLAG = 1, COMPARE_UNORDERED_FLAG = 2;
|
|
1485
|
+
function baseMatchesProperty$1(path, srcValue) {
|
|
1486
|
+
if (isKey$1(path) && isStrictComparable(srcValue)) {
|
|
1487
|
+
return matchesStrictComparable(toKey$1(path), srcValue);
|
|
1488
|
+
}
|
|
1489
|
+
return function(object2) {
|
|
1490
|
+
var objValue = get(object2, path);
|
|
1491
|
+
return objValue === void 0 && objValue === srcValue ? hasIn(object2, path) : baseIsEqual(srcValue, objValue, COMPARE_PARTIAL_FLAG | COMPARE_UNORDERED_FLAG);
|
|
1492
|
+
};
|
|
1493
|
+
}
|
|
1494
|
+
var _baseMatchesProperty = baseMatchesProperty$1;
|
|
1495
|
+
function identity$1(value) {
|
|
1496
|
+
return value;
|
|
1497
|
+
}
|
|
1498
|
+
var identity_1 = identity$1;
|
|
1499
|
+
function baseProperty$1(key) {
|
|
1500
|
+
return function(object2) {
|
|
1501
|
+
return object2 == null ? void 0 : object2[key];
|
|
1502
|
+
};
|
|
1503
|
+
}
|
|
1504
|
+
var _baseProperty = baseProperty$1;
|
|
1505
|
+
var baseGet = _baseGet;
|
|
1506
|
+
function basePropertyDeep$1(path) {
|
|
1507
|
+
return function(object2) {
|
|
1508
|
+
return baseGet(object2, path);
|
|
1509
|
+
};
|
|
1510
|
+
}
|
|
1511
|
+
var _basePropertyDeep = basePropertyDeep$1;
|
|
1512
|
+
var baseProperty = _baseProperty, basePropertyDeep = _basePropertyDeep, isKey = _isKey, toKey = _toKey;
|
|
1513
|
+
function property$1(path) {
|
|
1514
|
+
return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
|
|
1515
|
+
}
|
|
1516
|
+
var property_1 = property$1;
|
|
1517
|
+
var baseMatches = _baseMatches, baseMatchesProperty = _baseMatchesProperty, identity = identity_1, isArray = isArray_1, property = property_1;
|
|
1518
|
+
function baseIteratee$1(value) {
|
|
1519
|
+
if (typeof value == "function") {
|
|
1520
|
+
return value;
|
|
1521
|
+
}
|
|
1522
|
+
if (value == null) {
|
|
1523
|
+
return identity;
|
|
1524
|
+
}
|
|
1525
|
+
if (typeof value == "object") {
|
|
1526
|
+
return isArray(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
|
|
1527
|
+
}
|
|
1528
|
+
return property(value);
|
|
1529
|
+
}
|
|
1530
|
+
var _baseIteratee = baseIteratee$1;
|
|
1531
|
+
var baseAssignValue = _baseAssignValue, baseForOwn = _baseForOwn, baseIteratee = _baseIteratee;
|
|
1532
|
+
function mapValues(object2, iteratee) {
|
|
1533
|
+
var result = {};
|
|
1534
|
+
iteratee = baseIteratee(iteratee);
|
|
1535
|
+
baseForOwn(object2, function(value, key, object3) {
|
|
1536
|
+
baseAssignValue(result, key, iteratee(value, key, object3));
|
|
1537
|
+
});
|
|
1538
|
+
return result;
|
|
1539
|
+
}
|
|
1540
|
+
var mapValues_1 = mapValues;
|
|
1541
|
+
const mapValues$1 = /* @__PURE__ */ getDefaultExportFromCjs(mapValues_1);
|
|
1542
|
+
function Cache(maxSize) {
|
|
1543
|
+
this._maxSize = maxSize;
|
|
1544
|
+
this.clear();
|
|
1545
|
+
}
|
|
1546
|
+
Cache.prototype.clear = function() {
|
|
1547
|
+
this._size = 0;
|
|
1548
|
+
this._values = /* @__PURE__ */ Object.create(null);
|
|
1549
|
+
};
|
|
1550
|
+
Cache.prototype.get = function(key) {
|
|
1551
|
+
return this._values[key];
|
|
1552
|
+
};
|
|
1553
|
+
Cache.prototype.set = function(key, value) {
|
|
1554
|
+
this._size >= this._maxSize && this.clear();
|
|
1555
|
+
if (!(key in this._values))
|
|
1556
|
+
this._size++;
|
|
1557
|
+
return this._values[key] = value;
|
|
1558
|
+
};
|
|
1559
|
+
var SPLIT_REGEX = /[^.^\]^[]+|(?=\[\]|\.\.)/g, DIGIT_REGEX = /^\d+$/, LEAD_DIGIT_REGEX = /^\d/, SPEC_CHAR_REGEX = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, CLEAN_QUOTES_REGEX = /^\s*(['"]?)(.*?)(\1)\s*$/, MAX_CACHE_SIZE = 512;
|
|
1560
|
+
var pathCache = new Cache(MAX_CACHE_SIZE), setCache = new Cache(MAX_CACHE_SIZE), getCache = new Cache(MAX_CACHE_SIZE);
|
|
1561
|
+
var propertyExpr = {
|
|
1562
|
+
Cache,
|
|
1563
|
+
split,
|
|
1564
|
+
normalizePath,
|
|
1565
|
+
setter: function(path) {
|
|
1566
|
+
var parts = normalizePath(path);
|
|
1567
|
+
return setCache.get(path) || setCache.set(path, function setter(obj, value) {
|
|
1568
|
+
var index2 = 0;
|
|
1569
|
+
var len = parts.length;
|
|
1570
|
+
var data = obj;
|
|
1571
|
+
while (index2 < len - 1) {
|
|
1572
|
+
var part = parts[index2];
|
|
1573
|
+
if (part === "__proto__" || part === "constructor" || part === "prototype") {
|
|
1574
|
+
return obj;
|
|
1575
|
+
}
|
|
1576
|
+
data = data[parts[index2++]];
|
|
1577
|
+
}
|
|
1578
|
+
data[parts[index2]] = value;
|
|
1579
|
+
});
|
|
1580
|
+
},
|
|
1581
|
+
getter: function(path, safe) {
|
|
1582
|
+
var parts = normalizePath(path);
|
|
1583
|
+
return getCache.get(path) || getCache.set(path, function getter(data) {
|
|
1584
|
+
var index2 = 0, len = parts.length;
|
|
1585
|
+
while (index2 < len) {
|
|
1586
|
+
if (data != null || !safe)
|
|
1587
|
+
data = data[parts[index2++]];
|
|
1588
|
+
else
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
return data;
|
|
1592
|
+
});
|
|
1593
|
+
},
|
|
1594
|
+
join: function(segments) {
|
|
1595
|
+
return segments.reduce(function(path, part) {
|
|
1596
|
+
return path + (isQuoted(part) || DIGIT_REGEX.test(part) ? "[" + part + "]" : (path ? "." : "") + part);
|
|
1597
|
+
}, "");
|
|
1598
|
+
},
|
|
1599
|
+
forEach: function(path, cb, thisArg) {
|
|
1600
|
+
forEach(Array.isArray(path) ? path : split(path), cb, thisArg);
|
|
1601
|
+
}
|
|
1602
|
+
};
|
|
1603
|
+
function normalizePath(path) {
|
|
1604
|
+
return pathCache.get(path) || pathCache.set(
|
|
1605
|
+
path,
|
|
1606
|
+
split(path).map(function(part) {
|
|
1607
|
+
return part.replace(CLEAN_QUOTES_REGEX, "$2");
|
|
1608
|
+
})
|
|
1609
|
+
);
|
|
1610
|
+
}
|
|
1611
|
+
function split(path) {
|
|
1612
|
+
return path.match(SPLIT_REGEX) || [""];
|
|
1613
|
+
}
|
|
1614
|
+
function forEach(parts, iter, thisArg) {
|
|
1615
|
+
var len = parts.length, part, idx, isArray2, isBracket;
|
|
1616
|
+
for (idx = 0; idx < len; idx++) {
|
|
1617
|
+
part = parts[idx];
|
|
1618
|
+
if (part) {
|
|
1619
|
+
if (shouldBeQuoted(part)) {
|
|
1620
|
+
part = '"' + part + '"';
|
|
1621
|
+
}
|
|
1622
|
+
isBracket = isQuoted(part);
|
|
1623
|
+
isArray2 = !isBracket && /^\d+$/.test(part);
|
|
1624
|
+
iter.call(thisArg, part, isBracket, isArray2, idx, parts);
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
function isQuoted(str) {
|
|
1629
|
+
return typeof str === "string" && str && ["'", '"'].indexOf(str.charAt(0)) !== -1;
|
|
1630
|
+
}
|
|
1631
|
+
function hasLeadingNumber(part) {
|
|
1632
|
+
return part.match(LEAD_DIGIT_REGEX) && !part.match(DIGIT_REGEX);
|
|
1633
|
+
}
|
|
1634
|
+
function hasSpecialChars(part) {
|
|
1635
|
+
return SPEC_CHAR_REGEX.test(part);
|
|
1636
|
+
}
|
|
1637
|
+
function shouldBeQuoted(part) {
|
|
1638
|
+
return !isQuoted(part) && (hasLeadingNumber(part) || hasSpecialChars(part));
|
|
1639
|
+
}
|
|
1640
|
+
const prefixes = {
|
|
1641
|
+
context: "$",
|
|
1642
|
+
value: "."
|
|
1643
|
+
};
|
|
1644
|
+
class Reference {
|
|
1645
|
+
constructor(key, options = {}) {
|
|
1646
|
+
if (typeof key !== "string")
|
|
1647
|
+
throw new TypeError("ref must be a string, got: " + key);
|
|
1648
|
+
this.key = key.trim();
|
|
1649
|
+
if (key === "")
|
|
1650
|
+
throw new TypeError("ref must be a non-empty string");
|
|
1651
|
+
this.isContext = this.key[0] === prefixes.context;
|
|
1652
|
+
this.isValue = this.key[0] === prefixes.value;
|
|
1653
|
+
this.isSibling = !this.isContext && !this.isValue;
|
|
1654
|
+
let prefix = this.isContext ? prefixes.context : this.isValue ? prefixes.value : "";
|
|
1655
|
+
this.path = this.key.slice(prefix.length);
|
|
1656
|
+
this.getter = this.path && propertyExpr.getter(this.path, true);
|
|
1657
|
+
this.map = options.map;
|
|
1658
|
+
}
|
|
1659
|
+
getValue(value, parent, context) {
|
|
1660
|
+
let result = this.isContext ? context : this.isValue ? value : parent;
|
|
1661
|
+
if (this.getter)
|
|
1662
|
+
result = this.getter(result || {});
|
|
1663
|
+
if (this.map)
|
|
1664
|
+
result = this.map(result);
|
|
1665
|
+
return result;
|
|
1666
|
+
}
|
|
1667
|
+
/**
|
|
1668
|
+
*
|
|
1669
|
+
* @param {*} value
|
|
1670
|
+
* @param {Object} options
|
|
1671
|
+
* @param {Object=} options.context
|
|
1672
|
+
* @param {Object=} options.parent
|
|
1673
|
+
*/
|
|
1674
|
+
cast(value, options) {
|
|
1675
|
+
return this.getValue(value, options == null ? void 0 : options.parent, options == null ? void 0 : options.context);
|
|
1676
|
+
}
|
|
1677
|
+
resolve() {
|
|
1678
|
+
return this;
|
|
1679
|
+
}
|
|
1680
|
+
describe() {
|
|
1681
|
+
return {
|
|
1682
|
+
type: "ref",
|
|
1683
|
+
key: this.key
|
|
1684
|
+
};
|
|
1685
|
+
}
|
|
1686
|
+
toString() {
|
|
1687
|
+
return `Ref(${this.key})`;
|
|
1688
|
+
}
|
|
1689
|
+
static isRef(value) {
|
|
1690
|
+
return value && value.__isYupRef;
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
Reference.prototype.__isYupRef = true;
|
|
1694
|
+
function _extends$1() {
|
|
1695
|
+
_extends$1 = Object.assign || function(target) {
|
|
1696
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1697
|
+
var source = arguments[i];
|
|
1698
|
+
for (var key in source) {
|
|
1699
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1700
|
+
target[key] = source[key];
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
}
|
|
1704
|
+
return target;
|
|
1705
|
+
};
|
|
1706
|
+
return _extends$1.apply(this, arguments);
|
|
1707
|
+
}
|
|
1708
|
+
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
1709
|
+
if (source == null)
|
|
1710
|
+
return {};
|
|
1711
|
+
var target = {};
|
|
1712
|
+
var sourceKeys = Object.keys(source);
|
|
1713
|
+
var key, i;
|
|
1714
|
+
for (i = 0; i < sourceKeys.length; i++) {
|
|
1715
|
+
key = sourceKeys[i];
|
|
1716
|
+
if (excluded.indexOf(key) >= 0)
|
|
1717
|
+
continue;
|
|
1718
|
+
target[key] = source[key];
|
|
1719
|
+
}
|
|
1720
|
+
return target;
|
|
1721
|
+
}
|
|
1722
|
+
function createValidation(config) {
|
|
1723
|
+
function validate(_ref, cb) {
|
|
1724
|
+
let {
|
|
1725
|
+
value,
|
|
1726
|
+
path = "",
|
|
1727
|
+
label,
|
|
1728
|
+
options,
|
|
1729
|
+
originalValue,
|
|
1730
|
+
sync
|
|
1731
|
+
} = _ref, rest = _objectWithoutPropertiesLoose(_ref, ["value", "path", "label", "options", "originalValue", "sync"]);
|
|
1732
|
+
const {
|
|
1733
|
+
name: name2,
|
|
1734
|
+
test,
|
|
1735
|
+
params,
|
|
1736
|
+
message
|
|
1737
|
+
} = config;
|
|
1738
|
+
let {
|
|
1739
|
+
parent,
|
|
1740
|
+
context
|
|
1741
|
+
} = options;
|
|
1742
|
+
function resolve(item) {
|
|
1743
|
+
return Reference.isRef(item) ? item.getValue(value, parent, context) : item;
|
|
1744
|
+
}
|
|
1745
|
+
function createError(overrides = {}) {
|
|
1746
|
+
const nextParams = mapValues$1(_extends$1({
|
|
1747
|
+
value,
|
|
1748
|
+
originalValue,
|
|
1749
|
+
label,
|
|
1750
|
+
path: overrides.path || path
|
|
1751
|
+
}, params, overrides.params), resolve);
|
|
1752
|
+
const error = new ValidationError(ValidationError.formatError(overrides.message || message, nextParams), value, nextParams.path, overrides.type || name2);
|
|
1753
|
+
error.params = nextParams;
|
|
1754
|
+
return error;
|
|
1755
|
+
}
|
|
1756
|
+
let ctx = _extends$1({
|
|
1757
|
+
path,
|
|
1758
|
+
parent,
|
|
1759
|
+
type: name2,
|
|
1760
|
+
createError,
|
|
1761
|
+
resolve,
|
|
1762
|
+
options,
|
|
1763
|
+
originalValue
|
|
1764
|
+
}, rest);
|
|
1765
|
+
if (!sync) {
|
|
1766
|
+
try {
|
|
1767
|
+
Promise.resolve(test.call(ctx, value, ctx)).then((validOrError) => {
|
|
1768
|
+
if (ValidationError.isError(validOrError))
|
|
1769
|
+
cb(validOrError);
|
|
1770
|
+
else if (!validOrError)
|
|
1771
|
+
cb(createError());
|
|
1772
|
+
else
|
|
1773
|
+
cb(null, validOrError);
|
|
1774
|
+
});
|
|
1775
|
+
} catch (err) {
|
|
1776
|
+
cb(err);
|
|
1777
|
+
}
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
let result;
|
|
1781
|
+
try {
|
|
1782
|
+
var _ref2;
|
|
1783
|
+
result = test.call(ctx, value, ctx);
|
|
1784
|
+
if (typeof ((_ref2 = result) == null ? void 0 : _ref2.then) === "function") {
|
|
1785
|
+
throw new Error(`Validation test of type: "${ctx.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`);
|
|
1786
|
+
}
|
|
1787
|
+
} catch (err) {
|
|
1788
|
+
cb(err);
|
|
1789
|
+
return;
|
|
1790
|
+
}
|
|
1791
|
+
if (ValidationError.isError(result))
|
|
1792
|
+
cb(result);
|
|
1793
|
+
else if (!result)
|
|
1794
|
+
cb(createError());
|
|
1795
|
+
else
|
|
1796
|
+
cb(null, result);
|
|
1797
|
+
}
|
|
1798
|
+
validate.OPTIONS = config;
|
|
1799
|
+
return validate;
|
|
1800
|
+
}
|
|
1801
|
+
let trim = (part) => part.substr(0, part.length - 1).substr(1);
|
|
1802
|
+
function getIn(schema, path, value, context = value) {
|
|
1803
|
+
let parent, lastPart, lastPartDebug;
|
|
1804
|
+
if (!path)
|
|
1805
|
+
return {
|
|
1806
|
+
parent,
|
|
1807
|
+
parentPath: path,
|
|
1808
|
+
schema
|
|
1809
|
+
};
|
|
1810
|
+
propertyExpr.forEach(path, (_part, isBracket, isArray2) => {
|
|
1811
|
+
let part = isBracket ? trim(_part) : _part;
|
|
1812
|
+
schema = schema.resolve({
|
|
1813
|
+
context,
|
|
1814
|
+
parent,
|
|
1815
|
+
value
|
|
1816
|
+
});
|
|
1817
|
+
if (schema.innerType) {
|
|
1818
|
+
let idx = isArray2 ? parseInt(part, 10) : 0;
|
|
1819
|
+
if (value && idx >= value.length) {
|
|
1820
|
+
throw new Error(`Yup.reach cannot resolve an array item at index: ${_part}, in the path: ${path}. because there is no value at that index. `);
|
|
1821
|
+
}
|
|
1822
|
+
parent = value;
|
|
1823
|
+
value = value && value[idx];
|
|
1824
|
+
schema = schema.innerType;
|
|
1825
|
+
}
|
|
1826
|
+
if (!isArray2) {
|
|
1827
|
+
if (!schema.fields || !schema.fields[part])
|
|
1828
|
+
throw new Error(`The schema does not contain the path: ${path}. (failed at: ${lastPartDebug} which is a type: "${schema._type}")`);
|
|
1829
|
+
parent = value;
|
|
1830
|
+
value = value && value[part];
|
|
1831
|
+
schema = schema.fields[part];
|
|
1832
|
+
}
|
|
1833
|
+
lastPart = part;
|
|
1834
|
+
lastPartDebug = isBracket ? "[" + _part + "]" : "." + _part;
|
|
1835
|
+
});
|
|
1836
|
+
return {
|
|
1837
|
+
schema,
|
|
1838
|
+
parent,
|
|
1839
|
+
parentPath: lastPart
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
class ReferenceSet {
|
|
1843
|
+
constructor() {
|
|
1844
|
+
this.list = /* @__PURE__ */ new Set();
|
|
1845
|
+
this.refs = /* @__PURE__ */ new Map();
|
|
1846
|
+
}
|
|
1847
|
+
get size() {
|
|
1848
|
+
return this.list.size + this.refs.size;
|
|
1849
|
+
}
|
|
1850
|
+
describe() {
|
|
1851
|
+
const description2 = [];
|
|
1852
|
+
for (const item of this.list)
|
|
1853
|
+
description2.push(item);
|
|
1854
|
+
for (const [, ref] of this.refs)
|
|
1855
|
+
description2.push(ref.describe());
|
|
1856
|
+
return description2;
|
|
1857
|
+
}
|
|
1858
|
+
toArray() {
|
|
1859
|
+
return Array.from(this.list).concat(Array.from(this.refs.values()));
|
|
1860
|
+
}
|
|
1861
|
+
add(value) {
|
|
1862
|
+
Reference.isRef(value) ? this.refs.set(value.key, value) : this.list.add(value);
|
|
1863
|
+
}
|
|
1864
|
+
delete(value) {
|
|
1865
|
+
Reference.isRef(value) ? this.refs.delete(value.key) : this.list.delete(value);
|
|
1866
|
+
}
|
|
1867
|
+
has(value, resolve) {
|
|
1868
|
+
if (this.list.has(value))
|
|
1869
|
+
return true;
|
|
1870
|
+
let item, values = this.refs.values();
|
|
1871
|
+
while (item = values.next(), !item.done)
|
|
1872
|
+
if (resolve(item.value) === value)
|
|
1873
|
+
return true;
|
|
1874
|
+
return false;
|
|
1875
|
+
}
|
|
1876
|
+
clone() {
|
|
1877
|
+
const next = new ReferenceSet();
|
|
1878
|
+
next.list = new Set(this.list);
|
|
1879
|
+
next.refs = new Map(this.refs);
|
|
1880
|
+
return next;
|
|
1881
|
+
}
|
|
1882
|
+
merge(newItems, removeItems) {
|
|
1883
|
+
const next = this.clone();
|
|
1884
|
+
newItems.list.forEach((value) => next.add(value));
|
|
1885
|
+
newItems.refs.forEach((value) => next.add(value));
|
|
1886
|
+
removeItems.list.forEach((value) => next.delete(value));
|
|
1887
|
+
removeItems.refs.forEach((value) => next.delete(value));
|
|
1888
|
+
return next;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
function _extends() {
|
|
1892
|
+
_extends = Object.assign || function(target) {
|
|
1893
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
1894
|
+
var source = arguments[i];
|
|
1895
|
+
for (var key in source) {
|
|
1896
|
+
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
1897
|
+
target[key] = source[key];
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
}
|
|
1901
|
+
return target;
|
|
1902
|
+
};
|
|
1903
|
+
return _extends.apply(this, arguments);
|
|
1904
|
+
}
|
|
1905
|
+
class BaseSchema {
|
|
1906
|
+
constructor(options) {
|
|
1907
|
+
this.deps = [];
|
|
1908
|
+
this.conditions = [];
|
|
1909
|
+
this._whitelist = new ReferenceSet();
|
|
1910
|
+
this._blacklist = new ReferenceSet();
|
|
1911
|
+
this.exclusiveTests = /* @__PURE__ */ Object.create(null);
|
|
1912
|
+
this.tests = [];
|
|
1913
|
+
this.transforms = [];
|
|
1914
|
+
this.withMutation(() => {
|
|
1915
|
+
this.typeError(mixed.notType);
|
|
1916
|
+
});
|
|
1917
|
+
this.type = (options == null ? void 0 : options.type) || "mixed";
|
|
1918
|
+
this.spec = _extends({
|
|
1919
|
+
strip: false,
|
|
1920
|
+
strict: false,
|
|
1921
|
+
abortEarly: true,
|
|
1922
|
+
recursive: true,
|
|
1923
|
+
nullable: false,
|
|
1924
|
+
presence: "optional"
|
|
1925
|
+
}, options == null ? void 0 : options.spec);
|
|
1926
|
+
}
|
|
1927
|
+
// TODO: remove
|
|
1928
|
+
get _type() {
|
|
1929
|
+
return this.type;
|
|
1930
|
+
}
|
|
1931
|
+
_typeCheck(_value) {
|
|
1932
|
+
return true;
|
|
1933
|
+
}
|
|
1934
|
+
clone(spec) {
|
|
1935
|
+
if (this._mutate) {
|
|
1936
|
+
if (spec)
|
|
1937
|
+
Object.assign(this.spec, spec);
|
|
1938
|
+
return this;
|
|
1939
|
+
}
|
|
1940
|
+
const next = Object.create(Object.getPrototypeOf(this));
|
|
1941
|
+
next.type = this.type;
|
|
1942
|
+
next._typeError = this._typeError;
|
|
1943
|
+
next._whitelistError = this._whitelistError;
|
|
1944
|
+
next._blacklistError = this._blacklistError;
|
|
1945
|
+
next._whitelist = this._whitelist.clone();
|
|
1946
|
+
next._blacklist = this._blacklist.clone();
|
|
1947
|
+
next.exclusiveTests = _extends({}, this.exclusiveTests);
|
|
1948
|
+
next.deps = [...this.deps];
|
|
1949
|
+
next.conditions = [...this.conditions];
|
|
1950
|
+
next.tests = [...this.tests];
|
|
1951
|
+
next.transforms = [...this.transforms];
|
|
1952
|
+
next.spec = clone(_extends({}, this.spec, spec));
|
|
1953
|
+
return next;
|
|
1954
|
+
}
|
|
1955
|
+
label(label) {
|
|
1956
|
+
var next = this.clone();
|
|
1957
|
+
next.spec.label = label;
|
|
1958
|
+
return next;
|
|
1959
|
+
}
|
|
1960
|
+
meta(...args) {
|
|
1961
|
+
if (args.length === 0)
|
|
1962
|
+
return this.spec.meta;
|
|
1963
|
+
let next = this.clone();
|
|
1964
|
+
next.spec.meta = Object.assign(next.spec.meta || {}, args[0]);
|
|
1965
|
+
return next;
|
|
1966
|
+
}
|
|
1967
|
+
// withContext<TContext extends AnyObject>(): BaseSchema<
|
|
1968
|
+
// TCast,
|
|
1969
|
+
// TContext,
|
|
1970
|
+
// TOutput
|
|
1971
|
+
// > {
|
|
1972
|
+
// return this as any;
|
|
1973
|
+
// }
|
|
1974
|
+
withMutation(fn) {
|
|
1975
|
+
let before = this._mutate;
|
|
1976
|
+
this._mutate = true;
|
|
1977
|
+
let result = fn(this);
|
|
1978
|
+
this._mutate = before;
|
|
1979
|
+
return result;
|
|
1980
|
+
}
|
|
1981
|
+
concat(schema) {
|
|
1982
|
+
if (!schema || schema === this)
|
|
1983
|
+
return this;
|
|
1984
|
+
if (schema.type !== this.type && this.type !== "mixed")
|
|
1985
|
+
throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${schema.type}`);
|
|
1986
|
+
let base = this;
|
|
1987
|
+
let combined = schema.clone();
|
|
1988
|
+
const mergedSpec = _extends({}, base.spec, combined.spec);
|
|
1989
|
+
combined.spec = mergedSpec;
|
|
1990
|
+
combined._typeError || (combined._typeError = base._typeError);
|
|
1991
|
+
combined._whitelistError || (combined._whitelistError = base._whitelistError);
|
|
1992
|
+
combined._blacklistError || (combined._blacklistError = base._blacklistError);
|
|
1993
|
+
combined._whitelist = base._whitelist.merge(schema._whitelist, schema._blacklist);
|
|
1994
|
+
combined._blacklist = base._blacklist.merge(schema._blacklist, schema._whitelist);
|
|
1995
|
+
combined.tests = base.tests;
|
|
1996
|
+
combined.exclusiveTests = base.exclusiveTests;
|
|
1997
|
+
combined.withMutation((next) => {
|
|
1998
|
+
schema.tests.forEach((fn) => {
|
|
1999
|
+
next.test(fn.OPTIONS);
|
|
2000
|
+
});
|
|
2001
|
+
});
|
|
2002
|
+
return combined;
|
|
2003
|
+
}
|
|
2004
|
+
isType(v) {
|
|
2005
|
+
if (this.spec.nullable && v === null)
|
|
2006
|
+
return true;
|
|
2007
|
+
return this._typeCheck(v);
|
|
2008
|
+
}
|
|
2009
|
+
resolve(options) {
|
|
2010
|
+
let schema = this;
|
|
2011
|
+
if (schema.conditions.length) {
|
|
2012
|
+
let conditions = schema.conditions;
|
|
2013
|
+
schema = schema.clone();
|
|
2014
|
+
schema.conditions = [];
|
|
2015
|
+
schema = conditions.reduce((schema2, condition) => condition.resolve(schema2, options), schema);
|
|
2016
|
+
schema = schema.resolve(options);
|
|
2017
|
+
}
|
|
2018
|
+
return schema;
|
|
2019
|
+
}
|
|
2020
|
+
/**
|
|
2021
|
+
*
|
|
2022
|
+
* @param {*} value
|
|
2023
|
+
* @param {Object} options
|
|
2024
|
+
* @param {*=} options.parent
|
|
2025
|
+
* @param {*=} options.context
|
|
2026
|
+
*/
|
|
2027
|
+
cast(value, options = {}) {
|
|
2028
|
+
let resolvedSchema = this.resolve(_extends({
|
|
2029
|
+
value
|
|
2030
|
+
}, options));
|
|
2031
|
+
let result = resolvedSchema._cast(value, options);
|
|
2032
|
+
if (value !== void 0 && options.assert !== false && resolvedSchema.isType(result) !== true) {
|
|
2033
|
+
let formattedValue = printValue(value);
|
|
2034
|
+
let formattedResult = printValue(result);
|
|
2035
|
+
throw new TypeError(`The value of ${options.path || "field"} could not be cast to a value that satisfies the schema type: "${resolvedSchema._type}".
|
|
2036
|
+
|
|
2037
|
+
attempted value: ${formattedValue}
|
|
2038
|
+
` + (formattedResult !== formattedValue ? `result of cast: ${formattedResult}` : ""));
|
|
2039
|
+
}
|
|
2040
|
+
return result;
|
|
2041
|
+
}
|
|
2042
|
+
_cast(rawValue, _options) {
|
|
2043
|
+
let value = rawValue === void 0 ? rawValue : this.transforms.reduce((value2, fn) => fn.call(this, value2, rawValue, this), rawValue);
|
|
2044
|
+
if (value === void 0) {
|
|
2045
|
+
value = this.getDefault();
|
|
2046
|
+
}
|
|
2047
|
+
return value;
|
|
2048
|
+
}
|
|
2049
|
+
_validate(_value, options = {}, cb) {
|
|
2050
|
+
let {
|
|
2051
|
+
sync,
|
|
2052
|
+
path,
|
|
2053
|
+
from = [],
|
|
2054
|
+
originalValue = _value,
|
|
2055
|
+
strict = this.spec.strict,
|
|
2056
|
+
abortEarly = this.spec.abortEarly
|
|
2057
|
+
} = options;
|
|
2058
|
+
let value = _value;
|
|
2059
|
+
if (!strict) {
|
|
2060
|
+
value = this._cast(value, _extends({
|
|
2061
|
+
assert: false
|
|
2062
|
+
}, options));
|
|
2063
|
+
}
|
|
2064
|
+
let args = {
|
|
2065
|
+
value,
|
|
2066
|
+
path,
|
|
2067
|
+
options,
|
|
2068
|
+
originalValue,
|
|
2069
|
+
schema: this,
|
|
2070
|
+
label: this.spec.label,
|
|
2071
|
+
sync,
|
|
2072
|
+
from
|
|
2073
|
+
};
|
|
2074
|
+
let initialTests = [];
|
|
2075
|
+
if (this._typeError)
|
|
2076
|
+
initialTests.push(this._typeError);
|
|
2077
|
+
if (this._whitelistError)
|
|
2078
|
+
initialTests.push(this._whitelistError);
|
|
2079
|
+
if (this._blacklistError)
|
|
2080
|
+
initialTests.push(this._blacklistError);
|
|
2081
|
+
runTests({
|
|
2082
|
+
args,
|
|
2083
|
+
value,
|
|
2084
|
+
path,
|
|
2085
|
+
sync,
|
|
2086
|
+
tests: initialTests,
|
|
2087
|
+
endEarly: abortEarly
|
|
2088
|
+
}, (err) => {
|
|
2089
|
+
if (err)
|
|
2090
|
+
return void cb(err, value);
|
|
2091
|
+
runTests({
|
|
2092
|
+
tests: this.tests,
|
|
2093
|
+
args,
|
|
2094
|
+
path,
|
|
2095
|
+
sync,
|
|
2096
|
+
value,
|
|
2097
|
+
endEarly: abortEarly
|
|
2098
|
+
}, cb);
|
|
2099
|
+
});
|
|
2100
|
+
}
|
|
2101
|
+
validate(value, options, maybeCb) {
|
|
2102
|
+
let schema = this.resolve(_extends({}, options, {
|
|
2103
|
+
value
|
|
2104
|
+
}));
|
|
2105
|
+
return typeof maybeCb === "function" ? schema._validate(value, options, maybeCb) : new Promise((resolve, reject) => schema._validate(value, options, (err, value2) => {
|
|
2106
|
+
if (err)
|
|
2107
|
+
reject(err);
|
|
2108
|
+
else
|
|
2109
|
+
resolve(value2);
|
|
2110
|
+
}));
|
|
2111
|
+
}
|
|
2112
|
+
validateSync(value, options) {
|
|
2113
|
+
let schema = this.resolve(_extends({}, options, {
|
|
2114
|
+
value
|
|
2115
|
+
}));
|
|
2116
|
+
let result;
|
|
2117
|
+
schema._validate(value, _extends({}, options, {
|
|
2118
|
+
sync: true
|
|
2119
|
+
}), (err, value2) => {
|
|
2120
|
+
if (err)
|
|
2121
|
+
throw err;
|
|
2122
|
+
result = value2;
|
|
2123
|
+
});
|
|
2124
|
+
return result;
|
|
2125
|
+
}
|
|
2126
|
+
isValid(value, options) {
|
|
2127
|
+
return this.validate(value, options).then(() => true, (err) => {
|
|
2128
|
+
if (ValidationError.isError(err))
|
|
2129
|
+
return false;
|
|
2130
|
+
throw err;
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
isValidSync(value, options) {
|
|
2134
|
+
try {
|
|
2135
|
+
this.validateSync(value, options);
|
|
2136
|
+
return true;
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
if (ValidationError.isError(err))
|
|
2139
|
+
return false;
|
|
2140
|
+
throw err;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
_getDefault() {
|
|
2144
|
+
let defaultValue = this.spec.default;
|
|
2145
|
+
if (defaultValue == null) {
|
|
2146
|
+
return defaultValue;
|
|
2147
|
+
}
|
|
2148
|
+
return typeof defaultValue === "function" ? defaultValue.call(this) : clone(defaultValue);
|
|
2149
|
+
}
|
|
2150
|
+
getDefault(options) {
|
|
2151
|
+
let schema = this.resolve(options || {});
|
|
2152
|
+
return schema._getDefault();
|
|
2153
|
+
}
|
|
2154
|
+
default(def) {
|
|
2155
|
+
if (arguments.length === 0) {
|
|
2156
|
+
return this._getDefault();
|
|
2157
|
+
}
|
|
2158
|
+
let next = this.clone({
|
|
2159
|
+
default: def
|
|
2160
|
+
});
|
|
2161
|
+
return next;
|
|
2162
|
+
}
|
|
2163
|
+
strict(isStrict = true) {
|
|
2164
|
+
var next = this.clone();
|
|
2165
|
+
next.spec.strict = isStrict;
|
|
2166
|
+
return next;
|
|
2167
|
+
}
|
|
2168
|
+
_isPresent(value) {
|
|
2169
|
+
return value != null;
|
|
2170
|
+
}
|
|
2171
|
+
defined(message = mixed.defined) {
|
|
2172
|
+
return this.test({
|
|
2173
|
+
message,
|
|
2174
|
+
name: "defined",
|
|
2175
|
+
exclusive: true,
|
|
2176
|
+
test(value) {
|
|
2177
|
+
return value !== void 0;
|
|
2178
|
+
}
|
|
2179
|
+
});
|
|
2180
|
+
}
|
|
2181
|
+
required(message = mixed.required) {
|
|
2182
|
+
return this.clone({
|
|
2183
|
+
presence: "required"
|
|
2184
|
+
}).withMutation((s) => s.test({
|
|
2185
|
+
message,
|
|
2186
|
+
name: "required",
|
|
2187
|
+
exclusive: true,
|
|
2188
|
+
test(value) {
|
|
2189
|
+
return this.schema._isPresent(value);
|
|
2190
|
+
}
|
|
2191
|
+
}));
|
|
2192
|
+
}
|
|
2193
|
+
notRequired() {
|
|
2194
|
+
var next = this.clone({
|
|
2195
|
+
presence: "optional"
|
|
2196
|
+
});
|
|
2197
|
+
next.tests = next.tests.filter((test) => test.OPTIONS.name !== "required");
|
|
2198
|
+
return next;
|
|
2199
|
+
}
|
|
2200
|
+
nullable(isNullable = true) {
|
|
2201
|
+
var next = this.clone({
|
|
2202
|
+
nullable: isNullable !== false
|
|
2203
|
+
});
|
|
2204
|
+
return next;
|
|
2205
|
+
}
|
|
2206
|
+
transform(fn) {
|
|
2207
|
+
var next = this.clone();
|
|
2208
|
+
next.transforms.push(fn);
|
|
2209
|
+
return next;
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Adds a test function to the schema's queue of tests.
|
|
2213
|
+
* tests can be exclusive or non-exclusive.
|
|
2214
|
+
*
|
|
2215
|
+
* - exclusive tests, will replace any existing tests of the same name.
|
|
2216
|
+
* - non-exclusive: can be stacked
|
|
2217
|
+
*
|
|
2218
|
+
* If a non-exclusive test is added to a schema with an exclusive test of the same name
|
|
2219
|
+
* the exclusive test is removed and further tests of the same name will be stacked.
|
|
2220
|
+
*
|
|
2221
|
+
* If an exclusive test is added to a schema with non-exclusive tests of the same name
|
|
2222
|
+
* the previous tests are removed and further tests of the same name will replace each other.
|
|
2223
|
+
*/
|
|
2224
|
+
test(...args) {
|
|
2225
|
+
let opts;
|
|
2226
|
+
if (args.length === 1) {
|
|
2227
|
+
if (typeof args[0] === "function") {
|
|
2228
|
+
opts = {
|
|
2229
|
+
test: args[0]
|
|
2230
|
+
};
|
|
2231
|
+
} else {
|
|
2232
|
+
opts = args[0];
|
|
2233
|
+
}
|
|
2234
|
+
} else if (args.length === 2) {
|
|
2235
|
+
opts = {
|
|
2236
|
+
name: args[0],
|
|
2237
|
+
test: args[1]
|
|
2238
|
+
};
|
|
2239
|
+
} else {
|
|
2240
|
+
opts = {
|
|
2241
|
+
name: args[0],
|
|
2242
|
+
message: args[1],
|
|
2243
|
+
test: args[2]
|
|
2244
|
+
};
|
|
2245
|
+
}
|
|
2246
|
+
if (opts.message === void 0)
|
|
2247
|
+
opts.message = mixed.default;
|
|
2248
|
+
if (typeof opts.test !== "function")
|
|
2249
|
+
throw new TypeError("`test` is a required parameters");
|
|
2250
|
+
let next = this.clone();
|
|
2251
|
+
let validate = createValidation(opts);
|
|
2252
|
+
let isExclusive = opts.exclusive || opts.name && next.exclusiveTests[opts.name] === true;
|
|
2253
|
+
if (opts.exclusive) {
|
|
2254
|
+
if (!opts.name)
|
|
2255
|
+
throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");
|
|
2256
|
+
}
|
|
2257
|
+
if (opts.name)
|
|
2258
|
+
next.exclusiveTests[opts.name] = !!opts.exclusive;
|
|
2259
|
+
next.tests = next.tests.filter((fn) => {
|
|
2260
|
+
if (fn.OPTIONS.name === opts.name) {
|
|
2261
|
+
if (isExclusive)
|
|
2262
|
+
return false;
|
|
2263
|
+
if (fn.OPTIONS.test === validate.OPTIONS.test)
|
|
2264
|
+
return false;
|
|
2265
|
+
}
|
|
2266
|
+
return true;
|
|
2267
|
+
});
|
|
2268
|
+
next.tests.push(validate);
|
|
2269
|
+
return next;
|
|
2270
|
+
}
|
|
2271
|
+
when(keys2, options) {
|
|
2272
|
+
if (!Array.isArray(keys2) && typeof keys2 !== "string") {
|
|
2273
|
+
options = keys2;
|
|
2274
|
+
keys2 = ".";
|
|
2275
|
+
}
|
|
2276
|
+
let next = this.clone();
|
|
2277
|
+
let deps = toArray(keys2).map((key) => new Reference(key));
|
|
2278
|
+
deps.forEach((dep) => {
|
|
2279
|
+
if (dep.isSibling)
|
|
2280
|
+
next.deps.push(dep.key);
|
|
2281
|
+
});
|
|
2282
|
+
next.conditions.push(new Condition(deps, options));
|
|
2283
|
+
return next;
|
|
2284
|
+
}
|
|
2285
|
+
typeError(message) {
|
|
2286
|
+
var next = this.clone();
|
|
2287
|
+
next._typeError = createValidation({
|
|
2288
|
+
message,
|
|
2289
|
+
name: "typeError",
|
|
2290
|
+
test(value) {
|
|
2291
|
+
if (value !== void 0 && !this.schema.isType(value))
|
|
2292
|
+
return this.createError({
|
|
2293
|
+
params: {
|
|
2294
|
+
type: this.schema._type
|
|
2295
|
+
}
|
|
2296
|
+
});
|
|
2297
|
+
return true;
|
|
2298
|
+
}
|
|
2299
|
+
});
|
|
2300
|
+
return next;
|
|
2301
|
+
}
|
|
2302
|
+
oneOf(enums, message = mixed.oneOf) {
|
|
2303
|
+
var next = this.clone();
|
|
2304
|
+
enums.forEach((val) => {
|
|
2305
|
+
next._whitelist.add(val);
|
|
2306
|
+
next._blacklist.delete(val);
|
|
2307
|
+
});
|
|
2308
|
+
next._whitelistError = createValidation({
|
|
2309
|
+
message,
|
|
2310
|
+
name: "oneOf",
|
|
2311
|
+
test(value) {
|
|
2312
|
+
if (value === void 0)
|
|
2313
|
+
return true;
|
|
2314
|
+
let valids = this.schema._whitelist;
|
|
2315
|
+
return valids.has(value, this.resolve) ? true : this.createError({
|
|
2316
|
+
params: {
|
|
2317
|
+
values: valids.toArray().join(", ")
|
|
2318
|
+
}
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
});
|
|
2322
|
+
return next;
|
|
2323
|
+
}
|
|
2324
|
+
notOneOf(enums, message = mixed.notOneOf) {
|
|
2325
|
+
var next = this.clone();
|
|
2326
|
+
enums.forEach((val) => {
|
|
2327
|
+
next._blacklist.add(val);
|
|
2328
|
+
next._whitelist.delete(val);
|
|
2329
|
+
});
|
|
2330
|
+
next._blacklistError = createValidation({
|
|
2331
|
+
message,
|
|
2332
|
+
name: "notOneOf",
|
|
2333
|
+
test(value) {
|
|
2334
|
+
let invalids = this.schema._blacklist;
|
|
2335
|
+
if (invalids.has(value, this.resolve))
|
|
2336
|
+
return this.createError({
|
|
2337
|
+
params: {
|
|
2338
|
+
values: invalids.toArray().join(", ")
|
|
2339
|
+
}
|
|
2340
|
+
});
|
|
2341
|
+
return true;
|
|
2342
|
+
}
|
|
2343
|
+
});
|
|
2344
|
+
return next;
|
|
2345
|
+
}
|
|
2346
|
+
strip(strip = true) {
|
|
2347
|
+
let next = this.clone();
|
|
2348
|
+
next.spec.strip = strip;
|
|
2349
|
+
return next;
|
|
2350
|
+
}
|
|
2351
|
+
describe() {
|
|
2352
|
+
const next = this.clone();
|
|
2353
|
+
const {
|
|
2354
|
+
label,
|
|
2355
|
+
meta
|
|
2356
|
+
} = next.spec;
|
|
2357
|
+
const description2 = {
|
|
2358
|
+
meta,
|
|
2359
|
+
label,
|
|
2360
|
+
type: next.type,
|
|
2361
|
+
oneOf: next._whitelist.describe(),
|
|
2362
|
+
notOneOf: next._blacklist.describe(),
|
|
2363
|
+
tests: next.tests.map((fn) => ({
|
|
2364
|
+
name: fn.OPTIONS.name,
|
|
2365
|
+
params: fn.OPTIONS.params
|
|
2366
|
+
})).filter((n, idx, list) => list.findIndex((c) => c.name === n.name) === idx)
|
|
2367
|
+
};
|
|
2368
|
+
return description2;
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
BaseSchema.prototype.__isYupSchema__ = true;
|
|
2372
|
+
for (const method of ["validate", "validateSync"])
|
|
2373
|
+
BaseSchema.prototype[`${method}At`] = function(path, value, options = {}) {
|
|
2374
|
+
const {
|
|
2375
|
+
parent,
|
|
2376
|
+
parentPath,
|
|
2377
|
+
schema
|
|
2378
|
+
} = getIn(this, path, value, options.context);
|
|
2379
|
+
return schema[method](parent && parent[parentPath], _extends({}, options, {
|
|
2380
|
+
parent,
|
|
2381
|
+
path
|
|
2382
|
+
}));
|
|
2383
|
+
};
|
|
2384
|
+
for (const alias of ["equals", "is"])
|
|
2385
|
+
BaseSchema.prototype[alias] = BaseSchema.prototype.oneOf;
|
|
2386
|
+
for (const alias of ["not", "nope"])
|
|
2387
|
+
BaseSchema.prototype[alias] = BaseSchema.prototype.notOneOf;
|
|
2388
|
+
BaseSchema.prototype.optional = BaseSchema.prototype.notRequired;
|
|
2389
|
+
const isAbsent = (value) => value == null;
|
|
2390
|
+
let rEmail = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i;
|
|
2391
|
+
let rUrl = /^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
|
|
2392
|
+
let rUUID = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
|
2393
|
+
let isTrimmed = (value) => isAbsent(value) || value === value.trim();
|
|
2394
|
+
let objStringTag = {}.toString();
|
|
2395
|
+
function create() {
|
|
2396
|
+
return new StringSchema();
|
|
2397
|
+
}
|
|
2398
|
+
class StringSchema extends BaseSchema {
|
|
2399
|
+
constructor() {
|
|
2400
|
+
super({
|
|
2401
|
+
type: "string"
|
|
2402
|
+
});
|
|
2403
|
+
this.withMutation(() => {
|
|
2404
|
+
this.transform(function(value) {
|
|
2405
|
+
if (this.isType(value))
|
|
2406
|
+
return value;
|
|
2407
|
+
if (Array.isArray(value))
|
|
2408
|
+
return value;
|
|
2409
|
+
const strValue = value != null && value.toString ? value.toString() : value;
|
|
2410
|
+
if (strValue === objStringTag)
|
|
2411
|
+
return value;
|
|
2412
|
+
return strValue;
|
|
2413
|
+
});
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
_typeCheck(value) {
|
|
2417
|
+
if (value instanceof String)
|
|
2418
|
+
value = value.valueOf();
|
|
2419
|
+
return typeof value === "string";
|
|
2420
|
+
}
|
|
2421
|
+
_isPresent(value) {
|
|
2422
|
+
return super._isPresent(value) && !!value.length;
|
|
2423
|
+
}
|
|
2424
|
+
length(length, message = string.length) {
|
|
2425
|
+
return this.test({
|
|
2426
|
+
message,
|
|
2427
|
+
name: "length",
|
|
2428
|
+
exclusive: true,
|
|
2429
|
+
params: {
|
|
2430
|
+
length
|
|
2431
|
+
},
|
|
2432
|
+
test(value) {
|
|
2433
|
+
return isAbsent(value) || value.length === this.resolve(length);
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
}
|
|
2437
|
+
min(min, message = string.min) {
|
|
2438
|
+
return this.test({
|
|
2439
|
+
message,
|
|
2440
|
+
name: "min",
|
|
2441
|
+
exclusive: true,
|
|
2442
|
+
params: {
|
|
2443
|
+
min
|
|
2444
|
+
},
|
|
2445
|
+
test(value) {
|
|
2446
|
+
return isAbsent(value) || value.length >= this.resolve(min);
|
|
2447
|
+
}
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
max(max, message = string.max) {
|
|
2451
|
+
return this.test({
|
|
2452
|
+
name: "max",
|
|
2453
|
+
exclusive: true,
|
|
2454
|
+
message,
|
|
2455
|
+
params: {
|
|
2456
|
+
max
|
|
2457
|
+
},
|
|
2458
|
+
test(value) {
|
|
2459
|
+
return isAbsent(value) || value.length <= this.resolve(max);
|
|
2460
|
+
}
|
|
2461
|
+
});
|
|
2462
|
+
}
|
|
2463
|
+
matches(regex, options) {
|
|
2464
|
+
let excludeEmptyString = false;
|
|
2465
|
+
let message;
|
|
2466
|
+
let name2;
|
|
2467
|
+
if (options) {
|
|
2468
|
+
if (typeof options === "object") {
|
|
2469
|
+
({
|
|
2470
|
+
excludeEmptyString = false,
|
|
2471
|
+
message,
|
|
2472
|
+
name: name2
|
|
2473
|
+
} = options);
|
|
2474
|
+
} else {
|
|
2475
|
+
message = options;
|
|
2476
|
+
}
|
|
2477
|
+
}
|
|
2478
|
+
return this.test({
|
|
2479
|
+
name: name2 || "matches",
|
|
2480
|
+
message: message || string.matches,
|
|
2481
|
+
params: {
|
|
2482
|
+
regex
|
|
2483
|
+
},
|
|
2484
|
+
test: (value) => isAbsent(value) || value === "" && excludeEmptyString || value.search(regex) !== -1
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
email(message = string.email) {
|
|
2488
|
+
return this.matches(rEmail, {
|
|
2489
|
+
name: "email",
|
|
2490
|
+
message,
|
|
2491
|
+
excludeEmptyString: true
|
|
2492
|
+
});
|
|
2493
|
+
}
|
|
2494
|
+
url(message = string.url) {
|
|
2495
|
+
return this.matches(rUrl, {
|
|
2496
|
+
name: "url",
|
|
2497
|
+
message,
|
|
2498
|
+
excludeEmptyString: true
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
uuid(message = string.uuid) {
|
|
2502
|
+
return this.matches(rUUID, {
|
|
2503
|
+
name: "uuid",
|
|
2504
|
+
message,
|
|
2505
|
+
excludeEmptyString: false
|
|
2506
|
+
});
|
|
2507
|
+
}
|
|
2508
|
+
//-- transforms --
|
|
2509
|
+
ensure() {
|
|
2510
|
+
return this.default("").transform((val) => val === null ? "" : val);
|
|
2511
|
+
}
|
|
2512
|
+
trim(message = string.trim) {
|
|
2513
|
+
return this.transform((val) => val != null ? val.trim() : val).test({
|
|
2514
|
+
message,
|
|
2515
|
+
name: "trim",
|
|
2516
|
+
test: isTrimmed
|
|
2517
|
+
});
|
|
2518
|
+
}
|
|
2519
|
+
lowercase(message = string.lowercase) {
|
|
2520
|
+
return this.transform((value) => !isAbsent(value) ? value.toLowerCase() : value).test({
|
|
2521
|
+
message,
|
|
2522
|
+
name: "string_case",
|
|
2523
|
+
exclusive: true,
|
|
2524
|
+
test: (value) => isAbsent(value) || value === value.toLowerCase()
|
|
2525
|
+
});
|
|
2526
|
+
}
|
|
2527
|
+
uppercase(message = string.uppercase) {
|
|
2528
|
+
return this.transform((value) => !isAbsent(value) ? value.toUpperCase() : value).test({
|
|
2529
|
+
message,
|
|
2530
|
+
name: "string_case",
|
|
2531
|
+
exclusive: true,
|
|
2532
|
+
test: (value) => isAbsent(value) || value === value.toUpperCase()
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
create.prototype = StringSchema.prototype;
|
|
2537
|
+
var isoReg = /^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;
|
|
2538
|
+
function parseIsoDate(date2) {
|
|
2539
|
+
var numericKeys = [1, 4, 5, 6, 7, 10, 11], minutesOffset = 0, timestamp, struct;
|
|
2540
|
+
if (struct = isoReg.exec(date2)) {
|
|
2541
|
+
for (var i = 0, k; k = numericKeys[i]; ++i)
|
|
2542
|
+
struct[k] = +struct[k] || 0;
|
|
2543
|
+
struct[2] = (+struct[2] || 1) - 1;
|
|
2544
|
+
struct[3] = +struct[3] || 1;
|
|
2545
|
+
struct[7] = struct[7] ? String(struct[7]).substr(0, 3) : 0;
|
|
2546
|
+
if ((struct[8] === void 0 || struct[8] === "") && (struct[9] === void 0 || struct[9] === ""))
|
|
2547
|
+
timestamp = +new Date(struct[1], struct[2], struct[3], struct[4], struct[5], struct[6], struct[7]);
|
|
2548
|
+
else {
|
|
2549
|
+
if (struct[8] !== "Z" && struct[9] !== void 0) {
|
|
2550
|
+
minutesOffset = struct[10] * 60 + struct[11];
|
|
2551
|
+
if (struct[9] === "+")
|
|
2552
|
+
minutesOffset = 0 - minutesOffset;
|
|
2553
|
+
}
|
|
2554
|
+
timestamp = Date.UTC(struct[1], struct[2], struct[3], struct[4], struct[5] + minutesOffset, struct[6], struct[7]);
|
|
2555
|
+
}
|
|
2556
|
+
} else
|
|
2557
|
+
timestamp = Date.parse ? Date.parse(date2) : NaN;
|
|
2558
|
+
return timestamp;
|
|
2559
|
+
}
|
|
2560
|
+
let invalidDate = /* @__PURE__ */ new Date("");
|
|
2561
|
+
let isDate = (obj) => Object.prototype.toString.call(obj) === "[object Date]";
|
|
2562
|
+
class DateSchema extends BaseSchema {
|
|
2563
|
+
constructor() {
|
|
2564
|
+
super({
|
|
2565
|
+
type: "date"
|
|
2566
|
+
});
|
|
2567
|
+
this.withMutation(() => {
|
|
2568
|
+
this.transform(function(value) {
|
|
2569
|
+
if (this.isType(value))
|
|
2570
|
+
return value;
|
|
2571
|
+
value = parseIsoDate(value);
|
|
2572
|
+
return !isNaN(value) ? new Date(value) : invalidDate;
|
|
2573
|
+
});
|
|
2574
|
+
});
|
|
2575
|
+
}
|
|
2576
|
+
_typeCheck(v) {
|
|
2577
|
+
return isDate(v) && !isNaN(v.getTime());
|
|
2578
|
+
}
|
|
2579
|
+
prepareParam(ref, name2) {
|
|
2580
|
+
let param;
|
|
2581
|
+
if (!Reference.isRef(ref)) {
|
|
2582
|
+
let cast = this.cast(ref);
|
|
2583
|
+
if (!this._typeCheck(cast))
|
|
2584
|
+
throw new TypeError(`\`${name2}\` must be a Date or a value that can be \`cast()\` to a Date`);
|
|
2585
|
+
param = cast;
|
|
2586
|
+
} else {
|
|
2587
|
+
param = ref;
|
|
2588
|
+
}
|
|
2589
|
+
return param;
|
|
2590
|
+
}
|
|
2591
|
+
min(min, message = date.min) {
|
|
2592
|
+
let limit = this.prepareParam(min, "min");
|
|
2593
|
+
return this.test({
|
|
2594
|
+
message,
|
|
2595
|
+
name: "min",
|
|
2596
|
+
exclusive: true,
|
|
2597
|
+
params: {
|
|
2598
|
+
min
|
|
2599
|
+
},
|
|
2600
|
+
test(value) {
|
|
2601
|
+
return isAbsent(value) || value >= this.resolve(limit);
|
|
2602
|
+
}
|
|
2603
|
+
});
|
|
2604
|
+
}
|
|
2605
|
+
max(max, message = date.max) {
|
|
2606
|
+
var limit = this.prepareParam(max, "max");
|
|
2607
|
+
return this.test({
|
|
2608
|
+
message,
|
|
2609
|
+
name: "max",
|
|
2610
|
+
exclusive: true,
|
|
2611
|
+
params: {
|
|
2612
|
+
max
|
|
2613
|
+
},
|
|
2614
|
+
test(value) {
|
|
2615
|
+
return isAbsent(value) || value <= this.resolve(limit);
|
|
2616
|
+
}
|
|
2617
|
+
});
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
DateSchema.INVALID_DATE = invalidDate;
|
|
2621
|
+
var toposort$1 = { exports: {} };
|
|
2622
|
+
toposort$1.exports = function(edges) {
|
|
2623
|
+
return toposort(uniqueNodes(edges), edges);
|
|
2624
|
+
};
|
|
2625
|
+
toposort$1.exports.array = toposort;
|
|
2626
|
+
function toposort(nodes, edges) {
|
|
2627
|
+
var cursor = nodes.length, sorted = new Array(cursor), visited = {}, i = cursor, outgoingEdges = makeOutgoingEdges(edges), nodesHash = makeNodesHash(nodes);
|
|
2628
|
+
edges.forEach(function(edge) {
|
|
2629
|
+
if (!nodesHash.has(edge[0]) || !nodesHash.has(edge[1])) {
|
|
2630
|
+
throw new Error("Unknown node. There is an unknown node in the supplied edges.");
|
|
2631
|
+
}
|
|
2632
|
+
});
|
|
2633
|
+
while (i--) {
|
|
2634
|
+
if (!visited[i])
|
|
2635
|
+
visit(nodes[i], i, /* @__PURE__ */ new Set());
|
|
2636
|
+
}
|
|
2637
|
+
return sorted;
|
|
2638
|
+
function visit(node, i2, predecessors) {
|
|
2639
|
+
if (predecessors.has(node)) {
|
|
2640
|
+
var nodeRep;
|
|
2641
|
+
try {
|
|
2642
|
+
nodeRep = ", node was:" + JSON.stringify(node);
|
|
2643
|
+
} catch (e) {
|
|
2644
|
+
nodeRep = "";
|
|
2645
|
+
}
|
|
2646
|
+
throw new Error("Cyclic dependency" + nodeRep);
|
|
2647
|
+
}
|
|
2648
|
+
if (!nodesHash.has(node)) {
|
|
2649
|
+
throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: " + JSON.stringify(node));
|
|
2650
|
+
}
|
|
2651
|
+
if (visited[i2])
|
|
2652
|
+
return;
|
|
2653
|
+
visited[i2] = true;
|
|
2654
|
+
var outgoing = outgoingEdges.get(node) || /* @__PURE__ */ new Set();
|
|
2655
|
+
outgoing = Array.from(outgoing);
|
|
2656
|
+
if (i2 = outgoing.length) {
|
|
2657
|
+
predecessors.add(node);
|
|
2658
|
+
do {
|
|
2659
|
+
var child = outgoing[--i2];
|
|
2660
|
+
visit(child, nodesHash.get(child), predecessors);
|
|
2661
|
+
} while (i2);
|
|
2662
|
+
predecessors.delete(node);
|
|
2663
|
+
}
|
|
2664
|
+
sorted[--cursor] = node;
|
|
2665
|
+
}
|
|
2666
|
+
}
|
|
2667
|
+
function uniqueNodes(arr) {
|
|
2668
|
+
var res = /* @__PURE__ */ new Set();
|
|
2669
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
2670
|
+
var edge = arr[i];
|
|
2671
|
+
res.add(edge[0]);
|
|
2672
|
+
res.add(edge[1]);
|
|
2673
|
+
}
|
|
2674
|
+
return Array.from(res);
|
|
2675
|
+
}
|
|
2676
|
+
function makeOutgoingEdges(arr) {
|
|
2677
|
+
var edges = /* @__PURE__ */ new Map();
|
|
2678
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
2679
|
+
var edge = arr[i];
|
|
2680
|
+
if (!edges.has(edge[0]))
|
|
2681
|
+
edges.set(edge[0], /* @__PURE__ */ new Set());
|
|
2682
|
+
if (!edges.has(edge[1]))
|
|
2683
|
+
edges.set(edge[1], /* @__PURE__ */ new Set());
|
|
2684
|
+
edges.get(edge[0]).add(edge[1]);
|
|
2685
|
+
}
|
|
2686
|
+
return edges;
|
|
2687
|
+
}
|
|
2688
|
+
function makeNodesHash(arr) {
|
|
2689
|
+
var res = /* @__PURE__ */ new Map();
|
|
2690
|
+
for (var i = 0, len = arr.length; i < len; i++) {
|
|
2691
|
+
res.set(arr[i], i);
|
|
2692
|
+
}
|
|
2693
|
+
return res;
|
|
2694
|
+
}
|
|
2695
|
+
const mediaLibIcon = '<svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M4.3.6a.9.9 0 100 1.8h15.311a.9.9 0 100-1.8H4.301zm17.1 3.7A1.6 1.6 0 0123 5.9v15.5a1.6 1.6 0 01-1.6 1.6H2.6A1.601 1.601 0 011 21.4V8 5.915C1 5.03 1.716 4.3 2.6 4.3h18.8zM5.032 19.18h14.336l-3.136-3.205-1.792 1.831-4.032-4.12-5.376 5.494zm13.44-8.697c0 1.282-.985 2.289-2.24 2.289-1.254 0-2.24-1.007-2.24-2.29 0-1.281.986-2.288 2.24-2.288 1.255 0 2.24 1.007 2.24 2.289z"></path></svg>';
|
|
2696
|
+
class StrapiMediaLib extends cke.Plugin {
|
|
2697
|
+
/**
|
|
2698
|
+
* Strapi function used to show media library modal.
|
|
2699
|
+
* Should be provided via connect method before using toggle method.
|
|
2700
|
+
*
|
|
2701
|
+
* @type {function|null}
|
|
2702
|
+
*/
|
|
2703
|
+
strapiToggle = null;
|
|
2704
|
+
static get pluginName() {
|
|
2705
|
+
return "StrapiMediaLib";
|
|
2706
|
+
}
|
|
2707
|
+
init() {
|
|
2708
|
+
const editor = this.editor;
|
|
2709
|
+
const config = editor.config.get("strapiMediaLib");
|
|
2710
|
+
editor.ui.componentFactory.add("strapiMediaLib", () => {
|
|
2711
|
+
const button = new cke.ButtonView();
|
|
2712
|
+
button.set({
|
|
2713
|
+
label: "Media Library",
|
|
2714
|
+
icon: mediaLibIcon,
|
|
2715
|
+
tooltip: true
|
|
2716
|
+
});
|
|
2717
|
+
button.on("execute", config.toggle.bind(this));
|
|
2718
|
+
return button;
|
|
2719
|
+
});
|
|
2720
|
+
}
|
|
2721
|
+
}
|
|
2722
|
+
class StrapiUploadAdapter extends cke.Plugin {
|
|
2723
|
+
static get requires() {
|
|
2724
|
+
return [cke.FileRepository];
|
|
2725
|
+
}
|
|
2726
|
+
static get pluginName() {
|
|
2727
|
+
return "StrapiUploadAdapter";
|
|
2728
|
+
}
|
|
2729
|
+
init() {
|
|
2730
|
+
const options = this.editor.config.get("strapiUploadAdapter");
|
|
2731
|
+
if (!options) {
|
|
2732
|
+
return;
|
|
2733
|
+
}
|
|
2734
|
+
if (!options.uploadUrl) {
|
|
2735
|
+
console.warn(
|
|
2736
|
+
'strapi-upload-adapter-missing-uploadUrl: Missing the "uploadUrl" property in the "strapiUploadAdapter" editor configuration.'
|
|
2737
|
+
);
|
|
2738
|
+
return;
|
|
2739
|
+
}
|
|
2740
|
+
this.editor.plugins.get(cke.FileRepository).createUploadAdapter = (loader) => {
|
|
2741
|
+
return new Adapter(loader, options);
|
|
2742
|
+
};
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
class Adapter {
|
|
2746
|
+
/**
|
|
2747
|
+
* Creates a new adapter instance.
|
|
2748
|
+
*/
|
|
2749
|
+
constructor(loader, options) {
|
|
2750
|
+
this.loader = loader;
|
|
2751
|
+
this.options = options;
|
|
2752
|
+
}
|
|
2753
|
+
/**
|
|
2754
|
+
* Starts the upload process.
|
|
2755
|
+
*
|
|
2756
|
+
* @returns {Promise}
|
|
2757
|
+
*/
|
|
2758
|
+
upload() {
|
|
2759
|
+
return this.loader.file.then(
|
|
2760
|
+
(file) => new Promise((resolve, reject) => {
|
|
2761
|
+
this._initRequest();
|
|
2762
|
+
this._initListeners(resolve, reject, file);
|
|
2763
|
+
this._sendRequest(file);
|
|
2764
|
+
})
|
|
2765
|
+
);
|
|
2766
|
+
}
|
|
2767
|
+
/**
|
|
2768
|
+
* Aborts the upload process.
|
|
2769
|
+
*
|
|
2770
|
+
* @returns {Promise}
|
|
2771
|
+
*/
|
|
2772
|
+
abort() {
|
|
2773
|
+
if (this.xhr) {
|
|
2774
|
+
this.xhr.abort();
|
|
2775
|
+
}
|
|
2776
|
+
}
|
|
2777
|
+
/**
|
|
2778
|
+
* Initializes the `XMLHttpRequest` object using the URL specified as
|
|
2779
|
+
* `strapiUpload.uploadUrl` in the editor's
|
|
2780
|
+
* configuration.
|
|
2781
|
+
*
|
|
2782
|
+
* @private
|
|
2783
|
+
*/
|
|
2784
|
+
_initRequest() {
|
|
2785
|
+
const xhr = this.xhr = new XMLHttpRequest();
|
|
2786
|
+
xhr.open("POST", this.options.uploadUrl, true);
|
|
2787
|
+
xhr.responseType = "json";
|
|
2788
|
+
}
|
|
2789
|
+
/**
|
|
2790
|
+
* Initializes XMLHttpRequest listeners
|
|
2791
|
+
*
|
|
2792
|
+
* @private
|
|
2793
|
+
* @param {Function} resolve Callback function to be called when the request is successful.
|
|
2794
|
+
* @param {Function} reject Callback function to be called when the request cannot be completed.
|
|
2795
|
+
* @param {File} file Native File object.
|
|
2796
|
+
*/
|
|
2797
|
+
_initListeners(resolve, reject, file) {
|
|
2798
|
+
const xhr = this.xhr;
|
|
2799
|
+
const loader = this.loader;
|
|
2800
|
+
const genericErrorText = `Couldn't upload file: ${file.name}.`;
|
|
2801
|
+
xhr.addEventListener("error", () => reject(genericErrorText));
|
|
2802
|
+
xhr.addEventListener("abort", () => reject());
|
|
2803
|
+
xhr.addEventListener("load", () => {
|
|
2804
|
+
const response = xhr.response;
|
|
2805
|
+
if (!Array.isArray(response) || response.error || response.length !== 1) {
|
|
2806
|
+
return reject(
|
|
2807
|
+
response && response.error && response.error.message ? response.error.message : genericErrorText
|
|
2808
|
+
);
|
|
2809
|
+
}
|
|
2810
|
+
const { backendUrl, responsive } = this.options || {};
|
|
2811
|
+
const { name: name2, url, alternativeText, formats, provider } = response[0];
|
|
2812
|
+
const defaultUrl = provider !== "local" ? url : backendUrl + url;
|
|
2813
|
+
if (formats && responsive) {
|
|
2814
|
+
let urls = { default: defaultUrl };
|
|
2815
|
+
let keys2 = Object.keys(formats).sort(
|
|
2816
|
+
(a, b) => formats[a].width - formats[b].width
|
|
2817
|
+
);
|
|
2818
|
+
keys2.map(
|
|
2819
|
+
(k) => urls[formats[k].width] = provider !== "local" ? url : backendUrl + formats[k].url
|
|
2820
|
+
);
|
|
2821
|
+
resolve({ alt: alternativeText || name2, urls });
|
|
2822
|
+
} else {
|
|
2823
|
+
resolve(
|
|
2824
|
+
url ? {
|
|
2825
|
+
alt: alternativeText || name2,
|
|
2826
|
+
urls: { default: defaultUrl }
|
|
2827
|
+
} : null
|
|
2828
|
+
);
|
|
2829
|
+
}
|
|
2830
|
+
});
|
|
2831
|
+
if (xhr.upload) {
|
|
2832
|
+
xhr.upload.addEventListener("progress", (evt) => {
|
|
2833
|
+
if (evt.lengthComputable) {
|
|
2834
|
+
loader.uploadTotal = evt.total;
|
|
2835
|
+
loader.uploaded = evt.loaded;
|
|
2836
|
+
}
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
/**
|
|
2841
|
+
* Prepares the data and sends the request.
|
|
2842
|
+
*
|
|
2843
|
+
* @private
|
|
2844
|
+
* @param {File} file File instance to be uploaded.
|
|
2845
|
+
*/
|
|
2846
|
+
_sendRequest(file) {
|
|
2847
|
+
const headers = this.options.headers || {};
|
|
2848
|
+
const withCredentials = this.options.withCredentials || false;
|
|
2849
|
+
for (const headerName of Object.keys(headers)) {
|
|
2850
|
+
this.xhr.setRequestHeader(headerName, headers[headerName]);
|
|
2851
|
+
}
|
|
2852
|
+
this.xhr.withCredentials = withCredentials;
|
|
2853
|
+
const data = new FormData();
|
|
2854
|
+
data.append("files", file);
|
|
2855
|
+
this.xhr.send(data);
|
|
2856
|
+
}
|
|
2857
|
+
}
|
|
2858
|
+
const materialColors = [
|
|
2859
|
+
{ label: "Red 50", color: "#ffebee" },
|
|
2860
|
+
{ label: "Purple 50", color: "#f3e5f5" },
|
|
2861
|
+
{ label: "Indigo 50", color: "#e8eaf6" },
|
|
2862
|
+
{ label: "Blue 50", color: "#e3f2fd" },
|
|
2863
|
+
{ label: "Cyan 50", color: "#e0f7fa" },
|
|
2864
|
+
{ label: "Teal 50", color: "#e0f2f1" },
|
|
2865
|
+
{ label: "Light green 50", color: "#f1f8e9" },
|
|
2866
|
+
{ label: "Lime 50", color: "#f9fbe7" },
|
|
2867
|
+
{ label: "Amber 50", color: "#fff8e1" },
|
|
2868
|
+
{ label: "Orange 50", color: "#fff3e0" },
|
|
2869
|
+
{ label: "Grey 50", color: "#fafafa" },
|
|
2870
|
+
{ label: "Blue grey 50", color: "#eceff1" },
|
|
2871
|
+
{ label: "Red 100", color: "#ffcdd2" },
|
|
2872
|
+
{ label: "Purple 100", color: "#e1bee7" },
|
|
2873
|
+
{ label: "Indigo 100", color: "#c5cae9" },
|
|
2874
|
+
{ label: "Blue 100", color: "#bbdefb" },
|
|
2875
|
+
{ label: "Cyan 100", color: "#b2ebf2" },
|
|
2876
|
+
{ label: "Teal 100", color: "#b2dfdb" },
|
|
2877
|
+
{ label: "Light green 100", color: "#dcedc8" },
|
|
2878
|
+
{ label: "Lime 100", color: "#f0f4c3" },
|
|
2879
|
+
{ label: "Amber 100", color: "#ffecb3" },
|
|
2880
|
+
{ label: "Orange 100", color: "#ffe0b2" },
|
|
2881
|
+
{ label: "Grey 100", color: "#f5f5f5" },
|
|
2882
|
+
{ label: "Blue grey 100", color: "#cfd8dc" },
|
|
2883
|
+
{ label: "Red 200", color: "#ef9a9a" },
|
|
2884
|
+
{ label: "Purple 200", color: "#ce93d8" },
|
|
2885
|
+
{ label: "Indigo 200", color: "#9fa8da" },
|
|
2886
|
+
{ label: "Blue 200", color: "#90caf9" },
|
|
2887
|
+
{ label: "Cyan 200", color: "#80deea" },
|
|
2888
|
+
{ label: "Teal 200", color: "#80cbc4" },
|
|
2889
|
+
{ label: "Light green 200", color: "#c5e1a5" },
|
|
2890
|
+
{ label: "Lime 200", color: "#e6ee9c" },
|
|
2891
|
+
{ label: "Amber 200", color: "#ffe082" },
|
|
2892
|
+
{ label: "Orange 200", color: "#ffcc80" },
|
|
2893
|
+
{ label: "Grey 200", color: "#eeeeee" },
|
|
2894
|
+
{ label: "Blue grey 200", color: "#b0bec5" },
|
|
2895
|
+
{ label: "Red 300", color: "#e57373" },
|
|
2896
|
+
{ label: "Purple 300", color: "#ba68c8" },
|
|
2897
|
+
{ label: "Indigo 300", color: "#7986cb" },
|
|
2898
|
+
{ label: "Blue 300", color: "#64b5f6" },
|
|
2899
|
+
{ label: "Cyan 300", color: "#4dd0e1" },
|
|
2900
|
+
{ label: "Teal 300", color: "#4db6ac" },
|
|
2901
|
+
{ label: "Light green 300", color: "#aed581" },
|
|
2902
|
+
{ label: "Lime 300", color: "#dce775" },
|
|
2903
|
+
{ label: "Amber 300", color: "#ffd54f" },
|
|
2904
|
+
{ label: "Orange 300", color: "#ffb74d" },
|
|
2905
|
+
{ label: "Grey 300", color: "#e0e0e0" },
|
|
2906
|
+
{ label: "Blue grey 300", color: "#90a4ae" },
|
|
2907
|
+
{ label: "Red 400", color: "#ef5350" },
|
|
2908
|
+
{ label: "Purple 400", color: "#ab47bc" },
|
|
2909
|
+
{ label: "Indigo 400", color: "#5c6bc0" },
|
|
2910
|
+
{ label: "Blue 400", color: "#42a5f5" },
|
|
2911
|
+
{ label: "Cyan 400", color: "#26c6da" },
|
|
2912
|
+
{ label: "Teal 400", color: "#26a69a" },
|
|
2913
|
+
{ label: "Light green 400", color: "#9ccc65" },
|
|
2914
|
+
{ label: "Lime 400", color: "#d4e157" },
|
|
2915
|
+
{ label: "Amber 400", color: "#ffca28" },
|
|
2916
|
+
{ label: "Orange 400", color: "#ffa726" },
|
|
2917
|
+
{ label: "Grey 400", color: "#bdbdbd" },
|
|
2918
|
+
{ label: "Blue grey 400", color: "#78909c" },
|
|
2919
|
+
{ label: "Red 500", color: "#f44336" },
|
|
2920
|
+
{ label: "Purple 500", color: "#9c27b0" },
|
|
2921
|
+
{ label: "Indigo 500", color: "#3f51b5" },
|
|
2922
|
+
{ label: "Blue 500", color: "#2196f3" },
|
|
2923
|
+
{ label: "Cyan 500", color: "#00bcd4" },
|
|
2924
|
+
{ label: "Teal 500", color: "#009688" },
|
|
2925
|
+
{ label: "Light green 500", color: "#8bc34a" },
|
|
2926
|
+
{ label: "Lime 500", color: "#cddc39" },
|
|
2927
|
+
{ label: "Amber 500", color: "#ffc107" },
|
|
2928
|
+
{ label: "Orange 500", color: "#ff9800" },
|
|
2929
|
+
{ label: "Grey 500", color: "#9e9e9e" },
|
|
2930
|
+
{ label: "Blue grey 500", color: "#607d8b" },
|
|
2931
|
+
{ label: "Red 600", color: "#e53935" },
|
|
2932
|
+
{ label: "Purple 600", color: "#8e24aa" },
|
|
2933
|
+
{ label: "Indigo 600", color: "#3949ab" },
|
|
2934
|
+
{ label: "Blue 600", color: "#1e88e5" },
|
|
2935
|
+
{ label: "Cyan 600", color: "#00acc1" },
|
|
2936
|
+
{ label: "Teal 600", color: "#00897b" },
|
|
2937
|
+
{ label: "Light green 600", color: "#7cb342" },
|
|
2938
|
+
{ label: "Lime 600", color: "#c0ca33" },
|
|
2939
|
+
{ label: "Amber 600", color: "#ffb300" },
|
|
2940
|
+
{ label: "Orange 600", color: "#fb8c00" },
|
|
2941
|
+
{ label: "Grey 600", color: "#757575" },
|
|
2942
|
+
{ label: "Blue grey 600", color: "#546e7a" },
|
|
2943
|
+
{ label: "Red 700", color: "#d32f2f" },
|
|
2944
|
+
{ label: "Purple 700", color: "#7b1fa2" },
|
|
2945
|
+
{ label: "Indigo 700", color: "#303f9f" },
|
|
2946
|
+
{ label: "Blue 700", color: "#1976d2" },
|
|
2947
|
+
{ label: "Cyan 700", color: "#0097a7" },
|
|
2948
|
+
{ label: "Teal 700", color: "#00796b" },
|
|
2949
|
+
{ label: "Light green 700", color: "#689f38" },
|
|
2950
|
+
{ label: "Lime 700", color: "#afb42b" },
|
|
2951
|
+
{ label: "Amber 700", color: "#ffa000" },
|
|
2952
|
+
{ label: "Orange 700", color: "#f57c00" },
|
|
2953
|
+
{ label: "Grey 700", color: "#616161" },
|
|
2954
|
+
{ label: "Blue grey 700", color: "#455a64" },
|
|
2955
|
+
{ label: "Red 800", color: "#c62828" },
|
|
2956
|
+
{ label: "Purple 800", color: "#6a1b9a" },
|
|
2957
|
+
{ label: "Indigo 800", color: "#283593" },
|
|
2958
|
+
{ label: "Blue 800", color: "#1565c0" },
|
|
2959
|
+
{ label: "Cyan 800", color: "#00838f" },
|
|
2960
|
+
{ label: "Teal 800", color: "#00695c" },
|
|
2961
|
+
{ label: "Light green 800", color: "#558b2f" },
|
|
2962
|
+
{ label: "Lime 800", color: "#9e9d24" },
|
|
2963
|
+
{ label: "Amber 800", color: "#ff8f00" },
|
|
2964
|
+
{ label: "Orange 800", color: "#ef6c00" },
|
|
2965
|
+
{ label: "Grey 800", color: "#424242" },
|
|
2966
|
+
{ label: "Blue grey 800", color: "#37474f" },
|
|
2967
|
+
{ label: "Red 900", color: "#b71c1c" },
|
|
2968
|
+
{ label: "Purple 900", color: "#4a148c" },
|
|
2969
|
+
{ label: "Indigo 900", color: "#1a237e" },
|
|
2970
|
+
{ label: "Blue 900", color: "#0d47a1" },
|
|
2971
|
+
{ label: "Cyan 900", color: "#006064" },
|
|
2972
|
+
{ label: "Teal 900", color: "#004d40" },
|
|
2973
|
+
{ label: "Light green 900", color: "#33691e" },
|
|
2974
|
+
{ label: "Lime 900", color: "#827717" },
|
|
2975
|
+
{ label: "Amber 900", color: "#ff6f00" },
|
|
2976
|
+
{ label: "Orange 900", color: "#e65100" },
|
|
2977
|
+
{ label: "Grey 900", color: "#212121" },
|
|
2978
|
+
{ label: "Blue grey 900", color: "#263238" }
|
|
2979
|
+
];
|
|
2980
|
+
globalThis.SH_CKE = {
|
|
2981
|
+
...cke__namespace,
|
|
2982
|
+
StrapiMediaLib,
|
|
2983
|
+
StrapiUploadAdapter,
|
|
2984
|
+
MaterialColors: materialColors
|
|
2985
|
+
};
|
|
2986
|
+
const defaultEditorConfig = {
|
|
2987
|
+
plugins: [
|
|
2988
|
+
SH_CKE.Alignment,
|
|
2989
|
+
SH_CKE.Autoformat,
|
|
2990
|
+
SH_CKE.AutoImage,
|
|
2991
|
+
SH_CKE.BalloonToolbar,
|
|
2992
|
+
SH_CKE.BlockQuote,
|
|
2993
|
+
SH_CKE.Bold,
|
|
2994
|
+
SH_CKE.Code,
|
|
2995
|
+
SH_CKE.CodeBlock,
|
|
2996
|
+
SH_CKE.Essentials,
|
|
2997
|
+
SH_CKE.FontBackgroundColor,
|
|
2998
|
+
SH_CKE.FontColor,
|
|
2999
|
+
SH_CKE.FontFamily,
|
|
3000
|
+
SH_CKE.FontSize,
|
|
3001
|
+
SH_CKE.GeneralHtmlSupport,
|
|
3002
|
+
SH_CKE.Heading,
|
|
3003
|
+
SH_CKE.HorizontalLine,
|
|
3004
|
+
SH_CKE.HtmlEmbed,
|
|
3005
|
+
SH_CKE.Image,
|
|
3006
|
+
SH_CKE.ImageCaption,
|
|
3007
|
+
SH_CKE.ImageInsert,
|
|
3008
|
+
SH_CKE.ImageResize,
|
|
3009
|
+
SH_CKE.ImageStyle,
|
|
3010
|
+
SH_CKE.ImageToolbar,
|
|
3011
|
+
SH_CKE.ImageUpload,
|
|
3012
|
+
SH_CKE.Indent,
|
|
3013
|
+
SH_CKE.IndentBlock,
|
|
3014
|
+
SH_CKE.Italic,
|
|
3015
|
+
SH_CKE.List,
|
|
3016
|
+
SH_CKE.ListProperties,
|
|
3017
|
+
SH_CKE.Link,
|
|
3018
|
+
SH_CKE.LinkImage,
|
|
3019
|
+
SH_CKE.LinkImage,
|
|
3020
|
+
SH_CKE.MediaEmbed,
|
|
3021
|
+
SH_CKE.PageBreak,
|
|
3022
|
+
SH_CKE.Paragraph,
|
|
3023
|
+
SH_CKE.PasteFromOffice,
|
|
3024
|
+
SH_CKE.PictureEditing,
|
|
3025
|
+
SH_CKE.RemoveFormat,
|
|
3026
|
+
SH_CKE.SourceEditing,
|
|
3027
|
+
SH_CKE.SpecialCharacters,
|
|
3028
|
+
SH_CKE.SpecialCharactersArrows,
|
|
3029
|
+
SH_CKE.SpecialCharactersCurrency,
|
|
3030
|
+
SH_CKE.SpecialCharactersLatin,
|
|
3031
|
+
SH_CKE.SpecialCharactersMathematical,
|
|
3032
|
+
SH_CKE.SpecialCharactersText,
|
|
3033
|
+
SH_CKE.StrapiMediaLib,
|
|
3034
|
+
SH_CKE.StrapiUploadAdapter,
|
|
3035
|
+
SH_CKE.Strikethrough,
|
|
3036
|
+
SH_CKE.Style,
|
|
3037
|
+
SH_CKE.Subscript,
|
|
3038
|
+
SH_CKE.Superscript,
|
|
3039
|
+
SH_CKE.ShowBlocks,
|
|
3040
|
+
SH_CKE.Table,
|
|
3041
|
+
SH_CKE.TableCaption,
|
|
3042
|
+
SH_CKE.TableCellProperties,
|
|
3043
|
+
SH_CKE.TableColumnResize,
|
|
3044
|
+
SH_CKE.TableProperties,
|
|
3045
|
+
SH_CKE.TableToolbar,
|
|
3046
|
+
SH_CKE.Underline,
|
|
3047
|
+
SH_CKE.WordCount
|
|
3048
|
+
],
|
|
3049
|
+
toolbar: [
|
|
3050
|
+
{
|
|
3051
|
+
label: " ",
|
|
3052
|
+
tooltip: null,
|
|
3053
|
+
icon: "paragraph",
|
|
3054
|
+
items: ["heading", "style"]
|
|
3055
|
+
},
|
|
3056
|
+
{
|
|
3057
|
+
label: " ",
|
|
3058
|
+
tooltip: null,
|
|
3059
|
+
icon: "text",
|
|
3060
|
+
items: ["fontSize", "fontFamily"]
|
|
3061
|
+
},
|
|
3062
|
+
"|",
|
|
3063
|
+
"alignment",
|
|
3064
|
+
{
|
|
3065
|
+
label: " ",
|
|
3066
|
+
tooltip: null,
|
|
3067
|
+
icon: SH_CKE.icons.indent,
|
|
3068
|
+
items: ["outdent", "indent"]
|
|
3069
|
+
},
|
|
3070
|
+
"|",
|
|
3071
|
+
"bulletedList",
|
|
3072
|
+
"numberedList",
|
|
3073
|
+
"|",
|
|
3074
|
+
"insertImage",
|
|
3075
|
+
"mediaEmbed",
|
|
3076
|
+
"strapiMediaLib",
|
|
3077
|
+
"link",
|
|
3078
|
+
"blockquote",
|
|
3079
|
+
"insertTable",
|
|
3080
|
+
"specialCharacters",
|
|
3081
|
+
"htmlEmbed",
|
|
3082
|
+
"codeBlock",
|
|
3083
|
+
"|",
|
|
3084
|
+
"horizontalLine",
|
|
3085
|
+
"pageBreak",
|
|
3086
|
+
"|",
|
|
3087
|
+
"SourceEditing",
|
|
3088
|
+
"|",
|
|
3089
|
+
"showBlocks",
|
|
3090
|
+
"|",
|
|
3091
|
+
"undo",
|
|
3092
|
+
"redo",
|
|
3093
|
+
"|"
|
|
3094
|
+
],
|
|
3095
|
+
balloonToolbar: [
|
|
3096
|
+
"bold",
|
|
3097
|
+
"italic",
|
|
3098
|
+
"fontColor",
|
|
3099
|
+
"fontBackgroundColor",
|
|
3100
|
+
{
|
|
3101
|
+
label: " ",
|
|
3102
|
+
tooltip: null,
|
|
3103
|
+
icon: `
|
|
3104
|
+
<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
3105
|
+
<rect x="0" fill="none" width="24" height="24"/>
|
|
3106
|
+
<g>
|
|
3107
|
+
<path d="M14.348 12H21v2h-4.613c.24.515.368 1.094.368 1.748 0 1.317-.474 2.355-1.423 3.114-.947.76-2.266 1.138-3.956 1.138-1.557 0-2.934-.293-4.132-.878v-2.874c.985.44 1.818.75 2.5.928.682.18 1.306.27 1.872.27.68 0 1.2-.13 1.562-.39.363-.26.545-.644.545-1.158 0-.285-.08-.54-.24-.763-.16-.222-.394-.437-.704-.643-.18-.12-.483-.287-.88-.49H3v-2H14.347zm-3.528-2c-.073-.077-.143-.155-.193-.235-.126-.202-.19-.44-.19-.713 0-.44.157-.795.47-1.068.313-.273.762-.41 1.348-.41.492 0 .993.064 1.502.19.51.127 1.153.35 1.93.67l1-2.405c-.753-.327-1.473-.58-2.16-.76-.69-.18-1.414-.27-2.173-.27-1.544 0-2.753.37-3.628 1.108-.874.738-1.312 1.753-1.312 3.044 0 .302.036.58.088.848h3.318z"/>
|
|
3108
|
+
</g>
|
|
3109
|
+
</svg>`,
|
|
3110
|
+
items: ["underline", "strikethrough", "superscript", "subscript"]
|
|
3111
|
+
},
|
|
3112
|
+
"|",
|
|
3113
|
+
"removeFormat"
|
|
3114
|
+
],
|
|
3115
|
+
fontFamily: {
|
|
3116
|
+
supportAllValues: true
|
|
3117
|
+
},
|
|
3118
|
+
fontSize: {
|
|
3119
|
+
options: [10, 12, 14, "default", 18, 20, 22],
|
|
3120
|
+
supportAllValues: true
|
|
3121
|
+
},
|
|
3122
|
+
fontColor: {
|
|
3123
|
+
columns: 12,
|
|
3124
|
+
documentColors: 12,
|
|
3125
|
+
colors: materialColors
|
|
3126
|
+
},
|
|
3127
|
+
fontBackgroundColor: {
|
|
3128
|
+
columns: 12,
|
|
3129
|
+
documentColors: 12,
|
|
3130
|
+
colors: materialColors
|
|
3131
|
+
},
|
|
3132
|
+
heading: {
|
|
3133
|
+
options: [
|
|
3134
|
+
{ model: "paragraph", title: "Paragraph", class: "ck-heading_paragraph" },
|
|
3135
|
+
{
|
|
3136
|
+
model: "heading1",
|
|
3137
|
+
view: "h1",
|
|
3138
|
+
title: "Heading 1",
|
|
3139
|
+
class: "ck-heading_heading1"
|
|
3140
|
+
},
|
|
3141
|
+
{
|
|
3142
|
+
model: "heading2",
|
|
3143
|
+
view: "h2",
|
|
3144
|
+
title: "Heading 2",
|
|
3145
|
+
class: "ck-heading_heading2"
|
|
3146
|
+
},
|
|
3147
|
+
{
|
|
3148
|
+
model: "heading3",
|
|
3149
|
+
view: "h3",
|
|
3150
|
+
title: "Heading 3",
|
|
3151
|
+
class: "ck-heading_heading3"
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
model: "heading4",
|
|
3155
|
+
view: "h4",
|
|
3156
|
+
title: "Heading 4",
|
|
3157
|
+
class: "ck-heading_heading4"
|
|
3158
|
+
},
|
|
3159
|
+
{
|
|
3160
|
+
model: "heading5",
|
|
3161
|
+
view: "h5",
|
|
3162
|
+
title: "Heading 5",
|
|
3163
|
+
class: "ck-heading_heading5"
|
|
3164
|
+
},
|
|
3165
|
+
{
|
|
3166
|
+
model: "heading6",
|
|
3167
|
+
view: "h6",
|
|
3168
|
+
title: "Heading 6",
|
|
3169
|
+
class: "ck-heading_heading6"
|
|
3170
|
+
}
|
|
3171
|
+
]
|
|
3172
|
+
},
|
|
3173
|
+
htmlSupport: {
|
|
3174
|
+
allow: [
|
|
3175
|
+
{
|
|
3176
|
+
name: /.*/,
|
|
3177
|
+
attributes: true,
|
|
3178
|
+
classes: true,
|
|
3179
|
+
styles: true
|
|
3180
|
+
}
|
|
3181
|
+
],
|
|
3182
|
+
disallow: [
|
|
3183
|
+
{
|
|
3184
|
+
attributes: [
|
|
3185
|
+
{ key: /^on(.*)/i, value: true },
|
|
3186
|
+
{
|
|
3187
|
+
key: /.*/,
|
|
3188
|
+
value: /(\b)(on\S+)(\s*)=|javascript:|(<\s*)(\/*)script/i
|
|
3189
|
+
},
|
|
3190
|
+
{ key: /.*/, value: /data:(?!image\/(png|jpeg|gif|webp))/i }
|
|
3191
|
+
]
|
|
3192
|
+
},
|
|
3193
|
+
{ name: "script" }
|
|
3194
|
+
]
|
|
3195
|
+
},
|
|
3196
|
+
htmlEmbed: {
|
|
3197
|
+
showPreviews: true,
|
|
3198
|
+
sanitizeHtml: (inputHtml) => {
|
|
3199
|
+
const outputHtml = sanitizeHtml__default.default(inputHtml);
|
|
3200
|
+
return {
|
|
3201
|
+
html: outputHtml,
|
|
3202
|
+
hasChanged: true
|
|
3203
|
+
};
|
|
3204
|
+
}
|
|
3205
|
+
},
|
|
3206
|
+
list: {
|
|
3207
|
+
properties: {
|
|
3208
|
+
styles: true,
|
|
3209
|
+
startIndex: true,
|
|
3210
|
+
reversed: true
|
|
3211
|
+
}
|
|
3212
|
+
},
|
|
3213
|
+
table: {
|
|
3214
|
+
contentToolbar: [
|
|
3215
|
+
"tableColumn",
|
|
3216
|
+
"tableRow",
|
|
3217
|
+
"mergeTableCells",
|
|
3218
|
+
"tableProperties",
|
|
3219
|
+
"tableCellProperties",
|
|
3220
|
+
"toggleTableCaption"
|
|
3221
|
+
]
|
|
3222
|
+
},
|
|
3223
|
+
image: {
|
|
3224
|
+
styles: {
|
|
3225
|
+
options: [
|
|
3226
|
+
"inline",
|
|
3227
|
+
"alignLeft",
|
|
3228
|
+
"alignRight",
|
|
3229
|
+
"alignCenter",
|
|
3230
|
+
"alignBlockLeft",
|
|
3231
|
+
"alignBlockRight",
|
|
3232
|
+
"block",
|
|
3233
|
+
"side"
|
|
3234
|
+
]
|
|
3235
|
+
},
|
|
3236
|
+
resizeOptions: [
|
|
3237
|
+
{
|
|
3238
|
+
name: "resizeImage:original",
|
|
3239
|
+
label: "Default image width",
|
|
3240
|
+
value: null
|
|
3241
|
+
},
|
|
3242
|
+
{
|
|
3243
|
+
name: "resizeImage:50",
|
|
3244
|
+
label: "50% page width",
|
|
3245
|
+
value: "50"
|
|
3246
|
+
},
|
|
3247
|
+
{
|
|
3248
|
+
name: "resizeImage:75",
|
|
3249
|
+
label: "75% page width",
|
|
3250
|
+
value: "75"
|
|
3251
|
+
}
|
|
3252
|
+
],
|
|
3253
|
+
toolbar: [
|
|
3254
|
+
"imageTextAlternative",
|
|
3255
|
+
"toggleImageCaption",
|
|
3256
|
+
"linkImage",
|
|
3257
|
+
"|",
|
|
3258
|
+
"imageStyle:inline",
|
|
3259
|
+
"imageStyle:wrapText",
|
|
3260
|
+
"imageStyle:breakText",
|
|
3261
|
+
"imageStyle:side",
|
|
3262
|
+
"|",
|
|
3263
|
+
"resizeImage"
|
|
3264
|
+
]
|
|
3265
|
+
},
|
|
3266
|
+
link: {
|
|
3267
|
+
decorators: {
|
|
3268
|
+
toggleDownloadable: {
|
|
3269
|
+
mode: "manual",
|
|
3270
|
+
label: "Downloadable",
|
|
3271
|
+
attributes: {
|
|
3272
|
+
download: "file"
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
},
|
|
3276
|
+
addTargetToExternalLinks: true,
|
|
3277
|
+
defaultProtocol: "https://"
|
|
3278
|
+
},
|
|
3279
|
+
style: {
|
|
3280
|
+
definitions: [
|
|
3281
|
+
{
|
|
3282
|
+
name: "Title",
|
|
3283
|
+
element: "h1",
|
|
3284
|
+
classes: ["document-title"]
|
|
3285
|
+
},
|
|
3286
|
+
{
|
|
3287
|
+
name: "Subtitle",
|
|
3288
|
+
element: "h2",
|
|
3289
|
+
classes: ["document-subtitle"]
|
|
3290
|
+
},
|
|
3291
|
+
{
|
|
3292
|
+
name: "Callout",
|
|
3293
|
+
element: "p",
|
|
3294
|
+
classes: ["callout"]
|
|
3295
|
+
},
|
|
3296
|
+
{
|
|
3297
|
+
name: "Side quote",
|
|
3298
|
+
element: "blockquote",
|
|
3299
|
+
classes: ["side-quote"]
|
|
3300
|
+
},
|
|
3301
|
+
{
|
|
3302
|
+
name: "Needs clarification",
|
|
3303
|
+
element: "span",
|
|
3304
|
+
classes: ["needs-clarification"]
|
|
3305
|
+
},
|
|
3306
|
+
{
|
|
3307
|
+
name: "Wide spacing",
|
|
3308
|
+
element: "span",
|
|
3309
|
+
classes: ["wide-spacing"]
|
|
3310
|
+
},
|
|
3311
|
+
{
|
|
3312
|
+
name: "Small caps",
|
|
3313
|
+
element: "span",
|
|
3314
|
+
classes: ["small-caps"]
|
|
3315
|
+
},
|
|
3316
|
+
{
|
|
3317
|
+
name: "Code (dark)",
|
|
3318
|
+
element: "pre",
|
|
3319
|
+
classes: ["stylish-code", "stylish-code-dark"]
|
|
3320
|
+
},
|
|
3321
|
+
{
|
|
3322
|
+
name: "Code (bright)",
|
|
3323
|
+
element: "pre",
|
|
3324
|
+
classes: ["stylish-code", "stylish-code-bright"]
|
|
3325
|
+
}
|
|
3326
|
+
]
|
|
3327
|
+
},
|
|
3328
|
+
ui: {
|
|
3329
|
+
poweredBy: {
|
|
3330
|
+
position: "inside",
|
|
3331
|
+
side: "right",
|
|
3332
|
+
label: ""
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
const defaultEditor = {
|
|
3337
|
+
default: {
|
|
3338
|
+
field: {
|
|
3339
|
+
key: "default",
|
|
3340
|
+
value: "default",
|
|
3341
|
+
metadatas: {
|
|
3342
|
+
intlLabel: {
|
|
3343
|
+
id: "ckeditor.preset.default.label",
|
|
3344
|
+
defaultMessage: "default"
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
},
|
|
3348
|
+
editorConfig: defaultEditorConfig
|
|
3349
|
+
}
|
|
3350
|
+
};
|
|
3351
|
+
const basePresets = {
|
|
3352
|
+
...defaultEditor
|
|
3353
|
+
};
|
|
3354
|
+
const name = "@_sh/strapi-plugin-ckeditor";
|
|
3355
|
+
const version = "4.0.6";
|
|
3356
|
+
const description = "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)";
|
|
3357
|
+
const keywords = [
|
|
3358
|
+
"strapi",
|
|
3359
|
+
"ckeditor",
|
|
3360
|
+
"ckeditor5",
|
|
3361
|
+
"ckeditor 5",
|
|
3362
|
+
"wysiwyg",
|
|
3363
|
+
"rich text",
|
|
3364
|
+
"editor"
|
|
3365
|
+
];
|
|
3366
|
+
const author = {
|
|
3367
|
+
name: "nshenderov"
|
|
3368
|
+
};
|
|
3369
|
+
const homepage = "https://market.strapi.io/plugins/@_sh-strapi-plugin-ckeditor";
|
|
3370
|
+
const repository = {
|
|
3371
|
+
type: "git",
|
|
3372
|
+
url: "https://github.com/nshenderov/strapi-plugin-ckeditor.git"
|
|
3373
|
+
};
|
|
3374
|
+
const strapi$1 = {
|
|
3375
|
+
name: "ckeditor5",
|
|
3376
|
+
displayName: "CKEditor 5",
|
|
3377
|
+
description: "Integrates CKEditor 5 into your Strapi project as a fully customizable custom field. (Unofficial integration)",
|
|
3378
|
+
kind: "plugin"
|
|
3379
|
+
};
|
|
3380
|
+
const exports$1 = {
|
|
3381
|
+
"./package.json": "./package.json",
|
|
3382
|
+
"./strapi-admin": {
|
|
3383
|
+
source: "./admin/src/index.js",
|
|
3384
|
+
"import": "./dist/admin/index.mjs",
|
|
3385
|
+
require: "./dist/admin/index.js",
|
|
3386
|
+
"default": "./dist/admin/index.js"
|
|
3387
|
+
},
|
|
3388
|
+
"./strapi-server": {
|
|
3389
|
+
source: "./server/src/index.js",
|
|
3390
|
+
"import": "./dist/server/index.mjs",
|
|
3391
|
+
require: "./dist/server/index.js",
|
|
3392
|
+
"default": "./dist/server/index.js"
|
|
3393
|
+
}
|
|
3394
|
+
};
|
|
3395
|
+
const files = [
|
|
3396
|
+
"dist",
|
|
3397
|
+
"./strapi-server.js"
|
|
3398
|
+
];
|
|
3399
|
+
const scripts = {
|
|
3400
|
+
build: "strapi-plugin build",
|
|
3401
|
+
watch: "strapi-plugin watch",
|
|
3402
|
+
"watch:link": "strapi-plugin watch:link",
|
|
3403
|
+
verify: "strapi-plugin verify",
|
|
3404
|
+
release: "release-it",
|
|
3405
|
+
"release:info": "release-it --changelog"
|
|
3406
|
+
};
|
|
3407
|
+
const dependencies = {
|
|
3408
|
+
ckeditor5: "^43.1.0",
|
|
3409
|
+
"@ckeditor/ckeditor5-react": "^9.1.0",
|
|
3410
|
+
"@strapi/design-system": "^2.0.0-rc.11",
|
|
3411
|
+
"prop-types": "^15.8.1",
|
|
3412
|
+
"sanitize-html": "^2.13.0"
|
|
3413
|
+
};
|
|
3414
|
+
const devDependencies = {
|
|
3415
|
+
"@strapi/strapi": "^5.0.0",
|
|
3416
|
+
"@strapi/sdk-plugin": "^5.2.6",
|
|
3417
|
+
prettier: "^3.3.3",
|
|
3418
|
+
react: "^18.3.1",
|
|
3419
|
+
"react-dom": "^18.3.1",
|
|
3420
|
+
"react-router-dom": "^6.26.2",
|
|
3421
|
+
"styled-components": "^6.1.13",
|
|
3422
|
+
"release-it": "^17.6.0",
|
|
3423
|
+
"@release-it/conventional-changelog": "^8.0.1"
|
|
3424
|
+
};
|
|
3425
|
+
const peerDependencies = {
|
|
3426
|
+
"@strapi/strapi": "^5.0.0",
|
|
3427
|
+
"@strapi/sdk-plugin": "^5.2.6",
|
|
3428
|
+
react: "^18.3.1",
|
|
3429
|
+
"react-dom": "^18.3.1",
|
|
3430
|
+
"react-router-dom": "^6.26.2",
|
|
3431
|
+
"styled-components": "^6.1.13"
|
|
3432
|
+
};
|
|
3433
|
+
const engines = {
|
|
3434
|
+
node: ">=18.0.0 <=20.x.x",
|
|
3435
|
+
npm: ">=6.0.0"
|
|
3436
|
+
};
|
|
3437
|
+
const license = "MIT";
|
|
3438
|
+
const pluginPkg = {
|
|
3439
|
+
name,
|
|
3440
|
+
version,
|
|
3441
|
+
description,
|
|
3442
|
+
"private": false,
|
|
3443
|
+
keywords,
|
|
3444
|
+
author,
|
|
3445
|
+
homepage,
|
|
3446
|
+
repository,
|
|
3447
|
+
strapi: strapi$1,
|
|
3448
|
+
exports: exports$1,
|
|
3449
|
+
files,
|
|
3450
|
+
scripts,
|
|
3451
|
+
dependencies,
|
|
3452
|
+
devDependencies,
|
|
3453
|
+
peerDependencies,
|
|
3454
|
+
engines,
|
|
3455
|
+
license
|
|
3456
|
+
};
|
|
3457
|
+
const PLUGIN_ID = pluginPkg.strapi.name;
|
|
3458
|
+
const insertConfigScript = () => {
|
|
3459
|
+
const url = strapi.backendURL !== "/" ? `${strapi.backendURL}/${PLUGIN_ID}/config/ckeditor` : `/${PLUGIN_ID}/config/ckeditor`;
|
|
3460
|
+
var script = document.createElement("script");
|
|
3461
|
+
script.id = "ckeditor-config";
|
|
3462
|
+
script.src = url;
|
|
3463
|
+
document.body.appendChild(script);
|
|
3464
|
+
};
|
|
3465
|
+
const waitForConfigToInitialize = async () => {
|
|
3466
|
+
return new Promise((resolve) => {
|
|
3467
|
+
(function checkConfigLoaded() {
|
|
3468
|
+
if (typeof globalThis.SH_CKE_CONFIG !== "undefined") {
|
|
3469
|
+
resolve(globalThis.SH_CKE_CONFIG);
|
|
3470
|
+
} else
|
|
3471
|
+
setTimeout(checkConfigLoaded, 5);
|
|
3472
|
+
})();
|
|
3473
|
+
});
|
|
3474
|
+
};
|
|
3475
|
+
const getPluginConfig = async () => {
|
|
3476
|
+
insertConfigScript();
|
|
3477
|
+
const configFromScript = await waitForConfigToInitialize();
|
|
3478
|
+
if (configFromScript) {
|
|
3479
|
+
return configFromScript;
|
|
3480
|
+
}
|
|
3481
|
+
return null;
|
|
3482
|
+
};
|
|
3483
|
+
const mergePresetsTo = (userPresets, basePresets2) => {
|
|
3484
|
+
Object.keys(userPresets).map((presetName) => {
|
|
3485
|
+
if (basePresets2.hasOwnProperty(presetName)) {
|
|
3486
|
+
basePresets2[presetName].field = {
|
|
3487
|
+
...basePresets2[presetName].field,
|
|
3488
|
+
...userPresets[presetName].field
|
|
3489
|
+
};
|
|
3490
|
+
basePresets2[presetName].styles = userPresets[presetName].styles || basePresets2[presetName].styles;
|
|
3491
|
+
basePresets2[presetName].editorConfig = {
|
|
3492
|
+
...basePresets2[presetName].editorConfig,
|
|
3493
|
+
...userPresets[presetName].editorConfig
|
|
3494
|
+
};
|
|
3495
|
+
} else {
|
|
3496
|
+
basePresets2[presetName] = userPresets[presetName];
|
|
3497
|
+
}
|
|
3498
|
+
});
|
|
3499
|
+
};
|
|
3500
|
+
const getPresetsOptions = async () => {
|
|
3501
|
+
const { presets: userPresets, dontMergePresets } = await getPluginConfig() || {};
|
|
3502
|
+
if (!dontMergePresets && userPresets) {
|
|
3503
|
+
mergePresetsTo(userPresets, basePresets);
|
|
3504
|
+
}
|
|
3505
|
+
const options = [
|
|
3506
|
+
...Object.keys(basePresets).map(
|
|
3507
|
+
(presetName) => basePresets[presetName].field
|
|
3508
|
+
)
|
|
3509
|
+
];
|
|
3510
|
+
return options;
|
|
3511
|
+
};
|
|
3512
|
+
const IconBox = styled.styled(designSystem.Flex)`
|
|
3513
|
+
background-color: #f0f0ff; /* primary100 */
|
|
3514
|
+
border: 1px solid #d9d8ff; /* primary200 */
|
|
3515
|
+
svg > path {
|
|
3516
|
+
fill: #4945ff; /* primary600 */
|
|
3517
|
+
}
|
|
3518
|
+
`;
|
|
3519
|
+
const SvgIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3520
|
+
"svg",
|
|
3521
|
+
{
|
|
3522
|
+
width: "68",
|
|
3523
|
+
height: "64",
|
|
3524
|
+
viewBox: "-20 -14 98 94",
|
|
3525
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
3526
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("g", { fill: "none", "fill-rule": "evenodd", children: [
|
|
3527
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3528
|
+
"path",
|
|
3529
|
+
{
|
|
3530
|
+
d: "M43.71 11.025a11.508 11.508 0 0 0-1.213 5.159c0 6.42 5.244 11.625 11.713 11.625.083 0 .167 0 .25-.002v16.282a5.464 5.464 0 0 1-2.756 4.739L30.986 60.7a5.548 5.548 0 0 1-5.512 0L4.756 48.828A5.464 5.464 0 0 1 2 44.089V20.344c0-1.955 1.05-3.76 2.756-4.738L25.474 3.733a5.548 5.548 0 0 1 5.512 0l12.724 7.292z",
|
|
3531
|
+
fill: "#FFF"
|
|
3532
|
+
}
|
|
3533
|
+
),
|
|
3534
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3535
|
+
"path",
|
|
3536
|
+
{
|
|
3537
|
+
d: "M45.684 8.79a12.604 12.604 0 0 0-1.329 5.65c0 7.032 5.744 12.733 12.829 12.733.091 0 .183-.001.274-.003v17.834a5.987 5.987 0 0 1-3.019 5.19L31.747 63.196a6.076 6.076 0 0 1-6.037 0L3.02 50.193A5.984 5.984 0 0 1 0 45.003V18.997c0-2.14 1.15-4.119 3.019-5.19L25.71.804a6.076 6.076 0 0 1 6.037 0L45.684 8.79zm-29.44 11.89c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h25.489c.833 0 1.51-.67 1.51-1.498v-.715c0-.827-.677-1.498-1.51-1.498h-25.49.001zm0 9.227c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h18.479c.833 0 1.509-.67 1.509-1.498v-.715c0-.827-.676-1.498-1.51-1.498H16.244zm0 9.227c-.834 0-1.51.671-1.51 1.498v.715c0 .828.676 1.498 1.51 1.498h25.489c.833 0 1.51-.67 1.51-1.498v-.715c0-.827-.677-1.498-1.51-1.498h-25.49.001zm41.191-14.459c-5.835 0-10.565-4.695-10.565-10.486 0-5.792 4.73-10.487 10.565-10.487C63.27 3.703 68 8.398 68 14.19c0 5.791-4.73 10.486-10.565 10.486v-.001z",
|
|
3538
|
+
fill: "#1EBC61",
|
|
3539
|
+
"fill-rule": "nonzero"
|
|
3540
|
+
}
|
|
3541
|
+
),
|
|
3542
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3543
|
+
"path",
|
|
3544
|
+
{
|
|
3545
|
+
d: "M60.857 15.995c0-.467-.084-.875-.251-1.225a2.547 2.547 0 0 0-.686-.88 2.888 2.888 0 0 0-1.026-.531 4.418 4.418 0 0 0-1.259-.175c-.134 0-.283.006-.447.018-.15.01-.3.034-.446.07l.075-1.4h3.587v-1.8h-5.462l-.214 5.06c.319-.116.682-.21 1.089-.28.406-.071.77-.107 1.088-.107.218 0 .437.021.655.063.218.041.413.114.585.218s.313.244.422.419c.109.175.163.391.163.65 0 .424-.132.745-.396.961a1.434 1.434 0 0 1-.938.325c-.352 0-.656-.1-.912-.3-.256-.2-.43-.453-.523-.762l-1.925.588c.1.35.258.664.472.943.214.279.47.514.767.706.298.191.63.339.995.443.365.104.749.156 1.151.156.437 0 .86-.064 1.272-.193.41-.13.778-.323 1.1-.581a2.8 2.8 0 0 0 .775-.981c.193-.396.29-.864.29-1.405h-.001z",
|
|
3546
|
+
fill: "#FFF",
|
|
3547
|
+
"fill-rule": "nonzero"
|
|
3548
|
+
}
|
|
3549
|
+
)
|
|
3550
|
+
] })
|
|
3551
|
+
}
|
|
3552
|
+
);
|
|
3553
|
+
const CKEditorIcon = () => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3554
|
+
IconBox,
|
|
3555
|
+
{
|
|
3556
|
+
justifyContent: "center",
|
|
3557
|
+
alignItems: "center",
|
|
3558
|
+
width: 7,
|
|
3559
|
+
height: 6,
|
|
3560
|
+
hasRadius: true,
|
|
3561
|
+
"aria-hidden": true,
|
|
3562
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(SvgIcon, {})
|
|
3563
|
+
}
|
|
3564
|
+
);
|
|
3565
|
+
const index = {
|
|
3566
|
+
async register(app) {
|
|
3567
|
+
app.customFields.register({
|
|
3568
|
+
name: "CKEditor",
|
|
3569
|
+
type: "richtext",
|
|
3570
|
+
pluginId: PLUGIN_ID,
|
|
3571
|
+
icon: CKEditorIcon,
|
|
3572
|
+
intlLabel: {
|
|
3573
|
+
id: PLUGIN_ID + ".label",
|
|
3574
|
+
defaultMessage: "CKEditor 5"
|
|
3575
|
+
},
|
|
3576
|
+
intlDescription: {
|
|
3577
|
+
id: PLUGIN_ID + ".description",
|
|
3578
|
+
defaultMessage: "The rich text editor for every use case"
|
|
3579
|
+
},
|
|
3580
|
+
components: {
|
|
3581
|
+
Input: async () => Promise.resolve().then(() => require("./index-B3EDXnAT.js"))
|
|
3582
|
+
},
|
|
3583
|
+
options: {
|
|
3584
|
+
base: [
|
|
3585
|
+
{
|
|
3586
|
+
intlLabel: {
|
|
3587
|
+
id: PLUGIN_ID + ".preset.label",
|
|
3588
|
+
defaultMessage: "Preset"
|
|
3589
|
+
},
|
|
3590
|
+
description: {
|
|
3591
|
+
id: PLUGIN_ID + ".preset.description",
|
|
3592
|
+
defaultMessage: " "
|
|
3593
|
+
},
|
|
3594
|
+
name: "options.preset",
|
|
3595
|
+
type: "select",
|
|
3596
|
+
options: await getPresetsOptions()
|
|
3597
|
+
}
|
|
3598
|
+
],
|
|
3599
|
+
advanced: [
|
|
3600
|
+
{
|
|
3601
|
+
sectionTitle: null,
|
|
3602
|
+
items: [
|
|
3603
|
+
{
|
|
3604
|
+
name: "required",
|
|
3605
|
+
type: "checkbox",
|
|
3606
|
+
intlLabel: {
|
|
3607
|
+
id: PLUGIN_ID + ".required.label",
|
|
3608
|
+
defaultMessage: "Required field"
|
|
3609
|
+
},
|
|
3610
|
+
description: {
|
|
3611
|
+
id: PLUGIN_ID + "required.description",
|
|
3612
|
+
defaultMessage: "You won't be able to create an entry if this field is empty"
|
|
3613
|
+
}
|
|
3614
|
+
},
|
|
3615
|
+
{
|
|
3616
|
+
name: "options.maxLengthCharacters",
|
|
3617
|
+
type: "checkbox-with-number-field",
|
|
3618
|
+
intlLabel: {
|
|
3619
|
+
id: PLUGIN_ID + ".maxLength.label",
|
|
3620
|
+
defaultMessage: "Maximum length (characters)"
|
|
3621
|
+
}
|
|
3622
|
+
}
|
|
3623
|
+
]
|
|
3624
|
+
}
|
|
3625
|
+
],
|
|
3626
|
+
validator: (args) => ({
|
|
3627
|
+
preset: create().required({
|
|
3628
|
+
id: PLUGIN_ID + ".preset.error.required",
|
|
3629
|
+
defaultMessage: "Editor preset is required"
|
|
3630
|
+
})
|
|
3631
|
+
})
|
|
3632
|
+
}
|
|
3633
|
+
});
|
|
3634
|
+
}
|
|
3635
|
+
};
|
|
3636
|
+
exports.basePresets = basePresets;
|
|
3637
|
+
exports.index = index;
|
|
3638
|
+
//# sourceMappingURL=index-DnN7vdyg.js.map
|