@utilix-tech/sdk 0.22.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1139,13 +1139,186 @@ function jsonArrayToNdjson(input) {
1139
1139
  if (!Array.isArray(parsed)) return { error: "Input must be a JSON array" };
1140
1140
  return parsed.map((item) => JSON.stringify(item)).join("\n");
1141
1141
  }
1142
+ var _SUBTITLE_TIMESTAMP_RE = /(\d+):(\d{1,2}):(\d{1,2})[.,](\d{1,3})|(\d{1,3}):(\d{1,2})[.,](\d{1,3})/;
1143
+ var _VTT_BLOCK_KEYWORDS = ["NOTE", "STYLE", "REGION"];
1144
+ function parseSubtitleTimestamp(raw) {
1145
+ const m = _SUBTITLE_TIMESTAMP_RE.exec(raw.trim());
1146
+ if (!m || m.index !== 0) return null;
1147
+ let hours;
1148
+ let minutes;
1149
+ let seconds;
1150
+ let millis;
1151
+ if (m[1] !== void 0) {
1152
+ hours = Number(m[1]);
1153
+ minutes = Number(m[2]);
1154
+ seconds = Number(m[3]);
1155
+ millis = m[4];
1156
+ } else {
1157
+ hours = 0;
1158
+ minutes = Number(m[5]);
1159
+ seconds = Number(m[6]);
1160
+ millis = m[7];
1161
+ }
1162
+ if (minutes > 59 || seconds > 59) return null;
1163
+ return hours * 3600 + minutes * 60 + seconds + Number(millis.padEnd(3, "0")) / 1e3;
1164
+ }
1165
+ function formatSubtitleTimestamp(totalSeconds, format) {
1166
+ const totalMs = Math.round(Math.max(0, totalSeconds) * 1e3);
1167
+ const ms = totalMs % 1e3;
1168
+ const totalSecs = Math.floor(totalMs / 1e3);
1169
+ const pad = (n, width = 2) => String(n).padStart(width, "0");
1170
+ return `${pad(Math.floor(totalSecs / 3600))}:${pad(Math.floor(totalSecs / 60) % 60)}:${pad(totalSecs % 60)}${format === "srt" ? "," : "."}${pad(ms, 3)}`;
1171
+ }
1172
+ function _stripBom(input) {
1173
+ return input.charCodeAt(0) === 65279 ? input.slice(1) : input;
1174
+ }
1175
+ function detectSubtitleFormat(input) {
1176
+ const text = _stripBom(input).trimStart();
1177
+ if (/^WEBVTT/.test(text)) return "vtt";
1178
+ const arrow = /(\d{1,3}):(\d{1,2})(?::(\d{1,2}))?([.,])(\d{1,3})\s*-->/.exec(text);
1179
+ if (arrow && arrow[4] === ".") return "vtt";
1180
+ return "srt";
1181
+ }
1182
+ function parseSubtitles(input, format) {
1183
+ if (typeof input !== "string" || input.trim().length === 0) {
1184
+ return { error: "Subtitle input is empty" };
1185
+ }
1186
+ const sourceFormat = format ?? detectSubtitleFormat(input);
1187
+ const normalised = _stripBom(input).replace(/\r\n?/g, "\n");
1188
+ const warnings = [];
1189
+ let body = normalised;
1190
+ if (sourceFormat === "vtt") {
1191
+ const headerMatch = /^WEBVTT[^\n]*\n?/.exec(body.trimStart());
1192
+ if (headerMatch) {
1193
+ body = body.trimStart().slice(headerMatch[0].length);
1194
+ } else {
1195
+ warnings.push('WebVTT input is missing its "WEBVTT" header line');
1196
+ }
1197
+ }
1198
+ const blocks = body.split(/\n[ \t]*\n+/).map((b) => b.trim()).filter((b) => b.length > 0);
1199
+ const cues = [];
1200
+ for (const block of blocks) {
1201
+ const lines = block.split("\n");
1202
+ const arrowIdx = lines.findIndex((l) => l.includes("-->"));
1203
+ if (arrowIdx === -1) {
1204
+ const keyword = _VTT_BLOCK_KEYWORDS.find((k) => lines[0] === k || lines[0].startsWith(`${k} `));
1205
+ if (sourceFormat === "vtt" && keyword) {
1206
+ warnings.push(`Dropped a WebVTT ${keyword} block, which has no SRT equivalent`);
1207
+ } else {
1208
+ warnings.push(`Skipped a block with no "-->" timing line: ${JSON.stringify(lines[0].slice(0, 40))}`);
1209
+ }
1210
+ continue;
1211
+ }
1212
+ const timingLine = lines[arrowIdx];
1213
+ const parts = timingLine.split("-->");
1214
+ const start = parseSubtitleTimestamp(parts[0] ?? "");
1215
+ const rightTrimmed = (parts[1] ?? "").trim();
1216
+ const end = parseSubtitleTimestamp(rightTrimmed);
1217
+ if (start === null || end === null) {
1218
+ warnings.push(`Skipped a cue with an unparseable timing line: ${JSON.stringify(timingLine.slice(0, 60))}`);
1219
+ continue;
1220
+ }
1221
+ const endMatch = _SUBTITLE_TIMESTAMP_RE.exec(rightTrimmed);
1222
+ const settings = endMatch ? rightTrimmed.slice(endMatch[0].length).trim() : "";
1223
+ const idLines = lines.slice(0, arrowIdx).filter((l) => l.trim().length > 0);
1224
+ const text = lines.slice(arrowIdx + 1).join("\n").trim();
1225
+ const cue = { index: cues.length + 1, start, end, text };
1226
+ if (sourceFormat === "vtt" && idLines.length > 0) cue.id = idLines[idLines.length - 1].trim();
1227
+ if (settings.length > 0) cue.settings = settings;
1228
+ if (end < start) warnings.push(`Cue ${cue.index} ends before it starts`);
1229
+ if (text.length === 0) warnings.push(`Cue ${cue.index} has no text`);
1230
+ if (cues.length > 0 && start < cues[cues.length - 1].end) {
1231
+ warnings.push(`Cue ${cue.index} starts before cue ${cue.index - 1} ends (overlapping cues)`);
1232
+ }
1233
+ cues.push(cue);
1234
+ }
1235
+ if (cues.length === 0) {
1236
+ return { error: "No subtitle cues found: check that the input is a valid SRT or WebVTT file" };
1237
+ }
1238
+ return {
1239
+ format: sourceFormat,
1240
+ cues,
1241
+ cueCount: cues.length,
1242
+ duration: Math.round(Math.max(...cues.map((c) => c.end)) * 1e3) / 1e3,
1243
+ warnings
1244
+ };
1245
+ }
1246
+ function serializeSubtitles(cues, format) {
1247
+ const blocks = cues.map((cue, i) => {
1248
+ const time = `${formatSubtitleTimestamp(cue.start, format)} --> ${formatSubtitleTimestamp(cue.end, format)}`;
1249
+ if (format === "srt") return `${i + 1}
1250
+ ${time}
1251
+ ${cue.text}`;
1252
+ const timing = cue.settings ? `${time} ${cue.settings}` : time;
1253
+ return cue.id ? `${cue.id}
1254
+ ${timing}
1255
+ ${cue.text}` : `${timing}
1256
+ ${cue.text}`;
1257
+ });
1258
+ const body = blocks.join("\n\n");
1259
+ return format === "vtt" ? `WEBVTT
1260
+
1261
+ ${body}
1262
+ ` : `${body}
1263
+ `;
1264
+ }
1265
+ function convertSubtitles(input, target, sourceFormat) {
1266
+ if (target !== "srt" && target !== "vtt") return { error: 'target must be "srt" or "vtt"' };
1267
+ const parsed = parseSubtitles(input, sourceFormat);
1268
+ if ("error" in parsed) return parsed;
1269
+ const warnings = [...parsed.warnings];
1270
+ if (target === "srt") {
1271
+ const droppedSettings = parsed.cues.filter((c) => c.settings).length;
1272
+ const droppedIds = parsed.cues.filter((c) => c.id).length;
1273
+ if (droppedSettings > 0) {
1274
+ warnings.push(`Dropped WebVTT cue settings on ${droppedSettings} cue(s): SRT has no equivalent`);
1275
+ }
1276
+ if (droppedIds > 0) {
1277
+ warnings.push(`Dropped ${droppedIds} WebVTT cue identifier(s): SRT numbers cues sequentially instead`);
1278
+ }
1279
+ }
1280
+ return {
1281
+ format: target,
1282
+ sourceFormat: parsed.format,
1283
+ output: serializeSubtitles(parsed.cues, target),
1284
+ cueCount: parsed.cueCount,
1285
+ duration: parsed.duration,
1286
+ warnings
1287
+ };
1288
+ }
1289
+ function shiftSubtitles(input, offsetSeconds, target) {
1290
+ if (!Number.isFinite(offsetSeconds)) return { error: "offsetSeconds must be a finite number" };
1291
+ const parsed = parseSubtitles(input);
1292
+ if ("error" in parsed) return parsed;
1293
+ const warnings = [...parsed.warnings];
1294
+ let clamped = 0;
1295
+ const shifted = parsed.cues.map((cue) => {
1296
+ const start = cue.start + offsetSeconds;
1297
+ const end = cue.end + offsetSeconds;
1298
+ if (start < 0) clamped += 1;
1299
+ return { ...cue, start: Math.max(0, start), end: Math.max(0, end) };
1300
+ });
1301
+ if (clamped > 0) warnings.push(`${clamped} cue(s) would start before zero and were clamped to 00:00:00`);
1302
+ const outFormat = target ?? parsed.format;
1303
+ return {
1304
+ format: outFormat,
1305
+ sourceFormat: parsed.format,
1306
+ output: serializeSubtitles(shifted, outFormat),
1307
+ cueCount: shifted.length,
1308
+ duration: Math.round(Math.max(...shifted.map((c) => c.end)) * 1e3) / 1e3,
1309
+ warnings
1310
+ };
1311
+ }
1142
1312
 
