ssqch 0.11.0 → 0.13.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.
Files changed (138) hide show
  1. package/bundled/completions/bash +67 -9
  2. package/bundled/completions/elvish +24 -4
  3. package/bundled/completions/fish +37 -25
  4. package/bundled/completions/powershell +26 -4
  5. package/bundled/completions/zsh +45 -10
  6. package/bundled/docs/agents.md +2 -2
  7. package/bundled/docs/build-summary.md +1 -1
  8. package/bundled/docs/comparing-builds.md +7 -4
  9. package/bundled/docs/configuring.md +7 -12
  10. package/bundled/docs/deploying.md +1 -1
  11. package/bundled/docs/field-guide.md +4 -4
  12. package/bundled/docs/github-pages.md +2 -1
  13. package/bundled/docs/index.md +1 -1
  14. package/bundled/docs/install.md +1 -1
  15. package/bundled/docs/known-gaps.md +1 -1
  16. package/bundled/docs/markdown.md +11 -13
  17. package/bundled/docs/nav.yml +6 -1
  18. package/bundled/docs/netlify.md +4 -2
  19. package/bundled/docs/patrol.md +48 -0
  20. package/bundled/docs/plugins.md +6 -4
  21. package/bundled/docs/robots.md +72 -0
  22. package/bundled/docs/seo.md +2 -38
  23. package/bundled/docs/serving-markdown.md +142 -0
  24. package/bundled/docs/template-languages.md +2 -1
  25. package/bundled/docs/templates.md +2 -1
  26. package/bundled/docs/trailheads/from-component-frameworks.md +9 -10
  27. package/bundled/docs/trailheads/from-hugo.md +5 -3
  28. package/bundled/docs/trailheads/from-jekyll.md +54 -13
  29. package/bundled/docs/trailheads/from-mkdocs.md +15 -12
  30. package/bundled/docs/trailheads/from-vitepress.md +142 -0
  31. package/bundled/docs/trailheads.md +5 -5
  32. package/bundled/docs/where-values-come-from.md +5 -5
  33. package/bundled/docs/writing-plugins.md +69 -0
  34. package/bundled/ssqch.d.ts +150 -34
  35. package/bundled/starter/engines/index.edge +1 -0
  36. package/bundled/starter/engines/index.ejs +1 -0
  37. package/bundled/starter/engines/index.hbs +1 -0
  38. package/bundled/starter/engines/index.liquid +1 -0
  39. package/bundled/starter/engines/layout.edge +7 -0
  40. package/bundled/starter/engines/layout.ejs +4 -0
  41. package/bundled/starter/engines/layout.hbs +4 -0
  42. package/bundled/starter/engines/layout.liquid +4 -0
  43. package/bundled/starter/src/_data/site.json +1 -0
  44. package/bundled/starter/src/_includes/layout.jinja +4 -0
  45. package/bundled/starter/src/index.jinja +1 -0
  46. package/bundled/starter/ssqch.config.js +14 -1
  47. package/bundled/starter-docs/engines/edge/base.edge +7 -0
  48. package/bundled/starter-docs/engines/edge/doc.edge +4 -0
  49. package/bundled/starter-docs/engines/ejs/base.ejs +4 -0
  50. package/bundled/starter-docs/engines/ejs/doc.ejs +4 -0
  51. package/bundled/starter-docs/engines/hbs/base.hbs +4 -0
  52. package/bundled/starter-docs/engines/hbs/doc.hbs +3 -0
  53. package/bundled/starter-docs/engines/liquid/base.liquid +4 -0
  54. package/bundled/starter-docs/engines/liquid/doc.liquid +4 -0
  55. package/bundled/starter-docs/src/_data/site.json +1 -0
  56. package/bundled/starter-docs/src/_includes/base.jinja +4 -0
  57. package/bundled/starter-docs/src/_includes/doc.jinja +4 -0
  58. package/bundled/starter-docs/src/assets/docs.css +4 -0
  59. package/bundled/starter-docs/src/assets/docs.js +17 -0
  60. package/bundled/starter-docs/ssqch.config.js +14 -1
  61. package/lib/assets.js +13 -11
  62. package/lib/chunk-25WERNDD.js +112 -0
  63. package/lib/{chunk-H5K2ZE7B.js → chunk-2BJFGKOE.js} +13 -5
  64. package/lib/chunk-2FKYWYAB.js +268 -0
  65. package/lib/{chunk-LJOURBYT.js → chunk-3ZTRIO6O.js} +21 -19
  66. package/lib/{chunk-IOBC665M.js → chunk-4AZFCSGJ.js} +5 -3
  67. package/lib/{chunk-HWW5NCVJ.js → chunk-4Q6WMTER.js} +1 -1
  68. package/lib/{chunk-V2FSMOFX.js → chunk-55WXDGO4.js} +3 -3
  69. package/lib/{chunk-ZR3JYLFB.js → chunk-6FY77I4M.js} +331 -58
  70. package/lib/{chunk-JC54PHIT.js → chunk-6OUCRDYI.js} +514 -141
  71. package/lib/{chunk-ERAIEV3O.js → chunk-6U5VIQVY.js} +9 -7
  72. package/lib/{chunk-Z5OP43HU.js → chunk-7U5GWTEH.js} +455 -94
  73. package/lib/{chunk-CMJ7X5WW.js → chunk-AIJNG6MJ.js} +3 -2
  74. package/lib/{chunk-3K237XAX.js → chunk-C2Q7JKFI.js} +12 -10
  75. package/lib/{chunk-GS5B3CBW.js → chunk-DDV6JEC2.js} +1 -1
  76. package/lib/{chunk-A75EVUJX.js → chunk-DFJFHULZ.js} +47 -20
  77. package/lib/{chunk-KZZS4W2V.js → chunk-ENWDM2RW.js} +45 -42
  78. package/lib/{chunk-I3HYKEEW.js → chunk-ER72RPD6.js} +3 -3
  79. package/lib/chunk-F3JPNFCZ.js +23 -0
  80. package/lib/{chunk-B5E27PLU.js → chunk-FENJHLNM.js} +6 -3
  81. package/lib/{chunk-UU43WIZG.js → chunk-FJML7INB.js} +4 -2
  82. package/lib/{chunk-KCF2Z6N7.js → chunk-FQZDUDFK.js} +5 -3
  83. package/lib/{chunk-GJNIQAIH.js → chunk-GSNRAGKQ.js} +13 -6
  84. package/lib/{chunk-443ZQLVX.js → chunk-GU7BBYWB.js} +5 -4
  85. package/lib/{chunk-X2GAVYV2.js → chunk-HDKU6LRI.js} +110 -748
  86. package/lib/chunk-J3C2LEW7.js +121 -0
  87. package/lib/{chunk-XS4EJSEK.js → chunk-K5WZ2VYK.js} +7 -5
  88. package/lib/{chunk-3HZZY3Y7.js → chunk-OOKBXQAY.js} +7 -6
  89. package/lib/chunk-P2WS4RM4.js +707 -0
  90. package/lib/{chunk-RBNPBTDP.js → chunk-SNQOHNXE.js} +1 -1
  91. package/lib/{chunk-HFSWUTXX.js → chunk-SPIFZBIW.js} +1 -1
  92. package/lib/{chunk-QLUTNR37.js → chunk-T5IUI7W7.js} +12 -11
  93. package/lib/{chunk-ZINLHOX4.js → chunk-TGSVSG2G.js} +3 -2
  94. package/lib/{chunk-2L3HR67O.js → chunk-U2KEMVXO.js} +24 -16
  95. package/lib/{chunk-RYIWYWRQ.js → chunk-UHRBPZ4A.js} +7 -5
  96. package/lib/{chunk-2QTJTEBV.js → chunk-ULCT3PAV.js} +1 -1
  97. package/lib/{chunk-FCM3NYFR.js → chunk-UZNUS7RP.js} +12 -9
  98. package/lib/{chunk-GLJQ4C76.js → chunk-V3G2QGL3.js} +13 -106
  99. package/lib/{chunk-Z44IAMNG.js → chunk-VILOEVK7.js} +60 -28
  100. package/lib/chunk-VJWQSYEG.js +119 -0
  101. package/lib/{chunk-5ELAUHRL.js → chunk-WGAIE3DD.js} +23 -19
  102. package/lib/{chunk-OQGXZYZS.js → chunk-WUCRAV36.js} +13 -7
  103. package/lib/{chunk-RZYAIX2R.js → chunk-XYAWJTHM.js} +11 -10
  104. package/lib/{chunk-OSBEH67S.js → chunk-YA23NDMW.js} +5 -3
  105. package/lib/{chunk-AIMEXBTK.js → chunk-YNJNMQWU.js} +37 -142
  106. package/lib/{chunk-QJ5ZFTML.js → chunk-ZMG25MXF.js} +20 -18
  107. package/lib/cli.js +72 -35
  108. package/lib/elements.js +13 -11
  109. package/lib/from-hugo.js +36 -0
  110. package/lib/from-jekyll.js +41 -0
  111. package/lib/from-mkdocs.js +49 -0
  112. package/lib/from-vitepress.js +49 -0
  113. package/lib/image.js +12 -11
  114. package/lib/links.js +13 -11
  115. package/lib/llms.js +613 -0
  116. package/lib/minify.js +14 -12
  117. package/lib/redirects.js +13 -11
  118. package/lib/robots.js +87 -0
  119. package/lib/rss.js +24 -13
  120. package/lib/sass.js +12 -11
  121. package/lib/sitemap.js +23 -18
  122. package/lib/ssqch.js +6 -5
  123. package/lib/vue.js +400 -0
  124. package/package.json +29 -1
  125. package/types/from-hugo.d.ts +5 -0
  126. package/types/from-jekyll.d.ts +11 -0
  127. package/types/from-mkdocs.d.ts +11 -0
  128. package/types/from-vitepress.d.ts +5 -0
  129. package/types/index.d.ts +51 -31
  130. package/types/llms.d.ts +27 -0
  131. package/types/robots.d.ts +13 -0
  132. package/types/sass.d.ts +1 -1
  133. package/types/sitemap.d.ts +2 -2
  134. package/types/vue.d.ts +17 -0
  135. package/wasm/markdown.wasm +0 -0
  136. package/lib/chunk-RVXGUMFI.js +0 -21
  137. /package/lib/{chunk-ZR3JYLFB.js.LEGAL.txt → chunk-6FY77I4M.js.LEGAL.txt} +0 -0
  138. /package/lib/{chunk-AIMEXBTK.js.LEGAL.txt → chunk-YNJNMQWU.js.LEGAL.txt} +0 -0
