{"version":3,"file":"vector4-PO_7EYd-.mjs","names":["internal.isVector4","internal.equals","internal.make","internal.fromTuple","internal.transpose","internal.magnitude","internal.normalize","internal.dot","internal.components","internal.softmax","internal.add","internal.subtract","internal.hadamard","internal.scale","internal.getX","internal.setX","internal.mapX","internal.getY","internal.setY","internal.mapY","internal.getZ","internal.setZ","internal.mapZ","internal.getW","internal.setW","internal.mapW"],"sources":["../../src/vector/vector4.ts"],"sourcesContent":["import type { FourDimensional } from '../dimensions.ts'\nimport type { Pipeable } from '../utils.ts'\nimport type { Vector4TypeId } from './vector4.internal.ts'\nimport * as internal from './vector4.internal.ts'\n\n/**\n * A 4D vector.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Vector4 extends Pipeable, FourDimensional<number> {\n  readonly [Vector4TypeId]: Vector4TypeId\n}\n\n/**\n * Checks if a value is a `Vector4`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is a `Vector4`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isVector4: (v: unknown) => v is Vector4 = internal.isVector4\n\nexport const equals: {\n  /**\n   * Checks if two `Vector4` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns `true` when each pair of components is within tolerance.\n   * @since 1.1.0\n   */\n  (a: Vector4, b: Vector4): boolean\n  /**\n   * Checks if two `Vector4` instances are approximately equal within the\n   * default absolute tolerance ({@link EPSILON}).\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the comparison result.\n   * @since 1.1.0\n   */\n  (b: Vector4): (a: Vector4) => boolean\n} = internal.equals\n\nexport const make: {\n  /**\n   * Creates a new `Vector4` instance.\n   *\n   * @param xyzw - The x, y, z, and w components of the vector.\n   * @returns A new `Vector4` instance.\n   * @since 1.0.0\n   */\n  (xyzw: number): Vector4\n  /**\n   * Creates a new `Vector4` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param yzw - The y, z, and w components of the vector.\n   * @returns A new `Vector4` instance.\n   * @since 1.0.0\n   */\n  (x: number, yzw: number): Vector4\n  /**\n   * Creates a new `Vector4` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param y - The y component of the vector.\n   * @param zw - The z and w components of the vector.\n   * @returns A new `Vector4` instance.\n   * @since 1.0.0\n   */\n  (x: number, y: number, zw: number): Vector4\n  /**\n   * Creates a new `Vector4` instance.\n   *\n   * @param x - The x component of the vector.\n   * @param y - The y component of the vector.\n   * @param z - The z component of the vector.\n   * @param w - The w component of the vector.\n   * @returns A new `Vector4` instance.\n   * @since 1.0.0\n   */\n  (x: number, y: number, z: number, w: number): Vector4\n} = internal.make\n\n/**\n * Creates a new `Vector4` instance from a `[x, y, z, w]` tuple. Inverse of\n * {@link components}.\n *\n * @param t - The `[x, y, z, w]` tuple.\n * @returns A new `Vector4` instance.\n * @since 2.0.0\n */\nexport const fromTuple: (t: readonly [number, number, number, number]) => Vector4 =\n  internal.fromTuple\n\n/**\n * Transposes a 4-tuple of items into one or more `Vector4`s, one per channel\n * extracted by the projection function.\n *\n * For each output channel, takes the corresponding number from each of the\n * four projected items and packs them into a `Vector4` — the data-layout\n * transformation NumPy calls a transpose, FP calls `unzip`, GPUs call a\n * gather, and DSP people inexplicably call deinterleaving.\n *\n * The projection's return-tuple arity determines the number of output\n * vectors, and that arity is preserved in the return type.\n *\n * @example\n * ```ts\n * // Pack the x and y coordinates of four control points into two Vector4s.\n * const [xs, ys] = Vector4.transpose(\n *   [p0, p1, p2, p3],\n *   (p) => [p.x, p.y],\n * )\n * ```\n *\n * @param inputs - Exactly four items of any type.\n * @param project - A function returning a fixed-arity tuple of numbers — one per output channel.\n * @returns A tuple of `Vector4`s with the same arity as the projection's return tuple.\n * @since 2.0.0\n */\nexport const transpose: <T, const Channels extends ReadonlyArray<number>>(\n  inputs: readonly [T, T, T, T],\n  project: (item: T) => Channels,\n) => { readonly [K in keyof Channels]: Vector4 } = internal.transpose\n\n/**\n * Gets the magnitude of a `Vector4`.\n *\n * @param vector - The vector to calculate the magnitude of.\n * @returns The magnitude of the vector.\n * @since 1.0.0\n */\nexport const magnitude: (vector: Vector4) => number = internal.magnitude\n\n/**\n * Normalizes a `Vector4`.\n *\n * @param vector - The vector to normalize.\n * @returns A new `Vector4` instance with the same direction as the input vector but with a magnitude of 1.\n * @since 1.0.0\n */\nexport const normalize: (vector: Vector4) => Vector4 = internal.normalize\n\nexport const dot: {\n  /**\n   * Computes the dot product of two `Vector4` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns The dot product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector4, b: Vector4): number\n  /**\n   * Computes the dot product of a `Vector4` instance and another vector.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the dot product.\n   * @since 1.0.0\n   */\n  (b: Vector4): (a: Vector4) => number\n} = internal.dot\n\n/**\n * Returns the components of a `Vector4` as an array.\n *\n * @param v - The vector to get the components of.\n * @returns An array containing the x, y, z, and w components of the vector.\n * @since 1.0.0\n */\nexport const components: (v: Vector4) => [number, number, number, number] = internal.components\n\n/**\n * Applies the softmax function to a `Vector4`.\n *\n * @param v - The vector to calculate the softmax of.\n * @returns A new `Vector4` instance representing the softmax of the input vector.\n */\nexport const softmax: (v: Vector4) => Vector4 = internal.softmax\n\n/**\n * Creates a zero vector.\n *\n * @since 1.0.0\n */\nexport const zero = make(0)\n\n/**\n * Creates a unit vector.\n *\n * @since 1.0.0\n */\nexport const unit = make(1)\n\nexport const add: {\n  /**\n   * Adds two `Vector4` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector4` instance representing the sum of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector4, b: Vector4): Vector4\n\n  /**\n   * Adds a `Vector4` instance to another vector.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the sum.\n   * @since 1.0.0\n   */\n  (b: Vector4): (a: Vector4) => Vector4\n} = internal.add\n\nexport const subtract: {\n  /**\n   * Subtracts one `Vector4` instance from another.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector4` instance representing the difference of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector4, b: Vector4): Vector4\n  /**\n   * Subtracts a `Vector4` instance from another vector.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the difference.\n   * @since 1.0.0\n   */\n  (b: Vector4): (a: Vector4) => Vector4\n} = internal.subtract\n\nexport const hadamard: {\n  /**\n   * Computes the Hadamard product of two `Vector4` instances.\n   *\n   * @param a - The first vector.\n   * @param b - The second vector.\n   * @returns A new `Vector4` instance representing the Hadamard product of the two vectors.\n   * @since 1.0.0\n   */\n  (a: Vector4, b: Vector4): Vector4\n  /**\n   * Computes the Hadamard product of a `Vector4` instance and another vector.\n   *\n   * @param b - The second vector.\n   * @returns A function that takes the first vector and returns the Hadamard product.\n   * @since 1.0.0\n   */\n  (b: Vector4): (a: Vector4) => Vector4\n} = internal.hadamard\n\nexport const scale: {\n  /**\n   * Scales a `Vector4` by a scalar.\n   *\n   * @param s - The scalar to scale the vector by.\n   * @returns A function that takes the vector and returns the scaled vector.\n   * @since 1.0.0\n   */\n  (s: number): (v: Vector4) => Vector4\n  /**\n   * Scales a `Vector4` by a scalar.\n   *\n   * @param s - The scalar to scale the vector by.\n   * @param v - The vector to scale.\n   * @returns A new `Vector4` instance representing the scaled vector.\n   * @since 1.0.0\n   */\n  (v: Vector4, s: number): Vector4\n} = internal.scale\n\n/**\n * Gets the x component of a `Vector4`.\n *\n * @param v - The vector to get the x component of.\n * @returns The x component of the vector.\n * @since 2.0.0\n */\nexport const getX: (v: Vector4) => number = internal.getX\n\nexport const setX: {\n  /**\n   * Sets the x component of a `Vector4`.\n   *\n   * @param v - The vector to set the x component of.\n   * @param x - The new x component.\n   * @returns A new `Vector4` instance with the updated x component.\n   * @since 2.0.0\n   */\n  (v: Vector4, x: number): Vector4\n  /**\n   * Sets the x component of a `Vector4`.\n   *\n   * @param x - The new x component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (x: number): (v: Vector4) => Vector4\n} = internal.setX\n\nexport const mapX: {\n  /**\n   * Returns a new `Vector4` with the x component replaced by `f(v.x)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the x component.\n   * @returns A new `Vector4` with the updated x.\n   * @since 2.0.0\n   */\n  (v: Vector4, f: (x: number) => number): Vector4\n  /**\n   * Returns a new `Vector4` with the x component replaced by `f(v.x)`.\n   *\n   * @param f - The function to apply to the x component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (x: number) => number): (v: Vector4) => Vector4\n} = internal.mapX\n\n/**\n * Gets the y component of a `Vector4`.\n *\n * @param v - The vector to get the y component of.\n * @returns The y component of the vector.\n * @since 2.0.0\n */\nexport const getY: (v: Vector4) => number = internal.getY\n\nexport const setY: {\n  /**\n   * Sets the y component of a `Vector4`.\n   *\n   * @param v - The vector to set the y component of.\n   * @param y - The new y component.\n   * @returns A new `Vector4` instance with the updated y component.\n   * @since 2.0.0\n   */\n  (v: Vector4, y: number): Vector4\n  /**\n   * Sets the y component of a `Vector4`.\n   *\n   * @param y - The new y component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (y: number): (v: Vector4) => Vector4\n} = internal.setY\n\nexport const mapY: {\n  /**\n   * Returns a new `Vector4` with the y component replaced by `f(v.y)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the y component.\n   * @returns A new `Vector4` with the updated y.\n   * @since 2.0.0\n   */\n  (v: Vector4, f: (y: number) => number): Vector4\n  /**\n   * Returns a new `Vector4` with the y component replaced by `f(v.y)`.\n   *\n   * @param f - The function to apply to the y component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (y: number) => number): (v: Vector4) => Vector4\n} = internal.mapY\n\n/**\n * Gets the z component of a `Vector4`.\n *\n * @param v - The vector to get the z component of.\n * @returns The z component of the vector.\n * @since 2.0.0\n */\nexport const getZ: (v: Vector4) => number = internal.getZ\n\nexport const setZ: {\n  /**\n   * Sets the z component of a `Vector4`.\n   *\n   * @param v - The vector to set the z component of.\n   * @param z - The new z component.\n   * @returns A new `Vector4` instance with the updated z component.\n   * @since 2.0.0\n   */\n  (v: Vector4, z: number): Vector4\n  /**\n   * Sets the z component of a `Vector4`.\n   *\n   * @param z - The new z component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (z: number): (v: Vector4) => Vector4\n} = internal.setZ\n\nexport const mapZ: {\n  /**\n   * Returns a new `Vector4` with the z component replaced by `f(v.z)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the z component.\n   * @returns A new `Vector4` with the updated z.\n   * @since 2.0.0\n   */\n  (v: Vector4, f: (z: number) => number): Vector4\n  /**\n   * Returns a new `Vector4` with the z component replaced by `f(v.z)`.\n   *\n   * @param f - The function to apply to the z component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (z: number) => number): (v: Vector4) => Vector4\n} = internal.mapZ\n\n/**\n * Gets the w component of a `Vector4`.\n *\n * @param v - The vector to get the w component of.\n * @returns The w component of the vector.\n * @since 2.0.0\n */\nexport const getW: (v: Vector4) => number = internal.getW\n\nexport const setW: {\n  /**\n   * Sets the w component of a `Vector4`.\n   *\n   * @param v - The vector to set the w component of.\n   * @param w - The new w component.\n   * @returns A new `Vector4` instance with the updated w component.\n   * @since 2.0.0\n   */\n  (v: Vector4, w: number): Vector4\n  /**\n   * Sets the w component of a `Vector4`.\n   *\n   * @param w - The new w component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (w: number): (v: Vector4) => Vector4\n} = internal.setW\n\nexport const mapW: {\n  /**\n   * Returns a new `Vector4` with the w component replaced by `f(v.w)`.\n   *\n   * @param v - The vector to update.\n   * @param f - The function to apply to the w component.\n   * @returns A new `Vector4` with the updated w.\n   * @since 2.0.0\n   */\n  (v: Vector4, f: (w: number) => number): Vector4\n  /**\n   * Returns a new `Vector4` with the w component replaced by `f(v.w)`.\n   *\n   * @param f - The function to apply to the w component.\n   * @returns A function that takes a vector and returns the updated vector.\n   * @since 2.0.0\n   */\n  (f: (w: number) => number): (v: Vector4) => Vector4\n} = internal.mapW\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,YAA0CA;AAEvD,MAAa,SAoBTC;AAEJ,MAAa,OAuCTC;;;;;;;;;AAUJ,MAAa,YACXC;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BF,MAAa,YAGsCC;;;;;;;;AASnD,MAAa,YAAyCC;;;;;;;;AAStD,MAAa,YAA0CC;AAEvD,MAAa,MAkBTC;;;;;;;;AASJ,MAAa,aAA+DC;;;;;;;AAQ5E,MAAa,UAAmCC;;;;;;AAOhD,MAAa,OAAO,KAAK,EAAE;;;;;;AAO3B,MAAa,OAAO,KAAK,EAAE;AAE3B,MAAa,MAmBTC;AAEJ,MAAa,WAkBTC;AAEJ,MAAa,WAkBTC;AAEJ,MAAa,QAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC;;;;;;;;AASJ,MAAa,OAA+BC;AAE5C,MAAa,OAkBTC;AAEJ,MAAa,OAkBTC"}