1313
+ exports.convertSubtitles = convertSubtitles;
1143
1314
  exports.csvToJson = csvToJson;
1144
1315
  exports.detectDelimiter = detectDelimiter;
1316
+ exports.detectSubtitleFormat = detectSubtitleFormat;
1145
1317
  exports.diffEnvExample = diffEnvExample;
1146
1318
  exports.envToExport = envToExport;
1147
1319
  exports.envToJson = envToJson;
1148
1320
  exports.formatNdjson = formatNdjson;
1321
+ exports.formatSubtitleTimestamp = formatSubtitleTimestamp;
1149
1322
  exports.formatToml = formatToml;
1150
1323
  exports.formatXml = formatXml;
1151
1324
  exports.getSection = getSection;
@@ -1165,7 +1338,11 @@ exports.ndjsonToJsonArray = ndjsonToJsonArray;
1165
1338
  exports.parseCsv = parseCsv;
1166
1339
  exports.parseEnv = parseEnv;
1167
1340
  exports.parseIni = parseIni;
1341
+ exports.parseSubtitleTimestamp = parseSubtitleTimestamp;
1342
+ exports.parseSubtitles = parseSubtitles;
1168
1343
  exports.parseXmlToObject = parseXmlToObject;
1344
+ exports.serializeSubtitles = serializeSubtitles;
1345
+ exports.shiftSubtitles = shiftSubtitles;
1169
1346
  exports.stringifyIni = stringifyIni;
1170
1347
  exports.toCsvString = toCsvString;
1171
1348
  exports.tomlToJson = tomlToJson;