@@ -0,0 +1,707 @@
1
+ import { createRequire as __ssqchCreateRequire } from "node:module";
2
+ const require = __ssqchCreateRequire(import.meta.url);
3
+
4
+ // src/myers.ts
5
+ function diffOps(old, next) {
6
+ const capture = new Capture();
7
+ const compact = new Compact(new Replace(capture), old, next);
8
+ diff(compact, old, 0, old.length, next, 0, next.length);
9
+ return capture.ops;
10
+ }
11
+ var Capture = class {
12
+ ops = [];
13
+ equal(oldIndex, newIndex, len) {
14
+ this.ops.push({ tag: "equal", oldIndex, oldLen: len, newIndex, newLen: len });
15
+ }
16
+ delete(oldIndex, oldLen, newIndex) {
17
+ this.ops.push({ tag: "delete", oldIndex, oldLen, newIndex, newLen: 0 });
18
+ }
19
+ insert(oldIndex, newIndex, newLen) {
20
+ this.ops.push({ tag: "insert", oldIndex, oldLen: 0, newIndex, newLen });
21
+ }
22
+ replace(oldIndex, oldLen, newIndex, newLen) {
23
+ this.ops.push({ tag: "replace", oldIndex, oldLen, newIndex, newLen });
24
+ }
25
+ finish() {
26
+ }
27
+ };
28
+ var Replace = class {
29
+ d;
30
+ del;
31
+ ins;
32
+ eq;
33
+ constructor(d) {
34
+ this.d = d;
35
+ }
36
+ flushEq() {
37
+ if (this.eq) {
38
+ const [o, n, len] = this.eq;
39
+ this.eq = void 0;
40
+ this.d.equal(o, n, len);
41
+ }
42
+ }
43
+ flushDelIns() {
44
+ if (this.del) {
45
+ const [o, ol, n] = this.del;
46
+ this.del = void 0;
47
+ if (this.ins) {
48
+ const [, insNew, insLen] = this.ins;
49
+ this.ins = void 0;
50
+ this.d.replace(o, ol, insNew, insLen);
51
+ } else this.d.delete(o, ol, n);
52
+ } else if (this.ins) {
53
+ const [o, n, nl] = this.ins;
54
+ this.ins = void 0;
55
+ this.d.insert(o, n, nl);
56
+ }
57
+ }
58
+ equal(oldIndex, newIndex, len) {
59
+ this.flushDelIns();
60
+ this.eq = this.eq ? [this.eq[0], this.eq[1], this.eq[2] + len] : [oldIndex, newIndex, len];
61
+ }
62
+ delete(oldIndex, oldLen, newIndex) {
63
+ this.flushEq();
64
+ this.del = this.del ? [this.del[0], this.del[1] + oldLen, this.del[2]] : [oldIndex, oldLen, newIndex];
65
+ }
66
+ insert(oldIndex, newIndex, newLen) {
67
+ this.flushEq();
68
+ this.ins = this.ins ? [this.ins[0], this.ins[1], this.ins[2] + newLen] : [oldIndex, newIndex, newLen];
69
+ }
70
+ replace(oldIndex, oldLen, newIndex, newLen) {
71
+ this.flushEq();
72
+ this.d.replace(oldIndex, oldLen, newIndex, newLen);
73
+ }
74
+ finish() {
75
+ this.flushEq();
76
+ this.flushDelIns();
77
+ this.d.finish();
78
+ }
79
+ };
80
+ var EQUAL = 0;
81
+ var DELETE = 1;
82
+ var INSERT = 2;
83
+ var oldStart = (op) => op.oldIndex;
84
+ var oldEnd = (op) => op.oldIndex + (op.tag === INSERT ? 0 : op.len);
85
+ var newStart = (op) => op.newIndex;
86
+ var newEnd = (op) => op.newIndex + (op.tag === DELETE ? 0 : op.len);
87
+ var isEmpty = (op) => oldEnd(op) <= oldStart(op) && newEnd(op) <= newStart(op);
88
+ var adjust = (op, offset, len) => {
89
+ op.oldIndex += offset;
90
+ op.newIndex += offset;
91
+ op.len += len;
92
+ };
93
+ var shiftLeft = (op, n) => adjust(op, -n, 0);
94
+ var shiftRight = (op, n) => adjust(op, n, 0);
95
+ var growLeft = (op, n) => adjust(op, -n, n);
96
+ var growRight = (op, n) => adjust(op, 0, n);
97
+ var shrinkLeft = (op, n) => adjust(op, 0, -n);
98
+ var shrinkRight = (op, n) => adjust(op, n, -n);
99
+ var Compact = class {
100
+ d;
101
+ ops = [];
102
+ old;
103
+ next;
104
+ constructor(d, old, next) {
105
+ this.d = d;
106
+ this.old = old;
107
+ this.next = next;
108
+ }
109
+ equal(oldIndex, newIndex, len) {
110
+ this.ops.push({ tag: EQUAL, oldIndex, newIndex, len });
111
+ }
112
+ delete(oldIndex, oldLen, newIndex) {
113
+ this.ops.push({ tag: DELETE, oldIndex, newIndex, len: oldLen });
114
+ }
115
+ insert(oldIndex, newIndex, newLen) {
116
+ this.ops.push({ tag: INSERT, oldIndex, newIndex, len: newLen });
117
+ }
118
+ replace(oldIndex, oldLen, newIndex, newLen) {
119
+ this.delete(oldIndex, oldLen, newIndex);
120
+ this.insert(oldIndex, newIndex, newLen);
121
+ }
122
+ finish() {
123
+ const { ops, old, next } = this;
124
+ shiftAll(ops, old, next);
125
+ normalizeCursors(ops);
126
+ for (const op of ops) {
127
+ if (op.tag === EQUAL) this.d.equal(op.oldIndex, op.newIndex, op.len);
128
+ else if (op.tag === DELETE) this.d.delete(op.oldIndex, op.len, op.newIndex);
129
+ else this.d.insert(op.oldIndex, op.newIndex, op.len);
130
+ }
131
+ this.d.finish();
132
+ }
133
+ };
134
+ function shiftAll(ops, old, next) {
135
+ for (const tag of [DELETE, INSERT]) {
136
+ let pointer = 0;
137
+ while (pointer < ops.length) {
138
+ if (ops[pointer].tag === tag) {
139
+ pointer = shiftUp(ops, old, next, pointer);
140
+ pointer = shiftDown(ops, old, next, pointer);
141
+ }
142
+ pointer += 1;
143
+ }
144
+ }
145
+ }
146
+ function normalizeCursors(ops) {
147
+ if (!ops.length) return;
148
+ let oldCursor = oldStart(ops[0]);
149
+ let newCursor = newStart(ops[0]);
150
+ for (const op of ops) {
151
+ if (op.tag === EQUAL) {
152
+ oldCursor = op.oldIndex + op.len;
153
+ newCursor = op.newIndex + op.len;
154
+ } else if (op.tag === DELETE) {
155
+ op.newIndex = newCursor;
156
+ oldCursor = op.oldIndex + op.len;
157
+ } else {
158
+ op.oldIndex = oldCursor;
159
+ newCursor = op.newIndex + op.len;
160
+ }
161
+ }
162
+ }
163
+ function swapAdjacent(ops, left) {
164
+ const right = left + 1;
165
+ const oStart = oldStart(ops[left]);
166
+ const oEnd = oldEnd(ops[right]);
167
+ const nStart = newStart(ops[left]);
168
+ const nEnd = newEnd(ops[right]);
169
+ [ops[left], ops[right]] = [ops[right], ops[left]];
170
+ if (ops[left].tag === INSERT) ops[left].oldIndex = oStart;
171
+ else ops[left].newIndex = nStart;
172
+ if (ops[right].tag === INSERT) ops[right].oldIndex = oEnd;
173
+ else ops[right].newIndex = nEnd;
174
+ }
175
+ var copy = (op) => ({ ...op });
176
+ function shiftUp(ops, old, next, pointer) {
177
+ while (pointer >= 1 && pointer - 1 < ops.length) {
178
+ const prev = copy(ops[pointer - 1]);
179
+ const self = copy(ops[pointer]);
180
+ if ((self.tag === INSERT || self.tag === DELETE) && prev.tag === EQUAL) {
181
+ if (self.tag === DELETE && !(pointer >= 2 && ops[pointer - 2]?.tag === DELETE)) break;
182
+ const suffix = self.tag === INSERT ? commonSuffixLen(old, oldStart(prev), oldEnd(prev), next, newStart(self), newEnd(self)) : commonSuffixLen(old, oldStart(self), oldEnd(self), next, newStart(prev), newEnd(prev));
183
+ if (suffix > 0) {
184
+ if (ops[pointer + 1]?.tag === EQUAL) growLeft(ops[pointer + 1], suffix);
185
+ else {
186
+ const equalOld = (self.tag === INSERT ? oldEnd(prev) : oldEnd(self)) - suffix;
187
+ const equalNew = (self.tag === INSERT ? newEnd(self) : newEnd(prev)) - suffix;
188
+ ops.splice(pointer + 1, 0, { tag: EQUAL, oldIndex: equalOld, newIndex: equalNew, len: suffix });
189
+ }
190
+ shiftLeft(ops[pointer], suffix);
191
+ shrinkLeft(ops[pointer - 1], suffix);
192
+ if (isEmpty(ops[pointer - 1])) {
193
+ ops.splice(pointer - 1, 1);
194
+ pointer -= 1;
195
+ }
196
+ } else if (isEmpty(ops[pointer - 1])) {
197
+ ops.splice(pointer - 1, 1);
198
+ pointer -= 1;
199
+ } else break;
200
+ } else if (self.tag === INSERT && prev.tag === DELETE || self.tag === DELETE && prev.tag === INSERT) {
201
+ swapAdjacent(ops, pointer - 1);
202
+ pointer -= 1;
203
+ } else if (self.tag === prev.tag && self.tag !== EQUAL) {
204
+ growRight(ops[pointer - 1], self.len);
205
+ ops.splice(pointer, 1);
206
+ pointer -= 1;
207
+ } else throw new Error(`unexpected ops in the diff's cleanup: ${prev.tag} then ${self.tag}`);
208
+ }
209
+ return pointer;
210
+ }
211
+ function shiftDown(ops, old, next, pointer) {
212
+ while (pointer + 1 < ops.length) {
213
+ const following = copy(ops[pointer + 1]);
214
+ const self = copy(ops[pointer]);
215
+ if ((self.tag === INSERT || self.tag === DELETE) && following.tag === EQUAL) {
216
+ if (self.tag === DELETE && ops[pointer + 2]?.tag !== DELETE) break;
217
+ const prefix = self.tag === INSERT ? commonPrefixLen(old, oldStart(following), oldEnd(following), next, newStart(self), newEnd(self)) : commonPrefixLen(old, oldStart(self), oldEnd(self), next, newStart(following), newEnd(following));
218
+ if (prefix > 0) {
219
+ if (pointer >= 1 && ops[pointer - 1].tag === EQUAL) growRight(ops[pointer - 1], prefix);
220
+ else {
221
+ const equalOld = self.tag === INSERT ? oldStart(following) : oldStart(self);
222
+ ops.splice(pointer, 0, { tag: EQUAL, oldIndex: equalOld, newIndex: newStart(self), len: prefix });
223
+ pointer += 1;
224
+ }
225
+ shiftRight(ops[pointer], prefix);
226
+ shrinkRight(ops[pointer + 1], prefix);
227
+ if (isEmpty(ops[pointer + 1])) ops.splice(pointer + 1, 1);
228
+ } else if (isEmpty(ops[pointer + 1])) ops.splice(pointer + 1, 1);
229
+ else break;
230
+ } else if (self.tag === INSERT && following.tag === DELETE || self.tag === DELETE && following.tag === INSERT) {
231
+ swapAdjacent(ops, pointer);
232
+ pointer += 1;
233
+ } else if (self.tag === following.tag && self.tag !== EQUAL) {
234
+ growRight(ops[pointer], following.len);
235
+ ops.splice(pointer + 1, 1);
236
+ } else throw new Error(`unexpected ops in the diff's cleanup: ${self.tag} then ${following.tag}`);
237
+ }
238
+ return pointer;
239
+ }
240
+ function commonPrefixLen(old, os, oe, next, ns, ne) {
241
+ if (os >= oe || ns >= ne) return 0;
242
+ const max = Math.min(oe - os, ne - ns);
243
+ let n = 0;
244
+ while (n < max && next[ns + n] === old[os + n]) n++;
245
+ return n;
246
+ }
247
+ function commonSuffixLen(old, os, oe, next, ns, ne) {
248
+ if (os >= oe || ns >= ne) return 0;
249
+ const max = Math.min(oe - os, ne - ns);
250
+ let n = 0;
251
+ while (n < max && next[ne - 1 - n] === old[oe - 1 - n]) n++;
252
+ return n;
253
+ }
254
+ var DISJOINT_FAST_PATH_MIN_LEN = 512;
255
+ var DISJOINT_FAST_PATH_MIN_WORK = 128 * 1024;
256
+ var DISJOINT_FAST_PATH_BOUNDARY_PROBE = 8;
257
+ var CONFUSING_RECORD_SCAN_WINDOW = 100;
258
+ var CONFUSING_RECORD_RATIO = 4;
259
+ var MAX_MATCH_FREQUENCY_THRESHOLD = 1024;
260
+ var NO_MATCH = -1;
261
+ var DISCARD = 0;
262
+ var KEEP = 1;
263
+ var INVESTIGATE = 2;
264
+ var isqrt = (n) => {
265
+ let r = Math.floor(Math.sqrt(n));
266
+ while (r * r > n) r--;
267
+ while ((r + 1) * (r + 1) <= n) r++;
268
+ return r;
269
+ };
270
+ function diff(d, old, os, oe, next, ns, ne) {
271
+ const pre = reduceForMyers(old, os, oe, next, ns, ne);
272
+ if ("trimmed" in pre) diffReduced(d, pre);
273
+ else diffPretrimmed(d, old, next, pre, HEURISTIC);
274
+ }
275
+ function trim(old, os, oe, next, ns, ne) {
276
+ const prefixLen = commonPrefixLen(old, os, oe, next, ns, ne);
277
+ const suffixLen = commonSuffixLen(old, os + prefixLen, oe, next, ns + prefixLen, ne);
278
+ return { oldStart: os + prefixLen, oldEnd: oe - suffixLen, newStart: ns + prefixLen, newEnd: ne - suffixLen, originalOldStart: os, originalOldEnd: oe, originalNewStart: ns, originalNewEnd: ne, prefixLen, suffixLen };
279
+ }
280
+ function shouldScan(old, os, oe, next, ns, ne) {
281
+ const oldLen = oe - os, newLen = ne - ns;
282
+ if (oldLen < DISJOINT_FAST_PATH_MIN_LEN || newLen < DISJOINT_FAST_PATH_MIN_LEN || oldLen * newLen < DISJOINT_FAST_PATH_MIN_WORK) return false;
283
+ if (next[ns] === old[os] || next[ne - 1] === old[oe - 1]) return false;
284
+ const probe = Math.min(oldLen, newLen, DISJOINT_FAST_PATH_BOUNDARY_PROBE + 1);
285
+ for (let skip = 1; skip < probe; skip++) {
286
+ if (next[ns + skip] === old[os] || next[ns] === old[os + skip] || next[ne - 1 - skip] === old[oe - 1] || next[ne - 1] === old[oe - 1 - skip]) return false;
287
+ }
288
+ return true;
289
+ }
290
+ function recordActions(ids, oppositeCounts) {
291
+ const limit = Math.min(Math.max(isqrt(ids.length), 1), MAX_MATCH_FREQUENCY_THRESHOLD);
292
+ const out = new Uint8Array(ids.length);
293
+ ids.forEach((id, i) => {
294
+ const count = id === NO_MATCH ? 0 : oppositeCounts[id];
295
+ out[i] = count === 0 ? DISCARD : count < limit ? KEEP : INVESTIGATE;
296
+ });
297
+ return out;
298
+ }
299
+ function scanConfusingRun(actions, from, step) {
300
+ let discards = 0, investigates = 0;
301
+ for (let i = from, seen = 0; i >= 0 && i < actions.length && seen < CONFUSING_RECORD_SCAN_WINDOW; i += step, seen++) {
302
+ if (actions[i] === DISCARD) discards++;
303
+ else if (actions[i] === INVESTIGATE) investigates++;
304
+ else break;
305
+ }
306
+ return [discards, investigates];
307
+ }
308
+ function keepRecord(actions, index) {
309
+ if (actions[index] === DISCARD) return false;
310
+ if (actions[index] === KEEP) return true;
311
+ const [leftDiscards, leftInvestigates] = scanConfusingRun(actions, index - 1, -1);
312
+ if (leftDiscards === 0) return true;
313
+ const [rightDiscards, rightInvestigates] = scanConfusingRun(actions, index + 1, 1);
314
+ if (rightDiscards === 0) return true;
315
+ const discards = leftDiscards + rightDiscards;
316
+ const investigates = leftInvestigates + rightInvestigates + 1;
317
+ return !(investigates * CONFUSING_RECORD_RATIO < investigates + discards);
318
+ }
319
+ function reduceForMyers(old, os, oe, next, ns, ne) {
320
+ const trimmed = trim(old, os, oe, next, ns, ne);
321
+ const { oldStart: o0, oldEnd: o1, newStart: n0, newEnd: n1 } = trimmed;
322
+ if (!shouldScan(old, o0, o1, next, n0, n1)) return trimmed;
323
+ const ids = /* @__PURE__ */ new Map();
324
+ const oldValues = [];
325
+ const newValues = [];
326
+ const oldCounts = [];
327
+ const newCounts = [];
328
+ for (let i = o0; i < o1; i++) {
329
+ let id = ids.get(old[i]);
330
+ if (id === void 0) {
331
+ id = oldCounts.length;
332
+ ids.set(old[i], id);
333
+ oldCounts.push(0);
334
+ newCounts.push(0);
335
+ }
336
+ oldCounts[id]++;
337
+ oldValues.push(id);
338
+ }
339
+ for (let i = n0; i < n1; i++) {
340
+ const id = ids.get(next[i]) ?? NO_MATCH;
341
+ if (id !== NO_MATCH) newCounts[id]++;
342
+ newValues.push(id);
343
+ }
344
+ const reduced = { oldValues: [], oldIndices: [], newValues: [], newIndices: [], trimmed };
345
+ const oldActions = recordActions(oldValues, newCounts);
346
+ oldValues.forEach((id, offset) => {
347
+ if (keepRecord(oldActions, offset)) {
348
+ reduced.oldValues.push(id);
349
+ reduced.oldIndices.push(o0 + offset);
350
+ }
351
+ });
352
+ const newActions = recordActions(newValues, oldCounts);
353
+ newValues.forEach((id, offset) => {
354
+ if (keepRecord(newActions, offset)) {
355
+ reduced.newValues.push(id);
356
+ reduced.newIndices.push(n0 + offset);
357
+ }
358
+ });
359
+ if (reduced.oldIndices.length === o1 - o0 && reduced.newIndices.length === n1 - n0) return trimmed;
360
+ return reduced;
361
+ }
362
+ var ReducedHook = class {
363
+ d;
364
+ reduced;
365
+ oldCursor;
366
+ newCursor;
367
+ constructor(d, reduced) {
368
+ this.d = d;
369
+ this.reduced = reduced;
370
+ this.oldCursor = reduced.trimmed.oldStart;
371
+ this.newCursor = reduced.trimmed.newStart;
372
+ }
373
+ gaps(oldAnchor, newAnchor) {
374
+ if (this.oldCursor < oldAnchor) {
375
+ this.d.delete(this.oldCursor, oldAnchor - this.oldCursor, this.newCursor);
376
+ this.oldCursor = oldAnchor;
377
+ }
378
+ if (this.newCursor < newAnchor) {
379
+ this.d.insert(this.oldCursor, this.newCursor, newAnchor - this.newCursor);
380
+ this.newCursor = newAnchor;
381
+ }
382
+ }
383
+ equal(oldIndex, newIndex, len) {
384
+ const { oldIndices, newIndices } = this.reduced;
385
+ let offset = 0;
386
+ while (offset < len) {
387
+ const oldAnchor = oldIndices[oldIndex + offset];
388
+ const newAnchor = newIndices[newIndex + offset];
389
+ this.gaps(oldAnchor, newAnchor);
390
+ let run = 1;
391
+ while (offset + run < len && oldIndices[oldIndex + offset + run] === oldAnchor + run && newIndices[newIndex + offset + run] === newAnchor + run) run++;
392
+ this.d.equal(oldAnchor, newAnchor, run);
393
+ this.oldCursor = oldAnchor + run;
394
+ this.newCursor = newAnchor + run;
395
+ offset += run;
396
+ }
397
+ }
398
+ delete() {
399
+ }
400
+ insert() {
401
+ }
402
+ replace() {
403
+ }
404
+ finish() {
405
+ this.gaps(this.reduced.trimmed.oldEnd, this.reduced.trimmed.newEnd);
406
+ }
407
+ };
408
+ function diffReduced(d, reduced) {
409
+ const t = reduced.trimmed;
410
+ if (t.prefixLen > 0) d.equal(t.originalOldStart, t.originalNewStart, t.prefixLen);
411
+ const hook = new ReducedHook(d, reduced);
412
+ const { oldValues, newValues } = reduced;
413
+ diffPretrimmed(hook, oldValues, newValues, trim(oldValues, 0, oldValues.length, newValues, 0, newValues.length), HEURISTIC);
414
+ if (t.suffixLen > 0) d.equal(t.originalOldEnd - t.suffixLen, t.originalNewEnd - t.suffixLen, t.suffixLen);
415
+ d.finish();
416
+ }
417
+ var HEURISTIC = 0;
418
+ var RAW = 1;
419
+ function diffPretrimmed(d, old, next, t, mode) {
420
+ if (t.prefixLen > 0) d.equal(t.originalOldStart, t.originalNewStart, t.prefixLen);
421
+ const oldEmpty = t.oldStart >= t.oldEnd, newEmpty = t.newStart >= t.newEnd;
422
+ if (oldEmpty && newEmpty) {
423
+ } else if (oldEmpty) d.insert(t.oldStart, t.newStart, t.newEnd - t.newStart);
424
+ else if (newEmpty) d.delete(t.oldStart, t.oldEnd - t.oldStart, t.newStart);
425
+ else {
426
+ const maxD = maxDiagonals(t.oldEnd - t.oldStart, t.newEnd - t.newStart);
427
+ conquer(d, old, t.oldStart, t.oldEnd, next, t.newStart, t.newEnd, new V(maxD), new V(maxD), mode);
428
+ }
429
+ if (t.suffixLen > 0) d.equal(t.originalOldEnd - t.suffixLen, t.originalNewEnd - t.suffixLen, t.suffixLen);
430
+ d.finish();
431
+ }
432
+ var V = class {
433
+ offset;
434
+ v;
435
+ constructor(maxD) {
436
+ this.offset = maxD;
437
+ this.v = new Int32Array(2 * maxD);
438
+ }
439
+ get(k) {
440
+ return this.v[k + this.offset];
441
+ }
442
+ set(k, x) {
443
+ this.v[k + this.offset] = x;
444
+ }
445
+ };
446
+ var maxDiagonals = (n, m) => Math.ceil((n + m) / 2) + 1;
447
+ var SMALL_SIDE_EXACT_MAX = 64;
448
+ var SMALL_SIDE_EXACT_MIN_LARGE = 512;
449
+ var SMALL_SIDE_EXACT_MAX_WORK = 64e6;
450
+ var HEURISTIC_MIN_COST = 256;
451
+ var HEURISTIC_MIN_SNAKE = 20;
452
+ var HEURISTIC_MIN_MAX_COST = 256;
453
+ var HEURISTIC_PROGRESS_FACTOR = 4;
454
+ function conquer(d, old, os, oe, next, ns, ne, vf, vb, mode) {
455
+ const prefix = commonPrefixLen(old, os, oe, next, ns, ne);
456
+ if (prefix > 0) d.equal(os, ns, prefix);
457
+ os += prefix;
458
+ ns += prefix;
459
+ const suffix = commonSuffixLen(old, os, oe, next, ns, ne);
460
+ const suffixOld = oe - suffix, suffixNew = ne - suffix;
461
+ oe -= suffix;
462
+ ne -= suffix;
463
+ while (os < oe && ns < ne) {
464
+ const [o, n] = frontAnchor(d, old, os, oe, next, ns, ne);
465
+ if (o === os && n === ns) break;
466
+ os = o;
467
+ ns = n;
468
+ }
469
+ if (os >= oe && ns >= ne) {
470
+ } else if (ns >= ne) d.delete(os, oe - os, ns);
471
+ else if (os >= oe) d.insert(os, ns, ne - ns);
472
+ else if (smallSideExact(d, old, os, oe, next, ns, ne)) {
473
+ } else {
474
+ const split = middleSnake(old, os, oe, next, ns, ne, vf, vb, mode);
475
+ if (split) {
476
+ conquer(d, old, os, split.oldIndex, next, ns, split.newIndex, vf, vb, split.leftMode);
477
+ conquer(d, old, split.oldIndex, oe, next, split.newIndex, ne, vf, vb, split.rightMode);
478
+ } else {
479
+ d.delete(os, oe - os, ns);
480
+ d.insert(os, ns, ne - ns);
481
+ }
482
+ }
483
+ if (suffix > 0) d.equal(suffixOld, suffixNew, suffix);
484
+ }
485
+ function frontAnchor(d, old, os, oe, next, ns, ne) {
486
+ const MAX_SKIP = 4;
487
+ const MIN_ANCHOR_COMMON = 96;
488
+ const oldLen = oe - os, newLen = ne - ns;
489
+ if (oldLen <= MIN_ANCHOR_COMMON || newLen <= MIN_ANCHOR_COMMON) return [os, ns];
490
+ const small = Math.min(oldLen, newLen), large = Math.max(oldLen, newLen);
491
+ if (large < small * 2) return [os, ns];
492
+ const maxOldSkip = Math.min(oldLen - 1, MAX_SKIP);
493
+ const maxNewSkip = Math.min(newLen - 1, MAX_SKIP);
494
+ const preferInsert = newLen > oldLen;
495
+ const preferDelete = oldLen > newLen;
496
+ let best;
497
+ search: for (let oldSkip2 = 0; oldSkip2 <= maxOldSkip; oldSkip2++) {
498
+ for (let newSkip2 = 0; newSkip2 <= maxNewSkip; newSkip2++) {
499
+ if (oldSkip2 === 0 && newSkip2 === 0) continue;
500
+ if (oldSkip2 !== 0 && newSkip2 !== 0) continue;
501
+ if (preferInsert && oldSkip2 !== 0) continue;
502
+ if (preferDelete && newSkip2 !== 0) continue;
503
+ if (next[ns + newSkip2] !== old[os + oldSkip2]) continue;
504
+ const common2 = commonPrefixLen(old, os + oldSkip2, oe, next, ns + newSkip2, ne);
505
+ if (common2 < MIN_ANCHOR_COMMON) continue;
506
+ if (common2 >= MIN_ANCHOR_COMMON * 8) {
507
+ best = [oldSkip2, newSkip2, common2];
508
+ break search;
509
+ }
510
+ const better2 = best === void 0 || compareTuples([common2, -Math.max(oldSkip2, newSkip2), oldSkip2, newSkip2], [best[2], -Math.max(best[0], best[1]), best[0], best[1]]) > 0;
511
+ if (better2) best = [oldSkip2, newSkip2, common2];
512
+ }
513
+ }
514
+ if (!best) return [os, ns];
515
+ const [oldSkip, newSkip, common] = best;
516
+ if (oldSkip === 0) d.insert(os, ns, newSkip);
517
+ else if (newSkip === 0) d.delete(os, oldSkip, ns);
518
+ else d.replace(os, oldSkip, ns, newSkip);
519
+ d.equal(os + oldSkip, ns + newSkip, common);
520
+ return [os + oldSkip + common, ns + newSkip + common];
521
+ }
522
+ function compareTuples(a, b) {
523
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return a[i] - b[i];
524
+ return 0;
525
+ }
526
+ function smallSideExact(d, old, os, oe, next, ns, ne) {
527
+ const oldLen = oe - os, newLen = ne - ns;
528
+ const small = Math.min(oldLen, newLen), large = Math.max(oldLen, newLen);
529
+ if (small === 0 || small > SMALL_SIDE_EXACT_MAX || large < SMALL_SIDE_EXACT_MIN_LARGE || oldLen * newLen > SMALL_SIDE_EXACT_MAX_WORK) return false;
530
+ if (oldLen <= newLen) smallOld(d, old, os, oldLen, next, ns, newLen);
531
+ else smallNew(d, old, os, oldLen, next, ns, newLen);
532
+ return true;
533
+ }
534
+ function smallOld(d, old, os, n, next, ns, m) {
535
+ const width = m + 1;
536
+ const dp = new Uint8Array((n + 1) * width);
537
+ for (let i2 = n - 1; i2 >= 0; i2--) {
538
+ const row = i2 * width, below = (i2 + 1) * width;
539
+ for (let j2 = m - 1; j2 >= 0; j2--) dp[row + j2] = next[ns + j2] === old[os + i2] ? dp[below + j2 + 1] + 1 : Math.max(dp[below + j2], dp[row + j2 + 1]);
540
+ }
541
+ const takes = (i2, j2) => next[ns + j2] === old[os + i2] && dp[i2 * width + j2] === dp[(i2 + 1) * width + j2 + 1] + 1;
542
+ let i = 0, j = 0;
543
+ while (i < n && j < m) {
544
+ if (takes(i, j)) {
545
+ const si = i, sj = j;
546
+ while (i < n && j < m && takes(i, j)) {
547
+ i++;
548
+ j++;
549
+ }
550
+ d.equal(os + si, ns + sj, i - si);
551
+ } else if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) {
552
+ const si = i;
553
+ const at = ns + j;
554
+ while (i < n) {
555
+ if (j >= m) {
556
+ i = n;
557
+ break;
558
+ }
559
+ if (takes(i, j)) break;
560
+ if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) i++;
561
+ else break;
562
+ }
563
+ d.delete(os + si, i - si, at);
564
+ } else {
565
+ const sj = j;
566
+ const at = os + i;
567
+ while (j < m) {
568
+ if (i >= n) {
569
+ j = m;
570
+ break;
571
+ }
572
+ if (takes(i, j)) break;
573
+ if (dp[(i + 1) * width + j] < dp[i * width + j + 1]) j++;
574
+ else break;
575
+ }
576
+ d.insert(at, ns + sj, j - sj);
577
+ }
578
+ }
579
+ if (i < n) d.delete(os + i, n - i, ns + j);
580
+ if (j < m) d.insert(os + i, ns + j, m - j);
581
+ }
582
+ function smallNew(d, old, os, n, next, ns, m) {
583
+ const width = n + 1;
584
+ const dp = new Uint8Array((m + 1) * width);
585
+ for (let i2 = m - 1; i2 >= 0; i2--) {
586
+ const row = i2 * width, below = (i2 + 1) * width;
587
+ for (let j2 = n - 1; j2 >= 0; j2--) dp[row + j2] = next[ns + i2] === old[os + j2] ? dp[below + j2 + 1] + 1 : Math.max(dp[below + j2], dp[row + j2 + 1]);
588
+ }
589
+ const takes = (i2, j2) => next[ns + i2] === old[os + j2] && dp[i2 * width + j2] === dp[(i2 + 1) * width + j2 + 1] + 1;
590
+ let i = 0, j = 0;
591
+ while (i < m && j < n) {
592
+ if (takes(i, j)) {
593
+ const si = i, sj = j;
594
+ while (i < m && j < n && takes(i, j)) {
595
+ i++;
596
+ j++;
597
+ }
598
+ d.equal(os + sj, ns + si, j - sj);
599
+ } else if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) {
600
+ const si = i;
601
+ const at = os + j;
602
+ while (i < m) {
603
+ if (j >= n) {
604
+ i = m;
605
+ break;
606
+ }
607
+ if (takes(i, j)) break;
608
+ if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) i++;
609
+ else break;
610
+ }
611
+ d.insert(at, ns + si, i - si);
612
+ } else {
613
+ const sj = j;
614
+ const at = ns + i;
615
+ while (j < n) {
616
+ if (i >= m) {
617
+ j = n;
618
+ break;
619
+ }
620
+ if (takes(i, j)) break;
621
+ if (dp[(i + 1) * width + j] < dp[i * width + j + 1]) j++;
622
+ else break;
623
+ }
624
+ d.delete(os + sj, j - sj, at);
625
+ }
626
+ }
627
+ if (j < n) d.delete(os + j, n - j, ns + i);
628
+ if (i < m) d.insert(os + j, ns + i, m - i);
629
+ }
630
+ var better = (best, candidate) => best === void 0 || candidate.progress > best.progress ? candidate : best;
631
+ var isInterior = (o, n, oldLen, newLen) => o <= oldLen && n <= newLen && (o !== 0 || n !== 0) && (o !== oldLen || n !== newLen);
632
+ function clampDiagonal(oldIndex, k, oldLen, newLen) {
633
+ if (k < 0 && -k > newLen) return void 0;
634
+ const min = Math.max(k, 0);
635
+ const max = k >= 0 ? Math.min(oldLen, newLen + k) : Math.min(oldLen, Math.max(0, newLen + k));
636
+ if (min > max) return void 0;
637
+ const o = Math.min(Math.max(oldIndex, min), max);
638
+ return [o, o - k];
639
+ }
640
+ function middleSnake(old, os, oe, next, ns, ne, vf, vb, mode) {
641
+ const n = oe - os, m = ne - ns;
642
+ const delta = n - m;
643
+ const odd = (delta & 1) === 1 || (delta & 1) === -1;
644
+ vf.set(1, 0);
645
+ vb.set(1, 0);
646
+ const dMax = maxDiagonals(n, m);
647
+ const maxCost = mode === HEURISTIC ? Math.max(isqrt(n + m), HEURISTIC_MIN_MAX_COST) : Infinity;
648
+ const heuristic = (c) => ({ oldIndex: os + c.oldIndex, newIndex: ns + c.newIndex, leftMode: c.forward ? RAW : HEURISTIC, rightMode: c.forward ? HEURISTIC : RAW });
649
+ for (let d = 0; d < dMax; d++) {
650
+ let good, forward, backward;
651
+ const trackLimit = mode === HEURISTIC && d >= maxCost;
652
+ const trackGood = mode === HEURISTIC && d > HEURISTIC_MIN_COST;
653
+ for (let k = d; k >= -d; k -= 2) {
654
+ let x = k === -d || k !== d && vf.get(k - 1) < vf.get(k + 1) ? vf.get(k + 1) : vf.get(k - 1) + 1;
655
+ const y = x - k;
656
+ const x0 = x, y0 = y;
657
+ if (x < n && y < m) x += commonPrefixLen(old, os + x, oe, next, ns + y, ne);
658
+ const snake = x - x0;
659
+ vf.set(k, x);
660
+ if (odd && Math.abs(k - delta) <= d - 1 && vf.get(k) + vb.get(-(k - delta)) >= n) return { oldIndex: x0 + os, newIndex: y0 + ns, leftMode: RAW, rightMode: RAW };
661
+ if (trackLimit) {
662
+ const point = clampDiagonal(x, k, n, m);
663
+ if (point && isInterior(point[0], point[1], n, m)) forward = better(forward, { oldIndex: point[0], newIndex: point[1], progress: point[0] + point[1], forward: true });
664
+ }
665
+ if (trackGood && snake >= HEURISTIC_MIN_SNAKE && x < n && y < m) {
666
+ const progress = Math.max(0, x + y - Math.abs(k));
667
+ if (progress > HEURISTIC_PROGRESS_FACTOR * d && isInterior(x0, y0, n, m)) good = better(good, { oldIndex: x0, newIndex: y0, progress, forward: true });
668
+ }
669
+ }
670
+ for (let k = d; k >= -d; k -= 2) {
671
+ let x = k === -d || k !== d && vb.get(k - 1) < vb.get(k + 1) ? vb.get(k + 1) : vb.get(k - 1) + 1;
672
+ let y = x - k;
673
+ const x0 = x;
674
+ if (x < n && y < m) {
675
+ const advance = commonSuffixLen(old, os, os + n - x, next, ns, ns + m - y);
676
+ x += advance;
677
+ y += advance;
678
+ }
679
+ const snake = x - x0;
680
+ vb.set(k, x);
681
+ if (!odd && Math.abs(k - delta) <= d && vb.get(k) + vf.get(-(k - delta)) >= n) return { oldIndex: n - x + os, newIndex: m - y + ns, leftMode: RAW, rightMode: RAW };
682
+ if (trackLimit) {
683
+ const point = clampDiagonal(x, k, n, m);
684
+ if (point) {
685
+ const splitOld = n - point[0], splitNew = m - point[1];
686
+ if (isInterior(splitOld, splitNew, n, m)) backward = better(backward, { oldIndex: splitOld, newIndex: splitNew, progress: point[0] + point[1], forward: false });
687
+ }
688
+ }
689
+ if (trackGood && snake >= HEURISTIC_MIN_SNAKE && x <= n && y <= m) {
690
+ const splitOld = n - x, splitNew = m - y;
691
+ const progress = Math.max(0, x + y - Math.abs(k));
692
+ if (splitOld > 0 && splitNew > 0 && progress > HEURISTIC_PROGRESS_FACTOR * d) good = better(good, { oldIndex: splitOld, newIndex: splitNew, progress, forward: false });
693
+ }
694
+ }
695
+ if (good) return heuristic(good);
696
+ if (d >= maxCost) {
697
+ const split = forward && backward ? forward.progress > backward.progress ? forward : backward : forward ?? backward;
698
+ if (!split) break;
699
+ return heuristic(split);
700
+ }
701
+ }
702
+ return void 0;
703
+ }
704
+
705
+ export {
706
+ diffOps
707
+ };