{"version":3,"file":"random.module.js","sources":["../src/rng.ts","../src/generators/function.ts","../src/rng-factory.ts","../src/distributions/uniform.ts","../src/validation.ts","../src/distributions/uniform-int.ts","../src/distributions/uniform-boolean.ts","../src/distributions/normal.ts","../src/distributions/log-normal.ts","../src/distributions/bernoulli.ts","../src/distributions/binomial.ts","../src/distributions/geometric.ts","../src/distributions/poisson.ts","../src/distributions/exponential.ts","../src/distributions/irwin-hall.ts","../src/distributions/bates.ts","../src/distributions/pareto.ts","../src/generators/math-random.ts","../src/random.ts"],"sourcesContent":["export type SeedFn = () => number\nexport type SeedType = number | string | SeedFn | RNG\n\nexport default abstract class RNG {\n abstract get name(): string\n\n abstract next(): number\n\n abstract seed(_seed?: SeedType, _opts?: Record): void\n\n abstract clone(_seed?: SeedType, _opts?: Record): RNG\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n _seed(seed: number, _opts?: Record) {\n // TODO: add entropy and stuff\n\n if (seed === (seed || 0)) {\n return seed\n } else {\n const strSeed = '' + seed\n let s = 0\n\n for (let k = 0; k < strSeed.length; ++k) {\n s ^= strSeed.charCodeAt(k) | 0\n }\n\n return s\n }\n }\n}\n","import RNG, { SeedFn } from '../rng'\n\nexport default class RNGFunction extends RNG {\n _rng: SeedFn\n\n constructor(thunk: SeedFn, opts?: Record) {\n super()\n\n this.seed(thunk, opts)\n }\n\n get name() {\n return 'function'\n }\n\n next() {\n return this._rng()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n seed(thunk: SeedFn, _opts?: Record) {\n this._rng = thunk\n }\n\n clone(_: undefined, opts: Record) {\n return new RNGFunction(this._rng, opts)\n }\n}\n","import seedrandom from 'seedrandom'\n\nimport RNG from './rng'\nimport RNGFunction from './generators/function'\n\n/**\n * Construct an RNG with variable inputs. Used in calls to Random constructor\n * @param {...*} args - Distribution-specific arguments\n * @return RNG\n *\n * @example\n * new Random(RNGFactory(...args))\n */\nexport default (...args: T) => {\n const [arg0 = 'default'] = args\n\n switch (typeof arg0) {\n case 'object':\n if (arg0 instanceof RNG) {\n return arg0\n }\n break\n\n case 'function':\n return new RNGFunction(arg0)\n\n case 'number':\n case 'string':\n default:\n return new RNGFunction(seedrandom(...args))\n }\n\n throw new Error(`invalid RNG \"${arg0}\"`)\n}\n","import { Random } from '../random'\n\nexport default (random: Random, min = 0, max = 1) => {\n return () => {\n return random.next() * (max - min) + min\n }\n}\n","export function numberValidator(num: number) {\n return new NumberValidator(num)\n}\n\nexport class NumberValidator {\n private n: number\n constructor(num: number) {\n this.n = num\n }\n\n public isInt = (): this => {\n if (Number.isInteger(this.n)) {\n return this\n }\n throw new Error(`Expected number to be an integer, got ${this.n}`)\n }\n\n public isPositive = (): this => {\n if (this.n > 0) {\n return this\n }\n throw new Error(`Expected number to be positive, got ${this.n}`)\n }\n\n public lessThan = (v: number): this => {\n if (this.n < v) {\n return this\n }\n throw new Error(`Expected number to be less than ${v}, got ${this.n}`)\n }\n\n public greaterThanOrEqual = (v: number): this => {\n if (this.n >= v) {\n return this\n }\n throw new Error(\n `Expected number to be greater than or equal to ${v}, got ${this.n}`\n )\n }\n\n public greaterThan = (v: number): this => {\n if (this.n > v) {\n return this\n }\n throw new Error(`Expected number to be greater than ${v}, got ${this.n}`)\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, min = 0, max = 1) => {\n if (max === undefined) {\n max = min === undefined ? 1 : min\n min = 0\n }\n\n numberValidator(min).isInt()\n numberValidator(max).isInt()\n\n return () => {\n return Math.floor(random.next() * (max - min + 1) + min)\n }\n}\n","import { Random } from '../random'\n\nexport default (random: Random) => {\n return () => {\n return random.next() >= 0.5\n }\n}\n","import { Random } from '../random'\n\nexport default (random: Random, mu = 0, sigma = 1) => {\n return () => {\n let x: number, y: number, r: number\n\n do {\n x = random.next() * 2 - 1\n y = random.next() * 2 - 1\n r = x * x + y * y\n } while (!r || r > 1)\n\n return mu + sigma * y * Math.sqrt((-2 * Math.log(r)) / r)\n }\n}\n","import { Random } from '../random'\n\nexport default (random: Random, mu = 0, sigma = 1) => {\n const normal = random.normal(mu, sigma)\n return () => {\n return Math.exp(normal())\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, p = 0.5) => {\n numberValidator(p).greaterThanOrEqual(0).lessThan(1)\n\n return () => {\n return Math.floor(random.next() + p)\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, n = 1, p = 0.5) => {\n numberValidator(n).isInt().isPositive()\n numberValidator(p).greaterThanOrEqual(0).lessThan(1)\n\n return () => {\n let i = 0\n let x = 0\n\n while (i++ < n) {\n if (random.next() < p) {\n x++\n }\n }\n return x\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, p = 0.5) => {\n numberValidator(p).greaterThan(0).lessThan(1)\n const invLogP = 1.0 / Math.log(1.0 - p)\n\n return () => {\n return Math.floor(1 + Math.log(random.next()) * invLogP)\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nconst logFactorialTable = [\n 0.0, 0.0, 0.69314718055994529, 1.791759469228055, 3.1780538303479458,\n 4.7874917427820458, 6.5792512120101012, 8.5251613610654147,\n 10.604602902745251, 12.801827480081469\n]\n\nconst logFactorial = (k: number) => {\n return logFactorialTable[k]\n}\n\nconst logSqrt2PI = 0.91893853320467267\n\nexport default (random: Random, lambda = 1) => {\n numberValidator(lambda).isPositive()\n\n if (lambda < 10) {\n // inversion method\n const expMean = Math.exp(-lambda)\n\n return () => {\n let p = expMean\n let x = 0\n let u = random.next()\n\n while (u > p) {\n u = u - p\n p = (lambda * p) / ++x\n }\n\n return x\n }\n } else {\n // generative method\n const smu = Math.sqrt(lambda)\n const b = 0.931 + 2.53 * smu\n const a = -0.059 + 0.02483 * b\n const invAlpha = 1.1239 + 1.1328 / (b - 3.4)\n const vR = 0.9277 - 3.6224 / (b - 2)\n\n return () => {\n while (true) {\n let u\n let v = random.next()\n\n if (v <= 0.86 * vR) {\n u = v / vR - 0.43\n return Math.floor(\n ((2 * a) / (0.5 - Math.abs(u)) + b) * u + lambda + 0.445\n )\n }\n\n if (v >= vR) {\n u = random.next() - 0.5\n } else {\n u = v / vR - 0.93\n u = (u < 0 ? -0.5 : 0.5) - u\n v = random.next() * vR\n }\n\n const us = 0.5 - Math.abs(u)\n if (us < 0.013 && v > us) {\n continue\n }\n\n const k = Math.floor(((2 * a) / us + b) * u + lambda + 0.445)\n v = (v * invAlpha) / (a / (us * us) + b)\n\n if (k >= 10) {\n const t =\n (k + 0.5) * Math.log(lambda / k) -\n lambda -\n logSqrt2PI +\n k -\n (1 / 12.0 - (1 / 360.0 - 1 / (1260.0 * k * k)) / (k * k)) / k\n\n if (Math.log(v * smu) <= t) {\n return k\n }\n } else if (k >= 0) {\n const f = logFactorial(k) ?? 0\n\n if (Math.log(v) <= k * Math.log(lambda) - lambda - f) {\n return k\n }\n }\n }\n }\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, lambda = 1) => {\n numberValidator(lambda).isPositive()\n\n return () => {\n return -Math.log(1 - random.next()) / lambda\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, n = 1) => {\n numberValidator(n).isInt().greaterThanOrEqual(0)\n\n return () => {\n let sum = 0\n for (let i = 0; i < n; ++i) {\n sum += random.next()\n }\n\n return sum\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, n = 1) => {\n numberValidator(n).isInt().isPositive()\n const irwinHall = random.irwinHall(n)\n\n return () => {\n return irwinHall() / n\n }\n}\n","import { Random } from '../random'\nimport { numberValidator } from '../validation'\n\nexport default (random: Random, alpha = 1) => {\n numberValidator(alpha).greaterThanOrEqual(0)\n const invAlpha = 1.0 / alpha\n\n return () => {\n return 1.0 / Math.pow(1.0 - random.next(), invAlpha)\n }\n}\n","import RNG from '../rng'\n\nexport default class RNGMathRandom extends RNG {\n get name() {\n return 'default'\n }\n\n next() {\n return Math.random()\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n seed(_seed: unknown, _opts: Record) {\n // intentionally empty\n }\n\n clone() {\n return new RNGMathRandom()\n }\n}\n","import RNG from './rng'\nimport RNGFactory from './rng-factory'\n\nimport uniform from './distributions/uniform'\nimport uniformInt from './distributions/uniform-int'\nimport uniformBoolean from './distributions/uniform-boolean'\nimport normal from './distributions/normal'\nimport logNormal from './distributions/log-normal'\nimport bernoulli from './distributions/bernoulli'\nimport binomial from './distributions/binomial'\nimport geometric from './distributions/geometric'\nimport poisson from './distributions/poisson'\nimport exponential from './distributions/exponential'\nimport irwinHall from './distributions/irwin-hall'\nimport bates from './distributions/bates'\nimport pareto from './distributions/pareto'\nimport RNGMathRandom from './generators/math-random'\n\n/**\n * Distribution function\n */\ninterface IDistFn {\n (random: Random, ...argv: any): R\n}\n\n/**\n * Distribution\n */\ninterface IDist {\n (): R\n}\n\n/**\n * Keyed cache entry\n */\ninterface ICacheEntry {\n key: string\n distribution: () => T\n}\n\nexport { RNG, RNGFactory }\n\n/**\n * Seedable random number generator supporting many common distributions.\n *\n * Defaults to Math.random as its underlying pseudorandom number generator.\n *\n * @name Random\n * @class\n *\n * @param {RNG|function} [rng=Math.random] - Underlying pseudorandom number generator.\n */\nexport class Random {\n protected _rng: RNG\n protected _patch: typeof Math.random | undefined\n protected _cache: {\n [k: string]: ICacheEntry\n } = {}\n\n constructor(rng?: RNG) {\n if (rng && rng instanceof RNG) {\n this.use(rng)\n } else {\n this.use(new RNGMathRandom())\n }\n this._cache = {}\n }\n\n /**\n * @member {RNG} Underlying pseudo-random number generator\n */\n get rng() {\n return this._rng\n }\n\n /**\n * Creates a new `Random` instance, optionally specifying parameters to\n * set a new seed.\n *\n * @see RNG.clone\n *\n * @param {string} [seed] - Optional seed for new RNG.\n * @param {object} [opts] - Optional config for new RNG options.\n * @return {Random}\n */\n clone(...args: [T]): Random {\n if (args.length) {\n return new Random(RNGFactory(...args))\n } else {\n return new Random(this.rng.clone())\n }\n }\n\n /**\n * Sets the underlying pseudorandom number generator used via\n * either an instance of `seedrandom`, a custom instance of RNG\n * (for PRNG plugins), or a string specifying the PRNG to use\n * along with an optional `seed` and `opts` to initialize the\n * RNG.\n *\n * @example\n * import random from 'random'\n *\n * random.use('example_seedrandom_string')\n * // or\n * random.use(seedrandom('kittens'))\n * // or\n * random.use(Math.random)\n *\n * @param {...*} args\n */\n use(...args: [RNG]) {\n this._rng = RNGFactory(...args)\n }\n\n /**\n * Patches `Math.random` with this Random instance's PRNG.\n */\n patch() {\n if (this._patch) {\n throw new Error('Math.random already patched')\n }\n\n this._patch = Math.random\n Math.random = this.uniform()\n }\n\n /**\n * Restores a previously patched `Math.random` to its original value.\n */\n unpatch() {\n if (this._patch) {\n Math.random = this._patch\n delete this._patch\n }\n }\n\n // --------------------------------------------------------------------------\n // Uniform utility functions\n // --------------------------------------------------------------------------\n\n /**\n * Convenience wrapper around `this.rng.next()`\n *\n * Returns a floating point number in [0, 1).\n *\n * @return {number}\n */\n next = (): number => {\n return this._rng.next()\n }\n\n /**\n * Samples a uniform random floating point number, optionally specifying\n * lower and upper bounds.\n *\n * Convence wrapper around `random.uniform()`\n *\n * @param {number} [min=0] - Lower bound (float, inclusive)\n * @param {number} [max=1] - Upper bound (float, exclusive)\n * @return {number}\n */\n float = (min?: number, max?: number): number => {\n return this.uniform(min, max)()\n }\n\n /**\n * Samples a uniform random integer, optionally specifying lower and upper\n * bounds.\n *\n * Convence wrapper around `random.uniformInt()`\n *\n * @param {number} [min=0] - Lower bound (integer, inclusive)\n * @param {number} [max=1] - Upper bound (integer, inclusive)\n * @return {number}\n */\n int = (min?: number, max?: number) => {\n return this.uniformInt(min, max)()\n }\n\n /**\n * Samples a uniform random integer, optionally specifying lower and upper\n * bounds.\n *\n * Convence wrapper around `random.uniformInt()`\n *\n * @alias `random.int`\n *\n * @param {number} [min=0] - Lower bound (integer, inclusive)\n * @param {number} [max=1] - Upper bound (integer, inclusive)\n * @return {number}\n */\n integer = (min?: number, max?: number) => {\n return this.uniformInt(min, max)()\n }\n\n /**\n * Samples a uniform random boolean value.\n *\n * Convence wrapper around `random.uniformBoolean()`\n *\n * @alias `random.boolean`\n *\n * @return {boolean}\n */\n bool = () => {\n return this.uniformBoolean()()\n }\n\n /**\n * Samples a uniform random boolean value.\n *\n * Convence wrapper around `random.uniformBoolean()`\n *\n * @return {boolean}\n */\n boolean = () => {\n return this.uniformBoolean()()\n }\n\n /**\n * Returns an item chosen uniformly at trandom from the given array.\n *\n * Convence wrapper around `random.uniformInt()`\n *\n * @param {Array} [array] - Lower bound (integer, inclusive)\n * @return {T | undefined}\n */\n choice(array: Array): T | undefined {\n if (!Array.isArray(array)) {\n throw new Error(\n `Random.choice expected input to be an array, got ${typeof array}`\n )\n }\n\n const length = array?.length\n\n if (length > 0) {\n const index = this.uniformInt(0, length - 1)()\n return array[index]\n } else {\n return undefined\n }\n }\n\n // --------------------------------------------------------------------------\n // Uniform distributions\n // --------------------------------------------------------------------------\n\n /**\n * Generates a [Continuous uniform distribution](https://en.wikipedia.org/wiki/Uniform_distribution_(continuous)).\n *\n * @param {number} [min=0] - Lower bound (float, inclusive)\n * @param {number} [max=1] - Upper bound (float, exclusive)\n * @return {function}\n */\n uniform = (min?: number, max?: number) => {\n return this._memoize('uniform', uniform, min, max)\n }\n\n /**\n * Generates a [Discrete uniform distribution](https://en.wikipedia.org/wiki/Discrete_uniform_distribution).\n *\n * @param {number} [min=0] - Lower bound (integer, inclusive)\n * @param {number} [max=1] - Upper bound (integer, inclusive)\n * @return {function}\n */\n uniformInt = (min?: number, max?: number) => {\n return this._memoize('uniformInt', uniformInt, min, max)\n }\n\n /**\n * Generates a [Discrete uniform distribution](https://en.wikipedia.org/wiki/Discrete_uniform_distribution),\n * with two possible outcomes, `true` or `false.\n *\n * This method is analogous to flipping a coin.\n *\n * @return {function}\n */\n uniformBoolean = () => {\n return this._memoize('uniformBoolean', uniformBoolean)\n }\n\n // --------------------------------------------------------------------------\n // Normal distributions\n // --------------------------------------------------------------------------\n\n /**\n * Generates a [Normal distribution](https://en.wikipedia.org/wiki/Normal_distribution).\n *\n * @param {number} [mu=0] - Mean\n * @param {number} [sigma=1] - Standard deviation\n * @return {function}\n */\n normal = (mu?: number, sigma?: number) => {\n return normal(this, mu, sigma)\n }\n\n /**\n * Generates a [Log-normal distribution](https://en.wikipedia.org/wiki/Log-normal_distribution).\n *\n * @param {number} [mu=0] - Mean of underlying normal distribution\n * @param {number} [sigma=1] - Standard deviation of underlying normal distribution\n * @return {function}\n */\n logNormal = (mu?: number, sigma?: number) => {\n return logNormal(this, mu, sigma)\n }\n\n // --------------------------------------------------------------------------\n // Bernoulli distributions\n // --------------------------------------------------------------------------\n\n /**\n * Generates a [Bernoulli distribution](https://en.wikipedia.org/wiki/Bernoulli_distribution).\n *\n * @param {number} [p=0.5] - Success probability of each trial.\n * @return {function}\n */\n bernoulli = (p?: number) => {\n return bernoulli(this, p)\n }\n\n /**\n * Generates a [Binomial distribution](https://en.wikipedia.org/wiki/Binomial_distribution).\n *\n * @param {number} [n=1] - Number of trials.\n * @param {number} [p=0.5] - Success probability of each trial.\n * @return {function}\n */\n binomial = (n?: number, p?: number) => {\n return binomial(this, n, p)\n }\n\n /**\n * Generates a [Geometric distribution](https://en.wikipedia.org/wiki/Geometric_distribution).\n *\n * @param {number} [p=0.5] - Success probability of each trial.\n * @return {function}\n */\n geometric = (p?: number) => {\n return geometric(this, p)\n }\n\n // --------------------------------------------------------------------------\n // Poisson distributions\n // --------------------------------------------------------------------------\n\n /**\n * Generates a [Poisson distribution](https://en.wikipedia.org/wiki/Poisson_distribution).\n *\n * @param {number} [lambda=1] - Mean (lambda > 0)\n * @return {function}\n */\n poisson = (lambda?: number) => {\n return poisson(this, lambda)\n }\n\n /**\n * Generates an [Exponential distribution](https://en.wikipedia.org/wiki/Exponential_distribution).\n *\n * @param {number} [lambda=1] - Inverse mean (lambda > 0)\n * @return {function}\n */\n exponential = (lambda?: number) => {\n return exponential(this, lambda)\n }\n\n // --------------------------------------------------------------------------\n // Misc distributions\n // --------------------------------------------------------------------------\n\n /**\n * Generates an [Irwin Hall distribution](https://en.wikipedia.org/wiki/Irwin%E2%80%93Hall_distribution).\n *\n * @param {number} [n=1] - Number of uniform samples to sum (n >= 0)\n * @return {function}\n */\n irwinHall = (n?: number) => {\n return irwinHall(this, n)\n }\n\n /**\n * Generates a [Bates distribution](https://en.wikipedia.org/wiki/Bates_distribution).\n *\n * @param {number} [n=1] - Number of uniform samples to average (n >= 1)\n * @return {function}\n */\n bates = (n?: number) => {\n return bates(this, n)\n }\n\n /**\n * Generates a [Pareto distribution](https://en.wikipedia.org/wiki/Pareto_distribution).\n *\n * @param {number} [alpha=1] - Alpha\n * @return {function}\n */\n pareto = (alpha?: number) => {\n return pareto(this, alpha)\n }\n\n // --------------------------------------------------------------------------\n // Internal\n // --------------------------------------------------------------------------\n\n /**\n * Memoizes distributions to ensure they're only created when necessary.\n *\n * Returns a thunk which that returns independent, identically distributed\n * samples from the specified distribution.\n *\n * @private\n *\n * @param {string} label - Name of distribution\n * @param {function} getter - Function which generates a new distribution\n * @param {...*} args - Distribution-specific arguments\n *\n * @return {function}\n */\n _memoize(label: string, getter: IDistFn, ...args: any[]): IDist {\n const key = `${args.join(';')}`\n let value = this._cache[label]\n\n if (value === undefined || value.key !== key) {\n value = {\n key,\n distribution: getter(this, ...args)\n }\n this._cache[label] = value\n }\n\n return value.distribution\n }\n}\n\n// defaults to Math.random as its RNG\nexport default new Random()\n"],"names":["RNG","_seed","seed","_opts","strSeed","s","k","length","charCodeAt","RNGFunction","thunk","opts","_rng","next","clone","_","args","arg0","seedrandom","Error","random","min","max","numberValidator","num","NumberValidator","n","isInt","Number","isInteger","isPositive","lessThan","v","greaterThanOrEqual","greaterThan","undefined","Math","floor","mu","sigma","x","y","r","sqrt","log","normal","exp","p","i","invLogP","logFactorialTable","logFactorial","logSqrt2PI","lambda","expMean","u","smu","b","a","invAlpha","vR","abs","us","t","f","sum","irwinHall","alpha","pow","RNGMathRandom","Random","rng","_patch","_cache","uniform","uniformInt","integer","bool","uniformBoolean","_memoize","logNormal","bernoulli","binomial","geometric","poisson","exponential","bates","pareto","use","RNGFactory","patch","unpatch","choice","array","Array","isArray","index","label","getter","key","join","value","distribution"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAG8BA,GAAG,gBAAA,YAAA;AAAA,EAAA,SAAA,GAAA,GAAA,EAAA;AAAA,EAAA,IAAA,MAAA,GAAA,GAAA,CAAA,SAAA,CAAA;AAS/B;AAAA,EAAA,MAAA,CACAC,KAAK,GAAL,SAAA,KAAA,CAAMC,IAAY,EAAEC,KAA+B,EAAA;AACjD;AAEA,IAAA,IAAID,IAAI,MAAMA,IAAI,IAAI,CAAC,CAAC,EAAE;AACxB,MAAA,OAAOA,IAAI,CAAA;AACZ,KAAA,MAAM;AACL,MAAA,IAAME,OAAO,GAAG,EAAE,GAAGF,IAAI,CAAA;MACzB,IAAIG,CAAC,GAAG,CAAC,CAAA;AAET,MAAA,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,OAAO,CAACG,MAAM,EAAE,EAAED,CAAC,EAAE;QACvCD,CAAC,IAAID,OAAO,CAACI,UAAU,CAACF,CAAC,CAAC,GAAG,CAAC,CAAA;AAC/B,OAAA;AAED,MAAA,OAAOD,CAAC,CAAA;AACT,KAAA;GACF,CAAA;AAAA,EAAA,OAAA,GAAA,CAAA;AAAA,CAAA;;AC5BiC,IAEfI,WAAY,gBAAA,UAAA,IAAA,EAAA;AAAA,EAAA,cAAA,CAAA,WAAA,EAAA,IAAA,CAAA,CAAA;EAG/B,SAAYC,WAAAA,CAAAA,KAAa,EAAEC,IAA8B,EAAA;AAAA,IAAA,IAAA,KAAA,CAAA;IACvD,KAAO,GAAA,IAAA,CAAA,IAAA,CAAA,IAAA,CAAA,IAAA,IAAA,CAAA;AAAA,IAAA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