@mark1russell7/market 0.3.1 → 0.3.2

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/README.md CHANGED
@@ -148,11 +148,13 @@ The entry `@mark1russell7/market/supplies` has the format and the gate of a cata
148
148
  - The resource codes are the codes of a store of `@mark1russell7/stack-endurance`, for example `water.stored` in `L`.
149
149
  - A product can have a `size`: the amount of one unit as sold, for example 1 kg, 530 g or 1 gal. Its unit is a mass or a volume that converts to `kg` or `L`, or one bare count, for example `{each}`. A page can thus convert a size in a mass to `lb` with `valueIn` of `@mark1russell7/quantity`. The gate refuses a unit that does not convert, for example `g/{each}`. A no read is for a product that has a size, when the source of the size is not read yet. The gate examines a size as each other amount.
150
150
  - A product can join a series of average prices. The join names the source, the series and the amount of the item in one unit, with its reason. A product with no series has a no read with its reason.
151
- - The gate does not examine the joins to other packages. It does not find a FoodKeeper id that is not in `@mark1russell7/stock`, or a resource code that a layer of stores does not have. The code that joins the catalog to stock or to a layer of stores gives those gates. market depends on neither package.
151
+ - With the option `foodKeeper`, the gate examines each FoodKeeper id of a shelf life. An id that is not in the known ids is the error `supplies-shelf`. The option is a set or a list of ids, for example the ids of `FOODKEEPER_PRODUCTS` of `@mark1russell7/stock/foodkeeper`. With no option, the gate does not examine the ids against the data.
152
+ - market has no runtime dependency on `@mark1russell7/stock`. The code that calls the gate gives the ids. The tests of market gate the reference catalog with the ids of stock.
153
+ - The gate does not examine a resource code against a layer of stores. The code that joins the catalog to a layer of stores gives that gate.
152
154
 
153
155
  | Function | What it does |
154
156
  | --- | --- |
155
- | `checkSupplies(catalog, options)` | It gives the findings of the catalog: the errors of the gate, and a warning for each no read and for each fact or source that no product uses. |
157
+ | `checkSupplies(catalog, options)` | It gives the findings of the catalog: the errors of the gate, and a warning for each no read and for each fact or source that no product uses. The option `foodKeeper` gives the known FoodKeeper ids. |
156
158
  | `supplyWants(catalog, max)` | It gives the wants of the products with a part, for `buyCandidates`. A product with no part has no offer, so it has no price. |
157
159
  | `giftsOf(catalog, id, units)` | It gives the resources of a count of units, each in the unit of its resource. A unit converts exactly, so 1 gal gives 3.785411784 L. |
158
160
  | `averageSupplyPrices(catalog, prices, { since })` | It gives the price of one unit of each product with a join, from the last month of its series. A series with no price and a unit that does not fit give a no read. With `since`, so does a last price before that month. |
