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