@@ -1 +1 @@
1
- export { C as CsvParseResult, E as EnvDiffError, a as EnvDiffResult, b as EnvEntry, c as EnvParseResult, I as IniSection, N as NdjsonLineResult, e as NdjsonValidateResult, P as ParseOptions, f as ParsedIni, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, g as XmlToJsonOptions, h as csvToJson, i as detectDelimiter, j as diffEnvExample, k as envToExport, l as envToJson, m as formatNdjson, n as formatToml, o as formatXml, p as getSection, q as getSectionNames, r as getTomlStats, s as getXmlStats, t as getYamlStats, u as iniToJson, v as jsonArrayToNdjson, w as jsonToIni, x as jsonToToml, y as jsonToXml, z as minifyNdjson, A as minifyToml, B as minifyXml, D as ndjsonToJsonArray, F as parseCsv, G as parseEnv, H as parseIni, J as parseXmlToObject, K as stringifyIni, L as toCsvString, M as tomlToJson, O as validateEnvKey, Q as validateIni, R as validateNdjson, S as validateToml, U as validateXml, W as validateYaml, Y as xmlToJson } from '../data-D8XTI7Du.cjs';
1
+ export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, I as IniSection, N as NdjsonLineResult, f as NdjsonValidateResult, P as ParseOptions, g as ParsedIni, h as ParsedSubtitles, S as SubtitleCue, i as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, j as XmlToJsonOptions, k as convertSubtitles, l as csvToJson, m as detectDelimiter, n as detectSubtitleFormat, o as diffEnvExample, p as envToExport, q as envToJson, r as formatNdjson, s as formatSubtitleTimestamp, t as formatToml, u as formatXml, v as getSection, w as getSectionNames, x as getTomlStats, y as getXmlStats, z as getYamlStats, A as iniToJson, B as jsonArrayToNdjson, D as jsonToIni, F as jsonToToml, G as jsonToXml, H as minifyNdjson, J as minifyToml, K as minifyXml, L as ndjsonToJsonArray, M as parseCsv, O as parseEnv, Q as parseIni, R as parseSubtitleTimestamp, U as parseSubtitles, W as parseXmlToObject, Y as serializeSubtitles, Z as shiftSubtitles, _ as stringifyIni, $ as toCsvString, a0 as tomlToJson, a1 as validateEnvKey, a2 as validateIni, a3 as validateNdjson, a4 as validateToml, a5 as validateXml, a6 as validateYaml, a7 as xmlToJson } from '../data-XRb0D7Zn.cjs';
@@ -1 +1 @@
1
- export { C as CsvParseResult, E as EnvDiffError, a as EnvDiffResult, b as EnvEntry, c as EnvParseResult, I as IniSection, N as NdjsonLineResult, e as NdjsonValidateResult, P as ParseOptions, f as ParsedIni, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, g as XmlToJsonOptions, h as csvToJson, i as detectDelimiter, j as diffEnvExample, k as envToExport, l as envToJson, m as formatNdjson, n as formatToml, o as formatXml, p as getSection, q as getSectionNames, r as getTomlStats, s as getXmlStats, t as getYamlStats, u as iniToJson, v as jsonArrayToNdjson, w as jsonToIni, x as jsonToToml, y as jsonToXml, z as minifyNdjson, A as minifyToml, B as minifyXml, D as ndjsonToJsonArray, F as parseCsv, G as parseEnv, H as parseIni, J as parseXmlToObject, K as stringifyIni, L as toCsvString, M as tomlToJson, O as validateEnvKey, Q as validateIni, R as validateNdjson, S as validateToml, U as validateXml, W as validateYaml, Y as xmlToJson } from '../data-D8XTI7Du.js';
1
+ export { C as ConvertedSubtitles, a as CsvParseResult, E as EnvDiffError, b as EnvDiffResult, c as EnvEntry, e as EnvParseResult, I as IniSection, N as NdjsonLineResult, f as NdjsonValidateResult, P as ParseOptions, g as ParsedIni, h as ParsedSubtitles, S as SubtitleCue, i as SubtitleFormat, T as TomlFormatResult, V as ValidationResult, X as XmlFormatResult, j as XmlToJsonOptions, k as convertSubtitles, l as csvToJson, m as detectDelimiter, n as detectSubtitleFormat, o as diffEnvExample, p as envToExport, q as envToJson, r as formatNdjson, s as formatSubtitleTimestamp, t as formatToml, u as formatXml, v as getSection, w as getSectionNames, x as getTomlStats, y as getXmlStats, z as getYamlStats, A as iniToJson, B as jsonArrayToNdjson, D as jsonToIni, F as jsonToToml, G as jsonToXml, H as minifyNdjson, J as minifyToml, K as minifyXml, L as ndjsonToJsonArray, M as parseCsv, O as parseEnv, Q as parseIni, R as parseSubtitleTimestamp, U as parseSubtitles, W as parseXmlToObject, Y as serializeSubtitles, Z as shiftSubtitles, _ as stringifyIni, $ as toCsvString, a0 as tomlToJson, a1 as validateEnvKey, a2 as validateIni, a3 as validateNdjson, a4 as validateToml, a5 as validateXml, a6 as validateYaml, a7 as xmlToJson } from '../data-XRb0D7Zn.js';
@@ -1,2 +1,2 @@
1
- export { csvToJson, detectDelimiter, diffEnvExample, envToExport, envToJson, formatNdjson, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseXmlToObject, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-TINQFTLO.js';
1
+ export { convertSubtitles, csvToJson, detectDelimiter, detectSubtitleFormat, diffEnvExample, envToExport, envToJson, formatNdjson, formatSubtitleTimestamp, formatToml, formatXml, getSection, getSectionNames, getTomlStats, getXmlStats, getYamlStats, iniToJson, jsonArrayToNdjson, jsonToIni, jsonToToml, jsonToXml, minifyNdjson, minifyToml, minifyXml, ndjsonToJsonArray, parseCsv, parseEnv, parseIni, parseSubtitleTimestamp, parseSubtitles, parseXmlToObject, serializeSubtitles, shiftSubtitles, stringifyIni, toCsvString, tomlToJson, validateEnvKey, validateIni, validateNdjson, validateToml, validateXml, validateYaml, xmlToJson } from '../chunk-66QHV5KW.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -1319,6 +1319,155 @@ function convertAprApy(rate, compoundsPerYear, direction) {
1319
1319
  difference: round6(apy - apr)
1320
1320
  };
1321
1321
  }
