inferred-types 0.55.13 → 0.55.14
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/modules/inferred-types/dist/index.cjs +2072 -2067
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +12 -2
- package/modules/inferred-types/dist/index.js +2071 -2067
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +2408 -2401
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +12 -2
- package/modules/runtime/dist/index.js +2407 -2401
- package/modules/runtime/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -5133,2526 +5133,2529 @@ var filter = "NOT READY";
|
|
|
5133
5133
|
function filterEmpty(...val) {
|
|
5134
5134
|
return val.filter((i) => isNotEmpty(i));
|
|
5135
5135
|
}
|
|
5136
|
-
function
|
|
5137
|
-
return
|
|
5138
|
-
return list2.find((i) => {
|
|
5139
|
-
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
5140
|
-
return val === comparator;
|
|
5141
|
-
});
|
|
5142
|
-
};
|
|
5143
|
-
}
|
|
5144
|
-
function getEach(list2, dotPath) {
|
|
5145
|
-
const result2 = list2.map(
|
|
5146
|
-
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
5147
|
-
).filter((i) => !isErrorCondition(i));
|
|
5148
|
-
return result2;
|
|
5149
|
-
}
|
|
5150
|
-
function indexOf(val, index) {
|
|
5151
|
-
const isNegative = isNumber(index) && index < 0;
|
|
5152
|
-
if (isNegative && !Array.isArray(val)) {
|
|
5153
|
-
throw new Error(`The indexOf(val,idx) utility received a negative index value [${index}] but the value being de-references is not an array [${typeof val}]!`);
|
|
5154
|
-
}
|
|
5155
|
-
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
5156
|
-
throw new Error(`The indexOf(val,idx) utility received a negative index of ${index} but the length of the array passed in is only ${val.length}! This is not allowed.`);
|
|
5157
|
-
}
|
|
5158
|
-
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
5159
|
-
return index === null ? val : isNull(idx) ? val : isArray(val) ? Number(idx) in val ? val[Number(idx)] : errCondition("invalid-index", `attempt to index a numeric array with an invalid index: ${Number(idx)}`) : isObject(val) ? String(idx) in val ? val[String(idx)] : errCondition("invalid-index", `attempt to index a dictionary object with an invalid index: ${String(idx)}`) : errCondition("invalid-container-type", `Attempt to use indexOf() on an invalid container type: ${typeof val}`);
|
|
5136
|
+
function isFunction(value) {
|
|
5137
|
+
return typeof value === "function";
|
|
5160
5138
|
}
|
|
5161
|
-
function
|
|
5162
|
-
|
|
5163
|
-
const bIndexable = b.every((i) => isIndexable(i));
|
|
5164
|
-
if (!aIndexable || !bIndexable) {
|
|
5165
|
-
if (!aIndexable) {
|
|
5166
|
-
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
5167
|
-
} else {
|
|
5168
|
-
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
5169
|
-
}
|
|
5170
|
-
}
|
|
5171
|
-
const aMatches = getEach(a, deref);
|
|
5172
|
-
const bMatches = getEach(b, deref);
|
|
5173
|
-
const sharedKeys2 = ifNotNull(
|
|
5174
|
-
deref,
|
|
5175
|
-
(v) => [
|
|
5176
|
-
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
5177
|
-
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
5178
|
-
],
|
|
5179
|
-
() => a.filter((k) => b.includes(k))
|
|
5180
|
-
);
|
|
5181
|
-
return sharedKeys2;
|
|
5139
|
+
function isObject(value) {
|
|
5140
|
+
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
5182
5141
|
}
|
|
5183
|
-
function
|
|
5184
|
-
return
|
|
5142
|
+
function isNarrowableObject(value) {
|
|
5143
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
5185
5144
|
}
|
|
5186
|
-
function
|
|
5187
|
-
return
|
|
5145
|
+
function isEscapeFunction(val) {
|
|
5146
|
+
return isFunction(val) && "escape" in val && val.escape === true;
|
|
5188
5147
|
}
|
|
5189
|
-
function
|
|
5190
|
-
return (
|
|
5191
|
-
const tup = tuple3;
|
|
5192
|
-
return tup.join(joinWith2);
|
|
5193
|
-
};
|
|
5148
|
+
function isOptionalParamFunction(val) {
|
|
5149
|
+
return isFunction(val) && "optionalParams" in val && val.optionalParams === true;
|
|
5194
5150
|
}
|
|
5195
|
-
function
|
|
5196
|
-
return
|
|
5151
|
+
function isApi(api2) {
|
|
5152
|
+
return isObject(api2) && "surface" in api2 && "_kind" in api2 && api2._kind === "api";
|
|
5197
5153
|
}
|
|
5198
|
-
function
|
|
5199
|
-
return
|
|
5200
|
-
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
5201
|
-
);
|
|
5154
|
+
function isApiSurface(val) {
|
|
5155
|
+
return isObject(val) && Object.keys(val).some((k) => isEscapeFunction(val[k]));
|
|
5202
5156
|
}
|
|
5203
|
-
function
|
|
5204
|
-
return
|
|
5157
|
+
function isDate(val) {
|
|
5158
|
+
return val instanceof Date;
|
|
5205
5159
|
}
|
|
5206
|
-
function
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
5210
|
-
try {
|
|
5211
|
-
list2 = list2.slice(1);
|
|
5212
|
-
} catch {
|
|
5213
|
-
}
|
|
5214
|
-
} else {
|
|
5215
|
-
rtn = void 0;
|
|
5160
|
+
function isIsoDateTime(val) {
|
|
5161
|
+
if (!isString(val)) {
|
|
5162
|
+
return false;
|
|
5216
5163
|
}
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
return list2.slice(start2, end);
|
|
5221
|
-
}
|
|
5222
|
-
function unique(...values) {
|
|
5223
|
-
const u = [];
|
|
5224
|
-
for (const i of values.flat()) {
|
|
5225
|
-
if (!u.includes(i)) {
|
|
5226
|
-
u.push(i);
|
|
5227
|
-
}
|
|
5164
|
+
const ISO_DATETIME_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
5165
|
+
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
5166
|
+
return false;
|
|
5228
5167
|
}
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5233
|
-
|
|
5234
|
-
|
|
5235
|
-
|
|
5236
|
-
|
|
5168
|
+
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
5169
|
+
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
5170
|
+
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
5171
|
+
return false;
|
|
5172
|
+
}
|
|
5173
|
+
if (month < 1 || month > 12) {
|
|
5174
|
+
return false;
|
|
5175
|
+
}
|
|
5176
|
+
;
|
|
5177
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
5178
|
+
if (day < 1 || day > daysInMonth) {
|
|
5179
|
+
return false;
|
|
5180
|
+
}
|
|
5181
|
+
;
|
|
5182
|
+
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
5183
|
+
if (tzMatch) {
|
|
5184
|
+
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
5185
|
+
const numHours = Number.parseInt(tzHours, 10);
|
|
5186
|
+
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
5187
|
+
if (numHours > 14 || numMinutes > 59) {
|
|
5188
|
+
return false;
|
|
5237
5189
|
}
|
|
5238
|
-
|
|
5239
|
-
|
|
5240
|
-
}
|
|
5241
|
-
|
|
5242
|
-
return
|
|
5190
|
+
if (numHours === 14 && numMinutes > 0) {
|
|
5191
|
+
return false;
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
return true;
|
|
5243
5195
|
}
|
|
5244
|
-
function
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
(
|
|
5248
|
-
|
|
5249
|
-
|
|
5196
|
+
function isIsoExplicitDate(val) {
|
|
5197
|
+
if (isString(val)) {
|
|
5198
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
5199
|
+
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
5200
|
+
} else {
|
|
5201
|
+
return false;
|
|
5202
|
+
}
|
|
5250
5203
|
}
|
|
5251
|
-
function
|
|
5252
|
-
|
|
5204
|
+
function isIsoImplicitDate(val) {
|
|
5205
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
5206
|
+
const year = Number(val.slice(0, 4));
|
|
5207
|
+
const month = Number(val.slice(4, 6));
|
|
5208
|
+
const date = Number(val.slice(6, 8));
|
|
5209
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
5210
|
+
} else {
|
|
5211
|
+
return false;
|
|
5212
|
+
}
|
|
5253
5213
|
}
|
|
5254
|
-
function
|
|
5255
|
-
|
|
5214
|
+
function isIsoDate(val) {
|
|
5215
|
+
if (isString(val)) {
|
|
5216
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
5217
|
+
} else {
|
|
5218
|
+
return false;
|
|
5219
|
+
}
|
|
5256
5220
|
}
|
|
5257
|
-
function
|
|
5258
|
-
|
|
5221
|
+
function isIsoExplicitTime(val) {
|
|
5222
|
+
if (isString(val)) {
|
|
5223
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
5224
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5225
|
+
} else {
|
|
5226
|
+
return false;
|
|
5227
|
+
}
|
|
5259
5228
|
}
|
|
5260
|
-
function
|
|
5261
|
-
|
|
5262
|
-
|
|
5263
|
-
|
|
5264
|
-
|
|
5229
|
+
function isIsoImplicitTime(val) {
|
|
5230
|
+
if (isString(val)) {
|
|
5231
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
5232
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5233
|
+
} else {
|
|
5234
|
+
return false;
|
|
5235
|
+
}
|
|
5265
5236
|
}
|
|
5266
|
-
function
|
|
5267
|
-
|
|
5268
|
-
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
5237
|
+
function isIsoTime(val) {
|
|
5238
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
5269
5239
|
}
|
|
5270
|
-
function
|
|
5271
|
-
|
|
5272
|
-
let result2 = input;
|
|
5273
|
-
result2 = ensureLeading(result2, prefix);
|
|
5274
|
-
result2 = ensureTrailing(result2, postfix);
|
|
5275
|
-
return result2;
|
|
5276
|
-
};
|
|
5277
|
-
return fn2;
|
|
5240
|
+
function isIsoYear(val) {
|
|
5241
|
+
return !!(isString(val) && val.length === 4 && isNumber(Number(val)) && Number(val) >= 0 && Number(val) <= 9999);
|
|
5278
5242
|
}
|
|
5279
|
-
function
|
|
5280
|
-
return (
|
|
5281
|
-
//
|
|
5282
|
-
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
5283
|
-
);
|
|
5243
|
+
function isLuxonDateTime(val) {
|
|
5244
|
+
return isObject(val) && typeof val === "object" && val !== null && "isValid" in val && "invalidReason" in val && "invalidExplanation" in val && "toISO" in val && "toFormat" in val && "toMillis" in val && "year" in val && "month" in val && "day" in val && "hour" in val && "minute" in val && "second" in val && "millisecond" in val && typeof val.isValid === "boolean" && typeof val.toISO === "function";
|
|
5284
5245
|
}
|
|
5285
|
-
function
|
|
5286
|
-
if (
|
|
5287
|
-
|
|
5288
|
-
return [t, st];
|
|
5289
|
-
} else {
|
|
5290
|
-
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
5291
|
-
err.name = "InvalidTypeSubtype";
|
|
5292
|
-
throw err;
|
|
5246
|
+
function isMoment(val) {
|
|
5247
|
+
if (val instanceof Date) {
|
|
5248
|
+
return false;
|
|
5293
5249
|
}
|
|
5250
|
+
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
5294
5251
|
}
|
|
5295
|
-
function
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
if (
|
|
5300
|
-
|
|
5252
|
+
function isThisMonth(val) {
|
|
5253
|
+
const now = /* @__PURE__ */ new Date();
|
|
5254
|
+
const currentYear = now.getFullYear();
|
|
5255
|
+
const currentMonth = now.getMonth() + 1;
|
|
5256
|
+
if (val instanceof Date) {
|
|
5257
|
+
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
5301
5258
|
}
|
|
5302
|
-
|
|
5303
|
-
|
|
5304
|
-
|
|
5305
|
-
if (ch.length !== 1) {
|
|
5306
|
-
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5259
|
+
if (isMoment(val)) {
|
|
5260
|
+
const monthValue = val.month();
|
|
5261
|
+
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
5307
5262
|
}
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
function parseTemplate(template) {
|
|
5311
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
5312
|
-
let lastIndex = 0;
|
|
5313
|
-
let match;
|
|
5314
|
-
const segments = [];
|
|
5315
|
-
while (match = pattern.exec(template)) {
|
|
5316
|
-
const [fullMatch, varName, asType2] = match;
|
|
5317
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
5318
|
-
if (staticPart) {
|
|
5319
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
5320
|
-
}
|
|
5321
|
-
segments.push({
|
|
5322
|
-
dynamic: true,
|
|
5323
|
-
varName,
|
|
5324
|
-
type: asType2 ? asType2 : "string"
|
|
5325
|
-
});
|
|
5326
|
-
lastIndex = match.index + fullMatch.length;
|
|
5263
|
+
if (isLuxonDateTime(val)) {
|
|
5264
|
+
return val.year === currentYear && val.month === currentMonth;
|
|
5327
5265
|
}
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
|
|
5266
|
+
if (typeof val === "string") {
|
|
5267
|
+
const isoDateRegex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[-+][01]\d:[0-5]\d))?$/;
|
|
5268
|
+
if (!isoDateRegex.test(val)) {
|
|
5269
|
+
return false;
|
|
5270
|
+
}
|
|
5271
|
+
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
5272
|
+
if (dateMatch) {
|
|
5273
|
+
const year = Number.parseInt(dateMatch[1], 10);
|
|
5274
|
+
const month = Number.parseInt(dateMatch[2], 10);
|
|
5275
|
+
return year === currentYear && month === currentMonth;
|
|
5276
|
+
}
|
|
5331
5277
|
}
|
|
5332
|
-
return
|
|
5278
|
+
return false;
|
|
5333
5279
|
}
|
|
5334
|
-
function
|
|
5335
|
-
|
|
5280
|
+
function isThisWeek(date) {
|
|
5281
|
+
const targetDate = asDate(date);
|
|
5282
|
+
if (!targetDate) {
|
|
5283
|
+
return false;
|
|
5284
|
+
}
|
|
5285
|
+
const currentWeek = getWeekNumber();
|
|
5286
|
+
const targetWeek = getWeekNumber(targetDate);
|
|
5287
|
+
return currentWeek === targetWeek;
|
|
5336
5288
|
}
|
|
5337
|
-
function
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
5289
|
+
function isThisYear(val) {
|
|
5290
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
5291
|
+
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
5292
|
+
const date = asDate(val);
|
|
5293
|
+
if (date) {
|
|
5294
|
+
return date.getFullYear() === currentYear;
|
|
5342
5295
|
} else {
|
|
5343
|
-
|
|
5344
|
-
case "string":
|
|
5345
|
-
regexStr += "(.*?)";
|
|
5346
|
-
break;
|
|
5347
|
-
case "number":
|
|
5348
|
-
regexStr += "(\\d+)";
|
|
5349
|
-
break;
|
|
5350
|
-
case "boolean":
|
|
5351
|
-
regexStr += "(true|false)";
|
|
5352
|
-
break;
|
|
5353
|
-
}
|
|
5296
|
+
return false;
|
|
5354
5297
|
}
|
|
5355
5298
|
}
|
|
5356
|
-
|
|
5357
|
-
return new RegExp(regexStr);
|
|
5299
|
+
return false;
|
|
5358
5300
|
}
|
|
5359
|
-
function
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
|
|
5366
|
-
|
|
5301
|
+
function isToday(test) {
|
|
5302
|
+
if (isString(test)) {
|
|
5303
|
+
const justDate = stripAfter(test, "T");
|
|
5304
|
+
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
5305
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
5306
|
+
return stripAfter(test.toISOString(), "T") === getToday();
|
|
5307
|
+
} else if (isLuxonDateTime(test)) {
|
|
5308
|
+
return stripAfter(test.toISO(), "T") === getToday();
|
|
5367
5309
|
}
|
|
5310
|
+
return false;
|
|
5368
5311
|
}
|
|
5369
|
-
function
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5373
|
-
if (
|
|
5374
|
-
return
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
for (const seg of segments) {
|
|
5378
|
-
if (seg.dynamic) {
|
|
5379
|
-
const rawVal = match[captureIndex++];
|
|
5380
|
-
if (rawVal === void 0)
|
|
5381
|
-
return false;
|
|
5382
|
-
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
5383
|
-
}
|
|
5312
|
+
function isTomorrow(test) {
|
|
5313
|
+
if (isString(test)) {
|
|
5314
|
+
const justDate = stripAfter(test, "T");
|
|
5315
|
+
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
5316
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
5317
|
+
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
5318
|
+
} else if (isLuxonDateTime(test)) {
|
|
5319
|
+
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
5384
5320
|
}
|
|
5385
|
-
return
|
|
5321
|
+
return false;
|
|
5386
5322
|
}
|
|
5387
|
-
function
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5323
|
+
function isYesterday(test) {
|
|
5324
|
+
if (isString(test)) {
|
|
5325
|
+
const justDate = stripAfter(test, "T");
|
|
5326
|
+
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
5327
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
5328
|
+
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
5329
|
+
} else if (isLuxonDateTime(test)) {
|
|
5330
|
+
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
5331
|
+
}
|
|
5332
|
+
return false;
|
|
5391
5333
|
}
|
|
5392
|
-
function
|
|
5393
|
-
|
|
5334
|
+
function isVisa(val) {
|
|
5335
|
+
if (isString(val) && val.startsWith("4")) {
|
|
5336
|
+
const parts = val.split(" ");
|
|
5337
|
+
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
5338
|
+
}
|
|
5339
|
+
return false;
|
|
5394
5340
|
}
|
|
5395
|
-
function
|
|
5396
|
-
|
|
5341
|
+
function isMastercard(val) {
|
|
5342
|
+
if (isString(val) && val.startsWith("4")) {
|
|
5343
|
+
const parts = val.split(" ");
|
|
5344
|
+
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
|
|
5345
|
+
}
|
|
5346
|
+
return false;
|
|
5397
5347
|
}
|
|
5398
|
-
function
|
|
5399
|
-
return
|
|
5348
|
+
function isVisaMastercard(val) {
|
|
5349
|
+
return isVisa(val) || isMastercard(val);
|
|
5400
5350
|
}
|
|
5401
|
-
function
|
|
5402
|
-
|
|
5351
|
+
function isAmericanExpress(val) {
|
|
5352
|
+
if (isString(val)) {
|
|
5353
|
+
const parts = val.split(" ");
|
|
5354
|
+
return parts.length === 3 && parts.every(
|
|
5355
|
+
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
5356
|
+
);
|
|
5357
|
+
}
|
|
5358
|
+
return false;
|
|
5403
5359
|
}
|
|
5404
|
-
function
|
|
5405
|
-
return
|
|
5360
|
+
function isCreditCard(val) {
|
|
5361
|
+
return isVisaMastercard(val) || isAmericanExpress(val);
|
|
5406
5362
|
}
|
|
5407
|
-
function
|
|
5408
|
-
|
|
5363
|
+
function cardType(cardNumber) {
|
|
5364
|
+
const cleanedNumber = String(cardNumber).replace(/\D/g, "");
|
|
5365
|
+
const length = cleanedNumber.length;
|
|
5366
|
+
if (!isValidLength(length)) {
|
|
5367
|
+
return "invalid";
|
|
5368
|
+
}
|
|
5369
|
+
if (!luhnCheck(cleanedNumber)) {
|
|
5370
|
+
return "invalid";
|
|
5371
|
+
}
|
|
5372
|
+
const cardTypes = [
|
|
5373
|
+
{ name: "Visa", lengths: [16], prefixes: [/^4/] },
|
|
5374
|
+
{ name: "Mastercard", lengths: [16], prefixes: [/^(51|52|53|54|55|222[1-9]|22[3-9]\d|2[3-6]\d{2}|27[01]\d|2720)/] },
|
|
5375
|
+
{ name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
|
|
5376
|
+
{ name: "Discover", lengths: [16], prefixes: [/^(6011|622(12[6-9]|1[3-9]\d|2[0-4]\d|25\d|6[4-9]|7[0-4]|8[0-4]|9\d)|64[4-9]|65)/] },
|
|
5377
|
+
{ name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
|
|
5378
|
+
{ name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
|
|
5379
|
+
{ name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
|
|
5380
|
+
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
5381
|
+
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
5382
|
+
];
|
|
5383
|
+
for (const type of cardTypes) {
|
|
5384
|
+
if (type.lengths.includes(length)) {
|
|
5385
|
+
for (const prefix of type.prefixes) {
|
|
5386
|
+
if (prefix.test(cleanedNumber)) {
|
|
5387
|
+
return type.name;
|
|
5388
|
+
}
|
|
5389
|
+
}
|
|
5390
|
+
}
|
|
5391
|
+
}
|
|
5392
|
+
return "invalid";
|
|
5409
5393
|
}
|
|
5410
|
-
function
|
|
5411
|
-
|
|
5394
|
+
function isValidLength(length) {
|
|
5395
|
+
const validLengths = [13, 14, 15, 16, 17, 18, 19];
|
|
5396
|
+
return validLengths.includes(length);
|
|
5412
5397
|
}
|
|
5413
|
-
function
|
|
5414
|
-
|
|
5415
|
-
|
|
5416
|
-
|
|
5417
|
-
|
|
5418
|
-
|
|
5398
|
+
function luhnCheck(num) {
|
|
5399
|
+
let sum = 0;
|
|
5400
|
+
let double = false;
|
|
5401
|
+
for (let i = num.length - 1; i >= 0; i--) {
|
|
5402
|
+
let n = Number.parseInt(num.charAt(i), 10);
|
|
5403
|
+
if (double) {
|
|
5404
|
+
n *= 2;
|
|
5405
|
+
if (n > 9) {
|
|
5406
|
+
n -= 9;
|
|
5407
|
+
}
|
|
5408
|
+
}
|
|
5409
|
+
sum += n;
|
|
5410
|
+
double = !double;
|
|
5411
|
+
}
|
|
5412
|
+
return sum % 10 === 0;
|
|
5419
5413
|
}
|
|
5420
|
-
|
|
5421
|
-
|
|
5422
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
5423
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
5424
|
-
...NUMERIC_CHAR2
|
|
5425
|
-
) : "";
|
|
5414
|
+
function isString(value) {
|
|
5415
|
+
return typeof value === "string";
|
|
5426
5416
|
}
|
|
5427
|
-
function
|
|
5428
|
-
const
|
|
5429
|
-
return
|
|
5430
|
-
phone.trim(),
|
|
5431
|
-
"+",
|
|
5432
|
-
"00"
|
|
5433
|
-
), countryCode).trim() : phone.trim();
|
|
5417
|
+
function isIso3166Alpha2(val) {
|
|
5418
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
5419
|
+
return isString(val) && codes.includes(val);
|
|
5434
5420
|
}
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
|
|
5438
|
-
case "is":
|
|
5439
|
-
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
5440
|
-
case "singular-noun":
|
|
5441
|
-
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
5442
|
-
case "f":
|
|
5443
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
5444
|
-
case "y":
|
|
5445
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
5446
|
-
default:
|
|
5447
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
5448
|
-
}
|
|
5421
|
+
function isCountryCode2(val) {
|
|
5422
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
5423
|
+
return isString(val) && codes.includes(val);
|
|
5449
5424
|
}
|
|
5450
|
-
function
|
|
5451
|
-
const
|
|
5452
|
-
|
|
5453
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
5454
|
-
return `${result2}${right}`;
|
|
5455
|
-
}
|
|
5456
|
-
function retainAfter(content, ...find2) {
|
|
5457
|
-
const idx = Math.min(
|
|
5458
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
5459
|
-
);
|
|
5460
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
5461
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
5462
|
-
if (min !== len) {
|
|
5463
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
5464
|
-
len = min;
|
|
5465
|
-
}
|
|
5466
|
-
}
|
|
5467
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
5425
|
+
function isIso3166Alpha3(val) {
|
|
5426
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
5427
|
+
return isString(val) && codes.includes(val);
|
|
5468
5428
|
}
|
|
5469
|
-
function
|
|
5470
|
-
const
|
|
5471
|
-
|
|
5472
|
-
);
|
|
5473
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
5429
|
+
function isCountryCode3(val) {
|
|
5430
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
5431
|
+
return isString(val) && codes.includes(val);
|
|
5474
5432
|
}
|
|
5475
|
-
function
|
|
5476
|
-
const
|
|
5477
|
-
return
|
|
5433
|
+
function isIso3166CountryCode(val) {
|
|
5434
|
+
const codes = ISO3166_12.map((i) => i.countryCode);
|
|
5435
|
+
return isString(val) && codes.includes(val);
|
|
5478
5436
|
}
|
|
5479
|
-
function
|
|
5480
|
-
|
|
5481
|
-
let idx = 0;
|
|
5482
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
5483
|
-
idx = idx + 1;
|
|
5484
|
-
}
|
|
5485
|
-
return idx === 0 ? "" : content.slice(0, idx);
|
|
5437
|
+
function isCountryAbbrev(val) {
|
|
5438
|
+
return isCountryCode2(val) || isCountryCode3(val);
|
|
5486
5439
|
}
|
|
5487
|
-
function
|
|
5488
|
-
const
|
|
5489
|
-
|
|
5490
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
5491
|
-
idx = idx + 1;
|
|
5492
|
-
}
|
|
5493
|
-
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
5440
|
+
function isIso3166CountryName(val) {
|
|
5441
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
5442
|
+
return isString(val) && codes.includes(val);
|
|
5494
5443
|
}
|
|
5495
|
-
function
|
|
5496
|
-
const
|
|
5497
|
-
return
|
|
5444
|
+
function isCountryName(val) {
|
|
5445
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
5446
|
+
return isString(val) && codes.includes(val);
|
|
5498
5447
|
}
|
|
5499
|
-
|
|
5500
|
-
|
|
5501
|
-
|
|
5502
|
-
|
|
5503
|
-
...WHITESPACE_CHARS2
|
|
5504
|
-
);
|
|
5448
|
+
var ABBREV = US_STATE_LOOKUP2.map((i) => i.abbrev);
|
|
5449
|
+
var NAME = US_STATE_LOOKUP2.map((i) => i.name);
|
|
5450
|
+
function isUsStateAbbreviation(val) {
|
|
5451
|
+
return isString(val) && ABBREV.includes(val);
|
|
5505
5452
|
}
|
|
5506
|
-
function
|
|
5507
|
-
return
|
|
5453
|
+
function isUsStateName(val) {
|
|
5454
|
+
return isString(val) && NAME.includes(val);
|
|
5508
5455
|
}
|
|
5509
|
-
function
|
|
5510
|
-
|
|
5456
|
+
function isNumericString(value) {
|
|
5457
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
5458
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
5511
5459
|
}
|
|
5512
|
-
function
|
|
5513
|
-
|
|
5460
|
+
function isNumberLike(value) {
|
|
5461
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
5462
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
5514
5463
|
}
|
|
5515
|
-
function
|
|
5516
|
-
|
|
5517
|
-
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
5464
|
+
function isNumber(value) {
|
|
5465
|
+
return typeof value === "number";
|
|
5518
5466
|
}
|
|
5519
|
-
function
|
|
5520
|
-
if (
|
|
5521
|
-
return
|
|
5522
|
-
}
|
|
5523
|
-
let output = String(content);
|
|
5524
|
-
for (const s of strip2) {
|
|
5525
|
-
if (output.startsWith(String(s))) {
|
|
5526
|
-
output = output.slice(String(s).length);
|
|
5527
|
-
}
|
|
5467
|
+
function isZipCode5(val) {
|
|
5468
|
+
if (isNumber(val)) {
|
|
5469
|
+
return isZipCode5(`${val}`);
|
|
5528
5470
|
}
|
|
5529
|
-
return
|
|
5530
|
-
}
|
|
5531
|
-
function stripSurround(...chars) {
|
|
5532
|
-
return (input) => {
|
|
5533
|
-
let output = String(input);
|
|
5534
|
-
for (const s of chars) {
|
|
5535
|
-
if (output.startsWith(String(s))) {
|
|
5536
|
-
output = output.slice(String(s).length);
|
|
5537
|
-
}
|
|
5538
|
-
if (output.endsWith(String(s))) {
|
|
5539
|
-
output = output.slice(0, -1 * String(s).length);
|
|
5540
|
-
}
|
|
5541
|
-
}
|
|
5542
|
-
return isNumber(input) ? Number(output) : output;
|
|
5543
|
-
};
|
|
5471
|
+
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
5544
5472
|
}
|
|
5545
|
-
function
|
|
5546
|
-
if (
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
for (const s of strip2) {
|
|
5551
|
-
if (output.endsWith(String(s))) {
|
|
5552
|
-
output = output.slice(0, -1 * String(s).length);
|
|
5553
|
-
}
|
|
5473
|
+
function isZipPlus4(val) {
|
|
5474
|
+
if (isString(val)) {
|
|
5475
|
+
const first = retainWhile(val.trim(), ...NUMERIC_CHAR2);
|
|
5476
|
+
const next = stripChars(val.trim().replace(first, "").trim(), "-");
|
|
5477
|
+
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
5554
5478
|
}
|
|
5555
|
-
return
|
|
5479
|
+
return false;
|
|
5556
5480
|
}
|
|
5557
|
-
function
|
|
5558
|
-
|
|
5559
|
-
return content.slice(stopIdx);
|
|
5481
|
+
function isZipCode(val) {
|
|
5482
|
+
return isZipCode5(val) || isZipPlus4(val);
|
|
5560
5483
|
}
|
|
5561
|
-
function
|
|
5562
|
-
|
|
5563
|
-
|
|
5484
|
+
function isSpecificConstant(kind) {
|
|
5485
|
+
return (value) => {
|
|
5486
|
+
return !!(isConstant(value) && value.kind === kind);
|
|
5487
|
+
};
|
|
5564
5488
|
}
|
|
5565
|
-
function
|
|
5566
|
-
|
|
5489
|
+
function hasDefaultValue(value) {
|
|
5490
|
+
const noDefault = isSpecificConstant("no-default-value");
|
|
5491
|
+
return !noDefault(value);
|
|
5567
5492
|
}
|
|
5568
|
-
function
|
|
5569
|
-
const
|
|
5570
|
-
return
|
|
5493
|
+
function hasIndexOf(value, idx) {
|
|
5494
|
+
const result2 = isObject(value) ? String(idx) in value : Array.isArray(value) ? Number(idx) in value : false;
|
|
5495
|
+
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
5571
5496
|
}
|
|
5572
|
-
function
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
5578
|
-
return camel;
|
|
5497
|
+
function hasKeys(...props) {
|
|
5498
|
+
return (val) => {
|
|
5499
|
+
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
5500
|
+
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
5501
|
+
};
|
|
5579
5502
|
}
|
|
5580
|
-
function
|
|
5581
|
-
|
|
5582
|
-
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
5583
|
-
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
5584
|
-
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
5585
|
-
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
5586
|
-
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
5587
|
-
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
5588
|
-
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
5589
|
-
replaceTrailingDash(
|
|
5590
|
-
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
5591
|
-
)
|
|
5592
|
-
)}${postWhite}`);
|
|
5503
|
+
function asChars(str) {
|
|
5504
|
+
return str.split("");
|
|
5593
5505
|
}
|
|
5594
|
-
function
|
|
5595
|
-
return
|
|
5506
|
+
function asRecord(obj) {
|
|
5507
|
+
return obj;
|
|
5596
5508
|
}
|
|
5597
|
-
function
|
|
5598
|
-
|
|
5599
|
-
input
|
|
5600
|
-
);
|
|
5601
|
-
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
5602
|
-
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
5603
|
-
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
5604
|
-
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
5605
|
-
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
5606
|
-
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
5607
|
-
)}${preserveWhitespace ? postWhite : ""}`;
|
|
5608
|
-
return pascal;
|
|
5509
|
+
function asString(value) {
|
|
5510
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
5609
5511
|
}
|
|
5610
|
-
function
|
|
5611
|
-
const
|
|
5612
|
-
|
|
5613
|
-
|
|
5614
|
-
|
|
5615
|
-
|
|
5616
|
-
|
|
5617
|
-
|
|
5618
|
-
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
5512
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
5513
|
+
const tuple3 = [];
|
|
5514
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
5515
|
+
tuple3.push(
|
|
5516
|
+
format === "string-numeric-tuple" ? isNumberLike(v) ? Number(v) : v : format === "json-tuple" ? isNumberLike(v) ? Number(v) : v === "true" ? true : v === "false" ? false : `"${v}"` : format === "string-tuple" ? `${v}` : Never2
|
|
5517
|
+
);
|
|
5518
|
+
});
|
|
5519
|
+
return tuple3;
|
|
5619
5520
|
}
|
|
5620
|
-
function
|
|
5621
|
-
|
|
5521
|
+
function fromKeyValue(kvs) {
|
|
5522
|
+
const obj = {};
|
|
5523
|
+
for (const kv of kvs) {
|
|
5524
|
+
obj[kv.key] = kv.value;
|
|
5525
|
+
}
|
|
5526
|
+
return obj;
|
|
5622
5527
|
}
|
|
5623
|
-
function
|
|
5624
|
-
return
|
|
5528
|
+
function intersect(value, _intersectedWith) {
|
|
5529
|
+
return value;
|
|
5625
5530
|
}
|
|
5626
|
-
function
|
|
5627
|
-
return
|
|
5531
|
+
function ip6GroupExpansion(ip) {
|
|
5532
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
5628
5533
|
}
|
|
5629
|
-
function
|
|
5630
|
-
return
|
|
5534
|
+
function jsonValue(val) {
|
|
5535
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
5631
5536
|
}
|
|
5632
|
-
function
|
|
5633
|
-
return
|
|
5537
|
+
function jsonValues(...val) {
|
|
5538
|
+
return val.map((i) => jsonValue(i));
|
|
5634
5539
|
}
|
|
5635
|
-
function
|
|
5636
|
-
|
|
5540
|
+
function lookupAlpha2Code(code, prop) {
|
|
5541
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
5542
|
+
return found ? found[prop] : void 0;
|
|
5637
5543
|
}
|
|
5638
|
-
function
|
|
5639
|
-
|
|
5544
|
+
function lookupAlpha3Code(code, prop) {
|
|
5545
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
5546
|
+
return found ? found[prop] : void 0;
|
|
5640
5547
|
}
|
|
5641
|
-
function
|
|
5642
|
-
const
|
|
5643
|
-
return
|
|
5548
|
+
function lookupName(name, prop) {
|
|
5549
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
5550
|
+
return found ? found[prop] : void 0;
|
|
5644
5551
|
}
|
|
5645
|
-
function
|
|
5646
|
-
|
|
5647
|
-
|
|
5552
|
+
function lookupNumericCode(code, prop) {
|
|
5553
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
5554
|
+
if (num.length === 1) {
|
|
5555
|
+
num = `00${num}`;
|
|
5556
|
+
} else if (num.length === 2) {
|
|
5557
|
+
num = `0${num}`;
|
|
5558
|
+
}
|
|
5559
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
5560
|
+
return found ? found[prop] : void 0;
|
|
5648
5561
|
}
|
|
5649
|
-
function
|
|
5650
|
-
|
|
5562
|
+
function lookupCountryName(code) {
|
|
5563
|
+
const uc = uppercase(code);
|
|
5564
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
5651
5565
|
}
|
|
5652
|
-
|
|
5653
|
-
|
|
5654
|
-
return
|
|
5566
|
+
function lookupCountryAlpha2(code) {
|
|
5567
|
+
const uc = uppercase(code);
|
|
5568
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
5655
5569
|
}
|
|
5656
|
-
function
|
|
5657
|
-
|
|
5570
|
+
function lookupCountryAlpha3(token) {
|
|
5571
|
+
const uc = uppercase(token);
|
|
5572
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
5658
5573
|
}
|
|
5659
|
-
|
|
5660
|
-
|
|
5661
|
-
|
|
5662
|
-
return proto;
|
|
5574
|
+
function lookupCountryCode(token) {
|
|
5575
|
+
const uc = uppercase(token);
|
|
5576
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
5663
5577
|
}
|
|
5664
|
-
function
|
|
5665
|
-
|
|
5578
|
+
function asMapper(fn2) {
|
|
5579
|
+
const props = {
|
|
5580
|
+
kind: "Mapper",
|
|
5581
|
+
map: (from) => {
|
|
5582
|
+
return from.map(fn2);
|
|
5583
|
+
}
|
|
5584
|
+
};
|
|
5585
|
+
return createFnWithPropsExplicit(fn2, props);
|
|
5666
5586
|
}
|
|
5667
|
-
function
|
|
5668
|
-
|
|
5669
|
-
|
|
5587
|
+
function createObjectMap() {
|
|
5588
|
+
return (map2) => {
|
|
5589
|
+
const fn2 = (input) => {
|
|
5590
|
+
return Object.keys(map2).reduce(
|
|
5591
|
+
(acc, key) => {
|
|
5592
|
+
const val = map2[key];
|
|
5593
|
+
return {
|
|
5594
|
+
...acc,
|
|
5595
|
+
[key]: isFunction(val) ? val(input) : val
|
|
5596
|
+
};
|
|
5597
|
+
},
|
|
5598
|
+
{}
|
|
5599
|
+
);
|
|
5600
|
+
};
|
|
5601
|
+
return fn2;
|
|
5602
|
+
};
|
|
5670
5603
|
}
|
|
5671
|
-
function
|
|
5672
|
-
return
|
|
5673
|
-
|
|
5674
|
-
|
|
5604
|
+
function createMapper() {
|
|
5605
|
+
return (fn2) => {
|
|
5606
|
+
return asMapper(fn2);
|
|
5607
|
+
};
|
|
5675
5608
|
}
|
|
5676
|
-
function
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5680
|
-
|
|
5681
|
-
stripBefore(qp, `${specific}=`),
|
|
5682
|
-
"&"
|
|
5683
|
-
).replace(/\+/g, "%20")
|
|
5684
|
-
) : void 0;
|
|
5685
|
-
}
|
|
5686
|
-
return qp === "" ? qp : `?${qp}`;
|
|
5609
|
+
function mergeObjects(defVal, override) {
|
|
5610
|
+
return {
|
|
5611
|
+
...defVal,
|
|
5612
|
+
...override
|
|
5613
|
+
};
|
|
5687
5614
|
}
|
|
5688
|
-
function
|
|
5689
|
-
|
|
5690
|
-
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
5615
|
+
function isUndefined(value) {
|
|
5616
|
+
return typeof value === "undefined";
|
|
5691
5617
|
}
|
|
5692
|
-
function
|
|
5693
|
-
|
|
5694
|
-
const match = url.match(re);
|
|
5695
|
-
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
5618
|
+
function mergeScalars(a, b) {
|
|
5619
|
+
return isUndefined(b) ? a : b;
|
|
5696
5620
|
}
|
|
5697
|
-
function
|
|
5698
|
-
|
|
5699
|
-
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
5621
|
+
function mergeTuples(a, b) {
|
|
5622
|
+
return b.length > a.length ? b.map((v, idx) => v !== void 0 ? v : a[idx]) : [...b, ...a.slice(b.length)].map((v, idx) => v !== void 0 ? v : a[idx]);
|
|
5700
5623
|
}
|
|
5701
|
-
function
|
|
5702
|
-
|
|
5703
|
-
const remaining = stripAfter(url, path);
|
|
5704
|
-
return remaining;
|
|
5624
|
+
function never(val) {
|
|
5625
|
+
return val;
|
|
5705
5626
|
}
|
|
5706
|
-
function
|
|
5707
|
-
|
|
5708
|
-
const qp = getUrlQueryParams(url);
|
|
5709
|
-
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
5710
|
-
const segmentTypes = [
|
|
5711
|
-
"string",
|
|
5712
|
-
"number",
|
|
5713
|
-
"boolean",
|
|
5714
|
-
"Opt<string>",
|
|
5715
|
-
"Opt<number>",
|
|
5716
|
-
"Opt<boolean>"
|
|
5717
|
-
];
|
|
5718
|
-
const pathVars = {};
|
|
5719
|
-
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
5720
|
-
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
5721
|
-
const findPathNamed = infer(`<{{infer name}}>`);
|
|
5722
|
-
for (const part of pathParts) {
|
|
5723
|
-
const union4 = findPathUnion(part);
|
|
5724
|
-
const typed = findPathTyped(part);
|
|
5725
|
-
const named = findPathNamed(part);
|
|
5726
|
-
if (union4) {
|
|
5727
|
-
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
5728
|
-
pathVars[union4.name] = `string(${union4.union})`;
|
|
5729
|
-
}
|
|
5730
|
-
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
5731
|
-
pathVars[typed.name] = typed.type;
|
|
5732
|
-
} else if (named && isVariable(named.name)) {
|
|
5733
|
-
pathVars[named.name] = "string";
|
|
5734
|
-
}
|
|
5735
|
-
}
|
|
5736
|
-
const qpVars = {};
|
|
5737
|
-
const qpParts = stripLeading(qp, "?").split("&");
|
|
5738
|
-
for (const p of qpParts) {
|
|
5739
|
-
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
5740
|
-
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
5741
|
-
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
5742
|
-
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
5743
|
-
qpVars[union4.var] = `string(${union4.params})`;
|
|
5744
|
-
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
5745
|
-
qpVars[dynamic.var] = dynamic.val;
|
|
5746
|
-
} else if (fixed && isVariable(fixed.var)) {
|
|
5747
|
-
qpVars[fixed.var] = fixed.val;
|
|
5748
|
-
}
|
|
5749
|
-
}
|
|
5750
|
-
return {
|
|
5751
|
-
pathVars,
|
|
5752
|
-
qpVars,
|
|
5753
|
-
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
5754
|
-
...pathVars,
|
|
5755
|
-
...qpVars
|
|
5756
|
-
}
|
|
5757
|
-
};
|
|
5627
|
+
function optional(value) {
|
|
5628
|
+
return value;
|
|
5758
5629
|
}
|
|
5759
|
-
function
|
|
5630
|
+
function orNull(value) {
|
|
5631
|
+
return value;
|
|
5632
|
+
}
|
|
5633
|
+
function optionalOrNull(value) {
|
|
5634
|
+
return value;
|
|
5635
|
+
}
|
|
5636
|
+
function stripParenthesis(val) {
|
|
5637
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
5638
|
+
}
|
|
5639
|
+
function sortKeyApi(order) {
|
|
5760
5640
|
return {
|
|
5761
|
-
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
|
|
5766
|
-
|
|
5767
|
-
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5771
|
-
|
|
5641
|
+
order,
|
|
5642
|
+
toTop: (...keys) => sortKeyApi(
|
|
5643
|
+
[
|
|
5644
|
+
...keys,
|
|
5645
|
+
...order.filter((i) => !keys.includes(i))
|
|
5646
|
+
]
|
|
5647
|
+
),
|
|
5648
|
+
toBottom: (...keys) => sortKeyApi(
|
|
5649
|
+
[
|
|
5650
|
+
...order.filter((i) => !keys.includes(i)),
|
|
5651
|
+
...keys
|
|
5652
|
+
]
|
|
5653
|
+
),
|
|
5654
|
+
done: () => order
|
|
5772
5655
|
};
|
|
5773
5656
|
}
|
|
5774
|
-
function
|
|
5775
|
-
|
|
5657
|
+
function toKeyValue(obj, sort) {
|
|
5658
|
+
let keys = keysOf(obj);
|
|
5659
|
+
const tuple3 = [];
|
|
5660
|
+
if (sort) {
|
|
5661
|
+
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
5662
|
+
}
|
|
5663
|
+
for (const k of keys) {
|
|
5664
|
+
tuple3.push({ key: k, value: obj[k] });
|
|
5665
|
+
}
|
|
5666
|
+
return tuple3;
|
|
5776
5667
|
}
|
|
5777
|
-
function
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
return
|
|
5785
|
-
|
|
5786
|
-
throw new Error(
|
|
5787
|
-
}
|
|
5788
|
-
} else {
|
|
5789
|
-
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
5668
|
+
function convertScalar(val) {
|
|
5669
|
+
switch (typeof val) {
|
|
5670
|
+
case "number":
|
|
5671
|
+
return val;
|
|
5672
|
+
case "string":
|
|
5673
|
+
return Number(val);
|
|
5674
|
+
case "boolean":
|
|
5675
|
+
return val ? 1 : 0;
|
|
5676
|
+
default:
|
|
5677
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
5790
5678
|
}
|
|
5791
5679
|
}
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
isYouTubeUrl: true,
|
|
5796
|
-
isShareUrl: isYouTubeShareUrl(url),
|
|
5797
|
-
pageType: getYouTubePageType(url)
|
|
5798
|
-
} : {
|
|
5799
|
-
url,
|
|
5800
|
-
isYouTubeUrl: false
|
|
5801
|
-
};
|
|
5680
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
5681
|
+
function toNumber(value) {
|
|
5682
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
5802
5683
|
}
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
|
|
5806
|
-
size: state.length,
|
|
5807
|
-
isEmpty() {
|
|
5808
|
-
return state.length === 0;
|
|
5809
|
-
},
|
|
5810
|
-
clear() {
|
|
5811
|
-
state.slice(0, 0);
|
|
5812
|
-
},
|
|
5813
|
-
drain() {
|
|
5814
|
-
const old_state = [...state];
|
|
5815
|
-
state.slice(0, 0);
|
|
5816
|
-
return old_state;
|
|
5817
|
-
},
|
|
5818
|
-
push(...add) {
|
|
5819
|
-
state.push(...add);
|
|
5820
|
-
},
|
|
5821
|
-
drop(quantity) {
|
|
5822
|
-
if (quantity && quantity > state.length) {
|
|
5823
|
-
throw new Error("Cannot drop more elements than present in the queue");
|
|
5824
|
-
}
|
|
5825
|
-
state.splice(0, quantity || 1);
|
|
5826
|
-
},
|
|
5827
|
-
take(quantity) {
|
|
5828
|
-
if (quantity && quantity > state.length) {
|
|
5829
|
-
throw new Error("Cannot take more elements than present in the queue");
|
|
5830
|
-
}
|
|
5831
|
-
const result2 = state.slice(0, quantity || 1);
|
|
5832
|
-
state.splice(0, quantity || 1);
|
|
5833
|
-
return result2;
|
|
5834
|
-
},
|
|
5835
|
-
*[Symbol.iterator]() {
|
|
5836
|
-
for (let i = 0; i < state.length; i++) {
|
|
5837
|
-
yield state[i];
|
|
5838
|
-
}
|
|
5839
|
-
}
|
|
5840
|
-
};
|
|
5841
|
-
}
|
|
5842
|
-
function createFifoQueue(...list2) {
|
|
5843
|
-
return queue([...list2]);
|
|
5684
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
5685
|
+
function removeTailwindModifiers(val) {
|
|
5686
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
5844
5687
|
}
|
|
5845
|
-
function
|
|
5846
|
-
return
|
|
5847
|
-
queue: state,
|
|
5848
|
-
size: state.length,
|
|
5849
|
-
isEmpty() {
|
|
5850
|
-
return state.length === 0;
|
|
5851
|
-
},
|
|
5852
|
-
push(...add) {
|
|
5853
|
-
state.push(...add);
|
|
5854
|
-
},
|
|
5855
|
-
drop(quantity) {
|
|
5856
|
-
state.splice(-quantity);
|
|
5857
|
-
},
|
|
5858
|
-
clear() {
|
|
5859
|
-
state.slice(0, 0);
|
|
5860
|
-
},
|
|
5861
|
-
drain() {
|
|
5862
|
-
const old_state = [...state];
|
|
5863
|
-
state.slice(0, 0);
|
|
5864
|
-
return old_state;
|
|
5865
|
-
},
|
|
5866
|
-
take(quantity) {
|
|
5867
|
-
const result2 = state.slice(-quantity);
|
|
5868
|
-
state.splice(-quantity);
|
|
5869
|
-
return result2;
|
|
5870
|
-
},
|
|
5871
|
-
*[Symbol.iterator]() {
|
|
5872
|
-
for (let i = state.length - 1; i >= 0; i--) {
|
|
5873
|
-
yield state[i];
|
|
5874
|
-
}
|
|
5875
|
-
}
|
|
5876
|
-
};
|
|
5688
|
+
function getTailwindModifiers(val) {
|
|
5689
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
5877
5690
|
}
|
|
5878
|
-
function
|
|
5879
|
-
return
|
|
5691
|
+
function union(..._options) {
|
|
5692
|
+
return (value) => value;
|
|
5880
5693
|
}
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
number: "<<number>>",
|
|
5884
|
-
boolean: "<<boolean>>",
|
|
5885
|
-
true: "<<true>>",
|
|
5886
|
-
false: "<<false>>",
|
|
5887
|
-
null: "<<null>>",
|
|
5888
|
-
undefined: "<<undefined>>",
|
|
5889
|
-
unknown: "<<unknown>>",
|
|
5890
|
-
any: "<<any>>",
|
|
5891
|
-
never: "<<never>>"
|
|
5892
|
-
});
|
|
5893
|
-
function stringLiteral(str) {
|
|
5894
|
-
return stripAfter(stripBefore(str, "string("), ")");
|
|
5694
|
+
function unionize(value, _inUnionWith) {
|
|
5695
|
+
return value;
|
|
5895
5696
|
}
|
|
5896
|
-
function
|
|
5897
|
-
return
|
|
5697
|
+
function hasWhiteSpace(val) {
|
|
5698
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
5898
5699
|
}
|
|
5899
|
-
function
|
|
5900
|
-
|
|
5901
|
-
|
|
5700
|
+
function endsWith(endingIn2) {
|
|
5701
|
+
return (val) => {
|
|
5702
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
5703
|
+
};
|
|
5902
5704
|
}
|
|
5903
|
-
function
|
|
5904
|
-
return
|
|
5705
|
+
function isEqual(base) {
|
|
5706
|
+
return (value) => isSameTypeOf(base)(value) ? value === base : false;
|
|
5905
5707
|
}
|
|
5906
|
-
function
|
|
5907
|
-
return
|
|
5708
|
+
function isLength(value, len) {
|
|
5709
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
5908
5710
|
}
|
|
5909
|
-
function
|
|
5910
|
-
return
|
|
5711
|
+
function isSameTypeOf(base) {
|
|
5712
|
+
return (compare) => {
|
|
5713
|
+
return typeof base === typeof compare;
|
|
5714
|
+
};
|
|
5911
5715
|
}
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
return
|
|
5716
|
+
function isTuple(...tuple3) {
|
|
5717
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
5718
|
+
return (v) => {
|
|
5719
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
5720
|
+
};
|
|
5915
5721
|
}
|
|
5916
|
-
function
|
|
5722
|
+
function isTypeOf(type) {
|
|
5723
|
+
return (value) => {
|
|
5724
|
+
return typeof value === type;
|
|
5725
|
+
};
|
|
5917
5726
|
}
|
|
5918
|
-
function
|
|
5919
|
-
return
|
|
5727
|
+
function startsWith(startingWith) {
|
|
5728
|
+
return (val) => {
|
|
5729
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
5730
|
+
};
|
|
5920
5731
|
}
|
|
5921
|
-
function
|
|
5922
|
-
return
|
|
5732
|
+
function isHtmlElement(val) {
|
|
5733
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
5923
5734
|
}
|
|
5924
|
-
function
|
|
5925
|
-
return
|
|
5735
|
+
function isAlpha(value) {
|
|
5736
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
5926
5737
|
}
|
|
5927
|
-
|
|
5928
|
-
|
|
5929
|
-
var nullType = () => "<<null>>";
|
|
5930
|
-
function fn(..._args) {
|
|
5931
|
-
return {
|
|
5932
|
-
returns: (_rtn) => ({
|
|
5933
|
-
addProperties: (_kv) => {
|
|
5934
|
-
return null;
|
|
5935
|
-
},
|
|
5936
|
-
done: () => {
|
|
5937
|
-
return null;
|
|
5938
|
-
}
|
|
5939
|
-
}),
|
|
5940
|
-
done: () => {
|
|
5941
|
-
const result2 = null;
|
|
5942
|
-
return result2;
|
|
5943
|
-
}
|
|
5944
|
-
};
|
|
5738
|
+
function isArray(value) {
|
|
5739
|
+
return Array.isArray(value) === true;
|
|
5945
5740
|
}
|
|
5946
|
-
function
|
|
5947
|
-
return
|
|
5741
|
+
function isBoolean(value) {
|
|
5742
|
+
return typeof value === "boolean";
|
|
5948
5743
|
}
|
|
5949
|
-
function
|
|
5950
|
-
return
|
|
5744
|
+
function isBooleanLike(val) {
|
|
5745
|
+
return isBoolean(val) || isString(val) && ["true", "false", "boolean"].includes(val);
|
|
5951
5746
|
}
|
|
5952
|
-
function
|
|
5953
|
-
|
|
5954
|
-
if (isString(re)) {
|
|
5955
|
-
try {
|
|
5956
|
-
const test = new RegExp(re);
|
|
5957
|
-
if (!isRegExp(test)) {
|
|
5958
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
5959
|
-
err.name = "InvalidRegEx";
|
|
5960
|
-
throw err;
|
|
5961
|
-
} else {
|
|
5962
|
-
exp = re;
|
|
5963
|
-
}
|
|
5964
|
-
} catch {
|
|
5965
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
5966
|
-
err.name = "InvalidRegEx";
|
|
5967
|
-
throw err;
|
|
5968
|
-
}
|
|
5969
|
-
} else if (isRegExp(re)) {
|
|
5970
|
-
exp = re.toString();
|
|
5971
|
-
}
|
|
5972
|
-
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
5973
|
-
return token;
|
|
5747
|
+
function isConstant(value) {
|
|
5748
|
+
return !!(isObject(value) && "_type" in value && "kind" in value && value._type === "Constant");
|
|
5974
5749
|
}
|
|
5975
|
-
function
|
|
5976
|
-
return (
|
|
5977
|
-
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
5978
|
-
"union",
|
|
5979
|
-
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
5980
|
-
);
|
|
5981
|
-
};
|
|
5750
|
+
function isContainer(value) {
|
|
5751
|
+
return !!(Array.isArray(value) || isObject(value));
|
|
5982
5752
|
}
|
|
5983
|
-
var
|
|
5984
|
-
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
},
|
|
5996
|
-
civilianTime: (resolution) => {
|
|
5997
|
-
return addToken(
|
|
5998
|
-
"string-set",
|
|
5999
|
-
"militaryTime",
|
|
6000
|
-
resolution || "HH:MM"
|
|
6001
|
-
);
|
|
6002
|
-
},
|
|
6003
|
-
numericString: () => addToken("string-set", "numeric"),
|
|
6004
|
-
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
6005
|
-
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
6006
|
-
regex: (exp, ...literalRepresentation) => {
|
|
6007
|
-
const token = regexToken(exp, ...literalRepresentation);
|
|
6008
|
-
return token;
|
|
6009
|
-
},
|
|
6010
|
-
done: () => addToken("string")
|
|
6011
|
-
};
|
|
6012
|
-
var string22 = addSingleton("string", stringApi);
|
|
6013
|
-
var number = addSingleton("number");
|
|
6014
|
-
function union2(...elements) {
|
|
6015
|
-
const result2 = elements.map((_el) => {
|
|
6016
|
-
});
|
|
6017
|
-
return result2;
|
|
5753
|
+
var tokens = [
|
|
5754
|
+
"1",
|
|
5755
|
+
"inherit",
|
|
5756
|
+
"initial",
|
|
5757
|
+
"revert",
|
|
5758
|
+
"revert-layer",
|
|
5759
|
+
"unset",
|
|
5760
|
+
"auto"
|
|
5761
|
+
];
|
|
5762
|
+
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
5763
|
+
function isCssAspectRatio(val) {
|
|
5764
|
+
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6018
5765
|
}
|
|
6019
|
-
function
|
|
6020
|
-
return
|
|
5766
|
+
function isCsv(val) {
|
|
5767
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
6021
5768
|
}
|
|
6022
|
-
function
|
|
6023
|
-
return
|
|
5769
|
+
function isDefined(value) {
|
|
5770
|
+
return value !== void 0;
|
|
6024
5771
|
}
|
|
6025
|
-
function
|
|
6026
|
-
return
|
|
5772
|
+
function isDoneFn(val) {
|
|
5773
|
+
return hasKeys("done")(val) && typeof val.done === "function";
|
|
6027
5774
|
}
|
|
6028
|
-
function
|
|
6029
|
-
|
|
5775
|
+
function isEmail(val) {
|
|
5776
|
+
if (!isString(val)) {
|
|
5777
|
+
return false;
|
|
5778
|
+
}
|
|
5779
|
+
const parts = val?.split("@");
|
|
5780
|
+
const domain = parts[1]?.split(".");
|
|
5781
|
+
const tld = domain ? domain.pop() : "";
|
|
5782
|
+
const firstChar = val[0].toLowerCase();
|
|
5783
|
+
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
6030
5784
|
}
|
|
6031
|
-
function
|
|
6032
|
-
return
|
|
5785
|
+
function isEmpty(val) {
|
|
5786
|
+
return isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && val.length === 0;
|
|
6033
5787
|
}
|
|
6034
|
-
function
|
|
6035
|
-
return
|
|
5788
|
+
function isNotEmpty(val) {
|
|
5789
|
+
return !(isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && (val?.length === 0 || val?.length === void 0));
|
|
6036
5790
|
}
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
number,
|
|
6040
|
-
boolean,
|
|
6041
|
-
unknown,
|
|
6042
|
-
undefined: undefinedType,
|
|
6043
|
-
null: nullType,
|
|
6044
|
-
union: union2,
|
|
6045
|
-
fn,
|
|
6046
|
-
record,
|
|
6047
|
-
array,
|
|
6048
|
-
set,
|
|
6049
|
-
map,
|
|
6050
|
-
weakMap,
|
|
6051
|
-
dictionary,
|
|
6052
|
-
tuple: tuple2
|
|
6053
|
-
};
|
|
6054
|
-
function shape(cb) {
|
|
6055
|
-
const rtn = cb(ShapeApiImplementation);
|
|
6056
|
-
return handleDoneFn(
|
|
6057
|
-
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
6058
|
-
);
|
|
5791
|
+
function isErrorCondition(value, kind = null) {
|
|
5792
|
+
return isObject(value) && "__kind" in value && value.__kind === "ErrorCondition" && "kind" in value ? kind !== null ? value.kind === kind : true : false;
|
|
6059
5793
|
}
|
|
6060
|
-
function
|
|
6061
|
-
return
|
|
5794
|
+
function isFalse(i) {
|
|
5795
|
+
return typeof i === "boolean" && !i;
|
|
6062
5796
|
}
|
|
6063
|
-
function
|
|
6064
|
-
|
|
6065
|
-
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
6066
|
-
...acc,
|
|
6067
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6068
|
-
} : isFunction(defn[i]) ? {
|
|
6069
|
-
...acc,
|
|
6070
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6071
|
-
} : Never2,
|
|
6072
|
-
{}
|
|
6073
|
-
);
|
|
6074
|
-
return result2;
|
|
5797
|
+
function isFalsy(val) {
|
|
5798
|
+
return FALSY_VALUES2.includes(val);
|
|
6075
5799
|
}
|
|
6076
|
-
function
|
|
6077
|
-
return
|
|
5800
|
+
function isFnWithParams(input, ...params) {
|
|
5801
|
+
return params.length === 0 ? typeof input === "function" && input?.length > 0 : typeof input === "function" && input?.length === params.length;
|
|
6078
5802
|
}
|
|
6079
|
-
function
|
|
6080
|
-
return
|
|
5803
|
+
function isHexadecimal(val) {
|
|
5804
|
+
return isString(val) && asChars(val).every((i) => isNumericString(i) || ["a", "b", "c", "d", "e", "f"].includes(i.toLowerCase()));
|
|
6081
5805
|
}
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6093
|
-
|
|
6094
|
-
|
|
6095
|
-
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
6107
|
-
|
|
6108
|
-
|
|
6109
|
-
|
|
6110
|
-
|
|
6111
|
-
|
|
6112
|
-
|
|
6113
|
-
|
|
6114
|
-
|
|
6115
|
-
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
|
|
6135
|
-
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
if (type === "Array" || type === "Array<unknown>") {
|
|
6146
|
-
return true;
|
|
6147
|
-
}
|
|
6148
|
-
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
6149
|
-
response = true;
|
|
6150
|
-
}
|
|
6151
|
-
}
|
|
6152
|
-
if (isMap(val)) {
|
|
6153
|
-
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
6154
|
-
response = true;
|
|
6155
|
-
}
|
|
6156
|
-
}
|
|
6157
|
-
if (isSetContainer(val)) {
|
|
6158
|
-
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
6159
|
-
response = true;
|
|
6160
|
-
}
|
|
5806
|
+
function isIndexable(value) {
|
|
5807
|
+
return !!(Array.isArray(value) || typeof value === "object" && keysOf(value).length > 0);
|
|
5808
|
+
}
|
|
5809
|
+
function isInlineSvg(v) {
|
|
5810
|
+
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
5811
|
+
}
|
|
5812
|
+
function isMap(val) {
|
|
5813
|
+
return val instanceof Map;
|
|
5814
|
+
}
|
|
5815
|
+
function isNever(val) {
|
|
5816
|
+
return isConstant(val) && val.kind === "never";
|
|
5817
|
+
}
|
|
5818
|
+
function isNothing(val) {
|
|
5819
|
+
return !!(val === null || val === void 0);
|
|
5820
|
+
}
|
|
5821
|
+
function isNotNull(value) {
|
|
5822
|
+
return value === null;
|
|
5823
|
+
}
|
|
5824
|
+
function isNull(value) {
|
|
5825
|
+
return value === null;
|
|
5826
|
+
}
|
|
5827
|
+
function maybePhoneNumber(val) {
|
|
5828
|
+
const svelte = String(val).trim();
|
|
5829
|
+
const chars = svelte.split("");
|
|
5830
|
+
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
5831
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
5832
|
+
const nothing = stripChars(svelte, ...[
|
|
5833
|
+
...NUMERIC_CHAR2,
|
|
5834
|
+
...WHITESPACE_CHARS2,
|
|
5835
|
+
"(",
|
|
5836
|
+
")",
|
|
5837
|
+
"+",
|
|
5838
|
+
".",
|
|
5839
|
+
"-"
|
|
5840
|
+
]);
|
|
5841
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
5842
|
+
}
|
|
5843
|
+
var start = PHONE_COUNTRY_CODES2.map((i) => `+${i[0]} `);
|
|
5844
|
+
function hasCountryCode(val) {
|
|
5845
|
+
if (isString(val)) {
|
|
5846
|
+
return start.some((i) => val.trimStart().startsWith(i));
|
|
5847
|
+
}
|
|
5848
|
+
return false;
|
|
5849
|
+
}
|
|
5850
|
+
function isUsPhoneNumber(val) {
|
|
5851
|
+
if (isString(val)) {
|
|
5852
|
+
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
5853
|
+
}
|
|
5854
|
+
return false;
|
|
5855
|
+
}
|
|
5856
|
+
function isPhoneNumber(val) {
|
|
5857
|
+
if (isString(val) && maybePhoneNumber(val) && [" ", "-", "."].some((i) => val.includes(i))) {
|
|
5858
|
+
const cc = getPhoneCountryCode(val);
|
|
5859
|
+
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
5860
|
+
switch (cc) {
|
|
5861
|
+
case "1":
|
|
5862
|
+
return without.length === 10;
|
|
5863
|
+
case "44":
|
|
5864
|
+
return !![10, 11].includes(without.length);
|
|
5865
|
+
case "":
|
|
5866
|
+
return without.length <= 10;
|
|
5867
|
+
default:
|
|
5868
|
+
return without.length <= 11;
|
|
6161
5869
|
}
|
|
6162
|
-
|
|
6163
|
-
|
|
5870
|
+
}
|
|
5871
|
+
return false;
|
|
6164
5872
|
}
|
|
6165
|
-
function
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
6169
|
-
|
|
6170
|
-
|
|
5873
|
+
function isReadonlyArray(value) {
|
|
5874
|
+
return Array.isArray(value) === true;
|
|
5875
|
+
}
|
|
5876
|
+
function isRef(value) {
|
|
5877
|
+
return isObject(value) && "value" in value && Array.from(Object.keys(value)).includes("_value");
|
|
5878
|
+
}
|
|
5879
|
+
function isRegExp(val) {
|
|
5880
|
+
return val instanceof RegExp;
|
|
5881
|
+
}
|
|
5882
|
+
function isLikeRegExp(val) {
|
|
5883
|
+
if (isRegExp(val)) {
|
|
5884
|
+
return true;
|
|
6171
5885
|
}
|
|
6172
|
-
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
|
|
6179
|
-
|
|
5886
|
+
if (isString(val)) {
|
|
5887
|
+
try {
|
|
5888
|
+
const _re = new RegExp(val);
|
|
5889
|
+
return true;
|
|
5890
|
+
} catch {
|
|
5891
|
+
return false;
|
|
5892
|
+
}
|
|
5893
|
+
}
|
|
5894
|
+
return false;
|
|
5895
|
+
}
|
|
5896
|
+
function isSymbol(value) {
|
|
5897
|
+
return typeof value === "symbol";
|
|
5898
|
+
}
|
|
5899
|
+
function isScalar(value) {
|
|
5900
|
+
return isString(value) || isNumber(value) || isSymbol(value) || isNull(value);
|
|
5901
|
+
}
|
|
5902
|
+
function isSet(val) {
|
|
5903
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
5904
|
+
}
|
|
5905
|
+
function isSetContainer(val) {
|
|
5906
|
+
return val instanceof Set;
|
|
5907
|
+
}
|
|
5908
|
+
function isStringArray(val) {
|
|
5909
|
+
return Array.isArray(val) && val.every((i) => isString(i));
|
|
5910
|
+
}
|
|
5911
|
+
function isThenable(val) {
|
|
5912
|
+
return isObject(val) && "then" in val && "catch" in val && typeof val.then === "function";
|
|
5913
|
+
}
|
|
5914
|
+
function isTrimable(val) {
|
|
5915
|
+
return isString(val) && val !== val.trim();
|
|
5916
|
+
}
|
|
5917
|
+
function isTrue(value) {
|
|
5918
|
+
return value === true;
|
|
5919
|
+
}
|
|
5920
|
+
function isTruthy(val) {
|
|
5921
|
+
return !FALSY_VALUES2.includes(val);
|
|
5922
|
+
}
|
|
5923
|
+
function isTypeSubtype(val) {
|
|
5924
|
+
return isString(val) && val.split("/").length === 2;
|
|
5925
|
+
}
|
|
5926
|
+
function isTypeTuple(value) {
|
|
5927
|
+
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
5928
|
+
}
|
|
5929
|
+
function isUnset(val) {
|
|
5930
|
+
return isObject(val) && val.kind === "Unset";
|
|
6180
5931
|
}
|
|
6181
|
-
function
|
|
6182
|
-
const
|
|
6183
|
-
|
|
6184
|
-
const proxy = new Proxy(state, {});
|
|
6185
|
-
Object.defineProperty(proxy, "id", {
|
|
6186
|
-
enumerable: false
|
|
6187
|
-
});
|
|
6188
|
-
return proxy;
|
|
5932
|
+
function isUri(val, ...protocols) {
|
|
5933
|
+
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
5934
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6189
5935
|
}
|
|
6190
|
-
function
|
|
6191
|
-
|
|
5936
|
+
function isUrl(val, ...protocols) {
|
|
5937
|
+
const p = protocols.length === 0 ? ["http", "https"] : protocols;
|
|
5938
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6192
5939
|
}
|
|
6193
|
-
|
|
6194
|
-
|
|
6195
|
-
|
|
6196
|
-
|
|
6197
|
-
|
|
5940
|
+
var VALID = [
|
|
5941
|
+
...ALPHA_CHARS2,
|
|
5942
|
+
...NUMERIC_CHAR2,
|
|
5943
|
+
"_",
|
|
5944
|
+
"."
|
|
5945
|
+
];
|
|
5946
|
+
var alpha = null;
|
|
5947
|
+
function valid(chars) {
|
|
5948
|
+
return chars.every((i) => VALID.includes(i));
|
|
6198
5949
|
}
|
|
6199
|
-
function
|
|
6200
|
-
return
|
|
5950
|
+
function isVariable(val) {
|
|
5951
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
6201
5952
|
}
|
|
6202
|
-
function
|
|
6203
|
-
return
|
|
6204
|
-
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
6205
|
-
};
|
|
5953
|
+
function separate(s) {
|
|
5954
|
+
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR2).trim();
|
|
6206
5955
|
}
|
|
6207
|
-
function
|
|
6208
|
-
return
|
|
6209
|
-
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
6210
|
-
};
|
|
5956
|
+
function isAreaMetric(val) {
|
|
5957
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6211
5958
|
}
|
|
6212
|
-
function
|
|
6213
|
-
return
|
|
5959
|
+
function isLuminosityMetric(val) {
|
|
5960
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6214
5961
|
}
|
|
6215
|
-
function
|
|
6216
|
-
return
|
|
6217
|
-
done: fnDoneApi(kind, params, returns),
|
|
6218
|
-
params: fnParamsApi(kind, params, returns),
|
|
6219
|
-
returns: fnReturnsApi(kind, params, returns)
|
|
6220
|
-
};
|
|
5962
|
+
function isResistance(val) {
|
|
5963
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6221
5964
|
}
|
|
6222
|
-
function
|
|
6223
|
-
return
|
|
5965
|
+
function isCurrentMetric(val) {
|
|
5966
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6224
5967
|
}
|
|
6225
|
-
function
|
|
6226
|
-
return
|
|
5968
|
+
function isVoltageMetric(val) {
|
|
5969
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6227
5970
|
}
|
|
6228
|
-
function
|
|
6229
|
-
|
|
6230
|
-
const parts = bare.split("::");
|
|
6231
|
-
const kind = parts.pop();
|
|
6232
|
-
return kind;
|
|
5971
|
+
function isFrequencyMetric(val) {
|
|
5972
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6233
5973
|
}
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
var simpleContainerToken = (token) => token;
|
|
6237
|
-
function simpleScalarType(token) {
|
|
6238
|
-
const value = simpleScalarToken(token);
|
|
6239
|
-
return value;
|
|
5974
|
+
function isPowerMetric(val) {
|
|
5975
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6240
5976
|
}
|
|
6241
|
-
function
|
|
6242
|
-
|
|
6243
|
-
return value;
|
|
5977
|
+
function isTimeMetric(val) {
|
|
5978
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6244
5979
|
}
|
|
6245
|
-
function
|
|
6246
|
-
|
|
6247
|
-
return value;
|
|
5980
|
+
function isEnergyMetric(val) {
|
|
5981
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6248
5982
|
}
|
|
6249
|
-
function
|
|
6250
|
-
|
|
6251
|
-
for (const k of keys) {
|
|
6252
|
-
if (k in b) {
|
|
6253
|
-
return true;
|
|
6254
|
-
}
|
|
6255
|
-
}
|
|
6256
|
-
return false;
|
|
5983
|
+
function isPressureMetric(val) {
|
|
5984
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6257
5985
|
}
|
|
6258
|
-
function
|
|
6259
|
-
|
|
6260
|
-
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
6261
|
-
throw new Error("uniqueKeys(l,r) given invalid comparison; both left and right values should be an object or an array but not one of each!");
|
|
6262
|
-
}
|
|
6263
|
-
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
6264
|
-
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
6265
|
-
if (isNumeric) {
|
|
6266
|
-
throw new Error("uniqueKeys does not yet work with tuples");
|
|
6267
|
-
}
|
|
6268
|
-
const leftKeys = l.filter((i) => !r.includes(i));
|
|
6269
|
-
const rightKeys = r.filter((i) => !l.includes(i));
|
|
6270
|
-
return [
|
|
6271
|
-
"LeftRight",
|
|
6272
|
-
leftKeys,
|
|
6273
|
-
rightKeys
|
|
6274
|
-
];
|
|
5986
|
+
function isTemperatureMetric(val) {
|
|
5987
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6275
5988
|
}
|
|
6276
|
-
function
|
|
6277
|
-
return
|
|
5989
|
+
function isVolumeMetric(val) {
|
|
5990
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6278
5991
|
}
|
|
6279
|
-
function
|
|
6280
|
-
return
|
|
5992
|
+
function isAccelerationMetric(val) {
|
|
5993
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6281
5994
|
}
|
|
6282
|
-
function
|
|
6283
|
-
|
|
5995
|
+
function isSpeedMetric(val) {
|
|
5996
|
+
const speed = SPEED_METRICS_LOOKUP2.map((i) => i.abbrev);
|
|
5997
|
+
return isString(val) && speed.includes(separate(val));
|
|
6284
5998
|
}
|
|
6285
|
-
function
|
|
6286
|
-
return
|
|
5999
|
+
function isMassMetric(val) {
|
|
6000
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6287
6001
|
}
|
|
6288
|
-
function
|
|
6289
|
-
return
|
|
6002
|
+
function isDistanceMetric(val) {
|
|
6003
|
+
return isString(val) && DISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6290
6004
|
}
|
|
6291
|
-
function
|
|
6292
|
-
return
|
|
6005
|
+
function isMetric(val) {
|
|
6006
|
+
return isDistanceMetric(val) || isMassMetric(val) || isSpeedMetric(val) || isAccelerationMetric(val) || isVoltageMetric(val) || isTemperatureMetric(val) || isPressureMetric(val) || isEnergyMetric(val) || isTimeMetric(val) || isPowerMetric(val) || isFrequencyMetric(val) || isVoltageMetric(val) || isCurrentMetric(val) || isLuminosityMetric(val) || isAreaMetric(val);
|
|
6293
6007
|
}
|
|
6294
|
-
function
|
|
6295
|
-
return
|
|
6008
|
+
function isAreaUom(val) {
|
|
6009
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6296
6010
|
}
|
|
6297
|
-
function
|
|
6298
|
-
return
|
|
6011
|
+
function isLuminosityUom(val) {
|
|
6012
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6299
6013
|
}
|
|
6300
|
-
function
|
|
6301
|
-
return
|
|
6014
|
+
function isResistanceUom(val) {
|
|
6015
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6302
6016
|
}
|
|
6303
|
-
function
|
|
6304
|
-
return
|
|
6017
|
+
function isCurrentUom(val) {
|
|
6018
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6305
6019
|
}
|
|
6306
|
-
function
|
|
6307
|
-
return val
|
|
6020
|
+
function isVoltageUom(val) {
|
|
6021
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6308
6022
|
}
|
|
6309
|
-
function
|
|
6310
|
-
|
|
6311
|
-
return false;
|
|
6312
|
-
}
|
|
6313
|
-
const ISO_DATETIME_REGEX = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?(Z|[+-]\d{2}:\d{2})?$/;
|
|
6314
|
-
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
6315
|
-
return false;
|
|
6316
|
-
}
|
|
6317
|
-
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
6318
|
-
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
6319
|
-
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
6320
|
-
return false;
|
|
6321
|
-
}
|
|
6322
|
-
if (month < 1 || month > 12) {
|
|
6323
|
-
return false;
|
|
6324
|
-
}
|
|
6325
|
-
;
|
|
6326
|
-
const daysInMonth = new Date(year, month, 0).getDate();
|
|
6327
|
-
if (day < 1 || day > daysInMonth) {
|
|
6328
|
-
return false;
|
|
6329
|
-
}
|
|
6330
|
-
;
|
|
6331
|
-
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
6332
|
-
if (tzMatch) {
|
|
6333
|
-
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
6334
|
-
const numHours = Number.parseInt(tzHours, 10);
|
|
6335
|
-
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
6336
|
-
if (numHours > 14 || numMinutes > 59) {
|
|
6337
|
-
return false;
|
|
6338
|
-
}
|
|
6339
|
-
if (numHours === 14 && numMinutes > 0) {
|
|
6340
|
-
return false;
|
|
6341
|
-
}
|
|
6342
|
-
}
|
|
6343
|
-
return true;
|
|
6023
|
+
function isFrequencyUom(val) {
|
|
6024
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6344
6025
|
}
|
|
6345
|
-
function
|
|
6346
|
-
|
|
6347
|
-
const parts = val.split("-").map((i) => Number(i));
|
|
6348
|
-
return val.includes("-") ? val.split("-").every((i) => isNumberLike(i)) ? parts[0] >= 0 && parts[0] <= 9999 && parts[1] >= 1 && parts[1] <= 12 && parts[2] >= 1 && parts[2] <= 31 : false : false;
|
|
6349
|
-
} else {
|
|
6350
|
-
return false;
|
|
6351
|
-
}
|
|
6026
|
+
function isPowerUom(val) {
|
|
6027
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6352
6028
|
}
|
|
6353
|
-
function
|
|
6354
|
-
|
|
6355
|
-
const year = Number(val.slice(0, 4));
|
|
6356
|
-
const month = Number(val.slice(4, 6));
|
|
6357
|
-
const date = Number(val.slice(6, 8));
|
|
6358
|
-
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
6359
|
-
} else {
|
|
6360
|
-
return false;
|
|
6361
|
-
}
|
|
6029
|
+
function isTimeUom(val) {
|
|
6030
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6362
6031
|
}
|
|
6363
|
-
function
|
|
6364
|
-
|
|
6365
|
-
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
6366
|
-
} else {
|
|
6367
|
-
return false;
|
|
6368
|
-
}
|
|
6032
|
+
function isEnergyUom(val) {
|
|
6033
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6369
6034
|
}
|
|
6370
|
-
function
|
|
6371
|
-
|
|
6372
|
-
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
6373
|
-
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
6374
|
-
} else {
|
|
6375
|
-
return false;
|
|
6376
|
-
}
|
|
6035
|
+
function isPressureUom(val) {
|
|
6036
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6377
6037
|
}
|
|
6378
|
-
function
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6038
|
+
function isTemperatureUom(val) {
|
|
6039
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6040
|
+
}
|
|
6041
|
+
function isVolumeUom(val) {
|
|
6042
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6043
|
+
}
|
|
6044
|
+
function isAccelerationUom(val) {
|
|
6045
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6385
6046
|
}
|
|
6386
|
-
function
|
|
6387
|
-
return
|
|
6047
|
+
function isSpeedUom(val) {
|
|
6048
|
+
return isString(val) && SPEED_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6388
6049
|
}
|
|
6389
|
-
function
|
|
6390
|
-
return
|
|
6050
|
+
function isMassUom(val) {
|
|
6051
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6391
6052
|
}
|
|
6392
|
-
function
|
|
6393
|
-
return
|
|
6053
|
+
function isDistanceUom(val) {
|
|
6054
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6394
6055
|
}
|
|
6395
|
-
function
|
|
6396
|
-
|
|
6397
|
-
return false;
|
|
6398
|
-
}
|
|
6399
|
-
return isObject(val) && typeof val.format === "function" && typeof val.year === "function" && typeof val.month === "function" && typeof val.date === "function" && "_isAMomentObject" in val && "_isValid" in val && typeof val.add === "function" && typeof val.subtract === "function" && typeof val.toISOString === "function" && typeof val.isValid === "function";
|
|
6056
|
+
function isUom(val) {
|
|
6057
|
+
return isDistanceUom(val) || isMassUom(val) || isSpeedUom(val) || isAccelerationUom(val) || isVoltageUom(val) || isTemperatureUom(val) || isPressureUom(val) || isEnergyUom(val) || isTimeUom(val) || isPowerUom(val) || isFrequencyUom(val) || isVoltageUom(val) || isCurrentUom(val) || isLuminosityUom(val) || isAreaUom(val);
|
|
6400
6058
|
}
|
|
6401
|
-
function
|
|
6402
|
-
|
|
6403
|
-
const currentYear = now.getFullYear();
|
|
6404
|
-
const currentMonth = now.getMonth() + 1;
|
|
6405
|
-
if (val instanceof Date) {
|
|
6406
|
-
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
6407
|
-
}
|
|
6408
|
-
if (isMoment(val)) {
|
|
6409
|
-
const monthValue = val.month();
|
|
6410
|
-
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
6411
|
-
}
|
|
6412
|
-
if (isLuxonDateTime(val)) {
|
|
6413
|
-
return val.year === currentYear && val.month === currentMonth;
|
|
6414
|
-
}
|
|
6415
|
-
if (typeof val === "string") {
|
|
6416
|
-
const isoDateRegex = /^\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01])(?:T(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[-+][01]\d:[0-5]\d))?$/;
|
|
6417
|
-
if (!isoDateRegex.test(val)) {
|
|
6418
|
-
return false;
|
|
6419
|
-
}
|
|
6420
|
-
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
6421
|
-
if (dateMatch) {
|
|
6422
|
-
const year = Number.parseInt(dateMatch[1], 10);
|
|
6423
|
-
const month = Number.parseInt(dateMatch[2], 10);
|
|
6424
|
-
return year === currentYear && month === currentMonth;
|
|
6425
|
-
}
|
|
6426
|
-
}
|
|
6427
|
-
return false;
|
|
6059
|
+
function isIp4Address(val) {
|
|
6060
|
+
return isString(val) && val.split(".").length === 4 && val.split(".").every((i) => isNumberLike(i)) && val.split(".").every((i) => Number(i) >= 0 && Number(i) <= 255);
|
|
6428
6061
|
}
|
|
6429
|
-
function
|
|
6430
|
-
const
|
|
6431
|
-
|
|
6432
|
-
return false;
|
|
6433
|
-
}
|
|
6434
|
-
const currentWeek = getWeekNumber();
|
|
6435
|
-
const targetWeek = getWeekNumber(targetDate);
|
|
6436
|
-
return currentWeek === targetWeek;
|
|
6062
|
+
function isIp6Address(val) {
|
|
6063
|
+
const expanded = isString(val) ? ip6GroupExpansion(val) : "";
|
|
6064
|
+
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
6437
6065
|
}
|
|
6438
|
-
function
|
|
6439
|
-
|
|
6440
|
-
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
6441
|
-
const date = asDate(val);
|
|
6442
|
-
if (date) {
|
|
6443
|
-
return date.getFullYear() === currentYear;
|
|
6444
|
-
} else {
|
|
6445
|
-
return false;
|
|
6446
|
-
}
|
|
6447
|
-
}
|
|
6448
|
-
return false;
|
|
6066
|
+
function isIpAddress(val) {
|
|
6067
|
+
return isIp4Address(val) || isIp6Address(val);
|
|
6449
6068
|
}
|
|
6450
|
-
function
|
|
6451
|
-
|
|
6452
|
-
const justDate = stripAfter(test, "T");
|
|
6453
|
-
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
6454
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
6455
|
-
return stripAfter(test.toISOString(), "T") === getToday();
|
|
6456
|
-
} else if (isLuxonDateTime(test)) {
|
|
6457
|
-
return stripAfter(test.toISO(), "T") === getToday();
|
|
6458
|
-
}
|
|
6459
|
-
return false;
|
|
6069
|
+
function hasUrlPort(val) {
|
|
6070
|
+
return isString(val) && asChars(removeUrlProtocol(val)).includes(":");
|
|
6460
6071
|
}
|
|
6461
|
-
function
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
6466
|
-
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
6467
|
-
} else if (isLuxonDateTime(test)) {
|
|
6468
|
-
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
6469
|
-
}
|
|
6470
|
-
return false;
|
|
6072
|
+
function isUrlPath(val) {
|
|
6073
|
+
return isString(val) && (val === "" || val.startsWith("/")) && asChars(val).every(
|
|
6074
|
+
(c) => isAlpha(c) || isNumberLike(c) || c === "_" || c === "@" || c === "." || c === "-"
|
|
6075
|
+
);
|
|
6471
6076
|
}
|
|
6472
|
-
function
|
|
6473
|
-
|
|
6474
|
-
|
|
6475
|
-
|
|
6476
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
6477
|
-
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
6478
|
-
} else if (isLuxonDateTime(test)) {
|
|
6479
|
-
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
6480
|
-
}
|
|
6481
|
-
return false;
|
|
6077
|
+
function isDomainName(val) {
|
|
6078
|
+
return isString(val) && val.split(".").filter((i) => i).length > 1 && isString(val.split(".").filter((i) => i).pop()) && asChars(val.split(".").filter((i) => i).pop()).length > 1 && val.split(".").filter((i) => i).every(
|
|
6079
|
+
(i) => isAlpha(i) || isNumberLike(i) || i === "-" || i === "_"
|
|
6080
|
+
);
|
|
6482
6081
|
}
|
|
6483
|
-
function
|
|
6484
|
-
|
|
6485
|
-
const parts = val.split(" ");
|
|
6486
|
-
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
6487
|
-
}
|
|
6488
|
-
return false;
|
|
6082
|
+
function isUrlSource(val) {
|
|
6083
|
+
return isDomainName(val) || isIpAddress(val);
|
|
6489
6084
|
}
|
|
6490
|
-
function
|
|
6491
|
-
|
|
6492
|
-
const parts = val.split(" ");
|
|
6493
|
-
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4) && ["51", "55", "22", "23", "24", "25", "26", "27"].some((i) => val.startsWith(i));
|
|
6494
|
-
}
|
|
6495
|
-
return false;
|
|
6085
|
+
function hasUrlQueryParameter(val, prop) {
|
|
6086
|
+
return isString(getUrlQueryParams(val, prop));
|
|
6496
6087
|
}
|
|
6497
|
-
function
|
|
6498
|
-
return
|
|
6088
|
+
function isNumericArray(val) {
|
|
6089
|
+
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
6499
6090
|
}
|
|
6500
|
-
function
|
|
6501
|
-
|
|
6502
|
-
const parts = val.split(" ");
|
|
6503
|
-
return parts.length === 3 && parts.every(
|
|
6504
|
-
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
6505
|
-
);
|
|
6506
|
-
}
|
|
6507
|
-
return false;
|
|
6091
|
+
function hasProtocol(val, ...protocols) {
|
|
6092
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
6508
6093
|
}
|
|
6509
|
-
function
|
|
6510
|
-
return
|
|
6094
|
+
function isProtocol(val, ...protocols) {
|
|
6095
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.includes(val) : protocols.includes(val);
|
|
6511
6096
|
}
|
|
6512
|
-
function
|
|
6513
|
-
|
|
6514
|
-
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6518
|
-
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
6530
|
-
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
6531
|
-
];
|
|
6532
|
-
for (const type of cardTypes) {
|
|
6533
|
-
if (type.lengths.includes(length)) {
|
|
6534
|
-
for (const prefix of type.prefixes) {
|
|
6535
|
-
if (prefix.test(cleanedNumber)) {
|
|
6536
|
-
return type.name;
|
|
6097
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
6098
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).some((i) => val.startsWith(i)) : protocols.map((i) => `${i}://`).some((i) => val.startsWith(i));
|
|
6099
|
+
}
|
|
6100
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
6101
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
6102
|
+
}
|
|
6103
|
+
function isTypeToken(val, kind) {
|
|
6104
|
+
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
6105
|
+
const stripped = stripSurround("<<", ">>")(val);
|
|
6106
|
+
if (TT_KIND_VARIANTS2.some((k) => stripped.startsWith(k))) {
|
|
6107
|
+
if (kind) {
|
|
6108
|
+
if (isAtomicKind(kind)) {
|
|
6109
|
+
return val === `<<${kind}>>`;
|
|
6110
|
+
} else if (isSetBasedKind(kind)) {
|
|
6111
|
+
return val.startsWith(`<<${kind}::`);
|
|
6112
|
+
} else {
|
|
6113
|
+
return val === `<<${kind}>>` || val.startsWith(`<<${kind}::`);
|
|
6537
6114
|
}
|
|
6115
|
+
} else {
|
|
6116
|
+
return true;
|
|
6538
6117
|
}
|
|
6539
6118
|
}
|
|
6119
|
+
return false;
|
|
6540
6120
|
}
|
|
6541
|
-
return
|
|
6121
|
+
return false;
|
|
6542
6122
|
}
|
|
6543
|
-
function
|
|
6544
|
-
|
|
6545
|
-
return validLengths.includes(length);
|
|
6123
|
+
function isTypeTokenKind(val) {
|
|
6124
|
+
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
6546
6125
|
}
|
|
6547
|
-
function
|
|
6548
|
-
|
|
6549
|
-
let double = false;
|
|
6550
|
-
for (let i = num.length - 1; i >= 0; i--) {
|
|
6551
|
-
let n = Number.parseInt(num.charAt(i), 10);
|
|
6552
|
-
if (double) {
|
|
6553
|
-
n *= 2;
|
|
6554
|
-
if (n > 9) {
|
|
6555
|
-
n -= 9;
|
|
6556
|
-
}
|
|
6557
|
-
}
|
|
6558
|
-
sum += n;
|
|
6559
|
-
double = !double;
|
|
6560
|
-
}
|
|
6561
|
-
return sum % 10 === 0;
|
|
6126
|
+
function isAtomicToken(val) {
|
|
6127
|
+
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
6562
6128
|
}
|
|
6563
|
-
function
|
|
6564
|
-
return
|
|
6129
|
+
function isAtomicKind(val) {
|
|
6130
|
+
return isString(val) && TT_ATOMICS2.includes(val);
|
|
6565
6131
|
}
|
|
6566
|
-
function
|
|
6567
|
-
|
|
6568
|
-
return isString(val) && codes.includes(val);
|
|
6132
|
+
function isObjectToken(val) {
|
|
6133
|
+
return isTypeToken(val, "obj");
|
|
6569
6134
|
}
|
|
6570
|
-
function
|
|
6571
|
-
|
|
6572
|
-
return isString(val) && codes.includes(val);
|
|
6135
|
+
function isRecordToken(val) {
|
|
6136
|
+
return isTypeToken(val, "rec");
|
|
6573
6137
|
}
|
|
6574
|
-
function
|
|
6575
|
-
|
|
6576
|
-
return isString(val) && codes.includes(val);
|
|
6138
|
+
function isTupleToken(val) {
|
|
6139
|
+
return isTypeToken(val, "tuple");
|
|
6577
6140
|
}
|
|
6578
|
-
function
|
|
6579
|
-
|
|
6580
|
-
return isString(val) && codes.includes(val);
|
|
6141
|
+
function isArrayToken(val) {
|
|
6142
|
+
return isTypeToken(val, "arr");
|
|
6581
6143
|
}
|
|
6582
|
-
function
|
|
6583
|
-
|
|
6584
|
-
|
|
6144
|
+
function isMapToken(val) {
|
|
6145
|
+
return isTypeToken(val, "map");
|
|
6146
|
+
}
|
|
6147
|
+
function isSetToken(val) {
|
|
6148
|
+
return isTypeToken(val, "set");
|
|
6149
|
+
}
|
|
6150
|
+
function isContainerToken(val) {
|
|
6151
|
+
return isObjectToken(val) || isRecordToken(val) || isTupleToken(val) || isArrayToken(val) || isMapToken(val) || isSetToken(val);
|
|
6152
|
+
}
|
|
6153
|
+
function isShapeCallback(val) {
|
|
6154
|
+
return isFunction(val) && val.kind === "shape";
|
|
6155
|
+
}
|
|
6156
|
+
var token_types = [
|
|
6157
|
+
...TT_ATOMICS2,
|
|
6158
|
+
...TT_CONTAINERS2,
|
|
6159
|
+
...TT_FUNCTIONS2,
|
|
6160
|
+
...TT_SETS2,
|
|
6161
|
+
...TT_SINGLETONS2
|
|
6162
|
+
];
|
|
6163
|
+
function isShapeToken(val) {
|
|
6164
|
+
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
6585
6165
|
}
|
|
6586
|
-
|
|
6587
|
-
|
|
6166
|
+
var split_tokens = SIMPLE_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6167
|
+
var scalar_split_tokens = SIMPLE_SCALAR_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6168
|
+
function isSimpleToken(val) {
|
|
6169
|
+
return isString(val) && split_tokens.some(
|
|
6170
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6171
|
+
);
|
|
6588
6172
|
}
|
|
6589
|
-
function
|
|
6590
|
-
|
|
6591
|
-
|
|
6173
|
+
function isSimpleScalarToken(val) {
|
|
6174
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6175
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6176
|
+
);
|
|
6592
6177
|
}
|
|
6593
|
-
function
|
|
6594
|
-
|
|
6595
|
-
|
|
6178
|
+
function isSimpleContainerToken(val) {
|
|
6179
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6180
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6181
|
+
);
|
|
6596
6182
|
}
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
function isUsStateAbbreviation(val) {
|
|
6600
|
-
return isString(val) && ABBREV.includes(val);
|
|
6183
|
+
function isSimpleTokenTuple(val) {
|
|
6184
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleToken);
|
|
6601
6185
|
}
|
|
6602
|
-
function
|
|
6603
|
-
return
|
|
6186
|
+
function isSimpleScalarTokenTuple(val) {
|
|
6187
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleScalarToken);
|
|
6604
6188
|
}
|
|
6605
|
-
function
|
|
6606
|
-
|
|
6607
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
6189
|
+
function isSimpleContainerTokenTuple(val) {
|
|
6190
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleContainerToken);
|
|
6608
6191
|
}
|
|
6609
|
-
function
|
|
6610
|
-
|
|
6611
|
-
|
|
6192
|
+
function isDefineObject(val) {
|
|
6193
|
+
return isObject(val) && Object.keys(val).some(
|
|
6194
|
+
(key) => isSimpleToken(val[key]) || isShapeToken(val) || isShapeCallback(val)
|
|
6195
|
+
);
|
|
6612
6196
|
}
|
|
6613
|
-
function
|
|
6614
|
-
|
|
6197
|
+
function isFnBasedToken(val) {
|
|
6198
|
+
if (isString(val) && val.startsWith(TT_START2) && val.endsWith(TT_STOP2)) {
|
|
6199
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6200
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6201
|
+
}
|
|
6615
6202
|
}
|
|
6616
|
-
function
|
|
6617
|
-
if (
|
|
6618
|
-
|
|
6203
|
+
function isFnBasedKind(val) {
|
|
6204
|
+
if (isString(val) && isTypeTokenKind(val)) {
|
|
6205
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6206
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
6619
6207
|
}
|
|
6620
|
-
return
|
|
6208
|
+
return false;
|
|
6621
6209
|
}
|
|
6622
|
-
function
|
|
6623
|
-
if (
|
|
6624
|
-
const
|
|
6625
|
-
|
|
6626
|
-
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6210
|
+
function isSetBasedToken(val) {
|
|
6211
|
+
if (isTypeToken(val)) {
|
|
6212
|
+
const kind = getTokenKind(val);
|
|
6213
|
+
return kind.endsWith(`-set`);
|
|
6627
6214
|
}
|
|
6628
6215
|
return false;
|
|
6629
6216
|
}
|
|
6630
|
-
function
|
|
6631
|
-
return
|
|
6217
|
+
function isSetBasedKind(val) {
|
|
6218
|
+
return isString(val) && val.endsWith(`-set`);
|
|
6632
6219
|
}
|
|
6633
|
-
function
|
|
6634
|
-
return (
|
|
6635
|
-
return !!(isConstant(value) && value.kind === kind);
|
|
6636
|
-
};
|
|
6220
|
+
function isSingletonKind(val) {
|
|
6221
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
6637
6222
|
}
|
|
6638
|
-
function
|
|
6639
|
-
|
|
6640
|
-
return !noDefault(value);
|
|
6223
|
+
function isSingletonToken(val) {
|
|
6224
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
6641
6225
|
}
|
|
6642
|
-
function
|
|
6643
|
-
|
|
6644
|
-
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
6226
|
+
function isTailwindColorName(val) {
|
|
6227
|
+
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
6645
6228
|
}
|
|
6646
|
-
function
|
|
6647
|
-
return (val)
|
|
6648
|
-
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
6649
|
-
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
6650
|
-
};
|
|
6229
|
+
function isTailwindColorWithLuminosity(val) {
|
|
6230
|
+
return isString(val) && isTailwindColorName(val.split("-")[0]) && (!["white", "black"].includes(val.split("-")[0]) || val.split("-").length === 1) && (!val.includes("-") || Object.keys(TW_LUMINOSITY2).includes(retainAfter(val, "-")));
|
|
6651
6231
|
}
|
|
6652
|
-
function
|
|
6653
|
-
return isString(val) &&
|
|
6232
|
+
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
6233
|
+
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
6654
6234
|
}
|
|
6655
|
-
function
|
|
6656
|
-
return (val)
|
|
6657
|
-
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
6658
|
-
};
|
|
6235
|
+
function isTailwindColor(val) {
|
|
6236
|
+
return isTailwindColorWithLuminosity(val) || isTailwindColorWithLuminosityAndOpacity(val);
|
|
6659
6237
|
}
|
|
6660
|
-
function
|
|
6661
|
-
return (
|
|
6238
|
+
function isTailwindModifier(val) {
|
|
6239
|
+
return isString(val) && TW_MODIFIERS2.includes(val);
|
|
6662
6240
|
}
|
|
6663
|
-
function
|
|
6664
|
-
return
|
|
6241
|
+
function isTailwindColorTarget(val) {
|
|
6242
|
+
return isString(val) && TW_COLOR_TARGETS2.includes(val);
|
|
6665
6243
|
}
|
|
6666
|
-
function
|
|
6667
|
-
|
|
6668
|
-
|
|
6669
|
-
|
|
6244
|
+
function isTailwindColorClass(val, ...allowedModifiers) {
|
|
6245
|
+
if (isString(val)) {
|
|
6246
|
+
const mods = getTailwindModifiers(val);
|
|
6247
|
+
const targetted = removeTailwindModifiers(val);
|
|
6248
|
+
const target = targetted.split("-")[0];
|
|
6249
|
+
const color = targetted.split("-").slice(1).join("-");
|
|
6250
|
+
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
6251
|
+
}
|
|
6252
|
+
return false;
|
|
6670
6253
|
}
|
|
6671
|
-
|
|
6672
|
-
|
|
6673
|
-
return (
|
|
6674
|
-
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
6675
|
-
};
|
|
6254
|
+
var URL = AUSTRALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6255
|
+
function isAustralianNewsUrl(val) {
|
|
6256
|
+
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
6676
6257
|
}
|
|
6677
|
-
|
|
6678
|
-
|
|
6679
|
-
|
|
6680
|
-
};
|
|
6258
|
+
var URL2 = BELGIUM_NEWS2.flatMap((i) => i.baseUrls);
|
|
6259
|
+
function isBelgiumNewsUrl(val) {
|
|
6260
|
+
return isString(val) && val.startsWith("https://") && (URL2.includes(val) || URL2.some((i) => i.startsWith(`${i}/`)));
|
|
6681
6261
|
}
|
|
6682
|
-
|
|
6683
|
-
|
|
6684
|
-
|
|
6685
|
-
};
|
|
6262
|
+
var URL3 = CANADIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6263
|
+
function isCanadianNewsUrl(val) {
|
|
6264
|
+
return isString(val) && val.startsWith("https://") && (URL3.includes(val) || URL3.some((i) => i.startsWith(`${i}/`)));
|
|
6686
6265
|
}
|
|
6687
|
-
|
|
6688
|
-
|
|
6266
|
+
var URL4 = DANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6267
|
+
function isDanishNewsUrl(val) {
|
|
6268
|
+
return isString(val) && val.startsWith("https://") && (URL4.includes(val) || URL4.some((i) => i.startsWith(`${i}/`)));
|
|
6689
6269
|
}
|
|
6690
|
-
|
|
6691
|
-
|
|
6270
|
+
var URL5 = DUTCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6271
|
+
function isDutchNewsUrl(val) {
|
|
6272
|
+
return isString(val) && val.startsWith("https://") && (URL5.includes(val) || URL5.some((i) => i.startsWith(`${i}/`)));
|
|
6692
6273
|
}
|
|
6693
|
-
|
|
6694
|
-
|
|
6274
|
+
var URL6 = FRENCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6275
|
+
function isFrenchNewsUrl(val) {
|
|
6276
|
+
return isString(val) && val.startsWith("https://") && (URL6.includes(val) || URL6.some((i) => i.startsWith(`${i}/`)));
|
|
6695
6277
|
}
|
|
6696
|
-
|
|
6697
|
-
|
|
6278
|
+
var URL7 = GERMAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6279
|
+
function isGermanNewsUrl(val) {
|
|
6280
|
+
return isString(val) && val.startsWith("https://") && (URL7.includes(val) || URL7.some((i) => i.startsWith(`${i}/`)));
|
|
6698
6281
|
}
|
|
6699
|
-
|
|
6700
|
-
|
|
6282
|
+
var URL8 = INDIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6283
|
+
function isIndianNewsUrl(val) {
|
|
6284
|
+
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
6701
6285
|
}
|
|
6702
|
-
|
|
6703
|
-
|
|
6286
|
+
var URL9 = ITALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6287
|
+
function isItalianNewsUrl(val) {
|
|
6288
|
+
return isString(val) && val.startsWith("https://") && (URL9.includes(val) || URL9.some((i) => i.startsWith(`${i}/`)));
|
|
6704
6289
|
}
|
|
6705
|
-
|
|
6706
|
-
|
|
6290
|
+
var URL10 = JAPANESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6291
|
+
function isJapaneseNewsUrl(val) {
|
|
6292
|
+
return isString(val) && val.startsWith("https://") && (URL10.includes(val) || URL10.some((i) => i.startsWith(`${i}/`)));
|
|
6707
6293
|
}
|
|
6708
|
-
var
|
|
6709
|
-
|
|
6710
|
-
"
|
|
6711
|
-
"initial",
|
|
6712
|
-
"revert",
|
|
6713
|
-
"revert-layer",
|
|
6714
|
-
"unset",
|
|
6715
|
-
"auto"
|
|
6716
|
-
];
|
|
6717
|
-
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
6718
|
-
function isCssAspectRatio(val) {
|
|
6719
|
-
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6294
|
+
var URL11 = MEXICAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6295
|
+
function isMexicanNewsUrl(val) {
|
|
6296
|
+
return isString(val) && val.startsWith("https://") && (URL11.includes(val) || URL11.some((i) => i.startsWith(`${i}/`)));
|
|
6720
6297
|
}
|
|
6721
|
-
|
|
6722
|
-
|
|
6298
|
+
var URL12 = NORWEGIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6299
|
+
function isNorwegianNewsUrl(val) {
|
|
6300
|
+
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
6723
6301
|
}
|
|
6724
|
-
|
|
6725
|
-
|
|
6302
|
+
var URL13 = SOUTH_KOREAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6303
|
+
function isSouthKoreanNewsUrl(val) {
|
|
6304
|
+
return isString(val) && val.startsWith("https://") && (URL13.includes(val) || URL13.some((i) => i.startsWith(`${i}/`)));
|
|
6726
6305
|
}
|
|
6727
|
-
|
|
6728
|
-
|
|
6306
|
+
var URL14 = SPANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6307
|
+
function isSpanishNewsUrl(val) {
|
|
6308
|
+
return isString(val) && val.startsWith("https://") && (URL14.includes(val) || URL14.some((i) => i.startsWith(`${i}/`)));
|
|
6729
6309
|
}
|
|
6730
|
-
|
|
6731
|
-
|
|
6732
|
-
|
|
6733
|
-
}
|
|
6734
|
-
const parts = val?.split("@");
|
|
6735
|
-
const domain = parts[1]?.split(".");
|
|
6736
|
-
const tld = domain ? domain.pop() : "";
|
|
6737
|
-
const firstChar = val[0].toLowerCase();
|
|
6738
|
-
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
6310
|
+
var URL15 = SWISS_NEWS2.flatMap((i) => i.baseUrls);
|
|
6311
|
+
function isSwissNewsUrl(val) {
|
|
6312
|
+
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
6739
6313
|
}
|
|
6740
|
-
|
|
6741
|
-
|
|
6314
|
+
var URL16 = TURKISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6315
|
+
function isTurkishNewsUrl(val) {
|
|
6316
|
+
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
6742
6317
|
}
|
|
6743
|
-
|
|
6744
|
-
|
|
6318
|
+
var URL17 = UK_NEWS2.flatMap((i) => i.baseUrls);
|
|
6319
|
+
function isUkNewsUrl(val) {
|
|
6320
|
+
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
6745
6321
|
}
|
|
6746
|
-
|
|
6747
|
-
|
|
6322
|
+
var URL18 = US_NEWS2.flatMap((i) => i.baseUrls);
|
|
6323
|
+
function isUsNewsUrl(val) {
|
|
6324
|
+
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
6325
|
+
}
|
|
6326
|
+
var URL19 = CHINESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6327
|
+
function isChineseNewsUrl(val) {
|
|
6328
|
+
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
6329
|
+
}
|
|
6330
|
+
function isNewsUrl(val) {
|
|
6331
|
+
return isAustralianNewsUrl(val) || isBelgiumNewsUrl(val) || isCanadianNewsUrl(val) || isDanishNewsUrl(val) || isDutchNewsUrl(val) || isFrenchNewsUrl(val) || isGermanNewsUrl(val) || isIndianNewsUrl(val) || isItalianNewsUrl(val) || isJapaneseNewsUrl(val) || isMexicanNewsUrl(val) || isNorwegianNewsUrl(val) || isSouthKoreanNewsUrl(val) || isSpanishNewsUrl(val) || isSwissNewsUrl(val) || isTurkishNewsUrl(val) || isUkNewsUrl(val) || isUsNewsUrl(val);
|
|
6332
|
+
}
|
|
6333
|
+
function isBitbucketUrl(val) {
|
|
6334
|
+
const valid2 = REPO_SOURCE_LOOKUP2.bitbucket;
|
|
6335
|
+
return isString(val) && valid2.some(
|
|
6336
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6337
|
+
);
|
|
6748
6338
|
}
|
|
6749
|
-
function
|
|
6750
|
-
|
|
6339
|
+
function isCodeCommitUrl(val) {
|
|
6340
|
+
const valid2 = REPO_SOURCE_LOOKUP2.codecommit;
|
|
6341
|
+
return isString(val) && valid2.some(
|
|
6342
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6343
|
+
);
|
|
6751
6344
|
}
|
|
6752
|
-
function
|
|
6753
|
-
|
|
6345
|
+
function isGithubUrl(val) {
|
|
6346
|
+
const valid2 = [
|
|
6347
|
+
"https://github.com",
|
|
6348
|
+
"https://www.github.com",
|
|
6349
|
+
"https://github.io"
|
|
6350
|
+
];
|
|
6351
|
+
return isString(val) && valid2.some(
|
|
6352
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
6353
|
+
);
|
|
6754
6354
|
}
|
|
6755
|
-
function
|
|
6756
|
-
return
|
|
6355
|
+
function isGithubOrgUrl(val) {
|
|
6356
|
+
return isString(val) && (val.startsWith("https://github.com/") && stripper(val).length === 2);
|
|
6757
6357
|
}
|
|
6758
|
-
function
|
|
6759
|
-
return
|
|
6358
|
+
function stripper(s) {
|
|
6359
|
+
return stripTrailing(
|
|
6360
|
+
stripLeading(s, "https://github.com/"),
|
|
6361
|
+
"/"
|
|
6362
|
+
);
|
|
6760
6363
|
}
|
|
6761
|
-
function
|
|
6762
|
-
return !!(
|
|
6364
|
+
function isGithubRepoUrl(val) {
|
|
6365
|
+
return !!(isString(val) && (val.startsWith("https://github.com/") && stripper(val).split("/").length === 2));
|
|
6763
6366
|
}
|
|
6764
|
-
function
|
|
6765
|
-
return isString(
|
|
6367
|
+
function isGithubRepoReleasesUrl(val) {
|
|
6368
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases") && stripper(val).split("/").length === 3);
|
|
6766
6369
|
}
|
|
6767
|
-
function
|
|
6768
|
-
return val
|
|
6370
|
+
function isGithubRepoReleaseTagUrl(val) {
|
|
6371
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).length === 4);
|
|
6769
6372
|
}
|
|
6770
|
-
function
|
|
6771
|
-
return
|
|
6373
|
+
function isGithubIssuesListUrl(val) {
|
|
6374
|
+
return isString(val) && val.startsWith("https://github.com/") && val.includes("/issues");
|
|
6772
6375
|
}
|
|
6773
|
-
function
|
|
6774
|
-
return
|
|
6376
|
+
function isGithubIssueUrl(val) {
|
|
6377
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/issues/"));
|
|
6775
6378
|
}
|
|
6776
|
-
function
|
|
6777
|
-
return
|
|
6379
|
+
function isGithubProjectsListUrl(val) {
|
|
6380
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/projects?") || val.trim().endsWith("/projects")) && stripper(val).split("/").length === 3);
|
|
6778
6381
|
}
|
|
6779
|
-
function
|
|
6780
|
-
return
|
|
6382
|
+
function isGithubProjectUrl(val) {
|
|
6383
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/projects/") && stripper(val).split("/").length === 4);
|
|
6781
6384
|
}
|
|
6782
|
-
function
|
|
6783
|
-
|
|
6784
|
-
const chars = svelte.split("");
|
|
6785
|
-
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
6786
|
-
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
6787
|
-
const nothing = stripChars(svelte, ...[
|
|
6788
|
-
...NUMERIC_CHAR2,
|
|
6789
|
-
...WHITESPACE_CHARS2,
|
|
6790
|
-
"(",
|
|
6791
|
-
")",
|
|
6792
|
-
"+",
|
|
6793
|
-
".",
|
|
6794
|
-
"-"
|
|
6795
|
-
]);
|
|
6796
|
-
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
6385
|
+
function isGithubReleasesListUrl(val) {
|
|
6386
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/releases?") || val.trim().endsWith("/releases")) && stripper(val).split("/").length === 3);
|
|
6797
6387
|
}
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
if (isString(val)) {
|
|
6801
|
-
return start.some((i) => val.trimStart().startsWith(i));
|
|
6802
|
-
}
|
|
6803
|
-
return false;
|
|
6388
|
+
function isGithubReleaseTagUrl(val) {
|
|
6389
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).split("/").length === 5);
|
|
6804
6390
|
}
|
|
6805
|
-
function
|
|
6806
|
-
|
|
6807
|
-
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
6808
|
-
}
|
|
6809
|
-
return false;
|
|
6391
|
+
function isRepoSource(v) {
|
|
6392
|
+
return isString(v) && REPO_SOURCES2.includes(v);
|
|
6810
6393
|
}
|
|
6811
|
-
function
|
|
6812
|
-
|
|
6813
|
-
const cc = getPhoneCountryCode(val);
|
|
6814
|
-
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
6815
|
-
switch (cc) {
|
|
6816
|
-
case "1":
|
|
6817
|
-
return without.length === 10;
|
|
6818
|
-
case "44":
|
|
6819
|
-
return !![10, 11].includes(without.length);
|
|
6820
|
-
case "":
|
|
6821
|
-
return without.length <= 10;
|
|
6822
|
-
default:
|
|
6823
|
-
return without.length <= 11;
|
|
6824
|
-
}
|
|
6825
|
-
}
|
|
6826
|
-
return false;
|
|
6394
|
+
function isSemanticVersion(v, allowPrefix = false) {
|
|
6395
|
+
return isString(v) && v.split(".").length === 3 && !Number.isNaN(Number(v.split(".")[1])) && !Number.isNaN(Number(v.split(".")[2])) && (!Number.isNaN(Number(v.split(".")[0])) || allowPrefix && !Number.isNaN(Number(stripLeading(v.split(".")[0], "v").trim())));
|
|
6827
6396
|
}
|
|
6828
|
-
function
|
|
6829
|
-
return
|
|
6397
|
+
function isRepoUrl(val) {
|
|
6398
|
+
return isGithubUrl(val) || isBitbucketUrl(val) || isCodeCommitUrl(val);
|
|
6830
6399
|
}
|
|
6831
|
-
function
|
|
6832
|
-
return
|
|
6400
|
+
function isWholeFoodsUrl(val) {
|
|
6401
|
+
return isString(val) && WHOLE_FOODS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6833
6402
|
}
|
|
6834
|
-
function
|
|
6835
|
-
return val
|
|
6403
|
+
function isCvsUrl(val) {
|
|
6404
|
+
return isString(val) && CVS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6836
6405
|
}
|
|
6837
|
-
function
|
|
6838
|
-
|
|
6839
|
-
return true;
|
|
6840
|
-
}
|
|
6841
|
-
if (isString(val)) {
|
|
6842
|
-
try {
|
|
6843
|
-
const _re = new RegExp(val);
|
|
6844
|
-
return true;
|
|
6845
|
-
} catch {
|
|
6846
|
-
return false;
|
|
6847
|
-
}
|
|
6848
|
-
}
|
|
6849
|
-
return false;
|
|
6406
|
+
function isWalgreensUrl(val) {
|
|
6407
|
+
return isString(val) && WALGREENS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6850
6408
|
}
|
|
6851
|
-
function
|
|
6852
|
-
return
|
|
6409
|
+
function isKrogersUrl(val) {
|
|
6410
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6853
6411
|
}
|
|
6854
|
-
function
|
|
6855
|
-
return isString(
|
|
6412
|
+
function isZaraUrl(val) {
|
|
6413
|
+
return isString(val) && ZARA_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6856
6414
|
}
|
|
6857
|
-
function
|
|
6858
|
-
return
|
|
6415
|
+
function isHmUrl(val) {
|
|
6416
|
+
return isString(val) && HM_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6859
6417
|
}
|
|
6860
|
-
function
|
|
6861
|
-
return val
|
|
6418
|
+
function isDellUrl(val) {
|
|
6419
|
+
return isString(val) && DELL_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6862
6420
|
}
|
|
6863
|
-
function
|
|
6864
|
-
return
|
|
6421
|
+
function isIkeaUrl(val) {
|
|
6422
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6865
6423
|
}
|
|
6866
|
-
function
|
|
6867
|
-
return
|
|
6424
|
+
function isLowesUrl(val) {
|
|
6425
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6868
6426
|
}
|
|
6869
|
-
function
|
|
6870
|
-
return isString(val) &&
|
|
6427
|
+
function isNikeUrl(val) {
|
|
6428
|
+
return isString(val) && NIKE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6871
6429
|
}
|
|
6872
|
-
function
|
|
6873
|
-
return
|
|
6430
|
+
function isWayfairUrl(val) {
|
|
6431
|
+
return isString(val) && WAYFAIR_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6874
6432
|
}
|
|
6875
|
-
function
|
|
6876
|
-
return
|
|
6433
|
+
function isBestBuyUrl(val) {
|
|
6434
|
+
return isString(val) && BEST_BUY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6877
6435
|
}
|
|
6878
|
-
function
|
|
6879
|
-
return isString(val) &&
|
|
6436
|
+
function isCostCoUrl(val) {
|
|
6437
|
+
return isString(val) && COSTCO_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6880
6438
|
}
|
|
6881
|
-
function
|
|
6882
|
-
return
|
|
6439
|
+
function isEtsyUrl(val) {
|
|
6440
|
+
return isString(val) && ETSY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6883
6441
|
}
|
|
6884
|
-
function
|
|
6885
|
-
return
|
|
6442
|
+
function isTargetUrl(val) {
|
|
6443
|
+
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6886
6444
|
}
|
|
6887
|
-
function
|
|
6888
|
-
return
|
|
6445
|
+
function isEbayUrl(val) {
|
|
6446
|
+
return isString(val) && EBAY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6889
6447
|
}
|
|
6890
|
-
function
|
|
6891
|
-
|
|
6892
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6448
|
+
function isHomeDepotUrl(val) {
|
|
6449
|
+
return isString(val) && HOME_DEPOT_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6893
6450
|
}
|
|
6894
|
-
function
|
|
6895
|
-
|
|
6896
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6451
|
+
function isMacysUrl(val) {
|
|
6452
|
+
return isString(val) && MACYS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6897
6453
|
}
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
...NUMERIC_CHAR2,
|
|
6901
|
-
"_",
|
|
6902
|
-
"."
|
|
6903
|
-
];
|
|
6904
|
-
var alpha = null;
|
|
6905
|
-
function valid(chars) {
|
|
6906
|
-
return chars.every((i) => VALID.includes(i));
|
|
6454
|
+
function isAppleUrl(val) {
|
|
6455
|
+
return isString(val) && APPLE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6907
6456
|
}
|
|
6908
|
-
function
|
|
6909
|
-
return isString(val) &&
|
|
6457
|
+
function isWalmartUrl(val) {
|
|
6458
|
+
return isString(val) && WALMART_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6910
6459
|
}
|
|
6911
|
-
function
|
|
6912
|
-
return
|
|
6460
|
+
function isAmazonUrl(val) {
|
|
6461
|
+
return isString(val) && AMAZON_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
6913
6462
|
}
|
|
6914
|
-
function
|
|
6915
|
-
return
|
|
6463
|
+
function isRetailUrl(val) {
|
|
6464
|
+
return isAmazonUrl(val) || isWalgreensUrl(val) || isAppleUrl(val) || isMacysUrl(val) || isEbayUrl(val) || isHomeDepotUrl(val) || isTargetUrl(val) || isEtsyUrl(val) || isCostCoUrl(val) || isBestBuyUrl(val) || isWayfairUrl(val) || isNikeUrl(val) || isLowesUrl(val) || isIkeaUrl(val) || isDellUrl(val) || isHmUrl(val) || isZaraUrl(val) || isKrogersUrl(val) || isWalgreensUrl(val) || isCvsUrl(val) || isWholeFoodsUrl(val);
|
|
6916
6465
|
}
|
|
6917
|
-
|
|
6918
|
-
|
|
6466
|
+
var URL20 = SOCIAL_MEDIA2.flatMap((i) => i.baseUrls);
|
|
6467
|
+
var PROFILE = SOCIAL_MEDIA2.map((i) => i.profileUrl);
|
|
6468
|
+
function isSocialMediaUrl(val) {
|
|
6469
|
+
return isString(val) && URL20.some((i) => val.startsWith(i));
|
|
6919
6470
|
}
|
|
6920
|
-
function
|
|
6921
|
-
return isString(val) &&
|
|
6471
|
+
function isSocialMediaProfileUrl(val) {
|
|
6472
|
+
return isString(val) && PROFILE.some((i) => i.startsWith(`${i}`));
|
|
6922
6473
|
}
|
|
6923
|
-
function
|
|
6924
|
-
return isString(val) &&
|
|
6474
|
+
function isYouTubeUrl(val) {
|
|
6475
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
6925
6476
|
}
|
|
6926
|
-
function
|
|
6927
|
-
return isString(val) &&
|
|
6477
|
+
function isYouTubeShareUrl(val) {
|
|
6478
|
+
return isString(val) && val.startsWith(`https://youtu.be`);
|
|
6928
6479
|
}
|
|
6929
|
-
function
|
|
6930
|
-
return isString(val) &&
|
|
6480
|
+
function isYouTubeVideoUrl(val) {
|
|
6481
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
6931
6482
|
}
|
|
6932
|
-
function
|
|
6933
|
-
return isString(val) &&
|
|
6483
|
+
function isYouTubePlaylistUrl(val) {
|
|
6484
|
+
return isString(val) && (val === `https://www.youtube.com/feed/playlists` || val === `https://youtube.com/feed/playlists` || val === `https://www.youtube.com/channel/playlists` || val === `https://youtube.com/channel/playlists` || val.startsWith(`https://www.youtube.com/@`) && val.endsWith(`/playlists`) || val.startsWith(`https://youtube.com/@`) && val.endsWith(`/playlists`));
|
|
6934
6485
|
}
|
|
6935
|
-
function
|
|
6936
|
-
return
|
|
6486
|
+
function feed_map(type) {
|
|
6487
|
+
return isUndefined(type) ? `/feed` : type === "liked" ? `/playlist?list=LL` : ["history", "playlists", "trending", "subscriptions"].includes(type) ? `/feed/${type}` : `/feed/`;
|
|
6937
6488
|
}
|
|
6938
|
-
function
|
|
6939
|
-
return isString(val) &&
|
|
6489
|
+
function isYouTubeFeedUrl(val, type) {
|
|
6490
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com${feed_map(type)}`) || val.startsWith(`https://youtube.com${feed_map(type)}`));
|
|
6940
6491
|
}
|
|
6941
|
-
function
|
|
6942
|
-
return isString(val) &&
|
|
6492
|
+
function isYouTubeFeedHistoryUrl(val) {
|
|
6493
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/history`) || val.startsWith(`https://youtube.com/feed/history`));
|
|
6943
6494
|
}
|
|
6944
|
-
function
|
|
6945
|
-
return isString(val) &&
|
|
6495
|
+
function isYouTubePlaylistsUrl(val) {
|
|
6496
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/playlists`) || val.startsWith(`https://youtube.com/feed/playlists`));
|
|
6946
6497
|
}
|
|
6947
|
-
function
|
|
6948
|
-
return isString(val) &&
|
|
6498
|
+
function isYouTubeTrendingUrl(val) {
|
|
6499
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/trending`) || val.startsWith(`https://youtube.com/feed/trending`));
|
|
6949
6500
|
}
|
|
6950
|
-
function
|
|
6951
|
-
return isString(val) &&
|
|
6501
|
+
function isYouTubeSubscriptionsUrl(val) {
|
|
6502
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/subscriptions`) || val.startsWith(`https://youtube.com/feed/subscriptions`));
|
|
6952
6503
|
}
|
|
6953
|
-
function
|
|
6954
|
-
|
|
6955
|
-
return isString(val) && speed.includes(separate(val));
|
|
6504
|
+
function isYouTubeCreatorUrl(url) {
|
|
6505
|
+
return isString(url) && (url.startsWith(`https://www.youtube.com/@`) || url.startsWith(`https://youtube.com/@`) || url.startsWith(`https://www.youtube.com/channel/`));
|
|
6956
6506
|
}
|
|
6957
|
-
function
|
|
6958
|
-
return isString(val) &&
|
|
6507
|
+
function isYouTubeVideosInPlaylist(val) {
|
|
6508
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
6959
6509
|
}
|
|
6960
|
-
function
|
|
6961
|
-
|
|
6510
|
+
function isVueRef(val) {
|
|
6511
|
+
if (isObject(val)) {
|
|
6512
|
+
const keys = Object.keys(val);
|
|
6513
|
+
return !!["dep", "__v_isRef"].every((i) => keys.includes(i));
|
|
6514
|
+
}
|
|
6515
|
+
return false;
|
|
6962
6516
|
}
|
|
6963
|
-
function
|
|
6964
|
-
return
|
|
6517
|
+
function filterUndefined(...val) {
|
|
6518
|
+
return val.filter((i) => isDefined(i));
|
|
6965
6519
|
}
|
|
6966
|
-
function
|
|
6967
|
-
return
|
|
6520
|
+
function find(list2, deref = null) {
|
|
6521
|
+
return (comparator) => {
|
|
6522
|
+
return list2.find((i) => {
|
|
6523
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
6524
|
+
return val === comparator;
|
|
6525
|
+
});
|
|
6526
|
+
};
|
|
6968
6527
|
}
|
|
6969
|
-
function
|
|
6970
|
-
|
|
6528
|
+
function getEach(list2, dotPath) {
|
|
6529
|
+
const result2 = list2.map(
|
|
6530
|
+
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
6531
|
+
).filter((i) => !isErrorCondition(i));
|
|
6532
|
+
return result2;
|
|
6971
6533
|
}
|
|
6972
|
-
function
|
|
6973
|
-
|
|
6534
|
+
function indexOf(val, index) {
|
|
6535
|
+
const isNegative = isNumber(index) && index < 0;
|
|
6536
|
+
if (isNegative && !Array.isArray(val)) {
|
|
6537
|
+
throw new Error(`The indexOf(val,idx) utility received a negative index value [${index}] but the value being de-references is not an array [${typeof val}]!`);
|
|
6538
|
+
}
|
|
6539
|
+
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
6540
|
+
throw new Error(`The indexOf(val,idx) utility received a negative index of ${index} but the length of the array passed in is only ${val.length}! This is not allowed.`);
|
|
6541
|
+
}
|
|
6542
|
+
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
6543
|
+
return index === null ? val : isNull(idx) ? val : isArray(val) ? Number(idx) in val ? val[Number(idx)] : errCondition("invalid-index", `attempt to index a numeric array with an invalid index: ${Number(idx)}`) : isObject(val) ? String(idx) in val ? val[String(idx)] : errCondition("invalid-index", `attempt to index a dictionary object with an invalid index: ${String(idx)}`) : errCondition("invalid-container-type", `Attempt to use indexOf() on an invalid container type: ${typeof val}`);
|
|
6974
6544
|
}
|
|
6975
|
-
function
|
|
6976
|
-
|
|
6545
|
+
function intersectWithOffset(a, b, deref) {
|
|
6546
|
+
const aIndexable = a.every((i) => isIndexable(i));
|
|
6547
|
+
const bIndexable = b.every((i) => isIndexable(i));
|
|
6548
|
+
if (!aIndexable || !bIndexable) {
|
|
6549
|
+
if (!aIndexable) {
|
|
6550
|
+
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
6551
|
+
} else {
|
|
6552
|
+
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
6553
|
+
}
|
|
6554
|
+
}
|
|
6555
|
+
const aMatches = getEach(a, deref);
|
|
6556
|
+
const bMatches = getEach(b, deref);
|
|
6557
|
+
const sharedKeys2 = ifNotNull(
|
|
6558
|
+
deref,
|
|
6559
|
+
(v) => [
|
|
6560
|
+
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
6561
|
+
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
6562
|
+
],
|
|
6563
|
+
() => a.filter((k) => b.includes(k))
|
|
6564
|
+
);
|
|
6565
|
+
return sharedKeys2;
|
|
6977
6566
|
}
|
|
6978
|
-
function
|
|
6979
|
-
return
|
|
6567
|
+
function intersectNoOffset(a, b) {
|
|
6568
|
+
return a.length < b.length ? a.filter((val) => b.includes(val)) : b.filter((val) => a.includes(val));
|
|
6980
6569
|
}
|
|
6981
|
-
function
|
|
6982
|
-
return
|
|
6570
|
+
function intersection(a, b, deref = null) {
|
|
6571
|
+
return deref === null ? intersectNoOffset(a, b) : intersectWithOffset(a, b, deref);
|
|
6983
6572
|
}
|
|
6984
|
-
function
|
|
6985
|
-
return
|
|
6573
|
+
function joinWith(joinWith2) {
|
|
6574
|
+
return (...tuple3) => {
|
|
6575
|
+
const tup = tuple3;
|
|
6576
|
+
return tup.join(joinWith2);
|
|
6577
|
+
};
|
|
6986
6578
|
}
|
|
6987
|
-
function
|
|
6988
|
-
return
|
|
6579
|
+
function last(list2) {
|
|
6580
|
+
return [...list2].pop();
|
|
6989
6581
|
}
|
|
6990
|
-
function
|
|
6991
|
-
return
|
|
6582
|
+
function logicalReturns(conditions) {
|
|
6583
|
+
return conditions.map(
|
|
6584
|
+
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
6585
|
+
);
|
|
6992
6586
|
}
|
|
6993
|
-
function
|
|
6994
|
-
return
|
|
6587
|
+
function reverse(list2) {
|
|
6588
|
+
return [...list2].reverse();
|
|
6995
6589
|
}
|
|
6996
|
-
function
|
|
6997
|
-
|
|
6590
|
+
function shift(list2) {
|
|
6591
|
+
let rtn;
|
|
6592
|
+
if (isDefined(list2)) {
|
|
6593
|
+
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
6594
|
+
try {
|
|
6595
|
+
list2 = list2.slice(1);
|
|
6596
|
+
} catch {
|
|
6597
|
+
}
|
|
6598
|
+
} else {
|
|
6599
|
+
rtn = void 0;
|
|
6600
|
+
}
|
|
6601
|
+
return rtn;
|
|
6998
6602
|
}
|
|
6999
|
-
function
|
|
7000
|
-
return
|
|
6603
|
+
function slice(list2, start2, end) {
|
|
6604
|
+
return list2.slice(start2, end);
|
|
7001
6605
|
}
|
|
7002
|
-
function
|
|
7003
|
-
|
|
6606
|
+
function unique(...values) {
|
|
6607
|
+
const u = [];
|
|
6608
|
+
for (const i of values.flat()) {
|
|
6609
|
+
if (!u.includes(i)) {
|
|
6610
|
+
u.push(i);
|
|
6611
|
+
}
|
|
6612
|
+
}
|
|
6613
|
+
return u;
|
|
7004
6614
|
}
|
|
7005
|
-
function
|
|
7006
|
-
|
|
6615
|
+
function box(value) {
|
|
6616
|
+
const rtn = {
|
|
6617
|
+
__type: "box",
|
|
6618
|
+
value,
|
|
6619
|
+
unbox: (...p) => {
|
|
6620
|
+
return typeof value === "function" ? value(...p) : value;
|
|
6621
|
+
}
|
|
6622
|
+
};
|
|
6623
|
+
return rtn;
|
|
7007
6624
|
}
|
|
7008
|
-
function
|
|
7009
|
-
return
|
|
6625
|
+
function isBox(thing) {
|
|
6626
|
+
return typeof thing === "object" && "__type" in thing && thing.__type === "box";
|
|
7010
6627
|
}
|
|
7011
|
-
function
|
|
7012
|
-
|
|
6628
|
+
function boxDictionaryValues(dict) {
|
|
6629
|
+
const keys = Object.keys(dict);
|
|
6630
|
+
return keys.reduce(
|
|
6631
|
+
(acc, key) => ({ ...acc, [key]: box(dict[key]) }),
|
|
6632
|
+
{}
|
|
6633
|
+
);
|
|
7013
6634
|
}
|
|
7014
|
-
function
|
|
7015
|
-
return
|
|
6635
|
+
function unbox(val) {
|
|
6636
|
+
return isBox(val) ? val.value : val;
|
|
7016
6637
|
}
|
|
7017
|
-
function
|
|
7018
|
-
return
|
|
6638
|
+
function capitalize(str) {
|
|
6639
|
+
return `${str?.slice(0, 1).toUpperCase()}${str?.slice(1)}`;
|
|
7019
6640
|
}
|
|
7020
|
-
function
|
|
7021
|
-
|
|
7022
|
-
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
6641
|
+
function cssColor(color, v1, v2, v3, opacity) {
|
|
6642
|
+
return `color(${color} ${v1} ${v2} ${v3}${opacity ? ` / ${opacity}` : ""}`;
|
|
7023
6643
|
}
|
|
7024
|
-
function
|
|
7025
|
-
|
|
6644
|
+
function twColor(color, luminosity) {
|
|
6645
|
+
const lum = luminosity in TW_LUMINOSITY2 ? TW_LUMINOSITY2[luminosity] : 0;
|
|
6646
|
+
const chroma = luminosity in TW_CHROMA2 ? TW_CHROMA2[luminosity] : 0;
|
|
6647
|
+
const hue = TW_HUE2[color];
|
|
6648
|
+
return `oklch(${lum} ${chroma} ${hue})`;
|
|
7026
6649
|
}
|
|
7027
|
-
function
|
|
7028
|
-
|
|
6650
|
+
function ensureLeading(content, ensure) {
|
|
6651
|
+
const output = String(content);
|
|
6652
|
+
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
7029
6653
|
}
|
|
7030
|
-
function
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
6654
|
+
function ensureSurround(prefix, postfix) {
|
|
6655
|
+
const fn2 = (input) => {
|
|
6656
|
+
let result2 = input;
|
|
6657
|
+
result2 = ensureLeading(result2, prefix);
|
|
6658
|
+
result2 = ensureTrailing(result2, postfix);
|
|
6659
|
+
return result2;
|
|
6660
|
+
};
|
|
6661
|
+
return fn2;
|
|
7034
6662
|
}
|
|
7035
|
-
function
|
|
7036
|
-
return
|
|
7037
|
-
|
|
6663
|
+
function ensureTrailing(content, ensure) {
|
|
6664
|
+
return (
|
|
6665
|
+
//
|
|
6666
|
+
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
7038
6667
|
);
|
|
7039
6668
|
}
|
|
7040
|
-
function
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
|
|
6669
|
+
function getTypeSubtype(str) {
|
|
6670
|
+
if (isTypeSubtype(str)) {
|
|
6671
|
+
const [t, st] = str.split("/");
|
|
6672
|
+
return [t, st];
|
|
6673
|
+
} else {
|
|
6674
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
6675
|
+
err.name = "InvalidTypeSubtype";
|
|
6676
|
+
throw err;
|
|
6677
|
+
}
|
|
7045
6678
|
}
|
|
7046
|
-
function
|
|
7047
|
-
return
|
|
6679
|
+
function identity(...values) {
|
|
6680
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
7048
6681
|
}
|
|
7049
|
-
function
|
|
7050
|
-
|
|
6682
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
6683
|
+
if (ch.length !== 1) {
|
|
6684
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
6685
|
+
}
|
|
6686
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7051
6687
|
}
|
|
7052
|
-
function
|
|
7053
|
-
|
|
6688
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
6689
|
+
if (ch.length !== 1) {
|
|
6690
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
6691
|
+
}
|
|
6692
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7054
6693
|
}
|
|
7055
|
-
function
|
|
7056
|
-
|
|
6694
|
+
function parseTemplate(template) {
|
|
6695
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6696
|
+
let lastIndex = 0;
|
|
6697
|
+
let match;
|
|
6698
|
+
const segments = [];
|
|
6699
|
+
while (match = pattern.exec(template)) {
|
|
6700
|
+
const [fullMatch, varName, asType2] = match;
|
|
6701
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
6702
|
+
if (staticPart) {
|
|
6703
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
6704
|
+
}
|
|
6705
|
+
segments.push({
|
|
6706
|
+
dynamic: true,
|
|
6707
|
+
varName,
|
|
6708
|
+
type: asType2 ? asType2 : "string"
|
|
6709
|
+
});
|
|
6710
|
+
lastIndex = match.index + fullMatch.length;
|
|
6711
|
+
}
|
|
6712
|
+
const remainder = template.slice(lastIndex);
|
|
6713
|
+
if (remainder) {
|
|
6714
|
+
segments.push({ dynamic: false, text: remainder });
|
|
6715
|
+
}
|
|
6716
|
+
return segments;
|
|
7057
6717
|
}
|
|
7058
|
-
function
|
|
7059
|
-
return
|
|
6718
|
+
function escapeRegex(str) {
|
|
6719
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7060
6720
|
}
|
|
7061
|
-
function
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
if (
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7068
|
-
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
6721
|
+
function buildRegexPattern(segments) {
|
|
6722
|
+
let regexStr = "^";
|
|
6723
|
+
for (const seg of segments) {
|
|
6724
|
+
if (!seg.dynamic) {
|
|
6725
|
+
regexStr += escapeRegex(seg.text);
|
|
6726
|
+
} else {
|
|
6727
|
+
switch (seg.type) {
|
|
6728
|
+
case "string":
|
|
6729
|
+
regexStr += "(.*?)";
|
|
6730
|
+
break;
|
|
6731
|
+
case "number":
|
|
6732
|
+
regexStr += "(\\d+)";
|
|
6733
|
+
break;
|
|
6734
|
+
case "boolean":
|
|
6735
|
+
regexStr += "(true|false)";
|
|
6736
|
+
break;
|
|
7075
6737
|
}
|
|
7076
6738
|
}
|
|
7077
|
-
return false;
|
|
7078
6739
|
}
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
function isTypeTokenKind(val) {
|
|
7082
|
-
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
7083
|
-
}
|
|
7084
|
-
function isAtomicToken(val) {
|
|
7085
|
-
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
6740
|
+
regexStr += "$";
|
|
6741
|
+
return new RegExp(regexStr);
|
|
7086
6742
|
}
|
|
7087
|
-
function
|
|
7088
|
-
|
|
6743
|
+
function convertValue(type, value) {
|
|
6744
|
+
switch (type) {
|
|
6745
|
+
case "string":
|
|
6746
|
+
return value;
|
|
6747
|
+
case "number":
|
|
6748
|
+
return Number(value);
|
|
6749
|
+
case "boolean":
|
|
6750
|
+
return value === "true";
|
|
6751
|
+
}
|
|
7089
6752
|
}
|
|
7090
|
-
function
|
|
7091
|
-
|
|
6753
|
+
function matchTemplate(template, test) {
|
|
6754
|
+
const segments = parseTemplate(template);
|
|
6755
|
+
const regex = buildRegexPattern(segments);
|
|
6756
|
+
const match = regex.exec(test);
|
|
6757
|
+
if (!match)
|
|
6758
|
+
return false;
|
|
6759
|
+
let captureIndex = 1;
|
|
6760
|
+
const result2 = {};
|
|
6761
|
+
for (const seg of segments) {
|
|
6762
|
+
if (seg.dynamic) {
|
|
6763
|
+
const rawVal = match[captureIndex++];
|
|
6764
|
+
if (rawVal === void 0)
|
|
6765
|
+
return false;
|
|
6766
|
+
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
6767
|
+
}
|
|
6768
|
+
}
|
|
6769
|
+
return result2;
|
|
7092
6770
|
}
|
|
7093
|
-
function
|
|
7094
|
-
return
|
|
6771
|
+
function infer(inference) {
|
|
6772
|
+
return (test) => {
|
|
6773
|
+
return matchTemplate(inference, test);
|
|
6774
|
+
};
|
|
7095
6775
|
}
|
|
7096
|
-
function
|
|
7097
|
-
return
|
|
6776
|
+
function idLiteral(o) {
|
|
6777
|
+
return { ...o, id: o.id };
|
|
7098
6778
|
}
|
|
7099
|
-
function
|
|
7100
|
-
return
|
|
6779
|
+
function nameLiteral(o) {
|
|
6780
|
+
return o;
|
|
7101
6781
|
}
|
|
7102
|
-
function
|
|
7103
|
-
return
|
|
6782
|
+
function kindLiteral(o) {
|
|
6783
|
+
return o;
|
|
7104
6784
|
}
|
|
7105
|
-
function
|
|
7106
|
-
return
|
|
6785
|
+
function idTypeGuard(_o) {
|
|
6786
|
+
return true;
|
|
7107
6787
|
}
|
|
7108
|
-
function
|
|
7109
|
-
return
|
|
6788
|
+
function literal(obj) {
|
|
6789
|
+
return obj;
|
|
7110
6790
|
}
|
|
7111
|
-
function
|
|
7112
|
-
return
|
|
6791
|
+
function lowercase(str) {
|
|
6792
|
+
return str.toLowerCase();
|
|
7113
6793
|
}
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
...TT_CONTAINERS2,
|
|
7117
|
-
...TT_FUNCTIONS2,
|
|
7118
|
-
...TT_SETS2,
|
|
7119
|
-
...TT_SINGLETONS2
|
|
7120
|
-
];
|
|
7121
|
-
function isShapeToken(val) {
|
|
7122
|
-
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
6794
|
+
function narrow(...values) {
|
|
6795
|
+
return values.length === 1 ? values[0] : values;
|
|
7123
6796
|
}
|
|
7124
|
-
|
|
7125
|
-
|
|
7126
|
-
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
6797
|
+
function pathJoin(...segments) {
|
|
6798
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
6799
|
+
const original_path = segments.join("/");
|
|
6800
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
6801
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
6802
|
+
return `${pre}${clean_path}${post}`;
|
|
7130
6803
|
}
|
|
7131
|
-
|
|
7132
|
-
|
|
7133
|
-
|
|
7134
|
-
|
|
6804
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
6805
|
+
function getPhoneCountryCode(phone) {
|
|
6806
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6807
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6808
|
+
...NUMERIC_CHAR2
|
|
6809
|
+
) : "";
|
|
7135
6810
|
}
|
|
7136
|
-
function
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
6811
|
+
function removePhoneCountryCode(phone) {
|
|
6812
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
6813
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
6814
|
+
phone.trim(),
|
|
6815
|
+
"+",
|
|
6816
|
+
"00"
|
|
6817
|
+
), countryCode).trim() : phone.trim();
|
|
7140
6818
|
}
|
|
7141
|
-
|
|
7142
|
-
|
|
6819
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
6820
|
+
function endingIn(word, postfix) {
|
|
6821
|
+
switch (postfix) {
|
|
6822
|
+
case "is":
|
|
6823
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
6824
|
+
case "singular-noun":
|
|
6825
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
6826
|
+
case "f":
|
|
6827
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6828
|
+
case "y":
|
|
6829
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6830
|
+
default:
|
|
6831
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6832
|
+
}
|
|
7143
6833
|
}
|
|
7144
|
-
function
|
|
7145
|
-
|
|
6834
|
+
function pluralize(word) {
|
|
6835
|
+
const right = rightWhitespace(word);
|
|
6836
|
+
const w = word.trimEnd();
|
|
6837
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6838
|
+
return `${result2}${right}`;
|
|
7146
6839
|
}
|
|
7147
|
-
function
|
|
7148
|
-
|
|
6840
|
+
function retainAfter(content, ...find2) {
|
|
6841
|
+
const idx = Math.min(
|
|
6842
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6843
|
+
);
|
|
6844
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
6845
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
6846
|
+
if (min !== len) {
|
|
6847
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
6848
|
+
len = min;
|
|
6849
|
+
}
|
|
6850
|
+
}
|
|
6851
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
7149
6852
|
}
|
|
7150
|
-
function
|
|
7151
|
-
|
|
7152
|
-
(
|
|
6853
|
+
function retainAfterInclusive(content, ...find2) {
|
|
6854
|
+
const minFound = Math.min(
|
|
6855
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
7153
6856
|
);
|
|
6857
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
7154
6858
|
}
|
|
7155
|
-
function
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7159
|
-
}
|
|
6859
|
+
function retainChars(content, ...retain2) {
|
|
6860
|
+
const chars = asChars(content);
|
|
6861
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
7160
6862
|
}
|
|
7161
|
-
function
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
6863
|
+
function retainUntil(content, ...find2) {
|
|
6864
|
+
const chars = asChars(content);
|
|
6865
|
+
let idx = 0;
|
|
6866
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6867
|
+
idx = idx + 1;
|
|
7165
6868
|
}
|
|
7166
|
-
return
|
|
6869
|
+
return idx === 0 ? "" : content.slice(0, idx);
|
|
7167
6870
|
}
|
|
7168
|
-
function
|
|
7169
|
-
|
|
7170
|
-
|
|
7171
|
-
|
|
6871
|
+
function retainUntilInclusive(content, ...find2) {
|
|
6872
|
+
const chars = asChars(content);
|
|
6873
|
+
let idx = 0;
|
|
6874
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6875
|
+
idx = idx + 1;
|
|
7172
6876
|
}
|
|
7173
|
-
return
|
|
7174
|
-
}
|
|
7175
|
-
function isSetBasedKind(val) {
|
|
7176
|
-
return isString(val) && val.endsWith(`-set`);
|
|
7177
|
-
}
|
|
7178
|
-
function isSingletonKind(val) {
|
|
7179
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7180
|
-
}
|
|
7181
|
-
function isSingletonToken(val) {
|
|
7182
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7183
|
-
}
|
|
7184
|
-
function isTailwindColorName(val) {
|
|
7185
|
-
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
7186
|
-
}
|
|
7187
|
-
function isTailwindColorWithLuminosity(val) {
|
|
7188
|
-
return isString(val) && isTailwindColorName(val.split("-")[0]) && (!["white", "black"].includes(val.split("-")[0]) || val.split("-").length === 1) && (!val.includes("-") || Object.keys(TW_LUMINOSITY2).includes(retainAfter(val, "-")));
|
|
7189
|
-
}
|
|
7190
|
-
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
7191
|
-
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
6877
|
+
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
7192
6878
|
}
|
|
7193
|
-
function
|
|
7194
|
-
|
|
6879
|
+
function retainWhile(content, ...retain2) {
|
|
6880
|
+
const stopIdx = asChars(content).findIndex((c) => !retain2.includes(c));
|
|
6881
|
+
return content.slice(0, stopIdx);
|
|
7195
6882
|
}
|
|
7196
|
-
function
|
|
7197
|
-
|
|
6883
|
+
function rightWhitespace(content) {
|
|
6884
|
+
const trimmed = content.trimStart();
|
|
6885
|
+
return retainAfterInclusive(
|
|
6886
|
+
trimmed,
|
|
6887
|
+
...WHITESPACE_CHARS2
|
|
6888
|
+
);
|
|
7198
6889
|
}
|
|
7199
|
-
function
|
|
7200
|
-
return
|
|
6890
|
+
function split(str, sep = "") {
|
|
6891
|
+
return str.split(sep);
|
|
7201
6892
|
}
|
|
7202
|
-
function
|
|
7203
|
-
|
|
7204
|
-
const mods = getTailwindModifiers(val);
|
|
7205
|
-
const targetted = removeTailwindModifiers(val);
|
|
7206
|
-
const target = targetted.split("-")[0];
|
|
7207
|
-
const color = targetted.split("-").slice(1).join("-");
|
|
7208
|
-
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
7209
|
-
}
|
|
7210
|
-
return false;
|
|
6893
|
+
function stripAfter(content, find2) {
|
|
6894
|
+
return content.split(find2).shift();
|
|
7211
6895
|
}
|
|
7212
|
-
|
|
7213
|
-
|
|
7214
|
-
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
6896
|
+
function stripBefore(content, find2) {
|
|
6897
|
+
return content.split(find2).slice(1).join(find2);
|
|
7215
6898
|
}
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
return
|
|
6899
|
+
function stripChars(content, ...strip2) {
|
|
6900
|
+
const chars = asChars(content);
|
|
6901
|
+
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
7219
6902
|
}
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
6903
|
+
function stripLeading(content, ...strip2) {
|
|
6904
|
+
if (isUndefined(content)) {
|
|
6905
|
+
return void 0;
|
|
6906
|
+
}
|
|
6907
|
+
let output = String(content);
|
|
6908
|
+
for (const s of strip2) {
|
|
6909
|
+
if (output.startsWith(String(s))) {
|
|
6910
|
+
output = output.slice(String(s).length);
|
|
6911
|
+
}
|
|
6912
|
+
}
|
|
6913
|
+
return isNumber(content) ? Number(output) : output;
|
|
7223
6914
|
}
|
|
7224
|
-
|
|
7225
|
-
|
|
7226
|
-
|
|
6915
|
+
function stripSurround(...chars) {
|
|
6916
|
+
return (input) => {
|
|
6917
|
+
let output = String(input);
|
|
6918
|
+
for (const s of chars) {
|
|
6919
|
+
if (output.startsWith(String(s))) {
|
|
6920
|
+
output = output.slice(String(s).length);
|
|
6921
|
+
}
|
|
6922
|
+
if (output.endsWith(String(s))) {
|
|
6923
|
+
output = output.slice(0, -1 * String(s).length);
|
|
6924
|
+
}
|
|
6925
|
+
}
|
|
6926
|
+
return isNumber(input) ? Number(output) : output;
|
|
6927
|
+
};
|
|
7227
6928
|
}
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
6929
|
+
function stripTrailing(content, ...strip2) {
|
|
6930
|
+
if (isUndefined(content)) {
|
|
6931
|
+
return void 0;
|
|
6932
|
+
}
|
|
6933
|
+
let output = String(content);
|
|
6934
|
+
for (const s of strip2) {
|
|
6935
|
+
if (output.endsWith(String(s))) {
|
|
6936
|
+
output = output.slice(0, -1 * String(s).length);
|
|
6937
|
+
}
|
|
6938
|
+
}
|
|
6939
|
+
return isNumber(content) ? Number(output) : output;
|
|
7231
6940
|
}
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
return
|
|
6941
|
+
function stripUntil(content, ...until) {
|
|
6942
|
+
const stopIdx = asChars(content).findIndex((c) => until.includes(c));
|
|
6943
|
+
return content.slice(stopIdx);
|
|
7235
6944
|
}
|
|
7236
|
-
|
|
7237
|
-
|
|
7238
|
-
return
|
|
6945
|
+
function stripWhile(content, ...match) {
|
|
6946
|
+
const stopIdx = asChars(content).findIndex((c) => !match.includes(c));
|
|
6947
|
+
return content.slice(stopIdx);
|
|
7239
6948
|
}
|
|
7240
|
-
|
|
7241
|
-
|
|
7242
|
-
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
6949
|
+
function surround(prefix, postfix) {
|
|
6950
|
+
return (input) => `${prefix}${input}${postfix}`;
|
|
7243
6951
|
}
|
|
7244
|
-
|
|
7245
|
-
|
|
7246
|
-
return
|
|
6952
|
+
function takeNumericCharacters(content) {
|
|
6953
|
+
const nonNumericIdx = asChars(content).findIndex((i) => !NUMERIC_CHAR2.includes(i));
|
|
6954
|
+
return content.slice(0, nonNumericIdx);
|
|
7247
6955
|
}
|
|
7248
|
-
|
|
7249
|
-
|
|
7250
|
-
|
|
6956
|
+
function toCamelCase(input, preserveWhitespace) {
|
|
6957
|
+
const pascal = preserveWhitespace ? toPascalCase(input, preserveWhitespace) : toPascalCase(input);
|
|
6958
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
6959
|
+
pascal
|
|
6960
|
+
);
|
|
6961
|
+
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
6962
|
+
return camel;
|
|
7251
6963
|
}
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
6964
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
6965
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
6966
|
+
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
6967
|
+
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
6968
|
+
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
6969
|
+
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
6970
|
+
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
6971
|
+
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
6972
|
+
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
6973
|
+
replaceTrailingDash(
|
|
6974
|
+
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
6975
|
+
)
|
|
6976
|
+
)}${postWhite}`);
|
|
7255
6977
|
}
|
|
7256
|
-
|
|
7257
|
-
|
|
7258
|
-
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
6978
|
+
function toNumericArray(arr) {
|
|
6979
|
+
return arr.map((i) => Number(i));
|
|
7259
6980
|
}
|
|
7260
|
-
|
|
7261
|
-
|
|
7262
|
-
|
|
6981
|
+
function toPascalCase(input, preserveWhitespace = void 0) {
|
|
6982
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
6983
|
+
input
|
|
6984
|
+
);
|
|
6985
|
+
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
6986
|
+
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
6987
|
+
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
6988
|
+
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
6989
|
+
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
6990
|
+
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
6991
|
+
)}${preserveWhitespace ? postWhite : ""}`;
|
|
6992
|
+
return pascal;
|
|
7263
6993
|
}
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
|
|
6994
|
+
function toSnakeCase(input, preserveWhitespace = false) {
|
|
6995
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
6996
|
+
const convertInteriorSpace = (input2) => input2.replace(/\s+/g, "_");
|
|
6997
|
+
const convertDashes = (input2) => input2.replace(/-/g, "_");
|
|
6998
|
+
const injectUnderscoreBeforeCaps = (input2) => input2.replace(/([A-Z])/g, "_$1");
|
|
6999
|
+
const removeLeadingUnderscore = (input2) => input2.startsWith("_") ? input2.slice(1) : input2;
|
|
7000
|
+
return ((preserveWhitespace ? preWhite : "") + removeLeadingUnderscore(
|
|
7001
|
+
injectUnderscoreBeforeCaps(convertDashes(convertInteriorSpace(focus)))
|
|
7002
|
+
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
7267
7003
|
}
|
|
7268
|
-
|
|
7269
|
-
|
|
7270
|
-
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
7004
|
+
function toString(val) {
|
|
7005
|
+
return String(val);
|
|
7271
7006
|
}
|
|
7272
|
-
|
|
7273
|
-
|
|
7274
|
-
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
7007
|
+
function toUppercase(str) {
|
|
7008
|
+
return str.split("").map((i) => ifLowercaseChar(i, (v) => capitalize(v), (v) => v)).join("");
|
|
7275
7009
|
}
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
7010
|
+
function trim(input) {
|
|
7011
|
+
return input.trim();
|
|
7279
7012
|
}
|
|
7280
|
-
|
|
7281
|
-
|
|
7282
|
-
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
7013
|
+
function trimLeft(input) {
|
|
7014
|
+
return input.trimStart();
|
|
7283
7015
|
}
|
|
7284
|
-
|
|
7285
|
-
|
|
7286
|
-
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
7016
|
+
function trimStart(input) {
|
|
7017
|
+
return input.trimStart();
|
|
7287
7018
|
}
|
|
7288
|
-
function
|
|
7289
|
-
return
|
|
7019
|
+
function trimRight(input) {
|
|
7020
|
+
return input.trimEnd();
|
|
7290
7021
|
}
|
|
7291
|
-
function
|
|
7292
|
-
|
|
7293
|
-
return isString(val) && valid2.some(
|
|
7294
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7295
|
-
);
|
|
7022
|
+
function trimEnd(input) {
|
|
7023
|
+
return input.trimEnd();
|
|
7296
7024
|
}
|
|
7297
|
-
function
|
|
7298
|
-
const
|
|
7299
|
-
return
|
|
7300
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7301
|
-
);
|
|
7025
|
+
function truncate(content, maxLength, ellipsis = false) {
|
|
7026
|
+
const overLimit = content.length > maxLength;
|
|
7027
|
+
return overLimit ? ellipsis ? `${content.slice(0, maxLength)}${typeof ellipsis === "string" ? ellipsis : "..."}` : content.slice(0, maxLength) : content;
|
|
7302
7028
|
}
|
|
7303
|
-
function
|
|
7304
|
-
const
|
|
7305
|
-
|
|
7306
|
-
"https://www.github.com",
|
|
7307
|
-
"https://github.io"
|
|
7308
|
-
];
|
|
7309
|
-
return isString(val) && valid2.some(
|
|
7310
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7311
|
-
);
|
|
7029
|
+
function tuple(...values) {
|
|
7030
|
+
const arr = values.length === 1 ? values[0] : values;
|
|
7031
|
+
return asArray(arr);
|
|
7312
7032
|
}
|
|
7313
|
-
function
|
|
7314
|
-
return
|
|
7033
|
+
function uncapitalize(str) {
|
|
7034
|
+
return `${str?.slice(0, 1).toLowerCase()}${str?.slice(1)}`;
|
|
7315
7035
|
}
|
|
7316
|
-
|
|
7317
|
-
|
|
7318
|
-
|
|
7319
|
-
"/"
|
|
7320
|
-
);
|
|
7036
|
+
var unset = "<<unset>>";
|
|
7037
|
+
function uppercase(str) {
|
|
7038
|
+
return str.toUpperCase();
|
|
7321
7039
|
}
|
|
7322
|
-
function
|
|
7323
|
-
return
|
|
7040
|
+
function widen(value) {
|
|
7041
|
+
return value;
|
|
7324
7042
|
}
|
|
7325
|
-
|
|
7326
|
-
|
|
7043
|
+
var PROTOCOLS = Object.values(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i !== "");
|
|
7044
|
+
function getUrlProtocol(url) {
|
|
7045
|
+
const proto = PROTOCOLS.find((p) => url.startsWith(`${p}://`));
|
|
7046
|
+
return proto;
|
|
7327
7047
|
}
|
|
7328
|
-
function
|
|
7329
|
-
return
|
|
7048
|
+
function removeUrlProtocol(url) {
|
|
7049
|
+
return stripBefore(url, "://");
|
|
7330
7050
|
}
|
|
7331
|
-
function
|
|
7332
|
-
|
|
7051
|
+
function ensurePath(val) {
|
|
7052
|
+
const val2 = ensureLeading(val, "/");
|
|
7053
|
+
return val === "" ? "" : stripTrailing(val2, "/");
|
|
7333
7054
|
}
|
|
7334
|
-
function
|
|
7335
|
-
return
|
|
7055
|
+
function getUrlPath(url) {
|
|
7056
|
+
return isUrl(url) ? ensurePath(
|
|
7057
|
+
stripAfter(stripBefore(removeUrlProtocol(url), "/"), "?")
|
|
7058
|
+
) : Never2;
|
|
7336
7059
|
}
|
|
7337
|
-
function
|
|
7338
|
-
|
|
7060
|
+
function getUrlQueryParams(url, specific = void 0) {
|
|
7061
|
+
const qp = stripBefore(url, "?");
|
|
7062
|
+
if (specific) {
|
|
7063
|
+
return qp.includes(`${specific}=`) ? decodeURIComponent(
|
|
7064
|
+
stripAfter(
|
|
7065
|
+
stripBefore(qp, `${specific}=`),
|
|
7066
|
+
"&"
|
|
7067
|
+
).replace(/\+/g, "%20")
|
|
7068
|
+
) : void 0;
|
|
7069
|
+
}
|
|
7070
|
+
return qp === "" ? qp : `?${qp}`;
|
|
7339
7071
|
}
|
|
7340
|
-
function
|
|
7341
|
-
|
|
7072
|
+
function getUrlDefaultPort(url) {
|
|
7073
|
+
const proto = getUrlProtocol(url);
|
|
7074
|
+
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
7342
7075
|
}
|
|
7343
|
-
function
|
|
7344
|
-
|
|
7076
|
+
function getUrlPort(url, resolve = false) {
|
|
7077
|
+
const re = /.*:(\d{2,3})/;
|
|
7078
|
+
const match = url.match(re);
|
|
7079
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
7345
7080
|
}
|
|
7346
|
-
function
|
|
7347
|
-
|
|
7081
|
+
function getUrlSource(url) {
|
|
7082
|
+
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
7083
|
+
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
7348
7084
|
}
|
|
7349
|
-
function
|
|
7350
|
-
|
|
7085
|
+
function getUrlBase(url) {
|
|
7086
|
+
const path = getUrlPath(url);
|
|
7087
|
+
const remaining = stripAfter(url, path);
|
|
7088
|
+
return remaining;
|
|
7351
7089
|
}
|
|
7352
|
-
function
|
|
7353
|
-
|
|
7090
|
+
function getUrlDynamics(url) {
|
|
7091
|
+
const path = getUrlPath(url);
|
|
7092
|
+
const qp = getUrlQueryParams(url);
|
|
7093
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
7094
|
+
const segmentTypes = [
|
|
7095
|
+
"string",
|
|
7096
|
+
"number",
|
|
7097
|
+
"boolean",
|
|
7098
|
+
"Opt<string>",
|
|
7099
|
+
"Opt<number>",
|
|
7100
|
+
"Opt<boolean>"
|
|
7101
|
+
];
|
|
7102
|
+
const pathVars = {};
|
|
7103
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
7104
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
7105
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
7106
|
+
for (const part of pathParts) {
|
|
7107
|
+
const union4 = findPathUnion(part);
|
|
7108
|
+
const typed = findPathTyped(part);
|
|
7109
|
+
const named = findPathNamed(part);
|
|
7110
|
+
if (union4) {
|
|
7111
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
7112
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
7113
|
+
}
|
|
7114
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
7115
|
+
pathVars[typed.name] = typed.type;
|
|
7116
|
+
} else if (named && isVariable(named.name)) {
|
|
7117
|
+
pathVars[named.name] = "string";
|
|
7118
|
+
}
|
|
7119
|
+
}
|
|
7120
|
+
const qpVars = {};
|
|
7121
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
7122
|
+
for (const p of qpParts) {
|
|
7123
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
7124
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
7125
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
7126
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
7127
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
7128
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
7129
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
7130
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
7131
|
+
qpVars[fixed.var] = fixed.val;
|
|
7132
|
+
}
|
|
7133
|
+
}
|
|
7134
|
+
return {
|
|
7135
|
+
pathVars,
|
|
7136
|
+
qpVars,
|
|
7137
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
7138
|
+
...pathVars,
|
|
7139
|
+
...qpVars
|
|
7140
|
+
}
|
|
7141
|
+
};
|
|
7354
7142
|
}
|
|
7355
|
-
function
|
|
7356
|
-
return
|
|
7143
|
+
function urlMeta(url) {
|
|
7144
|
+
return {
|
|
7145
|
+
url,
|
|
7146
|
+
isUrl: isUrl(url),
|
|
7147
|
+
protocol: getUrlProtocol(url),
|
|
7148
|
+
path: getUrlPath(url),
|
|
7149
|
+
queryParameters: getUrlQueryParams(url),
|
|
7150
|
+
params: getUrlDynamics,
|
|
7151
|
+
port: getUrlPort(url),
|
|
7152
|
+
source: getUrlSource(url),
|
|
7153
|
+
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
7154
|
+
isIp4Address: isIp4Address(getUrlSource(url)),
|
|
7155
|
+
isIp6Address: isIp6Address(getUrlSource(url))
|
|
7156
|
+
};
|
|
7357
7157
|
}
|
|
7358
|
-
function
|
|
7359
|
-
return
|
|
7158
|
+
function getYouTubePageType(url) {
|
|
7159
|
+
return isYouTubeUrl(url) ? isYouTubeVideoUrl(url) && (hasUrlQueryParameter(url, "v") || isYouTubeShareUrl(url)) ? hasUrlQueryParameter(url, "list") ? isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::in-list::share-link::with-timestamp` : `play::video::in-list::share-link` : `play::video::in-list` : isYouTubeShareUrl(url) ? hasUrlQueryParameter(url, "t") ? `play::video::solo::share-link::with-timestamp` : `play::video::solo::share-link` : `play::video::solo` : isYouTubeCreatorUrl(url) ? getUrlPath(url).includes("/videos") ? "creator::videos" : getUrlPath(url).includes("/playlists") ? "creator::playlists" : last(getUrlPath(url).split("/")).startsWith("@") || getUrlPath(url).includes("/featured") ? "creator::featured" : "creator::other" : isYouTubeFeedUrl(url) ? isYouTubeFeedUrl(url, "history") ? "feed::history" : isYouTubeFeedUrl(url, "playlists") ? "feed::playlists" : isYouTubeFeedUrl(url, "liked") ? "feed::liked" : isYouTubeFeedUrl(url, "subscriptions") ? "feed::subscriptions" : isYouTubeFeedUrl(url, "trending") ? "feed::trending" : "feed::other" : isYouTubeVideosInPlaylist(url) ? "playlist::show" : "other" : Never2;
|
|
7360
7160
|
}
|
|
7361
|
-
function
|
|
7362
|
-
|
|
7161
|
+
function youtubeEmbed(url) {
|
|
7162
|
+
if (hasUrlQueryParameter(url, "v")) {
|
|
7163
|
+
const id = getUrlQueryParams(url, "v");
|
|
7164
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7165
|
+
} else if (isYouTubeShareUrl(url)) {
|
|
7166
|
+
const id = url.split("/").pop();
|
|
7167
|
+
if (id) {
|
|
7168
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7169
|
+
} else {
|
|
7170
|
+
throw new Error(`Unexpected problem parsing share URL -- "${url}" -- into a YouTube embed URL`);
|
|
7171
|
+
}
|
|
7172
|
+
} else {
|
|
7173
|
+
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
7174
|
+
}
|
|
7363
7175
|
}
|
|
7364
|
-
function
|
|
7365
|
-
return
|
|
7176
|
+
function youtubeMeta(url) {
|
|
7177
|
+
return isYouTubeUrl(url) ? {
|
|
7178
|
+
url,
|
|
7179
|
+
isYouTubeUrl: true,
|
|
7180
|
+
isShareUrl: isYouTubeShareUrl(url),
|
|
7181
|
+
pageType: getYouTubePageType(url)
|
|
7182
|
+
} : {
|
|
7183
|
+
url,
|
|
7184
|
+
isYouTubeUrl: false
|
|
7185
|
+
};
|
|
7366
7186
|
}
|
|
7367
|
-
function
|
|
7368
|
-
return
|
|
7187
|
+
function queue(state) {
|
|
7188
|
+
return {
|
|
7189
|
+
queue: state,
|
|
7190
|
+
size: state.length,
|
|
7191
|
+
isEmpty() {
|
|
7192
|
+
return state.length === 0;
|
|
7193
|
+
},
|
|
7194
|
+
clear() {
|
|
7195
|
+
state.slice(0, 0);
|
|
7196
|
+
},
|
|
7197
|
+
drain() {
|
|
7198
|
+
const old_state = [...state];
|
|
7199
|
+
state.slice(0, 0);
|
|
7200
|
+
return old_state;
|
|
7201
|
+
},
|
|
7202
|
+
push(...add) {
|
|
7203
|
+
state.push(...add);
|
|
7204
|
+
},
|
|
7205
|
+
drop(quantity) {
|
|
7206
|
+
if (quantity && quantity > state.length) {
|
|
7207
|
+
throw new Error("Cannot drop more elements than present in the queue");
|
|
7208
|
+
}
|
|
7209
|
+
state.splice(0, quantity || 1);
|
|
7210
|
+
},
|
|
7211
|
+
take(quantity) {
|
|
7212
|
+
if (quantity && quantity > state.length) {
|
|
7213
|
+
throw new Error("Cannot take more elements than present in the queue");
|
|
7214
|
+
}
|
|
7215
|
+
const result2 = state.slice(0, quantity || 1);
|
|
7216
|
+
state.splice(0, quantity || 1);
|
|
7217
|
+
return result2;
|
|
7218
|
+
},
|
|
7219
|
+
*[Symbol.iterator]() {
|
|
7220
|
+
for (let i = 0; i < state.length; i++) {
|
|
7221
|
+
yield state[i];
|
|
7222
|
+
}
|
|
7223
|
+
}
|
|
7224
|
+
};
|
|
7369
7225
|
}
|
|
7370
|
-
function
|
|
7371
|
-
return
|
|
7226
|
+
function createFifoQueue(...list2) {
|
|
7227
|
+
return queue([...list2]);
|
|
7372
7228
|
}
|
|
7373
|
-
function
|
|
7374
|
-
return
|
|
7229
|
+
function queue2(state) {
|
|
7230
|
+
return {
|
|
7231
|
+
queue: state,
|
|
7232
|
+
size: state.length,
|
|
7233
|
+
isEmpty() {
|
|
7234
|
+
return state.length === 0;
|
|
7235
|
+
},
|
|
7236
|
+
push(...add) {
|
|
7237
|
+
state.push(...add);
|
|
7238
|
+
},
|
|
7239
|
+
drop(quantity) {
|
|
7240
|
+
state.splice(-quantity);
|
|
7241
|
+
},
|
|
7242
|
+
clear() {
|
|
7243
|
+
state.slice(0, 0);
|
|
7244
|
+
},
|
|
7245
|
+
drain() {
|
|
7246
|
+
const old_state = [...state];
|
|
7247
|
+
state.slice(0, 0);
|
|
7248
|
+
return old_state;
|
|
7249
|
+
},
|
|
7250
|
+
take(quantity) {
|
|
7251
|
+
const result2 = state.slice(-quantity);
|
|
7252
|
+
state.splice(-quantity);
|
|
7253
|
+
return result2;
|
|
7254
|
+
},
|
|
7255
|
+
*[Symbol.iterator]() {
|
|
7256
|
+
for (let i = state.length - 1; i >= 0; i--) {
|
|
7257
|
+
yield state[i];
|
|
7258
|
+
}
|
|
7259
|
+
}
|
|
7260
|
+
};
|
|
7375
7261
|
}
|
|
7376
|
-
function
|
|
7377
|
-
return
|
|
7262
|
+
function createLifoQueue(...list2) {
|
|
7263
|
+
return queue2([...list2]);
|
|
7378
7264
|
}
|
|
7379
|
-
|
|
7380
|
-
|
|
7265
|
+
var scalarToToken = identity({
|
|
7266
|
+
string: "<<string>>",
|
|
7267
|
+
number: "<<number>>",
|
|
7268
|
+
boolean: "<<boolean>>",
|
|
7269
|
+
true: "<<true>>",
|
|
7270
|
+
false: "<<false>>",
|
|
7271
|
+
null: "<<null>>",
|
|
7272
|
+
undefined: "<<undefined>>",
|
|
7273
|
+
unknown: "<<unknown>>",
|
|
7274
|
+
any: "<<any>>",
|
|
7275
|
+
never: "<<never>>"
|
|
7276
|
+
});
|
|
7277
|
+
function stringLiteral(str) {
|
|
7278
|
+
return stripAfter(stripBefore(str, "string("), ")");
|
|
7381
7279
|
}
|
|
7382
|
-
function
|
|
7383
|
-
return
|
|
7280
|
+
function numericLiteral(str) {
|
|
7281
|
+
return stripAfter(stripBefore(str, "number("), ")");
|
|
7384
7282
|
}
|
|
7385
|
-
function
|
|
7386
|
-
|
|
7283
|
+
function handleOptional(token) {
|
|
7284
|
+
const bare = stripTrailing(stripLeading(token, "Opt<"), ">");
|
|
7285
|
+
return bare.startsWith("string") ? `<<union::[ <<string>>, <<undefined>> ]>>` : bare.startsWith("number") ? `<<union::[ <<number>>, <<undefined>> ]>>` : bare.startsWith("boolean") ? `<<union::[ <<boolean>>, <<undefined>> ]>>` : bare.startsWith("unknown") ? `<<union::[ <<unknown>>, <<undefined>> ]>>` : `<<never>>`;
|
|
7387
7286
|
}
|
|
7388
|
-
function
|
|
7389
|
-
return
|
|
7287
|
+
function simpleScalarTokenToTypeToken(val) {
|
|
7288
|
+
return val in scalarToToken ? scalarToToken[val] : val.startsWith("string(") ? stringLiteral(val).includes(",") ? `<<union::[ ${stringLiteral(val).split(/,\s?/).map((i) => `"${i}"`).join(", ")} ]>>` : `<<string::${stringLiteral(val)}>>` : val.startsWith("number(") ? numericLiteral(val).includes(",") ? `<<union::[ ${numericLiteral(val).split(/,\s?/).join(", ")} ]>>` : `<<number::${numericLiteral(val)}>>` : val.startsWith("Opt<") ? handleOptional(val) : `<<never>>`;
|
|
7390
7289
|
}
|
|
7391
|
-
function
|
|
7392
|
-
return
|
|
7290
|
+
function unionNode(node) {
|
|
7291
|
+
return isNumberLike(node) ? `<<number::${node}>>` : isBooleanLike(node) ? `<<${node}>>` : isSimpleContainerToken(node) ? simpleContainerTokenToTypeToken(node) : isSimpleScalarToken(node) ? simpleScalarToken(node) : `<<string::${node}>>`;
|
|
7393
7292
|
}
|
|
7394
|
-
function
|
|
7395
|
-
return
|
|
7293
|
+
function union2(nodes) {
|
|
7294
|
+
return Array.isArray(nodes) ? nodes.map((n) => unionNode(n)) : nodes.includes(",") ? nodes.split(/,\s?/).map((n) => unionNode(n)).join(", ") : unionNode(nodes);
|
|
7396
7295
|
}
|
|
7397
|
-
|
|
7398
|
-
|
|
7296
|
+
var stripUnion = stripSurround("Union(", ")");
|
|
7297
|
+
function simpleUnionTokenToTypeToken(val) {
|
|
7298
|
+
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union2(stripUnion(val))} ]>>` : Never2;
|
|
7399
7299
|
}
|
|
7400
|
-
function
|
|
7401
|
-
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7300
|
+
function simpleContainerTokenToTypeToken(_val) {
|
|
7402
7301
|
}
|
|
7403
|
-
function
|
|
7404
|
-
return
|
|
7302
|
+
function asTypeToken(_val) {
|
|
7303
|
+
return "not ready";
|
|
7405
7304
|
}
|
|
7406
|
-
function
|
|
7407
|
-
return
|
|
7305
|
+
function addToken(token, ...params) {
|
|
7306
|
+
return `<<${token}${params.length > 0 ? `::${params.join("::")}` : ""}>>`;
|
|
7408
7307
|
}
|
|
7409
|
-
function
|
|
7410
|
-
return
|
|
7308
|
+
function boolean(literal2) {
|
|
7309
|
+
return isDefined(literal2) ? isTrue(literal2) ? addToken("true") : isFalse(literal2) ? addToken("false") : addToken("boolean") : addToken("boolean");
|
|
7411
7310
|
}
|
|
7412
|
-
|
|
7413
|
-
|
|
7311
|
+
var unknown = () => "<<unknown>>";
|
|
7312
|
+
var undefinedType = () => "<<undefined>>";
|
|
7313
|
+
var nullType = () => "<<null>>";
|
|
7314
|
+
function fn(..._args) {
|
|
7315
|
+
return {
|
|
7316
|
+
returns: (_rtn) => ({
|
|
7317
|
+
addProperties: (_kv) => {
|
|
7318
|
+
return null;
|
|
7319
|
+
},
|
|
7320
|
+
done: () => {
|
|
7321
|
+
return null;
|
|
7322
|
+
}
|
|
7323
|
+
}),
|
|
7324
|
+
done: () => {
|
|
7325
|
+
const result2 = null;
|
|
7326
|
+
return result2;
|
|
7327
|
+
}
|
|
7328
|
+
};
|
|
7414
7329
|
}
|
|
7415
|
-
function
|
|
7416
|
-
return
|
|
7330
|
+
function dictionary(_obj) {
|
|
7331
|
+
return null;
|
|
7417
7332
|
}
|
|
7418
|
-
function
|
|
7419
|
-
return
|
|
7333
|
+
function tuple2(..._elements) {
|
|
7334
|
+
return null;
|
|
7420
7335
|
}
|
|
7421
|
-
function
|
|
7422
|
-
|
|
7336
|
+
function regexToken(re, ...rep) {
|
|
7337
|
+
let exp = "";
|
|
7338
|
+
if (isString(re)) {
|
|
7339
|
+
try {
|
|
7340
|
+
const test = new RegExp(re);
|
|
7341
|
+
if (!isRegExp(test)) {
|
|
7342
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
7343
|
+
err.name = "InvalidRegEx";
|
|
7344
|
+
throw err;
|
|
7345
|
+
} else {
|
|
7346
|
+
exp = re;
|
|
7347
|
+
}
|
|
7348
|
+
} catch {
|
|
7349
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
7350
|
+
err.name = "InvalidRegEx";
|
|
7351
|
+
throw err;
|
|
7352
|
+
}
|
|
7353
|
+
} else if (isRegExp(re)) {
|
|
7354
|
+
exp = re.toString();
|
|
7355
|
+
}
|
|
7356
|
+
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
7357
|
+
return token;
|
|
7423
7358
|
}
|
|
7424
|
-
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
|
|
7359
|
+
function addSingleton(token, api2) {
|
|
7360
|
+
return (...literals) => {
|
|
7361
|
+
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
7362
|
+
"union",
|
|
7363
|
+
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
7364
|
+
);
|
|
7365
|
+
};
|
|
7428
7366
|
}
|
|
7429
|
-
|
|
7430
|
-
|
|
7367
|
+
var stringApi = {
|
|
7368
|
+
startsWith: (startsWith2) => addToken(`string-set`, `startsWith::${startsWith2}`),
|
|
7369
|
+
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
7370
|
+
zip: () => addToken("string-set", "Zip5"),
|
|
7371
|
+
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
7372
|
+
zipCode: () => addToken("string-set", "ZipCode"),
|
|
7373
|
+
militaryTime: (resolution) => {
|
|
7374
|
+
return addToken(
|
|
7375
|
+
"string-set",
|
|
7376
|
+
"militaryTime",
|
|
7377
|
+
resolution || "HH:MM"
|
|
7378
|
+
);
|
|
7379
|
+
},
|
|
7380
|
+
civilianTime: (resolution) => {
|
|
7381
|
+
return addToken(
|
|
7382
|
+
"string-set",
|
|
7383
|
+
"militaryTime",
|
|
7384
|
+
resolution || "HH:MM"
|
|
7385
|
+
);
|
|
7386
|
+
},
|
|
7387
|
+
numericString: () => addToken("string-set", "numeric"),
|
|
7388
|
+
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
7389
|
+
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
7390
|
+
regex: (exp, ...literalRepresentation) => {
|
|
7391
|
+
const token = regexToken(exp, ...literalRepresentation);
|
|
7392
|
+
return token;
|
|
7393
|
+
},
|
|
7394
|
+
done: () => addToken("string")
|
|
7395
|
+
};
|
|
7396
|
+
var string22 = addSingleton("string", stringApi);
|
|
7397
|
+
var number = addSingleton("number");
|
|
7398
|
+
function union3(...elements) {
|
|
7399
|
+
const result2 = elements.map((_el) => {
|
|
7400
|
+
});
|
|
7401
|
+
return result2;
|
|
7431
7402
|
}
|
|
7432
|
-
function
|
|
7433
|
-
return
|
|
7403
|
+
function record(_key, _value) {
|
|
7404
|
+
return null;
|
|
7434
7405
|
}
|
|
7435
|
-
function
|
|
7436
|
-
return
|
|
7406
|
+
function array(_type) {
|
|
7407
|
+
return null;
|
|
7437
7408
|
}
|
|
7438
|
-
function
|
|
7439
|
-
return
|
|
7409
|
+
function set(_type) {
|
|
7410
|
+
return null;
|
|
7440
7411
|
}
|
|
7441
|
-
function
|
|
7442
|
-
return
|
|
7412
|
+
function map(_key, _value) {
|
|
7413
|
+
return null;
|
|
7443
7414
|
}
|
|
7444
|
-
function
|
|
7445
|
-
return
|
|
7415
|
+
function weakMap(_key, _value) {
|
|
7416
|
+
return null;
|
|
7446
7417
|
}
|
|
7447
|
-
function
|
|
7448
|
-
return
|
|
7418
|
+
function isAddOrDone(val) {
|
|
7419
|
+
return isObject(val) && hasKeys("add", "done") && typeof val.done === "function" && typeof val.add === "function";
|
|
7449
7420
|
}
|
|
7450
|
-
|
|
7451
|
-
|
|
7421
|
+
var ShapeApiImplementation = {
|
|
7422
|
+
string: string22,
|
|
7423
|
+
number,
|
|
7424
|
+
boolean,
|
|
7425
|
+
unknown,
|
|
7426
|
+
undefined: undefinedType,
|
|
7427
|
+
null: nullType,
|
|
7428
|
+
union: union3,
|
|
7429
|
+
fn,
|
|
7430
|
+
record,
|
|
7431
|
+
array,
|
|
7432
|
+
set,
|
|
7433
|
+
map,
|
|
7434
|
+
weakMap,
|
|
7435
|
+
dictionary,
|
|
7436
|
+
tuple: tuple2
|
|
7437
|
+
};
|
|
7438
|
+
function shape(cb) {
|
|
7439
|
+
const rtn = cb(ShapeApiImplementation);
|
|
7440
|
+
return handleDoneFn(
|
|
7441
|
+
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
7442
|
+
);
|
|
7452
7443
|
}
|
|
7453
|
-
function
|
|
7454
|
-
return isString(
|
|
7444
|
+
function isShape(v) {
|
|
7445
|
+
return !!(isString(v) && v.startsWith("<<") && v.endsWith(">>") && SHAPE_PREFIXES2.some((i) => v.startsWith(`<<${i}`)));
|
|
7455
7446
|
}
|
|
7456
|
-
function
|
|
7457
|
-
|
|
7447
|
+
function asDefineObject(defn) {
|
|
7448
|
+
const result2 = Object.keys(defn).reduce(
|
|
7449
|
+
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
7450
|
+
...acc,
|
|
7451
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
7452
|
+
} : isFunction(defn[i]) ? {
|
|
7453
|
+
...acc,
|
|
7454
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
7455
|
+
} : Never2,
|
|
7456
|
+
{}
|
|
7457
|
+
);
|
|
7458
|
+
return result2;
|
|
7458
7459
|
}
|
|
7459
|
-
function
|
|
7460
|
-
return
|
|
7460
|
+
function asType(...token) {
|
|
7461
|
+
return isFunction(token) ? token(ShapeApiImplementation) : token.length === 1 ? isFunction(token[0]) ? handleDoneFn(token[0](ShapeApiImplementation)) : isDefineObject(token[0]) ? asDefineObject(token[0]) : token[0] : token.map((i) => isFunction(i) ? handleDoneFn(i(ShapeApiImplementation)) : i);
|
|
7461
7462
|
}
|
|
7462
|
-
function
|
|
7463
|
-
return
|
|
7463
|
+
function asStringLiteral(...values) {
|
|
7464
|
+
return values.map((i) => i);
|
|
7464
7465
|
}
|
|
7465
|
-
|
|
7466
|
-
|
|
7466
|
+
var choices = "NOT READY";
|
|
7467
|
+
function doesExtend(type) {
|
|
7468
|
+
return (val) => {
|
|
7469
|
+
let response = false;
|
|
7470
|
+
if (isString(val)) {
|
|
7471
|
+
if (type === "string") {
|
|
7472
|
+
response = true;
|
|
7473
|
+
}
|
|
7474
|
+
if (type.startsWith("string(")) {
|
|
7475
|
+
const literals = stripAfter(
|
|
7476
|
+
stripBefore(type, "string("),
|
|
7477
|
+
")"
|
|
7478
|
+
).split(/,\s*/);
|
|
7479
|
+
if (literals.includes(val)) {
|
|
7480
|
+
response = true;
|
|
7481
|
+
}
|
|
7482
|
+
}
|
|
7483
|
+
}
|
|
7484
|
+
if (isNumber(val)) {
|
|
7485
|
+
if (type === "number") {
|
|
7486
|
+
response = true;
|
|
7487
|
+
}
|
|
7488
|
+
if (type.startsWith("number(")) {
|
|
7489
|
+
const literals = stripAfter(
|
|
7490
|
+
stripBefore(type, "number("),
|
|
7491
|
+
")"
|
|
7492
|
+
).split(/,\s*/).map(Number);
|
|
7493
|
+
if (literals.includes(val)) {
|
|
7494
|
+
response = true;
|
|
7495
|
+
}
|
|
7496
|
+
}
|
|
7497
|
+
}
|
|
7498
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
7499
|
+
response = true;
|
|
7500
|
+
}
|
|
7501
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
7502
|
+
response = true;
|
|
7503
|
+
}
|
|
7504
|
+
if (isBoolean(val)) {
|
|
7505
|
+
if (type === "boolean") {
|
|
7506
|
+
response = true;
|
|
7507
|
+
}
|
|
7508
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
7509
|
+
response = true;
|
|
7510
|
+
}
|
|
7511
|
+
}
|
|
7512
|
+
if (isNarrowableObject(val)) {
|
|
7513
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
7514
|
+
response = true;
|
|
7515
|
+
}
|
|
7516
|
+
if (startsWith("Dict<")(type)) {
|
|
7517
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
7518
|
+
if (match) {
|
|
7519
|
+
const { value } = match;
|
|
7520
|
+
const isOpt = value.includes(`Opt<`);
|
|
7521
|
+
const values = objectValues(val);
|
|
7522
|
+
if (values.every((i) => isOpt ? isString(i) || isUndefined(i) : isString(i)) && type === "Dict<string, string>" || values.every((i) => isOpt ? isUndefined(i) || isNumber(i) : isNumber(i)) && type === "Dict<string, number>" || values.every((i) => isOpt ? isUndefined(i) || isBoolean(i) : isBoolean(i)) && type === "Dict<string, boolean>") {
|
|
7523
|
+
response = true;
|
|
7524
|
+
}
|
|
7525
|
+
}
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
if (isArray(val)) {
|
|
7529
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
7530
|
+
return true;
|
|
7531
|
+
}
|
|
7532
|
+
if (type === "Array<Dict>" && val.every(isObject) || type === "Array<boolean>" && val.every(isBoolean) || type === "Array<string>" && val.every(isString) || type === "Array<number>" && val.every(isNumber) || type === "Array<Map>" && val.every(isMap) || type === "Array<Set>" && val.every(isSetContainer)) {
|
|
7533
|
+
response = true;
|
|
7534
|
+
}
|
|
7535
|
+
}
|
|
7536
|
+
if (isMap(val)) {
|
|
7537
|
+
if (type === "Map" || type === "Map<Dict, Array>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isArray) || type === "Map<Dict, Dict>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isObject) || type === "Map<Dict, boolean>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isBoolean) || type === "Map<Dict, number>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isNumber) || type === "Map<Dict, string>" && Array.from(val.keys()).every(isObject) && Array.from(val.values()).every(isString) || type === "Map<Dict, unknown>" && Array.from(val.keys()).every(isObject) || type === "Map<string, string>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isString) || type === "Map<string, number>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isNumber) || type === "Map<string, boolean>" && Array.from(val.keys()).every(isString) && Array.from(val.values()).every(isBoolean) || type === "Map<string, unknown>" && Array.from(val.keys()).every(isString) || type === "Map<number, string>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isString) || type === "Map<number, number>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isNumber) || type === "Map<number, boolean>" && Array.from(val.keys()).every(isNumber) && Array.from(val.values()).every(isBoolean) || type === "Map<number, unknown>" && Array.from(val.keys()).every(isNumber)) {
|
|
7538
|
+
response = true;
|
|
7539
|
+
}
|
|
7540
|
+
}
|
|
7541
|
+
if (isSetContainer(val)) {
|
|
7542
|
+
if (type === "Set" || type === "Set<unknown>" || type === "Set<boolean>" && Array.from(val).every(isBoolean) || type === "Set<string>" && Array.from(val).every(isString) || type === "Set<number>" && Array.from(val).every(isNumber) || type === "Set<Opt<boolean>>" && Array.from(val).every((i) => isBoolean(i) || isUndefined(i)) || type === "Set<Opt<string>>" && Array.from(val).every((i) => isString(i) || isUndefined(i)) || type === "Set<Opt<number>>" && Array.from(val).every((i) => isNumber(i) || isUndefined(i))) {
|
|
7543
|
+
response = true;
|
|
7544
|
+
}
|
|
7545
|
+
}
|
|
7546
|
+
return response;
|
|
7547
|
+
};
|
|
7467
7548
|
}
|
|
7468
|
-
function
|
|
7469
|
-
|
|
7470
|
-
|
|
7471
|
-
|
|
7549
|
+
function ip6Prefix(...groups) {
|
|
7550
|
+
const empty = addToken("string");
|
|
7551
|
+
const count = 4 - groups.length;
|
|
7552
|
+
const fillIn = [];
|
|
7553
|
+
for (let index = 0; index < count; index++) {
|
|
7554
|
+
fillIn.push(empty);
|
|
7472
7555
|
}
|
|
7473
|
-
return
|
|
7556
|
+
return [
|
|
7557
|
+
"<<string::",
|
|
7558
|
+
[
|
|
7559
|
+
groups.join(":"),
|
|
7560
|
+
fillIn.join(":")
|
|
7561
|
+
].join(":"),
|
|
7562
|
+
">>"
|
|
7563
|
+
].join("");
|
|
7474
7564
|
}
|
|
7475
|
-
function
|
|
7476
|
-
const
|
|
7477
|
-
|
|
7478
|
-
|
|
7479
|
-
|
|
7480
|
-
|
|
7565
|
+
function createProxy(...initialize) {
|
|
7566
|
+
const state = initialize;
|
|
7567
|
+
state.id = null;
|
|
7568
|
+
const proxy = new Proxy(state, {});
|
|
7569
|
+
Object.defineProperty(proxy, "id", {
|
|
7570
|
+
enumerable: false
|
|
7481
7571
|
});
|
|
7482
|
-
return
|
|
7483
|
-
}
|
|
7484
|
-
function fromKeyValue(kvs) {
|
|
7485
|
-
const obj = {};
|
|
7486
|
-
for (const kv of kvs) {
|
|
7487
|
-
obj[kv.key] = kv.value;
|
|
7488
|
-
}
|
|
7489
|
-
return obj;
|
|
7490
|
-
}
|
|
7491
|
-
function intersect(value, _intersectedWith) {
|
|
7492
|
-
return value;
|
|
7493
|
-
}
|
|
7494
|
-
function ip6GroupExpansion(ip) {
|
|
7495
|
-
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
7496
|
-
}
|
|
7497
|
-
function jsonValue(val) {
|
|
7498
|
-
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
7499
|
-
}
|
|
7500
|
-
function jsonValues(...val) {
|
|
7501
|
-
return val.map((i) => jsonValue(i));
|
|
7502
|
-
}
|
|
7503
|
-
function lookupAlpha2Code(code, prop) {
|
|
7504
|
-
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
7505
|
-
return found ? found[prop] : void 0;
|
|
7506
|
-
}
|
|
7507
|
-
function lookupAlpha3Code(code, prop) {
|
|
7508
|
-
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
7509
|
-
return found ? found[prop] : void 0;
|
|
7510
|
-
}
|
|
7511
|
-
function lookupName(name, prop) {
|
|
7512
|
-
const found = ISO3166_12.find((i) => i.name === name);
|
|
7513
|
-
return found ? found[prop] : void 0;
|
|
7514
|
-
}
|
|
7515
|
-
function lookupNumericCode(code, prop) {
|
|
7516
|
-
let num = isNumber(code) ? `${code}` : code;
|
|
7517
|
-
if (num.length === 1) {
|
|
7518
|
-
num = `00${num}`;
|
|
7519
|
-
} else if (num.length === 2) {
|
|
7520
|
-
num = `0${num}`;
|
|
7521
|
-
}
|
|
7522
|
-
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
7523
|
-
return found ? found[prop] : void 0;
|
|
7524
|
-
}
|
|
7525
|
-
function lookupCountryName(code) {
|
|
7526
|
-
const uc = uppercase(code);
|
|
7527
|
-
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
7572
|
+
return proxy;
|
|
7528
7573
|
}
|
|
7529
|
-
function
|
|
7530
|
-
|
|
7531
|
-
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
7574
|
+
function list(...init) {
|
|
7575
|
+
return init.length === 1 && isArray(init[0]) ? createProxy(...init[0]) : createProxy(...init);
|
|
7532
7576
|
}
|
|
7533
|
-
function
|
|
7534
|
-
|
|
7535
|
-
|
|
7577
|
+
function singletonApi(kind) {
|
|
7578
|
+
return {
|
|
7579
|
+
wide: () => `<<${kind}>>`,
|
|
7580
|
+
literal: (val) => `<<${kind}::${val}>>`
|
|
7581
|
+
};
|
|
7536
7582
|
}
|
|
7537
|
-
function
|
|
7538
|
-
|
|
7539
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
7583
|
+
function setApi(_variant) {
|
|
7584
|
+
return null;
|
|
7540
7585
|
}
|
|
7541
|
-
function
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
map: (from) => {
|
|
7545
|
-
return from.map(fn2);
|
|
7546
|
-
}
|
|
7586
|
+
function fnReturnsApi(variant, _params, returns) {
|
|
7587
|
+
return isSet(returns) ? null : (_rtn) => {
|
|
7588
|
+
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
7547
7589
|
};
|
|
7548
|
-
return createFnWithPropsExplicit(fn2, props);
|
|
7549
7590
|
}
|
|
7550
|
-
function
|
|
7551
|
-
return (
|
|
7552
|
-
|
|
7553
|
-
return Object.keys(map2).reduce(
|
|
7554
|
-
(acc, key) => {
|
|
7555
|
-
const val = map2[key];
|
|
7556
|
-
return {
|
|
7557
|
-
...acc,
|
|
7558
|
-
[key]: isFunction(val) ? val(input) : val
|
|
7559
|
-
};
|
|
7560
|
-
},
|
|
7561
|
-
{}
|
|
7562
|
-
);
|
|
7563
|
-
};
|
|
7564
|
-
return fn2;
|
|
7591
|
+
function fnParamsApi(variant, params, _returns) {
|
|
7592
|
+
return isSet(params) ? null : (params2) => {
|
|
7593
|
+
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
7565
7594
|
};
|
|
7566
7595
|
}
|
|
7567
|
-
function
|
|
7568
|
-
return (
|
|
7569
|
-
return asMapper(fn2);
|
|
7570
|
-
};
|
|
7596
|
+
function fnDoneApi(variant, params, returns) {
|
|
7597
|
+
return isUnset(params) && isUnset(returns) ? `<<` : ``;
|
|
7571
7598
|
}
|
|
7572
|
-
function
|
|
7599
|
+
function fnTokenClosure(kind, params, returns) {
|
|
7573
7600
|
return {
|
|
7574
|
-
|
|
7575
|
-
|
|
7601
|
+
done: fnDoneApi(kind, params, returns),
|
|
7602
|
+
params: fnParamsApi(kind, params, returns),
|
|
7603
|
+
returns: fnReturnsApi(kind, params, returns)
|
|
7576
7604
|
};
|
|
7577
7605
|
}
|
|
7578
|
-
function
|
|
7579
|
-
return
|
|
7606
|
+
function createTypeToken(kind) {
|
|
7607
|
+
return isAtomicKind(kind) ? `<<${kind}>>` : isSingletonKind(kind) ? singletonApi(kind) : isSetBasedKind(kind) ? setApi(kind) : isFnBasedKind(kind) ? handleDoneFn(fnTokenClosure(kind, unset, unset)) : "<<never>>";
|
|
7580
7608
|
}
|
|
7581
|
-
function
|
|
7582
|
-
return
|
|
7609
|
+
function fromDefineObject(defn) {
|
|
7610
|
+
return defn;
|
|
7583
7611
|
}
|
|
7584
|
-
function
|
|
7585
|
-
|
|
7612
|
+
function getTokenKind(token) {
|
|
7613
|
+
const bare = stripSurround("<<", ">>")(token);
|
|
7614
|
+
const parts = bare.split("::");
|
|
7615
|
+
const kind = parts.pop();
|
|
7616
|
+
return kind;
|
|
7586
7617
|
}
|
|
7587
|
-
|
|
7618
|
+
var simpleToken = (token) => token;
|
|
7619
|
+
var simpleScalarToken = (token) => token;
|
|
7620
|
+
var simpleContainerToken = (token) => token;
|
|
7621
|
+
function simpleScalarType(token) {
|
|
7622
|
+
const value = simpleScalarToken(token);
|
|
7588
7623
|
return value;
|
|
7589
7624
|
}
|
|
7590
|
-
function
|
|
7625
|
+
function simpleContainerType(token) {
|
|
7626
|
+
const value = simpleContainerToken(token);
|
|
7591
7627
|
return value;
|
|
7592
7628
|
}
|
|
7593
|
-
function
|
|
7629
|
+
function simpleType(token) {
|
|
7630
|
+
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
7594
7631
|
return value;
|
|
7595
7632
|
}
|
|
7596
|
-
function
|
|
7597
|
-
|
|
7598
|
-
}
|
|
7599
|
-
function sortKeyApi(order) {
|
|
7600
|
-
return {
|
|
7601
|
-
order,
|
|
7602
|
-
toTop: (...keys) => sortKeyApi(
|
|
7603
|
-
[
|
|
7604
|
-
...keys,
|
|
7605
|
-
...order.filter((i) => !keys.includes(i))
|
|
7606
|
-
]
|
|
7607
|
-
),
|
|
7608
|
-
toBottom: (...keys) => sortKeyApi(
|
|
7609
|
-
[
|
|
7610
|
-
...order.filter((i) => !keys.includes(i)),
|
|
7611
|
-
...keys
|
|
7612
|
-
]
|
|
7613
|
-
),
|
|
7614
|
-
done: () => order
|
|
7615
|
-
};
|
|
7616
|
-
}
|
|
7617
|
-
function toKeyValue(obj, sort) {
|
|
7618
|
-
let keys = keysOf(obj);
|
|
7619
|
-
const tuple3 = [];
|
|
7620
|
-
if (sort) {
|
|
7621
|
-
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
7622
|
-
}
|
|
7633
|
+
function hasOverlappingKeys(a, b) {
|
|
7634
|
+
const keys = Object.keys(a);
|
|
7623
7635
|
for (const k of keys) {
|
|
7624
|
-
|
|
7636
|
+
if (k in b) {
|
|
7637
|
+
return true;
|
|
7638
|
+
}
|
|
7625
7639
|
}
|
|
7626
|
-
return
|
|
7640
|
+
return false;
|
|
7627
7641
|
}
|
|
7628
|
-
function
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
case "string":
|
|
7633
|
-
return Number(val);
|
|
7634
|
-
case "boolean":
|
|
7635
|
-
return val ? 1 : 0;
|
|
7636
|
-
default:
|
|
7637
|
-
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
7642
|
+
function uniqueKeys(left, right) {
|
|
7643
|
+
const isNumeric = !!(isArray(left) && isArray(right));
|
|
7644
|
+
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
7645
|
+
throw new Error("uniqueKeys(l,r) given invalid comparison; both left and right values should be an object or an array but not one of each!");
|
|
7638
7646
|
}
|
|
7639
|
-
|
|
7640
|
-
|
|
7641
|
-
|
|
7642
|
-
|
|
7643
|
-
}
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
return
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
function union3(..._options) {
|
|
7652
|
-
return (value) => value;
|
|
7653
|
-
}
|
|
7654
|
-
function unionize(value, _inUnionWith) {
|
|
7655
|
-
return value;
|
|
7647
|
+
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
7648
|
+
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
7649
|
+
if (isNumeric) {
|
|
7650
|
+
throw new Error("uniqueKeys does not yet work with tuples");
|
|
7651
|
+
}
|
|
7652
|
+
const leftKeys = l.filter((i) => !r.includes(i));
|
|
7653
|
+
const rightKeys = r.filter((i) => !l.includes(i));
|
|
7654
|
+
return [
|
|
7655
|
+
"LeftRight",
|
|
7656
|
+
leftKeys,
|
|
7657
|
+
rightKeys
|
|
7658
|
+
];
|
|
7656
7659
|
}
|
|
7657
7660
|
function asVueRef(value) {
|
|
7658
7661
|
return {
|
|
@@ -8104,6 +8107,7 @@ export {
|
|
|
8104
8107
|
errCondition,
|
|
8105
8108
|
filter,
|
|
8106
8109
|
filterEmpty,
|
|
8110
|
+
filterUndefined,
|
|
8107
8111
|
find,
|
|
8108
8112
|
fnMeta,
|
|
8109
8113
|
fromDefineObject,
|
|
@@ -8510,7 +8514,7 @@ export {
|
|
|
8510
8514
|
twColor,
|
|
8511
8515
|
unbox,
|
|
8512
8516
|
uncapitalize,
|
|
8513
|
-
|
|
8517
|
+
union,
|
|
8514
8518
|
unionize,
|
|
8515
8519
|
unique,
|
|
8516
8520
|
uniqueKeys,
|