inferred-types 0.55.13 → 0.55.15
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 +2078 -2068
- package/modules/inferred-types/dist/index.cjs.map +1 -1
- package/modules/inferred-types/dist/index.d.ts +29 -18
- package/modules/inferred-types/dist/index.js +2077 -2068
- package/modules/inferred-types/dist/index.js.map +1 -1
- package/modules/runtime/dist/index.cjs +2414 -2402
- package/modules/runtime/dist/index.cjs.map +1 -1
- package/modules/runtime/dist/index.d.ts +28 -17
- package/modules/runtime/dist/index.js +2413 -2402
- package/modules/runtime/dist/index.js.map +1 -1
- package/modules/types/dist/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -274,6 +274,7 @@ __export(index_exports, {
|
|
|
274
274
|
errCondition: () => errCondition,
|
|
275
275
|
filter: () => filter,
|
|
276
276
|
filterEmpty: () => filterEmpty,
|
|
277
|
+
filterUndefined: () => filterUndefined,
|
|
277
278
|
find: () => find,
|
|
278
279
|
fnMeta: () => fnMeta,
|
|
279
280
|
fromDefineObject: () => fromDefineObject,
|
|
@@ -680,7 +681,7 @@ __export(index_exports, {
|
|
|
680
681
|
twColor: () => twColor,
|
|
681
682
|
unbox: () => unbox,
|
|
682
683
|
uncapitalize: () => uncapitalize,
|
|
683
|
-
union: () =>
|
|
684
|
+
union: () => union,
|
|
684
685
|
unionize: () => unionize,
|
|
685
686
|
unique: () => unique,
|
|
686
687
|
uniqueKeys: () => uniqueKeys,
|
|
@@ -5835,2526 +5836,2534 @@ var filter = "NOT READY";
|
|
|
5835
5836
|
function filterEmpty(...val) {
|
|
5836
5837
|
return val.filter((i) => isNotEmpty(i));
|
|
5837
5838
|
}
|
|
5838
|
-
function
|
|
5839
|
-
return
|
|
5840
|
-
return list2.find((i) => {
|
|
5841
|
-
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
5842
|
-
return val === comparator;
|
|
5843
|
-
});
|
|
5844
|
-
};
|
|
5845
|
-
}
|
|
5846
|
-
function getEach(list2, dotPath) {
|
|
5847
|
-
const result2 = list2.map(
|
|
5848
|
-
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
5849
|
-
).filter((i) => !isErrorCondition(i));
|
|
5850
|
-
return result2;
|
|
5851
|
-
}
|
|
5852
|
-
function indexOf(val, index) {
|
|
5853
|
-
const isNegative = isNumber(index) && index < 0;
|
|
5854
|
-
if (isNegative && !Array.isArray(val)) {
|
|
5855
|
-
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}]!`);
|
|
5856
|
-
}
|
|
5857
|
-
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
5858
|
-
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.`);
|
|
5859
|
-
}
|
|
5860
|
-
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
5861
|
-
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}`);
|
|
5839
|
+
function isFunction(value) {
|
|
5840
|
+
return typeof value === "function";
|
|
5862
5841
|
}
|
|
5863
|
-
function
|
|
5864
|
-
|
|
5865
|
-
const bIndexable = b.every((i) => isIndexable(i));
|
|
5866
|
-
if (!aIndexable || !bIndexable) {
|
|
5867
|
-
if (!aIndexable) {
|
|
5868
|
-
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
5869
|
-
} else {
|
|
5870
|
-
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
5871
|
-
}
|
|
5872
|
-
}
|
|
5873
|
-
const aMatches = getEach(a, deref);
|
|
5874
|
-
const bMatches = getEach(b, deref);
|
|
5875
|
-
const sharedKeys2 = ifNotNull(
|
|
5876
|
-
deref,
|
|
5877
|
-
(v) => [
|
|
5878
|
-
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
5879
|
-
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
5880
|
-
],
|
|
5881
|
-
() => a.filter((k) => b.includes(k))
|
|
5882
|
-
);
|
|
5883
|
-
return sharedKeys2;
|
|
5842
|
+
function isObject(value) {
|
|
5843
|
+
return typeof value === "object" && value !== null && Array.isArray(value) === false;
|
|
5884
5844
|
}
|
|
5885
|
-
function
|
|
5886
|
-
return
|
|
5845
|
+
function isNarrowableObject(value) {
|
|
5846
|
+
return isObject(value) && Object.keys(value).every((key) => ["string", "number", "boolean", "symbol", "object", "undefined", "void", "null"].includes(typeof value[key]));
|
|
5887
5847
|
}
|
|
5888
|
-
function
|
|
5889
|
-
return
|
|
5848
|
+
function isEscapeFunction(val) {
|
|
5849
|
+
return isFunction(val) && "escape" in val && val.escape === true;
|
|
5890
5850
|
}
|
|
5891
|
-
function
|
|
5892
|
-
return (
|
|
5893
|
-
const tup = tuple3;
|
|
5894
|
-
return tup.join(joinWith2);
|
|
5895
|
-
};
|
|
5851
|
+
function isOptionalParamFunction(val) {
|
|
5852
|
+
return isFunction(val) && "optionalParams" in val && val.optionalParams === true;
|
|
5896
5853
|
}
|
|
5897
|
-
function
|
|
5898
|
-
return
|
|
5854
|
+
function isApi(api2) {
|
|
5855
|
+
return isObject(api2) && "surface" in api2 && "_kind" in api2 && api2._kind === "api";
|
|
5899
5856
|
}
|
|
5900
|
-
function
|
|
5901
|
-
return
|
|
5902
|
-
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
5903
|
-
);
|
|
5857
|
+
function isApiSurface(val) {
|
|
5858
|
+
return isObject(val) && Object.keys(val).some((k) => isEscapeFunction(val[k]));
|
|
5904
5859
|
}
|
|
5905
|
-
function
|
|
5906
|
-
return
|
|
5860
|
+
function isDate(val) {
|
|
5861
|
+
return val instanceof Date;
|
|
5907
5862
|
}
|
|
5908
|
-
function
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
5912
|
-
try {
|
|
5913
|
-
list2 = list2.slice(1);
|
|
5914
|
-
} catch {
|
|
5915
|
-
}
|
|
5916
|
-
} else {
|
|
5917
|
-
rtn = void 0;
|
|
5863
|
+
function isIsoDateTime(val) {
|
|
5864
|
+
if (!isString(val)) {
|
|
5865
|
+
return false;
|
|
5918
5866
|
}
|
|
5919
|
-
|
|
5920
|
-
|
|
5921
|
-
|
|
5922
|
-
return list2.slice(start2, end);
|
|
5923
|
-
}
|
|
5924
|
-
function unique(...values) {
|
|
5925
|
-
const u = [];
|
|
5926
|
-
for (const i of values.flat()) {
|
|
5927
|
-
if (!u.includes(i)) {
|
|
5928
|
-
u.push(i);
|
|
5929
|
-
}
|
|
5867
|
+
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})?$/;
|
|
5868
|
+
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
5869
|
+
return false;
|
|
5930
5870
|
}
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5871
|
+
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
5872
|
+
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
5873
|
+
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
5874
|
+
return false;
|
|
5875
|
+
}
|
|
5876
|
+
if (month < 1 || month > 12) {
|
|
5877
|
+
return false;
|
|
5878
|
+
}
|
|
5879
|
+
;
|
|
5880
|
+
const daysInMonth = new Date(year, month, 0).getDate();
|
|
5881
|
+
if (day < 1 || day > daysInMonth) {
|
|
5882
|
+
return false;
|
|
5883
|
+
}
|
|
5884
|
+
;
|
|
5885
|
+
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
5886
|
+
if (tzMatch) {
|
|
5887
|
+
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
5888
|
+
const numHours = Number.parseInt(tzHours, 10);
|
|
5889
|
+
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
5890
|
+
if (numHours > 14 || numMinutes > 59) {
|
|
5891
|
+
return false;
|
|
5939
5892
|
}
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
}
|
|
5943
|
-
|
|
5944
|
-
return
|
|
5893
|
+
if (numHours === 14 && numMinutes > 0) {
|
|
5894
|
+
return false;
|
|
5895
|
+
}
|
|
5896
|
+
}
|
|
5897
|
+
return true;
|
|
5945
5898
|
}
|
|
5946
|
-
function
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
(
|
|
5950
|
-
|
|
5951
|
-
|
|
5899
|
+
function isIsoExplicitDate(val) {
|
|
5900
|
+
if (isString(val)) {
|
|
5901
|
+
const parts = val.split("-").map((i) => Number(i));
|
|
5902
|
+
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;
|
|
5903
|
+
} else {
|
|
5904
|
+
return false;
|
|
5905
|
+
}
|
|
5952
5906
|
}
|
|
5953
|
-
function
|
|
5954
|
-
|
|
5907
|
+
function isIsoImplicitDate(val) {
|
|
5908
|
+
if (isString(val) && val.length === 8 && isNumberLike(val)) {
|
|
5909
|
+
const year = Number(val.slice(0, 4));
|
|
5910
|
+
const month = Number(val.slice(4, 6));
|
|
5911
|
+
const date = Number(val.slice(6, 8));
|
|
5912
|
+
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
5913
|
+
} else {
|
|
5914
|
+
return false;
|
|
5915
|
+
}
|
|
5955
5916
|
}
|
|
5956
|
-
function
|
|
5957
|
-
|
|
5917
|
+
function isIsoDate(val) {
|
|
5918
|
+
if (isString(val)) {
|
|
5919
|
+
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
5920
|
+
} else {
|
|
5921
|
+
return false;
|
|
5922
|
+
}
|
|
5958
5923
|
}
|
|
5959
|
-
function
|
|
5960
|
-
|
|
5924
|
+
function isIsoExplicitTime(val) {
|
|
5925
|
+
if (isString(val)) {
|
|
5926
|
+
const parts = stripLeading(stripAfter(val, "Z"), "T").split(/[:.]/).map((i) => Number(i));
|
|
5927
|
+
return val.startsWith("T") && val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5928
|
+
} else {
|
|
5929
|
+
return false;
|
|
5930
|
+
}
|
|
5961
5931
|
}
|
|
5962
|
-
function
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5932
|
+
function isIsoImplicitTime(val) {
|
|
5933
|
+
if (isString(val)) {
|
|
5934
|
+
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
5935
|
+
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
5936
|
+
} else {
|
|
5937
|
+
return false;
|
|
5938
|
+
}
|
|
5967
5939
|
}
|
|
5968
|
-
function
|
|
5969
|
-
|
|
5970
|
-
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
5940
|
+
function isIsoTime(val) {
|
|
5941
|
+
return isIsoExplicitTime(val) || isIsoImplicitTime(val);
|
|
5971
5942
|
}
|
|
5972
|
-
function
|
|
5973
|
-
|
|
5974
|
-
let result2 = input;
|
|
5975
|
-
result2 = ensureLeading(result2, prefix);
|
|
5976
|
-
result2 = ensureTrailing(result2, postfix);
|
|
5977
|
-
return result2;
|
|
5978
|
-
};
|
|
5979
|
-
return fn2;
|
|
5943
|
+
function isIsoYear(val) {
|
|
5944
|
+
return !!(isString(val) && val.length === 4 && isNumber(Number(val)) && Number(val) >= 0 && Number(val) <= 9999);
|
|
5980
5945
|
}
|
|
5981
|
-
function
|
|
5982
|
-
return (
|
|
5983
|
-
//
|
|
5984
|
-
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
5985
|
-
);
|
|
5946
|
+
function isLuxonDateTime(val) {
|
|
5947
|
+
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";
|
|
5986
5948
|
}
|
|
5987
|
-
function
|
|
5988
|
-
if (
|
|
5989
|
-
|
|
5990
|
-
return [t, st];
|
|
5991
|
-
} else {
|
|
5992
|
-
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
5993
|
-
err.name = "InvalidTypeSubtype";
|
|
5994
|
-
throw err;
|
|
5949
|
+
function isMoment(val) {
|
|
5950
|
+
if (val instanceof Date) {
|
|
5951
|
+
return false;
|
|
5995
5952
|
}
|
|
5953
|
+
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";
|
|
5996
5954
|
}
|
|
5997
|
-
function
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
if (
|
|
6002
|
-
|
|
5955
|
+
function isThisMonth(val) {
|
|
5956
|
+
const now = /* @__PURE__ */ new Date();
|
|
5957
|
+
const currentYear = now.getFullYear();
|
|
5958
|
+
const currentMonth = now.getMonth() + 1;
|
|
5959
|
+
if (val instanceof Date) {
|
|
5960
|
+
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
6003
5961
|
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
if (ch.length !== 1) {
|
|
6008
|
-
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
5962
|
+
if (isMoment(val)) {
|
|
5963
|
+
const monthValue = val.month();
|
|
5964
|
+
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
6009
5965
|
}
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
function parseTemplate(template) {
|
|
6013
|
-
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
6014
|
-
let lastIndex = 0;
|
|
6015
|
-
let match;
|
|
6016
|
-
const segments = [];
|
|
6017
|
-
while (match = pattern.exec(template)) {
|
|
6018
|
-
const [fullMatch, varName, asType2] = match;
|
|
6019
|
-
const staticPart = template.slice(lastIndex, match.index);
|
|
6020
|
-
if (staticPart) {
|
|
6021
|
-
segments.push({ dynamic: false, text: staticPart });
|
|
6022
|
-
}
|
|
6023
|
-
segments.push({
|
|
6024
|
-
dynamic: true,
|
|
6025
|
-
varName,
|
|
6026
|
-
type: asType2 ? asType2 : "string"
|
|
6027
|
-
});
|
|
6028
|
-
lastIndex = match.index + fullMatch.length;
|
|
5966
|
+
if (isLuxonDateTime(val)) {
|
|
5967
|
+
return val.year === currentYear && val.month === currentMonth;
|
|
6029
5968
|
}
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
5969
|
+
if (typeof val === "string") {
|
|
5970
|
+
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))?$/;
|
|
5971
|
+
if (!isoDateRegex.test(val)) {
|
|
5972
|
+
return false;
|
|
5973
|
+
}
|
|
5974
|
+
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
5975
|
+
if (dateMatch) {
|
|
5976
|
+
const year = Number.parseInt(dateMatch[1], 10);
|
|
5977
|
+
const month = Number.parseInt(dateMatch[2], 10);
|
|
5978
|
+
return year === currentYear && month === currentMonth;
|
|
5979
|
+
}
|
|
6033
5980
|
}
|
|
6034
|
-
return
|
|
5981
|
+
return false;
|
|
6035
5982
|
}
|
|
6036
|
-
function
|
|
6037
|
-
|
|
5983
|
+
function isThisWeek(date) {
|
|
5984
|
+
const targetDate = asDate(date);
|
|
5985
|
+
if (!targetDate) {
|
|
5986
|
+
return false;
|
|
5987
|
+
}
|
|
5988
|
+
const currentWeek = getWeekNumber();
|
|
5989
|
+
const targetWeek = getWeekNumber(targetDate);
|
|
5990
|
+
return currentWeek === targetWeek;
|
|
6038
5991
|
}
|
|
6039
|
-
function
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
5992
|
+
function isThisYear(val) {
|
|
5993
|
+
const currentYear = (/* @__PURE__ */ new Date()).getFullYear();
|
|
5994
|
+
if (isObject(val) || isNumber(val) || isString(val)) {
|
|
5995
|
+
const date = asDate(val);
|
|
5996
|
+
if (date) {
|
|
5997
|
+
return date.getFullYear() === currentYear;
|
|
6044
5998
|
} else {
|
|
6045
|
-
|
|
6046
|
-
case "string":
|
|
6047
|
-
regexStr += "(.*?)";
|
|
6048
|
-
break;
|
|
6049
|
-
case "number":
|
|
6050
|
-
regexStr += "(\\d+)";
|
|
6051
|
-
break;
|
|
6052
|
-
case "boolean":
|
|
6053
|
-
regexStr += "(true|false)";
|
|
6054
|
-
break;
|
|
6055
|
-
}
|
|
5999
|
+
return false;
|
|
6056
6000
|
}
|
|
6057
6001
|
}
|
|
6058
|
-
|
|
6059
|
-
return new RegExp(regexStr);
|
|
6002
|
+
return false;
|
|
6060
6003
|
}
|
|
6061
|
-
function
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6004
|
+
function isToday(test) {
|
|
6005
|
+
if (isString(test)) {
|
|
6006
|
+
const justDate = stripAfter(test, "T");
|
|
6007
|
+
return isIsoExplicitDate(justDate) && justDate === getToday();
|
|
6008
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6009
|
+
return stripAfter(test.toISOString(), "T") === getToday();
|
|
6010
|
+
} else if (isLuxonDateTime(test)) {
|
|
6011
|
+
return stripAfter(test.toISO(), "T") === getToday();
|
|
6069
6012
|
}
|
|
6013
|
+
return false;
|
|
6070
6014
|
}
|
|
6071
|
-
function
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
if (
|
|
6076
|
-
return
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
for (const seg of segments) {
|
|
6080
|
-
if (seg.dynamic) {
|
|
6081
|
-
const rawVal = match[captureIndex++];
|
|
6082
|
-
if (rawVal === void 0)
|
|
6083
|
-
return false;
|
|
6084
|
-
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
6085
|
-
}
|
|
6015
|
+
function isTomorrow(test) {
|
|
6016
|
+
if (isString(test)) {
|
|
6017
|
+
const justDate = stripAfter(test, "T");
|
|
6018
|
+
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
6019
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6020
|
+
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
6021
|
+
} else if (isLuxonDateTime(test)) {
|
|
6022
|
+
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
6086
6023
|
}
|
|
6087
|
-
return
|
|
6024
|
+
return false;
|
|
6088
6025
|
}
|
|
6089
|
-
function
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
|
|
6026
|
+
function isYesterday(test) {
|
|
6027
|
+
if (isString(test)) {
|
|
6028
|
+
const justDate = stripAfter(test, "T");
|
|
6029
|
+
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
6030
|
+
} else if (isMoment(test) || isDate(test)) {
|
|
6031
|
+
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
6032
|
+
} else if (isLuxonDateTime(test)) {
|
|
6033
|
+
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
6034
|
+
}
|
|
6035
|
+
return false;
|
|
6093
6036
|
}
|
|
6094
|
-
function
|
|
6095
|
-
|
|
6037
|
+
function isVisa(val) {
|
|
6038
|
+
if (isString(val) && val.startsWith("4")) {
|
|
6039
|
+
const parts = val.split(" ");
|
|
6040
|
+
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
6041
|
+
}
|
|
6042
|
+
return false;
|
|
6096
6043
|
}
|
|
6097
|
-
function
|
|
6098
|
-
|
|
6044
|
+
function isMastercard(val) {
|
|
6045
|
+
if (isString(val) && val.startsWith("4")) {
|
|
6046
|
+
const parts = val.split(" ");
|
|
6047
|
+
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));
|
|
6048
|
+
}
|
|
6049
|
+
return false;
|
|
6099
6050
|
}
|
|
6100
|
-
function
|
|
6101
|
-
return
|
|
6051
|
+
function isVisaMastercard(val) {
|
|
6052
|
+
return isVisa(val) || isMastercard(val);
|
|
6102
6053
|
}
|
|
6103
|
-
function
|
|
6104
|
-
|
|
6054
|
+
function isAmericanExpress(val) {
|
|
6055
|
+
if (isString(val)) {
|
|
6056
|
+
const parts = val.split(" ");
|
|
6057
|
+
return parts.length === 3 && parts.every(
|
|
6058
|
+
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
6059
|
+
);
|
|
6060
|
+
}
|
|
6061
|
+
return false;
|
|
6105
6062
|
}
|
|
6106
|
-
function
|
|
6107
|
-
return
|
|
6063
|
+
function isCreditCard(val) {
|
|
6064
|
+
return isVisaMastercard(val) || isAmericanExpress(val);
|
|
6108
6065
|
}
|
|
6109
|
-
function
|
|
6110
|
-
|
|
6066
|
+
function cardType(cardNumber) {
|
|
6067
|
+
const cleanedNumber = String(cardNumber).replace(/\D/g, "");
|
|
6068
|
+
const length = cleanedNumber.length;
|
|
6069
|
+
if (!isValidLength(length)) {
|
|
6070
|
+
return "invalid";
|
|
6071
|
+
}
|
|
6072
|
+
if (!luhnCheck(cleanedNumber)) {
|
|
6073
|
+
return "invalid";
|
|
6074
|
+
}
|
|
6075
|
+
const cardTypes = [
|
|
6076
|
+
{ name: "Visa", lengths: [16], prefixes: [/^4/] },
|
|
6077
|
+
{ 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)/] },
|
|
6078
|
+
{ name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
|
|
6079
|
+
{ 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)/] },
|
|
6080
|
+
{ name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
|
|
6081
|
+
{ name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
|
|
6082
|
+
{ name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
|
|
6083
|
+
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
6084
|
+
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
6085
|
+
];
|
|
6086
|
+
for (const type of cardTypes) {
|
|
6087
|
+
if (type.lengths.includes(length)) {
|
|
6088
|
+
for (const prefix of type.prefixes) {
|
|
6089
|
+
if (prefix.test(cleanedNumber)) {
|
|
6090
|
+
return type.name;
|
|
6091
|
+
}
|
|
6092
|
+
}
|
|
6093
|
+
}
|
|
6094
|
+
}
|
|
6095
|
+
return "invalid";
|
|
6111
6096
|
}
|
|
6112
|
-
function
|
|
6113
|
-
|
|
6097
|
+
function isValidLength(length) {
|
|
6098
|
+
const validLengths = [13, 14, 15, 16, 17, 18, 19];
|
|
6099
|
+
return validLengths.includes(length);
|
|
6114
6100
|
}
|
|
6115
|
-
function
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6101
|
+
function luhnCheck(num) {
|
|
6102
|
+
let sum = 0;
|
|
6103
|
+
let double = false;
|
|
6104
|
+
for (let i = num.length - 1; i >= 0; i--) {
|
|
6105
|
+
let n = Number.parseInt(num.charAt(i), 10);
|
|
6106
|
+
if (double) {
|
|
6107
|
+
n *= 2;
|
|
6108
|
+
if (n > 9) {
|
|
6109
|
+
n -= 9;
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
sum += n;
|
|
6113
|
+
double = !double;
|
|
6114
|
+
}
|
|
6115
|
+
return sum % 10 === 0;
|
|
6121
6116
|
}
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
6125
|
-
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
6126
|
-
...NUMERIC_CHAR2
|
|
6127
|
-
) : "";
|
|
6117
|
+
function isString(value) {
|
|
6118
|
+
return typeof value === "string";
|
|
6128
6119
|
}
|
|
6129
|
-
function
|
|
6130
|
-
const
|
|
6131
|
-
return
|
|
6132
|
-
phone.trim(),
|
|
6133
|
-
"+",
|
|
6134
|
-
"00"
|
|
6135
|
-
), countryCode).trim() : phone.trim();
|
|
6120
|
+
function isIso3166Alpha2(val) {
|
|
6121
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6122
|
+
return isString(val) && codes.includes(val);
|
|
6136
6123
|
}
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
case "is":
|
|
6141
|
-
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
6142
|
-
case "singular-noun":
|
|
6143
|
-
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
6144
|
-
case "f":
|
|
6145
|
-
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
6146
|
-
case "y":
|
|
6147
|
-
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
6148
|
-
default:
|
|
6149
|
-
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
6150
|
-
}
|
|
6124
|
+
function isCountryCode2(val) {
|
|
6125
|
+
const codes = ISO3166_12.map((i) => i.alpha2);
|
|
6126
|
+
return isString(val) && codes.includes(val);
|
|
6151
6127
|
}
|
|
6152
|
-
function
|
|
6153
|
-
const
|
|
6154
|
-
|
|
6155
|
-
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
6156
|
-
return `${result2}${right}`;
|
|
6157
|
-
}
|
|
6158
|
-
function retainAfter(content, ...find2) {
|
|
6159
|
-
const idx = Math.min(
|
|
6160
|
-
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
6161
|
-
);
|
|
6162
|
-
const min = Math.min(...find2.map((i) => i.length));
|
|
6163
|
-
let len = Math.max(...find2.map((i) => i.length));
|
|
6164
|
-
if (min !== len) {
|
|
6165
|
-
if (!find2.includes(content.slice(idx, len))) {
|
|
6166
|
-
len = min;
|
|
6167
|
-
}
|
|
6168
|
-
}
|
|
6169
|
-
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
6128
|
+
function isIso3166Alpha3(val) {
|
|
6129
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6130
|
+
return isString(val) && codes.includes(val);
|
|
6170
6131
|
}
|
|
6171
|
-
function
|
|
6172
|
-
const
|
|
6173
|
-
|
|
6174
|
-
);
|
|
6175
|
-
return minFound > 0 ? content.slice(minFound) : "";
|
|
6132
|
+
function isCountryCode3(val) {
|
|
6133
|
+
const codes = ISO3166_12.map((i) => i.alpha3);
|
|
6134
|
+
return isString(val) && codes.includes(val);
|
|
6176
6135
|
}
|
|
6177
|
-
function
|
|
6178
|
-
const
|
|
6179
|
-
return
|
|
6136
|
+
function isIso3166CountryCode(val) {
|
|
6137
|
+
const codes = ISO3166_12.map((i) => i.countryCode);
|
|
6138
|
+
return isString(val) && codes.includes(val);
|
|
6180
6139
|
}
|
|
6181
|
-
function
|
|
6182
|
-
|
|
6183
|
-
let idx = 0;
|
|
6184
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6185
|
-
idx = idx + 1;
|
|
6186
|
-
}
|
|
6187
|
-
return idx === 0 ? "" : content.slice(0, idx);
|
|
6140
|
+
function isCountryAbbrev(val) {
|
|
6141
|
+
return isCountryCode2(val) || isCountryCode3(val);
|
|
6188
6142
|
}
|
|
6189
|
-
function
|
|
6190
|
-
const
|
|
6191
|
-
|
|
6192
|
-
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
6193
|
-
idx = idx + 1;
|
|
6194
|
-
}
|
|
6195
|
-
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
6143
|
+
function isIso3166CountryName(val) {
|
|
6144
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6145
|
+
return isString(val) && codes.includes(val);
|
|
6196
6146
|
}
|
|
6197
|
-
function
|
|
6198
|
-
const
|
|
6199
|
-
return
|
|
6147
|
+
function isCountryName(val) {
|
|
6148
|
+
const codes = ISO3166_12.map((i) => i.name);
|
|
6149
|
+
return isString(val) && codes.includes(val);
|
|
6200
6150
|
}
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
...WHITESPACE_CHARS2
|
|
6206
|
-
);
|
|
6151
|
+
var ABBREV = US_STATE_LOOKUP2.map((i) => i.abbrev);
|
|
6152
|
+
var NAME = US_STATE_LOOKUP2.map((i) => i.name);
|
|
6153
|
+
function isUsStateAbbreviation(val) {
|
|
6154
|
+
return isString(val) && ABBREV.includes(val);
|
|
6207
6155
|
}
|
|
6208
|
-
function
|
|
6209
|
-
return
|
|
6156
|
+
function isUsStateName(val) {
|
|
6157
|
+
return isString(val) && NAME.includes(val);
|
|
6210
6158
|
}
|
|
6211
|
-
function
|
|
6212
|
-
|
|
6159
|
+
function isNumericString(value) {
|
|
6160
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6161
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
6213
6162
|
}
|
|
6214
|
-
function
|
|
6215
|
-
|
|
6163
|
+
function isNumberLike(value) {
|
|
6164
|
+
const numericChars = [...NUMERIC_CHAR2];
|
|
6165
|
+
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
6216
6166
|
}
|
|
6217
|
-
function
|
|
6218
|
-
|
|
6219
|
-
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
6167
|
+
function isNumber(value) {
|
|
6168
|
+
return typeof value === "number";
|
|
6220
6169
|
}
|
|
6221
|
-
function
|
|
6222
|
-
if (
|
|
6223
|
-
return
|
|
6224
|
-
}
|
|
6225
|
-
let output = String(content);
|
|
6226
|
-
for (const s of strip2) {
|
|
6227
|
-
if (output.startsWith(String(s))) {
|
|
6228
|
-
output = output.slice(String(s).length);
|
|
6229
|
-
}
|
|
6170
|
+
function isZipCode5(val) {
|
|
6171
|
+
if (isNumber(val)) {
|
|
6172
|
+
return isZipCode5(`${val}`);
|
|
6230
6173
|
}
|
|
6231
|
-
return
|
|
6232
|
-
}
|
|
6233
|
-
function stripSurround(...chars) {
|
|
6234
|
-
return (input) => {
|
|
6235
|
-
let output = String(input);
|
|
6236
|
-
for (const s of chars) {
|
|
6237
|
-
if (output.startsWith(String(s))) {
|
|
6238
|
-
output = output.slice(String(s).length);
|
|
6239
|
-
}
|
|
6240
|
-
if (output.endsWith(String(s))) {
|
|
6241
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6242
|
-
}
|
|
6243
|
-
}
|
|
6244
|
-
return isNumber(input) ? Number(output) : output;
|
|
6245
|
-
};
|
|
6174
|
+
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
6246
6175
|
}
|
|
6247
|
-
function
|
|
6248
|
-
if (
|
|
6249
|
-
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
for (const s of strip2) {
|
|
6253
|
-
if (output.endsWith(String(s))) {
|
|
6254
|
-
output = output.slice(0, -1 * String(s).length);
|
|
6255
|
-
}
|
|
6176
|
+
function isZipPlus4(val) {
|
|
6177
|
+
if (isString(val)) {
|
|
6178
|
+
const first = retainWhile(val.trim(), ...NUMERIC_CHAR2);
|
|
6179
|
+
const next = stripChars(val.trim().replace(first, "").trim(), "-");
|
|
6180
|
+
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6256
6181
|
}
|
|
6257
|
-
return
|
|
6182
|
+
return false;
|
|
6258
6183
|
}
|
|
6259
|
-
function
|
|
6260
|
-
|
|
6261
|
-
return content.slice(stopIdx);
|
|
6184
|
+
function isZipCode(val) {
|
|
6185
|
+
return isZipCode5(val) || isZipPlus4(val);
|
|
6262
6186
|
}
|
|
6263
|
-
function
|
|
6264
|
-
|
|
6265
|
-
|
|
6187
|
+
function isSpecificConstant(kind) {
|
|
6188
|
+
return (value) => {
|
|
6189
|
+
return !!(isConstant(value) && value.kind === kind);
|
|
6190
|
+
};
|
|
6266
6191
|
}
|
|
6267
|
-
function
|
|
6268
|
-
|
|
6192
|
+
function hasDefaultValue(value) {
|
|
6193
|
+
const noDefault = isSpecificConstant("no-default-value");
|
|
6194
|
+
return !noDefault(value);
|
|
6269
6195
|
}
|
|
6270
|
-
function
|
|
6271
|
-
const
|
|
6272
|
-
return
|
|
6196
|
+
function hasIndexOf(value, idx) {
|
|
6197
|
+
const result2 = isObject(value) ? String(idx) in value : Array.isArray(value) ? Number(idx) in value : false;
|
|
6198
|
+
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
6273
6199
|
}
|
|
6274
|
-
function
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6278
|
-
|
|
6279
|
-
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
6280
|
-
return camel;
|
|
6200
|
+
function hasKeys(...props) {
|
|
6201
|
+
return (val) => {
|
|
6202
|
+
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
6203
|
+
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
6204
|
+
};
|
|
6281
6205
|
}
|
|
6282
|
-
function
|
|
6283
|
-
|
|
6284
|
-
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
6285
|
-
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
6286
|
-
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
6287
|
-
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
6288
|
-
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
6289
|
-
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
6290
|
-
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
6291
|
-
replaceTrailingDash(
|
|
6292
|
-
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
6293
|
-
)
|
|
6294
|
-
)}${postWhite}`);
|
|
6206
|
+
function asChars(str) {
|
|
6207
|
+
return str.split("");
|
|
6295
6208
|
}
|
|
6296
|
-
function
|
|
6297
|
-
return
|
|
6209
|
+
function asRecord(obj) {
|
|
6210
|
+
return obj;
|
|
6298
6211
|
}
|
|
6299
|
-
function
|
|
6300
|
-
|
|
6301
|
-
input
|
|
6302
|
-
);
|
|
6303
|
-
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
6304
|
-
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
6305
|
-
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
6306
|
-
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
6307
|
-
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
6308
|
-
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
6309
|
-
)}${preserveWhitespace ? postWhite : ""}`;
|
|
6310
|
-
return pascal;
|
|
6212
|
+
function asString(value) {
|
|
6213
|
+
return isString(value) ? value : isNumber(value) ? `${value}` : isBoolean(value) ? `${value}` : isArray(value) ? value.join("") : String(value);
|
|
6311
6214
|
}
|
|
6312
|
-
function
|
|
6313
|
-
const
|
|
6314
|
-
|
|
6315
|
-
|
|
6316
|
-
|
|
6317
|
-
|
|
6318
|
-
|
|
6319
|
-
|
|
6320
|
-
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
6215
|
+
function csv(csv2, format = `string-numeric-tuple`) {
|
|
6216
|
+
const tuple3 = [];
|
|
6217
|
+
csv2.split(/,\s?/).forEach((v) => {
|
|
6218
|
+
tuple3.push(
|
|
6219
|
+
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
|
|
6220
|
+
);
|
|
6221
|
+
});
|
|
6222
|
+
return tuple3;
|
|
6321
6223
|
}
|
|
6322
|
-
function
|
|
6323
|
-
|
|
6224
|
+
function fromKeyValue(kvs) {
|
|
6225
|
+
const obj = {};
|
|
6226
|
+
for (const kv of kvs) {
|
|
6227
|
+
obj[kv.key] = kv.value;
|
|
6228
|
+
}
|
|
6229
|
+
return obj;
|
|
6324
6230
|
}
|
|
6325
|
-
function
|
|
6326
|
-
return
|
|
6231
|
+
function intersect(value, _intersectedWith) {
|
|
6232
|
+
return value;
|
|
6327
6233
|
}
|
|
6328
|
-
function
|
|
6329
|
-
return
|
|
6234
|
+
function ip6GroupExpansion(ip) {
|
|
6235
|
+
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
6330
6236
|
}
|
|
6331
|
-
function
|
|
6332
|
-
return
|
|
6237
|
+
function jsonValue(val) {
|
|
6238
|
+
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
6333
6239
|
}
|
|
6334
|
-
function
|
|
6335
|
-
return
|
|
6240
|
+
function jsonValues(...val) {
|
|
6241
|
+
return val.map((i) => jsonValue(i));
|
|
6336
6242
|
}
|
|
6337
|
-
function
|
|
6338
|
-
|
|
6243
|
+
function lookupAlpha2Code(code, prop) {
|
|
6244
|
+
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
6245
|
+
return found ? found[prop] : void 0;
|
|
6339
6246
|
}
|
|
6340
|
-
function
|
|
6341
|
-
|
|
6247
|
+
function lookupAlpha3Code(code, prop) {
|
|
6248
|
+
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
6249
|
+
return found ? found[prop] : void 0;
|
|
6342
6250
|
}
|
|
6343
|
-
function
|
|
6344
|
-
const
|
|
6345
|
-
return
|
|
6251
|
+
function lookupName(name, prop) {
|
|
6252
|
+
const found = ISO3166_12.find((i) => i.name === name);
|
|
6253
|
+
return found ? found[prop] : void 0;
|
|
6346
6254
|
}
|
|
6347
|
-
function
|
|
6348
|
-
|
|
6349
|
-
|
|
6255
|
+
function lookupNumericCode(code, prop) {
|
|
6256
|
+
let num = isNumber(code) ? `${code}` : code;
|
|
6257
|
+
if (num.length === 1) {
|
|
6258
|
+
num = `00${num}`;
|
|
6259
|
+
} else if (num.length === 2) {
|
|
6260
|
+
num = `0${num}`;
|
|
6261
|
+
}
|
|
6262
|
+
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
6263
|
+
return found ? found[prop] : void 0;
|
|
6350
6264
|
}
|
|
6351
|
-
function
|
|
6352
|
-
|
|
6265
|
+
function lookupCountryName(code) {
|
|
6266
|
+
const uc = uppercase(code);
|
|
6267
|
+
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
6353
6268
|
}
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
return
|
|
6269
|
+
function lookupCountryAlpha2(code) {
|
|
6270
|
+
const uc = uppercase(code);
|
|
6271
|
+
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
6357
6272
|
}
|
|
6358
|
-
function
|
|
6359
|
-
|
|
6273
|
+
function lookupCountryAlpha3(token) {
|
|
6274
|
+
const uc = uppercase(token);
|
|
6275
|
+
return isNumberLike(token) ? lookupNumericCode(token, "alpha3") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha3") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha3") : isIso3166CountryName(token) ? lookupName(token, "alpha3") : void 0;
|
|
6360
6276
|
}
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
return proto;
|
|
6277
|
+
function lookupCountryCode(token) {
|
|
6278
|
+
const uc = uppercase(token);
|
|
6279
|
+
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
6365
6280
|
}
|
|
6366
|
-
function
|
|
6367
|
-
|
|
6281
|
+
function asMapper(fn2) {
|
|
6282
|
+
const props = {
|
|
6283
|
+
kind: "Mapper",
|
|
6284
|
+
map: (from) => {
|
|
6285
|
+
return from.map(fn2);
|
|
6286
|
+
}
|
|
6287
|
+
};
|
|
6288
|
+
return createFnWithPropsExplicit(fn2, props);
|
|
6368
6289
|
}
|
|
6369
|
-
function
|
|
6370
|
-
|
|
6371
|
-
|
|
6290
|
+
function createObjectMap() {
|
|
6291
|
+
return (map2) => {
|
|
6292
|
+
const fn2 = (input) => {
|
|
6293
|
+
return Object.keys(map2).reduce(
|
|
6294
|
+
(acc, key) => {
|
|
6295
|
+
const val = map2[key];
|
|
6296
|
+
return {
|
|
6297
|
+
...acc,
|
|
6298
|
+
[key]: isFunction(val) ? val(input) : val
|
|
6299
|
+
};
|
|
6300
|
+
},
|
|
6301
|
+
{}
|
|
6302
|
+
);
|
|
6303
|
+
};
|
|
6304
|
+
return fn2;
|
|
6305
|
+
};
|
|
6372
6306
|
}
|
|
6373
|
-
function
|
|
6374
|
-
return
|
|
6375
|
-
|
|
6376
|
-
|
|
6307
|
+
function createMapper() {
|
|
6308
|
+
return (fn2) => {
|
|
6309
|
+
return asMapper(fn2);
|
|
6310
|
+
};
|
|
6377
6311
|
}
|
|
6378
|
-
function
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
stripBefore(qp, `${specific}=`),
|
|
6384
|
-
"&"
|
|
6385
|
-
).replace(/\+/g, "%20")
|
|
6386
|
-
) : void 0;
|
|
6387
|
-
}
|
|
6388
|
-
return qp === "" ? qp : `?${qp}`;
|
|
6312
|
+
function mergeObjects(defVal, override) {
|
|
6313
|
+
return {
|
|
6314
|
+
...defVal,
|
|
6315
|
+
...override
|
|
6316
|
+
};
|
|
6389
6317
|
}
|
|
6390
|
-
function
|
|
6391
|
-
|
|
6392
|
-
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
6318
|
+
function isUndefined(value) {
|
|
6319
|
+
return typeof value === "undefined";
|
|
6393
6320
|
}
|
|
6394
|
-
function
|
|
6395
|
-
|
|
6396
|
-
const match = url.match(re);
|
|
6397
|
-
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
6321
|
+
function mergeScalars(a, b) {
|
|
6322
|
+
return isUndefined(b) ? a : b;
|
|
6398
6323
|
}
|
|
6399
|
-
function
|
|
6400
|
-
|
|
6401
|
-
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
6324
|
+
function mergeTuples(a, b) {
|
|
6325
|
+
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]);
|
|
6402
6326
|
}
|
|
6403
|
-
function
|
|
6404
|
-
|
|
6405
|
-
const remaining = stripAfter(url, path);
|
|
6406
|
-
return remaining;
|
|
6327
|
+
function never(val) {
|
|
6328
|
+
return val;
|
|
6407
6329
|
}
|
|
6408
|
-
function
|
|
6409
|
-
|
|
6410
|
-
const qp = getUrlQueryParams(url);
|
|
6411
|
-
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
6412
|
-
const segmentTypes = [
|
|
6413
|
-
"string",
|
|
6414
|
-
"number",
|
|
6415
|
-
"boolean",
|
|
6416
|
-
"Opt<string>",
|
|
6417
|
-
"Opt<number>",
|
|
6418
|
-
"Opt<boolean>"
|
|
6419
|
-
];
|
|
6420
|
-
const pathVars = {};
|
|
6421
|
-
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
6422
|
-
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
6423
|
-
const findPathNamed = infer(`<{{infer name}}>`);
|
|
6424
|
-
for (const part of pathParts) {
|
|
6425
|
-
const union4 = findPathUnion(part);
|
|
6426
|
-
const typed = findPathTyped(part);
|
|
6427
|
-
const named = findPathNamed(part);
|
|
6428
|
-
if (union4) {
|
|
6429
|
-
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
6430
|
-
pathVars[union4.name] = `string(${union4.union})`;
|
|
6431
|
-
}
|
|
6432
|
-
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
6433
|
-
pathVars[typed.name] = typed.type;
|
|
6434
|
-
} else if (named && isVariable(named.name)) {
|
|
6435
|
-
pathVars[named.name] = "string";
|
|
6436
|
-
}
|
|
6437
|
-
}
|
|
6438
|
-
const qpVars = {};
|
|
6439
|
-
const qpParts = stripLeading(qp, "?").split("&");
|
|
6440
|
-
for (const p of qpParts) {
|
|
6441
|
-
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
6442
|
-
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
6443
|
-
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
6444
|
-
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
6445
|
-
qpVars[union4.var] = `string(${union4.params})`;
|
|
6446
|
-
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
6447
|
-
qpVars[dynamic.var] = dynamic.val;
|
|
6448
|
-
} else if (fixed && isVariable(fixed.var)) {
|
|
6449
|
-
qpVars[fixed.var] = fixed.val;
|
|
6450
|
-
}
|
|
6451
|
-
}
|
|
6452
|
-
return {
|
|
6453
|
-
pathVars,
|
|
6454
|
-
qpVars,
|
|
6455
|
-
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
6456
|
-
...pathVars,
|
|
6457
|
-
...qpVars
|
|
6458
|
-
}
|
|
6459
|
-
};
|
|
6330
|
+
function optional(value) {
|
|
6331
|
+
return value;
|
|
6460
6332
|
}
|
|
6461
|
-
function
|
|
6333
|
+
function orNull(value) {
|
|
6334
|
+
return value;
|
|
6335
|
+
}
|
|
6336
|
+
function optionalOrNull(value) {
|
|
6337
|
+
return value;
|
|
6338
|
+
}
|
|
6339
|
+
function stripParenthesis(val) {
|
|
6340
|
+
return stripTrailing(stripLeading(val.trim(), "("), ")").trim();
|
|
6341
|
+
}
|
|
6342
|
+
function sortKeyApi(order) {
|
|
6462
6343
|
return {
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6470
|
-
|
|
6471
|
-
|
|
6472
|
-
|
|
6473
|
-
|
|
6344
|
+
order,
|
|
6345
|
+
toTop: (...keys) => sortKeyApi(
|
|
6346
|
+
[
|
|
6347
|
+
...keys,
|
|
6348
|
+
...order.filter((i) => !keys.includes(i))
|
|
6349
|
+
]
|
|
6350
|
+
),
|
|
6351
|
+
toBottom: (...keys) => sortKeyApi(
|
|
6352
|
+
[
|
|
6353
|
+
...order.filter((i) => !keys.includes(i)),
|
|
6354
|
+
...keys
|
|
6355
|
+
]
|
|
6356
|
+
),
|
|
6357
|
+
done: () => order
|
|
6474
6358
|
};
|
|
6475
6359
|
}
|
|
6476
|
-
function
|
|
6477
|
-
|
|
6360
|
+
function toKeyValue(obj, sort) {
|
|
6361
|
+
let keys = keysOf(obj);
|
|
6362
|
+
const tuple3 = [];
|
|
6363
|
+
if (sort) {
|
|
6364
|
+
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
6365
|
+
}
|
|
6366
|
+
for (const k of keys) {
|
|
6367
|
+
tuple3.push({ key: k, value: obj[k] });
|
|
6368
|
+
}
|
|
6369
|
+
return tuple3;
|
|
6478
6370
|
}
|
|
6479
|
-
function
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
return
|
|
6487
|
-
|
|
6488
|
-
throw new Error(
|
|
6489
|
-
}
|
|
6490
|
-
} else {
|
|
6491
|
-
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
6371
|
+
function convertScalar(val) {
|
|
6372
|
+
switch (typeof val) {
|
|
6373
|
+
case "number":
|
|
6374
|
+
return val;
|
|
6375
|
+
case "string":
|
|
6376
|
+
return Number(val);
|
|
6377
|
+
case "boolean":
|
|
6378
|
+
return val ? 1 : 0;
|
|
6379
|
+
default:
|
|
6380
|
+
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
6492
6381
|
}
|
|
6493
6382
|
}
|
|
6494
|
-
|
|
6495
|
-
|
|
6496
|
-
|
|
6497
|
-
isYouTubeUrl: true,
|
|
6498
|
-
isShareUrl: isYouTubeShareUrl(url),
|
|
6499
|
-
pageType: getYouTubePageType(url)
|
|
6500
|
-
} : {
|
|
6501
|
-
url,
|
|
6502
|
-
isYouTubeUrl: false
|
|
6503
|
-
};
|
|
6383
|
+
var convertList = (val) => val.map((i) => convertScalar(i));
|
|
6384
|
+
function toNumber(value) {
|
|
6385
|
+
return Array.isArray(value) ? convertList(value) : convertScalar(value);
|
|
6504
6386
|
}
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
size: state.length,
|
|
6509
|
-
isEmpty() {
|
|
6510
|
-
return state.length === 0;
|
|
6511
|
-
},
|
|
6512
|
-
clear() {
|
|
6513
|
-
state.slice(0, 0);
|
|
6514
|
-
},
|
|
6515
|
-
drain() {
|
|
6516
|
-
const old_state = [...state];
|
|
6517
|
-
state.slice(0, 0);
|
|
6518
|
-
return old_state;
|
|
6519
|
-
},
|
|
6520
|
-
push(...add) {
|
|
6521
|
-
state.push(...add);
|
|
6522
|
-
},
|
|
6523
|
-
drop(quantity) {
|
|
6524
|
-
if (quantity && quantity > state.length) {
|
|
6525
|
-
throw new Error("Cannot drop more elements than present in the queue");
|
|
6526
|
-
}
|
|
6527
|
-
state.splice(0, quantity || 1);
|
|
6528
|
-
},
|
|
6529
|
-
take(quantity) {
|
|
6530
|
-
if (quantity && quantity > state.length) {
|
|
6531
|
-
throw new Error("Cannot take more elements than present in the queue");
|
|
6532
|
-
}
|
|
6533
|
-
const result2 = state.slice(0, quantity || 1);
|
|
6534
|
-
state.splice(0, quantity || 1);
|
|
6535
|
-
return result2;
|
|
6536
|
-
},
|
|
6537
|
-
*[Symbol.iterator]() {
|
|
6538
|
-
for (let i = 0; i < state.length; i++) {
|
|
6539
|
-
yield state[i];
|
|
6540
|
-
}
|
|
6541
|
-
}
|
|
6542
|
-
};
|
|
6543
|
-
}
|
|
6544
|
-
function createFifoQueue(...list2) {
|
|
6545
|
-
return queue([...list2]);
|
|
6546
|
-
}
|
|
6547
|
-
function queue2(state) {
|
|
6548
|
-
return {
|
|
6549
|
-
queue: state,
|
|
6550
|
-
size: state.length,
|
|
6551
|
-
isEmpty() {
|
|
6552
|
-
return state.length === 0;
|
|
6553
|
-
},
|
|
6554
|
-
push(...add) {
|
|
6555
|
-
state.push(...add);
|
|
6556
|
-
},
|
|
6557
|
-
drop(quantity) {
|
|
6558
|
-
state.splice(-quantity);
|
|
6559
|
-
},
|
|
6560
|
-
clear() {
|
|
6561
|
-
state.slice(0, 0);
|
|
6562
|
-
},
|
|
6563
|
-
drain() {
|
|
6564
|
-
const old_state = [...state];
|
|
6565
|
-
state.slice(0, 0);
|
|
6566
|
-
return old_state;
|
|
6567
|
-
},
|
|
6568
|
-
take(quantity) {
|
|
6569
|
-
const result2 = state.slice(-quantity);
|
|
6570
|
-
state.splice(-quantity);
|
|
6571
|
-
return result2;
|
|
6572
|
-
},
|
|
6573
|
-
*[Symbol.iterator]() {
|
|
6574
|
-
for (let i = state.length - 1; i >= 0; i--) {
|
|
6575
|
-
yield state[i];
|
|
6576
|
-
}
|
|
6577
|
-
}
|
|
6578
|
-
};
|
|
6579
|
-
}
|
|
6580
|
-
function createLifoQueue(...list2) {
|
|
6581
|
-
return queue2([...list2]);
|
|
6387
|
+
var MODS = TW_MODIFIERS2.map((i) => `${i}:`);
|
|
6388
|
+
function removeTailwindModifiers(val) {
|
|
6389
|
+
return MODS.some((i) => val.startsWith(i)) ? removeTailwindModifiers(val.replace(MODS.find((i) => val.startsWith(i)), "")) : val;
|
|
6582
6390
|
}
|
|
6583
|
-
|
|
6584
|
-
|
|
6585
|
-
number: "<<number>>",
|
|
6586
|
-
boolean: "<<boolean>>",
|
|
6587
|
-
true: "<<true>>",
|
|
6588
|
-
false: "<<false>>",
|
|
6589
|
-
null: "<<null>>",
|
|
6590
|
-
undefined: "<<undefined>>",
|
|
6591
|
-
unknown: "<<unknown>>",
|
|
6592
|
-
any: "<<any>>",
|
|
6593
|
-
never: "<<never>>"
|
|
6594
|
-
});
|
|
6595
|
-
function stringLiteral(str) {
|
|
6596
|
-
return stripAfter(stripBefore(str, "string("), ")");
|
|
6391
|
+
function getTailwindModifiers(val) {
|
|
6392
|
+
return val.split(":").filter((i) => isTailwindModifier(i));
|
|
6597
6393
|
}
|
|
6598
|
-
function
|
|
6599
|
-
return
|
|
6394
|
+
function union(..._options) {
|
|
6395
|
+
return (value) => value;
|
|
6600
6396
|
}
|
|
6601
|
-
function
|
|
6602
|
-
|
|
6603
|
-
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>>`;
|
|
6397
|
+
function unionize(value, _inUnionWith) {
|
|
6398
|
+
return value;
|
|
6604
6399
|
}
|
|
6605
|
-
function
|
|
6606
|
-
return
|
|
6400
|
+
function hasWhiteSpace(val) {
|
|
6401
|
+
return isString(val) && asChars(val).some((c) => WHITESPACE_CHARS2.includes(c));
|
|
6607
6402
|
}
|
|
6608
|
-
function
|
|
6609
|
-
return
|
|
6403
|
+
function endsWith(endingIn2) {
|
|
6404
|
+
return (val) => {
|
|
6405
|
+
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
6406
|
+
};
|
|
6610
6407
|
}
|
|
6611
|
-
function
|
|
6612
|
-
return
|
|
6408
|
+
function compare(base) {
|
|
6409
|
+
return (value) => {
|
|
6410
|
+
return base.includes(value);
|
|
6411
|
+
};
|
|
6613
6412
|
}
|
|
6614
|
-
|
|
6615
|
-
|
|
6616
|
-
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union(stripUnion(val))} ]>>` : Never2;
|
|
6413
|
+
function isEqual(...base) {
|
|
6414
|
+
return compare(base);
|
|
6617
6415
|
}
|
|
6618
|
-
function
|
|
6416
|
+
function isLength(value, len) {
|
|
6417
|
+
return isArray(value) ? !!isEqual(value.length)(len) : isString(value) ? !!isEqual(value.length)(len) : isObject(value) ? !!isEqual(keysOf(value))(len) : false;
|
|
6619
6418
|
}
|
|
6620
|
-
function
|
|
6621
|
-
return
|
|
6419
|
+
function isSameTypeOf(base) {
|
|
6420
|
+
return (compare2) => {
|
|
6421
|
+
return typeof base === typeof compare2;
|
|
6422
|
+
};
|
|
6622
6423
|
}
|
|
6623
|
-
function
|
|
6624
|
-
|
|
6424
|
+
function isTuple(...tuple3) {
|
|
6425
|
+
const results = tuple3.map((i) => i(ShapeApiImplementation)).map((i) => isDoneFn(i) ? i.done() : i);
|
|
6426
|
+
return (v) => {
|
|
6427
|
+
return isArray(v) && v.length === results.length && results.every(isShape) && v.every((item, idx) => isSameTypeOf(results[idx])(item));
|
|
6428
|
+
};
|
|
6625
6429
|
}
|
|
6626
|
-
function
|
|
6627
|
-
return
|
|
6430
|
+
function isTypeOf(type) {
|
|
6431
|
+
return (value) => {
|
|
6432
|
+
return typeof value === type;
|
|
6433
|
+
};
|
|
6628
6434
|
}
|
|
6629
|
-
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
function fn(..._args) {
|
|
6633
|
-
return {
|
|
6634
|
-
returns: (_rtn) => ({
|
|
6635
|
-
addProperties: (_kv) => {
|
|
6636
|
-
return null;
|
|
6637
|
-
},
|
|
6638
|
-
done: () => {
|
|
6639
|
-
return null;
|
|
6640
|
-
}
|
|
6641
|
-
}),
|
|
6642
|
-
done: () => {
|
|
6643
|
-
const result2 = null;
|
|
6644
|
-
return result2;
|
|
6645
|
-
}
|
|
6435
|
+
function startsWith(startingWith) {
|
|
6436
|
+
return (val) => {
|
|
6437
|
+
return isString(val) ? !!val.startsWith(startingWith) : isNumber(val) ? !!String(val).startsWith(startingWith) : false;
|
|
6646
6438
|
};
|
|
6647
6439
|
}
|
|
6648
|
-
function
|
|
6649
|
-
return
|
|
6440
|
+
function isHtmlElement(val) {
|
|
6441
|
+
return isObject(val) && "attributes" in val && "firstElementChild" in val && "innerHTML" in val;
|
|
6650
6442
|
}
|
|
6651
|
-
function
|
|
6652
|
-
return
|
|
6443
|
+
function isAlpha(value) {
|
|
6444
|
+
return isString(value) && split(value).every((v) => ALPHA_CHARS2.includes(v));
|
|
6653
6445
|
}
|
|
6654
|
-
function
|
|
6655
|
-
|
|
6656
|
-
if (isString(re)) {
|
|
6657
|
-
try {
|
|
6658
|
-
const test = new RegExp(re);
|
|
6659
|
-
if (!isRegExp(test)) {
|
|
6660
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
6661
|
-
err.name = "InvalidRegEx";
|
|
6662
|
-
throw err;
|
|
6663
|
-
} else {
|
|
6664
|
-
exp = re;
|
|
6665
|
-
}
|
|
6666
|
-
} catch {
|
|
6667
|
-
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
6668
|
-
err.name = "InvalidRegEx";
|
|
6669
|
-
throw err;
|
|
6670
|
-
}
|
|
6671
|
-
} else if (isRegExp(re)) {
|
|
6672
|
-
exp = re.toString();
|
|
6673
|
-
}
|
|
6674
|
-
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
6675
|
-
return token;
|
|
6446
|
+
function isArray(value) {
|
|
6447
|
+
return Array.isArray(value) === true;
|
|
6676
6448
|
}
|
|
6677
|
-
function
|
|
6678
|
-
return
|
|
6679
|
-
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
6680
|
-
"union",
|
|
6681
|
-
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
6682
|
-
);
|
|
6683
|
-
};
|
|
6449
|
+
function isBoolean(value) {
|
|
6450
|
+
return typeof value === "boolean";
|
|
6684
6451
|
}
|
|
6685
|
-
|
|
6686
|
-
|
|
6687
|
-
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
6688
|
-
zip: () => addToken("string-set", "Zip5"),
|
|
6689
|
-
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
6690
|
-
zipCode: () => addToken("string-set", "ZipCode"),
|
|
6691
|
-
militaryTime: (resolution) => {
|
|
6692
|
-
return addToken(
|
|
6693
|
-
"string-set",
|
|
6694
|
-
"militaryTime",
|
|
6695
|
-
resolution || "HH:MM"
|
|
6696
|
-
);
|
|
6697
|
-
},
|
|
6698
|
-
civilianTime: (resolution) => {
|
|
6699
|
-
return addToken(
|
|
6700
|
-
"string-set",
|
|
6701
|
-
"militaryTime",
|
|
6702
|
-
resolution || "HH:MM"
|
|
6703
|
-
);
|
|
6704
|
-
},
|
|
6705
|
-
numericString: () => addToken("string-set", "numeric"),
|
|
6706
|
-
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
6707
|
-
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
6708
|
-
regex: (exp, ...literalRepresentation) => {
|
|
6709
|
-
const token = regexToken(exp, ...literalRepresentation);
|
|
6710
|
-
return token;
|
|
6711
|
-
},
|
|
6712
|
-
done: () => addToken("string")
|
|
6713
|
-
};
|
|
6714
|
-
var string22 = addSingleton("string", stringApi);
|
|
6715
|
-
var number = addSingleton("number");
|
|
6716
|
-
function union2(...elements) {
|
|
6717
|
-
const result2 = elements.map((_el) => {
|
|
6718
|
-
});
|
|
6719
|
-
return result2;
|
|
6452
|
+
function isBooleanLike(val) {
|
|
6453
|
+
return isBoolean(val) || isString(val) && ["true", "false", "boolean"].includes(val);
|
|
6720
6454
|
}
|
|
6721
|
-
function
|
|
6722
|
-
return
|
|
6455
|
+
function isConstant(value) {
|
|
6456
|
+
return !!(isObject(value) && "_type" in value && "kind" in value && value._type === "Constant");
|
|
6723
6457
|
}
|
|
6724
|
-
function
|
|
6725
|
-
return
|
|
6458
|
+
function isContainer(value) {
|
|
6459
|
+
return !!(Array.isArray(value) || isObject(value));
|
|
6726
6460
|
}
|
|
6727
|
-
|
|
6728
|
-
|
|
6461
|
+
var tokens = [
|
|
6462
|
+
"1",
|
|
6463
|
+
"inherit",
|
|
6464
|
+
"initial",
|
|
6465
|
+
"revert",
|
|
6466
|
+
"revert-layer",
|
|
6467
|
+
"unset",
|
|
6468
|
+
"auto"
|
|
6469
|
+
];
|
|
6470
|
+
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
6471
|
+
function isCssAspectRatio(val) {
|
|
6472
|
+
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6729
6473
|
}
|
|
6730
|
-
function
|
|
6731
|
-
return
|
|
6474
|
+
function isCsv(val) {
|
|
6475
|
+
return isString(val) && val.includes(",") && !val.startsWith(",");
|
|
6732
6476
|
}
|
|
6733
|
-
function
|
|
6734
|
-
return
|
|
6477
|
+
function isDefined(value) {
|
|
6478
|
+
return value !== void 0;
|
|
6735
6479
|
}
|
|
6736
|
-
function
|
|
6737
|
-
return
|
|
6480
|
+
function isDoneFn(val) {
|
|
6481
|
+
return hasKeys("done")(val) && typeof val.done === "function";
|
|
6738
6482
|
}
|
|
6739
|
-
|
|
6740
|
-
|
|
6741
|
-
|
|
6742
|
-
|
|
6743
|
-
|
|
6744
|
-
|
|
6745
|
-
|
|
6746
|
-
|
|
6747
|
-
|
|
6748
|
-
record,
|
|
6749
|
-
array,
|
|
6750
|
-
set,
|
|
6751
|
-
map,
|
|
6752
|
-
weakMap,
|
|
6753
|
-
dictionary,
|
|
6754
|
-
tuple: tuple2
|
|
6755
|
-
};
|
|
6756
|
-
function shape(cb) {
|
|
6757
|
-
const rtn = cb(ShapeApiImplementation);
|
|
6758
|
-
return handleDoneFn(
|
|
6759
|
-
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
6760
|
-
);
|
|
6483
|
+
function isEmail(val) {
|
|
6484
|
+
if (!isString(val)) {
|
|
6485
|
+
return false;
|
|
6486
|
+
}
|
|
6487
|
+
const parts = val?.split("@");
|
|
6488
|
+
const domain = parts[1]?.split(".");
|
|
6489
|
+
const tld = domain ? domain.pop() : "";
|
|
6490
|
+
const firstChar = val[0].toLowerCase();
|
|
6491
|
+
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
6761
6492
|
}
|
|
6762
|
-
function
|
|
6763
|
-
return
|
|
6493
|
+
function isEmpty(val) {
|
|
6494
|
+
return isUndefined(val) || isNull(val) || isString(val) && val.length === 0 || isObject(val) && Object.keys(val).length === 0 || isArray(val) && val.length === 0;
|
|
6764
6495
|
}
|
|
6765
|
-
function
|
|
6766
|
-
|
|
6767
|
-
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
6768
|
-
...acc,
|
|
6769
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6770
|
-
} : isFunction(defn[i]) ? {
|
|
6771
|
-
...acc,
|
|
6772
|
-
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
6773
|
-
} : Never2,
|
|
6774
|
-
{}
|
|
6775
|
-
);
|
|
6776
|
-
return result2;
|
|
6496
|
+
function isNotEmpty(val) {
|
|
6497
|
+
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));
|
|
6777
6498
|
}
|
|
6778
|
-
function
|
|
6779
|
-
return
|
|
6499
|
+
function isErrorCondition(value, kind = null) {
|
|
6500
|
+
return isObject(value) && "__kind" in value && value.__kind === "ErrorCondition" && "kind" in value ? kind !== null ? value.kind === kind : true : false;
|
|
6780
6501
|
}
|
|
6781
|
-
function
|
|
6782
|
-
return
|
|
6502
|
+
function isFalse(i) {
|
|
6503
|
+
return typeof i === "boolean" && !i;
|
|
6783
6504
|
}
|
|
6784
|
-
|
|
6785
|
-
|
|
6786
|
-
|
|
6787
|
-
|
|
6788
|
-
|
|
6789
|
-
|
|
6790
|
-
|
|
6791
|
-
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6795
|
-
|
|
6796
|
-
|
|
6797
|
-
|
|
6798
|
-
|
|
6799
|
-
|
|
6800
|
-
|
|
6801
|
-
|
|
6802
|
-
|
|
6803
|
-
|
|
6804
|
-
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
|
|
6809
|
-
|
|
6810
|
-
|
|
6811
|
-
|
|
6812
|
-
|
|
6813
|
-
|
|
6814
|
-
|
|
6815
|
-
|
|
6816
|
-
|
|
6817
|
-
|
|
6818
|
-
|
|
6819
|
-
|
|
6820
|
-
|
|
6821
|
-
|
|
6822
|
-
|
|
6823
|
-
|
|
6824
|
-
|
|
6825
|
-
|
|
6826
|
-
|
|
6827
|
-
|
|
6828
|
-
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
|
|
6832
|
-
|
|
6833
|
-
|
|
6834
|
-
|
|
6835
|
-
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
|
|
6841
|
-
|
|
6842
|
-
|
|
6843
|
-
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
-
|
|
6847
|
-
|
|
6848
|
-
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
|
|
6855
|
-
|
|
6856
|
-
response = true;
|
|
6857
|
-
}
|
|
6505
|
+
function isFalsy(val) {
|
|
6506
|
+
return FALSY_VALUES2.includes(val);
|
|
6507
|
+
}
|
|
6508
|
+
function isFnWithParams(input, ...params) {
|
|
6509
|
+
return params.length === 0 ? typeof input === "function" && input?.length > 0 : typeof input === "function" && input?.length === params.length;
|
|
6510
|
+
}
|
|
6511
|
+
function isHexadecimal(val) {
|
|
6512
|
+
return isString(val) && asChars(val).every((i) => isNumericString(i) || ["a", "b", "c", "d", "e", "f"].includes(i.toLowerCase()));
|
|
6513
|
+
}
|
|
6514
|
+
function isIndexable(value) {
|
|
6515
|
+
return !!(Array.isArray(value) || typeof value === "object" && keysOf(value).length > 0);
|
|
6516
|
+
}
|
|
6517
|
+
function isInlineSvg(v) {
|
|
6518
|
+
return isString(v) && v.trim().startsWith(`<svg`) && v.trim().endsWith(`</svg>`);
|
|
6519
|
+
}
|
|
6520
|
+
function isMap(val) {
|
|
6521
|
+
return val instanceof Map;
|
|
6522
|
+
}
|
|
6523
|
+
function isNever(val) {
|
|
6524
|
+
return isConstant(val) && val.kind === "never";
|
|
6525
|
+
}
|
|
6526
|
+
function isNothing(val) {
|
|
6527
|
+
return !!(val === null || val === void 0);
|
|
6528
|
+
}
|
|
6529
|
+
function isNotNull(value) {
|
|
6530
|
+
return value === null;
|
|
6531
|
+
}
|
|
6532
|
+
function isNull(value) {
|
|
6533
|
+
return value === null;
|
|
6534
|
+
}
|
|
6535
|
+
function maybePhoneNumber(val) {
|
|
6536
|
+
const svelte = String(val).trim();
|
|
6537
|
+
const chars = svelte.split("");
|
|
6538
|
+
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
6539
|
+
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
6540
|
+
const nothing = stripChars(svelte, ...[
|
|
6541
|
+
...NUMERIC_CHAR2,
|
|
6542
|
+
...WHITESPACE_CHARS2,
|
|
6543
|
+
"(",
|
|
6544
|
+
")",
|
|
6545
|
+
"+",
|
|
6546
|
+
".",
|
|
6547
|
+
"-"
|
|
6548
|
+
]);
|
|
6549
|
+
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
6550
|
+
}
|
|
6551
|
+
var start = PHONE_COUNTRY_CODES2.map((i) => `+${i[0]} `);
|
|
6552
|
+
function hasCountryCode(val) {
|
|
6553
|
+
if (isString(val)) {
|
|
6554
|
+
return start.some((i) => val.trimStart().startsWith(i));
|
|
6555
|
+
}
|
|
6556
|
+
return false;
|
|
6557
|
+
}
|
|
6558
|
+
function isUsPhoneNumber(val) {
|
|
6559
|
+
if (isString(val)) {
|
|
6560
|
+
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
6561
|
+
}
|
|
6562
|
+
return false;
|
|
6563
|
+
}
|
|
6564
|
+
function isPhoneNumber(val) {
|
|
6565
|
+
if (isString(val) && maybePhoneNumber(val) && [" ", "-", "."].some((i) => val.includes(i))) {
|
|
6566
|
+
const cc = getPhoneCountryCode(val);
|
|
6567
|
+
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
6568
|
+
switch (cc) {
|
|
6569
|
+
case "1":
|
|
6570
|
+
return without.length === 10;
|
|
6571
|
+
case "44":
|
|
6572
|
+
return !![10, 11].includes(without.length);
|
|
6573
|
+
case "":
|
|
6574
|
+
return without.length <= 10;
|
|
6575
|
+
default:
|
|
6576
|
+
return without.length <= 11;
|
|
6858
6577
|
}
|
|
6859
|
-
|
|
6860
|
-
|
|
6861
|
-
|
|
6862
|
-
|
|
6578
|
+
}
|
|
6579
|
+
return false;
|
|
6580
|
+
}
|
|
6581
|
+
function isReadonlyArray(value) {
|
|
6582
|
+
return Array.isArray(value) === true;
|
|
6583
|
+
}
|
|
6584
|
+
function isRef(value) {
|
|
6585
|
+
return isObject(value) && "value" in value && Array.from(Object.keys(value)).includes("_value");
|
|
6586
|
+
}
|
|
6587
|
+
function isRegExp(val) {
|
|
6588
|
+
return val instanceof RegExp;
|
|
6589
|
+
}
|
|
6590
|
+
function isLikeRegExp(val) {
|
|
6591
|
+
if (isRegExp(val)) {
|
|
6592
|
+
return true;
|
|
6593
|
+
}
|
|
6594
|
+
if (isString(val)) {
|
|
6595
|
+
try {
|
|
6596
|
+
const _re = new RegExp(val);
|
|
6597
|
+
return true;
|
|
6598
|
+
} catch {
|
|
6599
|
+
return false;
|
|
6863
6600
|
}
|
|
6864
|
-
|
|
6865
|
-
|
|
6601
|
+
}
|
|
6602
|
+
return false;
|
|
6603
|
+
}
|
|
6604
|
+
function isSymbol(value) {
|
|
6605
|
+
return typeof value === "symbol";
|
|
6606
|
+
}
|
|
6607
|
+
function isScalar(value) {
|
|
6608
|
+
return isString(value) || isNumber(value) || isSymbol(value) || isNull(value);
|
|
6609
|
+
}
|
|
6610
|
+
function isSet(val) {
|
|
6611
|
+
return isObject(val) ? val.kind !== "Unset" : true;
|
|
6612
|
+
}
|
|
6613
|
+
function isSetContainer(val) {
|
|
6614
|
+
return val instanceof Set;
|
|
6615
|
+
}
|
|
6616
|
+
function isStringArray(val) {
|
|
6617
|
+
return Array.isArray(val) && val.every((i) => isString(i));
|
|
6618
|
+
}
|
|
6619
|
+
function isThenable(val) {
|
|
6620
|
+
return isObject(val) && "then" in val && "catch" in val && typeof val.then === "function";
|
|
6621
|
+
}
|
|
6622
|
+
function isTrimable(val) {
|
|
6623
|
+
return isString(val) && val !== val.trim();
|
|
6624
|
+
}
|
|
6625
|
+
function isTrue(value) {
|
|
6626
|
+
return value === true;
|
|
6627
|
+
}
|
|
6628
|
+
function isTruthy(val) {
|
|
6629
|
+
return !FALSY_VALUES2.includes(val);
|
|
6630
|
+
}
|
|
6631
|
+
function isTypeSubtype(val) {
|
|
6632
|
+
return isString(val) && val.split("/").length === 2;
|
|
6633
|
+
}
|
|
6634
|
+
function isTypeTuple(value) {
|
|
6635
|
+
return Array.isArray(value) && value.length === 3 && typeof value[1] === "function";
|
|
6636
|
+
}
|
|
6637
|
+
function isUnset(val) {
|
|
6638
|
+
return isObject(val) && val.kind === "Unset";
|
|
6639
|
+
}
|
|
6640
|
+
function isUri(val, ...protocols) {
|
|
6641
|
+
const p = protocols.length === 0 ? valuesOf(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i) : protocols;
|
|
6642
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6643
|
+
}
|
|
6644
|
+
function isUrl(val, ...protocols) {
|
|
6645
|
+
const p = protocols.length === 0 ? ["http", "https"] : protocols;
|
|
6646
|
+
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
6866
6647
|
}
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
|
|
6873
|
-
|
|
6874
|
-
|
|
6875
|
-
|
|
6876
|
-
[
|
|
6877
|
-
groups.join(":"),
|
|
6878
|
-
fillIn.join(":")
|
|
6879
|
-
].join(":"),
|
|
6880
|
-
">>"
|
|
6881
|
-
].join("");
|
|
6648
|
+
var VALID = [
|
|
6649
|
+
...ALPHA_CHARS2,
|
|
6650
|
+
...NUMERIC_CHAR2,
|
|
6651
|
+
"_",
|
|
6652
|
+
"."
|
|
6653
|
+
];
|
|
6654
|
+
var alpha = null;
|
|
6655
|
+
function valid(chars) {
|
|
6656
|
+
return chars.every((i) => VALID.includes(i));
|
|
6882
6657
|
}
|
|
6883
|
-
function
|
|
6884
|
-
|
|
6885
|
-
state.id = null;
|
|
6886
|
-
const proxy = new Proxy(state, {});
|
|
6887
|
-
Object.defineProperty(proxy, "id", {
|
|
6888
|
-
enumerable: false
|
|
6889
|
-
});
|
|
6890
|
-
return proxy;
|
|
6658
|
+
function isVariable(val) {
|
|
6659
|
+
return isString(val) && startsWith(alpha)(val) && valid(asChars(val));
|
|
6891
6660
|
}
|
|
6892
|
-
function
|
|
6893
|
-
return
|
|
6661
|
+
function separate(s) {
|
|
6662
|
+
return stripWhile(s.toLowerCase(), ...NUMERIC_CHAR2).trim();
|
|
6894
6663
|
}
|
|
6895
|
-
function
|
|
6896
|
-
return
|
|
6897
|
-
wide: () => `<<${kind}>>`,
|
|
6898
|
-
literal: (val) => `<<${kind}::${val}>>`
|
|
6899
|
-
};
|
|
6664
|
+
function isAreaMetric(val) {
|
|
6665
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6900
6666
|
}
|
|
6901
|
-
function
|
|
6902
|
-
return
|
|
6667
|
+
function isLuminosityMetric(val) {
|
|
6668
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6903
6669
|
}
|
|
6904
|
-
function
|
|
6905
|
-
return
|
|
6906
|
-
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
6907
|
-
};
|
|
6670
|
+
function isResistance(val) {
|
|
6671
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6908
6672
|
}
|
|
6909
|
-
function
|
|
6910
|
-
return
|
|
6911
|
-
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
6912
|
-
};
|
|
6673
|
+
function isCurrentMetric(val) {
|
|
6674
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6913
6675
|
}
|
|
6914
|
-
function
|
|
6915
|
-
return
|
|
6676
|
+
function isVoltageMetric(val) {
|
|
6677
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6916
6678
|
}
|
|
6917
|
-
function
|
|
6918
|
-
return
|
|
6919
|
-
done: fnDoneApi(kind, params, returns),
|
|
6920
|
-
params: fnParamsApi(kind, params, returns),
|
|
6921
|
-
returns: fnReturnsApi(kind, params, returns)
|
|
6922
|
-
};
|
|
6679
|
+
function isFrequencyMetric(val) {
|
|
6680
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6923
6681
|
}
|
|
6924
|
-
function
|
|
6925
|
-
return
|
|
6682
|
+
function isPowerMetric(val) {
|
|
6683
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6926
6684
|
}
|
|
6927
|
-
function
|
|
6928
|
-
return
|
|
6685
|
+
function isTimeMetric(val) {
|
|
6686
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6929
6687
|
}
|
|
6930
|
-
function
|
|
6931
|
-
|
|
6932
|
-
const parts = bare.split("::");
|
|
6933
|
-
const kind = parts.pop();
|
|
6934
|
-
return kind;
|
|
6688
|
+
function isEnergyMetric(val) {
|
|
6689
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6935
6690
|
}
|
|
6936
|
-
|
|
6937
|
-
|
|
6938
|
-
var simpleContainerToken = (token) => token;
|
|
6939
|
-
function simpleScalarType(token) {
|
|
6940
|
-
const value = simpleScalarToken(token);
|
|
6941
|
-
return value;
|
|
6691
|
+
function isPressureMetric(val) {
|
|
6692
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6942
6693
|
}
|
|
6943
|
-
function
|
|
6944
|
-
|
|
6945
|
-
return value;
|
|
6694
|
+
function isTemperatureMetric(val) {
|
|
6695
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6946
6696
|
}
|
|
6947
|
-
function
|
|
6948
|
-
|
|
6949
|
-
return value;
|
|
6697
|
+
function isVolumeMetric(val) {
|
|
6698
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6950
6699
|
}
|
|
6951
|
-
function
|
|
6952
|
-
|
|
6953
|
-
for (const k of keys) {
|
|
6954
|
-
if (k in b) {
|
|
6955
|
-
return true;
|
|
6956
|
-
}
|
|
6957
|
-
}
|
|
6958
|
-
return false;
|
|
6700
|
+
function isAccelerationMetric(val) {
|
|
6701
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6959
6702
|
}
|
|
6960
|
-
function
|
|
6961
|
-
const
|
|
6962
|
-
|
|
6963
|
-
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!");
|
|
6964
|
-
}
|
|
6965
|
-
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
6966
|
-
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
6967
|
-
if (isNumeric) {
|
|
6968
|
-
throw new Error("uniqueKeys does not yet work with tuples");
|
|
6969
|
-
}
|
|
6970
|
-
const leftKeys = l.filter((i) => !r.includes(i));
|
|
6971
|
-
const rightKeys = r.filter((i) => !l.includes(i));
|
|
6972
|
-
return [
|
|
6973
|
-
"LeftRight",
|
|
6974
|
-
leftKeys,
|
|
6975
|
-
rightKeys
|
|
6976
|
-
];
|
|
6703
|
+
function isSpeedMetric(val) {
|
|
6704
|
+
const speed = SPEED_METRICS_LOOKUP2.map((i) => i.abbrev);
|
|
6705
|
+
return isString(val) && speed.includes(separate(val));
|
|
6977
6706
|
}
|
|
6978
|
-
function
|
|
6979
|
-
return
|
|
6707
|
+
function isMassMetric(val) {
|
|
6708
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6980
6709
|
}
|
|
6981
|
-
function
|
|
6982
|
-
return
|
|
6710
|
+
function isDistanceMetric(val) {
|
|
6711
|
+
return isString(val) && DISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(separate(val));
|
|
6983
6712
|
}
|
|
6984
|
-
function
|
|
6985
|
-
return
|
|
6713
|
+
function isMetric(val) {
|
|
6714
|
+
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);
|
|
6986
6715
|
}
|
|
6987
|
-
function
|
|
6988
|
-
return
|
|
6716
|
+
function isAreaUom(val) {
|
|
6717
|
+
return isString(val) && AREA_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6989
6718
|
}
|
|
6990
|
-
function
|
|
6991
|
-
return
|
|
6719
|
+
function isLuminosityUom(val) {
|
|
6720
|
+
return isString(val) && LUMINOSITY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6992
6721
|
}
|
|
6993
|
-
function
|
|
6994
|
-
return
|
|
6722
|
+
function isResistanceUom(val) {
|
|
6723
|
+
return isString(val) && RESISTANCE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6995
6724
|
}
|
|
6996
|
-
function
|
|
6997
|
-
return
|
|
6725
|
+
function isCurrentUom(val) {
|
|
6726
|
+
return isString(val) && CURRENT_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6998
6727
|
}
|
|
6999
|
-
function
|
|
7000
|
-
return
|
|
6728
|
+
function isVoltageUom(val) {
|
|
6729
|
+
return isString(val) && VOLTAGE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7001
6730
|
}
|
|
7002
|
-
function
|
|
7003
|
-
return
|
|
6731
|
+
function isFrequencyUom(val) {
|
|
6732
|
+
return isString(val) && FREQUENCY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7004
6733
|
}
|
|
7005
|
-
function
|
|
7006
|
-
return
|
|
6734
|
+
function isPowerUom(val) {
|
|
6735
|
+
return isString(val) && POWER_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7007
6736
|
}
|
|
7008
|
-
function
|
|
7009
|
-
return val
|
|
6737
|
+
function isTimeUom(val) {
|
|
6738
|
+
return isString(val) && TIME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7010
6739
|
}
|
|
7011
|
-
function
|
|
7012
|
-
|
|
7013
|
-
return false;
|
|
7014
|
-
}
|
|
7015
|
-
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})?$/;
|
|
7016
|
-
if (!ISO_DATETIME_REGEX.test(val)) {
|
|
7017
|
-
return false;
|
|
7018
|
-
}
|
|
7019
|
-
const [_, ...matches] = val.match(ISO_DATETIME_REGEX) || [];
|
|
7020
|
-
const [year, month, day, hours, minutes, seconds] = matches.map(Number);
|
|
7021
|
-
if (hours >= 24 || minutes >= 60 || seconds != null && seconds >= 60) {
|
|
7022
|
-
return false;
|
|
7023
|
-
}
|
|
7024
|
-
if (month < 1 || month > 12) {
|
|
7025
|
-
return false;
|
|
7026
|
-
}
|
|
7027
|
-
;
|
|
7028
|
-
const daysInMonth = new Date(year, month, 0).getDate();
|
|
7029
|
-
if (day < 1 || day > daysInMonth) {
|
|
7030
|
-
return false;
|
|
7031
|
-
}
|
|
7032
|
-
;
|
|
7033
|
-
const tzMatch = val.match(/([+-])(\d{2}):(\d{2})$/);
|
|
7034
|
-
if (tzMatch) {
|
|
7035
|
-
const [_2, _sign, tzHours, tzMinutes] = tzMatch;
|
|
7036
|
-
const numHours = Number.parseInt(tzHours, 10);
|
|
7037
|
-
const numMinutes = Number.parseInt(tzMinutes, 10);
|
|
7038
|
-
if (numHours > 14 || numMinutes > 59) {
|
|
7039
|
-
return false;
|
|
7040
|
-
}
|
|
7041
|
-
if (numHours === 14 && numMinutes > 0) {
|
|
7042
|
-
return false;
|
|
7043
|
-
}
|
|
7044
|
-
}
|
|
7045
|
-
return true;
|
|
6740
|
+
function isEnergyUom(val) {
|
|
6741
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7046
6742
|
}
|
|
7047
|
-
function
|
|
7048
|
-
|
|
7049
|
-
const parts = val.split("-").map((i) => Number(i));
|
|
7050
|
-
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;
|
|
7051
|
-
} else {
|
|
7052
|
-
return false;
|
|
7053
|
-
}
|
|
6743
|
+
function isPressureUom(val) {
|
|
6744
|
+
return isString(val) && PRESSURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7054
6745
|
}
|
|
7055
|
-
function
|
|
7056
|
-
|
|
7057
|
-
const year = Number(val.slice(0, 4));
|
|
7058
|
-
const month = Number(val.slice(4, 6));
|
|
7059
|
-
const date = Number(val.slice(6, 8));
|
|
7060
|
-
return year >= 0 && year <= 9999 && month >= 1 && month <= 12 && date >= 1 && date <= 31;
|
|
7061
|
-
} else {
|
|
7062
|
-
return false;
|
|
7063
|
-
}
|
|
6746
|
+
function isTemperatureUom(val) {
|
|
6747
|
+
return isString(val) && TEMPERATURE_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7064
6748
|
}
|
|
7065
|
-
function
|
|
7066
|
-
|
|
7067
|
-
return val.includes("-") ? isIsoExplicitDate(val) : isIsoImplicitDate(val);
|
|
7068
|
-
} else {
|
|
7069
|
-
return false;
|
|
7070
|
-
}
|
|
6749
|
+
function isVolumeUom(val) {
|
|
6750
|
+
return isString(val) && VOLUME_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7071
6751
|
}
|
|
7072
|
-
function
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
return false;
|
|
7078
|
-
}
|
|
6752
|
+
function isAccelerationUom(val) {
|
|
6753
|
+
return isString(val) && ACCELERATION_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
6754
|
+
}
|
|
6755
|
+
function isSpeedUom(val) {
|
|
6756
|
+
return isString(val) && SPEED_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7079
6757
|
}
|
|
7080
|
-
function
|
|
7081
|
-
|
|
7082
|
-
const parts = stripAfter(val, "Z").split(/[:.]/).map((i) => Number(i));
|
|
7083
|
-
return val.includes(":") && val.split(":").length === 3 && parts[0] >= 0 && parts[0] <= 23 && parts[1] >= 0 && parts[1] <= 59;
|
|
7084
|
-
} else {
|
|
7085
|
-
return false;
|
|
7086
|
-
}
|
|
6758
|
+
function isMassUom(val) {
|
|
6759
|
+
return isString(val) && MASS_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7087
6760
|
}
|
|
7088
|
-
function
|
|
7089
|
-
return
|
|
6761
|
+
function isDistanceUom(val) {
|
|
6762
|
+
return isString(val) && ENERGY_METRICS_LOOKUP2.map((i) => i.abbrev).includes(val);
|
|
7090
6763
|
}
|
|
7091
|
-
function
|
|
7092
|
-
return
|
|
6764
|
+
function isUom(val) {
|
|
6765
|
+
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);
|
|
7093
6766
|
}
|
|
7094
|
-
function
|
|
7095
|
-
return
|
|
6767
|
+
function isIp4Address(val) {
|
|
6768
|
+
return isString(val) && val.split(".").length === 4 && val.split(".").every((i) => isNumberLike(i)) && val.split(".").every((i) => Number(i) >= 0 && Number(i) <= 255);
|
|
7096
6769
|
}
|
|
7097
|
-
function
|
|
7098
|
-
|
|
7099
|
-
|
|
7100
|
-
}
|
|
7101
|
-
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";
|
|
6770
|
+
function isIp6Address(val) {
|
|
6771
|
+
const expanded = isString(val) ? ip6GroupExpansion(val) : "";
|
|
6772
|
+
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
7102
6773
|
}
|
|
7103
|
-
function
|
|
7104
|
-
|
|
7105
|
-
const currentYear = now.getFullYear();
|
|
7106
|
-
const currentMonth = now.getMonth() + 1;
|
|
7107
|
-
if (val instanceof Date) {
|
|
7108
|
-
return val.getFullYear() === currentYear && val.getMonth() + 1 === currentMonth;
|
|
7109
|
-
}
|
|
7110
|
-
if (isMoment(val)) {
|
|
7111
|
-
const monthValue = val.month();
|
|
7112
|
-
return val.year() === currentYear && (typeof monthValue === "number" ? monthValue + 1 : monthValue) === currentMonth;
|
|
7113
|
-
}
|
|
7114
|
-
if (isLuxonDateTime(val)) {
|
|
7115
|
-
return val.year === currentYear && val.month === currentMonth;
|
|
7116
|
-
}
|
|
7117
|
-
if (typeof val === "string") {
|
|
7118
|
-
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))?$/;
|
|
7119
|
-
if (!isoDateRegex.test(val)) {
|
|
7120
|
-
return false;
|
|
7121
|
-
}
|
|
7122
|
-
const dateMatch = val.match(/^(\d{4})-(\d{2})/);
|
|
7123
|
-
if (dateMatch) {
|
|
7124
|
-
const year = Number.parseInt(dateMatch[1], 10);
|
|
7125
|
-
const month = Number.parseInt(dateMatch[2], 10);
|
|
7126
|
-
return year === currentYear && month === currentMonth;
|
|
7127
|
-
}
|
|
7128
|
-
}
|
|
7129
|
-
return false;
|
|
6774
|
+
function isIpAddress(val) {
|
|
6775
|
+
return isIp4Address(val) || isIp6Address(val);
|
|
7130
6776
|
}
|
|
7131
|
-
function
|
|
7132
|
-
|
|
7133
|
-
if (!targetDate) {
|
|
7134
|
-
return false;
|
|
7135
|
-
}
|
|
7136
|
-
const currentWeek = getWeekNumber();
|
|
7137
|
-
const targetWeek = getWeekNumber(targetDate);
|
|
7138
|
-
return currentWeek === targetWeek;
|
|
6777
|
+
function hasUrlPort(val) {
|
|
6778
|
+
return isString(val) && asChars(removeUrlProtocol(val)).includes(":");
|
|
7139
6779
|
}
|
|
7140
|
-
function
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
if (date) {
|
|
7145
|
-
return date.getFullYear() === currentYear;
|
|
7146
|
-
} else {
|
|
7147
|
-
return false;
|
|
7148
|
-
}
|
|
7149
|
-
}
|
|
7150
|
-
return false;
|
|
6780
|
+
function isUrlPath(val) {
|
|
6781
|
+
return isString(val) && (val === "" || val.startsWith("/")) && asChars(val).every(
|
|
6782
|
+
(c) => isAlpha(c) || isNumberLike(c) || c === "_" || c === "@" || c === "." || c === "-"
|
|
6783
|
+
);
|
|
7151
6784
|
}
|
|
7152
|
-
function
|
|
7153
|
-
|
|
7154
|
-
|
|
7155
|
-
|
|
7156
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7157
|
-
return stripAfter(test.toISOString(), "T") === getToday();
|
|
7158
|
-
} else if (isLuxonDateTime(test)) {
|
|
7159
|
-
return stripAfter(test.toISO(), "T") === getToday();
|
|
7160
|
-
}
|
|
7161
|
-
return false;
|
|
6785
|
+
function isDomainName(val) {
|
|
6786
|
+
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(
|
|
6787
|
+
(i) => isAlpha(i) || isNumberLike(i) || i === "-" || i === "_"
|
|
6788
|
+
);
|
|
7162
6789
|
}
|
|
7163
|
-
function
|
|
7164
|
-
|
|
7165
|
-
const justDate = stripAfter(test, "T");
|
|
7166
|
-
return isIsoExplicitDate(justDate) && justDate === getTomorrow();
|
|
7167
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7168
|
-
return stripAfter(test.toISOString(), "T") === getTomorrow();
|
|
7169
|
-
} else if (isLuxonDateTime(test)) {
|
|
7170
|
-
return stripAfter(test.toISO(), "T") === getTomorrow();
|
|
7171
|
-
}
|
|
7172
|
-
return false;
|
|
6790
|
+
function isUrlSource(val) {
|
|
6791
|
+
return isDomainName(val) || isIpAddress(val);
|
|
7173
6792
|
}
|
|
7174
|
-
function
|
|
7175
|
-
|
|
7176
|
-
const justDate = stripAfter(test, "T");
|
|
7177
|
-
return isIsoExplicitDate(justDate) && justDate === getYesterday();
|
|
7178
|
-
} else if (isMoment(test) || isDate(test)) {
|
|
7179
|
-
return stripAfter(test.toISOString(), "T") === getYesterday();
|
|
7180
|
-
} else if (isLuxonDateTime(test)) {
|
|
7181
|
-
return stripAfter(test.toISO(), "T") === getYesterday();
|
|
7182
|
-
}
|
|
7183
|
-
return false;
|
|
6793
|
+
function hasUrlQueryParameter(val, prop) {
|
|
6794
|
+
return isString(getUrlQueryParams(val, prop));
|
|
7184
6795
|
}
|
|
7185
|
-
function
|
|
7186
|
-
|
|
7187
|
-
const parts = val.split(" ");
|
|
7188
|
-
return parts.length === 4 && parts.every((i) => isNumberLike(i) && i.length === 4);
|
|
7189
|
-
}
|
|
7190
|
-
return false;
|
|
6796
|
+
function isNumericArray(val) {
|
|
6797
|
+
return Array.isArray(val) && val.every((i) => isNumber(i));
|
|
7191
6798
|
}
|
|
7192
|
-
function
|
|
7193
|
-
|
|
7194
|
-
const parts = val.split(" ");
|
|
7195
|
-
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));
|
|
7196
|
-
}
|
|
7197
|
-
return false;
|
|
6799
|
+
function hasProtocol(val, ...protocols) {
|
|
6800
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.some((i) => val.startsWith(i)) : protocols.some((i) => val.startsWith(i));
|
|
7198
6801
|
}
|
|
7199
|
-
function
|
|
7200
|
-
return
|
|
6802
|
+
function isProtocol(val, ...protocols) {
|
|
6803
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.includes(val) : protocols.includes(val);
|
|
7201
6804
|
}
|
|
7202
|
-
function
|
|
7203
|
-
|
|
7204
|
-
const parts = val.split(" ");
|
|
7205
|
-
return parts.length === 3 && parts.every(
|
|
7206
|
-
(i) => isNumberLike(i) && parts[0].length === 4 && parts[1].length === 6
|
|
7207
|
-
);
|
|
7208
|
-
}
|
|
7209
|
-
return false;
|
|
6805
|
+
function hasProtocolPrefix(val, ...protocols) {
|
|
6806
|
+
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));
|
|
7210
6807
|
}
|
|
7211
|
-
function
|
|
7212
|
-
return
|
|
6808
|
+
function isProtocolPrefix(val, ...protocols) {
|
|
6809
|
+
return isString(val) && protocols.length === 0 ? NETWORK_PROTOCOL2.map((i) => `${i}://`).includes(val) : protocols.map((i) => `${i}://`).includes(val);
|
|
7213
6810
|
}
|
|
7214
|
-
function
|
|
7215
|
-
|
|
7216
|
-
|
|
7217
|
-
|
|
7218
|
-
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
{ 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)/] },
|
|
7226
|
-
{ name: "American Express", lengths: [15], prefixes: [/^3[47]/] },
|
|
7227
|
-
{ 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)/] },
|
|
7228
|
-
{ name: "JCB", lengths: [16], prefixes: [/^(35|2131|1800)/] },
|
|
7229
|
-
{ name: "Diners Club", lengths: [14, 16], prefixes: [/^(30[0-5]|36|38)/] },
|
|
7230
|
-
{ name: "China UnionPay", lengths: [16, 17, 18, 19], prefixes: [/^(62|88)/] },
|
|
7231
|
-
{ name: "Maestro", lengths: [12, 13, 14, 15, 16, 17, 18, 19], prefixes: [/^(5018|5020|5038|6304)/] },
|
|
7232
|
-
{ name: "Solo", lengths: [16, 18, 19], prefixes: [/^(6334|6767)/] }
|
|
7233
|
-
];
|
|
7234
|
-
for (const type of cardTypes) {
|
|
7235
|
-
if (type.lengths.includes(length)) {
|
|
7236
|
-
for (const prefix of type.prefixes) {
|
|
7237
|
-
if (prefix.test(cleanedNumber)) {
|
|
7238
|
-
return type.name;
|
|
6811
|
+
function isTypeToken(val, kind) {
|
|
6812
|
+
if (isString(val) && val.startsWith("<<") && val.endsWith(">>")) {
|
|
6813
|
+
const stripped = stripSurround("<<", ">>")(val);
|
|
6814
|
+
if (TT_KIND_VARIANTS2.some((k) => stripped.startsWith(k))) {
|
|
6815
|
+
if (kind) {
|
|
6816
|
+
if (isAtomicKind(kind)) {
|
|
6817
|
+
return val === `<<${kind}>>`;
|
|
6818
|
+
} else if (isSetBasedKind(kind)) {
|
|
6819
|
+
return val.startsWith(`<<${kind}::`);
|
|
6820
|
+
} else {
|
|
6821
|
+
return val === `<<${kind}>>` || val.startsWith(`<<${kind}::`);
|
|
7239
6822
|
}
|
|
6823
|
+
} else {
|
|
6824
|
+
return true;
|
|
7240
6825
|
}
|
|
7241
6826
|
}
|
|
6827
|
+
return false;
|
|
7242
6828
|
}
|
|
7243
|
-
return
|
|
6829
|
+
return false;
|
|
7244
6830
|
}
|
|
7245
|
-
function
|
|
7246
|
-
|
|
7247
|
-
return validLengths.includes(length);
|
|
6831
|
+
function isTypeTokenKind(val) {
|
|
6832
|
+
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
7248
6833
|
}
|
|
7249
|
-
function
|
|
7250
|
-
|
|
7251
|
-
let double = false;
|
|
7252
|
-
for (let i = num.length - 1; i >= 0; i--) {
|
|
7253
|
-
let n = Number.parseInt(num.charAt(i), 10);
|
|
7254
|
-
if (double) {
|
|
7255
|
-
n *= 2;
|
|
7256
|
-
if (n > 9) {
|
|
7257
|
-
n -= 9;
|
|
7258
|
-
}
|
|
7259
|
-
}
|
|
7260
|
-
sum += n;
|
|
7261
|
-
double = !double;
|
|
7262
|
-
}
|
|
7263
|
-
return sum % 10 === 0;
|
|
6834
|
+
function isAtomicToken(val) {
|
|
6835
|
+
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
7264
6836
|
}
|
|
7265
|
-
function
|
|
7266
|
-
return
|
|
6837
|
+
function isAtomicKind(val) {
|
|
6838
|
+
return isString(val) && TT_ATOMICS2.includes(val);
|
|
7267
6839
|
}
|
|
7268
|
-
function
|
|
7269
|
-
|
|
7270
|
-
return isString(val) && codes.includes(val);
|
|
6840
|
+
function isObjectToken(val) {
|
|
6841
|
+
return isTypeToken(val, "obj");
|
|
7271
6842
|
}
|
|
7272
|
-
function
|
|
7273
|
-
|
|
7274
|
-
return isString(val) && codes.includes(val);
|
|
6843
|
+
function isRecordToken(val) {
|
|
6844
|
+
return isTypeToken(val, "rec");
|
|
7275
6845
|
}
|
|
7276
|
-
function
|
|
7277
|
-
|
|
7278
|
-
return isString(val) && codes.includes(val);
|
|
6846
|
+
function isTupleToken(val) {
|
|
6847
|
+
return isTypeToken(val, "tuple");
|
|
7279
6848
|
}
|
|
7280
|
-
function
|
|
7281
|
-
|
|
7282
|
-
return isString(val) && codes.includes(val);
|
|
6849
|
+
function isArrayToken(val) {
|
|
6850
|
+
return isTypeToken(val, "arr");
|
|
7283
6851
|
}
|
|
7284
|
-
function
|
|
7285
|
-
|
|
7286
|
-
|
|
6852
|
+
function isMapToken(val) {
|
|
6853
|
+
return isTypeToken(val, "map");
|
|
6854
|
+
}
|
|
6855
|
+
function isSetToken(val) {
|
|
6856
|
+
return isTypeToken(val, "set");
|
|
6857
|
+
}
|
|
6858
|
+
function isContainerToken(val) {
|
|
6859
|
+
return isObjectToken(val) || isRecordToken(val) || isTupleToken(val) || isArrayToken(val) || isMapToken(val) || isSetToken(val);
|
|
6860
|
+
}
|
|
6861
|
+
function isShapeCallback(val) {
|
|
6862
|
+
return isFunction(val) && val.kind === "shape";
|
|
7287
6863
|
}
|
|
7288
|
-
|
|
7289
|
-
|
|
6864
|
+
var token_types = [
|
|
6865
|
+
...TT_ATOMICS2,
|
|
6866
|
+
...TT_CONTAINERS2,
|
|
6867
|
+
...TT_FUNCTIONS2,
|
|
6868
|
+
...TT_SETS2,
|
|
6869
|
+
...TT_SINGLETONS2
|
|
6870
|
+
];
|
|
6871
|
+
function isShapeToken(val) {
|
|
6872
|
+
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
7290
6873
|
}
|
|
7291
|
-
|
|
7292
|
-
|
|
7293
|
-
|
|
6874
|
+
var split_tokens = SIMPLE_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6875
|
+
var scalar_split_tokens = SIMPLE_SCALAR_TOKENS2.map((i) => i.split("TOKEN"));
|
|
6876
|
+
function isSimpleToken(val) {
|
|
6877
|
+
return isString(val) && split_tokens.some(
|
|
6878
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6879
|
+
);
|
|
7294
6880
|
}
|
|
7295
|
-
function
|
|
7296
|
-
|
|
7297
|
-
|
|
6881
|
+
function isSimpleScalarToken(val) {
|
|
6882
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6883
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6884
|
+
);
|
|
7298
6885
|
}
|
|
7299
|
-
|
|
7300
|
-
|
|
7301
|
-
|
|
7302
|
-
|
|
6886
|
+
function isSimpleContainerToken(val) {
|
|
6887
|
+
return isString(val) && scalar_split_tokens.some(
|
|
6888
|
+
(i) => i.length === 1 && val === i[0] || val.startsWith(i[0]) && val.endsWith(i.slice(-1)[0]) && i.every((p) => val.includes(p))
|
|
6889
|
+
);
|
|
7303
6890
|
}
|
|
7304
|
-
function
|
|
7305
|
-
return
|
|
6891
|
+
function isSimpleTokenTuple(val) {
|
|
6892
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleToken);
|
|
7306
6893
|
}
|
|
7307
|
-
function
|
|
7308
|
-
|
|
7309
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i));
|
|
6894
|
+
function isSimpleScalarTokenTuple(val) {
|
|
6895
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleScalarToken);
|
|
7310
6896
|
}
|
|
7311
|
-
function
|
|
7312
|
-
|
|
7313
|
-
return typeof value === "string" && split(value).every((i) => numericChars.includes(i)) ? true : typeof value === "number";
|
|
6897
|
+
function isSimpleContainerTokenTuple(val) {
|
|
6898
|
+
return isArray(val) && val.length !== 0 && val.every(isSimpleContainerToken);
|
|
7314
6899
|
}
|
|
7315
|
-
function
|
|
7316
|
-
return
|
|
6900
|
+
function isDefineObject(val) {
|
|
6901
|
+
return isObject(val) && Object.keys(val).some(
|
|
6902
|
+
(key) => isSimpleToken(val[key]) || isShapeToken(val) || isShapeCallback(val)
|
|
6903
|
+
);
|
|
7317
6904
|
}
|
|
7318
|
-
function
|
|
7319
|
-
if (
|
|
7320
|
-
|
|
6905
|
+
function isFnBasedToken(val) {
|
|
6906
|
+
if (isString(val) && val.startsWith(TT_START2) && val.endsWith(TT_STOP2)) {
|
|
6907
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6908
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7321
6909
|
}
|
|
7322
|
-
return isString(val) && val.trim().length === 5 && isNumberLike(val.trim());
|
|
7323
6910
|
}
|
|
7324
|
-
function
|
|
7325
|
-
if (isString(val)) {
|
|
7326
|
-
const
|
|
7327
|
-
|
|
7328
|
-
return first.length === 5 && next.length === 4 && isNumberLike(next);
|
|
6911
|
+
function isFnBasedKind(val) {
|
|
6912
|
+
if (isString(val) && isTypeTokenKind(val)) {
|
|
6913
|
+
const stripped = stripSurround(TT_START2, TT_STOP2)(val);
|
|
6914
|
+
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7329
6915
|
}
|
|
7330
6916
|
return false;
|
|
7331
6917
|
}
|
|
7332
|
-
function
|
|
7333
|
-
|
|
6918
|
+
function isSetBasedToken(val) {
|
|
6919
|
+
if (isTypeToken(val)) {
|
|
6920
|
+
const kind = getTokenKind(val);
|
|
6921
|
+
return kind.endsWith(`-set`);
|
|
6922
|
+
}
|
|
6923
|
+
return false;
|
|
7334
6924
|
}
|
|
7335
|
-
function
|
|
7336
|
-
return (
|
|
7337
|
-
return !!(isConstant(value) && value.kind === kind);
|
|
7338
|
-
};
|
|
6925
|
+
function isSetBasedKind(val) {
|
|
6926
|
+
return isString(val) && val.endsWith(`-set`);
|
|
7339
6927
|
}
|
|
7340
|
-
function
|
|
7341
|
-
|
|
7342
|
-
return !noDefault(value);
|
|
6928
|
+
function isSingletonKind(val) {
|
|
6929
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7343
6930
|
}
|
|
7344
|
-
function
|
|
7345
|
-
|
|
7346
|
-
return isErrorCondition(result2, "invalid-index") ? false : result2;
|
|
6931
|
+
function isSingletonToken(val) {
|
|
6932
|
+
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7347
6933
|
}
|
|
7348
|
-
function
|
|
7349
|
-
return (val)
|
|
7350
|
-
const keys = Array.isArray(props) ? props : Object.keys(props).filter((i) => typeof i === "string");
|
|
7351
|
-
return !!((isFunction(val) || isObject(val)) && keys.every((k) => k in val));
|
|
7352
|
-
};
|
|
6934
|
+
function isTailwindColorName(val) {
|
|
6935
|
+
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
7353
6936
|
}
|
|
7354
|
-
function
|
|
7355
|
-
return isString(val) &&
|
|
6937
|
+
function isTailwindColorWithLuminosity(val) {
|
|
6938
|
+
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, "-")));
|
|
7356
6939
|
}
|
|
7357
|
-
function
|
|
7358
|
-
return (val)
|
|
7359
|
-
return isString(val) ? !!val.endsWith(endingIn2) : isNumber(val) ? !!String(val).endsWith(endingIn2) : false;
|
|
7360
|
-
};
|
|
6940
|
+
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
6941
|
+
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
7361
6942
|
}
|
|
7362
|
-
function
|
|
7363
|
-
return (
|
|
6943
|
+
function isTailwindColor(val) {
|
|
6944
|
+
return isTailwindColorWithLuminosity(val) || isTailwindColorWithLuminosityAndOpacity(val);
|
|
7364
6945
|
}
|
|
7365
|
-
function
|
|
7366
|
-
return
|
|
6946
|
+
function isTailwindModifier(val) {
|
|
6947
|
+
return isString(val) && TW_MODIFIERS2.includes(val);
|
|
7367
6948
|
}
|
|
7368
|
-
function
|
|
7369
|
-
return (
|
|
7370
|
-
return typeof base === typeof compare;
|
|
7371
|
-
};
|
|
6949
|
+
function isTailwindColorTarget(val) {
|
|
6950
|
+
return isString(val) && TW_COLOR_TARGETS2.includes(val);
|
|
7372
6951
|
}
|
|
7373
|
-
function
|
|
7374
|
-
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
6952
|
+
function isTailwindColorClass(val, ...allowedModifiers) {
|
|
6953
|
+
if (isString(val)) {
|
|
6954
|
+
const mods = getTailwindModifiers(val);
|
|
6955
|
+
const targetted = removeTailwindModifiers(val);
|
|
6956
|
+
const target = targetted.split("-")[0];
|
|
6957
|
+
const color = targetted.split("-").slice(1).join("-");
|
|
6958
|
+
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
6959
|
+
}
|
|
6960
|
+
return false;
|
|
7378
6961
|
}
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
|
|
7382
|
-
};
|
|
6962
|
+
var URL = AUSTRALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6963
|
+
function isAustralianNewsUrl(val) {
|
|
6964
|
+
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
7383
6965
|
}
|
|
7384
|
-
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
};
|
|
6966
|
+
var URL2 = BELGIUM_NEWS2.flatMap((i) => i.baseUrls);
|
|
6967
|
+
function isBelgiumNewsUrl(val) {
|
|
6968
|
+
return isString(val) && val.startsWith("https://") && (URL2.includes(val) || URL2.some((i) => i.startsWith(`${i}/`)));
|
|
7388
6969
|
}
|
|
7389
|
-
|
|
7390
|
-
|
|
6970
|
+
var URL3 = CANADIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6971
|
+
function isCanadianNewsUrl(val) {
|
|
6972
|
+
return isString(val) && val.startsWith("https://") && (URL3.includes(val) || URL3.some((i) => i.startsWith(`${i}/`)));
|
|
7391
6973
|
}
|
|
7392
|
-
|
|
7393
|
-
|
|
6974
|
+
var URL4 = DANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6975
|
+
function isDanishNewsUrl(val) {
|
|
6976
|
+
return isString(val) && val.startsWith("https://") && (URL4.includes(val) || URL4.some((i) => i.startsWith(`${i}/`)));
|
|
7394
6977
|
}
|
|
7395
|
-
|
|
7396
|
-
|
|
6978
|
+
var URL5 = DUTCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6979
|
+
function isDutchNewsUrl(val) {
|
|
6980
|
+
return isString(val) && val.startsWith("https://") && (URL5.includes(val) || URL5.some((i) => i.startsWith(`${i}/`)));
|
|
7397
6981
|
}
|
|
7398
|
-
|
|
7399
|
-
|
|
6982
|
+
var URL6 = FRENCH_NEWS2.flatMap((i) => i.baseUrls);
|
|
6983
|
+
function isFrenchNewsUrl(val) {
|
|
6984
|
+
return isString(val) && val.startsWith("https://") && (URL6.includes(val) || URL6.some((i) => i.startsWith(`${i}/`)));
|
|
7400
6985
|
}
|
|
7401
|
-
|
|
7402
|
-
|
|
6986
|
+
var URL7 = GERMAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6987
|
+
function isGermanNewsUrl(val) {
|
|
6988
|
+
return isString(val) && val.startsWith("https://") && (URL7.includes(val) || URL7.some((i) => i.startsWith(`${i}/`)));
|
|
7403
6989
|
}
|
|
7404
|
-
|
|
7405
|
-
|
|
6990
|
+
var URL8 = INDIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6991
|
+
function isIndianNewsUrl(val) {
|
|
6992
|
+
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
7406
6993
|
}
|
|
7407
|
-
|
|
7408
|
-
|
|
6994
|
+
var URL9 = ITALIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
6995
|
+
function isItalianNewsUrl(val) {
|
|
6996
|
+
return isString(val) && val.startsWith("https://") && (URL9.includes(val) || URL9.some((i) => i.startsWith(`${i}/`)));
|
|
7409
6997
|
}
|
|
7410
|
-
var
|
|
7411
|
-
|
|
7412
|
-
"
|
|
7413
|
-
"initial",
|
|
7414
|
-
"revert",
|
|
7415
|
-
"revert-layer",
|
|
7416
|
-
"unset",
|
|
7417
|
-
"auto"
|
|
7418
|
-
];
|
|
7419
|
-
var isRatio = (val) => /\d{1,4}\s*\/\s*\d{1,4}/.test(val);
|
|
7420
|
-
function isCssAspectRatio(val) {
|
|
7421
|
-
return isString(val) && val.split(/\s+/).every((i) => tokens.includes(i) || isRatio(i));
|
|
6998
|
+
var URL10 = JAPANESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
6999
|
+
function isJapaneseNewsUrl(val) {
|
|
7000
|
+
return isString(val) && val.startsWith("https://") && (URL10.includes(val) || URL10.some((i) => i.startsWith(`${i}/`)));
|
|
7422
7001
|
}
|
|
7423
|
-
|
|
7424
|
-
|
|
7002
|
+
var URL11 = MEXICAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
7003
|
+
function isMexicanNewsUrl(val) {
|
|
7004
|
+
return isString(val) && val.startsWith("https://") && (URL11.includes(val) || URL11.some((i) => i.startsWith(`${i}/`)));
|
|
7425
7005
|
}
|
|
7426
|
-
|
|
7427
|
-
|
|
7006
|
+
var URL12 = NORWEGIAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
7007
|
+
function isNorwegianNewsUrl(val) {
|
|
7008
|
+
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
7428
7009
|
}
|
|
7429
|
-
|
|
7430
|
-
|
|
7010
|
+
var URL13 = SOUTH_KOREAN_NEWS2.flatMap((i) => i.baseUrls);
|
|
7011
|
+
function isSouthKoreanNewsUrl(val) {
|
|
7012
|
+
return isString(val) && val.startsWith("https://") && (URL13.includes(val) || URL13.some((i) => i.startsWith(`${i}/`)));
|
|
7431
7013
|
}
|
|
7432
|
-
|
|
7433
|
-
|
|
7434
|
-
|
|
7435
|
-
}
|
|
7436
|
-
const parts = val?.split("@");
|
|
7437
|
-
const domain = parts[1]?.split(".");
|
|
7438
|
-
const tld = domain ? domain.pop() : "";
|
|
7439
|
-
const firstChar = val[0].toLowerCase();
|
|
7440
|
-
return isString(val) && (LOWER_ALPHA_CHARS2.includes(firstChar) && parts.length === 2 && domain.length >= 1 && tld.length >= 2);
|
|
7014
|
+
var URL14 = SPANISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
7015
|
+
function isSpanishNewsUrl(val) {
|
|
7016
|
+
return isString(val) && val.startsWith("https://") && (URL14.includes(val) || URL14.some((i) => i.startsWith(`${i}/`)));
|
|
7441
7017
|
}
|
|
7442
|
-
|
|
7443
|
-
|
|
7018
|
+
var URL15 = SWISS_NEWS2.flatMap((i) => i.baseUrls);
|
|
7019
|
+
function isSwissNewsUrl(val) {
|
|
7020
|
+
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
7444
7021
|
}
|
|
7445
|
-
|
|
7446
|
-
|
|
7022
|
+
var URL16 = TURKISH_NEWS2.flatMap((i) => i.baseUrls);
|
|
7023
|
+
function isTurkishNewsUrl(val) {
|
|
7024
|
+
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
7447
7025
|
}
|
|
7448
|
-
|
|
7449
|
-
|
|
7026
|
+
var URL17 = UK_NEWS2.flatMap((i) => i.baseUrls);
|
|
7027
|
+
function isUkNewsUrl(val) {
|
|
7028
|
+
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
7029
|
+
}
|
|
7030
|
+
var URL18 = US_NEWS2.flatMap((i) => i.baseUrls);
|
|
7031
|
+
function isUsNewsUrl(val) {
|
|
7032
|
+
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
7033
|
+
}
|
|
7034
|
+
var URL19 = CHINESE_NEWS2.flatMap((i) => i.baseUrls);
|
|
7035
|
+
function isChineseNewsUrl(val) {
|
|
7036
|
+
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
7037
|
+
}
|
|
7038
|
+
function isNewsUrl(val) {
|
|
7039
|
+
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);
|
|
7040
|
+
}
|
|
7041
|
+
function isBitbucketUrl(val) {
|
|
7042
|
+
const valid2 = REPO_SOURCE_LOOKUP2.bitbucket;
|
|
7043
|
+
return isString(val) && valid2.some(
|
|
7044
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7045
|
+
);
|
|
7450
7046
|
}
|
|
7451
|
-
function
|
|
7452
|
-
|
|
7047
|
+
function isCodeCommitUrl(val) {
|
|
7048
|
+
const valid2 = REPO_SOURCE_LOOKUP2.codecommit;
|
|
7049
|
+
return isString(val) && valid2.some(
|
|
7050
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7051
|
+
);
|
|
7453
7052
|
}
|
|
7454
|
-
function
|
|
7455
|
-
|
|
7053
|
+
function isGithubUrl(val) {
|
|
7054
|
+
const valid2 = [
|
|
7055
|
+
"https://github.com",
|
|
7056
|
+
"https://www.github.com",
|
|
7057
|
+
"https://github.io"
|
|
7058
|
+
];
|
|
7059
|
+
return isString(val) && valid2.some(
|
|
7060
|
+
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7061
|
+
);
|
|
7456
7062
|
}
|
|
7457
|
-
function
|
|
7458
|
-
return
|
|
7063
|
+
function isGithubOrgUrl(val) {
|
|
7064
|
+
return isString(val) && (val.startsWith("https://github.com/") && stripper(val).length === 2);
|
|
7459
7065
|
}
|
|
7460
|
-
function
|
|
7461
|
-
return
|
|
7066
|
+
function stripper(s) {
|
|
7067
|
+
return stripTrailing(
|
|
7068
|
+
stripLeading(s, "https://github.com/"),
|
|
7069
|
+
"/"
|
|
7070
|
+
);
|
|
7462
7071
|
}
|
|
7463
|
-
function
|
|
7464
|
-
return !!(
|
|
7072
|
+
function isGithubRepoUrl(val) {
|
|
7073
|
+
return !!(isString(val) && (val.startsWith("https://github.com/") && stripper(val).split("/").length === 2));
|
|
7465
7074
|
}
|
|
7466
|
-
function
|
|
7467
|
-
return isString(
|
|
7075
|
+
function isGithubRepoReleasesUrl(val) {
|
|
7076
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases") && stripper(val).split("/").length === 3);
|
|
7468
7077
|
}
|
|
7469
|
-
function
|
|
7470
|
-
return val
|
|
7078
|
+
function isGithubRepoReleaseTagUrl(val) {
|
|
7079
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).length === 4);
|
|
7471
7080
|
}
|
|
7472
|
-
function
|
|
7473
|
-
return
|
|
7081
|
+
function isGithubIssuesListUrl(val) {
|
|
7082
|
+
return isString(val) && val.startsWith("https://github.com/") && val.includes("/issues");
|
|
7474
7083
|
}
|
|
7475
|
-
function
|
|
7476
|
-
return
|
|
7084
|
+
function isGithubIssueUrl(val) {
|
|
7085
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/issues/"));
|
|
7477
7086
|
}
|
|
7478
|
-
function
|
|
7479
|
-
return
|
|
7087
|
+
function isGithubProjectsListUrl(val) {
|
|
7088
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/projects?") || val.trim().endsWith("/projects")) && stripper(val).split("/").length === 3);
|
|
7480
7089
|
}
|
|
7481
|
-
function
|
|
7482
|
-
return
|
|
7090
|
+
function isGithubProjectUrl(val) {
|
|
7091
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/projects/") && stripper(val).split("/").length === 4);
|
|
7483
7092
|
}
|
|
7484
|
-
function
|
|
7485
|
-
|
|
7486
|
-
const chars = svelte.split("");
|
|
7487
|
-
const numeric = retainChars(svelte, ...NUMERIC_CHAR2);
|
|
7488
|
-
const valid2 = ["+", "(", ...NUMERIC_CHAR2];
|
|
7489
|
-
const nothing = stripChars(svelte, ...[
|
|
7490
|
-
...NUMERIC_CHAR2,
|
|
7491
|
-
...WHITESPACE_CHARS2,
|
|
7492
|
-
"(",
|
|
7493
|
-
")",
|
|
7494
|
-
"+",
|
|
7495
|
-
".",
|
|
7496
|
-
"-"
|
|
7497
|
-
]);
|
|
7498
|
-
return chars.every((i) => valid2.includes(i)) && svelte.startsWith(`+`) ? numeric.length >= 8 : svelte.startsWith(`00`) ? numeric.length >= 10 : numeric.length >= 7 && nothing === "";
|
|
7093
|
+
function isGithubReleasesListUrl(val) {
|
|
7094
|
+
return isString(val) && (val.startsWith("https://github.com/") && (val.includes("/releases?") || val.trim().endsWith("/releases")) && stripper(val).split("/").length === 3);
|
|
7499
7095
|
}
|
|
7500
|
-
|
|
7501
|
-
|
|
7502
|
-
if (isString(val)) {
|
|
7503
|
-
return start.some((i) => val.trimStart().startsWith(i));
|
|
7504
|
-
}
|
|
7505
|
-
return false;
|
|
7096
|
+
function isGithubReleaseTagUrl(val) {
|
|
7097
|
+
return isString(val) && (val.startsWith("https://github.com/") && val.includes("/releases/tag/") && stripper(val).split("/").length === 5);
|
|
7506
7098
|
}
|
|
7507
|
-
function
|
|
7508
|
-
|
|
7509
|
-
return maybePhoneNumber(val) && val.trimStart().startsWith(`+1 `);
|
|
7510
|
-
}
|
|
7511
|
-
return false;
|
|
7099
|
+
function isRepoSource(v) {
|
|
7100
|
+
return isString(v) && REPO_SOURCES2.includes(v);
|
|
7512
7101
|
}
|
|
7513
|
-
function
|
|
7514
|
-
|
|
7515
|
-
const cc = getPhoneCountryCode(val);
|
|
7516
|
-
const without = cc === "" ? retainChars(val, ...NUMERIC_CHAR2) : retainChars(val.trimStart().replace(`+${cc} `, ""), ...NUMERIC_CHAR2);
|
|
7517
|
-
switch (cc) {
|
|
7518
|
-
case "1":
|
|
7519
|
-
return without.length === 10;
|
|
7520
|
-
case "44":
|
|
7521
|
-
return !![10, 11].includes(without.length);
|
|
7522
|
-
case "":
|
|
7523
|
-
return without.length <= 10;
|
|
7524
|
-
default:
|
|
7525
|
-
return without.length <= 11;
|
|
7526
|
-
}
|
|
7527
|
-
}
|
|
7528
|
-
return false;
|
|
7102
|
+
function isSemanticVersion(v, allowPrefix = false) {
|
|
7103
|
+
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())));
|
|
7529
7104
|
}
|
|
7530
|
-
function
|
|
7531
|
-
return
|
|
7105
|
+
function isRepoUrl(val) {
|
|
7106
|
+
return isGithubUrl(val) || isBitbucketUrl(val) || isCodeCommitUrl(val);
|
|
7532
7107
|
}
|
|
7533
|
-
function
|
|
7534
|
-
return
|
|
7108
|
+
function isWholeFoodsUrl(val) {
|
|
7109
|
+
return isString(val) && WHOLE_FOODS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7535
7110
|
}
|
|
7536
|
-
function
|
|
7537
|
-
return val
|
|
7111
|
+
function isCvsUrl(val) {
|
|
7112
|
+
return isString(val) && CVS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7538
7113
|
}
|
|
7539
|
-
function
|
|
7540
|
-
|
|
7541
|
-
return true;
|
|
7542
|
-
}
|
|
7543
|
-
if (isString(val)) {
|
|
7544
|
-
try {
|
|
7545
|
-
const _re = new RegExp(val);
|
|
7546
|
-
return true;
|
|
7547
|
-
} catch {
|
|
7548
|
-
return false;
|
|
7549
|
-
}
|
|
7550
|
-
}
|
|
7551
|
-
return false;
|
|
7114
|
+
function isWalgreensUrl(val) {
|
|
7115
|
+
return isString(val) && WALGREENS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7552
7116
|
}
|
|
7553
|
-
function
|
|
7554
|
-
return
|
|
7117
|
+
function isKrogersUrl(val) {
|
|
7118
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7555
7119
|
}
|
|
7556
|
-
function
|
|
7557
|
-
return isString(
|
|
7120
|
+
function isZaraUrl(val) {
|
|
7121
|
+
return isString(val) && ZARA_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7558
7122
|
}
|
|
7559
|
-
function
|
|
7560
|
-
return
|
|
7123
|
+
function isHmUrl(val) {
|
|
7124
|
+
return isString(val) && HM_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7561
7125
|
}
|
|
7562
|
-
function
|
|
7563
|
-
return val
|
|
7126
|
+
function isDellUrl(val) {
|
|
7127
|
+
return isString(val) && DELL_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7564
7128
|
}
|
|
7565
|
-
function
|
|
7566
|
-
return
|
|
7129
|
+
function isIkeaUrl(val) {
|
|
7130
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7567
7131
|
}
|
|
7568
|
-
function
|
|
7569
|
-
return
|
|
7132
|
+
function isLowesUrl(val) {
|
|
7133
|
+
return isString(val) && KROGER_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7570
7134
|
}
|
|
7571
|
-
function
|
|
7572
|
-
return isString(val) &&
|
|
7135
|
+
function isNikeUrl(val) {
|
|
7136
|
+
return isString(val) && NIKE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7573
7137
|
}
|
|
7574
|
-
function
|
|
7575
|
-
return
|
|
7138
|
+
function isWayfairUrl(val) {
|
|
7139
|
+
return isString(val) && WAYFAIR_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7576
7140
|
}
|
|
7577
|
-
function
|
|
7578
|
-
return
|
|
7141
|
+
function isBestBuyUrl(val) {
|
|
7142
|
+
return isString(val) && BEST_BUY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7579
7143
|
}
|
|
7580
|
-
function
|
|
7581
|
-
return isString(val) &&
|
|
7144
|
+
function isCostCoUrl(val) {
|
|
7145
|
+
return isString(val) && COSTCO_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7582
7146
|
}
|
|
7583
|
-
function
|
|
7584
|
-
return
|
|
7147
|
+
function isEtsyUrl(val) {
|
|
7148
|
+
return isString(val) && ETSY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7585
7149
|
}
|
|
7586
|
-
function
|
|
7587
|
-
return
|
|
7150
|
+
function isTargetUrl(val) {
|
|
7151
|
+
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7588
7152
|
}
|
|
7589
|
-
function
|
|
7590
|
-
return
|
|
7153
|
+
function isEbayUrl(val) {
|
|
7154
|
+
return isString(val) && EBAY_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7591
7155
|
}
|
|
7592
|
-
function
|
|
7593
|
-
|
|
7594
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
7156
|
+
function isHomeDepotUrl(val) {
|
|
7157
|
+
return isString(val) && HOME_DEPOT_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7595
7158
|
}
|
|
7596
|
-
function
|
|
7597
|
-
|
|
7598
|
-
return isString(val) && p.some((i) => val.startsWith(`${i}://`));
|
|
7159
|
+
function isMacysUrl(val) {
|
|
7160
|
+
return isString(val) && MACYS_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7599
7161
|
}
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
...NUMERIC_CHAR2,
|
|
7603
|
-
"_",
|
|
7604
|
-
"."
|
|
7605
|
-
];
|
|
7606
|
-
var alpha = null;
|
|
7607
|
-
function valid(chars) {
|
|
7608
|
-
return chars.every((i) => VALID.includes(i));
|
|
7162
|
+
function isAppleUrl(val) {
|
|
7163
|
+
return isString(val) && APPLE_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7609
7164
|
}
|
|
7610
|
-
function
|
|
7611
|
-
return isString(val) &&
|
|
7165
|
+
function isWalmartUrl(val) {
|
|
7166
|
+
return isString(val) && WALMART_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7612
7167
|
}
|
|
7613
|
-
function
|
|
7614
|
-
return
|
|
7168
|
+
function isAmazonUrl(val) {
|
|
7169
|
+
return isString(val) && AMAZON_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
7615
7170
|
}
|
|
7616
|
-
function
|
|
7617
|
-
return
|
|
7171
|
+
function isRetailUrl(val) {
|
|
7172
|
+
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);
|
|
7618
7173
|
}
|
|
7619
|
-
|
|
7620
|
-
|
|
7174
|
+
var URL20 = SOCIAL_MEDIA2.flatMap((i) => i.baseUrls);
|
|
7175
|
+
var PROFILE = SOCIAL_MEDIA2.map((i) => i.profileUrl);
|
|
7176
|
+
function isSocialMediaUrl(val) {
|
|
7177
|
+
return isString(val) && URL20.some((i) => val.startsWith(i));
|
|
7621
7178
|
}
|
|
7622
|
-
function
|
|
7623
|
-
return isString(val) &&
|
|
7179
|
+
function isSocialMediaProfileUrl(val) {
|
|
7180
|
+
return isString(val) && PROFILE.some((i) => i.startsWith(`${i}`));
|
|
7624
7181
|
}
|
|
7625
|
-
function
|
|
7626
|
-
return isString(val) &&
|
|
7182
|
+
function isYouTubeUrl(val) {
|
|
7183
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
7627
7184
|
}
|
|
7628
|
-
function
|
|
7629
|
-
return isString(val) &&
|
|
7185
|
+
function isYouTubeShareUrl(val) {
|
|
7186
|
+
return isString(val) && val.startsWith(`https://youtu.be`);
|
|
7630
7187
|
}
|
|
7631
|
-
function
|
|
7632
|
-
return isString(val) &&
|
|
7188
|
+
function isYouTubeVideoUrl(val) {
|
|
7189
|
+
return isString(val) && (val.startsWith("https://www.youtube.com") || val.startsWith("https://youtube.com") || val.startsWith("https://youtu.be"));
|
|
7633
7190
|
}
|
|
7634
|
-
function
|
|
7635
|
-
return isString(val) &&
|
|
7191
|
+
function isYouTubePlaylistUrl(val) {
|
|
7192
|
+
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`));
|
|
7636
7193
|
}
|
|
7637
|
-
function
|
|
7638
|
-
return
|
|
7194
|
+
function feed_map(type) {
|
|
7195
|
+
return isUndefined(type) ? `/feed` : type === "liked" ? `/playlist?list=LL` : ["history", "playlists", "trending", "subscriptions"].includes(type) ? `/feed/${type}` : `/feed/`;
|
|
7639
7196
|
}
|
|
7640
|
-
function
|
|
7641
|
-
return isString(val) &&
|
|
7197
|
+
function isYouTubeFeedUrl(val, type) {
|
|
7198
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com${feed_map(type)}`) || val.startsWith(`https://youtube.com${feed_map(type)}`));
|
|
7642
7199
|
}
|
|
7643
|
-
function
|
|
7644
|
-
return isString(val) &&
|
|
7200
|
+
function isYouTubeFeedHistoryUrl(val) {
|
|
7201
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/history`) || val.startsWith(`https://youtube.com/feed/history`));
|
|
7645
7202
|
}
|
|
7646
|
-
function
|
|
7647
|
-
return isString(val) &&
|
|
7203
|
+
function isYouTubePlaylistsUrl(val) {
|
|
7204
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/playlists`) || val.startsWith(`https://youtube.com/feed/playlists`));
|
|
7648
7205
|
}
|
|
7649
|
-
function
|
|
7650
|
-
return isString(val) &&
|
|
7206
|
+
function isYouTubeTrendingUrl(val) {
|
|
7207
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/trending`) || val.startsWith(`https://youtube.com/feed/trending`));
|
|
7651
7208
|
}
|
|
7652
|
-
function
|
|
7653
|
-
return isString(val) &&
|
|
7209
|
+
function isYouTubeSubscriptionsUrl(val) {
|
|
7210
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/feed/subscriptions`) || val.startsWith(`https://youtube.com/feed/subscriptions`));
|
|
7654
7211
|
}
|
|
7655
|
-
function
|
|
7656
|
-
|
|
7657
|
-
return isString(val) && speed.includes(separate(val));
|
|
7212
|
+
function isYouTubeCreatorUrl(url) {
|
|
7213
|
+
return isString(url) && (url.startsWith(`https://www.youtube.com/@`) || url.startsWith(`https://youtube.com/@`) || url.startsWith(`https://www.youtube.com/channel/`));
|
|
7658
7214
|
}
|
|
7659
|
-
function
|
|
7660
|
-
return isString(val) &&
|
|
7215
|
+
function isYouTubeVideosInPlaylist(val) {
|
|
7216
|
+
return isString(val) && (val.startsWith(`https://www.youtube.com/playlist?`) || val.startsWith(`https://youtube.com/playlist?`)) && hasUrlQueryParameter(val, "list");
|
|
7661
7217
|
}
|
|
7662
|
-
function
|
|
7663
|
-
|
|
7218
|
+
function isVueRef(val) {
|
|
7219
|
+
if (isObject(val)) {
|
|
7220
|
+
const keys = Object.keys(val);
|
|
7221
|
+
return !!["dep", "__v_isRef"].every((i) => keys.includes(i));
|
|
7222
|
+
}
|
|
7223
|
+
return false;
|
|
7664
7224
|
}
|
|
7665
|
-
function
|
|
7666
|
-
return
|
|
7225
|
+
function filterUndefined(...val) {
|
|
7226
|
+
return val.filter((i) => isDefined(i));
|
|
7667
7227
|
}
|
|
7668
|
-
function
|
|
7669
|
-
return
|
|
7228
|
+
function find(list2, deref = null) {
|
|
7229
|
+
return (comparator) => {
|
|
7230
|
+
return list2.find((i) => {
|
|
7231
|
+
const val = deref ? isObject(i) || isArray(i) ? deref in i ? i[deref] : void 0 : i : i;
|
|
7232
|
+
return val === comparator;
|
|
7233
|
+
});
|
|
7234
|
+
};
|
|
7670
7235
|
}
|
|
7671
|
-
function
|
|
7672
|
-
|
|
7236
|
+
function getEach(list2, dotPath) {
|
|
7237
|
+
const result2 = list2.map(
|
|
7238
|
+
(i) => isNull(dotPath) ? i : isContainer(i) ? get(i, dotPath) : Never2
|
|
7239
|
+
).filter((i) => !isErrorCondition(i));
|
|
7240
|
+
return result2;
|
|
7673
7241
|
}
|
|
7674
|
-
function
|
|
7675
|
-
|
|
7242
|
+
function indexOf(val, index) {
|
|
7243
|
+
const isNegative = isNumber(index) && index < 0;
|
|
7244
|
+
if (isNegative && !Array.isArray(val)) {
|
|
7245
|
+
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}]!`);
|
|
7246
|
+
}
|
|
7247
|
+
if (isNegative && Array.isArray(val) && val.length < Math.abs(index)) {
|
|
7248
|
+
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.`);
|
|
7249
|
+
}
|
|
7250
|
+
const idx = isNegative && Array.isArray(val) ? val.length + 1 - Math.abs(index) : index;
|
|
7251
|
+
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}`);
|
|
7676
7252
|
}
|
|
7677
|
-
function
|
|
7678
|
-
|
|
7253
|
+
function intersectWithOffset(a, b, deref) {
|
|
7254
|
+
const aIndexable = a.every((i) => isIndexable(i));
|
|
7255
|
+
const bIndexable = b.every((i) => isIndexable(i));
|
|
7256
|
+
if (!aIndexable || !bIndexable) {
|
|
7257
|
+
if (!aIndexable) {
|
|
7258
|
+
throw new Error(`The "a" array passed into intersect(a,b) was not fully composed of indexable properties: ${a.map((i) => typeof i).join(", ")}`);
|
|
7259
|
+
} else {
|
|
7260
|
+
throw new Error(`The "b" array passed into intersect(a,b) was not fully composed of indexable properties: ${b.map((i) => typeof i).join(", ")}`);
|
|
7261
|
+
}
|
|
7262
|
+
}
|
|
7263
|
+
const aMatches = getEach(a, deref);
|
|
7264
|
+
const bMatches = getEach(b, deref);
|
|
7265
|
+
const sharedKeys2 = ifNotNull(
|
|
7266
|
+
deref,
|
|
7267
|
+
(v) => [
|
|
7268
|
+
a.filter((i) => Array.from(bMatches).includes(get(i, v))),
|
|
7269
|
+
b.filter((i) => Array.from(aMatches).includes(get(i, v)))
|
|
7270
|
+
],
|
|
7271
|
+
() => a.filter((k) => b.includes(k))
|
|
7272
|
+
);
|
|
7273
|
+
return sharedKeys2;
|
|
7679
7274
|
}
|
|
7680
|
-
function
|
|
7681
|
-
return
|
|
7275
|
+
function intersectNoOffset(a, b) {
|
|
7276
|
+
return a.length < b.length ? a.filter((val) => b.includes(val)) : b.filter((val) => a.includes(val));
|
|
7682
7277
|
}
|
|
7683
|
-
function
|
|
7684
|
-
return
|
|
7278
|
+
function intersection(a, b, deref = null) {
|
|
7279
|
+
return deref === null ? intersectNoOffset(a, b) : intersectWithOffset(a, b, deref);
|
|
7685
7280
|
}
|
|
7686
|
-
function
|
|
7687
|
-
return
|
|
7281
|
+
function joinWith(joinWith2) {
|
|
7282
|
+
return (...tuple3) => {
|
|
7283
|
+
const tup = tuple3;
|
|
7284
|
+
return tup.join(joinWith2);
|
|
7285
|
+
};
|
|
7688
7286
|
}
|
|
7689
|
-
function
|
|
7690
|
-
return
|
|
7287
|
+
function last(list2) {
|
|
7288
|
+
return [...list2].pop();
|
|
7691
7289
|
}
|
|
7692
|
-
function
|
|
7693
|
-
return
|
|
7290
|
+
function logicalReturns(conditions) {
|
|
7291
|
+
return conditions.map(
|
|
7292
|
+
(c) => isBoolean(c) ? c : isFunction(c) ? c() : Never2
|
|
7293
|
+
);
|
|
7694
7294
|
}
|
|
7695
|
-
function
|
|
7696
|
-
return
|
|
7295
|
+
function reverse(list2) {
|
|
7296
|
+
return [...list2].reverse();
|
|
7697
7297
|
}
|
|
7698
|
-
function
|
|
7699
|
-
|
|
7298
|
+
function shift(list2) {
|
|
7299
|
+
let rtn;
|
|
7300
|
+
if (isDefined(list2)) {
|
|
7301
|
+
rtn = list2.length === 0 ? void 0 : list2[0];
|
|
7302
|
+
try {
|
|
7303
|
+
list2 = list2.slice(1);
|
|
7304
|
+
} catch {
|
|
7305
|
+
}
|
|
7306
|
+
} else {
|
|
7307
|
+
rtn = void 0;
|
|
7308
|
+
}
|
|
7309
|
+
return rtn;
|
|
7700
7310
|
}
|
|
7701
|
-
function
|
|
7702
|
-
return
|
|
7311
|
+
function slice(list2, start2, end) {
|
|
7312
|
+
return list2.slice(start2, end);
|
|
7703
7313
|
}
|
|
7704
|
-
function
|
|
7705
|
-
|
|
7314
|
+
function unique(...values) {
|
|
7315
|
+
const u = [];
|
|
7316
|
+
for (const i of values.flat()) {
|
|
7317
|
+
if (!u.includes(i)) {
|
|
7318
|
+
u.push(i);
|
|
7319
|
+
}
|
|
7320
|
+
}
|
|
7321
|
+
return u;
|
|
7706
7322
|
}
|
|
7707
|
-
function
|
|
7708
|
-
|
|
7323
|
+
function box(value) {
|
|
7324
|
+
const rtn = {
|
|
7325
|
+
__type: "box",
|
|
7326
|
+
value,
|
|
7327
|
+
unbox: (...p) => {
|
|
7328
|
+
return typeof value === "function" ? value(...p) : value;
|
|
7329
|
+
}
|
|
7330
|
+
};
|
|
7331
|
+
return rtn;
|
|
7709
7332
|
}
|
|
7710
|
-
function
|
|
7711
|
-
return
|
|
7333
|
+
function isBox(thing) {
|
|
7334
|
+
return typeof thing === "object" && "__type" in thing && thing.__type === "box";
|
|
7712
7335
|
}
|
|
7713
|
-
function
|
|
7714
|
-
|
|
7336
|
+
function boxDictionaryValues(dict) {
|
|
7337
|
+
const keys = Object.keys(dict);
|
|
7338
|
+
return keys.reduce(
|
|
7339
|
+
(acc, key) => ({ ...acc, [key]: box(dict[key]) }),
|
|
7340
|
+
{}
|
|
7341
|
+
);
|
|
7715
7342
|
}
|
|
7716
|
-
function
|
|
7717
|
-
return
|
|
7343
|
+
function unbox(val) {
|
|
7344
|
+
return isBox(val) ? val.value : val;
|
|
7718
7345
|
}
|
|
7719
|
-
function
|
|
7720
|
-
return
|
|
7346
|
+
function capitalize(str) {
|
|
7347
|
+
return `${str?.slice(0, 1).toUpperCase()}${str?.slice(1)}`;
|
|
7721
7348
|
}
|
|
7722
|
-
function
|
|
7723
|
-
|
|
7724
|
-
return isString(val) && isString(expanded) && expanded.split(":").every((i) => asChars(i).length >= 1 && asChars(i).length <= 4) && expanded.split(":").every((i) => isHexadecimal(i));
|
|
7349
|
+
function cssColor(color, v1, v2, v3, opacity) {
|
|
7350
|
+
return `color(${color} ${v1} ${v2} ${v3}${opacity ? ` / ${opacity}` : ""}`;
|
|
7725
7351
|
}
|
|
7726
|
-
function
|
|
7727
|
-
|
|
7352
|
+
function twColor(color, luminosity) {
|
|
7353
|
+
const lum = luminosity in TW_LUMINOSITY2 ? TW_LUMINOSITY2[luminosity] : 0;
|
|
7354
|
+
const chroma = luminosity in TW_CHROMA2 ? TW_CHROMA2[luminosity] : 0;
|
|
7355
|
+
const hue = TW_HUE2[color];
|
|
7356
|
+
return `oklch(${lum} ${chroma} ${hue})`;
|
|
7728
7357
|
}
|
|
7729
|
-
function
|
|
7730
|
-
|
|
7358
|
+
function ensureLeading(content, ensure) {
|
|
7359
|
+
const output = String(content);
|
|
7360
|
+
return output.startsWith(String(ensure)) ? content : isString(content) ? `${ensure}${content}` : Number(`${ensure}${content}`);
|
|
7731
7361
|
}
|
|
7732
|
-
function
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7362
|
+
function ensureSurround(prefix, postfix) {
|
|
7363
|
+
const fn2 = (input) => {
|
|
7364
|
+
let result2 = input;
|
|
7365
|
+
result2 = ensureLeading(result2, prefix);
|
|
7366
|
+
result2 = ensureTrailing(result2, postfix);
|
|
7367
|
+
return result2;
|
|
7368
|
+
};
|
|
7369
|
+
return fn2;
|
|
7736
7370
|
}
|
|
7737
|
-
function
|
|
7738
|
-
return
|
|
7739
|
-
|
|
7371
|
+
function ensureTrailing(content, ensure) {
|
|
7372
|
+
return (
|
|
7373
|
+
//
|
|
7374
|
+
content.endsWith(ensure) ? content : `${content}${ensure}`
|
|
7740
7375
|
);
|
|
7741
7376
|
}
|
|
7742
|
-
function
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7377
|
+
function getTypeSubtype(str) {
|
|
7378
|
+
if (isTypeSubtype(str)) {
|
|
7379
|
+
const [t, st] = str.split("/");
|
|
7380
|
+
return [t, st];
|
|
7381
|
+
} else {
|
|
7382
|
+
const err = new Error(`An invalid Type/Subtype was passed into getTypeSubtype(${str})`);
|
|
7383
|
+
err.name = "InvalidTypeSubtype";
|
|
7384
|
+
throw err;
|
|
7385
|
+
}
|
|
7747
7386
|
}
|
|
7748
|
-
function
|
|
7749
|
-
return
|
|
7387
|
+
function identity(...values) {
|
|
7388
|
+
return values.length === 1 ? values[0] : values.length === 0 ? void 0 : values;
|
|
7750
7389
|
}
|
|
7751
|
-
function
|
|
7752
|
-
|
|
7390
|
+
function ifLowercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
7391
|
+
if (ch.length !== 1) {
|
|
7392
|
+
throw new Error(`call to ifUppercaseChar received ${ch.length} characters but is only valid when one character is passed in!`);
|
|
7393
|
+
}
|
|
7394
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7753
7395
|
}
|
|
7754
|
-
function
|
|
7755
|
-
|
|
7396
|
+
function ifUppercaseChar(ch, callbackForMatch, callbackForNoMatch) {
|
|
7397
|
+
if (ch.length !== 1) {
|
|
7398
|
+
throw new Error(`Invalid string length passed to ifUppercaseChar(ch); this function requires a single character but ${ch.length} were received`);
|
|
7399
|
+
}
|
|
7400
|
+
return LOWER_ALPHA_CHARS2.includes(ch) ? callbackForMatch(ch) : callbackForNoMatch(ch);
|
|
7756
7401
|
}
|
|
7757
|
-
function
|
|
7758
|
-
|
|
7402
|
+
function parseTemplate(template) {
|
|
7403
|
+
const pattern = /\{\{\s*infer\s+([A-Za-z_]\w*)\s*(?:(?:extends|as)\s+(string|number|boolean)\s*)?\}\}/g;
|
|
7404
|
+
let lastIndex = 0;
|
|
7405
|
+
let match;
|
|
7406
|
+
const segments = [];
|
|
7407
|
+
while (match = pattern.exec(template)) {
|
|
7408
|
+
const [fullMatch, varName, asType2] = match;
|
|
7409
|
+
const staticPart = template.slice(lastIndex, match.index);
|
|
7410
|
+
if (staticPart) {
|
|
7411
|
+
segments.push({ dynamic: false, text: staticPart });
|
|
7412
|
+
}
|
|
7413
|
+
segments.push({
|
|
7414
|
+
dynamic: true,
|
|
7415
|
+
varName,
|
|
7416
|
+
type: asType2 ? asType2 : "string"
|
|
7417
|
+
});
|
|
7418
|
+
lastIndex = match.index + fullMatch.length;
|
|
7419
|
+
}
|
|
7420
|
+
const remainder = template.slice(lastIndex);
|
|
7421
|
+
if (remainder) {
|
|
7422
|
+
segments.push({ dynamic: false, text: remainder });
|
|
7423
|
+
}
|
|
7424
|
+
return segments;
|
|
7759
7425
|
}
|
|
7760
|
-
function
|
|
7761
|
-
return
|
|
7426
|
+
function escapeRegex(str) {
|
|
7427
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7762
7428
|
}
|
|
7763
|
-
function
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
if (
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7429
|
+
function buildRegexPattern(segments) {
|
|
7430
|
+
let regexStr = "^";
|
|
7431
|
+
for (const seg of segments) {
|
|
7432
|
+
if (!seg.dynamic) {
|
|
7433
|
+
regexStr += escapeRegex(seg.text);
|
|
7434
|
+
} else {
|
|
7435
|
+
switch (seg.type) {
|
|
7436
|
+
case "string":
|
|
7437
|
+
regexStr += "(.*?)";
|
|
7438
|
+
break;
|
|
7439
|
+
case "number":
|
|
7440
|
+
regexStr += "(\\d+)";
|
|
7441
|
+
break;
|
|
7442
|
+
case "boolean":
|
|
7443
|
+
regexStr += "(true|false)";
|
|
7444
|
+
break;
|
|
7777
7445
|
}
|
|
7778
7446
|
}
|
|
7779
|
-
return false;
|
|
7780
7447
|
}
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
function isTypeTokenKind(val) {
|
|
7784
|
-
return !!(isString(val) && TT_KIND_VARIANTS2.includes(val));
|
|
7785
|
-
}
|
|
7786
|
-
function isAtomicToken(val) {
|
|
7787
|
-
return isString(val) && TT_ATOMICS2.some((i) => val.startsWith(`<<${i}`));
|
|
7448
|
+
regexStr += "$";
|
|
7449
|
+
return new RegExp(regexStr);
|
|
7788
7450
|
}
|
|
7789
|
-
function
|
|
7790
|
-
|
|
7451
|
+
function convertValue(type, value) {
|
|
7452
|
+
switch (type) {
|
|
7453
|
+
case "string":
|
|
7454
|
+
return value;
|
|
7455
|
+
case "number":
|
|
7456
|
+
return Number(value);
|
|
7457
|
+
case "boolean":
|
|
7458
|
+
return value === "true";
|
|
7459
|
+
}
|
|
7791
7460
|
}
|
|
7792
|
-
function
|
|
7793
|
-
|
|
7461
|
+
function matchTemplate(template, test) {
|
|
7462
|
+
const segments = parseTemplate(template);
|
|
7463
|
+
const regex = buildRegexPattern(segments);
|
|
7464
|
+
const match = regex.exec(test);
|
|
7465
|
+
if (!match)
|
|
7466
|
+
return false;
|
|
7467
|
+
let captureIndex = 1;
|
|
7468
|
+
const result2 = {};
|
|
7469
|
+
for (const seg of segments) {
|
|
7470
|
+
if (seg.dynamic) {
|
|
7471
|
+
const rawVal = match[captureIndex++];
|
|
7472
|
+
if (rawVal === void 0)
|
|
7473
|
+
return false;
|
|
7474
|
+
result2[seg.varName] = convertValue(seg.type, rawVal);
|
|
7475
|
+
}
|
|
7476
|
+
}
|
|
7477
|
+
return result2;
|
|
7794
7478
|
}
|
|
7795
|
-
function
|
|
7796
|
-
return
|
|
7479
|
+
function infer(inference) {
|
|
7480
|
+
return (test) => {
|
|
7481
|
+
return matchTemplate(inference, test);
|
|
7482
|
+
};
|
|
7797
7483
|
}
|
|
7798
|
-
function
|
|
7799
|
-
return
|
|
7484
|
+
function idLiteral(o) {
|
|
7485
|
+
return { ...o, id: o.id };
|
|
7800
7486
|
}
|
|
7801
|
-
function
|
|
7802
|
-
return
|
|
7487
|
+
function nameLiteral(o) {
|
|
7488
|
+
return o;
|
|
7803
7489
|
}
|
|
7804
|
-
function
|
|
7805
|
-
return
|
|
7490
|
+
function kindLiteral(o) {
|
|
7491
|
+
return o;
|
|
7806
7492
|
}
|
|
7807
|
-
function
|
|
7808
|
-
return
|
|
7493
|
+
function idTypeGuard(_o) {
|
|
7494
|
+
return true;
|
|
7809
7495
|
}
|
|
7810
|
-
function
|
|
7811
|
-
return
|
|
7496
|
+
function literal(obj) {
|
|
7497
|
+
return obj;
|
|
7812
7498
|
}
|
|
7813
|
-
function
|
|
7814
|
-
return
|
|
7499
|
+
function lowercase(str) {
|
|
7500
|
+
return str.toLowerCase();
|
|
7815
7501
|
}
|
|
7816
|
-
|
|
7817
|
-
|
|
7818
|
-
...TT_CONTAINERS2,
|
|
7819
|
-
...TT_FUNCTIONS2,
|
|
7820
|
-
...TT_SETS2,
|
|
7821
|
-
...TT_SINGLETONS2
|
|
7822
|
-
];
|
|
7823
|
-
function isShapeToken(val) {
|
|
7824
|
-
return isString(val) && val.startsWith("<<") && val.endsWith(">>") && token_types.some((t) => val.startsWith(`<<${t}`));
|
|
7502
|
+
function narrow(...values) {
|
|
7503
|
+
return values.length === 1 ? values[0] : values;
|
|
7825
7504
|
}
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7505
|
+
function pathJoin(...segments) {
|
|
7506
|
+
const clean_path = segments.map((i) => stripTrailing(stripLeading(i, "/"), "/")).join("/");
|
|
7507
|
+
const original_path = segments.join("/");
|
|
7508
|
+
const pre = original_path.startsWith("/") ? "/" : "";
|
|
7509
|
+
const post = original_path.endsWith("/") ? "/" : "";
|
|
7510
|
+
return `${pre}${clean_path}${post}`;
|
|
7832
7511
|
}
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
|
|
7836
|
-
|
|
7512
|
+
var asPhoneFormat = () => `NOT IMPLEMENTED`;
|
|
7513
|
+
function getPhoneCountryCode(phone) {
|
|
7514
|
+
return phone.trim().startsWith("+") || phone.trim().startsWith("00") ? retainWhile(
|
|
7515
|
+
stripLeading(stripLeading(phone.trim(), "+"), "00"),
|
|
7516
|
+
...NUMERIC_CHAR2
|
|
7517
|
+
) : "";
|
|
7837
7518
|
}
|
|
7838
|
-
function
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7519
|
+
function removePhoneCountryCode(phone) {
|
|
7520
|
+
const countryCode = getPhoneCountryCode(phone);
|
|
7521
|
+
return countryCode !== "" ? stripLeading(stripLeading(
|
|
7522
|
+
phone.trim(),
|
|
7523
|
+
"+",
|
|
7524
|
+
"00"
|
|
7525
|
+
), countryCode).trim() : phone.trim();
|
|
7842
7526
|
}
|
|
7843
|
-
|
|
7844
|
-
|
|
7527
|
+
var isException = (word) => Object.keys(PLURAL_EXCEPTIONS2).includes(word);
|
|
7528
|
+
function endingIn(word, postfix) {
|
|
7529
|
+
switch (postfix) {
|
|
7530
|
+
case "is":
|
|
7531
|
+
return word.endsWith(postfix) ? `${word}es` : void 0;
|
|
7532
|
+
case "singular-noun":
|
|
7533
|
+
return SINGULAR_NOUN_ENDINGS2.some((i) => word.endsWith(i)) ? split(word).every((i) => [...ALPHA_CHARS2].includes(i)) ? `${word}es` : void 0 : void 0;
|
|
7534
|
+
case "f":
|
|
7535
|
+
return word.endsWith("f") ? `${stripTrailing(word, "f")}ves` : word.endsWith("fe") ? `${stripTrailing(word, "fe")}ves` : void 0;
|
|
7536
|
+
case "y":
|
|
7537
|
+
return word.endsWith("y") ? `${stripTrailing(word, "y")}ies` : void 0;
|
|
7538
|
+
default:
|
|
7539
|
+
throw new Error(`endingIn received "${postfix}" as a postfix but this ending is not known!`);
|
|
7540
|
+
}
|
|
7845
7541
|
}
|
|
7846
|
-
function
|
|
7847
|
-
|
|
7542
|
+
function pluralize(word) {
|
|
7543
|
+
const right = rightWhitespace(word);
|
|
7544
|
+
const w = word.trimEnd();
|
|
7545
|
+
const result2 = isException(w) ? PLURAL_EXCEPTIONS2[w] : endingIn(w, "is") || endingIn(w, "singular-noun") || endingIn(w, "f") || endingIn(w, "y") || `${w}s`;
|
|
7546
|
+
return `${result2}${right}`;
|
|
7848
7547
|
}
|
|
7849
|
-
function
|
|
7850
|
-
|
|
7548
|
+
function retainAfter(content, ...find2) {
|
|
7549
|
+
const idx = Math.min(
|
|
7550
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
7551
|
+
);
|
|
7552
|
+
const min = Math.min(...find2.map((i) => i.length));
|
|
7553
|
+
let len = Math.max(...find2.map((i) => i.length));
|
|
7554
|
+
if (min !== len) {
|
|
7555
|
+
if (!find2.includes(content.slice(idx, len))) {
|
|
7556
|
+
len = min;
|
|
7557
|
+
}
|
|
7558
|
+
}
|
|
7559
|
+
return idx && idx > 0 ? content.slice(idx + len) : "";
|
|
7851
7560
|
}
|
|
7852
|
-
function
|
|
7853
|
-
|
|
7854
|
-
(
|
|
7561
|
+
function retainAfterInclusive(content, ...find2) {
|
|
7562
|
+
const minFound = Math.min(
|
|
7563
|
+
...find2.map((i) => content.indexOf(i)).filter((i) => i > -1)
|
|
7855
7564
|
);
|
|
7565
|
+
return minFound > 0 ? content.slice(minFound) : "";
|
|
7856
7566
|
}
|
|
7857
|
-
function
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
return TT_FUNCTIONS2.some((i) => stripped.startsWith(i));
|
|
7861
|
-
}
|
|
7567
|
+
function retainChars(content, ...retain2) {
|
|
7568
|
+
const chars = asChars(content);
|
|
7569
|
+
return chars.filter((c) => retain2.includes(c)).join("");
|
|
7862
7570
|
}
|
|
7863
|
-
function
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7571
|
+
function retainUntil(content, ...find2) {
|
|
7572
|
+
const chars = asChars(content);
|
|
7573
|
+
let idx = 0;
|
|
7574
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
7575
|
+
idx = idx + 1;
|
|
7867
7576
|
}
|
|
7868
|
-
return
|
|
7577
|
+
return idx === 0 ? "" : content.slice(0, idx);
|
|
7869
7578
|
}
|
|
7870
|
-
function
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7579
|
+
function retainUntilInclusive(content, ...find2) {
|
|
7580
|
+
const chars = asChars(content);
|
|
7581
|
+
let idx = 0;
|
|
7582
|
+
while (!find2.includes(chars[idx]) && idx <= chars.length) {
|
|
7583
|
+
idx = idx + 1;
|
|
7874
7584
|
}
|
|
7875
|
-
return
|
|
7876
|
-
}
|
|
7877
|
-
function isSetBasedKind(val) {
|
|
7878
|
-
return isString(val) && val.endsWith(`-set`);
|
|
7879
|
-
}
|
|
7880
|
-
function isSingletonKind(val) {
|
|
7881
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7882
|
-
}
|
|
7883
|
-
function isSingletonToken(val) {
|
|
7884
|
-
return isString(val) && TT_SINGLETONS2.some((i) => val.startsWith(`<<${i}`));
|
|
7885
|
-
}
|
|
7886
|
-
function isTailwindColorName(val) {
|
|
7887
|
-
return isString(val) && Object.keys(TW_HUE2).includes(val);
|
|
7888
|
-
}
|
|
7889
|
-
function isTailwindColorWithLuminosity(val) {
|
|
7890
|
-
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, "-")));
|
|
7891
|
-
}
|
|
7892
|
-
function isTailwindColorWithLuminosityAndOpacity(val) {
|
|
7893
|
-
return isString(val) && val.includes("/") && isTailwindColorWithLuminosity(val.split("/")[0]) && isNumberLike(val.split("/")[1]) && ([1, 2].includes(val.split("/")[1].length) || val.split("/")[1] === "100");
|
|
7585
|
+
return idx === 0 ? content.slice(0, 1) : content.slice(0, idx + 1);
|
|
7894
7586
|
}
|
|
7895
|
-
function
|
|
7896
|
-
|
|
7587
|
+
function retainWhile(content, ...retain2) {
|
|
7588
|
+
const stopIdx = asChars(content).findIndex((c) => !retain2.includes(c));
|
|
7589
|
+
return content.slice(0, stopIdx);
|
|
7897
7590
|
}
|
|
7898
|
-
function
|
|
7899
|
-
|
|
7591
|
+
function rightWhitespace(content) {
|
|
7592
|
+
const trimmed = content.trimStart();
|
|
7593
|
+
return retainAfterInclusive(
|
|
7594
|
+
trimmed,
|
|
7595
|
+
...WHITESPACE_CHARS2
|
|
7596
|
+
);
|
|
7900
7597
|
}
|
|
7901
|
-
function
|
|
7902
|
-
return
|
|
7598
|
+
function split(str, sep = "") {
|
|
7599
|
+
return str.split(sep);
|
|
7903
7600
|
}
|
|
7904
|
-
function
|
|
7905
|
-
|
|
7906
|
-
const mods = getTailwindModifiers(val);
|
|
7907
|
-
const targetted = removeTailwindModifiers(val);
|
|
7908
|
-
const target = targetted.split("-")[0];
|
|
7909
|
-
const color = targetted.split("-").slice(1).join("-");
|
|
7910
|
-
return isTailwindColorTarget(target) && isTailwindColor(color) && (allowedModifiers[0] === true || mods.every((i) => allowedModifiers.includes(i)));
|
|
7911
|
-
}
|
|
7912
|
-
return false;
|
|
7601
|
+
function stripAfter(content, find2) {
|
|
7602
|
+
return content.split(find2).shift();
|
|
7913
7603
|
}
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
return isString(val) && val.startsWith("https://") && (URL.includes(val) || URL.some((i) => i.startsWith(`${i}/`)));
|
|
7604
|
+
function stripBefore(content, find2) {
|
|
7605
|
+
return content.split(find2).slice(1).join(find2);
|
|
7917
7606
|
}
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
return
|
|
7607
|
+
function stripChars(content, ...strip2) {
|
|
7608
|
+
const chars = asChars(content);
|
|
7609
|
+
return chars.filter((c) => !strip2.includes(c)).join("");
|
|
7921
7610
|
}
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7611
|
+
function stripLeading(content, ...strip2) {
|
|
7612
|
+
if (isUndefined(content)) {
|
|
7613
|
+
return void 0;
|
|
7614
|
+
}
|
|
7615
|
+
let output = String(content);
|
|
7616
|
+
for (const s of strip2) {
|
|
7617
|
+
if (output.startsWith(String(s))) {
|
|
7618
|
+
output = output.slice(String(s).length);
|
|
7619
|
+
}
|
|
7620
|
+
}
|
|
7621
|
+
return isNumber(content) ? Number(output) : output;
|
|
7925
7622
|
}
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7623
|
+
function stripSurround(...chars) {
|
|
7624
|
+
return (input) => {
|
|
7625
|
+
let output = String(input);
|
|
7626
|
+
for (const s of chars) {
|
|
7627
|
+
if (output.startsWith(String(s))) {
|
|
7628
|
+
output = output.slice(String(s).length);
|
|
7629
|
+
}
|
|
7630
|
+
if (output.endsWith(String(s))) {
|
|
7631
|
+
output = output.slice(0, -1 * String(s).length);
|
|
7632
|
+
}
|
|
7633
|
+
}
|
|
7634
|
+
return isNumber(input) ? Number(output) : output;
|
|
7635
|
+
};
|
|
7929
7636
|
}
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7637
|
+
function stripTrailing(content, ...strip2) {
|
|
7638
|
+
if (isUndefined(content)) {
|
|
7639
|
+
return void 0;
|
|
7640
|
+
}
|
|
7641
|
+
let output = String(content);
|
|
7642
|
+
for (const s of strip2) {
|
|
7643
|
+
if (output.endsWith(String(s))) {
|
|
7644
|
+
output = output.slice(0, -1 * String(s).length);
|
|
7645
|
+
}
|
|
7646
|
+
}
|
|
7647
|
+
return isNumber(content) ? Number(output) : output;
|
|
7933
7648
|
}
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
return
|
|
7649
|
+
function stripUntil(content, ...until) {
|
|
7650
|
+
const stopIdx = asChars(content).findIndex((c) => until.includes(c));
|
|
7651
|
+
return content.slice(stopIdx);
|
|
7937
7652
|
}
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
return
|
|
7653
|
+
function stripWhile(content, ...match) {
|
|
7654
|
+
const stopIdx = asChars(content).findIndex((c) => !match.includes(c));
|
|
7655
|
+
return content.slice(stopIdx);
|
|
7941
7656
|
}
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
return isString(val) && val.startsWith("https://") && (URL8.includes(val) || URL8.some((i) => i.startsWith(`${i}/`)));
|
|
7657
|
+
function surround(prefix, postfix) {
|
|
7658
|
+
return (input) => `${prefix}${input}${postfix}`;
|
|
7945
7659
|
}
|
|
7946
|
-
|
|
7947
|
-
|
|
7948
|
-
return
|
|
7660
|
+
function takeNumericCharacters(content) {
|
|
7661
|
+
const nonNumericIdx = asChars(content).findIndex((i) => !NUMERIC_CHAR2.includes(i));
|
|
7662
|
+
return content.slice(0, nonNumericIdx);
|
|
7949
7663
|
}
|
|
7950
|
-
|
|
7951
|
-
|
|
7952
|
-
|
|
7664
|
+
function toCamelCase(input, preserveWhitespace) {
|
|
7665
|
+
const pascal = preserveWhitespace ? toPascalCase(input, preserveWhitespace) : toPascalCase(input);
|
|
7666
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
7667
|
+
pascal
|
|
7668
|
+
);
|
|
7669
|
+
const camel = (preserveWhitespace ? preWhite : "") + focus.replace(/^.*?(\d*[a-z|])/is, (_2, p1) => p1.toLowerCase()) + (preserveWhitespace ? postWhite : "");
|
|
7670
|
+
return camel;
|
|
7953
7671
|
}
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7672
|
+
function toKebabCase(input, _preserveWhitespace = false) {
|
|
7673
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
7674
|
+
const replaceWhitespace = (i) => i.replace(/\s/g, "-");
|
|
7675
|
+
const replaceUppercase = (i) => i.replace(/[A-Z]/g, (c) => `-${c[0].toLowerCase()}`);
|
|
7676
|
+
const replaceLeadingDash = (i) => i.replace(/^-/, "");
|
|
7677
|
+
const replaceTrailingDash = (i) => i.replace(/-$/, "");
|
|
7678
|
+
const replaceUnderscore = (i) => i.replace(/_/g, "-");
|
|
7679
|
+
const removeDupDashes = (i) => i.replace(/-+/g, "-");
|
|
7680
|
+
return removeDupDashes(`${preWhite}${replaceUnderscore(
|
|
7681
|
+
replaceTrailingDash(
|
|
7682
|
+
replaceLeadingDash(removeDupDashes(replaceWhitespace(replaceUppercase(focus))))
|
|
7683
|
+
)
|
|
7684
|
+
)}${postWhite}`);
|
|
7957
7685
|
}
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
return isString(val) && val.startsWith("https://") && (URL12.includes(val) || URL12.some((i) => i.startsWith(`${i}/`)));
|
|
7686
|
+
function toNumericArray(arr) {
|
|
7687
|
+
return arr.map((i) => Number(i));
|
|
7961
7688
|
}
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7689
|
+
function toPascalCase(input, preserveWhitespace = void 0) {
|
|
7690
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(
|
|
7691
|
+
input
|
|
7692
|
+
);
|
|
7693
|
+
const convertInteriorToCap = (i) => i.replace(/[ |_\-]+(\d*[a-z|])/gi, (_2, p1) => p1.toUpperCase());
|
|
7694
|
+
const startingToCap = (i) => i.replace(/^[_|-]*(\d*[a-z])/g, (_2, p1) => p1.toUpperCase());
|
|
7695
|
+
const replaceLeadingTrash = (i) => i.replace(/^[-_]/, "");
|
|
7696
|
+
const replaceTrailingTrash = (i) => i.replace(/[-_]$/, "");
|
|
7697
|
+
const pascal = `${preserveWhitespace ? preWhite : ""}${capitalize(
|
|
7698
|
+
replaceTrailingTrash(replaceLeadingTrash(convertInteriorToCap(startingToCap(focus))))
|
|
7699
|
+
)}${preserveWhitespace ? postWhite : ""}`;
|
|
7700
|
+
return pascal;
|
|
7965
7701
|
}
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
|
|
7702
|
+
function toSnakeCase(input, preserveWhitespace = false) {
|
|
7703
|
+
const [_, preWhite, focus, postWhite] = /^(\s*)(.*?)(\s*)$/.exec(input);
|
|
7704
|
+
const convertInteriorSpace = (input2) => input2.replace(/\s+/g, "_");
|
|
7705
|
+
const convertDashes = (input2) => input2.replace(/-/g, "_");
|
|
7706
|
+
const injectUnderscoreBeforeCaps = (input2) => input2.replace(/([A-Z])/g, "_$1");
|
|
7707
|
+
const removeLeadingUnderscore = (input2) => input2.startsWith("_") ? input2.slice(1) : input2;
|
|
7708
|
+
return ((preserveWhitespace ? preWhite : "") + removeLeadingUnderscore(
|
|
7709
|
+
injectUnderscoreBeforeCaps(convertDashes(convertInteriorSpace(focus)))
|
|
7710
|
+
).toLowerCase() + (preserveWhitespace ? postWhite : "")).replace(/__/g, "_");
|
|
7969
7711
|
}
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
return isString(val) && val.startsWith("https://") && (URL15.includes(val) || URL15.some((i) => i.startsWith(`${i}/`)));
|
|
7712
|
+
function toString(val) {
|
|
7713
|
+
return String(val);
|
|
7973
7714
|
}
|
|
7974
|
-
|
|
7975
|
-
|
|
7976
|
-
return isString(val) && val.startsWith("https://") && (URL16.includes(val) || URL16.some((i) => i.startsWith(`${i}/`)));
|
|
7715
|
+
function toUppercase(str) {
|
|
7716
|
+
return str.split("").map((i) => ifLowercaseChar(i, (v) => capitalize(v), (v) => v)).join("");
|
|
7977
7717
|
}
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
return isString(val) && val.startsWith("https://") && (URL17.includes(val) || URL17.some((i) => i.startsWith(`${i}/`)));
|
|
7718
|
+
function trim(input) {
|
|
7719
|
+
return input.trim();
|
|
7981
7720
|
}
|
|
7982
|
-
|
|
7983
|
-
|
|
7984
|
-
return isString(val) && val.startsWith("https://") && (URL18.includes(val) || URL18.some((i) => i.startsWith(`${i}/`)));
|
|
7721
|
+
function trimLeft(input) {
|
|
7722
|
+
return input.trimStart();
|
|
7985
7723
|
}
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
return isString(val) && val.startsWith("https://") && (URL19.includes(val) || URL19.some((i) => i.startsWith(`${i}/`)));
|
|
7724
|
+
function trimStart(input) {
|
|
7725
|
+
return input.trimStart();
|
|
7989
7726
|
}
|
|
7990
|
-
function
|
|
7991
|
-
return
|
|
7727
|
+
function trimRight(input) {
|
|
7728
|
+
return input.trimEnd();
|
|
7992
7729
|
}
|
|
7993
|
-
function
|
|
7994
|
-
|
|
7995
|
-
return isString(val) && valid2.some(
|
|
7996
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
7997
|
-
);
|
|
7730
|
+
function trimEnd(input) {
|
|
7731
|
+
return input.trimEnd();
|
|
7998
7732
|
}
|
|
7999
|
-
function
|
|
8000
|
-
const
|
|
8001
|
-
return
|
|
8002
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
8003
|
-
);
|
|
7733
|
+
function truncate(content, maxLength, ellipsis = false) {
|
|
7734
|
+
const overLimit = content.length > maxLength;
|
|
7735
|
+
return overLimit ? ellipsis ? `${content.slice(0, maxLength)}${typeof ellipsis === "string" ? ellipsis : "..."}` : content.slice(0, maxLength) : content;
|
|
8004
7736
|
}
|
|
8005
|
-
function
|
|
8006
|
-
const
|
|
8007
|
-
|
|
8008
|
-
"https://www.github.com",
|
|
8009
|
-
"https://github.io"
|
|
8010
|
-
];
|
|
8011
|
-
return isString(val) && valid2.some(
|
|
8012
|
-
(i) => val === i || val.startsWith(`${i}/`) || val.startsWith(`${i}?`)
|
|
8013
|
-
);
|
|
7737
|
+
function tuple(...values) {
|
|
7738
|
+
const arr = values.length === 1 ? values[0] : values;
|
|
7739
|
+
return asArray(arr);
|
|
8014
7740
|
}
|
|
8015
|
-
function
|
|
8016
|
-
return
|
|
7741
|
+
function uncapitalize(str) {
|
|
7742
|
+
return `${str?.slice(0, 1).toLowerCase()}${str?.slice(1)}`;
|
|
8017
7743
|
}
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
"/"
|
|
8022
|
-
);
|
|
7744
|
+
var unset = "<<unset>>";
|
|
7745
|
+
function uppercase(str) {
|
|
7746
|
+
return str.toUpperCase();
|
|
8023
7747
|
}
|
|
8024
|
-
function
|
|
8025
|
-
return
|
|
7748
|
+
function widen(value) {
|
|
7749
|
+
return value;
|
|
8026
7750
|
}
|
|
8027
|
-
|
|
8028
|
-
|
|
7751
|
+
var PROTOCOLS = Object.values(NETWORK_PROTOCOL_LOOKUP2).flat().filter((i) => i !== "");
|
|
7752
|
+
function getUrlProtocol(url) {
|
|
7753
|
+
const proto = PROTOCOLS.find((p) => url.startsWith(`${p}://`));
|
|
7754
|
+
return proto;
|
|
8029
7755
|
}
|
|
8030
|
-
function
|
|
8031
|
-
return
|
|
7756
|
+
function removeUrlProtocol(url) {
|
|
7757
|
+
return stripBefore(url, "://");
|
|
8032
7758
|
}
|
|
8033
|
-
function
|
|
8034
|
-
|
|
7759
|
+
function ensurePath(val) {
|
|
7760
|
+
const val2 = ensureLeading(val, "/");
|
|
7761
|
+
return val === "" ? "" : stripTrailing(val2, "/");
|
|
8035
7762
|
}
|
|
8036
|
-
function
|
|
8037
|
-
return
|
|
7763
|
+
function getUrlPath(url) {
|
|
7764
|
+
return isUrl(url) ? ensurePath(
|
|
7765
|
+
stripAfter(stripBefore(removeUrlProtocol(url), "/"), "?")
|
|
7766
|
+
) : Never2;
|
|
8038
7767
|
}
|
|
8039
|
-
function
|
|
8040
|
-
|
|
7768
|
+
function getUrlQueryParams(url, specific = void 0) {
|
|
7769
|
+
const qp = stripBefore(url, "?");
|
|
7770
|
+
if (specific) {
|
|
7771
|
+
return qp.includes(`${specific}=`) ? decodeURIComponent(
|
|
7772
|
+
stripAfter(
|
|
7773
|
+
stripBefore(qp, `${specific}=`),
|
|
7774
|
+
"&"
|
|
7775
|
+
).replace(/\+/g, "%20")
|
|
7776
|
+
) : void 0;
|
|
7777
|
+
}
|
|
7778
|
+
return qp === "" ? qp : `?${qp}`;
|
|
8041
7779
|
}
|
|
8042
|
-
function
|
|
8043
|
-
|
|
7780
|
+
function getUrlDefaultPort(url) {
|
|
7781
|
+
const proto = getUrlProtocol(url);
|
|
7782
|
+
return proto in PROTOCOL_DEFAULT_PORTS2 ? PROTOCOL_DEFAULT_PORTS2[proto] : null;
|
|
8044
7783
|
}
|
|
8045
|
-
function
|
|
8046
|
-
|
|
7784
|
+
function getUrlPort(url, resolve = false) {
|
|
7785
|
+
const re = /.*:(\d{2,3})/;
|
|
7786
|
+
const match = url.match(re);
|
|
7787
|
+
return re.test(url) && match && isNumberLike(Array.from(match)[1]) ? Number(Array.from(match)[1]) : resolve ? getUrlDefaultPort(url) : hasProtocol(url) ? `default` : null;
|
|
8047
7788
|
}
|
|
8048
|
-
function
|
|
8049
|
-
|
|
7789
|
+
function getUrlSource(url) {
|
|
7790
|
+
const candidate = stripAfter(stripAfter(stripAfter(removeUrlProtocol(url), "/"), "?"), ":");
|
|
7791
|
+
return isIpAddress(candidate) || isDomainName(candidate) ? candidate : Never2;
|
|
8050
7792
|
}
|
|
8051
|
-
function
|
|
8052
|
-
|
|
7793
|
+
function getUrlBase(url) {
|
|
7794
|
+
const path = getUrlPath(url);
|
|
7795
|
+
const remaining = stripAfter(url, path);
|
|
7796
|
+
return remaining;
|
|
8053
7797
|
}
|
|
8054
|
-
function
|
|
8055
|
-
|
|
7798
|
+
function getUrlDynamics(url) {
|
|
7799
|
+
const path = getUrlPath(url);
|
|
7800
|
+
const qp = getUrlQueryParams(url);
|
|
7801
|
+
const pathParts = path.startsWith("<") ? path.split("<").map((i) => ensureLeading(i, "<")) : path.split("<").map((i) => ensureLeading(i, "<")).slice(1);
|
|
7802
|
+
const segmentTypes = [
|
|
7803
|
+
"string",
|
|
7804
|
+
"number",
|
|
7805
|
+
"boolean",
|
|
7806
|
+
"Opt<string>",
|
|
7807
|
+
"Opt<number>",
|
|
7808
|
+
"Opt<boolean>"
|
|
7809
|
+
];
|
|
7810
|
+
const pathVars = {};
|
|
7811
|
+
const findPathTyped = infer(`<{{infer name}} as {{infer type}}>`);
|
|
7812
|
+
const findPathUnion = infer(`<{{infer name}} as string({{infer union}})>`);
|
|
7813
|
+
const findPathNamed = infer(`<{{infer name}}>`);
|
|
7814
|
+
for (const part of pathParts) {
|
|
7815
|
+
const union4 = findPathUnion(part);
|
|
7816
|
+
const typed = findPathTyped(part);
|
|
7817
|
+
const named = findPathNamed(part);
|
|
7818
|
+
if (union4) {
|
|
7819
|
+
if (isVariable(union4.name) && isCsv(union4.union)) {
|
|
7820
|
+
pathVars[union4.name] = `string(${union4.union})`;
|
|
7821
|
+
}
|
|
7822
|
+
} else if (typed && segmentTypes.includes(typed.type) && isVariable(typed.name)) {
|
|
7823
|
+
pathVars[typed.name] = typed.type;
|
|
7824
|
+
} else if (named && isVariable(named.name)) {
|
|
7825
|
+
pathVars[named.name] = "string";
|
|
7826
|
+
}
|
|
7827
|
+
}
|
|
7828
|
+
const qpVars = {};
|
|
7829
|
+
const qpParts = stripLeading(qp, "?").split("&");
|
|
7830
|
+
for (const p of qpParts) {
|
|
7831
|
+
const union4 = infer(`{{infer var}}=<string({{infer params}})>`)(p);
|
|
7832
|
+
const dynamic = infer(`{{infer var}}=<{{infer val}}>`)(p);
|
|
7833
|
+
const fixed = infer(`{{infer var}}={{infer val}}`)(p);
|
|
7834
|
+
if (union4 && isVariable(union4.var) && isCsv(union4.params)) {
|
|
7835
|
+
qpVars[union4.var] = `string(${union4.params})`;
|
|
7836
|
+
} else if (dynamic && isVariable(dynamic.var) && segmentTypes.includes(dynamic.val)) {
|
|
7837
|
+
qpVars[dynamic.var] = dynamic.val;
|
|
7838
|
+
} else if (fixed && isVariable(fixed.var)) {
|
|
7839
|
+
qpVars[fixed.var] = fixed.val;
|
|
7840
|
+
}
|
|
7841
|
+
}
|
|
7842
|
+
return {
|
|
7843
|
+
pathVars,
|
|
7844
|
+
qpVars,
|
|
7845
|
+
allVars: hasOverlappingKeys(pathVars, qpVars) ? null : {
|
|
7846
|
+
...pathVars,
|
|
7847
|
+
...qpVars
|
|
7848
|
+
}
|
|
7849
|
+
};
|
|
8056
7850
|
}
|
|
8057
|
-
function
|
|
8058
|
-
return
|
|
7851
|
+
function urlMeta(url) {
|
|
7852
|
+
return {
|
|
7853
|
+
url,
|
|
7854
|
+
isUrl: isUrl(url),
|
|
7855
|
+
protocol: getUrlProtocol(url),
|
|
7856
|
+
path: getUrlPath(url),
|
|
7857
|
+
queryParameters: getUrlQueryParams(url),
|
|
7858
|
+
params: getUrlDynamics,
|
|
7859
|
+
port: getUrlPort(url),
|
|
7860
|
+
source: getUrlSource(url),
|
|
7861
|
+
isIpAddress: isIpAddress(getUrlSource(url)),
|
|
7862
|
+
isIp4Address: isIp4Address(getUrlSource(url)),
|
|
7863
|
+
isIp6Address: isIp6Address(getUrlSource(url))
|
|
7864
|
+
};
|
|
8059
7865
|
}
|
|
8060
|
-
function
|
|
8061
|
-
return
|
|
7866
|
+
function getYouTubePageType(url) {
|
|
7867
|
+
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;
|
|
8062
7868
|
}
|
|
8063
|
-
function
|
|
8064
|
-
|
|
7869
|
+
function youtubeEmbed(url) {
|
|
7870
|
+
if (hasUrlQueryParameter(url, "v")) {
|
|
7871
|
+
const id = getUrlQueryParams(url, "v");
|
|
7872
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7873
|
+
} else if (isYouTubeShareUrl(url)) {
|
|
7874
|
+
const id = url.split("/").pop();
|
|
7875
|
+
if (id) {
|
|
7876
|
+
return `https://www.youtube.com/embed/${id}`;
|
|
7877
|
+
} else {
|
|
7878
|
+
throw new Error(`Unexpected problem parsing share URL -- "${url}" -- into a YouTube embed URL`);
|
|
7879
|
+
}
|
|
7880
|
+
} else {
|
|
7881
|
+
throw new Error(`Unexpected URL structure; unable to convert "${url}" to a YouTube embed URL`);
|
|
7882
|
+
}
|
|
8065
7883
|
}
|
|
8066
|
-
function
|
|
8067
|
-
return
|
|
7884
|
+
function youtubeMeta(url) {
|
|
7885
|
+
return isYouTubeUrl(url) ? {
|
|
7886
|
+
url,
|
|
7887
|
+
isYouTubeUrl: true,
|
|
7888
|
+
isShareUrl: isYouTubeShareUrl(url),
|
|
7889
|
+
pageType: getYouTubePageType(url)
|
|
7890
|
+
} : {
|
|
7891
|
+
url,
|
|
7892
|
+
isYouTubeUrl: false
|
|
7893
|
+
};
|
|
8068
7894
|
}
|
|
8069
|
-
function
|
|
8070
|
-
return
|
|
7895
|
+
function queue(state) {
|
|
7896
|
+
return {
|
|
7897
|
+
queue: state,
|
|
7898
|
+
size: state.length,
|
|
7899
|
+
isEmpty() {
|
|
7900
|
+
return state.length === 0;
|
|
7901
|
+
},
|
|
7902
|
+
clear() {
|
|
7903
|
+
state.slice(0, 0);
|
|
7904
|
+
},
|
|
7905
|
+
drain() {
|
|
7906
|
+
const old_state = [...state];
|
|
7907
|
+
state.slice(0, 0);
|
|
7908
|
+
return old_state;
|
|
7909
|
+
},
|
|
7910
|
+
push(...add) {
|
|
7911
|
+
state.push(...add);
|
|
7912
|
+
},
|
|
7913
|
+
drop(quantity) {
|
|
7914
|
+
if (quantity && quantity > state.length) {
|
|
7915
|
+
throw new Error("Cannot drop more elements than present in the queue");
|
|
7916
|
+
}
|
|
7917
|
+
state.splice(0, quantity || 1);
|
|
7918
|
+
},
|
|
7919
|
+
take(quantity) {
|
|
7920
|
+
if (quantity && quantity > state.length) {
|
|
7921
|
+
throw new Error("Cannot take more elements than present in the queue");
|
|
7922
|
+
}
|
|
7923
|
+
const result2 = state.slice(0, quantity || 1);
|
|
7924
|
+
state.splice(0, quantity || 1);
|
|
7925
|
+
return result2;
|
|
7926
|
+
},
|
|
7927
|
+
*[Symbol.iterator]() {
|
|
7928
|
+
for (let i = 0; i < state.length; i++) {
|
|
7929
|
+
yield state[i];
|
|
7930
|
+
}
|
|
7931
|
+
}
|
|
7932
|
+
};
|
|
8071
7933
|
}
|
|
8072
|
-
function
|
|
8073
|
-
return
|
|
7934
|
+
function createFifoQueue(...list2) {
|
|
7935
|
+
return queue([...list2]);
|
|
8074
7936
|
}
|
|
8075
|
-
function
|
|
8076
|
-
return
|
|
7937
|
+
function queue2(state) {
|
|
7938
|
+
return {
|
|
7939
|
+
queue: state,
|
|
7940
|
+
size: state.length,
|
|
7941
|
+
isEmpty() {
|
|
7942
|
+
return state.length === 0;
|
|
7943
|
+
},
|
|
7944
|
+
push(...add) {
|
|
7945
|
+
state.push(...add);
|
|
7946
|
+
},
|
|
7947
|
+
drop(quantity) {
|
|
7948
|
+
state.splice(-quantity);
|
|
7949
|
+
},
|
|
7950
|
+
clear() {
|
|
7951
|
+
state.slice(0, 0);
|
|
7952
|
+
},
|
|
7953
|
+
drain() {
|
|
7954
|
+
const old_state = [...state];
|
|
7955
|
+
state.slice(0, 0);
|
|
7956
|
+
return old_state;
|
|
7957
|
+
},
|
|
7958
|
+
take(quantity) {
|
|
7959
|
+
const result2 = state.slice(-quantity);
|
|
7960
|
+
state.splice(-quantity);
|
|
7961
|
+
return result2;
|
|
7962
|
+
},
|
|
7963
|
+
*[Symbol.iterator]() {
|
|
7964
|
+
for (let i = state.length - 1; i >= 0; i--) {
|
|
7965
|
+
yield state[i];
|
|
7966
|
+
}
|
|
7967
|
+
}
|
|
7968
|
+
};
|
|
8077
7969
|
}
|
|
8078
|
-
function
|
|
8079
|
-
return
|
|
7970
|
+
function createLifoQueue(...list2) {
|
|
7971
|
+
return queue2([...list2]);
|
|
8080
7972
|
}
|
|
8081
|
-
|
|
8082
|
-
|
|
7973
|
+
var scalarToToken = identity({
|
|
7974
|
+
string: "<<string>>",
|
|
7975
|
+
number: "<<number>>",
|
|
7976
|
+
boolean: "<<boolean>>",
|
|
7977
|
+
true: "<<true>>",
|
|
7978
|
+
false: "<<false>>",
|
|
7979
|
+
null: "<<null>>",
|
|
7980
|
+
undefined: "<<undefined>>",
|
|
7981
|
+
unknown: "<<unknown>>",
|
|
7982
|
+
any: "<<any>>",
|
|
7983
|
+
never: "<<never>>"
|
|
7984
|
+
});
|
|
7985
|
+
function stringLiteral(str) {
|
|
7986
|
+
return stripAfter(stripBefore(str, "string("), ")");
|
|
8083
7987
|
}
|
|
8084
|
-
function
|
|
8085
|
-
return
|
|
7988
|
+
function numericLiteral(str) {
|
|
7989
|
+
return stripAfter(stripBefore(str, "number("), ")");
|
|
8086
7990
|
}
|
|
8087
|
-
function
|
|
8088
|
-
|
|
7991
|
+
function handleOptional(token) {
|
|
7992
|
+
const bare = stripTrailing(stripLeading(token, "Opt<"), ">");
|
|
7993
|
+
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>>`;
|
|
8089
7994
|
}
|
|
8090
|
-
function
|
|
8091
|
-
return
|
|
7995
|
+
function simpleScalarTokenToTypeToken(val) {
|
|
7996
|
+
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>>`;
|
|
8092
7997
|
}
|
|
8093
|
-
function
|
|
8094
|
-
return
|
|
7998
|
+
function unionNode(node) {
|
|
7999
|
+
return isNumberLike(node) ? `<<number::${node}>>` : isBooleanLike(node) ? `<<${node}>>` : isSimpleContainerToken(node) ? simpleContainerTokenToTypeToken(node) : isSimpleScalarToken(node) ? simpleScalarToken(node) : `<<string::${node}>>`;
|
|
8095
8000
|
}
|
|
8096
|
-
function
|
|
8097
|
-
return
|
|
8001
|
+
function union2(nodes) {
|
|
8002
|
+
return Array.isArray(nodes) ? nodes.map((n) => unionNode(n)) : nodes.includes(",") ? nodes.split(/,\s?/).map((n) => unionNode(n)).join(", ") : unionNode(nodes);
|
|
8098
8003
|
}
|
|
8099
|
-
|
|
8100
|
-
|
|
8004
|
+
var stripUnion = stripSurround("Union(", ")");
|
|
8005
|
+
function simpleUnionTokenToTypeToken(val) {
|
|
8006
|
+
return val.startsWith(`Union(`) && val.endsWith(`)`) ? `<<union::[ ${union2(stripUnion(val))} ]>>` : Never2;
|
|
8101
8007
|
}
|
|
8102
|
-
function
|
|
8103
|
-
return isString(val) && TARGET_DNS2.some((i) => val.startsWith(`https://${i}`));
|
|
8008
|
+
function simpleContainerTokenToTypeToken(_val) {
|
|
8104
8009
|
}
|
|
8105
|
-
function
|
|
8106
|
-
return
|
|
8010
|
+
function asTypeToken(_val) {
|
|
8011
|
+
return "not ready";
|
|
8107
8012
|
}
|
|
8108
|
-
function
|
|
8109
|
-
return
|
|
8013
|
+
function addToken(token, ...params) {
|
|
8014
|
+
return `<<${token}${params.length > 0 ? `::${params.join("::")}` : ""}>>`;
|
|
8110
8015
|
}
|
|
8111
|
-
function
|
|
8112
|
-
return
|
|
8016
|
+
function boolean(literal2) {
|
|
8017
|
+
return isDefined(literal2) ? isTrue(literal2) ? addToken("true") : isFalse(literal2) ? addToken("false") : addToken("boolean") : addToken("boolean");
|
|
8113
8018
|
}
|
|
8114
|
-
|
|
8115
|
-
|
|
8019
|
+
var unknown = () => "<<unknown>>";
|
|
8020
|
+
var undefinedType = () => "<<undefined>>";
|
|
8021
|
+
var nullType = () => "<<null>>";
|
|
8022
|
+
function fn(..._args) {
|
|
8023
|
+
return {
|
|
8024
|
+
returns: (_rtn) => ({
|
|
8025
|
+
addProperties: (_kv) => {
|
|
8026
|
+
return null;
|
|
8027
|
+
},
|
|
8028
|
+
done: () => {
|
|
8029
|
+
return null;
|
|
8030
|
+
}
|
|
8031
|
+
}),
|
|
8032
|
+
done: () => {
|
|
8033
|
+
const result2 = null;
|
|
8034
|
+
return result2;
|
|
8035
|
+
}
|
|
8036
|
+
};
|
|
8116
8037
|
}
|
|
8117
|
-
function
|
|
8118
|
-
return
|
|
8038
|
+
function dictionary(_obj) {
|
|
8039
|
+
return null;
|
|
8119
8040
|
}
|
|
8120
|
-
function
|
|
8121
|
-
return
|
|
8041
|
+
function tuple2(..._elements) {
|
|
8042
|
+
return null;
|
|
8122
8043
|
}
|
|
8123
|
-
function
|
|
8124
|
-
|
|
8044
|
+
function regexToken(re, ...rep) {
|
|
8045
|
+
let exp = "";
|
|
8046
|
+
if (isString(re)) {
|
|
8047
|
+
try {
|
|
8048
|
+
const test = new RegExp(re);
|
|
8049
|
+
if (!isRegExp(test)) {
|
|
8050
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
8051
|
+
err.name = "InvalidRegEx";
|
|
8052
|
+
throw err;
|
|
8053
|
+
} else {
|
|
8054
|
+
exp = re;
|
|
8055
|
+
}
|
|
8056
|
+
} catch {
|
|
8057
|
+
const err = new Error(`Invalid RegEx passed into regexToken(${re}, ${JSON.stringify(rep)})!`);
|
|
8058
|
+
err.name = "InvalidRegEx";
|
|
8059
|
+
throw err;
|
|
8060
|
+
}
|
|
8061
|
+
} else if (isRegExp(re)) {
|
|
8062
|
+
exp = re.toString();
|
|
8063
|
+
}
|
|
8064
|
+
const token = `<<string-set::regexp::${encodeURIComponent(exp)}>>`;
|
|
8065
|
+
return token;
|
|
8125
8066
|
}
|
|
8126
|
-
|
|
8127
|
-
|
|
8128
|
-
|
|
8129
|
-
|
|
8067
|
+
function addSingleton(token, api2) {
|
|
8068
|
+
return (...literals) => {
|
|
8069
|
+
return literals.length === 0 ? api2 || addToken(token) : literals.length === 1 ? addToken(token, literals[0]) : addToken(
|
|
8070
|
+
"union",
|
|
8071
|
+
literals.map((l) => addToken(token, `${l}`)).join(",")
|
|
8072
|
+
);
|
|
8073
|
+
};
|
|
8130
8074
|
}
|
|
8131
|
-
|
|
8132
|
-
|
|
8075
|
+
var stringApi = {
|
|
8076
|
+
startsWith: (startsWith2) => addToken(`string-set`, `startsWith::${startsWith2}`),
|
|
8077
|
+
endsWith: (endsWith2) => addToken(`string-set`, `endsWith::${endsWith2}`),
|
|
8078
|
+
zip: () => addToken("string-set", "Zip5"),
|
|
8079
|
+
zipPlus4: () => addToken("string-set", "Zip5_4"),
|
|
8080
|
+
zipCode: () => addToken("string-set", "ZipCode"),
|
|
8081
|
+
militaryTime: (resolution) => {
|
|
8082
|
+
return addToken(
|
|
8083
|
+
"string-set",
|
|
8084
|
+
"militaryTime",
|
|
8085
|
+
resolution || "HH:MM"
|
|
8086
|
+
);
|
|
8087
|
+
},
|
|
8088
|
+
civilianTime: (resolution) => {
|
|
8089
|
+
return addToken(
|
|
8090
|
+
"string-set",
|
|
8091
|
+
"militaryTime",
|
|
8092
|
+
resolution || "HH:MM"
|
|
8093
|
+
);
|
|
8094
|
+
},
|
|
8095
|
+
numericString: () => addToken("string-set", "numeric"),
|
|
8096
|
+
ipv4Address: () => addToken("string-set", "ipv4Address"),
|
|
8097
|
+
ipv6Address: () => addToken("string-set", "ipv6Address"),
|
|
8098
|
+
regex: (exp, ...literalRepresentation) => {
|
|
8099
|
+
const token = regexToken(exp, ...literalRepresentation);
|
|
8100
|
+
return token;
|
|
8101
|
+
},
|
|
8102
|
+
done: () => addToken("string")
|
|
8103
|
+
};
|
|
8104
|
+
var string22 = addSingleton("string", stringApi);
|
|
8105
|
+
var number = addSingleton("number");
|
|
8106
|
+
function union3(...elements) {
|
|
8107
|
+
const result2 = elements.map((_el) => {
|
|
8108
|
+
});
|
|
8109
|
+
return result2;
|
|
8133
8110
|
}
|
|
8134
|
-
function
|
|
8135
|
-
return
|
|
8111
|
+
function record(_key, _value) {
|
|
8112
|
+
return null;
|
|
8136
8113
|
}
|
|
8137
|
-
function
|
|
8138
|
-
return
|
|
8114
|
+
function array(_type) {
|
|
8115
|
+
return null;
|
|
8139
8116
|
}
|
|
8140
|
-
function
|
|
8141
|
-
return
|
|
8117
|
+
function set(_type) {
|
|
8118
|
+
return null;
|
|
8142
8119
|
}
|
|
8143
|
-
function
|
|
8144
|
-
return
|
|
8120
|
+
function map(_key, _value) {
|
|
8121
|
+
return null;
|
|
8145
8122
|
}
|
|
8146
|
-
function
|
|
8147
|
-
return
|
|
8123
|
+
function weakMap(_key, _value) {
|
|
8124
|
+
return null;
|
|
8148
8125
|
}
|
|
8149
|
-
function
|
|
8150
|
-
return
|
|
8126
|
+
function isAddOrDone(val) {
|
|
8127
|
+
return isObject(val) && hasKeys("add", "done") && typeof val.done === "function" && typeof val.add === "function";
|
|
8151
8128
|
}
|
|
8152
|
-
|
|
8153
|
-
|
|
8129
|
+
var ShapeApiImplementation = {
|
|
8130
|
+
string: string22,
|
|
8131
|
+
number,
|
|
8132
|
+
boolean,
|
|
8133
|
+
unknown,
|
|
8134
|
+
undefined: undefinedType,
|
|
8135
|
+
null: nullType,
|
|
8136
|
+
union: union3,
|
|
8137
|
+
fn,
|
|
8138
|
+
record,
|
|
8139
|
+
array,
|
|
8140
|
+
set,
|
|
8141
|
+
map,
|
|
8142
|
+
weakMap,
|
|
8143
|
+
dictionary,
|
|
8144
|
+
tuple: tuple2
|
|
8145
|
+
};
|
|
8146
|
+
function shape(cb) {
|
|
8147
|
+
const rtn = cb(ShapeApiImplementation);
|
|
8148
|
+
return handleDoneFn(
|
|
8149
|
+
isAddOrDone(rtn) ? rtn.done() : rtn
|
|
8150
|
+
);
|
|
8154
8151
|
}
|
|
8155
|
-
function
|
|
8156
|
-
return isString(
|
|
8152
|
+
function isShape(v) {
|
|
8153
|
+
return !!(isString(v) && v.startsWith("<<") && v.endsWith(">>") && SHAPE_PREFIXES2.some((i) => v.startsWith(`<<${i}`)));
|
|
8157
8154
|
}
|
|
8158
|
-
function
|
|
8159
|
-
|
|
8155
|
+
function asDefineObject(defn) {
|
|
8156
|
+
const result2 = Object.keys(defn).reduce(
|
|
8157
|
+
(acc, i) => isSimpleToken(defn[i]) ? { ...acc, [i]: asType(defn[i]) } : isDoneFn(defn[i]) ? {
|
|
8158
|
+
...acc,
|
|
8159
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
8160
|
+
} : isFunction(defn[i]) ? {
|
|
8161
|
+
...acc,
|
|
8162
|
+
[i]: handleDoneFn(defn[i](ShapeApiImplementation))
|
|
8163
|
+
} : Never2,
|
|
8164
|
+
{}
|
|
8165
|
+
);
|
|
8166
|
+
return result2;
|
|
8160
8167
|
}
|
|
8161
|
-
function
|
|
8162
|
-
return
|
|
8168
|
+
function asType(...token) {
|
|
8169
|
+
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);
|
|
8163
8170
|
}
|
|
8164
|
-
function
|
|
8165
|
-
return
|
|
8171
|
+
function asStringLiteral(...values) {
|
|
8172
|
+
return values.map((i) => i);
|
|
8166
8173
|
}
|
|
8167
|
-
|
|
8168
|
-
|
|
8174
|
+
var choices = "NOT READY";
|
|
8175
|
+
function doesExtend(type) {
|
|
8176
|
+
return (val) => {
|
|
8177
|
+
let response = false;
|
|
8178
|
+
if (isString(val)) {
|
|
8179
|
+
if (type === "string") {
|
|
8180
|
+
response = true;
|
|
8181
|
+
}
|
|
8182
|
+
if (type.startsWith("string(")) {
|
|
8183
|
+
const literals = stripAfter(
|
|
8184
|
+
stripBefore(type, "string("),
|
|
8185
|
+
")"
|
|
8186
|
+
).split(/,\s*/);
|
|
8187
|
+
if (literals.includes(val)) {
|
|
8188
|
+
response = true;
|
|
8189
|
+
}
|
|
8190
|
+
}
|
|
8191
|
+
}
|
|
8192
|
+
if (isNumber(val)) {
|
|
8193
|
+
if (type === "number") {
|
|
8194
|
+
response = true;
|
|
8195
|
+
}
|
|
8196
|
+
if (type.startsWith("number(")) {
|
|
8197
|
+
const literals = stripAfter(
|
|
8198
|
+
stripBefore(type, "number("),
|
|
8199
|
+
")"
|
|
8200
|
+
).split(/,\s*/).map(Number);
|
|
8201
|
+
if (literals.includes(val)) {
|
|
8202
|
+
response = true;
|
|
8203
|
+
}
|
|
8204
|
+
}
|
|
8205
|
+
}
|
|
8206
|
+
if (isNull(val) && (type === "null" || type === "Opt<null>")) {
|
|
8207
|
+
response = true;
|
|
8208
|
+
}
|
|
8209
|
+
if (isUndefined(val) && (type === "undefined" || type.startsWith("Opt<"))) {
|
|
8210
|
+
response = true;
|
|
8211
|
+
}
|
|
8212
|
+
if (isBoolean(val)) {
|
|
8213
|
+
if (type === "boolean") {
|
|
8214
|
+
response = true;
|
|
8215
|
+
}
|
|
8216
|
+
if (type === "true" && val === true || type === "false" && val === false) {
|
|
8217
|
+
response = true;
|
|
8218
|
+
}
|
|
8219
|
+
}
|
|
8220
|
+
if (isNarrowableObject(val)) {
|
|
8221
|
+
if (type === "Dict" || type === "Dict<string, unknown>") {
|
|
8222
|
+
response = true;
|
|
8223
|
+
}
|
|
8224
|
+
if (startsWith("Dict<")(type)) {
|
|
8225
|
+
const match = infer("Dict<{{infer key}}, {{infer value}}>")(type);
|
|
8226
|
+
if (match) {
|
|
8227
|
+
const { value } = match;
|
|
8228
|
+
const isOpt = value.includes(`Opt<`);
|
|
8229
|
+
const values = objectValues(val);
|
|
8230
|
+
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>") {
|
|
8231
|
+
response = true;
|
|
8232
|
+
}
|
|
8233
|
+
}
|
|
8234
|
+
}
|
|
8235
|
+
}
|
|
8236
|
+
if (isArray(val)) {
|
|
8237
|
+
if (type === "Array" || type === "Array<unknown>") {
|
|
8238
|
+
return true;
|
|
8239
|
+
}
|
|
8240
|
+
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)) {
|
|
8241
|
+
response = true;
|
|
8242
|
+
}
|
|
8243
|
+
}
|
|
8244
|
+
if (isMap(val)) {
|
|
8245
|
+
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)) {
|
|
8246
|
+
response = true;
|
|
8247
|
+
}
|
|
8248
|
+
}
|
|
8249
|
+
if (isSetContainer(val)) {
|
|
8250
|
+
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))) {
|
|
8251
|
+
response = true;
|
|
8252
|
+
}
|
|
8253
|
+
}
|
|
8254
|
+
return response;
|
|
8255
|
+
};
|
|
8169
8256
|
}
|
|
8170
|
-
function
|
|
8171
|
-
|
|
8172
|
-
|
|
8173
|
-
|
|
8257
|
+
function ip6Prefix(...groups) {
|
|
8258
|
+
const empty = addToken("string");
|
|
8259
|
+
const count = 4 - groups.length;
|
|
8260
|
+
const fillIn = [];
|
|
8261
|
+
for (let index = 0; index < count; index++) {
|
|
8262
|
+
fillIn.push(empty);
|
|
8174
8263
|
}
|
|
8175
|
-
return
|
|
8264
|
+
return [
|
|
8265
|
+
"<<string::",
|
|
8266
|
+
[
|
|
8267
|
+
groups.join(":"),
|
|
8268
|
+
fillIn.join(":")
|
|
8269
|
+
].join(":"),
|
|
8270
|
+
">>"
|
|
8271
|
+
].join("");
|
|
8176
8272
|
}
|
|
8177
|
-
function
|
|
8178
|
-
const
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8273
|
+
function createProxy(...initialize) {
|
|
8274
|
+
const state = initialize;
|
|
8275
|
+
state.id = null;
|
|
8276
|
+
const proxy = new Proxy(state, {});
|
|
8277
|
+
Object.defineProperty(proxy, "id", {
|
|
8278
|
+
enumerable: false
|
|
8183
8279
|
});
|
|
8184
|
-
return
|
|
8185
|
-
}
|
|
8186
|
-
function fromKeyValue(kvs) {
|
|
8187
|
-
const obj = {};
|
|
8188
|
-
for (const kv of kvs) {
|
|
8189
|
-
obj[kv.key] = kv.value;
|
|
8190
|
-
}
|
|
8191
|
-
return obj;
|
|
8192
|
-
}
|
|
8193
|
-
function intersect(value, _intersectedWith) {
|
|
8194
|
-
return value;
|
|
8195
|
-
}
|
|
8196
|
-
function ip6GroupExpansion(ip) {
|
|
8197
|
-
return stripTrailing(ip.replaceAll("::", ":0000:"), ":");
|
|
8198
|
-
}
|
|
8199
|
-
function jsonValue(val) {
|
|
8200
|
-
return isNumberLike(val) ? Number(val) : val === "true" ? true : val === "false" ? false : `"${val}"`;
|
|
8201
|
-
}
|
|
8202
|
-
function jsonValues(...val) {
|
|
8203
|
-
return val.map((i) => jsonValue(i));
|
|
8204
|
-
}
|
|
8205
|
-
function lookupAlpha2Code(code, prop) {
|
|
8206
|
-
const found = ISO3166_12.find((i) => i.alpha2 === code);
|
|
8207
|
-
return found ? found[prop] : void 0;
|
|
8208
|
-
}
|
|
8209
|
-
function lookupAlpha3Code(code, prop) {
|
|
8210
|
-
const found = ISO3166_12.find((i) => i.alpha3 === code);
|
|
8211
|
-
return found ? found[prop] : void 0;
|
|
8212
|
-
}
|
|
8213
|
-
function lookupName(name, prop) {
|
|
8214
|
-
const found = ISO3166_12.find((i) => i.name === name);
|
|
8215
|
-
return found ? found[prop] : void 0;
|
|
8216
|
-
}
|
|
8217
|
-
function lookupNumericCode(code, prop) {
|
|
8218
|
-
let num = isNumber(code) ? `${code}` : code;
|
|
8219
|
-
if (num.length === 1) {
|
|
8220
|
-
num = `00${num}`;
|
|
8221
|
-
} else if (num.length === 2) {
|
|
8222
|
-
num = `0${num}`;
|
|
8223
|
-
}
|
|
8224
|
-
const found = ISO3166_12.find((i) => i.countryCode === num);
|
|
8225
|
-
return found ? found[prop] : void 0;
|
|
8226
|
-
}
|
|
8227
|
-
function lookupCountryName(code) {
|
|
8228
|
-
const uc = uppercase(code);
|
|
8229
|
-
return isNumberLike(code) ? lookupNumericCode(code, "name") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "name") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "name") : void 0;
|
|
8280
|
+
return proxy;
|
|
8230
8281
|
}
|
|
8231
|
-
function
|
|
8232
|
-
|
|
8233
|
-
return isNumberLike(code) ? lookupNumericCode(code, "alpha2") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "alpha2") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "alpha2") : isIso3166CountryName(code) ? lookupName(code, "alpha2") : void 0;
|
|
8282
|
+
function list(...init) {
|
|
8283
|
+
return init.length === 1 && isArray(init[0]) ? createProxy(...init[0]) : createProxy(...init);
|
|
8234
8284
|
}
|
|
8235
|
-
function
|
|
8236
|
-
|
|
8237
|
-
|
|
8285
|
+
function singletonApi(kind) {
|
|
8286
|
+
return {
|
|
8287
|
+
wide: () => `<<${kind}>>`,
|
|
8288
|
+
literal: (val) => `<<${kind}::${val}>>`
|
|
8289
|
+
};
|
|
8238
8290
|
}
|
|
8239
|
-
function
|
|
8240
|
-
|
|
8241
|
-
return isNumberLike(token) ? lookupNumericCode(token, "countryCode") : isIso3166Alpha2(uc) ? lookupAlpha2Code(uc, "countryCode") : isIso3166Alpha3(uc) ? lookupAlpha3Code(uc, "countryCode") : isIso3166CountryName(token) ? lookupName(token, "countryCode") : void 0;
|
|
8291
|
+
function setApi(_variant) {
|
|
8292
|
+
return null;
|
|
8242
8293
|
}
|
|
8243
|
-
function
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
map: (from) => {
|
|
8247
|
-
return from.map(fn2);
|
|
8248
|
-
}
|
|
8294
|
+
function fnReturnsApi(variant, _params, returns) {
|
|
8295
|
+
return isSet(returns) ? null : (_rtn) => {
|
|
8296
|
+
return isSet(returns) ? `<<${variant}::>>` : null;
|
|
8249
8297
|
};
|
|
8250
|
-
return createFnWithPropsExplicit(fn2, props);
|
|
8251
8298
|
}
|
|
8252
|
-
function
|
|
8253
|
-
return (
|
|
8254
|
-
|
|
8255
|
-
return Object.keys(map2).reduce(
|
|
8256
|
-
(acc, key) => {
|
|
8257
|
-
const val = map2[key];
|
|
8258
|
-
return {
|
|
8259
|
-
...acc,
|
|
8260
|
-
[key]: isFunction(val) ? val(input) : val
|
|
8261
|
-
};
|
|
8262
|
-
},
|
|
8263
|
-
{}
|
|
8264
|
-
);
|
|
8265
|
-
};
|
|
8266
|
-
return fn2;
|
|
8299
|
+
function fnParamsApi(variant, params, _returns) {
|
|
8300
|
+
return isSet(params) ? null : (params2) => {
|
|
8301
|
+
return isSet(params2) ? `<<${variant}::>>` : null;
|
|
8267
8302
|
};
|
|
8268
8303
|
}
|
|
8269
|
-
function
|
|
8270
|
-
return (
|
|
8271
|
-
return asMapper(fn2);
|
|
8272
|
-
};
|
|
8304
|
+
function fnDoneApi(variant, params, returns) {
|
|
8305
|
+
return isUnset(params) && isUnset(returns) ? `<<` : ``;
|
|
8273
8306
|
}
|
|
8274
|
-
function
|
|
8307
|
+
function fnTokenClosure(kind, params, returns) {
|
|
8275
8308
|
return {
|
|
8276
|
-
|
|
8277
|
-
|
|
8309
|
+
done: fnDoneApi(kind, params, returns),
|
|
8310
|
+
params: fnParamsApi(kind, params, returns),
|
|
8311
|
+
returns: fnReturnsApi(kind, params, returns)
|
|
8278
8312
|
};
|
|
8279
8313
|
}
|
|
8280
|
-
function
|
|
8281
|
-
return
|
|
8314
|
+
function createTypeToken(kind) {
|
|
8315
|
+
return isAtomicKind(kind) ? `<<${kind}>>` : isSingletonKind(kind) ? singletonApi(kind) : isSetBasedKind(kind) ? setApi(kind) : isFnBasedKind(kind) ? handleDoneFn(fnTokenClosure(kind, unset, unset)) : "<<never>>";
|
|
8282
8316
|
}
|
|
8283
|
-
function
|
|
8284
|
-
return
|
|
8317
|
+
function fromDefineObject(defn) {
|
|
8318
|
+
return defn;
|
|
8285
8319
|
}
|
|
8286
|
-
function
|
|
8287
|
-
|
|
8320
|
+
function getTokenKind(token) {
|
|
8321
|
+
const bare = stripSurround("<<", ">>")(token);
|
|
8322
|
+
const parts = bare.split("::");
|
|
8323
|
+
const kind = parts.pop();
|
|
8324
|
+
return kind;
|
|
8288
8325
|
}
|
|
8289
|
-
|
|
8326
|
+
var simpleToken = (token) => token;
|
|
8327
|
+
var simpleScalarToken = (token) => token;
|
|
8328
|
+
var simpleContainerToken = (token) => token;
|
|
8329
|
+
function simpleScalarType(token) {
|
|
8330
|
+
const value = simpleScalarToken(token);
|
|
8290
8331
|
return value;
|
|
8291
8332
|
}
|
|
8292
|
-
function
|
|
8333
|
+
function simpleContainerType(token) {
|
|
8334
|
+
const value = simpleContainerToken(token);
|
|
8293
8335
|
return value;
|
|
8294
8336
|
}
|
|
8295
|
-
function
|
|
8337
|
+
function simpleType(token) {
|
|
8338
|
+
const value = isSimpleScalarToken(token) ? simpleScalarType(token) : isSimpleContainerToken(token) ? simpleContainerToken(token) : Never2;
|
|
8296
8339
|
return value;
|
|
8297
8340
|
}
|
|
8298
|
-
function
|
|
8299
|
-
|
|
8300
|
-
}
|
|
8301
|
-
function sortKeyApi(order) {
|
|
8302
|
-
return {
|
|
8303
|
-
order,
|
|
8304
|
-
toTop: (...keys) => sortKeyApi(
|
|
8305
|
-
[
|
|
8306
|
-
...keys,
|
|
8307
|
-
...order.filter((i) => !keys.includes(i))
|
|
8308
|
-
]
|
|
8309
|
-
),
|
|
8310
|
-
toBottom: (...keys) => sortKeyApi(
|
|
8311
|
-
[
|
|
8312
|
-
...order.filter((i) => !keys.includes(i)),
|
|
8313
|
-
...keys
|
|
8314
|
-
]
|
|
8315
|
-
),
|
|
8316
|
-
done: () => order
|
|
8317
|
-
};
|
|
8318
|
-
}
|
|
8319
|
-
function toKeyValue(obj, sort) {
|
|
8320
|
-
let keys = keysOf(obj);
|
|
8321
|
-
const tuple3 = [];
|
|
8322
|
-
if (sort) {
|
|
8323
|
-
keys = handleDoneFn(sort(sortKeyApi(keys)));
|
|
8324
|
-
}
|
|
8341
|
+
function hasOverlappingKeys(a, b) {
|
|
8342
|
+
const keys = Object.keys(a);
|
|
8325
8343
|
for (const k of keys) {
|
|
8326
|
-
|
|
8344
|
+
if (k in b) {
|
|
8345
|
+
return true;
|
|
8346
|
+
}
|
|
8327
8347
|
}
|
|
8328
|
-
return
|
|
8348
|
+
return false;
|
|
8329
8349
|
}
|
|
8330
|
-
function
|
|
8331
|
-
|
|
8332
|
-
|
|
8333
|
-
|
|
8334
|
-
case "string":
|
|
8335
|
-
return Number(val);
|
|
8336
|
-
case "boolean":
|
|
8337
|
-
return val ? 1 : 0;
|
|
8338
|
-
default:
|
|
8339
|
-
throw new Error(`${typeof val} is an invalid scalar type to convert to a number!`);
|
|
8350
|
+
function uniqueKeys(left, right) {
|
|
8351
|
+
const isNumeric = !!(isArray(left) && isArray(right));
|
|
8352
|
+
if (isArray(left) && !isArray(right) || isArray(right) && !isArray(left)) {
|
|
8353
|
+
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!");
|
|
8340
8354
|
}
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
}
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
return
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
function union3(..._options) {
|
|
8354
|
-
return (value) => value;
|
|
8355
|
-
}
|
|
8356
|
-
function unionize(value, _inUnionWith) {
|
|
8357
|
-
return value;
|
|
8355
|
+
const l = isNumeric ? Object.keys(left).map((i) => Number(i)) : Object.keys(left);
|
|
8356
|
+
const r = isNumeric ? Object.keys(right).map((i) => Number(i)) : Object.keys(right);
|
|
8357
|
+
if (isNumeric) {
|
|
8358
|
+
throw new Error("uniqueKeys does not yet work with tuples");
|
|
8359
|
+
}
|
|
8360
|
+
const leftKeys = l.filter((i) => !r.includes(i));
|
|
8361
|
+
const rightKeys = r.filter((i) => !l.includes(i));
|
|
8362
|
+
return [
|
|
8363
|
+
"LeftRight",
|
|
8364
|
+
leftKeys,
|
|
8365
|
+
rightKeys
|
|
8366
|
+
];
|
|
8358
8367
|
}
|
|
8359
8368
|
function asVueRef(value) {
|
|
8360
8369
|
return {
|
|
@@ -8807,6 +8816,7 @@ var ExifSaturation = /* @__PURE__ */ ((ExifSaturation2) => {
|
|
|
8807
8816
|
errCondition,
|
|
8808
8817
|
filter,
|
|
8809
8818
|
filterEmpty,
|
|
8819
|
+
filterUndefined,
|
|
8810
8820
|
find,
|
|
8811
8821
|
fnMeta,
|
|
8812
8822
|
fromDefineObject,
|