@mark1russell7/market 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/market",
4
- "version": "0.1.7",
4
+ "version": "0.1.9",
5
5
  "description": "The records of a market: a product, an offer of a seller and a price reading, with their checks, the GTIN check, match keys, the cost of an order, the storage rules of a source, the best offer of a part, a board of current prices within the terms of each source, a buy plan: the Pareto front of the baskets of a need, and metered prices of cloud resources with tiers, free amounts, terms and their cost.",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"records-DU5uvTYJ.js","names":[],"sources":["../src/gtin.ts","../src/identifiers.ts","../src/price.ts","../src/offers.ts","../src/records.ts"],"sourcesContent":["/**\n * This module reads the GTIN of a product: a GTIN-8, a UPC-A (12 digits), an EAN-13 or a GTIN-14.\n * The last digit is a check digit. The sum of the other digits, with the weights 3 and 1 from the right, gives it.\n */\n\nconst LENGTHS: ReadonlySet<number> = new Set([8, 12, 13, 14]);\n\n/**\n * This function gives the check digit of the digits of a GTIN without its last digit.\n *\n * @throws RangeError when the text has a character that is not a digit, or no character.\n */\nexport function gtinCheckDigit(body: string): number {\n if (!/^\\d+$/.test(body)) throw new RangeError(`The text ${JSON.stringify(body)} is not a string of digits.`);\n let total = 0;\n for (let i = 0; i < body.length; i += 1) {\n const digit = body.charCodeAt(body.length - 1 - i) - 48;\n total += i % 2 === 0 ? digit * 3 : digit;\n }\n return (10 - (total % 10)) % 10;\n}\n\n/**\n * This function gives the GTIN-14 form of a GTIN, or null. It removes the spaces and the hyphens first.\n * It refuses a length other than 8, 12, 13 or 14 digits, a wrong check digit, and a GTIN of zeros only.\n */\nexport function parseGtin(text: string): string | null {\n const digits = text.replace(/[\\s-]/g, \"\");\n if (!/^\\d+$/.test(digits) || !LENGTHS.has(digits.length) || /^0+$/.test(digits)) return null;\n if (gtinCheckDigit(digits.slice(0, -1)) !== Number(digits.slice(-1))) return null;\n return digits.padStart(14, \"0\");\n}\n","import { parseGtin } from \"./gtin.ts\";\n\n/** A part number of a maker: the brand, and the number that the maker gives to the part. */\nexport interface PartNumber {\n readonly brand: string;\n readonly partNumber: string;\n}\n\n/** The identifiers of a product or of an offer. */\nexport interface Identifiers {\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n}\n\n/**\n * This function folds a brand or a part number for a comparison. The result has only capital letters A to Z\n * and digits. Thus `MZ-V8V1T0B/AM` and `mzv8v1t0bam` fold to one text.\n */\nexport function foldCode(text: string): string {\n return text.normalize(\"NFKD\").toUpperCase().replace(/[^A-Z0-9]/g, \"\");\n}\n\n/**\n * This function gives the match keys of a record, sorted and with no copy. A key is `gtin:` with the GTIN-14,\n * or `part:` with the folded brand and part number. Two records with a key in common name one product.\n * The function ignores a GTIN that is not valid, and a part number whose brand or number folds to no text.\n */\nexport function matchKeys(identifiers: Identifiers): string[] {\n const keys = new Set<string>();\n for (const text of identifiers.gtins) {\n const gtin = parseGtin(text);\n if (gtin !== null) keys.add(`gtin:${gtin}`);\n }\n for (const { brand, partNumber } of identifiers.partNumbers) {\n const folded = [foldCode(brand), foldCode(partNumber)];\n if (folded.every((part) => part !== \"\")) keys.add(`part:${folded.join(\"/\")}`);\n }\n return [...keys].sort();\n}\n","import { add, scale, type Quantity } from \"@mark1russell7/quantity\";\nimport type { PriceReading } from \"./records.ts\";\n\n/**\n * This function gives the unit price for an order of `count` units. The price of the largest break at or\n * below the count applies, or the price of the reading when no break applies.\n *\n * @throws RangeError when the count is not a whole number, or when it is less than the minimum of the reading.\n */\nexport function unitPriceFor(reading: PriceReading, count: number): Quantity {\n const minimum = reading.minimumQuantity ?? 1;\n if (!Number.isSafeInteger(count) || count < minimum) {\n throw new RangeError(`The count ${count} is not a whole number of ${minimum} or more.`);\n }\n let price: Quantity = reading.price;\n for (const entry of reading.priceBreaks ?? []) if (entry.quantity <= count) price = entry.unitPrice;\n return price;\n}\n\n/**\n * This function gives the cost of an order of `count` units with its shipping, or null when the shipping\n * cost is not known. The cost is exact, and the function does not round it to the cent.\n *\n * @throws RangeError when the count is not a whole number, or when it is less than the minimum of the reading.\n */\nexport function costOf(reading: PriceReading, count: number): Quantity | null {\n const goods = scale(unitPriceFor(reading, count), count);\n switch (reading.shipping.kind) {\n case \"free\":\n return goods;\n case \"fixed\":\n return add(goods, reading.shipping.cost);\n default:\n return null;\n }\n}\n","import { compare, convert, convertible, kindOf, scale, UnitError, type Quantity } from \"@mark1russell7/quantity\";\nimport { foldCode } from \"./identifiers.ts\";\nimport { costOf, unitPriceFor } from \"./price.ts\";\nimport type { Condition, Offer, PriceReading } from \"./records.ts\";\n\n/** One offer of a source, and its price reading at one instant. */\nexport interface Observation {\n readonly offer: Offer;\n readonly reading: PriceReading;\n}\n\n/**\n * This record names a part that a buyer wants: the names of its maker, and its part numbers. A seller can write\n * the brand of one maker in more than one form, so the want has a list of names.\n */\nexport interface PartWant {\n /** The names of the maker, as the sellers write the brand. */\n readonly brands: readonly string[];\n /** The part numbers of the maker. A part number of an offer matches when it starts with one of them, after the fold. */\n readonly partNumbers: readonly string[];\n}\n\n/**\n * This function tells if an offer is an offer of the part. One part number of the offer must have a brand of the\n * want and start with a part number of the want. `foldCode` folds each text before the comparison. A part number\n * of another maker does not match: many makers use short numbers like `A1383`.\n */\nexport function offersPart(offer: Pick<Offer, \"partNumbers\">, want: PartWant): boolean {\n const brands = new Set(want.brands.map(foldCode).filter((brand) => brand !== \"\"));\n const parts = want.partNumbers.map(foldCode).filter((part) => part !== \"\");\n return offer.partNumbers.some(({ brand, partNumber }) => {\n const folded = foldCode(partNumber);\n return brands.has(foldCode(brand)) && parts.some((part) => folded.startsWith(part));\n });\n}\n\n/**\n * This function gives the latest observation of each offer, in the order of the offer ids. When two readings of\n * one offer have the same instant, the later one in the list applies.\n */\nexport function latestObservations(observations: readonly Observation[]): Observation[] {\n const latest = new Map<string, Observation>();\n for (const each of observations) {\n const seen = latest.get(each.offer.id);\n if (seen === undefined || Date.parse(seen.reading.at) <= Date.parse(each.reading.at)) latest.set(each.offer.id, each);\n }\n return [...latest.values()].sort((a, b) => order(a.offer.id, b.offer.id));\n}\n\n/** This function gives the latest observation of each offer of the part, in the order of the offer ids. */\nexport function offersOfPart(observations: readonly Observation[], want: PartWant): Observation[] {\n return latestObservations(observations.filter((each) => offersPart(each.offer, want)));\n}\n\n/** This record is one offer that a buyer can choose, with the price of an order in the currency of the buyer. */\nexport interface OfferChoice {\n readonly observation: Observation;\n /** The unit price for the count, times the count. */\n readonly goods: Quantity;\n /** The goods and the shipping, or null when the shipping cost is not known. */\n readonly cost: Quantity | null;\n /** True when the availability is `in-stock` or `low-stock`. */\n readonly inStock: boolean;\n}\n\n/** These options change the choice of an offer. */\nexport interface BestOfferOptions {\n /** The currency of the prices, a unit of money of `@mark1russell7/quantity`, for example `USD`. An offer with a price in another currency is skipped. */\n readonly currency: string;\n /** The count of units of the order. The default is 1. */\n readonly count?: number;\n /** The conditions that the buyer accepts. The default is `new` only. */\n readonly conditions?: readonly Condition[];\n}\n\n/** This record is the choice of an offer: the best offer, each offer in the order of the price, and each skipped offer. */\nexport interface BestOffer {\n /** The offer with the lowest price that is in stock, or else the offer with the lowest price, or null with no offer. */\n readonly best: OfferChoice | null;\n /** The offers, from the lowest price of the goods. Equal prices go in the order of the cost, then of the offer id. */\n readonly offers: readonly OfferChoice[];\n /** The offers that the choice skipped, each with the reason. */\n readonly skipped: readonly { readonly offerId: string; readonly why: string }[];\n}\n\n/**\n * This function chooses the offer to buy from the latest observation of each offer. It skips an offer with a\n * condition that the buyer does not accept, a price in another currency, or a minimum above the count.\n *\n * @throws RangeError when the count is not a whole number of 1 or more, or when the currency is not a unit of money.\n */\nexport function bestOffer(observations: readonly Observation[], options: BestOfferOptions): BestOffer {\n const { currency, count = 1, conditions = [\"new\"] } = options;\n if (!Number.isSafeInteger(count) || count < 1) throw new RangeError(`The count ${count} is not a whole number of 1 or more.`);\n if (!isMoney(currency)) throw new RangeError(`The currency ${currency} is not a unit of money of @mark1russell7/quantity.`);\n const accepted = new Set<Condition>(conditions);\n const offers: OfferChoice[] = [];\n const skipped: { offerId: string; why: string }[] = [];\n for (const observation of latestObservations(observations)) {\n const { offer, reading } = observation;\n const minimum = reading.minimumQuantity ?? 1;\n if (!accepted.has(offer.condition)) skipped.push({ offerId: offer.id, why: `The condition ${offer.condition} is not a condition that the buyer accepts.` });\n else if (!converts(reading.price.unit, currency)) skipped.push({ offerId: offer.id, why: `The price is in ${reading.price.unit}, not in ${currency}.` });\n else if (count < minimum) skipped.push({ offerId: offer.id, why: `The minimum order is ${minimum} units, more than the count ${count}.` });\n else {\n const goods = convert(scale(unitPriceFor(reading, count), count), currency);\n // A shipping cost in another currency is not known in the currency of the buyer.\n const shipping = reading.shipping.kind !== \"fixed\" || converts(reading.shipping.cost.unit, currency);\n const total = shipping ? costOf(reading, count) : null;\n const cost = total === null ? null : convert(total, currency);\n const inStock = reading.availability === \"in-stock\" || reading.availability === \"low-stock\";\n offers.push({ observation, goods, cost, inStock });\n }\n }\n offers.sort((a, b) => compare(a.goods, b.goods) || byCost(a.cost, b.cost) || order(a.observation.offer.id, b.observation.offer.id));\n const best = offers.find((choice) => choice.inStock) ?? offers[0] ?? null;\n return { best, offers, skipped };\n}\n\n/** This function tells if a unit is a unit of money that the quantity package knows. */\nfunction isMoney(unit: string): boolean {\n try {\n return kindOf(unit) === \"money\";\n } catch (error) {\n if (error instanceof UnitError) return false;\n throw error;\n }\n}\n\n/** This function tells if an amount in one unit converts to another unit. A unit that the quantity package does not know does not convert. */\nfunction converts(from: string, to: string): boolean {\n try {\n return convertible(from, to);\n } catch (error) {\n if (error instanceof UnitError) return false;\n throw error;\n }\n}\n\n/** This function orders two costs. A known cost comes before a cost that is not known. */\nfunction byCost(a: Quantity | null, b: Quantity | null): number {\n if (a === null || b === null) return a === b ? 0 : a === null ? 1 : -1;\n return compare(a, b);\n}\n\n/** This function orders two texts by their code units, so the order does not depend on the locale. */\nfunction order(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n\n/** The offer to buy for one count of a part, or the reason that no offer is usable. */\nexport type Priced = { readonly ok: true; readonly offerId: string; readonly cost: Quantity } | { readonly ok: false; readonly why: string };\n\n/**\n * This function chooses the offer to buy for a count of a part: the in-stock offer with the lowest cost, with the\n * shipping. An offer with a cost that is not known is not usable. Equal costs keep the order of `bestOffer`.\n */\nexport function priceOf(observations: readonly Observation[], count: number, need: { readonly currency: string; readonly conditions?: readonly Condition[] | undefined }): Priced {\n const choice = bestOffer(observations, { currency: need.currency, count, ...(need.conditions === undefined ? {} : { conditions: need.conditions }) });\n let pick: (OfferChoice & { readonly cost: Quantity }) | undefined;\n for (const offer of choice.offers) {\n const cost = offer.cost;\n if (offer.inStock && cost !== null && (pick === undefined || compare(cost, pick.cost) < 0)) pick = { ...offer, cost };\n }\n if (pick !== undefined) return { ok: true, offerId: pick.observation.offer.id, cost: pick.cost };\n if (choice.offers.length > 0) return { ok: false, why: `No offer of ${String(count)} units is in stock with a known cost.` };\n const first = choice.skipped[0];\n return { ok: false, why: first === undefined ? \"No offer matches the part.\" : `No offer is usable. The first offer that the choice skipped: ${first.why}` };\n}\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { quantitySchema } from \"@mark1russell7/quantity/schema\";\nimport { z } from \"zod\";\nimport { parseGtin } from \"./gtin.ts\";\nimport type { PartNumber } from \"./identifiers.ts\";\n\n/**\n * The conditions of an offer. A source maps its own condition to one of them, and it keeps its own text in\n * the field `grade` of the offer.\n */\nexport const CONDITIONS = [\"new\", \"open-box\", \"refurbished\", \"used\", \"for-parts\", \"unknown\"] as const;\n/** The condition of an offer. */\nexport type Condition = (typeof CONDITIONS)[number];\n\n/** The states of the stock of an offer at the time of a reading. */\nexport const AVAILABILITIES = [\"in-stock\", \"low-stock\", \"out-of-stock\", \"preorder\", \"unknown\"] as const;\n/** The state of the stock of an offer. */\nexport type Availability = (typeof AVAILABILITIES)[number];\n\n/** The buying formats of an offer. In an auction, the price of a reading is the current bid. */\nexport const FORMATS = [\"fixed-price\", \"auction\"] as const;\n/** The buying format of an offer. */\nexport type Format = (typeof FORMATS)[number];\n\n/** One specification of a product as text. */\nexport interface Spec {\n readonly name: string;\n readonly value: string;\n}\n\n/** The feedback of a seller: the percent of good feedback, and the count of the feedback. */\nexport interface Rating {\n readonly percent: number;\n readonly count: number;\n}\n\n/** A seller of an offer. A source gives some of these fields, or none. */\nexport interface Seller {\n readonly id?: string | undefined;\n readonly name?: string | undefined;\n readonly rating?: Rating | undefined;\n}\n\n/** A product of the catalog: one thing that a person can buy, with its identifiers and its specifications. */\nexport interface Product {\n readonly id: string;\n readonly title: string;\n readonly brand?: string | undefined;\n readonly category?: readonly string[] | undefined;\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n readonly specs: readonly Spec[];\n}\n\n/** An offer of a seller: one product at one seller, with the identifiers that the source gives. */\nexport interface Offer {\n readonly id: string;\n readonly source: string;\n readonly sourceId: string;\n readonly productId?: string | undefined;\n readonly title: string;\n readonly url?: string | undefined;\n readonly seller: Seller;\n readonly condition: Condition;\n readonly grade?: string | undefined;\n readonly format: Format;\n readonly endsAt?: string | undefined;\n readonly gtins: readonly string[];\n readonly partNumbers: readonly PartNumber[];\n readonly specs: readonly Spec[];\n}\n\n/** The shipping of a reading. A calculated cost depends on the address of the buyer. */\nexport type Shipping =\n | { readonly kind: \"free\" }\n | { readonly kind: \"fixed\"; readonly cost: Quantity }\n | { readonly kind: \"calculated\" }\n | { readonly kind: \"unknown\" };\n\n/** A price break of a reading: the unit price for an order of `quantity` units or more. */\nexport interface PriceBreak {\n readonly quantity: number;\n readonly unitPrice: Quantity;\n}\n\n/** A price reading: the state of one offer at one instant. */\nexport interface PriceReading {\n readonly offerId: string;\n readonly at: string;\n readonly price: Quantity;\n readonly listPrice?: Quantity | undefined;\n readonly shipping: Shipping;\n readonly availability: Availability;\n readonly available?: number | undefined;\n readonly minimumQuantity?: number | undefined;\n readonly priceBreaks?: readonly PriceBreak[] | undefined;\n}\n\n/** This schema accepts a text with a character that is not a space, and with no space at an end. */\nexport const textSchema: z.ZodType<string> = z\n .string()\n .refine((text) => text !== \"\" && text === text.trim(), \"The text is empty, or it has a space at an end.\");\n\n/** This schema accepts the name of a source: small letters, digits and hyphens, with a letter first. */\nexport const sourceSchema: z.ZodType<string> = z\n .string()\n .regex(/^[a-z][a-z0-9-]*$/, \"The name of a source has small letters, digits and hyphens, with a letter first.\");\n\n/** This schema accepts a GTIN in its GTIN-14 form, with a correct check digit. `parseGtin` gives this form. */\nexport const gtinSchema: z.ZodType<string> = z\n .string()\n .refine((text) => /^\\d{14}$/.test(text) && parseGtin(text) === text, \"The GTIN is not a GTIN-14 with a correct check digit.\");\n\n/** This schema accepts an amount of money of zero or more, for example `{ \"value\": 129.99, \"unit\": \"USD\" }`. */\nexport const moneySchema: z.ZodType<Quantity, Quantity> = quantitySchema(\"money\", { nonnegative: true });\n\n/** This schema accepts an instant in UTC in the ISO 8601 form, for example `2026-11-12T18:00:00Z`. */\nexport const instantSchema: z.ZodType<string> = z.iso.datetime();\n\n/** This schema accepts a part number of a maker. */\nexport const partNumberSchema: z.ZodType<PartNumber> = z.strictObject({ brand: textSchema, partNumber: textSchema });\n\n/** This schema accepts one specification as text, for example `{ \"name\": \"Capacity\", \"value\": \"1 TB\" }`. */\nexport const specSchema: z.ZodType<Spec> = z.strictObject({ name: textSchema, value: textSchema });\n\n/** This schema accepts a seller. A rating is the percent of good feedback and the count of the feedback. */\nexport const sellerSchema: z.ZodType<Seller> = z.strictObject({\n id: textSchema.optional(),\n name: textSchema.optional(),\n rating: z.strictObject({ percent: z.number().min(0).max(100), count: z.int().nonnegative() }).optional(),\n});\n\n/** This schema accepts a product: one thing that a person can buy, with its identifiers and its specifications. */\nexport const productSchema: z.ZodType<Product> = z.strictObject({\n id: textSchema,\n title: textSchema,\n brand: textSchema.optional(),\n category: z.array(textSchema).optional(),\n gtins: z.array(gtinSchema),\n partNumbers: z.array(partNumberSchema),\n specs: z.array(specSchema),\n});\n\n/** This function gives the id of an offer: the name of its source, a colon, and the id at the source. */\nexport function offerId(source: string, sourceId: string): string {\n return `${source}:${sourceId}`;\n}\n\n/** This function gives the name of the source of an offer id: the text before the first colon. */\nexport function sourceOfOffer(id: string): string {\n const colon = id.indexOf(\":\");\n if (colon <= 0) throw new RangeError(`The offer id ${JSON.stringify(id)} has no source.`);\n return id.slice(0, colon);\n}\n\n/**\n * This schema accepts an offer: one product at one seller. The offer has the identifiers that the source gives.\n * `productId` names the product of the catalog after a match.\n */\nexport const offerSchema: z.ZodType<Offer> = z\n .strictObject({\n id: textSchema,\n source: sourceSchema,\n sourceId: textSchema,\n productId: textSchema.optional(),\n title: textSchema,\n url: z.url({ protocol: /^https$/ }).optional(),\n seller: sellerSchema,\n condition: z.enum(CONDITIONS),\n grade: textSchema.optional(),\n format: z.enum(FORMATS),\n endsAt: instantSchema.optional(),\n gtins: z.array(gtinSchema),\n partNumbers: z.array(partNumberSchema),\n specs: z.array(specSchema),\n })\n .refine((offer) => offer.id === offerId(offer.source, offer.sourceId), {\n message: \"The id of an offer is its source and its source id, with a colon between them.\",\n path: [\"id\"],\n });\n\n/** This schema accepts the shipping of a reading. A calculated cost depends on the address of the buyer. */\nexport const shippingSchema: z.ZodType<Shipping> = z.discriminatedUnion(\"kind\", [\n z.strictObject({ kind: z.literal(\"free\") }),\n z.strictObject({ kind: z.literal(\"fixed\"), cost: moneySchema }),\n z.strictObject({ kind: z.literal(\"calculated\") }),\n z.strictObject({ kind: z.literal(\"unknown\") }),\n]);\n\n/** This schema accepts a price break: the unit price for an order of `quantity` units or more. */\nexport const priceBreakSchema: z.ZodType<PriceBreak> = z.strictObject({ quantity: z.int().min(2), unitPrice: moneySchema });\n\n/**\n * This schema accepts a price reading: the state of one offer at one instant. `price` is the unit price for an\n * order of `minimumQuantity` units, or of one unit. The quantities of the breaks increase, and each is more\n * than the minimum.\n */\nexport const priceReadingSchema: z.ZodType<PriceReading> = z\n .strictObject({\n offerId: textSchema,\n at: instantSchema,\n price: moneySchema,\n listPrice: moneySchema.optional(),\n shipping: shippingSchema,\n availability: z.enum(AVAILABILITIES),\n available: z.int().nonnegative().optional(),\n minimumQuantity: z.int().min(1).optional(),\n priceBreaks: z.array(priceBreakSchema).optional(),\n })\n .superRefine((reading, context) => {\n let last = reading.minimumQuantity ?? 1;\n for (const [index, entry] of (reading.priceBreaks ?? []).entries()) {\n if (entry.quantity <= last) {\n context.addIssue({\n code: \"custom\",\n message: `The break ${index} has the quantity ${entry.quantity}, which is not more than ${last}.`,\n path: [\"priceBreaks\", index, \"quantity\"],\n });\n }\n last = Math.max(last, entry.quantity);\n }\n const { availability, available } = reading;\n if (available === undefined || availability === \"unknown\" || availability === \"preorder\") return;\n if ((availability === \"out-of-stock\") !== (available === 0)) {\n context.addIssue({\n code: \"custom\",\n message: `The availability ${availability} does not agree with the count ${available}.`,\n path: [\"available\"],\n });\n }\n });\n"],"mappings":";;;;;;;;AAKA,MAAM,0BAA+B,IAAI,IAAI;CAAC;CAAG;CAAI;CAAI;AAAE,CAAC;;;;;;AAO5D,SAAgB,eAAe,MAAsB;CACnD,IAAI,CAAC,QAAQ,KAAK,IAAI,GAAG,MAAM,IAAI,WAAW,YAAY,KAAK,UAAU,IAAI,EAAE,4BAA4B;CAC3G,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK,GAAG;EACvC,MAAM,QAAQ,KAAK,WAAW,KAAK,SAAS,IAAI,CAAC,IAAI;EACrD,SAAS,IAAI,MAAM,IAAI,QAAQ,IAAI;CACrC;CACA,QAAQ,KAAM,QAAQ,MAAO;AAC/B;;;;;AAMA,SAAgB,UAAU,MAA6B;CACrD,MAAM,SAAS,KAAK,QAAQ,UAAU,EAAE;CACxC,IAAI,CAAC,QAAQ,KAA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