@@ -110,6 +110,17 @@ export declare const SUPPLY_CODES: readonly ["supplies-format", "supplies-twice"
110
110
  type SupplyCode = (typeof SUPPLY_CODES)[number];
111
111
  /** A finding of the catalog gate, or of the gate of the facts and their sources. */
112
112
  type SupplyFinding = Finding<SupplyCode | FindingCode, "source" | "unit" | "resource" | "product">;
113
+ /**
114
+ * The options of the catalog gate: the options of the gate of the sources, and the known FoodKeeper ids.
115
+ */
116
+ interface SupplyGateOptions extends GateOptions {
117
+ /**
118
+ * The ids of the products of the FoodKeeper data, for example the ids of `FOODKEEPER_PRODUCTS` of the entry
119
+ * `/foodkeeper` of `@mark1russell7/stock`. With this option, a shelf life with an id that is not in the set is an
120
+ * error. With no option, the gate does not examine the ids against the data.
121
+ */
122
+ readonly foodKeeper?: ReadonlySet<number> | readonly number[] | undefined;
123
+ }
113
124
  /**
114
125
  * This function examines a catalog. It gives the findings of the sources and the facts (the gate of
115
126
  * `@mark1russell7/guidebook`), and the findings of the products:
@@ -124,6 +135,7 @@ type SupplyFinding = Finding<SupplyCode | FindingCode, "source" | "unit" | "reso
124
135
  * - An error for a unit that does not convert to the unit of its resource.
125
136
  * - An error for a size in a unit that is not a mass, a volume or a count, for example `h` or `kcal`.
126
137
  * - The amount of the item of an average price has the same checks as each other amount.
138
+ * - With the option `foodKeeper`, an error for a FoodKeeper id of a shelf life that is not in the known ids.
127
139
  * - A warning for each value with no read, and for a no read with a blank reason.
128
140
  * - A warning for each fact and each source that no product uses.
129
141
  *
@@ -131,9 +143,9 @@ type SupplyFinding = Finding<SupplyCode | FindingCode, "source" | "unit" | "reso
131
143
  * example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.
132
144
  *
133
145
  * @param catalog - The catalog
134
- * @param options - The options of the gate of the sources, for example the date of the gate
146
+ * @param options - The options of the gate of the sources, for example the date of the gate, and the known FoodKeeper ids
135
147
  */
136
- export declare function checkSupplies(catalog: SupplyCatalog, options?: GateOptions): SupplyFinding[];
148
+ export declare function checkSupplies(catalog: SupplyCatalog, options?: SupplyGateOptions): SupplyFinding[];
137
149
  /**
138
150
  * This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.
139
151
  * A product with no part has no offer, so it is not in the result.
@@ -320,5 +332,5 @@ interface BuyListEnergy {
320
332
  * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of an energy does not convert to `kcal`
321
333
  */
322
334
  export declare function buyListEnergy(catalog: SupplyCatalog, units: Readonly<Record<string, number>>): BuyListEnergy;
323
- export type { AverageJoin, BuyListEnergy, BuyListEnergyLine, CitedAmount, FoodPlan, FoodPlanCheck, FoodPlanGroup, FoodPlanMember, FoodPlanSize, GiftOf, NoRead, ShelfLife, SupplyCatalog, SupplyCode, SupplyFinding, SupplyGift, SupplyKind, SupplyPrice, SupplyProduct, SupplyResource };
335
+ export type { AverageJoin, BuyListEnergy, BuyListEnergyLine, CitedAmount, FoodPlan, FoodPlanCheck, FoodPlanGroup, FoodPlanMember, FoodPlanSize, GiftOf, NoRead, ShelfLife, SupplyCatalog, SupplyCode, SupplyFinding, SupplyGateOptions, SupplyGift, SupplyKind, SupplyPrice, SupplyProduct, SupplyResource };
324
336
  //# sourceMappingURL=supplies-entry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"supplies-entry.d.ts","names":[],"sources":["../src/supplies.ts","../src/supplies-data.ts","../src/food-plan.ts","../src/food-plan-data.ts","../src/buy-list-energy.ts"],"mappings":";;;;;;;;;;;;qBAca;;qBAGA;;KAGD,qBAAqB;;UAGhB;WACN;WACA;;;;;;KAOC;WACG;WAAqB;WAAyB;WAAuB;WAAuB;;WAC5F;WAAqB;WAAyB;WAAuB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B;;;;;KCQtB;WACG;WAA0B;WAAwB;WAAuC;WAAqB,QAAQ;;WACtH;WAA0B;WAAwB;WAAuC;WAAsB;;;UAG7G;;WAEN,gBAAgB;;WAEhB;;WAEA,QAAQ;;;;;;;;;;;;;;;;;;;;;wBAsBH,cAAc,SAAS,eAAe,OAAO,SAAS,0BAA0B"}
1
+ {"version":3,"file":"supplies-entry.d.ts","names":[],"sources":["../src/supplies.ts","../src/supplies-data.ts","../src/food-plan.ts","../src/food-plan-data.ts","../src/buy-list-energy.ts"],"mappings":";;;;;;;;;;;;qBAca;;qBAGA;;KAGD,qBAAqB;;UAGhB;WACN;WACA;;;;;;KAOC;WACG;WAAqB;WAAyB;WAAuB;WAAuB;;WAC5F;WAAqB;WAAyB;WAAuB;WAA6B;;;UAGhG;WACN;WACA;WACA;;;UAIM;WACN;WACA,QAAQ,cAAc;;;;;;KAOrB,YAAY;WAAyB;WAAqB;IAAuB;;;;;;UAO5E;WACN;;WAEA;;WAEA;;WAEA,KAAK;;;UAIC;WACN;WACA;WACA,MAAM;;WAEN,OAAO;;WAEP,gBAAgB;;WAEhB;;WAEA,SAAS,cAAc;;;;;;WAMvB,OAAO,cAAc;WACrB,OAAO;;;;;WAKP,UAAU,cAAc;;;UAIlB;WACN,eAAe;WACf,kBAAkB;WAClB,gBAAgB;WAChB,oBAAoB;WACpB,mBAAmB;;;qBAIjB;;KAgBD,qBAAqB;;KAGrB,gBAAgB,QAAQ,aAAa;;;;UAKhC,0BAA0B;;;;;;WAMhC,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;wBAkDR,cAAc,SAAS,eAAe,UAAS,oBAAyB;;;;;;;;wBA4FxE,YAAY,SAAS,eAAe,OAAM,SAAS,2BAAqC;;KAK5F;WAAoB;WAA2B;WAAqB;WAAyB;;WAA4B;WAA2B;WAAsB;;;;;;;;;;;;;wBAatK,QAAQ,SAAS,eAAe,YAAY,gBAAgB;;KAahE;WACG;WAA0B;WAAqB,OAAO;WAAmB;WAA0B;;WACnG;WAA0B;WAAsB;;;;;;;;;;;;;;;;;wBAiB/C,oBAAoB,SAAS,eAAe,iBAAiB,gBAAgB;WAAoB;IAAoC;;qBChUxI,gBAAgB;;qBCQhB;;KAmBD,wBAAwB;;UAGnB;;WAEN;;WAEA;;WAEA;;;UAIM;;WAEN;WACA;;WAEA;;WAEA;WACA,QAAQ;;WAER;;WAEA,QAAQ,SAAS,OAAO,eAAe;;WAEvC,gBAAgB;;;UAIV;WACN,OAAO;WACP;;;UAIM;;WAEN,MAAM;;WAEN,MAAM;;WAEN;;;;;WAKA;;;;;;;;;;;;;wBAcK,aAAa,MAAM,UAAU,kBAAkB,kBAAkB,eAAe;;;;;;;;;;;;;;wBAkChF,cAAc,MAAM,UAAU,MAAM,UAAU,kBAAkB,kBAAkB,eAAe;;qBC5HpG,qBAAqB;;;;;KCQtB;WACG;WAA0B;WAAwB;WAAuC;WAAqB,QAAQ;;WACtH;WAA0B;WAAwB;WAAuC;WAAsB;;;UAG7G;;WAEN,gBAAgB;;WAEhB;;WAEA,QAAQ;;;;;;;;;;;;;;;;;;;;;wBAsBH,cAAc,SAAS,eAAe,OAAO,SAAS,0BAA0B"}
@@ -64,6 +64,7 @@ function sizeUnit(unit) {
64
64
  * - An error for a unit that does not convert to the unit of its resource.
65
65
  * - An error for a size in a unit that is not a mass, a volume or a count, for example `h` or `kcal`.
66
66
  * - The amount of the item of an average price has the same checks as each other amount.
67
+ * - With the option `foodKeeper`, an error for a FoodKeeper id of a shelf life that is not in the known ids.
67
68
  * - A warning for each value with no read, and for a no read with a blank reason.
68
69
  * - A warning for each fact and each source that no product uses.
69
70
  *
@@ -71,10 +72,12 @@ function sizeUnit(unit) {
71
72
  * example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.
72
73
  *
73
74
  * @param catalog - The catalog
74
- * @param options - The options of the gate of the sources, for example the date of the gate
75
+ * @param options - The options of the gate of the sources, for example the date of the gate, and the known FoodKeeper ids
75
76
  */
76
77
  function checkSupplies(catalog, options = {}) {
77
- const out = [...checkSources(catalog.sources, options), ...checkUnits(catalog.facts, catalog.sources, options)];
78
+ const { foodKeeper: knownFoodKeeper, ...gate } = options;
79
+ const foodKeeper = knownFoodKeeper === void 0 ? void 0 : new Set(knownFoodKeeper);
80
+ const out = [...checkSources(catalog.sources, gate), ...checkUnits(catalog.facts, catalog.sources, gate)];
78
81
  const error = (code, record, id, message) => {
79
82
  out.push({
80
83
  level: "error",
@@ -149,6 +152,7 @@ function checkSupplies(catalog, options = {}) {
149
152
  if (product.average !== void 0) amount(product.id, "average price", product.average.read ? product.average.per : product.average, product.average.read ? product.average.per.unit : "");
150
153
  if ("foodKeeper" in product.shelf) {
151
154
  if (!(Number.isSafeInteger(product.shelf.foodKeeper) && product.shelf.foodKeeper > 0)) error("supplies-shelf", "product", product.id, `The FoodKeeper id of the product ${product.id} is ${String(product.shelf.foodKeeper)}. It must be a whole number more than 0.`);
155
+ else if (foodKeeper !== void 0 && !foodKeeper.has(product.shelf.foodKeeper)) error("supplies-shelf", "product", product.id, `The FoodKeeper id ${String(product.shelf.foodKeeper)} of the product ${product.id} is not in the known FoodKeeper ids.`);
152
156
  } else amount(product.id, "shelf life", product.shelf, SHELF_UNIT);
153
157
  }
154
158
  for (const fact of catalog.facts) if (!used.has(fact.id)) warning("supplies-unused", "unit", fact.id, `No product uses the fact ${fact.id}.`);
@@ -1 +1 @@
1
- {"version":3,"file":"supplies-entry.js","names":["ENERGY_UNIT"],"sources":["../src/supplies.ts","../src/supplies-data.ts","../src/food-plan.ts","../src/food-plan-data.ts","../src/buy-list-energy.ts"],"sourcesContent":["import { checkSources, checkUnits, type CitedUnit, type Finding, type FindingCode, type GateOptions, type Source } from \"@mark1russell7/guidebook\";\nimport { convertible, kindOf, quantity, valueIn, whyNotConvertible, type Quantity } from \"@mark1russell7/quantity\";\nimport { latestAverages, moneyOf, monthSchema, type AveragePrice } from \"./average.ts\";\nimport type { PartWant } from \"./offers.ts\";\nimport type { ProductWant } from \"./order.ts\";\n\n/*\n * This module is the format and the gate of a catalog of supplies: the products that a household keeps for an\n * emergency, the resource and the amount that one unit gives, and its shelf life. Each value has a cited fact, the\n * definition of the product, or an explicit no read. The facts and their sources are the records of\n * `@mark1russell7/guidebook`, and its gate examines them. The module names no person and no place.\n */\n\n/** The format of a catalog of supplies. */\nexport const SUPPLY_FORMAT = \"supply-catalog/1\";\n\n/** The kinds of the supplies. */\nexport const SUPPLY_KINDS = [\"water\", \"food\", \"power\", \"light\", \"heat\", \"first-aid\", \"communication\"] as const;\n\n/** A kind of a supply. */\nexport type SupplyKind = (typeof SUPPLY_KINDS)[number];\n\n/** A value that no source gives yet. The reason tells what is missing. */\nexport interface NoRead {\n readonly read: false;\n readonly why: string;\n}\n\n/**\n * An amount with its reason. The reason is a cited fact: the `id` of a unit of the catalog with the use `fact`.\n * Or it is the definition of the product, for example the 1 gal of a jug of 1 gal.\n */\nexport type CitedAmount =\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly fact: string; readonly definition?: never }\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly definition: string; readonly fact?: never };\n\n/** A resource that a supply gives, with its unit, for example `water.stored` in `L`. The codes are the resource codes of a store. */\nexport interface SupplyResource {\n readonly code: string;\n readonly unit: string;\n readonly title: string;\n}\n\n/** The gift of one unit of a product: an amount of one resource, or no read. */\nexport interface SupplyGift {\n readonly resource: string;\n readonly amount: CitedAmount | NoRead;\n}\n\n/**\n * The shelf life of a product: a cited amount of time, the `id` of a product of the FoodKeeper data of USDA FSIS, or no read.\n * The entry `/foodkeeper` of `@mark1russell7/stock` gives the due rule of a FoodKeeper product.\n */\nexport type ShelfLife = CitedAmount | { readonly read: true; readonly foodKeeper: number } | NoRead;\n\n/**\n * The join of a product to a series of average prices. It names the source and the series. It also gives the amount\n * of the item of the series in one unit of the product. For example, 1 kg of dry rice is the amount of a series of\n * rice in USD/lb.\n */\nexport interface AverageJoin {\n readonly read: true;\n /** The source of the average prices, for example `bls-ap`. */\n readonly source: string;\n /** The id of the series in the source, for example `APU0000701312`. */\n readonly series: string;\n /** The amount of the item of the series in one unit of the product, with its reason. */\n readonly per: CitedAmount;\n}\n\n/** A product of the catalog. */\nexport interface SupplyProduct {\n readonly id: string;\n readonly title: string;\n readonly kind: SupplyKind;\n /** The part that the offers of a seller must match. A product with no part has no offer, so it has no price. */\n readonly want?: PartWant | undefined;\n /** The resources that one unit gives. A product that gives no stored resource, for example a radio, gives none. */\n readonly gives: readonly SupplyGift[];\n /** The `id` of a fact that tells why a kit has the product, for example the kit list of a public agency. */\n readonly basis?: string | undefined;\n /** The food energy of one unit, in a unit of energy. A cooking converter gives it. */\n readonly energy?: CitedAmount | NoRead | undefined;\n /**\n * The amount of one unit as sold: a mass, a volume or a count, for example 1 kg, 530 g or 1 gal.\n * A product with no known size has no field `size`. A no read is for a product that has a size, when the source\n * of the size is not read yet, for example a label.\n */\n readonly size?: CitedAmount | NoRead | undefined;\n readonly shelf: ShelfLife;\n /**\n * The series of average prices that gives the price of one unit, or no read with the reason. A product with no join\n * and no part has no price.\n */\n readonly average?: AverageJoin | NoRead | undefined;\n}\n\n/** A catalog of supplies: the sources, the cited facts, the resources and the products. */\nexport interface SupplyCatalog {\n readonly format: typeof SUPPLY_FORMAT;\n readonly sources: readonly Source[];\n readonly facts: readonly CitedUnit[];\n readonly resources: readonly SupplyResource[];\n readonly products: readonly SupplyProduct[];\n}\n\n/** The codes of the findings of the catalog gate. */\nexport const SUPPLY_CODES = [\n \"supplies-format\",\n \"supplies-twice\",\n \"supplies-kind\",\n \"supplies-resource\",\n \"supplies-fact\",\n \"supplies-basis\",\n \"supplies-amount\",\n \"supplies-unit\",\n \"supplies-shelf\",\n \"supplies-unused\",\n \"supplies-no-read\",\n \"supplies-no-reason\",\n] as const;\n\n/** A code of a finding of the catalog gate. */\nexport type SupplyCode = (typeof SUPPLY_CODES)[number];\n\n/** A finding of the catalog gate, or of the gate of the facts and their sources. */\nexport type SupplyFinding = Finding<SupplyCode | FindingCode, \"source\" | \"unit\" | \"resource\" | \"product\">;\n\n/** This function tells if a text is a unit of `@mark1russell7/quantity`. `convertible` throws for an unknown unit. */\nfunction known(unit: unknown): boolean {\n if (typeof unit !== \"string\") return false;\n try {\n return convertible(unit, unit);\n } catch {\n return false;\n }\n}\n\n/** The unit that each food energy converts to. */\nconst ENERGY_UNIT = \"kcal\";\n/** The unit that each shelf life converts to. */\nconst SHELF_UNIT = \"d\";\n/**\n * This function gives true for the unit of a size. That is a mass or a volume that converts to `kg` or `L`, or one\n * bare count, for example `{each}`. The kind of a unit is not sufficient. For example, `g/{each}` has the kind\n * mass, and it does not convert to `kg`.\n */\nfunction sizeUnit(unit: string): boolean {\n return convertible(unit, \"kg\") || convertible(unit, \"L\") || (/^{[^{}/]+}$/.test(unit) && kindOf(unit) === \"count\");\n}\n\n/**\n * This function examines a catalog. It gives the findings of the sources and the facts (the gate of\n * `@mark1russell7/guidebook`), and the findings of the products:\n *\n * - An error for a product or a resource two times, a kind that is not a supply kind, and a gift of an unknown resource.\n * - An error for a product that gives no resource and has no basis.\n * - An error for a field `energy` on a product that is not food. The field is the food energy of one unit.\n * - An error for a fact that is not a fact of the catalog, and for an amount that is not more than 0. The basis of a\n * product is also a fact.\n * - An error for an amount with no reason, with two reasons, or with a blank definition. A catalog from JSON can have them.\n * - An error for a unit that is not a unit of `@mark1russell7/quantity`.\n * - An error for a unit that does not convert to the unit of its resource.\n * - An error for a size in a unit that is not a mass, a volume or a count, for example `h` or `kcal`.\n * - The amount of the item of an average price has the same checks as each other amount.\n * - A warning for each value with no read, and for a no read with a blank reason.\n * - A warning for each fact and each source that no product uses.\n *\n * The function takes a decoded catalog: each record has the fields of its type. Decode a catalog from JSON first, for\n * example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.\n *\n * @param catalog - The catalog\n * @param options - The options of the gate of the sources, for example the date of the gate\n */\nexport function checkSupplies(catalog: SupplyCatalog, options: GateOptions = {}): SupplyFinding[] {\n const out: SupplyFinding[] = [...checkSources(catalog.sources, options), ...checkUnits(catalog.facts, catalog.sources, options)];\n const error = (code: SupplyCode, record: \"resource\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"error\", code, record, id, message });\n };\n const warning = (code: SupplyCode, record: \"source\" | \"unit\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"warning\", code, record, id, message });\n };\n if (catalog.format !== SUPPLY_FORMAT) error(\"supplies-format\", \"product\", \"\", `The format is ${String(catalog.format)}. It must be ${SUPPLY_FORMAT}.`);\n\n const resources = new Map<string, SupplyResource>();\n for (const resource of catalog.resources) {\n if (resources.has(resource.code)) error(\"supplies-twice\", \"resource\", resource.code, `The resource ${resource.code} is two times in the catalog.`);\n if (!known(resource.unit)) error(\"supplies-unit\", \"resource\", resource.code, `The unit ${String(resource.unit)} of the resource ${resource.code} is not a known unit.`);\n resources.set(resource.code, resource);\n }\n const facts = new Map(catalog.facts.map((fact) => [fact.id, fact]));\n const used = new Set<string>();\n\n /** This function examines one cited amount, and gives the unit check to `units`. */\n const amount = (product: string, what: string, value: CitedAmount | NoRead, unit: string): void => {\n if (!value.read) {\n warning(\"supplies-no-read\", \"product\", product, `The ${what} of the product ${product} is no read: ${String(value.why)}`);\n if (typeof value.why !== \"string\" || value.why.trim() === \"\") warning(\"supplies-no-reason\", \"product\", product, `The no read of the ${what} of the product ${product} has no reason.`);\n return;\n }\n // The type permits one reason only. A catalog from JSON can have no reason, two reasons or a blank definition.\n const reasons = (value.fact === undefined ? 0 : 1) + (value.definition === undefined ? 0 : 1);\n if (reasons !== 1) error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} has ${String(reasons)} reasons. It must have a fact or a definition, not the two.`);\n else if (value.definition !== undefined && (typeof value.definition !== \"string\" || value.definition.trim() === \"\")) error(\"supplies-fact\", \"product\", product, `The definition of the ${what} of the product ${product} is blank.`);\n if (value.fact !== undefined) {\n const fact = facts.get(value.fact);\n if (fact === undefined || fact.use !== \"fact\") error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} cites ${value.fact}, and the catalog has no fact with that id.`);\n used.add(value.fact);\n }\n if (!(Number.isFinite(value.amount) && value.amount > 0)) error(\"supplies-amount\", \"product\", product, `The ${what} of the product ${product} is ${String(value.amount)}. It must be a finite number more than 0.`);\n if (!known(value.unit)) error(\"supplies-unit\", \"product\", product, `The unit ${String(value.unit)} of the ${what} of the product ${product} is not a known unit.`);\n else if (known(unit) && !convertible(value.unit, unit)) error(\"supplies-unit\", \"product\", product, `The ${what} of the product ${product} is in ${value.unit}, and ${value.unit} does not convert to ${unit}.`);\n };\n\n const products = new Set<string>();\n for (const product of catalog.products) {\n if (products.has(product.id)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} is two times in the catalog.`);\n products.add(product.id);\n if (!(SUPPLY_KINDS as readonly string[]).includes(product.kind)) error(\"supplies-kind\", \"product\", product.id, `The kind ${String(product.kind)} of the product ${product.id} is not a supply kind.`);\n const gifts = new Set<string>();\n for (const gift of product.gives) {\n if (gifts.has(gift.resource)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource} two times.`);\n gifts.add(gift.resource);\n const resource = resources.get(gift.resource);\n if (resource === undefined) error(\"supplies-resource\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n else amount(product.id, `gift of ${gift.resource}`, gift.amount, resource.unit);\n }\n if (product.gives.length === 0 && product.basis === undefined) error(\"supplies-basis\", \"product\", product.id, `The product ${product.id} gives no resource and has no basis. A product that gives no resource cites a fact in its basis.`);\n if (product.basis !== undefined) {\n const fact = facts.get(product.basis);\n if (fact === undefined || fact.use !== \"fact\") error(\"supplies-fact\", \"product\", product.id, `The basis of the product ${product.id} cites ${String(product.basis)}, and the catalog has no fact with that id.`);\n used.add(product.basis);\n }\n // An unknown kind has its own error above, so this rule examines only a known kind that is not food.\n if (product.energy !== undefined && product.kind !== \"food\" && (SUPPLY_KINDS as readonly string[]).includes(product.kind)) error(\"supplies-kind\", \"product\", product.id, `The product ${product.id} has a food energy, and its kind is ${String(product.kind)}. Only a product of the kind food has a food energy.`);\n if (product.energy !== undefined) amount(product.id, \"food energy\", product.energy, ENERGY_UNIT);\n if (product.size !== undefined) {\n // The size has no single unit to convert to. Its unit must be a mass, a volume or one bare count. An unknown unit\n // has its own error.\n amount(product.id, \"size\", product.size, \"\");\n if (product.size.read && known(product.size.unit) && !sizeUnit(product.size.unit))\n error(\"supplies-unit\", \"product\", product.id, `The size of the product ${product.id} is in ${product.size.unit}. It must be a mass, a volume or a count.`);\n }\n if (product.average !== undefined) amount(product.id, \"average price\", product.average.read ? product.average.per : product.average, product.average.read ? product.average.per.unit : \"\");\n if (\"foodKeeper\" in product.shelf) {\n if (!(Number.isSafeInteger(product.shelf.foodKeeper) && product.shelf.foodKeeper > 0)) error(\"supplies-shelf\", \"product\", product.id, `The FoodKeeper id of the product ${product.id} is ${String(product.shelf.foodKeeper)}. It must be a whole number more than 0.`);\n } else amount(product.id, \"shelf life\", product.shelf, SHELF_UNIT);\n }\n\n for (const fact of catalog.facts) if (!used.has(fact.id)) warning(\"supplies-unused\", \"unit\", fact.id, `No product uses the fact ${fact.id}.`);\n const cited = new Set(catalog.facts.map((fact) => fact.source));\n for (const source of catalog.sources) if (!cited.has(source.id)) warning(\"supplies-unused\", \"source\", source.id, `No fact cites the source ${source.id}.`);\n return out;\n}\n\n/**\n * This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.\n * A product with no part has no offer, so it is not in the result.\n *\n * @param catalog - The catalog\n * @param max - The largest count of units of a product. The default is 1 for each product\n */\nexport function supplyWants(catalog: SupplyCatalog, max: (product: SupplyProduct) => number = () => 1): ProductWant[] {\n return catalog.products.flatMap((product) => (product.want === undefined ? [] : [{ product: product.id, want: product.want, max: max(product) }]));\n}\n\n/** The gift of a count of units: an amount in the unit of its resource, or no read. */\nexport type GiftOf = { readonly resource: string; readonly read: true; readonly amount: number; readonly unit: string } | { readonly resource: string; readonly read: false; readonly why: string };\n\n/**\n * This function gives the resources of a count of units of a product, each in the unit of its resource.\n * A gift with no read stays no read: it is not 0.\n *\n * @param catalog - The catalog\n * @param id - The `id` of the product\n * @param units - The count of units\n * @throws RangeError when the count of units is not a finite number of 0 or more\n * @throws RangeError when the catalog has no such product, or a gift of an unknown resource\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of a gift does not convert to the unit of its resource\n */\nexport function giftsOf(catalog: SupplyCatalog, id: string, units: number): GiftOf[] {\n if (!(Number.isFinite(units) && units >= 0)) throw new RangeError(`The count of units is ${String(units)}. It must be a finite number of 0 or more.`);\n const product = catalog.products.find((each) => each.id === id);\n if (product === undefined) throw new RangeError(`The catalog has no product ${id}.`);\n return product.gives.map((gift): GiftOf => {\n const resource = catalog.resources.find((each) => each.code === gift.resource);\n if (resource === undefined) throw new RangeError(`The product ${id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n if (!gift.amount.read) return { resource: gift.resource, read: false, why: gift.amount.why };\n return { resource: gift.resource, read: true, amount: units * valueIn(quantity(gift.amount.amount, gift.amount.unit), resource.unit), unit: resource.unit };\n });\n}\n\n/** The price of one unit of a product from an average price, or no read with the reason. */\nexport type SupplyPrice =\n | { readonly product: string; readonly read: true; readonly price: Quantity; readonly average: string; readonly period: string }\n | { readonly product: string; readonly read: false; readonly why: string };\n\n/**\n * This function gives the price of one unit of each product with a join to a series, in the order of the catalog.\n * It takes the last month of each series (`latestAverages`). The price is in the money of the average price.\n *\n * - A product with no join is not in the result.\n * - A join with no read, a series with no price, and a unit that does not fit give no read. A no read is not 0.\n * - The unit of the series must convert to the unit of the product, for example USD/lb to 1 kg.\n * - With the option `since`, a last price before that month gives no read. A series that stops then gives no old price.\n *\n * @param catalog - The catalog\n * @param prices - The average prices, from one or more reads\n * @param options - The option `since`: the first month of a price that the result can use, in the form `YYYY-MM`\n * @returns The price of one unit of each product with a join, or no read with the reason\n * @throws RangeError when `since` is not a month in the form `YYYY-MM`\n */\nexport function averageSupplyPrices(catalog: SupplyCatalog, prices: readonly AveragePrice[], options: { readonly since?: string | undefined } = {}): SupplyPrice[] {\n const { since } = options;\n if (since !== undefined && !monthSchema.safeParse(since).success) throw new RangeError(`The month ${String(since)} is not in the form YYYY-MM.`);\n const last = new Map(latestAverages(prices).map((price) => [`${price.source}:${price.series}`, price]));\n return catalog.products.flatMap((product): SupplyPrice[] => {\n const join = product.average;\n if (join === undefined) return [];\n const none = (why: string): SupplyPrice[] => [{ product: product.id, read: false, why }];\n if (!join.read) return none(join.why);\n const average = last.get(`${join.source}:${join.series}`);\n if (average === undefined) return none(`The prices have no average price of the series ${join.series} of ${join.source}.`);\n if (since !== undefined && average.period < since) return none(`The last average price of the series ${join.series} of ${join.source} is for ${average.period}, before ${since}.`);\n const money = moneyOf(average.price.unit);\n if (money === undefined) return none(`The unit ${average.price.unit} of ${average.id} is not a price for each unit of an amount.`);\n if (!known(join.per.unit)) return none(`The unit ${String(join.per.unit)} of the product ${product.id} is not a known unit.`);\n const unit = `${money}/${join.per.unit}`;\n const why = whyNotConvertible(average.price.unit, unit);\n if (why !== undefined) return none(`The average price ${average.id} is in ${average.price.unit}, and it does not convert to ${unit}: ${why}.`);\n const price = quantity(valueIn(average.price, unit) * join.per.amount, money);\n return [{ product: product.id, read: true, price, average: average.id, period: average.period }];\n });\n}\n","import { SUPPLY_FORMAT, type SupplyCatalog } from \"./supplies.ts\";\n\n// The reference catalog of supplies. Each value has a cited fact, the definition of the product, or a no read.\n// Each fact is in own words, not a quote. The shelf life of a food is a product of the FoodKeeper data of USDA FSIS:\n// the entry `/foodkeeper` of `@mark1russell7/stock` gives its due rule, so this catalog does not copy its times.\n\nconst CHECKED = \"2026-11-22\";\n\n/** The reference catalog of supplies. A household adds its own products to a copy of it. */\nexport const SUPPLY_CATALOG: SupplyCatalog = {\n format: SUPPLY_FORMAT,\n sources: [\n { id: \"ready.water\", title: \"Water\", url: \"https://www.ready.gov/water\", license: \"us-public-domain\", checked: CHECKED, by: \"FEMA (Ready.gov)\" },\n { id: \"ready.kit\", title: \"Build A Kit\", url: \"https://www.ready.gov/kit\", license: \"us-public-domain\", checked: CHECKED, by: \"FEMA (Ready.gov)\" },\n { id: \"fdc.sr-legacy\", title: \"FoodData Central, SR Legacy\", url: \"https://fdc.nal.usda.gov/\", license: \"cc0\", checked: CHECKED, by: \"USDA Agricultural Research Service\" },\n ],\n facts: [\n {\n id: \"ready.water-replace\",\n use: \"fact\",\n text: \"The page tells to replace the stored water that is not commercially bottled each six months.\",\n source: \"ready.water\",\n locator: \"Water storage\",\n },\n {\n id: \"fdc.rice-white\",\n use: \"fact\",\n text: \"The item 168877 (white long-grain rice, raw, enriched) gives 365 kcal in 100 g. Thus 1 kg gives 3650 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 168877\",\n },\n {\n id: \"fdc.oats\",\n use: \"fact\",\n text: \"The item 173904 (oats, regular and quick, not fortified, dry) gives 379 kcal in 100 g. Thus 1 kg gives 3790 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 173904\",\n },\n {\n id: \"fdc.beans-black\",\n use: \"fact\",\n text: \"The item 173734 (black beans, mature seeds, raw) gives 341 kcal in 100 g. Thus 1 kg gives 3410 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 173734\",\n },\n {\n id: \"fdc.peanut-butter\",\n use: \"fact\",\n text: \"The item 174266 (peanut butter, smooth style, with salt) gives 598 kcal in 100 g. Thus 1 kg gives 5980 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 174266\",\n },\n {\n id: \"fdc.pasta\",\n use: \"fact\",\n text: \"The item 168927 (pasta, dry, unenriched) gives 371 kcal in 100 g. Thus 1 kg gives 3710 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 168927\",\n },\n {\n id: \"fdc.flour-white\",\n use: \"fact\",\n text: \"The item 169761 (wheat flour, white, all-purpose, unenriched) gives 364 kcal in 100 g. Thus 1 kg gives 3640 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 169761\",\n },\n {\n id: \"fdc.soup-chicken-noodle\",\n use: \"fact\",\n text: \"The item 171148 (chunky chicken noodle soup, canned, ready-to-serve) gives 41 kcal in 100 g. Its portion of 1 can is 530 g. Thus 1 can gives 217.3 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 171148, portion 1 can (530 g)\",\n },\n {\n id: \"ready.kit-flashlight\",\n use: \"fact\",\n text: \"The basic kit of the page has a flashlight and extra batteries.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-first-aid\",\n use: \"fact\",\n text: \"The basic kit of the page has a first aid kit.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-radio\",\n use: \"fact\",\n text: \"The basic kit of the page has a radio on batteries or a hand crank, and a NOAA Weather Radio with tone alert.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-sleeping-bag\",\n use: \"fact\",\n text: \"The page tells to add a sleeping bag or a warm blanket for each person.\",\n source: \"ready.kit\",\n locator: \"Additional Emergency Supplies\",\n },\n ],\n resources: [\n { code: \"water.stored\", unit: \"L\", title: \"Stored drinking water\" },\n { code: \"food.grain-dry\", unit: \"kg\", title: \"Dry grain, to cook with water and fuel\" },\n { code: \"food.legume-dry\", unit: \"kg\", title: \"Dry beans, to cook with water and fuel\" },\n { code: \"food.pasta-dry\", unit: \"kg\", title: \"Dry pasta, to boil in water that the cook drains\" },\n { code: \"food.flour\", unit: \"kg\", title: \"Flour, to bake or cook with water and fuel\" },\n { code: \"food.no-cook\", unit: \"kcal\", title: \"Food energy to eat with no water and no fuel\" },\n { code: \"energy.battery\", unit: \"Wh\", title: \"Energy in a battery\" },\n ],\n products: [\n {\n id: \"water.jug-1gal\",\n title: \"Drinking water, commercially bottled, in a jug of 1 gal\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a jug of 1 gal.\" } }],\n size: { read: true, amount: 1, unit: \"gal\", definition: \"The catalog item is defined as a jug of 1 gal.\" },\n shelf: { read: false, why: \"The source tells to keep commercially bottled water sealed, and it gives no time. The date on the label applies.\" },\n },\n {\n id: \"water.container-1gal\",\n title: \"A water container of 1 gal, filled from the tap\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a container of 1 gal.\" } }],\n shelf: { read: true, amount: 6, unit: \"mo\", fact: \"ready.water-replace\" },\n },\n {\n id: \"food.rice-white-1kg\",\n title: \"White long-grain rice, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry rice.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry rice.\" },\n energy: { read: true, amount: 3650, unit: \"kcal\", fact: \"fdc.rice-white\" },\n shelf: { read: true, foodKeeper: 338 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701312\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry white long-grain rice, the item of the series.\" },\n },\n },\n {\n id: \"food.oats-1kg\",\n title: \"Rolled oats, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry oats.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry oats.\" },\n energy: { read: true, amount: 3790, unit: \"kcal\", fact: \"fdc.oats\" },\n shelf: { read: true, foodKeeper: 375 },\n average: { read: false, why: \"The known series of average prices have no series of oats yet.\" },\n },\n {\n id: \"food.beans-dry-1kg\",\n title: \"Dry beans, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.legume-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry beans.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry beans.\" },\n energy: { read: true, amount: 3410, unit: \"kcal\", fact: \"fdc.beans-black\" },\n shelf: { read: true, foodKeeper: 333 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000714233\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry beans of any type, the item of the series.\" },\n },\n },\n {\n id: \"food.peanut-butter-1kg\",\n title: \"Peanut butter, smooth, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.no-cook\", amount: { read: true, amount: 5980, unit: \"kcal\", fact: \"fdc.peanut-butter\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of peanut butter.\" },\n energy: { read: true, amount: 5980, unit: \"kcal\", fact: \"fdc.peanut-butter\" },\n shelf: { read: true, foodKeeper: 387 },\n average: { read: false, why: \"The known series of average prices have no series of peanut butter yet.\" },\n },\n {\n id: \"food.pasta-dry-1kg\",\n title: \"Dry pasta, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.pasta-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry pasta.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry pasta.\" },\n energy: { read: true, amount: 3710, unit: \"kcal\", fact: \"fdc.pasta\" },\n shelf: { read: true, foodKeeper: 335 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701322\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry spaghetti or macaroni, the item of the series.\" },\n },\n },\n {\n id: \"food.flour-white-1kg\",\n title: \"White all-purpose flour, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.flour\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of white flour.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of white flour.\" },\n energy: { read: true, amount: 3640, unit: \"kcal\", fact: \"fdc.flour-white\" },\n shelf: { read: true, foodKeeper: 222 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701111\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of white all-purpose flour, the item of the series.\" },\n },\n },\n {\n id: \"food.soup-can\",\n title: \"Chunky chicken noodle soup, ready-to-serve, 1 can (530 g)\",\n kind: \"food\",\n gives: [{ resource: \"food.no-cook\", amount: { read: true, amount: 217.3, unit: \"kcal\", fact: \"fdc.soup-chicken-noodle\" } }],\n size: { read: true, amount: 530, unit: \"g\", fact: \"fdc.soup-chicken-noodle\" },\n energy: { read: true, amount: 217.3, unit: \"kcal\", fact: \"fdc.soup-chicken-noodle\" },\n shelf: { read: true, foodKeeper: 372 },\n average: { read: false, why: \"The known series of average prices have no series of canned soup yet.\" },\n },\n {\n id: \"light.flashlight\",\n title: \"A flashlight on batteries\",\n kind: \"light\",\n basis: \"ready.kit-flashlight\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life. The batteries have the date on their label.\" },\n },\n {\n id: \"heat.sleeping-bag\",\n title: \"A sleeping bag for each person\",\n kind: \"heat\",\n basis: \"ready.kit-sleeping-bag\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life.\" },\n },\n {\n id: \"first-aid.kit\",\n title: \"A first aid kit\",\n kind: \"first-aid\",\n basis: \"ready.kit-first-aid\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life. Each item of the kit has the date on its label.\" },\n },\n {\n id: \"communication.noaa-radio\",\n title: \"A NOAA Weather Radio with tone alert, on batteries or a hand crank\",\n kind: \"communication\",\n basis: \"ready.kit-radio\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life.\" },\n },\n {\n id: \"power.anker-737\",\n title: \"Anker 737 Power Bank (PowerCore 24K)\",\n kind: \"power\",\n want: { brands: [\"Anker\"], partNumbers: [\"A1289\"] },\n gives: [{ resource: \"energy.battery\", amount: { read: false, why: \"The page of the maker gives 24,000 mAh and no Wh. A charge does not convert to energy without its voltage.\" } }],\n shelf: { read: false, why: \"No source is read yet.\" },\n },\n ],\n};\n","import type { Source } from \"@mark1russell7/guidebook\";\nimport { convertible, quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { moneyAbove } from \"./average.ts\";\n\n/** This function gives the money of a cost for each unit of time, for example `USD` for `USD/wk`. */\nfunction moneyOfRate(unit: string): string | undefined {\n const money = moneyAbove(unit);\n return money !== undefined && convertible(unit, `${money}/d`) ? money : undefined;\n}\n\n/*\n * This module has the cost of a food plan: the cost of the food of one week for one person of each age and sex, from\n * an official source. A check compares the food of a buy list with the cost of the plan for the same people and days.\n * The module names no person. The members of a household are input data.\n */\n\n/** The age and sex groups of a food plan of USDA. */\nexport const FOOD_PLAN_GROUPS = [\n \"child-1\",\n \"child-2-3\",\n \"child-4-5\",\n \"child-6-8\",\n \"child-9-11\",\n \"female-12-13\",\n \"female-14-19\",\n \"female-20-50\",\n \"female-51-70\",\n \"female-71-up\",\n \"male-12-13\",\n \"male-14-19\",\n \"male-20-50\",\n \"male-51-70\",\n \"male-71-up\",\n] as const;\n\n/** An age and sex group of a food plan. */\nexport type FoodPlanGroup = (typeof FOOD_PLAN_GROUPS)[number];\n\n/** The change of the cost for a size of household, for example 0.2 for one person. */\nexport interface FoodPlanSize {\n /** The smallest count of persons. */\n readonly from: number;\n /** The largest count of persons. Without it, the change applies to each larger household. */\n readonly to?: number | undefined;\n /** The change of the cost, as a fraction: 0.2 adds 20 percent, and -0.05 subtracts 5 percent. */\n readonly change: number;\n}\n\n/** The cost of a food plan in one area and one month, from one source. */\nexport interface FoodPlan {\n /** The id, for example `usda.thrifty:2026-10`. */\n readonly id: string;\n readonly title: string;\n /** The area, as the source names it, for example `U.S. average`. */\n readonly area: string;\n /** The month of the costs, in the form `YYYY-MM`. */\n readonly period: string;\n readonly source: Source;\n /** The place of the table in the source. */\n readonly locator: string;\n /** The cost of the food of one week for one person of each group, for example `{ \"value\": 58.7, \"unit\": \"USD/wk\" }`. */\n readonly weekly: Readonly<Record<FoodPlanGroup, Quantity>>;\n /** The change of the cost for each size of household. The costs of `weekly` are for the size with the change 0. */\n readonly sizes: readonly FoodPlanSize[];\n}\n\n/** A group of the members of a household, and the count of its persons. */\nexport interface FoodPlanMember {\n readonly group: FoodPlanGroup;\n readonly count: number;\n}\n\n/** The result of a check of the cost of food against a food plan. */\nexport interface FoodPlanCheck {\n /** The cost of the plan for the same members and days. */\n readonly plan: Quantity;\n /** The cost of the food, in the money of the plan. */\n readonly cost: Quantity;\n /** The cost of the food divided by the cost of the plan. */\n readonly ratio: number;\n /**\n * True when the food costs more than the plan. The Thrifty plan is the lowest of the four plans of USDA. Thus a list\n * above the cost of the Thrifty plan is not wrong when it has foods that cost more than staples.\n */\n readonly above: boolean;\n}\n\n/**\n * This function gives the cost of a food plan for the members of a household and a count of days. It adds the cost of\n * each person, and then it applies the change for the size of the household.\n *\n * @param plan - The food plan\n * @param members - The groups of the members of the household, each with its count of persons\n * @param days - The count of days, a finite number of 0 or more\n * @throws RangeError when a count of persons is not a whole number of 0 or more, or when the household has no person\n * @throws RangeError when a group is not in the plan, or when the plan has no change for the size of the household\n * @throws RangeError when the count of days is not a finite number of 0 or more\n */\nexport function foodPlanCost(plan: FoodPlan, members: readonly FoodPlanMember[], days: number): Quantity {\n if (!(Number.isFinite(days) && days >= 0)) throw new RangeError(`The count of days is ${String(days)}. It must be a finite number of 0 or more.`);\n let persons = 0;\n let money: string | undefined;\n let total = 0;\n for (const member of members) {\n if (!(Number.isSafeInteger(member.count) && member.count >= 0)) throw new RangeError(`The count of the group ${member.group} is ${String(member.count)}. It must be a whole number of 0 or more.`);\n const weekly = plan.weekly[member.group] as Quantity | undefined;\n const symbol = weekly === undefined ? undefined : moneyOfRate(weekly.unit);\n if (weekly === undefined || symbol === undefined) throw new RangeError(`The plan ${plan.id} has no cost for each unit of time of the group ${String(member.group)}.`);\n if (money !== undefined && symbol !== money) throw new RangeError(`The plan ${plan.id} has costs in ${money} and in ${symbol}.`);\n money = symbol;\n persons += member.count;\n total += member.count * valueIn(weekly, `${symbol}/d`) * days;\n }\n if (persons === 0 || money === undefined) throw new RangeError(\"The household has no person.\");\n const size = plan.sizes.find((each) => persons >= each.from && (each.to === undefined || persons <= each.to));\n if (size === undefined) throw new RangeError(`The plan ${plan.id} has no change for a household of ${String(persons)} persons.`);\n return quantity(total * (1 + size.change), money);\n}\n\n/**\n * This function compares the cost of the food of a buy list with the cost of a food plan for the same members and\n * days. A list of dry staples costs less than the plan, because the plan is a full diet. A ratio above 1 tells that\n * a price or an amount of the list is possibly wrong. A low ratio is normal, because a list can be any part of a diet.\n * The check of the amount of food is a check of its energy, not of its cost.\n *\n * @param cost - The cost of the food, in a money that converts to the money of the plan\n * @param plan - The food plan\n * @param members - The groups of the members of the household, each with its count of persons\n * @param days - The count of days of the food\n * @throws RangeError for the errors of `foodPlanCost`\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the money of the cost does not convert to the money of the plan\n */\nexport function foodPlanCheck(cost: Quantity, plan: FoodPlan, members: readonly FoodPlanMember[], days: number): FoodPlanCheck {\n const planned = foodPlanCost(plan, members, days);\n const value = valueIn(cost, planned.unit);\n const ratio = planned.value === 0 ? (value === 0 ? 0 : Number.POSITIVE_INFINITY) : value / planned.value;\n return { plan: planned, cost: quantity(value, planned.unit), ratio, above: ratio > 1 };\n}\n","import type { FoodPlan } from \"./food-plan.ts\";\n\n// The costs of the food plans of USDA. Each value is from the table of the report, read on 2026-11-22. The report\n// rounds each weekly cost to 10 cents. Footnote 2 of the report gives the change for each size of household.\n\nconst week = (value: number): { readonly value: number; readonly unit: string } => ({ value, unit: \"USD/wk\" });\n\n/** The costs of the food plans of USDA, one record for each plan and month. */\nexport const FOOD_PLANS: readonly FoodPlan[] = [\n {\n id: \"usda.thrifty:2026-10\",\n title: \"Official USDA Thrifty Food Plan: U.S. Average, October 2026\",\n area: \"U.S. average\",\n period: \"2026-10\",\n source: {\n id: \"usda.food-plans\",\n title: \"USDA Food Plans: Monthly Cost of Food Reports\",\n url: \"https://www.fna.usda.gov/research/cnpp/usda-food-plans/cost-food-monthly-reports\",\n license: \"us-public-domain\",\n checked: \"2026-11-22\",\n by: \"USDA Food and Nutrition Administration\",\n },\n locator: \"CostofFoodOct2026Thrifty.pdf, the column Weekly Cost of the table of age-sex groups\",\n weekly: {\n \"child-1\": week(26.4),\n \"child-2-3\": week(39.8),\n \"child-4-5\": week(43.5),\n \"child-6-8\": week(48.3),\n \"child-9-11\": week(55.8),\n \"female-12-13\": week(51.7),\n \"female-14-19\": week(60.1),\n \"female-20-50\": week(58.7),\n \"female-51-70\": week(54.6),\n \"female-71-up\": week(60.3),\n \"male-12-13\": week(59.7),\n \"male-14-19\": week(75.3),\n \"male-20-50\": week(73.7),\n \"male-51-70\": week(65),\n \"male-71-up\": week(62),\n },\n sizes: [\n { from: 1, to: 1, change: 0.2 },\n { from: 2, to: 2, change: 0.1 },\n { from: 3, to: 3, change: 0.05 },\n { from: 4, to: 4, change: 0 },\n { from: 5, to: 6, change: -0.05 },\n { from: 7, change: -0.1 },\n ],\n },\n];\n","import { quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { giftsOf, type SupplyCatalog } from \"./supplies.ts\";\n\n/*\n * This module has the food energy of a buy list, from the catalog of supplies. It gives the energy of each line and\n * their sum. The energy need of the members, the days of food and the shortfall are not in this package. The days\n * depend on the water and the fuel that a case leaves, so the model of the endurance of the stores gives them.\n */\n\n/** The unit of each food energy. */\nconst ENERGY_UNIT = \"kcal\";\n\n/**\n * The food energy of the units of one product of a buy list, or no read with the reason. A no read is not 0.\n * The resources are the codes of the gifts of the product, for example `food.no-cook` or `food.grain-dry`.\n */\nexport type BuyListEnergyLine =\n | { readonly product: string; readonly units: number; readonly resources: readonly string[]; readonly read: true; readonly energy: Quantity }\n | { readonly product: string; readonly units: number; readonly resources: readonly string[]; readonly read: false; readonly why: string };\n\n/** The food energy of a buy list. */\nexport interface BuyListEnergy {\n /** The food energy of each product of the list, in the order of the list. */\n readonly lines: readonly BuyListEnergyLine[];\n /** True when each line has a read. When it is false, `energy` is a lower limit. */\n readonly read: boolean;\n /** The sum of the food energy of the lines with a read, in `kcal`. */\n readonly energy: Quantity;\n}\n\n/**\n * This function gives the food energy of a buy list, from the catalog. The energy of each product is its field\n * `energy` times its count of units. Each line has the resources of the product. Thus a caller can split the energy\n * of `food.no-cook` from the energy of the dry food.\n *\n * - A product with a no read for its energy gives a line with no read. A no read is not 0.\n * - A food product with no field `energy` also gives a line with no read.\n * - A product of another kind is not food, for example water or a battery. It gives no line, also when it has a\n * field `energy`. The gate of the catalog refuses that field on a product that is not food.\n * - A product with 0 units gives no line.\n *\n * The list can be the `units` of a buy order.\n *\n * @param catalog - The catalog of supplies\n * @param units - The count of units of each product of the list, by the `id` of the product\n * @throws RangeError when a count of units is not a finite number of 0 or more, or when the catalog has no such product\n * @throws RangeError when a product gives a resource that the catalog does not have, as for `giftsOf`\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of an energy does not convert to `kcal`\n */\nexport function buyListEnergy(catalog: SupplyCatalog, units: Readonly<Record<string, number>>): BuyListEnergy {\n const lines: BuyListEnergyLine[] = [];\n for (const [id, count] of Object.entries(units)) {\n // `giftsOf` refuses a bad count of units and an unknown product.\n const resources = giftsOf(catalog, id, count).map((gift) => gift.resource);\n const product = catalog.products.find((each) => each.id === id);\n if (product === undefined || count === 0 || product.kind !== \"food\") continue;\n const energy = product.energy;\n if (energy === undefined) {\n lines.push({ product: id, units: count, resources, read: false, why: `The catalog has no food energy for the product ${id}.` });\n continue;\n }\n if (!energy.read) lines.push({ product: id, units: count, resources, read: false, why: energy.why });\n else lines.push({ product: id, units: count, resources, read: true, energy: quantity(count * valueIn(quantity(energy.amount, energy.unit), ENERGY_UNIT), ENERGY_UNIT) });\n }\n const total = lines.reduce((sum, line) => sum + (line.read ? line.energy.value : 0),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AQ,QAAQ,SAAS,OAAO,QAAQ,OAAO,IAAI,GAAG,WAAW,GAAG,WAAW;EAAE,CAAC;CACzK;CACA,MAAM,QAAQ,MAAM,QAAQ,KAAK,SAAS,OAAO,KAAK,OAAO,KAAK,OAAO,QAAQ,IAAI,CAAC;CACtF,OAAO;EAAE;EAAO,MAAM,MAAM,OAAO,SAAS,KAAK,IAAI;EAAG,QAAQ,SAAS,OAAO,WAAW;CAAE;AAC/F"}
1
+ {"version":3,"file":"supplies-entry.js","names":["ENERGY_UNIT"],"sources":["../src/supplies.ts","../src/supplies-data.ts","../src/food-plan.ts","../src/food-plan-data.ts","../src/buy-list-energy.ts"],"sourcesContent":["import { checkSources, checkUnits, type CitedUnit, type Finding, type FindingCode, type GateOptions, type Source } from \"@mark1russell7/guidebook\";\nimport { convertible, kindOf, quantity, valueIn, whyNotConvertible, type Quantity } from \"@mark1russell7/quantity\";\nimport { latestAverages, moneyOf, monthSchema, type AveragePrice } from \"./average.ts\";\nimport type { PartWant } from \"./offers.ts\";\nimport type { ProductWant } from \"./order.ts\";\n\n/*\n * This module is the format and the gate of a catalog of supplies: the products that a household keeps for an\n * emergency, the resource and the amount that one unit gives, and its shelf life. Each value has a cited fact, the\n * definition of the product, or an explicit no read. The facts and their sources are the records of\n * `@mark1russell7/guidebook`, and its gate examines them. The module names no person and no place.\n */\n\n/** The format of a catalog of supplies. */\nexport const SUPPLY_FORMAT = \"supply-catalog/1\";\n\n/** The kinds of the supplies. */\nexport const SUPPLY_KINDS = [\"water\", \"food\", \"power\", \"light\", \"heat\", \"first-aid\", \"communication\"] as const;\n\n/** A kind of a supply. */\nexport type SupplyKind = (typeof SUPPLY_KINDS)[number];\n\n/** A value that no source gives yet. The reason tells what is missing. */\nexport interface NoRead {\n readonly read: false;\n readonly why: string;\n}\n\n/**\n * An amount with its reason. The reason is a cited fact: the `id` of a unit of the catalog with the use `fact`.\n * Or it is the definition of the product, for example the 1 gal of a jug of 1 gal.\n */\nexport type CitedAmount =\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly fact: string; readonly definition?: never }\n | { readonly read: true; readonly amount: number; readonly unit: string; readonly definition: string; readonly fact?: never };\n\n/** A resource that a supply gives, with its unit, for example `water.stored` in `L`. The codes are the resource codes of a store. */\nexport interface SupplyResource {\n readonly code: string;\n readonly unit: string;\n readonly title: string;\n}\n\n/** The gift of one unit of a product: an amount of one resource, or no read. */\nexport interface SupplyGift {\n readonly resource: string;\n readonly amount: CitedAmount | NoRead;\n}\n\n/**\n * The shelf life of a product: a cited amount of time, the `id` of a product of the FoodKeeper data of USDA FSIS, or no read.\n * The entry `/foodkeeper` of `@mark1russell7/stock` gives the due rule of a FoodKeeper product.\n */\nexport type ShelfLife = CitedAmount | { readonly read: true; readonly foodKeeper: number } | NoRead;\n\n/**\n * The join of a product to a series of average prices. It names the source and the series. It also gives the amount\n * of the item of the series in one unit of the product. For example, 1 kg of dry rice is the amount of a series of\n * rice in USD/lb.\n */\nexport interface AverageJoin {\n readonly read: true;\n /** The source of the average prices, for example `bls-ap`. */\n readonly source: string;\n /** The id of the series in the source, for example `APU0000701312`. */\n readonly series: string;\n /** The amount of the item of the series in one unit of the product, with its reason. */\n readonly per: CitedAmount;\n}\n\n/** A product of the catalog. */\nexport interface SupplyProduct {\n readonly id: string;\n readonly title: string;\n readonly kind: SupplyKind;\n /** The part that the offers of a seller must match. A product with no part has no offer, so it has no price. */\n readonly want?: PartWant | undefined;\n /** The resources that one unit gives. A product that gives no stored resource, for example a radio, gives none. */\n readonly gives: readonly SupplyGift[];\n /** The `id` of a fact that tells why a kit has the product, for example the kit list of a public agency. */\n readonly basis?: string | undefined;\n /** The food energy of one unit, in a unit of energy. A cooking converter gives it. */\n readonly energy?: CitedAmount | NoRead | undefined;\n /**\n * The amount of one unit as sold: a mass, a volume or a count, for example 1 kg, 530 g or 1 gal.\n * A product with no known size has no field `size`. A no read is for a product that has a size, when the source\n * of the size is not read yet, for example a label.\n */\n readonly size?: CitedAmount | NoRead | undefined;\n readonly shelf: ShelfLife;\n /**\n * The series of average prices that gives the price of one unit, or no read with the reason. A product with no join\n * and no part has no price.\n */\n readonly average?: AverageJoin | NoRead | undefined;\n}\n\n/** A catalog of supplies: the sources, the cited facts, the resources and the products. */\nexport interface SupplyCatalog {\n readonly format: typeof SUPPLY_FORMAT;\n readonly sources: readonly Source[];\n readonly facts: readonly CitedUnit[];\n readonly resources: readonly SupplyResource[];\n readonly products: readonly SupplyProduct[];\n}\n\n/** The codes of the findings of the catalog gate. */\nexport const SUPPLY_CODES = [\n \"supplies-format\",\n \"supplies-twice\",\n \"supplies-kind\",\n \"supplies-resource\",\n \"supplies-fact\",\n \"supplies-basis\",\n \"supplies-amount\",\n \"supplies-unit\",\n \"supplies-shelf\",\n \"supplies-unused\",\n \"supplies-no-read\",\n \"supplies-no-reason\",\n] as const;\n\n/** A code of a finding of the catalog gate. */\nexport type SupplyCode = (typeof SUPPLY_CODES)[number];\n\n/** A finding of the catalog gate, or of the gate of the facts and their sources. */\nexport type SupplyFinding = Finding<SupplyCode | FindingCode, \"source\" | \"unit\" | \"resource\" | \"product\">;\n\n/**\n * The options of the catalog gate: the options of the gate of the sources, and the known FoodKeeper ids.\n */\nexport interface SupplyGateOptions extends GateOptions {\n /**\n * The ids of the products of the FoodKeeper data, for example the ids of `FOODKEEPER_PRODUCTS` of the entry\n * `/foodkeeper` of `@mark1russell7/stock`. With this option, a shelf life with an id that is not in the set is an\n * error. With no option, the gate does not examine the ids against the data.\n */\n readonly foodKeeper?: ReadonlySet<number> | readonly number[] | undefined;\n}\n\n/** This function tells if a text is a unit of `@mark1russell7/quantity`. `convertible` throws for an unknown unit. */\nfunction known(unit: unknown): boolean {\n if (typeof unit !== \"string\") return false;\n try {\n return convertible(unit, unit);\n } catch {\n return false;\n }\n}\n\n/** The unit that each food energy converts to. */\nconst ENERGY_UNIT = \"kcal\";\n/** The unit that each shelf life converts to. */\nconst SHELF_UNIT = \"d\";\n/**\n * This function gives true for the unit of a size. That is a mass or a volume that converts to `kg` or `L`, or one\n * bare count, for example `{each}`. The kind of a unit is not sufficient. For example, `g/{each}` has the kind\n * mass, and it does not convert to `kg`.\n */\nfunction sizeUnit(unit: string): boolean {\n return convertible(unit, \"kg\") || convertible(unit, \"L\") || (/^{[^{}/]+}$/.test(unit) && kindOf(unit) === \"count\");\n}\n\n/**\n * This function examines a catalog. It gives the findings of the sources and the facts (the gate of\n * `@mark1russell7/guidebook`), and the findings of the products:\n *\n * - An error for a product or a resource two times, a kind that is not a supply kind, and a gift of an unknown resource.\n * - An error for a product that gives no resource and has no basis.\n * - An error for a field `energy` on a product that is not food. The field is the food energy of one unit.\n * - An error for a fact that is not a fact of the catalog, and for an amount that is not more than 0. The basis of a\n * product is also a fact.\n * - An error for an amount with no reason, with two reasons, or with a blank definition. A catalog from JSON can have them.\n * - An error for a unit that is not a unit of `@mark1russell7/quantity`.\n * - An error for a unit that does not convert to the unit of its resource.\n * - An error for a size in a unit that is not a mass, a volume or a count, for example `h` or `kcal`.\n * - The amount of the item of an average price has the same checks as each other amount.\n * - With the option `foodKeeper`, an error for a FoodKeeper id of a shelf life that is not in the known ids.\n * - A warning for each value with no read, and for a no read with a blank reason.\n * - A warning for each fact and each source that no product uses.\n *\n * The function takes a decoded catalog: each record has the fields of its type. Decode a catalog from JSON first, for\n * example with the entry `/read` of `@mark1russell7/optional`. The gate then finds the values that the type does not hold.\n *\n * @param catalog - The catalog\n * @param options - The options of the gate of the sources, for example the date of the gate, and the known FoodKeeper ids\n */\nexport function checkSupplies(catalog: SupplyCatalog, options: SupplyGateOptions = {}): SupplyFinding[] {\n const { foodKeeper: knownFoodKeeper, ...gate } = options;\n const foodKeeper = knownFoodKeeper === undefined ? undefined : new Set<number>(knownFoodKeeper);\n const out: SupplyFinding[] = [...checkSources(catalog.sources, gate), ...checkUnits(catalog.facts, catalog.sources, gate)];\n const error = (code: SupplyCode, record: \"resource\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"error\", code, record, id, message });\n };\n const warning = (code: SupplyCode, record: \"source\" | \"unit\" | \"product\", id: string, message: string): void => {\n out.push({ level: \"warning\", code, record, id, message });\n };\n if (catalog.format !== SUPPLY_FORMAT) error(\"supplies-format\", \"product\", \"\", `The format is ${String(catalog.format)}. It must be ${SUPPLY_FORMAT}.`);\n\n const resources = new Map<string, SupplyResource>();\n for (const resource of catalog.resources) {\n if (resources.has(resource.code)) error(\"supplies-twice\", \"resource\", resource.code, `The resource ${resource.code} is two times in the catalog.`);\n if (!known(resource.unit)) error(\"supplies-unit\", \"resource\", resource.code, `The unit ${String(resource.unit)} of the resource ${resource.code} is not a known unit.`);\n resources.set(resource.code, resource);\n }\n const facts = new Map(catalog.facts.map((fact) => [fact.id, fact]));\n const used = new Set<string>();\n\n /** This function examines one cited amount, and gives the unit check to `units`. */\n const amount = (product: string, what: string, value: CitedAmount | NoRead, unit: string): void => {\n if (!value.read) {\n warning(\"supplies-no-read\", \"product\", product, `The ${what} of the product ${product} is no read: ${String(value.why)}`);\n if (typeof value.why !== \"string\" || value.why.trim() === \"\") warning(\"supplies-no-reason\", \"product\", product, `The no read of the ${what} of the product ${product} has no reason.`);\n return;\n }\n // The type permits one reason only. A catalog from JSON can have no reason, two reasons or a blank definition.\n const reasons = (value.fact === undefined ? 0 : 1) + (value.definition === undefined ? 0 : 1);\n if (reasons !== 1) error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} has ${String(reasons)} reasons. It must have a fact or a definition, not the two.`);\n else if (value.definition !== undefined && (typeof value.definition !== \"string\" || value.definition.trim() === \"\")) error(\"supplies-fact\", \"product\", product, `The definition of the ${what} of the product ${product} is blank.`);\n if (value.fact !== undefined) {\n const fact = facts.get(value.fact);\n if (fact === undefined || fact.use !== \"fact\") error(\"supplies-fact\", \"product\", product, `The ${what} of the product ${product} cites ${value.fact}, and the catalog has no fact with that id.`);\n used.add(value.fact);\n }\n if (!(Number.isFinite(value.amount) && value.amount > 0)) error(\"supplies-amount\", \"product\", product, `The ${what} of the product ${product} is ${String(value.amount)}. It must be a finite number more than 0.`);\n if (!known(value.unit)) error(\"supplies-unit\", \"product\", product, `The unit ${String(value.unit)} of the ${what} of the product ${product} is not a known unit.`);\n else if (known(unit) && !convertible(value.unit, unit)) error(\"supplies-unit\", \"product\", product, `The ${what} of the product ${product} is in ${value.unit}, and ${value.unit} does not convert to ${unit}.`);\n };\n\n const products = new Set<string>();\n for (const product of catalog.products) {\n if (products.has(product.id)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} is two times in the catalog.`);\n products.add(product.id);\n if (!(SUPPLY_KINDS as readonly string[]).includes(product.kind)) error(\"supplies-kind\", \"product\", product.id, `The kind ${String(product.kind)} of the product ${product.id} is not a supply kind.`);\n const gifts = new Set<string>();\n for (const gift of product.gives) {\n if (gifts.has(gift.resource)) error(\"supplies-twice\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource} two times.`);\n gifts.add(gift.resource);\n const resource = resources.get(gift.resource);\n if (resource === undefined) error(\"supplies-resource\", \"product\", product.id, `The product ${product.id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n else amount(product.id, `gift of ${gift.resource}`, gift.amount, resource.unit);\n }\n if (product.gives.length === 0 && product.basis === undefined) error(\"supplies-basis\", \"product\", product.id, `The product ${product.id} gives no resource and has no basis. A product that gives no resource cites a fact in its basis.`);\n if (product.basis !== undefined) {\n const fact = facts.get(product.basis);\n if (fact === undefined || fact.use !== \"fact\") error(\"supplies-fact\", \"product\", product.id, `The basis of the product ${product.id} cites ${String(product.basis)}, and the catalog has no fact with that id.`);\n used.add(product.basis);\n }\n // An unknown kind has its own error above, so this rule examines only a known kind that is not food.\n if (product.energy !== undefined && product.kind !== \"food\" && (SUPPLY_KINDS as readonly string[]).includes(product.kind)) error(\"supplies-kind\", \"product\", product.id, `The product ${product.id} has a food energy, and its kind is ${String(product.kind)}. Only a product of the kind food has a food energy.`);\n if (product.energy !== undefined) amount(product.id, \"food energy\", product.energy, ENERGY_UNIT);\n if (product.size !== undefined) {\n // The size has no single unit to convert to. Its unit must be a mass, a volume or one bare count. An unknown unit\n // has its own error.\n amount(product.id, \"size\", product.size, \"\");\n if (product.size.read && known(product.size.unit) && !sizeUnit(product.size.unit))\n error(\"supplies-unit\", \"product\", product.id, `The size of the product ${product.id} is in ${product.size.unit}. It must be a mass, a volume or a count.`);\n }\n if (product.average !== undefined) amount(product.id, \"average price\", product.average.read ? product.average.per : product.average, product.average.read ? product.average.per.unit : \"\");\n if (\"foodKeeper\" in product.shelf) {\n if (!(Number.isSafeInteger(product.shelf.foodKeeper) && product.shelf.foodKeeper > 0)) error(\"supplies-shelf\", \"product\", product.id, `The FoodKeeper id of the product ${product.id} is ${String(product.shelf.foodKeeper)}. It must be a whole number more than 0.`);\n else if (foodKeeper !== undefined && !foodKeeper.has(product.shelf.foodKeeper))\n error(\"supplies-shelf\", \"product\", product.id, `The FoodKeeper id ${String(product.shelf.foodKeeper)} of the product ${product.id} is not in the known FoodKeeper ids.`);\n } else amount(product.id, \"shelf life\", product.shelf, SHELF_UNIT);\n }\n\n for (const fact of catalog.facts) if (!used.has(fact.id)) warning(\"supplies-unused\", \"unit\", fact.id, `No product uses the fact ${fact.id}.`);\n const cited = new Set(catalog.facts.map((fact) => fact.source));\n for (const source of catalog.sources) if (!cited.has(source.id)) warning(\"supplies-unused\", \"source\", source.id, `No fact cites the source ${source.id}.`);\n return out;\n}\n\n/**\n * This function gives the wants of the products with a part, in the order of the catalog, for `buyCandidates`.\n * A product with no part has no offer, so it is not in the result.\n *\n * @param catalog - The catalog\n * @param max - The largest count of units of a product. The default is 1 for each product\n */\nexport function supplyWants(catalog: SupplyCatalog, max: (product: SupplyProduct) => number = () => 1): ProductWant[] {\n return catalog.products.flatMap((product) => (product.want === undefined ? [] : [{ product: product.id, want: product.want, max: max(product) }]));\n}\n\n/** The gift of a count of units: an amount in the unit of its resource, or no read. */\nexport type GiftOf = { readonly resource: string; readonly read: true; readonly amount: number; readonly unit: string } | { readonly resource: string; readonly read: false; readonly why: string };\n\n/**\n * This function gives the resources of a count of units of a product, each in the unit of its resource.\n * A gift with no read stays no read: it is not 0.\n *\n * @param catalog - The catalog\n * @param id - The `id` of the product\n * @param units - The count of units\n * @throws RangeError when the count of units is not a finite number of 0 or more\n * @throws RangeError when the catalog has no such product, or a gift of an unknown resource\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of a gift does not convert to the unit of its resource\n */\nexport function giftsOf(catalog: SupplyCatalog, id: string, units: number): GiftOf[] {\n if (!(Number.isFinite(units) && units >= 0)) throw new RangeError(`The count of units is ${String(units)}. It must be a finite number of 0 or more.`);\n const product = catalog.products.find((each) => each.id === id);\n if (product === undefined) throw new RangeError(`The catalog has no product ${id}.`);\n return product.gives.map((gift): GiftOf => {\n const resource = catalog.resources.find((each) => each.code === gift.resource);\n if (resource === undefined) throw new RangeError(`The product ${id} gives the resource ${gift.resource}, and the catalog has no such resource.`);\n if (!gift.amount.read) return { resource: gift.resource, read: false, why: gift.amount.why };\n return { resource: gift.resource, read: true, amount: units * valueIn(quantity(gift.amount.amount, gift.amount.unit), resource.unit), unit: resource.unit };\n });\n}\n\n/** The price of one unit of a product from an average price, or no read with the reason. */\nexport type SupplyPrice =\n | { readonly product: string; readonly read: true; readonly price: Quantity; readonly average: string; readonly period: string }\n | { readonly product: string; readonly read: false; readonly why: string };\n\n/**\n * This function gives the price of one unit of each product with a join to a series, in the order of the catalog.\n * It takes the last month of each series (`latestAverages`). The price is in the money of the average price.\n *\n * - A product with no join is not in the result.\n * - A join with no read, a series with no price, and a unit that does not fit give no read. A no read is not 0.\n * - The unit of the series must convert to the unit of the product, for example USD/lb to 1 kg.\n * - With the option `since`, a last price before that month gives no read. A series that stops then gives no old price.\n *\n * @param catalog - The catalog\n * @param prices - The average prices, from one or more reads\n * @param options - The option `since`: the first month of a price that the result can use, in the form `YYYY-MM`\n * @returns The price of one unit of each product with a join, or no read with the reason\n * @throws RangeError when `since` is not a month in the form `YYYY-MM`\n */\nexport function averageSupplyPrices(catalog: SupplyCatalog, prices: readonly AveragePrice[], options: { readonly since?: string | undefined } = {}): SupplyPrice[] {\n const { since } = options;\n if (since !== undefined && !monthSchema.safeParse(since).success) throw new RangeError(`The month ${String(since)} is not in the form YYYY-MM.`);\n const last = new Map(latestAverages(prices).map((price) => [`${price.source}:${price.series}`, price]));\n return catalog.products.flatMap((product): SupplyPrice[] => {\n const join = product.average;\n if (join === undefined) return [];\n const none = (why: string): SupplyPrice[] => [{ product: product.id, read: false, why }];\n if (!join.read) return none(join.why);\n const average = last.get(`${join.source}:${join.series}`);\n if (average === undefined) return none(`The prices have no average price of the series ${join.series} of ${join.source}.`);\n if (since !== undefined && average.period < since) return none(`The last average price of the series ${join.series} of ${join.source} is for ${average.period}, before ${since}.`);\n const money = moneyOf(average.price.unit);\n if (money === undefined) return none(`The unit ${average.price.unit} of ${average.id} is not a price for each unit of an amount.`);\n if (!known(join.per.unit)) return none(`The unit ${String(join.per.unit)} of the product ${product.id} is not a known unit.`);\n const unit = `${money}/${join.per.unit}`;\n const why = whyNotConvertible(average.price.unit, unit);\n if (why !== undefined) return none(`The average price ${average.id} is in ${average.price.unit}, and it does not convert to ${unit}: ${why}.`);\n const price = quantity(valueIn(average.price, unit) * join.per.amount, money);\n return [{ product: product.id, read: true, price, average: average.id, period: average.period }];\n });\n}\n","import { SUPPLY_FORMAT, type SupplyCatalog } from \"./supplies.ts\";\n\n// The reference catalog of supplies. Each value has a cited fact, the definition of the product, or a no read.\n// Each fact is in own words, not a quote. The shelf life of a food is a product of the FoodKeeper data of USDA FSIS:\n// the entry `/foodkeeper` of `@mark1russell7/stock` gives its due rule, so this catalog does not copy its times.\n\nconst CHECKED = \"2026-11-22\";\n\n/** The reference catalog of supplies. A household adds its own products to a copy of it. */\nexport const SUPPLY_CATALOG: SupplyCatalog = {\n format: SUPPLY_FORMAT,\n sources: [\n { id: \"ready.water\", title: \"Water\", url: \"https://www.ready.gov/water\", license: \"us-public-domain\", checked: CHECKED, by: \"FEMA (Ready.gov)\" },\n { id: \"ready.kit\", title: \"Build A Kit\", url: \"https://www.ready.gov/kit\", license: \"us-public-domain\", checked: CHECKED, by: \"FEMA (Ready.gov)\" },\n { id: \"fdc.sr-legacy\", title: \"FoodData Central, SR Legacy\", url: \"https://fdc.nal.usda.gov/\", license: \"cc0\", checked: CHECKED, by: \"USDA Agricultural Research Service\" },\n ],\n facts: [\n {\n id: \"ready.water-replace\",\n use: \"fact\",\n text: \"The page tells to replace the stored water that is not commercially bottled each six months.\",\n source: \"ready.water\",\n locator: \"Water storage\",\n },\n {\n id: \"fdc.rice-white\",\n use: \"fact\",\n text: \"The item 168877 (white long-grain rice, raw, enriched) gives 365 kcal in 100 g. Thus 1 kg gives 3650 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 168877\",\n },\n {\n id: \"fdc.oats\",\n use: \"fact\",\n text: \"The item 173904 (oats, regular and quick, not fortified, dry) gives 379 kcal in 100 g. Thus 1 kg gives 3790 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 173904\",\n },\n {\n id: \"fdc.beans-black\",\n use: \"fact\",\n text: \"The item 173734 (black beans, mature seeds, raw) gives 341 kcal in 100 g. Thus 1 kg gives 3410 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 173734\",\n },\n {\n id: \"fdc.peanut-butter\",\n use: \"fact\",\n text: \"The item 174266 (peanut butter, smooth style, with salt) gives 598 kcal in 100 g. Thus 1 kg gives 5980 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 174266\",\n },\n {\n id: \"fdc.pasta\",\n use: \"fact\",\n text: \"The item 168927 (pasta, dry, unenriched) gives 371 kcal in 100 g. Thus 1 kg gives 3710 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 168927\",\n },\n {\n id: \"fdc.flour-white\",\n use: \"fact\",\n text: \"The item 169761 (wheat flour, white, all-purpose, unenriched) gives 364 kcal in 100 g. Thus 1 kg gives 3640 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 169761\",\n },\n {\n id: \"fdc.soup-chicken-noodle\",\n use: \"fact\",\n text: \"The item 171148 (chunky chicken noodle soup, canned, ready-to-serve) gives 41 kcal in 100 g. Its portion of 1 can is 530 g. Thus 1 can gives 217.3 kcal.\",\n source: \"fdc.sr-legacy\",\n locator: \"FDC ID 171148, portion 1 can (530 g)\",\n },\n {\n id: \"ready.kit-flashlight\",\n use: \"fact\",\n text: \"The basic kit of the page has a flashlight and extra batteries.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-first-aid\",\n use: \"fact\",\n text: \"The basic kit of the page has a first aid kit.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-radio\",\n use: \"fact\",\n text: \"The basic kit of the page has a radio on batteries or a hand crank, and a NOAA Weather Radio with tone alert.\",\n source: \"ready.kit\",\n locator: \"Basic Disaster Supplies Kit\",\n },\n {\n id: \"ready.kit-sleeping-bag\",\n use: \"fact\",\n text: \"The page tells to add a sleeping bag or a warm blanket for each person.\",\n source: \"ready.kit\",\n locator: \"Additional Emergency Supplies\",\n },\n ],\n resources: [\n { code: \"water.stored\", unit: \"L\", title: \"Stored drinking water\" },\n { code: \"food.grain-dry\", unit: \"kg\", title: \"Dry grain, to cook with water and fuel\" },\n { code: \"food.legume-dry\", unit: \"kg\", title: \"Dry beans, to cook with water and fuel\" },\n { code: \"food.pasta-dry\", unit: \"kg\", title: \"Dry pasta, to boil in water that the cook drains\" },\n { code: \"food.flour\", unit: \"kg\", title: \"Flour, to bake or cook with water and fuel\" },\n { code: \"food.no-cook\", unit: \"kcal\", title: \"Food energy to eat with no water and no fuel\" },\n { code: \"energy.battery\", unit: \"Wh\", title: \"Energy in a battery\" },\n ],\n products: [\n {\n id: \"water.jug-1gal\",\n title: \"Drinking water, commercially bottled, in a jug of 1 gal\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a jug of 1 gal.\" } }],\n size: { read: true, amount: 1, unit: \"gal\", definition: \"The catalog item is defined as a jug of 1 gal.\" },\n shelf: { read: false, why: \"The source tells to keep commercially bottled water sealed, and it gives no time. The date on the label applies.\" },\n },\n {\n id: \"water.container-1gal\",\n title: \"A water container of 1 gal, filled from the tap\",\n kind: \"water\",\n gives: [{ resource: \"water.stored\", amount: { read: true, amount: 1, unit: \"gal\", definition: \"The product is a container of 1 gal.\" } }],\n shelf: { read: true, amount: 6, unit: \"mo\", fact: \"ready.water-replace\" },\n },\n {\n id: \"food.rice-white-1kg\",\n title: \"White long-grain rice, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry rice.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry rice.\" },\n energy: { read: true, amount: 3650, unit: \"kcal\", fact: \"fdc.rice-white\" },\n shelf: { read: true, foodKeeper: 338 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701312\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry white long-grain rice, the item of the series.\" },\n },\n },\n {\n id: \"food.oats-1kg\",\n title: \"Rolled oats, dry, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.grain-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry oats.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry oats.\" },\n energy: { read: true, amount: 3790, unit: \"kcal\", fact: \"fdc.oats\" },\n shelf: { read: true, foodKeeper: 375 },\n average: { read: false, why: \"The known series of average prices have no series of oats yet.\" },\n },\n {\n id: \"food.beans-dry-1kg\",\n title: \"Dry beans, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.legume-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry beans.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry beans.\" },\n energy: { read: true, amount: 3410, unit: \"kcal\", fact: \"fdc.beans-black\" },\n shelf: { read: true, foodKeeper: 333 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000714233\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry beans of any type, the item of the series.\" },\n },\n },\n {\n id: \"food.peanut-butter-1kg\",\n title: \"Peanut butter, smooth, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.no-cook\", amount: { read: true, amount: 5980, unit: \"kcal\", fact: \"fdc.peanut-butter\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of peanut butter.\" },\n energy: { read: true, amount: 5980, unit: \"kcal\", fact: \"fdc.peanut-butter\" },\n shelf: { read: true, foodKeeper: 387 },\n average: { read: false, why: \"The known series of average prices have no series of peanut butter yet.\" },\n },\n {\n id: \"food.pasta-dry-1kg\",\n title: \"Dry pasta, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.pasta-dry\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry pasta.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of dry pasta.\" },\n energy: { read: true, amount: 3710, unit: \"kcal\", fact: \"fdc.pasta\" },\n shelf: { read: true, foodKeeper: 335 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701322\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of dry spaghetti or macaroni, the item of the series.\" },\n },\n },\n {\n id: \"food.flour-white-1kg\",\n title: \"White all-purpose flour, 1 kg\",\n kind: \"food\",\n gives: [{ resource: \"food.flour\", amount: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of white flour.\" } }],\n size: { read: true, amount: 1, unit: \"kg\", definition: \"The catalog item is defined as a package of 1 kg of white flour.\" },\n energy: { read: true, amount: 3640, unit: \"kcal\", fact: \"fdc.flour-white\" },\n shelf: { read: true, foodKeeper: 222 },\n average: {\n read: true,\n source: \"bls-ap\",\n series: \"APU0000701111\",\n per: { read: true, amount: 1, unit: \"kg\", definition: \"The product is 1 kg of white all-purpose flour, the item of the series.\" },\n },\n },\n {\n id: \"food.soup-can\",\n title: \"Chunky chicken noodle soup, ready-to-serve, 1 can (530 g)\",\n kind: \"food\",\n gives: [{ resource: \"food.no-cook\", amount: { read: true, amount: 217.3, unit: \"kcal\", fact: \"fdc.soup-chicken-noodle\" } }],\n size: { read: true, amount: 530, unit: \"g\", fact: \"fdc.soup-chicken-noodle\" },\n energy: { read: true, amount: 217.3, unit: \"kcal\", fact: \"fdc.soup-chicken-noodle\" },\n shelf: { read: true, foodKeeper: 372 },\n average: { read: false, why: \"The known series of average prices have no series of canned soup yet.\" },\n },\n {\n id: \"light.flashlight\",\n title: \"A flashlight on batteries\",\n kind: \"light\",\n basis: \"ready.kit-flashlight\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life. The batteries have the date on their label.\" },\n },\n {\n id: \"heat.sleeping-bag\",\n title: \"A sleeping bag for each person\",\n kind: \"heat\",\n basis: \"ready.kit-sleeping-bag\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life.\" },\n },\n {\n id: \"first-aid.kit\",\n title: \"A first aid kit\",\n kind: \"first-aid\",\n basis: \"ready.kit-first-aid\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life. Each item of the kit has the date on its label.\" },\n },\n {\n id: \"communication.noaa-radio\",\n title: \"A NOAA Weather Radio with tone alert, on batteries or a hand crank\",\n kind: \"communication\",\n basis: \"ready.kit-radio\",\n gives: [],\n shelf: { read: false, why: \"The source gives no shelf life.\" },\n },\n {\n id: \"power.anker-737\",\n title: \"Anker 737 Power Bank (PowerCore 24K)\",\n kind: \"power\",\n want: { brands: [\"Anker\"], partNumbers: [\"A1289\"] },\n gives: [{ resource: \"energy.battery\", amount: { read: false, why: \"The page of the maker gives 24,000 mAh and no Wh. A charge does not convert to energy without its voltage.\" } }],\n shelf: { read: false, why: \"No source is read yet.\" },\n },\n ],\n};\n","import type { Source } from \"@mark1russell7/guidebook\";\nimport { convertible, quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { moneyAbove } from \"./average.ts\";\n\n/** This function gives the money of a cost for each unit of time, for example `USD` for `USD/wk`. */\nfunction moneyOfRate(unit: string): string | undefined {\n const money = moneyAbove(unit);\n return money !== undefined && convertible(unit, `${money}/d`) ? money : undefined;\n}\n\n/*\n * This module has the cost of a food plan: the cost of the food of one week for one person of each age and sex, from\n * an official source. A check compares the food of a buy list with the cost of the plan for the same people and days.\n * The module names no person. The members of a household are input data.\n */\n\n/** The age and sex groups of a food plan of USDA. */\nexport const FOOD_PLAN_GROUPS = [\n \"child-1\",\n \"child-2-3\",\n \"child-4-5\",\n \"child-6-8\",\n \"child-9-11\",\n \"female-12-13\",\n \"female-14-19\",\n \"female-20-50\",\n \"female-51-70\",\n \"female-71-up\",\n \"male-12-13\",\n \"male-14-19\",\n \"male-20-50\",\n \"male-51-70\",\n \"male-71-up\",\n] as const;\n\n/** An age and sex group of a food plan. */\nexport type FoodPlanGroup = (typeof FOOD_PLAN_GROUPS)[number];\n\n/** The change of the cost for a size of household, for example 0.2 for one person. */\nexport interface FoodPlanSize {\n /** The smallest count of persons. */\n readonly from: number;\n /** The largest count of persons. Without it, the change applies to each larger household. */\n readonly to?: number | undefined;\n /** The change of the cost, as a fraction: 0.2 adds 20 percent, and -0.05 subtracts 5 percent. */\n readonly change: number;\n}\n\n/** The cost of a food plan in one area and one month, from one source. */\nexport interface FoodPlan {\n /** The id, for example `usda.thrifty:2026-10`. */\n readonly id: string;\n readonly title: string;\n /** The area, as the source names it, for example `U.S. average`. */\n readonly area: string;\n /** The month of the costs, in the form `YYYY-MM`. */\n readonly period: string;\n readonly source: Source;\n /** The place of the table in the source. */\n readonly locator: string;\n /** The cost of the food of one week for one person of each group, for example `{ \"value\": 58.7, \"unit\": \"USD/wk\" }`. */\n readonly weekly: Readonly<Record<FoodPlanGroup, Quantity>>;\n /** The change of the cost for each size of household. The costs of `weekly` are for the size with the change 0. */\n readonly sizes: readonly FoodPlanSize[];\n}\n\n/** A group of the members of a household, and the count of its persons. */\nexport interface FoodPlanMember {\n readonly group: FoodPlanGroup;\n readonly count: number;\n}\n\n/** The result of a check of the cost of food against a food plan. */\nexport interface FoodPlanCheck {\n /** The cost of the plan for the same members and days. */\n readonly plan: Quantity;\n /** The cost of the food, in the money of the plan. */\n readonly cost: Quantity;\n /** The cost of the food divided by the cost of the plan. */\n readonly ratio: number;\n /**\n * True when the food costs more than the plan. The Thrifty plan is the lowest of the four plans of USDA. Thus a list\n * above the cost of the Thrifty plan is not wrong when it has foods that cost more than staples.\n */\n readonly above: boolean;\n}\n\n/**\n * This function gives the cost of a food plan for the members of a household and a count of days. It adds the cost of\n * each person, and then it applies the change for the size of the household.\n *\n * @param plan - The food plan\n * @param members - The groups of the members of the household, each with its count of persons\n * @param days - The count of days, a finite number of 0 or more\n * @throws RangeError when a count of persons is not a whole number of 0 or more, or when the household has no person\n * @throws RangeError when a group is not in the plan, or when the plan has no change for the size of the household\n * @throws RangeError when the count of days is not a finite number of 0 or more\n */\nexport function foodPlanCost(plan: FoodPlan, members: readonly FoodPlanMember[], days: number): Quantity {\n if (!(Number.isFinite(days) && days >= 0)) throw new RangeError(`The count of days is ${String(days)}. It must be a finite number of 0 or more.`);\n let persons = 0;\n let money: string | undefined;\n let total = 0;\n for (const member of members) {\n if (!(Number.isSafeInteger(member.count) && member.count >= 0)) throw new RangeError(`The count of the group ${member.group} is ${String(member.count)}. It must be a whole number of 0 or more.`);\n const weekly = plan.weekly[member.group] as Quantity | undefined;\n const symbol = weekly === undefined ? undefined : moneyOfRate(weekly.unit);\n if (weekly === undefined || symbol === undefined) throw new RangeError(`The plan ${plan.id} has no cost for each unit of time of the group ${String(member.group)}.`);\n if (money !== undefined && symbol !== money) throw new RangeError(`The plan ${plan.id} has costs in ${money} and in ${symbol}.`);\n money = symbol;\n persons += member.count;\n total += member.count * valueIn(weekly, `${symbol}/d`) * days;\n }\n if (persons === 0 || money === undefined) throw new RangeError(\"The household has no person.\");\n const size = plan.sizes.find((each) => persons >= each.from && (each.to === undefined || persons <= each.to));\n if (size === undefined) throw new RangeError(`The plan ${plan.id} has no change for a household of ${String(persons)} persons.`);\n return quantity(total * (1 + size.change), money);\n}\n\n/**\n * This function compares the cost of the food of a buy list with the cost of a food plan for the same members and\n * days. A list of dry staples costs less than the plan, because the plan is a full diet. A ratio above 1 tells that\n * a price or an amount of the list is possibly wrong. A low ratio is normal, because a list can be any part of a diet.\n * The check of the amount of food is a check of its energy, not of its cost.\n *\n * @param cost - The cost of the food, in a money that converts to the money of the plan\n * @param plan - The food plan\n * @param members - The groups of the members of the household, each with its count of persons\n * @param days - The count of days of the food\n * @throws RangeError for the errors of `foodPlanCost`\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the money of the cost does not convert to the money of the plan\n */\nexport function foodPlanCheck(cost: Quantity, plan: FoodPlan, members: readonly FoodPlanMember[], days: number): FoodPlanCheck {\n const planned = foodPlanCost(plan, members, days);\n const value = valueIn(cost, planned.unit);\n const ratio = planned.value === 0 ? (value === 0 ? 0 : Number.POSITIVE_INFINITY) : value / planned.value;\n return { plan: planned, cost: quantity(value, planned.unit), ratio, above: ratio > 1 };\n}\n","import type { FoodPlan } from \"./food-plan.ts\";\n\n// The costs of the food plans of USDA. Each value is from the table of the report, read on 2026-11-22. The report\n// rounds each weekly cost to 10 cents. Footnote 2 of the report gives the change for each size of household.\n\nconst week = (value: number): { readonly value: number; readonly unit: string } => ({ value, unit: \"USD/wk\" });\n\n/** The costs of the food plans of USDA, one record for each plan and month. */\nexport const FOOD_PLANS: readonly FoodPlan[] = [\n {\n id: \"usda.thrifty:2026-10\",\n title: \"Official USDA Thrifty Food Plan: U.S. Average, October 2026\",\n area: \"U.S. average\",\n period: \"2026-10\",\n source: {\n id: \"usda.food-plans\",\n title: \"USDA Food Plans: Monthly Cost of Food Reports\",\n url: \"https://www.fna.usda.gov/research/cnpp/usda-food-plans/cost-food-monthly-reports\",\n license: \"us-public-domain\",\n checked: \"2026-11-22\",\n by: \"USDA Food and Nutrition Administration\",\n },\n locator: \"CostofFoodOct2026Thrifty.pdf, the column Weekly Cost of the table of age-sex groups\",\n weekly: {\n \"child-1\": week(26.4),\n \"child-2-3\": week(39.8),\n \"child-4-5\": week(43.5),\n \"child-6-8\": week(48.3),\n \"child-9-11\": week(55.8),\n \"female-12-13\": week(51.7),\n \"female-14-19\": week(60.1),\n \"female-20-50\": week(58.7),\n \"female-51-70\": week(54.6),\n \"female-71-up\": week(60.3),\n \"male-12-13\": week(59.7),\n \"male-14-19\": week(75.3),\n \"male-20-50\": week(73.7),\n \"male-51-70\": week(65),\n \"male-71-up\": week(62),\n },\n sizes: [\n { from: 1, to: 1, change: 0.2 },\n { from: 2, to: 2, change: 0.1 },\n { from: 3, to: 3, change: 0.05 },\n { from: 4, to: 4, change: 0 },\n { from: 5, to: 6, change: -0.05 },\n { from: 7, change: -0.1 },\n ],\n },\n];\n","import { quantity, valueIn, type Quantity } from \"@mark1russell7/quantity\";\nimport { giftsOf, type SupplyCatalog } from \"./supplies.ts\";\n\n/*\n * This module has the food energy of a buy list, from the catalog of supplies. It gives the energy of each line and\n * their sum. The energy need of the members, the days of food and the shortfall are not in this package. The days\n * depend on the water and the fuel that a case leaves, so the model of the endurance of the stores gives them.\n */\n\n/** The unit of each food energy. */\nconst ENERGY_UNIT = \"kcal\";\n\n/**\n * The food energy of the units of one product of a buy list, or no read with the reason. A no read is not 0.\n * The resources are the codes of the gifts of the product, for example `food.no-cook` or `food.grain-dry`.\n */\nexport type BuyListEnergyLine =\n | { readonly product: string; readonly units: number; readonly resources: readonly string[]; readonly read: true; readonly energy: Quantity }\n | { readonly product: string; readonly units: number; readonly resources: readonly string[]; readonly read: false; readonly why: string };\n\n/** The food energy of a buy list. */\nexport interface BuyListEnergy {\n /** The food energy of each product of the list, in the order of the list. */\n readonly lines: readonly BuyListEnergyLine[];\n /** True when each line has a read. When it is false, `energy` is a lower limit. */\n readonly read: boolean;\n /** The sum of the food energy of the lines with a read, in `kcal`. */\n readonly energy: Quantity;\n}\n\n/**\n * This function gives the food energy of a buy list, from the catalog. The energy of each product is its field\n * `energy` times its count of units. Each line has the resources of the product. Thus a caller can split the energy\n * of `food.no-cook` from the energy of the dry food.\n *\n * - A product with a no read for its energy gives a line with no read. A no read is not 0.\n * - A food product with no field `energy` also gives a line with no read.\n * - A product of another kind is not food, for example water or a battery. It gives no line, also when it has a\n * field `energy`. The gate of the catalog refuses that field on a product that is not food.\n * - A product with 0 units gives no line.\n *\n * The list can be the `units` of a buy order.\n *\n * @param catalog - The catalog of supplies\n * @param units - The count of units of each product of the list, by the `id` of the product\n * @throws RangeError when a count of units is not a finite number of 0 or more, or when the catalog has no such product\n * @throws RangeError when a product gives a resource that the catalog does not have, as for `giftsOf`\n * @throws The error of `valueIn` of `@mark1russell7/quantity` when the unit of an energy does not convert to `kcal`\n */\nexport function buyListEnergy(catalog: SupplyCatalog, units: Readonly<Record<string, number>>): BuyListEnergy {\n const lines: BuyListEnergyLine[] = [];\n for (const [id, count] of Object.entries(units)) {\n // `giftsOf` refuses a bad count of units and an unknown product.\n const resources = giftsOf(catalog, id, count).map((gift) => gift.resource);\n const product = catalog.products.find((each) => each.id === id);\n if (product === undefined || count === 0 || product.kind !== \"food\") continue;\n const energy = product.energy;\n if (energy === undefined) {\n lines.push({ product: id, units: count, resources, read: false, why: `The catalog has no food energy for the product ${id}.` });\n continue;\n }\n if (!energy.read) lines.push({ product: id, units: count, resources, read: false, why: energy.why });\n else lines.push({ product: id, units: count, resources, read: true, energy: quantity(count * valueIn(quantity(energy.amount, energy.unit), ENERGY_UNIT), ENERGY_UNIT) });\n }\n const total = lines.reduce((sum, line) => sum + (line.read ? line.energy.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;GACxB,MAAM,KAAK;IAAE,SAAS;IAAI,OAAO;IAAO;IAAW,MAAM;IAAO,KAAK,kDAAkD,GAAG;GAAG,CAAC;GAC9H;EACF;EACA,IAAI,CAAC,OAAO,MAAM,MAAM,KAAK;GAAE,SAAS;GAAI,OAAO;GAAO;GAAW,MAAM;GAAO,KAAK,OAAO;EAAI,CAAC;OAC9F,MAAM,KAAK;GAAE,SAAS;GAAI,OAAO;GAAO;GAAW,MAAM;GAAM,QAAQ,SAAS,QAAQ,QAAQ,SAAS,OAAO,QAAQ,OAAO,IAAI,GAAG,WAAW,GAAG,WAAW;EAAE,CAAC;CACzK;CACA,MAAM,QAAQ,MAAM,QAAQ,KAAK,SAAS,OAAO,KAAK,OAAO,KAAK,OAAO,QAAQ,IAAI,CAAC;CACtF,OAAO;EAAE;EAAO,MAAM,MAAM,OAAO,SAAS,KAAK,IAAI;EAAG,QAAQ,SAAS,OAAO,WAAW;CAAE;AAC/F"}
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.3.1",
4
+ "version": "0.3.2",
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": {
@@ -51,7 +51,7 @@
51
51
  ],
52
52
  "dependencies": {
53
53
  "@mark1russell7/guidebook": "^0.1.1",
54
- "@mark1russell7/quantity": "^0.4.0",
54
+ "@mark1russell7/quantity": "^0.4.4",
55
55
  "@mark1russell7/strategy-search": "^0.1.2",
56
56
  "@mark1russell7/strategy-space": "^0.1.0",
57
57
  "@mark1russell7/vex": "^0.19.1",
@@ -60,6 +60,7 @@
60
60
  },
61
61
  "devDependencies": {
62
62
  "@mark1russell7/cue": "^2.0.0",
63
+ "@mark1russell7/stock": "^0.3.0",
63
64
  "@types/node": "^26.6.5",
64
65
  "@vitest/coverage-v8": "^5.0.3",
65
66
  "fast-check": "^4.10.2",