@zthun/helpful-fn 6.2.0 → 6.3.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.
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Returns true if an object is empty, null, or undefined.
3
+ *
4
+ * Note that this is different than lodash's isEmpty method.
5
+ * Checking an empty array or empty string will result
6
+ * in false.
7
+ *
8
+ * @param candidate -
9
+ * The object to test.
10
+ *
11
+ * @returns
12
+ * True if candidate is the empty object or
13
+ * null. False otherwise.
14
+ */
15
+ export declare function isEmptyObject(candidate: any): candidate is {};
package/dist/index.cjs CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const uuid = require("uuid");
4
- const lodashEs = require("lodash-es");
5
4
  var ZVerticalAnchor = /* @__PURE__ */ ((ZVerticalAnchor2) => {
6
5
  ZVerticalAnchor2["Top"] = "top";
7
6
  ZVerticalAnchor2["Middle"] = "middle";
@@ -94,6 +93,9 @@ function createError(problem, schema = ["message", "error", "exception", "data"]
94
93
  return new Error(String(problem));
95
94
  }
96
95
  const createGuid = uuid.v4;
96
+ function isEmptyObject(candidate) {
97
+ return candidate == null || typeof candidate === "object" && Object.keys(candidate).length === 0;
98
+ }
97
99
  function firstWhere(predicate, fallback, first, ...remaining) {
98
100
  if (predicate(first)) {
99
101
  return first;
@@ -273,13 +275,12 @@ class ZQuadrilateralCornersBuilder {
273
275
  this._corners.topRight = firstDefined(topRight, other.right);
274
276
  return this;
275
277
  }
276
- if (typeof other === "object" && lodashEs.isEmpty(other)) {
277
- return this;
278
+ if (!isEmptyObject(other)) {
279
+ this._corners.bottomLeft = firstDefined(bottomLeft, other);
280
+ this._corners.bottomRight = firstDefined(bottomRight, other);
281
+ this._corners.topLeft = firstDefined(topLeft, other);
282
+ this._corners.topRight = firstDefined(topRight, other);
278
283
  }
279
- this._corners.bottomLeft = firstDefined(bottomLeft, other);
280
- this._corners.bottomRight = firstDefined(bottomRight, other);
281
- this._corners.topLeft = firstDefined(topLeft, other);
282
- this._corners.topRight = firstDefined(topRight, other);
283
284
  return this;
284
285
  }
285
286
  /**
@@ -430,13 +431,12 @@ class ZQuadrilateralBuilder {
430
431
  this._quad.top = firstDefined(this._quad.top, other.y);
431
432
  return this;
432
433
  }
433
- if (typeof other === "object" && lodashEs.isEmpty(other)) {
434
- return this;
434
+ if (!isEmptyObject(other)) {
435
+ this._quad.bottom = firstDefined(this._quad.bottom, other);
436
+ this._quad.left = firstDefined(this._quad.left, other);
437
+ this._quad.right = firstDefined(this._quad.right, other);
438
+ this._quad.top = firstDefined(this._quad.top, other);
435
439
  }
436
- this._quad.bottom = firstDefined(this._quad.bottom, other);
437
- this._quad.left = firstDefined(this._quad.left, other);
438
- this._quad.right = firstDefined(this._quad.right, other);
439
- this._quad.top = firstDefined(this._quad.top, other);
440
440
  return this;
441
441
  }
442
442
  /**
@@ -628,6 +628,23 @@ function peelBetween(str, open, close) {
628
628
  }
629
629
  return [null, str];
630
630
  }
631
+ function pickBy(predicate, target) {
632
+ const keys = Object.keys(target);
633
+ const reduced = {};
634
+ keys.forEach((key) => {
635
+ const value = target[key];
636
+ if (predicate(key, value)) {
637
+ reduced[key] = value;
638
+ }
639
+ });
640
+ return reduced;
641
+ }
642
+ function pickDefined(target) {
643
+ return pickBy((_, v) => v != null, target);
644
+ }
645
+ function pickDataAttributes(target) {
646
+ return pickBy((k) => String(k).startsWith("data-"), target);
647
+ }
631
648
  class ZDeserializeJson {
632
649
  constructor(_schema) {
633
650
  this._schema = _schema;
@@ -739,6 +756,7 @@ exports.firstDefined = firstDefined;
739
756
  exports.firstTruthy = firstTruthy;
740
757
  exports.firstWhere = firstWhere;
741
758
  exports.html = html;
759
+ exports.isEmptyObject = isEmptyObject;
742
760
  exports.javascript = javascript;
743
761
  exports.joinDefined = joinDefined;
744
762
  exports.js = js;
@@ -747,6 +765,9 @@ exports.md = md;
747
765
  exports.optional = optional;
748
766
  exports.peel = peel;
749
767
  exports.peelBetween = peelBetween;
768
+ exports.pickBy = pickBy;
769
+ exports.pickDataAttributes = pickDataAttributes;
770
+ exports.pickDefined = pickDefined;
750
771
  exports.pipeJoinDefined = pipeJoinDefined;
751
772
  exports.required = required;
752
773
  exports.semiColonJoinDefined = semiColonJoinDefined;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/anchor/anchor.mts","../src/assert/assert.mts","../src/count-buckets/count-buckets.mts","../src/create-error/create-error.mts","../src/create-guid/create-guid.mts","../src/first-where/first-where.mts","../src/geometry/quadrilateral-corners.mts","../src/geometry/quadrilateral.mts","../src/geometry/rectangle.mts","../src/global/global.mts","../src/join-defined/join-defined.mts","../src/obligation/obligation.mts","../src/orientation/orientation.mts","../src/peel/peel.mts","../src/serialize/deserialize-json.mts","../src/serialize/deserialize-try.mts","../src/serialize/serialize-json.mts","../src/set-first/set-first.mts","../src/sleep/sleep.mts","../src/tag/tag.mts","../src/try-fallback/try-fallback.mts"],"sourcesContent":["/**\n * Represents a targeted point along a y axis.\n */\nexport enum ZVerticalAnchor {\n /**\n * Top boundary.\n *\n * In vertical device space, this would equate to y = 0.\n */\n Top = \"top\",\n /**\n * Centerpoint between the top and bottom.\n */\n Middle = \"middle\",\n /**\n * Bottom boundary.\n *\n * In vertical device space, this would equate to y = Infinity.\n */\n Bottom = \"bottom\",\n}\n\n/**\n * Represents a targeted point along an x axis.\n */\nexport enum ZHorizontalAnchor {\n /**\n * Left boundary.\n *\n * In horizontal device space, this would equate to x = 0.\n */\n Left = \"left\",\n /**\n * Centerpoint between the left and right boundary.\n */\n Center = \"center\",\n /**\n * Right boundary.\n *\n * In horizontal device space, this would equate to x = Infinity.\n */\n Right = \"right\",\n}\n\n/**\n * Represents an anchor point in 2d space.\n *\n * An anchor array is defined by [vertical, horizontal]\n * and is read as such.\n *\n * @example\n *\n * ```ts\n * const topCenter = [ZVerticalAnchor.Top, ZHorizontalAnchor.Center];\n * const bottomRight = [ZVerticalAnchor.Bottom, ZHorizontalAnchor.Right];\n * ```\n *\n * @see {@link ZVerticalAnchor} For more information.\n * @see {@link ZHorizontalAnchor} For more information.\n */\nexport type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];\n\n/**\n * Represents a special type of anchor that excludes the center points.\n */\nexport type ZSideAnchor =\n | ZVerticalAnchor.Top\n | ZVerticalAnchor.Bottom\n | ZHorizontalAnchor.Left\n | ZHorizontalAnchor.Right;\n","/**\n * Represents an object that can be used to build a list of assertions.\n *\n * @example\n *\n * ```ts\n * import { ZAssert, createError } from '@zthun/helpful-fn';\n *\n * const user = readUser();\n *\n * ZAssert\n * .claim(user.name != null, 'User name is required')\n * .claim(user.email != null, 'User email is required')\n * .assert((m) => createError(m));\n * ```\n */\nexport class ZAssert {\n /**\n * Initializes a new instance of a ZAssert with one claim.\n *\n * @param claim -\n * The claim to make.\n * @param msg -\n * The message to throw if the claim is false.\n *\n * @returns\n * A new ZAssert object with an initial claim.\n */\n public static claim(claim: boolean, msg: any): ZAssert {\n return new ZAssert().claim(claim, msg);\n }\n\n private _messages: any[] = [];\n\n /**\n * Initializes a new instance of this object.\n */\n private constructor() {}\n\n /**\n * Adds a claim.\n *\n * @param claim -\n * The claim predicate.\n * @param msg -\n * The message to add if the claim fails.\n *\n * @returns This object.\n */\n public claim(claim: boolean, msg: any): this {\n if (!claim) {\n this._messages.push(msg);\n }\n return this;\n }\n\n /**\n * Runs the assertion.\n *\n * @param fail -\n * The factory that is responsible for returning the specified error to throw.\n */\n public assert<E extends Error>(fail: (message: any | any[]) => E): void {\n if (this._messages.length === 1) {\n throw fail(this._messages[0]);\n }\n\n if (this._messages.length) {\n throw fail(this._messages);\n }\n }\n}\n","/**\n * Calculates the total number of buckets you need to\n * store a number of items where each bucket can hold a\n * maximum weight of items.\n *\n * You can use this function to calculate groupings of\n * items based on total counts and sizes. A good example\n * usage would be to calculate the total number of pages\n * on a paginated list of items given a page size and item\n * count.\n *\n * @param weight -\n * The maximum weight a bucket can store. If this value receives\n * Infinity, then it will result in 1 or min buckets being returned,\n * whichever is larger. If this receives NaN, then this method will\n * result in NaN. Finally, if this receives a negative value, then\n * the result will be max.\n * @param items -\n * The total number of items you need to store where each item\n * counts as 1 towards the weight. If the total number of items\n * is Infinity, then this method will result in max buckets.\n * If this receives NaN, then this method will result in NaN. Finally,\n * if you pass 0, or a negative number of items, then result will be min.\n * @param min -\n * The bounded minimum value. If the total number of buckets\n * evaluates to less than this value, then this value is returned.\n * The default is 0.\n * @param max -\n * The bounded maximum value. If the total number of buckets\n * evaluates to more than this value, then this value is returned.\n * The default is Infinity.\n *\n * @returns\n * The number of buckets you need to store the total number\n * of items given that a single bucket can hold a max weight of items.\n * If either weight or items is NaN, then NaN will be returned regardless\n * of the opposite value. Passing a negative number is the same as\n * passing 0.\n *\n * @example\n *\n * ```ts\n * // The following will return 5 for numberOfPages since you need 5 buckets\n * // to store 101 number of items where each bucket can hold a max of 25\n * // items. The 5th page would be a page of 1 item, since 1 is the remainder.\n * const numberOfPages = countBuckets(25, 101);\n *\n * // In this case, the numberOfPages would be 1 here since our minimum buckets\n * // is 1. By default, this would be 0.\n * const numberOfPages = countBuckets(10, 0, 1);\n *\n * // In this case, we have more items that can be held in the number of buckets\n * // available, so only 4 is returned instead of the 5.\n * const numberOfPages = countBuckets(25, 101, undefined, 4);\n * ```\n */\nexport function countBuckets(\n weight: number,\n items: number,\n min = 0,\n max = Infinity,\n) {\n weight = Math.max(0, weight);\n items = Math.max(0, items);\n\n if (Number.isNaN(weight) || Number.isNaN(items)) {\n return NaN;\n }\n\n if (items === 0) {\n return min;\n }\n\n const boxes = weight === Infinity ? 1 : Math.ceil(items / weight);\n return Math.min(max, Math.max(min, boxes));\n}\n","/**\n * A helper method to construct a JavaScript error object given a list of acceptable schema keys.\n *\n * @param problem -\n * A generic representation of the problem that occurred. This can be an Error object,\n * another object representing some kind of error, or some message representing the error.\n * If this is null or undefined, then a generic error is returned.\n * @param schema -\n * The list of acceptable object keys to look into problem. These will be recursively\n * evaluated to strip out the real error message. Note that this is in order of\n * priority. If schema[0] and schema[1] are both keys on problem, then schema[0] takes\n * a higher precedence than schema[1]. By default, the schema will look for properties\n * named, message, error, exception, and data, in that order.\n *\n * @returns\n * An error object that is the best evaluation of what the problem actually is.\n *\n * @example\n *\n * ```ts\n * // All of these result an Error with the message, 'Something went wrong'\n * const errorWithStringProblem = createError('Something went wrong');\n * const errorWithObjectProblemInSchema = createError({ error: 'Something went wrong'});\n * const errorWithCustomSchema = createError({ issue: 'Something went wrong'}, ['issue']);\n * const errorRecursive = createError({ error: { message: 'Something went wrong' }});\n *\n * // This would result in '[Object object]' as there is no way to figure out how to deconstruct this problem.\n * const errorCannotBeFound = createError({ wut: 'Something went wrong' });\n * ```\n */\nexport function createError(\n problem: any,\n schema = [\"message\", \"error\", \"exception\", \"data\"],\n): Error {\n if (problem instanceof Error) {\n return problem;\n }\n\n if (problem == null) {\n return new Error();\n }\n\n for (let i = 0; i < schema.length; ++i) {\n const key = schema[i];\n\n if (Object.prototype.hasOwnProperty.call(problem, key)) {\n return createError(problem[key]);\n }\n }\n\n return new Error(String(problem));\n}\n","import { v4 } from \"uuid\";\n\n/**\n * Creates a globally unique identifier.\n *\n * The identifier holds to v4 of the UUID specification. A summary\n * of the specification can be found at\n * {@link https://commons.apache.org/sandbox/commons-id/uuid.html | Apache Commons UUID Documentation}.\n *\n * The official documentation of the UUID specification is under\n * {@link https://www.rfc-editor.org/info/rfc4122 | RFC 4122}\n *\n * @returns\n * A new generated globally unique identifier based on random bytes.\n *\n * @example\n *\n * ```ts\n * // Will get a value similar to 53e33fb6-d05a-4fa9-8dc0-b78e4feaa702\n * const guidA = createGuid();\n * // Will most likely not ever be equal to guidA\n * const guidB = createGuid();\n * ```\n */\nexport const createGuid: () => string = v4;\n","/**\n * Returns the first value in an argument list that matches a predicate.\n *\n * @param predicate -\n * The match method against each value argument.\n * @param fallback -\n * The fallback value in the case that all arguments fail\n * the predicate.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value for where {@link predicate} returns true for the given argument value.\n * If first and all values of remaining fail the predicate then fallback is returned.\n */\nexport function firstWhere<T = any>(\n predicate: (v: T | null | undefined) => boolean,\n fallback: T,\n first: T,\n ...remaining: T[]\n): T {\n if (predicate(first)) {\n return first;\n }\n\n for (let i = 0; i < remaining.length; ++i) {\n const val = remaining[i];\n\n if (predicate(val)) {\n return val;\n }\n }\n\n return fallback;\n}\n\n/**\n * Returns the first value in args such that args is not null or undefined.\n *\n * @param fallback -\n * The fallback value in the case that all values in args are null/undefined.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is not null or undefined. If first is undefined or null, then the first item\n * in remaining such that remaining[i] is not null or undefined is returned. If first and all values of\n * remaining are null or undefined, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstDefined('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstDefined('Fallback', null, undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', undefined);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, 'Third');\n * ```\n */\nexport function firstDefined<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => v != null,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n\n/**\n * Returns the first value in args such that args is truthy\n *\n * @param fallback -\n * The fallback value in the case that all values in args are falsy.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is truthy. If first is falsy, then the first item\n * in remaining such that remaining[i] is truthy is returned. If first and\n * all values of remaining are falsy, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstTruthy('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstTruthy('Fallback', '', undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', 0, false);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, false, 0, NaN);\n * ```\n */\nexport function firstTruthy<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => !!v,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n","import { isEmpty } from \"lodash-es\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\n\n/**\n * An object that describes 4 corner values of a quadrilateral.\n *\n * This object is almost identical in functionality to a quadrilateral,\n * but is mostly useful for semantics.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport interface IZQuadrilateralCorners<T = number> {\n bottomLeft: T;\n bottomRight: T;\n topLeft: T;\n topRight: T;\n}\n\n/**\n * A type that describes quadrilateral corners on the vertical axis.\n */\ntype ZCornersVertical<T> = {\n bottom?: T;\n top?: T;\n};\n\n/**\n * A type that describes quadrilateral corners on the horizontal axis.\n */\ntype ZCornersHorizontal<T> = {\n left?: T;\n right?: T;\n};\n\n/**\n * An value that a corners object can be built upon.\n */\nexport type ZQuadrilateralCornersLike<T = number> =\n | T\n | ZCornersVertical<T>\n | ZCornersHorizontal<T>\n | Partial<IZQuadrilateralCorners<T>>\n | null\n | undefined;\n\n/**\n * An object that can be used to build an {@link IZQuadrilateralCorners} object.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport class ZQuadrilateralCornersBuilder<T = number> {\n private _corners: IZQuadrilateralCorners<T>;\n\n public constructor(start: T) {\n this._corners = {\n bottomLeft: start,\n bottomRight: start,\n topLeft: start,\n topRight: start,\n };\n }\n\n /**\n * Sets the bottom left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomLeft(value: T): this {\n this._corners.bottomLeft = value;\n return this;\n }\n\n /**\n * Sets the bottom right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomRight(value: T): this {\n this._corners.bottomRight = value;\n return this;\n }\n\n /**\n * Sets the top left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topLeft(value: T): this {\n this._corners.topLeft = value;\n return this;\n }\n\n /**\n * Sets the top right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topRight(value: T): this {\n this._corners.topRight = value;\n return this;\n }\n\n /**\n * Sets the bottom left and bottom right values.\n *\n * @param value -\n * The value for bottom left and bottom right.\n *\n * @returns\n * This object.\n */\n public bottom(value: T): this {\n return this.bottomLeft(value).bottomRight(value);\n }\n\n /**\n * Sets the bottom left and top left values.\n *\n * @param value -\n * The value for bottom left and top left.\n *\n * @returns\n * This object.\n */\n public left(value: T): this {\n return this.topLeft(value).bottomLeft(value);\n }\n\n /**\n * Sets the bottom right and top right values.\n *\n * @param value -\n * The value for bottom right and top right.\n *\n * @returns\n * This object.\n */\n public right(value: T): this {\n return this.bottomRight(value).topRight(value);\n }\n\n /**\n * Sets the top left and top right values.\n *\n * @param value -\n * The value for top left and top right.\n *\n * @returns\n * This object.\n */\n public top(value: T): this {\n return this.topLeft(value).topRight(value);\n }\n\n /**\n * Sets the corner values based on an object that\n * describes a set of quadrilateral corners.\n *\n * @param other -\n * The object that describes the corners.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralCornersLike<T>): this {\n function isVerticals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersVertical<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n function isHorizontals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersHorizontal<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\"))\n );\n }\n\n function isCorners<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is Partial<IZQuadrilateralCorners<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottomLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"bottomRight\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topRight\"))\n );\n }\n\n const { bottomLeft, bottomRight, topLeft, topRight } = this._corners;\n\n if (isCorners(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottomLeft);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottomRight);\n this._corners.topLeft = firstDefined(topLeft, other.topLeft);\n this._corners.topRight = firstDefined(topRight, other.topRight);\n return this;\n }\n\n if (isVerticals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottom);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottom);\n this._corners.topLeft = firstDefined(topLeft, other.top);\n this._corners.topRight = firstDefined(topRight, other.top);\n return this;\n }\n\n if (isHorizontals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.left);\n this._corners.bottomRight = firstDefined(bottomRight, other.right);\n this._corners.topLeft = firstDefined(topLeft, other.left);\n this._corners.topRight = firstDefined(topRight, other.right);\n return this;\n }\n\n if (typeof other === \"object\" && isEmpty(other)) {\n return this;\n }\n\n this._corners.bottomLeft = firstDefined(bottomLeft, other);\n this._corners.bottomRight = firstDefined(bottomRight, other);\n this._corners.topLeft = firstDefined(topLeft, other);\n this._corners.topRight = firstDefined(topRight, other);\n return this;\n }\n\n /**\n * Copies another corners object into this builder.\n *\n * @param other -\n * The corners object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateralCorners<T>): this {\n this._corners = structuredClone(other);\n return this;\n }\n\n /**\n * Builds the corners.\n *\n * @returns\n * The built corners.\n */\n public build(): IZQuadrilateralCorners<T> {\n return structuredClone(this._corners);\n }\n}\n","import { isEmpty } from \"lodash-es\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\n\n/**\n * Represents a object of 4 side values.\n *\n * @param T -\n * Value type. Typically number.\n */\nexport interface IZQuadrilateral<T = number> {\n /**\n * Bottom value.\n */\n bottom: T;\n /**\n * Left value.\n */\n left: T;\n /**\n * Right value.\n */\n right: T;\n /**\n * Top value.\n */\n top: T;\n}\n\n/**\n * Represents an object that can describe a quadrilateral.\n *\n * Note that there will be limitations on what you can describe\n * when building Quadrilaterals of Quadrilaterals, or Quadrilaterals\n * of Point2d's which is not supported and has undefined behavior.\n */\nexport type ZQuadrilateralLike<T = number> =\n | T\n | Partial<IZPoint2d<T>>\n | Partial<IZQuadrilateral<T>>\n | null\n | undefined;\n\n/**\n * Represents a builder for a quadrilateral object.\n */\nexport class ZQuadrilateralBuilder<T = number> {\n private _quad: IZQuadrilateral<T>;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param start -\n * The starting value.\n */\n public constructor(start: T) {\n this._quad = {\n bottom: start,\n left: start,\n right: start,\n top: start,\n };\n }\n\n /**\n * Sets the bottom value.\n *\n * @param bottom -\n * The bottom value.\n *\n * @returns\n * This object.\n */\n public bottom(bottom: T): this {\n this._quad.bottom = bottom;\n return this;\n }\n\n /**\n * Sets the left value.\n *\n * @param left -\n * The left value.\n *\n * @returns\n * This object.\n */\n public left(left: T): this {\n this._quad.left = left;\n return this;\n }\n\n /**\n * Sets the right value.\n *\n * @param right -\n * The right value.\n *\n * @returns\n * This object.\n */\n public right(right: T): this {\n this._quad.right = right;\n return this;\n }\n\n /**\n * Sets the top value.\n *\n * @param top -\n * The top value.\n *\n * @returns\n * This object.\n */\n public top(top: T): this {\n this._quad.top = top;\n return this;\n }\n\n /**\n * Sets the left and right value.\n *\n * @param x -\n * The left and right value.\n *\n * @returns\n * This object.\n */\n public x(x: T): this {\n return this.left(x).right(x);\n }\n\n /**\n * Sets the top and bottom value.\n *\n * @param y -\n * The top and bottom value.\n *\n * @returns\n * This object.\n */\n public y(y: T): this {\n return this.bottom(y).top(y);\n }\n\n /**\n * Constructs a full quadrilateral from an object that describes a quadrilateral.\n *\n * Note the limitations of this method. If T is of type Quadrilateral or Point2d,\n * then this method's behavior is undefined and it will most likely build a\n * corrupt object.\n *\n * @param other -\n * The object to build from.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralLike<T>): this {\n function isPoint2d<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZPoint2d<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"x\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"y\"))\n );\n }\n\n function isQuadrilateral<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZQuadrilateral<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n if (isQuadrilateral(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.bottom);\n this._quad.left = firstDefined(this._quad.left, other.left);\n this._quad.right = firstDefined(this._quad.right, other.right);\n this._quad.top = firstDefined(this._quad.top, other.top);\n return this;\n }\n\n if (isPoint2d(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.y);\n this._quad.left = firstDefined(this._quad.left, other.x);\n this._quad.right = firstDefined(this._quad.right, other.x);\n this._quad.top = firstDefined(this._quad.top, other.y);\n return this;\n }\n\n if (typeof other === \"object\" && isEmpty(other)) {\n return this;\n }\n\n this._quad.bottom = firstDefined(this._quad.bottom, other);\n this._quad.left = firstDefined(this._quad.left, other);\n this._quad.right = firstDefined(this._quad.right, other);\n this._quad.top = firstDefined(this._quad.top, other);\n\n return this;\n }\n\n /**\n * Copies another quadrilateral object into the current instance.\n *\n * @param other -\n * The quadrilateral object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateral<T>): this {\n this._quad = structuredClone(other);\n return this;\n }\n\n /**\n * Returns the built quadrilateral object.\n *\n * @returns\n * The built quadrilateral.\n */\n public build(): IZQuadrilateral<T> {\n return structuredClone(this._quad);\n }\n}\n","import {\n ZAnchor,\n ZHorizontalAnchor,\n ZVerticalAnchor,\n} from \"../anchor/anchor.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\nimport { IZQuadrilateral } from \"./quadrilateral.mjs\";\n\n/**\n * Represents a helper object that can run calculations on a numeric quadrilateral.\n */\nexport class ZRectangle {\n /**\n * Initializes a new instance of this object.\n *\n * @param sides -\n * The numeric sides of a quadrilateral.\n */\n public constructor(public readonly sides: IZQuadrilateral) {}\n\n /**\n * Calculates the width of the rectangle.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public width(): number {\n const { left, right } = this.sides;\n return right - left;\n }\n\n /**\n * Calculates the height of the rectangle.\n *\n * @returns\n * The numeric height of the rectangle.\n */\n public height(): number {\n const { top, bottom } = this.sides;\n return bottom - top;\n }\n\n /**\n * Calculates the area of the rectangle.\n *\n * @returns\n * The numeric area of the rectangle.\n */\n public area(): number {\n return this.width() * this.height();\n }\n\n /**\n * Calculates the (x, y) point given an anchor target.\n *\n * @param anchor -\n * The anchor target to calculate the point for.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public point(anchor: ZAnchor): IZPoint2d {\n const { bottom, left, right, top } = this.sides;\n const [vertical, horizontal] = anchor;\n\n const v: Record<ZVerticalAnchor, number> = {\n [ZVerticalAnchor.Top]: top,\n [ZVerticalAnchor.Middle]: (bottom + top) / 2,\n [ZVerticalAnchor.Bottom]: bottom,\n };\n\n const h: Record<ZHorizontalAnchor, number> = {\n [ZHorizontalAnchor.Left]: left,\n [ZHorizontalAnchor.Center]: (right + left) / 2,\n [ZHorizontalAnchor.Right]: right,\n };\n\n return { x: h[horizontal], y: v[vertical] };\n }\n\n /**\n * Calculates the top left point of the rectangle.\n *\n * @returns\n * The top left point of the rectangle.\n */\n public topLeft = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the top center point of the rectangle.\n *\n * @returns\n * The top center point of the rectangle.\n */\n public topCenter = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the top right point of the rectangle.\n *\n * @returns\n * The top right point of the rectangle.\n */\n public topRight = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the middle left point of the rectangle.\n *\n * @returns\n * The middle left point of the rectangle.\n */\n public middleLeft = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the middle center point of the rectangle.\n *\n * @returns\n * The middle center point of the rectangle.\n */\n public middleCenter = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the middle right point of the rectangle.\n *\n * @returns\n * The middle right point of the rectangle.\n */\n public middleRight = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the bottom left point of the rectangle.\n *\n * @returns\n * The bottom left point of the rectangle.\n */\n public bottomLeft = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the bottom center point of the rectangle.\n *\n * @returns\n * The bottom center point of the rectangle.\n */\n public bottomCenter = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the bottom right point of the rectangle.\n *\n * @returns\n * The bottom right point of the rectangle.\n */\n public bottomRight = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Right,\n ]);\n}\n","/* istanbul ignore next -- @preserve */\nexport const $global = typeof window === \"undefined\" ? global : window;\n","/**\n * A set of parameters that can be used for a string join.\n *\n * Join lists can be a regular object, null, undefined, or a tuple where the\n * first item is the object to join, and the second item is a boolean that specifies\n * whether to include it if the value is truthy.\n *\n * @param T -\n * The type of data to join.\n */\nexport type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;\n\n/**\n * Similar to {@link Array.join}, but filters out null and undefined items.\n *\n * @param delimiter -\n * The delimiter that separates the items.\n * @param items -\n * The items to join.\n * @param T -\n * The type of data to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by delimiter.\n *\n * @example\n *\n * ```ts\n * // 'a b d'\n * const joinBySpace = joinDefined(' ', 'a', 'b', ['c', false], null, undefined, ['d', true]);\n * // (Empty String)\n * const joinEmpty = joinDefined('?');\n * ```\n */\nexport function joinDefined<T>(\n delimiter: string,\n ...items: JoinListInputParameter<T>[]\n) {\n return items\n .map((item) => (item instanceof Array ? (item[1] ? item[0] : null) : item))\n .filter((item) => item != null)\n .join(delimiter);\n}\n\n/**\n * Alias to joinList with a space delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const spaceJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \" \");\n\n/**\n * Alias of spaceJoinList.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const cssJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = spaceJoinDefined;\n\n/**\n * Alias of joinList with a comma delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a comma delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const commaJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \",\");\n\n/**\n * Alias of joinList with a semi-colon delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a semi-colon delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const semiColonJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \";\");\n\n/**\n * Alias of joinList with a pipe delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a pipe delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const pipeJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \"|\");\n","/**\n * A specific set of possible values that need to be checked for requirements.\n *\n * @param T -\n * The type of value that is being checked.\n */\nexport type ZObligatedValue<T> =\n | T\n | null\n | undefined\n | Promise<T | null | undefined>;\n\n/**\n * Requires a value to be non null.\n *\n * @param val -\n * The value to require. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, an error is thrown.\n *\n * @throws\n * An error if the value is null or undefined.\n */\nexport async function required<T>(val: ZObligatedValue<T>): Promise<T> {\n if (val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n const _val = await val;\n\n if (_val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n return _val;\n}\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>, fallback: T): Promise<T>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, null is returned.\n * If val is a promise and rejects, then null is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>): Promise<T | null>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport async function optional<T>(\n val: ZObligatedValue<T>,\n fallback: T | null = null,\n): Promise<T | null> {\n if (val == null) {\n return fallback;\n }\n\n try {\n const _val = await val;\n return _val == null ? fallback : _val;\n } catch {\n return fallback;\n }\n}\n","/**\n * Represents a direction orientation.\n */\nexport enum ZOrientation {\n /**\n * Horizontal orientation.\n *\n * This type of orientation is a row\n * style orientation or flex-row orientation.\n */\n Horizontal = \"horizontal\",\n\n /**\n * Vertical orientation.\n *\n * This type of orientation is a column\n * style orientation or block orientation.\n */\n Vertical = \"vertical\",\n}\n","/**\n * Peels a candidate string from the start of a string and splits it into two segments.\n *\n * @param str -\n * The string to peel from.\n * @param candidates -\n * The candidate list of values to peel from str.\n *\n * @returns\n * A tuple where the first item is the peeled string and\n * the second item is the remainder of the string. If the string\n * does not start with any given candidates, then the first\n * item will be null and the second item will be str.\n */\nexport function peel<T extends string = string>(\n str: string,\n candidates: T[],\n): [T | null, string] {\n for (const check of candidates) {\n if (str.startsWith(check)) {\n return [str.substring(0, check.length) as T, str.substring(check.length)];\n }\n }\n\n return [null, str];\n}\n\n/**\n * Peels the values between an opening string set and a closing string set.\n *\n * The actual value will handle issues with internal opening and closing brackets\n *\n * @example\n *\n * ```ts\n * const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');\n *\n * // Outputs 'a, b, [c1, c2], [d]'\n * console.log(peeled);\n *\n * // Outputs ' other' - white space is included'\n * console.log(rest);\n * ```\n *\n * @param str -\n * The string to peel between.\n * @param open -\n * The opening string. This will test\n * at the start of str.\n * @param close -\n * The closing string. This can be anywhere\n * in the str. If this is equal to open, then\n * the open string is removed from the start of the\n * string and the rest of the string would be returned.\n *\n * @returns\n * A tuple where the first argument is string that was found between\n * the opening and closing bracket. Returns null if no string could\n * be found between an open and close pair. The second argument will\n * be the remaining text of the string, including whitespace.\n */\nexport function peelBetween(\n str: string,\n open: string,\n close: string,\n): [string | null, string] {\n if (!str.startsWith(open)) {\n return [null, str];\n }\n\n let stack = 1;\n\n const _str = str.substring(open.length);\n\n for (let i = 0; i < _str.length; ++i) {\n if (_str.startsWith(open, i)) {\n stack += 1;\n i += open.length - 1;\n continue;\n }\n\n if (_str.startsWith(close, i)) {\n stack -= 1;\n\n if (stack === 0) {\n return [_str.substring(0, i), _str.substring(i + close.length)];\n }\n\n i += close.length - 1;\n }\n }\n\n return [null, str];\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that deserializes a JSON string.\n */\nexport class ZDeserializeJson<T> implements IZDeserialize<T> {\n public constructor(private _schema?: (k: any) => k is T) {}\n\n public deserialize(candidate: string): T {\n const parsed = JSON.parse(candidate);\n\n if (this._schema && !this._schema(parsed)) {\n throw new Error(\n \"The parsed JSON does not conform to the given schema requirement\",\n );\n }\n\n return parsed;\n }\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that attempts to deserialize multiple times through a series of supported languages.\n *\n * @param T -\n * The type of data to deserialize.\n * @param S -\n * The input type\n */\nexport class ZDeserializeTry<T, S = string> implements IZDeserialize<T, S> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The list of deserializer objects to try on a specific candidate.\n * The first deserializer to succeed will return the target object.\n * If no deserializer is able to deserialize the candidate, then an\n * error is throw with a mapping of serialization errors between each\n * deserializer.\n */\n public constructor(private _children: IZDeserialize<T, S>[]) {}\n\n public deserialize(candidate: S): T {\n const errors: string[] = [];\n\n for (const child of this._children) {\n try {\n return child.deserialize(candidate);\n } catch (e) {\n errors.push(e.message);\n }\n }\n\n const msg = `Unable to deserialize candidate, ${candidate}.`;\n errors.splice(0, 0, msg);\n throw new Error(errors.join(\"\\n\\n\"));\n }\n}\n","import { IZSerialize } from \"./serialize.mjs\";\n\n/**\n * Represents a serializer that serializes anything to a JSON string.\n */\nexport class ZSerializeJson implements IZSerialize<any> {\n public serialize(candidate: any): string | undefined {\n return JSON.stringify(candidate, undefined, 2);\n }\n}\n","/**\n * Represents a setter function for when you want to set a single value,\n * but you have an array instead.\n *\n * This is useful when you want to support lists of items, but you need\n * backwards compatibility for setting a single item. This is primarily meant\n * to be use with bind to construct a new method setter that takes an array\n * and forwards it to a setter method which will accept a single value of the\n * first item in the target value.\n *\n * @param setValue -\n * The setter function that takes a single value. This will receive\n * the first item of the value list.\n * @param fallback -\n * The fallback value in the case that there are no values.\n * @param value -\n * The value list to retrieve the first item from.\n * @param T -\n * The type of data that the array holds.\n *\n * @example\n *\n * ```ts\n * // An example of a react component that needs a value of an array, but you only care about a single selection.\n * const [value, setValue] = useState<TypesOfPie>();\n * const _values = useMemo(() => value ? [value] : [], [value]);\n * const _setValues = setFirst.bind(null, setValue, undefined);\n *\n * return <ComponentWithMultiSelectSupport values={_values} onValuesChange={_setValues} />\n * ```\n */\nexport function setFirst<T>(\n setValue: (val: T) => any,\n fallback: T,\n value: T[] | null | undefined,\n) {\n const _value = value?.length ? value[0] : fallback;\n setValue(_value);\n}\n","/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n *\n * @returns\n * A promise that resolves after ms milliseconds.\n */\nexport function sleep(ms?: number): Promise<void>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param val -\n * The value to resolve with.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(ms: number, val: T): Promise<T>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(\n ms = 0,\n val: T | undefined = undefined,\n): Promise<T | undefined> {\n return new Promise<T | undefined>((resolve) =>\n setTimeout(() => resolve(val), ms),\n );\n}\n","/**\n * This is just a method that allows you to tag an interpolation\n * string as a syntax language.\n *\n * This is useful with IDE extensions that can detect the language\n * and do the syntax highlighting for you.\n *\n * @param strings -\n * The string breaks for interpolation.\n * @param expressions -\n * The equivalent expressions that break apart\n * the single string literal.\n *\n * @returns\n * The compiled string literal. This is no different\n * than letting native JavaScript do it for you.\n *\n * @example\n *\n * ```ts\n * const html = tag;\n * const css = tag;\n *\n * const $html = html`\n * <div>Some IDE extensions will highlight this as html</div>\n * `\n *\n * const $css = css`\n * button {\n * display: grid;\n * }\n * `\n * ```\n */\nexport function tag(\n strings: TemplateStringsArray,\n ...expressions: unknown[]\n): string {\n let [result] = strings;\n\n for (let i = 1, l = strings.length; i < l; i++) {\n result += expressions[i - 1];\n result += strings[i];\n }\n\n return result;\n}\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html | IDE extensions will detect the string}\n * interpolation as html when using this tag.\n */\nexport const html = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css | IDE extensions will detect the string}\n * interpolation as css when using this tag.\n */\nexport const css = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=zjcompt.es6-string-javascript | IDE extensions will detect the string}\n * interpolation as javascript when using this tag.\n */\nexport const js = tag;\n\n/**\n * See {@link js}\n */\nexport const javascript = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=jeoht.es6-string-markdown | IDE extensions will detect the string}\n * interpolation as markdown when using this tag.\n */\nexport const md = tag;\n\n/**\n * See {@link md}\n */\nexport const markdown = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=HoodieCollin.es6-string-typescript | IDE extensions will detect the string}\n * interpolation as typescript when using this tag.\n */\nexport const ts = tag;\n\n/**\n * See {@link ts}\n */\nexport const typescript = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const sh = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const bash = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const zsh = tag;\n","/**\n * Invokes the candidate function and returns undefined if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * The result from candidate. Returns undefined if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T): T | undefined;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T, fallback: T): T;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n * If no fallback value is provided, then undefined is returned.\n */\nexport function tryFallback<T>(\n candidate: () => T,\n fallback?: T,\n): T | undefined {\n try {\n return candidate();\n } catch {\n return fallback;\n }\n}\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns undefined\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n): Promise<T | undefined>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value that will be returned if candidate returns a rejected promise.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns fallback\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback: T,\n): Promise<T>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The optional fallback value to return if the candidate throws an Error.\n *\n * @returns\n * A promise that resolves with the result from candidate or fallback\n * if candidate returns a rejected promise. Resolves with undefined\n * if no fallback is provided.\n */\nexport async function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback?: T,\n): Promise<T | undefined> {\n try {\n return await candidate();\n } catch {\n return fallback;\n }\n}\n"],"names":["ZVerticalAnchor","ZHorizontalAnchor","v4","isEmpty","ZOrientation"],"mappings":";;;;AAGY,IAAA,oCAAAA,qBAAL;AAMLA,mBAAA,KAAM,IAAA;AAINA,mBAAA,QAAS,IAAA;AAMTA,mBAAA,QAAS,IAAA;AAhBCA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;AAsBA,IAAA,sCAAAC,uBAAL;AAMLA,qBAAA,MAAO,IAAA;AAIPA,qBAAA,QAAS,IAAA;AAMTA,qBAAA,OAAQ,IAAA;AAhBEA,SAAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;ACTL,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAqBX,cAAc;AALtB,SAAQ,YAAmB;EAKJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EATvB,OAAc,MAAM,OAAgB,KAAmB;AACrD,WAAO,IAAI,QAAU,EAAA,MAAM,OAAO,GAAG;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,MAAM,OAAgB,KAAgB;AAC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Ef,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AACpC,cAAA,YAAY,IAAI,CAAC;AAC3B,cAAU,QAAQ,CAAC;AAAA,EACrB;AAEO,SAAA;AACT;AAQO,MAAM,OAAO;AAQb,MAAM,MAAM;AAQZ,MAAM,KAAK;AAKX,MAAM,aAAa;AAQnB,MAAM,KAAK;AAKX,MAAM,WAAW;AAQjB,MAAM,KAAK;AAKX,MAAM,aAAa;AAKnB,MAAM,KAAK;AAKX,MAAM,OAAO;AAKb,MAAM,MAAM;AChFH,SAAA,YACd,WACA,UACe;AACX,MAAA;AACF,WAAO,UAAU;AAAA,EAAA,QACX;AACC,WAAA;AAAA,EACT;AACF;AA8CsB,eAAA,iBACpB,WACA,UACwB;AACpB,MAAA;AACF,WAAO,MAAM,UAAU;AAAA,EAAA,QACjB;AACC,WAAA;AAAA,EACT;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/anchor/anchor.mts","../src/assert/assert.mts","../src/count-buckets/count-buckets.mts","../src/create-error/create-error.mts","../src/create-guid/create-guid.mts","../src/empty/is-empty-object.mts","../src/first-where/first-where.mts","../src/geometry/quadrilateral-corners.mts","../src/geometry/quadrilateral.mts","../src/geometry/rectangle.mts","../src/global/global.mts","../src/join-defined/join-defined.mts","../src/obligation/obligation.mts","../src/orientation/orientation.mts","../src/peel/peel.mts","../src/pick/pick.mts","../src/serialize/deserialize-json.mts","../src/serialize/deserialize-try.mts","../src/serialize/serialize-json.mts","../src/set-first/set-first.mts","../src/sleep/sleep.mts","../src/tag/tag.mts","../src/try-fallback/try-fallback.mts"],"sourcesContent":["/**\n * Represents a targeted point along a y axis.\n */\nexport enum ZVerticalAnchor {\n /**\n * Top boundary.\n *\n * In vertical device space, this would equate to y = 0.\n */\n Top = \"top\",\n /**\n * Centerpoint between the top and bottom.\n */\n Middle = \"middle\",\n /**\n * Bottom boundary.\n *\n * In vertical device space, this would equate to y = Infinity.\n */\n Bottom = \"bottom\",\n}\n\n/**\n * Represents a targeted point along an x axis.\n */\nexport enum ZHorizontalAnchor {\n /**\n * Left boundary.\n *\n * In horizontal device space, this would equate to x = 0.\n */\n Left = \"left\",\n /**\n * Centerpoint between the left and right boundary.\n */\n Center = \"center\",\n /**\n * Right boundary.\n *\n * In horizontal device space, this would equate to x = Infinity.\n */\n Right = \"right\",\n}\n\n/**\n * Represents an anchor point in 2d space.\n *\n * An anchor array is defined by [vertical, horizontal]\n * and is read as such.\n *\n * @example\n *\n * ```ts\n * const topCenter = [ZVerticalAnchor.Top, ZHorizontalAnchor.Center];\n * const bottomRight = [ZVerticalAnchor.Bottom, ZHorizontalAnchor.Right];\n * ```\n *\n * @see {@link ZVerticalAnchor} For more information.\n * @see {@link ZHorizontalAnchor} For more information.\n */\nexport type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];\n\n/**\n * Represents a special type of anchor that excludes the center points.\n */\nexport type ZSideAnchor =\n | ZVerticalAnchor.Top\n | ZVerticalAnchor.Bottom\n | ZHorizontalAnchor.Left\n | ZHorizontalAnchor.Right;\n","/**\n * Represents an object that can be used to build a list of assertions.\n *\n * @example\n *\n * ```ts\n * import { ZAssert, createError } from '@zthun/helpful-fn';\n *\n * const user = readUser();\n *\n * ZAssert\n * .claim(user.name != null, 'User name is required')\n * .claim(user.email != null, 'User email is required')\n * .assert((m) => createError(m));\n * ```\n */\nexport class ZAssert {\n /**\n * Initializes a new instance of a ZAssert with one claim.\n *\n * @param claim -\n * The claim to make.\n * @param msg -\n * The message to throw if the claim is false.\n *\n * @returns\n * A new ZAssert object with an initial claim.\n */\n public static claim(claim: boolean, msg: any): ZAssert {\n return new ZAssert().claim(claim, msg);\n }\n\n private _messages: any[] = [];\n\n /**\n * Initializes a new instance of this object.\n */\n private constructor() {}\n\n /**\n * Adds a claim.\n *\n * @param claim -\n * The claim predicate.\n * @param msg -\n * The message to add if the claim fails.\n *\n * @returns This object.\n */\n public claim(claim: boolean, msg: any): this {\n if (!claim) {\n this._messages.push(msg);\n }\n return this;\n }\n\n /**\n * Runs the assertion.\n *\n * @param fail -\n * The factory that is responsible for returning the specified error to throw.\n */\n public assert<E extends Error>(fail: (message: any | any[]) => E): void {\n if (this._messages.length === 1) {\n throw fail(this._messages[0]);\n }\n\n if (this._messages.length) {\n throw fail(this._messages);\n }\n }\n}\n","/**\n * Calculates the total number of buckets you need to\n * store a number of items where each bucket can hold a\n * maximum weight of items.\n *\n * You can use this function to calculate groupings of\n * items based on total counts and sizes. A good example\n * usage would be to calculate the total number of pages\n * on a paginated list of items given a page size and item\n * count.\n *\n * @param weight -\n * The maximum weight a bucket can store. If this value receives\n * Infinity, then it will result in 1 or min buckets being returned,\n * whichever is larger. If this receives NaN, then this method will\n * result in NaN. Finally, if this receives a negative value, then\n * the result will be max.\n * @param items -\n * The total number of items you need to store where each item\n * counts as 1 towards the weight. If the total number of items\n * is Infinity, then this method will result in max buckets.\n * If this receives NaN, then this method will result in NaN. Finally,\n * if you pass 0, or a negative number of items, then result will be min.\n * @param min -\n * The bounded minimum value. If the total number of buckets\n * evaluates to less than this value, then this value is returned.\n * The default is 0.\n * @param max -\n * The bounded maximum value. If the total number of buckets\n * evaluates to more than this value, then this value is returned.\n * The default is Infinity.\n *\n * @returns\n * The number of buckets you need to store the total number\n * of items given that a single bucket can hold a max weight of items.\n * If either weight or items is NaN, then NaN will be returned regardless\n * of the opposite value. Passing a negative number is the same as\n * passing 0.\n *\n * @example\n *\n * ```ts\n * // The following will return 5 for numberOfPages since you need 5 buckets\n * // to store 101 number of items where each bucket can hold a max of 25\n * // items. The 5th page would be a page of 1 item, since 1 is the remainder.\n * const numberOfPages = countBuckets(25, 101);\n *\n * // In this case, the numberOfPages would be 1 here since our minimum buckets\n * // is 1. By default, this would be 0.\n * const numberOfPages = countBuckets(10, 0, 1);\n *\n * // In this case, we have more items that can be held in the number of buckets\n * // available, so only 4 is returned instead of the 5.\n * const numberOfPages = countBuckets(25, 101, undefined, 4);\n * ```\n */\nexport function countBuckets(\n weight: number,\n items: number,\n min = 0,\n max = Infinity,\n) {\n weight = Math.max(0, weight);\n items = Math.max(0, items);\n\n if (Number.isNaN(weight) || Number.isNaN(items)) {\n return NaN;\n }\n\n if (items === 0) {\n return min;\n }\n\n const boxes = weight === Infinity ? 1 : Math.ceil(items / weight);\n return Math.min(max, Math.max(min, boxes));\n}\n","/**\n * A helper method to construct a JavaScript error object given a list of acceptable schema keys.\n *\n * @param problem -\n * A generic representation of the problem that occurred. This can be an Error object,\n * another object representing some kind of error, or some message representing the error.\n * If this is null or undefined, then a generic error is returned.\n * @param schema -\n * The list of acceptable object keys to look into problem. These will be recursively\n * evaluated to strip out the real error message. Note that this is in order of\n * priority. If schema[0] and schema[1] are both keys on problem, then schema[0] takes\n * a higher precedence than schema[1]. By default, the schema will look for properties\n * named, message, error, exception, and data, in that order.\n *\n * @returns\n * An error object that is the best evaluation of what the problem actually is.\n *\n * @example\n *\n * ```ts\n * // All of these result an Error with the message, 'Something went wrong'\n * const errorWithStringProblem = createError('Something went wrong');\n * const errorWithObjectProblemInSchema = createError({ error: 'Something went wrong'});\n * const errorWithCustomSchema = createError({ issue: 'Something went wrong'}, ['issue']);\n * const errorRecursive = createError({ error: { message: 'Something went wrong' }});\n *\n * // This would result in '[Object object]' as there is no way to figure out how to deconstruct this problem.\n * const errorCannotBeFound = createError({ wut: 'Something went wrong' });\n * ```\n */\nexport function createError(\n problem: any,\n schema = [\"message\", \"error\", \"exception\", \"data\"],\n): Error {\n if (problem instanceof Error) {\n return problem;\n }\n\n if (problem == null) {\n return new Error();\n }\n\n for (let i = 0; i < schema.length; ++i) {\n const key = schema[i];\n\n if (Object.prototype.hasOwnProperty.call(problem, key)) {\n return createError(problem[key]);\n }\n }\n\n return new Error(String(problem));\n}\n","import { v4 } from \"uuid\";\n\n/**\n * Creates a globally unique identifier.\n *\n * The identifier holds to v4 of the UUID specification. A summary\n * of the specification can be found at\n * {@link https://commons.apache.org/sandbox/commons-id/uuid.html | Apache Commons UUID Documentation}.\n *\n * The official documentation of the UUID specification is under\n * {@link https://www.rfc-editor.org/info/rfc4122 | RFC 4122}\n *\n * @returns\n * A new generated globally unique identifier based on random bytes.\n *\n * @example\n *\n * ```ts\n * // Will get a value similar to 53e33fb6-d05a-4fa9-8dc0-b78e4feaa702\n * const guidA = createGuid();\n * // Will most likely not ever be equal to guidA\n * const guidB = createGuid();\n * ```\n */\nexport const createGuid: () => string = v4;\n","/**\n * Returns true if an object is empty, null, or undefined.\n *\n * Note that this is different than lodash's isEmpty method.\n * Checking an empty array or empty string will result\n * in false.\n *\n * @param candidate -\n * The object to test.\n *\n * @returns\n * True if candidate is the empty object or\n * null. False otherwise.\n */\nexport function isEmptyObject(candidate: any): candidate is {} {\n return (\n candidate == null ||\n (typeof candidate === \"object\" && Object.keys(candidate).length === 0)\n );\n}\n","/**\n * Returns the first value in an argument list that matches a predicate.\n *\n * @param predicate -\n * The match method against each value argument.\n * @param fallback -\n * The fallback value in the case that all arguments fail\n * the predicate.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value for where {@link predicate} returns true for the given argument value.\n * If first and all values of remaining fail the predicate then fallback is returned.\n */\nexport function firstWhere<T = any>(\n predicate: (v: T | null | undefined) => boolean,\n fallback: T,\n first: T,\n ...remaining: T[]\n): T {\n if (predicate(first)) {\n return first;\n }\n\n for (let i = 0; i < remaining.length; ++i) {\n const val = remaining[i];\n\n if (predicate(val)) {\n return val;\n }\n }\n\n return fallback;\n}\n\n/**\n * Returns the first value in args such that args is not null or undefined.\n *\n * @param fallback -\n * The fallback value in the case that all values in args are null/undefined.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is not null or undefined. If first is undefined or null, then the first item\n * in remaining such that remaining[i] is not null or undefined is returned. If first and all values of\n * remaining are null or undefined, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstDefined('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstDefined('Fallback', null, undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', undefined);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, 'Third');\n * ```\n */\nexport function firstDefined<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => v != null,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n\n/**\n * Returns the first value in args such that args is truthy\n *\n * @param fallback -\n * The fallback value in the case that all values in args are falsy.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is truthy. If first is falsy, then the first item\n * in remaining such that remaining[i] is truthy is returned. If first and\n * all values of remaining are falsy, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstTruthy('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstTruthy('Fallback', '', undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', 0, false);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, false, 0, NaN);\n * ```\n */\nexport function firstTruthy<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => !!v,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\n\n/**\n * An object that describes 4 corner values of a quadrilateral.\n *\n * This object is almost identical in functionality to a quadrilateral,\n * but is mostly useful for semantics.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport interface IZQuadrilateralCorners<T = number> {\n bottomLeft: T;\n bottomRight: T;\n topLeft: T;\n topRight: T;\n}\n\n/**\n * A type that describes quadrilateral corners on the vertical axis.\n */\ntype ZCornersVertical<T> = {\n bottom?: T;\n top?: T;\n};\n\n/**\n * A type that describes quadrilateral corners on the horizontal axis.\n */\ntype ZCornersHorizontal<T> = {\n left?: T;\n right?: T;\n};\n\n/**\n * An value that a corners object can be built upon.\n */\nexport type ZQuadrilateralCornersLike<T = number> =\n | T\n | ZCornersVertical<T>\n | ZCornersHorizontal<T>\n | Partial<IZQuadrilateralCorners<T>>\n | null\n | undefined;\n\n/**\n * An object that can be used to build an {@link IZQuadrilateralCorners} object.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport class ZQuadrilateralCornersBuilder<T = number> {\n private _corners: IZQuadrilateralCorners<T>;\n\n public constructor(start: T) {\n this._corners = {\n bottomLeft: start,\n bottomRight: start,\n topLeft: start,\n topRight: start,\n };\n }\n\n /**\n * Sets the bottom left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomLeft(value: T): this {\n this._corners.bottomLeft = value;\n return this;\n }\n\n /**\n * Sets the bottom right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomRight(value: T): this {\n this._corners.bottomRight = value;\n return this;\n }\n\n /**\n * Sets the top left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topLeft(value: T): this {\n this._corners.topLeft = value;\n return this;\n }\n\n /**\n * Sets the top right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topRight(value: T): this {\n this._corners.topRight = value;\n return this;\n }\n\n /**\n * Sets the bottom left and bottom right values.\n *\n * @param value -\n * The value for bottom left and bottom right.\n *\n * @returns\n * This object.\n */\n public bottom(value: T): this {\n return this.bottomLeft(value).bottomRight(value);\n }\n\n /**\n * Sets the bottom left and top left values.\n *\n * @param value -\n * The value for bottom left and top left.\n *\n * @returns\n * This object.\n */\n public left(value: T): this {\n return this.topLeft(value).bottomLeft(value);\n }\n\n /**\n * Sets the bottom right and top right values.\n *\n * @param value -\n * The value for bottom right and top right.\n *\n * @returns\n * This object.\n */\n public right(value: T): this {\n return this.bottomRight(value).topRight(value);\n }\n\n /**\n * Sets the top left and top right values.\n *\n * @param value -\n * The value for top left and top right.\n *\n * @returns\n * This object.\n */\n public top(value: T): this {\n return this.topLeft(value).topRight(value);\n }\n\n /**\n * Sets the corner values based on an object that\n * describes a set of quadrilateral corners.\n *\n * @param other -\n * The object that describes the corners.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralCornersLike<T>): this {\n function isVerticals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersVertical<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n function isHorizontals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersHorizontal<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\"))\n );\n }\n\n function isCorners<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is Partial<IZQuadrilateralCorners<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottomLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"bottomRight\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topRight\"))\n );\n }\n\n const { bottomLeft, bottomRight, topLeft, topRight } = this._corners;\n\n if (isCorners(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottomLeft);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottomRight);\n this._corners.topLeft = firstDefined(topLeft, other.topLeft);\n this._corners.topRight = firstDefined(topRight, other.topRight);\n return this;\n }\n\n if (isVerticals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottom);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottom);\n this._corners.topLeft = firstDefined(topLeft, other.top);\n this._corners.topRight = firstDefined(topRight, other.top);\n return this;\n }\n\n if (isHorizontals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.left);\n this._corners.bottomRight = firstDefined(bottomRight, other.right);\n this._corners.topLeft = firstDefined(topLeft, other.left);\n this._corners.topRight = firstDefined(topRight, other.right);\n return this;\n }\n\n if (!isEmptyObject(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other);\n this._corners.bottomRight = firstDefined(bottomRight, other);\n this._corners.topLeft = firstDefined(topLeft, other);\n this._corners.topRight = firstDefined(topRight, other);\n }\n\n return this;\n }\n\n /**\n * Copies another corners object into this builder.\n *\n * @param other -\n * The corners object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateralCorners<T>): this {\n this._corners = structuredClone(other);\n return this;\n }\n\n /**\n * Builds the corners.\n *\n * @returns\n * The built corners.\n */\n public build(): IZQuadrilateralCorners<T> {\n return structuredClone(this._corners);\n }\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\n\n/**\n * Represents a object of 4 side values.\n *\n * @param T -\n * Value type. Typically number.\n */\nexport interface IZQuadrilateral<T = number> {\n /**\n * Bottom value.\n */\n bottom: T;\n /**\n * Left value.\n */\n left: T;\n /**\n * Right value.\n */\n right: T;\n /**\n * Top value.\n */\n top: T;\n}\n\n/**\n * Represents an object that can describe a quadrilateral.\n *\n * Note that there will be limitations on what you can describe\n * when building Quadrilaterals of Quadrilaterals, or Quadrilaterals\n * of Point2d's which is not supported and has undefined behavior.\n */\nexport type ZQuadrilateralLike<T = number> =\n | T\n | Partial<IZPoint2d<T>>\n | Partial<IZQuadrilateral<T>>\n | null\n | undefined;\n\n/**\n * Represents a builder for a quadrilateral object.\n */\nexport class ZQuadrilateralBuilder<T = number> {\n private _quad: IZQuadrilateral<T>;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param start -\n * The starting value.\n */\n public constructor(start: T) {\n this._quad = {\n bottom: start,\n left: start,\n right: start,\n top: start,\n };\n }\n\n /**\n * Sets the bottom value.\n *\n * @param bottom -\n * The bottom value.\n *\n * @returns\n * This object.\n */\n public bottom(bottom: T): this {\n this._quad.bottom = bottom;\n return this;\n }\n\n /**\n * Sets the left value.\n *\n * @param left -\n * The left value.\n *\n * @returns\n * This object.\n */\n public left(left: T): this {\n this._quad.left = left;\n return this;\n }\n\n /**\n * Sets the right value.\n *\n * @param right -\n * The right value.\n *\n * @returns\n * This object.\n */\n public right(right: T): this {\n this._quad.right = right;\n return this;\n }\n\n /**\n * Sets the top value.\n *\n * @param top -\n * The top value.\n *\n * @returns\n * This object.\n */\n public top(top: T): this {\n this._quad.top = top;\n return this;\n }\n\n /**\n * Sets the left and right value.\n *\n * @param x -\n * The left and right value.\n *\n * @returns\n * This object.\n */\n public x(x: T): this {\n return this.left(x).right(x);\n }\n\n /**\n * Sets the top and bottom value.\n *\n * @param y -\n * The top and bottom value.\n *\n * @returns\n * This object.\n */\n public y(y: T): this {\n return this.bottom(y).top(y);\n }\n\n /**\n * Constructs a full quadrilateral from an object that describes a quadrilateral.\n *\n * Note the limitations of this method. If T is of type Quadrilateral or Point2d,\n * then this method's behavior is undefined and it will most likely build a\n * corrupt object.\n *\n * @param other -\n * The object to build from.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralLike<T>): this {\n function isPoint2d<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZPoint2d<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"x\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"y\"))\n );\n }\n\n function isQuadrilateral<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZQuadrilateral<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n if (isQuadrilateral(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.bottom);\n this._quad.left = firstDefined(this._quad.left, other.left);\n this._quad.right = firstDefined(this._quad.right, other.right);\n this._quad.top = firstDefined(this._quad.top, other.top);\n return this;\n }\n\n if (isPoint2d(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.y);\n this._quad.left = firstDefined(this._quad.left, other.x);\n this._quad.right = firstDefined(this._quad.right, other.x);\n this._quad.top = firstDefined(this._quad.top, other.y);\n return this;\n }\n\n if (!isEmptyObject(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other);\n this._quad.left = firstDefined(this._quad.left, other);\n this._quad.right = firstDefined(this._quad.right, other);\n this._quad.top = firstDefined(this._quad.top, other);\n }\n\n return this;\n }\n\n /**\n * Copies another quadrilateral object into the current instance.\n *\n * @param other -\n * The quadrilateral object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateral<T>): this {\n this._quad = structuredClone(other);\n return this;\n }\n\n /**\n * Returns the built quadrilateral object.\n *\n * @returns\n * The built quadrilateral.\n */\n public build(): IZQuadrilateral<T> {\n return structuredClone(this._quad);\n }\n}\n","import {\n ZAnchor,\n ZHorizontalAnchor,\n ZVerticalAnchor,\n} from \"../anchor/anchor.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\nimport { IZQuadrilateral } from \"./quadrilateral.mjs\";\n\n/**\n * Represents a helper object that can run calculations on a numeric quadrilateral.\n */\nexport class ZRectangle {\n /**\n * Initializes a new instance of this object.\n *\n * @param sides -\n * The numeric sides of a quadrilateral.\n */\n public constructor(public readonly sides: IZQuadrilateral) {}\n\n /**\n * Calculates the width of the rectangle.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public width(): number {\n const { left, right } = this.sides;\n return right - left;\n }\n\n /**\n * Calculates the height of the rectangle.\n *\n * @returns\n * The numeric height of the rectangle.\n */\n public height(): number {\n const { top, bottom } = this.sides;\n return bottom - top;\n }\n\n /**\n * Calculates the area of the rectangle.\n *\n * @returns\n * The numeric area of the rectangle.\n */\n public area(): number {\n return this.width() * this.height();\n }\n\n /**\n * Calculates the (x, y) point given an anchor target.\n *\n * @param anchor -\n * The anchor target to calculate the point for.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public point(anchor: ZAnchor): IZPoint2d {\n const { bottom, left, right, top } = this.sides;\n const [vertical, horizontal] = anchor;\n\n const v: Record<ZVerticalAnchor, number> = {\n [ZVerticalAnchor.Top]: top,\n [ZVerticalAnchor.Middle]: (bottom + top) / 2,\n [ZVerticalAnchor.Bottom]: bottom,\n };\n\n const h: Record<ZHorizontalAnchor, number> = {\n [ZHorizontalAnchor.Left]: left,\n [ZHorizontalAnchor.Center]: (right + left) / 2,\n [ZHorizontalAnchor.Right]: right,\n };\n\n return { x: h[horizontal], y: v[vertical] };\n }\n\n /**\n * Calculates the top left point of the rectangle.\n *\n * @returns\n * The top left point of the rectangle.\n */\n public topLeft = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the top center point of the rectangle.\n *\n * @returns\n * The top center point of the rectangle.\n */\n public topCenter = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the top right point of the rectangle.\n *\n * @returns\n * The top right point of the rectangle.\n */\n public topRight = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the middle left point of the rectangle.\n *\n * @returns\n * The middle left point of the rectangle.\n */\n public middleLeft = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the middle center point of the rectangle.\n *\n * @returns\n * The middle center point of the rectangle.\n */\n public middleCenter = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the middle right point of the rectangle.\n *\n * @returns\n * The middle right point of the rectangle.\n */\n public middleRight = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the bottom left point of the rectangle.\n *\n * @returns\n * The bottom left point of the rectangle.\n */\n public bottomLeft = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the bottom center point of the rectangle.\n *\n * @returns\n * The bottom center point of the rectangle.\n */\n public bottomCenter = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the bottom right point of the rectangle.\n *\n * @returns\n * The bottom right point of the rectangle.\n */\n public bottomRight = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Right,\n ]);\n}\n","/* istanbul ignore next -- @preserve */\nexport const $global = typeof window === \"undefined\" ? global : window;\n","/**\n * A set of parameters that can be used for a string join.\n *\n * Join lists can be a regular object, null, undefined, or a tuple where the\n * first item is the object to join, and the second item is a boolean that specifies\n * whether to include it if the value is truthy.\n *\n * @param T -\n * The type of data to join.\n */\nexport type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;\n\n/**\n * Similar to {@link Array.join}, but filters out null and undefined items.\n *\n * @param delimiter -\n * The delimiter that separates the items.\n * @param items -\n * The items to join.\n * @param T -\n * The type of data to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by delimiter.\n *\n * @example\n *\n * ```ts\n * // 'a b d'\n * const joinBySpace = joinDefined(' ', 'a', 'b', ['c', false], null, undefined, ['d', true]);\n * // (Empty String)\n * const joinEmpty = joinDefined('?');\n * ```\n */\nexport function joinDefined<T>(\n delimiter: string,\n ...items: JoinListInputParameter<T>[]\n) {\n return items\n .map((item) => (item instanceof Array ? (item[1] ? item[0] : null) : item))\n .filter((item) => item != null)\n .join(delimiter);\n}\n\n/**\n * Alias to joinList with a space delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const spaceJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \" \");\n\n/**\n * Alias of spaceJoinList.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const cssJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = spaceJoinDefined;\n\n/**\n * Alias of joinList with a comma delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a comma delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const commaJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \",\");\n\n/**\n * Alias of joinList with a semi-colon delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a semi-colon delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const semiColonJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \";\");\n\n/**\n * Alias of joinList with a pipe delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a pipe delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const pipeJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \"|\");\n","/**\n * A specific set of possible values that need to be checked for requirements.\n *\n * @param T -\n * The type of value that is being checked.\n */\nexport type ZObligatedValue<T> =\n | T\n | null\n | undefined\n | Promise<T | null | undefined>;\n\n/**\n * Requires a value to be non null.\n *\n * @param val -\n * The value to require. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, an error is thrown.\n *\n * @throws\n * An error if the value is null or undefined.\n */\nexport async function required<T>(val: ZObligatedValue<T>): Promise<T> {\n if (val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n const _val = await val;\n\n if (_val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n return _val;\n}\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>, fallback: T): Promise<T>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, null is returned.\n * If val is a promise and rejects, then null is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>): Promise<T | null>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport async function optional<T>(\n val: ZObligatedValue<T>,\n fallback: T | null = null,\n): Promise<T | null> {\n if (val == null) {\n return fallback;\n }\n\n try {\n const _val = await val;\n return _val == null ? fallback : _val;\n } catch {\n return fallback;\n }\n}\n","/**\n * Represents a direction orientation.\n */\nexport enum ZOrientation {\n /**\n * Horizontal orientation.\n *\n * This type of orientation is a row\n * style orientation or flex-row orientation.\n */\n Horizontal = \"horizontal\",\n\n /**\n * Vertical orientation.\n *\n * This type of orientation is a column\n * style orientation or block orientation.\n */\n Vertical = \"vertical\",\n}\n","/**\n * Peels a candidate string from the start of a string and splits it into two segments.\n *\n * @param str -\n * The string to peel from.\n * @param candidates -\n * The candidate list of values to peel from str.\n *\n * @returns\n * A tuple where the first item is the peeled string and\n * the second item is the remainder of the string. If the string\n * does not start with any given candidates, then the first\n * item will be null and the second item will be str.\n */\nexport function peel<T extends string = string>(\n str: string,\n candidates: T[],\n): [T | null, string] {\n for (const check of candidates) {\n if (str.startsWith(check)) {\n return [str.substring(0, check.length) as T, str.substring(check.length)];\n }\n }\n\n return [null, str];\n}\n\n/**\n * Peels the values between an opening string set and a closing string set.\n *\n * The actual value will handle issues with internal opening and closing brackets\n *\n * @example\n *\n * ```ts\n * const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');\n *\n * // Outputs 'a, b, [c1, c2], [d]'\n * console.log(peeled);\n *\n * // Outputs ' other' - white space is included'\n * console.log(rest);\n * ```\n *\n * @param str -\n * The string to peel between.\n * @param open -\n * The opening string. This will test\n * at the start of str.\n * @param close -\n * The closing string. This can be anywhere\n * in the str. If this is equal to open, then\n * the open string is removed from the start of the\n * string and the rest of the string would be returned.\n *\n * @returns\n * A tuple where the first argument is string that was found between\n * the opening and closing bracket. Returns null if no string could\n * be found between an open and close pair. The second argument will\n * be the remaining text of the string, including whitespace.\n */\nexport function peelBetween(\n str: string,\n open: string,\n close: string,\n): [string | null, string] {\n if (!str.startsWith(open)) {\n return [null, str];\n }\n\n let stack = 1;\n\n const _str = str.substring(open.length);\n\n for (let i = 0; i < _str.length; ++i) {\n if (_str.startsWith(open, i)) {\n stack += 1;\n i += open.length - 1;\n continue;\n }\n\n if (_str.startsWith(close, i)) {\n stack -= 1;\n\n if (stack === 0) {\n return [_str.substring(0, i), _str.substring(i + close.length)];\n }\n\n i += close.length - 1;\n }\n }\n\n return [null, str];\n}\n","export type PickPredicate = (\n key: number | string | symbol,\n value: any,\n) => boolean;\n\nexport type PickResult<T> = Partial<T> | null | undefined;\n\n/**\n * A function that reduces an object to keys and values that match a predicate.\n *\n * @param predicate -\n * The predicate to match the key and value against.\n * @param target -\n * The object to reduce.\n *\n * @returns\n * A reduced object that only contains key-value pairs that match\n * the predicate.\n */\nexport function pickBy<T = unknown>(\n predicate: PickPredicate,\n target: object,\n): PickResult<T> {\n const keys = Object.keys(target);\n const reduced = {};\n\n keys.forEach((key) => {\n const value = target[key];\n if (predicate(key, value)) {\n reduced[key] = value;\n }\n });\n\n return reduced;\n}\n\n/**\n * An alias to pickBy with a predicate of (_, v) =&gt; v != null.\n *\n * @param target -\n * The target object to reduce.\n *\n * @returns\n * The reduced object.\n */\nexport function pickDefined<T = unknown>(target: object): PickResult<T> {\n return pickBy((_, v) => v != null, target);\n}\n\n/**\n * An alias to pickBy((k) =&gt; k.startsWith('data-')).\n *\n * @param target -\n * The target object to reduce.\n *\n * @returns\n * The reduced object.\n */\nexport function pickDataAttributes<T = unknown>(target: object): PickResult<T> {\n return pickBy((k) => String(k).startsWith(\"data-\"), target);\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that deserializes a JSON string.\n */\nexport class ZDeserializeJson<T> implements IZDeserialize<T> {\n public constructor(private _schema?: (k: any) => k is T) {}\n\n public deserialize(candidate: string): T {\n const parsed = JSON.parse(candidate);\n\n if (this._schema && !this._schema(parsed)) {\n throw new Error(\n \"The parsed JSON does not conform to the given schema requirement\",\n );\n }\n\n return parsed;\n }\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that attempts to deserialize multiple times through a series of supported languages.\n *\n * @param T -\n * The type of data to deserialize.\n * @param S -\n * The input type\n */\nexport class ZDeserializeTry<T, S = string> implements IZDeserialize<T, S> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The list of deserializer objects to try on a specific candidate.\n * The first deserializer to succeed will return the target object.\n * If no deserializer is able to deserialize the candidate, then an\n * error is throw with a mapping of serialization errors between each\n * deserializer.\n */\n public constructor(private _children: IZDeserialize<T, S>[]) {}\n\n public deserialize(candidate: S): T {\n const errors: string[] = [];\n\n for (const child of this._children) {\n try {\n return child.deserialize(candidate);\n } catch (e) {\n errors.push(e.message);\n }\n }\n\n const msg = `Unable to deserialize candidate, ${candidate}.`;\n errors.splice(0, 0, msg);\n throw new Error(errors.join(\"\\n\\n\"));\n }\n}\n","import { IZSerialize } from \"./serialize.mjs\";\n\n/**\n * Represents a serializer that serializes anything to a JSON string.\n */\nexport class ZSerializeJson implements IZSerialize<any> {\n public serialize(candidate: any): string | undefined {\n return JSON.stringify(candidate, undefined, 2);\n }\n}\n","/**\n * Represents a setter function for when you want to set a single value,\n * but you have an array instead.\n *\n * This is useful when you want to support lists of items, but you need\n * backwards compatibility for setting a single item. This is primarily meant\n * to be use with bind to construct a new method setter that takes an array\n * and forwards it to a setter method which will accept a single value of the\n * first item in the target value.\n *\n * @param setValue -\n * The setter function that takes a single value. This will receive\n * the first item of the value list.\n * @param fallback -\n * The fallback value in the case that there are no values.\n * @param value -\n * The value list to retrieve the first item from.\n * @param T -\n * The type of data that the array holds.\n *\n * @example\n *\n * ```ts\n * // An example of a react component that needs a value of an array, but you only care about a single selection.\n * const [value, setValue] = useState<TypesOfPie>();\n * const _values = useMemo(() => value ? [value] : [], [value]);\n * const _setValues = setFirst.bind(null, setValue, undefined);\n *\n * return <ComponentWithMultiSelectSupport values={_values} onValuesChange={_setValues} />\n * ```\n */\nexport function setFirst<T>(\n setValue: (val: T) => any,\n fallback: T,\n value: T[] | null | undefined,\n) {\n const _value = value?.length ? value[0] : fallback;\n setValue(_value);\n}\n","/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n *\n * @returns\n * A promise that resolves after ms milliseconds.\n */\nexport function sleep(ms?: number): Promise<void>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param val -\n * The value to resolve with.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(ms: number, val: T): Promise<T>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(\n ms = 0,\n val: T | undefined = undefined,\n): Promise<T | undefined> {\n return new Promise<T | undefined>((resolve) =>\n setTimeout(() => resolve(val), ms),\n );\n}\n","/**\n * This is just a method that allows you to tag an interpolation\n * string as a syntax language.\n *\n * This is useful with IDE extensions that can detect the language\n * and do the syntax highlighting for you.\n *\n * @param strings -\n * The string breaks for interpolation.\n * @param expressions -\n * The equivalent expressions that break apart\n * the single string literal.\n *\n * @returns\n * The compiled string literal. This is no different\n * than letting native JavaScript do it for you.\n *\n * @example\n *\n * ```ts\n * const html = tag;\n * const css = tag;\n *\n * const $html = html`\n * <div>Some IDE extensions will highlight this as html</div>\n * `\n *\n * const $css = css`\n * button {\n * display: grid;\n * }\n * `\n * ```\n */\nexport function tag(\n strings: TemplateStringsArray,\n ...expressions: unknown[]\n): string {\n let [result] = strings;\n\n for (let i = 1, l = strings.length; i < l; i++) {\n result += expressions[i - 1];\n result += strings[i];\n }\n\n return result;\n}\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html | IDE extensions will detect the string}\n * interpolation as html when using this tag.\n */\nexport const html = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css | IDE extensions will detect the string}\n * interpolation as css when using this tag.\n */\nexport const css = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=zjcompt.es6-string-javascript | IDE extensions will detect the string}\n * interpolation as javascript when using this tag.\n */\nexport const js = tag;\n\n/**\n * See {@link js}\n */\nexport const javascript = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=jeoht.es6-string-markdown | IDE extensions will detect the string}\n * interpolation as markdown when using this tag.\n */\nexport const md = tag;\n\n/**\n * See {@link md}\n */\nexport const markdown = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=HoodieCollin.es6-string-typescript | IDE extensions will detect the string}\n * interpolation as typescript when using this tag.\n */\nexport const ts = tag;\n\n/**\n * See {@link ts}\n */\nexport const typescript = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const sh = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const bash = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const zsh = tag;\n","/**\n * Invokes the candidate function and returns undefined if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * The result from candidate. Returns undefined if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T): T | undefined;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T, fallback: T): T;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n * If no fallback value is provided, then undefined is returned.\n */\nexport function tryFallback<T>(\n candidate: () => T,\n fallback?: T,\n): T | undefined {\n try {\n return candidate();\n } catch {\n return fallback;\n }\n}\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns undefined\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n): Promise<T | undefined>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value that will be returned if candidate returns a rejected promise.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns fallback\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback: T,\n): Promise<T>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The optional fallback value to return if the candidate throws an Error.\n *\n * @returns\n * A promise that resolves with the result from candidate or fallback\n * if candidate returns a rejected promise. Resolves with undefined\n * if no fallback is provided.\n */\nexport async function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback?: T,\n): Promise<T | undefined> {\n try {\n return await candidate();\n } catch {\n return fallback;\n }\n}\n"],"names":["ZVerticalAnchor","ZHorizontalAnchor","v4","ZOrientation"],"mappings":";;;AAGY,IAAA,oCAAAA,qBAAL;AAMLA,mBAAA,KAAM,IAAA;AAINA,mBAAA,QAAS,IAAA;AAMTA,mBAAA,QAAS,IAAA;AAhBCA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;AAsBA,IAAA,sCAAAC,uBAAL;AAMLA,qBAAA,MAAO,IAAA;AAIPA,qBAAA,QAAS,IAAA;AAMTA,qBAAA,OAAQ,IAAA;AAhBEA,SAAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;ACTL,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAqBX,cAAc;AALtB,SAAQ,YAAmB;EAKJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EATvB,OAAc,MAAM,OAAgB,KAAmB;AACrD,WAAO,IAAI,QAA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;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './assert/assert.mjs';
3
3
  export * from './count-buckets/count-buckets.mjs';
4
4
  export * from './create-error/create-error.mjs';
5
5
  export * from './create-guid/create-guid.mjs';
6
+ export * from './empty/is-empty-object.mjs';
6
7
  export * from './first-where/first-where.mjs';
7
8
  export * from './geometry/point.mjs';
8
9
  export * from './geometry/quadrilateral-corners.mjs';
@@ -13,6 +14,7 @@ export * from './join-defined/join-defined.mjs';
13
14
  export * from './obligation/obligation.mjs';
14
15
  export * from './orientation/orientation.mjs';
15
16
  export * from './peel/peel.mjs';
17
+ export * from './pick/pick.mjs';
16
18
  export * from './required/required-deep.mjs';
17
19
  export * from './required/required-pick.mjs';
18
20
  export * from './serialize/deserialize-json.mjs';
package/dist/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { v4 } from "uuid";
2
- import { isEmpty } from "lodash-es";
3
2
  var ZVerticalAnchor = /* @__PURE__ */ ((ZVerticalAnchor2) => {
4
3
  ZVerticalAnchor2["Top"] = "top";
5
4
  ZVerticalAnchor2["Middle"] = "middle";
@@ -92,6 +91,9 @@ function createError(problem, schema = ["message", "error", "exception", "data"]
92
91
  return new Error(String(problem));
93
92
  }
94
93
  const createGuid = v4;
94
+ function isEmptyObject(candidate) {
95
+ return candidate == null || typeof candidate === "object" && Object.keys(candidate).length === 0;
96
+ }
95
97
  function firstWhere(predicate, fallback, first, ...remaining) {
96
98
  if (predicate(first)) {
97
99
  return first;
@@ -271,13 +273,12 @@ class ZQuadrilateralCornersBuilder {
271
273
  this._corners.topRight = firstDefined(topRight, other.right);
272
274
  return this;
273
275
  }
274
- if (typeof other === "object" && isEmpty(other)) {
275
- return this;
276
+ if (!isEmptyObject(other)) {
277
+ this._corners.bottomLeft = firstDefined(bottomLeft, other);
278
+ this._corners.bottomRight = firstDefined(bottomRight, other);
279
+ this._corners.topLeft = firstDefined(topLeft, other);
280
+ this._corners.topRight = firstDefined(topRight, other);
276
281
  }
277
- this._corners.bottomLeft = firstDefined(bottomLeft, other);
278
- this._corners.bottomRight = firstDefined(bottomRight, other);
279
- this._corners.topLeft = firstDefined(topLeft, other);
280
- this._corners.topRight = firstDefined(topRight, other);
281
282
  return this;
282
283
  }
283
284
  /**
@@ -428,13 +429,12 @@ class ZQuadrilateralBuilder {
428
429
  this._quad.top = firstDefined(this._quad.top, other.y);
429
430
  return this;
430
431
  }
431
- if (typeof other === "object" && isEmpty(other)) {
432
- return this;
432
+ if (!isEmptyObject(other)) {
433
+ this._quad.bottom = firstDefined(this._quad.bottom, other);
434
+ this._quad.left = firstDefined(this._quad.left, other);
435
+ this._quad.right = firstDefined(this._quad.right, other);
436
+ this._quad.top = firstDefined(this._quad.top, other);
433
437
  }
434
- this._quad.bottom = firstDefined(this._quad.bottom, other);
435
- this._quad.left = firstDefined(this._quad.left, other);
436
- this._quad.right = firstDefined(this._quad.right, other);
437
- this._quad.top = firstDefined(this._quad.top, other);
438
438
  return this;
439
439
  }
440
440
  /**
@@ -626,6 +626,23 @@ function peelBetween(str, open, close) {
626
626
  }
627
627
  return [null, str];
628
628
  }
629
+ function pickBy(predicate, target) {
630
+ const keys = Object.keys(target);
631
+ const reduced = {};
632
+ keys.forEach((key) => {
633
+ const value = target[key];
634
+ if (predicate(key, value)) {
635
+ reduced[key] = value;
636
+ }
637
+ });
638
+ return reduced;
639
+ }
640
+ function pickDefined(target) {
641
+ return pickBy((_, v) => v != null, target);
642
+ }
643
+ function pickDataAttributes(target) {
644
+ return pickBy((k) => String(k).startsWith("data-"), target);
645
+ }
629
646
  class ZDeserializeJson {
630
647
  constructor(_schema) {
631
648
  this._schema = _schema;
@@ -738,6 +755,7 @@ export {
738
755
  firstTruthy,
739
756
  firstWhere,
740
757
  html,
758
+ isEmptyObject,
741
759
  javascript,
742
760
  joinDefined,
743
761
  js,
@@ -746,6 +764,9 @@ export {
746
764
  optional,
747
765
  peel,
748
766
  peelBetween,
767
+ pickBy,
768
+ pickDataAttributes,
769
+ pickDefined,
749
770
  pipeJoinDefined,
750
771
  required,
751
772
  semiColonJoinDefined,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/anchor/anchor.mts","../src/assert/assert.mts","../src/count-buckets/count-buckets.mts","../src/create-error/create-error.mts","../src/create-guid/create-guid.mts","../src/first-where/first-where.mts","../src/geometry/quadrilateral-corners.mts","../src/geometry/quadrilateral.mts","../src/geometry/rectangle.mts","../src/global/global.mts","../src/join-defined/join-defined.mts","../src/obligation/obligation.mts","../src/orientation/orientation.mts","../src/peel/peel.mts","../src/serialize/deserialize-json.mts","../src/serialize/deserialize-try.mts","../src/serialize/serialize-json.mts","../src/set-first/set-first.mts","../src/sleep/sleep.mts","../src/tag/tag.mts","../src/try-fallback/try-fallback.mts"],"sourcesContent":["/**\n * Represents a targeted point along a y axis.\n */\nexport enum ZVerticalAnchor {\n /**\n * Top boundary.\n *\n * In vertical device space, this would equate to y = 0.\n */\n Top = \"top\",\n /**\n * Centerpoint between the top and bottom.\n */\n Middle = \"middle\",\n /**\n * Bottom boundary.\n *\n * In vertical device space, this would equate to y = Infinity.\n */\n Bottom = \"bottom\",\n}\n\n/**\n * Represents a targeted point along an x axis.\n */\nexport enum ZHorizontalAnchor {\n /**\n * Left boundary.\n *\n * In horizontal device space, this would equate to x = 0.\n */\n Left = \"left\",\n /**\n * Centerpoint between the left and right boundary.\n */\n Center = \"center\",\n /**\n * Right boundary.\n *\n * In horizontal device space, this would equate to x = Infinity.\n */\n Right = \"right\",\n}\n\n/**\n * Represents an anchor point in 2d space.\n *\n * An anchor array is defined by [vertical, horizontal]\n * and is read as such.\n *\n * @example\n *\n * ```ts\n * const topCenter = [ZVerticalAnchor.Top, ZHorizontalAnchor.Center];\n * const bottomRight = [ZVerticalAnchor.Bottom, ZHorizontalAnchor.Right];\n * ```\n *\n * @see {@link ZVerticalAnchor} For more information.\n * @see {@link ZHorizontalAnchor} For more information.\n */\nexport type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];\n\n/**\n * Represents a special type of anchor that excludes the center points.\n */\nexport type ZSideAnchor =\n | ZVerticalAnchor.Top\n | ZVerticalAnchor.Bottom\n | ZHorizontalAnchor.Left\n | ZHorizontalAnchor.Right;\n","/**\n * Represents an object that can be used to build a list of assertions.\n *\n * @example\n *\n * ```ts\n * import { ZAssert, createError } from '@zthun/helpful-fn';\n *\n * const user = readUser();\n *\n * ZAssert\n * .claim(user.name != null, 'User name is required')\n * .claim(user.email != null, 'User email is required')\n * .assert((m) => createError(m));\n * ```\n */\nexport class ZAssert {\n /**\n * Initializes a new instance of a ZAssert with one claim.\n *\n * @param claim -\n * The claim to make.\n * @param msg -\n * The message to throw if the claim is false.\n *\n * @returns\n * A new ZAssert object with an initial claim.\n */\n public static claim(claim: boolean, msg: any): ZAssert {\n return new ZAssert().claim(claim, msg);\n }\n\n private _messages: any[] = [];\n\n /**\n * Initializes a new instance of this object.\n */\n private constructor() {}\n\n /**\n * Adds a claim.\n *\n * @param claim -\n * The claim predicate.\n * @param msg -\n * The message to add if the claim fails.\n *\n * @returns This object.\n */\n public claim(claim: boolean, msg: any): this {\n if (!claim) {\n this._messages.push(msg);\n }\n return this;\n }\n\n /**\n * Runs the assertion.\n *\n * @param fail -\n * The factory that is responsible for returning the specified error to throw.\n */\n public assert<E extends Error>(fail: (message: any | any[]) => E): void {\n if (this._messages.length === 1) {\n throw fail(this._messages[0]);\n }\n\n if (this._messages.length) {\n throw fail(this._messages);\n }\n }\n}\n","/**\n * Calculates the total number of buckets you need to\n * store a number of items where each bucket can hold a\n * maximum weight of items.\n *\n * You can use this function to calculate groupings of\n * items based on total counts and sizes. A good example\n * usage would be to calculate the total number of pages\n * on a paginated list of items given a page size and item\n * count.\n *\n * @param weight -\n * The maximum weight a bucket can store. If this value receives\n * Infinity, then it will result in 1 or min buckets being returned,\n * whichever is larger. If this receives NaN, then this method will\n * result in NaN. Finally, if this receives a negative value, then\n * the result will be max.\n * @param items -\n * The total number of items you need to store where each item\n * counts as 1 towards the weight. If the total number of items\n * is Infinity, then this method will result in max buckets.\n * If this receives NaN, then this method will result in NaN. Finally,\n * if you pass 0, or a negative number of items, then result will be min.\n * @param min -\n * The bounded minimum value. If the total number of buckets\n * evaluates to less than this value, then this value is returned.\n * The default is 0.\n * @param max -\n * The bounded maximum value. If the total number of buckets\n * evaluates to more than this value, then this value is returned.\n * The default is Infinity.\n *\n * @returns\n * The number of buckets you need to store the total number\n * of items given that a single bucket can hold a max weight of items.\n * If either weight or items is NaN, then NaN will be returned regardless\n * of the opposite value. Passing a negative number is the same as\n * passing 0.\n *\n * @example\n *\n * ```ts\n * // The following will return 5 for numberOfPages since you need 5 buckets\n * // to store 101 number of items where each bucket can hold a max of 25\n * // items. The 5th page would be a page of 1 item, since 1 is the remainder.\n * const numberOfPages = countBuckets(25, 101);\n *\n * // In this case, the numberOfPages would be 1 here since our minimum buckets\n * // is 1. By default, this would be 0.\n * const numberOfPages = countBuckets(10, 0, 1);\n *\n * // In this case, we have more items that can be held in the number of buckets\n * // available, so only 4 is returned instead of the 5.\n * const numberOfPages = countBuckets(25, 101, undefined, 4);\n * ```\n */\nexport function countBuckets(\n weight: number,\n items: number,\n min = 0,\n max = Infinity,\n) {\n weight = Math.max(0, weight);\n items = Math.max(0, items);\n\n if (Number.isNaN(weight) || Number.isNaN(items)) {\n return NaN;\n }\n\n if (items === 0) {\n return min;\n }\n\n const boxes = weight === Infinity ? 1 : Math.ceil(items / weight);\n return Math.min(max, Math.max(min, boxes));\n}\n","/**\n * A helper method to construct a JavaScript error object given a list of acceptable schema keys.\n *\n * @param problem -\n * A generic representation of the problem that occurred. This can be an Error object,\n * another object representing some kind of error, or some message representing the error.\n * If this is null or undefined, then a generic error is returned.\n * @param schema -\n * The list of acceptable object keys to look into problem. These will be recursively\n * evaluated to strip out the real error message. Note that this is in order of\n * priority. If schema[0] and schema[1] are both keys on problem, then schema[0] takes\n * a higher precedence than schema[1]. By default, the schema will look for properties\n * named, message, error, exception, and data, in that order.\n *\n * @returns\n * An error object that is the best evaluation of what the problem actually is.\n *\n * @example\n *\n * ```ts\n * // All of these result an Error with the message, 'Something went wrong'\n * const errorWithStringProblem = createError('Something went wrong');\n * const errorWithObjectProblemInSchema = createError({ error: 'Something went wrong'});\n * const errorWithCustomSchema = createError({ issue: 'Something went wrong'}, ['issue']);\n * const errorRecursive = createError({ error: { message: 'Something went wrong' }});\n *\n * // This would result in '[Object object]' as there is no way to figure out how to deconstruct this problem.\n * const errorCannotBeFound = createError({ wut: 'Something went wrong' });\n * ```\n */\nexport function createError(\n problem: any,\n schema = [\"message\", \"error\", \"exception\", \"data\"],\n): Error {\n if (problem instanceof Error) {\n return problem;\n }\n\n if (problem == null) {\n return new Error();\n }\n\n for (let i = 0; i < schema.length; ++i) {\n const key = schema[i];\n\n if (Object.prototype.hasOwnProperty.call(problem, key)) {\n return createError(problem[key]);\n }\n }\n\n return new Error(String(problem));\n}\n","import { v4 } from \"uuid\";\n\n/**\n * Creates a globally unique identifier.\n *\n * The identifier holds to v4 of the UUID specification. A summary\n * of the specification can be found at\n * {@link https://commons.apache.org/sandbox/commons-id/uuid.html | Apache Commons UUID Documentation}.\n *\n * The official documentation of the UUID specification is under\n * {@link https://www.rfc-editor.org/info/rfc4122 | RFC 4122}\n *\n * @returns\n * A new generated globally unique identifier based on random bytes.\n *\n * @example\n *\n * ```ts\n * // Will get a value similar to 53e33fb6-d05a-4fa9-8dc0-b78e4feaa702\n * const guidA = createGuid();\n * // Will most likely not ever be equal to guidA\n * const guidB = createGuid();\n * ```\n */\nexport const createGuid: () => string = v4;\n","/**\n * Returns the first value in an argument list that matches a predicate.\n *\n * @param predicate -\n * The match method against each value argument.\n * @param fallback -\n * The fallback value in the case that all arguments fail\n * the predicate.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value for where {@link predicate} returns true for the given argument value.\n * If first and all values of remaining fail the predicate then fallback is returned.\n */\nexport function firstWhere<T = any>(\n predicate: (v: T | null | undefined) => boolean,\n fallback: T,\n first: T,\n ...remaining: T[]\n): T {\n if (predicate(first)) {\n return first;\n }\n\n for (let i = 0; i < remaining.length; ++i) {\n const val = remaining[i];\n\n if (predicate(val)) {\n return val;\n }\n }\n\n return fallback;\n}\n\n/**\n * Returns the first value in args such that args is not null or undefined.\n *\n * @param fallback -\n * The fallback value in the case that all values in args are null/undefined.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is not null or undefined. If first is undefined or null, then the first item\n * in remaining such that remaining[i] is not null or undefined is returned. If first and all values of\n * remaining are null or undefined, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstDefined('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstDefined('Fallback', null, undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', undefined);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, 'Third');\n * ```\n */\nexport function firstDefined<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => v != null,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n\n/**\n * Returns the first value in args such that args is truthy\n *\n * @param fallback -\n * The fallback value in the case that all values in args are falsy.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is truthy. If first is falsy, then the first item\n * in remaining such that remaining[i] is truthy is returned. If first and\n * all values of remaining are falsy, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstTruthy('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstTruthy('Fallback', '', undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', 0, false);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, false, 0, NaN);\n * ```\n */\nexport function firstTruthy<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => !!v,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n","import { isEmpty } from \"lodash-es\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\n\n/**\n * An object that describes 4 corner values of a quadrilateral.\n *\n * This object is almost identical in functionality to a quadrilateral,\n * but is mostly useful for semantics.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport interface IZQuadrilateralCorners<T = number> {\n bottomLeft: T;\n bottomRight: T;\n topLeft: T;\n topRight: T;\n}\n\n/**\n * A type that describes quadrilateral corners on the vertical axis.\n */\ntype ZCornersVertical<T> = {\n bottom?: T;\n top?: T;\n};\n\n/**\n * A type that describes quadrilateral corners on the horizontal axis.\n */\ntype ZCornersHorizontal<T> = {\n left?: T;\n right?: T;\n};\n\n/**\n * An value that a corners object can be built upon.\n */\nexport type ZQuadrilateralCornersLike<T = number> =\n | T\n | ZCornersVertical<T>\n | ZCornersHorizontal<T>\n | Partial<IZQuadrilateralCorners<T>>\n | null\n | undefined;\n\n/**\n * An object that can be used to build an {@link IZQuadrilateralCorners} object.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport class ZQuadrilateralCornersBuilder<T = number> {\n private _corners: IZQuadrilateralCorners<T>;\n\n public constructor(start: T) {\n this._corners = {\n bottomLeft: start,\n bottomRight: start,\n topLeft: start,\n topRight: start,\n };\n }\n\n /**\n * Sets the bottom left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomLeft(value: T): this {\n this._corners.bottomLeft = value;\n return this;\n }\n\n /**\n * Sets the bottom right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomRight(value: T): this {\n this._corners.bottomRight = value;\n return this;\n }\n\n /**\n * Sets the top left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topLeft(value: T): this {\n this._corners.topLeft = value;\n return this;\n }\n\n /**\n * Sets the top right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topRight(value: T): this {\n this._corners.topRight = value;\n return this;\n }\n\n /**\n * Sets the bottom left and bottom right values.\n *\n * @param value -\n * The value for bottom left and bottom right.\n *\n * @returns\n * This object.\n */\n public bottom(value: T): this {\n return this.bottomLeft(value).bottomRight(value);\n }\n\n /**\n * Sets the bottom left and top left values.\n *\n * @param value -\n * The value for bottom left and top left.\n *\n * @returns\n * This object.\n */\n public left(value: T): this {\n return this.topLeft(value).bottomLeft(value);\n }\n\n /**\n * Sets the bottom right and top right values.\n *\n * @param value -\n * The value for bottom right and top right.\n *\n * @returns\n * This object.\n */\n public right(value: T): this {\n return this.bottomRight(value).topRight(value);\n }\n\n /**\n * Sets the top left and top right values.\n *\n * @param value -\n * The value for top left and top right.\n *\n * @returns\n * This object.\n */\n public top(value: T): this {\n return this.topLeft(value).topRight(value);\n }\n\n /**\n * Sets the corner values based on an object that\n * describes a set of quadrilateral corners.\n *\n * @param other -\n * The object that describes the corners.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralCornersLike<T>): this {\n function isVerticals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersVertical<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n function isHorizontals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersHorizontal<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\"))\n );\n }\n\n function isCorners<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is Partial<IZQuadrilateralCorners<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottomLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"bottomRight\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topRight\"))\n );\n }\n\n const { bottomLeft, bottomRight, topLeft, topRight } = this._corners;\n\n if (isCorners(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottomLeft);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottomRight);\n this._corners.topLeft = firstDefined(topLeft, other.topLeft);\n this._corners.topRight = firstDefined(topRight, other.topRight);\n return this;\n }\n\n if (isVerticals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottom);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottom);\n this._corners.topLeft = firstDefined(topLeft, other.top);\n this._corners.topRight = firstDefined(topRight, other.top);\n return this;\n }\n\n if (isHorizontals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.left);\n this._corners.bottomRight = firstDefined(bottomRight, other.right);\n this._corners.topLeft = firstDefined(topLeft, other.left);\n this._corners.topRight = firstDefined(topRight, other.right);\n return this;\n }\n\n if (typeof other === \"object\" && isEmpty(other)) {\n return this;\n }\n\n this._corners.bottomLeft = firstDefined(bottomLeft, other);\n this._corners.bottomRight = firstDefined(bottomRight, other);\n this._corners.topLeft = firstDefined(topLeft, other);\n this._corners.topRight = firstDefined(topRight, other);\n return this;\n }\n\n /**\n * Copies another corners object into this builder.\n *\n * @param other -\n * The corners object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateralCorners<T>): this {\n this._corners = structuredClone(other);\n return this;\n }\n\n /**\n * Builds the corners.\n *\n * @returns\n * The built corners.\n */\n public build(): IZQuadrilateralCorners<T> {\n return structuredClone(this._corners);\n }\n}\n","import { isEmpty } from \"lodash-es\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\n\n/**\n * Represents a object of 4 side values.\n *\n * @param T -\n * Value type. Typically number.\n */\nexport interface IZQuadrilateral<T = number> {\n /**\n * Bottom value.\n */\n bottom: T;\n /**\n * Left value.\n */\n left: T;\n /**\n * Right value.\n */\n right: T;\n /**\n * Top value.\n */\n top: T;\n}\n\n/**\n * Represents an object that can describe a quadrilateral.\n *\n * Note that there will be limitations on what you can describe\n * when building Quadrilaterals of Quadrilaterals, or Quadrilaterals\n * of Point2d's which is not supported and has undefined behavior.\n */\nexport type ZQuadrilateralLike<T = number> =\n | T\n | Partial<IZPoint2d<T>>\n | Partial<IZQuadrilateral<T>>\n | null\n | undefined;\n\n/**\n * Represents a builder for a quadrilateral object.\n */\nexport class ZQuadrilateralBuilder<T = number> {\n private _quad: IZQuadrilateral<T>;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param start -\n * The starting value.\n */\n public constructor(start: T) {\n this._quad = {\n bottom: start,\n left: start,\n right: start,\n top: start,\n };\n }\n\n /**\n * Sets the bottom value.\n *\n * @param bottom -\n * The bottom value.\n *\n * @returns\n * This object.\n */\n public bottom(bottom: T): this {\n this._quad.bottom = bottom;\n return this;\n }\n\n /**\n * Sets the left value.\n *\n * @param left -\n * The left value.\n *\n * @returns\n * This object.\n */\n public left(left: T): this {\n this._quad.left = left;\n return this;\n }\n\n /**\n * Sets the right value.\n *\n * @param right -\n * The right value.\n *\n * @returns\n * This object.\n */\n public right(right: T): this {\n this._quad.right = right;\n return this;\n }\n\n /**\n * Sets the top value.\n *\n * @param top -\n * The top value.\n *\n * @returns\n * This object.\n */\n public top(top: T): this {\n this._quad.top = top;\n return this;\n }\n\n /**\n * Sets the left and right value.\n *\n * @param x -\n * The left and right value.\n *\n * @returns\n * This object.\n */\n public x(x: T): this {\n return this.left(x).right(x);\n }\n\n /**\n * Sets the top and bottom value.\n *\n * @param y -\n * The top and bottom value.\n *\n * @returns\n * This object.\n */\n public y(y: T): this {\n return this.bottom(y).top(y);\n }\n\n /**\n * Constructs a full quadrilateral from an object that describes a quadrilateral.\n *\n * Note the limitations of this method. If T is of type Quadrilateral or Point2d,\n * then this method's behavior is undefined and it will most likely build a\n * corrupt object.\n *\n * @param other -\n * The object to build from.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralLike<T>): this {\n function isPoint2d<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZPoint2d<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"x\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"y\"))\n );\n }\n\n function isQuadrilateral<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZQuadrilateral<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n if (isQuadrilateral(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.bottom);\n this._quad.left = firstDefined(this._quad.left, other.left);\n this._quad.right = firstDefined(this._quad.right, other.right);\n this._quad.top = firstDefined(this._quad.top, other.top);\n return this;\n }\n\n if (isPoint2d(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.y);\n this._quad.left = firstDefined(this._quad.left, other.x);\n this._quad.right = firstDefined(this._quad.right, other.x);\n this._quad.top = firstDefined(this._quad.top, other.y);\n return this;\n }\n\n if (typeof other === \"object\" && isEmpty(other)) {\n return this;\n }\n\n this._quad.bottom = firstDefined(this._quad.bottom, other);\n this._quad.left = firstDefined(this._quad.left, other);\n this._quad.right = firstDefined(this._quad.right, other);\n this._quad.top = firstDefined(this._quad.top, other);\n\n return this;\n }\n\n /**\n * Copies another quadrilateral object into the current instance.\n *\n * @param other -\n * The quadrilateral object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateral<T>): this {\n this._quad = structuredClone(other);\n return this;\n }\n\n /**\n * Returns the built quadrilateral object.\n *\n * @returns\n * The built quadrilateral.\n */\n public build(): IZQuadrilateral<T> {\n return structuredClone(this._quad);\n }\n}\n","import {\n ZAnchor,\n ZHorizontalAnchor,\n ZVerticalAnchor,\n} from \"../anchor/anchor.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\nimport { IZQuadrilateral } from \"./quadrilateral.mjs\";\n\n/**\n * Represents a helper object that can run calculations on a numeric quadrilateral.\n */\nexport class ZRectangle {\n /**\n * Initializes a new instance of this object.\n *\n * @param sides -\n * The numeric sides of a quadrilateral.\n */\n public constructor(public readonly sides: IZQuadrilateral) {}\n\n /**\n * Calculates the width of the rectangle.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public width(): number {\n const { left, right } = this.sides;\n return right - left;\n }\n\n /**\n * Calculates the height of the rectangle.\n *\n * @returns\n * The numeric height of the rectangle.\n */\n public height(): number {\n const { top, bottom } = this.sides;\n return bottom - top;\n }\n\n /**\n * Calculates the area of the rectangle.\n *\n * @returns\n * The numeric area of the rectangle.\n */\n public area(): number {\n return this.width() * this.height();\n }\n\n /**\n * Calculates the (x, y) point given an anchor target.\n *\n * @param anchor -\n * The anchor target to calculate the point for.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public point(anchor: ZAnchor): IZPoint2d {\n const { bottom, left, right, top } = this.sides;\n const [vertical, horizontal] = anchor;\n\n const v: Record<ZVerticalAnchor, number> = {\n [ZVerticalAnchor.Top]: top,\n [ZVerticalAnchor.Middle]: (bottom + top) / 2,\n [ZVerticalAnchor.Bottom]: bottom,\n };\n\n const h: Record<ZHorizontalAnchor, number> = {\n [ZHorizontalAnchor.Left]: left,\n [ZHorizontalAnchor.Center]: (right + left) / 2,\n [ZHorizontalAnchor.Right]: right,\n };\n\n return { x: h[horizontal], y: v[vertical] };\n }\n\n /**\n * Calculates the top left point of the rectangle.\n *\n * @returns\n * The top left point of the rectangle.\n */\n public topLeft = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the top center point of the rectangle.\n *\n * @returns\n * The top center point of the rectangle.\n */\n public topCenter = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the top right point of the rectangle.\n *\n * @returns\n * The top right point of the rectangle.\n */\n public topRight = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the middle left point of the rectangle.\n *\n * @returns\n * The middle left point of the rectangle.\n */\n public middleLeft = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the middle center point of the rectangle.\n *\n * @returns\n * The middle center point of the rectangle.\n */\n public middleCenter = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the middle right point of the rectangle.\n *\n * @returns\n * The middle right point of the rectangle.\n */\n public middleRight = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the bottom left point of the rectangle.\n *\n * @returns\n * The bottom left point of the rectangle.\n */\n public bottomLeft = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the bottom center point of the rectangle.\n *\n * @returns\n * The bottom center point of the rectangle.\n */\n public bottomCenter = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the bottom right point of the rectangle.\n *\n * @returns\n * The bottom right point of the rectangle.\n */\n public bottomRight = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Right,\n ]);\n}\n","/* istanbul ignore next -- @preserve */\nexport const $global = typeof window === \"undefined\" ? global : window;\n","/**\n * A set of parameters that can be used for a string join.\n *\n * Join lists can be a regular object, null, undefined, or a tuple where the\n * first item is the object to join, and the second item is a boolean that specifies\n * whether to include it if the value is truthy.\n *\n * @param T -\n * The type of data to join.\n */\nexport type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;\n\n/**\n * Similar to {@link Array.join}, but filters out null and undefined items.\n *\n * @param delimiter -\n * The delimiter that separates the items.\n * @param items -\n * The items to join.\n * @param T -\n * The type of data to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by delimiter.\n *\n * @example\n *\n * ```ts\n * // 'a b d'\n * const joinBySpace = joinDefined(' ', 'a', 'b', ['c', false], null, undefined, ['d', true]);\n * // (Empty String)\n * const joinEmpty = joinDefined('?');\n * ```\n */\nexport function joinDefined<T>(\n delimiter: string,\n ...items: JoinListInputParameter<T>[]\n) {\n return items\n .map((item) => (item instanceof Array ? (item[1] ? item[0] : null) : item))\n .filter((item) => item != null)\n .join(delimiter);\n}\n\n/**\n * Alias to joinList with a space delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const spaceJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \" \");\n\n/**\n * Alias of spaceJoinList.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const cssJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = spaceJoinDefined;\n\n/**\n * Alias of joinList with a comma delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a comma delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const commaJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \",\");\n\n/**\n * Alias of joinList with a semi-colon delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a semi-colon delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const semiColonJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \";\");\n\n/**\n * Alias of joinList with a pipe delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a pipe delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const pipeJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \"|\");\n","/**\n * A specific set of possible values that need to be checked for requirements.\n *\n * @param T -\n * The type of value that is being checked.\n */\nexport type ZObligatedValue<T> =\n | T\n | null\n | undefined\n | Promise<T | null | undefined>;\n\n/**\n * Requires a value to be non null.\n *\n * @param val -\n * The value to require. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, an error is thrown.\n *\n * @throws\n * An error if the value is null or undefined.\n */\nexport async function required<T>(val: ZObligatedValue<T>): Promise<T> {\n if (val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n const _val = await val;\n\n if (_val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n return _val;\n}\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>, fallback: T): Promise<T>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, null is returned.\n * If val is a promise and rejects, then null is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>): Promise<T | null>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport async function optional<T>(\n val: ZObligatedValue<T>,\n fallback: T | null = null,\n): Promise<T | null> {\n if (val == null) {\n return fallback;\n }\n\n try {\n const _val = await val;\n return _val == null ? fallback : _val;\n } catch {\n return fallback;\n }\n}\n","/**\n * Represents a direction orientation.\n */\nexport enum ZOrientation {\n /**\n * Horizontal orientation.\n *\n * This type of orientation is a row\n * style orientation or flex-row orientation.\n */\n Horizontal = \"horizontal\",\n\n /**\n * Vertical orientation.\n *\n * This type of orientation is a column\n * style orientation or block orientation.\n */\n Vertical = \"vertical\",\n}\n","/**\n * Peels a candidate string from the start of a string and splits it into two segments.\n *\n * @param str -\n * The string to peel from.\n * @param candidates -\n * The candidate list of values to peel from str.\n *\n * @returns\n * A tuple where the first item is the peeled string and\n * the second item is the remainder of the string. If the string\n * does not start with any given candidates, then the first\n * item will be null and the second item will be str.\n */\nexport function peel<T extends string = string>(\n str: string,\n candidates: T[],\n): [T | null, string] {\n for (const check of candidates) {\n if (str.startsWith(check)) {\n return [str.substring(0, check.length) as T, str.substring(check.length)];\n }\n }\n\n return [null, str];\n}\n\n/**\n * Peels the values between an opening string set and a closing string set.\n *\n * The actual value will handle issues with internal opening and closing brackets\n *\n * @example\n *\n * ```ts\n * const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');\n *\n * // Outputs 'a, b, [c1, c2], [d]'\n * console.log(peeled);\n *\n * // Outputs ' other' - white space is included'\n * console.log(rest);\n * ```\n *\n * @param str -\n * The string to peel between.\n * @param open -\n * The opening string. This will test\n * at the start of str.\n * @param close -\n * The closing string. This can be anywhere\n * in the str. If this is equal to open, then\n * the open string is removed from the start of the\n * string and the rest of the string would be returned.\n *\n * @returns\n * A tuple where the first argument is string that was found between\n * the opening and closing bracket. Returns null if no string could\n * be found between an open and close pair. The second argument will\n * be the remaining text of the string, including whitespace.\n */\nexport function peelBetween(\n str: string,\n open: string,\n close: string,\n): [string | null, string] {\n if (!str.startsWith(open)) {\n return [null, str];\n }\n\n let stack = 1;\n\n const _str = str.substring(open.length);\n\n for (let i = 0; i < _str.length; ++i) {\n if (_str.startsWith(open, i)) {\n stack += 1;\n i += open.length - 1;\n continue;\n }\n\n if (_str.startsWith(close, i)) {\n stack -= 1;\n\n if (stack === 0) {\n return [_str.substring(0, i), _str.substring(i + close.length)];\n }\n\n i += close.length - 1;\n }\n }\n\n return [null, str];\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that deserializes a JSON string.\n */\nexport class ZDeserializeJson<T> implements IZDeserialize<T> {\n public constructor(private _schema?: (k: any) => k is T) {}\n\n public deserialize(candidate: string): T {\n const parsed = JSON.parse(candidate);\n\n if (this._schema && !this._schema(parsed)) {\n throw new Error(\n \"The parsed JSON does not conform to the given schema requirement\",\n );\n }\n\n return parsed;\n }\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that attempts to deserialize multiple times through a series of supported languages.\n *\n * @param T -\n * The type of data to deserialize.\n * @param S -\n * The input type\n */\nexport class ZDeserializeTry<T, S = string> implements IZDeserialize<T, S> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The list of deserializer objects to try on a specific candidate.\n * The first deserializer to succeed will return the target object.\n * If no deserializer is able to deserialize the candidate, then an\n * error is throw with a mapping of serialization errors between each\n * deserializer.\n */\n public constructor(private _children: IZDeserialize<T, S>[]) {}\n\n public deserialize(candidate: S): T {\n const errors: string[] = [];\n\n for (const child of this._children) {\n try {\n return child.deserialize(candidate);\n } catch (e) {\n errors.push(e.message);\n }\n }\n\n const msg = `Unable to deserialize candidate, ${candidate}.`;\n errors.splice(0, 0, msg);\n throw new Error(errors.join(\"\\n\\n\"));\n }\n}\n","import { IZSerialize } from \"./serialize.mjs\";\n\n/**\n * Represents a serializer that serializes anything to a JSON string.\n */\nexport class ZSerializeJson implements IZSerialize<any> {\n public serialize(candidate: any): string | undefined {\n return JSON.stringify(candidate, undefined, 2);\n }\n}\n","/**\n * Represents a setter function for when you want to set a single value,\n * but you have an array instead.\n *\n * This is useful when you want to support lists of items, but you need\n * backwards compatibility for setting a single item. This is primarily meant\n * to be use with bind to construct a new method setter that takes an array\n * and forwards it to a setter method which will accept a single value of the\n * first item in the target value.\n *\n * @param setValue -\n * The setter function that takes a single value. This will receive\n * the first item of the value list.\n * @param fallback -\n * The fallback value in the case that there are no values.\n * @param value -\n * The value list to retrieve the first item from.\n * @param T -\n * The type of data that the array holds.\n *\n * @example\n *\n * ```ts\n * // An example of a react component that needs a value of an array, but you only care about a single selection.\n * const [value, setValue] = useState<TypesOfPie>();\n * const _values = useMemo(() => value ? [value] : [], [value]);\n * const _setValues = setFirst.bind(null, setValue, undefined);\n *\n * return <ComponentWithMultiSelectSupport values={_values} onValuesChange={_setValues} />\n * ```\n */\nexport function setFirst<T>(\n setValue: (val: T) => any,\n fallback: T,\n value: T[] | null | undefined,\n) {\n const _value = value?.length ? value[0] : fallback;\n setValue(_value);\n}\n","/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n *\n * @returns\n * A promise that resolves after ms milliseconds.\n */\nexport function sleep(ms?: number): Promise<void>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param val -\n * The value to resolve with.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(ms: number, val: T): Promise<T>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(\n ms = 0,\n val: T | undefined = undefined,\n): Promise<T | undefined> {\n return new Promise<T | undefined>((resolve) =>\n setTimeout(() => resolve(val), ms),\n );\n}\n","/**\n * This is just a method that allows you to tag an interpolation\n * string as a syntax language.\n *\n * This is useful with IDE extensions that can detect the language\n * and do the syntax highlighting for you.\n *\n * @param strings -\n * The string breaks for interpolation.\n * @param expressions -\n * The equivalent expressions that break apart\n * the single string literal.\n *\n * @returns\n * The compiled string literal. This is no different\n * than letting native JavaScript do it for you.\n *\n * @example\n *\n * ```ts\n * const html = tag;\n * const css = tag;\n *\n * const $html = html`\n * <div>Some IDE extensions will highlight this as html</div>\n * `\n *\n * const $css = css`\n * button {\n * display: grid;\n * }\n * `\n * ```\n */\nexport function tag(\n strings: TemplateStringsArray,\n ...expressions: unknown[]\n): string {\n let [result] = strings;\n\n for (let i = 1, l = strings.length; i < l; i++) {\n result += expressions[i - 1];\n result += strings[i];\n }\n\n return result;\n}\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html | IDE extensions will detect the string}\n * interpolation as html when using this tag.\n */\nexport const html = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css | IDE extensions will detect the string}\n * interpolation as css when using this tag.\n */\nexport const css = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=zjcompt.es6-string-javascript | IDE extensions will detect the string}\n * interpolation as javascript when using this tag.\n */\nexport const js = tag;\n\n/**\n * See {@link js}\n */\nexport const javascript = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=jeoht.es6-string-markdown | IDE extensions will detect the string}\n * interpolation as markdown when using this tag.\n */\nexport const md = tag;\n\n/**\n * See {@link md}\n */\nexport const markdown = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=HoodieCollin.es6-string-typescript | IDE extensions will detect the string}\n * interpolation as typescript when using this tag.\n */\nexport const ts = tag;\n\n/**\n * See {@link ts}\n */\nexport const typescript = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const sh = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const bash = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const zsh = tag;\n","/**\n * Invokes the candidate function and returns undefined if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * The result from candidate. Returns undefined if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T): T | undefined;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T, fallback: T): T;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n * If no fallback value is provided, then undefined is returned.\n */\nexport function tryFallback<T>(\n candidate: () => T,\n fallback?: T,\n): T | undefined {\n try {\n return candidate();\n } catch {\n return fallback;\n }\n}\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns undefined\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n): Promise<T | undefined>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value that will be returned if candidate returns a rejected promise.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns fallback\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback: T,\n): Promise<T>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The optional fallback value to return if the candidate throws an Error.\n *\n * @returns\n * A promise that resolves with the result from candidate or fallback\n * if candidate returns a rejected promise. Resolves with undefined\n * if no fallback is provided.\n */\nexport async function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback?: T,\n): Promise<T | undefined> {\n try {\n return await candidate();\n } catch {\n return fallback;\n }\n}\n"],"names":["ZVerticalAnchor","ZHorizontalAnchor","ZOrientation"],"mappings":";;AAGY,IAAA,oCAAAA,qBAAL;AAMLA,mBAAA,KAAM,IAAA;AAINA,mBAAA,QAAS,IAAA;AAMTA,mBAAA,QAAS,IAAA;AAhBCA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;AAsBA,IAAA,sCAAAC,uBAAL;AAMLA,qBAAA,MAAO,IAAA;AAIPA,qBAAA,QAAS,IAAA;AAMTA,qBAAA,OAAQ,IAAA;AAhBEA,SAAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;ACTL,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAqBX,cAAc;AALtB,SAAQ,YAAmB;EAKJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EATvB,OAAc,MAAM,OAAgB,KAAmB;AACrD,WAAO,IAAI,QAAU,EAAA,MAAM,OAAO,GAAG;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,MAAM,OAAgB,KAAgB;AAC3C,QAAI,CAAC,OAAO;AACL,WAAA,UAAU,KAAK,GAAG;AAAA,IACzB;AACO,WAAA;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQO,OAAwB,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;AAQb,MAAM,MAAM;AAQZ,MAAM,KAAK;AAKX,MAAM,aAAa;AAQnB,MAAM,KAAK;AAKX,MAAM,WAAW;AAQjB,MAAM,KAAK;AAKX,MAAM,aAAa;AAKnB,MAAM,KAAK;AAKX,MAAM,OAAO;AAKb,MAAM,MAAM;AChFH,SAAA,YACd,WACA,UACe;AACX,MAAA;AACF,WAAO,UAAU;AAAA,EAAA,QACX;AACC,WAAA;AAAA,EACT;AACF;AA8CsB,eAAA,iBACpB,WACA,UACwB;AACpB,MAAA;AACF,WAAO,MAAM,UAAU;AAAA,EAAA,QACjB;AACC,WAAA;AAAA,EACT;AACF;"}
1
+ {"version":3,"file":"index.js","sources":["../src/anchor/anchor.mts","../src/assert/assert.mts","../src/count-buckets/count-buckets.mts","../src/create-error/create-error.mts","../src/create-guid/create-guid.mts","../src/empty/is-empty-object.mts","../src/first-where/first-where.mts","../src/geometry/quadrilateral-corners.mts","../src/geometry/quadrilateral.mts","../src/geometry/rectangle.mts","../src/global/global.mts","../src/join-defined/join-defined.mts","../src/obligation/obligation.mts","../src/orientation/orientation.mts","../src/peel/peel.mts","../src/pick/pick.mts","../src/serialize/deserialize-json.mts","../src/serialize/deserialize-try.mts","../src/serialize/serialize-json.mts","../src/set-first/set-first.mts","../src/sleep/sleep.mts","../src/tag/tag.mts","../src/try-fallback/try-fallback.mts"],"sourcesContent":["/**\n * Represents a targeted point along a y axis.\n */\nexport enum ZVerticalAnchor {\n /**\n * Top boundary.\n *\n * In vertical device space, this would equate to y = 0.\n */\n Top = \"top\",\n /**\n * Centerpoint between the top and bottom.\n */\n Middle = \"middle\",\n /**\n * Bottom boundary.\n *\n * In vertical device space, this would equate to y = Infinity.\n */\n Bottom = \"bottom\",\n}\n\n/**\n * Represents a targeted point along an x axis.\n */\nexport enum ZHorizontalAnchor {\n /**\n * Left boundary.\n *\n * In horizontal device space, this would equate to x = 0.\n */\n Left = \"left\",\n /**\n * Centerpoint between the left and right boundary.\n */\n Center = \"center\",\n /**\n * Right boundary.\n *\n * In horizontal device space, this would equate to x = Infinity.\n */\n Right = \"right\",\n}\n\n/**\n * Represents an anchor point in 2d space.\n *\n * An anchor array is defined by [vertical, horizontal]\n * and is read as such.\n *\n * @example\n *\n * ```ts\n * const topCenter = [ZVerticalAnchor.Top, ZHorizontalAnchor.Center];\n * const bottomRight = [ZVerticalAnchor.Bottom, ZHorizontalAnchor.Right];\n * ```\n *\n * @see {@link ZVerticalAnchor} For more information.\n * @see {@link ZHorizontalAnchor} For more information.\n */\nexport type ZAnchor = [ZVerticalAnchor, ZHorizontalAnchor];\n\n/**\n * Represents a special type of anchor that excludes the center points.\n */\nexport type ZSideAnchor =\n | ZVerticalAnchor.Top\n | ZVerticalAnchor.Bottom\n | ZHorizontalAnchor.Left\n | ZHorizontalAnchor.Right;\n","/**\n * Represents an object that can be used to build a list of assertions.\n *\n * @example\n *\n * ```ts\n * import { ZAssert, createError } from '@zthun/helpful-fn';\n *\n * const user = readUser();\n *\n * ZAssert\n * .claim(user.name != null, 'User name is required')\n * .claim(user.email != null, 'User email is required')\n * .assert((m) => createError(m));\n * ```\n */\nexport class ZAssert {\n /**\n * Initializes a new instance of a ZAssert with one claim.\n *\n * @param claim -\n * The claim to make.\n * @param msg -\n * The message to throw if the claim is false.\n *\n * @returns\n * A new ZAssert object with an initial claim.\n */\n public static claim(claim: boolean, msg: any): ZAssert {\n return new ZAssert().claim(claim, msg);\n }\n\n private _messages: any[] = [];\n\n /**\n * Initializes a new instance of this object.\n */\n private constructor() {}\n\n /**\n * Adds a claim.\n *\n * @param claim -\n * The claim predicate.\n * @param msg -\n * The message to add if the claim fails.\n *\n * @returns This object.\n */\n public claim(claim: boolean, msg: any): this {\n if (!claim) {\n this._messages.push(msg);\n }\n return this;\n }\n\n /**\n * Runs the assertion.\n *\n * @param fail -\n * The factory that is responsible for returning the specified error to throw.\n */\n public assert<E extends Error>(fail: (message: any | any[]) => E): void {\n if (this._messages.length === 1) {\n throw fail(this._messages[0]);\n }\n\n if (this._messages.length) {\n throw fail(this._messages);\n }\n }\n}\n","/**\n * Calculates the total number of buckets you need to\n * store a number of items where each bucket can hold a\n * maximum weight of items.\n *\n * You can use this function to calculate groupings of\n * items based on total counts and sizes. A good example\n * usage would be to calculate the total number of pages\n * on a paginated list of items given a page size and item\n * count.\n *\n * @param weight -\n * The maximum weight a bucket can store. If this value receives\n * Infinity, then it will result in 1 or min buckets being returned,\n * whichever is larger. If this receives NaN, then this method will\n * result in NaN. Finally, if this receives a negative value, then\n * the result will be max.\n * @param items -\n * The total number of items you need to store where each item\n * counts as 1 towards the weight. If the total number of items\n * is Infinity, then this method will result in max buckets.\n * If this receives NaN, then this method will result in NaN. Finally,\n * if you pass 0, or a negative number of items, then result will be min.\n * @param min -\n * The bounded minimum value. If the total number of buckets\n * evaluates to less than this value, then this value is returned.\n * The default is 0.\n * @param max -\n * The bounded maximum value. If the total number of buckets\n * evaluates to more than this value, then this value is returned.\n * The default is Infinity.\n *\n * @returns\n * The number of buckets you need to store the total number\n * of items given that a single bucket can hold a max weight of items.\n * If either weight or items is NaN, then NaN will be returned regardless\n * of the opposite value. Passing a negative number is the same as\n * passing 0.\n *\n * @example\n *\n * ```ts\n * // The following will return 5 for numberOfPages since you need 5 buckets\n * // to store 101 number of items where each bucket can hold a max of 25\n * // items. The 5th page would be a page of 1 item, since 1 is the remainder.\n * const numberOfPages = countBuckets(25, 101);\n *\n * // In this case, the numberOfPages would be 1 here since our minimum buckets\n * // is 1. By default, this would be 0.\n * const numberOfPages = countBuckets(10, 0, 1);\n *\n * // In this case, we have more items that can be held in the number of buckets\n * // available, so only 4 is returned instead of the 5.\n * const numberOfPages = countBuckets(25, 101, undefined, 4);\n * ```\n */\nexport function countBuckets(\n weight: number,\n items: number,\n min = 0,\n max = Infinity,\n) {\n weight = Math.max(0, weight);\n items = Math.max(0, items);\n\n if (Number.isNaN(weight) || Number.isNaN(items)) {\n return NaN;\n }\n\n if (items === 0) {\n return min;\n }\n\n const boxes = weight === Infinity ? 1 : Math.ceil(items / weight);\n return Math.min(max, Math.max(min, boxes));\n}\n","/**\n * A helper method to construct a JavaScript error object given a list of acceptable schema keys.\n *\n * @param problem -\n * A generic representation of the problem that occurred. This can be an Error object,\n * another object representing some kind of error, or some message representing the error.\n * If this is null or undefined, then a generic error is returned.\n * @param schema -\n * The list of acceptable object keys to look into problem. These will be recursively\n * evaluated to strip out the real error message. Note that this is in order of\n * priority. If schema[0] and schema[1] are both keys on problem, then schema[0] takes\n * a higher precedence than schema[1]. By default, the schema will look for properties\n * named, message, error, exception, and data, in that order.\n *\n * @returns\n * An error object that is the best evaluation of what the problem actually is.\n *\n * @example\n *\n * ```ts\n * // All of these result an Error with the message, 'Something went wrong'\n * const errorWithStringProblem = createError('Something went wrong');\n * const errorWithObjectProblemInSchema = createError({ error: 'Something went wrong'});\n * const errorWithCustomSchema = createError({ issue: 'Something went wrong'}, ['issue']);\n * const errorRecursive = createError({ error: { message: 'Something went wrong' }});\n *\n * // This would result in '[Object object]' as there is no way to figure out how to deconstruct this problem.\n * const errorCannotBeFound = createError({ wut: 'Something went wrong' });\n * ```\n */\nexport function createError(\n problem: any,\n schema = [\"message\", \"error\", \"exception\", \"data\"],\n): Error {\n if (problem instanceof Error) {\n return problem;\n }\n\n if (problem == null) {\n return new Error();\n }\n\n for (let i = 0; i < schema.length; ++i) {\n const key = schema[i];\n\n if (Object.prototype.hasOwnProperty.call(problem, key)) {\n return createError(problem[key]);\n }\n }\n\n return new Error(String(problem));\n}\n","import { v4 } from \"uuid\";\n\n/**\n * Creates a globally unique identifier.\n *\n * The identifier holds to v4 of the UUID specification. A summary\n * of the specification can be found at\n * {@link https://commons.apache.org/sandbox/commons-id/uuid.html | Apache Commons UUID Documentation}.\n *\n * The official documentation of the UUID specification is under\n * {@link https://www.rfc-editor.org/info/rfc4122 | RFC 4122}\n *\n * @returns\n * A new generated globally unique identifier based on random bytes.\n *\n * @example\n *\n * ```ts\n * // Will get a value similar to 53e33fb6-d05a-4fa9-8dc0-b78e4feaa702\n * const guidA = createGuid();\n * // Will most likely not ever be equal to guidA\n * const guidB = createGuid();\n * ```\n */\nexport const createGuid: () => string = v4;\n","/**\n * Returns true if an object is empty, null, or undefined.\n *\n * Note that this is different than lodash's isEmpty method.\n * Checking an empty array or empty string will result\n * in false.\n *\n * @param candidate -\n * The object to test.\n *\n * @returns\n * True if candidate is the empty object or\n * null. False otherwise.\n */\nexport function isEmptyObject(candidate: any): candidate is {} {\n return (\n candidate == null ||\n (typeof candidate === \"object\" && Object.keys(candidate).length === 0)\n );\n}\n","/**\n * Returns the first value in an argument list that matches a predicate.\n *\n * @param predicate -\n * The match method against each value argument.\n * @param fallback -\n * The fallback value in the case that all arguments fail\n * the predicate.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value for where {@link predicate} returns true for the given argument value.\n * If first and all values of remaining fail the predicate then fallback is returned.\n */\nexport function firstWhere<T = any>(\n predicate: (v: T | null | undefined) => boolean,\n fallback: T,\n first: T,\n ...remaining: T[]\n): T {\n if (predicate(first)) {\n return first;\n }\n\n for (let i = 0; i < remaining.length; ++i) {\n const val = remaining[i];\n\n if (predicate(val)) {\n return val;\n }\n }\n\n return fallback;\n}\n\n/**\n * Returns the first value in args such that args is not null or undefined.\n *\n * @param fallback -\n * The fallback value in the case that all values in args are null/undefined.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is not null or undefined. If first is undefined or null, then the first item\n * in remaining such that remaining[i] is not null or undefined is returned. If first and all values of\n * remaining are null or undefined, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstDefined('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstDefined('Fallback', null, undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', undefined);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, 'Third');\n * ```\n */\nexport function firstDefined<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => v != null,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n\n/**\n * Returns the first value in args such that args is truthy\n *\n * @param fallback -\n * The fallback value in the case that all values in args are falsy.\n * @param first -\n * The first value to check.\n * @param remaining -\n * The remaining values beyond the first to check.\n * @param T -\n * The type of data that will be enumerated.\n *\n * @returns\n * The first value if it is truthy. If first is falsy, then the first item\n * in remaining such that remaining[i] is truthy is returned. If first and\n * all values of remaining are falsy, then fallback is returned.\n *\n * @example\n *\n * ```ts\n * // 'Defined'\n * const shouldBeDefined = firstTruthy('Fallback', null, undefined, 'Defined');\n * // 'Fallback'\n * const shouldBeFallback = firstTruthy('Fallback', '', undefined);\n * const shouldAlsoBeFallback = firstDefined('Fallback', 0, false);\n * // 'First'\n * const shouldBeFirst = firstDefined('Fallback', 'First', null, false, 0, NaN);\n * ```\n */\nexport function firstTruthy<T = any>(\n fallback: T,\n first: T | null | undefined,\n ...remaining: (T | null | undefined)[]\n): T {\n return firstWhere<T | null | undefined>(\n (v) => !!v,\n fallback,\n first,\n ...remaining,\n ) as T;\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\n\n/**\n * An object that describes 4 corner values of a quadrilateral.\n *\n * This object is almost identical in functionality to a quadrilateral,\n * but is mostly useful for semantics.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport interface IZQuadrilateralCorners<T = number> {\n bottomLeft: T;\n bottomRight: T;\n topLeft: T;\n topRight: T;\n}\n\n/**\n * A type that describes quadrilateral corners on the vertical axis.\n */\ntype ZCornersVertical<T> = {\n bottom?: T;\n top?: T;\n};\n\n/**\n * A type that describes quadrilateral corners on the horizontal axis.\n */\ntype ZCornersHorizontal<T> = {\n left?: T;\n right?: T;\n};\n\n/**\n * An value that a corners object can be built upon.\n */\nexport type ZQuadrilateralCornersLike<T = number> =\n | T\n | ZCornersVertical<T>\n | ZCornersHorizontal<T>\n | Partial<IZQuadrilateralCorners<T>>\n | null\n | undefined;\n\n/**\n * An object that can be used to build an {@link IZQuadrilateralCorners} object.\n *\n * @param T -\n * The type of data to associate to each corner.\n */\nexport class ZQuadrilateralCornersBuilder<T = number> {\n private _corners: IZQuadrilateralCorners<T>;\n\n public constructor(start: T) {\n this._corners = {\n bottomLeft: start,\n bottomRight: start,\n topLeft: start,\n topRight: start,\n };\n }\n\n /**\n * Sets the bottom left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomLeft(value: T): this {\n this._corners.bottomLeft = value;\n return this;\n }\n\n /**\n * Sets the bottom right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public bottomRight(value: T): this {\n this._corners.bottomRight = value;\n return this;\n }\n\n /**\n * Sets the top left corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topLeft(value: T): this {\n this._corners.topLeft = value;\n return this;\n }\n\n /**\n * Sets the top right corner value.\n *\n * @param value -\n * The value to set.\n *\n * @returns\n * This object.\n */\n public topRight(value: T): this {\n this._corners.topRight = value;\n return this;\n }\n\n /**\n * Sets the bottom left and bottom right values.\n *\n * @param value -\n * The value for bottom left and bottom right.\n *\n * @returns\n * This object.\n */\n public bottom(value: T): this {\n return this.bottomLeft(value).bottomRight(value);\n }\n\n /**\n * Sets the bottom left and top left values.\n *\n * @param value -\n * The value for bottom left and top left.\n *\n * @returns\n * This object.\n */\n public left(value: T): this {\n return this.topLeft(value).bottomLeft(value);\n }\n\n /**\n * Sets the bottom right and top right values.\n *\n * @param value -\n * The value for bottom right and top right.\n *\n * @returns\n * This object.\n */\n public right(value: T): this {\n return this.bottomRight(value).topRight(value);\n }\n\n /**\n * Sets the top left and top right values.\n *\n * @param value -\n * The value for top left and top right.\n *\n * @returns\n * This object.\n */\n public top(value: T): this {\n return this.topLeft(value).topRight(value);\n }\n\n /**\n * Sets the corner values based on an object that\n * describes a set of quadrilateral corners.\n *\n * @param other -\n * The object that describes the corners.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralCornersLike<T>): this {\n function isVerticals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersVertical<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n function isHorizontals<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is ZCornersHorizontal<T> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\"))\n );\n }\n\n function isCorners<T>(\n candidate: ZQuadrilateralCornersLike<T>,\n ): candidate is Partial<IZQuadrilateralCorners<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottomLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"bottomRight\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topLeft\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"topRight\"))\n );\n }\n\n const { bottomLeft, bottomRight, topLeft, topRight } = this._corners;\n\n if (isCorners(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottomLeft);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottomRight);\n this._corners.topLeft = firstDefined(topLeft, other.topLeft);\n this._corners.topRight = firstDefined(topRight, other.topRight);\n return this;\n }\n\n if (isVerticals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.bottom);\n this._corners.bottomRight = firstDefined(bottomRight, other.bottom);\n this._corners.topLeft = firstDefined(topLeft, other.top);\n this._corners.topRight = firstDefined(topRight, other.top);\n return this;\n }\n\n if (isHorizontals(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other.left);\n this._corners.bottomRight = firstDefined(bottomRight, other.right);\n this._corners.topLeft = firstDefined(topLeft, other.left);\n this._corners.topRight = firstDefined(topRight, other.right);\n return this;\n }\n\n if (!isEmptyObject(other)) {\n this._corners.bottomLeft = firstDefined(bottomLeft, other);\n this._corners.bottomRight = firstDefined(bottomRight, other);\n this._corners.topLeft = firstDefined(topLeft, other);\n this._corners.topRight = firstDefined(topRight, other);\n }\n\n return this;\n }\n\n /**\n * Copies another corners object into this builder.\n *\n * @param other -\n * The corners object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateralCorners<T>): this {\n this._corners = structuredClone(other);\n return this;\n }\n\n /**\n * Builds the corners.\n *\n * @returns\n * The built corners.\n */\n public build(): IZQuadrilateralCorners<T> {\n return structuredClone(this._corners);\n }\n}\n","import { isEmptyObject } from \"../empty/is-empty-object.mjs\";\nimport { firstDefined } from \"../first-where/first-where.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\n\n/**\n * Represents a object of 4 side values.\n *\n * @param T -\n * Value type. Typically number.\n */\nexport interface IZQuadrilateral<T = number> {\n /**\n * Bottom value.\n */\n bottom: T;\n /**\n * Left value.\n */\n left: T;\n /**\n * Right value.\n */\n right: T;\n /**\n * Top value.\n */\n top: T;\n}\n\n/**\n * Represents an object that can describe a quadrilateral.\n *\n * Note that there will be limitations on what you can describe\n * when building Quadrilaterals of Quadrilaterals, or Quadrilaterals\n * of Point2d's which is not supported and has undefined behavior.\n */\nexport type ZQuadrilateralLike<T = number> =\n | T\n | Partial<IZPoint2d<T>>\n | Partial<IZQuadrilateral<T>>\n | null\n | undefined;\n\n/**\n * Represents a builder for a quadrilateral object.\n */\nexport class ZQuadrilateralBuilder<T = number> {\n private _quad: IZQuadrilateral<T>;\n\n /**\n * Initializes a new instance of this object.\n *\n * @param start -\n * The starting value.\n */\n public constructor(start: T) {\n this._quad = {\n bottom: start,\n left: start,\n right: start,\n top: start,\n };\n }\n\n /**\n * Sets the bottom value.\n *\n * @param bottom -\n * The bottom value.\n *\n * @returns\n * This object.\n */\n public bottom(bottom: T): this {\n this._quad.bottom = bottom;\n return this;\n }\n\n /**\n * Sets the left value.\n *\n * @param left -\n * The left value.\n *\n * @returns\n * This object.\n */\n public left(left: T): this {\n this._quad.left = left;\n return this;\n }\n\n /**\n * Sets the right value.\n *\n * @param right -\n * The right value.\n *\n * @returns\n * This object.\n */\n public right(right: T): this {\n this._quad.right = right;\n return this;\n }\n\n /**\n * Sets the top value.\n *\n * @param top -\n * The top value.\n *\n * @returns\n * This object.\n */\n public top(top: T): this {\n this._quad.top = top;\n return this;\n }\n\n /**\n * Sets the left and right value.\n *\n * @param x -\n * The left and right value.\n *\n * @returns\n * This object.\n */\n public x(x: T): this {\n return this.left(x).right(x);\n }\n\n /**\n * Sets the top and bottom value.\n *\n * @param y -\n * The top and bottom value.\n *\n * @returns\n * This object.\n */\n public y(y: T): this {\n return this.bottom(y).top(y);\n }\n\n /**\n * Constructs a full quadrilateral from an object that describes a quadrilateral.\n *\n * Note the limitations of this method. If T is of type Quadrilateral or Point2d,\n * then this method's behavior is undefined and it will most likely build a\n * corrupt object.\n *\n * @param other -\n * The object to build from.\n *\n * @returns\n * This object.\n */\n public from(other: ZQuadrilateralLike<T>): this {\n function isPoint2d<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZPoint2d<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"x\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"y\"))\n );\n }\n\n function isQuadrilateral<T>(\n candidate: ZQuadrilateralLike<T>,\n ): candidate is Partial<IZQuadrilateral<T>> {\n return (\n candidate != null &&\n (Object.prototype.hasOwnProperty.call(candidate, \"bottom\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"left\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"right\") ||\n Object.prototype.hasOwnProperty.call(candidate, \"top\"))\n );\n }\n\n if (isQuadrilateral(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.bottom);\n this._quad.left = firstDefined(this._quad.left, other.left);\n this._quad.right = firstDefined(this._quad.right, other.right);\n this._quad.top = firstDefined(this._quad.top, other.top);\n return this;\n }\n\n if (isPoint2d(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other.y);\n this._quad.left = firstDefined(this._quad.left, other.x);\n this._quad.right = firstDefined(this._quad.right, other.x);\n this._quad.top = firstDefined(this._quad.top, other.y);\n return this;\n }\n\n if (!isEmptyObject(other)) {\n this._quad.bottom = firstDefined(this._quad.bottom, other);\n this._quad.left = firstDefined(this._quad.left, other);\n this._quad.right = firstDefined(this._quad.right, other);\n this._quad.top = firstDefined(this._quad.top, other);\n }\n\n return this;\n }\n\n /**\n * Copies another quadrilateral object into the current instance.\n *\n * @param other -\n * The quadrilateral object to copy.\n *\n * @returns\n * This object.\n */\n public copy(other: IZQuadrilateral<T>): this {\n this._quad = structuredClone(other);\n return this;\n }\n\n /**\n * Returns the built quadrilateral object.\n *\n * @returns\n * The built quadrilateral.\n */\n public build(): IZQuadrilateral<T> {\n return structuredClone(this._quad);\n }\n}\n","import {\n ZAnchor,\n ZHorizontalAnchor,\n ZVerticalAnchor,\n} from \"../anchor/anchor.mjs\";\nimport { IZPoint2d } from \"./point.mjs\";\nimport { IZQuadrilateral } from \"./quadrilateral.mjs\";\n\n/**\n * Represents a helper object that can run calculations on a numeric quadrilateral.\n */\nexport class ZRectangle {\n /**\n * Initializes a new instance of this object.\n *\n * @param sides -\n * The numeric sides of a quadrilateral.\n */\n public constructor(public readonly sides: IZQuadrilateral) {}\n\n /**\n * Calculates the width of the rectangle.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public width(): number {\n const { left, right } = this.sides;\n return right - left;\n }\n\n /**\n * Calculates the height of the rectangle.\n *\n * @returns\n * The numeric height of the rectangle.\n */\n public height(): number {\n const { top, bottom } = this.sides;\n return bottom - top;\n }\n\n /**\n * Calculates the area of the rectangle.\n *\n * @returns\n * The numeric area of the rectangle.\n */\n public area(): number {\n return this.width() * this.height();\n }\n\n /**\n * Calculates the (x, y) point given an anchor target.\n *\n * @param anchor -\n * The anchor target to calculate the point for.\n *\n * @returns\n * The numeric width of the rectangle.\n */\n public point(anchor: ZAnchor): IZPoint2d {\n const { bottom, left, right, top } = this.sides;\n const [vertical, horizontal] = anchor;\n\n const v: Record<ZVerticalAnchor, number> = {\n [ZVerticalAnchor.Top]: top,\n [ZVerticalAnchor.Middle]: (bottom + top) / 2,\n [ZVerticalAnchor.Bottom]: bottom,\n };\n\n const h: Record<ZHorizontalAnchor, number> = {\n [ZHorizontalAnchor.Left]: left,\n [ZHorizontalAnchor.Center]: (right + left) / 2,\n [ZHorizontalAnchor.Right]: right,\n };\n\n return { x: h[horizontal], y: v[vertical] };\n }\n\n /**\n * Calculates the top left point of the rectangle.\n *\n * @returns\n * The top left point of the rectangle.\n */\n public topLeft = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the top center point of the rectangle.\n *\n * @returns\n * The top center point of the rectangle.\n */\n public topCenter = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the top right point of the rectangle.\n *\n * @returns\n * The top right point of the rectangle.\n */\n public topRight = this.point.bind(this, [\n ZVerticalAnchor.Top,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the middle left point of the rectangle.\n *\n * @returns\n * The middle left point of the rectangle.\n */\n public middleLeft = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the middle center point of the rectangle.\n *\n * @returns\n * The middle center point of the rectangle.\n */\n public middleCenter = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the middle right point of the rectangle.\n *\n * @returns\n * The middle right point of the rectangle.\n */\n public middleRight = this.point.bind(this, [\n ZVerticalAnchor.Middle,\n ZHorizontalAnchor.Right,\n ]);\n\n /**\n * Calculates the bottom left point of the rectangle.\n *\n * @returns\n * The bottom left point of the rectangle.\n */\n public bottomLeft = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Left,\n ]);\n\n /**\n * Calculates the bottom center point of the rectangle.\n *\n * @returns\n * The bottom center point of the rectangle.\n */\n public bottomCenter = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Center,\n ]);\n\n /**\n * Calculates the bottom right point of the rectangle.\n *\n * @returns\n * The bottom right point of the rectangle.\n */\n public bottomRight = this.point.bind(this, [\n ZVerticalAnchor.Bottom,\n ZHorizontalAnchor.Right,\n ]);\n}\n","/* istanbul ignore next -- @preserve */\nexport const $global = typeof window === \"undefined\" ? global : window;\n","/**\n * A set of parameters that can be used for a string join.\n *\n * Join lists can be a regular object, null, undefined, or a tuple where the\n * first item is the object to join, and the second item is a boolean that specifies\n * whether to include it if the value is truthy.\n *\n * @param T -\n * The type of data to join.\n */\nexport type JoinListInputParameter<T> = T | [T, boolean] | null | undefined;\n\n/**\n * Similar to {@link Array.join}, but filters out null and undefined items.\n *\n * @param delimiter -\n * The delimiter that separates the items.\n * @param items -\n * The items to join.\n * @param T -\n * The type of data to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by delimiter.\n *\n * @example\n *\n * ```ts\n * // 'a b d'\n * const joinBySpace = joinDefined(' ', 'a', 'b', ['c', false], null, undefined, ['d', true]);\n * // (Empty String)\n * const joinEmpty = joinDefined('?');\n * ```\n */\nexport function joinDefined<T>(\n delimiter: string,\n ...items: JoinListInputParameter<T>[]\n) {\n return items\n .map((item) => (item instanceof Array ? (item[1] ? item[0] : null) : item))\n .filter((item) => item != null)\n .join(delimiter);\n}\n\n/**\n * Alias to joinList with a space delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const spaceJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \" \");\n\n/**\n * Alias of spaceJoinList.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a space delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const cssJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = spaceJoinDefined;\n\n/**\n * Alias of joinList with a comma delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a comma delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const commaJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \",\");\n\n/**\n * Alias of joinList with a semi-colon delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a semi-colon delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const semiColonJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \";\");\n\n/**\n * Alias of joinList with a pipe delimiter.\n *\n * @param items -\n * The items to join.\n *\n * @returns\n * A string that joins the items that are defined, separated by a pipe delimiter.\n *\n * @see\n * {@link joinDefined} for more information and examples.\n */\nexport const pipeJoinDefined: <T>(\n ...items: JoinListInputParameter<T>[]\n) => string = joinDefined.bind(null, \"|\");\n","/**\n * A specific set of possible values that need to be checked for requirements.\n *\n * @param T -\n * The type of value that is being checked.\n */\nexport type ZObligatedValue<T> =\n | T\n | null\n | undefined\n | Promise<T | null | undefined>;\n\n/**\n * Requires a value to be non null.\n *\n * @param val -\n * The value to require. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, an error is thrown.\n *\n * @throws\n * An error if the value is null or undefined.\n */\nexport async function required<T>(val: ZObligatedValue<T>): Promise<T> {\n if (val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n const _val = await val;\n\n if (_val == null) {\n throw new Error(\"A required value was not provided\");\n }\n\n return _val;\n}\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>, fallback: T): Promise<T>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, null is returned.\n * If val is a promise and rejects, then null is\n * also returned.\n */\nexport function optional<T>(val: ZObligatedValue<T>): Promise<T | null>;\n\n/**\n * Allows a value to be null or undefined and has a fallback.\n *\n * @param val -\n * The value to check. This can be a promise\n * that can return null or undefined in addition to the\n * value.\n * @param fallback -\n * The fallback value in the case that val is\n * null or undefined.\n * @param T -\n * The type of value that is being checked.\n *\n * @returns\n * This method returns val if it is not null\n * or undefined, otherwise, the fallback is returned.\n * If val is a promise and rejects, then fallback is\n * also returned.\n */\nexport async function optional<T>(\n val: ZObligatedValue<T>,\n fallback: T | null = null,\n): Promise<T | null> {\n if (val == null) {\n return fallback;\n }\n\n try {\n const _val = await val;\n return _val == null ? fallback : _val;\n } catch {\n return fallback;\n }\n}\n","/**\n * Represents a direction orientation.\n */\nexport enum ZOrientation {\n /**\n * Horizontal orientation.\n *\n * This type of orientation is a row\n * style orientation or flex-row orientation.\n */\n Horizontal = \"horizontal\",\n\n /**\n * Vertical orientation.\n *\n * This type of orientation is a column\n * style orientation or block orientation.\n */\n Vertical = \"vertical\",\n}\n","/**\n * Peels a candidate string from the start of a string and splits it into two segments.\n *\n * @param str -\n * The string to peel from.\n * @param candidates -\n * The candidate list of values to peel from str.\n *\n * @returns\n * A tuple where the first item is the peeled string and\n * the second item is the remainder of the string. If the string\n * does not start with any given candidates, then the first\n * item will be null and the second item will be str.\n */\nexport function peel<T extends string = string>(\n str: string,\n candidates: T[],\n): [T | null, string] {\n for (const check of candidates) {\n if (str.startsWith(check)) {\n return [str.substring(0, check.length) as T, str.substring(check.length)];\n }\n }\n\n return [null, str];\n}\n\n/**\n * Peels the values between an opening string set and a closing string set.\n *\n * The actual value will handle issues with internal opening and closing brackets\n *\n * @example\n *\n * ```ts\n * const [peeled, rest] = peelBetween('[a, b, [c1, c2],[d]] other', '[' ']');\n *\n * // Outputs 'a, b, [c1, c2], [d]'\n * console.log(peeled);\n *\n * // Outputs ' other' - white space is included'\n * console.log(rest);\n * ```\n *\n * @param str -\n * The string to peel between.\n * @param open -\n * The opening string. This will test\n * at the start of str.\n * @param close -\n * The closing string. This can be anywhere\n * in the str. If this is equal to open, then\n * the open string is removed from the start of the\n * string and the rest of the string would be returned.\n *\n * @returns\n * A tuple where the first argument is string that was found between\n * the opening and closing bracket. Returns null if no string could\n * be found between an open and close pair. The second argument will\n * be the remaining text of the string, including whitespace.\n */\nexport function peelBetween(\n str: string,\n open: string,\n close: string,\n): [string | null, string] {\n if (!str.startsWith(open)) {\n return [null, str];\n }\n\n let stack = 1;\n\n const _str = str.substring(open.length);\n\n for (let i = 0; i < _str.length; ++i) {\n if (_str.startsWith(open, i)) {\n stack += 1;\n i += open.length - 1;\n continue;\n }\n\n if (_str.startsWith(close, i)) {\n stack -= 1;\n\n if (stack === 0) {\n return [_str.substring(0, i), _str.substring(i + close.length)];\n }\n\n i += close.length - 1;\n }\n }\n\n return [null, str];\n}\n","export type PickPredicate = (\n key: number | string | symbol,\n value: any,\n) => boolean;\n\nexport type PickResult<T> = Partial<T> | null | undefined;\n\n/**\n * A function that reduces an object to keys and values that match a predicate.\n *\n * @param predicate -\n * The predicate to match the key and value against.\n * @param target -\n * The object to reduce.\n *\n * @returns\n * A reduced object that only contains key-value pairs that match\n * the predicate.\n */\nexport function pickBy<T = unknown>(\n predicate: PickPredicate,\n target: object,\n): PickResult<T> {\n const keys = Object.keys(target);\n const reduced = {};\n\n keys.forEach((key) => {\n const value = target[key];\n if (predicate(key, value)) {\n reduced[key] = value;\n }\n });\n\n return reduced;\n}\n\n/**\n * An alias to pickBy with a predicate of (_, v) =&gt; v != null.\n *\n * @param target -\n * The target object to reduce.\n *\n * @returns\n * The reduced object.\n */\nexport function pickDefined<T = unknown>(target: object): PickResult<T> {\n return pickBy((_, v) => v != null, target);\n}\n\n/**\n * An alias to pickBy((k) =&gt; k.startsWith('data-')).\n *\n * @param target -\n * The target object to reduce.\n *\n * @returns\n * The reduced object.\n */\nexport function pickDataAttributes<T = unknown>(target: object): PickResult<T> {\n return pickBy((k) => String(k).startsWith(\"data-\"), target);\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that deserializes a JSON string.\n */\nexport class ZDeserializeJson<T> implements IZDeserialize<T> {\n public constructor(private _schema?: (k: any) => k is T) {}\n\n public deserialize(candidate: string): T {\n const parsed = JSON.parse(candidate);\n\n if (this._schema && !this._schema(parsed)) {\n throw new Error(\n \"The parsed JSON does not conform to the given schema requirement\",\n );\n }\n\n return parsed;\n }\n}\n","import { IZDeserialize } from \"./deserialize.mjs\";\n\n/**\n * A deserializer that attempts to deserialize multiple times through a series of supported languages.\n *\n * @param T -\n * The type of data to deserialize.\n * @param S -\n * The input type\n */\nexport class ZDeserializeTry<T, S = string> implements IZDeserialize<T, S> {\n /**\n * Initializes a new instance of this object.\n *\n * @param _children -\n * The list of deserializer objects to try on a specific candidate.\n * The first deserializer to succeed will return the target object.\n * If no deserializer is able to deserialize the candidate, then an\n * error is throw with a mapping of serialization errors between each\n * deserializer.\n */\n public constructor(private _children: IZDeserialize<T, S>[]) {}\n\n public deserialize(candidate: S): T {\n const errors: string[] = [];\n\n for (const child of this._children) {\n try {\n return child.deserialize(candidate);\n } catch (e) {\n errors.push(e.message);\n }\n }\n\n const msg = `Unable to deserialize candidate, ${candidate}.`;\n errors.splice(0, 0, msg);\n throw new Error(errors.join(\"\\n\\n\"));\n }\n}\n","import { IZSerialize } from \"./serialize.mjs\";\n\n/**\n * Represents a serializer that serializes anything to a JSON string.\n */\nexport class ZSerializeJson implements IZSerialize<any> {\n public serialize(candidate: any): string | undefined {\n return JSON.stringify(candidate, undefined, 2);\n }\n}\n","/**\n * Represents a setter function for when you want to set a single value,\n * but you have an array instead.\n *\n * This is useful when you want to support lists of items, but you need\n * backwards compatibility for setting a single item. This is primarily meant\n * to be use with bind to construct a new method setter that takes an array\n * and forwards it to a setter method which will accept a single value of the\n * first item in the target value.\n *\n * @param setValue -\n * The setter function that takes a single value. This will receive\n * the first item of the value list.\n * @param fallback -\n * The fallback value in the case that there are no values.\n * @param value -\n * The value list to retrieve the first item from.\n * @param T -\n * The type of data that the array holds.\n *\n * @example\n *\n * ```ts\n * // An example of a react component that needs a value of an array, but you only care about a single selection.\n * const [value, setValue] = useState<TypesOfPie>();\n * const _values = useMemo(() => value ? [value] : [], [value]);\n * const _setValues = setFirst.bind(null, setValue, undefined);\n *\n * return <ComponentWithMultiSelectSupport values={_values} onValuesChange={_setValues} />\n * ```\n */\nexport function setFirst<T>(\n setValue: (val: T) => any,\n fallback: T,\n value: T[] | null | undefined,\n) {\n const _value = value?.length ? value[0] : fallback;\n setValue(_value);\n}\n","/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n *\n * @returns\n * A promise that resolves after ms milliseconds.\n */\nexport function sleep(ms?: number): Promise<void>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param val -\n * The value to resolve with.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(ms: number, val: T): Promise<T>;\n\n/**\n * Halts the current thread to invoke an event loop.\n *\n * @param ms -\n * The total number of milliseconds to sleep.\n * @param T -\n * The type of value that will be resolved.\n *\n * @returns\n * A promise that resolves with val after ms milliseconds.\n */\nexport function sleep<T>(\n ms = 0,\n val: T | undefined = undefined,\n): Promise<T | undefined> {\n return new Promise<T | undefined>((resolve) =>\n setTimeout(() => resolve(val), ms),\n );\n}\n","/**\n * This is just a method that allows you to tag an interpolation\n * string as a syntax language.\n *\n * This is useful with IDE extensions that can detect the language\n * and do the syntax highlighting for you.\n *\n * @param strings -\n * The string breaks for interpolation.\n * @param expressions -\n * The equivalent expressions that break apart\n * the single string literal.\n *\n * @returns\n * The compiled string literal. This is no different\n * than letting native JavaScript do it for you.\n *\n * @example\n *\n * ```ts\n * const html = tag;\n * const css = tag;\n *\n * const $html = html`\n * <div>Some IDE extensions will highlight this as html</div>\n * `\n *\n * const $css = css`\n * button {\n * display: grid;\n * }\n * `\n * ```\n */\nexport function tag(\n strings: TemplateStringsArray,\n ...expressions: unknown[]\n): string {\n let [result] = strings;\n\n for (let i = 1, l = strings.length; i < l; i++) {\n result += expressions[i - 1];\n result += strings[i];\n }\n\n return result;\n}\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=Tobermory.es6-string-html | IDE extensions will detect the string}\n * interpolation as html when using this tag.\n */\nexport const html = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=bashmish.es6-string-css | IDE extensions will detect the string}\n * interpolation as css when using this tag.\n */\nexport const css = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=zjcompt.es6-string-javascript | IDE extensions will detect the string}\n * interpolation as javascript when using this tag.\n */\nexport const js = tag;\n\n/**\n * See {@link js}\n */\nexport const javascript = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=jeoht.es6-string-markdown | IDE extensions will detect the string}\n * interpolation as markdown when using this tag.\n */\nexport const md = tag;\n\n/**\n * See {@link md}\n */\nexport const markdown = tag;\n\n/**\n * An alias for {@link tag}.\n *\n * Some {@link https://marketplace.visualstudio.com/items?itemName=HoodieCollin.es6-string-typescript | IDE extensions will detect the string}\n * interpolation as typescript when using this tag.\n */\nexport const ts = tag;\n\n/**\n * See {@link ts}\n */\nexport const typescript = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const sh = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const bash = tag;\n\n/**\n * An alias for {@link tag}.\n */\nexport const zsh = tag;\n","/**\n * Invokes the candidate function and returns undefined if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * The result from candidate. Returns undefined if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T): T | undefined;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n */\nexport function tryFallback<T>(candidate: () => T, fallback: T): T;\n\n/**\n * Invokes the candidate function and returns fallback if an error is thrown from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value to return if candidate throws an error.\n *\n * @returns\n * The result from candidate. Returns fallback if candidate throws an Error.\n * If no fallback value is provided, then undefined is returned.\n */\nexport function tryFallback<T>(\n candidate: () => T,\n fallback?: T,\n): T | undefined {\n try {\n return candidate();\n } catch {\n return fallback;\n }\n}\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns undefined\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n): Promise<T | undefined>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The fallback value that will be returned if candidate returns a rejected promise.\n *\n * @returns\n * A promise that resolves with the result from candidate. Returns fallback\n * if candidate returns a rejected promise.\n */\nexport function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback: T,\n): Promise<T>;\n\n/**\n * Invokes the candidate function and returns undefined if an rejected promise is returned from it.\n *\n * @param candidate -\n * The candidate function to run.\n * @param fallback -\n * The optional fallback value to return if the candidate throws an Error.\n *\n * @returns\n * A promise that resolves with the result from candidate or fallback\n * if candidate returns a rejected promise. Resolves with undefined\n * if no fallback is provided.\n */\nexport async function tryFallbackAsync<T>(\n candidate: () => Promise<T>,\n fallback?: T,\n): Promise<T | undefined> {\n try {\n return await candidate();\n } catch {\n return fallback;\n }\n}\n"],"names":["ZVerticalAnchor","ZHorizontalAnchor","ZOrientation"],"mappings":";AAGY,IAAA,oCAAAA,qBAAL;AAMLA,mBAAA,KAAM,IAAA;AAINA,mBAAA,QAAS,IAAA;AAMTA,mBAAA,QAAS,IAAA;AAhBCA,SAAAA;AAAA,GAAA,mBAAA,CAAA,CAAA;AAsBA,IAAA,sCAAAC,uBAAL;AAMLA,qBAAA,MAAO,IAAA;AAIPA,qBAAA,QAAS,IAAA;AAMTA,qBAAA,OAAQ,IAAA;AAhBEA,SAAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;ACTL,MAAM,QAAQ;AAAA;AAAA;AAAA;AAAA,EAqBX,cAAc;AALtB,SAAQ,YAAmB;EAKJ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EATvB,OAAc,MAAM,OAAgB,KAAmB;AACrD,WAAO,IAAI,QAAU,EAAA,MAAM,OAAO,GAAG;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBO,MAAM,OAAgB,KAAgB;AAC3C,QAAI,CAAC,OAAO;AACL,WAAA,UAAU,KAAK,GAAG;AAAA,IACzB;AACO,WAAA;AAAA,EACT;AA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AA2C;AAAA,EAC/C,UAAU,WAAoC;AACnD,WAAO,KAAK,UAAU,WAAW,QAAW,CAAC;AAAA,EAC/C;AACF;ACsBgB,SAAA,SACd,UACA,UACA,OACA;AACA,QAAM,UAAS,+BAAO,UAAS,MAAM,CAAC,IAAI;AAC1C,WAAS,MAAM;AACjB;ACDO,SAAS,MACd,KAAK,GACL,MAAqB,QACG;AACxB,SAAO,IAAI;AAAA,IAAuB,CAAC,YACjC,WAAW,MAAM,QAAQ,GAAG,GAAG,EAAE;AAAA,EAAA;AAErC;ACVgB,SAAA,IACd,YACG,aACK;AACJ,MAAA,CAAC,MAAM,IAAI;AAEf,WAAS,IAAI,GAAG,IAAI,QAAQ,QAAQ,IAAI,GAAG,KAAK;AACpC,cAAA,YAAY,IAAI,CAAC;AAC3B,cAAU,QAAQ,CAAC;AAAA,EACrB;AAEO,SAAA;AACT;AAQO,MAAM,OAAO;AAQb,MAAM,MAAM;AAQZ,MAAM,KAAK;AAKX,MAAM,aAAa;AAQnB,MAAM,KAAK;AAKX,MAAM,WAAW;AAQjB,MAAM,KAAK;AAKX,MAAM,aAAa;AAKnB,MAAM,KAAK;AAKX,MAAM,OAAO;AAKb,MAAM,MAAM;AChFH,SAAA,YACd,WACA,UACe;AACX,MAAA;AACF,WAAO,UAAU;AAAA,EAAA,QACX;AACC,WAAA;AAAA,EACT;AACF;AA8CsB,eAAA,iBACpB,WACA,UACwB;AACpB,MAAA;AACF,WAAO,MAAM,UAAU;AAAA,EAAA,QACjB;AACC,WAAA;AAAA,EACT;AACF;"}
@@ -0,0 +1,35 @@
1
+ export type PickPredicate = (key: number | string | symbol, value: any) => boolean;
2
+ export type PickResult<T> = Partial<T> | null | undefined;
3
+ /**
4
+ * A function that reduces an object to keys and values that match a predicate.
5
+ *
6
+ * @param predicate -
7
+ * The predicate to match the key and value against.
8
+ * @param target -
9
+ * The object to reduce.
10
+ *
11
+ * @returns
12
+ * A reduced object that only contains key-value pairs that match
13
+ * the predicate.
14
+ */
15
+ export declare function pickBy<T = unknown>(predicate: PickPredicate, target: object): PickResult<T>;
16
+ /**
17
+ * An alias to pickBy with a predicate of (_, v) =&gt; v != null.
18
+ *
19
+ * @param target -
20
+ * The target object to reduce.
21
+ *
22
+ * @returns
23
+ * The reduced object.
24
+ */
25
+ export declare function pickDefined<T = unknown>(target: object): PickResult<T>;
26
+ /**
27
+ * An alias to pickBy((k) =&gt; k.startsWith('data-')).
28
+ *
29
+ * @param target -
30
+ * The target object to reduce.
31
+ *
32
+ * @returns
33
+ * The reduced object.
34
+ */
35
+ export declare function pickDataAttributes<T = unknown>(target: object): PickResult<T>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zthun/helpful-fn",
3
- "version": "6.2.0",
3
+ "version": "6.3.0",
4
4
  "description": "Helpful, isolated pure functions that are not found in other libraries such as lodash.",
5
5
  "author": "Anthony Bonta",
6
6
  "license": "MIT",
@@ -25,18 +25,17 @@
25
25
  "access": "public"
26
26
  },
27
27
  "dependencies": {
28
- "lodash-es": "^4.17.21",
29
28
  "uuid": "^10.0.0"
30
29
  },
31
30
  "devDependencies": {
32
- "typescript": "^5.5.4",
33
- "vite": "^5.4.3",
34
- "vitest": "^2.0.5",
31
+ "typescript": "^5.6.2",
32
+ "vite": "^5.4.5",
33
+ "vitest": "^2.1.1",
35
34
  "vitest-mock-extended": "^2.0.2"
36
35
  },
37
36
  "files": [
38
37
  "dist"
39
38
  ],
40
39
  "sideEffects": false,
41
- "gitHead": "b8923fd4fa05188f191c8f6540e1a06700b72634"
40
+ "gitHead": "dfb59c4458cc38f023d7f2001549e6cd89ed1eb8"
42
41
  }