@wistia/wistia-player 0.7.31 → 0.8.0
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/CHANGELOG.md +31 -0
- package/dist/types/embeds/carousel/CarouselApi.d.ts +1 -1
- package/dist/types/embeds/carousel/CarouselApi.d.ts.map +1 -1
- package/dist/types/embeds/cta/domain/attributes.d.ts +1 -1
- package/dist/types/embeds/cta/domain/attributes.d.ts.map +1 -1
- package/dist/types/embeds/emojiReactions/types.d.ts +41 -0
- package/dist/types/embeds/emojiReactions/types.d.ts.map +1 -0
- package/dist/types/embeds/forms/components/FormFields/types.d.ts +1 -1
- package/dist/types/embeds/forms/components/FormFields/types.d.ts.map +1 -1
- package/dist/types/embeds/forms/types.d.ts +1 -1
- package/dist/types/embeds/forms/types.d.ts.map +1 -1
- package/dist/types/embeds/forms/utilities/FormApi.d.ts +1 -1
- package/dist/types/embeds/forms/utilities/FormApi.d.ts.map +1 -1
- package/dist/types/embeds/shared/components/HardWall/HardWall.d.ts +1 -1
- package/dist/types/embeds/shared/components/HardWall/HardWall.d.ts.map +1 -1
- package/dist/types/embeds/shared/components/HardWall/HardWallWithPasswordForm.d.ts +1 -1
- package/dist/types/embeds/shared/components/HardWall/HardWallWithPasswordForm.d.ts.map +1 -1
- package/dist/types/embeds/shared/components/HardWall/PasswordForm.d.ts +1 -1
- package/dist/types/embeds/shared/components/HardWall/PasswordForm.d.ts.map +1 -1
- package/dist/types/embeds/shared/components/HardWall/hardWallBorderRadius.d.ts +1 -1
- package/dist/types/embeds/shared/components/HardWall/hardWallBorderRadius.d.ts.map +1 -1
- package/dist/types/embeds/shared/getLogoAltText.d.ts +1 -1
- package/dist/types/embeds/shared/getLogoAltText.d.ts.map +1 -1
- package/dist/types/embeds/shared/playlists/playlist-methods.d.ts +1 -1
- package/dist/types/embeds/shared/playlists/playlist-methods.d.ts.map +1 -1
- package/dist/types/embeds/wistiaPlayer/WistiaPlayer.d.ts.map +1 -1
- package/dist/types/types/EmbedOptions.d.ts +1 -0
- package/dist/types/types/EmbedOptions.d.ts.map +1 -1
- package/dist/types/types/carousel.d.ts +1 -1
- package/dist/types/types/carousel.d.ts.map +1 -1
- package/dist/types/types/media-data.d.ts +1 -1
- package/dist/types/types/media-data.d.ts.map +1 -1
- package/dist/types/types/player-api-types.d.ts +15 -1
- package/dist/types/types/player-api-types.d.ts.map +1 -1
- package/dist/types/types/plugins.d.ts +11 -0
- package/dist/types/types/plugins.d.ts.map +1 -1
- package/dist/types/types/poster.d.ts +1 -1
- package/dist/types/types/poster.d.ts.map +1 -1
- package/dist/wistia-player.js +1929 -112
- package/dist/wistia-player.js.map +1 -1
- package/package.json +1 -1
package/dist/wistia-player.js
CHANGED
|
@@ -1648,7 +1648,7 @@ const getSubdomainSuffixHostname = (subdomain = 'app') => {
|
|
|
1648
1648
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1649
1649
|
/* harmony export */ V: () => (/* binding */ isMediaDataError)
|
|
1650
1650
|
/* harmony export */ });
|
|
1651
|
-
/* harmony import */ var
|
|
1651
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
1652
1652
|
var _objectHasOwn = function (object, property) {
|
|
1653
1653
|
if (typeof object === 'undefined' || object === null) {
|
|
1654
1654
|
throw new TypeError('Cannot convert undefined or null to object');
|
|
@@ -1657,7 +1657,7 @@ var _objectHasOwn = function (object, property) {
|
|
|
1657
1657
|
};
|
|
1658
1658
|
|
|
1659
1659
|
const isMediaDataError = mediaData => {
|
|
1660
|
-
if (!_objectHasOwn(mediaData, 'error') || (0,
|
|
1660
|
+
if (!_objectHasOwn(mediaData, 'error') || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(mediaData.error)) {
|
|
1661
1661
|
return false;
|
|
1662
1662
|
}
|
|
1663
1663
|
if (mediaData.error === 'true' || mediaData.error === true) {
|
|
@@ -1680,7 +1680,7 @@ const isMediaDataError = mediaData => {
|
|
|
1680
1680
|
/* harmony export */ ui: () => (/* binding */ adjustColorForProperContrast)
|
|
1681
1681
|
/* harmony export */ });
|
|
1682
1682
|
/* unused harmony exports generateColorPalette, getBestColorForShape, getHexWithoutHash, getAudioPlayerIconColor, getBackgroundColorFromPlayerColor, isDarkColor, isVeryDarkColor, isLightColor, isMidToneColor */
|
|
1683
|
-
/* harmony import */ var
|
|
1683
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
1684
1684
|
/* harmony import */ var _color_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5417);
|
|
1685
1685
|
/* harmony import */ var _sentryUtils_ts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2621);
|
|
1686
1686
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
@@ -1705,13 +1705,13 @@ const colorContrastRatiosByShape = {
|
|
|
1705
1705
|
const rgbToHsl = color => {
|
|
1706
1706
|
let colorArray = color;
|
|
1707
1707
|
if (color instanceof _color_js__WEBPACK_IMPORTED_MODULE_1__/* .Color */ .Q1) {
|
|
1708
|
-
if ((0,
|
|
1708
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(color.r) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(color.g) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(color.b)) {
|
|
1709
1709
|
throw new Error('Color does not contain required RGB values');
|
|
1710
1710
|
}
|
|
1711
1711
|
colorArray = [color.r, color.g, color.b];
|
|
1712
1712
|
} else if (typeof color === 'string') {
|
|
1713
1713
|
const colorInstance = new _color_js__WEBPACK_IMPORTED_MODULE_1__/* .Color */ .Q1(color);
|
|
1714
|
-
if ((0,
|
|
1714
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(colorInstance.r) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(colorInstance.g) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(colorInstance.b)) {
|
|
1715
1715
|
throw new Error('Color does not contain required RGB values');
|
|
1716
1716
|
}
|
|
1717
1717
|
colorArray = [colorInstance.r, colorInstance.g, colorInstance.b];
|
|
@@ -1771,7 +1771,7 @@ const adjustColorForProperContrast = (foreground, background, shape = 'paragraph
|
|
|
1771
1771
|
|
|
1772
1772
|
// This shouldn't be a valid scenario, but since the Color class isn't converted to TS yet
|
|
1773
1773
|
// the r, g, and b properties could theoretically be optional
|
|
1774
|
-
if ((0,
|
|
1774
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(foregroundColor.r) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(foregroundColor.g) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(foregroundColor.b)) {
|
|
1775
1775
|
throw new Error('Color does not contain required RGB values');
|
|
1776
1776
|
}
|
|
1777
1777
|
const initialContrastRatio = getContrast(foregroundColor.toHexWithHash(), backgroundColor.toHexWithHash());
|
|
@@ -2560,6 +2560,1856 @@ const standardSvgAttrs = ({
|
|
|
2560
2560
|
|
|
2561
2561
|
/***/ },
|
|
2562
2562
|
|
|
2563
|
+
/***/ 2002
|
|
2564
|
+
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2565
|
+
|
|
2566
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2567
|
+
/* harmony export */ gD: () => (/* binding */ isNil),
|
|
2568
|
+
/* harmony export */ jw: () => (/* binding */ isEmptyString),
|
|
2569
|
+
/* harmony export */ n9: () => (/* binding */ isNotNil),
|
|
2570
|
+
/* harmony export */ uI: () => (/* binding */ isNonEmptyString),
|
|
2571
|
+
/* harmony export */ uu: () => (/* binding */ isNonEmptyRecord)
|
|
2572
|
+
/* harmony export */ });
|
|
2573
|
+
/* unused harmony exports asyncNoOpFn, buildTimeDuration, coerceToBoolean, dateOnlyISOString, dateOnlyString, dateOnlyStringForSentence, dateOnlyStringNumeric, dateTimeRounded, dateTimeString, dateTimeStringForSentence, dateTimeToDate, dateTimeToISO, dateToDateTime, dateUTCOffset, dayOfWeekString, deepMerge, getObjectEntries, getObjectKeys, getObjectValues, hasKey, isArray, isAsyncFunction, isBigInt, isBoolean, isDate, isEmail, isEmptyArray, isEmptyRecord, isError, isFalsy, isFiniteNumber, isFunction, isHtmlButtonElement, isHtmlElement, isHtmlInputElement, isHtmlVideoElement, isInteger, isIterable, isMap, isMouseEvent, isNaN, isNonBlankString, isNonEmptyArray, isNonNaNNumber, isNotArray, isNotBoolean, isNotFunction, isNotNull, isNotNumber, isNotRecord, isNotString, isNotUndefined, isNotVoid, isNull, isNumber, isPlainObject, isPromise, isRecord, isRegExp, isSet, isString, isSvgElement, isSymbol, isTextNode, isTruthy, isUndefined, isUrl, isVoid, isWeakMap, isWeakSet, mediaDurationString, millisecondsToDurationISOString, monthDayStringNumeric, noOpFn, noOpFnReturningFalse, noOpFnReturningNull, parseDateString, readonlyArrayIncludes, sessionDurationString, stripExtension, timeAgoString, timeOnlyString, tupleIncludes */
|
|
2574
|
+
|
|
2575
|
+
/*
|
|
2576
|
+
* @license @wistia/utils v1.0.1
|
|
2577
|
+
*
|
|
2578
|
+
* Copyright (c) 2023-2026, Wistia, Inc. and its affiliates.
|
|
2579
|
+
*
|
|
2580
|
+
* This source code is unlicensed, all rights reserved.
|
|
2581
|
+
*/
|
|
2582
|
+
|
|
2583
|
+
//#region src/guards/isNull.ts
|
|
2584
|
+
/**
|
|
2585
|
+
* Checks if the provided value is null.
|
|
2586
|
+
*
|
|
2587
|
+
* @param value - The value to check.
|
|
2588
|
+
* @returns True if the value is null, false otherwise.
|
|
2589
|
+
*
|
|
2590
|
+
* @example
|
|
2591
|
+
* isNull(null); // true
|
|
2592
|
+
* isNull(undefined); // false
|
|
2593
|
+
*
|
|
2594
|
+
* @category Primitives
|
|
2595
|
+
*/
|
|
2596
|
+
const isNull = (value) => value === null;
|
|
2597
|
+
//#endregion
|
|
2598
|
+
//#region src/guards/isUndefined.ts
|
|
2599
|
+
/**
|
|
2600
|
+
* Checks if the provided value is undefined.
|
|
2601
|
+
*
|
|
2602
|
+
* @param value - The value to check.
|
|
2603
|
+
* @returns True if the value is undefined, false otherwise.
|
|
2604
|
+
*
|
|
2605
|
+
* @example
|
|
2606
|
+
* isUndefined(undefined); // true
|
|
2607
|
+
* isUndefined(null); // false
|
|
2608
|
+
*
|
|
2609
|
+
* @category Primitives
|
|
2610
|
+
*/
|
|
2611
|
+
const isUndefined = (value) => value === void 0;
|
|
2612
|
+
//#endregion
|
|
2613
|
+
//#region src/guards/isNil.ts
|
|
2614
|
+
/**
|
|
2615
|
+
* Checks if the provided value is null or undefined.
|
|
2616
|
+
*
|
|
2617
|
+
* @param value - The value to check.
|
|
2618
|
+
* @returns True if the value is null or undefined, false otherwise.
|
|
2619
|
+
*
|
|
2620
|
+
* @example
|
|
2621
|
+
* isNil(null); // true
|
|
2622
|
+
* isNil(0); // false
|
|
2623
|
+
*
|
|
2624
|
+
* @category Primitives
|
|
2625
|
+
*/
|
|
2626
|
+
const isNil = (value) => isNull(value) || isUndefined(value);
|
|
2627
|
+
//#endregion
|
|
2628
|
+
//#region src/guards/isNotNil.ts
|
|
2629
|
+
/**
|
|
2630
|
+
* Checks if the provided value is neither null nor undefined.
|
|
2631
|
+
*
|
|
2632
|
+
* @param value - The value to check.
|
|
2633
|
+
* @returns True if the value is not null or undefined, false otherwise.
|
|
2634
|
+
*
|
|
2635
|
+
* @remarks
|
|
2636
|
+
* Common in `.filter(isNotNil)` to drop `null`/`undefined` from arrays
|
|
2637
|
+
* with narrowing.
|
|
2638
|
+
*
|
|
2639
|
+
* @example
|
|
2640
|
+
* isNotNil(0); // true
|
|
2641
|
+
* isNotNil(null); // false
|
|
2642
|
+
*
|
|
2643
|
+
* const items: (string | null)[] = ['a', null, 'b'];
|
|
2644
|
+
* const clean: string[] = items.filter(isNotNil); // ['a', 'b']
|
|
2645
|
+
*
|
|
2646
|
+
* @category Negated
|
|
2647
|
+
*/
|
|
2648
|
+
const isNotNil = (value) => !isNil(value);
|
|
2649
|
+
//#endregion
|
|
2650
|
+
//#region src/guards/isRecord.ts
|
|
2651
|
+
/**
|
|
2652
|
+
* Checks if the provided value is a non-null object that is not an array.
|
|
2653
|
+
*
|
|
2654
|
+
* @param value - The value to check.
|
|
2655
|
+
* @returns True if the value is an object (but not an array), false otherwise.
|
|
2656
|
+
*
|
|
2657
|
+
* @example
|
|
2658
|
+
* isRecord({}); // true
|
|
2659
|
+
* isRecord([]); // false
|
|
2660
|
+
*
|
|
2661
|
+
* @category Records
|
|
2662
|
+
*/
|
|
2663
|
+
const isRecord = (value) => isNotNil(value) && typeof value === "object" && !Array.isArray(value);
|
|
2664
|
+
//#endregion
|
|
2665
|
+
//#region src/guards/isNonEmptyRecord.ts
|
|
2666
|
+
/**
|
|
2667
|
+
* Checks if the provided value is an object with at least one own property.
|
|
2668
|
+
*
|
|
2669
|
+
* @param value - The value to check.
|
|
2670
|
+
* @returns True if the value is a non-empty object, false otherwise.
|
|
2671
|
+
*
|
|
2672
|
+
* @example
|
|
2673
|
+
* isNonEmptyRecord({ a: 1 }); // true
|
|
2674
|
+
* isNonEmptyRecord({}); // false
|
|
2675
|
+
*
|
|
2676
|
+
* @category Records
|
|
2677
|
+
*/
|
|
2678
|
+
const isNonEmptyRecord = (value) => isRecord(value) && Object.keys(value).length > 0;
|
|
2679
|
+
//#endregion
|
|
2680
|
+
//#region src/guards/hasKey.ts
|
|
2681
|
+
/**
|
|
2682
|
+
* Curried function that tests if an input is an object
|
|
2683
|
+
* _and_ that a key that was passed in is a property of that object.
|
|
2684
|
+
*
|
|
2685
|
+
* @param value - The input object to test.
|
|
2686
|
+
* @param key - The key to test if it is a property of the input record.
|
|
2687
|
+
* @returns A function that takes an unknown input and then tests if the
|
|
2688
|
+
* input is an object and whether the key is a property of that object or not.
|
|
2689
|
+
*
|
|
2690
|
+
* @example
|
|
2691
|
+
* hasKey({ a: 1 }, 'a'); // true
|
|
2692
|
+
* hasKey({ a: 1 }, 'b'); // false
|
|
2693
|
+
*
|
|
2694
|
+
* @category Records
|
|
2695
|
+
*/
|
|
2696
|
+
const hasKey = (value, key) => isNonEmptyRecord(value) && key in value;
|
|
2697
|
+
//#endregion
|
|
2698
|
+
//#region src/guards/isArray.ts
|
|
2699
|
+
/**
|
|
2700
|
+
* Checks if the provided value is an array.
|
|
2701
|
+
*
|
|
2702
|
+
* @param value - The value to check.
|
|
2703
|
+
* @returns True if the value is an array, false otherwise.
|
|
2704
|
+
*
|
|
2705
|
+
* @example
|
|
2706
|
+
* isArray([1, 2]); // true
|
|
2707
|
+
* isArray('abc'); // false
|
|
2708
|
+
*
|
|
2709
|
+
* @category Arrays
|
|
2710
|
+
*/
|
|
2711
|
+
const isArray = (value) => isNotNil(value) && typeof value === "object" && Array.isArray(value);
|
|
2712
|
+
//#endregion
|
|
2713
|
+
//#region src/guards/isFunction.ts
|
|
2714
|
+
/**
|
|
2715
|
+
* Checks if the provided value is a function.
|
|
2716
|
+
*
|
|
2717
|
+
* @param value - The value to check.
|
|
2718
|
+
* @returns True if the value is a function, false otherwise.
|
|
2719
|
+
*
|
|
2720
|
+
* @example
|
|
2721
|
+
* isFunction(() => {}); // true
|
|
2722
|
+
* isFunction({}); // false
|
|
2723
|
+
*
|
|
2724
|
+
* @category Primitives
|
|
2725
|
+
*/
|
|
2726
|
+
const isFunction = (value) => isNotNil(value) && typeof value === "function";
|
|
2727
|
+
//#endregion
|
|
2728
|
+
//#region src/guards/isAsyncFunction.ts
|
|
2729
|
+
/**
|
|
2730
|
+
* Checks if the provided value is an async function.
|
|
2731
|
+
*
|
|
2732
|
+
* @param value - The value to check.
|
|
2733
|
+
* @returns True if the value is an async function, false otherwise.
|
|
2734
|
+
*
|
|
2735
|
+
* @remarks
|
|
2736
|
+
* Detection relies on `constructor.name === 'AsyncFunction'` and is a
|
|
2737
|
+
* heuristic: async functions transpiled to regular functions return false,
|
|
2738
|
+
* async generator functions return false, and a forged `constructor`
|
|
2739
|
+
* property can fool the check. Bound async functions return true, since
|
|
2740
|
+
* `bind` preserves the prototype chain. Synchronous functions that return
|
|
2741
|
+
* promises also return false.
|
|
2742
|
+
*
|
|
2743
|
+
* @example
|
|
2744
|
+
* isAsyncFunction(async () => {}); // true
|
|
2745
|
+
* isAsyncFunction(() => {}); // false
|
|
2746
|
+
*
|
|
2747
|
+
* @category Primitives
|
|
2748
|
+
*/
|
|
2749
|
+
const isAsyncFunction = (value) => {
|
|
2750
|
+
return isFunction(value) && value.constructor?.name === "AsyncFunction";
|
|
2751
|
+
};
|
|
2752
|
+
//#endregion
|
|
2753
|
+
//#region src/guards/isBigInt.ts
|
|
2754
|
+
/**
|
|
2755
|
+
* Checks if the provided value is a bigint.
|
|
2756
|
+
*
|
|
2757
|
+
* @param value - The value to check.
|
|
2758
|
+
* @returns True if the value is a bigint, false otherwise.
|
|
2759
|
+
*
|
|
2760
|
+
* @example
|
|
2761
|
+
* isBigInt(10n); // true
|
|
2762
|
+
* isBigInt(10); // false
|
|
2763
|
+
*
|
|
2764
|
+
* @category Primitives
|
|
2765
|
+
*/
|
|
2766
|
+
const isBigInt = (value) => typeof value === "bigint";
|
|
2767
|
+
//#endregion
|
|
2768
|
+
//#region src/guards/isBoolean.ts
|
|
2769
|
+
/**
|
|
2770
|
+
* Checks if the provided value is a boolean.
|
|
2771
|
+
*
|
|
2772
|
+
* @param value - The value to check.
|
|
2773
|
+
* @returns True if the value is a boolean, false otherwise.
|
|
2774
|
+
*
|
|
2775
|
+
* @example
|
|
2776
|
+
* isBoolean(true); // true
|
|
2777
|
+
* isBoolean(1); // false
|
|
2778
|
+
*
|
|
2779
|
+
* @category Primitives
|
|
2780
|
+
*/
|
|
2781
|
+
const isBoolean = (value) => isNotNil(value) && typeof value === "boolean";
|
|
2782
|
+
//#endregion
|
|
2783
|
+
//#region src/guards/isDate.ts
|
|
2784
|
+
/**
|
|
2785
|
+
* Checks if the provided value is an instance of Date.
|
|
2786
|
+
*
|
|
2787
|
+
* @param value - The value to check.
|
|
2788
|
+
* @returns True if the value is a Date instance, false otherwise.
|
|
2789
|
+
*
|
|
2790
|
+
* @remarks
|
|
2791
|
+
* Matches `Date` instances only. Does not parse date strings or
|
|
2792
|
+
* accept numeric timestamps.
|
|
2793
|
+
*
|
|
2794
|
+
* @example
|
|
2795
|
+
* isDate(new Date()); // true
|
|
2796
|
+
* isDate('2024-01-01'); // false
|
|
2797
|
+
*
|
|
2798
|
+
* @category Primitives
|
|
2799
|
+
*/
|
|
2800
|
+
const isDate = (value) => {
|
|
2801
|
+
return isNotNil(value) && value instanceof Date;
|
|
2802
|
+
};
|
|
2803
|
+
//#endregion
|
|
2804
|
+
//#region src/guards/isEmptyArray.ts
|
|
2805
|
+
/**
|
|
2806
|
+
* Checks if the provided value is an empty array.
|
|
2807
|
+
*
|
|
2808
|
+
* @param value - The value to check.
|
|
2809
|
+
* @returns True if the value is an empty array, false otherwise.
|
|
2810
|
+
*
|
|
2811
|
+
* @example
|
|
2812
|
+
* isEmptyArray([]); // true
|
|
2813
|
+
* isEmptyArray([1]); // false
|
|
2814
|
+
*
|
|
2815
|
+
* @category Arrays
|
|
2816
|
+
*/
|
|
2817
|
+
const isEmptyArray = (value) => isArray(value) && value.length === 0;
|
|
2818
|
+
//#endregion
|
|
2819
|
+
//#region src/guards/isEmptyRecord.ts
|
|
2820
|
+
/**
|
|
2821
|
+
* Checks if the provided value is an object with no own properties.
|
|
2822
|
+
*
|
|
2823
|
+
* @param value - The value to check.
|
|
2824
|
+
* @returns True if the value is an empty object, false otherwise.
|
|
2825
|
+
*
|
|
2826
|
+
* @example
|
|
2827
|
+
* isEmptyRecord({}); // true
|
|
2828
|
+
* isEmptyRecord({ a: 1 }); // false
|
|
2829
|
+
*
|
|
2830
|
+
* @category Records
|
|
2831
|
+
*/
|
|
2832
|
+
const isEmptyRecord = (value) => isRecord(value) && Object.keys(value).length === 0;
|
|
2833
|
+
//#endregion
|
|
2834
|
+
//#region src/guards/isString.ts
|
|
2835
|
+
/**
|
|
2836
|
+
* Checks if the provided value is a string.
|
|
2837
|
+
*
|
|
2838
|
+
* @param value - The value to check.
|
|
2839
|
+
* @returns True if the value is a string, false otherwise.
|
|
2840
|
+
*
|
|
2841
|
+
* @example
|
|
2842
|
+
* isString('hi'); // true
|
|
2843
|
+
* isString(42); // false
|
|
2844
|
+
*
|
|
2845
|
+
* @category Primitives
|
|
2846
|
+
*/
|
|
2847
|
+
const isString = (value) => typeof value === "string";
|
|
2848
|
+
//#endregion
|
|
2849
|
+
//#region src/guards/isEmptyString.ts
|
|
2850
|
+
/**
|
|
2851
|
+
* Checks if the provided value is an empty string.
|
|
2852
|
+
*
|
|
2853
|
+
* @param value - The value to check.
|
|
2854
|
+
* @returns True if the value is an empty string, false otherwise.
|
|
2855
|
+
*
|
|
2856
|
+
* @example
|
|
2857
|
+
* isEmptyString(''); // true
|
|
2858
|
+
* isEmptyString('a'); // false
|
|
2859
|
+
*
|
|
2860
|
+
* @category Strings
|
|
2861
|
+
*/
|
|
2862
|
+
const isEmptyString = (value) => isString(value) && value === "";
|
|
2863
|
+
//#endregion
|
|
2864
|
+
//#region src/guards/isError.ts
|
|
2865
|
+
/**
|
|
2866
|
+
* Checks if the provided value is an instance of Error.
|
|
2867
|
+
*
|
|
2868
|
+
* @param value - The value to check.
|
|
2869
|
+
* @returns True if the value is an Error instance, false otherwise.
|
|
2870
|
+
*
|
|
2871
|
+
* @remarks
|
|
2872
|
+
* Matches subclasses of `Error` too (e.g. `TypeError`, custom errors).
|
|
2873
|
+
*
|
|
2874
|
+
* @example
|
|
2875
|
+
* isError(new Error('boom')); // true
|
|
2876
|
+
* isError('boom'); // false
|
|
2877
|
+
*
|
|
2878
|
+
* @category Primitives
|
|
2879
|
+
*/
|
|
2880
|
+
const isError = (value) => {
|
|
2881
|
+
return isNotNil(value) && value instanceof Error;
|
|
2882
|
+
};
|
|
2883
|
+
//#endregion
|
|
2884
|
+
//#region src/guards/_falsyValues.ts
|
|
2885
|
+
const FALSY_VALUES = [
|
|
2886
|
+
false,
|
|
2887
|
+
0,
|
|
2888
|
+
-0,
|
|
2889
|
+
0n,
|
|
2890
|
+
"",
|
|
2891
|
+
null,
|
|
2892
|
+
void 0,
|
|
2893
|
+
NaN
|
|
2894
|
+
];
|
|
2895
|
+
//#endregion
|
|
2896
|
+
//#region src/guards/isFalsy.ts
|
|
2897
|
+
/**
|
|
2898
|
+
* Checks if the provided value is falsy.
|
|
2899
|
+
*
|
|
2900
|
+
* @param value - The value to check.
|
|
2901
|
+
* @returns True if the value is falsy, false otherwise.
|
|
2902
|
+
*
|
|
2903
|
+
* @remarks
|
|
2904
|
+
* Returns true for `false`, `0`, `-0`, `0n`, `''`, `null`, `undefined`,
|
|
2905
|
+
* and `NaN`.
|
|
2906
|
+
*
|
|
2907
|
+
* @example
|
|
2908
|
+
* isFalsy(0); // true
|
|
2909
|
+
* isFalsy(1); // false
|
|
2910
|
+
*
|
|
2911
|
+
* @category Truthy / falsy
|
|
2912
|
+
*/
|
|
2913
|
+
const isFalsy = (value) => FALSY_VALUES.includes(value) || Number.isNaN(value);
|
|
2914
|
+
//#endregion
|
|
2915
|
+
//#region src/guards/isNumber.ts
|
|
2916
|
+
/**
|
|
2917
|
+
* Checks if the provided value is a number.
|
|
2918
|
+
*
|
|
2919
|
+
* @param value - The value to check.
|
|
2920
|
+
* @returns True if the value is a number, false otherwise.
|
|
2921
|
+
*
|
|
2922
|
+
* @remarks
|
|
2923
|
+
* `NaN` is a `number`, so `isNumber(NaN)` is true. Use `isInteger` or
|
|
2924
|
+
* combine with `!isNaN(value)` if you need a finite number.
|
|
2925
|
+
*
|
|
2926
|
+
* @example
|
|
2927
|
+
* isNumber(1); // true
|
|
2928
|
+
* isNumber('1'); // false
|
|
2929
|
+
*
|
|
2930
|
+
* @category Primitives
|
|
2931
|
+
*/
|
|
2932
|
+
const isNumber = (value) => typeof value === "number";
|
|
2933
|
+
//#endregion
|
|
2934
|
+
//#region src/guards/isFiniteNumber.ts
|
|
2935
|
+
/**
|
|
2936
|
+
* Checks if the provided value is a finite number.
|
|
2937
|
+
*
|
|
2938
|
+
* @param value - The value to check.
|
|
2939
|
+
* @returns True if the value is a finite number, false otherwise.
|
|
2940
|
+
*
|
|
2941
|
+
* @example
|
|
2942
|
+
* isFiniteNumber(42); // true
|
|
2943
|
+
* isFiniteNumber(Infinity); // false
|
|
2944
|
+
*
|
|
2945
|
+
* @category Primitives
|
|
2946
|
+
*/
|
|
2947
|
+
const isFiniteNumber = (value) => isNumber(value) && Number.isFinite(value);
|
|
2948
|
+
//#endregion
|
|
2949
|
+
//#region src/guards/isHtmlButtonElement.ts
|
|
2950
|
+
/**
|
|
2951
|
+
* Checks if the provided value is an HTMLButtonElement.
|
|
2952
|
+
*
|
|
2953
|
+
* @param value - The value to check.
|
|
2954
|
+
* @returns True if the value is an HTMLButtonElement, false otherwise.
|
|
2955
|
+
*
|
|
2956
|
+
* @example
|
|
2957
|
+
* isHtmlButtonElement(document.createElement('button')); // true
|
|
2958
|
+
* isHtmlButtonElement(document.createElement('div')); // false
|
|
2959
|
+
*
|
|
2960
|
+
* @category DOM
|
|
2961
|
+
*/
|
|
2962
|
+
const isHtmlButtonElement = (value) => value instanceof HTMLButtonElement;
|
|
2963
|
+
//#endregion
|
|
2964
|
+
//#region src/guards/isHtmlElement.ts
|
|
2965
|
+
/**
|
|
2966
|
+
* Checks if the provided value is an HTMLElement.
|
|
2967
|
+
*
|
|
2968
|
+
* @param value - The value to check.
|
|
2969
|
+
* @returns True if the value is an HTMLElement, false otherwise.
|
|
2970
|
+
*
|
|
2971
|
+
* @example
|
|
2972
|
+
* isHtmlElement(document.body); // true
|
|
2973
|
+
* isHtmlElement('div'); // false
|
|
2974
|
+
*
|
|
2975
|
+
* @category DOM
|
|
2976
|
+
*/
|
|
2977
|
+
const isHtmlElement = (value) => value instanceof HTMLElement;
|
|
2978
|
+
//#endregion
|
|
2979
|
+
//#region src/guards/isHtmlInputElement.ts
|
|
2980
|
+
/**
|
|
2981
|
+
* Checks if the provided value is an HTMLInputElement.
|
|
2982
|
+
*
|
|
2983
|
+
* @param value - The value to check.
|
|
2984
|
+
* @returns True if the value is an HTMLInputElement, false otherwise.
|
|
2985
|
+
*
|
|
2986
|
+
* @example
|
|
2987
|
+
* isHtmlInputElement(document.createElement('input')); // true
|
|
2988
|
+
* isHtmlInputElement(document.createElement('div')); // false
|
|
2989
|
+
*
|
|
2990
|
+
* @category DOM
|
|
2991
|
+
*/
|
|
2992
|
+
const isHtmlInputElement = (value) => value instanceof HTMLInputElement;
|
|
2993
|
+
//#endregion
|
|
2994
|
+
//#region src/guards/isHtmlVideoElement.ts
|
|
2995
|
+
/**
|
|
2996
|
+
* Checks if the provided value is an HTMLVideoElement.
|
|
2997
|
+
*
|
|
2998
|
+
* @param value - The value to check.
|
|
2999
|
+
* @returns True if the value is an HTMLVideoElement, false otherwise.
|
|
3000
|
+
*
|
|
3001
|
+
* @example
|
|
3002
|
+
* isHtmlVideoElement(document.createElement('video')); // true
|
|
3003
|
+
* isHtmlVideoElement(document.createElement('div')); // false
|
|
3004
|
+
*
|
|
3005
|
+
* @category DOM
|
|
3006
|
+
*/
|
|
3007
|
+
const isHtmlVideoElement = (value) => value instanceof HTMLVideoElement;
|
|
3008
|
+
//#endregion
|
|
3009
|
+
//#region src/guards/isInteger.ts
|
|
3010
|
+
/**
|
|
3011
|
+
* Checks if the provided value is an integer.
|
|
3012
|
+
*
|
|
3013
|
+
* @param value - The value to check.
|
|
3014
|
+
* @returns True if the value is an integer, false otherwise.
|
|
3015
|
+
*
|
|
3016
|
+
* @remarks
|
|
3017
|
+
* Uses `Number.isInteger`, so non-finite values (`NaN`, `Infinity`)
|
|
3018
|
+
* return false.
|
|
3019
|
+
*
|
|
3020
|
+
* @example
|
|
3021
|
+
* isInteger(5); // true
|
|
3022
|
+
* isInteger(5.5); // false
|
|
3023
|
+
*
|
|
3024
|
+
* @category Primitives
|
|
3025
|
+
*/
|
|
3026
|
+
const isInteger = (value) => Number.isInteger(value);
|
|
3027
|
+
//#endregion
|
|
3028
|
+
//#region src/guards/isIterable.ts
|
|
3029
|
+
/**
|
|
3030
|
+
* Checks if the provided value implements the iterable protocol.
|
|
3031
|
+
*
|
|
3032
|
+
* @param value - The value to check.
|
|
3033
|
+
* @returns True if the value is iterable, false otherwise.
|
|
3034
|
+
*
|
|
3035
|
+
* @remarks
|
|
3036
|
+
* Strings are iterable and return true. Plain objects without
|
|
3037
|
+
* `Symbol.iterator` return false.
|
|
3038
|
+
*
|
|
3039
|
+
* @example
|
|
3040
|
+
* isIterable([1, 2, 3]); // true
|
|
3041
|
+
* isIterable({}); // false
|
|
3042
|
+
*
|
|
3043
|
+
* @category Primitives
|
|
3044
|
+
*/
|
|
3045
|
+
const isIterable = (value) => {
|
|
3046
|
+
if (!isNotNil(value)) return false;
|
|
3047
|
+
return typeof value[Symbol.iterator] === "function";
|
|
3048
|
+
};
|
|
3049
|
+
//#endregion
|
|
3050
|
+
//#region src/guards/isMap.ts
|
|
3051
|
+
/**
|
|
3052
|
+
* Checks if the provided value is an instance of Map.
|
|
3053
|
+
*
|
|
3054
|
+
* @param value - The value to check.
|
|
3055
|
+
* @returns True if the value is a Map instance, false otherwise.
|
|
3056
|
+
*
|
|
3057
|
+
* @remarks
|
|
3058
|
+
* WeakMap instances return false.
|
|
3059
|
+
*
|
|
3060
|
+
* @example
|
|
3061
|
+
* isMap(new Map()); // true
|
|
3062
|
+
* isMap({}); // false
|
|
3063
|
+
*
|
|
3064
|
+
* @category Primitives
|
|
3065
|
+
*/
|
|
3066
|
+
const isMap = (value) => {
|
|
3067
|
+
return isNotNil(value) && value instanceof Map;
|
|
3068
|
+
};
|
|
3069
|
+
//#endregion
|
|
3070
|
+
//#region src/guards/isMouseEvent.ts
|
|
3071
|
+
/**
|
|
3072
|
+
* Checks if the provided value is a MouseEvent.
|
|
3073
|
+
*
|
|
3074
|
+
* @param value - The value to check.
|
|
3075
|
+
* @returns True if the value is a MouseEvent, false otherwise.
|
|
3076
|
+
*
|
|
3077
|
+
* @example
|
|
3078
|
+
* isMouseEvent(new MouseEvent('click')); // true
|
|
3079
|
+
* isMouseEvent(new Event('change')); // false
|
|
3080
|
+
*
|
|
3081
|
+
* @category DOM
|
|
3082
|
+
*/
|
|
3083
|
+
const isMouseEvent = (value) => value instanceof MouseEvent;
|
|
3084
|
+
//#endregion
|
|
3085
|
+
//#region src/guards/isNaN.ts
|
|
3086
|
+
/**
|
|
3087
|
+
* Checks if the provided value is NaN (Not a Number).
|
|
3088
|
+
*
|
|
3089
|
+
* @param value - The value to check.
|
|
3090
|
+
* @returns True if the value is NaN, false otherwise.
|
|
3091
|
+
*
|
|
3092
|
+
* @remarks
|
|
3093
|
+
* Uses `Number.isNaN` (not the coercive global `isNaN`), so only the
|
|
3094
|
+
* literal `NaN` value returns true.
|
|
3095
|
+
*
|
|
3096
|
+
* @example
|
|
3097
|
+
* isNaN(Number.NaN); // true
|
|
3098
|
+
* isNaN(0); // false
|
|
3099
|
+
*
|
|
3100
|
+
* @category Primitives
|
|
3101
|
+
*/
|
|
3102
|
+
const isNaN = (value) => Number.isNaN(value);
|
|
3103
|
+
//#endregion
|
|
3104
|
+
//#region src/guards/isNonBlankString.ts
|
|
3105
|
+
/**
|
|
3106
|
+
* Checks if the provided value is a non-blank string (not empty and not whitespace-only).
|
|
3107
|
+
* Use {@link isNonEmptyString} when whitespace-only strings are acceptable (e.g. preserving
|
|
3108
|
+
* intentional formatting).
|
|
3109
|
+
*
|
|
3110
|
+
* @param value - The value to check.
|
|
3111
|
+
* @returns True if the value is a string with at least one non-whitespace character, false otherwise.
|
|
3112
|
+
*
|
|
3113
|
+
* @example
|
|
3114
|
+
* isNonBlankString('a'); // true
|
|
3115
|
+
* isNonBlankString(' '); // false
|
|
3116
|
+
*
|
|
3117
|
+
* @category Strings
|
|
3118
|
+
*/
|
|
3119
|
+
const isNonBlankString = (value) => isString(value) && value.trim() !== "";
|
|
3120
|
+
//#endregion
|
|
3121
|
+
//#region src/guards/isNonEmptyArray.ts
|
|
3122
|
+
/**
|
|
3123
|
+
* Checks if the provided value is a non-empty array.
|
|
3124
|
+
*
|
|
3125
|
+
* @param value - The value to check. Can be null or undefined.
|
|
3126
|
+
* @returns True if the value is a non-empty array, false otherwise.
|
|
3127
|
+
*
|
|
3128
|
+
* @example
|
|
3129
|
+
* isNonEmptyArray([1]); // true
|
|
3130
|
+
* isNonEmptyArray([]); // false
|
|
3131
|
+
*
|
|
3132
|
+
* @category Arrays
|
|
3133
|
+
*/
|
|
3134
|
+
const isNonEmptyArray = (value) => isArray(value) && value.length > 0;
|
|
3135
|
+
//#endregion
|
|
3136
|
+
//#region src/guards/isNonEmptyString.ts
|
|
3137
|
+
/**
|
|
3138
|
+
* Checks if the provided value is a non-empty string. Whitespace-only strings like `" "` pass.
|
|
3139
|
+
* Use {@link isNonBlankString} when whitespace-only strings should be rejected (e.g. user input
|
|
3140
|
+
* validation).
|
|
3141
|
+
*
|
|
3142
|
+
* @param value - The value to check.
|
|
3143
|
+
* @returns True if the value is a non-empty string, false otherwise.
|
|
3144
|
+
*
|
|
3145
|
+
* @example
|
|
3146
|
+
* isNonEmptyString('a'); // true
|
|
3147
|
+
* isNonEmptyString(''); // false
|
|
3148
|
+
*
|
|
3149
|
+
* @category Strings
|
|
3150
|
+
*/
|
|
3151
|
+
const isNonEmptyString = (value) => isString(value) && !isEmptyString(value);
|
|
3152
|
+
//#endregion
|
|
3153
|
+
//#region src/guards/isNonNaNNumber.ts
|
|
3154
|
+
/**
|
|
3155
|
+
* Checks if the provided value is a number that is not NaN.
|
|
3156
|
+
*
|
|
3157
|
+
* @param value - The value to check.
|
|
3158
|
+
* @returns True if the value is a number and not NaN, false otherwise.
|
|
3159
|
+
*
|
|
3160
|
+
* @example
|
|
3161
|
+
* isNonNaNNumber(42); // true
|
|
3162
|
+
* isNonNaNNumber(Number.NaN); // false
|
|
3163
|
+
*
|
|
3164
|
+
* @category Primitives
|
|
3165
|
+
*/
|
|
3166
|
+
const isNonNaNNumber = (value) => isNumber(value) && !isNaN(value);
|
|
3167
|
+
//#endregion
|
|
3168
|
+
//#region src/guards/isNotArray.ts
|
|
3169
|
+
/**
|
|
3170
|
+
* Checks if the provided value is not an array.
|
|
3171
|
+
*
|
|
3172
|
+
* @param value - The value to check.
|
|
3173
|
+
* @returns True if the value is not an array, false otherwise.
|
|
3174
|
+
*
|
|
3175
|
+
* @example
|
|
3176
|
+
* isNotArray('x'); // true
|
|
3177
|
+
* isNotArray([]); // false
|
|
3178
|
+
*
|
|
3179
|
+
* @category Negated
|
|
3180
|
+
*/
|
|
3181
|
+
const isNotArray = (value) => !isArray(value);
|
|
3182
|
+
//#endregion
|
|
3183
|
+
//#region src/guards/isNotBoolean.ts
|
|
3184
|
+
/**
|
|
3185
|
+
* Checks if the provided value is not a boolean.
|
|
3186
|
+
*
|
|
3187
|
+
* @param value - The value to check.
|
|
3188
|
+
* @returns True if the value is not a boolean, false otherwise.
|
|
3189
|
+
*
|
|
3190
|
+
* @example
|
|
3191
|
+
* isNotBoolean(1); // true
|
|
3192
|
+
* isNotBoolean(true); // false
|
|
3193
|
+
*
|
|
3194
|
+
* @category Negated
|
|
3195
|
+
*/
|
|
3196
|
+
const isNotBoolean = (value) => !isBoolean(value);
|
|
3197
|
+
//#endregion
|
|
3198
|
+
//#region src/guards/isNotFunction.ts
|
|
3199
|
+
/**
|
|
3200
|
+
* Checks if the provided value is not a function.
|
|
3201
|
+
*
|
|
3202
|
+
* @param value - The value to check.
|
|
3203
|
+
* @returns True if the value is not a function, false otherwise.
|
|
3204
|
+
*
|
|
3205
|
+
* @example
|
|
3206
|
+
* isNotFunction(1); // true
|
|
3207
|
+
* isNotFunction(() => {}); // false
|
|
3208
|
+
*
|
|
3209
|
+
* @category Negated
|
|
3210
|
+
*/
|
|
3211
|
+
const isNotFunction = (value) => !isFunction(value);
|
|
3212
|
+
//#endregion
|
|
3213
|
+
//#region src/guards/isNotNull.ts
|
|
3214
|
+
/**
|
|
3215
|
+
* Checks if the provided value is not null.
|
|
3216
|
+
*
|
|
3217
|
+
* @param value - The value to check.
|
|
3218
|
+
* @returns True if the value is not null, false otherwise.
|
|
3219
|
+
*
|
|
3220
|
+
* @example
|
|
3221
|
+
* isNotNull(undefined); // true
|
|
3222
|
+
* isNotNull(null); // false
|
|
3223
|
+
*
|
|
3224
|
+
* @category Negated
|
|
3225
|
+
*/
|
|
3226
|
+
const isNotNull = (value) => !isNull(value);
|
|
3227
|
+
//#endregion
|
|
3228
|
+
//#region src/guards/isNotNumber.ts
|
|
3229
|
+
/**
|
|
3230
|
+
* Checks if the provided value is not a number.
|
|
3231
|
+
*
|
|
3232
|
+
* @param value - The value to check.
|
|
3233
|
+
* @returns True if the value is not a number, false otherwise.
|
|
3234
|
+
*
|
|
3235
|
+
* @example
|
|
3236
|
+
* isNotNumber('1'); // true
|
|
3237
|
+
* isNotNumber(1); // false
|
|
3238
|
+
*
|
|
3239
|
+
* @category Negated
|
|
3240
|
+
*/
|
|
3241
|
+
const isNotNumber = (value) => !isNumber(value);
|
|
3242
|
+
//#endregion
|
|
3243
|
+
//#region src/guards/isNotRecord.ts
|
|
3244
|
+
/**
|
|
3245
|
+
* Checks if the provided value is not an object.
|
|
3246
|
+
*
|
|
3247
|
+
* @param value - The value to check.
|
|
3248
|
+
* @returns True if the value is not a record (object), false otherwise.
|
|
3249
|
+
*
|
|
3250
|
+
* @example
|
|
3251
|
+
* isNotRecord([]); // true
|
|
3252
|
+
* isNotRecord({}); // false
|
|
3253
|
+
*
|
|
3254
|
+
* @category Negated
|
|
3255
|
+
*/
|
|
3256
|
+
const isNotRecord = (value) => !isRecord(value);
|
|
3257
|
+
//#endregion
|
|
3258
|
+
//#region src/guards/isNotString.ts
|
|
3259
|
+
/**
|
|
3260
|
+
* Checks if the provided value is not a string.
|
|
3261
|
+
*
|
|
3262
|
+
* @param value - The value to check.
|
|
3263
|
+
* @returns True if the value is not a string, false otherwise.
|
|
3264
|
+
*
|
|
3265
|
+
* @example
|
|
3266
|
+
* isNotString(1); // true
|
|
3267
|
+
* isNotString('a'); // false
|
|
3268
|
+
*
|
|
3269
|
+
* @category Negated
|
|
3270
|
+
*/
|
|
3271
|
+
const isNotString = (value) => !isString(value);
|
|
3272
|
+
//#endregion
|
|
3273
|
+
//#region src/guards/isNotUndefined.ts
|
|
3274
|
+
/**
|
|
3275
|
+
* Checks if the provided value is not undefined.
|
|
3276
|
+
*
|
|
3277
|
+
* @param value - The value to check.
|
|
3278
|
+
* @returns True if the value is not undefined, false otherwise.
|
|
3279
|
+
*
|
|
3280
|
+
* @example
|
|
3281
|
+
* isNotUndefined(null); // true
|
|
3282
|
+
* isNotUndefined(undefined); // false
|
|
3283
|
+
*
|
|
3284
|
+
* @category Negated
|
|
3285
|
+
*/
|
|
3286
|
+
const isNotUndefined = (value) => !isUndefined(value);
|
|
3287
|
+
//#endregion
|
|
3288
|
+
//#region src/guards/isVoid.ts
|
|
3289
|
+
/**
|
|
3290
|
+
* Checks if the provided value is void.
|
|
3291
|
+
*
|
|
3292
|
+
* @param value - The value to check.
|
|
3293
|
+
* @returns True if the value is void (undefined), false otherwise.
|
|
3294
|
+
*
|
|
3295
|
+
* @example
|
|
3296
|
+
* isVoid(undefined); // true
|
|
3297
|
+
* isVoid(0); // false
|
|
3298
|
+
*
|
|
3299
|
+
* @category Primitives
|
|
3300
|
+
*/
|
|
3301
|
+
const isVoid = (value) => value === void 0;
|
|
3302
|
+
//#endregion
|
|
3303
|
+
//#region src/guards/isNotVoid.ts
|
|
3304
|
+
/**
|
|
3305
|
+
* Checks if the provided value is not void.
|
|
3306
|
+
*
|
|
3307
|
+
* @param value - The value to check.
|
|
3308
|
+
* @returns True if the value is not void (defined), false otherwise.
|
|
3309
|
+
*
|
|
3310
|
+
* @example
|
|
3311
|
+
* isNotVoid(0); // true
|
|
3312
|
+
* isNotVoid(undefined); // false
|
|
3313
|
+
*
|
|
3314
|
+
* @category Negated
|
|
3315
|
+
*/
|
|
3316
|
+
const isNotVoid = (value) => !isVoid(value);
|
|
3317
|
+
//#endregion
|
|
3318
|
+
//#region src/guards/isPlainObject.ts
|
|
3319
|
+
/**
|
|
3320
|
+
* Checks if the provided value is a plain object created with `{}` or `Object.create(null)`.
|
|
3321
|
+
* Returns false for arrays, `Date`, `Map`, `RegExp`, boxed primitives, and class instances.
|
|
3322
|
+
*
|
|
3323
|
+
* @param value - The value to check.
|
|
3324
|
+
* @returns True if the value is a plain object, false otherwise.
|
|
3325
|
+
*
|
|
3326
|
+
* @example
|
|
3327
|
+
* isPlainObject({}); // true
|
|
3328
|
+
* isPlainObject(new Date()); // false
|
|
3329
|
+
*
|
|
3330
|
+
* @category Records
|
|
3331
|
+
*/
|
|
3332
|
+
const isPlainObject = (value) => {
|
|
3333
|
+
if (isNil(value) || typeof value !== "object") return false;
|
|
3334
|
+
if (isArray(value)) return false;
|
|
3335
|
+
const proto = Object.getPrototypeOf(value);
|
|
3336
|
+
return proto === Object.prototype || proto === null;
|
|
3337
|
+
};
|
|
3338
|
+
//#endregion
|
|
3339
|
+
//#region src/guards/isPromise.ts
|
|
3340
|
+
/**
|
|
3341
|
+
* Checks if the provided value is a Promise, including promise-like objects
|
|
3342
|
+
* that implement `then`, `catch`, and `finally`.
|
|
3343
|
+
*
|
|
3344
|
+
* @param value - The value to check.
|
|
3345
|
+
* @returns True if the value is a Promise or promise-like object, false otherwise.
|
|
3346
|
+
*
|
|
3347
|
+
* @remarks
|
|
3348
|
+
* The full `Promise` method surface is required so the narrowed type is
|
|
3349
|
+
* accurate: `then`, `catch`, and `finally` must all be functions. Thenables
|
|
3350
|
+
* that only implement a subset are rejected.
|
|
3351
|
+
*
|
|
3352
|
+
* @example
|
|
3353
|
+
* isPromise(Promise.resolve()); // true
|
|
3354
|
+
* isPromise({ then: () => 1 }); // false
|
|
3355
|
+
*
|
|
3356
|
+
* @category Primitives
|
|
3357
|
+
*/
|
|
3358
|
+
const isPromise = (value) => {
|
|
3359
|
+
if (!isNotNil(value)) return false;
|
|
3360
|
+
const candidate = value;
|
|
3361
|
+
return typeof candidate.then === "function" && typeof candidate.catch === "function" && typeof candidate.finally === "function";
|
|
3362
|
+
};
|
|
3363
|
+
//#endregion
|
|
3364
|
+
//#region src/guards/isRegExp.ts
|
|
3365
|
+
/**
|
|
3366
|
+
* Checks if the provided value is an instance of RegExp.
|
|
3367
|
+
*
|
|
3368
|
+
* @param value - The value to check.
|
|
3369
|
+
* @returns True if the value is a RegExp instance, false otherwise.
|
|
3370
|
+
*
|
|
3371
|
+
* @example
|
|
3372
|
+
* isRegExp(/abc/); // true
|
|
3373
|
+
* isRegExp('/abc/'); // false
|
|
3374
|
+
*
|
|
3375
|
+
* @category Primitives
|
|
3376
|
+
*/
|
|
3377
|
+
const isRegExp = (value) => {
|
|
3378
|
+
return isNotNil(value) && value instanceof RegExp;
|
|
3379
|
+
};
|
|
3380
|
+
//#endregion
|
|
3381
|
+
//#region src/guards/isSet.ts
|
|
3382
|
+
/**
|
|
3383
|
+
* Checks if the provided value is an instance of Set.
|
|
3384
|
+
*
|
|
3385
|
+
* @param value - The value to check.
|
|
3386
|
+
* @returns True if the value is a Set instance, false otherwise.
|
|
3387
|
+
*
|
|
3388
|
+
* @remarks
|
|
3389
|
+
* WeakSet instances return false.
|
|
3390
|
+
*
|
|
3391
|
+
* @example
|
|
3392
|
+
* isSet(new Set()); // true
|
|
3393
|
+
* isSet([]); // false
|
|
3394
|
+
*
|
|
3395
|
+
* @category Primitives
|
|
3396
|
+
*/
|
|
3397
|
+
const isSet = (value) => {
|
|
3398
|
+
return isNotNil(value) && value instanceof Set;
|
|
3399
|
+
};
|
|
3400
|
+
//#endregion
|
|
3401
|
+
//#region src/guards/isSvgElement.ts
|
|
3402
|
+
/**
|
|
3403
|
+
* Checks if the provided value is an SVGElement.
|
|
3404
|
+
*
|
|
3405
|
+
* @param value - The value to check.
|
|
3406
|
+
* @returns True if the value is an SVGElement, false otherwise.
|
|
3407
|
+
*
|
|
3408
|
+
* @example
|
|
3409
|
+
* isSvgElement(document.createElementNS('http://www.w3.org/2000/svg', 'svg')); // true
|
|
3410
|
+
* isSvgElement(document.createElement('div')); // false
|
|
3411
|
+
*
|
|
3412
|
+
* @category DOM
|
|
3413
|
+
*/
|
|
3414
|
+
const isSvgElement = (value) => value instanceof SVGElement;
|
|
3415
|
+
//#endregion
|
|
3416
|
+
//#region src/guards/isSymbol.ts
|
|
3417
|
+
/**
|
|
3418
|
+
* Checks if the provided value is a symbol.
|
|
3419
|
+
*
|
|
3420
|
+
* @param value - The value to check.
|
|
3421
|
+
* @returns True if the value is a symbol, false otherwise.
|
|
3422
|
+
*
|
|
3423
|
+
* @example
|
|
3424
|
+
* isSymbol(Symbol('a')); // true
|
|
3425
|
+
* isSymbol('symbol'); // false
|
|
3426
|
+
*
|
|
3427
|
+
* @category Primitives
|
|
3428
|
+
*/
|
|
3429
|
+
const isSymbol = (value) => typeof value === "symbol";
|
|
3430
|
+
//#endregion
|
|
3431
|
+
//#region src/guards/isTextNode.ts
|
|
3432
|
+
/**
|
|
3433
|
+
* Checks if the provided value is a Text node.
|
|
3434
|
+
*
|
|
3435
|
+
* @param value - The value to check.
|
|
3436
|
+
* @returns True if the value is a Text node, false otherwise.
|
|
3437
|
+
*
|
|
3438
|
+
* @example
|
|
3439
|
+
* isTextNode(document.createTextNode('hi')); // true
|
|
3440
|
+
* isTextNode(document.createElement('div')); // false
|
|
3441
|
+
*
|
|
3442
|
+
* @category DOM
|
|
3443
|
+
*/
|
|
3444
|
+
const isTextNode = (value) => value.nodeName === "#text";
|
|
3445
|
+
//#endregion
|
|
3446
|
+
//#region src/guards/isTruthy.ts
|
|
3447
|
+
/**
|
|
3448
|
+
* Checks if the provided value is truthy.
|
|
3449
|
+
*
|
|
3450
|
+
* @param value - The value to check.
|
|
3451
|
+
* @returns True if the value is truthy, false otherwise.
|
|
3452
|
+
*
|
|
3453
|
+
* @remarks
|
|
3454
|
+
* The complement of `isFalsy`. Does not provide narrowing on its own;
|
|
3455
|
+
* use `isNotNil` or a specific positive guard when narrowing matters.
|
|
3456
|
+
*
|
|
3457
|
+
* @example
|
|
3458
|
+
* isTruthy(1); // true
|
|
3459
|
+
* isTruthy(0); // false
|
|
3460
|
+
*
|
|
3461
|
+
* @category Truthy / falsy
|
|
3462
|
+
*/
|
|
3463
|
+
const isTruthy = (value) => !FALSY_VALUES.includes(value) && !Number.isNaN(value);
|
|
3464
|
+
//#endregion
|
|
3465
|
+
//#region src/guards/isWeakMap.ts
|
|
3466
|
+
/**
|
|
3467
|
+
* Checks if the provided value is an instance of WeakMap.
|
|
3468
|
+
*
|
|
3469
|
+
* @param value - The value to check.
|
|
3470
|
+
* @returns True if the value is a WeakMap instance, false otherwise.
|
|
3471
|
+
*
|
|
3472
|
+
* @remarks
|
|
3473
|
+
* Map instances return false. Narrows to `WeakMap<WeakKey, unknown>`, since
|
|
3474
|
+
* weak collections accept non-registered symbols as keys (ES2023).
|
|
3475
|
+
*
|
|
3476
|
+
* @example
|
|
3477
|
+
* isWeakMap(new WeakMap()); // true
|
|
3478
|
+
* isWeakMap(new Map()); // false
|
|
3479
|
+
*
|
|
3480
|
+
* @category Primitives
|
|
3481
|
+
*/
|
|
3482
|
+
const isWeakMap = (value) => {
|
|
3483
|
+
return isNotNil(value) && value instanceof WeakMap;
|
|
3484
|
+
};
|
|
3485
|
+
//#endregion
|
|
3486
|
+
//#region src/guards/isWeakSet.ts
|
|
3487
|
+
/**
|
|
3488
|
+
* Checks if the provided value is an instance of WeakSet.
|
|
3489
|
+
*
|
|
3490
|
+
* @param value - The value to check.
|
|
3491
|
+
* @returns True if the value is a WeakSet instance, false otherwise.
|
|
3492
|
+
*
|
|
3493
|
+
* @remarks
|
|
3494
|
+
* Set instances return false. Narrows to `WeakSet<WeakKey>`, since weak
|
|
3495
|
+
* collections accept non-registered symbols as members (ES2023).
|
|
3496
|
+
*
|
|
3497
|
+
* @example
|
|
3498
|
+
* isWeakSet(new WeakSet()); // true
|
|
3499
|
+
* isWeakSet(new Set()); // false
|
|
3500
|
+
*
|
|
3501
|
+
* @category Primitives
|
|
3502
|
+
*/
|
|
3503
|
+
const isWeakSet = (value) => {
|
|
3504
|
+
return isNotNil(value) && value instanceof WeakSet;
|
|
3505
|
+
};
|
|
3506
|
+
//#endregion
|
|
3507
|
+
//#region src/guards/readonlyArrayIncludes.ts
|
|
3508
|
+
/**
|
|
3509
|
+
* Checks if a readonly array includes the given element, with type narrowing.
|
|
3510
|
+
*
|
|
3511
|
+
* @param arr - The readonly array to search.
|
|
3512
|
+
* @param elem - The element to search for.
|
|
3513
|
+
* @returns True if the array includes the element, false otherwise.
|
|
3514
|
+
*
|
|
3515
|
+
* @example
|
|
3516
|
+
* const arr = ['a', 'b'] as const;
|
|
3517
|
+
* readonlyArrayIncludes(arr, 'a'); // true
|
|
3518
|
+
* readonlyArrayIncludes(arr, 'z'); // false
|
|
3519
|
+
*
|
|
3520
|
+
* @category Arrays
|
|
3521
|
+
*/
|
|
3522
|
+
const readonlyArrayIncludes = (arr, elem) => arr.includes(elem);
|
|
3523
|
+
//#endregion
|
|
3524
|
+
//#region src/utilities/asyncNoOpFn.ts
|
|
3525
|
+
/**
|
|
3526
|
+
* An async function that does nothing. Useful as a default or placeholder
|
|
3527
|
+
* callback where a promise is expected.
|
|
3528
|
+
*
|
|
3529
|
+
* @returns A promise that resolves to `undefined`.
|
|
3530
|
+
*
|
|
3531
|
+
* @example
|
|
3532
|
+
* await asyncNoOpFn(); // undefined
|
|
3533
|
+
*/
|
|
3534
|
+
const asyncNoOpFn = async () => {};
|
|
3535
|
+
//#endregion
|
|
3536
|
+
//#region src/utilities/_constants.ts
|
|
3537
|
+
const defaultLocales = (/* unused pure expression or super */ null && (["en-US"]));
|
|
3538
|
+
const defaultTimeZone = /* @__PURE__ */ (/* unused pure expression or super */ null && ((() => Intl.DateTimeFormat().resolvedOptions().timeZone)()));
|
|
3539
|
+
const milisecondsInSecond = 1e3;
|
|
3540
|
+
const millisecondsInDay = 86400 * milisecondsInSecond;
|
|
3541
|
+
//#endregion
|
|
3542
|
+
//#region src/utilities/buildTimeDuration.ts
|
|
3543
|
+
/**
|
|
3544
|
+
* Returns an object representing a duration in seconds, minutes and hours.
|
|
3545
|
+
*
|
|
3546
|
+
* @param numberOfMilliseconds - The duration in milliseconds.
|
|
3547
|
+
* @returns The duration split into hours, minutes and seconds.
|
|
3548
|
+
*
|
|
3549
|
+
* @example
|
|
3550
|
+
* buildTimeDuration(3723000); // { hours: 1, minutes: 2, seconds: 3 }
|
|
3551
|
+
*/
|
|
3552
|
+
const buildTimeDuration = (numberOfMilliseconds) => {
|
|
3553
|
+
const numberOfSeconds = Math.floor(numberOfMilliseconds / milisecondsInSecond);
|
|
3554
|
+
const numberOfMinutes = Math.floor(numberOfSeconds / 60);
|
|
3555
|
+
const numberOfHours = Math.floor(numberOfMinutes / 60);
|
|
3556
|
+
return {
|
|
3557
|
+
seconds: numberOfSeconds - numberOfMinutes * 60,
|
|
3558
|
+
minutes: numberOfMinutes - numberOfHours * 60,
|
|
3559
|
+
hours: numberOfHours
|
|
3560
|
+
};
|
|
3561
|
+
};
|
|
3562
|
+
//#endregion
|
|
3563
|
+
//#region src/utilities/coerceToBoolean.ts
|
|
3564
|
+
/**
|
|
3565
|
+
* Converts the boolean string values 'true' and 'false' into the
|
|
3566
|
+
* corresponding boolean. Any other value is coerced with `Boolean()`.
|
|
3567
|
+
*
|
|
3568
|
+
* @param value - The value to coerce.
|
|
3569
|
+
* @returns The value as a boolean.
|
|
3570
|
+
*
|
|
3571
|
+
* @example
|
|
3572
|
+
* coerceToBoolean('true'); // true
|
|
3573
|
+
* coerceToBoolean('false'); // false
|
|
3574
|
+
* coerceToBoolean(0); // false
|
|
3575
|
+
*/
|
|
3576
|
+
const coerceToBoolean = (value) => {
|
|
3577
|
+
if (value === "true" || value === "false") return value === "true";
|
|
3578
|
+
return Boolean(value);
|
|
3579
|
+
};
|
|
3580
|
+
//#endregion
|
|
3581
|
+
//#region src/utilities/_isInvalidDate.ts
|
|
3582
|
+
/**
|
|
3583
|
+
* Checks whether a value is not a usable Date. Note that the Unix epoch
|
|
3584
|
+
* (getTime() === 0) is treated as invalid.
|
|
3585
|
+
*
|
|
3586
|
+
* @param date - The value to check.
|
|
3587
|
+
* @returns True if the value is not a Date, is an invalid Date, or is the Unix epoch.
|
|
3588
|
+
*/
|
|
3589
|
+
const isInvalidDate = (date) => {
|
|
3590
|
+
if (!isDate(date)) return true;
|
|
3591
|
+
const time = date.getTime();
|
|
3592
|
+
return time === 0 || Number.isNaN(time);
|
|
3593
|
+
};
|
|
3594
|
+
//#endregion
|
|
3595
|
+
//#region src/utilities/dateOnlyISOString.ts
|
|
3596
|
+
/**
|
|
3597
|
+
* Converts a Date object into a date only string formatted to ISO 8601,
|
|
3598
|
+
* e.g. '2021-06-03'.
|
|
3599
|
+
*
|
|
3600
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
3601
|
+
* @param options - Formatting options.
|
|
3602
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3603
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3604
|
+
*
|
|
3605
|
+
* @example
|
|
3606
|
+
* dateOnlyISOString(new Date(2011, 11, 15)); // '2011-12-15'
|
|
3607
|
+
*/
|
|
3608
|
+
const dateOnlyISOString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
3609
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
3610
|
+
try {
|
|
3611
|
+
const partsAsObject = new Intl.DateTimeFormat(defaultLocales, {
|
|
3612
|
+
year: "numeric",
|
|
3613
|
+
month: "2-digit",
|
|
3614
|
+
day: "2-digit",
|
|
3615
|
+
timeZone
|
|
3616
|
+
}).formatToParts(date).reduce((map, obj) => {
|
|
3617
|
+
map[obj.type] = obj.value;
|
|
3618
|
+
return map;
|
|
3619
|
+
}, {});
|
|
3620
|
+
return `${partsAsObject.year}-${partsAsObject.month}-${partsAsObject.day}`;
|
|
3621
|
+
} catch (error) {
|
|
3622
|
+
console.error(error);
|
|
3623
|
+
return "";
|
|
3624
|
+
}
|
|
3625
|
+
};
|
|
3626
|
+
//#endregion
|
|
3627
|
+
//#region src/utilities/dateOnlyString.ts
|
|
3628
|
+
/**
|
|
3629
|
+
* Converts a Date object into a date only string, e.g. 'Jun 3, 2021',
|
|
3630
|
+
* or 'Jun 3' if omitYear is true. Formats with the en-US locale.
|
|
3631
|
+
*
|
|
3632
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
3633
|
+
* @param options - Formatting options.
|
|
3634
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3635
|
+
* @param options.omitYear - If true, display the date without the year.
|
|
3636
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3637
|
+
*
|
|
3638
|
+
* @example
|
|
3639
|
+
* dateOnlyString(new Date(2011, 11, 15)); // 'Dec 15, 2011'
|
|
3640
|
+
*/
|
|
3641
|
+
const dateOnlyString = (date, { timeZone = defaultTimeZone, omitYear = false } = {}) => {
|
|
3642
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
3643
|
+
const formatOptions = omitYear ? {
|
|
3644
|
+
month: "short",
|
|
3645
|
+
day: "numeric",
|
|
3646
|
+
timeZone
|
|
3647
|
+
} : {
|
|
3648
|
+
dateStyle: "medium",
|
|
3649
|
+
timeZone
|
|
3650
|
+
};
|
|
3651
|
+
try {
|
|
3652
|
+
return new Intl.DateTimeFormat(defaultLocales, formatOptions).format(date);
|
|
3653
|
+
} catch (error) {
|
|
3654
|
+
console.error(error);
|
|
3655
|
+
return "";
|
|
3656
|
+
}
|
|
3657
|
+
};
|
|
3658
|
+
//#endregion
|
|
3659
|
+
//#region src/utilities/dateOnlyStringForSentence.ts
|
|
3660
|
+
/**
|
|
3661
|
+
* Converts a Date object into a date only string for use in a sentence,
|
|
3662
|
+
* e.g. 'June 3, 2021'. Formats with the en-US locale.
|
|
3663
|
+
*
|
|
3664
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
3665
|
+
* @param options - Formatting options.
|
|
3666
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3667
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3668
|
+
*
|
|
3669
|
+
* @example
|
|
3670
|
+
* dateOnlyStringForSentence(new Date(2011, 11, 15)); // 'December 15, 2011'
|
|
3671
|
+
*/
|
|
3672
|
+
const dateOnlyStringForSentence = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
3673
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
3674
|
+
try {
|
|
3675
|
+
return new Intl.DateTimeFormat(defaultLocales, {
|
|
3676
|
+
dateStyle: "long",
|
|
3677
|
+
timeZone
|
|
3678
|
+
}).format(date);
|
|
3679
|
+
} catch (error) {
|
|
3680
|
+
console.error(error);
|
|
3681
|
+
return "";
|
|
3682
|
+
}
|
|
3683
|
+
};
|
|
3684
|
+
//#endregion
|
|
3685
|
+
//#region src/utilities/dateOnlyStringNumeric.ts
|
|
3686
|
+
/**
|
|
3687
|
+
* Converts a Date object into a date only string formatted numerically,
|
|
3688
|
+
* e.g. '06/03/2021'. Formats with the en-US locale.
|
|
3689
|
+
*
|
|
3690
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
3691
|
+
* @param options - Formatting options.
|
|
3692
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3693
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3694
|
+
*
|
|
3695
|
+
* @example
|
|
3696
|
+
* dateOnlyStringNumeric(new Date(2011, 11, 15)); // '12/15/2011'
|
|
3697
|
+
*/
|
|
3698
|
+
const dateOnlyStringNumeric = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
3699
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
3700
|
+
try {
|
|
3701
|
+
return new Intl.DateTimeFormat(defaultLocales, {
|
|
3702
|
+
year: "numeric",
|
|
3703
|
+
month: "2-digit",
|
|
3704
|
+
day: "2-digit",
|
|
3705
|
+
timeZone
|
|
3706
|
+
}).format(date);
|
|
3707
|
+
} catch (error) {
|
|
3708
|
+
console.error(error);
|
|
3709
|
+
return "";
|
|
3710
|
+
}
|
|
3711
|
+
};
|
|
3712
|
+
//#endregion
|
|
3713
|
+
//#region src/utilities/dateTimeToDate.ts
|
|
3714
|
+
/**
|
|
3715
|
+
* Converts a plain object of date and time parts into a Date object.
|
|
3716
|
+
*
|
|
3717
|
+
* @param dateTime - The date parts to convert.
|
|
3718
|
+
* @returns The converted Date, or null if year, month, or dayOfMonth is missing.
|
|
3719
|
+
*
|
|
3720
|
+
* @example
|
|
3721
|
+
* dateTimeToDate({ year: 2015, month: 10, dayOfMonth: 7, hours: 4, minutes: 15 });
|
|
3722
|
+
* // new Date(2015, 10, 7, 4, 15)
|
|
3723
|
+
*/
|
|
3724
|
+
const dateTimeToDate = (dateTime) => {
|
|
3725
|
+
const { year, month, dayOfMonth, hours, minutes } = dateTime ?? {};
|
|
3726
|
+
if (year !== void 0 && month !== void 0 && dayOfMonth !== void 0) return new Date(year, month, dayOfMonth, hours ?? 0, minutes ?? 0);
|
|
3727
|
+
return null;
|
|
3728
|
+
};
|
|
3729
|
+
//#endregion
|
|
3730
|
+
//#region src/utilities/dateTimeToISO.ts
|
|
3731
|
+
/**
|
|
3732
|
+
* Converts a plain object of date and time parts into an ISO-8601 string.
|
|
3733
|
+
*
|
|
3734
|
+
* @param dateTime - The date parts to convert.
|
|
3735
|
+
* @returns The ISO-8601 string, or null if year, month, or dayOfMonth is missing.
|
|
3736
|
+
*
|
|
3737
|
+
* @example
|
|
3738
|
+
* dateTimeToISO({ year: 2015, month: 10, dayOfMonth: 7, hours: 4, minutes: 15 });
|
|
3739
|
+
* // '2015-11-07T04:15:00.000Z' (in UTC)
|
|
3740
|
+
*/
|
|
3741
|
+
const dateTimeToISO = (dateTime) => dateTimeToDate(dateTime)?.toISOString() ?? null;
|
|
3742
|
+
//#endregion
|
|
3743
|
+
//#region src/utilities/dateToDateTime.ts
|
|
3744
|
+
/**
|
|
3745
|
+
* Converts a Date object into a plain object of its local date and time parts.
|
|
3746
|
+
*
|
|
3747
|
+
* @param date - The Date object to convert.
|
|
3748
|
+
* @returns The date parts, or null if the value is not a Date.
|
|
3749
|
+
*
|
|
3750
|
+
* @example
|
|
3751
|
+
* dateToDateTime(new Date(2011, 11, 15, 3, 10));
|
|
3752
|
+
* // { year: 2011, month: 11, dayOfMonth: 15, hours: 3, minutes: 10 }
|
|
3753
|
+
*/
|
|
3754
|
+
const dateToDateTime = (date) => {
|
|
3755
|
+
if (!isDate(date)) return null;
|
|
3756
|
+
return {
|
|
3757
|
+
year: date.getFullYear(),
|
|
3758
|
+
month: date.getMonth(),
|
|
3759
|
+
dayOfMonth: date.getDate(),
|
|
3760
|
+
hours: date.getHours(),
|
|
3761
|
+
minutes: date.getMinutes()
|
|
3762
|
+
};
|
|
3763
|
+
};
|
|
3764
|
+
//#endregion
|
|
3765
|
+
//#region src/utilities/dateTimeRounded.ts
|
|
3766
|
+
/**
|
|
3767
|
+
* Rounds a Date up to the next half hour boundary.
|
|
3768
|
+
*
|
|
3769
|
+
* @param dateTime - The Date to round.
|
|
3770
|
+
* @param toISOString - Whether to return an ISO-8601 string instead of a Date.
|
|
3771
|
+
* @returns The rounded value as a string or Date depending on toISOString.
|
|
3772
|
+
*
|
|
3773
|
+
* @example
|
|
3774
|
+
* dateTimeRounded(new Date(2015, 10, 7, 0, 10)); // '2015-11-07T00:30:00.000Z' (in UTC)
|
|
3775
|
+
* dateTimeRounded(new Date(2015, 10, 7, 0, 40), false); // new Date(2015, 10, 7, 1, 0)
|
|
3776
|
+
*/
|
|
3777
|
+
const dateTimeRounded = (dateTime, toISOString = true) => {
|
|
3778
|
+
const first30Min = dateTime.getMinutes() <= 30;
|
|
3779
|
+
const hours = first30Min ? dateTime.getHours() : dateTime.getHours() + 1;
|
|
3780
|
+
const minutes = first30Min ? 30 : 0;
|
|
3781
|
+
const dateWithTime = {
|
|
3782
|
+
...dateToDateTime(dateTime),
|
|
3783
|
+
hours,
|
|
3784
|
+
minutes
|
|
3785
|
+
};
|
|
3786
|
+
if (toISOString) return dateTimeToISO(dateWithTime);
|
|
3787
|
+
return dateTimeToDate(dateWithTime);
|
|
3788
|
+
};
|
|
3789
|
+
//#endregion
|
|
3790
|
+
//#region src/utilities/dateTimeString.ts
|
|
3791
|
+
/**
|
|
3792
|
+
* Converts a Date, timestamp, or date string into a date and time string,
|
|
3793
|
+
* e.g. 'Jun 3, 2021, 11:52 AM'. Formats with the en-US locale.
|
|
3794
|
+
*
|
|
3795
|
+
* NOTE: you should probably use timeAgoString when trying to display
|
|
3796
|
+
* an updated/created timestamp.
|
|
3797
|
+
*
|
|
3798
|
+
* @param date - The Date, timestamp, or date string to format; gracefully handles any value.
|
|
3799
|
+
* @param options - Formatting options.
|
|
3800
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3801
|
+
* @param options.omitYear - If true, display the date without the year.
|
|
3802
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3803
|
+
*
|
|
3804
|
+
* @example
|
|
3805
|
+
* dateTimeString(new Date(2011, 11, 15, 7, 30)); // 'Dec 15, 2011, 7:30 AM'
|
|
3806
|
+
*/
|
|
3807
|
+
const dateTimeString = (date, { timeZone = defaultTimeZone, omitYear = false } = {}) => {
|
|
3808
|
+
if (isNil(date)) return "";
|
|
3809
|
+
const formattedDate = new Date(date);
|
|
3810
|
+
if (isInvalidDate(formattedDate)) return "";
|
|
3811
|
+
try {
|
|
3812
|
+
const baseOptions = {
|
|
3813
|
+
month: "short",
|
|
3814
|
+
day: "numeric",
|
|
3815
|
+
hour: "numeric",
|
|
3816
|
+
minute: "2-digit",
|
|
3817
|
+
timeZone
|
|
3818
|
+
};
|
|
3819
|
+
const options = omitYear ? baseOptions : {
|
|
3820
|
+
...baseOptions,
|
|
3821
|
+
year: "numeric"
|
|
3822
|
+
};
|
|
3823
|
+
return formattedDate.toLocaleDateString(defaultLocales, options);
|
|
3824
|
+
} catch (error) {
|
|
3825
|
+
console.error(error);
|
|
3826
|
+
return "";
|
|
3827
|
+
}
|
|
3828
|
+
};
|
|
3829
|
+
//#endregion
|
|
3830
|
+
//#region src/utilities/dateTimeStringForSentence.ts
|
|
3831
|
+
/**
|
|
3832
|
+
* Converts a Date object into a date and time string for use in a sentence,
|
|
3833
|
+
* e.g. 'June 3, 2021, 11:52 AM'. Formats with the en-US locale.
|
|
3834
|
+
*
|
|
3835
|
+
* NOTE: you should probably use timeAgoString when trying to display
|
|
3836
|
+
* an updated/created timestamp.
|
|
3837
|
+
*
|
|
3838
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
3839
|
+
* @param options - Formatting options.
|
|
3840
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3841
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
3842
|
+
*
|
|
3843
|
+
* @example
|
|
3844
|
+
* dateTimeStringForSentence(new Date(2011, 11, 15, 7, 30)); // 'December 15, 2011, 7:30 AM'
|
|
3845
|
+
*/
|
|
3846
|
+
const dateTimeStringForSentence = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
3847
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
3848
|
+
try {
|
|
3849
|
+
const { year, month, day, hour, minute, dayPeriod } = new Intl.DateTimeFormat(defaultLocales, {
|
|
3850
|
+
month: "long",
|
|
3851
|
+
day: "numeric",
|
|
3852
|
+
year: "numeric",
|
|
3853
|
+
hour: "numeric",
|
|
3854
|
+
minute: "2-digit",
|
|
3855
|
+
timeZone
|
|
3856
|
+
}).formatToParts(date).reduce((acc, part) => {
|
|
3857
|
+
if (part.type !== "literal") acc[part.type] = part.value;
|
|
3858
|
+
return acc;
|
|
3859
|
+
}, {});
|
|
3860
|
+
return `${month} ${day}, ${year}, ${hour}:${minute} ${dayPeriod}`;
|
|
3861
|
+
} catch (error) {
|
|
3862
|
+
console.error(error);
|
|
3863
|
+
return "";
|
|
3864
|
+
}
|
|
3865
|
+
};
|
|
3866
|
+
//#endregion
|
|
3867
|
+
//#region src/utilities/dateUTCOffset.ts
|
|
3868
|
+
/**
|
|
3869
|
+
* Given a date, shows the UTC offset of the current time zone, e.g. '+02:00'.
|
|
3870
|
+
*
|
|
3871
|
+
* @param date - The Date to calculate the offset for.
|
|
3872
|
+
* @returns The UTC offset string.
|
|
3873
|
+
*
|
|
3874
|
+
* @example
|
|
3875
|
+
* dateUTCOffset(new Date(2011, 11, 15)); // '+00:00' (when run in UTC)
|
|
3876
|
+
*/
|
|
3877
|
+
const dateUTCOffset = (date) => {
|
|
3878
|
+
const offsetInHours = date.getTimezoneOffset() / 60 * -1;
|
|
3879
|
+
const hours = Math.round(offsetInHours);
|
|
3880
|
+
const minutes = (offsetInHours - hours) * 60;
|
|
3881
|
+
return `${hours >= 0 ? "+" : ""}${`${hours}`.padStart(2, "0")}:${`${minutes}`.padStart(2, "0")}`;
|
|
3882
|
+
};
|
|
3883
|
+
//#endregion
|
|
3884
|
+
//#region src/utilities/dayOfWeekString.ts
|
|
3885
|
+
/**
|
|
3886
|
+
* Converts a Date object into a day of the week string, e.g. 'Thursday'.
|
|
3887
|
+
* Formats with the en-US locale.
|
|
3888
|
+
*
|
|
3889
|
+
* @param date - The Date to format.
|
|
3890
|
+
* @param options - Formatting options.
|
|
3891
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
3892
|
+
* @returns The formatted day of the week, or '' for null or invalid input.
|
|
3893
|
+
*
|
|
3894
|
+
* @example
|
|
3895
|
+
* dayOfWeekString(new Date(2011, 11, 15)); // 'Thursday'
|
|
3896
|
+
*/
|
|
3897
|
+
const dayOfWeekString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
3898
|
+
if (date === null) return "";
|
|
3899
|
+
try {
|
|
3900
|
+
return new Intl.DateTimeFormat(defaultLocales, {
|
|
3901
|
+
weekday: "long",
|
|
3902
|
+
timeZone
|
|
3903
|
+
}).format(date);
|
|
3904
|
+
} catch (error) {
|
|
3905
|
+
console.error(error);
|
|
3906
|
+
return "";
|
|
3907
|
+
}
|
|
3908
|
+
};
|
|
3909
|
+
//#endregion
|
|
3910
|
+
//#region src/utilities/deepMerge.ts
|
|
3911
|
+
const UNSAFE_KEYS = /* @__PURE__ */ new Set([
|
|
3912
|
+
"__proto__",
|
|
3913
|
+
"constructor",
|
|
3914
|
+
"prototype"
|
|
3915
|
+
]);
|
|
3916
|
+
const cloneIfArray = (value) => isArray(value) ? [...value] : value;
|
|
3917
|
+
/**
|
|
3918
|
+
* Deeply merges objects without mutating them, inferring the return type from
|
|
3919
|
+
* the inputs. Plain objects are merged recursively, arrays are concatenated
|
|
3920
|
+
* with duplicate items removed (by reference for object items), and all other
|
|
3921
|
+
* values (including class instances) are overwritten in the order of the
|
|
3922
|
+
* provided arguments. The prototype-polluting keys `__proto__`, `constructor`,
|
|
3923
|
+
* and `prototype` are dropped. Symbol-keyed properties are not merged.
|
|
3924
|
+
*
|
|
3925
|
+
* @param objects - The objects to merge.
|
|
3926
|
+
* @returns A new object containing the merged result.
|
|
3927
|
+
* @throws TypeError when an argument is an array.
|
|
3928
|
+
*
|
|
3929
|
+
* @example
|
|
3930
|
+
* deepMerge({ a: { b: 1 }, c: [1] }, { a: { d: 2 }, c: [2] });
|
|
3931
|
+
* // { a: { b: 1, d: 2 }, c: [1, 2] }
|
|
3932
|
+
*/
|
|
3933
|
+
const deepMerge = (...objects) => {
|
|
3934
|
+
const result = {};
|
|
3935
|
+
for (const current of objects) {
|
|
3936
|
+
if (isArray(current)) throw new TypeError("Arguments provided to deepMerge must be objects, not arrays.");
|
|
3937
|
+
const safeKeys = Object.keys(current).filter((key) => !UNSAFE_KEYS.has(key));
|
|
3938
|
+
for (const key of safeKeys) {
|
|
3939
|
+
const existing = result[key];
|
|
3940
|
+
const incoming = current[key];
|
|
3941
|
+
if (isArray(existing) && isArray(incoming)) result[key] = [.../* @__PURE__ */ new Set([...existing, ...incoming])];
|
|
3942
|
+
else if (isPlainObject(existing) && isPlainObject(incoming)) result[key] = deepMerge(existing, incoming);
|
|
3943
|
+
else if (isPlainObject(incoming)) result[key] = deepMerge(incoming);
|
|
3944
|
+
else result[key] = cloneIfArray(incoming);
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
return result;
|
|
3948
|
+
};
|
|
3949
|
+
//#endregion
|
|
3950
|
+
//#region src/utilities/getObjectEntries.ts
|
|
3951
|
+
/**
|
|
3952
|
+
* Returns the entries of an object with strongly typed keys and values.
|
|
3953
|
+
*
|
|
3954
|
+
* @param obj - The object to get entries from.
|
|
3955
|
+
* @returns An array of [key, value] tuples.
|
|
3956
|
+
*
|
|
3957
|
+
* @example
|
|
3958
|
+
* getObjectEntries({ a: 1, b: 2 }); // [['a', 1], ['b', 2]]
|
|
3959
|
+
*/
|
|
3960
|
+
const getObjectEntries = (obj) => Object.keys(obj).map((key) => [key, obj[key]]);
|
|
3961
|
+
//#endregion
|
|
3962
|
+
//#region src/utilities/getObjectKeys.ts
|
|
3963
|
+
/**
|
|
3964
|
+
* Returns the keys of an object with strongly typed key type.
|
|
3965
|
+
*
|
|
3966
|
+
* @param obj - The object to get keys from.
|
|
3967
|
+
* @returns An array of the object's keys.
|
|
3968
|
+
*
|
|
3969
|
+
* @example
|
|
3970
|
+
* getObjectKeys({ a: 1, b: 2 }); // ['a', 'b']
|
|
3971
|
+
*/
|
|
3972
|
+
const getObjectKeys = (obj) => Object.keys(obj);
|
|
3973
|
+
//#endregion
|
|
3974
|
+
//#region src/utilities/getObjectValues.ts
|
|
3975
|
+
/**
|
|
3976
|
+
* Returns the values of an object with strongly typed value type.
|
|
3977
|
+
*
|
|
3978
|
+
* @param obj - The object to get values from.
|
|
3979
|
+
* @returns An array of the object's values.
|
|
3980
|
+
*
|
|
3981
|
+
* @example
|
|
3982
|
+
* getObjectValues({ a: 1, b: 2 }); // [1, 2]
|
|
3983
|
+
*/
|
|
3984
|
+
const getObjectValues = (obj) => Object.values(obj);
|
|
3985
|
+
//#endregion
|
|
3986
|
+
//#region src/utilities/isEmail.ts
|
|
3987
|
+
/**
|
|
3988
|
+
* Loosely validates an email address string.
|
|
3989
|
+
*
|
|
3990
|
+
* @param value - The string to validate.
|
|
3991
|
+
* @returns True if the string appears to be an email address, false otherwise.
|
|
3992
|
+
*
|
|
3993
|
+
* @example
|
|
3994
|
+
* isEmail('user@example.com'); // true
|
|
3995
|
+
* isEmail('user@example'); // false
|
|
3996
|
+
*/
|
|
3997
|
+
const isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
|
|
3998
|
+
//#endregion
|
|
3999
|
+
//#region src/utilities/isUrl.ts
|
|
4000
|
+
/**
|
|
4001
|
+
* Loosely validates a URL string.
|
|
4002
|
+
*
|
|
4003
|
+
* @param value - The value to validate.
|
|
4004
|
+
* @returns True if the value appears to be a URL, false otherwise.
|
|
4005
|
+
*
|
|
4006
|
+
* @example
|
|
4007
|
+
* isUrl('https://wistia.com'); // true
|
|
4008
|
+
* isUrl('not a url'); // false
|
|
4009
|
+
*/
|
|
4010
|
+
const isUrl = (value) => {
|
|
4011
|
+
const protocolAndDomain = /^(?:\w+:)?\/\/(\S+)$/;
|
|
4012
|
+
const localhostDomain = /^localhost[:?\d]*(?:[^:?\d]\S*)?$/;
|
|
4013
|
+
const nonLocalhostDomain = /^[^\s.]+\.\S{2,}$/;
|
|
4014
|
+
if (!isString(value)) return false;
|
|
4015
|
+
const remaining = protocolAndDomain.exec(value)?.[1];
|
|
4016
|
+
if (remaining === void 0) return false;
|
|
4017
|
+
return localhostDomain.test(remaining) || nonLocalhostDomain.test(remaining);
|
|
4018
|
+
};
|
|
4019
|
+
//#endregion
|
|
4020
|
+
//#region src/utilities/_padTimeInteger.ts
|
|
4021
|
+
/**
|
|
4022
|
+
* Pads an integer with a leading zero.
|
|
4023
|
+
*
|
|
4024
|
+
* @param num - The integer to pad.
|
|
4025
|
+
* @returns The integer as a string with padding.
|
|
4026
|
+
*/
|
|
4027
|
+
const padTimeInteger = (num) => num.toString().padStart(2, "0");
|
|
4028
|
+
//#endregion
|
|
4029
|
+
//#region src/utilities/mediaDurationString.ts
|
|
4030
|
+
/**
|
|
4031
|
+
* A string representation of a duration for a media. Assumes most medias
|
|
4032
|
+
* are under an hour so only shows hours if media is over an hour.
|
|
4033
|
+
*
|
|
4034
|
+
* @param numberOfMilliseconds - The duration in milliseconds.
|
|
4035
|
+
* @returns The formatted duration string.
|
|
4036
|
+
*
|
|
4037
|
+
* @example
|
|
4038
|
+
* mediaDurationString(234230); // '3:54'
|
|
4039
|
+
* mediaDurationString(23423000); // '6:30:23'
|
|
4040
|
+
*/
|
|
4041
|
+
const mediaDurationString = (numberOfMilliseconds) => {
|
|
4042
|
+
const { hours, minutes, seconds } = buildTimeDuration(numberOfMilliseconds);
|
|
4043
|
+
if (hours < 1) return `${minutes}:${padTimeInteger(seconds)}`;
|
|
4044
|
+
return `${hours}:${padTimeInteger(minutes)}:${padTimeInteger(seconds)}`;
|
|
4045
|
+
};
|
|
4046
|
+
//#endregion
|
|
4047
|
+
//#region src/utilities/millisecondsToDurationISOString.ts
|
|
4048
|
+
/**
|
|
4049
|
+
* Given a number of milliseconds, returns the ISO 8601 duration string
|
|
4050
|
+
* rounded down from the number of seconds.
|
|
4051
|
+
*
|
|
4052
|
+
* @param numberOfMilliseconds - The duration in milliseconds.
|
|
4053
|
+
* @returns The ISO 8601 duration string.
|
|
4054
|
+
*
|
|
4055
|
+
* @example
|
|
4056
|
+
* millisecondsToDurationISOString(33000); // 'PT33S'
|
|
4057
|
+
* millisecondsToDurationISOString(3605000); // 'PT1H5S'
|
|
4058
|
+
*/
|
|
4059
|
+
const millisecondsToDurationISOString = (numberOfMilliseconds) => {
|
|
4060
|
+
const { seconds, minutes, hours } = buildTimeDuration(numberOfMilliseconds);
|
|
4061
|
+
let string = "PT";
|
|
4062
|
+
if (hours) string += `${hours}H`;
|
|
4063
|
+
if (minutes) string += `${minutes}M`;
|
|
4064
|
+
if (seconds) string += `${seconds}S`;
|
|
4065
|
+
if (!(seconds || minutes || hours)) string += "0S";
|
|
4066
|
+
return string;
|
|
4067
|
+
};
|
|
4068
|
+
//#endregion
|
|
4069
|
+
//#region src/utilities/monthDayStringNumeric.ts
|
|
4070
|
+
/**
|
|
4071
|
+
* Converts a Date object into a month and day string formatted numerically,
|
|
4072
|
+
* e.g. '06/03'. Formats with the en-US locale.
|
|
4073
|
+
*
|
|
4074
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
4075
|
+
* @param options - Formatting options.
|
|
4076
|
+
* @param options.timeZone - The time zone to display the date in. Defaults to the current time zone.
|
|
4077
|
+
* @returns The formatted date string, or '' for invalid input.
|
|
4078
|
+
*
|
|
4079
|
+
* @example
|
|
4080
|
+
* monthDayStringNumeric(new Date(2011, 11, 15)); // '12/15'
|
|
4081
|
+
*/
|
|
4082
|
+
const monthDayStringNumeric = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
4083
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
4084
|
+
try {
|
|
4085
|
+
return new Intl.DateTimeFormat(defaultLocales, {
|
|
4086
|
+
month: "2-digit",
|
|
4087
|
+
day: "2-digit",
|
|
4088
|
+
timeZone
|
|
4089
|
+
}).format(date);
|
|
4090
|
+
} catch (error) {
|
|
4091
|
+
console.error(error);
|
|
4092
|
+
return "";
|
|
4093
|
+
}
|
|
4094
|
+
};
|
|
4095
|
+
//#endregion
|
|
4096
|
+
//#region src/utilities/noOpFn.ts
|
|
4097
|
+
/**
|
|
4098
|
+
* A function that does nothing. Useful as a default or placeholder callback.
|
|
4099
|
+
*
|
|
4100
|
+
* @returns Nothing.
|
|
4101
|
+
*
|
|
4102
|
+
* @example
|
|
4103
|
+
* noOpFn(); // undefined
|
|
4104
|
+
*/
|
|
4105
|
+
const noOpFn = () => {};
|
|
4106
|
+
//#endregion
|
|
4107
|
+
//#region src/utilities/noOpFnReturningFalse.ts
|
|
4108
|
+
/**
|
|
4109
|
+
* A function that does nothing and returns `false`. Useful as a default or
|
|
4110
|
+
* placeholder callback where `false` is expected.
|
|
4111
|
+
*
|
|
4112
|
+
* @returns `false`.
|
|
4113
|
+
*
|
|
4114
|
+
* @example
|
|
4115
|
+
* noOpFnReturningFalse(); // false
|
|
4116
|
+
*/
|
|
4117
|
+
const noOpFnReturningFalse = () => false;
|
|
4118
|
+
//#endregion
|
|
4119
|
+
//#region src/utilities/noOpFnReturningNull.ts
|
|
4120
|
+
/**
|
|
4121
|
+
* A function that does nothing and returns `null`. Useful as a default or
|
|
4122
|
+
* placeholder callback where `null` is expected.
|
|
4123
|
+
*
|
|
4124
|
+
* @returns `null`.
|
|
4125
|
+
*
|
|
4126
|
+
* @example
|
|
4127
|
+
* noOpFnReturningNull(); // null
|
|
4128
|
+
*/
|
|
4129
|
+
const noOpFnReturningNull = () => null;
|
|
4130
|
+
//#endregion
|
|
4131
|
+
//#region src/utilities/parseDateString.ts
|
|
4132
|
+
const MONTH_NAMES = (/* unused pure expression or super */ null && ([
|
|
4133
|
+
"January",
|
|
4134
|
+
"February",
|
|
4135
|
+
"March",
|
|
4136
|
+
"April",
|
|
4137
|
+
"May",
|
|
4138
|
+
"June",
|
|
4139
|
+
"July",
|
|
4140
|
+
"August",
|
|
4141
|
+
"September",
|
|
4142
|
+
"October",
|
|
4143
|
+
"November",
|
|
4144
|
+
"December"
|
|
4145
|
+
]));
|
|
4146
|
+
const startOfDay = (date) => {
|
|
4147
|
+
const result = new Date(date);
|
|
4148
|
+
result.setHours(0, 0, 0, 0);
|
|
4149
|
+
return result;
|
|
4150
|
+
};
|
|
4151
|
+
const startOfToday = () => startOfDay(/* @__PURE__ */ new Date());
|
|
4152
|
+
const startOfTomorrow = () => {
|
|
4153
|
+
const tomorrow = startOfToday();
|
|
4154
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
4155
|
+
return tomorrow;
|
|
4156
|
+
};
|
|
4157
|
+
const monthIndexIn = (names, value) => names.findIndex((name) => name.toLowerCase() === value.toLowerCase());
|
|
4158
|
+
const toNumberOrUndefined = (value) => value === void 0 ? void 0 : Number(value);
|
|
4159
|
+
const buildDatePatterns = () => {
|
|
4160
|
+
const monthAbbreviations = MONTH_NAMES.map((name) => name.slice(0, 3));
|
|
4161
|
+
return [
|
|
4162
|
+
{
|
|
4163
|
+
regex: new RegExp(`^(${monthAbbreviations.join("|")}) (\\d{1,2})(?:, (\\d{1,4}))?$`, "i"),
|
|
4164
|
+
toParts: ([, month, day, year]) => ({
|
|
4165
|
+
monthIndex: monthIndexIn(monthAbbreviations, String(month)),
|
|
4166
|
+
day: Number(day),
|
|
4167
|
+
year: toNumberOrUndefined(year)
|
|
4168
|
+
})
|
|
4169
|
+
},
|
|
4170
|
+
{
|
|
4171
|
+
regex: new RegExp(`^(${MONTH_NAMES.join("|")}) (\\d{1,2})(?:, (\\d{1,4}))?$`, "i"),
|
|
4172
|
+
toParts: ([, month, day, year]) => ({
|
|
4173
|
+
monthIndex: monthIndexIn(MONTH_NAMES, String(month)),
|
|
4174
|
+
day: Number(day),
|
|
4175
|
+
year: toNumberOrUndefined(year)
|
|
4176
|
+
})
|
|
4177
|
+
},
|
|
4178
|
+
{
|
|
4179
|
+
regex: /^(\d{1,2})\/(\d{1,2})(?:\/(\d{1,4}))?$/,
|
|
4180
|
+
toParts: ([, month, day, year]) => ({
|
|
4181
|
+
monthIndex: Number(month) - 1,
|
|
4182
|
+
day: Number(day),
|
|
4183
|
+
year: toNumberOrUndefined(year)
|
|
4184
|
+
})
|
|
4185
|
+
},
|
|
4186
|
+
{
|
|
4187
|
+
regex: /^(\d{1,2})-(\d{1,2})(?:-(\d{1,4}))?$/,
|
|
4188
|
+
toParts: ([, month, day, year]) => ({
|
|
4189
|
+
monthIndex: Number(month) - 1,
|
|
4190
|
+
day: Number(day),
|
|
4191
|
+
year: toNumberOrUndefined(year)
|
|
4192
|
+
})
|
|
4193
|
+
},
|
|
4194
|
+
{
|
|
4195
|
+
regex: /^(\d{1,4})-(\d{1,2})-(\d{1,2})$/,
|
|
4196
|
+
toParts: ([, year, month, day]) => ({
|
|
4197
|
+
monthIndex: Number(month) - 1,
|
|
4198
|
+
day: Number(day),
|
|
4199
|
+
year: Number(year)
|
|
4200
|
+
})
|
|
4201
|
+
}
|
|
4202
|
+
];
|
|
4203
|
+
};
|
|
4204
|
+
const DATE_PATTERNS = /* @__PURE__ */ (/* unused pure expression or super */ null && (buildDatePatterns()));
|
|
4205
|
+
const toValidDate = ({ monthIndex, day, year }, referenceDate) => {
|
|
4206
|
+
if (year === 0) return null;
|
|
4207
|
+
const resolvedYear = year ?? referenceDate.getFullYear();
|
|
4208
|
+
const date = new Date(referenceDate.getFullYear(), 0, 1);
|
|
4209
|
+
date.setFullYear(resolvedYear, monthIndex, day);
|
|
4210
|
+
return date.getFullYear() === resolvedYear && date.getMonth() === monthIndex && date.getDate() === day ? date : null;
|
|
4211
|
+
};
|
|
4212
|
+
/**
|
|
4213
|
+
* Loosely parses a human-entered date string into a Date at local midnight.
|
|
4214
|
+
* Accepts 'today' and 'tomorrow', month name prefixes (resolved to the next
|
|
4215
|
+
* 1st of that month), and common numeric and month-name formats, with a
|
|
4216
|
+
* native Date fallback for anything else.
|
|
4217
|
+
*
|
|
4218
|
+
* @param str - The date string to parse.
|
|
4219
|
+
* @returns The parsed Date at local midnight, or null if unparseable.
|
|
4220
|
+
*
|
|
4221
|
+
* @example
|
|
4222
|
+
* parseDateString('Jan 5, 2025'); // Date for 2025-01-05 at local midnight
|
|
4223
|
+
* parseDateString('garbage'); // null
|
|
4224
|
+
*/
|
|
4225
|
+
const parseDateString = (str) => {
|
|
4226
|
+
const trimmed = str.trim();
|
|
4227
|
+
if (!trimmed) return null;
|
|
4228
|
+
const lower = trimmed.toLowerCase();
|
|
4229
|
+
if (lower === "today") return startOfToday();
|
|
4230
|
+
if (lower === "tomorrow") return startOfTomorrow();
|
|
4231
|
+
const monthIndex = MONTH_NAMES.findIndex((name) => name.toLowerCase().startsWith(lower));
|
|
4232
|
+
if (monthIndex !== -1) {
|
|
4233
|
+
const today = startOfToday();
|
|
4234
|
+
let date = new Date(today.getFullYear(), monthIndex, 1);
|
|
4235
|
+
if (date.getTime() < Date.now()) date = new Date(today.getFullYear() + 1, monthIndex, 1);
|
|
4236
|
+
return date;
|
|
4237
|
+
}
|
|
4238
|
+
const referenceDate = /* @__PURE__ */ new Date();
|
|
4239
|
+
for (const { regex, toParts } of DATE_PATTERNS) {
|
|
4240
|
+
const match = trimmed.match(regex);
|
|
4241
|
+
if (match) {
|
|
4242
|
+
const parsed = toValidDate(toParts(match), referenceDate);
|
|
4243
|
+
if (parsed !== null) return parsed;
|
|
4244
|
+
}
|
|
4245
|
+
}
|
|
4246
|
+
const native = new Date(trimmed);
|
|
4247
|
+
if (!Number.isNaN(native.getTime())) return startOfDay(native);
|
|
4248
|
+
return null;
|
|
4249
|
+
};
|
|
4250
|
+
//#endregion
|
|
4251
|
+
//#region src/utilities/sessionDurationString.ts
|
|
4252
|
+
/**
|
|
4253
|
+
* A string representation of a duration for a user session. Assumes that
|
|
4254
|
+
* sessions may or may not be more than an hour. To prevent confusion all
|
|
4255
|
+
* times show hours, even those that are less than an hour.
|
|
4256
|
+
*
|
|
4257
|
+
* @param numberOfMilliseconds - The duration in milliseconds.
|
|
4258
|
+
* @returns The formatted duration string.
|
|
4259
|
+
*
|
|
4260
|
+
* @example
|
|
4261
|
+
* sessionDurationString(2342300); // '0:39:02'
|
|
4262
|
+
*/
|
|
4263
|
+
const sessionDurationString = (numberOfMilliseconds) => {
|
|
4264
|
+
const { hours, minutes, seconds } = buildTimeDuration(numberOfMilliseconds);
|
|
4265
|
+
return `${hours}:${padTimeInteger(minutes)}:${padTimeInteger(seconds)}`;
|
|
4266
|
+
};
|
|
4267
|
+
//#endregion
|
|
4268
|
+
//#region src/utilities/stripExtension.ts
|
|
4269
|
+
/**
|
|
4270
|
+
* Removes the file extension from a string.
|
|
4271
|
+
*
|
|
4272
|
+
* @param str - The string to remove the file extension from.
|
|
4273
|
+
* @returns The string without its file extension.
|
|
4274
|
+
*
|
|
4275
|
+
* @example
|
|
4276
|
+
* stripExtension('config.yml'); // 'config'
|
|
4277
|
+
* stripExtension('example.test.ts'); // 'example.test'
|
|
4278
|
+
*/
|
|
4279
|
+
const stripExtension = (str) => (str || "").replace(/\.[^/.]{1,4}$/, "");
|
|
4280
|
+
//#endregion
|
|
4281
|
+
//#region src/utilities/_getLocalDateParts.ts
|
|
4282
|
+
/**
|
|
4283
|
+
* Get local year, month, day parts from a Date using Intl.DateTimeFormat.
|
|
4284
|
+
* This ignores the time of day (hours, minutes, etc.).
|
|
4285
|
+
*
|
|
4286
|
+
* @param date - The Date to extract parts from.
|
|
4287
|
+
* @returns The numeric year, month (1-based) and day.
|
|
4288
|
+
*/
|
|
4289
|
+
const getLocalDateParts = (date) => {
|
|
4290
|
+
const partsAsObject = new Intl.DateTimeFormat(defaultLocales, {
|
|
4291
|
+
year: "numeric",
|
|
4292
|
+
month: "numeric",
|
|
4293
|
+
day: "numeric",
|
|
4294
|
+
timeZone: defaultTimeZone
|
|
4295
|
+
}).formatToParts(date).reduce((map, part) => {
|
|
4296
|
+
map[part.type] = part.value;
|
|
4297
|
+
return map;
|
|
4298
|
+
}, {});
|
|
4299
|
+
return {
|
|
4300
|
+
year: Math.trunc(Number(partsAsObject.year)),
|
|
4301
|
+
month: Math.trunc(Number(partsAsObject.month)),
|
|
4302
|
+
day: Math.trunc(Number(partsAsObject.day))
|
|
4303
|
+
};
|
|
4304
|
+
};
|
|
4305
|
+
//#endregion
|
|
4306
|
+
//#region src/utilities/_differenceInCalendarDays.ts
|
|
4307
|
+
/**
|
|
4308
|
+
* Returns the difference in calendar days between two dates in local time,
|
|
4309
|
+
* ignoring the time of day.
|
|
4310
|
+
*
|
|
4311
|
+
* @param dateLeft - The later date (or timestamp).
|
|
4312
|
+
* @param dateRight - The earlier date (or timestamp).
|
|
4313
|
+
* @returns The number of calendar days (can be negative).
|
|
4314
|
+
*/
|
|
4315
|
+
const differenceInCalendarDays = (dateLeft, dateRight) => {
|
|
4316
|
+
const leftDate = isDate(dateLeft) ? dateLeft : new Date(dateLeft);
|
|
4317
|
+
const rightDate = isDate(dateRight) ? dateRight : new Date(dateRight);
|
|
4318
|
+
if (Number.isNaN(leftDate.getTime()) || Number.isNaN(rightDate.getTime())) return NaN;
|
|
4319
|
+
const { year: y1, month: m1, day: d1 } = getLocalDateParts(leftDate);
|
|
4320
|
+
const { year: y2, month: m2, day: d2 } = getLocalDateParts(rightDate);
|
|
4321
|
+
const msDiff = new Date(y1, m1 - 1, d1).getTime() - new Date(y2, m2 - 1, d2).getTime();
|
|
4322
|
+
return Math.round(msDiff / millisecondsInDay);
|
|
4323
|
+
};
|
|
4324
|
+
//#endregion
|
|
4325
|
+
//#region src/utilities/timeAgoString.ts
|
|
4326
|
+
/**
|
|
4327
|
+
* Shows time ago relative to current time, e.g. '< 1 minute ago',
|
|
4328
|
+
* '33 minutes ago', 'Today, 3:30 PM', 'Yesterday, 6:22 AM',
|
|
4329
|
+
* 'Nov 11, 11:32 AM', or 'Feb 23, 2020, 1:55 PM'. When includeTime is
|
|
4330
|
+
* false: 'Today', 'Yesterday', 'on Thursday', 'Nov 11', 'Feb 23, 2020'.
|
|
4331
|
+
*
|
|
4332
|
+
* NOTE: timeAgoString doesn't support multiple time zones since doing so
|
|
4333
|
+
* would complicate calculations for whether to use "Today" or "Yesterday".
|
|
4334
|
+
*
|
|
4335
|
+
* @param date - The date relative to now.
|
|
4336
|
+
* @param options - Formatting options.
|
|
4337
|
+
* @param options.nowAnchor - The date used to calculate relative to now. Defaults to the current date but can be overwritten for tests.
|
|
4338
|
+
* @param options.includeTime - Whether to include the time in the output. Defaults to true.
|
|
4339
|
+
* @returns The relative date string, or '' for invalid input.
|
|
4340
|
+
*
|
|
4341
|
+
* @example
|
|
4342
|
+
* timeAgoString(new Date(Date.now() - 30_000)); // '< 1 minute ago'
|
|
4343
|
+
*/
|
|
4344
|
+
const timeAgoString = (date, { nowAnchor = /* @__PURE__ */ new Date(), includeTime = true } = {}) => {
|
|
4345
|
+
if (isInvalidDate(date)) return "";
|
|
4346
|
+
const minutesAgo = (nowAnchor.valueOf() - date.valueOf()) / (60 * milisecondsInSecond);
|
|
4347
|
+
const minutesAgoRounded = Math.round(minutesAgo);
|
|
4348
|
+
const differenceInDays = differenceInCalendarDays(nowAnchor, date);
|
|
4349
|
+
const isSameYear = date.getFullYear() === nowAnchor.getFullYear();
|
|
4350
|
+
if (minutesAgo < 0) return dateTimeString(date);
|
|
4351
|
+
if (minutesAgo < 1) return "< 1 minute ago";
|
|
4352
|
+
if (minutesAgoRounded < 2) return "1 minute ago";
|
|
4353
|
+
if (minutesAgoRounded <= 60) return `${minutesAgoRounded} minutes ago`;
|
|
4354
|
+
if (differenceInDays === 0) return includeTime ? `Today, ${Intl.DateTimeFormat(defaultLocales, {
|
|
4355
|
+
hour: "numeric",
|
|
4356
|
+
minute: "2-digit"
|
|
4357
|
+
}).format(date)}` : "Today";
|
|
4358
|
+
if (differenceInDays === 1) return includeTime ? `Yesterday, ${Intl.DateTimeFormat(defaultLocales, {
|
|
4359
|
+
hour: "numeric",
|
|
4360
|
+
minute: "2-digit"
|
|
4361
|
+
}).format(date)}` : "Yesterday";
|
|
4362
|
+
if (differenceInDays < 7 && !includeTime) return `on ${dayOfWeekString(date)}`;
|
|
4363
|
+
return includeTime ? dateTimeString(date, { omitYear: isSameYear }) : dateOnlyString(date, { omitYear: false });
|
|
4364
|
+
};
|
|
4365
|
+
//#endregion
|
|
4366
|
+
//#region src/utilities/timeOnlyString.ts
|
|
4367
|
+
/**
|
|
4368
|
+
* Converts a Date object into a time only string, e.g. '7:30 AM'.
|
|
4369
|
+
* Formats with the en-US locale.
|
|
4370
|
+
*
|
|
4371
|
+
* @param date - The Date to format; gracefully handles any value.
|
|
4372
|
+
* @param options - Formatting options.
|
|
4373
|
+
* @param options.timeZone - The time zone to display the time in. Defaults to the current time zone.
|
|
4374
|
+
* @returns The formatted time string, or '' for invalid input.
|
|
4375
|
+
*
|
|
4376
|
+
* @example
|
|
4377
|
+
* timeOnlyString(new Date(2011, 11, 15, 7, 30)); // '7:30 AM'
|
|
4378
|
+
*/
|
|
4379
|
+
const timeOnlyString = (date, { timeZone = defaultTimeZone } = {}) => {
|
|
4380
|
+
if (!isDate(date) || isInvalidDate(date)) return "";
|
|
4381
|
+
try {
|
|
4382
|
+
return new Intl.DateTimeFormat(defaultLocales, {
|
|
4383
|
+
timeStyle: "short",
|
|
4384
|
+
timeZone
|
|
4385
|
+
}).format(date);
|
|
4386
|
+
} catch (error) {
|
|
4387
|
+
console.error(error);
|
|
4388
|
+
return "";
|
|
4389
|
+
}
|
|
4390
|
+
};
|
|
4391
|
+
//#endregion
|
|
4392
|
+
//#region src/utilities/tupleIncludes.ts
|
|
4393
|
+
/**
|
|
4394
|
+
* Checks if a tuple includes the given item, with type narrowing.
|
|
4395
|
+
*
|
|
4396
|
+
* @param tuple - The tuple to search.
|
|
4397
|
+
* @param item - The item to search for.
|
|
4398
|
+
* @returns True if the tuple includes the item, false otherwise.
|
|
4399
|
+
*
|
|
4400
|
+
* @example
|
|
4401
|
+
* const tuple = ['x', 'y'] as const;
|
|
4402
|
+
* tupleIncludes(tuple, 'x'); // true
|
|
4403
|
+
* tupleIncludes(tuple, 'z'); // false
|
|
4404
|
+
*/
|
|
4405
|
+
const tupleIncludes = (tuple, item) => tuple.includes(item);
|
|
4406
|
+
//#endregion
|
|
4407
|
+
|
|
4408
|
+
|
|
4409
|
+
//# sourceMappingURL=index.mjs.map
|
|
4410
|
+
|
|
4411
|
+
/***/ },
|
|
4412
|
+
|
|
2563
4413
|
/***/ 2147
|
|
2564
4414
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
2565
4415
|
|
|
@@ -2780,7 +4630,7 @@ const unescapeHtml = (encodedHtmlStr, options = {}) => {
|
|
|
2780
4630
|
/* harmony export */ N7: () => (/* binding */ reportError)
|
|
2781
4631
|
/* harmony export */ });
|
|
2782
4632
|
/* unused harmony exports getRecentSentryEventIds, initializeSentry, listenForGlobalErrors, listenForGlobalUnhandledRejections */
|
|
2783
|
-
/* harmony import */ var
|
|
4633
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
2784
4634
|
/* harmony import */ var _globalBindAndTrigger_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4271);
|
|
2785
4635
|
/* harmony import */ var _trackingConsentApi_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4755);
|
|
2786
4636
|
/* harmony import */ var _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5509);
|
|
@@ -2842,7 +4692,7 @@ const rememberSentryEventId = eventId => {
|
|
|
2842
4692
|
}
|
|
2843
4693
|
};
|
|
2844
4694
|
const configureSentry = () => {
|
|
2845
|
-
if ((0,
|
|
4695
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.Sentry) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.Sentry.BrowserClient) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.Sentry.makeFetchTransport) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.Sentry.defaultStackParser) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.Sentry.Scope)) {
|
|
2846
4696
|
return;
|
|
2847
4697
|
}
|
|
2848
4698
|
|
|
@@ -2861,7 +4711,7 @@ const configureSentry = () => {
|
|
|
2861
4711
|
stackParser: window.Sentry.defaultStackParser,
|
|
2862
4712
|
integrations: [window.Sentry.httpContextIntegration()],
|
|
2863
4713
|
// Allow httpContextIntegration so we can collect URL, browser, and OS version information. No PII is included here.
|
|
2864
|
-
release: (0,
|
|
4714
|
+
release: (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNonEmptyString */ .uI)(_hosts_js__WEBPACK_IMPORTED_MODULE_5__/* .TAGGED_VERSION */ .U4) ? _hosts_js__WEBPACK_IMPORTED_MODULE_5__/* .TAGGED_VERSION */ .U4 : _hosts_js__WEBPACK_IMPORTED_MODULE_5__/* .CURRENT_SHA */ .lR
|
|
2865
4715
|
});
|
|
2866
4716
|
const scope = new window.Sentry.Scope();
|
|
2867
4717
|
scope.setClient(client);
|
|
@@ -2954,7 +4804,7 @@ const reportError = (product, error, details) => {
|
|
|
2954
4804
|
return;
|
|
2955
4805
|
}
|
|
2956
4806
|
let shouldSendToSentry = false;
|
|
2957
|
-
const cryptoObj = (0,
|
|
4807
|
+
const cryptoObj = (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(window.crypto) ? window.msCrypto : window.crypto;
|
|
2958
4808
|
if (cryptoObj !== undefined) {
|
|
2959
4809
|
const cryptoRandom = cryptoObj.getRandomValues(new Uint32Array(1));
|
|
2960
4810
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
@@ -2975,7 +4825,7 @@ const reportError = (product, error, details) => {
|
|
|
2975
4825
|
_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__/* .Wistia */ .s._sentryScope.clear();
|
|
2976
4826
|
_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__/* .Wistia */ .s._sentryScope.setTag('pillar', 'publish');
|
|
2977
4827
|
_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__/* .Wistia */ .s._sentryScope.setTag('product', product);
|
|
2978
|
-
if ((0,
|
|
4828
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNonEmptyRecord */ .uu)(details)) {
|
|
2979
4829
|
_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__/* .Wistia */ .s._sentryScope.setTags(details);
|
|
2980
4830
|
}
|
|
2981
4831
|
_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__/* .Wistia */ .s._sentryScope.setTag('url', window.location.href);
|
|
@@ -3034,10 +4884,11 @@ const listenForGlobalUnhandledRejections = () => {
|
|
|
3034
4884
|
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
3035
4885
|
|
|
3036
4886
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
4887
|
+
/* harmony export */ dn: () => (/* binding */ debrack),
|
|
3037
4888
|
/* harmony export */ ff: () => (/* binding */ proto),
|
|
3038
4889
|
/* harmony export */ s0: () => (/* binding */ Url)
|
|
3039
4890
|
/* harmony export */ });
|
|
3040
|
-
/* unused harmony exports queryParamsToObject, urlComponentToObject, objectToQueryParams, splitPath, joinPath, brack,
|
|
4891
|
+
/* unused harmony exports queryParamsToObject, urlComponentToObject, objectToQueryParams, splitPath, joinPath, brack, createUrl, parseUrl */
|
|
3041
4892
|
/* harmony import */ var utilities_obj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(731);
|
|
3042
4893
|
/* harmony import */ var utilities_wlog_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6637);
|
|
3043
4894
|
|
|
@@ -3661,7 +5512,7 @@ const updateLocalStorage = (ns, fn) => {
|
|
|
3661
5512
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3662
5513
|
/* harmony export */ j: () => (/* binding */ fetchMediaData)
|
|
3663
5514
|
/* harmony export */ });
|
|
3664
|
-
/* harmony import */ var
|
|
5515
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
3665
5516
|
/* harmony import */ var _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5509);
|
|
3666
5517
|
/* harmony import */ var _hosts_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5857);
|
|
3667
5518
|
/* harmony import */ var _media_data_transforms_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3917);
|
|
@@ -3683,19 +5534,19 @@ const fetchUnlocalizedMediaData = async (hashedId, options = {}) => {
|
|
|
3683
5534
|
if (mediaDataFromCache && options.skipCache !== true) {
|
|
3684
5535
|
return Promise.resolve(mediaDataFromCache);
|
|
3685
5536
|
}
|
|
3686
|
-
if ((0,
|
|
5537
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(_wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_1__/* .Wistia */ .s._mediaDataPromises[cacheKey]) && options.skipCache !== true) {
|
|
3687
5538
|
return _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_1__/* .Wistia */ .s._mediaDataPromises[cacheKey];
|
|
3688
5539
|
}
|
|
3689
5540
|
const host = (0,_hosts_js__WEBPACK_IMPORTED_MODULE_2__/* .mediaDataHost */ .Dd)(options);
|
|
3690
5541
|
const url = new window.URL(`https://${host}/embed/medias/${hashedId}.json`);
|
|
3691
|
-
if ((0,
|
|
5542
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(options.channelId)) {
|
|
3692
5543
|
url.searchParams.set('channelId', options.channelId.toString());
|
|
3693
5544
|
}
|
|
3694
5545
|
const channelPasswordParam = options.channelPassword ?? options.plugin?.passwordProtectedChannel?.password;
|
|
3695
|
-
if ((0,
|
|
5546
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(channelPasswordParam)) {
|
|
3696
5547
|
url.searchParams.set('channelPassword', channelPasswordParam);
|
|
3697
5548
|
}
|
|
3698
|
-
if ((0,
|
|
5549
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(options.password)) {
|
|
3699
5550
|
url.searchParams.set('password', options.password);
|
|
3700
5551
|
}
|
|
3701
5552
|
if (options.deferFetchingToCarousel) {
|
|
@@ -4157,7 +6008,7 @@ const getOrSetEmbedOptionStore = (id, options) => {
|
|
|
4157
6008
|
/* harmony export */ s3: () => (/* binding */ uncacheMediaData)
|
|
4158
6009
|
/* harmony export */ });
|
|
4159
6010
|
/* unused harmony exports cacheLiveStreamEventData, uncacheLiveStreamEventData, getLiveStreamEventDataFromCache, getCarouselDataFromCache, cacheCarouselData, uncacheCarouselData */
|
|
4160
|
-
/* harmony import */ var
|
|
6011
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
4161
6012
|
/* harmony import */ var _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5509);
|
|
4162
6013
|
/* harmony import */ var _wlog_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6637);
|
|
4163
6014
|
var _objectHasOwn = function (object, property) {
|
|
@@ -4171,7 +6022,7 @@ var _objectHasOwn = function (object, property) {
|
|
|
4171
6022
|
|
|
4172
6023
|
const getMediaDataFromCache = hashedId => {
|
|
4173
6024
|
const mediaData = _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_1__/* .Wistia */ .s._remoteData.get(`media_${hashedId}`);
|
|
4174
|
-
if ((0,
|
|
6025
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNil */ .gD)(mediaData)) return null;
|
|
4175
6026
|
|
|
4176
6027
|
// It's possible that we're caching a server error response as MediaData.
|
|
4177
6028
|
// If we find one of those places, log an error.
|
|
@@ -4228,7 +6079,7 @@ const uncacheCarouselData = hashedId => {
|
|
|
4228
6079
|
/* harmony export */ Vq: () => (/* binding */ shouldAddKeyMoments),
|
|
4229
6080
|
/* harmony export */ oG: () => (/* binding */ clipsFromChapters)
|
|
4230
6081
|
/* harmony export */ });
|
|
4231
|
-
/* harmony import */ var
|
|
6082
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
4232
6083
|
/* harmony import */ var _normalizeChapters_ts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9128);
|
|
4233
6084
|
|
|
4234
6085
|
|
|
@@ -4291,6 +6142,12 @@ const sortedFilteredChapters = chapterList => {
|
|
|
4291
6142
|
return true;
|
|
4292
6143
|
});
|
|
4293
6144
|
};
|
|
6145
|
+
// Removes every wtime key (wtime, wtime[0], wtime[0][1], ...) so setting a new
|
|
6146
|
+
// wtime leaves exactly one on the URL.
|
|
6147
|
+
const deleteTimeParams = url => {
|
|
6148
|
+
const keys = [...new Set(url.searchParams.keys())];
|
|
6149
|
+
keys.filter(key => /^wtime(\[|$)/.test(key)).forEach(key => url.searchParams.delete(key));
|
|
6150
|
+
};
|
|
4294
6151
|
const clipsFromChapters = (chapterList, baseUrl, mediaDuration) => {
|
|
4295
6152
|
if (!Array.isArray(chapterList) || chapterList.length === 0) {
|
|
4296
6153
|
return [];
|
|
@@ -4303,9 +6160,10 @@ const clipsFromChapters = (chapterList, baseUrl, mediaDuration) => {
|
|
|
4303
6160
|
const url = new window.URL(baseUrl);
|
|
4304
6161
|
const floorTime = Math.floor(time);
|
|
4305
6162
|
const nextChapter = chapters[index + 1];
|
|
4306
|
-
const endOffsetTime = (0,
|
|
6163
|
+
const endOffsetTime = (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(nextChapter) ? nextChapter.time : mediaDuration;
|
|
4307
6164
|
|
|
4308
6165
|
// wtime does not support decimals
|
|
6166
|
+
deleteTimeParams(url);
|
|
4309
6167
|
url.searchParams.set('wtime', `${floorTime}s`);
|
|
4310
6168
|
|
|
4311
6169
|
// https://schema.org/Clip
|
|
@@ -4323,6 +6181,7 @@ const clipsFromChapters = (chapterList, baseUrl, mediaDuration) => {
|
|
|
4323
6181
|
const seekToAction = () => {
|
|
4324
6182
|
const url = new window.URL(window.location.href);
|
|
4325
6183
|
// if wtime is already on the url as query param, it will be overwritten here. This is only for the JSON+LD though.
|
|
6184
|
+
deleteTimeParams(url);
|
|
4326
6185
|
url.searchParams.set('wtime', '{seek_to_second_number}');
|
|
4327
6186
|
return {
|
|
4328
6187
|
'@type': 'SeekToAction',
|
|
@@ -4563,7 +6422,7 @@ const extractEmailFromParams = pageUrl => {
|
|
|
4563
6422
|
/* harmony import */ var utilities_obj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(731);
|
|
4564
6423
|
/* harmony import */ var utilities_url_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2671);
|
|
4565
6424
|
/* harmony import */ var utilities_detect_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7231);
|
|
4566
|
-
/* harmony import */ var
|
|
6425
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2002);
|
|
4567
6426
|
/* harmony import */ var _assets_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7209);
|
|
4568
6427
|
|
|
4569
6428
|
|
|
@@ -4603,12 +6462,12 @@ const maybeCloneOriginalAsMp4 = (media, options = {}) => {
|
|
|
4603
6462
|
})];
|
|
4604
6463
|
};
|
|
4605
6464
|
const maybeAddChannelIdToEmbedOptions = (media, options = {}) => {
|
|
4606
|
-
if ((0,
|
|
6465
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_3__/* .isNotNil */ .n9)(options.channelId) && media.embedOptions) {
|
|
4607
6466
|
media.embedOptions.channelId = options.channelId;
|
|
4608
6467
|
}
|
|
4609
6468
|
};
|
|
4610
6469
|
const maybeAddChannelPasswordToEmbedOptions = (media, options = {}) => {
|
|
4611
|
-
if ((0,
|
|
6470
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_3__/* .isNotNil */ .n9)(options.channelPassword) && media.embedOptions) {
|
|
4612
6471
|
media.embedOptions.channelPassword = options.channelPassword;
|
|
4613
6472
|
}
|
|
4614
6473
|
};
|
|
@@ -6997,8 +8856,8 @@ const PROD_EMBED_HOST = 'embed.wistia.com';
|
|
|
6997
8856
|
const PROD_SSL_EMBED_HOST = 'embed-ssl.wistia.com';
|
|
6998
8857
|
const PROD_FASTLY_SSL_HOST = 'embed-fastly.wistia.com';
|
|
6999
8858
|
const SSL_EMBED_HOST = "embed-ssl.wistia.com";
|
|
7000
|
-
const TAGGED_VERSION = "0.
|
|
7001
|
-
const CURRENT_SHA = "
|
|
8859
|
+
const TAGGED_VERSION = "0.8.0" || 0;
|
|
8860
|
+
const CURRENT_SHA = "c4dfb97c74cd43828ca1b66be73cc7c693ee8695" || 0;
|
|
7002
8861
|
const DEFAULT_PROTOCOL = (() => {
|
|
7003
8862
|
if (typeof window !== 'undefined' && utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z === window && utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z.location) {
|
|
7004
8863
|
return utilities_root_js__WEBPACK_IMPORTED_MODULE_0__/* .root */ .z.location.protocol;
|
|
@@ -9316,7 +11175,7 @@ const setViewerPreference = (preference, value) => {
|
|
|
9316
11175
|
/* harmony export */ cG: () => (/* binding */ elemWidth),
|
|
9317
11176
|
/* harmony export */ lj: () => (/* binding */ elemInDom)
|
|
9318
11177
|
/* harmony export */ });
|
|
9319
|
-
/* unused harmony exports elemHtml, getCssTags, execCssTags, removeCssTags, elemFromObject, elemToObject, elemClone, elemAppend, elemPrepend, elemBefore, elemAfter, elemRemove, elemRemoveClass, elemAddClass, elemHasClass, elemClasses, elemStyle, propsWithVendorPrefixes, getComputedStyle, elemHeight, elemContainsOffset, elemScrollOffset, elemIsHidden, elemIsHiddenByStyle, getDeepActiveElement, elemIsDescendantOf, elemAncestorWithClass, elemAncestorHasClass, elemAncestors, elemIsInside, elemAnimate, elemBind, elemUnbind, elemUnbindAll, elemUnbindAllInside, elemBindKey, elemRebind, elemBindOnce, elemTrigger, fullscreenElement, elemRequestFullscreen, elemCancelFullscreen, elemStripEventAttributes, elemMutationObserver, docScrollTop, docScrollLeft, safeRequestAnimationFrame, formInputIsFocused, currentEventSource, inUserEventContext, getLastActiveEventAt */
|
|
11178
|
+
/* unused harmony exports elemHtml, getCssTags, execCssTags, removeCssTags, elemFromObject, elemToObject, elemClone, elemAppend, elemPrepend, elemBefore, elemAfter, elemRemove, elemRemoveClass, elemAddClass, elemHasClass, elemClasses, elemStyle, propsWithVendorPrefixes, getComputedStyle, elemHeight, elemContainsOffset, elemScrollOffset, elemIsHidden, elemIsHiddenByStyle, getDeepActiveElement, elemIsDescendantOf, elemAncestorWithClass, elemAncestorHasClass, elemAncestors, elemIsInside, elemIsInsideComposedTree, elemAnimate, elemBind, elemUnbind, elemUnbindAll, elemUnbindAllInside, elemBindKey, elemRebind, elemBindOnce, elemTrigger, fullscreenElement, elemRequestFullscreen, elemCancelFullscreen, elemStripEventAttributes, elemMutationObserver, docScrollTop, docScrollLeft, safeRequestAnimationFrame, formInputIsFocused, currentEventSource, inUserEventContext, getLastActiveEventAt */
|
|
9320
11179
|
/* harmony import */ var utilities_obj_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(731);
|
|
9321
11180
|
/* harmony import */ var utilities_pageLoaded_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(9562);
|
|
9322
11181
|
/* harmony import */ var utilities_detect_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7231);
|
|
@@ -9914,6 +11773,20 @@ const elemAncestors = elem => {
|
|
|
9914
11773
|
const elemIsInside = (elem, ancestor) => {
|
|
9915
11774
|
return elem === ancestor || elemIsDescendantOf(elem, ancestor);
|
|
9916
11775
|
};
|
|
11776
|
+
|
|
11777
|
+
// Like elemIsInside, but also climbs from a shadow root to its host, so an element inside a nested
|
|
11778
|
+
// web component counts as inside the elements that contain that component.
|
|
11779
|
+
const elemIsInsideComposedTree = (elem, ancestor) => {
|
|
11780
|
+
let current = elem;
|
|
11781
|
+
while (current) {
|
|
11782
|
+
if (elemIsInside(current, ancestor)) {
|
|
11783
|
+
return true;
|
|
11784
|
+
}
|
|
11785
|
+
const root = current.getRootNode();
|
|
11786
|
+
current = root instanceof ShadowRoot ? root.host : null;
|
|
11787
|
+
}
|
|
11788
|
+
return false;
|
|
11789
|
+
};
|
|
9917
11790
|
const getTransitionProp = (props, time, easing) => {
|
|
9918
11791
|
const result = [];
|
|
9919
11792
|
for (let prop in props) {
|
|
@@ -14325,7 +16198,7 @@ bindify(Bindings.prototype);
|
|
|
14325
16198
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
14326
16199
|
/* harmony export */ a: () => (/* binding */ normalizeChapters)
|
|
14327
16200
|
/* harmony export */ });
|
|
14328
|
-
/* harmony import */ var
|
|
16201
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2002);
|
|
14329
16202
|
// chapters has two ways of being defined in embed options.
|
|
14330
16203
|
// The current way is as an object inside `embedOptions.plugin`
|
|
14331
16204
|
// The old way was as root embed options like `chaptersOn` and `chapterList`.
|
|
@@ -14343,8 +16216,8 @@ const normalizeChapters = embedOptions => {
|
|
|
14343
16216
|
return plugin.chapters;
|
|
14344
16217
|
}
|
|
14345
16218
|
const areChaptersOn = chaptersOn === true || chaptersOn === 'true';
|
|
14346
|
-
if ((0,
|
|
14347
|
-
const hasChapters = (0,
|
|
16219
|
+
if ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(chapterList) || areChaptersOn) {
|
|
16220
|
+
const hasChapters = (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_0__/* .isNotNil */ .n9)(chapterList) && chapterList.length > 0;
|
|
14348
16221
|
const list = hasChapters ? chapterList : [];
|
|
14349
16222
|
return {
|
|
14350
16223
|
on: chaptersOn,
|
|
@@ -14831,74 +16704,6 @@ const PreloadThumbnail = ({
|
|
|
14831
16704
|
);
|
|
14832
16705
|
};
|
|
14833
16706
|
|
|
14834
|
-
/***/ },
|
|
14835
|
-
|
|
14836
|
-
/***/ 9814
|
|
14837
|
-
(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
|
|
14838
|
-
|
|
14839
|
-
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
14840
|
-
/* harmony export */ gD: () => (/* binding */ isNil),
|
|
14841
|
-
/* harmony export */ jw: () => (/* binding */ isEmptyString),
|
|
14842
|
-
/* harmony export */ n9: () => (/* binding */ isNotNil),
|
|
14843
|
-
/* harmony export */ uI: () => (/* binding */ isNonEmptyString),
|
|
14844
|
-
/* harmony export */ uu: () => (/* binding */ isNonEmptyRecord)
|
|
14845
|
-
/* harmony export */ });
|
|
14846
|
-
/* unused harmony exports hasKey, isArray, isBoolean, isEmptyArray, isEmptyRecord, isError, isFalsy, isFunction, isInteger, isNaN, isNonEmptyArray, isNotArray, isNotBoolean, isNotFunction, isNotNull, isNotNumber, isNotRecord, isNotString, isNotUndefined, isNotVoid, isNull, isNumber, isRecord, isString, isTruthy, isUndefined, isVoid */
|
|
14847
|
-
|
|
14848
|
-
/*
|
|
14849
|
-
* @license @wistia/type-guards v0.9.3
|
|
14850
|
-
*
|
|
14851
|
-
* Copyright (c) 2023-2025, Wistia, Inc. and its affiliates.
|
|
14852
|
-
*
|
|
14853
|
-
* This source code is unlicensed, all rights reserved.
|
|
14854
|
-
*/
|
|
14855
|
-
|
|
14856
|
-
|
|
14857
|
-
// index.ts
|
|
14858
|
-
var FALSY_VALUES = [false, 0, -0, 0n, "", null, void 0, Number.NaN];
|
|
14859
|
-
var isNull = (value) => value === null;
|
|
14860
|
-
var isNotNull = (value) => !isNull(value);
|
|
14861
|
-
var isUndefined = (value) => value === void 0;
|
|
14862
|
-
var isNotUndefined = (value) => !isUndefined(value);
|
|
14863
|
-
var isNil = (value) => isNull(value) || isUndefined(value);
|
|
14864
|
-
var isNotNil = (value) => !isNil(value);
|
|
14865
|
-
var isString = (value) => typeof value === "string";
|
|
14866
|
-
var isNotString = (value) => !isString(value);
|
|
14867
|
-
var isEmptyString = (value) => isString(value) && value === "";
|
|
14868
|
-
var isNonEmptyString = (value) => isString(value) && !isEmptyString(value);
|
|
14869
|
-
var isNumber = (value) => typeof value === "number";
|
|
14870
|
-
var isNotNumber = (value) => !isNumber(value);
|
|
14871
|
-
var isNaN = (value) => Number.isNaN(value);
|
|
14872
|
-
var isInteger = (value) => Number.isInteger(value);
|
|
14873
|
-
var isRecord = (value) => isNotNil(value) && typeof value === "object" && !(value instanceof Array);
|
|
14874
|
-
var isNotRecord = (value) => !isRecord(value);
|
|
14875
|
-
var isEmptyRecord = (value) => isRecord(value) && Object.keys(value).length === 0;
|
|
14876
|
-
var isNonEmptyRecord = (value) => isRecord(value) && Object.keys(value).length > 0;
|
|
14877
|
-
var isArray = (value) => isNotNil(value) && typeof value === "object" && value instanceof Array;
|
|
14878
|
-
var isNotArray = (value) => !isArray(value);
|
|
14879
|
-
var isEmptyArray = (value) => isArray(value) && value.length === 0;
|
|
14880
|
-
var isNonEmptyArray = (value) => isArray(value) && value.length > 0;
|
|
14881
|
-
var isFunction = (value) => isNotNil(value) && typeof value === "function";
|
|
14882
|
-
var isNotFunction = (value) => !isFunction(value);
|
|
14883
|
-
var isBoolean = (value) => isNotNil(value) && typeof value === "boolean";
|
|
14884
|
-
var isNotBoolean = (value) => !isBoolean(value);
|
|
14885
|
-
var isVoid = (value) => value === void 0;
|
|
14886
|
-
var isNotVoid = (value) => !isVoid(value);
|
|
14887
|
-
var isError = (value) => {
|
|
14888
|
-
return isNotNil(value) && value instanceof Error;
|
|
14889
|
-
};
|
|
14890
|
-
var isFalsy = (value) => (
|
|
14891
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
14892
|
-
FALSY_VALUES.includes(value) || Number.isNaN(value)
|
|
14893
|
-
);
|
|
14894
|
-
var isTruthy = (value) => (
|
|
14895
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
14896
|
-
!FALSY_VALUES.includes(value) && !Number.isNaN(value)
|
|
14897
|
-
);
|
|
14898
|
-
var hasKey = (value, key) => isNonEmptyRecord(value) && key in value;
|
|
14899
|
-
|
|
14900
|
-
//# sourceMappingURL=index.mjs.map
|
|
14901
|
-
|
|
14902
16707
|
/***/ }
|
|
14903
16708
|
|
|
14904
16709
|
/******/ });
|
|
@@ -14999,7 +16804,7 @@ var __webpack_exports__ = {};
|
|
|
14999
16804
|
/* harmony export */ A: () => (/* binding */ wistiaSwatchElement)
|
|
15000
16805
|
/* harmony export */ });
|
|
15001
16806
|
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1765);
|
|
15002
|
-
/* harmony import */ var
|
|
16807
|
+
/* harmony import */ var _wistia_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2002);
|
|
15003
16808
|
/* harmony import */ var _utilities_gradients_ts__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4372);
|
|
15004
16809
|
/* harmony import */ var _wistia_namespace_ts__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5509);
|
|
15005
16810
|
/* harmony import */ var _components_PreloadThumbnail_tsx__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9804);
|
|
@@ -15033,9 +16838,10 @@ var __webpack_exports__ = {};
|
|
|
15033
16838
|
/* harmony import */ var _utilities_injectJsonLd_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(2147);
|
|
15034
16839
|
/* harmony import */ var _utilities_getInitialMediaData_ts__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(5833);
|
|
15035
16840
|
/* harmony import */ var _utilities_mediaDataError_ts__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(959);
|
|
15036
|
-
/* harmony import */ var
|
|
15037
|
-
/* harmony import */ var
|
|
15038
|
-
/* harmony import */ var
|
|
16841
|
+
/* harmony import */ var _utilities_obj_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(731);
|
|
16842
|
+
/* harmony import */ var _utilities_remote_data_cache_ts__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(3411);
|
|
16843
|
+
/* harmony import */ var _utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_37__ = __webpack_require__(4989);
|
|
16844
|
+
/* harmony import */ var _types_gradient_ts__WEBPACK_IMPORTED_MODULE_38__ = __webpack_require__(7350);
|
|
15039
16845
|
var _WistiaPlayer;
|
|
15040
16846
|
function _classPrivateMethodInitSpec(e, a) { _checkPrivateRedeclaration(e, a), a.add(e); }
|
|
15041
16847
|
function _classPrivateFieldInitSpec(e, t, a) { _checkPrivateRedeclaration(e, t), t.set(e, a); }
|
|
@@ -15084,6 +16890,7 @@ function _assertClassBrand(e, t, n) { if ("function" == typeof e ? e === t : e.h
|
|
|
15084
16890
|
|
|
15085
16891
|
|
|
15086
16892
|
|
|
16893
|
+
|
|
15087
16894
|
|
|
15088
16895
|
|
|
15089
16896
|
// The component will not run without these attributes.
|
|
@@ -16105,7 +17912,7 @@ class WistiaPlayer extends HTMLElement {
|
|
|
16105
17912
|
*/
|
|
16106
17913
|
get playerColorGradient() {
|
|
16107
17914
|
const value = _assertClassBrand(_WistiaPlayer_brand, this, _getSyncedEmbedOption).call(this, 'playerColorGradient');
|
|
16108
|
-
if ((0,
|
|
17915
|
+
if ((0,_types_gradient_ts__WEBPACK_IMPORTED_MODULE_38__/* .isGradient */ .b)(value)) {
|
|
16109
17916
|
return value;
|
|
16110
17917
|
}
|
|
16111
17918
|
return undefined;
|
|
@@ -16117,7 +17924,7 @@ class WistiaPlayer extends HTMLElement {
|
|
|
16117
17924
|
* @returns {void}
|
|
16118
17925
|
*/
|
|
16119
17926
|
set playerColorGradient(gradient) {
|
|
16120
|
-
if (!(0,
|
|
17927
|
+
if (!(0,_types_gradient_ts__WEBPACK_IMPORTED_MODULE_38__/* .isGradient */ .b)(gradient)) {
|
|
16121
17928
|
throw new Error('playerColorGradient must be a valid gradient object');
|
|
16122
17929
|
}
|
|
16123
17930
|
_classPrivateFieldGet(_impl, this)?.playerColorGradient(gradient);
|
|
@@ -17419,7 +19226,7 @@ class WistiaPlayer extends HTMLElement {
|
|
|
17419
19226
|
|
|
17420
19227
|
// Attribute names must match their corresponding property names (kebab-case -> camelCase)
|
|
17421
19228
|
// So the player-color attribute maps to the playerColor property
|
|
17422
|
-
this[(0,
|
|
19229
|
+
this[(0,_utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_37__/* .kebabCaseToCamelCase */ .b)(name)] = finalValue;
|
|
17423
19230
|
}
|
|
17424
19231
|
connectedCallback() {
|
|
17425
19232
|
if (_classPrivateFieldGet(_hasElementConnectedToDOM, this)) {
|
|
@@ -17532,7 +19339,7 @@ class WistiaPlayer extends HTMLElement {
|
|
|
17532
19339
|
this.removeAllEventListeners();
|
|
17533
19340
|
_classPrivateFieldSet(_eventListeners, this, {});
|
|
17534
19341
|
(0,_utilities_injectJsonLd_js__WEBPACK_IMPORTED_MODULE_32__/* .removeInjectedJsonLd */ .Z)(_classPrivateFieldGet(_jsonLdId, this));
|
|
17535
|
-
(0,
|
|
19342
|
+
(0,_utilities_remote_data_cache_ts__WEBPACK_IMPORTED_MODULE_36__/* .uncacheMediaData */ .s3)(this.mediaId);
|
|
17536
19343
|
_classPrivateFieldGet(_resizeObserver, this)?.disconnect();
|
|
17537
19344
|
_classPrivateFieldSet(_resizeObserver, this, null);
|
|
17538
19345
|
(0,_utilities_embedOptionStore_ts__WEBPACK_IMPORTED_MODULE_14__/* .removeEmbedOptionStore */ .iU)(`__${this.uniqueId}_dom_options__`);
|
|
@@ -17586,7 +19393,7 @@ function _defaultLocalization() {
|
|
|
17586
19393
|
* @returns {boolean}
|
|
17587
19394
|
*/
|
|
17588
19395
|
function _deferMediaDataFetchingToCarouselEmbed() {
|
|
17589
|
-
if (!(0,
|
|
19396
|
+
if (!(0,_wistia_utils__WEBPACK_IMPORTED_MODULE_1__/* .isNonEmptyString */ .uI)(this.id)) {
|
|
17590
19397
|
return false;
|
|
17591
19398
|
}
|
|
17592
19399
|
return !!document.querySelector(`wistia-channel-carousel[player-dom-id="${this.id}"]:not([is-inside-playlist-embed="true"][channel-id])`);
|
|
@@ -17651,7 +19458,7 @@ function _getSyncedEmbedOption(key) {
|
|
|
17651
19458
|
|
|
17652
19459
|
// Otherwise check this element's embed config for a value and fallback
|
|
17653
19460
|
// to the default embed options as a last resort
|
|
17654
|
-
return this.embedOptions[key] ?? _assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, (0,
|
|
19461
|
+
return this.embedOptions[key] ?? _assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, (0,_utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_37__/* .camelCaseToKebabCase */ .$)(key)) ?? defaultEmbedOptions[key];
|
|
17655
19462
|
}
|
|
17656
19463
|
/**
|
|
17657
19464
|
* Gets the value of an attribute if it exists, returns null if not
|
|
@@ -17785,7 +19592,7 @@ async function _initPublicApi(mediaId, options) {
|
|
|
17785
19592
|
* @returns {boolean}
|
|
17786
19593
|
*/
|
|
17787
19594
|
function _isPopoverWithThumbnail() {
|
|
17788
|
-
return this.wistiaPopover && ((0,
|
|
19595
|
+
return this.wistiaPopover && ((0,_wistia_utils__WEBPACK_IMPORTED_MODULE_1__/* .isNil */ .gD)(this.popoverContent) || (0,_wistia_utils__WEBPACK_IMPORTED_MODULE_1__/* .isEmptyString */ .jw)(this.popoverContent) || this.popoverContent === 'thumbnail');
|
|
17789
19596
|
}
|
|
17790
19597
|
/**
|
|
17791
19598
|
* Do a coin flip to determine if Mux should be enabled
|
|
@@ -17839,8 +19646,18 @@ function _maybeSetupEmbedOptionsFromIframe() {
|
|
|
17839
19646
|
// If we're in an iframe, grab the embed options from the iframe URL now
|
|
17840
19647
|
// instead of waiting for insideIframe.coffee to do it - otherwise we won't
|
|
17841
19648
|
// have these embed options until after the api has been initialized.
|
|
17842
|
-
|
|
17843
|
-
|
|
19649
|
+
//
|
|
19650
|
+
// Bracketed params are nested options, as they are for insideIframe.coffee:
|
|
19651
|
+
// `authorization[jwt]=...` has to arrive as `{ authorization: { jwt } }`,
|
|
19652
|
+
// not as a flat "authorization[jwt]" key. URLSearchParams still does the
|
|
19653
|
+
// decoding, so flat values keep their `=` and `+` handling.
|
|
19654
|
+
const iframeEmbedOptions = {};
|
|
19655
|
+
new URLSearchParams(window.location.search).forEach((value, key) => {
|
|
19656
|
+
const path = key.includes('[') ? (0,_utilities_url_js__WEBPACK_IMPORTED_MODULE_27__/* .debrack */ .dn)(key) : [key];
|
|
19657
|
+
if (path) {
|
|
19658
|
+
(0,_utilities_obj_js__WEBPACK_IMPORTED_MODULE_35__/* .setDeep */ .vd)(iframeEmbedOptions, path, value);
|
|
19659
|
+
}
|
|
19660
|
+
});
|
|
17844
19661
|
iframeEmbedOptions.pageTitle = document.title;
|
|
17845
19662
|
iframeEmbedOptions._inIframe = true;
|
|
17846
19663
|
_classPrivateFieldGet(_playerData, this).setIframeEmbedOptionSource(iframeEmbedOptions);
|
|
@@ -18019,7 +19836,7 @@ function _runMethodsFromAttributes() {
|
|
|
18019
19836
|
* @private
|
|
18020
19837
|
*/
|
|
18021
19838
|
function _saveInitialAttributesFromDomOptions() {
|
|
18022
|
-
const domOptions = Object.fromEntries(Object.entries(this.attributes).map(([, value]) => [(0,
|
|
19839
|
+
const domOptions = Object.fromEntries(Object.entries(this.attributes).map(([, value]) => [(0,_utilities_camelCaseToKebabCase_ts__WEBPACK_IMPORTED_MODULE_37__/* .kebabCaseToCamelCase */ .b)(value.name), _assertClassBrand(_WistiaPlayer_brand, this, _getValueFromAttribute).call(this, value.name)]));
|
|
18023
19840
|
_classPrivateFieldGet(_playerData, this).setDomEmbedOptionSource(domOptions);
|
|
18024
19841
|
|
|
18025
19842
|
// The public api uses this store when it gathers options from our many different sources
|