1322
+ var _MARGIN_FIELDS = ["cost", "price", "marginPercent", "markupPercent"];
1323
+ function calculateMarginMarkup(input) {
1324
+ const provided = (v) => typeof v === "number" && Number.isFinite(v);
1325
+ const given = _MARGIN_FIELDS.filter((f) => provided(input[f]));
1326
+ if (given.length !== 2) {
1327
+ return { error: `Provide exactly two of cost, price, marginPercent, markupPercent (got ${given.length})` };
1328
+ }
1329
+ const has = (f) => given.includes(f);
1330
+ const cost0 = input.cost;
1331
+ const price0 = input.price;
1332
+ const margin0 = input.marginPercent;
1333
+ const markup0 = input.markupPercent;
1334
+ if (has("cost") && cost0 <= 0) return { error: "Cost must be greater than zero" };
1335
+ if (has("price") && price0 <= 0) return { error: "Price must be greater than zero" };
1336
+ if (has("marginPercent") && margin0 >= 100) {
1337
+ return { error: "Margin percent must be below 100 (a 100% margin implies a zero cost)" };
1338
+ }
1339
+ if (has("markupPercent") && markup0 <= -100) {
1340
+ return { error: "Markup percent must be greater than -100" };
1341
+ }
1342
+ let cost;
1343
+ let price;
1344
+ if (has("cost") && has("price")) {
1345
+ cost = cost0;
1346
+ price = price0;
1347
+ } else if (has("cost") && has("marginPercent")) {
1348
+ cost = cost0;
1349
+ price = cost0 / (1 - margin0 / 100);
1350
+ } else if (has("cost") && has("markupPercent")) {
1351
+ cost = cost0;
1352
+ price = cost0 * (1 + markup0 / 100);
1353
+ } else if (has("price") && has("marginPercent")) {
1354
+ price = price0;
1355
+ cost = price0 * (1 - margin0 / 100);
1356
+ } else if (has("price") && has("markupPercent")) {
1357
+ price = price0;
1358
+ cost = price0 / (1 + markup0 / 100);
1359
+ } else {
1360
+ return { error: "Margin and markup alone cannot be solved: also provide a cost or a price" };
1361
+ }
1362
+ if (!Number.isFinite(cost) || !Number.isFinite(price)) return { error: "Inputs produce a non-finite result" };
1363
+ if (cost <= 0) return { error: "Those inputs imply a cost of zero or less" };
1364
+ if (price <= 0) return { error: "Those inputs imply a price of zero or less" };
1365
+ const round4 = (n) => Math.round(n * 1e4) / 1e4;
1366
+ const profit = price - cost;
1367
+ return {
1368
+ cost: round4(cost),
1369
+ price: round4(price),
1370
+ profit: round4(profit),
1371
+ marginPercent: round4(profit / price * 100),
1372
+ markupPercent: round4(profit / cost * 100),
1373
+ given,
1374
+ solvedFor: _MARGIN_FIELDS.filter((f) => !given.includes(f))
1375
+ };
1376
+ }
1377
+ function marginToMarkup(marginPercent) {
1378
+ if (!Number.isFinite(marginPercent) || marginPercent >= 100) {
1379
+ return { error: "Margin percent must be a finite number below 100" };
1380
+ }
1381
+ return Math.round(marginPercent / (100 - marginPercent) * 100 * 1e4) / 1e4;
1382
+ }
1383
+ function markupToMargin(markupPercent) {
1384
+ if (!Number.isFinite(markupPercent) || markupPercent <= -100) {
1385
+ return { error: "Markup percent must be a finite number greater than -100" };
1386
+ }
1387
+ return Math.round(markupPercent / (100 + markupPercent) * 100 * 1e4) / 1e4;
1388
+ }
1389
+ var _DISCOUNT_FIELDS = ["discountPercent", "discountAmount", "finalPrice"];
1390
+ function calculateDiscount(input) {
1391
+ const provided = (v) => typeof v === "number" && Number.isFinite(v);
1392
+ if (!provided(input.originalPrice)) {
1393
+ return { error: "originalPrice is required and must be a finite number" };
1394
+ }
1395
+ const originalPrice = input.originalPrice;
1396
+ if (originalPrice <= 0) return { error: "Original price must be greater than zero" };
1397
+ const given = _DISCOUNT_FIELDS.filter((f) => provided(input[f]));
1398
+ if (given.length !== 1) {
1399
+ return { error: `Provide exactly one of discountPercent, discountAmount, finalPrice (got ${given.length})` };
1400
+ }
1401
+ const field = given[0];
1402
+ let discountAmount;
1403
+ if (field === "discountPercent") {
1404
+ const pct = input.discountPercent;
1405
+ if (pct < 0) return { error: "Discount percent cannot be negative" };
1406
+ if (pct > 100) return { error: "Discount percent cannot exceed 100" };
1407
+ discountAmount = originalPrice * (pct / 100);
1408
+ } else if (field === "discountAmount") {
1409
+ const amt = input.discountAmount;
1410
+ if (amt < 0) return { error: "Discount amount cannot be negative" };
1411
+ if (amt > originalPrice) return { error: "Discount amount cannot exceed the original price" };
1412
+ discountAmount = amt;
1413
+ } else {
1414
+ const fin = input.finalPrice;
1415
+ if (fin < 0) return { error: "Final price cannot be negative" };
1416
+ if (fin > originalPrice) {
1417
+ return { error: "Final price cannot exceed the original price: that is a price increase, not a discount" };
1418
+ }
1419
+ discountAmount = originalPrice - fin;
1420
+ }
1421
+ const round4 = (n) => Math.round(n * 1e4) / 1e4;
1422
+ const finalPrice = originalPrice - discountAmount;
1423
+ return {
1424
+ originalPrice: round4(originalPrice),
1425
+ finalPrice: round4(finalPrice),
1426
+ discountAmount: round4(discountAmount),
1427
+ discountPercent: round4(discountAmount / originalPrice * 100),
1428
+ given: field,
1429
+ solvedFor: _DISCOUNT_FIELDS.filter((f) => f !== field)
1430
+ };
1431
+ }
1432
+ function applySuccessiveDiscounts(originalPrice, discountPercents) {
1433
+ if (!Number.isFinite(originalPrice) || originalPrice <= 0) {
1434
+ return { error: "Original price must be a finite number greater than zero" };
1435
+ }
1436
+ if (!Array.isArray(discountPercents) || discountPercents.length === 0) {
1437
+ return { error: "Provide at least one discount percent" };
1438
+ }
1439
+ if (discountPercents.length > 20) {
1440
+ return { error: "Provide at most 20 successive discounts" };
1441
+ }
1442
+ const round4 = (n) => Math.round(n * 1e4) / 1e4;
1443
+ const steps = [];
1444
+ let running = originalPrice;
1445
+ let sumOfDiscountPercents = 0;
1446
+ for (const pct of discountPercents) {
1447
+ if (!Number.isFinite(pct)) return { error: "Every discount percent must be a finite number" };
1448
+ if (pct < 0) return { error: "Discount percent cannot be negative" };
1449
+ if (pct > 100) return { error: "Discount percent cannot exceed 100" };
1450
+ const priceBefore = running;
1451
+ const saved = priceBefore * (pct / 100);
1452
+ running = priceBefore - saved;
1453
+ sumOfDiscountPercents += pct;
1454
+ steps.push({
1455
+ discountPercent: round4(pct),
1456
+ priceBefore: round4(priceBefore),
1457
+ priceAfter: round4(running),
1458
+ saved: round4(saved)
1459
+ });
1460
+ }
1461
+ const totalSaved = originalPrice - running;
1462
+ return {
1463
+ originalPrice: round4(originalPrice),
1464
+ finalPrice: round4(running),
1465
+ totalSaved: round4(totalSaved),
1466
+ effectiveDiscountPercent: round4(totalSaved / originalPrice * 100),
1467
+ sumOfDiscountPercents: round4(sumOfDiscountPercents),
1468
+ steps
1469
+ };
1470
+ }
1322
1471
 
1323
1472
  exports.BASE_LABELS = BASE_LABELS;
1324
1473
  exports.BASE_PREFIXES = BASE_PREFIXES;
@@ -1331,12 +1480,15 @@ exports.COMMON_SIZES = COMMON_SIZES;
1331
1480
  exports.COMMON_TAX_RATES = COMMON_TAX_RATES;
1332
1481
  exports.COMMON_TIP_PERCENTAGES = COMMON_TIP_PERCENTAGES;
1333
1482
  exports.COMMON_VIEWPORTS = COMMON_VIEWPORTS;
1483
+ exports.applySuccessiveDiscounts = applySuccessiveDiscounts;
1334
1484
  exports.autoFormat = autoFormat;
1335
1485
  exports.bumpVersion = bumpVersion;
1336
1486
  exports.calcAspectRatio = calcAspectRatio;
1337
1487
  exports.calcSubnet = calcSubnet;
1338
1488
  exports.calculateCompoundInterest = calculateCompoundInterest;
1489
+ exports.calculateDiscount = calculateDiscount;
1339
1490
  exports.calculateLoan = calculateLoan;
1491
+ exports.calculateMarginMarkup = calculateMarginMarkup;
1340
1492
  exports.calculatePercentageChange = calculatePercentageChange;
1341
1493
  exports.calculateSimpleInterest = calculateSimpleInterest;
1342
1494
  exports.calculateTax = calculateTax;
@@ -1369,6 +1521,8 @@ exports.isValid = isValid;
1369
1521
  exports.isValidCidr = isValidCidr;
1370
1522
  exports.isValidIp = isValidIp;
1371
1523
  exports.isValidIpv4 = isValidIpv4;
1524
+ exports.marginToMarkup = marginToMarkup;
1525
+ exports.markupToMargin = markupToMargin;
1372
1526
  exports.octalToPermissions = octalToPermissions;
1373
1527
  exports.parseFileSize = parseFileSize;
1374
1528
  exports.parseInput = parseInput;
