@utilix-tech/sdk 0.89.0 → 0.91.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.
@@ -22,6 +22,8 @@
22
22
  * - yaml-anchor-resolver: resolveYamlAnchors
23
23
  * - markdown-table-aligner: alignMarkdownTables
24
24
  * - markdown-heading-hierarchy-validator: validateMarkdownHeadingHierarchy
25
+ * - markdown-internal-link-checker: checkMarkdownInternalLinks
26
+ * - yaml-duplicate-key-detector: findYamlDuplicateKeys
25
27
  */
26
28
  interface ValidationResult {
27
29
  valid: boolean;
@@ -409,6 +411,32 @@ interface HeadingHierarchyResult {
409
411
  * not recognized, and headings inside fenced code blocks are ignored.
410
412
  */
411
413
  declare function validateMarkdownHeadingHierarchy(markdown: string): HeadingHierarchyResult;
414
+ interface MarkdownAnchorHeading {
415
+ level: number;
416
+ text: string;
417
+ slug: string;
418
+ line: number;
419
+ }
420
+ interface MarkdownAnchorLink {
421
+ text: string;
422
+ target: string;
423
+ line: number;
424
+ valid: boolean;
425
+ }
426
+ interface MarkdownInternalLinkCheckResult {
427
+ headings: MarkdownAnchorHeading[];
428
+ links: MarkdownAnchorLink[];
429
+ brokenLinks: MarkdownAnchorLink[];
430
+ }
431
+ /**
432
+ * Scan a Markdown document's ATX headings, compute the GitHub-style anchor
433
+ * slug for each, and check every `[text](#slug)` internal link against
434
+ * them, flagging links that point at a heading that doesn't exist (or was
435
+ * renamed).
436
+ */
437
+ declare function checkMarkdownInternalLinks(markdown: string): MarkdownInternalLinkCheckResult | {
438
+ error: string;
439
+ };
412
440
  interface CsvToSqlOptions {
413
441
  tableName?: string;
414
442
  dialect?: 'ansi' | 'mysql';
@@ -510,6 +538,28 @@ interface YamlAnchorResolveError {
510
538
  * syntax remaining.
511
539
  */
512
540
  declare function resolveYamlAnchors(yamlText: string): YamlAnchorResolveResult | YamlAnchorResolveError;
541
+ interface YamlDuplicateKeyEntry {
542
+ key: string;
543
+ line: number;
544
+ column: number;
545
+ }
546
+ interface YamlDuplicateKeyResult {
547
+ duplicateCount: number;
548
+ duplicates: YamlDuplicateKeyEntry[];
549
+ }
550
+ interface YamlDuplicateKeyError {
551
+ error: string;
552
+ }
553
+ /**
554
+ * Parse a YAML document and report every mapping key that collides with an
555
+ * earlier key in the *same* mapping scope (a sibling object with the same
556
+ * key name is not a duplicate), with the line and column of each repeated
557
+ * occurrence. Standard YAML parsers, including this one by default, treat
558
+ * a duplicate key as "last one wins" rather than an error, so this is the
559
+ * check that catches a merge conflict or a copy-paste mistake before it
560
+ * silently drops a config value.
561
+ */
562
+ declare function findYamlDuplicateKeys(yamlText: string): YamlDuplicateKeyResult | YamlDuplicateKeyError;
513
563
  interface MarkdownTaskListItem {
514
564
  text: string;
515
565
  checked: boolean;
@@ -593,6 +643,9 @@ type data_HeadingHierarchyResult = HeadingHierarchyResult;
593
643
  type data_HeadingIssue = HeadingIssue;
594
644
  type data_HeadingIssueType = HeadingIssueType;
595
645
  type data_IniSection = IniSection;
646
+ type data_MarkdownAnchorHeading = MarkdownAnchorHeading;
647
+ type data_MarkdownAnchorLink = MarkdownAnchorLink;
648
+ type data_MarkdownInternalLinkCheckResult = MarkdownInternalLinkCheckResult;
596
649
  type data_MarkdownTableAlignResult = MarkdownTableAlignResult;
597
650
  type data_MarkdownTableColumnAlignment = MarkdownTableColumnAlignment;
598
651
  type data_MarkdownTableInfo = MarkdownTableInfo;
@@ -617,9 +670,13 @@ type data_XmlToJsonOptions = XmlToJsonOptions;
617
670
  type data_YamlAnchorInfo = YamlAnchorInfo;
618
671
  type data_YamlAnchorResolveError = YamlAnchorResolveError;
619
672
  type data_YamlAnchorResolveResult = YamlAnchorResolveResult;
673
+ type data_YamlDuplicateKeyEntry = YamlDuplicateKeyEntry;
674
+ type data_YamlDuplicateKeyError = YamlDuplicateKeyError;
675
+ type data_YamlDuplicateKeyResult = YamlDuplicateKeyResult;
620
676
  declare const data_alignMarkdownTables: typeof alignMarkdownTables;
621
677
  declare const data_analyzeCaptionSpeed: typeof analyzeCaptionSpeed;
622
678
  declare const data_calculateMarkdownTaskListProgress: typeof calculateMarkdownTaskListProgress;
679
+ declare const data_checkMarkdownInternalLinks: typeof checkMarkdownInternalLinks;
623
680
  declare const data_convertSubtitles: typeof convertSubtitles;
624
681
  declare const data_csvToJson: typeof csvToJson;
625
682
  declare const data_csvToSqlInsert: typeof csvToSqlInsert;
@@ -630,6 +687,7 @@ declare const data_diffEnvExample: typeof diffEnvExample;
630
687
  declare const data_envToExport: typeof envToExport;
631
688
  declare const data_envToJson: typeof envToJson;
632
689
  declare const data_findCsvDuplicateRows: typeof findCsvDuplicateRows;
690
+ declare const data_findYamlDuplicateKeys: typeof findYamlDuplicateKeys;
633
691
  declare const data_formatNdjson: typeof formatNdjson;
634
692
  declare const data_formatSubtitleTimestamp: typeof formatSubtitleTimestamp;
635
693
  declare const data_formatToml: typeof formatToml;
@@ -673,7 +731,7 @@ declare const data_validateXml: typeof validateXml;
673
731
  declare const data_validateYaml: typeof validateYaml;
674
732
  declare const data_xmlToJson: typeof xmlToJson;
675
733
  declare namespace data {
676
- export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_HeadingEntry as HeadingEntry, type data_HeadingHierarchyResult as HeadingHierarchyResult, type data_HeadingIssue as HeadingIssue, type data_HeadingIssueType as HeadingIssueType, type data_IniSection as IniSection, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToCsv as ndjsonToCsv, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateMarkdownHeadingHierarchy as validateMarkdownHeadingHierarchy, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
734
+ export { type data_CaptionSpeedCue as CaptionSpeedCue, type data_CaptionSpeedResult as CaptionSpeedResult, type data_ConvertedSubtitles as ConvertedSubtitles, type data_CsvColumnType as CsvColumnType, type data_CsvColumnTypeInfo as CsvColumnTypeInfo, type data_CsvColumnTypeOptions as CsvColumnTypeOptions, type data_CsvColumnTypeResult as CsvColumnTypeResult, type data_CsvDuplicateGroup as CsvDuplicateGroup, type data_CsvDuplicateOptions as CsvDuplicateOptions, type data_CsvDuplicateResult as CsvDuplicateResult, type data_CsvParseResult as CsvParseResult, type data_CsvToSqlOptions as CsvToSqlOptions, type data_CsvToSqlResult as CsvToSqlResult, type data_EnvDiffError as EnvDiffError, type data_EnvDiffResult as EnvDiffResult, type data_EnvEntry as EnvEntry, type data_EnvParseResult as EnvParseResult, type data_FrontMatterError as FrontMatterError, type data_FrontMatterResult as FrontMatterResult, type data_HeadingEntry as HeadingEntry, type data_HeadingHierarchyResult as HeadingHierarchyResult, type data_HeadingIssue as HeadingIssue, type data_HeadingIssueType as HeadingIssueType, type data_IniSection as IniSection, type data_MarkdownAnchorHeading as MarkdownAnchorHeading, type data_MarkdownAnchorLink as MarkdownAnchorLink, type data_MarkdownInternalLinkCheckResult as MarkdownInternalLinkCheckResult, type data_MarkdownTableAlignResult as MarkdownTableAlignResult, type data_MarkdownTableColumnAlignment as MarkdownTableColumnAlignment, type data_MarkdownTableInfo as MarkdownTableInfo, type data_MarkdownTaskListItem as MarkdownTaskListItem, type data_MarkdownTaskListProgressResult as MarkdownTaskListProgressResult, type data_MarkdownTaskListSectionSummary as MarkdownTaskListSectionSummary, type data_MarkdownTocEntry as MarkdownTocEntry, type data_MarkdownTocOptions as MarkdownTocOptions, type data_MarkdownTocResult as MarkdownTocResult, type data_NdjsonDedupeResult as NdjsonDedupeResult, type data_NdjsonLineResult as NdjsonLineResult, type data_NdjsonValidateResult as NdjsonValidateResult, type data_ParseOptions as ParseOptions, type data_ParsedIni as ParsedIni, type data_ParsedSubtitles as ParsedSubtitles, type data_SubtitleCue as SubtitleCue, type data_SubtitleFormat as SubtitleFormat, type data_TomlFormatResult as TomlFormatResult, type data_ValidationResult as ValidationResult, type data_XmlFormatResult as XmlFormatResult, type data_XmlToJsonOptions as XmlToJsonOptions, type data_YamlAnchorInfo as YamlAnchorInfo, type data_YamlAnchorResolveError as YamlAnchorResolveError, type data_YamlAnchorResolveResult as YamlAnchorResolveResult, type data_YamlDuplicateKeyEntry as YamlDuplicateKeyEntry, type data_YamlDuplicateKeyError as YamlDuplicateKeyError, type data_YamlDuplicateKeyResult as YamlDuplicateKeyResult, data_alignMarkdownTables as alignMarkdownTables, data_analyzeCaptionSpeed as analyzeCaptionSpeed, data_calculateMarkdownTaskListProgress as calculateMarkdownTaskListProgress, data_checkMarkdownInternalLinks as checkMarkdownInternalLinks, data_convertSubtitles as convertSubtitles, data_csvToJson as csvToJson, data_csvToSqlInsert as csvToSqlInsert, data_dedupeNdjson as dedupeNdjson, data_detectDelimiter as detectDelimiter, data_detectSubtitleFormat as detectSubtitleFormat, data_diffEnvExample as diffEnvExample, data_envToExport as envToExport, data_envToJson as envToJson, data_findCsvDuplicateRows as findCsvDuplicateRows, data_findYamlDuplicateKeys as findYamlDuplicateKeys, data_formatNdjson as formatNdjson, data_formatSubtitleTimestamp as formatSubtitleTimestamp, data_formatToml as formatToml, data_formatXml as formatXml, data_generateMarkdownToc as generateMarkdownToc, data_getSection as getSection, data_getSectionNames as getSectionNames, data_getTomlStats as getTomlStats, data_getXmlStats as getXmlStats, data_getYamlStats as getYamlStats, data_inferCsvColumnTypes as inferCsvColumnTypes, data_iniToJson as iniToJson, data_jsonArrayToNdjson as jsonArrayToNdjson, data_jsonToIni as jsonToIni, data_jsonToToml as jsonToToml, data_jsonToXml as jsonToXml, data_minifyNdjson as minifyNdjson, data_minifyToml as minifyToml, data_minifyXml as minifyXml, data_ndjsonToCsv as ndjsonToCsv, data_ndjsonToJsonArray as ndjsonToJsonArray, data_parseCsv as parseCsv, data_parseEnv as parseEnv, data_parseFrontMatter as parseFrontMatter, data_parseIni as parseIni, data_parseSubtitleTimestamp as parseSubtitleTimestamp, data_parseSubtitles as parseSubtitles, data_parseXmlToObject as parseXmlToObject, data_resolveYamlAnchors as resolveYamlAnchors, data_serializeSubtitles as serializeSubtitles, data_shiftSubtitles as shiftSubtitles, data_stringifyIni as stringifyIni, data_toCsvString as toCsvString, data_tomlToJson as tomlToJson, data_validateEnvKey as validateEnvKey, data_validateIni as validateIni, data_validateMarkdownHeadingHierarchy as validateMarkdownHeadingHierarchy, data_validateNdjson as validateNdjson, data_validateToml as validateToml, data_validateXml as validateXml, data_validateYaml as validateYaml, data_xmlToJson as xmlToJson };
677
735
  }
678
736
 
679
- export { csvToJson as $, type MarkdownTocOptions as A, type MarkdownTocResult as B, type CaptionSpeedCue as C, type NdjsonLineResult as D, type EnvDiffError as E, type FrontMatterError as F, type NdjsonValidateResult as G, type HeadingEntry as H, type IniSection as I, type ParsedIni as J, type ParsedSubtitles as K, type SubtitleFormat as L, type MarkdownTableAlignResult as M, type NdjsonDedupeResult as N, type XmlToJsonOptions as O, type ParseOptions as P, type YamlAnchorResolveError as Q, type YamlAnchorResolveResult as R, type SubtitleCue as S, type TomlFormatResult as T, alignMarkdownTables as U, type ValidationResult as V, analyzeCaptionSpeed as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, calculateMarkdownTaskListProgress as Z, convertSubtitles as _, type CaptionSpeedResult as a, csvToSqlInsert as a0, dedupeNdjson as a1, detectDelimiter as a2, detectSubtitleFormat as a3, diffEnvExample as a4, envToExport as a5, envToJson as a6, findCsvDuplicateRows as a7, formatNdjson as a8, formatSubtitleTimestamp as a9, resolveYamlAnchors as aA, serializeSubtitles as aB, shiftSubtitles as aC, stringifyIni as aD, toCsvString as aE, tomlToJson as aF, validateEnvKey as aG, validateIni as aH, validateMarkdownHeadingHierarchy as aI, validateNdjson as aJ, validateToml as aK, validateXml as aL, validateYaml as aM, xmlToJson as aN, formatToml as aa, formatXml as ab, generateMarkdownToc as ac, getSection as ad, getSectionNames as ae, getTomlStats as af, getXmlStats as ag, getYamlStats as ah, inferCsvColumnTypes as ai, iniToJson as aj, jsonArrayToNdjson as ak, jsonToIni as al, jsonToToml as am, jsonToXml as an, minifyNdjson as ao, minifyToml as ap, minifyXml as aq, ndjsonToCsv as ar, ndjsonToJsonArray as as, parseCsv as at, parseEnv as au, parseFrontMatter as av, parseIni as aw, parseSubtitleTimestamp as ax, parseSubtitles as ay, parseXmlToObject as az, type ConvertedSubtitles as b, type CsvColumnType as c, data as d, type CsvColumnTypeInfo as e, type CsvColumnTypeOptions as f, type CsvColumnTypeResult as g, type CsvDuplicateGroup as h, type CsvDuplicateOptions as i, type CsvDuplicateResult as j, type CsvParseResult as k, type CsvToSqlOptions as l, type CsvToSqlResult as m, type EnvDiffResult as n, type EnvEntry as o, type EnvParseResult as p, type FrontMatterResult as q, type HeadingHierarchyResult as r, type HeadingIssue as s, type HeadingIssueType as t, type MarkdownTableColumnAlignment as u, type MarkdownTableInfo as v, type MarkdownTaskListItem as w, type MarkdownTaskListProgressResult as x, type MarkdownTaskListSectionSummary as y, type MarkdownTocEntry as z };
737
+ export { type YamlDuplicateKeyError as $, type MarkdownTaskListProgressResult as A, type MarkdownTaskListSectionSummary as B, type CaptionSpeedCue as C, type MarkdownTocEntry as D, type EnvDiffError as E, type FrontMatterError as F, type MarkdownTocOptions as G, type HeadingEntry as H, type IniSection as I, type MarkdownTocResult as J, type NdjsonLineResult as K, type NdjsonValidateResult as L, type MarkdownAnchorHeading as M, type NdjsonDedupeResult as N, type ParsedIni as O, type ParseOptions as P, type ParsedSubtitles as Q, type SubtitleFormat as R, type SubtitleCue as S, type TomlFormatResult as T, type XmlToJsonOptions as U, type ValidationResult as V, type YamlAnchorResolveError as W, type XmlFormatResult as X, type YamlAnchorInfo as Y, type YamlAnchorResolveResult as Z, type YamlDuplicateKeyEntry as _, type CaptionSpeedResult as a, type YamlDuplicateKeyResult as a0, alignMarkdownTables as a1, analyzeCaptionSpeed as a2, calculateMarkdownTaskListProgress as a3, checkMarkdownInternalLinks as a4, convertSubtitles as a5, csvToJson as a6, csvToSqlInsert as a7, dedupeNdjson as a8, detectDelimiter as a9, ndjsonToJsonArray as aA, parseCsv as aB, parseEnv as aC, parseFrontMatter as aD, parseIni as aE, parseSubtitleTimestamp as aF, parseSubtitles as aG, parseXmlToObject as aH, resolveYamlAnchors as aI, serializeSubtitles as aJ, shiftSubtitles as aK, stringifyIni as aL, toCsvString as aM, tomlToJson as aN, validateEnvKey as aO, validateIni as aP, validateMarkdownHeadingHierarchy as aQ, validateNdjson as aR, validateToml as aS, validateXml as aT, validateYaml as aU, xmlToJson as aV, detectSubtitleFormat as aa, diffEnvExample as ab, envToExport as ac, envToJson as ad, findCsvDuplicateRows as ae, findYamlDuplicateKeys as af, formatNdjson as ag, formatSubtitleTimestamp as ah, formatToml as ai, formatXml as aj, generateMarkdownToc as ak, getSection as al, getSectionNames as am, getTomlStats as an, getXmlStats as ao, getYamlStats as ap, inferCsvColumnTypes as aq, iniToJson as ar, jsonArrayToNdjson as as, jsonToIni as at, jsonToToml as au, jsonToXml as av, minifyNdjson as aw, minifyToml as ax, minifyXml as ay, ndjsonToCsv as az, type ConvertedSubtitles as b, type CsvColumnType as c, data as d, type CsvColumnTypeInfo as e, type CsvColumnTypeOptions as f, type CsvColumnTypeResult as g, type CsvDuplicateGroup as h, type CsvDuplicateOptions as i, type CsvDuplicateResult as j, type CsvParseResult as k, type CsvToSqlOptions as l, type CsvToSqlResult as m, type EnvDiffResult as n, type EnvEntry as o, type EnvParseResult as p, type FrontMatterResult as q, type HeadingHierarchyResult as r, type HeadingIssue as s, type HeadingIssueType as t, type MarkdownAnchorLink as u, type MarkdownInternalLinkCheckResult as v, type MarkdownTableAlignResult as w, type MarkdownTableColumnAlignment as x, type MarkdownTableInfo as y, type MarkdownTaskListItem as z };
package/dist/index.cjs CHANGED
@@ -5638,6 +5638,7 @@ __export(data_exports, {
5638
5638
  alignMarkdownTables: () => alignMarkdownTables,
5639
5639
  analyzeCaptionSpeed: () => analyzeCaptionSpeed,
5640
5640
  calculateMarkdownTaskListProgress: () => calculateMarkdownTaskListProgress,
5641
+ checkMarkdownInternalLinks: () => checkMarkdownInternalLinks,
5641
5642
  convertSubtitles: () => convertSubtitles,
5642
5643
  csvToJson: () => csvToJson2,
5643
5644
  csvToSqlInsert: () => csvToSqlInsert,
@@ -5648,6 +5649,7 @@ __export(data_exports, {
5648
5649
  envToExport: () => envToExport,
5649
5650
  envToJson: () => envToJson,
5650
5651
  findCsvDuplicateRows: () => findCsvDuplicateRows,
5652
+ findYamlDuplicateKeys: () => findYamlDuplicateKeys,
5651
5653
  formatNdjson: () => formatNdjson,
5652
5654
  formatSubtitleTimestamp: () => formatSubtitleTimestamp,
5653
5655
  formatToml: () => formatToml,
@@ -7289,6 +7291,63 @@ function validateMarkdownHeadingHierarchy(markdown) {
7289
7291
  });
7290
7292
  return { headings, issues, h1Count };
7291
7293
  }
7294
+ var ANCHOR_LINK_RE = /\[([^\]]*)\]\(#([^)\s]+)\)/g;
7295
+ function checkMarkdownInternalLinks(markdown) {
7296
+ if (typeof markdown !== "string" || markdown.trim() === "") {
7297
+ return { error: "markdown is required" };
7298
+ }
7299
+ const lines = markdown.replace(/\r\n/g, "\n").split("\n");
7300
+ const headings = [];
7301
+ const seen = /* @__PURE__ */ new Map();
7302
+ let inFence = false;
7303
+ let fenceMarker = "";
7304
+ for (let i = 0; i < lines.length; i++) {
7305
+ const line = lines[i];
7306
+ const fenceMatch = line.match(/^\s*(```+|~~~+)/);
7307
+ if (fenceMatch) {
7308
+ if (!inFence) {
7309
+ inFence = true;
7310
+ fenceMarker = fenceMatch[1][0];
7311
+ } else if (fenceMatch[1][0] === fenceMarker) {
7312
+ inFence = false;
7313
+ }
7314
+ continue;
7315
+ }
7316
+ if (inFence) continue;
7317
+ const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
7318
+ if (!headingMatch) continue;
7319
+ const level = headingMatch[1].length;
7320
+ const text = stripInlineMarkdown(headingMatch[2]);
7321
+ if (text === "") continue;
7322
+ const slug = slugifyHeading(text, seen);
7323
+ headings.push({ level, text, slug, line: i + 1 });
7324
+ }
7325
+ const validSlugs = new Set(headings.map((h) => h.slug));
7326
+ const links = [];
7327
+ inFence = false;
7328
+ fenceMarker = "";
7329
+ for (let i = 0; i < lines.length; i++) {
7330
+ const line = lines[i];
7331
+ const fenceMatch = line.match(/^\s*(```+|~~~+)/);
7332
+ if (fenceMatch) {
7333
+ if (!inFence) {
7334
+ inFence = true;
7335
+ fenceMarker = fenceMatch[1][0];
7336
+ } else if (fenceMatch[1][0] === fenceMarker) {
7337
+ inFence = false;
7338
+ }
7339
+ continue;
7340
+ }
7341
+ if (inFence) continue;
7342
+ const re = new RegExp(ANCHOR_LINK_RE);
7343
+ let m;
7344
+ while ((m = re.exec(line)) !== null) {
7345
+ const target = m[2];
7346
+ links.push({ text: m[1], target, line: i + 1, valid: validSlugs.has(target) });
7347
+ }
7348
+ }
7349
+ return { headings, links, brokenLinks: links.filter((l) => !l.valid) };
7350
+ }
7292
7351
  function quoteSqlIdentifier(name, dialect) {
7293
7352
  if (dialect === "mysql") return "`" + name.replace(/`/g, "``") + "`";
7294
7353
  return '"' + name.replace(/"/g, '""') + '"';
@@ -7501,6 +7560,53 @@ function resolveYamlAnchors(yamlText) {
7501
7560
  const unusedAnchors = seenAnchorNames.filter((name) => !referencedNames.has(name));
7502
7561
  return { resolvedYaml, anchors, unusedAnchors, aliasCount };
7503
7562
  }
7563
+ function _matchYamlKey(lineText) {
7564
+ const dashMatch = /^(\s*)((?:-\s+)*)/.exec(lineText);
7565
+ const basePrefix = (dashMatch?.[1].length ?? 0) + (dashMatch?.[2].length ?? 0);
7566
+ const rest = lineText.slice(basePrefix);
7567
+ const quoted = /^(["'])((?:\\.|(?!\1).)*)\1(\s*:(?:\s|$))/.exec(rest);
7568
+ if (quoted) {
7569
+ return { key: quoted[2], prefixLength: basePrefix, matchLength: quoted[1].length * 2 + quoted[2].length, quote: quoted[1] };
7570
+ }
7571
+ const plain = /^([^\s:#][^:]*?)(\s*:(?:\s|$))/.exec(rest);
7572
+ if (plain) {
7573
+ return { key: plain[1], prefixLength: basePrefix, matchLength: plain[1].length, quote: null };
7574
+ }
7575
+ return null;
7576
+ }
7577
+ function _maskYamlKey(lineText, match, n) {
7578
+ const suffix = `__dup${n}__`;
7579
+ const before = lineText.slice(0, match.prefixLength);
7580
+ const keyPart = lineText.slice(match.prefixLength, match.prefixLength + match.matchLength);
7581
+ const after = lineText.slice(match.prefixLength + match.matchLength);
7582
+ if (match.quote) {
7583
+ return `${before}${keyPart.slice(0, -1)}${suffix}${match.quote}${after}`;
7584
+ }
7585
+ return `${before}${keyPart}${suffix}${after}`;
7586
+ }
7587
+ var _MAX_YAML_DUPLICATE_PASSES = 500;
7588
+ function findYamlDuplicateKeys(yamlText) {
7589
+ if (!yamlText || !yamlText.trim()) return { error: "Input is empty" };
7590
+ const lines = yamlText.split("\n");
7591
+ const duplicates = [];
7592
+ for (let pass = 0; pass < _MAX_YAML_DUPLICATE_PASSES; pass++) {
7593
+ try {
7594
+ yaml2__namespace.load(lines.join("\n"));
7595
+ return { duplicateCount: duplicates.length, duplicates };
7596
+ } catch (e) {
7597
+ const err = e;
7598
+ const reason = err.reason ?? err.message;
7599
+ if (!/duplicated mapping key/i.test(reason)) return { error: reason };
7600
+ const lineIdx = err.mark?.line;
7601
+ if (lineIdx == null || lineIdx < 0 || lineIdx >= lines.length) return { error: reason };
7602
+ const match = _matchYamlKey(lines[lineIdx]);
7603
+ if (!match) return { error: reason };
7604
+ duplicates.push({ key: match.key, line: lineIdx + 1, column: match.prefixLength + 1 });
7605
+ lines[lineIdx] = _maskYamlKey(lines[lineIdx], match, duplicates.length);
7606
+ }
7607
+ }
7608
+ return { error: "Too many duplicate keys to fully enumerate" };
7609
+ }
7504
7610
  function calculateMarkdownTaskListProgress(markdown) {
7505
7611
  if (typeof markdown !== "string") return { error: "markdown must be a string" };
7506
7612
  const round23 = (n) => Math.round(n * 100) / 100;
@@ -9202,12 +9308,14 @@ __export(units_exports, {
9202
9308
  decimalToIp: () => decimalToIp,
9203
9309
  decimalToIpCidr: () => decimalToIpCidr,
9204
9310
  describePermissions: () => describePermissions,
9311
+ detectNegativeAmortization: () => detectNegativeAmortization,
9205
9312
  fitIntoBox: () => fitIntoBox,
9206
9313
  formatNumber: () => formatNumber,
9207
9314
  formatValue: () => formatValue,
9208
9315
  formatVwValue: () => formatVwValue,
9209
9316
  formatWithSeparator: () => formatWithSeparator,
9210
9317
  gcd: () => gcd,
9318
+ intersectSemverRanges: () => intersectSemverRanges,
9211
9319
  ipFromBinary: () => ipFromBinary,
9212
9320
  ipFromDecimal: () => ipFromDecimal,
9213
9321
  ipFromHex: () => ipFromHex,
@@ -10079,6 +10187,133 @@ function sortVersions(versions, order = "asc") {
10079
10187
  return order === "asc" ? cmp : -cmp;
10080
10188
  });
10081
10189
  }
10190
+ function tightenLower(a, b) {
10191
+ if (a.value === null) return b;
10192
+ if (b.value === null) return a;
10193
+ const cmp = compareVersionObjects(a.value, b.value);
10194
+ if (cmp > 0) return a;
10195
+ if (cmp < 0) return b;
10196
+ return { value: a.value, inclusive: a.inclusive && b.inclusive };
10197
+ }
10198
+ function tightenUpper(a, b) {
10199
+ if (a.value === null) return b;
10200
+ if (b.value === null) return a;
10201
+ const cmp = compareVersionObjects(a.value, b.value);
10202
+ if (cmp < 0) return a;
10203
+ if (cmp > 0) return b;
10204
+ return { value: a.value, inclusive: a.inclusive && b.inclusive };
10205
+ }
10206
+ function isValidInterval(lower, upper) {
10207
+ if (lower.value === null || upper.value === null) return true;
10208
+ const cmp = compareVersionObjects(lower.value, upper.value);
10209
+ if (cmp < 0) return true;
10210
+ if (cmp > 0) return false;
10211
+ return lower.inclusive && upper.inclusive;
10212
+ }
10213
+ function formatVersionBound(v) {
10214
+ let s = `${v.major}.${v.minor}.${v.patch}`;
10215
+ if (v.prerelease) s += `-${v.prerelease}`;
10216
+ if (v.build) s += `+${v.build}`;
10217
+ return s;
10218
+ }
10219
+ function intervalToRangeString(interval) {
10220
+ const { lower, upper } = interval;
10221
+ if (lower.value === null && upper.value === null) return "*";
10222
+ if (lower.value !== null && upper.value !== null) {
10223
+ const cmp = compareVersionObjects(lower.value, upper.value);
10224
+ if (cmp === 0 && lower.inclusive && upper.inclusive) return formatVersionBound(lower.value);
10225
+ }
10226
+ const parts = [];
10227
+ if (lower.value !== null) parts.push(`${lower.inclusive ? ">=" : ">"}${formatVersionBound(lower.value)}`);
10228
+ if (upper.value !== null) parts.push(`${upper.inclusive ? "<=" : "<"}${formatVersionBound(upper.value)}`);
10229
+ return parts.length ? parts.join(" ") : "*";
10230
+ }
10231
+ function parseSingleConstraintToInterval(range) {
10232
+ if (range === "*" || range === "") {
10233
+ return { lower: { value: null, inclusive: true }, upper: { value: null, inclusive: true } };
10234
+ }
10235
+ const caretMatch = range.match(/^\^v?(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9._-]+))?$/);
10236
+ if (caretMatch) {
10237
+ const major = parseInt(caretMatch[1], 10);
10238
+ const minor = parseInt(caretMatch[2], 10);
10239
+ const patch = parseInt(caretMatch[3], 10);
10240
+ const pre = caretMatch[4];
10241
+ const lowerVal = { major, minor, patch, prerelease: pre, raw: range };
10242
+ let upperVal;
10243
+ if (major !== 0) upperVal = { major: major + 1, minor: 0, patch: 0, raw: "" };
10244
+ else if (minor !== 0) upperVal = { major: 0, minor: minor + 1, patch: 0, raw: "" };
10245
+ else upperVal = { major: 0, minor: 0, patch: patch + 1, raw: "" };
10246
+ return { lower: { value: lowerVal, inclusive: true }, upper: { value: upperVal, inclusive: false } };
10247
+ }
10248
+ const tildeMatch = range.match(/^~v?(\d+)\.(\d+)\.(\d+)(?:-([a-zA-Z0-9._-]+))?$/);
10249
+ if (tildeMatch) {
10250
+ const major = parseInt(tildeMatch[1], 10);
10251
+ const minor = parseInt(tildeMatch[2], 10);
10252
+ const patch = parseInt(tildeMatch[3], 10);
10253
+ const pre = tildeMatch[4];
10254
+ const lowerVal = { major, minor, patch, prerelease: pre, raw: range };
10255
+ const upperVal = { major, minor: minor + 1, patch: 0, raw: "" };
10256
+ return { lower: { value: lowerVal, inclusive: true }, upper: { value: upperVal, inclusive: false } };
10257
+ }
10258
+ const opMatch = range.match(/^(>=|<=|>|<|=)v?(.+)$/);
10259
+ if (opMatch) {
10260
+ const op = opMatch[1];
10261
+ const parsed = parseSemver(opMatch[2]);
10262
+ if ("error" in parsed) return parsed;
10263
+ if (op === ">=") return { lower: { value: parsed, inclusive: true }, upper: { value: null, inclusive: true } };
10264
+ if (op === "<=") return { lower: { value: null, inclusive: true }, upper: { value: parsed, inclusive: true } };
10265
+ if (op === ">") return { lower: { value: parsed, inclusive: false }, upper: { value: null, inclusive: true } };
10266
+ if (op === "<") return { lower: { value: null, inclusive: true }, upper: { value: parsed, inclusive: false } };
10267
+ return { lower: { value: parsed, inclusive: true }, upper: { value: parsed, inclusive: true } };
10268
+ }
10269
+ const plain = parseSemver(range);
10270
+ if (!("error" in plain)) {
10271
+ return { lower: { value: plain, inclusive: true }, upper: { value: plain, inclusive: true } };
10272
+ }
10273
+ return { error: `Unsupported range: '${range}'` };
10274
+ }
10275
+ function rangeToIntervals(range) {
10276
+ const trimmed = range.trim();
10277
+ if (trimmed === "") {
10278
+ return [{ lower: { value: null, inclusive: true }, upper: { value: null, inclusive: true } }];
10279
+ }
10280
+ const orParts = trimmed.split("||").map((s) => s.trim());
10281
+ const intervals = [];
10282
+ for (const orPart of orParts) {
10283
+ const andTokens = orPart.split(/\s+/).filter(Boolean);
10284
+ let combined = {
10285
+ lower: { value: null, inclusive: true },
10286
+ upper: { value: null, inclusive: true }
10287
+ };
10288
+ for (const token of andTokens) {
10289
+ const parsed = parseSingleConstraintToInterval(token);
10290
+ if ("error" in parsed) return parsed;
10291
+ combined = {
10292
+ lower: tightenLower(combined.lower, parsed.lower),
10293
+ upper: tightenUpper(combined.upper, parsed.upper)
10294
+ };
10295
+ }
10296
+ intervals.push(combined);
10297
+ }
10298
+ return intervals;
10299
+ }
10300
+ function intersectSemverRanges(rangeA, rangeB) {
10301
+ const intervalsA = rangeToIntervals(rangeA);
10302
+ if (!Array.isArray(intervalsA)) return intervalsA;
10303
+ const intervalsB = rangeToIntervals(rangeB);
10304
+ if (!Array.isArray(intervalsB)) return intervalsB;
10305
+ const results = [];
10306
+ for (const a of intervalsA) {
10307
+ for (const b of intervalsB) {
10308
+ const lower = tightenLower(a.lower, b.lower);
10309
+ const upper = tightenUpper(a.upper, b.upper);
10310
+ if (isValidInterval(lower, upper)) results.push({ lower, upper });
10311
+ }
10312
+ }
10313
+ if (results.length === 0) return { overlaps: false, intersection: null };
10314
+ const formatted = Array.from(new Set(results.map(intervalToRangeString)));
10315
+ return { overlaps: true, intersection: formatted.join(" || ") };
10316
+ }
10082
10317
  var CARD_NETWORK_RULES = [
10083
10318
  { name: "American Express", lengths: [15], test: (d) => /^3[47]/.test(d) },
10084
10319
  { name: "Diners Club", lengths: [14], test: (d) => /^3(?:0[0-5]|[68])/.test(d) },
@@ -12118,6 +12353,58 @@ function calculateSalesCommission(input) {
12118
12353
  breakdown
12119
12354
  };
12120
12355
  }
12356
+ var NEGATIVE_AMORTIZATION_MAX_PROJECTION_MONTHS = 600;
12357
+ function detectNegativeAmortization(input) {
12358
+ const { principal, annualRatePercent, monthlyPayment } = input;
12359
+ if (!Number.isFinite(principal) || principal <= 0) {
12360
+ return { error: "principal must be a positive number" };
12361
+ }
12362
+ if (!Number.isFinite(annualRatePercent) || annualRatePercent < 0) {
12363
+ return { error: "annualRatePercent must be zero or a positive number" };
12364
+ }
12365
+ if (!Number.isFinite(monthlyPayment) || monthlyPayment < 0) {
12366
+ return { error: "monthlyPayment must be zero or a positive number" };
12367
+ }
12368
+ if (input.projectionMonths !== void 0 && (!Number.isInteger(input.projectionMonths) || input.projectionMonths <= 0)) {
12369
+ return { error: "projectionMonths must be a positive whole number" };
12370
+ }
12371
+ if (input.capPercent !== void 0 && (!Number.isFinite(input.capPercent) || input.capPercent <= 0)) {
12372
+ return { error: "capPercent must be a positive number" };
12373
+ }
12374
+ const monthlyRate = annualRatePercent / 100 / 12;
12375
+ const monthlyInterest = principal * monthlyRate;
12376
+ const shortfall = Math.max(0, round2(monthlyInterest - monthlyPayment));
12377
+ const isNegativeAmortizing = monthlyPayment < monthlyInterest;
12378
+ const projectionMonths = Math.min(input.projectionMonths ?? 12, NEGATIVE_AMORTIZATION_MAX_PROJECTION_MONTHS);
12379
+ const capBalance = input.capPercent != null ? principal * (input.capPercent / 100) : null;
12380
+ const projection = [];
12381
+ let balance = principal;
12382
+ let capCrossedMonth = null;
12383
+ for (let month = 1; month <= projectionMonths; month++) {
12384
+ const interest = balance * monthlyRate;
12385
+ const endingBalance = balance + interest - monthlyPayment;
12386
+ projection.push({
12387
+ month,
12388
+ startingBalance: round2(balance),
12389
+ interest: round2(interest),
12390
+ payment: round2(monthlyPayment),
12391
+ endingBalance: round2(Math.max(endingBalance, 0))
12392
+ });
12393
+ if (capBalance != null && capCrossedMonth == null && endingBalance >= capBalance) {
12394
+ capCrossedMonth = month;
12395
+ }
12396
+ balance = endingBalance;
12397
+ if (balance <= 0) break;
12398
+ }
12399
+ return {
12400
+ monthlyInterest: round2(monthlyInterest),
12401
+ isNegativeAmortizing,
12402
+ shortfall,
12403
+ breakEvenPayment: round2(monthlyInterest),
12404
+ projection,
12405
+ capCrossedMonth
12406
+ };
12407
+ }
12121
12408
 
12122
12409
  // src/tools/network.ts
12123
12410
  var network_exports = {};
package/dist/index.d.cts CHANGED
@@ -2,10 +2,10 @@ export { j as json } from './json-Ca6gZCNB.cjs';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.cjs';
3
3
  export { h as hashing } from './hashing-CJjlvqS_.cjs';
4
4
  export { t as text } from './text-DOopHoK3.cjs';
5
- export { d as data } from './data-Cz1Q0sg0.cjs';
5
+ export { d as data } from './data-cDudn2P6.cjs';
6
6
  export { g as generators } from './generators-DAXXrMvG.cjs';
7
7
  export { t as time } from './time-VMAy_SrV.cjs';
8
- export { u as units } from './units-B6aXeGr6.cjs';
8
+ export { u as units } from './units-DnWrOTSV.cjs';
9
9
  export { n as network } from './network-ylRtLPEs.cjs';
10
10
  export { a as api } from './api-CQnIUrVB.cjs';
11
11
  export { c as code } from './code-DvJYYTea.cjs';
package/dist/index.d.ts CHANGED
@@ -2,10 +2,10 @@ export { j as json } from './json-Ca6gZCNB.js';
2
2
  export { e as encoding } from './encoding-Dk3wpmb3.js';
3
3
  export { h as hashing } from './hashing-CJjlvqS_.js';
4
4
  export { t as text } from './text-DOopHoK3.js';
5
- export { d as data } from './data-Cz1Q0sg0.js';
5
+ export { d as data } from './data-cDudn2P6.js';
6
6
  export { g as generators } from './generators-DAXXrMvG.js';
7
7
  export { t as time } from './time-VMAy_SrV.js';
8
- export { u as units } from './units-B6aXeGr6.js';
8
+ export { u as units } from './units-DnWrOTSV.js';
9
9
  export { n as network } from './network-ylRtLPEs.js';
10
10
  export { a as api } from './api-CQnIUrVB.js';
11
11
  export { c as code } from './code-DvJYYTea.js';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { media_exports as media } from './chunk-ZWFZRDQ4.js';
2
- export { units_exports as units } from './chunk-LKFMBUJZ.js';
2
+ export { units_exports as units } from './chunk-XAPHAUPI.js';
3
3
  export { network_exports as network } from './chunk-SW3J5CAI.js';
4
4
  export { api_exports as api } from './chunk-U2HREMZU.js';
5
5
  export { code_exports as code } from './chunk-KYBI62YY.js';
@@ -11,7 +11,7 @@ export { json_exports as json } from './chunk-WUOZHCIC.js';
11
11
  export { encoding_exports as encoding } from './chunk-DOWQZUTP.js';
12
12
  export { hashing_exports as hashing } from './chunk-PET2CGTH.js';
13
13
  export { text_exports as text } from './chunk-YQJ7CEUL.js';
14
- export { data_exports as data } from './chunk-CUQDHXUX.js';
14
+ export { data_exports as data } from './chunk-2QNU6KRL.js';
15
15
  export { generators_exports as generators } from './chunk-422ICOZX.js';
16
16
  export { time_exports as time } from './chunk-6EJVNQSY.js';
17
17
  import './chunk-MLKGABMK.js';
@@ -1622,6 +1622,63 @@ function validateMarkdownHeadingHierarchy(markdown) {
1622
1622
  });
1623
1623
  return { headings, issues, h1Count };
1624
1624
  }
1625
+ var ANCHOR_LINK_RE = /\[([^\]]*)\]\(#([^)\s]+)\)/g;
1626
+ function checkMarkdownInternalLinks(markdown) {
1627
+ if (typeof markdown !== "string" || markdown.trim() === "") {
1628
+ return { error: "markdown is required" };
1629
+ }
1630
+ const lines = markdown.replace(/\r\n/g, "\n").split("\n");
1631
+ const headings = [];
1632
+ const seen = /* @__PURE__ */ new Map();
1633
+ let inFence = false;
1634
+ let fenceMarker = "";
1635
+ for (let i = 0; i < lines.length; i++) {
1636
+ const line = lines[i];
1637
+ const fenceMatch = line.match(/^\s*(```+|~~~+)/);
1638
+ if (fenceMatch) {
1639
+ if (!inFence) {
1640
+ inFence = true;
1641
+ fenceMarker = fenceMatch[1][0];
1642
+ } else if (fenceMatch[1][0] === fenceMarker) {
1643
+ inFence = false;
1644
+ }
1645
+ continue;
1646
+ }
1647
+ if (inFence) continue;
1648
+ const headingMatch = line.match(/^(#{1,6})\s+(.+?)\s*#*\s*$/);
1649
+ if (!headingMatch) continue;
1650
+ const level = headingMatch[1].length;
1651
+ const text = stripInlineMarkdown(headingMatch[2]);
1652
+ if (text === "") continue;
1653
+ const slug = slugifyHeading(text, seen);
1654
+ headings.push({ level, text, slug, line: i + 1 });
1655
+ }
1656
+ const validSlugs = new Set(headings.map((h) => h.slug));
1657
+ const links = [];
1658
+ inFence = false;
1659
+ fenceMarker = "";
1660
+ for (let i = 0; i < lines.length; i++) {
1661
+ const line = lines[i];
1662
+ const fenceMatch = line.match(/^\s*(```+|~~~+)/);
1663
+ if (fenceMatch) {
1664
+ if (!inFence) {
1665
+ inFence = true;
1666
+ fenceMarker = fenceMatch[1][0];
1667
+ } else if (fenceMatch[1][0] === fenceMarker) {
1668
+ inFence = false;
1669
+ }
1670
+ continue;
1671
+ }
1672
+ if (inFence) continue;
1673
+ const re = new RegExp(ANCHOR_LINK_RE);
1674
+ let m;
1675
+ while ((m = re.exec(line)) !== null) {
1676
+ const target = m[2];
1677
+ links.push({ text: m[1], target, line: i + 1, valid: validSlugs.has(target) });
1678
+ }
1679
+ }
1680
+ return { headings, links, brokenLinks: links.filter((l) => !l.valid) };
1681
+ }
1625
1682
  function quoteSqlIdentifier(name, dialect) {
1626
1683
  if (dialect === "mysql") return "`" + name.replace(/`/g, "``") + "`";
1627
1684
  return '"' + name.replace(/"/g, '""') + '"';
@@ -1834,6 +1891,53 @@ function resolveYamlAnchors(yamlText) {
1834
1891
  const unusedAnchors = seenAnchorNames.filter((name) => !referencedNames.has(name));
1835
1892
  return { resolvedYaml, anchors, unusedAnchors, aliasCount };
1836
1893
  }
1894
+ function _matchYamlKey(lineText) {
1895
+ const dashMatch = /^(\s*)((?:-\s+)*)/.exec(lineText);
1896
+ const basePrefix = (dashMatch?.[1].length ?? 0) + (dashMatch?.[2].length ?? 0);
1897
+ const rest = lineText.slice(basePrefix);
1898
+ const quoted = /^(["'])((?:\\.|(?!\1).)*)\1(\s*:(?:\s|$))/.exec(rest);
1899
+ if (quoted) {
1900
+ return { key: quoted[2], prefixLength: basePrefix, matchLength: quoted[1].length * 2 + quoted[2].length, quote: quoted[1] };
1901
+ }
1902
+ const plain = /^([^\s:#][^:]*?)(\s*:(?:\s|$))/.exec(rest);
1903
+ if (plain) {
1904
+ return { key: plain[1], prefixLength: basePrefix, matchLength: plain[1].length, quote: null };
1905
+ }
1906
+ return null;
1907
+ }
1908
+ function _maskYamlKey(lineText, match, n) {
1909
+ const suffix = `__dup${n}__`;
1910
+ const before = lineText.slice(0, match.prefixLength);
1911
+ const keyPart = lineText.slice(match.prefixLength, match.prefixLength + match.matchLength);
1912
+ const after = lineText.slice(match.prefixLength + match.matchLength);
1913
+ if (match.quote) {
1914
+ return `${before}${keyPart.slice(0, -1)}${suffix}${match.quote}${after}`;
1915
+ }
1916
+ return `${before}${keyPart}${suffix}${after}`;
1917
+ }
1918
+ var _MAX_YAML_DUPLICATE_PASSES = 500;
1919
+ function findYamlDuplicateKeys(yamlText) {
1920
+ if (!yamlText || !yamlText.trim()) return { error: "Input is empty" };
1921
+ const lines = yamlText.split("\n");
1922
+ const duplicates = [];
1923
+ for (let pass = 0; pass < _MAX_YAML_DUPLICATE_PASSES; pass++) {
1924
+ try {
1925
+ yaml__namespace.load(lines.join("\n"));
1926
+ return { duplicateCount: duplicates.length, duplicates };
1927
+ } catch (e) {
1928
+ const err = e;
1929
+ const reason = err.reason ?? err.message;
1930
+ if (!/duplicated mapping key/i.test(reason)) return { error: reason };
1931
+ const lineIdx = err.mark?.line;
1932
+ if (lineIdx == null || lineIdx < 0 || lineIdx >= lines.length) return { error: reason };
1933
+ const match = _matchYamlKey(lines[lineIdx]);
1934
+ if (!match) return { error: reason };
1935
+ duplicates.push({ key: match.key, line: lineIdx + 1, column: match.prefixLength + 1 });
1936
+ lines[lineIdx] = _maskYamlKey(lines[lineIdx], match, duplicates.length);
1937
+ }
1938
+ }
1939
+ return { error: "Too many duplicate keys to fully enumerate" };
1940
+ }
1837
1941
  function calculateMarkdownTaskListProgress(markdown) {
1838
1942
  if (typeof markdown !== "string") return { error: "markdown must be a string" };
1839
1943
  const round2 = (n) => Math.round(n * 100) / 100;
@@ -2021,6 +2125,7 @@ function alignMarkdownTables(markdown) {
2021
2125
  exports.alignMarkdownTables = alignMarkdownTables;
2022
2126
  exports.analyzeCaptionSpeed = analyzeCaptionSpeed;
2023
2127
  exports.calculateMarkdownTaskListProgress = calculateMarkdownTaskListProgress;
2128
+ exports.checkMarkdownInternalLinks = checkMarkdownInternalLinks;
2024
2129
  exports.convertSubtitles = convertSubtitles;
2025
2130
  exports.csvToJson = csvToJson;
2026
2131
  exports.csvToSqlInsert = csvToSqlInsert;
@@ -2031,6 +2136,7 @@ exports.diffEnvExample = diffEnvExample;
2031
2136
  exports.envToExport = envToExport;
2032
2137
  exports.envToJson = envToJson;
2033
2138
  exports.findCsvDuplicateRows = findCsvDuplicateRows;
2139
+ exports.findYamlDuplicateKeys = findYamlDuplicateKeys;
2034
2140
  exports.formatNdjson = formatNdjson;
2035
2141
  exports.formatSubtitleTimestamp = formatSubtitleTimestamp;
2036
2142
  exports.formatToml = formatToml;