@@ -1 +1 @@
1
- export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.cjs';
1
+ export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, v as DiscountField, w as DiscountInput, x as DiscountResult, F as FilePermissions, y as FormatOptions, I as IbanValidationResult, z as IpConversion, E as IsbnFormat, G as IsbnResult, L as LoanResult, M as MarginMarkupField, H as MarginMarkupInput, J as MarginMarkupResult, N as NotationStyle, K as NumberBase, P as PercentChangeDirection, O as PercentageChangeResult, Q as Permission, R as PxConvertResult, S as SemverVersion, T as SimpleInterestResult, U as SubnetInfo, V as SuccessiveDiscountResult, W as SuccessiveDiscountStep, X as TaxDirection, Y as TaxResult, Z as TimeValueDirection, _ as TimeValueResult, $ as TipSplitResult, a0 as ViewportConvertResult, a1 as applySuccessiveDiscounts, a2 as autoFormat, a3 as bumpVersion, a4 as calcAspectRatio, a5 as calcSubnet, a6 as calculateCompoundInterest, a7 as calculateDiscount, a8 as calculateLoan, a9 as calculateMarginMarkup, aa as calculatePercentageChange, ab as calculateSimpleInterest, ac as calculateTax, ad as calculateTimeValue, ae as calculateTipSplit, af as compareSemver, ag as convert, ah as convertAprApy, ai as convertBytes, aj as convertIp, ak as coverBox, al as decimalToIp, am as decimalToIpCidr, an as describePermissions, ao as fitIntoBox, ap as formatNumber, aq as formatValue, ar as formatVwValue, as as formatWithSeparator, at as gcd, au as ipFromBinary, av as ipFromDecimal, aw as ipFromHex, ax as ipToBinary, ay as ipToDecimal, az as ipToDecimalCidr, aA as ipToHex, aB as ipToOctal, aC as isValid, aD as isValidCidr, aE as isValidIp, aF as isValidIpv4, aG as marginToMarkup, aH as markupToMargin, aI as octalToPermissions, aJ as parseFileSize, aK as parseInput, aL as parseNumberString, aM as parseSemver, aN as permissionsToChmod, aO as permissionsToOctal, aP as permissionsToSymbolic, aQ as ptToPx, aR as pxToAll, aS as pxToViewport, aT as remToPx, aU as satisfiesRange, aV as scaleByHeight, aW as scaleByWidth, aX as sortVersions, aY as splitSubnet, aZ as symbolicToPermissions, a_ as validateBarcode, a$ as validateCardNumber, b0 as validateIban, b1 as validateIsbn, b2 as viewportToPx } from '../units-DAoSM2g8.cjs';
@@ -1 +1 @@
1
- export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, F as FilePermissions, v as FormatOptions, I as IbanValidationResult, w as IpConversion, x as IsbnFormat, y as IsbnResult, L as LoanResult, N as NotationStyle, z as NumberBase, P as PercentChangeDirection, E as PercentageChangeResult, G as Permission, H as PxConvertResult, S as SemverVersion, J as SimpleInterestResult, K as SubnetInfo, T as TaxDirection, M as TaxResult, O as TimeValueDirection, Q as TimeValueResult, R as TipSplitResult, V as ViewportConvertResult, U as autoFormat, W as bumpVersion, X as calcAspectRatio, Y as calcSubnet, Z as calculateCompoundInterest, _ as calculateLoan, $ as calculatePercentageChange, a0 as calculateSimpleInterest, a1 as calculateTax, a2 as calculateTimeValue, a3 as calculateTipSplit, a4 as compareSemver, a5 as convert, a6 as convertAprApy, a7 as convertBytes, a8 as convertIp, a9 as coverBox, aa as decimalToIp, ab as decimalToIpCidr, ac as describePermissions, ad as fitIntoBox, ae as formatNumber, af as formatValue, ag as formatVwValue, ah as formatWithSeparator, ai as gcd, aj as ipFromBinary, ak as ipFromDecimal, al as ipFromHex, am as ipToBinary, an as ipToDecimal, ao as ipToDecimalCidr, ap as ipToHex, aq as ipToOctal, ar as isValid, as as isValidCidr, at as isValidIp, au as isValidIpv4, av as octalToPermissions, aw as parseFileSize, ax as parseInput, ay as parseNumberString, az as parseSemver, aA as permissionsToChmod, aB as permissionsToOctal, aC as permissionsToSymbolic, aD as ptToPx, aE as pxToAll, aF as pxToViewport, aG as remToPx, aH as satisfiesRange, aI as scaleByHeight, aJ as scaleByWidth, aK as sortVersions, aL as splitSubnet, aM as symbolicToPermissions, aN as validateBarcode, aO as validateCardNumber, aP as validateIban, aQ as validateIsbn, aR as viewportToPx } from '../units-KrjRyu0w.js';
1
+ export { A as AmortizationRow, a as AprApyDirection, b as AprApyResult, c as AspectRatioResult, B as BASE_LABELS, d as BASE_PREFIXES, e as BYTE_UNITS, f as BarcodeFormat, g as BarcodeValidationResult, h as BaseConvertResult, i as ByteConvertResult, j as ByteUnit, C as COMMON_CURRENCIES, k as COMMON_LOCALES, l as COMMON_PERMISSIONS, m as COMMON_RATIOS, n as COMMON_SIZES, o as COMMON_TAX_RATES, p as COMMON_TIP_PERCENTAGES, q as COMMON_VIEWPORTS, r as CardValidationResult, s as CompoundInterestResult, t as CompoundYearRow, D as Dimensions, v as DiscountField, w as DiscountInput, x as DiscountResult, F as FilePermissions, y as FormatOptions, I as IbanValidationResult, z as IpConversion, E as IsbnFormat, G as IsbnResult, L as LoanResult, M as MarginMarkupField, H as MarginMarkupInput, J as MarginMarkupResult, N as NotationStyle, K as NumberBase, P as PercentChangeDirection, O as PercentageChangeResult, Q as Permission, R as PxConvertResult, S as SemverVersion, T as SimpleInterestResult, U as SubnetInfo, V as SuccessiveDiscountResult, W as SuccessiveDiscountStep, X as TaxDirection, Y as TaxResult, Z as TimeValueDirection, _ as TimeValueResult, $ as TipSplitResult, a0 as ViewportConvertResult, a1 as applySuccessiveDiscounts, a2 as autoFormat, a3 as bumpVersion, a4 as calcAspectRatio, a5 as calcSubnet, a6 as calculateCompoundInterest, a7 as calculateDiscount, a8 as calculateLoan, a9 as calculateMarginMarkup, aa as calculatePercentageChange, ab as calculateSimpleInterest, ac as calculateTax, ad as calculateTimeValue, ae as calculateTipSplit, af as compareSemver, ag as convert, ah as convertAprApy, ai as convertBytes, aj as convertIp, ak as coverBox, al as decimalToIp, am as decimalToIpCidr, an as describePermissions, ao as fitIntoBox, ap as formatNumber, aq as formatValue, ar as formatVwValue, as as formatWithSeparator, at as gcd, au as ipFromBinary, av as ipFromDecimal, aw as ipFromHex, ax as ipToBinary, ay as ipToDecimal, az as ipToDecimalCidr, aA as ipToHex, aB as ipToOctal, aC as isValid, aD as isValidCidr, aE as isValidIp, aF as isValidIpv4, aG as marginToMarkup, aH as markupToMargin, aI as octalToPermissions, aJ as parseFileSize, aK as parseInput, aL as parseNumberString, aM as parseSemver, aN as permissionsToChmod, aO as permissionsToOctal, aP as permissionsToSymbolic, aQ as ptToPx, aR as pxToAll, aS as pxToViewport, aT as remToPx, aU as satisfiesRange, aV as scaleByHeight, aW as scaleByWidth, aX as sortVersions, aY as splitSubnet, aZ as symbolicToPermissions, a_ as validateBarcode, a$ as validateCardNumber, b0 as validateIban, b1 as validateIsbn, b2 as viewportToPx } from '../units-DAoSM2g8.js';
@@ -1,2 +1,2 @@
1
- export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateLoan, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-TLRSQHMP.js';
1
+ export { BASE_LABELS, BASE_PREFIXES, BYTE_UNITS, COMMON_CURRENCIES, COMMON_LOCALES, COMMON_PERMISSIONS, COMMON_RATIOS, COMMON_SIZES, COMMON_TAX_RATES, COMMON_TIP_PERCENTAGES, COMMON_VIEWPORTS, applySuccessiveDiscounts, autoFormat, bumpVersion, calcAspectRatio, calcSubnet, calculateCompoundInterest, calculateDiscount, calculateLoan, calculateMarginMarkup, calculatePercentageChange, calculateSimpleInterest, calculateTax, calculateTimeValue, calculateTipSplit, compareSemver, convert, convertAprApy, convertBytes, convertIp, coverBox, decimalToIp, decimalToIpCidr, describePermissions, fitIntoBox, formatNumber, formatValue, formatVwValue, formatWithSeparator, gcd, ipFromBinary, ipFromDecimal, ipFromHex, ipToBinary, ipToDecimal, ipToDecimalCidr, ipToHex, ipToOctal, isValid, isValidCidr, isValidIp, isValidIpv4, marginToMarkup, markupToMargin, octalToPermissions, parseFileSize, parseInput, parseNumberString, parseSemver, permissionsToChmod, permissionsToOctal, permissionsToSymbolic, ptToPx, pxToAll, pxToViewport, remToPx, satisfiesRange, scaleByHeight, scaleByWidth, sortVersions, splitSubnet, symbolicToPermissions, validateBarcode, validateCardNumber, validateIban, validateIsbn, viewportToPx } from '../chunk-HZIS2DMJ.js';
2
2
  import '../chunk-MLKGABMK.js';
@@ -24,6 +24,8 @@
24
24
  * - present-value-calculator : calculateTimeValue
25
25
  * - percentage-change-calculator : calculatePercentageChange
26
26
  * - apr-apy-converter : convertAprApy
27
+ * - margin-markup-calculator : calculateMarginMarkup, marginToMarkup, markupToMargin
28
+ * - discount-calculator : calculateDiscount, applySuccessiveDiscounts
27
29
  */
28
30
  interface PxConvertResult {
29
31
  px: number;
@@ -474,6 +476,90 @@ interface AprApyResult {
474
476
  declare function convertAprApy(rate: number, compoundsPerYear: number, direction: AprApyDirection): AprApyResult | {
475
477
  error: string;
476
478
  };
479
+ type MarginMarkupField = "cost" | "price" | "marginPercent" | "markupPercent";
480
+ interface MarginMarkupInput {
481
+ cost?: number | null;
482
+ price?: number | null;
483
+ marginPercent?: number | null;
484
+ markupPercent?: number | null;
485
+ }
486
+ interface MarginMarkupResult {
487
+ cost: number;
488
+ price: number;
489
+ profit: number;
490
+ marginPercent: number;
491
+ markupPercent: number;
492
+ given: MarginMarkupField[];
493
+ solvedFor: MarginMarkupField[];
494
+ }
495
+ /**
496
+ * Solve a pricing triangle: given exactly two of cost, price, gross margin
497
+ * percent, and markup percent, derive the other two. Margin is profit as a
498
+ * share of the selling price (profit / price) while markup is profit as a
499
+ * share of the cost (profit / cost), so a 20% margin is the same deal as a
500
+ * 25% markup — conflating them is the classic mistake this exists to avoid.
501
+ * Margin plus markup alone cannot be solved, since neither carries an
502
+ * absolute amount. Pure closed-form arithmetic, no live price feed.
503
+ */
504
+ declare function calculateMarginMarkup(input: MarginMarkupInput): MarginMarkupResult | {
505
+ error: string;
506
+ };
507
+ /** Markup percent that produces a given gross margin percent (margin < 100). */
508
+ declare function marginToMarkup(marginPercent: number): number | {
509
+ error: string;
510
+ };
511
+ /** Gross margin percent that results from a given markup percent (markup > -100). */
512
+ declare function markupToMargin(markupPercent: number): number | {
513
+ error: string;
514
+ };
515
+ type DiscountField = "discountPercent" | "discountAmount" | "finalPrice";
516
+ interface DiscountInput {
517
+ originalPrice?: number | null;
518
+ discountPercent?: number | null;
519
+ discountAmount?: number | null;
520
+ finalPrice?: number | null;
521
+ }
522
+ interface DiscountResult {
523
+ originalPrice: number;
524
+ finalPrice: number;
525
+ discountAmount: number;
526
+ discountPercent: number;
527
+ given: DiscountField;
528
+ solvedFor: DiscountField[];
529
+ }
530
+ interface SuccessiveDiscountStep {
531
+ discountPercent: number;
532
+ priceBefore: number;
533
+ priceAfter: number;
534
+ saved: number;
535
+ }
536
+ interface SuccessiveDiscountResult {
537
+ originalPrice: number;
538
+ finalPrice: number;
539
+ totalSaved: number;
540
+ effectiveDiscountPercent: number;
541
+ sumOfDiscountPercents: number;
542
+ steps: SuccessiveDiscountStep[];
543
+ }
544
+ /**
545
+ * Supply the original price plus exactly one of discountPercent,
546
+ * discountAmount, or finalPrice; the other two are derived. A discount cannot
547
+ * exceed the original price, so a final price above the original or a percent
548
+ * above 100 is rejected rather than silently returning a negative amount.
549
+ * Pure arithmetic over user-supplied numbers, no live price feed.
550
+ */
551
+ declare function calculateDiscount(input: DiscountInput): DiscountResult | {
552
+ error: string;
553
+ };
554
+ /**
555
+ * Apply discounts one after another, each off the running price. Stacked
556
+ * discounts never simply add up: 20% then 10% leaves 72% of the original, an
557
+ * effective 28% discount, not 30%. Returns each step plus the effective single
558
+ * discount that would produce the same final price.
559
+ */
560
+ declare function applySuccessiveDiscounts(originalPrice: number, discountPercents: number[]): SuccessiveDiscountResult | {
561
+ error: string;
562
+ };
477
563
 
478
564
  type units_AmortizationRow = AmortizationRow;
479
565
  type units_AprApyDirection = AprApyDirection;
@@ -499,6 +585,9 @@ type units_CardValidationResult = CardValidationResult;
499
585
  type units_CompoundInterestResult = CompoundInterestResult;
500
586
  type units_CompoundYearRow = CompoundYearRow;
501
587
  type units_Dimensions = Dimensions;
588
+ type units_DiscountField = DiscountField;
589
+ type units_DiscountInput = DiscountInput;
590
+ type units_DiscountResult = DiscountResult;
502
591
  type units_FilePermissions = FilePermissions;
503
592
  type units_FormatOptions = FormatOptions;
504
593
  type units_IbanValidationResult = IbanValidationResult;
@@ -506,6 +595,9 @@ type units_IpConversion = IpConversion;
506
595
  type units_IsbnFormat = IsbnFormat;
507
596
  type units_IsbnResult = IsbnResult;
508
597
  type units_LoanResult = LoanResult;
598
+ type units_MarginMarkupField = MarginMarkupField;
599
+ type units_MarginMarkupInput = MarginMarkupInput;
600
+ type units_MarginMarkupResult = MarginMarkupResult;
509
601
  type units_NotationStyle = NotationStyle;
510
602
  type units_NumberBase = NumberBase;
511
603
  type units_PercentChangeDirection = PercentChangeDirection;
@@ -515,18 +607,23 @@ type units_PxConvertResult = PxConvertResult;
515
607
  type units_SemverVersion = SemverVersion;
516
608
  type units_SimpleInterestResult = SimpleInterestResult;
517
609
  type units_SubnetInfo = SubnetInfo;
610
+ type units_SuccessiveDiscountResult = SuccessiveDiscountResult;
611
+ type units_SuccessiveDiscountStep = SuccessiveDiscountStep;
518
612
  type units_TaxDirection = TaxDirection;
519
613
  type units_TaxResult = TaxResult;
520
614
  type units_TimeValueDirection = TimeValueDirection;
521
615
  type units_TimeValueResult = TimeValueResult;
522
616
  type units_TipSplitResult = TipSplitResult;
523
617
  type units_ViewportConvertResult = ViewportConvertResult;
618
+ declare const units_applySuccessiveDiscounts: typeof applySuccessiveDiscounts;
524
619
  declare const units_autoFormat: typeof autoFormat;
525
620
  declare const units_bumpVersion: typeof bumpVersion;
526
621
  declare const units_calcAspectRatio: typeof calcAspectRatio;
527
622
  declare const units_calcSubnet: typeof calcSubnet;
528
623
  declare const units_calculateCompoundInterest: typeof calculateCompoundInterest;
624
+ declare const units_calculateDiscount: typeof calculateDiscount;
529
625
  declare const units_calculateLoan: typeof calculateLoan;
626
+ declare const units_calculateMarginMarkup: typeof calculateMarginMarkup;
530
627
  declare const units_calculatePercentageChange: typeof calculatePercentageChange;
531
628
  declare const units_calculateSimpleInterest: typeof calculateSimpleInterest;
532
629
  declare const units_calculateTax: typeof calculateTax;
@@ -559,6 +656,8 @@ declare const units_isValid: typeof isValid;
559
656
  declare const units_isValidCidr: typeof isValidCidr;
560
657
  declare const units_isValidIp: typeof isValidIp;
561
658
  declare const units_isValidIpv4: typeof isValidIpv4;
659
+ declare const units_marginToMarkup: typeof marginToMarkup;
660
+ declare const units_markupToMargin: typeof markupToMargin;
562
661
  declare const units_octalToPermissions: typeof octalToPermissions;
563
662
  declare const units_parseFileSize: typeof parseFileSize;
564
663
  declare const units_parseInput: typeof parseInput;
@@ -583,7 +682,7 @@ declare const units_validateIban: typeof validateIban;
583
682
  declare const units_validateIsbn: typeof validateIsbn;
584
683
  declare const units_viewportToPx: typeof viewportToPx;
585
684
  declare namespace units {
586
- export { type units_AmortizationRow as AmortizationRow, type units_AprApyDirection as AprApyDirection, type units_AprApyResult as AprApyResult, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateLoan as calculateLoan, units_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertAprApy as convertAprApy, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
685
+ export { type units_AmortizationRow as AmortizationRow, type units_AprApyDirection as AprApyDirection, type units_AprApyResult as AprApyResult, type units_AspectRatioResult as AspectRatioResult, units_BASE_LABELS as BASE_LABELS, units_BASE_PREFIXES as BASE_PREFIXES, units_BYTE_UNITS as BYTE_UNITS, type units_BarcodeFormat as BarcodeFormat, type units_BarcodeValidationResult as BarcodeValidationResult, type units_BaseConvertResult as BaseConvertResult, type units_ByteConvertResult as ByteConvertResult, type units_ByteUnit as ByteUnit, units_COMMON_CURRENCIES as COMMON_CURRENCIES, units_COMMON_LOCALES as COMMON_LOCALES, units_COMMON_PERMISSIONS as COMMON_PERMISSIONS, units_COMMON_RATIOS as COMMON_RATIOS, units_COMMON_SIZES as COMMON_SIZES, units_COMMON_TAX_RATES as COMMON_TAX_RATES, units_COMMON_TIP_PERCENTAGES as COMMON_TIP_PERCENTAGES, units_COMMON_VIEWPORTS as COMMON_VIEWPORTS, type units_CardValidationResult as CardValidationResult, type units_CompoundInterestResult as CompoundInterestResult, type units_CompoundYearRow as CompoundYearRow, type units_Dimensions as Dimensions, type units_DiscountField as DiscountField, type units_DiscountInput as DiscountInput, type units_DiscountResult as DiscountResult, type units_FilePermissions as FilePermissions, type units_FormatOptions as FormatOptions, type units_IbanValidationResult as IbanValidationResult, type units_IpConversion as IpConversion, type units_IsbnFormat as IsbnFormat, type units_IsbnResult as IsbnResult, type units_LoanResult as LoanResult, type units_MarginMarkupField as MarginMarkupField, type units_MarginMarkupInput as MarginMarkupInput, type units_MarginMarkupResult as MarginMarkupResult, type units_NotationStyle as NotationStyle, type units_NumberBase as NumberBase, type units_PercentChangeDirection as PercentChangeDirection, type units_PercentageChangeResult as PercentageChangeResult, type units_Permission as Permission, type units_PxConvertResult as PxConvertResult, type units_SemverVersion as SemverVersion, type units_SimpleInterestResult as SimpleInterestResult, type units_SubnetInfo as SubnetInfo, type units_SuccessiveDiscountResult as SuccessiveDiscountResult, type units_SuccessiveDiscountStep as SuccessiveDiscountStep, type units_TaxDirection as TaxDirection, type units_TaxResult as TaxResult, type units_TimeValueDirection as TimeValueDirection, type units_TimeValueResult as TimeValueResult, type units_TipSplitResult as TipSplitResult, type units_ViewportConvertResult as ViewportConvertResult, units_applySuccessiveDiscounts as applySuccessiveDiscounts, units_autoFormat as autoFormat, units_bumpVersion as bumpVersion, units_calcAspectRatio as calcAspectRatio, units_calcSubnet as calcSubnet, units_calculateCompoundInterest as calculateCompoundInterest, units_calculateDiscount as calculateDiscount, units_calculateLoan as calculateLoan, units_calculateMarginMarkup as calculateMarginMarkup, units_calculatePercentageChange as calculatePercentageChange, units_calculateSimpleInterest as calculateSimpleInterest, units_calculateTax as calculateTax, units_calculateTimeValue as calculateTimeValue, units_calculateTipSplit as calculateTipSplit, units_compareSemver as compareSemver, units_convert as convert, units_convertAprApy as convertAprApy, units_convertBytes as convertBytes, units_convertIp as convertIp, units_coverBox as coverBox, units_decimalToIp as decimalToIp, units_decimalToIpCidr as decimalToIpCidr, units_describePermissions as describePermissions, units_fitIntoBox as fitIntoBox, units_formatNumber as formatNumber, units_formatValue as formatValue, units_formatVwValue as formatVwValue, units_formatWithSeparator as formatWithSeparator, units_gcd as gcd, units_ipFromBinary as ipFromBinary, units_ipFromDecimal as ipFromDecimal, units_ipFromHex as ipFromHex, units_ipToBinary as ipToBinary, units_ipToDecimal as ipToDecimal, units_ipToDecimalCidr as ipToDecimalCidr, units_ipToHex as ipToHex, units_ipToOctal as ipToOctal, units_isValid as isValid, units_isValidCidr as isValidCidr, units_isValidIp as isValidIp, units_isValidIpv4 as isValidIpv4, units_marginToMarkup as marginToMarkup, units_markupToMargin as markupToMargin, units_octalToPermissions as octalToPermissions, units_parseFileSize as parseFileSize, units_parseInput as parseInput, units_parseNumberString as parseNumberString, units_parseSemver as parseSemver, units_permissionsToChmod as permissionsToChmod, units_permissionsToOctal as permissionsToOctal, units_permissionsToSymbolic as permissionsToSymbolic, units_ptToPx as ptToPx, units_pxToAll as pxToAll, units_pxToViewport as pxToViewport, units_remToPx as remToPx, units_satisfiesRange as satisfiesRange, units_scaleByHeight as scaleByHeight, units_scaleByWidth as scaleByWidth, units_sortVersions as sortVersions, units_splitSubnet as splitSubnet, units_symbolicToPermissions as symbolicToPermissions, units_validateBarcode as validateBarcode, units_validateCardNumber as validateCardNumber, units_validateIban as validateIban, units_validateIsbn as validateIsbn, units_viewportToPx as viewportToPx };
587
686
  }
588
687
 
589
- export { calculatePercentageChange as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type PercentageChangeResult as E, type FilePermissions as F, type Permission as G, type PxConvertResult as H, type IbanValidationResult as I, type SimpleInterestResult as J, type SubnetInfo as K, type LoanResult as L, type TaxResult as M, type NotationStyle as N, type TimeValueDirection as O, type PercentChangeDirection as P, type TimeValueResult as Q, type TipSplitResult as R, type SemverVersion as S, type TaxDirection as T, autoFormat as U, type ViewportConvertResult as V, bumpVersion as W, calcAspectRatio as X, calcSubnet as Y, calculateCompoundInterest as Z, calculateLoan as _, type AprApyDirection as a, calculateSimpleInterest as a0, calculateTax as a1, calculateTimeValue as a2, calculateTipSplit as a3, compareSemver as a4, convert as a5, convertAprApy as a6, convertBytes as a7, convertIp as a8, coverBox as a9, permissionsToChmod as aA, permissionsToOctal as aB, permissionsToSymbolic as aC, ptToPx as aD, pxToAll as aE, pxToViewport as aF, remToPx as aG, satisfiesRange as aH, scaleByHeight as aI, scaleByWidth as aJ, sortVersions as aK, splitSubnet as aL, symbolicToPermissions as aM, validateBarcode as aN, validateCardNumber as aO, validateIban as aP, validateIsbn as aQ, viewportToPx as aR, decimalToIp as aa, decimalToIpCidr as ab, describePermissions as ac, fitIntoBox as ad, formatNumber as ae, formatValue as af, formatVwValue as ag, formatWithSeparator as ah, gcd as ai, ipFromBinary as aj, ipFromDecimal as ak, ipFromHex as al, ipToBinary as am, ipToDecimal as an, ipToDecimalCidr as ao, ipToHex as ap, ipToOctal as aq, isValid as ar, isValidCidr as as, isValidIp as at, isValidIpv4 as au, octalToPermissions as av, parseFileSize as aw, parseInput as ax, parseNumberString as ay, parseSemver as az, type AprApyResult as b, type AspectRatioResult as c, BASE_PREFIXES as d, BYTE_UNITS as e, type BarcodeFormat as f, type BarcodeValidationResult as g, type BaseConvertResult as h, type ByteConvertResult as i, type ByteUnit as j, COMMON_LOCALES as k, COMMON_PERMISSIONS as l, COMMON_RATIOS as m, COMMON_SIZES as n, COMMON_TAX_RATES as o, COMMON_TIP_PERCENTAGES as p, COMMON_VIEWPORTS as q, type CardValidationResult as r, type CompoundInterestResult as s, type CompoundYearRow as t, units as u, type FormatOptions as v, type IpConversion as w, type IsbnFormat as x, type IsbnResult as y, type NumberBase as z };
688
+ export { type TipSplitResult as $, type AmortizationRow as A, BASE_LABELS as B, COMMON_CURRENCIES as C, type Dimensions as D, type IsbnFormat as E, type FilePermissions as F, type IsbnResult as G, type MarginMarkupInput as H, type IbanValidationResult as I, type MarginMarkupResult as J, type NumberBase as K, type LoanResult as L, type MarginMarkupField as M, type NotationStyle as N, type PercentageChangeResult as O, type PercentChangeDirection as P, type Permission as Q, type PxConvertResult as R, type SemverVersion as S, type SimpleInterestResult as T, type SubnetInfo as U, type SuccessiveDiscountResult as V, type SuccessiveDiscountStep as W, type TaxDirection as X, type TaxResult as Y, type TimeValueDirection as Z, type TimeValueResult as _, type AprApyDirection as a, validateCardNumber as a$, type ViewportConvertResult as a0, applySuccessiveDiscounts as a1, autoFormat as a2, bumpVersion as a3, calcAspectRatio as a4, calcSubnet as a5, calculateCompoundInterest as a6, calculateDiscount as a7, calculateLoan as a8, calculateMarginMarkup as a9, ipToHex as aA, ipToOctal as aB, isValid as aC, isValidCidr as aD, isValidIp as aE, isValidIpv4 as aF, marginToMarkup as aG, markupToMargin as aH, octalToPermissions as aI, parseFileSize as aJ, parseInput as aK, parseNumberString as aL, parseSemver as aM, permissionsToChmod as aN, permissionsToOctal as aO, permissionsToSymbolic as aP, ptToPx as aQ, pxToAll as aR, pxToViewport as aS, remToPx as aT, satisfiesRange as aU, scaleByHeight as aV, scaleByWidth as aW, sortVersions as aX, splitSubnet as aY, symbolicToPermissions as aZ, validateBarcode as a_, calculatePercentageChange as aa, calculateSimpleInterest as ab, calculateTax as ac, calculateTimeValue as ad, calculateTipSplit as ae, compareSemver as af, convert as ag, convertAprApy as ah, convertBytes as ai, convertIp as aj, coverBox as ak, decimalToIp as al, decimalToIpCidr as am, describePermissions as an, fitIntoBox as ao, formatNumber as ap, formatValue as aq, formatVwValue as ar, formatWithSeparator as as, gcd as at, ipFromBinary as au, ipFromDecimal as av, ipFromHex as aw, ipToBinary as ax, ipToDecimal as ay, ipToDecimalCidr as az, type AprApyResult as b, validateIban as b0, validateIsbn as b1, viewportToPx as b2, type AspectRatioResult as c, BASE_PREFIXES as d, BYTE_UNITS as e, type BarcodeFormat as f, type BarcodeValidationResult as g, type BaseConvertResult as h, type ByteConvertResult as i, type ByteUnit as j, COMMON_LOCALES as k, COMMON_PERMISSIONS as l, COMMON_RATIOS as m, COMMON_SIZES as n, COMMON_TAX_RATES as o, COMMON_TIP_PERCENTAGES as p, COMMON_VIEWPORTS as q, type CardValidationResult as r, type CompoundInterestResult as s, type CompoundYearRow as t, units as u, type DiscountField as v, type DiscountInput as w, type DiscountResult as x, type FormatOptions as y, type IpConversion as z };